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