VGA renaming

This commit is contained in:
Mathieu Maret 2021-01-25 14:00:06 +01:00
parent 3f4fb9e952
commit ede53ae4f9
7 changed files with 32 additions and 26 deletions

View File

@ -11,7 +11,7 @@
ulong error_code) \ ulong error_code) \
{ \ { \
int intNbInt = int_nb; \ int intNbInt = int_nb; \
VGAprintf(RED, BLACK, 0, VGA_HEIGHT - 1, "EXCEPTION %d %d", intNbInt, error_code); \ VGAPrintf(RED, BLACK, 0, VGA_HEIGHT - 1, "EXCEPTION %d %d", intNbInt, error_code); \
printf("Exception %d (Err %d) at 0x%x\n", int_nb, error_code, frame->eip); \ printf("Exception %d (Err %d) at 0x%x\n", int_nb, error_code, frame->eip); \
asm("hlt"); \ asm("hlt"); \
} }
@ -62,7 +62,7 @@ __attribute__((interrupt)) void pagefault_handler(struct interrupt_frame *frame,
struct kthread *current = getCurrentThread(); struct kthread *current = getCurrentThread();
printf("page fault while in thread %s\n", current->name); printf("page fault while in thread %s\n", current->name);
VGAprintf(RED, BLACK, 0, VGA_HEIGHT - 1, "PAGE FAULT %d", error_code); VGAPrintf(RED, BLACK, 0, VGA_HEIGHT - 1, "PAGE FAULT %d", error_code);
(void)faulting_address; (void)faulting_address;
(void)frame; (void)frame;
(void)error_code; (void)error_code;

View File

@ -18,7 +18,7 @@ __attribute__((interrupt)) void timer_handler(struct interrupt_frame *frame)
{ {
static int timeCnt = 0; static int timeCnt = 0;
EOIIrq(IRQ_TIMER); EOIIrq(IRQ_TIMER);
VGAprintf(RED, BLACK, 20, VGA_HEIGHT - 1, "IRQ %d", timeCnt++); VGAPrintf(RED, BLACK, 20, VGA_HEIGHT - 1, "IRQ %d", timeCnt++);
(void)frame; (void)frame;
} }

View File

@ -98,7 +98,7 @@ int allocSlab(struct slabDesc **desc, size_t size, size_t sizeSlab, int selfCont
pr_devel("%s for size %d is self %d\n", __func__, size, selfContained); pr_devel("%s for size %d is self %d\n", __func__, size, selfContained);
sizeSlab = MAX(sizeSlab, PAGE_SIZE); sizeSlab = MAX(sizeSlab, PAGE_SIZE);
if (size > sizeSlab) { if (size > sizeSlab) {
pr_devel("%s size of element %d are bigger than slab size %d\n", size, sizeSlab); pr_devel("size of element %d are bigger than slab size %d\n", size, sizeSlab);
return -ENOENT; return -ENOENT;
} }
@ -141,7 +141,7 @@ int allocSlabEntry(struct slabEntry **desc, size_t size, size_t sizeSlab, int se
pr_devel("%s for size %d is self %d\n", __func__, size, selfContained); pr_devel("%s for size %d is self %d\n", __func__, size, selfContained);
sizeSlab = MAX(sizeSlab, PAGE_SIZE); sizeSlab = MAX(sizeSlab, PAGE_SIZE);
if (size > sizeSlab) { if (size > sizeSlab) {
pr_devel("%s size of element %d are bigger than slab size %d\n", size, sizeSlab); pr_devel("size of element %d are bigger than slab size %d\n", size, sizeSlab);
return -ENOENT; return -ENOENT;
} }

View File

@ -152,7 +152,7 @@ int puts(const char *str)
int putc(const char c) int putc(const char c)
{ {
VGAputc(c); VGAPutc(c);
serialPutc(c); serialPutc(c);
return (unsigned char)c; return (unsigned char)c;
} }
@ -404,7 +404,6 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
/* Determine required size */ /* Determine required size */
n = vsnprintf(p, size, fmt, ap); n = vsnprintf(p, size, fmt, ap);
printf("Found length %d\n", n);
if (n < 0) if (n < 0)
return -1; return -1;

View File

@ -27,7 +27,7 @@ void idleThread(void *arg)
{ {
(void)arg; (void)arg;
while (1) { while (1) {
VGAprintf(GREEN, BLACK, 0, VGA_HEIGHT - 1, "%d", (jiffies / HZ)); VGAPrintf(GREEN, BLACK, 0, VGA_HEIGHT - 1, "%d", (jiffies / HZ));
kthreadYield(); kthreadYield();
} }
} }
@ -42,7 +42,6 @@ void kmain(unsigned long magic, unsigned long addr)
paddr_t lastUsedByMem; paddr_t lastUsedByMem;
VGASetup(BLACK, GREEN); VGASetup(BLACK, GREEN);
cursorEnable(14, 15);
printf("Setting up Interruptions\n"); printf("Setting up Interruptions\n");
gdtSetup(); gdtSetup();
@ -97,7 +96,9 @@ void kmain(unsigned long magic, unsigned long addr)
multiboot_info_t *mbi = (multiboot_info_t *)addr; multiboot_info_t *mbi = (multiboot_info_t *)addr;
struct multiboot_mmap_entry *mmap = (struct multiboot_mmap_entry *)mbi->mmap_addr; struct multiboot_mmap_entry *mmap = (struct multiboot_mmap_entry *)mbi->mmap_addr;
uint size = mbi->mmap_length / sizeof(struct multiboot_mmap_entry); uint size = mbi->mmap_length / sizeof(struct multiboot_mmap_entry);
pr_devel("mmap buffer at 0x%x with %d entries\n", mbi->mmap_addr, size); pr_devel("mmap buffer at 0x%x with %d entries\n", mbi->mmap_addr, size);
for (uint i = 0; i < size; i++) { for (uint i = 0; i < size; i++) {
printf(" base_addr 0x%llx, length = 0x%llx, type = 0x%x\n", mmap[i].addr, printf(" base_addr 0x%llx, length = 0x%llx, type = 0x%x\n", mmap[i].addr,
mmap[i].len, (uint32_t)mmap[i].type); mmap[i].len, (uint32_t)mmap[i].type);
@ -109,6 +110,7 @@ void kmain(unsigned long magic, unsigned long addr)
memAddBank(0, lastUsedByMem, 0); memAddBank(0, lastUsedByMem, 0);
memAddBank(lastUsedByMem, upperMemKB * 1024, 1); memAddBank(lastUsedByMem, upperMemKB * 1024, 1);
} }
#ifdef RUN_TEST #ifdef RUN_TEST
testPhymem(); testPhymem();
#endif #endif
@ -125,9 +127,14 @@ void kmain(unsigned long magic, unsigned long addr)
printf("Setting up Serial link (115200)\n"); printf("Setting up Serial link (115200)\n");
serialSetup(115200); serialSetup(115200);
printf("Setting up allocation system\n");
allocSetup(); allocSetup();
printf("Setting up thread system\n");
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1)); kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
kthreadCreate("idle ", idleThread, NULL); kthreadCreate("idle ", idleThread, NULL);
irqSetRoutine(IRQ_TIMER, pit_handler); irqSetRoutine(IRQ_TIMER, pit_handler);
#ifdef RUN_TEST #ifdef RUN_TEST
run_test(); run_test();

View File

@ -9,6 +9,9 @@ static int line, col;
static volatile short *vga = (short *)VGA_ADDR; static volatile short *vga = (short *)VGA_ADDR;
static void clearScreen(uint bgColor); static void clearScreen(uint bgColor);
static void cursorMove(int x, int y);
static void cursorEnable(uint8_t cursor_start, uint8_t cursor_end);
static void printCharDetails(char str, uint color, uint bgColor, int startX, int startY);
int VGASetup(uint bgColor, uint color) int VGASetup(uint bgColor, uint color)
{ {
@ -17,6 +20,7 @@ int VGASetup(uint bgColor, uint color)
line = 0; line = 0;
col = 0; col = 0;
clearScreen(bgColor); clearScreen(bgColor);
cursorEnable(14, 15);
return 0; return 0;
} }
@ -32,7 +36,7 @@ static void clearScreen(uint bgColor)
restore_IRQs(flags); restore_IRQs(flags);
} }
void clearScreenLine(uint bgColor, uint line) void VGAclearLine(uint bgColor, uint line)
{ {
uint32_t flags; uint32_t flags;
long int colorAttr = bgColor << 12; long int colorAttr = bgColor << 12;
@ -47,7 +51,7 @@ void clearScreenLine(uint bgColor, uint line)
restore_IRQs(flags); restore_IRQs(flags);
} }
void VGAprintf(uint color, uint bgColor, int startX, int startY, const char *format, ...) void VGAPrintf(uint color, uint bgColor, int startX, int startY, const char *format, ...)
{ {
int flags; int flags;
char tmp[VGA_WIDTH]; char tmp[VGA_WIDTH];
@ -68,13 +72,13 @@ void VGAprintf(uint color, uint bgColor, int startX, int startY, const char *for
restore_IRQs(flags); restore_IRQs(flags);
} }
void printCharDetails(const char str, uint color, uint bgColor, int startX, int startY) static void printCharDetails(const char str, uint color, uint bgColor, int startX, int startY)
{ {
long int colorAttr = (bgColor << 4 | (color & 0x0f)) << 8; long int colorAttr = (bgColor << 4 | (color & 0x0f)) << 8;
vga[VGA_WIDTH * startY + startX] = colorAttr | str; vga[VGA_WIDTH * startY + startX] = colorAttr | str;
} }
void vgaScrollUp(void) void VGAScrollUp(void)
{ {
long int colorAttr = vgaBgColor << 12; long int colorAttr = vgaBgColor << 12;
int flags; int flags;
@ -90,7 +94,7 @@ void vgaScrollUp(void)
restore_IRQs(flags); restore_IRQs(flags);
} }
void VGAputc(const char str) void VGAPutc(const char str)
{ {
int flags; int flags;
@ -99,7 +103,7 @@ void VGAputc(const char str)
line++; line++;
col = 0; col = 0;
if (line >= VGA_HEIGHT - 1) { if (line >= VGA_HEIGHT - 1) {
vgaScrollUp(); VGAScrollUp();
line--; line--;
} }
} else if (str == '\r') { } else if (str == '\r') {
@ -118,7 +122,7 @@ void VGAputc(const char str)
line++; line++;
} }
if (line >= VGA_HEIGHT - 1) { if (line >= VGA_HEIGHT - 1) {
vgaScrollUp(); VGAScrollUp();
line--; line--;
} }
} }
@ -127,7 +131,7 @@ void VGAputc(const char str)
restore_IRQs(flags); restore_IRQs(flags);
} }
void cursorEnable(uint8_t cursor_start, uint8_t cursor_end) static void cursorEnable(uint8_t cursor_start, uint8_t cursor_end)
{ {
outb(0x3D4, 0x0A); outb(0x3D4, 0x0A);
outb(0x3D5, (inb(0x3D5) & 0xC0) | cursor_start); outb(0x3D5, (inb(0x3D5) & 0xC0) | cursor_start);
@ -142,7 +146,7 @@ void cursorDisable(void)
outb(0x3D5, 0x20); outb(0x3D5, 0x20);
} }
void cursorMove(int x, int y) static void cursorMove(int x, int y)
{ {
long int colorAttr = (vgaBgColor << 4 | (vgaColor & 0x0f)) << 8; long int colorAttr = (vgaBgColor << 4 | (vgaColor & 0x0f)) << 8;
uint16_t pos = y * VGA_WIDTH + x; uint16_t pos = y * VGA_WIDTH + x;

View File

@ -18,11 +18,7 @@
#define VGA_HEIGHT 25 #define VGA_HEIGHT 25
int VGASetup(uint bgColor, uint color); int VGASetup(uint bgColor, uint color);
void VGAputc(const char str); void VGAPutc(const char str);
void VGAprintf(uint color, uint bgColor, int startX, int startY, const char *format, ...); void VGAPrintf(uint color, uint bgColor, int startX, int startY, const char *format, ...);
void clearScreenLine(uint bgColor, uint line); void VGAClearLine(uint bgColor, uint line);
void printCharDetails(char str, uint color, uint bgColor, int startX, int startY); void VGAScrollUp(void);
void vgaScrollUp(void);
void cursorEnable(uint8_t cursor_start, uint8_t cursor_end);
void cursorDisable(void);
void cursorMove(int x, int y);