blob: a4c4b456208640680b9982c8a009baf0fa18544f [file] [log] [blame]
Shruti Gupta38133fa2023-04-19 17:00:38 +01001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef FPU_H
8#define FPU_H
9
10/* The FPU and SIMD register bank is 32 quadword (128 bits) Q registers. */
11#define FPU_Q_SIZE 16U
12#define FPU_Q_COUNT 32U
13
14/* These defines are needed by assembly code to access FPU registers. */
15#define FPU_OFFSET_Q 0U
16#define FPU_OFFSET_FPSR (FPU_Q_SIZE * FPU_Q_COUNT)
17#define FPU_OFFSET_FPCR (FPU_OFFSET_FPSR + 8)
18
19#ifndef __ASSEMBLER__
20
Shruti Gupta369955a2023-04-19 18:05:56 +010021#include <stdbool.h>
Shruti Gupta38133fa2023-04-19 17:00:38 +010022#include <stdint.h>
23
24typedef struct fpu_reg_state {
25 uint8_t q[FPU_Q_COUNT][FPU_Q_SIZE];
26 unsigned long fpsr;
27 unsigned long fpcr;
28} fpu_reg_state_t;
29
30/*
31 * Read and compare FPU state registers with provided template values in parameters.
32 */
33bool fpu_state_compare_template(fpu_reg_state_t *fpu);
34
35/*
36 * Fill the template with random values and copy it to
37 * FPU state registers(SIMD vectors, FPCR, FPSR).
38 */
39void fpu_state_fill_regs_and_template(fpu_reg_state_t *fpu);
40
41/*
42 * This function populates the provided FPU structure with the provided template
43 * regs_val for all the 32 FPU/SMID registers, and the status registers FPCR/FPSR
44 */
45void fpu_state_set(fpu_reg_state_t *vec,
46 uint8_t regs_val);
47
48/*
49 * This function prints the content of the provided FPU structure
50 */
51void fpu_state_print(fpu_reg_state_t *vec);
52
53#endif /* __ASSEMBLER__ */
54#endif /* FPU_H */