mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 13:54:58 +00:00

As we removed the support of VBE modesetting that was done by GRUB early on boot, we need to determine if we can modeset the resolution with our drivers, and if not, we should enable text mode and ensure that SystemServer knows about it too. Also, SystemServer should first check if there's a framebuffer device node, which is an indication that text mode was not even if it was requested. Then, if it doesn't find it, it should check what boot_mode argument the user specified (in case it's self-test). This way if we try to use bochs-display device (which is not VGA compatible) and request a text mode, it will not honor the request and will continue with graphical mode. Also try to print critical messages with mininum memory allocations possible. In LibVT, We make the implementation flexible for kernel-specific methods that are implemented in ConsoleImpl class.
82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/RefCounted.h>
|
|
#include <AK/String.h>
|
|
#include <AK/Types.h>
|
|
#include <Kernel/Graphics/GraphicsDevice.h>
|
|
|
|
namespace Kernel::Graphics {
|
|
|
|
class Console : public RefCounted<Console> {
|
|
public:
|
|
// Stanadard VGA text mode colors
|
|
enum Color : u8 {
|
|
Black = 0,
|
|
Blue,
|
|
Green,
|
|
Cyan,
|
|
Red,
|
|
Magenta,
|
|
Brown,
|
|
LightGray,
|
|
DarkGray,
|
|
BrightBlue,
|
|
BrightGreen,
|
|
BrightCyan,
|
|
BrightRed,
|
|
BrightMagenta,
|
|
Yellow,
|
|
White,
|
|
};
|
|
|
|
public:
|
|
size_t width() const { return m_width; }
|
|
size_t height() const { return m_height; }
|
|
size_t pitch() const { return bytes_per_base_glyph() * width(); }
|
|
virtual size_t max_column() const { return m_width; }
|
|
virtual size_t max_row() const { return m_height; }
|
|
virtual size_t bytes_per_base_glyph() const = 0;
|
|
virtual size_t chars_per_line() const = 0;
|
|
|
|
virtual void enable() = 0;
|
|
virtual void disable() = 0;
|
|
|
|
virtual bool is_hardware_paged_capable() const = 0;
|
|
virtual bool has_hardware_cursor() const = 0;
|
|
|
|
virtual void set_cursor(size_t x, size_t y) = 0;
|
|
virtual void hide_cursor() = 0;
|
|
virtual void show_cursor() = 0;
|
|
|
|
virtual void clear(size_t x, size_t y, size_t length) const = 0;
|
|
virtual void write(size_t x, size_t y, char ch, Color background, Color foreground) const = 0;
|
|
virtual void write(size_t x, size_t y, String, Color background, Color foreground) const = 0;
|
|
virtual void write(size_t x, size_t y, char ch) const = 0;
|
|
virtual void write(size_t x, size_t y, String) const = 0;
|
|
virtual void write(char ch) const = 0;
|
|
|
|
virtual ~Console() { }
|
|
|
|
protected:
|
|
Console(size_t width, size_t height)
|
|
: m_width(width)
|
|
, m_height(height)
|
|
{
|
|
m_enabled.store(true);
|
|
}
|
|
|
|
Atomic<bool> m_enabled;
|
|
Color m_default_foreground_color { Color::White };
|
|
Color m_default_background_color { Color::Black };
|
|
const size_t m_width;
|
|
const size_t m_height;
|
|
mutable size_t m_x { 0 };
|
|
mutable size_t m_y { 0 };
|
|
};
|
|
}
|