]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Ebc/Dxe/x64/EbcLowLevel.S
1. Advance IP in case of Break(3) in breakpoint exception
[mirror_edk2.git] / EdkModulePkg / Universal / Ebc / Dxe / x64 / EbcLowLevel.S
CommitLineData
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#****************************************************************************
73ebf379 47.global _CopyMem;
48
8b7ba927 49# VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
50.global _EbcLLCALLEXNative;
51_EbcLLCALLEXNative:
52 push %rbp
53 push %rbx
54 mov %rsp, %rbp
55 # Function prolog
56
57 # Copy FuncAddr to a preserved register.
58 mov %rcx, %rbx
59
60 # Set stack pointer to new value
73ebf379 61 sub %r8, %rdx
62 sub %rsp, %r8
63 mov %rsp, %rcx
64 sub %rsp, 0x20
65 call _CopyMem
66 add %rsp, 0x20
8b7ba927 67
68 # Considering the worst case, load 4 potiential arguments
69 # into registers.
70 mov (%rsp), %rcx
71 mov 8(%rsp), %rdx
72 mov 10(%rsp), %r8
73 mov 18(%rsp), %r9
74
75 # Now call the external routine
76 call *%rbx
77
78 # Function epilog
79 mov %rbp, %rsp
80 pop %rbx
81 pop %rbp
82 ret
83
84
85# UINTN EbcLLGetEbcEntryPoint(VOID);
86# Routine Description:
87# The VM thunk code stuffs an EBC entry point into a processor
88# register. Since we can't use inline assembly to get it from
89# the interpreter C code, stuff it into the return value
90# register and return.
91#
92# Arguments:
93# None.
94#
95# Returns:
96# The contents of the register in which the entry point is passed.
97#
98.global _EbcLLGetEbcEntryPoint;
99_EbcLLGetEbcEntryPoint:
100 ret
101
102#/*++
103#
104#Routine Description:
105#
106# Return the caller's value of the stack pointer.
107#
108#Arguments:
109#
110# None.
111#
112#Returns:
113#
114# The current value of the stack pointer for the caller. We
115# adjust it by 4 here because when they called us, the return address
116# is put on the stack, thereby lowering it by 4 bytes.
117#
118#--*/
119
120# UINTN EbcLLGetStackPointer()
121.global _EbcLLGetStackPointer;
122_EbcLLGetStackPointer:
123 mov %rsp, %rax
124 # Stack adjusted by this much when we were called,
125 # For this function, it's 4.
126 add $4, %rax
127 ret
128
129.global _EbcLLGetReturnValue;
130_EbcLLGetReturnValue:
131# UINT64 EbcLLGetReturnValue(VOID);
132# Routine Description:
133# When EBC calls native, on return the VM has to stuff the return
134# value into a VM register. It's assumed here that the value is still
135# in the register, so simply return and the caller should get the
136# return result properly.
137#
138# Arguments:
139# None.
140#
141# Returns:
142# The unmodified value returned by the native code.
143#
144 ret