2 /*--------------------------------------------------------------------*/
3 /*--- x86/FreeBSD-specific kernel interface. vki-x86-freebsd.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2005 Julian Seward
12 Copyright (C) 2009 Stanislav Sedov
14 Copyright (C) 2018-2021 Paul Floyd
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License as
19 published by the Free Software Foundation; either version 2 of the
20 License, or (at your option) any later version.
22 This program is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, see <http://www.gnu.org/licenses/>.
30 The GNU General Public License is contained in the file COPYING.
33 #ifndef VKI_X86_FREEBSD_H
34 #define VKI_X86_FREEBSD_H
36 //----------------------------------------------------------------------
38 //----------------------------------------------------------------------
40 /* PAGE_SHIFT determines the page size */
41 #define VKI_PAGE_SHIFT 12
42 #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
43 #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
44 #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
46 //----------------------------------------------------------------------
47 // From sys/i386/include/_limits.h and sys/sys/_sigset.h
48 //----------------------------------------------------------------------
50 #define VKI_MINSIGSTKSZ (512 * 4)
53 #define _VKI_NSIG_WORDS 4
54 #define _VKI_NSIG_BPW ((_VKI_NSIG) / (_VKI_NSIG_WORDS))
57 vki_uint32_t sig
[_VKI_NSIG_WORDS
];
61 //----------------------------------------------------------------------
62 // From sys/i386/include/npx.h
63 //----------------------------------------------------------------------
70 unsigned short en_fcs
;
71 unsigned short en_opcode
;
77 unsigned char fp_bytes
[10];
81 struct _vki_env87 sv_env
;
82 struct _vki_fpacc87 sv_ac
[8];
83 unsigned char sv_pad0
[4];
84 unsigned char sv_pad
[64];
88 unsigned char xmm_bytes
[16];
95 unsigned short en_opcode
;
97 unsigned short en_fcs
;
98 unsigned short en_pad0
;
100 unsigned short en_fos
;
101 unsigned short en_pad1
;
102 unsigned int en_mxcsr
;
103 unsigned int en_mxcsr_mask
;
106 struct _vki_savexmm
{
107 struct _vki_envxmm sv_env
;
109 struct _vki_fpacc87 fp_acc
;
110 unsigned char fp_pad
[6];
112 struct _vki_xmmacc sv_xmm
[8];
113 unsigned char sv_pad
[224];
116 struct _vki_fpstate
{
118 struct _vki_save87 sv_87
;
119 struct _vki_savexmm sv_xmm
;
123 struct vki_sigcontext
{
124 vki_sigset_t sc_mask
;
149 struct _vki_fpstate fpstate
__attribute__((aligned(16)));
155 struct vki_user_regs_struct
{
178 unsigned long fpr_env
[7];
179 unsigned char fpr_acc
[8][10];
180 unsigned long fpr_ex_sw
;
181 unsigned char fpr_pad
[64];
188 typedef unsigned int vki_elf_greg_t
;
189 typedef struct _vki_fpstate vki_elf_fpregset_t
;
190 typedef struct _vki_fpstate vki_elf_fpxregset_t
;
192 #define VKI_AT_SYSINFO 32
193 #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
194 typedef vki_elf_greg_t vki_elf_gregset_t
[VKI_ELF_NGREG
];
196 #define VKI_FPFMT_NODEV 0x10000
197 #define VKI_FPFMT_387 0x10001
198 #define VKI_FPFMT_XMM 0x10002
200 #define VKI_FPOWNED_NONE 0x20000
201 #define VKI_FPOWNED_FPU 0x20001
202 #define VKI_FPOWNED_PCB 0x20002
204 struct vki_mcontext
{
230 struct _vki_fpstate fpstate
__attribute__((aligned(16)));
238 struct vki_sigaction_base
{
239 void (*ksa_handler
)(int);
241 vki_sigset_t sa_mask
; /* mask last for extensibility */
243 typedef struct vki_sigaction_base vki_sigaction_toK_t
;
244 typedef struct vki_sigaction_base vki_sigaction_fromK_t
;
246 //----------------------------------------------------------------------
248 //----------------------------------------------------------------------
249 #define VKI_VDSO_TIMEHANDS_MD \
250 vki_uint32_t th_x86_shift; \
251 vki_uint32_t th_x86_hpet_idx; \
252 vki_uint32_t th_res[6];
254 struct vki_bintime32
{
255 #if defined(__amd64__)
260 vki_uint32_t frac
[2];
263 struct vki_vdso_timehands
{
264 vki_uint32_t th_algo
;
266 vki_uint32_t th_scale
[2];
267 vki_uint32_t th_offset_count
;
268 vki_uint32_t th_counter_mask
;
269 struct vki_bintime32 th_offset
;
270 struct vki_bintime32 th_boottime
;
271 VKI_VDSO_TIMEHANDS_MD
276 #endif // VKI_X86_FREEBSD_H
278 /*--------------------------------------------------------------------*/
280 /*--------------------------------------------------------------------*/