176 lines
3.9 KiB
ArmAsm
176 lines
3.9 KiB
ArmAsm
/*
|
|
Copyright 2025 Kamil Kowalczyk
|
|
|
|
Redistribution and use in source and binary forms, with or
|
|
without modification, are permitted provided that the following
|
|
conditions are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in the
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the copyright holder nor the names of its
|
|
contributors may be used to endorse or promote products derived from
|
|
this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
“AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
.extern except_fini
|
|
.extern irq_fini
|
|
|
|
.section .text
|
|
#define EXCEPT_NOERR(exc) \
|
|
.global except ## exc; \
|
|
.type except ## exc, @function; \
|
|
except ## exc:; \
|
|
cli; \
|
|
pushl $0; \
|
|
pushl $exc; \
|
|
jmp temp_except_hndlr;
|
|
|
|
#define EXCEPT_ERR(exc) \
|
|
.global except ## exc; \
|
|
.type except ## exc, @function; \
|
|
except ## exc:; \
|
|
cli; \
|
|
pushl $exc; \
|
|
jmp temp_except_hndlr;
|
|
|
|
EXCEPT_NOERR(0)
|
|
EXCEPT_NOERR(1)
|
|
EXCEPT_NOERR(2)
|
|
EXCEPT_NOERR(3)
|
|
EXCEPT_NOERR(4)
|
|
EXCEPT_NOERR(5)
|
|
EXCEPT_NOERR(6)
|
|
EXCEPT_NOERR(7)
|
|
EXCEPT_ERR(8)
|
|
EXCEPT_NOERR(9)
|
|
EXCEPT_ERR(10)
|
|
EXCEPT_ERR(11)
|
|
EXCEPT_ERR(12)
|
|
EXCEPT_ERR(13)
|
|
EXCEPT_ERR(14)
|
|
EXCEPT_NOERR(15)
|
|
EXCEPT_NOERR(16)
|
|
EXCEPT_NOERR(17)
|
|
EXCEPT_NOERR(18)
|
|
EXCEPT_NOERR(19)
|
|
EXCEPT_NOERR(20)
|
|
EXCEPT_NOERR(21)
|
|
EXCEPT_NOERR(22)
|
|
EXCEPT_NOERR(23)
|
|
EXCEPT_NOERR(24)
|
|
EXCEPT_NOERR(25)
|
|
EXCEPT_NOERR(26)
|
|
EXCEPT_NOERR(27)
|
|
EXCEPT_NOERR(28)
|
|
EXCEPT_NOERR(29)
|
|
EXCEPT_NOERR(30)
|
|
EXCEPT_NOERR(31)
|
|
EXCEPT_NOERR(128)
|
|
|
|
temp_except_hndlr:
|
|
pushal
|
|
xorl %eax, %eax
|
|
movw %ds, %ax
|
|
pushl %eax
|
|
|
|
/* load kernel DS */
|
|
movw $0x10, %ax
|
|
movw %ax, %ds
|
|
movw %ax, %es
|
|
movw %ax, %fs
|
|
movw %ax, %gs
|
|
|
|
pushl %esp
|
|
|
|
call except_fini
|
|
|
|
addl $4, %esp
|
|
|
|
/* restore DS */
|
|
popl %eax
|
|
movw %ax, %ds
|
|
movw %ax, %es
|
|
movw %ax, %fs
|
|
movw %ax, %gs
|
|
|
|
/* rebalance */
|
|
popal
|
|
addl $8, %esp
|
|
|
|
iretl
|
|
|
|
#define IRQ(irq1) \
|
|
.global irq ## irq1; \
|
|
.type irq ## irq1, @function; \
|
|
irq ## irq1:; \
|
|
cli; \
|
|
pushl $0; \
|
|
pushl $irq1; \
|
|
jmp temp_irq_hndlr;
|
|
|
|
IRQ(0)
|
|
IRQ(1)
|
|
IRQ(2)
|
|
IRQ(3)
|
|
IRQ(4)
|
|
IRQ(5)
|
|
IRQ(6)
|
|
IRQ(7)
|
|
IRQ(8)
|
|
IRQ(9)
|
|
IRQ(10)
|
|
IRQ(11)
|
|
IRQ(12)
|
|
IRQ(13)
|
|
IRQ(14)
|
|
IRQ(15)
|
|
|
|
temp_irq_hndlr:
|
|
pushal
|
|
xorl %eax, %eax
|
|
movw %ds, %ax
|
|
pushl %eax
|
|
|
|
/* load kernel DS */
|
|
movw $0x10, %ax
|
|
movw %ax, %ds
|
|
movw %ax, %es
|
|
movw %ax, %fs
|
|
movw %ax, %gs
|
|
|
|
pushl %esp
|
|
|
|
call irq_fini
|
|
|
|
addl $4, %esp
|
|
|
|
/* restore DS */
|
|
popl %eax
|
|
movw %ax, %ds
|
|
movw %ax, %es
|
|
movw %ax, %fs
|
|
movw %ax, %gs
|
|
|
|
/* rebalance */
|
|
popal
|
|
addl $8, %esp
|
|
|
|
iretl
|