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