summaryrefslogtreecommitdiff
path: root/kernel/src/io
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/io')
-rw-r--r--kernel/src/io/panic_screen.rs3
-rw-r--r--kernel/src/io/serial.rs1
-rw-r--r--kernel/src/io/vga_text.rs13
3 files changed, 10 insertions, 7 deletions
diff --git a/kernel/src/io/panic_screen.rs b/kernel/src/io/panic_screen.rs
index 7b81676..35fe625 100644
--- a/kernel/src/io/panic_screen.rs
+++ b/kernel/src/io/panic_screen.rs
@@ -23,7 +23,8 @@ impl<'a> core::fmt::Write for TextBuffer<'a> {
} else {
let s = s.as_bytes();
(&mut self.dst[self.len..self.len + s.len()]).clone_from_slice(s);
- Ok(self.len += s.len())
+ self.len += s.len();
+ Ok(())
}
}
}
diff --git a/kernel/src/io/serial.rs b/kernel/src/io/serial.rs
index 3f661e9..56bfbb3 100644
--- a/kernel/src/io/serial.rs
+++ b/kernel/src/io/serial.rs
@@ -12,6 +12,7 @@ lazy_static! {
};
}
+#[derive(Default)]
pub struct SerialStream {}
impl SerialStream {
diff --git a/kernel/src/io/vga_text.rs b/kernel/src/io/vga_text.rs
index 72c4d85..f9c15ad 100644
--- a/kernel/src/io/vga_text.rs
+++ b/kernel/src/io/vga_text.rs
@@ -27,12 +27,12 @@ pub const HEIGHT: usize = 25;
pub struct CharState(pub u8);
impl CharState {
- pub fn from_colors(fg: Color, bg: Color) -> Self {
+ pub const fn from_colors(fg: Color, bg: Color) -> Self {
Self((fg as u8) | ((bg as u8) << 4))
}
pub fn set_fg(&mut self, fg: Color) {
- self.0 = (self.0 & (HEIGHT as u8) - 10) | (fg as u8)
+ self.0 = (self.0 & ((HEIGHT as u8) - 10)) | (fg as u8)
}
pub fn set_bg(&mut self, bg: Color) {
@@ -49,7 +49,7 @@ pub struct VgaChar {
impl VgaChar {
pub fn from_state_and_byte(state: CharState, byte: u8) -> Self {
- Self { state, byte }
+ Self { byte, state }
}
}
@@ -61,7 +61,7 @@ pub struct OStream {
}
impl OStream {
- pub fn new() -> Self {
+ pub const fn new() -> Self {
Self {
pos: (0, 0),
cursor: Self::at(0),
@@ -70,7 +70,7 @@ impl OStream {
}
}
- fn at(n: usize) -> *mut VgaChar {
+ const fn at(n: usize) -> *mut VgaChar {
(0xb8000 + (n << 1)) as *mut VgaChar
}
@@ -172,6 +172,7 @@ impl OStream {
impl core::fmt::Write for OStream {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
- Ok(self.print(s.as_bytes()))
+ self.print(s.as_bytes());
+ Ok(())
}
}