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