Compare commits

..

No commits in common. "5383bf80d30e28356447b2a07a233373963ed6b7" and "61c5386355178c7600764d589ad8aa418688bf56" have entirely different histories.

5 changed files with 18 additions and 24 deletions

View File

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

View File

@ -1,7 +1,5 @@
#include <print/print.h>
#include <stddef.h>
#include "gdt.h"
void print_gdt_ent(uint64_t* ent) {
@ -16,7 +14,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", (size_t)base, (size_t)length);
printf("%X (%h): \t", base, length);
if(e == 0) {
puts("NULL");
return;
@ -32,13 +30,3 @@ 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,10 +1,3 @@
#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,6 +3,7 @@
#include <stddef.h>
#include <arch/x86/stivale2-parse.h>
#include <arch/x86/gdt.h>
#include <arch/x86_64/gdt.h>
#include <print/print.h>
@ -44,7 +45,14 @@ void stivale2_main(struct stivale2_struct *info) {
printf("PAGE TABLE AT: %x\n", cr3);
loadgdt();
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 = (uint64_t*)(pGDT.base + 8*i);
printf("GDT %d: ", i); print_gdt_ent(gdt_ent); putchar('\n');
}
asmpanic();
kmain();

View File

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