From 5846351aedfd2877ac9f0fd77308a38f7339267d Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Tue, 6 May 2025 18:07:37 +0200 Subject: [PATCH] feedback --- arch/cga.cc | 2 +- arch/serial.cc | 9 ++++----- debug/assert.cc | 2 ++ device/ps2controller.cc | 8 +++++--- device/textstream.cc | 4 ++-- main.cc | 5 ++++- tools/remote.mk | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/cga.cc b/arch/cga.cc index 3913279..4eccf7c 100644 --- a/arch/cga.cc +++ b/arch/cga.cc @@ -17,7 +17,7 @@ namespace CGA { } void setCursor(unsigned abs_x, unsigned abs_y) { - uint16_t pos = abs_y * COLUMNS + abs_x; + uint16_t pos = abs_y * COLUMNS + abs_x; writeCGAReg(RegisterIndex::CURSOR_LOW, pos & 0xFF); writeCGAReg(RegisterIndex::CURSOR_HIGH, ((pos >> 8) & 0xFF)); diff --git a/arch/serial.cc b/arch/serial.cc index b888e22..c5d32a4 100644 --- a/arch/serial.cc +++ b/arch/serial.cc @@ -43,9 +43,8 @@ int Serial::write(char out) { if(out == '\n') write('\r'); - if(readReg(LINE_STATUS_REGISTER) & TRANSMITTER_EMPTY){ - writeReg(TRANSMIT_BUFFER_REGISTER, out); - return out; - } - return -1; + while(!(readReg(LINE_STATUS_REGISTER) & TRANSMITTER_EMPTY)); + + writeReg(TRANSMIT_BUFFER_REGISTER, out); + return out; } diff --git a/debug/assert.cc b/debug/assert.cc index 96dd7c3..e7149a8 100644 --- a/debug/assert.cc +++ b/debug/assert.cc @@ -1,4 +1,5 @@ #include "assert.h" +#include "output.h" [[noreturn]] void assertion_failed(const char* exp, const char* func, const char* file, int line) { @@ -6,6 +7,7 @@ (void)func; (void)file; (void)line; + DBG << "Assertion failed: " << exp << "\nin function: " << func << "\nfrom file: \"" << file << "\" in line " << line << flush; // TODO: Print error message (in debug window) // TODO: Then stop the current core permanently // Use appropriate method from class Core to do so. diff --git a/device/ps2controller.cc b/device/ps2controller.cc index f29638f..7d9edb2 100644 --- a/device/ps2controller.cc +++ b/device/ps2controller.cc @@ -108,18 +108,20 @@ void init() { } bool fetch(Key &pressed) { - // TODO: You have to implement this method uint8_t status_reg = ctrl_port.inb(); - if(status_reg & IS_MOUSE || !(status_reg & HAS_OUTPUT) ) + if(!(status_reg & HAS_OUTPUT) ) return false; // TODO Remove mouse events from buffer DBG_VERBOSE << "status: " << hex << static_cast(status_reg) << "\n" << flush; uint8_t out_buffer = data_port.inb(); DBG_VERBOSE << "scancode: " << hex << static_cast(out_buffer) << "\n" << flush; + if (status_reg & IS_MOUSE) + return false; + pressed = key_decoder.decode(out_buffer); - if (pressed.alt() || pressed.ctrl() || pressed.shift || !pressed.valid()) + if (pressed.alt() || pressed.ctrl() || !pressed.valid()) return false; else return true; diff --git a/device/textstream.cc b/device/textstream.cc index a72de68..ad029cd 100644 --- a/device/textstream.cc +++ b/device/textstream.cc @@ -1,5 +1,5 @@ #include "textstream.h" -#include "../arch/lapic.h" +#include "../arch/core.h" TextStream::TextStream(unsigned from_col, unsigned to_col, @@ -17,7 +17,7 @@ TextStream::TextStream(unsigned from_col, void TextStream::flush() { - CGA::Color fg = static_cast((LAPIC::getID() + 1 )); + CGA::Color fg = static_cast((Core::getID() + 1 )); print(buffer,pos,CGA::Attribute(CGA::LIGHT_GREEN, fg, false)); pos = 0; } diff --git a/main.cc b/main.cc index 85b1974..c25e180 100644 --- a/main.cc +++ b/main.cc @@ -2,6 +2,7 @@ #include "boot/startup_ap.h" #include "debug/copystream.h" #include "debug/output.h" +#include "debug/assert.h" #include "arch/cga.h" #include "arch/textwindow.h" @@ -141,7 +142,9 @@ extern "C" int main_ap() { //uint8_t to = from+20; //dout[LAPIC::getID()] = TextStream(from, to, 0, 6, false); DBG << "test\n" << flush; - DBG << static_cast(LAPIC::getID()) << flush; + DBG << static_cast(LAPIC::getID()) << endl << flush; + + assert(Core::getID() != 1); return 0; } diff --git a/tools/remote.mk b/tools/remote.mk index 0733bd1..4274413 100644 --- a/tools/remote.mk +++ b/tools/remote.mk @@ -1,7 +1,7 @@ # Test your system on real hardware NETBOOT_LOCAL="/ibr/adm/user-boot/" -NETBOOT_HOST="x1.ibr.cs.tu-bs.de" +NETBOOT_HOST="y0085044@x1.ibr.cs.tu-bs.de" # The boot menu shows pairs of `vmlinuz-*` + `initrd-*.img` with owning user and timestamp. # We just need to choose a name that doesn't overlap with another user's.