Move BootGDT definition to C
This commit is contained in:
parent
3508b182b7
commit
04f2123499
@ -43,7 +43,7 @@ _start:
|
|||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
|
|
||||||
//; Load a new GDT
|
//; Load a new GDT
|
||||||
lgdt [V2P(BootGDTp)]
|
lgdt [V2P(GDTp)]
|
||||||
|
|
||||||
//; and update the code selector by a long jump
|
//; and update the code selector by a long jump
|
||||||
jmp 0x8:V2P(long_mode_start)
|
jmp 0x8:V2P(long_mode_start)
|
||||||
@ -76,7 +76,7 @@ upper_memory:
|
|||||||
mov cr3, rax
|
mov cr3, rax
|
||||||
|
|
||||||
//; Reload GDT
|
//; Reload GDT
|
||||||
movabs rax, offset BootGDTp
|
movabs rax, offset GDTp
|
||||||
lgdt [rax]
|
lgdt [rax]
|
||||||
mov rax, 0x0
|
mov rax, 0x0
|
||||||
mov ss, rax
|
mov ss, rax
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#include <gdt.h>
|
|
||||||
#include <memory.h>
|
|
||||||
.intel_syntax noprefix
|
|
||||||
|
|
||||||
.section .rodata
|
|
||||||
.align PAGE_SIZE
|
|
||||||
.global BootGDT
|
|
||||||
.global BootGDTp
|
|
||||||
BootGDT:
|
|
||||||
.long 0, 0
|
|
||||||
.long 0, (GDT_PRESENT | GDT_DPL(0) | GDT_CODE | GDT_LONG)
|
|
||||||
BootGDTp:
|
|
||||||
.short 2*8-1
|
|
||||||
.quad offset BootGDT
|
|
28
src/kernel/cpu/gdt.c
Normal file
28
src/kernel/cpu/gdt.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <cpu.h>
|
||||||
|
|
||||||
|
#define GDT_CODE (3<<11)
|
||||||
|
#define GDT_DPL(lvl) ((lvl)<<13)
|
||||||
|
#define GDT_PRESENT (1<<15)
|
||||||
|
#define GDT_LONG (1<<21)
|
||||||
|
|
||||||
|
|
||||||
|
struct gdt
|
||||||
|
{
|
||||||
|
uint32_t _;
|
||||||
|
uint32_t flags;
|
||||||
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
struct gdtp
|
||||||
|
{
|
||||||
|
uint16_t len;
|
||||||
|
struct gdt *gdt;
|
||||||
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
|
||||||
|
struct gdt BootGDT[] = {
|
||||||
|
{0, 0},
|
||||||
|
{0, GDT_PRESENT | GDT_DPL(0) | GDT_CODE | GDT_LONG}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gdtp GDTp = {2*8-1, BootGDT};
|
@ -1,6 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define GDT_CODE (3<<11)
|
|
||||||
#define GDT_DPL(lvl) ((lvl)<<13)
|
|
||||||
#define GDT_PRESENT (1<<15)
|
|
||||||
#define GDT_LONG (1<<21)
|
|
Loading…
x
Reference in New Issue
Block a user