]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/EbcDxe/x64/EbcLowLevel.asm
Update to fix minor coding style issues.
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / x64 / EbcLowLevel.asm
CommitLineData
7b414b4e 1;/** @file\r
f45af90b 2; \r
3; This code provides low level routines that support the Virtual Machine.\r
4; for option ROMs.\r
5; \r
7b414b4e 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
f45af90b 11; \r
7b414b4e 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
f45af90b 14; \r
7b414b4e 15;**/\r
16\r
7b414b4e 17 page ,132\r
18 title VM ASSEMBLY LANGUAGE ROUTINES\r
53c71d09 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
7b414b4e 33; This function is called to execute an EBC CALLEX instruction.\r
53c71d09 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
7b414b4e 36; and jump to the specified function.\r
53c71d09 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
db01f13e 46EbcLLCALLEXNative PROC PUBLIC\r
53c71d09 47 push rbp\r
48 push rbx\r
49 mov rbp, rsp\r
50 ; Function prolog\r
7b414b4e 51\r
53c71d09 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
7b414b4e 60 call CopyMem\r
53c71d09 61 add rsp, 20h\r
7b414b4e 62\r
53c71d09 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
7b414b4e 72\r
53c71d09 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
7b414b4e 85; the interpreter C code, stuff it into the return value\r
53c71d09 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
db01f13e 94EbcLLGetEbcEntryPoint PROC PUBLIC\r
53c71d09 95 ret\r
96EbcLLGetEbcEntryPoint ENDP\r
97\r
98;/*++\r
99;\r
100;Routine Description:\r
7b414b4e 101;\r
53c71d09 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
7b414b4e 116; UINTN EbcLLGetStackPointer()\r
db01f13e 117EbcLLGetStackPointer PROC PUBLIC\r
53c71d09 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
db01f13e 138EbcLLGetReturnValue PROC PUBLIC\r
53c71d09 139 ret\r
140EbcLLGetReturnValue ENDP\r
141\r
142text ENDS\r
143END\r
144\r