Reload GDT from c
This commit is contained in:
parent
04f2123499
commit
132645c0e6
@ -1,7 +1,11 @@
|
||||
#include <cpu.h>
|
||||
#include <interrupts.h>
|
||||
|
||||
uint64_t gdt[2];
|
||||
void gdt_init(uint64_t *);
|
||||
|
||||
void cpu_init()
|
||||
{
|
||||
interrupt_init();
|
||||
gdt_init(gdt);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <cpu.h>
|
||||
#include <memory.h>
|
||||
|
||||
#define GDT_CODE (3<<11)
|
||||
#define GDT_DPL(lvl) ((lvl)<<13)
|
||||
@ -26,3 +27,15 @@ struct gdt BootGDT[] = {
|
||||
};
|
||||
|
||||
struct gdtp GDTp = {2*8-1, BootGDT};
|
||||
|
||||
|
||||
void gdt_init(uint64_t *_gdt)
|
||||
{
|
||||
struct gdt *gdt = (struct gdt *)_gdt;
|
||||
memcpy(gdt, BootGDT, sizeof(BootGDT));
|
||||
|
||||
GDTp.len = 2*8 - 1;
|
||||
GDTp.gdt = gdt;
|
||||
|
||||
load_gdt(&GDTp);
|
||||
}
|
||||
|
@ -5,6 +5,20 @@ load_idt:
|
||||
lidt [rdi]
|
||||
ret
|
||||
|
||||
.global load_gdt
|
||||
load_gdt:
|
||||
lgdt [rdi]
|
||||
mov ax, 0x0
|
||||
mov ss, ax
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
movabs rax, offset .load_gdt
|
||||
pushq 0x8
|
||||
push rax
|
||||
retfq
|
||||
.load_gdt:
|
||||
ret
|
||||
|
||||
.global read_cr0
|
||||
read_cr0:
|
||||
mov rax, cr0
|
||||
|
@ -4,7 +4,9 @@
|
||||
void cpu_init();
|
||||
|
||||
|
||||
|
||||
void load_idt(void *);
|
||||
void load_gdt(void *);
|
||||
|
||||
uint64_t read_cr0();
|
||||
uint64_t read_cr2();
|
||||
|
Loading…
x
Reference in New Issue
Block a user