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.
|
||||
.extern handleINT
|
||||
intr_common_handler:
|
||||
cli
|
||||
push %ebp
|
||||
push %edi
|
||||
push %esi
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
#include <idt.hpp>
|
||||
#include <serial.hpp>
|
||||
#include <textDISP.hpp>
|
||||
#include <vmm3.hpp>
|
||||
auto syscall(uint32_t syscall_num, void* handle, void* args) -> void*;
|
||||
extern void** progs;
|
||||
namespace MTGosHAL {
|
||||
IDT::IDT() {
|
||||
//Init PIC
|
||||
|
@ -36,6 +38,23 @@ namespace MTGosHAL {
|
|||
debug << "Interrupt 0x" << Base::HEXADECIMAL << (int) cpu->intr << " was raised.\n";
|
||||
if(cpu->intr<=0x1F) {
|
||||
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) {
|
||||
asm volatile("cli; hlt");
|
||||
}
|
||||
|
@ -54,7 +73,7 @@ namespace MTGosHAL {
|
|||
new_cpu=ivt[cpu->intr][i](new_cpu);
|
||||
}
|
||||
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;
|
||||
}
|
||||
auto IDT::request(uint8_t intr, struct cpu_state* (*handler)(struct cpu_state*)) -> bool {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <vmm3.hpp>
|
||||
extern "C" void intr_stub_0(void);
|
||||
void main(void ** programs);
|
||||
void** progs;
|
||||
namespace MTGosHAL {
|
||||
Serial debug;
|
||||
Screen out;
|
||||
|
@ -45,14 +46,14 @@ namespace MTGosHAL {
|
|||
idt.apply();
|
||||
mm.init(ebx);
|
||||
multiboot_mod_list *mods = (multiboot_mod_list*) ebx->mods_addr;
|
||||
void** progs=(void**)mm.alloc(4096);
|
||||
uint32_t 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=(void**)mm.alloc(4096);
|
||||
for(int i=0;i<1024;i++) {
|
||||
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);
|
||||
debug << "Found module!\n";
|
||||
}
|
||||
i++;
|
||||
progs[i]=nullptr;
|
||||
::main(progs);
|
||||
sti();
|
||||
for(;;);
|
||||
|
|
Loading…
Reference in a new issue