Kernel: Rewrite the whole VESA driver
We dont support vga text mode currently. I might add it later if needed. I also removed mouse 'support' from Shell since it didn't do anything and I didn't implement arbitary bitmap rendering to framebuffer
This commit is contained in:
@@ -21,7 +21,6 @@ namespace Kernel
|
||||
BAN::Vector<BAN::String> ParseArguments(BAN::StringView) const;
|
||||
void ProcessCommand(const BAN::Vector<BAN::String>&);
|
||||
void KeyEventCallback(Input::KeyEvent);
|
||||
void MouseMoveEventCallback(Input::MouseMoveEvent);
|
||||
|
||||
private:
|
||||
TTY* m_tty;
|
||||
@@ -36,13 +35,6 @@ namespace Kernel
|
||||
uint32_t col = 0;
|
||||
uint32_t index = 0;
|
||||
} m_cursor_pos;
|
||||
|
||||
struct
|
||||
{
|
||||
bool exists = false;
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
} m_mouse_pos;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/VESA.h>
|
||||
#include <kernel/TerminalDriver.h>
|
||||
#include <kernel/Serial.h>
|
||||
|
||||
class TTY
|
||||
{
|
||||
public:
|
||||
TTY();
|
||||
TTY(TerminalDriver*);
|
||||
void Clear();
|
||||
void PutChar(char ch);
|
||||
void Write(const char* data, size_t size);
|
||||
@@ -31,8 +31,8 @@ private:
|
||||
private:
|
||||
struct Cell
|
||||
{
|
||||
VESA::Color foreground = VESA::Color::BRIGHT_WHITE;
|
||||
VESA::Color background = VESA::Color::BLACK;
|
||||
TerminalDriver::Color foreground = TerminalColor::BRIGHT_WHITE;
|
||||
TerminalDriver::Color background = TerminalColor::BLACK;
|
||||
uint16_t character = ' ';
|
||||
};
|
||||
|
||||
@@ -43,12 +43,13 @@ private:
|
||||
int32_t nums[2] = { -1, -1 };
|
||||
};
|
||||
|
||||
uint32_t m_width { 0 };
|
||||
uint32_t m_height { 0 };
|
||||
uint32_t m_row { 0 };
|
||||
uint32_t m_column { 0 };
|
||||
VESA::Color m_foreground { VESA::Color::BRIGHT_WHITE };
|
||||
VESA::Color m_background { VESA::Color::BLACK };
|
||||
Cell* m_buffer { nullptr };
|
||||
AnsiState m_ansi_state;
|
||||
uint32_t m_width { 0 };
|
||||
uint32_t m_height { 0 };
|
||||
uint32_t m_row { 0 };
|
||||
uint32_t m_column { 0 };
|
||||
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
|
||||
TerminalDriver::Color m_background { TerminalColor::BLACK };
|
||||
Cell* m_buffer { nullptr };
|
||||
AnsiState m_ansi_state;
|
||||
TerminalDriver* m_terminal_driver { nullptr };
|
||||
};
|
||||
|
||||
53
kernel/include/kernel/TerminalDriver.h
Normal file
53
kernel/include/kernel/TerminalDriver.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class TerminalDriver
|
||||
{
|
||||
public:
|
||||
struct Color
|
||||
{
|
||||
constexpr Color(uint32_t rgb)
|
||||
: rgb(rgb)
|
||||
{ }
|
||||
constexpr Color(uint8_t r, uint8_t g, uint8_t b)
|
||||
: rgb(((uint32_t)r << 16) | ((uint32_t)g << 8) | b)
|
||||
{ }
|
||||
uint8_t red() const { return (rgb >> 0x10) & 0xFF; }
|
||||
uint8_t green() const { return (rgb >> 0x08) & 0xFF; }
|
||||
uint8_t blue() const { return (rgb >> 0x00) & 0xFF; }
|
||||
uint32_t rgb;
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~TerminalDriver() {}
|
||||
|
||||
virtual uint32_t Width() const = 0;
|
||||
virtual uint32_t Height() const = 0;
|
||||
|
||||
virtual void PutCharAt(uint16_t, uint32_t, uint32_t, Color, Color) = 0;
|
||||
virtual void Clear(Color) = 0;
|
||||
|
||||
virtual void SetCursorPosition(uint32_t, uint32_t) = 0;
|
||||
};
|
||||
|
||||
namespace TerminalColor
|
||||
{
|
||||
static constexpr TerminalDriver::Color BLACK = 0x000000;
|
||||
static constexpr TerminalDriver::Color BLUE = 0x0000AA;
|
||||
static constexpr TerminalDriver::Color GREEN = 0x00AA00;
|
||||
static constexpr TerminalDriver::Color CYAN = 0x00AAAA;
|
||||
static constexpr TerminalDriver::Color RED = 0xAA0000;
|
||||
static constexpr TerminalDriver::Color MAGENTA = 0xAA00AA;
|
||||
static constexpr TerminalDriver::Color YELLOW = 0xAA5500;
|
||||
static constexpr TerminalDriver::Color WHITE = 0xAAAAAA;
|
||||
|
||||
static constexpr TerminalDriver::Color BRIGHT_BLACK = 0x555555;
|
||||
static constexpr TerminalDriver::Color BRIGHT_BLUE = 0x5555FF;
|
||||
static constexpr TerminalDriver::Color BRIGHT_GREEN = 0x55FF55;
|
||||
static constexpr TerminalDriver::Color BRIGHT_CYAN = 0x55FFFF;
|
||||
static constexpr TerminalDriver::Color BRIGHT_RED = 0xFF5555;
|
||||
static constexpr TerminalDriver::Color BRIGHT_MAGENTA = 0xFF55FF;
|
||||
static constexpr TerminalDriver::Color BRIGHT_YELLOW = 0xFFFF55;
|
||||
static constexpr TerminalDriver::Color BRIGHT_WHITE = 0xFFFFFF;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace VESA
|
||||
{
|
||||
|
||||
enum class Color : uint8_t
|
||||
{
|
||||
BLACK = 0,
|
||||
BLUE = 1,
|
||||
GREEN = 2,
|
||||
CYAN = 3,
|
||||
RED = 4,
|
||||
MAGENTA = 5,
|
||||
YELLOW = 6,
|
||||
WHITE = 7,
|
||||
BRIGHT_BLACK = 8,
|
||||
BRIGHT_BLUE = 9,
|
||||
BRIGHT_GREEN = 10,
|
||||
BRIGHT_CYAN = 11,
|
||||
BRIGHT_RED = 12,
|
||||
BRIGHT_MAGENTA = 13,
|
||||
BRIGHT_YELLOW = 14,
|
||||
BRIGHT_WHITE = 15,
|
||||
};
|
||||
|
||||
bool Initialize();
|
||||
void PutBitmapAt(const uint8_t*, uint32_t, uint32_t, Color);
|
||||
void PutBitmapAt(const uint8_t*, uint32_t, uint32_t, Color, Color);
|
||||
void PutCharAt(uint16_t, uint32_t, uint32_t, Color, Color);
|
||||
void Clear(Color);
|
||||
void SetCursorPosition(uint32_t, uint32_t, Color);
|
||||
|
||||
uint32_t GetTerminalWidth();
|
||||
uint32_t GetTerminalHeight();
|
||||
|
||||
}
|
||||
41
kernel/include/kernel/VesaTerminalDriver.h
Normal file
41
kernel/include/kernel/VesaTerminalDriver.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/font.h>
|
||||
#include <kernel/TerminalDriver.h>
|
||||
|
||||
class VesaTerminalDriver final : public TerminalDriver
|
||||
{
|
||||
public:
|
||||
static VesaTerminalDriver* Create();
|
||||
~VesaTerminalDriver();
|
||||
|
||||
virtual uint32_t Width() const override { return m_width / m_font.Width; }
|
||||
virtual uint32_t Height() const override { return m_height / m_font.Height; }
|
||||
|
||||
virtual void PutCharAt(uint16_t, uint32_t, uint32_t, Color, Color) override;
|
||||
virtual void Clear(Color) override;
|
||||
|
||||
virtual void SetCursorPosition(uint32_t, uint32_t) override;
|
||||
|
||||
private:
|
||||
VesaTerminalDriver(uint32_t width, uint32_t height, uint32_t pitch, uint8_t bpp, uintptr_t address, bitmap_font font)
|
||||
: m_width(width)
|
||||
, m_height(height)
|
||||
, m_pitch(pitch)
|
||||
, m_bpp(bpp)
|
||||
, m_address(address)
|
||||
, m_font(font)
|
||||
{ }
|
||||
|
||||
void SetPixel(uint32_t, Color);
|
||||
|
||||
private:
|
||||
uint32_t m_width = 0;
|
||||
uint32_t m_height = 0;
|
||||
uint32_t m_pitch = 0;
|
||||
uint8_t m_bpp = 0;
|
||||
uintptr_t m_address = 0;
|
||||
bitmap_font m_font;
|
||||
|
||||
static constexpr Color s_cursor_color = TerminalColor::BRIGHT_WHITE;
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
// (c) 2009, 2010 Lutz Sammer, License: AGPLv3
|
||||
|
||||
/// bitmap font structure
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MULTIBOOT_FLAGS_FRAMEBUFFER (1 << 12)
|
||||
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_TEXT 2
|
||||
|
||||
struct framebuffer_info_t
|
||||
{
|
||||
uint64_t addr;
|
||||
|
||||
Reference in New Issue
Block a user