Compare commits

..

No commits in common. "b0e433fca25fa6d253cbb7db26171493c795a464" and "2a0b5ed86ea441863599550f1c4d4fed438a163b" have entirely different histories.

8 changed files with 14 additions and 54 deletions

2
.gdbinit Normal file
View File

@ -0,0 +1,2 @@
file kernel/bin/kernel-x86_64
target remote :1234

View File

@ -4,7 +4,7 @@ ARCH ?= x86_64
KERNEL_HDD = kornos.img
.PHONY: clean all $(COMPONENTS) run bochs gdb
.PHONY: clean all $(COMPONENTS) run bochs
.DEFAULT_GOAL = $(KERNEL_HDD)
$(COMPONENTS):
@ -24,9 +24,6 @@ bochs: $(KERNEL_HDD) ext/bochsrc
bochs -qf ext/bochsrc
rm bochsout.txt
gdb:
QEMUFLAGS="-s -S" $(MAKE) run & gdb -x ext/gdbinit
ext/limine/limine-install:
$(MAKE) -C ext/limine/ limine-install
ext/echfs/echfs-utils:

View File

@ -1,5 +0,0 @@
file kernel/bin/kernel-x86_64
target remote :1234
hbreak stivale2_main
hbreak halt_catch_fire
continue

View File

@ -1,32 +0,0 @@
#include <print/print.h>
#include "gdt.h"
void print_gdt_ent(uint64_t* ent) {
uint64_t e = *ent;
uint64_t base = ((e >> 16) & 0xFFFFFF) | ((e >> 32) & 0xFF000000);
uint64_t limit = (e & 0xFFFF) | ((e >> 32) & 0xF0000);
uint64_t flags = ((e >> 52) & 0xF);
uint64_t access = ((e >> 40) & 0xFF);
uint64_t code = (access & 0x8);
int bits = (flags&0x2) ? 64 : ((flags&0x4) ? 32 : 16);
uint64_t length = limit * ((flags & 0x8) ? 4096 : 1);
printf("%X (%h): \t", base, length);
if(e == 0) {
puts("NULL");
return;
}
if(access & 0x80) putchar('P');
printf("%d", (access >> 5) & 0x3);
if(access & 0x10) putchar('S');
if(code) printf(" Code%d\t", bits); else puts(" Data\t");
if(access & 0x4) putchar(code ? 'C' : 'D');
if(access & 0x2) putchar(code ? 'R' : 'W');
if(access & 0x1) putchar('A');
if(flags & 0x8) putchar('G');
if(flags & 0x1) putchar('z');
}

View File

@ -1,3 +0,0 @@
#include <stdint.h>
void print_gdt_ent(uint64_t* ent);

View File

@ -3,12 +3,11 @@
#include <stddef.h>
#include <arch/x86/stivale2-parse.h>
#include <arch/x86/gdt.h>
#include <arch/x86_64/gdt.h>
#include <print/print.h>
#include <main.h>
#include "gdt.h"
static uint8_t stack[4096] = {0};
void stivale2_main(struct stivale2_struct *info);
@ -47,7 +46,7 @@ void stivale2_main(struct stivale2_struct *info) {
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');
printf("GDTent(%d at %x): %x\n", i, gdt_ent, *gdt_ent);
}
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};

View File

@ -6,4 +6,4 @@ struct gdt_ptr
uint64_t base;
} __attribute__((packed));
void loadgdt();
void loadgdt();

View File

@ -1,6 +1,5 @@
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
#include "print.h"
@ -17,10 +16,15 @@ void print(const char* c) {
static const char CONVERSION_TABLE[] = "0123456789abcdef";
static const char UNITS[] = "bKM";
static void printhex(size_t num, bool pad) {
static void printhex(size_t num) {
int i;
char buf[17];
if (!num) {
puts("0x0");
return;
}
buf[16] = 0;
for (i = 15; num; i--) {
@ -29,7 +33,7 @@ static void printhex(size_t num, bool pad) {
}
puts("0x");
for(int j = i; pad && j >= 0; j--) {
for(int j = i; j >= 0; j--) {
putchar('0');
}
@ -75,9 +79,7 @@ void printf(const char *format, ...) {
if (*format == '%') {
format++;
if (*format == 'x') {
printhex(va_arg(argp, size_t), false);
} else if (*format == 'X') {
printhex(va_arg(argp, size_t), true);
printhex(va_arg(argp, size_t));
} else if (*format == 'd') {
printdec(va_arg(argp, size_t));
} else if (*format == 's') {