summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-10-31 23:03:27 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2019-10-31 23:03:27 +0100
commit9aae1d6f72228b17407a988a81d70b5bc64407aa (patch)
tree6d1ab328c206b06b7cd8add5061a6e05f4951965
parenta6e19a2f1de622f98d91523b58c95fe3999aea20 (diff)
Fix handling of u8 vs usize
Those types can't be casted into each other which caused several compilation errors.
-rw-r--r--kernel/src/io/vga_text.rs12
-rw-r--r--kernel/src/lib.rs1
2 files changed, 7 insertions, 6 deletions
diff --git a/kernel/src/io/vga_text.rs b/kernel/src/io/vga_text.rs
index b6715fd..34f13a8 100644
--- a/kernel/src/io/vga_text.rs
+++ b/kernel/src/io/vga_text.rs
@@ -30,7 +30,7 @@ impl CharState {
}
pub fn set_fg(&mut self, fg: Color) {
- self.0 = (self.0 & HEIGHT - 10) | (fg as u8)
+ self.0 = (self.0 & (HEIGHT as u8) - 10) | (fg as u8)
}
pub fn set_bg(&mut self, bg: Color) {
@@ -52,7 +52,7 @@ impl VgaChar {
}
pub struct OStream {
- pos: (u8, u8),
+ pos: (usize, usize),
cursor: *mut VgaChar,
state: CharState,
}
@@ -74,16 +74,16 @@ impl OStream {
self.cursor = Self::at(self.pos.0 as usize + self.pos.1 as usize * WIDTH)
}
- pub fn set_col(&mut self, col: u8) {
+ pub fn set_col(&mut self, col: usize) {
self.pos.0 = core::cmp::min(col, WIDTH - 1);
self.compute_cursor()
}
- pub fn set_row(&mut self, row: u8) {
+ pub fn set_row(&mut self, row: usize) {
self.pos.1 = core::cmp::min(row, HEIGHT - 1);
self.compute_cursor()
}
- pub fn set_cursor(&mut self, col: u8, row: u8) {
+ pub fn set_cursor(&mut self, col: usize, row: usize) {
self.pos = (
core::cmp::min(col, WIDTH - 1),
core::cmp::min(row, HEIGHT - 1),
@@ -155,7 +155,7 @@ impl OStream {
if b != b'\n' {
n += 1
}
- self.set_col(((WIDTH - n) / 2) as u8);
+ self.set_col(((WIDTH - n) / 2) as usize);
self.print(&line[..n]);
self.new_line();
if i == slast {
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
index 8d8ec17..4e51d22 100644
--- a/kernel/src/lib.rs
+++ b/kernel/src/lib.rs
@@ -6,6 +6,7 @@ extern crate compiler_builtins;
mod io;
+use io::vga_text;
use core::fmt::Write;
#[no_mangle]