arceos icon indicating copy to clipboard operation
arceos copied to clipboard

feat: add basic loongarch64 support

Open Godones opened this issue 1 year ago • 7 comments

  • Refactor the repo code to merge
  • Use standard toolchain
  • Fix the compile command

image

I will submit other code about interrupt soon.

Godones avatar Sep 18 '23 12:09 Godones

@hky1999 Support for la64 is now complete. Except for the two applications redis and sqlite, which were not tested, other apps have passed. If you have time, please check to see if there are any areas for improvement.

Godones avatar Sep 29 '23 12:09 Godones

Thanks for your contribution! Are you still available? Let’s work on merging this PR.

I will fix these errors.

Godones avatar Dec 07 '23 07:12 Godones

@equation314 Do you have time to check and see if there are any other problems?

Godones avatar Dec 15 '23 04:12 Godones

Thanks! Please fix conflicts and CI.

equation314 avatar Dec 18 '23 08:12 equation314

Thanks! Please fix conflicts and CI.

@equation314 This CI error may be due to a rust version issue. I'm not very familiar with CI, but it seems that the latest version of rust is used in CI.

Godones avatar Dec 18 '23 13:12 Godones

Thanks! Please fix conflicts and CI.

@equation314 This CI error may be due to a rust version issue. I'm not very familiar with CI, but it seems that the latest version of rust is used in CI.

Hello, CI should fit the latest version of Rust, currently I believe it should be rust version 1.77.0-nightly (bf8716f1c 2023-12-24).

Some warnings like this should be fixed.

warning: `axhal` (lib) generated 1 warning
warning: the feature `ip_in_core` has been stable since 1.77.0-nightly and no longer requires an attribute to enable
 --> api/arceos_api/src/lib.rs:6:12
  |
6 | #![feature(ip_in_core)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default

I try to build this branch tonight.

  • BIOS loongarch_bios_0310.bin is downloaded from https://github.com/foxsen/qemu-loongarch-runenv/blob/main/loongarch_bios_0310.bin and put it under tools/la64. maybe this should be added into .gitignore or some corresponding scripts should be added ?
  • QEMU version :
➜  arceos git:(la64) ✗ qemu-system-loongarch64 --version                                                     
QEMU emulator version 8.1.94
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers
  • The command is make A=apps/helloworld ARCH=loongarch64 run.
  • But I just get no output:
➜  arceos git:(la64) ✗ make A=apps/helloworld ARCH=loongarch64 run
    Building App: helloworld, Arch: loongarch64, Platform: loongarch64-qemu-virt, App type: rust
cargo build --target loongarch64-unknown-none --target-dir /home/hky/workspace/rcore-os/arceos/target --release  -Z build-std --manifest-path apps/helloworld/Cargo.toml --features "axstd/log-level-warn axstd/bus-pci"
warning: value assigned to `flags` is never read
  --> crates/kernel_guard/src/arch/loongarch64.rs:17:53
   |
17 |     unsafe { asm!("csrxchg {}, {}, 0x0", inout(reg) flags, in(reg) IE_BIT) };
   |                                                     ^^^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: `kernel_guard` (lib) generated 1 warning
warning: the feature `const_maybe_uninit_zeroed` has been stable since 1.75.0 and no longer requires an attribute to enable
  --> modules/axhal/src/lib.rs:30:12
   |
30 | #![feature(const_maybe_uninit_zeroed)]
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(stable_features)]` on by default

warning: `axhal` (lib) generated 1 warning
warning: the feature `ip_in_core` has been stable since 1.77.0-nightly and no longer requires an attribute to enable
 --> api/arceos_api/src/lib.rs:6:12
  |
6 | #![feature(ip_in_core)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default

warning: `arceos_api` (lib) generated 1 warning
warning: the feature `ip_in_core` has been stable since 1.77.0-nightly and no longer requires an attribute to enable
  --> ulib/axstd/src/lib.rs:52:12
   |
52 | #![feature(ip_in_core)]
   |            ^^^^^^^^^^
   |
   = note: `#[warn(stable_features)]` on by default

warning: `axstd` (lib) generated 1 warning
    Finished release [optimized] target(s) in 0.11s
rust-objcopy --binary-architecture=loongarch64 apps/helloworld/helloworld_loongarch64-qemu-virt.elf --strip-all -O binary apps/helloworld/helloworld_loongarch64-qemu-virt.bin
    Running on qemu...
qemu-system-loongarch64 -m 1G -smp 1 -bios tools/la64/loongarch_bios_0310.bin -kernel apps/helloworld/helloworld_loongarch64-qemu-virt.elf -nographic -vga none

Could you offer some help or advice with it? Thanks a lot! @Godones

hky1999 avatar Dec 25 '23 16:12 hky1999

Thanks! Please fix conflicts and CI.

@equation314 This CI error may be due to a rust version issue. I'm not very familiar with CI, but it seems that the latest version of rust is used in CI.

Hello, CI should fit the latest version of Rust, currently I believe it should be rust version 1.77.0-nightly (bf8716f1c 2023-12-24).

Some warnings like this should be fixed.

warning: `axhal` (lib) generated 1 warning
warning: the feature `ip_in_core` has been stable since 1.77.0-nightly and no longer requires an attribute to enable
 --> api/arceos_api/src/lib.rs:6:12
  |
6 | #![feature(ip_in_core)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default

I try to build this branch tonight.

  • BIOS loongarch_bios_0310.bin is downloaded from https://github.com/foxsen/qemu-loongarch-runenv/blob/main/loongarch_bios_0310.bin and put it under tools/la64. maybe this should be added into .gitignore or some corresponding scripts should be added ?
  • QEMU version :
➜  arceos git:(la64) ✗ qemu-system-loongarch64 --version                                                     
QEMU emulator version 8.1.94
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers
  • The command is make A=apps/helloworld ARCH=loongarch64 run.
  • But I just get no output:
➜  arceos git:(la64) ✗ make A=apps/helloworld ARCH=loongarch64 run
    Building App: helloworld, Arch: loongarch64, Platform: loongarch64-qemu-virt, App type: rust
cargo build --target loongarch64-unknown-none --target-dir /home/hky/workspace/rcore-os/arceos/target --release  -Z build-std --manifest-path apps/helloworld/Cargo.toml --features "axstd/log-level-warn axstd/bus-pci"
warning: value assigned to `flags` is never read
  --> crates/kernel_guard/src/arch/loongarch64.rs:17:53
   |
17 |     unsafe { asm!("csrxchg {}, {}, 0x0", inout(reg) flags, in(reg) IE_BIT) };
   |                                                     ^^^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: `kernel_guard` (lib) generated 1 warning
warning: the feature `const_maybe_uninit_zeroed` has been stable since 1.75.0 and no longer requires an attribute to enable
  --> modules/axhal/src/lib.rs:30:12
   |
30 | #![feature(const_maybe_uninit_zeroed)]
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(stable_features)]` on by default

warning: `axhal` (lib) generated 1 warning
warning: the feature `ip_in_core` has been stable since 1.77.0-nightly and no longer requires an attribute to enable
 --> api/arceos_api/src/lib.rs:6:12
  |
6 | #![feature(ip_in_core)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default

warning: `arceos_api` (lib) generated 1 warning
warning: the feature `ip_in_core` has been stable since 1.77.0-nightly and no longer requires an attribute to enable
  --> ulib/axstd/src/lib.rs:52:12
   |
52 | #![feature(ip_in_core)]
   |            ^^^^^^^^^^
   |
   = note: `#[warn(stable_features)]` on by default

warning: `axstd` (lib) generated 1 warning
    Finished release [optimized] target(s) in 0.11s
rust-objcopy --binary-architecture=loongarch64 apps/helloworld/helloworld_loongarch64-qemu-virt.elf --strip-all -O binary apps/helloworld/helloworld_loongarch64-qemu-virt.bin
    Running on qemu...
qemu-system-loongarch64 -m 1G -smp 1 -bios tools/la64/loongarch_bios_0310.bin -kernel apps/helloworld/helloworld_loongarch64-qemu-virt.elf -nographic -vga none

Could you offer some help or advice with it? Thanks a lot! @Godones

The Qemu version should be:

❯ qemu-system-loongarch64 --version
QEMU emulator version 6.2.50 (v6.0.0-7567-gac069a8ffb)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

You can complie it according to tools/la64/la-qemu.sh or https://github.com/foxsen/qemu-loongarch-runenv/

Godones avatar Dec 26 '23 05:12 Godones