From 861073d07b0fd70c5017fa96aa67dd7df4de9443 Mon Sep 17 00:00:00 2001 From: NatrixAeria Date: Mon, 22 Mar 2021 20:36:15 +0100 Subject: Refresh rust version --- kernel/.cargo/config | 4 ++++ kernel/Cargo.toml | 10 +--------- kernel/run | 2 +- kernel/shell.nix | 2 +- kernel/src/interrupts/apic.rs | 8 ++------ kernel/src/interrupts/exception_handlers.rs | 2 +- kernel/src/interrupts/idt.rs | 2 +- kernel/src/io/qemu.rs | 3 ++- kernel/src/main.rs | 6 +++--- kernel/tests/boot.rs | 1 - kernel/tests/int3.rs | 1 - kernel/tests/stack_overflow.rs | 1 - kernel/x86_64-uff.json | 2 +- 13 files changed, 17 insertions(+), 27 deletions(-) diff --git a/kernel/.cargo/config b/kernel/.cargo/config index 992b819..f1e8621 100644 --- a/kernel/.cargo/config +++ b/kernel/.cargo/config @@ -1,3 +1,7 @@ +[unstable] +build-std = ["core", "compiler_builtins", "alloc"] +build-std-features = ["compiler-builtins-mem"] + [build] target = "x86_64-uff.json" rustflags = ["-Clink-arg=-r","-Clink-dead-code"] diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 75f5503..bce79cb 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -16,19 +16,11 @@ harness = false [features] testing_qemu = [] -[package.metadata.cargo-xbuild] -sysroot_path = "target/sysroot" - [dependencies] -x86_64 = "0.7.5" +x86_64 = "0.13" uart_16550 = "0.2.1" spin = "0.5" [dependencies.lazy_static] version = "1.4.0" features = ["spin_no_std"] - -[dependencies.compiler_builtins] -version = "0.1.19" -git = "https://github.com/rust-lang/compiler-builtins" -features = ["mem"] diff --git a/kernel/run b/kernel/run index 3420ac1..85c4b7a 100755 --- a/kernel/run +++ b/kernel/run @@ -17,7 +17,7 @@ function define_vars() { target_name="$target-$name" target_path="target/" rust_target_path="$target_path/$target_name/$build_mode/" - kernel_libary="$rust_target_path/libkernel.a" + kernel_libary="$rust_target_path/kernel" iso_path="$target_path/iso/" obj_path="$iso_path/obj/" src_path="src/" diff --git a/kernel/shell.nix b/kernel/shell.nix index e57790f..8e4079b 100644 --- a/kernel/shell.nix +++ b/kernel/shell.nix @@ -4,7 +4,7 @@ with import (fetchTarball { }) { }; mkShell { name = "uff-os"; - buildInputs = [ rustup nasm grub2 cargo-xbuild gcc xorriso ]; + buildInputs = [ rustup nasm grub2 gcc xorriso ]; shellHook = '' export GRUB_i386="${grub2}/lib/grub/i386-pc" ''; diff --git a/kernel/src/interrupts/apic.rs b/kernel/src/interrupts/apic.rs index 93fba8b..2761fb9 100644 --- a/kernel/src/interrupts/apic.rs +++ b/kernel/src/interrupts/apic.rs @@ -11,17 +11,13 @@ const APIC_SW_ENABLE: u32 = 0x0000_0100; pub fn is_x2apic() -> bool { let info: u32; - unsafe { - asm!("cpuid" : "={ecx}" (info) : "{eax}" (1) : "memory"); - } + unsafe { asm!("cpuid", inout("eax") 1 => _, out("ecx") info) } info & (1 << 21) != 0 } pub fn is_apic() -> bool { let info: u32; - unsafe { - asm!("cpuid" : "={edx}" (info) : "{eax}" (1) : "memory"); - } + unsafe { asm!("cpuid", inout("eax") 1 => _, out("edx") info) } info & (1 << 9) != 0 } diff --git a/kernel/src/interrupts/exception_handlers.rs b/kernel/src/interrupts/exception_handlers.rs index ef67eff..c689501 100644 --- a/kernel/src/interrupts/exception_handlers.rs +++ b/kernel/src/interrupts/exception_handlers.rs @@ -94,7 +94,7 @@ pub extern "x86-interrupt" fn segment_not_present_handler( pub extern "x86-interrupt" fn double_fault_handler( stack_frame: &mut InterruptStackFrame, _error_code: u64, // code is always zero -) { +) -> ! { match get_expected_fault() { InterruptType::DoubleFault => qemu::exit_qemu(qemu::QemuExitCode::Success), _ => panic!( diff --git a/kernel/src/interrupts/idt.rs b/kernel/src/interrupts/idt.rs index c901916..641e44e 100644 --- a/kernel/src/interrupts/idt.rs +++ b/kernel/src/interrupts/idt.rs @@ -11,7 +11,7 @@ lazy_static! { idt.breakpoint .set_handler_fn(exception_handlers::breakpoint_handler); - idt.divide_by_zero + idt.divide_error .set_handler_fn(exception_handlers::div_zero_handler); idt.segment_not_present .set_handler_fn(exception_handlers::segment_not_present_handler); diff --git a/kernel/src/io/qemu.rs b/kernel/src/io/qemu.rs index 8b01885..cf673da 100644 --- a/kernel/src/io/qemu.rs +++ b/kernel/src/io/qemu.rs @@ -5,11 +5,12 @@ pub enum QemuExitCode { Failed = 0x11, } -pub fn exit_qemu(exit_code: QemuExitCode) { +pub fn exit_qemu(exit_code: QemuExitCode) -> ! { use x86_64::instructions::port::Port; unsafe { let mut port = Port::new(0xf4); port.write(exit_code as u32); + unreachable!("qemu should have quitted") } } diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 8b21eef..50b281f 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -10,17 +10,17 @@ pub mod interrupts; pub mod io; pub mod testing; -use core::fmt::Write; pub use io::qemu::{exit_qemu, QemuExitCode}; pub use io::vga_text::OStream; pub use io::{qemu, serial, vga_text}; #[no_mangle] extern "C" fn _start() -> ! { - kernel::init(); + interrupts::gdt::init(); + interrupts::idt::init(); let apic = interrupts::apic::Apic::new().expect("no APIC support"); - let mut apic = unsafe { interrupts::apic::set_local_apic(apic) }; + let apic = unsafe { interrupts::apic::set_local_apic(apic) }; apic.set_timer_interrupt_handler( interrupts::apic::TimerDivideConfig::Div16, diff --git a/kernel/tests/boot.rs b/kernel/tests/boot.rs index 534199a..3a65ff6 100644 --- a/kernel/tests/boot.rs +++ b/kernel/tests/boot.rs @@ -1,5 +1,4 @@ #![no_main] -#![feature(compiler_builtins_lib)] #![feature(custom_test_frameworks)] #![feature(abi_x86_interrupt)] #![feature(panic_info_message)] diff --git a/kernel/tests/int3.rs b/kernel/tests/int3.rs index d068b9e..faa5b3d 100644 --- a/kernel/tests/int3.rs +++ b/kernel/tests/int3.rs @@ -1,5 +1,4 @@ #![no_main] -#![feature(compiler_builtins_lib)] #![feature(abi_x86_interrupt)] #![feature(panic_info_message)] #![no_std] diff --git a/kernel/tests/stack_overflow.rs b/kernel/tests/stack_overflow.rs index cff28e0..fc93376 100644 --- a/kernel/tests/stack_overflow.rs +++ b/kernel/tests/stack_overflow.rs @@ -1,5 +1,4 @@ #![no_main] -#![feature(compiler_builtins_lib)] #![feature(abi_x86_interrupt)] #![feature(panic_info_message)] #![no_std] diff --git a/kernel/x86_64-uff.json b/kernel/x86_64-uff.json index 7d2110d..5fdbf5d 100644 --- a/kernel/x86_64-uff.json +++ b/kernel/x86_64-uff.json @@ -11,5 +11,5 @@ "linker": "rust-lld", "panic-strategy": "abort", "disable-redzone": true, - "features": "-mmx,-sse,+soft-float" + "features": "-mmx,+sse,-soft-float" } -- cgit v1.2.3-70-g09d2