]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S
MdeModulePkg/EbcDxe: Add AARCH64 EBC VM support
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / AArch64 / EbcLowLevel.S
CommitLineData
a15e5bc2
JB
1#/** @file\r
2#\r
3# This code provides low level routines that support the Virtual Machine\r
4# for option ROMs.\r
5#\r
6# Copyright (c) 2015, The Linux Foundation. All rights reserved.\r
7# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
8# This program and the accompanying materials\r
9# are licensed and made available under the terms and conditions of the BSD License\r
10# which accompanies this distribution. The full text of the license may be found at\r
11# http://opensource.org/licenses/bsd-license.php\r
12#\r
13# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15#\r
16#**/\r
17\r
18#---------------------------------------------------------------------------\r
19# Equate files needed.\r
20#---------------------------------------------------------------------------\r
21\r
22ASM_GLOBAL ASM_PFX(CopyMem);\r
23ASM_GLOBAL ASM_PFX(EbcInterpret);\r
24ASM_GLOBAL ASM_PFX(ExecuteEbcImageEntryPoint);\r
25\r
26#****************************************************************************\r
27# EbcLLCALLEX\r
28#\r
29# This function is called to execute an EBC CALLEX instruction.\r
30# This instruction requires that we thunk out to external native\r
31# code. For AArch64, we copy the VM stack into the main stack and then pop\r
32# the first 8 arguments off according to the AArch64 Procedure Call Standard\r
33# On return, we restore the stack pointer to its original location.\r
34#\r
35#****************************************************************************\r
36# UINTN EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
37ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative);\r
38ASM_PFX(EbcLLCALLEXNative):\r
39 stp x19, x20, [sp, #-16]!\r
40 stp x29, x30, [sp, #-16]!\r
41\r
42 mov x19, x0\r
43 mov x20, sp\r
44 sub x2, x2, x1 // Length = NewStackPointer-FramePtr\r
45 sub sp, sp, x2\r
46 sub sp, sp, #64 // Make sure there is room for at least 8 args in the new stack\r
47 mov x0, sp\r
48\r
49 bl CopyMem // Sp, NewStackPointer, Length\r
50\r
51 ldp x0, x1, [sp], #16\r
52 ldp x2, x3, [sp], #16\r
53 ldp x4, x5, [sp], #16\r
54 ldp x6, x7, [sp], #16\r
55\r
56 blr x19\r
57\r
58 mov sp, x20\r
59 ldp x29, x30, [sp], #16\r
60 ldp x19, x20, [sp], #16\r
61\r
62 ret\r
63\r
64#****************************************************************************\r
65# EbcLLEbcInterpret\r
66#\r
67# This function is called by the thunk code to handle an Native to EBC call\r
68# This can handle up to 16 arguments (1-8 on in x0-x7, 9-16 are on the stack)\r
69# x9 contains the Entry point that will be the first argument when\r
70# EBCInterpret is called.\r
71#\r
72#****************************************************************************\r
73ASM_GLOBAL ASM_PFX(EbcLLEbcInterpret);\r
74ASM_PFX(EbcLLEbcInterpret):\r
75 stp x29, x30, [sp, #-16]!\r
76\r
77 // copy the current arguments 9-16 from old location and add arg 7 to stack\r
78 // keeping 16 byte stack alignment\r
79 sub sp, sp, #80\r
80 str x7, [sp]\r
81 ldr x11, [sp, #96]\r
82 str x11, [sp, #8]\r
83 ldr x11, [sp, #104]\r
84 str x11, [sp, #16]\r
85 ldr x11, [sp, #112]\r
86 str x11, [sp, #24]\r
87 ldr x11, [sp, #120]\r
88 str x11, [sp, #32]\r
89 ldr x11, [sp, #128]\r
90 str x11, [sp, #40]\r
91 ldr x11, [sp, #136]\r
92 str x11, [sp, #48]\r
93 ldr x11, [sp, #144]\r
94 str x11, [sp, #56]\r
95 ldr x11, [sp, #152]\r
96 str x11, [sp, #64]\r
97\r
98 // Shift arguments and add entry point and as argument 1\r
99 mov x7, x6\r
100 mov x6, x5\r
101 mov x5, x4\r
102 mov x4, x3\r
103 mov x3, x2\r
104 mov x2, x1\r
105 mov x1, x0\r
106 mov x0, x9\r
107\r
108 # call C-code\r
109 bl ASM_PFX(EbcInterpret)\r
110 add sp, sp, #80\r
111\r
112 ldp x29, x30, [sp], #16\r
113\r
114 ret\r
115\r
116#****************************************************************************\r
117# EbcLLExecuteEbcImageEntryPoint\r
118#\r
119# This function is called by the thunk code to handle the image entry point\r
120# x9 contains the Entry point that will be the first argument when\r
121# ExecuteEbcImageEntryPoint is called.\r
122#\r
123#****************************************************************************\r
124ASM_GLOBAL ASM_PFX(EbcLLExecuteEbcImageEntryPoint);\r
125ASM_PFX(EbcLLExecuteEbcImageEntryPoint):\r
126 stp x29, x30, [sp, #-16]!\r
127 # build new paramater calling convention\r
128 mov x2, x1\r
129 mov x1, x0\r
130 mov x0, x9\r
131\r
132 # call C-code\r
133 bl ASM_PFX(ExecuteEbcImageEntryPoint)\r
134 ldp x29, x30, [sp], #16\r
135 ret\r