Make ostd::trap::irq public

This commit is contained in:
Ruihan Li
2025-04-16 20:27:14 +08:00
committed by Tate, Hongliang Tian
parent 751e0b2ebf
commit b96c8f9ed2
45 changed files with 75 additions and 67 deletions

View File

@ -7,7 +7,7 @@ use core::{alloc::Layout, cell::RefCell};
use ostd::{
cpu_local,
mm::{Paddr, PAGE_SIZE},
trap::DisabledLocalIrqGuard,
trap::irq::DisabledLocalIrqGuard,
};
cpu_local! {

View File

@ -64,7 +64,7 @@ pub struct FrameAllocator;
impl GlobalFrameAllocator for FrameAllocator {
fn alloc(&self, layout: Layout) -> Option<Paddr> {
let guard = trap::disable_local();
let guard = trap::irq::disable_local();
let res = cache::alloc(&guard, layout);
if res.is_some() {
TOTAL_FREE_SIZE.sub(guard.current_cpu(), layout.size());
@ -73,13 +73,13 @@ impl GlobalFrameAllocator for FrameAllocator {
}
fn dealloc(&self, addr: Paddr, size: usize) {
let guard = trap::disable_local();
let guard = trap::irq::disable_local();
TOTAL_FREE_SIZE.add(guard.current_cpu(), size);
cache::dealloc(&guard, addr, size);
}
fn add_free_memory(&self, addr: Paddr, size: usize) {
let guard = trap::disable_local();
let guard = trap::irq::disable_local();
TOTAL_FREE_SIZE.add(guard.current_cpu(), size);
pools::add_free_memory(&guard, addr, size);
}

View File

@ -13,7 +13,7 @@ use ostd::{
cpu_local,
mm::Paddr,
sync::{LocalIrqDisabled, SpinLock, SpinLockGuard},
trap::DisabledLocalIrqGuard,
trap::irq::DisabledLocalIrqGuard,
};
use crate::chunk::{greater_order_of, lesser_order_of, size_of_order, split_to_chunks, BuddyOrder};

View File

@ -98,7 +98,7 @@ mod test {
pub static FREE_SIZE_COUNTER: usize;
}
let guard = trap::disable_local();
let guard = trap::irq::disable_local();
let cur_cpu = guard.current_cpu();
FREE_SIZE_COUNTER.add(cur_cpu, 10);
assert_eq!(FREE_SIZE_COUNTER.get(), 10);