johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 1 | /* |
Olivier Deprez | 6043eaf | 2024-03-08 14:14:12 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2024, Arm Limited. All rights reserved. |
johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Olivier Deprez | 1920238 | 2022-08-17 14:18:51 +0200 | [diff] [blame] | 7 | #ifndef SME_H |
| 8 | #define SME_H |
johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 9 | |
Arunachalam Ganapathy | 5b68e20 | 2023-06-06 16:31:19 +0100 | [diff] [blame] | 10 | #include <stdlib.h> /* for rand() */ |
| 11 | |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 12 | #define MAX_VL (512) |
| 13 | #define MAX_VL_B (MAX_VL / 8) |
Arunachalam Ganapathy | 5b68e20 | 2023-06-06 16:31:19 +0100 | [diff] [blame] | 14 | #define SME_SVQ_ARCH_MAX (MASK(SMCR_ELX_LEN) >> SMCR_ELX_LEN_SHIFT) |
| 15 | |
Olivier Deprez | 6043eaf | 2024-03-08 14:14:12 +0100 | [diff] [blame] | 16 | /* convert SME SVL in bytes to SVQ */ |
| 17 | #define SME_SVL_TO_SVQ(svl_bytes) (((svl_bytes) >> 4U) - 1U) |
| 18 | |
Arunachalam Ganapathy | 5b68e20 | 2023-06-06 16:31:19 +0100 | [diff] [blame] | 19 | /* get a random Streaming SVE VQ b/w 0 to SME_SVQ_ARCH_MAX */ |
| 20 | #define SME_GET_RANDOM_SVQ (rand() % (SME_SVQ_ARCH_MAX + 1)) |
johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 21 | |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 22 | typedef enum { |
| 23 | SMSTART, /* enters streaming sve mode and enables SME ZA array */ |
| 24 | SMSTART_SM, /* enters streaming sve mode only */ |
| 25 | SMSTART_ZA, /* enables SME ZA array storage only */ |
| 26 | } smestart_instruction_type_t; |
johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 27 | |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 28 | typedef enum { |
| 29 | SMSTOP, /* exits streaming sve mode, & disables SME ZA array */ |
| 30 | SMSTOP_SM, /* exits streaming sve mode only */ |
| 31 | SMSTOP_ZA, /* disables SME ZA array storage only */ |
| 32 | } smestop_instruction_type_t; |
| 33 | |
| 34 | /* SME feature related prototypes. */ |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 35 | void sme_smstart(smestart_instruction_type_t smstart_type); |
| 36 | void sme_smstop(smestop_instruction_type_t smstop_type); |
Olivier Deprez | 6043eaf | 2024-03-08 14:14:12 +0100 | [diff] [blame] | 37 | uint32_t sme_probe_svl(uint8_t sme_max_svq); |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 38 | |
| 39 | /* Assembly function prototypes. */ |
Arunachalam Ganapathy | 47b702c | 2023-06-06 13:31:46 +0100 | [diff] [blame] | 40 | uint64_t sme_rdsvl_1(void); |
johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 41 | void sme_try_illegal_instruction(void); |
Jayanth Dodderi Chidanand | b3ffd3c | 2023-02-13 12:15:11 +0000 | [diff] [blame] | 42 | void sme_vector_to_ZA(const uint64_t *input_vector); |
| 43 | void sme_ZA_to_vector(const uint64_t *output_vector); |
Jayanth Dodderi Chidanand | 95d5d27 | 2023-01-16 17:58:47 +0000 | [diff] [blame] | 44 | void sme2_load_zt0_instruction(const uint64_t *inputbuf); |
| 45 | void sme2_store_zt0_instruction(const uint64_t *outputbuf); |
Arunachalam Ganapathy | 5b68e20 | 2023-06-06 16:31:19 +0100 | [diff] [blame] | 46 | void sme_config_svq(uint32_t svq); |
| 47 | void sme_enable_fa64(void); |
| 48 | void sme_disable_fa64(void); |
| 49 | bool sme_smstat_sm(void); |
| 50 | bool sme_feat_fa64_enabled(void); |
johpow01 | 50ccb55 | 2020-11-10 19:22:13 -0600 | [diff] [blame] | 51 | |
Olivier Deprez | 1920238 | 2022-08-17 14:18:51 +0200 | [diff] [blame] | 52 | #endif /* SME_H */ |