forked from Bananymous/banan-os
Kernel: Implement basic VESA Graphics mode driver
We now support VESA Graphics mode with some bitmap fonts
This commit is contained in:
parent
9274c9ee2f
commit
6fe0d04f07
|
@ -2,4 +2,5 @@
|
|||
isodir
|
||||
sysroot
|
||||
.vscode/
|
||||
.idea/
|
||||
.idea/
|
||||
fonts/
|
|
@ -60,7 +60,7 @@ $(ARCHDIR)/crtend.o \
|
|||
$(ARCHDIR)/crtn.o \
|
||||
|
||||
.PHONY: all always clean install install-headers install-kernel
|
||||
.SUFFIXES: .o .cpp .S
|
||||
.SUFFIXES: .o .c .cpp .S
|
||||
|
||||
all: banan-os.kernel
|
||||
|
||||
|
@ -71,6 +71,9 @@ banan-os.kernel: always $(OBJS) $(ARCHDIR)/linker.ld
|
|||
$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o:
|
||||
OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $(BUILDDIR)/$@
|
||||
|
||||
.c.o:
|
||||
$(CC) -MD -c $< -o $(BUILDDIR)/$@ $(CFLAGS)
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -MD -c $< -o $(BUILDDIR)/$@ $(CFLAGS) $(CPPFLAGS)
|
||||
|
||||
|
|
|
@ -2,33 +2,34 @@
|
|||
#include <kernel/Serial.h>
|
||||
#include <kernel/VESA.h>
|
||||
|
||||
#include "font.h"
|
||||
|
||||
#define MULTIBOOT_FLAGS_FRAMEBUFFER (1 << 12)
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_TEXT 2
|
||||
|
||||
|
||||
extern multiboot_info_t* s_multiboot_info;
|
||||
extern const struct bitmap_font font;
|
||||
|
||||
namespace VESA
|
||||
{
|
||||
static void* s_addr = nullptr;
|
||||
static uint8_t s_bpp = 0;
|
||||
static uint32_t s_pitch = 0;
|
||||
static uint32_t s_width = 0;
|
||||
static uint32_t s_height = 0;
|
||||
static uint8_t s_mode = 0;
|
||||
|
||||
static void GraphicsPutCharAt(char ch, uint32_t x, uint32_t y, Color fg, Color bg);
|
||||
static void GraphicsPutCharAt(uint8_t ch, uint32_t x, uint32_t y, Color fg, Color bg);
|
||||
static void GraphicsClear(Color color);
|
||||
static void GraphicsScrollLine(uint32_t line);
|
||||
static bool InitializeGraphicsMode();
|
||||
|
||||
static inline uint8_t TextColor(Color fg, Color bg);
|
||||
static inline uint16_t TextEntry(uint8_t ch, uint8_t color);
|
||||
static void TextPutCharAt(char c, uint32_t x, uint32_t y, Color fg, Color bg);
|
||||
static void TextPutCharAt(uint8_t c, uint32_t x, uint32_t y, Color fg, Color bg);
|
||||
static void TextClear(Color color);
|
||||
static void TextScrollLine(uint32_t line);
|
||||
static bool InitializeTextMode();
|
||||
|
||||
void PutEntryAt(char ch, uint32_t x, uint32_t y, Color fg, Color bg)
|
||||
void PutEntryAt(uint8_t ch, uint32_t x, uint32_t y, Color fg, Color bg)
|
||||
{
|
||||
if (x >= s_width)
|
||||
return;
|
||||
|
@ -58,14 +59,22 @@ namespace VESA
|
|||
return TextScrollLine(line);
|
||||
}
|
||||
|
||||
uint32_t GetWidth()
|
||||
uint32_t GetTerminalWidth()
|
||||
{
|
||||
return s_width;
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS)
|
||||
return s_width / font.Width;
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_TEXT)
|
||||
return s_width;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t GetHeight()
|
||||
uint32_t GetTerminalHeight()
|
||||
{
|
||||
return s_height;
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS)
|
||||
return s_height / font.Height;
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_TEXT)
|
||||
return s_height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Initialize()
|
||||
|
@ -76,15 +85,22 @@ namespace VESA
|
|||
auto& framebuffer = s_multiboot_info->framebuffer;
|
||||
s_addr = (void*)framebuffer.addr;
|
||||
s_bpp = framebuffer.bpp;
|
||||
s_pitch = framebuffer.pitch;
|
||||
s_width = framebuffer.width;
|
||||
s_height = framebuffer.height;
|
||||
s_mode = framebuffer.type;
|
||||
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS)
|
||||
{
|
||||
if (s_bpp != 24 && s_bpp != 32)
|
||||
{
|
||||
dprintln("Unsupported bpp {}", s_bpp);
|
||||
return false;
|
||||
}
|
||||
|
||||
dprintln("VESA in Graphics mode {}x{} ({} bpp)", s_width, s_height, s_bpp);
|
||||
GraphicsClear(Color::BLACK);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_TEXT)
|
||||
|
@ -102,36 +118,91 @@ namespace VESA
|
|||
|
||||
|
||||
|
||||
|
||||
static void GraphicsPutCharAt(char ch, uint32_t x, uint32_t y, Color fg, Color bg)
|
||||
static uint32_t s_graphics_colors[]
|
||||
{
|
||||
0x00'00'00'00,
|
||||
0x00'00'00'AA,
|
||||
0x00'00'AA'00,
|
||||
0x00'00'AA'AA,
|
||||
0x00'AA'00'00,
|
||||
0x00'AA'00'AA,
|
||||
0x00'AA'55'00,
|
||||
0x00'AA'AA'AA,
|
||||
0x00'55'55'55,
|
||||
0x00'55'55'FF,
|
||||
0x00'55'FF'55,
|
||||
0x00'55'FF'FF,
|
||||
0x00'FF'55'55,
|
||||
0x00'FF'55'FF,
|
||||
0x00'FF'FF'55,
|
||||
0x00'FF'FF'FF,
|
||||
};
|
||||
|
||||
static void GraphicsPutPixelAt(uint32_t offset, uint32_t color)
|
||||
{
|
||||
uint32_t* pixel = (uint32_t*)((uint8_t*)s_addr + offset);
|
||||
switch (s_bpp)
|
||||
{
|
||||
case 24:
|
||||
*pixel = (*pixel & 0xFF000000) | color;
|
||||
break;
|
||||
case 32:
|
||||
*pixel = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void GraphicsPutPixelAt(uint32_t x, uint32_t y, uint32_t color)
|
||||
{
|
||||
uint32_t offset = y * s_pitch + (x * (s_bpp / 8));
|
||||
GraphicsPutPixelAt(offset, color);
|
||||
}
|
||||
|
||||
static void GraphicsPutCharAt(uint8_t ch, uint32_t x, uint32_t y, Color fg, Color bg)
|
||||
{
|
||||
// find correct bitmap
|
||||
uint32_t index = 0;
|
||||
for (uint32_t i = 0; i < font.Chars; i++)
|
||||
{
|
||||
if (font.Index[i] == ch)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned char* glyph = font.Bitmap + index * font.Height;
|
||||
|
||||
uint32_t u32_fg = s_graphics_colors[(uint8_t)fg];
|
||||
uint32_t u32_bg = s_graphics_colors[(uint8_t)bg];
|
||||
|
||||
for (uint32_t cy = 0; cy < font.Height; cy++)
|
||||
if (y * font.Height + cy < s_height)
|
||||
for (uint32_t cx = 0; cx < font.Width; cx++)
|
||||
if (x * font.Width + cx < s_width)
|
||||
GraphicsPutPixelAt(x * font.Width + cx, y * font.Height + cy, glyph[cy] & (1 << (font.Width - cx - 1)) ? u32_fg : u32_bg);
|
||||
}
|
||||
|
||||
static void GraphicsClear(Color color)
|
||||
{
|
||||
|
||||
uint32_t u32_color = s_graphics_colors[(uint8_t)color];
|
||||
for (uint32_t y = 0; y < s_height; y++)
|
||||
for (uint32_t x = 0; x < s_width; x++)
|
||||
GraphicsPutPixelAt(x, y, u32_color);
|
||||
}
|
||||
|
||||
static void GraphicsScrollLine(uint32_t line)
|
||||
{
|
||||
|
||||
(void)line;
|
||||
}
|
||||
|
||||
static bool InitializeGraphicsMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static inline uint8_t TextColor(Color fg, Color bg)
|
||||
{
|
||||
return ((bg & 0x0F) << 4) | (fg & 0x0F);
|
||||
return (((uint8_t)bg & 0x0F) << 4) | ((uint8_t)fg & 0x0F);
|
||||
}
|
||||
|
||||
static inline uint16_t TextEntry(uint8_t ch, uint8_t color)
|
||||
|
@ -139,33 +210,27 @@ namespace VESA
|
|||
return ((uint16_t)color << 8) | ch;
|
||||
}
|
||||
|
||||
static void TextPutCharAt(char c, uint32_t x, uint32_t y, Color fg, Color bg)
|
||||
static void TextPutCharAt(uint8_t ch, uint32_t x, uint32_t y, Color fg, Color bg)
|
||||
{
|
||||
uint64_t index = y * s_width + x;
|
||||
((uint16_t*)s_addr)[index] = TextEntry(c, TextColor(fg, bg));
|
||||
uint32_t index = y * s_width + x;
|
||||
((uint16_t*)s_addr)[index] = TextEntry(ch, TextColor(fg, bg));
|
||||
}
|
||||
|
||||
static void TextClear(Color color)
|
||||
{
|
||||
for (uint32_t y = 0; y < s_height; y++)
|
||||
for (uint32_t x = 0; x < s_width; x++)
|
||||
TextPutCharAt(' ', x, y, Color::WHITE, color);
|
||||
TextPutCharAt(' ', x, y, Color::BRIGHT_WHITE, color);
|
||||
}
|
||||
|
||||
static void TextScrollLine(uint32_t line)
|
||||
{
|
||||
for (uint32_t x = 0; x < s_width; x++)
|
||||
{
|
||||
uint64_t index1 = (line - 0) * s_width + x;
|
||||
uint64_t index2 = (line - 1) * s_width + x;
|
||||
uint32_t index1 = (line - 0) * s_width + x;
|
||||
uint32_t index2 = (line - 1) * s_width + x;
|
||||
((uint16_t*)s_addr)[index2] = ((uint16_t*)s_addr)[index1];
|
||||
}
|
||||
}
|
||||
|
||||
static bool InitializeTextMode()
|
||||
{
|
||||
TextClear(Color::BLACK);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,10 +17,11 @@
|
|||
.skip 4
|
||||
.skip 4
|
||||
.skip 4
|
||||
.long 1
|
||||
.long 80
|
||||
.long 25
|
||||
|
||||
.long 0
|
||||
.long 800
|
||||
.long 600
|
||||
.long 32
|
||||
|
||||
# Create stack
|
||||
.section .bss
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,270 @@
|
|||
// (c) 2009, 2010 Lutz Sammer, License: AGPLv3
|
||||
|
||||
/// bitmap font structure
|
||||
struct bitmap_font {
|
||||
unsigned char Width; ///< max. character width
|
||||
unsigned char Height; ///< character height
|
||||
unsigned short Chars; ///< number of characters in font
|
||||
const unsigned char *Widths; ///< width of each character
|
||||
const unsigned short *Index; ///< encoding to character index
|
||||
const unsigned char *Bitmap; ///< bitmap of all characters
|
||||
};
|
||||
|
||||
/// @{ defines to have human readable font files
|
||||
#define ________ 0x00
|
||||
#define _______X 0x01
|
||||
#define ______X_ 0x02
|
||||
#define ______XX 0x03
|
||||
#define _____X__ 0x04
|
||||
#define _____X_X 0x05
|
||||
#define _____XX_ 0x06
|
||||
#define _____XXX 0x07
|
||||
#define ____X___ 0x08
|
||||
#define ____X__X 0x09
|
||||
#define ____X_X_ 0x0A
|
||||
#define ____X_XX 0x0B
|
||||
#define ____XX__ 0x0C
|
||||
#define ____XX_X 0x0D
|
||||
#define ____XXX_ 0x0E
|
||||
#define ____XXXX 0x0F
|
||||
#define ___X____ 0x10
|
||||
#define ___X___X 0x11
|
||||
#define ___X__X_ 0x12
|
||||
#define ___X__XX 0x13
|
||||
#define ___X_X__ 0x14
|
||||
#define ___X_X_X 0x15
|
||||
#define ___X_XX_ 0x16
|
||||
#define ___X_XXX 0x17
|
||||
#define ___XX___ 0x18
|
||||
#define ___XX__X 0x19
|
||||
#define ___XX_X_ 0x1A
|
||||
#define ___XX_XX 0x1B
|
||||
#define ___XXX__ 0x1C
|
||||
#define ___XXX_X 0x1D
|
||||
#define ___XXXX_ 0x1E
|
||||
#define ___XXXXX 0x1F
|
||||
#define __X_____ 0x20
|
||||
#define __X____X 0x21
|
||||
#define __X___X_ 0x22
|
||||
#define __X___XX 0x23
|
||||
#define __X__X__ 0x24
|
||||
#define __X__X_X 0x25
|
||||
#define __X__XX_ 0x26
|
||||
#define __X__XXX 0x27
|
||||
#define __X_X___ 0x28
|
||||
#define __X_X__X 0x29
|
||||
#define __X_X_X_ 0x2A
|
||||
#define __X_X_XX 0x2B
|
||||
#define __X_XX__ 0x2C
|
||||
#define __X_XX_X 0x2D
|
||||
#define __X_XXX_ 0x2E
|
||||
#define __X_XXXX 0x2F
|
||||
#define __XX____ 0x30
|
||||
#define __XX___X 0x31
|
||||
#define __XX__X_ 0x32
|
||||
#define __XX__XX 0x33
|
||||
#define __XX_X__ 0x34
|
||||
#define __XX_X_X 0x35
|
||||
#define __XX_XX_ 0x36
|
||||
#define __XX_XXX 0x37
|
||||
#define __XXX___ 0x38
|
||||
#define __XXX__X 0x39
|
||||
#define __XXX_X_ 0x3A
|
||||
#define __XXX_XX 0x3B
|
||||
#define __XXXX__ 0x3C
|
||||
#define __XXXX_X 0x3D
|
||||
#define __XXXXX_ 0x3E
|
||||
#define __XXXXXX 0x3F
|
||||
#define _X______ 0x40
|
||||
#define _X_____X 0x41
|
||||
#define _X____X_ 0x42
|
||||
#define _X____XX 0x43
|
||||
#define _X___X__ 0x44
|
||||
#define _X___X_X 0x45
|
||||
#define _X___XX_ 0x46
|
||||
#define _X___XXX 0x47
|
||||
#define _X__X___ 0x48
|
||||
#define _X__X__X 0x49
|
||||
#define _X__X_X_ 0x4A
|
||||
#define _X__X_XX 0x4B
|
||||
#define _X__XX__ 0x4C
|
||||
#define _X__XX_X 0x4D
|
||||
#define _X__XXX_ 0x4E
|
||||
#define _X__XXXX 0x4F
|
||||
#define _X_X____ 0x50
|
||||
#define _X_X___X 0x51
|
||||
#define _X_X__X_ 0x52
|
||||
#define _X_X__XX 0x53
|
||||
#define _X_X_X__ 0x54
|
||||
#define _X_X_X_X 0x55
|
||||
#define _X_X_XX_ 0x56
|
||||
#define _X_X_XXX 0x57
|
||||
#define _X_XX___ 0x58
|
||||
#define _X_XX__X 0x59
|
||||
#define _X_XX_X_ 0x5A
|
||||
#define _X_XX_XX 0x5B
|
||||
#define _X_XXX__ 0x5C
|
||||
#define _X_XXX_X 0x5D
|
||||
#define _X_XXXX_ 0x5E
|
||||
#define _X_XXXXX 0x5F
|
||||
#define _XX_____ 0x60
|
||||
#define _XX____X 0x61
|
||||
#define _XX___X_ 0x62
|
||||
#define _XX___XX 0x63
|
||||
#define _XX__X__ 0x64
|
||||
#define _XX__X_X 0x65
|
||||
#define _XX__XX_ 0x66
|
||||
#define _XX__XXX 0x67
|
||||
#define _XX_X___ 0x68
|
||||
#define _XX_X__X 0x69
|
||||
#define _XX_X_X_ 0x6A
|
||||
#define _XX_X_XX 0x6B
|
||||
#define _XX_XX__ 0x6C
|
||||
#define _XX_XX_X 0x6D
|
||||
#define _XX_XXX_ 0x6E
|
||||
#define _XX_XXXX 0x6F
|
||||
#define _XXX____ 0x70
|
||||
#define _XXX___X 0x71
|
||||
#define _XXX__X_ 0x72
|
||||
#define _XXX__XX 0x73
|
||||
#define _XXX_X__ 0x74
|
||||
#define _XXX_X_X 0x75
|
||||
#define _XXX_XX_ 0x76
|
||||
#define _XXX_XXX 0x77
|
||||
#define _XXXX___ 0x78
|
||||
#define _XXXX__X 0x79
|
||||
#define _XXXX_X_ 0x7A
|
||||
#define _XXXX_XX 0x7B
|
||||
#define _XXXXX__ 0x7C
|
||||
#define _XXXXX_X 0x7D
|
||||
#define _XXXXXX_ 0x7E
|
||||
#define _XXXXXXX 0x7F
|
||||
#define X_______ 0x80
|
||||
#define X______X 0x81
|
||||
#define X_____X_ 0x82
|
||||
#define X_____XX 0x83
|
||||
#define X____X__ 0x84
|
||||
#define X____X_X 0x85
|
||||
#define X____XX_ 0x86
|
||||
#define X____XXX 0x87
|
||||
#define X___X___ 0x88
|
||||
#define X___X__X 0x89
|
||||
#define X___X_X_ 0x8A
|
||||
#define X___X_XX 0x8B
|
||||
#define X___XX__ 0x8C
|
||||
#define X___XX_X 0x8D
|
||||
#define X___XXX_ 0x8E
|
||||
#define X___XXXX 0x8F
|
||||
#define X__X____ 0x90
|
||||
#define X__X___X 0x91
|
||||
#define X__X__X_ 0x92
|
||||
#define X__X__XX 0x93
|
||||
#define X__X_X__ 0x94
|
||||
#define X__X_X_X 0x95
|
||||
#define X__X_XX_ 0x96
|
||||
#define X__X_XXX 0x97
|
||||
#define X__XX___ 0x98
|
||||
#define X__XX__X 0x99
|
||||
#define X__XX_X_ 0x9A
|
||||
#define X__XX_XX 0x9B
|
||||
#define X__XXX__ 0x9C
|
||||
#define X__XXX_X 0x9D
|
||||
#define X__XXXX_ 0x9E
|
||||
#define X__XXXXX 0x9F
|
||||
#define X_X_____ 0xA0
|
||||
#define X_X____X 0xA1
|
||||
#define X_X___X_ 0xA2
|
||||
#define X_X___XX 0xA3
|
||||
#define X_X__X__ 0xA4
|
||||
#define X_X__X_X 0xA5
|
||||
#define X_X__XX_ 0xA6
|
||||
#define X_X__XXX 0xA7
|
||||
#define X_X_X___ 0xA8
|
||||
#define X_X_X__X 0xA9
|
||||
#define X_X_X_X_ 0xAA
|
||||
#define X_X_X_XX 0xAB
|
||||
#define X_X_XX__ 0xAC
|
||||
#define X_X_XX_X 0xAD
|
||||
#define X_X_XXX_ 0xAE
|
||||
#define X_X_XXXX 0xAF
|
||||
#define X_XX____ 0xB0
|
||||
#define X_XX___X 0xB1
|
||||
#define X_XX__X_ 0xB2
|
||||
#define X_XX__XX 0xB3
|
||||
#define X_XX_X__ 0xB4
|
||||
#define X_XX_X_X 0xB5
|
||||
#define X_XX_XX_ 0xB6
|
||||
#define X_XX_XXX 0xB7
|
||||
#define X_XXX___ 0xB8
|
||||
#define X_XXX__X 0xB9
|
||||
#define X_XXX_X_ 0xBA
|
||||
#define X_XXX_XX 0xBB
|
||||
#define X_XXXX__ 0xBC
|
||||
#define X_XXXX_X 0xBD
|
||||
#define X_XXXXX_ 0xBE
|
||||
#define X_XXXXXX 0xBF
|
||||
#define XX______ 0xC0
|
||||
#define XX_____X 0xC1
|
||||
#define XX____X_ 0xC2
|
||||
#define XX____XX 0xC3
|
||||
#define XX___X__ 0xC4
|
||||
#define XX___X_X 0xC5
|
||||
#define XX___XX_ 0xC6
|
||||
#define XX___XXX 0xC7
|
||||
#define XX__X___ 0xC8
|
||||
#define XX__X__X 0xC9
|
||||
#define XX__X_X_ 0xCA
|
||||
#define XX__X_XX 0xCB
|
||||
#define XX__XX__ 0xCC
|
||||
#define XX__XX_X 0xCD
|
||||
#define XX__XXX_ 0xCE
|
||||
#define XX__XXXX 0xCF
|
||||
#define XX_X____ 0xD0
|
||||
#define XX_X___X 0xD1
|
||||
#define XX_X__X_ 0xD2
|
||||
#define XX_X__XX 0xD3
|
||||
#define XX_X_X__ 0xD4
|
||||
#define XX_X_X_X 0xD5
|
||||
#define XX_X_XX_ 0xD6
|
||||
#define XX_X_XXX 0xD7
|
||||
#define XX_XX___ 0xD8
|
||||
#define XX_XX__X 0xD9
|
||||
#define XX_XX_X_ 0xDA
|
||||
#define XX_XX_XX 0xDB
|
||||
#define XX_XXX__ 0xDC
|
||||
#define XX_XXX_X 0xDD
|
||||
#define XX_XXXX_ 0xDE
|
||||
#define XX_XXXXX 0xDF
|
||||
#define XXX_____ 0xE0
|
||||
#define XXX____X 0xE1
|
||||
#define XXX___X_ 0xE2
|
||||
#define XXX___XX 0xE3
|
||||
#define XXX__X__ 0xE4
|
||||
#define XXX__X_X 0xE5
|
||||
#define XXX__XX_ 0xE6
|
||||
#define XXX__XXX 0xE7
|
||||
#define XXX_X___ 0xE8
|
||||
#define XXX_X__X 0xE9
|
||||
#define XXX_X_X_ 0xEA
|
||||
#define XXX_X_XX 0xEB
|
||||
#define XXX_XX__ 0xEC
|
||||
#define XXX_XX_X 0xED
|
||||
#define XXX_XXX_ 0xEE
|
||||
#define XXX_XXXX 0xEF
|
||||
#define XXXX____ 0xF0
|
||||
#define XXXX___X 0xF1
|
||||
#define XXXX__X_ 0xF2
|
||||
#define XXXX__XX 0xF3
|
||||
#define XXXX_X__ 0xF4
|
||||
#define XXXX_X_X 0xF5
|
||||
#define XXXX_XX_ 0xF6
|
||||
#define XXXX_XXX 0xF7
|
||||
#define XXXXX___ 0xF8
|
||||
#define XXXXX__X 0xF9
|
||||
#define XXXXX_X_ 0xFA
|
||||
#define XXXXX_XX 0xFB
|
||||
#define XXXXXX__ 0xFC
|
||||
#define XXXXXX_X 0xFD
|
||||
#define XXXXXXX_ 0xFE
|
||||
#define XXXXXXXX 0xFF
|
||||
/// @}
|
|
@ -3,12 +3,13 @@ KERNEL_ARCH_CPPFLAGS=
|
|||
KERNEL_ARCH_LDFLAGS=
|
||||
KERNEL_ARCH_LIBS=
|
||||
|
||||
KERNEL_ARCH_OBJS=\
|
||||
$(ARCHDIR)/boot.o \
|
||||
$(ARCHDIR)/tty.o \
|
||||
$(ARCHDIR)/CPUID.o \
|
||||
$(ARCHDIR)/GDT.o \
|
||||
$(ARCHDIR)/GDT_asm.o \
|
||||
$(ARCHDIR)/IDT.o \
|
||||
$(ARCHDIR)/IDT_asm.o \
|
||||
$(ARCHDIR)/VESA.o \
|
||||
KERNEL_ARCH_OBJS= \
|
||||
$(ARCHDIR)/boot.o \
|
||||
$(ARCHDIR)/CPUID.o \
|
||||
$(ARCHDIR)/font.o \
|
||||
$(ARCHDIR)/GDT_asm.o \
|
||||
$(ARCHDIR)/GDT.o \
|
||||
$(ARCHDIR)/IDT_asm.o \
|
||||
$(ARCHDIR)/IDT.o \
|
||||
$(ARCHDIR)/tty.o \
|
||||
$(ARCHDIR)/VESA.o \
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace TTY
|
|||
static uint32_t terminal_width = 0;
|
||||
static uint32_t terminal_row = 0;
|
||||
static uint32_t terminal_col = 0;
|
||||
static VESA::Color terminal_fg = VESA::Color::WHITE;
|
||||
static VESA::Color terminal_fg = VESA::Color::BRIGHT_WHITE;
|
||||
static VESA::Color terminal_bg = VESA::Color::BLACK;
|
||||
|
||||
static char s_ansi_escape_mode = '\0';
|
||||
|
@ -36,8 +36,8 @@ namespace TTY
|
|||
|
||||
void initialize()
|
||||
{
|
||||
terminal_width = VESA::GetWidth();
|
||||
terminal_height = VESA::GetHeight();
|
||||
terminal_width = VESA::GetTerminalWidth();
|
||||
terminal_height = VESA::GetTerminalHeight();
|
||||
}
|
||||
|
||||
void clear()
|
||||
|
@ -87,27 +87,27 @@ namespace TTY
|
|||
{
|
||||
case -1:
|
||||
case 0:
|
||||
terminal_fg = VESA::Color::WHITE;
|
||||
terminal_fg = VESA::Color::BRIGHT_WHITE;
|
||||
terminal_bg = VESA::Color::BLACK;
|
||||
break;
|
||||
|
||||
case 30: terminal_fg = VESA::Color::BLACK; break;
|
||||
case 31: terminal_fg = VESA::Color::LIGHT_RED; break;
|
||||
case 32: terminal_fg = VESA::Color::LIGHT_GREEN; break;
|
||||
case 33: terminal_fg = VESA::Color::LIGHT_BROWN; break;
|
||||
case 34: terminal_fg = VESA::Color::LIGHT_BLUE; break;
|
||||
case 35: terminal_fg = VESA::Color::LIGHT_MAGENTA; break;
|
||||
case 36: terminal_fg = VESA::Color::LIGHT_CYAN; break;
|
||||
case 37: terminal_fg = VESA::Color::LIGHT_GREY; break;
|
||||
case 30: terminal_fg = VESA::Color::BRIGHT_BLACK; break;
|
||||
case 31: terminal_fg = VESA::Color::BRIGHT_RED; break;
|
||||
case 32: terminal_fg = VESA::Color::BRIGHT_GREEN; break;
|
||||
case 33: terminal_fg = VESA::Color::BRIGHT_YELLOW; break;
|
||||
case 34: terminal_fg = VESA::Color::BRIGHT_BLUE; break;
|
||||
case 35: terminal_fg = VESA::Color::BRIGHT_MAGENTA; break;
|
||||
case 36: terminal_fg = VESA::Color::BRIGHT_CYAN; break;
|
||||
case 37: terminal_fg = VESA::Color::BRIGHT_WHITE; break;
|
||||
|
||||
case 40: terminal_bg = VESA::Color::BLACK; break;
|
||||
case 41: terminal_bg = VESA::Color::LIGHT_RED; break;
|
||||
case 42: terminal_bg = VESA::Color::LIGHT_GREEN; break;
|
||||
case 43: terminal_bg = VESA::Color::LIGHT_BROWN; break;
|
||||
case 44: terminal_bg = VESA::Color::LIGHT_BLUE; break;
|
||||
case 45: terminal_bg = VESA::Color::LIGHT_MAGENTA; break;
|
||||
case 46: terminal_bg = VESA::Color::LIGHT_CYAN; break;
|
||||
case 47: terminal_bg = VESA::Color::LIGHT_GREY; break;
|
||||
case 40: terminal_bg = VESA::Color::BRIGHT_BLACK; break;
|
||||
case 41: terminal_bg = VESA::Color::BRIGHT_RED; break;
|
||||
case 42: terminal_bg = VESA::Color::BRIGHT_GREEN; break;
|
||||
case 43: terminal_bg = VESA::Color::BRIGHT_YELLOW; break;
|
||||
case 44: terminal_bg = VESA::Color::BRIGHT_BLUE; break;
|
||||
case 45: terminal_bg = VESA::Color::BRIGHT_MAGENTA; break;
|
||||
case 46: terminal_bg = VESA::Color::BRIGHT_CYAN; break;
|
||||
case 47: terminal_bg = VESA::Color::BRIGHT_WHITE; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum vga_color
|
||||
{
|
||||
VGA_COLOR_BLACK = 0,
|
||||
VGA_COLOR_BLUE = 1,
|
||||
VGA_COLOR_GREEN = 2,
|
||||
VGA_COLOR_CYAN = 3,
|
||||
VGA_COLOR_RED = 4,
|
||||
VGA_COLOR_MAGENTA = 5,
|
||||
VGA_COLOR_BROWN = 6,
|
||||
VGA_COLOR_LIGHT_GREY = 7,
|
||||
VGA_COLOR_DARK_GREY = 8,
|
||||
VGA_COLOR_LIGHT_BLUE = 9,
|
||||
VGA_COLOR_LIGHT_GREEN = 10,
|
||||
VGA_COLOR_LIGHT_CYAN = 11,
|
||||
VGA_COLOR_LIGHT_RED = 12,
|
||||
VGA_COLOR_LIGHT_MAGENTA = 13,
|
||||
VGA_COLOR_LIGHT_BROWN = 14,
|
||||
VGA_COLOR_WHITE = 15,
|
||||
};
|
||||
|
||||
static inline uint8_t vga_set_foreground(enum vga_color fg, uint8_t color)
|
||||
{
|
||||
return (color & 0xf0) | fg;
|
||||
}
|
||||
|
||||
static inline uint8_t vga_set_background(enum vga_color bg, uint8_t color)
|
||||
{
|
||||
return (bg << 4) | (color & 0x0f);
|
||||
}
|
||||
|
||||
static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg)
|
||||
{
|
||||
return (bg << 4) | fg;
|
||||
}
|
||||
|
||||
static inline uint16_t vga_entry(unsigned char uc, uint8_t color)
|
||||
{
|
||||
return (uint16_t) uc | (uint16_t) color << 8;
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
namespace VESA
|
||||
{
|
||||
|
||||
enum Color : uint8_t
|
||||
enum class Color : uint8_t
|
||||
{
|
||||
BLACK = 0,
|
||||
BLUE = 1,
|
||||
|
@ -13,24 +13,24 @@ namespace VESA
|
|||
CYAN = 3,
|
||||
RED = 4,
|
||||
MAGENTA = 5,
|
||||
BROWN = 6,
|
||||
LIGHT_GREY = 7,
|
||||
DARK_GREY = 8,
|
||||
LIGHT_BLUE = 9,
|
||||
LIGHT_GREEN = 10,
|
||||
LIGHT_CYAN = 11,
|
||||
LIGHT_RED = 12,
|
||||
LIGHT_MAGENTA = 13,
|
||||
LIGHT_BROWN = 14,
|
||||
WHITE = 15,
|
||||
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 PutEntryAt(char, uint32_t, uint32_t, Color, Color);
|
||||
void PutEntryAt(uint8_t, uint32_t, uint32_t, Color, Color);
|
||||
void Clear(Color);
|
||||
void ScrollLine(uint32_t line);
|
||||
|
||||
uint32_t GetWidth();
|
||||
uint32_t GetHeight();
|
||||
uint32_t GetTerminalWidth();
|
||||
uint32_t GetTerminalHeight();
|
||||
|
||||
}
|
Loading…
Reference in New Issue