Compare commits
3 Commits
61c5386355
...
5383bf80d3
| Author | SHA1 | Date |
|---|---|---|
|
|
5383bf80d3 | |
|
|
bb9ffb43ef | |
|
|
529c1e2a80 |
|
|
@ -18,7 +18,6 @@ struct stivale2_header header2 = {
|
||||||
|
|
||||||
void stivale2_main(struct stivale2_struct *info) {
|
void stivale2_main(struct stivale2_struct *info) {
|
||||||
parse_stivale2(info);
|
parse_stivale2(info);
|
||||||
print_stivale2_memmap(info);
|
|
||||||
|
|
||||||
uint32_t* cr3;
|
uint32_t* cr3;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
|
|
@ -29,5 +28,7 @@ void stivale2_main(struct stivale2_struct *info) {
|
||||||
);
|
);
|
||||||
printf("PAGE TABLE AT: %x\n", cr3);
|
printf("PAGE TABLE AT: %x\n", cr3);
|
||||||
|
|
||||||
|
print_gdt();
|
||||||
|
|
||||||
kmain();
|
kmain();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <print/print.h>
|
#include <print/print.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "gdt.h"
|
#include "gdt.h"
|
||||||
|
|
||||||
void print_gdt_ent(uint64_t* ent) {
|
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);
|
int bits = (flags&0x2) ? 64 : ((flags&0x4) ? 32 : 16);
|
||||||
|
|
||||||
uint64_t length = limit * ((flags & 0x8) ? 4096 : 1);
|
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) {
|
if(e == 0) {
|
||||||
puts("NULL");
|
puts("NULL");
|
||||||
return;
|
return;
|
||||||
|
|
@ -30,3 +32,13 @@ void print_gdt_ent(uint64_t* ent) {
|
||||||
if(flags & 0x8) putchar('G');
|
if(flags & 0x8) putchar('G');
|
||||||
if(flags & 0x1) putchar('z');
|
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>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct gdt_ptr
|
||||||
|
{
|
||||||
|
uint16_t limit;
|
||||||
|
uint64_t base;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
void print_gdt_ent(uint64_t* ent);
|
void print_gdt_ent(uint64_t* ent);
|
||||||
|
void print_gdt();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <arch/x86/stivale2-parse.h>
|
#include <arch/x86/stivale2-parse.h>
|
||||||
#include <arch/x86/gdt.h>
|
|
||||||
#include <arch/x86_64/gdt.h>
|
#include <arch/x86_64/gdt.h>
|
||||||
#include <print/print.h>
|
#include <print/print.h>
|
||||||
|
|
||||||
|
|
@ -45,14 +44,7 @@ void stivale2_main(struct stivale2_struct *info) {
|
||||||
printf("PAGE TABLE AT: %x\n", cr3);
|
printf("PAGE TABLE AT: %x\n", cr3);
|
||||||
|
|
||||||
loadgdt();
|
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();
|
asmpanic();
|
||||||
kmain();
|
kmain();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
#include <stdint.h>
|
#include <arch/x86/gdt.h>
|
||||||
|
|
||||||
struct gdt_ptr
|
|
||||||
{
|
|
||||||
uint16_t limit;
|
|
||||||
uint64_t base;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
void loadgdt();
|
void loadgdt();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue