2018-10-21 21:59:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-28 22:40:55 +01:00
|
|
|
#include <AK/CircularQueue.h>
|
2018-10-27 23:42:20 +02:00
|
|
|
#include <AK/Vector.h>
|
2019-04-03 12:36:40 +02:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
2018-10-21 21:59:43 +02:00
|
|
|
|
2018-10-30 13:59:29 +01:00
|
|
|
class ConsoleImplementation {
|
|
|
|
public:
|
|
|
|
virtual ~ConsoleImplementation();
|
2018-12-03 00:39:25 +01:00
|
|
|
virtual void on_sysconsole_receive(byte) = 0;
|
2018-10-30 13:59:29 +01:00
|
|
|
};
|
|
|
|
|
2018-10-21 21:59:43 +02:00
|
|
|
class Console final : public CharacterDevice {
|
2018-10-31 23:19:15 +01:00
|
|
|
AK_MAKE_ETERNAL
|
2018-10-21 21:59:43 +02:00
|
|
|
public:
|
2019-02-15 12:30:48 +01:00
|
|
|
static Console& the();
|
2018-10-21 21:59:43 +02:00
|
|
|
|
|
|
|
Console();
|
|
|
|
virtual ~Console() override;
|
|
|
|
|
2019-01-21 02:33:01 +01:00
|
|
|
// ^CharacterDevice
|
2019-01-16 00:10:13 +01:00
|
|
|
virtual bool can_read(Process&) const override;
|
2019-01-15 09:17:22 +01:00
|
|
|
virtual bool can_write(Process&) const override { return true; }
|
2019-02-25 21:19:57 +01:00
|
|
|
virtual ssize_t read(Process&, byte*, ssize_t) override;
|
|
|
|
virtual ssize_t write(Process&, const byte*, ssize_t) override;
|
2019-01-21 02:33:01 +01:00
|
|
|
virtual const char* class_name() const override { return "Console"; }
|
2018-10-21 21:59:43 +02:00
|
|
|
|
2019-01-31 17:31:23 +01:00
|
|
|
void set_implementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
|
2018-10-30 13:59:29 +01:00
|
|
|
|
2018-12-03 01:38:22 +01:00
|
|
|
void put_char(char);
|
2018-10-21 22:11:46 +02:00
|
|
|
|
2019-01-28 22:40:55 +01:00
|
|
|
const CircularQueue<char, 16384>& logbuffer() const { return m_logbuffer; }
|
|
|
|
|
2018-10-23 15:19:02 +02:00
|
|
|
private:
|
2018-10-30 13:59:29 +01:00
|
|
|
ConsoleImplementation* m_implementation { nullptr };
|
2019-01-28 22:40:55 +01:00
|
|
|
CircularQueue<char, 16384> m_logbuffer;
|
2018-10-21 21:59:43 +02:00
|
|
|
};
|
|
|
|
|