This repository has been archived on 2020-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
Legacy-Sync/isr.c
Jenny Curle f6ba6aa117 Legacy OS files. Have an i686-elf-gcc & -ld in your PATH,
and the Makefile will take care of the rest.
2019-04-01 01:38:50 +01:00

51 lines
1.2 KiB
C

//
// isr.c -- High level interrupt service routines and interrupt request handlers.
// Part of this code is modified from Bran's kernel development tutorials.
// Rewritten for JamesM's kernel development tutorials.
//
#include "headers/common.h"
#include "headers/isr.h"
#include "headers/screen.h"
#include <stdint.h>
isr_t interrupt_handlers[256];
// This gets called from our ASM interrupt handler stub.
void isr_handler(registers_t *regs)
{
//kprintf("recieved interrupt: %d\n",regs->int_no);
if(interrupt_handlers[regs->int_no] != 0)
{
isr_t handler = interrupt_handlers[regs->int_no];
handler(regs);
}
}
void irq_handler(registers_t *regs)
{
//kprintf("recieved irq: %d\n",regs->int_no);
// send an EOI signal to pics if this
// interrupt involved the slave
if(regs->int_no >= 40)
{
outb(0xA0,0x20);
}
// send reset siginal to master. (as well as slave, if neccessary).
outb(0x20,0x20);
if(interrupt_handlers[regs->int_no] != 0)
{
isr_t handler = interrupt_handlers[regs->int_no];
handler(regs);
}
}
void register_interrupt_handler(uint8_t n, isr_t handler)
{
interrupt_handlers[n] = handler;
}