adds a utility to dump the gdt, adds serial printing for printf in testing
This commit is contained in:
@ -1,9 +1,14 @@
|
|||||||
#include <kernel/x86/gdt.h>
|
#include <kernel/x86/gdt.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __TESTING__
|
#ifdef __TESTING__
|
||||||
#include <kernel/_kernel.h>
|
#include <kernel/_kernel.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t gdt[GDT_SIZE];
|
||||||
|
|
||||||
uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag)
|
uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag)
|
||||||
{
|
{
|
||||||
uint64_t descriptor;
|
uint64_t descriptor;
|
||||||
@ -21,7 +26,7 @@ uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag)
|
|||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdt_init(uint64_t* gdt)
|
void gdt_init(void)
|
||||||
{
|
{
|
||||||
#ifdef __TESTING__
|
#ifdef __TESTING__
|
||||||
kinfo("Initializing the GDT");
|
kinfo("Initializing the GDT");
|
||||||
@ -36,5 +41,13 @@ void gdt_init(uint64_t* gdt)
|
|||||||
reloadSegments();
|
reloadSegments();
|
||||||
#ifdef __TESTING__
|
#ifdef __TESTING__
|
||||||
kinfo("Initialized the GDT");
|
kinfo("Initialized the GDT");
|
||||||
|
dump_gdt();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dump_gdt(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < GDT_SIZE; i++) {
|
||||||
|
printf("GDT_ENTRY %d: %1 | %2\n", i, gdt[i], gdt[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -56,8 +56,11 @@ void reloadSegments();
|
|||||||
|
|
||||||
uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag);
|
uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag);
|
||||||
|
|
||||||
void gdt_init(uint64_t* gdt);
|
void gdt_init(void);
|
||||||
|
|
||||||
|
void dump_gdt(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,15 +8,13 @@
|
|||||||
#include <kernel/x86/idt.h>
|
#include <kernel/x86/idt.h>
|
||||||
#include <kernel/x86/pic.h>
|
#include <kernel/x86/pic.h>
|
||||||
|
|
||||||
uint64_t gdt[GDT_SIZE];
|
|
||||||
|
|
||||||
void kmain(void)
|
void kmain(void)
|
||||||
{
|
{
|
||||||
#ifdef __TESTING__ // important components should be declared first, but if we're testing we want to log all of that
|
#ifdef __TESTING__ // important components should be declared first, but if we're testing we want to log all of that
|
||||||
terminal_initialize();
|
terminal_initialize();
|
||||||
serial_initialize();
|
serial_initialize();
|
||||||
#endif
|
#endif
|
||||||
gdt_init(gdt);
|
gdt_init();
|
||||||
idt_init();
|
idt_init();
|
||||||
PIC_remap(0x20, 0x28);
|
PIC_remap(0x20, 0x28);
|
||||||
|
|
||||||
@ -24,8 +22,4 @@ void kmain(void)
|
|||||||
terminal_initialize();
|
terminal_initialize();
|
||||||
serial_initialize();
|
serial_initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
printf("Integer: %1\n", gdt[1]);
|
|
||||||
printf("Hex Int: %x\n", 2);
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
#if defined(__is_libk)
|
#if defined(__is_libk)
|
||||||
#include <kernel/tty.h>
|
#include <kernel/tty.h>
|
||||||
|
#ifdef __TESTING__
|
||||||
|
#include <kernel/serial.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int putchar(int ic) {
|
int putchar(int ic) {
|
||||||
#if defined(__is_libk)
|
#if defined(__is_libk)
|
||||||
char c = (char) ic;
|
char c = (char) ic;
|
||||||
terminal_write(&c, sizeof(c));
|
terminal_write(&c, sizeof(c));
|
||||||
|
#ifdef __TESTING__
|
||||||
|
serial_write(&c, sizeof(c));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
// TODO: Implement stdio and the write system call.
|
// TODO: Implement stdio and the write system call.
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user