blob: 1a828182e838c55cf4eac3afddb68dd7462166d5 [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
Shruti Gupta38133fa2023-04-19 17:00:38 +010014#ifndef __ASSEMBLER__
15
Shruti Gupta369955a2023-04-19 18:05:56 +010016#include <stdbool.h>
Shruti Gupta38133fa2023-04-19 17:00:38 +010017#include <stdint.h>
18
Arunachalam Ganapathy7e514f62023-08-30 13:27:36 +010019typedef uint8_t fpu_q_reg_t[FPU_Q_SIZE] __aligned(16);
20typedef struct fpu_cs_regs {
Shruti Gupta38133fa2023-04-19 17:00:38 +010021 unsigned long fpcr;
Arunachalam Ganapathy7e514f62023-08-30 13:27:36 +010022 unsigned long fpsr;
23} fpu_cs_regs_t __aligned(16);
Shruti Gupta38133fa2023-04-19 17:00:38 +010024
Arunachalam Ganapathy7e514f62023-08-30 13:27:36 +010025typedef struct fpu_state {
26 fpu_q_reg_t q_regs[FPU_Q_COUNT];
27 fpu_cs_regs_t cs_regs;
28} fpu_state_t __aligned(16);
Shruti Gupta38133fa2023-04-19 17:00:38 +010029
Arunachalam Ganapathy7e514f62023-08-30 13:27:36 +010030void fpu_cs_regs_write(const fpu_cs_regs_t *cs_regs);
31void fpu_cs_regs_write_rand(fpu_cs_regs_t *cs_regs);
32void fpu_cs_regs_read(fpu_cs_regs_t *cs_regs);
33int fpu_cs_regs_compare(const fpu_cs_regs_t *s1, const fpu_cs_regs_t *s2);
Shruti Gupta38133fa2023-04-19 17:00:38 +010034
Arunachalam Ganapathy7e514f62023-08-30 13:27:36 +010035void fpu_q_regs_write_rand(fpu_q_reg_t q_regs[FPU_Q_COUNT]);
36void fpu_q_regs_read(fpu_q_reg_t q_regs[FPU_Q_COUNT]);
37int fpu_q_regs_compare(const fpu_q_reg_t s1[FPU_Q_COUNT],
38 const fpu_q_reg_t s2[FPU_Q_COUNT]);
Shruti Gupta38133fa2023-04-19 17:00:38 +010039
Arunachalam Ganapathy7e514f62023-08-30 13:27:36 +010040void fpu_state_write_rand(fpu_state_t *fpu_state);
41void fpu_state_read(fpu_state_t *fpu_state);
42int fpu_state_compare(const fpu_state_t *s1, const fpu_state_t *s2);
Shruti Gupta38133fa2023-04-19 17:00:38 +010043
44#endif /* __ASSEMBLER__ */
45#endif /* FPU_H */