]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
Update the copyright notice format
[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
e5eed7d3
HT
6; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
7; This program and the accompanying materials\r
7b414b4e 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
045e90ac 95 mov rax, r10\r
53c71d09 96 ret\r
97EbcLLGetEbcEntryPoint ENDP\r
98\r
99;/*++\r
100;\r
101;Routine Description:\r
7b414b4e 102;\r
53c71d09 103; Return the caller's value of the stack pointer.\r
104;\r
105;Arguments:\r
106;\r
107; None.\r
108;\r
109;Returns:\r
110;\r
111; The current value of the stack pointer for the caller. We\r
112; adjust it by 4 here because when they called us, the return address\r
113; is put on the stack, thereby lowering it by 4 bytes.\r
114;\r
115;--*/\r
116\r
7b414b4e 117; UINTN EbcLLGetStackPointer()\r
db01f13e 118EbcLLGetStackPointer PROC PUBLIC\r
53c71d09 119 mov rax, rsp ; get current stack pointer\r
120 ; Stack adjusted by this much when we were called,\r
121 ; For this function, it's 4.\r
122 add rax, 4\r
123 ret\r
124EbcLLGetStackPointer ENDP\r
125\r
126; UINT64 EbcLLGetReturnValue(VOID);\r
127; Routine Description:\r
128; When EBC calls native, on return the VM has to stuff the return\r
129; value into a VM register. It's assumed here that the value is still\r
130; in the register, so simply return and the caller should get the\r
131; return result properly.\r
132;\r
133; Arguments:\r
134; None.\r
135;\r
136; Returns:\r
137; The unmodified value returned by the native code.\r
138;\r
db01f13e 139EbcLLGetReturnValue PROC PUBLIC\r
53c71d09 140 ret\r
141EbcLLGetReturnValue ENDP\r
142\r
143text ENDS\r
144END\r
145\r