fix compilier warnings
This commit is contained in:
parent
c26e0e0599
commit
4b4ad2ca65
|
@ -29,6 +29,6 @@ SET(src_no_sse
|
||||||
set_property(SOURCE ${src_no_sse} PROPERTY COMPILE_FLAGS -mgeneral-regs-only)
|
set_property(SOURCE ${src_no_sse} PROPERTY COMPILE_FLAGS -mgeneral-regs-only)
|
||||||
|
|
||||||
add_executable(kernel.elf ${src_files} ${src_no_sse} font.o)
|
add_executable(kernel.elf ${src_files} ${src_no_sse} font.o)
|
||||||
target_compile_options(kernel.elf PRIVATE -ffreestanding -O2 -Wall -Wextra -v -fPIC)
|
target_compile_options(kernel.elf PRIVATE -ffreestanding -O2 -Wall -Wextra -Wall -Werror -pedantic -fPIC)
|
||||||
target_link_options(kernel.elf PRIVATE -T linker.ld -ffreestanding -O2 -nostdlib -lgcc)
|
target_link_options(kernel.elf PRIVATE -T linker.ld -ffreestanding -O2 -nostdlib -lgcc)
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
static const char* ExceptionStrings[] = {
|
extern const char* ExceptionStrings[];
|
||||||
"Division by Zero",
|
|
||||||
"Debug",
|
|
||||||
"Non Maskable Interrupt",
|
|
||||||
"Breakpoint",
|
|
||||||
"Into Detected Overflow",
|
|
||||||
"Out of Bounds",
|
|
||||||
"Invalid Opcode",
|
|
||||||
"No Coprocessor",
|
|
||||||
"Double Fault",
|
|
||||||
"Coprocessor Segment Overrun",
|
|
||||||
"Bad TSS",
|
|
||||||
"Segment Not Present",
|
|
||||||
"Stack Fault",
|
|
||||||
"General Protection Fault",
|
|
||||||
"Page Fault",
|
|
||||||
"Unknown Interrupt",
|
|
||||||
"Coprocessor Fault",
|
|
||||||
"Alignment Check",
|
|
||||||
"Machine Check",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved",
|
|
||||||
"Reserved"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed)) {
|
||||||
|
@ -55,10 +21,10 @@ typedef struct __attribute__((packed)) {
|
||||||
size_t ss;
|
size_t ss;
|
||||||
} EXCEPTION_FRAME;
|
} EXCEPTION_FRAME;
|
||||||
|
|
||||||
static void* IRQ_Handlers[16] = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
typedef void (*IRQHandler)(INTERRUPT_FRAME* Frame);
|
||||||
0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
extern IRQHandler IRQ_Handlers[16];
|
||||||
|
|
||||||
void IRQ_Common(INTERRUPT_FRAME* Frame, size_t Interupt);
|
void IRQ_Common(INTERRUPT_FRAME* Frame, size_t Interupt);
|
||||||
void ISR_Common(INTERRUPT_FRAME* Frame, size_t Interrupt);
|
void ISR_Common(INTERRUPT_FRAME* Frame, size_t Interrupt);
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#ifndef _KERNEL_TTY_H
|
|
||||||
#define _KERNEL_TTY_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
void Term_Init(void);
|
|
||||||
void Term_PutChar(char c);
|
|
||||||
void Term_Write(const char* str, size_t len);
|
|
||||||
void Term_WriteStr(const char* str);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -36,6 +36,18 @@ char keys[128] = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void KbdEcho() {
|
||||||
|
if(!KbdFlags.EchoCount) {
|
||||||
|
if(!KbdFlags.Echo) {
|
||||||
|
Send8042(0xEE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
KbdFlags.EchoCount = 0;
|
||||||
|
KbdFlags.Echo = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UpdateKeyboard(uint8_t msg) {
|
void UpdateKeyboard(uint8_t msg) {
|
||||||
|
|
||||||
InputBuffer[0] = msg;
|
InputBuffer[0] = msg;
|
||||||
|
@ -79,23 +91,12 @@ void UpdateKeyboard(uint8_t msg) {
|
||||||
if(msg & 0x80) {
|
if(msg & 0x80) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SerialPrintf("Key pressed: [\%c]\r\n", keys[msg]);
|
SerialPrintf("Key pressed: [\\%c]\r\n", keys[msg]);
|
||||||
WriteChar(keys[msg]);
|
WriteChar(keys[msg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KbdEcho() {
|
|
||||||
if(!KbdFlags.EchoCount) {
|
|
||||||
if(!KbdFlags.Echo) {
|
|
||||||
Send8042(0xEE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
KbdFlags.EchoCount = 0;
|
|
||||||
KbdFlags.Echo = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Send8042(size_t info) {
|
void Send8042(size_t info) {
|
||||||
for(size_t i = 0; i < 8; i++) {
|
for(size_t i = 0; i < 8; i++) {
|
||||||
unsigned char chr = (unsigned char) info;
|
unsigned char chr = (unsigned char) info;
|
||||||
|
|
|
@ -36,6 +36,51 @@
|
||||||
#include <kernel/system/interrupts.h>
|
#include <kernel/system/interrupts.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define UNUSED(X) ((void)X)
|
||||||
|
|
||||||
|
const char* ExceptionStrings[] = {
|
||||||
|
"Division by Zero",
|
||||||
|
"Debug",
|
||||||
|
"Non Maskable Interrupt",
|
||||||
|
"Breakpoint",
|
||||||
|
"Into Detected Overflow",
|
||||||
|
"Out of Bounds",
|
||||||
|
"Invalid Opcode",
|
||||||
|
"No Coprocessor",
|
||||||
|
"Double Fault",
|
||||||
|
"Coprocessor Segment Overrun",
|
||||||
|
"Bad TSS",
|
||||||
|
"Segment Not Present",
|
||||||
|
"Stack Fault",
|
||||||
|
"General Protection Fault",
|
||||||
|
"Page Fault",
|
||||||
|
"Unknown Interrupt",
|
||||||
|
"Coprocessor Fault",
|
||||||
|
"Alignment Check",
|
||||||
|
"Machine Check",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved",
|
||||||
|
"Reserved"
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void (*IRQHandler)(INTERRUPT_FRAME* Frame);
|
||||||
|
|
||||||
|
IRQHandler IRQ_Handlers[16] = {
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned long long int uword_t;
|
typedef unsigned long long int uword_t;
|
||||||
|
|
||||||
/* All of the ISR routines call this function for now.
|
/* All of the ISR routines call this function for now.
|
||||||
|
@ -43,6 +88,9 @@ typedef unsigned long long int uword_t;
|
||||||
! Be careful!
|
! Be careful!
|
||||||
*/
|
*/
|
||||||
void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
|
void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
|
||||||
|
|
||||||
|
UNUSED(Frame);
|
||||||
|
|
||||||
/* Only the first 32 ISR/IRQs are reserved for exceptions by the CPU. We can handle up to 512 interrupts total, though. */
|
/* Only the first 32 ISR/IRQs are reserved for exceptions by the CPU. We can handle up to 512 interrupts total, though. */
|
||||||
if(Exception < 32) {
|
if(Exception < 32) {
|
||||||
|
|
||||||
|
@ -58,6 +106,9 @@ void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
|
||||||
/* The common handler for exceptions that throw error codes, which give us useful insight
|
/* The common handler for exceptions that throw error codes, which give us useful insight
|
||||||
into what went wrong. In pure Curle style, though, we just ignore the error code. */
|
into what went wrong. In pure Curle style, though, we just ignore the error code. */
|
||||||
void ISR_Error_Common(INTERRUPT_FRAME* Frame, size_t ErrorCode, size_t Exception) {
|
void ISR_Error_Common(INTERRUPT_FRAME* Frame, size_t ErrorCode, size_t Exception) {
|
||||||
|
|
||||||
|
UNUSED(Frame);
|
||||||
|
|
||||||
if(Exception < 32) {
|
if(Exception < 32) {
|
||||||
|
|
||||||
FillScreen(0x0000FF00);
|
FillScreen(0x0000FF00);
|
||||||
|
@ -125,11 +176,14 @@ void InstallIRQ(int IRQ, void (*Handler)(INTERRUPT_FRAME* Frame)) {
|
||||||
|
|
||||||
/* A simple wrapper that unlinks a function pointer, rendering the IRQ unused. */
|
/* A simple wrapper that unlinks a function pointer, rendering the IRQ unused. */
|
||||||
void UninstallIRQHandler(int IRQ) {
|
void UninstallIRQHandler(int IRQ) {
|
||||||
IRQ_Handlers[IRQ] = 0; // 0 is used in the common check to make sure that the function is callable.
|
IRQ_Handlers[IRQ] = NULL; // 0 is used in the common check to make sure that the function is callable.
|
||||||
// This removes this irq from that check, ergo the function will no longer be called.
|
// This removes this irq from that check, ergo the function will no longer be called.
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmptyIRQ(INTERRUPT_FRAME* frame) {
|
void EmptyIRQ(INTERRUPT_FRAME* frame) {
|
||||||
|
|
||||||
|
UNUSED(frame);
|
||||||
|
|
||||||
// Flash the borders green, then back to blue
|
// Flash the borders green, then back to blue
|
||||||
|
|
||||||
for(size_t y = 0; y < bootldr.fb_height; y++) {
|
for(size_t y = 0; y < bootldr.fb_height; y++) {
|
||||||
|
@ -175,6 +229,8 @@ void EmptyIRQ(INTERRUPT_FRAME* frame) {
|
||||||
|
|
||||||
static void KeyboardCallback(INTERRUPT_FRAME* frame) {
|
static void KeyboardCallback(INTERRUPT_FRAME* frame) {
|
||||||
|
|
||||||
|
UNUSED(frame);
|
||||||
|
|
||||||
uint8_t msg = ReadPort(0x60, 1);
|
uint8_t msg = ReadPort(0x60, 1);
|
||||||
|
|
||||||
UpdateKeyboard(msg);
|
UpdateKeyboard(msg);
|
||||||
|
@ -271,7 +327,7 @@ __attribute__((interrupt)) void ISR14Handler(INTERRUPT_FRAME* Frame, size_t Erro
|
||||||
|
|
||||||
SerialPrintf("Page fault! Caused by: [\r\n");
|
SerialPrintf("Page fault! Caused by: [\r\n");
|
||||||
|
|
||||||
size_t FaultAddr = ReadControlRegister(2);
|
//size_t FaultAddr = ReadControlRegister(2);
|
||||||
uint8_t FaultPres = ErrorCode & 0x1;
|
uint8_t FaultPres = ErrorCode & 0x1;
|
||||||
uint8_t FaultRW = ErrorCode & 0x2;
|
uint8_t FaultRW = ErrorCode & 0x2;
|
||||||
uint8_t FaultUser = ErrorCode & 0x4;
|
uint8_t FaultUser = ErrorCode & 0x4;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <kernel/chroma.h>
|
#include <kernel/chroma.h>
|
||||||
|
|
||||||
__attribute__((aligned(4096))) static size_t Pagetable[512] = {0};
|
//__attribute__((aligned(4096))) static size_t Pagetable[512] = {0};
|
||||||
|
|
||||||
#define LAST_ENTRY 0xFF8
|
#define LAST_ENTRY 0xFF8
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void InitPaging() {
|
||||||
SET_ADDRESS(PT_KERNEL + LAST_ENTRY, 0xF14003);
|
SET_ADDRESS(PT_KERNEL + LAST_ENTRY, 0xF14003);
|
||||||
MappingIterations = 1;
|
MappingIterations = 1;
|
||||||
// For every core:
|
// For every core:
|
||||||
for(size_t i = 0; i < (bootldr.numcores + 3) >> 2; i++) {
|
for(size_t i = 0; i < (bootldr.numcores + 3U) >> 2; i++) {
|
||||||
// PT_KERNEL[512 - (iterations + 1)] = 0x14003 + (iterations * page-width)
|
// PT_KERNEL[512 - (iterations + 1)] = 0x14003 + (iterations * page-width)
|
||||||
SET_ADDRESS(PT_KERNEL + LAST_ENTRY - (MappingIterations * 8), 0xF14003 + (4096 * MappingIterations));
|
SET_ADDRESS(PT_KERNEL + LAST_ENTRY - (MappingIterations * 8), 0xF14003 + (4096 * MappingIterations));
|
||||||
MappingIterations++;
|
MappingIterations++;
|
||||||
|
@ -115,7 +115,7 @@ void InitPagingOldImpl() {
|
||||||
|
|
||||||
// Clear space for our pagetable
|
// Clear space for our pagetable
|
||||||
size_t PagetableDest = 0x1000;
|
size_t PagetableDest = 0x1000;
|
||||||
memset(PagetableDest, 0, 4096);
|
memset((char*)PagetableDest, 0, 4096);
|
||||||
|
|
||||||
// Start setting pagetable indexes
|
// Start setting pagetable indexes
|
||||||
*((size_t*)PagetableDest) = 0x2003; // PDP at 0x2000, present & r/w
|
*((size_t*)PagetableDest) = 0x2003; // PDP at 0x2000, present & r/w
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <kernel/system/heap.h>
|
#include <kernel/system/heap.h>
|
||||||
|
|
||||||
uint8_t* Memory = ((uint8_t*)(&end));
|
uint8_t* Memory = ((uint8_t*)(&end));
|
||||||
uint8_t MemoryStart;
|
uint8_t* MemoryStart;
|
||||||
size_t MemoryBuckets;
|
size_t MemoryBuckets;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void ListMemoryMap() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(MMapEnt* MapEntry = &bootldr.mmap; MapEntry < (size_t) &bootldr + bootldr.size; MapEntry++) {
|
for(MMapEnt* MapEntry = &bootldr.mmap; (size_t)MapEntry < (size_t)&environment; MapEntry++) {
|
||||||
char EntryType[8] = {0};
|
char EntryType[8] = {0};
|
||||||
switch(MMapEnt_Type(MapEntry)) {
|
switch(MMapEnt_Type(MapEntry)) {
|
||||||
case MMAP_FREE:
|
case MMAP_FREE:
|
||||||
|
@ -103,9 +103,9 @@ void MemoryTest() {
|
||||||
SerialPrintf("Initializing basic memory test..\r\n");
|
SerialPrintf("Initializing basic memory test..\r\n");
|
||||||
bool Passed = true;
|
bool Passed = true;
|
||||||
size_t FirstPage = SeekFrame();
|
size_t FirstPage = SeekFrame();
|
||||||
void* FirstPageAlloc = (void*) AllocateFrame();
|
/*(void* FirstPageAlloc = (void*)*/ AllocateFrame();
|
||||||
size_t SecondPage = SeekFrame();
|
size_t SecondPage = SeekFrame();
|
||||||
void* SecondPageAlloc = (void*) AllocateFrame();
|
/*void* SecondPageAlloc = (void*)*/ AllocateFrame();
|
||||||
|
|
||||||
if(!(FirstPage == 0 && SecondPage == 1)) {
|
if(!(FirstPage == 0 && SecondPage == 1)) {
|
||||||
Passed = false;
|
Passed = false;
|
||||||
|
|
|
@ -41,10 +41,9 @@ size_t ReadModelSpecificRegister(size_t MSR) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t WriteModelSpecificRegister(size_t MSR, size_t Data) {
|
size_t WriteModelSpecificRegister(size_t MSR, size_t Data) {
|
||||||
size_t DataLow = 0, DataHigh = 0;
|
|
||||||
|
|
||||||
DataLow = ((uint32_t*) &Data)[0];
|
const size_t DataLow = Data & 0x00000000ffffffff;
|
||||||
DataHigh = ((uint32_t*) &Data)[1];
|
const size_t DataHigh = (Data & 0xffffffff00000000) >> 32;
|
||||||
|
|
||||||
__asm__ __volatile__ ("wrmsr" : : "a" (DataLow), "c" (MSR), "d" (DataHigh) :);
|
__asm__ __volatile__ ("wrmsr" : : "a" (DataLow), "c" (MSR), "d" (DataHigh) :);
|
||||||
|
|
||||||
|
@ -104,6 +103,8 @@ size_t ReadControlRegister(int CRX) {
|
||||||
__asm__ __volatile__ ("pushfq\n\t" "popq %[dest]" : [dest] "=r" (Data) : :);
|
__asm__ __volatile__ ("pushfq\n\t" "popq %[dest]" : [dest] "=r" (Data) : :);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
SerialPrintf("invalid crx read %x\r\n",CRX);
|
||||||
|
Data = 0xdeadbeef;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +149,12 @@ size_t ReadExtendedControlRegister(size_t XCRX) {
|
||||||
return (RegHigh << 32 | RegLow);
|
return (RegHigh << 32 | RegLow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: make this just have an assert as returning data for a write to catch
|
||||||
|
// errors that shoudlunt really happen doesent make alot of sense
|
||||||
size_t WriteExtendedControlRegister(size_t XCRX, size_t Data){
|
size_t WriteExtendedControlRegister(size_t XCRX, size_t Data){
|
||||||
|
uint32_t DataLow = Data & 0xffffffff;
|
||||||
__asm__ __volatile__("xsetbv" : : "a" ( ((uint32_t*) &Data)[0]), "c" (XCRX), "d" ( ((uint32_t*) &Data)[1] ) :);
|
uint32_t DataHigh = (Data & 0xffffffff00000000) >> 32;
|
||||||
|
__asm__ __volatile__("xsetbv" : : "a" (DataLow), "c" (XCRX), "d" (DataHigh) :);
|
||||||
return Data;
|
return Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ static void DrawChar(const char character, size_t x, size_t y) {
|
||||||
|
|
||||||
// This one is crazy. Stick with me.
|
// This one is crazy. Stick with me.
|
||||||
|
|
||||||
if((FONT[character][Row * Y + X] >> (Bit & 0x7)) & 1) { // Check the bit in the bitmap, if it's solid..
|
if((FONT[(int)character][Row * Y + X] >> (Bit & 0x7)) & 1) { // Check the bit in the bitmap, if it's solid..
|
||||||
for(uint32_t ScaleY = 0; ScaleY < PrintInfo.charScale; ScaleY++) { // Take care of the scale height
|
for(uint32_t ScaleY = 0; ScaleY < PrintInfo.charScale; ScaleY++) { // Take care of the scale height
|
||||||
for(uint32_t ScaleX = 0; ScaleX < PrintInfo.charScale; ScaleX++) { // And the scale width
|
for(uint32_t ScaleX = 0; ScaleX < PrintInfo.charScale; ScaleX++) { // And the scale width
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void WriteChar(const char character) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteString(const char* string) {
|
void WriteString(const char* string) {
|
||||||
for(int i = 0; i < strlen(string); i++) {
|
for(unsigned int i = 0; i < strlen(string); i++) {
|
||||||
WriteChar(string[i]);
|
WriteChar(string[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,15 +276,15 @@ void WriteStringWithFont(const char *inChar)
|
||||||
{
|
{
|
||||||
psf_t *font = (psf_t*) &_binary_font_psf_start;
|
psf_t *font = (psf_t*) &_binary_font_psf_start;
|
||||||
|
|
||||||
int drawX, drawY, kx = 0, fontLine, bitMask, offset;
|
unsigned int drawX, drawY, kx = 0, fontLine, bitMask, offset;
|
||||||
|
|
||||||
int bytesPerLine = ( font -> glyphWidth + 7 ) / 8;
|
const unsigned int bytesPerLine = ( font -> glyphWidth + 7 ) / 8;
|
||||||
|
|
||||||
while(*inChar) {
|
while(*inChar) {
|
||||||
unsigned char *glyph =
|
unsigned char *glyph =
|
||||||
(unsigned char*) &_binary_font_psf_start
|
(unsigned char*) &_binary_font_psf_start
|
||||||
+ font->headerSize
|
+ font->headerSize
|
||||||
+ (*inChar > 0 && *inChar < font->numGlyphs ? *inChar : 0) *
|
+ (*inChar > 0 && *inChar < (int)font->numGlyphs ? *inChar : 0) *
|
||||||
font->glyphSize;
|
font->glyphSize;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <kernel/video/tty.h>
|
|
||||||
|
|
||||||
#include <kernel/video/vga-textmode.h>
|
|
||||||
|
|
||||||
static const size_t TERM_WIDTH = 80;
|
|
||||||
static const size_t TERM_HEIGHT = 25;
|
|
||||||
|
|
||||||
size_t TERM_ROW;
|
|
||||||
size_t TERM_COL;
|
|
||||||
uint8_t TERM_COLOR;
|
|
||||||
|
|
||||||
uint16_t* TERM_BUFFER;
|
|
||||||
|
|
||||||
void Term_Init(void) {
|
|
||||||
|
|
||||||
TERM_ROW = 0;
|
|
||||||
TERM_COL = 0;
|
|
||||||
TERM_COLOR = VGACharColor(VGA_COLOR_LIGHTGREY, VGA_COLOR_BLACK);
|
|
||||||
|
|
||||||
TERM_BUFFER = (uint16_t*) 0xB8000;
|
|
||||||
|
|
||||||
for(size_t y = 0; y < TERM_HEIGHT; y++) {
|
|
||||||
for(size_t x = 0; x < TERM_WIDTH; x++) {
|
|
||||||
const size_t index = y * TERM_WIDTH + x;
|
|
||||||
TERM_BUFFER[index] = VGAChar(' ', TERM_COLOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Term_SetColor(uint8_t color) {
|
|
||||||
TERM_COLOR = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Term_PutVGAChar(char c, uint8_t color, size_t x, size_t y) {
|
|
||||||
const size_t index = y * TERM_WIDTH + x;
|
|
||||||
TERM_BUFFER[index] = VGAChar(c, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Term_PutChar(char c) {
|
|
||||||
Term_PutVGAChar(c, TERM_COLOR, TERM_COL, TERM_ROW);
|
|
||||||
|
|
||||||
if(++TERM_COL == TERM_WIDTH) {
|
|
||||||
TERM_COL = 0;
|
|
||||||
if(++TERM_ROW == TERM_HEIGHT)
|
|
||||||
TERM_ROW = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Term_Write(const char* str, size_t len) {
|
|
||||||
for(size_t i = 0; i < len; i++)
|
|
||||||
Term_PutChar(str[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Term_WriteString(const char* str) {
|
|
||||||
Term_Write(str, strlen(str));
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
chroma/video/tty.o: chroma/video/tty.c chroma/inc/kernel/video/tty.h \
|
|
||||||
chroma/inc/kernel/video/vga-textmode.h
|
|
||||||
|
|
||||||
chroma/inc/kernel/video/tty.h:
|
|
||||||
|
|
||||||
chroma/inc/kernel/video/vga-textmode.h:
|
|
BIN
iso/boot/initrd
BIN
iso/boot/initrd
Binary file not shown.
BIN
kernel.elf
BIN
kernel.elf
Binary file not shown.
Loading…
Reference in New Issue
Block a user