mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-09 13:26:48 +00:00
Fix the bug caused by opt-level=1
This commit is contained in:
parent
84155289cf
commit
c321e411f6
@ -1,3 +1,4 @@
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use log::info;
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
@ -20,13 +21,11 @@ pub fn init() {
|
||||
pic::enable_temp();
|
||||
super::pit::init();
|
||||
|
||||
static mut IS_FINISH: bool = false;
|
||||
// wait until it is finish
|
||||
x86_64::instructions::interrupts::enable();
|
||||
unsafe {
|
||||
while !IS_FINISH {
|
||||
x86_64::instructions::hlt();
|
||||
}
|
||||
static IS_FINISH: AtomicBool = AtomicBool::new(false);
|
||||
while !IS_FINISH.load(Ordering::Acquire) {
|
||||
x86_64::instructions::hlt();
|
||||
}
|
||||
x86_64::instructions::interrupts::disable();
|
||||
drop(a);
|
||||
@ -36,7 +35,7 @@ pub fn init() {
|
||||
static mut IN_TIME: u8 = 0;
|
||||
static mut FIRST_TIME_COUNT: u64 = 0;
|
||||
unsafe {
|
||||
if IS_FINISH || IN_TIME == 0 {
|
||||
if IS_FINISH.load(Ordering::Acquire) || IN_TIME == 0 {
|
||||
// drop the first entry, since it may not be the time we want
|
||||
IN_TIME += 1;
|
||||
let apic_lock = APIC_INSTANCE.get().unwrap().lock();
|
||||
@ -63,8 +62,6 @@ pub fn init() {
|
||||
remain_ticks,
|
||||
config::TIMER_FREQ
|
||||
);
|
||||
unsafe {
|
||||
IS_FINISH = true;
|
||||
}
|
||||
IS_FINISH.store(true, Ordering::Release);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ pub(crate) fn init(regions: &Vec<MemoryRegion>) {
|
||||
if region.typ() == MemoryRegionType::Usable {
|
||||
// Make the memory region page-aligned
|
||||
let start = region.base().align_up(PAGE_SIZE) / PAGE_SIZE;
|
||||
let end = (start + region.len()).align_down(PAGE_SIZE) / PAGE_SIZE;
|
||||
let end = (region.base() + region.len()).align_down(PAGE_SIZE) / PAGE_SIZE;
|
||||
allocator.add_frame(start, end);
|
||||
info!(
|
||||
"Found usable region, start:{:x}, end:{:x}",
|
||||
|
Loading…
x
Reference in New Issue
Block a user