Working i386 paging and liballoc
This commit is contained in:
182
kernel/platform/i386_pc/sys/isr.S
Normal file
182
kernel/platform/i386_pc/sys/isr.S
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
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; \
|
||||
push $0; \
|
||||
push $exc; \
|
||||
jmp temp_except_hndlr;
|
||||
|
||||
#define EXCEPT_ERR(exc) \
|
||||
.global except ## exc; \
|
||||
.type except ## exc, @function; \
|
||||
except ## exc:; \
|
||||
cli; \
|
||||
push $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 /* push eax, ecx, edx, ebx, esp, ebp, esi, edi (8*4) */
|
||||
xorl %eax, %eax
|
||||
mov %ds, %ax
|
||||
push %eax /* save ds (4) */
|
||||
|
||||
/* load kernel DS */
|
||||
mov $0x10, %ax
|
||||
mov %ax, %ds
|
||||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
|
||||
mov %cr3, %ecx
|
||||
push %ecx
|
||||
|
||||
/* save frame (4) */
|
||||
push %esp
|
||||
call except_fini
|
||||
add $0x04, %esp
|
||||
|
||||
/* restore DS */
|
||||
pop %ebx
|
||||
mov %bx, %ds
|
||||
mov %bx, %es
|
||||
mov %bx, %fs
|
||||
mov %bx, %gs
|
||||
|
||||
/* rebalance */
|
||||
popal
|
||||
add $0x8, %esp
|
||||
|
||||
sti
|
||||
iret
|
||||
|
||||
#define IRQ(irq1) \
|
||||
.global irq ## irq1; \
|
||||
.type irq ## irq1, @function; \
|
||||
irq ## irq1:; \
|
||||
cli; \
|
||||
push $0; \
|
||||
push $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 /* push eax, ecx, edx, ebx, esp, ebp, esi, edi (8*4) */
|
||||
xorl %eax, %eax
|
||||
mov %ds, %ax
|
||||
push %eax /* save ds (4) */
|
||||
|
||||
/* load kernel DS */
|
||||
mov $0x10, %ax
|
||||
mov %ax, %ds
|
||||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
|
||||
mov %cr3, %ecx
|
||||
push %ecx
|
||||
|
||||
/* save frame (4) */
|
||||
push %esp
|
||||
call irq_fini
|
||||
add $0x04, %esp
|
||||
|
||||
/* restore DS */
|
||||
pop %ebx
|
||||
mov %bx, %ds
|
||||
mov %bx, %es
|
||||
mov %bx, %fs
|
||||
mov %bx, %gs
|
||||
|
||||
/* rebalance */
|
||||
popal
|
||||
add $0x8, %esp
|
||||
|
||||
sti
|
||||
iret
|
||||
Reference in New Issue
Block a user