Merge branch 'master' of ssh://git.dehosting.club:3022/quintenk/kornos
This commit is contained in:
commit
2a0b5ed86e
1
Makefile
1
Makefile
|
|
@ -17,7 +17,6 @@ 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 ?= -O2
|
CFLAGS ?= -Og -g
|
||||||
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,4 +1,9 @@
|
||||||
|
|
||||||
|
#include <print/print.h>
|
||||||
void halt_catch_fire() {
|
void halt_catch_fire() {
|
||||||
asm volatile ("cli");
|
asm volatile ("cli");
|
||||||
while(1) asm volatile ("hlt");
|
while(1) {
|
||||||
|
asm volatile ("hlt");
|
||||||
|
puts("INTERRUPTED!");
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#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);
|
||||||
|
|
||||||
|
|
@ -28,7 +30,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__ (
|
||||||
|
|
@ -39,6 +41,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct gdt_ptr
|
||||||
|
{
|
||||||
|
uint16_t limit;
|
||||||
|
uint64_t base;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
void loadgdt();
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
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", boot_info.cmdline);
|
printf("Cmdline: %s\n", 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,8 +32,12 @@ static void printhex(size_t num) {
|
||||||
num /= 16;
|
num /= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
|
||||||
puts("0x");
|
puts("0x");
|
||||||
|
for(int j = i; j >= 0; j--) {
|
||||||
|
putchar('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
puts(&buf[i]);
|
puts(&buf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue