You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1009 B
ArmAsm
72 lines
1009 B
ArmAsm
/* Copyright (C) 2021,2022 fef <owo@fef.moe>. All rights reserved. */
|
|
|
|
#include <arch/port.h>
|
|
|
|
#include <asm/common.h>
|
|
|
|
#include <gay/config.h>
|
|
|
|
.data
|
|
|
|
/* void (*irq_table[NUM_IRQ])(void); */
|
|
.extern irq_table
|
|
|
|
/* there is probably a fancy CPU feature for this, but idk */
|
|
L_DATA(irq_count)
|
|
.byte 0
|
|
L_END(irq_count)
|
|
|
|
.text
|
|
|
|
/* bool in_irq(void); */
|
|
ENTRY(in_irq)
|
|
xor %eax, %eax
|
|
cmpb $0, irq_count
|
|
setne %al
|
|
ret
|
|
END(in_irq)
|
|
|
|
.section .text.isr
|
|
|
|
.macro gen_irq num
|
|
ENTRY(_x86_isr_irq\num )
|
|
push %eax
|
|
push %ecx
|
|
push %edx
|
|
incb irq_count
|
|
#if CFG_DEBUG_IRQ
|
|
pushl $\num
|
|
#endif
|
|
call *(irq_table + \num * 4)
|
|
#if CFG_DEBUG_IRQ
|
|
add $4, %esp
|
|
#endif
|
|
jmp leave_irq
|
|
END(_x86_isr_irq\num )
|
|
.endm
|
|
|
|
gen_irq 0
|
|
gen_irq 1
|
|
/* IRQ 2 is for cascading from PIC2 to PIC1 */
|
|
gen_irq 3
|
|
gen_irq 4
|
|
gen_irq 5
|
|
gen_irq 6
|
|
gen_irq 7
|
|
gen_irq 8
|
|
gen_irq 9
|
|
gen_irq 10
|
|
gen_irq 11
|
|
gen_irq 12
|
|
gen_irq 13
|
|
gen_irq 14
|
|
gen_irq 15
|
|
|
|
L_ENTRY(leave_irq)
|
|
decb irq_count
|
|
pop %edx
|
|
pop %ecx
|
|
pop %eax
|
|
iret
|
|
L_END(leave_irq)
|