summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Cunningham <c@localhost>2022-08-23 20:56:57 -0700
committerChristian Cunningham <c@localhost>2022-08-23 20:56:57 -0700
commite83717b454722b8c61844686377c2ac58f18454f (patch)
tree3f243026dd102ccc9117481e795e6d8e938fc39b /src
parent526abb3e5b3175008cb60f78b645d5e2c0f5072a (diff)
Migrate the processor-independent code
Due to the similarity with my ARM-based OS ghOSt, I am migrating similar code out to a common crate Not all has been moved out yet
Diffstat (limited to 'src')
-rw-r--r--src/kernel.rs2
-rw-r--r--src/serial/buffer.rs12
-rw-r--r--src/sync.rs3
-rw-r--r--src/vga/buffer.rs38
4 files changed, 11 insertions, 44 deletions
diff --git a/src/kernel.rs b/src/kernel.rs
index c040a4b..57cc04f 100644
--- a/src/kernel.rs
+++ b/src/kernel.rs
@@ -57,8 +57,6 @@ pub extern "C" fn _start() -> ! {
#[cfg(not(test))]
{
- WRITER.write_string("Hello World!");
- WRITER.write_string("\n\nHi\n");
println!("{}", 5);
}
diff --git a/src/serial/buffer.rs b/src/serial/buffer.rs
index b0f704e..b52728a 100644
--- a/src/serial/buffer.rs
+++ b/src/serial/buffer.rs
@@ -12,13 +12,11 @@ impl Serial {
}
}
-impl NullLock<Serial> {
- pub fn init(&self) {
- self.lock(|serial| {
- let mut serial_port = unsafe { SerialPort::new(0x3F8) };
- serial_port.init();
- serial.buffer = Some(serial_port);
- });
+impl crate::sync::interface::Initializable for Serial {
+ fn init(&mut self) {
+ let mut serial_port = unsafe { SerialPort::new(0x3F8) };
+ serial_port.init();
+ self.buffer = Some(serial_port);
}
}
diff --git a/src/sync.rs b/src/sync.rs
index 5afa620..cb245da 100644
--- a/src/sync.rs
+++ b/src/sync.rs
@@ -1,3 +1,5 @@
+pub use os_pic::sync::*;
+/*
//! # Synchronization module
//!
//! Provides synchronization objects for thread-safe memory sharing.
@@ -63,3 +65,4 @@ impl<T> interface::Mutex for NullLock<T> {
f(data)
}
}
+*/
diff --git a/src/vga/buffer.rs b/src/vga/buffer.rs
index 1ae4ff8..2512123 100644
--- a/src/vga/buffer.rs
+++ b/src/vga/buffer.rs
@@ -86,36 +86,6 @@ impl VgaWriter {
}
}
-impl NullLock<VgaWriter> {
- #[allow(dead_code)]
- pub fn write_byte(&self, byte: u8) {
- self.lock(|writer| {
- writer.write_byte(byte);
- });
- }
-
- #[allow(dead_code)]
- fn new_line(&self) {
- self.lock(|writer| {
- writer.new_line();
- });
- }
-
- #[allow(dead_code)]
- fn clear_row(&self, row: usize) {
- self.lock(|writer| {
- writer.clear_row(row);
- });
- }
-
- #[allow(dead_code)]
- pub fn write_string(&self, s: &str) {
- self.lock(|writer| {
- writer.write_string(s);
- });
- }
-}
-
impl fmt::Write for VgaWriter {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.write_string(s);
@@ -123,11 +93,9 @@ impl fmt::Write for VgaWriter {
}
}
-impl NullLock<VgaWriter> {
- pub fn init(&self) {
- self.lock(|writer| {
- writer.buffer = Some(unsafe { &mut *(0xb8000 as *mut Buffer) });
- })
+impl crate::sync::interface::Initializable for VgaWriter {
+ fn init(&mut self) {
+ self.buffer = Some(unsafe { &mut *(0xb8000 as *mut Buffer) });
}
}