Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
float_context.h
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2011-2014 Wind River Systems, Inc.
8 *
9 * SPDX-License-Identifier: Apache-2.0
10 */
11
12#ifndef _FLOATCONTEXT_H
13#define _FLOATCONTEXT_H
14
15/*
16 * Each architecture must define the following structures (which may be empty):
17 * 'struct fp_volatile_register_set'
18 * 'struct fp_non_volatile_register_set'
19 *
20 * Each architecture must also define the following macros:
21 * SIZEOF_FP_VOLATILE_REGISTER_SET
22 * SIZEOF_FP_NON_VOLATILE_REGISTER_SET
23 * Those macros are used as sizeof(<an empty structure>) is compiler specific;
24 * that is, it may evaluate to a non-zero value.
25 *
26 * Each architecture shall also have custom implementations of:
27 * _load_all_float_registers()
28 * _load_then_store_all_float_registers()
29 * _store_all_float_registers()
30 */
31
32#if defined(CONFIG_X86)
33
34#define FP_OPTION 0
35
36/*
37 * In the future, the struct definitions may need to be refined based on the
38 * specific IA-32 processor, but for now only the Pentium4 is supported:
39 *
40 * 8 x 80 bit floating point registers (ST[0] -> ST[7])
41 * 8 x 128 bit XMM registers (XMM[0] -> XMM[7])
42 *
43 * All these registers are considered volatile across a function invocation.
44 */
45
46struct fp_register {
47 unsigned char reg[10];
48};
49
50struct xmm_register {
51 unsigned char reg[16];
52};
53
54struct fp_volatile_register_set {
55 struct xmm_register xmm[8]; /* XMM[0] -> XMM[7] */
56 struct fp_register st[8]; /* ST[0] -> ST[7] */
57};
58
59struct fp_non_volatile_register_set {
60 /* No non-volatile floating point registers */
61};
62
63#define SIZEOF_FP_VOLATILE_REGISTER_SET sizeof(struct fp_volatile_register_set)
64#define SIZEOF_FP_NON_VOLATILE_REGISTER_SET 0
65
66#elif defined(CONFIG_ARMV7_M_ARMV8_M_FP)
67
68#define FP_OPTION 0
69
70/*
71 * Registers s0..s15 are volatile and do not
72 * need to be preserved across function calls.
73 */
74struct fp_volatile_register_set {
75 float s[16];
76};
77
78/*
79 * Registers s16..s31 are non-volatile and
80 * need to be preserved across function calls.
81 */
82struct fp_non_volatile_register_set {
83 float s[16];
84};
85
86#define SIZEOF_FP_VOLATILE_REGISTER_SET \
87 sizeof(struct fp_volatile_register_set)
88#define SIZEOF_FP_NON_VOLATILE_REGISTER_SET \
89 sizeof(struct fp_non_volatile_register_set)
90
91#elif defined(CONFIG_ARM64)
92
93struct fp_volatile_register_set {
94 __int128 regs[16]; /* q0..q15 */
95};
96
97struct fp_non_volatile_register_set {
98 __int128 regs[16]; /* q16..q31 */
99};
100
101#define SIZEOF_FP_VOLATILE_REGISTER_SET \
102 sizeof(struct fp_volatile_register_set)
103#define SIZEOF_FP_NON_VOLATILE_REGISTER_SET \
104 sizeof(struct fp_non_volatile_register_set)
105
106#elif defined(CONFIG_ISA_ARCV2)
107
108struct fp_volatile_register_set {
109#ifdef CONFIG_FP_FPU_DA
110 uint32_t dpfp2h;
111 uint32_t dpfp2l;
112 uint32_t dpfp1h;
113 uint32_t dpfp1l;
114#endif
115};
116
117struct fp_non_volatile_register_set {
118 /* No non-volatile floating point registers */
119};
120
121#define SIZEOF_FP_VOLATILE_REGISTER_SET sizeof(struct fp_volatile_register_set)
122#define SIZEOF_FP_NON_VOLATILE_REGISTER_SET 0
123
124#elif defined(CONFIG_RISCV)
125
126struct fp_volatile_register_set {
127#ifdef CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION
128 uint64_t fp[32];
129#else
130 uint32_t fp[32];
131#endif
132};
133
134struct fp_non_volatile_register_set {
135 /* No non-volatile floating point registers */
136};
137
138#define SIZEOF_FP_VOLATILE_REGISTER_SET sizeof(struct fp_volatile_register_set)
139#define SIZEOF_FP_NON_VOLATILE_REGISTER_SET 0
140
141#elif defined(CONFIG_SPARC)
142
143struct fp_volatile_register_set {
144 double d[16];
145};
146
147struct fp_non_volatile_register_set {
148};
149
150#define SIZEOF_FP_VOLATILE_REGISTER_SET sizeof(struct fp_volatile_register_set)
151#define SIZEOF_FP_NON_VOLATILE_REGISTER_SET 0
152
153#else
154
155#error "Architecture must provide the following definitions:\n"
156"\t'struct fp_volatile_registers'\n"
157"\t'struct fp_non_volatile_registers'\n"
158"\t'SIZEOF_FP_VOLATILE_REGISTER_SET'\n"
159"\t'SIZEOF_FP_NON_VOLATILE_REGISTER_SET'\n"
160#endif /* CONFIG_X86 */
161
162/* the set of ALL floating point registers */
163
164struct fp_register_set {
165 struct fp_volatile_register_set fp_volatile;
166 struct fp_non_volatile_register_set fp_non_volatile;
167};
168
169#define SIZEOF_FP_REGISTER_SET \
170 (SIZEOF_FP_VOLATILE_REGISTER_SET + SIZEOF_FP_NON_VOLATILE_REGISTER_SET)
171
172/*
173 * The following constants define the initial byte value used by the background
174 * task, and the thread when loading up the floating point registers.
175 */
176
177#define MAIN_FLOAT_REG_CHECK_BYTE ((unsigned char)0xe5)
178#define FIBER_FLOAT_REG_CHECK_BYTE ((unsigned char)0xf9)
179
180#endif /* _FLOATCONTEXT_H */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa s
Definition: asm-macro-32-bit-gnu.h:17
irp nz macro MOVR cc d
Definition: asm-macro-32-bit-gnu.h:11
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
Definition: float_context.h:164
struct fp_non_volatile_register_set fp_non_volatile
Definition: float_context.h:166
struct fp_volatile_register_set fp_volatile
Definition: float_context.h:165