ladybird/Kernel/Console.h
Andreas Kling c6f2890d8e Implement a basic way for read() to block.
FileHandle gets a hasDataAvailableForRead() getter.
If this returns true in sys$read(), the task will block(BlockedRead) + yield.
The fd blocked on is stored in Task::m_fdBlockedOnRead.
The scheduler then looks at the state of that fd during the unblock phase.

This makes "sh" restful. :^)

There's still some problem with the kernel not surviving the colonel task
getting scheduled. I need to figure that out and fix it.
2018-10-25 13:09:56 +02:00

29 lines
637 B
C++

#pragma once
#include <VirtualFileSystem/CharacterDevice.h>
class Console final : public CharacterDevice {
public:
static Console& the();
Console();
virtual ~Console() override;
virtual bool hasDataAvailableForRead() const override;
virtual ssize_t read(byte* buffer, size_t size) override;
virtual ssize_t write(const byte* data, size_t size) override;
void putChar(char);
private:
const byte m_rows { 25 };
const byte m_columns { 80 };
byte m_cursorRow { 0 };
byte m_cursorColumn { 0 };
byte m_currentAttribute { 0x07 };
const byte* s_vgaMemory { (const byte*)0xb8000 };
};