ladybird/Kernel/Console.cpp
Andreas Kling 79ffdb7205 A lot of hacking:
- More work on funneling console output through Console.
- init() now breaks off into a separate task ASAP.
- ..this leaves the "colonel" task as a simple hlt idle loop.
- Mask all IRQs on startup (except IRQ2 for slave passthru)
- Fix underallocation bug in Task::allocateRegion().
- Remember how many times each Task has been scheduled.

The panel and scheduling banner are disabled until I get things
working nicely in the (brave) new Console world.
2018-10-22 11:15:16 +02:00

66 lines
1.2 KiB
C++

#include "Console.h"
#include "VGA.h"
static Console* s_the;
Console& Console::the()
{
return *s_the;
}
Console::Console()
{
s_the = this;
}
Console::~Console()
{
}
ssize_t Console::read(byte* buffer, size_t bufferSize)
{
// FIXME: Implement reading from the console.
// Maybe we could use a ring buffer for this device?
// A generalized ring buffer would probably be useful.
return 0;
}
void Console::putChar(char ch)
{
switch (ch) {
case '\n':
m_cursorColumn = 0;
if (m_cursorRow == (m_rows - 2)) {
vga_scroll_up();
} else {
++m_cursorRow;
}
vga_set_cursor(m_cursorRow, m_cursorColumn);
return;
}
vga_putch_at(m_cursorRow, m_cursorColumn, ch);
++m_cursorColumn;
if (m_cursorColumn >= m_columns) {
if (m_cursorRow == (m_rows - 2)) {
vga_scroll_up();
} else {
++m_cursorRow;
}
m_cursorColumn = 0;
}
vga_set_cursor(m_cursorRow, m_cursorColumn);
}
ssize_t Console::write(const byte* data, size_t size)
{
if (!size)
return 0;
for (size_t i = 0; i < size; ++i)
putChar(data[i]);
return 0;
}