diff options
Diffstat (limited to 'kernel/src/io/vga_text.rs')
-rw-r--r-- | kernel/src/io/vga_text.rs | 13 |
1 files changed, 7 insertions, 6 deletions
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(()) } } |