2016-05-10 15:03:56 +00:00
|
|
|
/*
|
2021-03-14 23:42:49 +00:00
|
|
|
* PROJECT: ReactOS Hardware Abstraction Layer
|
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
|
|
|
* PURPOSE: HAL PIC Management and Control Code
|
|
|
|
* COPYRIGHT: Copyright 2016-2018 Thomas Faber <thomas.faber@reactos.org>
|
2016-05-10 15:03:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <asm.inc>
|
|
|
|
|
|
|
|
#include <ks386.inc>
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
|
|
|
.code
|
2018-02-18 11:42:18 +00:00
|
|
|
|
|
|
|
MACRO(DEFINE_END_INTERRUPT_WRAPPER, WrapperName, HandlerName)
|
|
|
|
EXTERN @&HandlerName&@8:PROC
|
|
|
|
PUBLIC _&WrapperName&@8
|
|
|
|
.PROC _&WrapperName&@8
|
2016-05-10 15:03:56 +00:00
|
|
|
FPO 0, 2, 0, 0, 0, FRAME_FPO
|
|
|
|
|
|
|
|
/* Call the C function with the same arguments we got */
|
2018-02-11 10:33:16 +00:00
|
|
|
mov ecx, [esp+4]
|
|
|
|
mov edx, [esp+8]
|
2018-02-18 11:42:18 +00:00
|
|
|
call @&HandlerName&@8
|
2016-05-10 15:03:56 +00:00
|
|
|
|
|
|
|
/* Check if we got a pointer back */
|
|
|
|
test eax, eax
|
2018-02-18 11:42:18 +00:00
|
|
|
jnz WrapperName&_CallIntHandler
|
2016-05-10 15:03:56 +00:00
|
|
|
|
|
|
|
/* No? Just return */
|
|
|
|
ret 8
|
|
|
|
|
2018-02-18 11:42:18 +00:00
|
|
|
WrapperName&_CallIntHandler:
|
2018-04-13 06:48:57 +00:00
|
|
|
/* We got a pointer to call. Since it won't return, reset the stack to
|
|
|
|
the location of the stack frame. This frees up our own stack as well
|
|
|
|
as that of the functions above us, and avoids an overflow due to
|
|
|
|
excessive recursion.
|
2018-02-11 10:33:16 +00:00
|
|
|
The next function takes the trap frame as its (fastcall) argument. */
|
2016-05-10 15:03:56 +00:00
|
|
|
mov ecx, [esp+8]
|
2018-04-13 06:48:57 +00:00
|
|
|
mov esp, ecx
|
|
|
|
mov ebp, esp
|
2016-05-10 15:03:56 +00:00
|
|
|
jmp eax
|
|
|
|
.ENDP
|
2018-02-18 11:42:18 +00:00
|
|
|
ENDM
|
|
|
|
|
2018-02-18 11:50:54 +00:00
|
|
|
MACRO(DEFINE_INTERRUPT_WRAPPER, WrapperName, HandlerName)
|
|
|
|
EXTERN _&HandlerName:PROC
|
|
|
|
PUBLIC _&WrapperName
|
|
|
|
.PROC _&WrapperName
|
|
|
|
FPO 0, 0, 0, 0, 0, FRAME_FPO
|
|
|
|
|
|
|
|
/* Call the C function */
|
|
|
|
call _&HandlerName
|
|
|
|
|
|
|
|
/* Check if we got a pointer back */
|
|
|
|
test eax, eax
|
|
|
|
jnz WrapperName&_CallIntHandler
|
|
|
|
|
|
|
|
/* No? Just return */
|
|
|
|
ret
|
|
|
|
|
|
|
|
WrapperName&_CallIntHandler:
|
|
|
|
/* Optimize the tail call to avoid stack overflow */
|
|
|
|
jmp eax
|
|
|
|
.ENDP
|
|
|
|
ENDM
|
|
|
|
|
2018-02-18 11:42:18 +00:00
|
|
|
|
|
|
|
DEFINE_END_INTERRUPT_WRAPPER HalpEndSoftwareInterrupt, HalpEndSoftwareInterrupt2
|
2018-02-18 11:49:24 +00:00
|
|
|
DEFINE_END_INTERRUPT_WRAPPER HalEndSystemInterrupt, HalEndSystemInterrupt2
|
2016-05-10 15:03:56 +00:00
|
|
|
|
2018-02-18 11:50:54 +00:00
|
|
|
DEFINE_INTERRUPT_WRAPPER HalpDispatchInterrupt, HalpDispatchInterrupt2
|
2018-02-18 11:51:16 +00:00
|
|
|
DEFINE_INTERRUPT_WRAPPER HalpHardwareInterruptLevel, HalpHardwareInterruptLevel2
|
2018-02-18 11:50:54 +00:00
|
|
|
|
2016-05-10 15:03:56 +00:00
|
|
|
END
|