]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Ebc/Dxe/x64/EbcLowLevel.S
Add EBC, FTW, Crc32SectionExtract, NullMemoryTest modules.
[mirror_edk2.git] / MdeModulePkg / Universal / Ebc / Dxe / x64 / EbcLowLevel.S
CommitLineData
d7dec593 1#****************************************************************************\r
2#* \r
3#* Copyright (c) 2006, Intel Corporation \r
4#* All rights reserved. This program and the accompanying materials \r
5#* are licensed and made available under the terms and conditions of the BSD License \r
6#* which accompanies this distribution. The full text of the license may be found at \r
7#* http://opensource.org/licenses/bsd-license.php \r
8#* \r
9#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11#* \r
12#****************************************************************************\r
13#****************************************************************************\r
14# REV 1.0\r
15#****************************************************************************\r
16#\r
17# Rev Date Description\r
18# --- -------- ------------------------------------------------------------\r
19# 1.0 05/09/12 Initial creation of file.\r
20#\r
21#****************************************************************************\r
22\r
23#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\r
24# This code provides low level routines that support the Virtual Machine\r
25# for option ROMs. \r
26#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\r
27\r
28#---------------------------------------------------------------------------\r
29# Equate files needed.\r
30#---------------------------------------------------------------------------\r
31\r
32#---------------------------------------------------------------------------\r
33##GenericPostSegment SEGMENT USE16\r
34#---------------------------------------------------------------------------\r
35\r
36#****************************************************************************\r
37# EbcLLCALLEX\r
38#\r
39# This function is called to execute an EBC CALLEX instruction. \r
40# This instruction requires that we thunk out to external native\r
41# code. For x64, we switch stacks, copy the arguments to the stack\r
42# and jump to the specified function. \r
43# On return, we restore the stack pointer to its original location.\r
44#\r
45# Destroys no working registers.\r
46#****************************************************************************\r
47.global _CopyMem;\r
48\r
49# VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
50.global _EbcLLCALLEXNative;\r
51_EbcLLCALLEXNative:\r
52 push %rbp\r
53 push %rbx\r
54 mov %rsp, %rbp\r
55 # Function prolog\r
56\r
57 # Copy FuncAddr to a preserved register.\r
58 mov %rcx, %rbx\r
59\r
60 # Set stack pointer to new value\r
61 sub %r8, %rdx\r
62 sub %rsp, %r8\r
63 mov %rsp, %rcx\r
64 sub %rsp, 0x20\r
65 call _CopyMem \r
66 add %rsp, 0x20\r
67\r
68 # Considering the worst case, load 4 potiential arguments\r
69 # into registers.\r
70 mov (%rsp), %rcx\r
71 mov 8(%rsp), %rdx\r
72 mov 10(%rsp), %r8\r
73 mov 18(%rsp), %r9\r
74\r
75 # Now call the external routine\r
76 call *%rbx\r
77\r
78 # Function epilog\r
79 mov %rbp, %rsp\r
80 pop %rbx\r
81 pop %rbp\r
82 ret\r
83\r
84\r
85# UINTN EbcLLGetEbcEntryPoint(VOID);\r
86# Routine Description:\r
87# The VM thunk code stuffs an EBC entry point into a processor\r
88# register. Since we can't use inline assembly to get it from\r
89# the interpreter C code, stuff it into the return value \r
90# register and return.\r
91#\r
92# Arguments:\r
93# None.\r
94#\r
95# Returns:\r
96# The contents of the register in which the entry point is passed.\r
97#\r
98.global _EbcLLGetEbcEntryPoint;\r
99_EbcLLGetEbcEntryPoint:\r
100 ret\r
101\r
102#/*++\r
103#\r
104#Routine Description:\r
105# \r
106# Return the caller's value of the stack pointer.\r
107#\r
108#Arguments:\r
109#\r
110# None.\r
111#\r
112#Returns:\r
113#\r
114# The current value of the stack pointer for the caller. We\r
115# adjust it by 4 here because when they called us, the return address\r
116# is put on the stack, thereby lowering it by 4 bytes.\r
117#\r
118#--*/\r
119\r
120# UINTN EbcLLGetStackPointer() \r
121.global _EbcLLGetStackPointer;\r
122_EbcLLGetStackPointer:\r
123 mov %rsp, %rax\r
124 # Stack adjusted by this much when we were called,\r
125 # For this function, it's 4.\r
126 add $4, %rax\r
127 ret\r
128\r
129.global _EbcLLGetReturnValue;\r
130_EbcLLGetReturnValue:\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 ret\r