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