Skip to content

Commit

Permalink
Add support for loongarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondyoungberg committed Sep 20, 2024
1 parent c10238a commit 01720ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
components: rustfmt, clippy
- name: Install Targets
run: rustup target add x86_64-unknown-none aarch64-unknown-none riscv64gc-unknown-none-elf
run: rustup target add x86_64-unknown-none aarch64-unknown-none riscv64gc-unknown-none-elf loongarch64-unknown-none
- name: Rust Version
run: rustup --version && rustc --version
- name: Run clippy x86_64
Expand All @@ -27,6 +27,8 @@ jobs:
run: cargo clippy --verbose --target aarch64-unknown-none --all-features -- -D warnings
- name: Run clippy riscv64
run: cargo clippy --verbose --target riscv64gc-unknown-none-elf --all-features -- -D warnings
- name: Run clippy loongarch64
run: cargo clippy --verbose --target loongarch64-unknown-none --all-features -- -D warnings
- name: Reformat code
uses: mbrobbel/rustfmt-check@master
with:
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ unsafe impl Send for BaseRevision {}
#[cfg(not(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64"
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
compile_error!("Unsupported architecture, please use `x86_64`, `aarch64`, or `riscv64`");
compile_error!(
"Unsupported architecture, please use `x86_64`, `aarch64`, `riscv64`, or `loongarch64`"
);
2 changes: 2 additions & 0 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl PagingModeResponse {
#[repr(C)]
pub struct SmpResponse {
revision: u64,
#[cfg(not(target_arch = "loongarch64"))]
flags: smp::ResponseFlags,
#[cfg(target_arch = "x86_64")]
bsp_lapic_id: u32,
Expand All @@ -172,6 +173,7 @@ impl SmpResponse {

/// Returns the flags that were enabled by the bootloader. See
/// [`ResponseFlags`](smp::ResponseFlags) for more information.
#[cfg(not(target_arch = "loongarch64"))]
pub fn flags(&self) -> smp::ResponseFlags {
self.flags
}
Expand Down
4 changes: 3 additions & 1 deletion src/smp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ pub struct Cpu {
/// The address to jump to. Writing to this field will cause the core to
/// jump to the given function. The function will receive a pointer to this
/// structure, and it will have its own 64KiB (or requested-size) stack.
#[cfg(not(target_arch = "loongarch64"))]
pub goto_address: GotoAddress,
/// Free for use by the kernel.
#[cfg(not(target_arch = "loongarch64"))]
pub extra: u64,
}

Expand All @@ -73,7 +75,7 @@ bitflags! {
}
}

#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
#[cfg(not(target_arch = "x86_64"))]
bitflags! {
/// Flags for the [SMP response](crate::response::SmpResponse).
#[derive(Default, Clone, Copy)]
Expand Down

0 comments on commit 01720ca

Please sign in to comment.