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