Compare commits

...

3 Commits

5 changed files with 24 additions and 18 deletions

View File

@ -18,7 +18,6 @@ struct stivale2_header header2 = {
void stivale2_main(struct stivale2_struct *info) {
parse_stivale2(info);
print_stivale2_memmap(info);
uint32_t* cr3;
__asm__ __volatile__ (
@ -29,5 +28,7 @@ void stivale2_main(struct stivale2_struct *info) {
);
printf("PAGE TABLE AT: %x\n", cr3);
print_gdt();
kmain();
}

View File

@ -1,5 +1,7 @@
#include <print/print.h>
#include <stddef.h>
#include "gdt.h"
void print_gdt_ent(uint64_t* ent) {
@ -14,7 +16,7 @@ void print_gdt_ent(uint64_t* ent) {
int bits = (flags&0x2) ? 64 : ((flags&0x4) ? 32 : 16);
uint64_t length = limit * ((flags & 0x8) ? 4096 : 1);
printf("%X (%h): \t", base, length);
printf("%X (%h): \t", (size_t)base, (size_t)length);
if(e == 0) {
puts("NULL");
return;
@ -30,3 +32,13 @@ void print_gdt_ent(uint64_t* ent) {
if(flags & 0x8) putchar('G');
if(flags & 0x1) putchar('z');
}
void print_gdt() {
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("GDT %d: ", i); print_gdt_ent(gdt_ent); putchar('\n');
}
}

View File

@ -1,3 +1,10 @@
#include <stdint.h>
struct gdt_ptr
{
uint16_t limit;
uint64_t base;
} __attribute__((packed));
void print_gdt_ent(uint64_t* ent);
void print_gdt();

View File

@ -3,7 +3,6 @@
#include <stddef.h>
#include <arch/x86/stivale2-parse.h>
#include <arch/x86/gdt.h>
#include <arch/x86_64/gdt.h>
#include <print/print.h>
@ -45,14 +44,7 @@ void stivale2_main(struct stivale2_struct *info) {
printf("PAGE TABLE AT: %x\n", cr3);
loadgdt();
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 = (uint64_t*)(pGDT.base + 8*i);
printf("GDT %d: ", i); print_gdt_ent(gdt_ent); putchar('\n');
}
print_gdt();
asmpanic();
kmain();

View File

@ -1,9 +1,3 @@
#include <stdint.h>
struct gdt_ptr
{
uint16_t limit;
uint64_t base;
} __attribute__((packed));
#include <arch/x86/gdt.h>
void loadgdt();