mirror of
https://github.com/rcore-os/rCore.git
synced 2025-01-18 17:07:04 +04:00
move wait_for_interrupt from executor to kernel
This commit is contained in:
parent
7479293a11
commit
9d82b29517
7
kernel/Cargo.lock
generated
7
kernel/Cargo.lock
generated
@ -186,21 +186,18 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "executor"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/rcore-os/executor.git?rev=7cf7ac0#7cf7ac0e9ff27086b41621ca7096520a1f3f6a57"
|
||||
source = "git+https://github.com/rcore-os/executor.git?rev=a2d02ee9#a2d02ee9567973209f557db53adc988dad2095e5"
|
||||
dependencies = [
|
||||
"aarch64",
|
||||
"executor-macros",
|
||||
"lazy_static",
|
||||
"riscv 0.5.6 (git+https://github.com/rcore-os/riscv?rev=d9794e)",
|
||||
"spin",
|
||||
"woke",
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "executor-macros"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/rcore-os/executor.git?rev=7cf7ac0#7cf7ac0e9ff27086b41621ca7096520a1f3f6a57"
|
||||
source = "git+https://github.com/rcore-os/executor.git?rev=a2d02ee9#a2d02ee9567973209f557db53adc988dad2095e5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -54,7 +54,7 @@ bit_field = "0.10"
|
||||
buddy_system_allocator = "0.4.0"
|
||||
compression = { version = "0.1.4", default-features = false, features = ["gzip"] }
|
||||
device_tree = { git = "https://github.com/rcore-os/device_tree-rs", rev = "2fa8411c" }
|
||||
executor = { git = "https://github.com/rcore-os/executor.git", rev = "7cf7ac0" }
|
||||
executor = { git = "https://github.com/rcore-os/executor.git", rev = "a2d02ee9" }
|
||||
isomorphic_drivers = { git = "https://github.com/rcore-os/isomorphic_drivers", rev = "fcf694d2", features = ["log"] }
|
||||
lazy_static = { version = "1.4", features = ["spin_no_std"] }
|
||||
log = "0.4"
|
||||
|
@ -58,3 +58,13 @@ pub fn get_trap_num(cx: &UserContext) -> usize {
|
||||
pub fn enable_irq(irq: usize) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
pub fn wait_for_interrupt() {
|
||||
use aarch64::regs::*;
|
||||
let daif = DAIF.get();
|
||||
unsafe {
|
||||
llvm_asm!("msr daifclr, #2");
|
||||
}
|
||||
aarch64::asm::wfe();
|
||||
DAIF.set(daif);
|
||||
}
|
||||
|
@ -101,3 +101,15 @@ pub fn enable_irq(irq: usize) {
|
||||
pub fn get_trap_num(_context: &UserContext) -> usize {
|
||||
scause::read().bits()
|
||||
}
|
||||
|
||||
pub fn wait_for_interrupt() {
|
||||
unsafe {
|
||||
// enable interrupt and disable
|
||||
let sie = riscv::register::sstatus::read().sie();
|
||||
riscv::register::sstatus::set_sie();
|
||||
riscv::asm::wfi();
|
||||
if !sie {
|
||||
riscv::register::sstatus::clear_sie();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,3 +55,8 @@ pub fn ack(_irq: usize) {
|
||||
pub fn get_trap_num(context: &UserContext) -> usize {
|
||||
context.trap_num
|
||||
}
|
||||
|
||||
pub fn wait_for_interrupt() {
|
||||
x86_64::instructions::interrupts::enable_interrupts_and_hlt();
|
||||
x86_64::instructions::interrupts::disable();
|
||||
}
|
||||
|
@ -69,7 +69,10 @@ pub mod arch;
|
||||
pub mod arch;
|
||||
|
||||
pub fn kmain() -> ! {
|
||||
executor::run();
|
||||
loop {
|
||||
executor::run_until_idle();
|
||||
arch::interrupt::wait_for_interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
/// Global heap allocator
|
||||
|
Loading…
Reference in New Issue
Block a user