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