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