blob: 07bd6633b4c03dcd7e168fbb24a568741994e9fb [file] [log] [blame]
Max Shvetsov959be332021-03-16 14:18:13 +00001/*
Olivier Deprez569be402022-07-08 10:24:39 +02002 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
Max Shvetsov959be332021-03-16 14:18:13 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef SVE_H
8#define SVE_H
9
10#define fill_sve_helper(num) "ldr z"#num", [%0, #"#num", MUL VL];"
11#define read_sve_helper(num) "str z"#num", [%0, #"#num", MUL VL];"
12
Olivier Deprez569be402022-07-08 10:24:39 +020013/*
14 * Max. vector length permitted by the architecture:
15 * SVE: 2048 bits = 256 bytes
16 */
17#define SVE_VECTOR_LEN_BYTES 256
18#define SVE_NUM_VECTORS 32
19
Kathleen Capellac59184c2022-08-23 19:09:41 -040020#ifndef __ASSEMBLY__
21
Olivier Deprez569be402022-07-08 10:24:39 +020022typedef uint8_t sve_vector_t[SVE_VECTOR_LEN_BYTES];
23
24#ifdef __aarch64__
25
26/* Returns the SVE implemented VL in bytes (constrained by ZCR_EL3.LEN) */
27static inline uint64_t sve_vector_length_get(void)
28{
29 uint64_t vl;
30
31 __asm__ volatile(
32 ".arch_extension sve\n"
33 "rdvl %0, #1;"
34 ".arch_extension nosve\n"
35 : "=r" (vl)
36 );
37
38 return vl;
39}
40
41#endif /* __aarch64__ */
Kathleen Capellac59184c2022-08-23 19:09:41 -040042#endif /* __ASSEMBLY__ */
Olivier Deprez569be402022-07-08 10:24:39 +020043#endif /* SVE_H */