[HAL] Create a macro for the HalpEndSoftwareInterrupt to allow reuse. CORE-14076
[reactos.git] / hal / halx86 / up / pic.S
1 /*
2 * FILE: hal/halx86/up/pic.S
3 * COPYRIGHT: See COPYING in the top level directory
4 * PURPOSE: HAL PIC Management and Control Code
5 * PROGRAMMER: Thomas Faber (thomas.faber@reactos.org)
6 */
7
8 /* INCLUDES ******************************************************************/
9
10 #include <asm.inc>
11
12 #include <ks386.inc>
13
14 /* GLOBALS *******************************************************************/
15
16 .data
17 ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING
18
19 /* FUNCTIONS *****************************************************************/
20
21 .code
22
23 MACRO(DEFINE_END_INTERRUPT_WRAPPER, WrapperName, HandlerName)
24 EXTERN @&HandlerName&@8:PROC
25 PUBLIC _&WrapperName&@8
26 .PROC _&WrapperName&@8
27 FPO 0, 2, 0, 0, 0, FRAME_FPO
28
29 /* Call the C function with the same arguments we got */
30 mov ecx, [esp+4]
31 mov edx, [esp+8]
32 call @&HandlerName&@8
33
34 /* Check if we got a pointer back */
35 test eax, eax
36 jnz WrapperName&_CallIntHandler
37
38 /* No? Just return */
39 ret 8
40
41 WrapperName&_CallIntHandler:
42 /* We got a pointer to call. Since it won't return, free up our stack
43 space. Otherwise we could end up with some nasty deep recursion.
44 The next function takes the trap frame as its (fastcall) argument. */
45 mov ecx, [esp+8]
46 add esp, 12
47 jmp eax
48 .ENDP
49 ENDM
50
51
52 DEFINE_END_INTERRUPT_WRAPPER HalpEndSoftwareInterrupt, HalpEndSoftwareInterrupt2
53
54 END