arch/x86: sync LogicalCpuId changes
This commit is contained in:
+3
-1
@@ -4,6 +4,8 @@ use core::convert::TryInto;
|
||||
use core::mem;
|
||||
use core::ptr::addr_of_mut;
|
||||
|
||||
use crate::LogicalCpuId;
|
||||
|
||||
use x86::bits32::task::TaskStateSegment;
|
||||
use x86::Ring;
|
||||
use x86::dtables::{self, DescriptorTablePointer};
|
||||
@@ -124,7 +126,7 @@ pub unsafe fn init() {
|
||||
}
|
||||
|
||||
/// Initialize GDT and configure percpu.
|
||||
pub unsafe fn init_paging(stack_offset: usize, cpu_id: usize) {
|
||||
pub unsafe fn init_paging(stack_offset: usize, cpu_id: LogicalCpuId) {
|
||||
let pcr_frame = crate::memory::allocate_frames(1).expect("failed to allocate PCR frame");
|
||||
let pcr = &mut *(RmmA::phys_to_virt(pcr_frame.start_address()).data() as *mut ProcessorControlRegion);
|
||||
|
||||
|
||||
+6
-6
@@ -8,7 +8,7 @@ use alloc::collections::BTreeMap;
|
||||
use x86::segmentation::Descriptor as X86IdtEntry;
|
||||
use x86::dtables::{self, DescriptorTablePointer};
|
||||
|
||||
use crate::interrupt::*;
|
||||
use crate::{interrupt::*, LogicalCpuId};
|
||||
use crate::ipi::IpiKind;
|
||||
|
||||
use spin::RwLock;
|
||||
@@ -68,10 +68,10 @@ impl Idt {
|
||||
static mut INIT_BSP_IDT: Idt = Idt::new();
|
||||
|
||||
// TODO: VecMap?
|
||||
pub static IDTS: RwLock<Option<BTreeMap<usize, &'static mut Idt>>> = RwLock::new(None);
|
||||
pub static IDTS: RwLock<Option<BTreeMap<LogicalCpuId, &'static mut Idt>>> = RwLock::new(None);
|
||||
|
||||
#[inline]
|
||||
pub fn is_reserved(cpu_id: usize, index: u8) -> bool {
|
||||
pub fn is_reserved(cpu_id: LogicalCpuId, index: u8) -> bool {
|
||||
let byte_index = index / 32;
|
||||
let bit = index % 32;
|
||||
|
||||
@@ -79,7 +79,7 @@ pub fn is_reserved(cpu_id: usize, index: u8) -> bool {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_reserved(cpu_id: usize, index: u8, reserved: bool) {
|
||||
pub fn set_reserved(cpu_id: LogicalCpuId, index: u8, reserved: bool) {
|
||||
let byte_index = index / 32;
|
||||
let bit = index % 32;
|
||||
|
||||
@@ -97,7 +97,7 @@ pub fn allocate_interrupt() -> Option<NonZeroU8> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn available_irqs_iter(cpu_id: usize) -> impl Iterator<Item = u8> + 'static {
|
||||
pub fn available_irqs_iter(cpu_id: LogicalCpuId) -> impl Iterator<Item = u8> + 'static {
|
||||
(32..=254).filter(move |&index| !is_reserved(cpu_id, index))
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ const fn new_idt_reservations() -> [AtomicU32; 8] {
|
||||
}
|
||||
|
||||
/// Initialize the IDT for a
|
||||
pub unsafe fn init_paging_post_heap(is_bsp: bool, cpu_id: usize) {
|
||||
pub unsafe fn init_paging_post_heap(is_bsp: bool, cpu_id: LogicalCpuId) {
|
||||
let mut idts_guard = IDTS.write();
|
||||
let idts_btree = idts_guard.get_or_insert_with(BTreeMap::new);
|
||||
|
||||
|
||||
+5
-3
@@ -24,6 +24,8 @@ use rmm::{
|
||||
};
|
||||
use spin::Mutex;
|
||||
|
||||
use crate::LogicalCpuId;
|
||||
|
||||
use super::CurrentRmmArch as RmmA;
|
||||
|
||||
extern "C" {
|
||||
@@ -297,14 +299,14 @@ impl KernelMapper {
|
||||
|
||||
prev_count > 0
|
||||
}
|
||||
pub unsafe fn lock_for_manual_mapper(current_processor: usize, mapper: crate::paging::PageMapper) -> Self {
|
||||
let ro = Self::lock_inner(current_processor);
|
||||
pub unsafe fn lock_for_manual_mapper(current_processor: LogicalCpuId, mapper: crate::paging::PageMapper) -> Self {
|
||||
let ro = Self::lock_inner(current_processor.get() as usize);
|
||||
Self {
|
||||
mapper,
|
||||
ro,
|
||||
}
|
||||
}
|
||||
pub fn lock_manually(current_processor: usize) -> Self {
|
||||
pub fn lock_manually(current_processor: LogicalCpuId) -> Self {
|
||||
unsafe { Self::lock_for_manual_mapper(current_processor, PageMapper::current(TableKind::Kernel, FRAME_ALLOCATOR)) }
|
||||
}
|
||||
pub fn lock() -> Self {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
/// defined in other files inside of the `arch` module
|
||||
|
||||
use core::slice;
|
||||
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering, AtomicU32};
|
||||
|
||||
use crate::allocator;
|
||||
use crate::{allocator, LogicalCpuId};
|
||||
#[cfg(feature = "acpi")]
|
||||
use crate::acpi;
|
||||
use crate::arch::pti;
|
||||
@@ -28,7 +28,10 @@ static DATA_TEST_NONZERO: usize = usize::max_value();
|
||||
|
||||
pub static KERNEL_BASE: AtomicUsize = AtomicUsize::new(0);
|
||||
pub static KERNEL_SIZE: AtomicUsize = AtomicUsize::new(0);
|
||||
pub static CPU_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
// TODO: This probably shouldn't be an atomic. Only the BSP starts APs.
|
||||
pub static CPU_COUNT: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
pub static AP_READY: AtomicBool = AtomicBool::new(false);
|
||||
static BSP_READY: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
@@ -128,7 +131,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
|
||||
paging::init();
|
||||
|
||||
// Set up GDT after paging with TLS
|
||||
gdt::init_paging(args.stack_base as usize + args.stack_size as usize, 0);
|
||||
gdt::init_paging(args.stack_base as usize + args.stack_size as usize, LogicalCpuId::BSP);
|
||||
|
||||
// Set up IDT
|
||||
idt::init_paging_bsp();
|
||||
@@ -148,7 +151,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
|
||||
#[cfg(feature = "graphical_debug")]
|
||||
graphical_debug::init_heap();
|
||||
|
||||
idt::init_paging_post_heap(true, 0);
|
||||
idt::init_paging_post_heap(true, LogicalCpuId::BSP);
|
||||
|
||||
// Activate memory logging
|
||||
log::init();
|
||||
@@ -202,7 +205,7 @@ pub struct KernelArgsAp {
|
||||
pub unsafe extern fn kstart_ap(args_ptr: *const KernelArgsAp) -> ! {
|
||||
let cpu_id = {
|
||||
let args = &*args_ptr;
|
||||
let cpu_id = args.cpu_id as usize;
|
||||
let cpu_id = LogicalCpuId::new(args.cpu_id as u32);
|
||||
let bsp_table = args.page_table as usize;
|
||||
let _stack_start = args.stack_start as usize;
|
||||
let stack_end = args.stack_end as usize;
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ pub unsafe fn debugger(target_id: Option<crate::context::ContextId>) {
|
||||
for (id, context_lock) in crate::context::contexts().iter() {
|
||||
if target_id.map_or(false, |target_id| *id != target_id) { continue; }
|
||||
let context = context_lock.read();
|
||||
println!("{}: {}", (*id).into(), context.name);
|
||||
println!("{}: {}", (*id).get(), context.name);
|
||||
|
||||
// Switch to context page table to ensure syscall debug and stack dump will work
|
||||
if let Some(ref space) = context.addr_space {
|
||||
|
||||
Reference in New Issue
Block a user