blob: 4a7e9b74a488279ddcda5b20164f8f492db7b68a [file] [log] [blame]
johpow0150ccb552020-11-10 19:22:13 -06001/*
Jayanth Dodderi Chidanand95d5d272023-01-16 17:58:47 +00002 * Copyright (c) 2021-2023, 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
16/* get a random Streaming SVE VQ b/w 0 to SME_SVQ_ARCH_MAX */
17#define SME_GET_RANDOM_SVQ (rand() % (SME_SVQ_ARCH_MAX + 1))
johpow0150ccb552020-11-10 19:22:13 -060018
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000019typedef enum {
20 SMSTART, /* enters streaming sve mode and enables SME ZA array */
21 SMSTART_SM, /* enters streaming sve mode only */
22 SMSTART_ZA, /* enables SME ZA array storage only */
23} smestart_instruction_type_t;
johpow0150ccb552020-11-10 19:22:13 -060024
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000025typedef enum {
26 SMSTOP, /* exits streaming sve mode, & disables SME ZA array */
27 SMSTOP_SM, /* exits streaming sve mode only */
28 SMSTOP_ZA, /* disables SME ZA array storage only */
29} smestop_instruction_type_t;
30
31/* SME feature related prototypes. */
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000032void sme_smstart(smestart_instruction_type_t smstart_type);
33void sme_smstop(smestop_instruction_type_t smstop_type);
34
35/* Assembly function prototypes. */
Arunachalam Ganapathy47b702c2023-06-06 13:31:46 +010036uint64_t sme_rdsvl_1(void);
johpow0150ccb552020-11-10 19:22:13 -060037void sme_try_illegal_instruction(void);
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000038void sme_vector_to_ZA(const uint64_t *input_vector);
39void sme_ZA_to_vector(const uint64_t *output_vector);
Jayanth Dodderi Chidanand95d5d272023-01-16 17:58:47 +000040void sme2_load_zt0_instruction(const uint64_t *inputbuf);
41void sme2_store_zt0_instruction(const uint64_t *outputbuf);
Arunachalam Ganapathy5b68e202023-06-06 16:31:19 +010042void sme_config_svq(uint32_t svq);
43void sme_enable_fa64(void);
44void sme_disable_fa64(void);
45bool sme_smstat_sm(void);
46bool sme_feat_fa64_enabled(void);
johpow0150ccb552020-11-10 19:22:13 -060047
Olivier Deprez19202382022-08-17 14:18:51 +020048#endif /* SME_H */