driver/pic: one argument for IRQ handlers

This commit is contained in:
Edgaru089 2021-11-14 19:42:44 +08:00
parent 219bf76535
commit a5fa453be2
4 changed files with 11 additions and 8 deletions

View File

@ -3,6 +3,7 @@ format elf64
include 'pic_constants.incS' include 'pic_constants.incS'
extrn irq_pic_IntHandler extrn irq_pic_IntHandler
extrn irq_pic_IRQHandler_Data
extrn irq_pic_IRQHandlerRaw extrn irq_pic_IRQHandlerRaw
public irq_pic_IntHandler20h public irq_pic_IntHandler20h

View File

@ -14,6 +14,6 @@ SYSV_ABI void irq_pic_IntHandler(int irq) {
io_Printf("INT %xh (IRQ %d) (no handler)\n", irq + IRQ_PIC_INT_OFFSET_MASTER, irq); io_Printf("INT %xh (IRQ %d) (no handler)\n", irq + IRQ_PIC_INT_OFFSET_MASTER, irq);
else { else {
//io_Printf("INT %xh (IRQ %d), handler%llx\n", irq + IRQ_PIC_INT_OFFSET_MASTER, irq, irq_pic_IRQHandler[irq]); //io_Printf("INT %xh (IRQ %d), handler%llx\n", irq + IRQ_PIC_INT_OFFSET_MASTER, irq, irq_pic_IRQHandler[irq]);
irq_pic_IRQHandler[irq](); ((irq_pic_IRQHandlerType)irq_pic_IRQHandler[irq])(irq_pic_IRQHandler_Data[irq]);
} }
} }

View File

@ -29,12 +29,13 @@ uint16_t irq_pic_GetIRR();
uint16_t irq_pic_GetISR(); uint16_t irq_pic_GetISR();
// void() for IRQ handlers, no need to call out8(OCW2, 0x6*) // void(uintptr_t) for IRQ handlers, no need to call out8(OCW2, 0x6*)
typedef SYSV_ABI void (*irq_pic_IRQHandlerType)(); typedef SYSV_ABI void (*irq_pic_IRQHandlerType)(uintptr_t);
// defined in pic_init.c // defined in pic_init.c
extern irq_pic_IRQHandlerType irq_pic_IRQHandler[16]; extern void * irq_pic_IRQHandler[16];
extern bool irq_pic_Enabled; extern uintptr_t irq_pic_IRQHandler_Data[16]; // written into RDI on handler (first argument)
extern bool irq_pic_Enabled;
// If IRQHandlerRaw[irq] is not NULL, the function is jumped to (not called). // If IRQHandlerRaw[irq] is not NULL, the function is jumped to (not called).
// //

View File

@ -9,9 +9,10 @@
#include <string.h> #include <string.h>
irq_pic_IRQHandlerType irq_pic_IRQHandler[16]; void * irq_pic_IRQHandler[16];
void * irq_pic_IRQHandlerRaw[16]; uintptr_t irq_pic_IRQHandler_Data[16];
bool irq_pic_Enabled; void * irq_pic_IRQHandlerRaw[16];
bool irq_pic_Enabled;
void irq_pic_Init() { void irq_pic_Init() {
assert(interrupt_Enabled && "Interrupt must be set up before PIC init"); assert(interrupt_Enabled && "Interrupt must be set up before PIC init");