Jayanth Dodderi Chidanand | 95d5d27 | 2023-01-16 17:58:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <asm_macros.S> |
| 8 | #include <arch.h> |
| 9 | |
| 10 | .arch armv8-a+sve |
| 11 | .globl sme2_load_zt0_instruction |
| 12 | .globl sme2_store_zt0_instruction |
| 13 | |
| 14 | /* |
| 15 | * TODO: Due to the limitation with toolchain, SME2 intrinsics, still not |
| 16 | * being supported, manually instructions are encoded using the opcodes. |
| 17 | * Further, when the toolchain supports the requirements, these macros could |
| 18 | * be refactored. |
| 19 | */ |
| 20 | .macro _check_general_reg_number nr |
| 21 | .if ((\nr) < 0) || ((\nr) > 30) |
| 22 | .error "Bad register number \nr." |
| 23 | .endif |
| 24 | .endm |
| 25 | |
| 26 | /* |
| 27 | * LDR (ZT0) : Load ZT0 register with 64byte data. |
| 28 | * Instruction: LDR ZT0, [<Xn|SP>] |
| 29 | * |
| 30 | * LDR ZT0, nx |
| 31 | * Opcode bit field: |
| 32 | * nx : 64-bit name of the general-purpose base register |
| 33 | */ |
| 34 | .macro _ldr_zt nx |
| 35 | _check_general_reg_number \nx |
| 36 | .inst 0xe11f8000 | (((\nx) & 0x1f) << 5) |
| 37 | .endm |
| 38 | |
| 39 | /* |
| 40 | * STR (ZT0) : Store the 64-byte ZT0 register to the memory address |
| 41 | * provided in the 64-bit base register or stack pointer. |
| 42 | * Instruction: STR ZT0, [<Xn|SP>] |
| 43 | * |
| 44 | * STR ZT0, nx |
| 45 | * Opcode bit field: |
| 46 | * nx : 64-bit name of the general-purpose base register |
| 47 | */ |
| 48 | .macro _str_zt nx |
| 49 | .inst 0xe13f8000 | (((\nx) & 0x1f) << 5) |
| 50 | .endm |
| 51 | |
| 52 | /* |
| 53 | * void sme2_load_zt0_instruction; |
| 54 | * |
| 55 | * This function loads data from input buffer pointed |
| 56 | * to by X0 register into the 512 bits ZT0 register. |
| 57 | */ |
| 58 | func sme2_load_zt0_instruction |
| 59 | _ldr_zt 0 |
| 60 | ret |
| 61 | endfunc sme2_load_zt0_instruction |
| 62 | |
| 63 | /* |
| 64 | * void sme2_store_zt0_instruction; |
| 65 | * |
| 66 | * This function stores data from the SME2 ZT0 register |
| 67 | * into the memory section pointed by the x0 register. |
| 68 | * It copies 512bits of data to the inout memory buffer. |
| 69 | */ |
| 70 | func sme2_store_zt0_instruction |
| 71 | _str_zt 0 |
| 72 | ret |
| 73 | endfunc sme2_store_zt0_instruction |