Compare commits
No commits in common. "1229393a8cdefd9afdeb6c276e0254946f12b5a5" and "64b01f843364ad0ea29504bc7539212cb53eaf11" have entirely different histories.
1229393a8c
...
64b01f8433
1
Makefile
1
Makefile
|
|
@ -17,6 +17,7 @@ run: $(KERNEL_HDD)
|
||||||
-drive file=$(KERNEL_HDD),format=raw \
|
-drive file=$(KERNEL_HDD),format=raw \
|
||||||
-smp 2 \
|
-smp 2 \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
|
-debugcon stdio \
|
||||||
$(QEMUFLAGS)
|
$(QEMUFLAGS)
|
||||||
|
|
||||||
bochs: $(KERNEL_HDD) ext/bochsrc
|
bochs: $(KERNEL_HDD) ext/bochsrc
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ LDSCRIPT = make/$(ARCH)/linker.ld
|
||||||
|
|
||||||
-include make/$(ARCH)/make.config
|
-include make/$(ARCH)/make.config
|
||||||
|
|
||||||
CFLAGS ?= -Og -g
|
CFLAGS ?= -O2
|
||||||
CFLAGS := $(CFLAGS) $(ARCH_CFLAGS) \
|
CFLAGS := $(CFLAGS) $(ARCH_CFLAGS) \
|
||||||
-Wall -Wextra -pedantic -Wno-language-extension-token -std=gnu11 -I../ext -Isrc -fPIE
|
-Wall -Wextra -pedantic -Wno-language-extension-token -std=gnu11 -I../ext -Isrc -fPIE
|
||||||
LDFLAGS := $(LDFLAGS) -T $(LDSCRIPT)
|
LDFLAGS := $(LDFLAGS) -T $(LDSCRIPT)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
|
|
||||||
#include <print/print.h>
|
|
||||||
void halt_catch_fire() {
|
void halt_catch_fire() {
|
||||||
asm volatile ("cli");
|
asm volatile ("cli");
|
||||||
while(1) {
|
while(1) asm volatile ("hlt");
|
||||||
asm volatile ("hlt");
|
|
||||||
puts("INTERRUPTED!");
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
#include "gdt.h"
|
|
||||||
|
|
||||||
static uint8_t stack[4096] = {0};
|
static uint8_t stack[4096] = {0};
|
||||||
void stivale2_main(struct stivale2_struct *info);
|
void stivale2_main(struct stivale2_struct *info);
|
||||||
|
|
||||||
|
|
@ -30,7 +28,7 @@ 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);
|
print_stivale2_memmap(info);
|
||||||
|
|
||||||
uint64_t* cr3;
|
uint64_t* cr3;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
|
|
@ -41,14 +39,6 @@ void stivale2_main(struct stivale2_struct *info) {
|
||||||
);
|
);
|
||||||
printf("PAGE TABLE AT: %x\n", cr3);
|
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("GDTent(%d at %x): %x\n", i, gdt_ent, *gdt_ent);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
|
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
|
||||||
kmain(3, argv);
|
kmain(3, argv);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
struct gdt_ptr
|
|
||||||
{
|
|
||||||
uint16_t limit;
|
|
||||||
uint64_t base;
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
void loadgdt();
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
section .rodata
|
|
||||||
gdt64:
|
|
||||||
dq 0
|
|
||||||
.code: equ $-gdt64
|
|
||||||
dq (1<<44) | (1<<47) | (1<<41) | (1<<43) | (1<<53)
|
|
||||||
.data: equ $ - gdt64
|
|
||||||
dq (1<<44) | (1<<47) | (1<<41)
|
|
||||||
.pointer:
|
|
||||||
dw .pointer - gdt64 - 1
|
|
||||||
dq gdt64
|
|
||||||
|
|
||||||
section .text
|
|
||||||
global loadgdt
|
|
||||||
loadgdt:
|
|
||||||
lgdt [gdt64.pointer]
|
|
||||||
|
|
||||||
|
|
@ -11,7 +11,7 @@ void kmain() {
|
||||||
printf("Bootloader type: %s (%s %s)\n", boot_info.boot_protocol, boot_info.bootloader_name, boot_info.bootloader_ver);
|
printf("Bootloader type: %s (%s %s)\n", boot_info.boot_protocol, boot_info.bootloader_name, boot_info.bootloader_ver);
|
||||||
printf("System time: %d\n", boot_info.epoch);
|
printf("System time: %d\n", boot_info.epoch);
|
||||||
printf("Usable memory: %h (at %x)\n", boot_info.usable.len, boot_info.usable.start);
|
printf("Usable memory: %h (at %x)\n", boot_info.usable.len, boot_info.usable.start);
|
||||||
printf("Cmdline: %s\n", boot_info.cmdline);
|
printf("Cmdline: %s", boot_info.cmdline);
|
||||||
|
|
||||||
vga_setcolor(VGA_DARK_GRAY);
|
vga_setcolor(VGA_DARK_GRAY);
|
||||||
vga_write_elsewhere("(c) Quinten Kock 2020 (MIT License)", 24, 0);
|
vga_write_elsewhere("(c) Quinten Kock 2020 (MIT License)", 24, 0);
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,8 @@ static void printhex(size_t num) {
|
||||||
num /= 16;
|
num /= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("0x");
|
|
||||||
for(int j = i; j >= 0; j--) {
|
|
||||||
putchar('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
puts("0x");
|
||||||
puts(&buf[i]);
|
puts(&buf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue