main
Eggert Jung 6 months ago
parent 35c2667fbf
commit 5846351aed

@ -17,7 +17,7 @@ namespace CGA {
} }
void setCursor(unsigned abs_x, unsigned abs_y) { 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_LOW, pos & 0xFF);
writeCGAReg(RegisterIndex::CURSOR_HIGH, ((pos >> 8) & 0xFF)); writeCGAReg(RegisterIndex::CURSOR_HIGH, ((pos >> 8) & 0xFF));

@ -43,9 +43,8 @@ int Serial::write(char out) {
if(out == '\n') if(out == '\n')
write('\r'); write('\r');
if(readReg(LINE_STATUS_REGISTER) & TRANSMITTER_EMPTY){ while(!(readReg(LINE_STATUS_REGISTER) & TRANSMITTER_EMPTY));
writeReg(TRANSMIT_BUFFER_REGISTER, out);
return out; writeReg(TRANSMIT_BUFFER_REGISTER, out);
} return out;
return -1;
} }

@ -1,4 +1,5 @@
#include "assert.h" #include "assert.h"
#include "output.h"
[[noreturn]] void assertion_failed(const char* exp, const char* func, [[noreturn]] void assertion_failed(const char* exp, const char* func,
const char* file, int line) { const char* file, int line) {
@ -6,6 +7,7 @@
(void)func; (void)func;
(void)file; (void)file;
(void)line; (void)line;
DBG << "Assertion failed: " << exp << "\nin function: " << func << "\nfrom file: \"" << file << "\" in line " << line << flush;
// TODO: Print error message (in debug window) // TODO: Print error message (in debug window)
// TODO: Then stop the current core permanently // TODO: Then stop the current core permanently
// Use appropriate method from class Core to do so. // Use appropriate method from class Core to do so.

@ -108,18 +108,20 @@ void init() {
} }
bool fetch(Key &pressed) { bool fetch(Key &pressed) {
// TODO: You have to implement this method
uint8_t status_reg = ctrl_port.inb(); 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 return false; // TODO Remove mouse events from buffer
DBG_VERBOSE << "status: " << hex << static_cast<int>(status_reg) << "\n" << flush; DBG_VERBOSE << "status: " << hex << static_cast<int>(status_reg) << "\n" << flush;
uint8_t out_buffer = data_port.inb(); uint8_t out_buffer = data_port.inb();
DBG_VERBOSE << "scancode: " << hex << static_cast<int>(out_buffer) << "\n" << flush; DBG_VERBOSE << "scancode: " << hex << static_cast<int>(out_buffer) << "\n" << flush;
if (status_reg & IS_MOUSE)
return false;
pressed = key_decoder.decode(out_buffer); pressed = key_decoder.decode(out_buffer);
if (pressed.alt() || pressed.ctrl() || pressed.shift || !pressed.valid()) if (pressed.alt() || pressed.ctrl() || !pressed.valid())
return false; return false;
else else
return true; return true;

@ -1,5 +1,5 @@
#include "textstream.h" #include "textstream.h"
#include "../arch/lapic.h" #include "../arch/core.h"
TextStream::TextStream(unsigned from_col, TextStream::TextStream(unsigned from_col,
unsigned to_col, unsigned to_col,
@ -17,7 +17,7 @@ TextStream::TextStream(unsigned from_col,
void TextStream::flush() { void TextStream::flush() {
CGA::Color fg = static_cast<CGA::Color>((LAPIC::getID() + 1 )); CGA::Color fg = static_cast<CGA::Color>((Core::getID() + 1 ));
print(buffer,pos,CGA::Attribute(CGA::LIGHT_GREEN, fg, false)); print(buffer,pos,CGA::Attribute(CGA::LIGHT_GREEN, fg, false));
pos = 0; pos = 0;
} }

@ -2,6 +2,7 @@
#include "boot/startup_ap.h" #include "boot/startup_ap.h"
#include "debug/copystream.h" #include "debug/copystream.h"
#include "debug/output.h" #include "debug/output.h"
#include "debug/assert.h"
#include "arch/cga.h" #include "arch/cga.h"
#include "arch/textwindow.h" #include "arch/textwindow.h"
@ -141,7 +142,9 @@ extern "C" int main_ap() {
//uint8_t to = from+20; //uint8_t to = from+20;
//dout[LAPIC::getID()] = TextStream(from, to, 0, 6, false); //dout[LAPIC::getID()] = TextStream(from, to, 0, 6, false);
DBG << "test\n" << flush; DBG << "test\n" << flush;
DBG << static_cast<int>(LAPIC::getID()) << flush; DBG << static_cast<int>(LAPIC::getID()) << endl << flush;
assert(Core::getID() != 1);
return 0; return 0;
} }

@ -1,7 +1,7 @@
# Test your system on real hardware # Test your system on real hardware
NETBOOT_LOCAL="/ibr/adm/user-boot/" 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. # 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. # We just need to choose a name that doesn't overlap with another user's.

Loading…
Cancel
Save