Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Masahiro Yamada | a93297e | 2017-04-14 11:10:22 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015, Linaro Limited |
Abdellatif El Khlifi | 0b77c1d | 2023-08-04 14:33:37 +0100 | [diff] [blame] | 4 | * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 5 | * |
| 6 | * Authors: |
| 7 | * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> |
| 8 | */ |
Masahiro Yamada | a93297e | 2017-04-14 11:10:22 +0900 | [diff] [blame] | 9 | #include <linux/linkage.h> |
| 10 | #include <linux/arm-smccc.h> |
Masahiro Yamada | e8ead73 | 2017-04-14 11:10:23 +0900 | [diff] [blame] | 11 | #include <generated/asm-offsets.h> |
Masahiro Yamada | a93297e | 2017-04-14 11:10:22 +0900 | [diff] [blame] | 12 | |
Alexander Graf | 449c8b2 | 2019-02-11 15:07:17 +0100 | [diff] [blame] | 13 | #ifdef CONFIG_EFI_LOADER |
Heinrich Schuchardt | 26f09d0 | 2018-10-18 12:29:40 +0200 | [diff] [blame] | 14 | .section .text.efi_runtime |
Alexander Graf | 449c8b2 | 2019-02-11 15:07:17 +0100 | [diff] [blame] | 15 | #endif |
Heinrich Schuchardt | 26f09d0 | 2018-10-18 12:29:40 +0200 | [diff] [blame] | 16 | |
Masahiro Yamada | a93297e | 2017-04-14 11:10:22 +0900 | [diff] [blame] | 17 | .macro SMCCC instr |
| 18 | .cfi_startproc |
| 19 | \instr #0 |
| 20 | ldr x4, [sp] |
| 21 | stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] |
| 22 | stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] |
| 23 | ldr x4, [sp, #8] |
| 24 | cbz x4, 1f /* no quirk structure */ |
| 25 | ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS] |
| 26 | cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6 |
| 27 | b.ne 1f |
| 28 | str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS] |
| 29 | 1: ret |
| 30 | .cfi_endproc |
| 31 | .endm |
| 32 | |
| 33 | /* |
| 34 | * void arm_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, |
| 35 | * unsigned long a3, unsigned long a4, unsigned long a5, |
| 36 | * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, |
| 37 | * struct arm_smccc_quirk *quirk) |
| 38 | */ |
| 39 | ENTRY(__arm_smccc_smc) |
| 40 | SMCCC smc |
| 41 | ENDPROC(__arm_smccc_smc) |
| 42 | |
| 43 | /* |
| 44 | * void arm_smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, |
| 45 | * unsigned long a3, unsigned long a4, unsigned long a5, |
| 46 | * unsigned long a6, unsigned long a7, struct arm_smccc_res *res, |
| 47 | * struct arm_smccc_quirk *quirk) |
| 48 | */ |
| 49 | ENTRY(__arm_smccc_hvc) |
| 50 | SMCCC hvc |
| 51 | ENDPROC(__arm_smccc_hvc) |
Abdellatif El Khlifi | 0b77c1d | 2023-08-04 14:33:37 +0100 | [diff] [blame] | 52 | |
| 53 | #ifdef CONFIG_ARM64 |
| 54 | |
| 55 | .macro SMCCC_1_2 instr |
| 56 | /* Save `res` and free a GPR that won't be clobbered */ |
| 57 | stp x1, x19, [sp, #-16]! |
| 58 | |
| 59 | /* Ensure `args` won't be clobbered while loading regs in next step */ |
| 60 | mov x19, x0 |
| 61 | |
| 62 | /* Load the registers x0 - x17 from the struct arm_smccc_1_2_regs */ |
| 63 | ldp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS] |
| 64 | ldp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS] |
| 65 | ldp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS] |
| 66 | ldp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS] |
| 67 | ldp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS] |
| 68 | ldp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS] |
| 69 | ldp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS] |
| 70 | ldp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS] |
| 71 | ldp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS] |
| 72 | |
| 73 | \instr #0 |
| 74 | |
| 75 | /* Load the `res` from the stack */ |
| 76 | ldr x19, [sp] |
| 77 | |
| 78 | /* Store the registers x0 - x17 into the result structure */ |
| 79 | stp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS] |
| 80 | stp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS] |
| 81 | stp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS] |
| 82 | stp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS] |
| 83 | stp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS] |
| 84 | stp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS] |
| 85 | stp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS] |
| 86 | stp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS] |
| 87 | stp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS] |
| 88 | |
| 89 | /* Restore original x19 */ |
| 90 | ldp xzr, x19, [sp], #16 |
| 91 | ret |
| 92 | .endm |
| 93 | |
| 94 | /* |
| 95 | * void arm_smccc_1_2_smc(const struct arm_smccc_1_2_regs *args, |
| 96 | * struct arm_smccc_1_2_regs *res); |
| 97 | */ |
| 98 | ENTRY(arm_smccc_1_2_smc) |
| 99 | SMCCC_1_2 smc |
| 100 | ENDPROC(arm_smccc_1_2_smc) |
| 101 | |
| 102 | #endif |