diff --git a/Cargo.toml b/Cargo.toml index a38a82f4..b8b113c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" authors = ["Stefan Lankes "] [dependencies] -spin = "0.4.9" # Spinlocks. +#spin = "0.4.9" # Spinlocks. cortex-a = "2.3.1" register = "0.3.2" r0 = "0.2.2" diff --git a/aarch64-eduos.json b/aarch64-eduos.json index bae91ff1..2646803e 100644 --- a/aarch64-eduos.json +++ b/aarch64-eduos.json @@ -8,7 +8,7 @@ "os": "none", "executables": true, "linker-flavor": "ld.lld", - "linker": "rust-lld", + "linker": "lld-8", "panic-strategy": "abort", "disable-redzone": true, "features": "+a53,+strict-align,-fp-armv8", diff --git a/src/arch/aarch64/boot.S b/src/arch/aarch64/boot.S index 70c308a4..ae14e97f 100644 --- a/src/arch/aarch64/boot.S +++ b/src/arch/aarch64/boot.S @@ -23,6 +23,12 @@ * DEALINGS IN THE SOFTWARE. * */ + +.section ".data" +.global boot_stack +.balign 0x10 +boot_stack: .skip 0x2000 + .section ".text.boot" .global _start @@ -38,7 +44,8 @@ _start: 2: // cpu id == 0 // init 1G stack stack in RAM area (>0x40000000 for qemu virt device) - movz x1, 0x5000, lsl 16 + //movz x1, 0x5000, lsl 16 + ldr x1, =(boot_stack+0x2000-0x10) mov sp, x1 // jump to Rust code, should not return diff --git a/src/arch/aarch64/boot.rs b/src/arch/aarch64/boot.rs index 563800b1..29ccca18 100644 --- a/src/arch/aarch64/boot.rs +++ b/src/arch/aarch64/boot.rs @@ -1,5 +1,3 @@ -#![no_std] - /// Some space for init stuff before calling `main()`. #[no_mangle] pub unsafe extern "C" fn init() -> ! { @@ -14,4 +12,4 @@ pub unsafe extern "C" fn init() -> ! { } // Disable all cores except core 0, and then jump to init() -global_asm!(include_str!("boot.S")); \ No newline at end of file +global_asm!(include_str!("boot.S")); diff --git a/src/arch/aarch64/serial.rs b/src/arch/aarch64/serial.rs index 6a22c367..514c8a52 100644 --- a/src/arch/aarch64/serial.rs +++ b/src/arch/aarch64/serial.rs @@ -1,6 +1,5 @@ use core::fmt; -use spin::Mutex; -use aarch64::io::*; +use core::ptr::write_volatile; /// A COM serial port. pub struct ComPort { @@ -23,11 +22,11 @@ impl fmt::Write for ComPort { // Output each byte of our string. for &b in s.as_bytes() { // Write our byte. - write_byte(self.port_address, b); + unsafe { write_volatile(self.port_address as *mut u8, b); } } Ok(()) } } /// Our primary serial port. -pub static COM1: Mutex = Mutex::new(ComPort::new(0x09000000)); +pub static mut COM1: ComPort = ComPort::new(0x800 /*0x09000000*/); diff --git a/src/arch/x86_64/serial.rs b/src/arch/x86_64/serial.rs index de811a30..6e0123f7 100644 --- a/src/arch/x86_64/serial.rs +++ b/src/arch/x86_64/serial.rs @@ -1,5 +1,4 @@ use core::fmt; -use spin::Mutex; use x86::io::*; /// A COM serial port. @@ -32,4 +31,4 @@ impl fmt::Write for ComPort { } /// Our primary serial port. -pub static COM1: Mutex = Mutex::new(ComPort::new(0x3F8)); +pub static mut COM1: ComPort = ComPort::new(0x3F8); diff --git a/src/console.rs b/src/console.rs index 2961c84e..dcd14989 100644 --- a/src/console.rs +++ b/src/console.rs @@ -1,7 +1,6 @@ //! A wrapper around our serial console. use core::fmt; -use spin::Mutex; use arch::serial; pub struct Console; @@ -9,8 +8,6 @@ pub struct Console; impl fmt::Write for Console { /// Output a string to each of our console outputs. fn write_str(&mut self, s: &str) -> fmt::Result { - serial::COM1.lock().write_str(s) + unsafe { serial::COM1.write_str(s) } } } - -pub static CONSOLE: Mutex = Mutex::new(Console); diff --git a/src/lib.rs b/src/lib.rs index fac91c20..03b7608b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![feature(asm, const_fn, lang_items, global_asm)] #![no_std] -extern crate spin; +//extern crate spin; #[cfg(target_arch = "x86_64")] extern crate x86; diff --git a/src/macros.rs b/src/macros.rs index baf45ab8..ac472cbf 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -6,7 +6,8 @@ macro_rules! print { ($($arg:tt)*) => ({ use core::fmt::Write; - $crate::console::CONSOLE.lock().write_fmt(format_args!($($arg)*)).unwrap(); + let mut console: $crate::console::Console = $crate::console::Console{}; + console.write_fmt(format_args!($($arg)*)).unwrap(); }); } diff --git a/src/main.rs b/src/main.rs index 6d78aaef..f6b18d90 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ extern crate eduos_rs; use core::panic::PanicInfo; -use core::ptr; +// use core::ptr; // use eduos_rs::arch::processor::shutdown; /// This is the main function called by `init()` function from boot.rs