blob: c80308183369b3bcaabfa50322901a04a8a2efa6 [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
21#include <stdint.h>
22
23typedef struct fpu_reg_state {
24 uint8_t q[FPU_Q_COUNT][FPU_Q_SIZE];
25 unsigned long fpsr;
26 unsigned long fpcr;
27} fpu_reg_state_t;
28
29/*
30 * Read and compare FPU state registers with provided template values in parameters.
31 */
32bool fpu_state_compare_template(fpu_reg_state_t *fpu);
33
34/*
35 * Fill the template with random values and copy it to
36 * FPU state registers(SIMD vectors, FPCR, FPSR).
37 */
38void fpu_state_fill_regs_and_template(fpu_reg_state_t *fpu);
39
40/*
41 * This function populates the provided FPU structure with the provided template
42 * regs_val for all the 32 FPU/SMID registers, and the status registers FPCR/FPSR
43 */
44void fpu_state_set(fpu_reg_state_t *vec,
45 uint8_t regs_val);
46
47/*
48 * This function prints the content of the provided FPU structure
49 */
50void fpu_state_print(fpu_reg_state_t *vec);
51
52#endif /* __ASSEMBLER__ */
53#endif /* FPU_H */