Skip to content

Commit

Permalink
Upgrade toolchain channel to nightly-2021-11-01
Browse files Browse the repository at this point in the history
The kernel's target os was removed in rust-lang/rust#90404.
It is only used for x86_64 and not for aarch64.
Adjust filter on __rg_oom since the filter for `target_os = "hermit"` does not
work anymore for the kernel target: rust-lang/rust@bc6b2ac
  • Loading branch information
mkroening committed Dec 4, 2021
1 parent c68c598 commit 578e066
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 71 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2021-10-20"
channel = "nightly-2021-11-01"
components = [
"rust-src",
"llvm-tools-preview",
Expand Down
8 changes: 6 additions & 2 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ pub use crate::arch::x86_64::*;

#[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 = "hermit", feature = "smp"))]
#[cfg(all(
target_arch = "x86_64",
any(target_os = "none", target_os = "hermit"),
feature = "smp"
))]
pub use crate::arch::x86_64::kernel::application_processor_init;
#[cfg(target_arch = "x86_64")]
pub use crate::arch::x86_64::kernel::gdt::set_current_kernel_stack;
Expand All @@ -60,7 +64,7 @@ pub use crate::arch::x86_64::kernel::scheduler;
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 = "hermit"))]
#[cfg(all(target_arch = "x86_64", any(target_os = "none", target_os = "hermit")))]
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::{
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::arch;
#[cfg(feature = "acpi")]
use crate::arch::x86_64::kernel::acpi;
use crate::arch::x86_64::kernel::irq::IrqStatistics;
#[cfg(all(target_os = "hermit", feature = "smp"))]
#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))]
use crate::arch::x86_64::kernel::smp_boot_code::SMP_BOOT_CODE;
use crate::arch::x86_64::kernel::IRQ_COUNTERS;
use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize, PageTableEntryFlags};
Expand Down Expand Up @@ -568,7 +568,7 @@ extern "C" {
/// This algorithm is derived from Intel MultiProcessor Specification 1.4, B.4, but testing has shown
/// that a second STARTUP IPI and setting the BIOS Reset Vector are no longer necessary.
/// This is partly confirmed by https://wiki.osdev.org/Symmetric_Multiprocessing
#[cfg(all(target_os = "hermit", feature = "smp"))]
#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))]
pub fn boot_application_processors() {
// We shouldn't have any problems fitting the boot code into a single page, but let's better be sure.
assert!(
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn disable() {
/// were not activated before calling this function.
#[inline]
pub fn nested_disable() -> bool {
cfg!(target_os = "hermit") && {
cfg!(any(target_os = "none", target_os = "hermit")) && {
let ret = rflags::read().contains(RFlags::FLAGS_IF);
disable();
ret
Expand Down
25 changes: 14 additions & 11 deletions src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ impl BootInfo {
}

/// Kernel header to announce machine features
#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
static mut BOOT_INFO: *mut BootInfo = ptr::null_mut();

#[cfg(all(target_os = "hermit", not(feature = "newlib")))]
#[cfg(all(any(target_os = "none", target_os = "hermit"), not(feature = "newlib")))]
#[link_section = ".data"]
static mut BOOT_INFO: *mut BootInfo = ptr::null_mut();

#[cfg(all(target_os = "hermit", feature = "newlib"))]
#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "newlib"))]
#[link_section = ".mboot"]
static mut BOOT_INFO: *mut BootInfo = ptr::null_mut();

Expand Down Expand Up @@ -298,7 +298,10 @@ pub fn message_output_init() {
}
}

#[cfg(all(not(target_os = "hermit"), not(target_os = "windows")))]
#[cfg(all(
not(any(target_os = "none", target_os = "hermit")),
not(target_os = "windows")
))]
pub fn output_message_byte(byte: u8) {
extern "C" {
fn write(fd: i32, buf: *const u8, count: usize) -> isize;
Expand All @@ -320,7 +323,7 @@ pub fn output_message_byte(byte: u8) {
}
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn test_output() {
output_message_byte('t' as u8);
Expand All @@ -330,7 +333,7 @@ fn test_output() {
output_message_byte('\n' as u8);
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
pub fn output_message_byte(byte: u8) {
if environment::is_single_kernel() {
// Output messages to the serial port and VGA screen in unikernel mode.
Expand All @@ -348,15 +351,15 @@ pub fn output_message_byte(byte: u8) {
}
}

//#[cfg(target_os = "hermit")]
//#[cfg(any(target_os = "none", target_os = "hermit"))]
pub fn output_message_buf(buf: &[u8]) {
for byte in buf {
output_message_byte(*byte);
}
}

/// Real Boot Processor initialization as soon as we have put the first Welcome message on the screen.
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
pub fn boot_processor_init() {
processor::detect_features();
processor::configure();
Expand Down Expand Up @@ -403,15 +406,15 @@ pub fn boot_processor_init() {

/// Boots all available Application Processors on bare-metal or QEMU.
/// Called after the Boot Processor has been fully initialized along with its scheduler.
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
pub fn boot_application_processors() {
#[cfg(feature = "smp")]
apic::boot_application_processors();
apic::print_information();
}

/// Application Processor initialization
#[cfg(all(target_os = "hermit", feature = "smp"))]
#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))]
pub fn application_processor_init() {
percore::init();
processor::configure();
Expand Down Expand Up @@ -466,7 +469,7 @@ pub fn print_statistics() {
}
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
#[inline(never)]
#[no_mangle]
unsafe fn pre_init(boot_info: &'static mut BootInfo) -> ! {
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/percore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ impl<T: Is32BitVariable> PerCoreVariableMethods<T> for PerCoreVariable<T> {
}
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
#[inline]
pub fn core_id() -> CoreId {
unsafe { PERCORE.core_id.get() }
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
pub fn core_id() -> CoreId {
0
}
Expand Down
6 changes: 3 additions & 3 deletions src/arch/x86_64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ impl CpuFrequency {
pic::eoi(pit::PIT_INTERRUPT_NUMBER);
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
fn measure_frequency(&mut self) -> Result<(), ()> {
// return just Ok because the real implementation must run in ring 0
self.source = CpuFrequencySources::Measurement;
Ok(())
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
fn measure_frequency(&mut self) -> Result<(), ()> {
// The PIC is not initialized for uhyve, so we cannot measure anything.
if environment::is_uhyve() {
Expand Down Expand Up @@ -865,7 +865,7 @@ pub fn print_information() {
infofooter!();
}

/*#[cfg(not(target_os = "hermit"))]
/*#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn print_cpu_information() {
::logging::init();
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ impl Clone for TaskTLS {
}
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize, _user_stack: u64) -> ! {
unimplemented!()
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
#[naked]
extern "C" fn task_start(_f: extern "C" fn(usize), _arg: usize, _user_stack: u64) -> ! {
// `f` is in the `rdi` register
Expand Down
2 changes: 1 addition & 1 deletion src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Console {

pub static CONSOLE: SpinlockIrqSave<Console> = SpinlockIrqSave::new(Console(()));

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn test_console() {
println!("HelloWorld");
Expand Down
38 changes: 22 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@
#![feature(llvm_asm)]
#![feature(global_asm)]
#![no_std]
#![cfg_attr(target_os = "hermit", feature(custom_test_frameworks))]
#![cfg_attr(target_os = "hermit", cfg_attr(test, test_runner(crate::test_runner)))]
#![cfg_attr(
target_os = "hermit",
any(target_os = "none", target_os = "hermit"),
feature(custom_test_frameworks)
)]
#![cfg_attr(
any(target_os = "none", target_os = "hermit"),
cfg_attr(test, test_runner(crate::test_runner))
)]
#![cfg_attr(
any(target_os = "none", target_os = "hermit"),
cfg_attr(test, reexport_test_harness_main = "test_main")
)]
#![cfg_attr(target_os = "hermit", cfg_attr(test, no_main))]
#![cfg_attr(any(target_os = "none", target_os = "hermit"), cfg_attr(test, no_main))]

// EXTERNAL CRATES
#[macro_use]
Expand All @@ -47,7 +53,7 @@ extern crate bitflags;
extern crate log;
#[macro_use]
extern crate num_derive;
#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[macro_use]
extern crate std;
#[cfg(target_arch = "aarch64")]
Expand Down Expand Up @@ -88,7 +94,7 @@ mod errno;
mod ffi;
mod kernel_message_buffer;
mod mm;
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
mod runtime_glue;
mod scheduler;
mod synch;
Expand All @@ -102,7 +108,7 @@ pub fn _print(args: ::core::fmt::Arguments<'_>) {
}

#[cfg(test)]
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
#[no_mangle]
extern "C" fn runtime_entry(_argc: i32, _argv: *const *const u8, _env: *const *const u8) -> ! {
println!("Executing hermit unittests. Any arguments are dropped");
Expand All @@ -120,14 +126,14 @@ pub fn test_runner(tests: &[&dyn Fn()]) {
sys_exit(0);
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
#[test_case]
fn trivial_test() {
println!("Test test test");
panic!("Test called");
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();

Expand All @@ -137,7 +143,7 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty();
/// Returning a null pointer indicates that either memory is exhausted or
/// `size` and `align` do not meet this allocator's size or alignment constraints.
///
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 {
let layout_res = Layout::from_size_align(size, align);
if layout_res.is_err() || size == 0 {
Expand Down Expand Up @@ -179,7 +185,7 @@ pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 {
/// # Errors
/// Returns null if the new layout does not meet the size and alignment constraints of the
/// allocator, or if reallocation otherwise fails.
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
pub extern "C" fn __sys_realloc(
ptr: *mut u8,
size: usize,
Expand Down Expand Up @@ -224,7 +230,7 @@ pub extern "C" fn __sys_realloc(
///
/// # Errors
/// May panic if debug assertions are enabled and invalid parameters `size` or `align` where passed.
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) {
unsafe {
let layout_res = Layout::from_size_align(size, align);
Expand All @@ -247,7 +253,7 @@ pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) {
}
}

#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
extern "C" {
static mut __bss_start: usize;
}
Expand All @@ -259,7 +265,7 @@ fn has_ipdevice() -> bool {
}

/// Entry point of a kernel thread, which initialize the libos
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
extern "C" fn initd(_arg: usize) {
extern "C" {
#[cfg(not(test))]
Expand Down Expand Up @@ -319,7 +325,7 @@ fn synch_all_cores() {
}

/// Entry Point of HermitCore for the Boot Processor
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
fn boot_processor_main() -> ! {
// Initialize the kernel and hardware.
arch::message_output_init();
Expand Down Expand Up @@ -372,7 +378,7 @@ fn boot_processor_main() -> ! {
}

/// Entry Point of HermitCore for an Application Processor
#[cfg(all(target_os = "hermit", feature = "smp"))]
#[cfg(all(any(target_os = "none", target_os = "hermit"), feature = "smp"))]
fn application_processor_main() -> ! {
arch::application_processor_init();
scheduler::add_current_core();
Expand Down
4 changes: 2 additions & 2 deletions src/mm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pub struct Heap {
index: usize,
bottom: usize,
size: usize,
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "none", target_os = "hermit"))]
holes: HoleList,
#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
pub holes: HoleList,
}

Expand Down
6 changes: 3 additions & 3 deletions src/mm/freelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl FreeList {
}
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn add_element() {
let mut freelist = FreeList::new();
Expand All @@ -208,7 +208,7 @@ fn add_element() {
}
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn allocate() {
let mut freelist = FreeList::new();
Expand Down Expand Up @@ -241,7 +241,7 @@ fn allocate() {
}
}

#[cfg(not(target_os = "hermit"))]
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn deallocate() {
let mut freelist = FreeList::new();
Expand Down
Loading

0 comments on commit 578e066

Please sign in to comment.