-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #948 from mkroening/cfg-if
refactor: use cfg-if for arch module
- Loading branch information
Showing
5 changed files
with
88 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
pub mod kernel; | ||
pub mod mm; | ||
|
||
/// Force strict CPU ordering, serializes load and store operations. | ||
#[allow(dead_code)] | ||
#[inline(always)] | ||
pub(crate) fn memory_barrier() { | ||
use core::arch::asm; | ||
unsafe { | ||
asm!("dmb ish", options(nostack, nomem, preserves_flags),); | ||
} | ||
} | ||
|
||
pub fn init_drivers() { | ||
// Initialize PCI Drivers | ||
#[cfg(feature = "pci")] | ||
crate::drivers::pci::init_drivers(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,57 @@ | ||
// Platform-specific implementations | ||
#[cfg(target_arch = "aarch64")] | ||
pub mod aarch64; | ||
//! Architecture-specific architecture abstraction. | ||
|
||
#[cfg(target_arch = "x86_64")] | ||
pub mod x86_64; | ||
cfg_if::cfg_if! { | ||
if #[cfg(target_arch = "aarch64")] { | ||
pub mod aarch64; | ||
pub use self::aarch64::*; | ||
|
||
// Export our platform-specific modules. | ||
#[cfg(all(target_arch = "aarch64", target_os = "none"))] | ||
pub use crate::arch::aarch64::kernel::boot_processor_init; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::core_local; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::interrupts; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::interrupts::wakeup_core; | ||
#[cfg(all(target_arch = "aarch64", feature = "pci"))] | ||
pub use crate::arch::aarch64::kernel::pci; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::processor; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::processor::set_oneshot_timer; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::scheduler; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::switch; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::systemtime::get_boot_time; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::kernel::{ | ||
application_processor_init, boot_application_processors, get_processor_count, | ||
message_output_init, output_message_buf, | ||
}; | ||
#[cfg(target_arch = "aarch64")] | ||
pub use crate::arch::aarch64::*; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::apic::{set_oneshot_timer, wakeup_core}; | ||
#[cfg(all(target_arch = "x86_64", target_os = "none", feature = "smp"))] | ||
pub use crate::arch::x86_64::kernel::application_processor_init; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::core_local; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::gdt::set_current_kernel_stack; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::interrupts; | ||
#[cfg(all(target_arch = "x86_64", feature = "pci"))] | ||
pub use crate::arch::x86_64::kernel::pci; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::processor; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::scheduler; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::switch; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::systemtime::get_boot_time; | ||
#[cfg(all(target_arch = "x86_64", target_os = "none"))] | ||
pub use crate::arch::x86_64::kernel::{boot_application_processors, boot_processor_init}; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::kernel::{ | ||
get_processor_count, message_output_init, output_message_buf, | ||
}; | ||
#[cfg(target_arch = "x86_64")] | ||
pub use crate::arch::x86_64::*; | ||
#[cfg(target_os = "none")] | ||
pub use self::aarch64::kernel::boot_processor_init; | ||
pub use self::aarch64::kernel::core_local; | ||
pub use self::aarch64::kernel::interrupts; | ||
pub use self::aarch64::kernel::interrupts::wakeup_core; | ||
#[cfg(feature = "pci")] | ||
pub use self::aarch64::kernel::pci; | ||
pub use self::aarch64::kernel::processor; | ||
pub use self::aarch64::kernel::processor::set_oneshot_timer; | ||
pub use self::aarch64::kernel::scheduler; | ||
pub use self::aarch64::kernel::switch; | ||
pub use self::aarch64::kernel::systemtime::get_boot_time; | ||
pub use self::aarch64::kernel::{ | ||
application_processor_init, | ||
boot_application_processors, | ||
get_processor_count, | ||
message_output_init, | ||
output_message_buf, | ||
}; | ||
} else if #[cfg(target_arch = "x86_64")] { | ||
pub mod x86_64; | ||
pub use self::x86_64::*; | ||
|
||
/// Force strict CPU ordering, serializes load and store operations. | ||
#[allow(dead_code)] | ||
#[cfg(target_arch = "aarch64")] | ||
#[inline(always)] | ||
pub(crate) fn memory_barrier() { | ||
use core::arch::asm; | ||
unsafe { | ||
asm!("dmb ish", options(nostack, nomem, preserves_flags),); | ||
pub use self::x86_64::kernel::apic::{ | ||
set_oneshot_timer, | ||
wakeup_core, | ||
}; | ||
#[cfg(all(target_os = "none", feature = "smp"))] | ||
pub use self::x86_64::kernel::application_processor_init; | ||
pub use self::x86_64::kernel::core_local; | ||
pub use self::x86_64::kernel::gdt::set_current_kernel_stack; | ||
pub use self::x86_64::kernel::interrupts; | ||
#[cfg(feature = "pci")] | ||
pub use self::x86_64::kernel::pci; | ||
pub use self::x86_64::kernel::processor; | ||
pub use self::x86_64::kernel::scheduler; | ||
pub use self::x86_64::kernel::switch; | ||
pub use self::x86_64::kernel::systemtime::get_boot_time; | ||
#[cfg(target_os = "none")] | ||
pub use self::x86_64::kernel::{ | ||
boot_application_processors, | ||
boot_processor_init, | ||
}; | ||
pub use self::x86_64::kernel::{ | ||
get_processor_count, | ||
message_output_init, | ||
output_message_buf, | ||
}; | ||
} | ||
} | ||
|
||
/// Force strict CPU ordering, serializes load and store operations. | ||
#[allow(dead_code)] | ||
#[cfg(target_arch = "x86_64")] | ||
#[inline(always)] | ||
pub(crate) fn memory_barrier() { | ||
use core::arch::asm; | ||
unsafe { | ||
asm!("mfence", options(nostack, nomem, preserves_flags),); | ||
} | ||
} | ||
|
||
pub fn init_drivers() { | ||
// Initialize PCI Drivers for x86_64 | ||
#[cfg(feature = "pci")] | ||
crate::drivers::pci::init_drivers(); | ||
#[cfg(all( | ||
target_arch = "x86_64", | ||
not(feature = "pci"), | ||
any(feature = "tcp", feature = "udp") | ||
))] | ||
crate::arch::x86_64::kernel::mmio::init_drivers(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
pub mod kernel; | ||
pub mod mm; | ||
|
||
/// Force strict CPU ordering, serializes load and store operations. | ||
#[allow(dead_code)] | ||
#[inline(always)] | ||
pub(crate) fn memory_barrier() { | ||
use core::arch::asm; | ||
unsafe { | ||
asm!("mfence", options(nostack, nomem, preserves_flags),); | ||
} | ||
} | ||
|
||
pub fn init_drivers() { | ||
// Initialize PCI Drivers | ||
#[cfg(feature = "pci")] | ||
crate::drivers::pci::init_drivers(); | ||
#[cfg(all(not(feature = "pci"), any(feature = "tcp", feature = "udp")))] | ||
crate::arch::x86_64::kernel::mmio::init_drivers(); | ||
} |