From 3b725b2c27d2165fd720b0fb9b993f7274ac00dc Mon Sep 17 00:00:00 2001
From: 4lDO2 <4lDO2@protonmail.com>
Date: Mon, 4 Sep 2023 21:27:48 +0200
Subject: [PATCH] Add logical CPU ID newtype, switch to u32.
---
src/arch/x86_64/gdt.rs | 3 ++-
src/arch/x86_64/idt.rs | 12 +++++------
src/arch/x86_64/misc.rs | 5 +++--
src/arch/x86_64/rmm.rs | 8 +++++---
src/arch/x86_64/start.rs | 19 +++++++++++-------
src/context/context.rs | 9 +++++----
src/context/list.rs | 2 +-
src/context/mod.rs | 2 +-
src/context/switch.rs | 4 ++--
src/lib.rs | 43 ++++++++++++++++++++++++++++++----------
src/percpu.rs | 4 ++--
src/scheme/irq.rs | 10 +++++-----
src/scheme/proc.rs | 17 ++++++++++++----
13 files changed, 90 insertions(+), 48 deletions(-)
diff --git a/src/arch/x86_64/gdt.rs b/src/arch/x86_64/gdt.rs
index 5add48cb46..b0bf641481 100644
--- a/src/arch/x86_64/gdt.rs
+++ b/src/arch/x86_64/gdt.rs
@@ -3,6 +3,7 @@
use core::convert::TryInto;
use core::mem;
+use crate::LogicalCpuId;
use crate::paging::{RmmA, RmmArch};
use crate::percpu::PercpuBlock;
@@ -144,7 +145,7 @@ unsafe fn load_segments() {
/// Initialize GDT and PCR.
#[cold]
-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");
let pcr = &mut *(RmmA::phys_to_virt(pcr_frame.start_address()).data() as *mut ProcessorControlRegion);
diff --git a/src/arch/x86_64/idt.rs b/src/arch/x86_64/idt.rs
index 6adffb7fa2..c3c5d311ce 100644
--- a/src/arch/x86_64/idt.rs
+++ b/src/arch/x86_64/idt.rs
@@ -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