Skip to content

Commit db6f3a4

Browse files
authored
Prepare multicore_bringup for aarch64 support (#889)
* Move `multicore_bringup/lib.rs` to x86_64-specific module file. * Remove `max_framebuffer_resolution` parameter in `multicore_bringup`, use the fixed constant definition from `kernel_config`. * Restore arch-gate for early exceptions init in `nano_core`
1 parent 0f4f28f commit db6f3a4

File tree

4 files changed

+19
-63
lines changed

4 files changed

+19
-63
lines changed

kernel/captain/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,8 @@ impl DropAfterInit {
5555
}
5656
}
5757

58-
#[cfg(target_arch = "x86_64")]
5958
pub use multicore_bringup::MulticoreBringupInfo;
6059

61-
/// TODO: in the future this could be defined here or re-exported from another aarch64 crate.
62-
#[cfg(target_arch = "aarch64")]
63-
pub struct MulticoreBringupInfo {
64-
// nothing needed on aarch64 yet
65-
}
66-
67-
6860
/// Initialize the Captain, which is the main crate that "steers the ship" of Theseus.
6961
///
7062
/// This does the rest of the initialization procedures so that the OS
@@ -144,7 +136,6 @@ pub fn init(
144136
let ap_count = multicore_bringup::handle_ap_cores(
145137
&kernel_mmi_ref,
146138
multicore_info,
147-
Some(kernel_config::display::FRAMEBUFFER_MAX_RESOLUTION),
148139
)?;
149140
#[cfg(not(target_arch = "x86_64"))]
150141
let ap_count = 0;

kernel/multicore_bringup/Cargo.toml

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,25 @@ authors = ["Kevin Boos <kevinaboos@gmail.com>"]
33
name = "multicore_bringup"
44
description = "Support for bringing up other CPU cores (APs) from the main core (BSP)"
55
version = "0.1.0"
6+
edition = "2021"
67

78
[dependencies]
89
spin = "0.9.4"
910
volatile = "0.2.7"
1011
zerocopy = "0.5.0"
1112
log = "0.4.8"
12-
13-
[dependencies.memory]
14-
path = "../memory"
15-
16-
[dependencies.stack]
17-
path = "../stack"
18-
19-
[dependencies.kernel_config]
20-
path = "../kernel_config"
21-
22-
[dependencies.pit_clock_basic]
23-
path = "../pit_clock_basic"
24-
25-
[dependencies.mod_mgmt]
26-
path = "../mod_mgmt"
27-
28-
[dependencies.acpi]
29-
path = "../acpi"
30-
31-
[dependencies.apic]
32-
path = "../apic"
33-
34-
[dependencies.cpu]
35-
path = "../cpu"
36-
37-
[dependencies.ap_start]
38-
path = "../ap_start"
39-
40-
[dependencies.madt]
41-
path = "../acpi/madt"
42-
43-
[dependencies.pause]
44-
path = "../pause"
45-
13+
memory = { path = "../memory" }
14+
stack = { path = "../stack" }
15+
cpu = { path = "../cpu" }
16+
ap_start = { path = "../ap_start" }
17+
kernel_config = { path = "../kernel_config" }
18+
pit_clock_basic = { path = "../pit_clock_basic" }
19+
mod_mgmt = { path = "../mod_mgmt" }
20+
acpi = { path = "../acpi" }
21+
apic = { path = "../apic" }
22+
madt = { path = "../acpi/madt" }
23+
pause = { path = "../pause" }
4624

4725
[lib]
4826
crate-type = ["rlib"]
27+
path = "src/x86_64.rs"

kernel/multicore_bringup/src/lib.rs renamed to kernel/multicore_bringup/src/x86_64.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,7 @@
77
#![no_std]
88
#![feature(let_chains)]
99

10-
extern crate alloc;
1110
#[macro_use] extern crate log;
12-
extern crate spin;
13-
extern crate volatile;
14-
extern crate zerocopy;
15-
extern crate memory;
16-
extern crate pit_clock_basic;
17-
extern crate stack;
18-
extern crate kernel_config;
19-
extern crate apic;
20-
extern crate acpi;
21-
extern crate madt;
22-
extern crate mod_mgmt;
23-
extern crate ap_start;
24-
extern crate pause;
25-
extern crate cpu;
2611

2712
use core::{
2813
convert::TryInto,
@@ -34,7 +19,7 @@ use spin::Mutex;
3419
use volatile::Volatile;
3520
use zerocopy::FromBytes;
3621
use memory::{VirtualAddress, PhysicalAddress, MappedPages, PteFlags, MmiRef};
37-
use kernel_config::memory::{PAGE_SIZE, PAGE_SHIFT, KERNEL_STACK_SIZE_IN_PAGES};
22+
use kernel_config::{memory::{PAGE_SIZE, PAGE_SHIFT, KERNEL_STACK_SIZE_IN_PAGES}, display::FRAMEBUFFER_MAX_RESOLUTION};
3823
use apic::{LocalApic, get_lapics, current_cpu, has_x2apic, bootstrap_cpu, cpu_count};
3924
use ap_start::{kstart_ap, AP_READY_FLAG};
4025
use madt::{Madt, MadtEntry, find_nmi_entry_for_processor};
@@ -206,7 +191,6 @@ pub struct MulticoreBringupInfo {
206191
pub fn handle_ap_cores(
207192
kernel_mmi_ref: &MmiRef,
208193
multicore_info: MulticoreBringupInfo,
209-
max_framebuffer_resolution: Option<(u16, u16)>,
210194
) -> Result<u32, &'static str> {
211195
let MulticoreBringupInfo {
212196
ap_start_realmode_begin,
@@ -276,7 +260,7 @@ pub fn handle_ap_cores(
276260
// Here, we set up the data items that will be accessible to the APs when they boot up.
277261
// We only set the values of fields that are the same for ALL APs here;
278262
// values that change for each AP are set individually in `bring_up_ap()` below.
279-
let (max_width, max_height) = max_framebuffer_resolution.unwrap_or((u16::MAX, u16::MAX));
263+
let (max_width, max_height) = FRAMEBUFFER_MAX_RESOLUTION;
280264
ap_trampoline_data.ap_max_fb_width.write(max_width);
281265
ap_trampoline_data.ap_max_fb_height.write(max_height);
282266
ap_trampoline_data.ap_gdt.write(ap_gdt.value().try_into().map_err(|_| "AP_GDT physical address larger than u32::MAX")?);

kernel/nano_core/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ where
112112
build_info::CUSTOM_CFG_STR,
113113
);
114114

115-
exceptions_early::init(Some(double_fault_stack_top));
116-
println!("early_setup(): initialized early IDT with exception handlers.");
115+
#[cfg(target_arch = "x86_64")] {
116+
exceptions_early::init(Some(double_fault_stack_top));
117+
println!("early_setup(): initialized early IDT with exception handlers.");
118+
}
117119

118120
let rsdp_address = boot_info.rsdp();
119121
println!("nano_core(): bootloader-provided RSDP address: {:X?}", rsdp_address);

0 commit comments

Comments
 (0)