Change _start to kmain

This commit is contained in:
Michael Shaw 2023-02-27 18:46:50 -05:00
commit 4410dde3f2
4 changed files with 17 additions and 5 deletions

View file

@ -6,7 +6,7 @@
#define IDT_GATE_SIZE 16
#define IDT_NUM_VECTORS 256
#define IDT_SIZE 32768
#define IDT_SIZE (IDT_GATE_SIZE * IDT_NUM_VECTORS)
#ifndef __ASM__
@ -27,6 +27,8 @@ struct idtr {
uint64_t offset;
};
void idt_init();
extern struct idtr __idtr;
extern struct irqdesc __idt[IDT_NUM_VECTORS];

View file

@ -1,7 +1,9 @@
#include <kernel/idt.h>
void idt_insert(uint16_t gate, uint8_t type, uint8_t ist,
uint16_t segment, void *func)
void idt_load();
void idt_insert(uint16_t gate, uint8_t type, uint8_t ist, uint16_t segment,
void *func)
{
uintptr_t f = (uintptr_t)(func);
struct irqdesc *irqdesc = (__idt + gate);
@ -16,4 +18,9 @@ void idt_insert(uint16_t gate, uint8_t type, uint8_t ist,
void idt_init()
{
__idtr.size = (IDT_SIZE - 1);
__idtr.offset = (uint64_t)__idt;
idt_load();
printf("IDT successfully loaded\n");
}

View file

@ -1,5 +1,7 @@
#include <kernel/common.h>
#include <kernel/gdt.h>
#include <kernel/idt.h>
#include <dev/serial.h>
#include <limine/limine.h>
@ -11,9 +13,10 @@ static void done(void)
}
}
void _start(void)
void kmain(void)
{
gdt_init();
idt_init();
serial_init();
done();

View file

@ -3,7 +3,7 @@ OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
/* We want the symbol _start to be our entry point */
ENTRY(_start)
ENTRY(kmain)
/* Define the program headers we want so the bootloader gives us the right */
/* MMU permissions */