Commit | Line | Data |
---|---|---|
53631b54 CM |
1 | /* |
2 | * Copyright (C) 2012 ARM Ltd. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | */ | |
16 | #ifndef __ASM_FP_H | |
17 | #define __ASM_FP_H | |
18 | ||
19 | #include <asm/ptrace.h> | |
2d2123bc | 20 | #include <asm/errno.h> |
53631b54 CM |
21 | |
22 | #ifndef __ASSEMBLY__ | |
23 | ||
7582e220 | 24 | #include <linux/cache.h> |
b4f9b390 | 25 | #include <linux/init.h> |
bc0ee476 DM |
26 | #include <linux/stddef.h> |
27 | ||
53631b54 CM |
28 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) |
29 | /* Masks for extracting the FPSR and FPCR from the FPSCR */ | |
30 | #define VFP_FPSCR_STAT_MASK 0xf800009f | |
31 | #define VFP_FPSCR_CTRL_MASK 0x07f79f00 | |
32 | /* | |
33 | * The VFP state has 32x64-bit registers and a single 32-bit | |
34 | * control/status register. | |
35 | */ | |
36 | #define VFP_STATE_SIZE ((32 * 8) + 4) | |
37 | #endif | |
38 | ||
39 | struct task_struct; | |
40 | ||
20b85472 DM |
41 | extern void fpsimd_save_state(struct user_fpsimd_state *state); |
42 | extern void fpsimd_load_state(struct user_fpsimd_state *state); | |
53631b54 | 43 | |
e6b673b7 DM |
44 | extern void fpsimd_save(void); |
45 | ||
53631b54 CM |
46 | extern void fpsimd_thread_switch(struct task_struct *next); |
47 | extern void fpsimd_flush_thread(void); | |
48 | ||
8cd969d2 | 49 | extern void fpsimd_signal_preserve_current_state(void); |
c51f9269 | 50 | extern void fpsimd_preserve_current_state(void); |
005f78cd | 51 | extern void fpsimd_restore_current_state(void); |
0abdeff5 | 52 | extern void fpsimd_update_current_state(struct user_fpsimd_state const *state); |
c51f9269 | 53 | |
e6b673b7 DM |
54 | extern void fpsimd_bind_task_to_cpu(void); |
55 | extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state); | |
56 | ||
005f78cd | 57 | extern void fpsimd_flush_task_state(struct task_struct *target); |
e6b673b7 | 58 | extern void fpsimd_flush_cpu_state(void); |
17eed27b | 59 | extern void sve_flush_cpu_state(void); |
005f78cd | 60 | |
7582e220 DM |
61 | /* Maximum VL that SVE VL-agnostic software can transparently support */ |
62 | #define SVE_VL_ARCH_MAX 0x100 | |
63 | ||
1fc5dce7 DM |
64 | extern void sve_save_state(void *state, u32 *pfpsr); |
65 | extern void sve_load_state(void const *state, u32 const *pfpsr, | |
66 | unsigned long vq_minus_1); | |
67 | extern unsigned int sve_get_vl(void); | |
c0cda3b8 DM |
68 | |
69 | struct arm64_cpu_capabilities; | |
70 | extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused); | |
1fc5dce7 | 71 | |
7582e220 DM |
72 | extern int __ro_after_init sve_max_vl; |
73 | ||
bc0ee476 DM |
74 | #ifdef CONFIG_ARM64_SVE |
75 | ||
76 | extern size_t sve_state_size(struct task_struct const *task); | |
77 | ||
78 | extern void sve_alloc(struct task_struct *task); | |
79 | extern void fpsimd_release_task(struct task_struct *task); | |
43d4da2c DM |
80 | extern void fpsimd_sync_to_sve(struct task_struct *task); |
81 | extern void sve_sync_to_fpsimd(struct task_struct *task); | |
82 | extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task); | |
83 | ||
7582e220 DM |
84 | extern int sve_set_vector_length(struct task_struct *task, |
85 | unsigned long vl, unsigned long flags); | |
bc0ee476 | 86 | |
2d2123bc DM |
87 | extern int sve_set_current_vl(unsigned long arg); |
88 | extern int sve_get_current_vl(void); | |
89 | ||
2e0f2478 DM |
90 | /* |
91 | * Probing and setup functions. | |
92 | * Calls to these functions must be serialised with one another. | |
93 | */ | |
94 | extern void __init sve_init_vq_map(void); | |
95 | extern void sve_update_vq_map(void); | |
96 | extern int sve_verify_vq_map(void); | |
97 | extern void __init sve_setup(void); | |
98 | ||
bc0ee476 DM |
99 | #else /* ! CONFIG_ARM64_SVE */ |
100 | ||
101 | static inline void sve_alloc(struct task_struct *task) { } | |
102 | static inline void fpsimd_release_task(struct task_struct *task) { } | |
43d4da2c DM |
103 | static inline void sve_sync_to_fpsimd(struct task_struct *task) { } |
104 | static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { } | |
105 | ||
2d2123bc DM |
106 | static inline int sve_set_current_vl(unsigned long arg) |
107 | { | |
108 | return -EINVAL; | |
109 | } | |
110 | ||
111 | static inline int sve_get_current_vl(void) | |
112 | { | |
113 | return -EINVAL; | |
114 | } | |
115 | ||
2e0f2478 DM |
116 | static inline void sve_init_vq_map(void) { } |
117 | static inline void sve_update_vq_map(void) { } | |
118 | static inline int sve_verify_vq_map(void) { return 0; } | |
119 | static inline void sve_setup(void) { } | |
bc0ee476 DM |
120 | |
121 | #endif /* ! CONFIG_ARM64_SVE */ | |
122 | ||
4328825d DM |
123 | /* For use by EFI runtime services calls only */ |
124 | extern void __efi_fpsimd_begin(void); | |
125 | extern void __efi_fpsimd_end(void); | |
126 | ||
53631b54 CM |
127 | #endif |
128 | ||
129 | #endif |