some cleanup from debugging and todos
This commit is contained in:
@ -31,8 +31,6 @@ section .text
|
|||||||
loader:
|
loader:
|
||||||
mov esp, kernel_stack + KERNEL_STACK_SIZE ; move the top of the stack into esp
|
mov esp, kernel_stack + KERNEL_STACK_SIZE ; move the top of the stack into esp
|
||||||
|
|
||||||
call gdt_init
|
|
||||||
|
|
||||||
call kmain ; pass execution over to our kmain function, where all of the real stuff is done
|
call kmain ; pass execution over to our kmain function, where all of the real stuff is done
|
||||||
|
|
||||||
; Should the system exit, we clear the interrupt flag
|
; Should the system exit, we clear the interrupt flag
|
||||||
|
@ -8,8 +8,12 @@ setGdt:
|
|||||||
mov eax, [esp + 8]
|
mov eax, [esp + 8]
|
||||||
mov [gdtr + 2], eax
|
mov [gdtr + 2], eax
|
||||||
lgdt [gdtr]
|
lgdt [gdtr]
|
||||||
jmp 0x08:reload_CS ; 0x08 is a stand in for the code segment
|
ret
|
||||||
reload_CS:
|
|
||||||
|
global reloadSegments
|
||||||
|
reloadSegments:
|
||||||
|
jmp 0x08:.reload_CS ; 0x08 is a stand in for the code segment
|
||||||
|
.reload_CS:
|
||||||
mov ax, 0x10 ; stand in for the data segment
|
mov ax, 0x10 ; stand in for the data segment
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
@ -67,7 +67,7 @@ void gdt_init(void)
|
|||||||
//gdt[4] = create_descriptor(0, 0x000FFFFF, (GDT_DATA_PL3)); // user data
|
//gdt[4] = create_descriptor(0, 0x000FFFFF, (GDT_DATA_PL3)); // user data
|
||||||
|
|
||||||
setGdt((sizeof(uint64_t) * GDT_SIZE) - 1, &(gdt[0])); // limit, base
|
setGdt((sizeof(uint64_t) * GDT_SIZE) - 1, &(gdt[0])); // limit, base
|
||||||
//reloadSegments();
|
reloadSegments();
|
||||||
#ifdef __TESTING__
|
#ifdef __TESTING__
|
||||||
kinfo("Initialized the GDT");
|
kinfo("Initialized the GDT");
|
||||||
dump_gdt();
|
dump_gdt();
|
||||||
|
@ -17,18 +17,22 @@ static bool vectors[IDT_MAX_DESCRIPTORS];
|
|||||||
|
|
||||||
void exception_handler(unsigned int i)
|
void exception_handler(unsigned int i)
|
||||||
{
|
{
|
||||||
|
if (i <= 31) { // TODO: implement proper handling for each exception, also implement the proper gates & error code checking
|
||||||
#ifdef __TESTING__
|
#ifdef __TESTING__
|
||||||
kerror("EXCEPTION");
|
kerror("EXCEPTION");
|
||||||
printf("Exeption: %u\n", i);
|
printf("Exeption: %u\n", i);
|
||||||
#endif
|
#endif
|
||||||
if (i <= 31)
|
|
||||||
__asm__ volatile ("cli; hlt"); // hangs the computer
|
__asm__ volatile ("cli; hlt"); // hangs the computer
|
||||||
|
}
|
||||||
|
|
||||||
if (i == PIC_KEYB) {
|
if (i == PIC_KEYB) {
|
||||||
#ifdef __TESTING__
|
#ifdef __TESTING__
|
||||||
kinfo("Sending EOI instruction to KEYB");
|
kinfo("Sending EOI instruction to KEYB");
|
||||||
#endif
|
#endif
|
||||||
printf("Scancode: %x\n", inb(0x60)); // read from kb
|
printf("Scancode: %x\n", inb(0x60)); // read from kb
|
||||||
|
/**
|
||||||
|
* TODO: this is a cute temporary fix but lets do a real keyboard driver please?
|
||||||
|
*/
|
||||||
|
|
||||||
PIC_sendEOI(1);
|
PIC_sendEOI(1);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void kmain(void)
|
|||||||
terminal_initialize();
|
terminal_initialize();
|
||||||
serial_initialize();
|
serial_initialize();
|
||||||
#endif
|
#endif
|
||||||
//gdt_init();
|
gdt_init();
|
||||||
idt_init();
|
idt_init();
|
||||||
|
|
||||||
#ifndef __TESTING__
|
#ifndef __TESTING__
|
||||||
|
Reference in New Issue
Block a user