blob: 45481d743c233c919dc8412fc185ac0493d5c7f3 [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
20typedef uint8_t sve_vector_t[SVE_VECTOR_LEN_BYTES];
21
22#ifdef __aarch64__
23
24/* Returns the SVE implemented VL in bytes (constrained by ZCR_EL3.LEN) */
25static inline uint64_t sve_vector_length_get(void)
26{
27 uint64_t vl;
28
29 __asm__ volatile(
30 ".arch_extension sve\n"
31 "rdvl %0, #1;"
32 ".arch_extension nosve\n"
33 : "=r" (vl)
34 );
35
36 return vl;
37}
38
39#endif /* __aarch64__ */
40
41#endif /* SVE_H */