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.

106 lines
1.9 KiB
ArmAsm

/* See the end of this file for copyright and license terms. */
#include <arch/port.h>
#include <asm/common.h>
#include <gay/config.h>
/*
* XXX We should probably move to exclusively using the APIC on amd64
* (and i386 too, because the APIC was introduced with the 486 and we don't
* support anything below 686 anyway)
*/
.data
/* void (*irq_table[NUM_IRQ])(void); */
.extern irq_table
/* there is probably a fancy CPU feature for this, but idk */
irq_count:
.long 0
.text
/* bool in_irq(void); */
ASM_ENTRY(in_irq)
movabsq $irq_count, %rdx
xor %eax, %eax
mov %eax, %ecx
not %ecx
testl %ecx, (%rdx)
setne %al
retq
ASM_END(in_irq)
.macro gen_irq num
ASM_ENTRY(_x86_isr_irq\num )
push %rax
push %rcx
push %rdx
push %rdi
push %rsi
push %r8
push %r9
push %r10
push %r11
movabsq $irq_count, %rax
incl (%rax)
#if CFG_DEBUG_IRQ
movl $\num, %edi
#endif
movabsq $(irq_table + \num * 8), %rax
callq *%rax
jmp leave_irq
ASM_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
.align 4
leave_irq:
movabsq $irq_count, %rax
decl (%rax)
pop %r11
pop %r10
pop %r9
pop %r8
pop %rsi
pop %rdi
pop %rdx
pop %rcx
pop %rax
iretq
.size leave_irq, . - leave_irq
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/