]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm
Added incremental support in GenFds
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / Ia32 / EbcLowLevel.asm
1 ;/** @file
2 ; This code provides low level routines that support the Virtual Machine
3 ; for option ROMs.
4 ;
5 ; Copyright (c) 2006 - 2008, Intel Corporation. <BR>
6 ; All rights reserved. This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php
10 ;
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 ;
14 ;**/
15
16 page ,132
17 title VM ASSEMBLY LANGUAGE ROUTINES
18
19 ;---------------------------------------------------------------------------
20 ; Equate files needed.
21 ;---------------------------------------------------------------------------
22
23 .XLIST
24
25 .LIST
26
27 ;---------------------------------------------------------------------------
28 ; Assembler options
29 ;---------------------------------------------------------------------------
30
31 .686p
32 .model flat
33 .code
34 ;---------------------------------------------------------------------------
35 ;;GenericPostSegment SEGMENT USE16
36 ;---------------------------------------------------------------------------
37 CopyMem PROTO C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
38
39 ;****************************************************************************
40 ; EbcLLCALLEXNative
41 ;
42 ; This function is called to execute an EBC CALLEX instruction
43 ; to native code.
44 ; This instruction requires that we thunk out to external native
45 ; code. For IA32, we simply switch stacks and jump to the
46 ; specified function. On return, we restore the stack pointer
47 ; to its original location.
48 ;
49 ; Destroys no working registers.
50 ;****************************************************************************
51 ; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
52 _EbcLLCALLEXNative PROC NEAR PUBLIC
53 push ebp
54 push ebx
55 mov ebp, esp ; standard function prolog
56
57 ; Get function address in a register
58 ; mov ecx, FuncAddr => mov ecx, dword ptr [FuncAddr]
59 mov ecx, dword ptr [esp]+0Ch
60
61 ; Set stack pointer to new value
62 ; mov eax, NewStackPointer => mov eax, dword ptr [NewSp]
63 mov eax, dword ptr [esp] + 14h
64 mov edx, dword ptr [esp] + 10h
65 sub eax, edx
66 sub esp, eax
67 mov ebx, esp
68 push ecx
69 push eax
70 push edx
71 push ebx
72 call CopyMem
73 pop eax
74 pop eax
75 pop eax
76 pop ecx
77
78 ; Now call the external routine
79 call ecx
80
81 ; ebp is preserved by the callee. In this function it
82 ; equals the original esp, so set them equal
83 mov esp, ebp
84
85 ; Standard function epilog
86 mov esp, ebp
87 pop ebx
88 pop ebp
89 ret
90 _EbcLLCALLEXNative ENDP
91
92
93 ; UINTN EbcLLGetEbcEntryPoint(VOID);
94 ; Routine Description:
95 ; The VM thunk code stuffs an EBC entry point into a processor
96 ; register. Since we can't use inline assembly to get it from
97 ; the interpreter C code, stuff it into the return value
98 ; register and return.
99 ;
100 ; Arguments:
101 ; None.
102 ;
103 ; Returns:
104 ; The contents of the register in which the entry point is passed.
105 ;
106 _EbcLLGetEbcEntryPoint PROC NEAR PUBLIC
107 ret
108 _EbcLLGetEbcEntryPoint ENDP
109
110 ;/*++
111 ;
112 ;Routine Description:
113 ;
114 ; Return the caller's value of the stack pointer.
115 ;
116 ;Arguments:
117 ;
118 ; None.
119 ;
120 ;Returns:
121 ;
122 ; The current value of the stack pointer for the caller. We
123 ; adjust it by 4 here because when they called us, the return address
124 ; is put on the stack, thereby lowering it by 4 bytes.
125 ;
126 ;--*/
127
128 ; UINTN EbcLLGetStackPointer()
129 _EbcLLGetStackPointer PROC NEAR PUBLIC
130 mov eax, esp ; get current stack pointer
131 add eax, 4 ; stack adjusted by this much when we were called
132 ret
133 _EbcLLGetStackPointer ENDP
134
135 ; UINT64 EbcLLGetReturnValue(VOID);
136 ; Routine Description:
137 ; When EBC calls native, on return the VM has to stuff the return
138 ; value into a VM register. It's assumed here that the value is still
139 ; in the register, so simply return and the caller should get the
140 ; return result properly.
141 ;
142 ; Arguments:
143 ; None.
144 ;
145 ; Returns:
146 ; The unmodified value returned by the native code.
147 ;
148 _EbcLLGetReturnValue PROC NEAR PUBLIC
149 ret
150 _EbcLLGetReturnValue ENDP
151
152 END