]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Ebc/Dxe/x64/EbcLowLevel.asm
Add EBC, FTW, Crc32SectionExtract, NullMemoryTest modules.
[mirror_edk2.git] / MdeModulePkg / Universal / Ebc / Dxe / x64 / EbcLowLevel.asm
CommitLineData
d7dec593 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 05/09/12 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
34text SEGMENT\r
35\r
36;---------------------------------------------------------------------------\r
37;;GenericPostSegment SEGMENT USE16\r
38;---------------------------------------------------------------------------\r
39\r
40;****************************************************************************\r
41; EbcLLCALLEX\r
42;\r
43; This function is called to execute an EBC CALLEX instruction. \r
44; This instruction requires that we thunk out to external native\r
45; code. For x64, we switch stacks, copy the arguments to the stack\r
46; and jump to the specified function. \r
47; On return, we restore the stack pointer to its original location.\r
48;\r
49; Destroys no working registers.\r
50;****************************************************************************\r
51; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
52\r
53CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD\r
54\r
55\r
56EbcLLCALLEXNative PROC NEAR PUBLIC\r
57 push rbp\r
58 push rbx\r
59 mov rbp, rsp\r
60 ; Function prolog\r
61 \r
62 ; Copy FuncAddr to a preserved register.\r
63 mov rbx, rcx\r
64\r
65 ; Set stack pointer to new value\r
66 sub r8, rdx\r
67 sub rsp, r8\r
68 mov rcx, rsp\r
69 sub rsp, 20h\r
70 call CopyMem \r
71 add rsp, 20h\r
72 \r
73 ; Considering the worst case, load 4 potiential arguments\r
74 ; into registers.\r
75 mov rcx, qword ptr [rsp]\r
76 mov rdx, qword ptr [rsp+8h]\r
77 mov r8, qword ptr [rsp+10h]\r
78 mov r9, qword ptr [rsp+18h]\r
79\r
80 ; Now call the external routine\r
81 call rbx\r
82 \r
83 ; Function epilog\r
84 mov rsp, rbp\r
85 pop rbx\r
86 pop rbp\r
87 ret\r
88EbcLLCALLEXNative ENDP\r
89\r
90\r
91; UINTN EbcLLGetEbcEntryPoint(VOID);\r
92; Routine Description:\r
93; The VM thunk code stuffs an EBC entry point into a processor\r
94; register. Since we can't use inline assembly to get it from\r
95; the interpreter C code, stuff it into the return value \r
96; register and return.\r
97;\r
98; Arguments:\r
99; None.\r
100;\r
101; Returns:\r
102; The contents of the register in which the entry point is passed.\r
103;\r
104EbcLLGetEbcEntryPoint PROC NEAR PUBLIC\r
105 ret\r
106EbcLLGetEbcEntryPoint ENDP\r
107\r
108;/*++\r
109;\r
110;Routine Description:\r
111; \r
112; Return the caller's value of the stack pointer.\r
113;\r
114;Arguments:\r
115;\r
116; None.\r
117;\r
118;Returns:\r
119;\r
120; The current value of the stack pointer for the caller. We\r
121; adjust it by 4 here because when they called us, the return address\r
122; is put on the stack, thereby lowering it by 4 bytes.\r
123;\r
124;--*/\r
125\r
126; UINTN EbcLLGetStackPointer() \r
127EbcLLGetStackPointer PROC NEAR PUBLIC\r
128 mov rax, rsp ; get current stack pointer\r
129 ; Stack adjusted by this much when we were called,\r
130 ; For this function, it's 4.\r
131 add rax, 4\r
132 ret\r
133EbcLLGetStackPointer ENDP\r
134\r
135; UINT64 EbcLLGetReturnValue(VOID);\r
136; Routine Description:\r
137; When EBC calls native, on return the VM has to stuff the return\r
138; value into a VM register. It's assumed here that the value is still\r
139; in the register, so simply return and the caller should get the\r
140; return result properly.\r
141;\r
142; Arguments:\r
143; None.\r
144;\r
145; Returns:\r
146; The unmodified value returned by the native code.\r
147;\r
148EbcLLGetReturnValue PROC NEAR PUBLIC\r
149 ret\r
150EbcLLGetReturnValue ENDP\r
151\r
152text ENDS\r
153END\r
154\r