| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include "mos/device/console.hpp" |
| 6 | #include "mos/device/serial.hpp" |
| 7 | |
| 8 | #include <ansi_colors.h> |
| 9 | #include <stddef.h> |
| 10 | |
| 11 | class SerialConsole : public Console |
| 12 | { |
| 13 | ISerialDevice *device; |
| 14 | |
| 15 | public: |
| 16 | template<size_t buf_size> |
| 17 | explicit SerialConsole(const char *name, ConsoleCapFlags caps, Buffer<buf_size> *buffer, ISerialDevice *device, StandardColor fg, StandardColor bg) |
| 18 | : Console(name, caps | CONSOLE_CAP_COLOR | CONSOLE_CAP_CLEAR, buffer, fg, bg), device(device) |
| 19 | { |
| 20 | device->setup(); |
| 21 | } |
| 22 | |
| 23 | public: |
| 24 | void handle_irq(); |
| 25 | |
| 26 | public: |
| 27 | size_t do_write(const char *data, size_t size) override; |
| 28 | |
| 29 | bool set_color(StandardColor fg, StandardColor bg) override; |
| 30 | |
| 31 | bool clear() override; |
| 32 | }; |
| 33 | |
| 34 | bool serial_console_irq_handler(u32 irq, void *data); |
| 35 | |