Skip to content

Commit 941443d

Browse files
committed
refactor(x86_64): put platform-specific files into separate directories
1 parent b3b3c2e commit 941443d

File tree

9 files changed

+23
-21
lines changed

9 files changed

+23
-21
lines changed

src/arch/x86_64/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
cfg_if::cfg_if! {
2-
if #[cfg(feature = "linux")] {
3-
mod linux;
4-
pub use self::linux::*;
5-
} else if #[cfg(feature = "multiboot")] {
6-
mod multiboot;
7-
pub use self::multiboot::*;
8-
}
9-
}
10-
111
mod console;
122
#[cfg(target_os = "none")]
133
mod paging;
144
#[cfg(target_os = "none")]
155
mod physicalmem;
6+
mod platform;
167

178
pub use console::Console;
189

10+
#[cfg(target_os = "none")]
11+
pub use self::platform::{boot_kernel, find_kernel};
12+
1913
#[cfg(target_os = "none")]
2014
const KERNEL_STACK_SIZE: u64 = 32_768;
2115
pub const SERIAL_IO_PORT: u16 = 0x3F8;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use linux_boot_params::{BootE820Entry, BootParams};
1212
use log::{error, info};
1313
use x86_64::structures::paging::{PageSize, PageTableFlags, Size2MiB, Size4KiB};
1414

15-
use super::physicalmem::PhysAlloc;
16-
use super::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, paging};
1715
use crate::BootInfoExt;
16+
use crate::arch::x86_64::physicalmem::PhysAlloc;
17+
use crate::arch::x86_64::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, paging};
1818
use crate::fdt::Fdt;
1919

2020
unsafe extern "C" {
@@ -24,7 +24,7 @@ unsafe extern "C" {
2424

2525
mod entry {
2626
core::arch::global_asm!(
27-
include_str!("entry_linux.s"),
27+
include_str!("entry.s"),
2828
loader_main = sym crate::os::loader_main,
2929
);
3030
}
@@ -126,7 +126,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
126126
let entry = ptr::with_exposed_provenance(entry_point.try_into().unwrap());
127127
let raw_boot_info = boot_info.write();
128128

129-
unsafe { super::enter_kernel(stack, entry, raw_boot_info) }
129+
unsafe { crate::arch::x86_64::enter_kernel(stack, entry, raw_boot_info) }
130130
}
131131

132132
trait BootParamsExt {

src/arch/x86_64/platform/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cfg_if::cfg_if! {
2+
if #[cfg(feature = "linux")] {
3+
mod linux;
4+
pub use self::linux::*;
5+
} else if #[cfg(feature = "multiboot")] {
6+
mod multiboot;
7+
pub use self::multiboot::*;
8+
}
9+
}
File renamed without changes.
File renamed without changes.
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use multiboot::information::{MemoryManagement, Multiboot, PAddr};
1212
use vm_fdt::FdtWriterResult;
1313
use x86_64::structures::paging::{PageSize, PageTableFlags, Size2MiB, Size4KiB};
1414

15-
use super::paging;
16-
use super::physicalmem::PhysAlloc;
1715
use crate::BootInfoExt;
18-
use crate::arch::x86_64::{KERNEL_STACK_SIZE, SERIAL_IO_PORT};
16+
use crate::arch::x86_64::physicalmem::PhysAlloc;
17+
use crate::arch::x86_64::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, paging};
1918
use crate::fdt::Fdt;
2019

2120
unsafe extern "C" {
@@ -26,7 +25,7 @@ unsafe extern "C" {
2625
#[allow(bad_asm_style)]
2726
mod entry {
2827
core::arch::global_asm!(
29-
include_str!("entry_multiboot.s"),
28+
include_str!("entry.s"),
3029
loader_main = sym crate::os::loader_main,
3130
);
3231
}
@@ -204,5 +203,5 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
204203
let entry = ptr::with_exposed_provenance(entry_point.try_into().unwrap());
205204
let raw_boot_info = boot_info.write();
206205

207-
unsafe { super::enter_kernel(stack, entry, raw_boot_info) }
206+
unsafe { crate::arch::x86_64::enter_kernel(stack, entry, raw_boot_info) }
208207
}

xtask/src/target.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ impl Target {
7575
pub fn rustflags(&self) -> &'static [&'static str] {
7676
match self {
7777
Self::X86_64Linux => &[
78-
"-Clink-arg=-Tsrc/arch/x86_64/link_linux.ld",
78+
"-Clink-arg=-Tsrc/arch/x86_64/platform/linux/link.ld",
7979
"-Crelocation-model=static",
8080
],
8181
Self::X86_64Multiboot => &[
82-
"-Clink-arg=-Tsrc/arch/x86_64/link_multiboot.ld",
82+
"-Clink-arg=-Tsrc/arch/x86_64/platform/multiboot/link.ld",
8383
"-Crelocation-model=static",
8484
],
8585
Self::X86_64Uefi => &[],

0 commit comments

Comments
 (0)