Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kernel/ap_start/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ scheduler = { path = "../scheduler" }
spawn = { path = "../spawn" }
kernel_config = { path = "../kernel_config" }
cpu = { path = "../cpu" }
per_cpu = { path = "../per_cpu" }
no_drop = { path = "../no_drop" }
early_tls = { path = "../early_tls" }

Expand Down
9 changes: 5 additions & 4 deletions kernel/ap_start/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ pub fn kstart_ap(
interrupts::init_ap();

// Initialize this CPU's Local APIC such that we can use everything that depends on APIC IDs.
// This must be done before initializing task spawning, because that relies on the ability to
// enable/disable preemption, which is partially implemented by the Local APIC.
// This must be done before initializing per-CPU storage, task spawning, and more,
// as those rely on enable/disable preemption, which itself depends on the Local APIC.
#[cfg(target_arch = "x86_64")]
LocalApic::init(
&mut kernel_mmi_ref.lock().page_table,
Expand All @@ -102,9 +102,10 @@ pub fn kstart_ap(
nmi_lint,
nmi_flags,
).unwrap();

// Now that the Local APIC has been initialized for this CPU, we can initialize the
// task management subsystem and create the idle task for this CPU.
// per-CPU storage, tasking, and create the idle task for this CPU.
per_cpu::init(cpu_id).unwrap();
let bootstrap_task = spawn::init(kernel_mmi_ref.clone(), cpu_id, this_ap_stack).unwrap();
spawn::create_idle_task().unwrap();

Expand Down
1 change: 1 addition & 0 deletions kernel/captain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spawn = { path = "../spawn" }
stack = { path = "../stack" }
task = { path = "../task" }
cpu = { path = "../cpu" }
per_cpu = { path = "../per_cpu" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
logger_x86_64 = { path = "../logger_x86_64" }
Expand Down
1 change: 1 addition & 0 deletions kernel/captain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub fn init(

// get BSP's CPU ID
let bsp_id = cpu::bootstrap_cpu().ok_or("captain::init(): couldn't get ID of bootstrap CPU!")?;
per_cpu::init(bsp_id)?;

// Initialize the scheduler and create the initial `Task`,
// which is bootstrapped from this current execution context.
Expand Down
16 changes: 16 additions & 0 deletions kernel/cpu_local/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
authors = ["Kevin Boos <[email protected]>"]
name = "cpu_local"
description = "Support for accessing CPU-local storage via per-CPU variables"
version = "0.1.0"
edition = "2021"

[dependencies]
crossbeam-utils = { version = "0.8.12", default-features = false }
log = "0.4.8"
spin = "0.9.0"
x86_64 = "0.14.8"

irq_safety = { git = "https://github.com/theseus-os/irq_safety" }
memory = { path = "../memory" }
preemption = { path = "../preemption" }
Loading