make printing GDT work on both x86
This commit is contained in:
parent
fb71a09ec4
commit
529c1e2a80
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,3 +30,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');
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
@ -42,13 +41,7 @@ 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("GDT %d: ", i); print_gdt_ent(gdt_ent); putchar('\n');
|
||||
}
|
||||
print_gdt();
|
||||
|
||||
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
|
||||
kmain(3, argv);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue