Adds improved interrupt handling.
This commit is contained in:
parent
bae2c0a763
commit
5829e701df
4 changed files with 66 additions and 18 deletions
|
@ -12,7 +12,7 @@ struct CpuState
|
|||
uint32_t edi;
|
||||
uint32_t ebp;
|
||||
|
||||
uint32_t intr;
|
||||
uint32_t interrupt;
|
||||
uint32_t error;
|
||||
|
||||
uint32_t eip;
|
||||
|
|
|
@ -9,9 +9,20 @@ private:
|
|||
public:
|
||||
PIC(uint16_t port);
|
||||
|
||||
/**
|
||||
* Sends an initialization code to the PIC.s
|
||||
*/
|
||||
void initialize(uint16_t irqBase, uint16_t icw3, uint16_t icw4);
|
||||
|
||||
/**
|
||||
* Disables all interrupts where the corresponding bit in mask is set.
|
||||
*/
|
||||
void maskInterrupts(uint8_t mask);
|
||||
|
||||
/**
|
||||
* Sends an end-of-interrupt to the PIC.
|
||||
*/
|
||||
void sendEndOfInterrupt();
|
||||
};
|
||||
|
||||
extern PIC masterPIC, slavePIC;
|
|
@ -56,23 +56,55 @@ void IDT::dispatch(CpuState *cpu)
|
|||
{
|
||||
using namespace console_tools;
|
||||
|
||||
Console::main << "Ermahgerd, Interrupts!\n";
|
||||
if(cpu->interrupt <= 0x1F) {
|
||||
// Exception Handling
|
||||
|
||||
Console::main
|
||||
<< "eax = " << hex(cpu->eax) << "\n"
|
||||
<< "ebx = " << hex(cpu->ebx) << "\n"
|
||||
<< "ecx = " << hex(cpu->ecx) << "\n"
|
||||
<< "edx = " << hex(cpu->edx) << "\n"
|
||||
<< "esi = " << hex(cpu->esi) << "\n"
|
||||
<< "edi = " << hex(cpu->edi) << "\n"
|
||||
<< "ebp = " << hex(cpu->ebp) << "\n"
|
||||
<< "intr = " << cpu->intr << "\n"
|
||||
<< "error = " << cpu->error << "\n"
|
||||
<< "eip = " << hex(cpu->eip) << "\n"
|
||||
<< "cs = " << hex(cpu->cs) << "\n"
|
||||
<< "eflags = " << bin(cpu->eflags) << "\n"
|
||||
<< "esp = " << hex(cpu->esp) << "\n"
|
||||
<< "ss = " << hex(cpu->ss) << "\n";
|
||||
Console::main << FColor(Color::Red) << "Ermahgerd, Exceptions!\n";
|
||||
Console::main
|
||||
<< "eax = " << hex(cpu->eax) << "\n"
|
||||
<< "ebx = " << hex(cpu->ebx) << "\n"
|
||||
<< "ecx = " << hex(cpu->ecx) << "\n"
|
||||
<< "edx = " << hex(cpu->edx) << "\n"
|
||||
<< "esi = " << hex(cpu->esi) << "\n"
|
||||
<< "edi = " << hex(cpu->edi) << "\n"
|
||||
<< "ebp = " << hex(cpu->ebp) << "\n"
|
||||
<< "intr = " << cpu->interrupt << "\n"
|
||||
<< "error = " << cpu->error << "\n"
|
||||
<< "eip = " << hex(cpu->eip) << "\n"
|
||||
<< "cs = " << hex(cpu->cs) << "\n"
|
||||
<< "eflags = " << bin(cpu->eflags) << "\n"
|
||||
<< "esp = " << hex(cpu->esp) << "\n"
|
||||
<< "ss = " << hex(cpu->ss) << "\n";
|
||||
|
||||
while(true);
|
||||
} else if (cpu->interrupt >= 0x20 && cpu->interrupt <= 0x2F) {
|
||||
|
||||
while(true);
|
||||
// IRQ
|
||||
Console::main << "[IRQ " << (cpu->interrupt - 0x20) << "]";
|
||||
|
||||
if(cpu->interrupt >= 0x28) {
|
||||
slavePIC.sendEndOfInterrupt();
|
||||
}
|
||||
masterPIC.sendEndOfInterrupt();
|
||||
} else {
|
||||
// Other Interrupt
|
||||
Console::main << "Ermahgerd, Interrupts!\n";
|
||||
Console::main
|
||||
<< "eax = " << hex(cpu->eax) << "\n"
|
||||
<< "ebx = " << hex(cpu->ebx) << "\n"
|
||||
<< "ecx = " << hex(cpu->ecx) << "\n"
|
||||
<< "edx = " << hex(cpu->edx) << "\n"
|
||||
<< "esi = " << hex(cpu->esi) << "\n"
|
||||
<< "edi = " << hex(cpu->edi) << "\n"
|
||||
<< "ebp = " << hex(cpu->ebp) << "\n"
|
||||
<< "intr = " << cpu->interrupt << "\n"
|
||||
<< "error = " << cpu->error << "\n"
|
||||
<< "eip = " << hex(cpu->eip) << "\n"
|
||||
<< "cs = " << hex(cpu->cs) << "\n"
|
||||
<< "eflags = " << bin(cpu->eflags) << "\n"
|
||||
<< "esp = " << hex(cpu->esp) << "\n"
|
||||
<< "ss = " << hex(cpu->ss) << "\n";
|
||||
|
||||
while(true);
|
||||
}
|
||||
}
|
|
@ -21,4 +21,9 @@ void PIC::initialize(uint16_t irqBase, uint16_t icw3, uint16_t icw4)
|
|||
void PIC::maskInterrupts(uint8_t mask)
|
||||
{
|
||||
outb(this->port + 0x01, mask);
|
||||
}
|
||||
|
||||
void PIC::sendEndOfInterrupt()
|
||||
{
|
||||
outb(this->port + 0x00, 0x20);
|
||||
}
|
Loading…
Reference in a new issue