Skip to content

Commit

Permalink
Merge pull request #1088 from luojia65/main
Browse files Browse the repository at this point in the history
riscv64: replace deprecated legacy extensions to SBI 2.0 extensions
  • Loading branch information
mkroening authored Apr 17, 2024
2 parents bc0efb4 + 6b62109 commit 6952f40
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
17 changes: 13 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ semihosting = { version = "0.1", optional = true }

[target.'cfg(target_arch = "riscv64")'.dependencies]
riscv = "0.11"
sbi = "0.2"
sbi-rt = "0.0.3"
trapframe = "0.9"
semihosting = { version = "0.1", optional = true }

Expand Down
4 changes: 2 additions & 2 deletions src/arch/riscv64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn message_output_init() {

pub fn output_message_buf(buf: &[u8]) {
for byte in buf {
sbi::legacy::console_putchar(*byte);
sbi_rt::console_write_byte(*byte);
}
}

Expand Down Expand Up @@ -198,7 +198,7 @@ fn finish_processor_init() {

//When running bare-metal/QEMU we use the firmware to start the next hart
if !env::is_uhyve() {
sbi::hart_state_management::hart_start(
sbi_rt::hart_start(
next_hart_id as usize,
start::_start as usize,
RAW_BOOT_INFO.load(Ordering::Relaxed) as usize,
Expand Down
11 changes: 7 additions & 4 deletions src/arch/riscv64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ pub fn shutdown(error_code: i32) -> ! {
semihosting::process::exit(error_code)
} else {
// use SBI shutdown
sbi::legacy::shutdown()
sbi_rt::system_reset(sbi_rt::Shutdown, sbi_rt::NoReason);
loop {
core::hint::spin_loop();
}
}
}
}
Expand Down Expand Up @@ -270,16 +273,16 @@ pub fn set_oneshot_timer(wakeup_time: Option<u64>) {
}
let next_time = wt * u64::from(get_frequency());

sbi::legacy::set_timer(next_time);
sbi_rt::set_timer(next_time);
} else {
// Disable the Timer (and clear a pending interrupt)
debug!("Stopping Timer");
sbi::legacy::set_timer(u64::MAX);
sbi_rt::set_timer(u64::MAX);
}
}

pub fn wakeup_core(core_to_wakeup: CoreId) {
let hart_id = unsafe { HARTS_AVAILABLE[core_to_wakeup as usize] };
debug!("Wakeup core: {} , hart_id: {}", core_to_wakeup, hart_id);
sbi::legacy::send_ipi(&[1 << hart_id]);
sbi_rt::send_ipi(sbi_rt::HartMask::from_mask_base(0b1, hart_id));
}

0 comments on commit 6952f40

Please sign in to comment.