Added sequence to remap PIC

Wrote GDT code in C
Added routines to initialize GDT and IDT
This commit is contained in:
2021-04-16 01:45:40 -05:00
parent 8e6589b472
commit 6138766c49
7 changed files with 223 additions and 74 deletions

View File

@@ -1,12 +1,34 @@
#include "mmgr.h"
#include "apic.h"
#include "msr.h"
#include "stdio.h"
#include <stddef.h>
extern int _kernel_end;
void apic_enable(struct page_stact_t *page_stack)
{
// Remap and mask 8259 PIC
asm volatile(
"mov $0x11, %%al;"
"outb %%al, $0x20;"
"outb %%al, $0xA0;"
"mov $0x20, %%al;"
"outb %%al, $0x21;"
"mov $0x28, %%al;"
"outb %%al, $0xA1;"
"mov $4, %%al;"
"outb %%al, $0x21;"
"mov $2, %%al;"
"outb %%al, $0xA1;"
"mov $0x01, %%al;"
"outb %%al, $0x21;"
"outb %%al, $0xA1;"
"mov $0xFF, %%al;"
"outb %%al, $0xA1;"
"outb %%al, $0x21;"
::: "al"
);
struct msr_apic_base_t msr;
read_msr(MSR_APIC_BASE, (uint64_t*)&msr);
map_page(page_stack, &_kernel_end, msr.apic_base << 12, 0);