summaryrefslogtreecommitdiff
path: root/kernel/src/io/serial.rs
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2019-11-09 03:12:41 +0100
committerDennis Kobert <dennis@kobert.dev>2019-11-09 03:12:41 +0100
commit1e0422eb84988464836a8f17fd7420b9f3cf277b (patch)
tree2704f35afacf93fdb733ba88f0459f487380a221 /kernel/src/io/serial.rs
parent8602b41f192fec43fde735c9c1f99cd59040f1bb (diff)
Add testing runner functions
Diffstat (limited to 'kernel/src/io/serial.rs')
-rw-r--r--kernel/src/io/serial.rs25
1 files changed, 6 insertions, 19 deletions
diff --git a/kernel/src/io/serial.rs b/kernel/src/io/serial.rs
index eb9377c..3f661e9 100644
--- a/kernel/src/io/serial.rs
+++ b/kernel/src/io/serial.rs
@@ -1,23 +1,15 @@
+use lazy_static::lazy_static;
use spin::Mutex;
use uart_16550::SerialPort;
-/*lazy_static! {
+const SERIAL_IO_PORT: u16 = 0x3F8;
+
+lazy_static! {
pub static ref SERIAL1: Mutex<SerialPort> = {
- let mut serial_port = unsafe { SerialPort::new(0x3F8) };
+ let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) };
serial_port.init();
Mutex::new(serial_port)
};
-}*/
-const SERIAL_IO_PORT: u16 = 0x3F8;
-
-static CONNECTION: Mutex<Serial> = Mutex::new(Serial {
- initialized: false,
- port: unsafe { SerialPort::new(SERIAL_IO_PORT) },
-});
-
-struct Serial {
- pub initialized: bool,
- pub port: SerialPort,
}
pub struct SerialStream {}
@@ -30,11 +22,6 @@ impl SerialStream {
impl core::fmt::Write for SerialStream {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
- let mut guard = CONNECTION.lock();
- if !guard.initialized {
- guard.port.init();
- guard.initialized = true;
- }
- guard.port.write_str(s)
+ SERIAL1.lock().write_str(s)
}
}