Compare commits
12 Commits
563d30f9f2
...
35c2667fbf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35c2667fbf | ||
|
|
2c60b88849 | ||
|
|
bccd23c0c6 | ||
|
|
35d9c7bd48 | ||
|
|
69c1afa5dc | ||
|
|
a3495dbc72 | ||
|
|
0b8c00ab19 | ||
|
|
92792d9cac | ||
|
|
0666fc30c7 | ||
|
|
6b2d3dc8ed | ||
|
|
4a537711e4 | ||
|
|
7add9c8fca |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.build*
|
||||
/build*
|
||||
/tools/qemu.mk
|
||||
|
||||
@@ -95,7 +95,6 @@ void setCursor(unsigned abs_x, unsigned abs_y);
|
||||
|
||||
/*! \brief Retrieve the keyboard hardware cursor position on screen
|
||||
*
|
||||
* \todo(11) Implement the method using the \ref IOPort
|
||||
*
|
||||
* \param abs_x absolute column of the keyboard hardware cursor
|
||||
* \param abs_y absolute row of the keyboard hardware cursor
|
||||
@@ -118,7 +117,6 @@ void getCursor(unsigned& abs_x, unsigned& abs_y);
|
||||
* \param character Character to be displayed
|
||||
* \param attrib Attribute with color settings
|
||||
*
|
||||
* \todo(11) Implement the method
|
||||
*/
|
||||
void show(unsigned abs_x, unsigned abs_y, char character,
|
||||
Attribute attrib = Attribute());
|
||||
|
||||
@@ -22,7 +22,6 @@ Serial::Serial(ComPort port, BaudRate baud_rate, DataBits data_bits,
|
||||
// FIFO: Enable & clear buffers
|
||||
writeReg(FIFO_CONTROL_REGISTER,
|
||||
ENABLE_FIFO | CLEAR_RECEIVE_FIFO | CLEAR_TRANSMIT_FIFO);
|
||||
|
||||
// Modem Control: OUT2 (0000 1000) must be set for interrupt
|
||||
writeReg(MODEM_CONTROL_REGISTER, OUT_2);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,6 @@ class Serial {
|
||||
|
||||
/*! \brief Read value from register
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*
|
||||
* \param reg Register index
|
||||
* \return The value read from register
|
||||
@@ -170,7 +169,6 @@ class Serial {
|
||||
|
||||
/*! \brief Write value to register
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*
|
||||
* \param reg Register index
|
||||
* \param out value to be written
|
||||
@@ -188,7 +186,6 @@ class Serial {
|
||||
* parameters used for the serial connection. Default values are `8N1` (8 bit,
|
||||
* no parity bit, one stop bit) with 115200 Baud using COM1.
|
||||
*
|
||||
* \todo(11) - Implement Constructor
|
||||
*/
|
||||
explicit Serial(ComPort port = COM1, BaudRate baud_rate = BAUD_115200,
|
||||
DataBits data_bits = DATA_8BIT,
|
||||
@@ -196,7 +193,6 @@ class Serial {
|
||||
|
||||
/*! \brief Write one byte to the serial interface
|
||||
*
|
||||
* \todo(11) - Implement Method
|
||||
*
|
||||
* \param out Byte to be written
|
||||
* \return Byte written (or `-1` if writing byte failed)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "textwindow.h"
|
||||
#include "cga.h"
|
||||
#include "../utils/string.h"
|
||||
|
||||
TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row,
|
||||
unsigned to_row, bool use_cursor) {
|
||||
@@ -8,6 +9,8 @@ TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row,
|
||||
this->from_row = from_row;
|
||||
this->to_row = to_row;
|
||||
this->use_cursor = use_cursor;
|
||||
|
||||
setPos(0,0);
|
||||
}
|
||||
|
||||
void TextWindow::setPos(unsigned rel_x, unsigned rel_y) {
|
||||
@@ -47,6 +50,13 @@ void TextWindow::getPos(int& rel_x, int& rel_y) const {
|
||||
rel_y = y;
|
||||
}
|
||||
|
||||
void TextWindow::scrollUp(){
|
||||
for(uint8_t row = from_row; row < to_row-1; row++){
|
||||
memmove(&CGA::TEXT_BUFFER_BASE[row*CGA::COLUMNS + from_col], &CGA::TEXT_BUFFER_BASE[(row+1)*CGA::COLUMNS + from_col], 2*(to_col-from_col));
|
||||
}
|
||||
memset(&CGA::TEXT_BUFFER_BASE[(to_row-1)*CGA::COLUMNS + from_col] , 0, 2*(to_col-from_col));
|
||||
}
|
||||
|
||||
void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) {
|
||||
for(unsigned i=0; i<length; i++){
|
||||
unsigned x_now, y_now;
|
||||
@@ -54,7 +64,7 @@ void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) {
|
||||
if(str[i] == '\n'){
|
||||
x_now = 0;
|
||||
if(from_row + y_now >= to_row-1){
|
||||
//TODO scrollUp()
|
||||
scrollUp();
|
||||
}
|
||||
else{
|
||||
y_now++;
|
||||
@@ -63,11 +73,11 @@ void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGA::show(x_now, y_now, str[i], attrib);
|
||||
CGA::show(from_col + x_now, from_row + y_now, str[i], attrib);
|
||||
if(from_col+x_now >= to_col-1){
|
||||
x_now = 0;
|
||||
if(from_row + y_now >= to_row-1){
|
||||
//TODO scrollUp()
|
||||
scrollUp();
|
||||
}
|
||||
else{
|
||||
y_now++;
|
||||
|
||||
@@ -29,6 +29,8 @@ class TextWindow {
|
||||
unsigned pos_x;
|
||||
unsigned pos_y;
|
||||
|
||||
void scrollUp();
|
||||
|
||||
public:
|
||||
/*! \brief Constructor of a text window
|
||||
*
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
* possible that the debug output in a multi core system is displayed
|
||||
* on the wrong (previous) core.
|
||||
*/
|
||||
#define DBG nullstream
|
||||
|
||||
#include "../arch/core.h"
|
||||
#include "../device/textstream.h"
|
||||
#define DBG *copyout[Core::getID()]
|
||||
|
||||
/*! \brief Debug window for the CGA screen
|
||||
*
|
||||
@@ -72,7 +72,6 @@
|
||||
* without any overlap and should be able to display at least 3 lines.
|
||||
* In \MPStuBS, two windows can be placed side-by-side, having 40 columns each.
|
||||
*
|
||||
* \todo(11) Define `dout`
|
||||
*/
|
||||
extern TextStream dout[Core::MAX];
|
||||
|
||||
@@ -83,11 +82,11 @@ extern TextStream dout[Core::MAX];
|
||||
* an array in the multi core case, which consists of three TextStreams and
|
||||
* one CopyStream.
|
||||
* For that, construction is done like:
|
||||
* \todo(11) Define `copyout`
|
||||
*
|
||||
* \code{.cpp}
|
||||
* OutputStream* copyout[Core::MAX]{&dout[0], &dout[1], ...}
|
||||
* \endcode
|
||||
*
|
||||
* \todo(11) Define `copyout`
|
||||
*/
|
||||
extern OutputStream* copyout[Core::MAX];
|
||||
|
||||
@@ -89,8 +89,11 @@ enum ControllerCommand {
|
||||
*
|
||||
* \param value data to be sent
|
||||
*/
|
||||
[[maybe_unused]] static void sendData(uint8_t value) {
|
||||
// TODO: You have to implement this method
|
||||
static void sendData(uint8_t value) {
|
||||
|
||||
if (!(ctrl_port.inb()&HAS_OUTPUT)) {
|
||||
data_port.outb(value);
|
||||
}
|
||||
(void)value;
|
||||
}
|
||||
|
||||
@@ -106,8 +109,20 @@ void init() {
|
||||
|
||||
bool fetch(Key &pressed) {
|
||||
// TODO: You have to implement this method
|
||||
(void)pressed;
|
||||
return false;
|
||||
uint8_t status_reg = ctrl_port.inb();
|
||||
if(status_reg & IS_MOUSE || !(status_reg & HAS_OUTPUT) )
|
||||
return false; // TODO Remove mouse events from buffer
|
||||
DBG_VERBOSE << "status: " << hex << static_cast<int>(status_reg) << "\n" << flush;
|
||||
|
||||
uint8_t out_buffer = data_port.inb();
|
||||
DBG_VERBOSE << "scancode: " << hex << static_cast<int>(out_buffer) << "\n" << flush;
|
||||
|
||||
pressed = key_decoder.decode(out_buffer);
|
||||
|
||||
if (pressed.alt() || pressed.ctrl() || pressed.shift || !pressed.valid())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void setRepeatRate(Speed speed, Delay delay) {
|
||||
|
||||
@@ -61,7 +61,6 @@ class SerialStream : public OutputStream, public Serial {
|
||||
*
|
||||
* Sets up the serial connection as well
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*/
|
||||
explicit SerialStream(ComPort port = COM1, BaudRate baud_rate = BAUD_115200,
|
||||
DataBits data_bits = DATA_8BIT,
|
||||
@@ -74,13 +73,11 @@ class SerialStream : public OutputStream, public Serial {
|
||||
* The method is automatically called when the buffer is full,
|
||||
* but can also be called explicitly to force output of the current buffer.
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*/
|
||||
void flush() override;
|
||||
|
||||
/*! \brief Change foreground color (for subsequent output)
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*
|
||||
* \param c Color
|
||||
*/
|
||||
@@ -88,7 +85,6 @@ class SerialStream : public OutputStream, public Serial {
|
||||
|
||||
/*! \brief Change background color (for subsequent output)
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*
|
||||
* \param c Color
|
||||
*/
|
||||
@@ -96,7 +92,6 @@ class SerialStream : public OutputStream, public Serial {
|
||||
|
||||
/*! \brief Change text attribute (for subsequent output)
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*
|
||||
* \param a Attribute
|
||||
*/
|
||||
@@ -107,7 +102,6 @@ class SerialStream : public OutputStream, public Serial {
|
||||
* Clear screen, place cursor at the beginning and reset colors
|
||||
* and attributes to the default value.
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*/
|
||||
void reset();
|
||||
|
||||
@@ -116,7 +110,6 @@ class SerialStream : public OutputStream, public Serial {
|
||||
* \param x Column in window
|
||||
* \param y Row in window
|
||||
*
|
||||
* \todo(11) Implement Method
|
||||
*/
|
||||
void setPos(int x, int y);
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ TextStream::TextStream(unsigned from_col,
|
||||
from_row,
|
||||
to_row,
|
||||
use_cursor){
|
||||
CGA::Color fg = static_cast<CGA::Color>((LAPIC::getID() + 1 ));
|
||||
this->reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, fg, false));
|
||||
//CGA::Color fg = static_cast<CGA::Color>((LAPIC::getID() + 1 ));
|
||||
//this->reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, fg, false));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,14 +36,7 @@ class TextStream: public OutputStream, protected TextWindow {
|
||||
* but can also be called explicitly to force output of the current buffer.
|
||||
*
|
||||
*
|
||||
* \todo(11) Implement method
|
||||
*/
|
||||
void flush();
|
||||
|
||||
private:
|
||||
unsigned from_col;
|
||||
unsigned to_col;
|
||||
unsigned from_row;
|
||||
unsigned to_row;
|
||||
bool use_cursor;
|
||||
};
|
||||
|
||||
71
main.cc
71
main.cc
@@ -1,13 +1,59 @@
|
||||
#include "arch/lapic.h"
|
||||
#include "boot/startup_ap.h"
|
||||
#include "debug/copystream.h"
|
||||
#include "debug/output.h"
|
||||
|
||||
#include "arch/cga.h"
|
||||
#include "arch/textwindow.h"
|
||||
#include "arch/serial.h"
|
||||
#include "device/serialstream.h"
|
||||
#include "device/textstream.h"
|
||||
#include "device/ps2controller.h"
|
||||
TextStream kout = TextStream(0, 80, 0, 10, true);
|
||||
|
||||
//TextStream dout[8] = {
|
||||
// TextStream(0 ,20,12,25,false),
|
||||
// TextStream(20,40,12,25,false),
|
||||
// TextStream(40,60,12,25,false),
|
||||
// TextStream(60,80,12,25,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
//};
|
||||
TextStream dout[Core::MAX] = {
|
||||
{0, 40, 10, 14},
|
||||
{40, 80, 10, 14},
|
||||
{0, 40, 14, 18},
|
||||
{40, 80, 14, 18},
|
||||
{0, 40, 18, 22},
|
||||
{40, 80, 18, 22},
|
||||
{0, 40, 22, 25},
|
||||
{40, 80, 22, 25},
|
||||
};
|
||||
|
||||
CopyStream copystream[Core::MAX]{
|
||||
{&dout[0], &sout},
|
||||
{&dout[1], &sout},
|
||||
{&dout[2], &sout},
|
||||
{&dout[3], &sout},
|
||||
{&dout[4], &sout},
|
||||
{&dout[5], &sout},
|
||||
{&dout[6], &sout},
|
||||
{&dout[7], &sout},
|
||||
};
|
||||
|
||||
OutputStream* copyout[Core::MAX]{
|
||||
&dout[0],
|
||||
©stream[1],
|
||||
&dout[2],
|
||||
&dout[3],
|
||||
&dout[4],
|
||||
&dout[5],
|
||||
&dout[6],
|
||||
&dout[7]
|
||||
};
|
||||
|
||||
TextStream kout = TextStream(0, 80, 0, 12, true);
|
||||
|
||||
// Main function
|
||||
// (the bootstrap processor starts here)}
|
||||
@@ -55,14 +101,22 @@ extern "C" int main() {
|
||||
kout << "pointer: " << reinterpret_cast<void*>(1994473406541717165ull)
|
||||
<< " -> 0x1badcafefee1dead" << endl;
|
||||
kout << "smiley: " << static_cast<char>(1) << endl;
|
||||
|
||||
|
||||
/* Start application processors
|
||||
* To avoid unexpected behaviour, make sure that interrupts are not
|
||||
* enabled before the APs are booted. Otherwise it might interfere with the
|
||||
* Startup IPIs or even block devices like keyboard because of a missing EOI
|
||||
*/
|
||||
ApplicationProcessor::boot();
|
||||
|
||||
ApplicationProcessor::boot();
|
||||
|
||||
PS2Controller::init();
|
||||
Key key = Key();
|
||||
while (true){
|
||||
if (PS2Controller::fetch(key)) {
|
||||
kout << key.ascii() << flush ;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,16 +127,21 @@ extern "C" int main_ap() {
|
||||
|
||||
|
||||
|
||||
|
||||
//TextWindow dout0 = TextWindow(0,20,13,19, false);
|
||||
//dout0.reset();
|
||||
//dout0.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::RED, false));
|
||||
|
||||
|
||||
////test Serial
|
||||
Serial s = Serial();
|
||||
s.write('a');
|
||||
//Serial s = Serial();
|
||||
//s.write('a');
|
||||
|
||||
|
||||
//uint8_t from = static_cast<int>(LAPIC::getID()) * 20;
|
||||
//uint8_t to = from+20;
|
||||
//dout[LAPIC::getID()] = TextStream(from, to, 0, 6, false);
|
||||
DBG << "test\n" << flush;
|
||||
DBG << static_cast<int>(LAPIC::getID()) << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ class Stringbuffer {
|
||||
*
|
||||
* \param c Char to be added
|
||||
*
|
||||
* \todo(11) Implement
|
||||
*/
|
||||
void put(char c);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ kvm: all
|
||||
|
||||
# Execute Qemu with activated GDB stub and directly connect GDB to the spawned Qemu.
|
||||
gdb: all
|
||||
${VERBOSE} cgdb -d $(GDB) "$(DBGKERNEL)" \
|
||||
${VERBOSE} cgdb "$(DBGKERNEL)" \
|
||||
-ex "set arch $(DBGARCH)" \
|
||||
-ex "target remote | exec $(QEMU) -gdb stdio $(QEMUKERNEL) -smp $(QEMUCPUS) -S $(QEMUFLAGS) $(DBGFLAGS)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user