Fixed timing issues on real hardware
Added a beeping sound and a register dump on crash
This commit is contained in:
parent
f71e781839
commit
6a4a634bd0
3 changed files with 28 additions and 7 deletions
|
@ -309,6 +309,7 @@ intr_stub 255
|
||||||
//This should cover everything.
|
//This should cover everything.
|
||||||
.extern handleINT
|
.extern handleINT
|
||||||
intr_common_handler:
|
intr_common_handler:
|
||||||
|
cli
|
||||||
push %ebp
|
push %ebp
|
||||||
push %edi
|
push %edi
|
||||||
push %esi
|
push %esi
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
#include <idt.hpp>
|
#include <idt.hpp>
|
||||||
#include <serial.hpp>
|
#include <serial.hpp>
|
||||||
#include <textDISP.hpp>
|
#include <textDISP.hpp>
|
||||||
|
#include <vmm3.hpp>
|
||||||
auto syscall(uint32_t syscall_num, void* handle, void* args) -> void*;
|
auto syscall(uint32_t syscall_num, void* handle, void* args) -> void*;
|
||||||
|
extern void** progs;
|
||||||
namespace MTGosHAL {
|
namespace MTGosHAL {
|
||||||
IDT::IDT() {
|
IDT::IDT() {
|
||||||
//Init PIC
|
//Init PIC
|
||||||
|
@ -32,10 +34,27 @@ namespace MTGosHAL {
|
||||||
loadIDT((void*)&idtptr);
|
loadIDT((void*)&idtptr);
|
||||||
}
|
}
|
||||||
auto IDT::handle(struct cpu_state* cpu) -> struct cpu_state* {
|
auto IDT::handle(struct cpu_state* cpu) -> struct cpu_state* {
|
||||||
struct cpu_state* new_cpu=cpu;
|
struct cpu_state* new_cpu=cpu;
|
||||||
debug << "Interrupt 0x" << Base::HEXADECIMAL << (int) cpu->intr << " was raised.\n";
|
debug << "Interrupt 0x" << Base::HEXADECIMAL << (int) cpu->intr << " was raised.\n";
|
||||||
if(cpu->intr<=0x1F) {
|
if(cpu->intr<=0x1F) {
|
||||||
err << "Exception 0x" << Base::HEXADECIMAL << (int) cpu->intr << "! Kernel halted!\n";
|
err << "Exception 0x" << Base::HEXADECIMAL << (int) cpu->intr << "! Kernel halted!\n";
|
||||||
|
err << "EAX = 0x" << (int)cpu->eax << " - EBX = 0x" << (int)cpu->ebx << "\n";
|
||||||
|
err << "ECX = 0x" << (int)cpu->ecx << " - EDX = 0x" << (int)cpu->edx << "\n";
|
||||||
|
err << "ESI = 0x" << (int)cpu->esi << " - EDI = 0x" << (int)cpu->edi << "\n";
|
||||||
|
err << "SS:ESP = 0x" << (int)cpu->ss << ":0x" << (int)cpu->esp << " - SS:EBP = 0x" << (int)cpu->ss << ":0x" << (int)cpu->ebp << "\n";
|
||||||
|
err << "CS:EIP = 0x" << (int)cpu->cs << ":0x" << (int)cpu->eip << " - INTR:ERR = 0x" << (int)cpu->intr << ":0x" << (int)cpu->error << "\n";
|
||||||
|
err << "------ END OF REGISTER DUMP ------ ------ START OF PROGRAM LOADPOINTS ------\n";
|
||||||
|
for(int i=0;i<1024;i++) {
|
||||||
|
if(!progs[i])
|
||||||
|
break;
|
||||||
|
err << "0x" << (int)((uint32_t)progs[i]) << "; ";
|
||||||
|
}
|
||||||
|
err << "\n";
|
||||||
|
uint16_t counter = 1193180 / 220; //Make an annoying beep
|
||||||
|
outb(0x43, 0xB6);
|
||||||
|
outb(0x42, (uint8_t)counter);
|
||||||
|
outb(0x42, (uint8_t)(counter>>8));
|
||||||
|
outb(0x61, inb(0x61) | 3);
|
||||||
while(1) {
|
while(1) {
|
||||||
asm volatile("cli; hlt");
|
asm volatile("cli; hlt");
|
||||||
}
|
}
|
||||||
|
@ -54,7 +73,7 @@ namespace MTGosHAL {
|
||||||
new_cpu=ivt[cpu->intr][i](new_cpu);
|
new_cpu=ivt[cpu->intr][i](new_cpu);
|
||||||
}
|
}
|
||||||
if(cpu->intr>=48)
|
if(cpu->intr>=48)
|
||||||
cpu->eax=(uint32_t)(::syscall(cpu->eax, (void*)(cpu->ebx), (void*)(cpu->esp)));
|
new_cpu->eax=(uint32_t)(::syscall(cpu->eax, (void*)(cpu->ebx), (void*)(cpu->esp)));
|
||||||
return new_cpu;
|
return new_cpu;
|
||||||
}
|
}
|
||||||
auto IDT::request(uint8_t intr, struct cpu_state* (*handler)(struct cpu_state*)) -> bool {
|
auto IDT::request(uint8_t intr, struct cpu_state* (*handler)(struct cpu_state*)) -> bool {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <vmm3.hpp>
|
#include <vmm3.hpp>
|
||||||
extern "C" void intr_stub_0(void);
|
extern "C" void intr_stub_0(void);
|
||||||
void main(void ** programs);
|
void main(void ** programs);
|
||||||
|
void** progs;
|
||||||
namespace MTGosHAL {
|
namespace MTGosHAL {
|
||||||
Serial debug;
|
Serial debug;
|
||||||
Screen out;
|
Screen out;
|
||||||
|
@ -45,14 +46,14 @@ namespace MTGosHAL {
|
||||||
idt.apply();
|
idt.apply();
|
||||||
mm.init(ebx);
|
mm.init(ebx);
|
||||||
multiboot_mod_list *mods = (multiboot_mod_list*) ebx->mods_addr;
|
multiboot_mod_list *mods = (multiboot_mod_list*) ebx->mods_addr;
|
||||||
void** progs=(void**)mm.alloc(4096);
|
progs=(void**)mm.alloc(4096);
|
||||||
uint32_t i;
|
for(int i=0;i<1024;i++) {
|
||||||
for(i=0;i<(ebx->mods_count<1023?ebx->mods_count:1023);i++) { //Basically until MIN(ebx->mods_count, 1023), as we only support loading up to 1023 programs directly.
|
progs[i]=nullptr;
|
||||||
|
}
|
||||||
|
for(uint32_t i=0;i<(ebx->mods_count<1023?ebx->mods_count:1023);i++) { //Basically until MIN(ebx->mods_count, 1023), as we only support loading up to 1023 programs directly.
|
||||||
progs[i]=(void*)(mods[i].mod_start);
|
progs[i]=(void*)(mods[i].mod_start);
|
||||||
debug << "Found module!\n";
|
debug << "Found module!\n";
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
progs[i]=nullptr;
|
|
||||||
::main(progs);
|
::main(progs);
|
||||||
sti();
|
sti();
|
||||||
for(;;);
|
for(;;);
|
||||||
|
|
Loading…
Reference in a new issue