Add printing GDT entries
This commit is contained in:
parent
64b01f8433
commit
366bd653f8
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <main.h>
|
||||
|
||||
#include "gdt.h"
|
||||
|
||||
static uint8_t stack[4096] = {0};
|
||||
void stivale2_main(struct stivale2_struct *info);
|
||||
|
||||
|
|
@ -28,7 +30,7 @@ struct stivale2_header header2 = {
|
|||
|
||||
void stivale2_main(struct stivale2_struct *info) {
|
||||
parse_stivale2(info);
|
||||
print_stivale2_memmap(info);
|
||||
// print_stivale2_memmap(info);
|
||||
|
||||
uint64_t* cr3;
|
||||
__asm__ __volatile__ (
|
||||
|
|
@ -39,6 +41,14 @@ void stivale2_main(struct stivale2_struct *info) {
|
|||
);
|
||||
printf("PAGE TABLE AT: %x\n", cr3);
|
||||
|
||||
struct gdt_ptr pGDT;
|
||||
__asm__ __volatile__("sgdt %0" : : "m"(pGDT) : "memory");
|
||||
printf("GDT: %x (%d)\n", pGDT.base, pGDT.limit);
|
||||
for(int i = 0; i < (pGDT.limit+1)/8; i++) {
|
||||
uint64_t *gdt_ent = pGDT.base + 8*i;
|
||||
printf("GDTent(%d at %x): %x\n", i, gdt_ent, *gdt_ent);
|
||||
}
|
||||
|
||||
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
|
||||
kmain(3, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
#include <stdint.h>
|
||||
|
||||
struct gdt_ptr
|
||||
{
|
||||
uint16_t limit;
|
||||
uint64_t base;
|
||||
} __attribute__((packed));
|
||||
|
||||
void loadgdt();
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
section .rodata
|
||||
gdt64:
|
||||
dq 0
|
||||
.code: equ $-gdt64
|
||||
dq (1<<44) | (1<<47) | (1<<41) | (1<<43) | (1<<53)
|
||||
.data: equ $ - gdt64
|
||||
dq (1<<44) | (1<<47) | (1<<41)
|
||||
.pointer:
|
||||
dw .pointer - gdt64 - 1
|
||||
dq gdt64
|
||||
|
||||
section .text
|
||||
global loadgdt
|
||||
loadgdt:
|
||||
lgdt [gdt64.pointer]
|
||||
|
||||
Loading…
Reference in New Issue