]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Ebc/Dxe/Ia32/EbcLowLevel.asm
Initial import.
[mirror_edk2.git] / EdkModulePkg / Universal / Ebc / Dxe / Ia32 / EbcLowLevel.asm
CommitLineData
878ddf1f 1 page ,132\r
2 title VM ASSEMBLY LANGUAGE ROUTINES\r
3;****************************************************************************\r
4;* \r
5;* Copyright (c) 2006, 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\r
49;****************************************************************************\r
50; EbcLLCALLEXNative\r
51;\r
52; This function is called to execute an EBC CALLEX instruction\r
53; to native code. \r
54; This instruction requires that we thunk out to external native\r
55; code. For IA32, we simply switch stacks and jump to the \r
56; specified function. On return, we restore the stack pointer\r
57; to its original location.\r
58;\r
59; Destroys no working registers.\r
60;****************************************************************************\r
61; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
62_EbcLLCALLEXNative PROC NEAR PUBLIC\r
63 push ebp\r
64 mov ebp, esp ; standard function prolog\r
65 \r
66 ; Get function address in a register\r
67 ; mov ecx, FuncAddr => mov ecx, dword ptr [FuncAddr]\r
68 mov ecx, dword ptr [esp]+8\r
69\r
70 ; Set stack pointer to new value\r
71 ; mov eax, NewStackPointer => mov eax, dword ptr [NewSp]\r
72 mov eax, dword ptr [esp] + 0Ch\r
73 mov esp, eax \r
74\r
75 ; Now call the external routine\r
76 call ecx\r
77 \r
78 ; ebp is preserved by the callee. In this function it\r
79 ; equals the original esp, so set them equal\r
80 mov esp, ebp\r
81\r
82 ; Standard function epilog\r
83 mov esp, ebp\r
84 pop ebp\r
85 ret\r
86_EbcLLCALLEXNative ENDP\r
87\r
88\r
89; UINTN EbcLLGetEbcEntryPoint(VOID);\r
90; Routine Description:\r
91; The VM thunk code stuffs an EBC entry point into a processor\r
92; register. Since we can't use inline assembly to get it from\r
93; the interpreter C code, stuff it into the return value \r
94; register and return.\r
95;\r
96; Arguments:\r
97; None.\r
98;\r
99; Returns:\r
100; The contents of the register in which the entry point is passed.\r
101;\r
102_EbcLLGetEbcEntryPoint PROC NEAR PUBLIC\r
103 ret\r
104_EbcLLGetEbcEntryPoint ENDP\r
105\r
106;/*++\r
107;\r
108;Routine Description:\r
109; \r
110; Return the caller's value of the stack pointer.\r
111;\r
112;Arguments:\r
113;\r
114; None.\r
115;\r
116;Returns:\r
117;\r
118; The current value of the stack pointer for the caller. We\r
119; adjust it by 4 here because when they called us, the return address\r
120; is put on the stack, thereby lowering it by 4 bytes.\r
121;\r
122;--*/\r
123\r
124; UINTN EbcLLGetStackPointer() \r
125_EbcLLGetStackPointer PROC NEAR PUBLIC\r
126 mov eax, esp ; get current stack pointer\r
127 add eax, 4 ; stack adjusted by this much when we were called\r
128 ret\r
129_EbcLLGetStackPointer ENDP\r
130\r
131; UINT64 EbcLLGetReturnValue(VOID);\r
132; Routine Description:\r
133; When EBC calls native, on return the VM has to stuff the return\r
134; value into a VM register. It's assumed here that the value is still\r
135; in the register, so simply return and the caller should get the\r
136; return result properly.\r
137;\r
138; Arguments:\r
139; None.\r
140;\r
141; Returns:\r
142; The unmodified value returned by the native code.\r
143;\r
144_EbcLLGetReturnValue PROC NEAR PUBLIC\r
145 ret\r
146_EbcLLGetReturnValue ENDP\r
147\r
148END\r