diff --git a/README-pl.md b/README-pl.md index 4536baf..ac0fcc4 100644 --- a/README-pl.md +++ b/README-pl.md @@ -29,7 +29,7 @@ x86_64 System Operacyjny (kernel) zrobiony od zera w Assembly & Rust ## Budowa ze źródła na Linuxie ### Główny Kernel **Wymagania:** - - System kontroli wersji[Git] (https://git-scm.com) + - System kontroli wersji [Git](https://git-scm.com) - [Rust toolchain](https://www.rust-lang.org/tools/install) **Kroki:** diff --git a/kernel/src/cmd/mod.rs b/kernel/src/cmd/mod.rs index 5b38009..5989a50 100644 --- a/kernel/src/cmd/mod.rs +++ b/kernel/src/cmd/mod.rs @@ -44,8 +44,7 @@ fn cc(_args: Vec<&str>) -> i32 { This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + the Free Software Foundation,version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/kernel/src/vga_buffer.rs b/kernel/src/vga_buffer.rs index c85cd98..ea0ffc1 100644 --- a/kernel/src/vga_buffer.rs +++ b/kernel/src/vga_buffer.rs @@ -132,6 +132,22 @@ pub struct Writer { } impl Writer { + fn update_cursor(&mut self) { + let pos = (BUFFER_HEIGHT - 1) * BUFFER_WIDTH + self.column_position; + unsafe { + let mut port = x86_64::instructions::port::Port::new(0x3D4); + port.write(0x0F_u8); + let mut data_port = x86_64::instructions::port::Port::new(0x3D5); + data_port.write((pos & 0xFF) as u8); + port.write(0x0E_u8); + data_port.write(((pos >> 8) & 0xFF) as u8); + } + self.buffer.chars[BUFFER_HEIGHT - 1][self.column_position].write(ScreenChar { + ascii_character: b' ', + color_code: self.color_code, + }); + } + pub fn write_byte(&mut self, byte: u8) { match byte { b'\n' => self.new_line(), @@ -149,6 +165,10 @@ impl Writer { color_code, }); self.column_position += 1; + + if self.column_position < BUFFER_WIDTH { + self.update_cursor(); + } } } } @@ -171,6 +191,7 @@ impl Writer { } self.clear_row(BUFFER_HEIGHT - 1); self.column_position = 0; + self.update_cursor(); } fn clear_row(&mut self, row: usize) { @@ -188,6 +209,7 @@ impl Writer { self.clear_row(row); } self.column_position = 0; + self.update_cursor(); } pub fn change_color(&mut self, fgc: Color, bgc: Color) { @@ -204,9 +226,11 @@ impl Writer { pub fn decrement_column_position(&mut self) { self.column_position -= 1; + self.update_cursor(); } pub fn increment_column_position(&mut self) { self.column_position += 1; + self.update_cursor(); } pub fn get_column_position(&mut self) -> usize { self.column_position