Skip to content

Implement basic per-CPU / CPU-local storage #917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
37 changes: 37 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
6 changes: 5 additions & 1 deletion kernel/ap_start/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ pub fn kstart_ap(
}

// 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.

#[cfg(target_arch = "x86_64")] // not yet supported on aarch64
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
2 changes: 2 additions & 0 deletions kernel/captain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ 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!")?;
#[cfg(target_arch = "x86_64")] // not yet supported on aarch64
per_cpu::init(bsp_id)?;

// Initialize the scheduler and create the initial `Task`,
// which is bootstrapped from this current execution context.
Expand Down
18 changes: 18 additions & 0 deletions kernel/cpu_local/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[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"

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

[target.'cfg(target_arch = "x86_64")'.dependencies]
x86_64 = "0.14.8"
Loading