feat: misc
Nicer kernel, now can fetch multiboot2 boot info
This commit is contained in:
@@ -54,7 +54,7 @@ impl<M: TextMode> VgaBuffer<M> {
|
||||
where
|
||||
[[(u8, u8); M::WIDTH as usize]; M::HEIGHT as usize]:,
|
||||
{
|
||||
unsafe { core::mem::transmute(Self::VGA_ADDR) }
|
||||
unsafe { &mut *Self::VGA_ADDR.cast() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use core::fmt::Write;
|
||||
|
||||
use crate::vga::{ColorNibble, TextMode, VgaBuffer, VgaColor};
|
||||
|
||||
pub struct Writer<M: TextMode> {
|
||||
@@ -52,6 +54,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_n(&mut self, n: u32) {
|
||||
const BASE: u32 = 10;
|
||||
|
||||
if n == 0 {
|
||||
// TODO: print a 0 if no recursion in the future
|
||||
} else {
|
||||
let digit = (n % BASE) as u8;
|
||||
self.print_n(n / 10);
|
||||
self.write(&[b'0' + digit]);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write(&mut self, data: &[u8]) {
|
||||
const BAD_CHAR_COL: VgaColor = VgaColor::new(ColorNibble::WHITE, ColorNibble::RED);
|
||||
|
||||
@@ -94,3 +108,13 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: TextMode> Write for Writer<M>
|
||||
where
|
||||
[[(u8, u8); M::WIDTH as usize]; M::HEIGHT as usize]:,
|
||||
{
|
||||
fn write_str(&mut self, s: &str) -> core::fmt::Result {
|
||||
self.write(s.as_bytes());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user