diff --git a/crate/bcm2837/src/gpio.rs b/crate/bcm2837/src/gpio.rs index aa2f9ef..4465303 100644 --- a/crate/bcm2837/src/gpio.rs +++ b/crate/bcm2837/src/gpio.rs @@ -116,8 +116,12 @@ impl Gpio { /// Enables the alternative function `function` for `self`. Consumes self /// and returns a `Gpio` structure in the `Alt` state. pub fn into_alt(self, function: Function) -> Gpio { - self.registers.FSEL[(self.pin / 10) as usize] - .write((function as u32) << (3 * (self.pin % 10))); + let select = (self.pin / 10) as usize; + let offset = 3 * (self.pin % 10) as usize; + let mut value = self.registers.FSEL[select].read(); + value &= !(0b111 << offset); + value |= (function as u32) << offset; + self.registers.FSEL[select].write(value); self.transition() } diff --git a/kernel/src/arch/aarch64/board/raspi3/mod.rs b/kernel/src/arch/aarch64/board/raspi3/mod.rs index bdd0b21..3ff2324 100644 --- a/kernel/src/arch/aarch64/board/raspi3/mod.rs +++ b/kernel/src/arch/aarch64/board/raspi3/mod.rs @@ -5,9 +5,12 @@ extern crate bcm2837; pub mod serial; pub fn init() { - assert_has_not_been_called!("board::init must be called only once"); + // FIXME + // assert_has_not_been_called!("board::init must be called only once"); - serial::SERIAL_PORT.lock().init(); + unsafe { + serial::SERIAL_PORT.init(); + } println!("Hello Raspberry Pi!"); } diff --git a/kernel/src/arch/aarch64/board/raspi3/serial.rs b/kernel/src/arch/aarch64/board/raspi3/serial.rs index b6c29f7..5434071 100644 --- a/kernel/src/arch/aarch64/board/raspi3/serial.rs +++ b/kernel/src/arch/aarch64/board/raspi3/serial.rs @@ -20,7 +20,8 @@ impl SerialPort { /// Init a newly created SerialPort, can only be called once. pub fn init(&mut self) { - assert_has_not_been_called!("SerialPort::init must be called only once"); + // FIXME + // assert_has_not_been_called!("SerialPort::init must be called only once"); self.mu = Some(MiniUart::new()); } @@ -70,4 +71,7 @@ impl fmt::Write for SerialPort { } } -pub static SERIAL_PORT: Mutex = Mutex::new(SerialPort::new()); +// FIXME +// pub static SERIAL_PORT: Mutex = Mutex::new(SerialPort::new()); +pub static mut SERIAL_PORT: SerialPort = SerialPort::new(); + diff --git a/kernel/src/arch/aarch64/io.rs b/kernel/src/arch/aarch64/io.rs index 5e5a645..deda39c 100644 --- a/kernel/src/arch/aarch64/io.rs +++ b/kernel/src/arch/aarch64/io.rs @@ -4,9 +4,15 @@ use core::fmt::{Arguments, Write}; use super::board::serial::{SerialRead, SERIAL_PORT}; pub fn getchar() -> char { - SERIAL_PORT.lock().receive() as char + // FIXME + unsafe { + SERIAL_PORT.receive() as char + } } pub fn putfmt(fmt: Arguments) { - SERIAL_PORT.lock().write_fmt(fmt).unwrap() + // FIXME + unsafe { + SERIAL_PORT.write_fmt(fmt).unwrap() + } } diff --git a/kernel/src/arch/aarch64/mod.rs b/kernel/src/arch/aarch64/mod.rs index ac14adb..f668a25 100644 --- a/kernel/src/arch/aarch64/mod.rs +++ b/kernel/src/arch/aarch64/mod.rs @@ -17,7 +17,8 @@ pub extern "C" fn rust_main() -> ! { board::init(); // First init log mod, so that we can print log info. - ::logging::init(); + // FIXME + // ::logging::init(); super::fs::show_logo();