Skip to content

Commit

Permalink
feat: add doc and test script
Browse files Browse the repository at this point in the history
  • Loading branch information
yfblock committed Jul 24, 2024
1 parent 7dd0934 commit 69c3cb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ target = "riscv64gc-unknown-none-elf"
# target = 'aarch64-unknown-none-softfloat'
# target = 'x86_64-unknown-none'
# target = 'loongarch64-unknown-none'

[target.'cfg(target_os = "none")']
runner = "./test.sh"
rustflags = [
"-Clink-arg=-Texample/linker/linker-riscv64.ld",
"-Cforce-frame-pointers=yes",
'--cfg=board="qemu"',
]
9 changes: 9 additions & 0 deletions src/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,22 @@ impl MultiCore {
}
}

/// PolyHAL defined percpu reserved fields.
/// Just used in the polyHAL and context switch.
#[repr(C)]
pub(crate) struct PerCPUReserved {
pub user_rsp: usize,
pub kernel_rsp: usize,
pub user_context: usize,
}

/// Get the offset of the specified percpu field.
///
/// PerCPU Arrange is that.
///
/// IN x86_64. The Reserved fields was used in manually.
/// IN other architectures, the reserved fields was defined
/// negative offset of the percpu pointer.
pub macro PerCPUReservedOffset($field: ident) {
core::mem::offset_of!(PerCPUReserved, $field) as isize
- core::mem::size_of::<PerCPUReserved>() as isize
Expand Down

0 comments on commit 69c3cb7

Please sign in to comment.