Skip to content

Commit 7c60ced

Browse files
authored
Merge pull request #2486 from hermit-os/arch-imports
refactor: clean up arch-specific imports
2 parents 6a1f391 + f88d984 commit 7c60ced

50 files changed

Lines changed: 147 additions & 192 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/arch/aarch64/kernel/interrupts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ use hashbrown::HashMap;
1414
use hermit_sync::{InterruptSpinMutex, InterruptTicketMutex, OnceCell, SpinMutex};
1515
use memory_addresses::{PhysAddr, VirtAddr};
1616

17-
use crate::arch::aarch64::kernel::core_local::increment_irq_counter;
17+
use crate::arch::aarch64::kernel::core_local::{core_id, core_scheduler, increment_irq_counter};
1818
use crate::arch::aarch64::kernel::scheduler::State;
19+
use crate::arch::aarch64::kernel::serial::handle_uart_interrupt;
1920
use crate::arch::aarch64::mm::paging::{self, BasePageSize, PageSize, PageTableEntryFlags};
2021
#[cfg(not(feature = "pci"))]
2122
use crate::drivers::mmio::get_interrupt_handlers;
2223
#[cfg(feature = "pci")]
2324
use crate::drivers::pci::get_interrupt_handlers;
2425
use crate::drivers::{InterruptHandlerQueue, InterruptLine};
25-
use crate::kernel::serial::handle_uart_interrupt;
26+
use crate::env;
2627
use crate::mm::{PageAlloc, PageRangeAllocator};
2728
use crate::scheduler::{self, CoreId, timer_interrupts};
28-
use crate::{core_id, core_scheduler, env};
2929

3030
/// The ID of the first Private Peripheral Interrupt.
3131
const PPI_START: u8 = 16;

src/arch/aarch64/kernel/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use core::{ptr, str};
2121

2222
use memory_addresses::PhysAddr;
2323

24+
pub(crate) use self::interrupts::wakeup_core;
25+
pub(crate) use self::processor::set_oneshot_timer;
2426
use crate::arch::aarch64::kernel::core_local::*;
2527
use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize};
2628
use crate::config::*;
@@ -124,7 +126,7 @@ pub fn boot_next_processor() {
124126

125127
use memory_addresses::VirtAddr;
126128

127-
use crate::kernel::start::{TTBR0, smp_start};
129+
use crate::arch::aarch64::kernel::start::{TTBR0, smp_start};
128130
use crate::mm::virtual_to_physical;
129131

130132
if cpu_online == 0 {

src/arch/aarch64/kernel/pci.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ use pci_types::{
1111
PciHeader,
1212
};
1313

14+
use crate::arch::aarch64::kernel::core_local::core_id;
1415
use crate::arch::aarch64::kernel::interrupts::GIC;
1516
use crate::arch::aarch64::mm::paging::{self, BasePageSize, PageSize, PageTableEntryFlags};
1617
use crate::drivers::pci::{PCI_DEVICES, PciDevice};
18+
use crate::env;
1719
use crate::mm::{PageAlloc, PageRangeAllocator};
18-
use crate::{core_id, env};
1920

2021
const PCI_MAX_DEVICE_NUMBER: u8 = 32;
2122
const PCI_MAX_FUNCTION_NUMBER: u8 = 8;

src/arch/aarch64/kernel/scheduler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::arch::aarch64::mm::paging::{BasePageSize, PageSize, PageTableEntryFla
1515
use crate::mm::{FrameAlloc, PageAlloc, PageRangeAllocator};
1616
use crate::scheduler::PerCoreSchedulerExt;
1717
use crate::scheduler::task::{Task, TaskFrame};
18-
use crate::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};
18+
use crate::config::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};
1919

2020
#[derive(Debug)]
2121
#[repr(C, packed)]

src/arch/aarch64/kernel/start.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use hermit_entry::Entry;
1111
use hermit_entry::boot_info::RawBootInfo;
1212

1313
use crate::arch::aarch64::kernel::scheduler::TaskStacks;
14-
use crate::{KERNEL_STACK_SIZE, env};
14+
use crate::config::KERNEL_STACK_SIZE;
15+
use crate::env;
1516

1617
/*
1718
* Memory types available.
@@ -277,7 +278,7 @@ unsafe extern "C" fn pre_init(boot_info: Option<&'static RawBootInfo>, cpu_id: u
277278
"{preamble} Secondary core booted, but Hermit was not built with SMP support!"
278279
);
279280
loop {
280-
crate::arch::processor::halt();
281+
crate::arch::kernel::processor::halt();
281282
}
282283
}
283284
#[cfg(feature = "smp")]

src/arch/aarch64/mm/paging.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ bitflags! {
8080
}
8181

8282
impl PageTableEntryFlags {
83+
#[expect(dead_code)]
8384
pub fn present(&mut self) -> &mut Self {
8485
self.insert(PageTableEntryFlags::PRESENT);
8586
self
@@ -102,6 +103,7 @@ impl PageTableEntryFlags {
102103
self
103104
}
104105

106+
#[expect(dead_code)]
105107
pub fn read_only(&mut self) -> &mut Self {
106108
self.insert(PageTableEntryFlags::READ_ONLY);
107109
self

src/arch/mod.rs

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,15 @@
22
33
cfg_select! {
44
target_arch = "aarch64" => {
5-
pub(crate) mod aarch64;
5+
mod aarch64;
66
pub(crate) use self::aarch64::*;
7-
8-
#[cfg(target_os = "none")]
9-
pub(crate) use self::aarch64::kernel::boot_processor_init;
10-
pub(crate) use self::aarch64::kernel::core_local;
11-
pub(crate) use self::aarch64::kernel::interrupts;
12-
pub(crate) use self::aarch64::kernel::interrupts::wakeup_core;
13-
#[cfg(feature = "pci")]
14-
pub(crate) use self::aarch64::kernel::pci;
15-
pub(crate) use self::aarch64::kernel::processor;
16-
pub(crate) use self::aarch64::kernel::serial::SerialDevice;
17-
pub(crate) use self::aarch64::kernel::processor::set_oneshot_timer;
18-
pub(crate) use self::aarch64::kernel::scheduler;
19-
#[cfg(feature = "smp")]
20-
pub(crate) use self::aarch64::kernel::application_processor_init;
21-
pub(crate) use self::aarch64::kernel::{
22-
get_processor_count,
23-
};
24-
pub use self::aarch64::mm::paging::{BasePageSize, PageSize};
25-
}
26-
target_arch = "x86_64" => {
27-
pub(crate) mod x86_64;
28-
pub(crate) use self::x86_64::*;
29-
30-
pub(crate) use self::x86_64::kernel::apic::{
31-
set_oneshot_timer,
32-
wakeup_core,
33-
};
34-
#[cfg(all(target_os = "none", feature = "smp"))]
35-
pub(crate) use self::x86_64::kernel::application_processor_init;
36-
pub(crate) use self::x86_64::kernel::core_local;
37-
pub(crate) use self::x86_64::kernel::gdt::set_current_kernel_stack;
38-
pub(crate) use self::x86_64::kernel::interrupts;
39-
#[cfg(feature = "pci")]
40-
pub(crate) use self::x86_64::kernel::pci;
41-
pub(crate) use self::x86_64::kernel::processor;
42-
pub(crate) use self::x86_64::kernel::serial::SerialDevice;
43-
pub(crate) use self::x86_64::kernel::scheduler;
44-
pub(crate) use self::x86_64::kernel::switch;
45-
#[cfg(target_os = "none")]
46-
pub(crate) use self::x86_64::kernel::boot_processor_init;
47-
pub(crate) use self::x86_64::kernel::{
48-
get_processor_count,
49-
};
50-
pub use self::x86_64::mm::paging::{BasePageSize, PageSize};
51-
#[cfg(feature = "common-os")]
52-
pub use self::x86_64::mm::create_new_root_page_table;
53-
#[cfg(feature = "common-os")]
54-
pub use self::x86_64::kernel::{load_application, jump_to_user_land};
557
}
568
target_arch = "riscv64" => {
57-
pub(crate) mod riscv64;
9+
mod riscv64;
5810
pub(crate) use self::riscv64::*;
59-
60-
#[cfg(feature = "smp")]
61-
pub(crate) use self::riscv64::kernel::application_processor_init;
62-
#[cfg(feature = "pci")]
63-
pub(crate) use self::riscv64::kernel::pci;
64-
pub(crate) use self::riscv64::kernel::processor::{self, set_oneshot_timer, wakeup_core};
65-
pub(crate) use self::riscv64::kernel::serial::SerialDevice;
66-
pub(crate) use self::riscv64::kernel::{
67-
boot_processor_init,
68-
core_local,
69-
get_processor_count,
70-
interrupts,
71-
scheduler,
72-
switch,
73-
};
74-
pub use self::riscv64::mm::paging::{BasePageSize, PageSize};
11+
}
12+
target_arch = "x86_64" => {
13+
mod x86_64;
14+
pub(crate) use self::x86_64::*;
7515
}
7616
}

src/arch/riscv64/kernel/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use free_list::PageLayout;
1919
use memory_addresses::PhysAddr;
2020
use riscv::register::sstatus;
2121

22+
pub(crate) use self::processor::{set_oneshot_timer, wakeup_core};
2223
use crate::arch::riscv64::kernel::core_local::core_id;
2324
pub use crate::arch::riscv64::kernel::devicetree::init_drivers;
2425
use crate::arch::riscv64::kernel::processor::lsb;
@@ -107,10 +108,12 @@ pub fn boot_processor_init() {
107108
/// Application Processor initialization
108109
#[cfg(feature = "smp")]
109110
pub fn application_processor_init() {
111+
use crate::arch::kernel::core_local::CoreLocal;
112+
110113
unsafe {
111114
super::mm::paging::enable_page_table();
112115
}
113-
crate::CoreLocal::install();
116+
CoreLocal::install();
114117
interrupts::install();
115118
finish_processor_init();
116119
}

src/arch/riscv64/kernel/scheduler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::arch::riscv64::mm::paging::{BasePageSize, PageSize, PageTableEntryFla
77
use crate::mm::{FrameAlloc, PageAlloc, PageRangeAllocator};
88
use crate::scheduler::task::{Task, TaskFrame};
99
use crate::scheduler::{PerCoreSchedulerExt, timer_interrupts};
10-
use crate::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};
10+
use crate::config::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};
1111

1212
/// For details, see [RISC-V Calling Conventions].
1313
///

src/arch/riscv64/kernel/start.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use super::{CPU_ONLINE, CURRENT_BOOT_ID, HART_MASK, NUM_CPUS};
88
use crate::arch::riscv64::kernel::CURRENT_STACK_ADDRESS;
99
#[cfg(not(feature = "smp"))]
1010
use crate::arch::riscv64::kernel::processor;
11-
use crate::{KERNEL_STACK_SIZE, env};
11+
use crate::config::KERNEL_STACK_SIZE;
12+
use crate::env;
1213

1314
//static mut BOOT_STACK: [u8; KERNEL_STACK_SIZE] = [0; KERNEL_STACK_SIZE];
1415

0 commit comments

Comments
 (0)