blob: 7175b71452653805e7ed7f54c4e151ad7b7b44af [file] [log] [blame]
johpow0150ccb552020-11-10 19:22:13 -06001/*
Olivier Deprez6043eaf2024-03-08 14:14:12 +01002 * Copyright (c) 2021-2024, Arm Limited. All rights reserved.
johpow0150ccb552020-11-10 19:22:13 -06003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Olivier Deprez19202382022-08-17 14:18:51 +02007#ifndef SME_H
8#define SME_H
johpow0150ccb552020-11-10 19:22:13 -06009
Arunachalam Ganapathy5b68e202023-06-06 16:31:19 +010010#include <stdlib.h> /* for rand() */
11
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000012#define MAX_VL (512)
13#define MAX_VL_B (MAX_VL / 8)
Arunachalam Ganapathy5b68e202023-06-06 16:31:19 +010014#define SME_SVQ_ARCH_MAX (MASK(SMCR_ELX_LEN) >> SMCR_ELX_LEN_SHIFT)
15
Olivier Deprez6043eaf2024-03-08 14:14:12 +010016/* convert SME SVL in bytes to SVQ */
17#define SME_SVL_TO_SVQ(svl_bytes) (((svl_bytes) >> 4U) - 1U)
18
Arunachalam Ganapathy5b68e202023-06-06 16:31:19 +010019/* 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))
johpow0150ccb552020-11-10 19:22:13 -060021
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000022typedef 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;
johpow0150ccb552020-11-10 19:22:13 -060027
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000028typedef 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 Chidanandb3ffd3c2023-02-13 12:15:11 +000035void sme_smstart(smestart_instruction_type_t smstart_type);
36void sme_smstop(smestop_instruction_type_t smstop_type);
Olivier Deprez6043eaf2024-03-08 14:14:12 +010037uint32_t sme_probe_svl(uint8_t sme_max_svq);
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000038
39/* Assembly function prototypes. */
Arunachalam Ganapathy47b702c2023-06-06 13:31:46 +010040uint64_t sme_rdsvl_1(void);
johpow0150ccb552020-11-10 19:22:13 -060041void sme_try_illegal_instruction(void);
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000042void sme_vector_to_ZA(const uint64_t *input_vector);
43void sme_ZA_to_vector(const uint64_t *output_vector);
Jayanth Dodderi Chidanand95d5d272023-01-16 17:58:47 +000044void sme2_load_zt0_instruction(const uint64_t *inputbuf);
45void sme2_store_zt0_instruction(const uint64_t *outputbuf);
Arunachalam Ganapathy5b68e202023-06-06 16:31:19 +010046void sme_config_svq(uint32_t svq);
47void sme_enable_fa64(void);
48void sme_disable_fa64(void);
49bool sme_smstat_sm(void);
50bool sme_feat_fa64_enabled(void);
johpow0150ccb552020-11-10 19:22:13 -060051
Olivier Deprez19202382022-08-17 14:18:51 +020052#endif /* SME_H */