This commit is contained in:
Benjamin Kyd
2019-05-02 21:29:22 +01:00
parent 44330e8427
commit 631ea7b7cb
10 changed files with 28 additions and 83 deletions

View File

@@ -1,56 +0,0 @@
# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1
config_interface: win32config
display_library: win32, options="gui_debug"
memory: host=32, guest=32
romimage: file="C:\Program Files (x86)\Bochs-2.6.9/BIOS-bochs-latest", address=0x0, options=none
vgaromimage: file="C:\Program Files (x86)\Bochs-2.6.9/VGABIOS-lgpl-latest"
boot: cdrom
floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=cdrom, path="E:\OS\OwOS\build\OwOS.iso", status=inserted, model="Generic 1234", biosdetect=auto
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
optromimage1: file=none
optromimage2: file=none
optromimage3: file=none
optromimage4: file=none
optramimage1: file=none
optramimage2: file=none
optramimage3: file=none
optramimage4: file=none
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5, realtime=1
cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU "
cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0
cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, x86_64=1, 1g_pages=0, pcid=0, fsgsbase=0
cpuid: smep=0, smap=0, mwait=1, vmx=1
print_timestamps: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
sound: waveoutdrv=win, waveout=none, waveindrv=win, wavein=none, midioutdrv=win, midiout=none
speaker: enabled=1, mode=sound
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -37,10 +37,10 @@ _start:
jmp 1b
.global INIT_FPU
.type INIT_FPU, @function
.global FPU_Init
.type FPU_Init, @function
INIT_FPU:
FPU_Init:
# FPU Config
VAL_037F:
.hword 0x037F
@@ -58,5 +58,6 @@ INIT_FPU:
fldcw VAL_037E
fldcw VAL_037A
fninit
ret
.size _start, . - _start

View File

@@ -13,7 +13,7 @@
#include <lib/kernel/logger/logger.h>
extern "C" {
extern void INIT_FPU(void);
extern void FPU_Init(void);
}
extern "C"
@@ -28,6 +28,9 @@ int kernel_main(uint32_t magic, MultibootInfo_t* multiboot) {
// Init systems
FPU_Init();
loggerOK("FPU Init");
GDT_Init();
loggerOK("GDT Init");
@@ -51,6 +54,8 @@ int kernel_main(uint32_t magic, MultibootInfo_t* multiboot) {
SetFGColour(VGA_BRIGHT_MAGENTA);
Write("~#");
asm("sti");
// PanicKernel(0x00, "Self Triggered Panic", "kernel.cpp:48", "kernel_main(uint32_t magic, MultibootInfo_t* multiboot)");
for (;;)

View File

@@ -31,9 +31,9 @@ void GDT_Init() {
// Null segment
GDT_Set_Gate(0, 0, 0, 0, 0);
// Code Base 0 limit 32 Access EXEC + RW
// Code Base 0 limit 32 Access EXEC + RW
GDT_Set_Gate(1, 0x00000000, 0xFFFFFFFF, GDT_ACCESS_PRESENT | GDT_ACCESS_EXEC | GDT_ACCESS_RW, GDT_FLAG_GR_PAGE | GDT_FLAG_SZ_32B);
// Data Base 0 Limit 32 Access RW
// Data Base 0 Limit 32 Access RW
GDT_Set_Gate(2, 0x00000000, 0xFFFFFFFF, GDT_ACCESS_PRESENT | GDT_ACCESS_RW, GDT_FLAG_GR_PAGE | GDT_FLAG_SZ_32B);
lgdt(_GDTptr);

View File

@@ -4,10 +4,10 @@
#include <kernel/kernio.h>
struct Regs_t {
unsigned int gs, fs, es, ds; /* pushed the segs last */
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */
unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
unsigned int gs, fs, es, ds; /* pushed the segs last */
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */
unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
};
char *PanicMessage[] = {
@@ -48,7 +48,6 @@ char *PanicMessage[] = {
extern "C" {
void DEFAULT_ISR() {
Write("SMH \n");
outb(0x20,0x20);
}
@@ -57,12 +56,13 @@ void KeyboardHandler() {
outb(0x20,0x20);
}
void FaultHandler(struct Regs_t *r) {
uint32_t val;
asm volatile ( "mov %%cr2, %0" : "=r"(val) );
PanicKernel(val, PanicMessage[r->int_no]);
for (;;)
asm("hlt");
void FaultHandler(struct Regs_t* r) {
if (r->int_no < 32) {
uint32_t val;
asm volatile ( "mov %%cr2, %0" : "=r"(val) );
PanicKernel(val, PanicMessage[r->int_no], "kernel/isr.cpp:64", "FaultHandler(struct Regs_t* r)");
for(;;) {}
}
}
}

View File

@@ -7,6 +7,8 @@
#include <kernel/drivers/terminal/terminal.h>
void PanicKernel(char code, char* why, char* where, char* what) {
asm("cli");
if (why == "") {
switch (code) {
case 0x00:
@@ -79,5 +81,7 @@ void PanicKernel(char code, char* why, char* where, char* what) {
Write("Error Code: 0x");
Write(itohx(code));
asm("cli"); // Clear interrupt bit / dissable interrupts
for (;;) {
asm("hlt");
}
}

View File

@@ -4,23 +4,14 @@
void PIC_Default_Remap() {
outb(0x20, 0x11);
io_wait();
outb(0xA0, 0x11);
io_wait();
outb(0x21, 0x20);
io_wait();
outb(0xA1, 0x28);
io_wait();
outb(0x21, 0x04);
io_wait();
outb(0xA1, 0x02);
io_wait();
outb(0x21, 0x01);
io_wait();
outb(0xA1, 0x01);
io_wait();
outb(0x21, 0x0);
io_wait();
outb(0xA1, 0x0);
}