mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Enable IRQs before leaving the OSTD boot routine
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
20d5212910
commit
491e4325fa
@ -89,9 +89,6 @@ fn init_thread() {
|
|||||||
// Work queue should be initialized before interrupt is enabled,
|
// Work queue should be initialized before interrupt is enabled,
|
||||||
// in case any irq handler uses work queue as bottom half
|
// in case any irq handler uses work queue as bottom half
|
||||||
thread::work_queue::init();
|
thread::work_queue::init();
|
||||||
// FIXME: Remove this if we move the step of mounting
|
|
||||||
// the filesystems to be done within the init process.
|
|
||||||
ostd::trap::enable_local();
|
|
||||||
net::lazy_init();
|
net::lazy_init();
|
||||||
fs::lazy_init();
|
fs::lazy_init();
|
||||||
// driver::pci::virtio::block::block_device_test();
|
// driver::pci::virtio::block::block_device_test();
|
||||||
|
@ -18,12 +18,14 @@ use ostd::{
|
|||||||
|
|
||||||
use super::Process;
|
use super::Process;
|
||||||
use crate::{
|
use crate::{
|
||||||
prelude::*,
|
|
||||||
process::{
|
process::{
|
||||||
posix_thread::PosixThreadExt,
|
posix_thread::PosixThreadExt,
|
||||||
signal::{constants::SIGALRM, signals::kernel::KernelSignal},
|
signal::{constants::SIGALRM, signals::kernel::KernelSignal},
|
||||||
},
|
},
|
||||||
thread::work_queue::{submit_work_item, work_item::WorkItem},
|
thread::{
|
||||||
|
work_queue::{submit_work_item, work_item::WorkItem},
|
||||||
|
Thread,
|
||||||
|
},
|
||||||
time::{
|
time::{
|
||||||
clocks::{ProfClock, RealTimeClock},
|
clocks::{ProfClock, RealTimeClock},
|
||||||
Timer, TimerManager,
|
Timer, TimerManager,
|
||||||
@ -36,8 +38,12 @@ use crate::{
|
|||||||
/// invoke the callbacks of expired timers which are based on the updated
|
/// invoke the callbacks of expired timers which are based on the updated
|
||||||
/// CPU clock.
|
/// CPU clock.
|
||||||
fn update_cpu_time() {
|
fn update_cpu_time() {
|
||||||
let current_thread = current_thread!();
|
let Some(current_thread) = Thread::current() else {
|
||||||
if let Some(posix_thread) = current_thread.as_posix_thread() {
|
return;
|
||||||
|
};
|
||||||
|
let Some(posix_thread) = current_thread.as_posix_thread() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
let process = posix_thread.process();
|
let process = posix_thread.process();
|
||||||
let timer_manager = process.timer_manager();
|
let timer_manager = process.timer_manager();
|
||||||
let jiffies_interval = Duration::from_millis(1000 / TIMER_FREQ);
|
let jiffies_interval = Duration::from_millis(1000 / TIMER_FREQ);
|
||||||
@ -69,7 +75,6 @@ fn update_cpu_time() {
|
|||||||
.timer_manager()
|
.timer_manager()
|
||||||
.process_expired_timers();
|
.process_expired_timers();
|
||||||
posix_thread.process_expired_timers();
|
posix_thread.process_expired_timers();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers a function to update the CPU clock in processes and
|
/// Registers a function to update the CPU clock in processes and
|
||||||
|
@ -190,7 +190,7 @@ fn taskless_softirq_handler(
|
|||||||
mod test {
|
mod test {
|
||||||
use core::sync::atomic::AtomicUsize;
|
use core::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
use ostd::{prelude::*, trap::enable_local};
|
use ostd::prelude::*;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@ -198,7 +198,6 @@ mod test {
|
|||||||
static DONE: AtomicBool = AtomicBool::new(false);
|
static DONE: AtomicBool = AtomicBool::new(false);
|
||||||
if !DONE.load(Ordering::SeqCst) {
|
if !DONE.load(Ordering::SeqCst) {
|
||||||
super::init();
|
super::init();
|
||||||
enable_local();
|
|
||||||
DONE.store(true, Ordering::SeqCst);
|
DONE.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,7 @@ fn ap_early_entry(local_apic_id: u32) -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trap::init();
|
trap::init();
|
||||||
|
crate::arch::irq::enable_local();
|
||||||
|
|
||||||
// Mark the AP as started.
|
// Mark the AP as started.
|
||||||
let ap_boot_info = AP_BOOT_INFO.get().unwrap();
|
let ap_boot_info = AP_BOOT_INFO.get().unwrap();
|
||||||
|
@ -86,6 +86,8 @@ pub fn init() {
|
|||||||
|
|
||||||
mm::kspace::activate_kernel_page_table();
|
mm::kspace::activate_kernel_page_table();
|
||||||
|
|
||||||
|
arch::irq::enable_local();
|
||||||
|
|
||||||
invoke_ffi_init_funcs();
|
invoke_ffi_init_funcs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,18 +172,3 @@ impl Drop for DisabledLocalIrqGuard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enables all IRQs on the current CPU.
|
|
||||||
///
|
|
||||||
/// FIXME: The reason we need to add this API is that currently IRQs
|
|
||||||
/// are enabled when the CPU enters the user space for the first time,
|
|
||||||
/// which is too late. During the OS initialization phase,
|
|
||||||
/// we need to get the block device working and mount the filesystems,
|
|
||||||
/// thus requiring the IRQs should be enabled as early as possible.
|
|
||||||
///
|
|
||||||
/// FIXME: this method may be unsound.
|
|
||||||
pub fn enable_local() {
|
|
||||||
if !crate::arch::irq::is_local_enabled() {
|
|
||||||
crate::arch::irq::enable_local();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -11,9 +11,7 @@ pub use softirq::SoftIrqLine;
|
|||||||
pub use trapframe::TrapFrame;
|
pub use trapframe::TrapFrame;
|
||||||
|
|
||||||
pub(crate) use self::handler::call_irq_callback_functions;
|
pub(crate) use self::handler::call_irq_callback_functions;
|
||||||
pub use self::irq::{
|
pub use self::irq::{disable_local, DisabledLocalIrqGuard, IrqCallbackFunction, IrqLine};
|
||||||
disable_local, enable_local, DisabledLocalIrqGuard, IrqCallbackFunction, IrqLine,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(crate) fn init() {
|
pub(crate) fn init() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
Reference in New Issue
Block a user