microsoft/mu_feature_ffa
Publicmirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable
FfaFeaturePkg/Library/SecurePartitionEntryPoint/AArch64/ModuleEntryPoint.S
63lines · modecode
| 1 | // |
| 2 | // Copyright (c) 2021, ARM Limited. All rights reserved. |
| 3 | // |
| 4 | // SPDX-License-Identifier: BSD-2-Clause-Patent |
| 5 | // |
| 6 | // |
| 7 | |
| 8 | #include <AArch64/AsmMacroLib.h> |
| 9 | |
| 10 | .align 12 |
| 11 | StackBase: |
| 12 | .space 8192 |
| 13 | StackEnd: |
| 14 | |
| 15 | .macro FfaMemPermSet start:req end:req perm:req |
| 16 | adrp x29, \start |
| 17 | add x29, x29, :lo12: \start |
| 18 | |
| 19 | adrp x30, \end |
| 20 | add x30, x30, :lo12:\end |
| 21 | |
| 22 | /* x30 = end - begin */ |
| 23 | sub x30, x30, x29 |
| 24 | /* x28 = x30 >> 12 (number of pages) */ |
| 25 | mov x28, #12 |
| 26 | lsrv x28, x30, x28 |
| 27 | |
| 28 | mov w0, #0x89 |
| 29 | movk w0, #0x8400, lsl #16 |
| 30 | mov x1, x29 |
| 31 | mov x2, x28 |
| 32 | mov w3, #\perm |
| 33 | |
| 34 | svc #0 |
| 35 | |
| 36 | mov w1, #0x61 |
| 37 | movk w1, #0x8400, lsl #16 |
| 38 | cmp w1, w0 |
| 39 | b.ne . |
| 40 | .endm |
| 41 | |
| 42 | ASM_FUNC(_ModuleEntryPoint) |
| 43 | // Stash boot information registers from the SPMC |
| 44 | mov x8, x0 |
| 45 | mov x9, x1 |
| 46 | mov x10, x2 |
| 47 | mov x11, x3 |
| 48 | |
| 49 | // Set the correct permissions on stack memory |
| 50 | FfaMemPermSet StackBase StackEnd 0x5 |
| 51 | |
| 52 | // Initialise SP |
| 53 | adr x0, StackEnd |
| 54 | mov sp, x0 |
| 55 | |
| 56 | // Restore boot information registers from the SPMC |
| 57 | mov x0, x8 |
| 58 | mov x1, x9 |
| 59 | mov x2, x10 |
| 60 | mov x3, x11 |
| 61 | |
| 62 | // Invoke the C entrypoint |
| 63 | b ModuleEntryPoint |