Now prints "Hello, World" on boot

This commit is contained in:
Chris
2026-04-10 17:41:15 +00:00
parent c9d5705ae8
commit c4bed9000d
8 changed files with 119 additions and 11 deletions

View File

@@ -1,16 +1,36 @@
#include <libc/stdio.h>
#include <libc/stdint.h>
#include <libc/limits.h>
#ifndef KERNEL_TERMINAL_H
#define KERNEL_TERMINAL_H
#include <libc/stddef.h>
#include <libc/stdint.h>
const size_t VGA_HEIGHT = 25;
const size_t VGA_WIDTH = 80;
enum vga_colour{
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 uint16_t* terminalBuffer = (uint16_t*) 0xB8000;
uint8_t vgaEntryColour(enum vga_colour fg, enum vga_colour bg);
uint16_t vgaEntry(unsigned char uc, uint8_t color);
void terminalEntryAt(char c, uint8_t colour, size_t x, size_t y);
void terminalInitialize(void);
void terminalSetColour(uint8_t colour);
void terminalPutChar(char c);
void terminalWrite(const char* data, size_t size);
void terminalWriteString(const char* data);
void terminalEntryAt(char c, uint8_t colour, size_t x, size_t y){
size_t index = y * VGA_WIDTH + x;
terminalBuffer[index] = vgaEntry(c, colour);
}
#endif