matos/arch/x86/irq_pit.S

60 lines
1.2 KiB
ArmAsm
Raw Normal View History

2021-11-02 21:24:12 +01:00
#define ASM_SOURCE 1
#include "segment.h"
2020-04-23 00:49:09 +02:00
.file "irq_pit.S"
.text
2020-04-23 23:40:16 +02:00
.extern switchKthread
2020-04-23 00:49:09 +02:00
.globl pit_handler
.type pit_handler, @function
pit_handler: // already got eflags, cs and eip on stack thanks to CPU
2021-10-26 20:55:15 +02:00
pushl $0 // err_code esp+12+7*4=40
pushl %ebp
pushl %eax
pushl %ecx
pushl %edx
pushl %ebx
pushl %esi
pushl %edi
2020-04-23 00:49:09 +02:00
subl $2, %esp // (alignment) esp+10
pushw %ss // esp+8
pushw %ds // esp+6
pushw %es // esp+4
pushw %fs // esp+2
pushw %gs // esp
2021-11-02 21:24:12 +01:00
/* Set correct kernel segment descriptors' value */
movw $BUILD_SEGMENT_REG_VALUE(0, 0, SEG_KDATA), %di
pushw %di ; popw %ds
pushw %di ; popw %es
pushw %di ; popw %fs
pushw %di ; popw %gs
2020-04-23 00:49:09 +02:00
/* Send EOI to PIC */
movb $0x20, %al
outb %al, $0x20
pushl %esp
2020-04-27 23:08:36 +02:00
call pitIrqHandler
2020-04-23 00:49:09 +02:00
movl %eax,%esp
/* Restore the CPU context */
popw %gs
popw %fs
popw %es
popw %ds
popw %ss
addl $2,%esp
2021-10-26 20:55:15 +02:00
popl %edi
popl %esi
popl %ebx
popl %edx
popl %ecx
popl %eax
popl %ebp
2020-04-23 00:49:09 +02:00
addl $4, %esp /* Ignore "error code" */
/* This restores the eflags, the cs and the eip registers */
iret /* equivalent to: popfl ; ret */