[kernel] Clean up interrupts.cpp
There was a lot of old kruft in interrupts.cpp - clean it up and make irq_handler also use kassert for invalid states.
This commit is contained in:
@@ -3,21 +3,13 @@
|
|||||||
#include "kernel_memory.h"
|
#include "kernel_memory.h"
|
||||||
#include "kutil/printf.h"
|
#include "kutil/printf.h"
|
||||||
|
|
||||||
#include "apic.h"
|
|
||||||
#include "console.h"
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "debug.h"
|
|
||||||
#include "device_manager.h"
|
#include "device_manager.h"
|
||||||
#include "gdt.h"
|
|
||||||
#include "idt.h"
|
#include "idt.h"
|
||||||
#include "interrupts.h"
|
#include "interrupts.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "kernel_memory.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "objects/process.h"
|
#include "objects/process.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "syscall.h"
|
|
||||||
#include "tss.h"
|
|
||||||
#include "vm_space.h"
|
#include "vm_space.h"
|
||||||
|
|
||||||
static const uint16_t PIC1 = 0x20;
|
static const uint16_t PIC1 = 0x20;
|
||||||
@@ -25,21 +17,9 @@ static const uint16_t PIC2 = 0xa0;
|
|||||||
|
|
||||||
constexpr uintptr_t apic_eoi_addr = 0xfee000b0 + ::memory::page_offset;
|
constexpr uintptr_t apic_eoi_addr = 0xfee000b0 + ::memory::page_offset;
|
||||||
|
|
||||||
constexpr size_t increment_offset = 0x1000;
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void _halt();
|
|
||||||
|
|
||||||
void isr_handler(cpu_state*);
|
void isr_handler(cpu_state*);
|
||||||
void irq_handler(cpu_state*);
|
void irq_handler(cpu_state*);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
isr
|
|
||||||
operator+(const isr &lhs, int rhs)
|
|
||||||
{
|
|
||||||
using under_t = std::underlying_type<isr>::type;
|
|
||||||
return static_cast<isr>(static_cast<under_t>(lhs) + rhs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
@@ -186,15 +166,12 @@ isr_handler(cpu_state *regs)
|
|||||||
void
|
void
|
||||||
irq_handler(cpu_state *regs)
|
irq_handler(cpu_state *regs)
|
||||||
{
|
{
|
||||||
console *cons = console::get();
|
|
||||||
uint8_t irq = get_irq(regs->interrupt);
|
uint8_t irq = get_irq(regs->interrupt);
|
||||||
if (! device_manager::get().dispatch_irq(irq)) {
|
if (! device_manager::get().dispatch_irq(irq)) {
|
||||||
cons->set_color(11);
|
char message[100];
|
||||||
cons->printf("\nReceived unknown IRQ: %d (vec %d)\n",
|
snprintf(message, sizeof(message),
|
||||||
irq, regs->interrupt);
|
"Unknown IRQ: %d (vec 0x%x)", irq, regs->interrupt);
|
||||||
cons->set_color();
|
kassert(false, message);
|
||||||
|
|
||||||
print_regs(*regs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*reinterpret_cast<uint32_t *>(apic_eoi_addr) = 0;
|
*reinterpret_cast<uint32_t *>(apic_eoi_addr) = 0;
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ enum class isr : uint8_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Helper operator to add an offset to an isr vector
|
/// Helper operator to add an offset to an isr vector
|
||||||
isr operator+(const isr &lhs, int rhs);
|
constexpr isr operator+(const isr &lhs, int rhs) {
|
||||||
|
return static_cast<isr>(static_cast<uint8_t>(lhs) + rhs);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
/// Set the CPU interrupt enable flag (sti)
|
/// Set the CPU interrupt enable flag (sti)
|
||||||
|
|||||||
Reference in New Issue
Block a user