authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-08 15:42:05+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-08 15:42:05+01:00
log7f36c4c7d3c8f3bfabb49a922a6156e4f1c61f67
tree783c358e06ea2fdcab5e4659aff2a70c8c4ea1b8
parentc2aeef04e564213d8ea57007a11451bf825ae883
parent81c52fd62188a43591f0df52c0a121999b497a28

Merge pull request 'add FreeBSD 15 libc support' (#30135) from alexrp/zig:freebsd-15 into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30135

1116 files changed, 30069 insertions(+), 22531 deletions(-)

lib/libc/freebsd/COPYRIGHT+1-2
......@@ -1,9 +1,8 @@
1# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
21
32The compilation of software known as FreeBSD is distributed under the
43following terms:
54
6Copyright (c) 1992-2023 The FreeBSD Project.
5Copyright (c) 1992-2025 The FreeBSD Project.
76
87Redistribution and use in source and binary forms, with or without
98modification, are permitted provided that the following conditions
lib/libc/freebsd/abilists
Binary files a/lib/libc/freebsd/abilists and b/lib/libc/freebsd/abilists differ
lib/libc/freebsd/lib/csu/amd64/crt1_s.S+6-9
......@@ -49,15 +49,12 @@ _start:
4949#ifdef GCRT
5050 subq $16, %rsp
5151#endif
52 movq %rsi, %rcx
53 movq %rdi, %rsi /* argv = ap */
54 addq $8, %rsi /* argv += 1 */
55 movq %rdi, %rdx /* env = ap */
56 addq $16, %rdx /* env += 2 */
57 movslq (%rdi), %rax
58 movl %eax, %edi /* argc = *(long *)(void *)ap */
59 shlq $3, %rax
60 addq %rax, %rdx /* env += argc */
52 movq %rsi, %rcx /* cleanup */
53 movslq (%rdi), %rax /* long *ap; tmpargc = *ap */
54 leaq 0x8(%rdi), %rsi /* argv = ap + 1 */
55 leaq 0x10(%rdi, %rax, 8), %rdx /* env = ap + 2 + tmpargc */
56 movl %eax, %edi /* argc = tmpargc */
57
6158#ifdef PIC
6259 /*
6360 * XXX. %rip relative addressing is not intended for use in the
lib/libc/freebsd/lib/csu/arm/crt1_c.c-1
......@@ -41,7 +41,6 @@
4141 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4242 */
4343
44#include <sys/cdefs.h>
4544#include <sys/param.h>
4645#include <sys/elf_common.h>
4746
lib/libc/freebsd/lib/csu/common/crtbegin.c+2-43
......@@ -21,7 +21,6 @@
2121 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2222 */
2323
24#include <sys/cdefs.h>
2524#include <sys/param.h>
2625
2726#include "crt.h"
......@@ -41,9 +40,8 @@ void __cxa_finalize(void *) __weak_symbol;
4140 * When we have ctors/dtors call from the dtor handler before calling
4241 * any dtors, otherwise use a destructor.
4342 */
44#ifndef HAVE_CTORS
43/* zig patch: no HAVE_CTORS */
4544__attribute__((destructor))
46#endif
4745static void
4846run_cxa_finalize(void)
4947{
......@@ -53,43 +51,4 @@ run_cxa_finalize(void)
5351}
5452#endif
5553
56/*
57 * On some architectures and toolchains we may need to call the .dtors.
58 * These are called in the order they are in the ELF file.
59 */
60#ifdef HAVE_CTORS
61static void __do_global_dtors_aux(void) __used;
62
63static crt_func __CTOR_LIST__[] __section(".ctors") __used = {
64 (crt_func)-1
65};
66static crt_func __DTOR_LIST__[] __section(".dtors") __used = {
67 (crt_func)-1
68};
69
70static void
71__do_global_dtors_aux(void)
72{
73 crt_func fn;
74 int n;
75
76#ifdef SHARED
77 run_cxa_finalize();
78#endif
79
80 for (n = 1;; n++) {
81 fn = __DTOR_LIST__[n];
82 if (fn == (crt_func)0 || fn == (crt_func)-1)
83 break;
84 fn();
85 }
86}
87
88asm (
89 ".pushsection .fini \n"
90 "\t" INIT_CALL_SEQ(__do_global_dtors_aux) "\n"
91 ".popsection \n"
92);
93#endif
94
95/* zig patch: remove gcj nonsense */
54/* zig patch: no HAVE_CTORS */
lib/libc/freebsd/lib/csu/common/crtbrand.S+1-1
......@@ -36,7 +36,7 @@
3636 * for more information.
3737 */
3838
39 .section .note.tag,"aG",%note,.freebsd.noteG,comdat
39 .section .note.tag,"aGR",%note,.freebsd.noteG,comdat
4040 .p2align 2
4141 .4byte 2f-1f
4242 .4byte 4f-3f
lib/libc/freebsd/lib/csu/common/crtend.c deleted-65
......@@ -1,65 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-1-Clause
3 *
4 * Copyright 2018 Andrew Turner
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 */
23
24#include <sys/cdefs.h>
25#include "crt.h"
26
27typedef void (*crt_func)(void);
28
29/* zig patch: remove gcj nonsense */
30
31#ifdef HAVE_CTORS
32
33/*
34 * On some architectures and toolchains we may need to call the .ctors.
35 * These are called in the reverse order they are in the ELF file.
36 */
37static void __do_global_ctors_aux(void) __used;
38
39static crt_func __CTOR_END__[] __section(".ctors") __used = {
40 (crt_func)0
41};
42static crt_func __DTOR_END__[] __section(".dtors") __used = {
43 (crt_func)0
44};
45
46static void
47__do_global_ctors_aux(void)
48{
49 crt_func fn;
50 int n;
51
52 for (n = 1;; n++) {
53 fn = __CTOR_END__[-n];
54 if (fn == (crt_func)0 || fn == (crt_func)-1)
55 break;
56 fn();
57 }
58}
59
60asm (
61 ".pushsection .init \n"
62 "\t" INIT_CALL_SEQ(__do_global_ctors_aux) "\n"
63 ".popsection \n"
64);
65#endif
lib/libc/freebsd/lib/csu/common/feature_note.S+1-1
......@@ -29,7 +29,7 @@
2929#include <sys/elf_common.h>
3030#include "notes.h"
3131
32 .section .note.tag,"a",%note
32 .section .note.tag,"aR",%note
3333 .p2align 2
3434 .4byte 2f-1f
3535 .4byte 4f-3f
lib/libc/freebsd/lib/csu/common/ignore_init_note.S+1-1
......@@ -30,7 +30,7 @@
3030
3131#include "notes.h"
3232
33 .section .note.tag,"a",%note
33 .section .note.tag,"aR",%note
3434 .p2align 2
3535 .4byte 2f-1f
3636 .4byte 4f-3f
lib/libc/freebsd/lib/csu/powerpc/crt.h+1-2
......@@ -24,8 +24,7 @@
2424#ifndef _CRT_H_
2525#define _CRT_H_
2626
27/* zig patch: no HAVE_CTORS */
28#define CTORS_CONSTRUCTORS
27/* zig patch: no HAVE_CTORS/CTORS_CONSTRUCTORS */
2928#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
3029
3130#endif
lib/libc/freebsd/lib/csu/powerpc64/crt.h+1-2
......@@ -24,8 +24,7 @@
2424#ifndef _CRT_H_
2525#define _CRT_H_
2626
27/* zig patch: no HAVE_CTORS */
28#define CTORS_CONSTRUCTORS
27/* zig patch: no HAVE_CTORS/CTORS_CONSTRUCTORS */
2928#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
3029
3130#endif
lib/libc/freebsd/lib/libc/include/libc_private.h+22-86
......@@ -37,6 +37,8 @@
3737#include <sys/_types.h>
3838#include <sys/_pthreadtypes.h>
3939
40#include <libsys.h>
41
4042extern char **environ;
4143
4244/*
......@@ -185,10 +187,12 @@ typedef enum {
185187 PJT_GETTHREADID_NP,
186188 PJT_ATTR_GET_NP,
187189 PJT_GETNAME_NP,
190 PJT_SUSPEND_ALL_NP,
191 PJT_RESUME_ALL_NP,
188192 PJT_MAX
189193} pjt_index_t;
190194
191typedef int (*pthread_func_t)(void);
195typedef void (*pthread_func_t)(void);
192196typedef pthread_func_t pthread_func_entry_t[2];
193197
194198extern pthread_func_entry_t __thr_jtable[];
......@@ -197,9 +201,10 @@ void __set_error_selector(int *(*arg)(void));
197201int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
198202 void *(calloc_cb)(__size_t, __size_t));
199203
200typedef int (*interpos_func_t)(void);
204typedef void (*interpos_func_t)(void);
201205interpos_func_t *__libc_interposing_slot(int interposno);
202206extern interpos_func_t __libc_interposing[] __hidden;
207interpos_func_t *__libsys_interposing_slot(int interposno);
203208
204209enum {
205210 INTERPOS_accept,
......@@ -244,11 +249,18 @@ enum {
244249 INTERPOS_map_stacks_exec,
245250 INTERPOS_fdatasync,
246251 INTERPOS_clock_nanosleep,
247 INTERPOS_distribute_static_tls,
252 INTERPOS__reserved0, /* was distribute_static_tls */
248253 INTERPOS_pdfork,
254 INTERPOS_uexterr_gettext,
249255 INTERPOS_MAX
250256};
251257
258#define _INTERPOS_SYS(type, idx, ...) \
259 ((type *)*(__libc_interposing_slot(idx)))(__VA_ARGS__)
260#define INTERPOS_SYS(syscall, ...) \
261 _INTERPOS_SYS(__sys_## syscall ##_t, INTERPOS_## syscall \
262 __VA_OPT__(,) __VA_ARGS__)
263
252264/*
253265 * yplib internal interfaces
254266 */
......@@ -333,102 +345,22 @@ struct __siginfo;
333345struct __ucontext;
334346struct __wrusage;
335347enum idtype;
336int __sys_aio_suspend(const struct aiocb * const[], int,
337 const struct timespec *);
338int __sys_accept(int, struct sockaddr *, __socklen_t *);
339int __sys_accept4(int, struct sockaddr *, __socklen_t *, int);
340int __sys_clock_gettime(__clockid_t, struct timespec *ts);
341int __sys_clock_nanosleep(__clockid_t, int,
342 const struct timespec *, struct timespec *);
343int __sys_close(int);
344int __sys_close_range(unsigned, unsigned, int);
345int __sys_connect(int, const struct sockaddr *, __socklen_t);
346int __sys_fcntl(int, int, ...);
347int __sys_fdatasync(int);
348int __sys_fstat(int fd, struct stat *);
349int __sys_fstatfs(int fd, struct statfs *);
350int __sys_fstatat(int, const char *, struct stat *, int);
351int __sys_fsync(int);
352__pid_t __sys_fork(void);
353int __sys_ftruncate(int, __off_t);
354__ssize_t __sys_getdirentries(int, char *, __size_t, __off_t *);
355int __sys_getfsstat(struct statfs *, long, int);
356int __sys_gettimeofday(struct timeval *, struct timezone *);
357int __sys_kevent(int, const struct kevent *, int, struct kevent *,
358 int, const struct timespec *);
359__off_t __sys_lseek(int, __off_t, int);
360void *__sys_mmap(void *, __size_t, int, int, int, __off_t);
361int __sys_msync(void *, __size_t, int);
362int __sys_nanosleep(const struct timespec *, struct timespec *);
363int __sys_open(const char *, int, ...);
364int __sys_openat(int, const char *, int, ...);
365int __sys_pdfork(int *, int);
366int __sys_pselect(int, struct fd_set *, struct fd_set *,
367 struct fd_set *, const struct timespec *,
368 const __sigset_t *);
369int __sys_ptrace(int, __pid_t, char *, int);
370int __sys_poll(struct pollfd *, unsigned, int);
371int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *,
372 const __sigset_t *);
373__ssize_t __sys_pread(int, void *, __size_t, __off_t);
374__ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
375__ssize_t __sys_read(int, void *, __size_t);
376__ssize_t __sys_readv(int, const struct iovec *, int);
377__ssize_t __sys_recv(int, void *, __size_t, int);
378__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
379 __socklen_t *);
380__ssize_t __sys_recvmsg(int, struct msghdr *, int);
381int __sys_sched_getcpu(void);
382int __sys_select(int, struct fd_set *, struct fd_set *,
383 struct fd_set *, struct timeval *);
384__ssize_t __sys_sendmsg(int, const struct msghdr *, int);
385__ssize_t __sys_sendto(int, const void *, __size_t, int,
386 const struct sockaddr *, __socklen_t);
387int __sys_setcontext(const struct __ucontext *);
388int __sys_sigaction(int, const struct sigaction *,
389 struct sigaction *);
390int __sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
391int __sys_sigsuspend(const __sigset_t *);
392int __sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
393 const struct timespec *);
394int __sys_sigwait(const __sigset_t *, int *);
395int __sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
396int __sys___specialfd(int, const void *, __size_t);
397int __sys_statfs(const char *, struct statfs *);
398int __sys_swapcontext(struct __ucontext *,
399 const struct __ucontext *);
400int __sys_thr_kill(long, int);
401int __sys_thr_self(long *);
402int __sys_truncate(const char *, __off_t);
403__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *);
404__pid_t __sys_wait6(enum idtype, __id_t, int *, int,
405 struct __wrusage *, struct __siginfo *);
406__ssize_t __sys_write(int, const void *, __size_t);
407__ssize_t __sys_writev(int, const struct iovec *, int);
408int __sys_shm_open2(const char *, int, __mode_t, int, const char *);
409348
349int __libc_execvpe(const char *, char * const *, char * const *);
410350int __libc_sigaction(int, const struct sigaction *,
411351 struct sigaction *) __hidden;
412352int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)
413353 __hidden;
414354int __libc_sigsuspend(const __sigset_t *) __hidden;
415int __libc_sigwait(const __sigset_t * __restrict,
416 int * restrict sig);
355int __libsys_sigwait(const __sigset_t *, int *) __hidden;
417356int __libc_system(const char *);
418357int __libc_tcdrain(int);
419int __fcntl_compat(int fd, int cmd, ...);
420
421int __sys_futimens(int fd, const struct timespec *times) __hidden;
422int __sys_utimensat(int fd, const char *path,
423 const struct timespec *times, int flag) __hidden;
424358
425359int _elf_aux_info(int aux, void *buf, int buflen);
426360struct dl_phdr_info;
427361int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
428362void __init_elf_aux_vector(void);
429363void __libc_map_stacks_exec(void);
430void __libc_distribute_static_tls(__size_t, void *, __size_t, __size_t);
431__uintptr_t __libc_static_tls_base(__size_t);
432364
433365void _pthread_cancel_enter(int);
434366void _pthread_cancel_leave(int);
......@@ -444,7 +376,11 @@ struct __nl_cat_d;
444376struct _xlocale;
445377struct __nl_cat_d *__catopen_l(const char *name, int type,
446378 struct _xlocale *locale);
447int __strerror_rl(int errnum, char *strerrbuf, __size_t buflen,
379int __strerror_rl(int errnum, char *strerrbuf, size_t buflen,
448380 struct _xlocale *locale);
449381
382struct uexterror;
383int __uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz);
384int __libc_uexterr_gettext(char *buf, size_t bufsz);
385
450386#endif /* _LIBC_PRIVATE_H_ */
lib/libc/include/aarch64-freebsd-none/arm/_align.h-2
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
4038 */
4139
4240#ifndef _ARM_INCLUDE__ALIGN_H_
lib/libc/include/aarch64-freebsd-none/arm/_limits.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _MACHINE__LIMITS_H_
lib/libc/include/aarch64-freebsd-none/arm/_types.h-3
......@@ -32,9 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
3835 */
3936
4037#ifndef _MACHINE__TYPES_H_
lib/libc/include/aarch64-freebsd-none/arm/acle-compat.h+3-155
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2014 ARM Ltd
2 * Copyright (c) 2024 Arm Ltd
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
......@@ -27,157 +27,5 @@
2727 */
2828
2929#ifndef __ARM_ARCH
30
31/* ACLE standardises a set of pre-defines that describe the ARM architecture.
32 These were mostly implemented in GCC around GCC-4.8; older versions
33 have no, or only partial support. To provide a level of backwards
34 compatibility we try to work out what the definitions should be, given
35 the older pre-defines that GCC did produce. This isn't complete, but
36 it should be enough for use by routines that depend on this header. */
37
38/* No need to handle ARMv8, GCC had ACLE support before that. */
39
40#define __ARM_ACLE 101
41
42# ifdef __ARM_ARCH_7__
43/* The common subset of ARMv7 in all profiles. */
44# define __ARM_ARCH 7
45# define __ARM_ARCH_ISA_THUMB 2
46# define __ARM_FEATURE_CLZ
47# define __ARM_FEATURE_LDREX 7
48# define __ARM_FEATURE_UNALIGNED
49# endif
50
51# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
52# define __ARM_ARCH 7
53# define __ARM_ARCH_ISA_THUMB 2
54# define __ARM_ARCH_ISA_ARM
55# define __ARM_FEATURE_CLZ
56# define __ARM_FEATURE_SIMD32
57# define __ARM_FEATURE_DSP
58# define __ARM_FEATURE_QBIT
59# define __ARM_FEATURE_SAT
60# define __ARM_FEATURE_LDREX 15
61# define __ARM_FEATURE_UNALIGNED
62# ifdef __ARM_ARCH_7A__
63# define __ARM_ARCH_PROFILE 'A'
64# else
65# define __ARM_ARCH_PROFILE 'R'
66# endif
67# endif
68
69# ifdef __ARM_ARCH_7EM__
70# define __ARM_ARCH 7
71# define __ARM_ARCH_ISA_THUMB 2
72# define __ARM_FEATURE_CLZ
73# define __ARM_FEATURE_SIMD32
74# define __ARM_FEATURE_DSP
75# define __ARM_FEATURE_QBIT
76# define __ARM_FEATURE_SAT
77# define __ARM_FEATURE_LDREX 7
78# define __ARM_FEATURE_UNALIGNED
79# define __ARM_ARCH_PROFILE 'M'
80# endif
81
82# ifdef __ARM_ARCH_7M__
83# define __ARM_ARCH 7
84# define __ARM_ARCH_ISA_THUMB 2
85# define __ARM_FEATURE_CLZ
86# define __ARM_FEATURE_QBIT
87# define __ARM_FEATURE_SAT
88# define __ARM_FEATURE_LDREX 7
89# define __ARM_FEATURE_UNALIGNED
90# define __ARM_ARCH_PROFILE 'M'
91# endif
92
93# ifdef __ARM_ARCH_6T2__
94# define __ARM_ARCH 6
95# define __ARM_ARCH_ISA_THUMB 2
96# define __ARM_ARCH_ISA_ARM
97# define __ARM_FEATURE_CLZ
98# define __ARM_FEATURE_SIMD32
99# define __ARM_FEATURE_DSP
100# define __ARM_FEATURE_QBIT
101# define __ARM_FEATURE_SAT
102# define __ARM_FEATURE_LDREX 4
103# define __ARM_FEATURE_UNALIGNED
104# endif
105
106# ifdef __ARM_ARCH_6M__
107# define __ARM_ARCH 6
108# define __ARM_ARCH_ISA_THUMB 1
109# define __ARM_ARCH_PROFILE 'M'
110# endif
111
112# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
113 || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
114 || defined (__ARM_ARCH_6ZK__)
115# define __ARM_ARCH 6
116# define __ARM_ARCH_ISA_THUMB 1
117# define __ARM_ARCH_ISA_ARM
118# define __ARM_FEATURE_CLZ
119# define __ARM_FEATURE_SIMD32
120# define __ARM_FEATURE_DSP
121# define __ARM_FEATURE_QBIT
122# define __ARM_FEATURE_SAT
123# define __ARM_FEATURE_UNALIGNED
124# ifndef __thumb__
125# if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
126# define __ARM_FEATURE_LDREX 15
127# else
128# define __ARM_FEATURE_LDREX 4
129# endif
130# endif
131# endif
132
133# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
134# define __ARM_ARCH 5
135# define __ARM_ARCH_ISA_ARM
136# ifdef __ARM_ARCH_5TE__
137# define __ARM_ARCH_ISA_THUMB 1
138# endif
139# define __ARM_FEATURE_CLZ
140# define __ARM_FEATURE_DSP
141# endif
142
143# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
144# define __ARM_ARCH 5
145# define __ARM_ARCH_ISA_ARM
146# ifdef __ARM_ARCH_5TE__
147# define __ARM_ARCH_ISA_THUMB 1
148# endif
149# define __ARM_FEATURE_CLZ
150# endif
151
152# ifdef __ARM_ARCH_4T__
153# define __ARM_ARCH 4
154# define __ARM_ARCH_ISA_ARM
155# define __ARM_ARCH_ISA_THUMB 1
156# endif
157
158# ifdef __ARM_ARCH_4__
159# define __ARM_ARCH 4
160# define __ARM_ARCH_ISA_ARM
161# endif
162
163# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
164# define __ARM_ARCH 3
165# define __ARM_ARCH_ISA_ARM
166# endif
167
168# ifdef __ARM_ARCH_2__
169# define __ARM_ARCH 2
170# define __ARM_ARCH_ISA_ARM
171# endif
172
173# ifdef __ARMEB__
174# define __ARM_BIG_ENDIAN
175# endif
176
177/* If we still don't know what the target architecture is, then we're
178 probably not using GCC. */
179# ifndef __ARM_ARCH
180# error Unable to determine architecture version.
181# endif
182
183#endif /* __ARM_ARCH */
\ No newline at end of file
30#error Your compiler is too old
31#endif
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/asm.h-10
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
3735 */
3836
3937#ifndef _MACHINE_ASM_H_
......@@ -176,7 +174,6 @@
176174# define RETne bxne lr
177175# define RETc(c) bx##c lr
178176
179#if __ARM_ARCH >= 7
180177#define ISB isb
181178#define DSB dsb
182179#define DMB dmb
......@@ -190,12 +187,5 @@
190187#define ERET .word 0xe160006e
191188#endif
192189
193#elif __ARM_ARCH == 6
194#include <machine/sysreg.h>
195#define ISB mcr CP15_CP15ISB
196#define DSB mcr CP15_CP15DSB
197#define DMB mcr CP15_CP15DMB
198#define WFI mcr CP15_CP15WFI
199#endif
200190
201191#endif /* !_MACHINE_ASM_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/atomic.h+28-21
......@@ -41,15 +41,9 @@
4141
4242#include <sys/atomic_common.h>
4343
44#if __ARM_ARCH >= 7
4544#define isb() __asm __volatile("isb" : : : "memory")
4645#define dsb() __asm __volatile("dsb" : : : "memory")
4746#define dmb() __asm __volatile("dmb" : : : "memory")
48#else
49#define isb() __asm __volatile("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : "memory")
50#define dsb() __asm __volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory")
51#define dmb() __asm __volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory")
52#endif
5347
5448#define mb() dmb()
5549#define wmb() dmb()
......@@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val)
614608}
615609
616610static __inline uint32_t
617atomic_load_acq_32(volatile uint32_t *p)
611atomic_load_acq_32(const volatile uint32_t *p)
618612{
619613 uint32_t v;
620614
......@@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p)
624618}
625619
626620static __inline uint64_t
627atomic_load_64(volatile uint64_t *p)
621atomic_load_64(const volatile uint64_t *p)
628622{
629623 uint64_t ret;
630624
......@@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p)
643637}
644638
645639static __inline uint64_t
646atomic_load_acq_64(volatile uint64_t *p)
640atomic_load_acq_64(const volatile uint64_t *p)
647641{
648642 uint64_t ret;
649643
......@@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p)
653647}
654648
655649static __inline u_long
656atomic_load_acq_long(volatile u_long *p)
650atomic_load_acq_long(const volatile u_long *p)
657651{
658652 u_long v;
659653
......@@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v)
898892
899893 return (atomic_testandclear_32((volatile uint32_t *)p, v));
900894}
901#define atomic_testandclear_long atomic_testandclear_long
902
903895
904896static __inline int
905897atomic_testandclear_64(volatile uint64_t *p, u_int v)
......@@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v)
958950
959951 return (atomic_testandset_32((volatile uint32_t *)p, v));
960952}
961#define atomic_testandset_long atomic_testandset_long
953
954static __inline int
955atomic_testandset_acq_long(volatile u_long *p, u_int v)
956{
957 int ret;
958
959 ret = atomic_testandset_32((volatile uint32_t *)p, v);
960 dmb();
961 return (ret);
962}
962963
963964static __inline int
964965atomic_testandset_64(volatile uint64_t *p, u_int v)
......@@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void)
10521053 dmb();
10531054}
10541055
1056#define atomic_add_ptr atomic_add_32
1057#define atomic_add_acq_ptr atomic_add_acq_32
1058#define atomic_add_rel_ptr atomic_add_rel_32
1059#define atomic_subtract_ptr atomic_subtract_32
1060#define atomic_subtract_acq_ptr atomic_subtract_acq_32
1061#define atomic_subtract_rel_ptr atomic_subtract_rel_32
10551062#define atomic_clear_ptr atomic_clear_32
10561063#define atomic_clear_acq_ptr atomic_clear_acq_32
10571064#define atomic_clear_rel_ptr atomic_clear_rel_32
......@@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void)
10591066#define atomic_set_acq_ptr atomic_set_acq_32
10601067#define atomic_set_rel_ptr atomic_set_rel_32
10611068#define atomic_fcmpset_ptr atomic_fcmpset_32
1062#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
10631069#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32
1070#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
10641071#define atomic_cmpset_ptr atomic_cmpset_32
10651072#define atomic_cmpset_acq_ptr atomic_cmpset_acq_32
10661073#define atomic_cmpset_rel_ptr atomic_cmpset_rel_32
1074#define atomic_fetchadd_ptr atomic_fetchadd_32
1075#define atomic_readandclear_ptr atomic_readandclear_32
10671076#define atomic_load_acq_ptr atomic_load_acq_32
10681077#define atomic_store_rel_ptr atomic_store_rel_32
10691078#define atomic_swap_ptr atomic_swap_32
1070#define atomic_readandclear_ptr atomic_readandclear_32
1079#define atomic_testandset_ptr atomic_testandset_32
1080#define atomic_testandclear_ptr atomic_testandclear_32
10711081
10721082#define atomic_add_int atomic_add_32
10731083#define atomic_add_acq_int atomic_add_acq_32
......@@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void)
10931103#define atomic_store_rel_int atomic_store_rel_32
10941104#define atomic_swap_int atomic_swap_32
10951105
1096/*
1097 * For:
1098 * - atomic_load_acq_8
1099 * - atomic_load_acq_16
1100 * - atomic_testandset_acq_long
1101 */
11021106#include <sys/_atomic_subword.h>
11031107
1108#define atomic_set_short atomic_set_16
1109#define atomic_clear_short atomic_clear_16
1110
11041111#endif /* _MACHINE_ATOMIC_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/cpu.h+11-45
......@@ -45,13 +45,7 @@ void cpu_halt(void);
4545 * unconditionally with -DSMP. Although it looks like a bug,
4646 * handle this case here and in #elif condition in ARM_SMP_UP macro.
4747 */
48#if __ARM_ARCH <= 6 && defined(SMP) && !defined(KLD_MODULE)
49#error SMP option is not supported on ARMv6
50#endif
5148
52#if __ARM_ARCH <= 6 && defined(SMP_ON_UP)
53#error SMP_ON_UP option is only supported on ARMv7+ CPUs
54#endif
5549
5650#if !defined(SMP) && defined(SMP_ON_UP)
5751#error SMP option must be defined for SMP_ON_UP option
......@@ -68,7 +62,7 @@ do { \
6862 up_code; \
6963 } \
7064} while (0)
71#elif defined(SMP) && __ARM_ARCH > 6
65#elif defined(SMP)
7266#define ARM_SMP_UP(smp_code, up_code) \
7367do { \
7468 smp_code; \
......@@ -146,15 +140,15 @@ fname(uint64_t reg) \
146140/* TLB */
147141
148142_WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */
149#if __ARM_ARCH >= 7 && defined(SMP)
143#if defined(SMP)
150144_WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */
151145#endif
152146_WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */
153#if __ARM_ARCH >= 7 && defined(SMP)
147#if defined(SMP)
154148_WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */
155149#endif
156150_WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */
157#if __ARM_ARCH >= 7 && defined(SMP)
151#if defined(SMP)
158152_WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */
159153#endif
160154_WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */
......@@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0))
164158/* Cache and Branch predictor */
165159
166160_WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */
167#if __ARM_ARCH >= 7 && defined(SMP)
161#if defined(SMP)
168162_WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */
169163#endif
170164_WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */
171165_WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */
172166_WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */
173167_WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */
174#if __ARM_ARCH >= 7
175168_WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */
176#endif
177169_WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */
178170_WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */
179171_WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */
180172_WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */
181#if __ARM_ARCH >= 7 && defined(SMP)
173#if defined(SMP)
182174_WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */
183175#endif
184176_WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */
......@@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0))
209201_WF1(cp15_nmrr_set, CP15_NMRR(%0))
210202_RF0(cp15_ttbr_get, CP15_TTBR0(%0))
211203_RF0(cp15_dfar_get, CP15_DFAR(%0))
212#if __ARM_ARCH >= 7
213204_RF0(cp15_ifar_get, CP15_IFAR(%0))
214205_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))
215#endif
216206_RF0(cp15_actlr_get, CP15_ACTLR(%0))
217207_WF1(cp15_actlr_set, CP15_ACTLR(%0))
218208_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0))
......@@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0))
251241
252242/* Performance Monitor registers */
253243
254#if __ARM_ARCH == 6 && defined(CPU_ARM1176)
255_RF0(cp15_pmuserenr_get, CP15_PMUSERENR(%0))
256_WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))
257_RF0(cp15_pmcr_get, CP15_PMCR(%0))
258_WF1(cp15_pmcr_set, CP15_PMCR(%0))
259_RF0(cp15_pmccntr_get, CP15_PMCCNTR(%0))
260_WF1(cp15_pmccntr_set, CP15_PMCCNTR(%0))
261#elif __ARM_ARCH > 6
262244_RF0(cp15_pmcr_get, CP15_PMCR(%0))
263245_WF1(cp15_pmcr_set, CP15_PMCR(%0))
264246_RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0))
......@@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))
280262_RF0(cp15_pminten_get, CP15_PMINTENSET(%0))
281263_WF1(cp15_pminten_set, CP15_PMINTENSET(%0))
282264_WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0))
283#endif
284265
285266_RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0))
286267_WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0))
......@@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size)
380361}
381362
382363/* Broadcasting operations. */
383#if __ARM_ARCH >= 7 && defined(SMP)
364#if defined(SMP)
384365
385366static __inline void
386367tlb_flush_all(void)
......@@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size)
442423 );
443424 dsb();
444425}
445#else /* __ARM_ARCH < 7 */
426#else /* !SMP */
446427
447428#define tlb_flush_all() tlb_flush_all_local()
448429#define tlb_flush_all_ng() tlb_flush_all_ng_local()
449430#define tlb_flush(va) tlb_flush_local(va)
450431#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)
451432
452#endif /* __ARM_ARCH < 7 */
433#endif /* !SMP */
453434
454435/*
455436 * Cache maintenance operations.
......@@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size)
465446 va &= ~cpuinfo.dcache_line_mask;
466447
467448 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
468#if __ARM_ARCH >= 7
469449 _CP15_DCCMVAU(va);
470#else
471 _CP15_DCCMVAC(va);
472#endif
473450 }
474451 dsb();
475452 ARM_SMP_UP(
......@@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size)
515492 dsb();
516493 va &= ~cpuinfo.dcache_line_mask;
517494 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
518#if __ARM_ARCH >= 7
519495 _CP15_DCCMVAU(va);
520#else
521 _CP15_DCCMVAC(va);
522#endif
523496 }
524497 dsb();
525498}
......@@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr)
686659static __inline uint64_t
687660get_cyclecount(void)
688661{
689#if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176))
690#if (__ARM_ARCH > 6) && defined(DEV_PMU)
662#if defined(DEV_PMU)
691663 if (pmu_attched) {
692664 u_int cpu;
693665 uint64_t h, h2;
......@@ -711,12 +683,6 @@ get_cyclecount(void)
711683 } else
712684#endif
713685 return cp15_pmccntr_get();
714#else /* No performance counters, so use nanotime(9). */
715 struct timespec tv;
716
717 nanotime(&tv);
718 return (tv.tv_sec * (uint64_t)1000000000ull + tv.tv_nsec);
719#endif
720686}
721687#endif
722688
......@@ -729,7 +695,7 @@ get_cyclecount(void)
729695#define cpu_spinwait() /* nothing */
730696#define cpu_lock_delay() DELAY(1)
731697
732#define ARM_NVEC 8
698#define ARM_NVEC 7
733699#define ARM_VEC_ALL 0xffffffff
734700
735701extern vm_offset_t vector_page;
lib/libc/include/aarch64-freebsd-none/arm/cpufunc.h-3
......@@ -97,9 +97,6 @@ void armv7_cpu_sleep (int);
9797void pj4b_config (void);
9898#endif
9999
100#if defined(CPU_ARM1176)
101void arm11x6_sleep (int); /* no ref. for errata */
102#endif
103100
104101
105102/*
lib/libc/include/aarch64-freebsd-none/arm/fenv.h+1
......@@ -29,6 +29,7 @@
2929#ifndef _FENV_H_
3030#define _FENV_H_
3131
32#include <sys/cdefs.h>
3233#include <sys/_types.h>
3334
3435#ifndef __fenv_static
lib/libc/include/aarch64-freebsd-none/arm/float.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3230 */
3331
3432#ifndef _MACHINE_FLOAT_H_
lib/libc/include/aarch64-freebsd-none/arm/ieeefp.h+10
......@@ -49,4 +49,14 @@ typedef enum {
4949
5050#define fp_except_t int
5151
52/* Augment the userland declarations. */
53__BEGIN_DECLS
54extern fp_rnd_t fpgetround(void);
55extern fp_rnd_t fpsetround(fp_rnd_t);
56extern fp_except_t fpgetmask(void);
57extern fp_except_t fpsetmask(fp_except_t);
58extern fp_except_t fpgetsticky(void);
59extern fp_except_t fpsetsticky(fp_except_t);
60__END_DECLS
61
5262#endif /* _MACHINE_IEEEFP_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/param.h+2-15
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
4038 */
4139
4240#ifndef _ARM_INCLUDE_PARAM_H_
......@@ -51,17 +49,11 @@
5149#define STACKALIGNBYTES (8 - 1)
5250#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)
5351
54#define __PCI_REROUTE_INTERRUPT
55
5652#ifndef MACHINE
5753#define MACHINE "arm"
5854#endif
5955#ifndef MACHINE_ARCH
60#if __ARM_ARCH >= 7
6156#define MACHINE_ARCH "armv7"
62#else
63#define MACHINE_ARCH "armv6"
64#endif
6557#endif
6658
6759#ifdef SMP
......@@ -76,6 +68,8 @@
7668#define MAXMEMDOM 1
7769#endif
7870
71#define __HAVE_STATIC_DEVMAP
72
7973#define ALIGNBYTES _ALIGNBYTES
8074#define ALIGN(p) _ALIGN(p)
8175/*
......@@ -129,17 +123,10 @@
129123/*
130124 * Mach derived conversion macros
131125 */
132#define trunc_page(x) ((x) & ~PAGE_MASK)
133#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
134126#define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK)
135127#define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK)
136128
137#define atop(x) ((unsigned)(x) >> PAGE_SHIFT)
138#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT)
139
140129#define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT)
141130#define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT)
142131
143#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
144
145132#endif /* !_ARM_INCLUDE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/pmap.h+3-12
......@@ -39,9 +39,6 @@
3939 * map the page tables using the pagetables themselves. This is done to
4040 * reduce the impact on kernel virtual memory for lots of sparse address
4141 * space, and to reduce the cost of memory to each process.
42 *
43 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
44 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
4542 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30
4643 */
4744
......@@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */
138135 * vtopte2().
139136 */
140137void pmap_bootstrap(vm_offset_t);
141void pmap_kenter(vm_offset_t, vm_paddr_t);
138void pmap_kenter(vm_offset_t, vm_size_t, vm_paddr_t, int);
142139void pmap_kremove(vm_offset_t);
143boolean_t pmap_page_is_mapped(vm_page_t);
140bool pmap_page_is_mapped(vm_page_t);
144141bool pmap_ps_enabled(pmap_t pmap);
145142
146143void pmap_tlb_flush(pmap_t, vm_offset_t);
......@@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
175172#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)
176173
177174void *pmap_mapdev(vm_paddr_t, vm_size_t);
175void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
178176void pmap_unmapdev(void *, vm_size_t);
179177
180static inline void *
181pmap_mapdev_attr(vm_paddr_t addr __unused, vm_size_t size __unused,
182 int attr __unused)
183{
184 panic("%s is not implemented yet!\n", __func__);
185}
186
187178struct pcb;
188179void pmap_set_pcb_pagedir(pmap_t, struct pcb *);
189180
lib/libc/include/aarch64-freebsd-none/arm/proc.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3634 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
3735 */
3836
lib/libc/include/aarch64-freebsd-none/arm/profile.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)profile.h 8.1 (Berkeley) 6/11/93
3634 */
3735
3836#ifndef _MACHINE_PROFILE_H_
lib/libc/include/aarch64-freebsd-none/arm/reloc.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)reloc.h 8.1 (Berkeley) 6/10/93
3634 */
3735
3836#ifndef _MACHINE_RELOC_H_
lib/libc/include/aarch64-freebsd-none/arm/resource.h-2
......@@ -40,8 +40,6 @@
4040#define SYS_RES_MEMORY 3 /* i/o memory */
4141#define SYS_RES_IOPORT 4 /* i/o ports */
4242#define SYS_RES_GPIO 5 /* general purpose i/o */
43#ifdef NEW_PCIB
4443#define PCI_RES_BUS 6 /* PCI bus numbers */
45#endif
4644
4745#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/runq.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RUNQ_H_
30#define _MACHINE_RUNQ_H_
31
32#define RQB_LEN (2) /* Number of priority status words. */
33#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */
34#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */
35
36#define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1)))
37#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
38
39#define RQB_FFS(word) (ffs(word) - 1)
40
41/*
42 * Type of run queue status word.
43 */
44typedef u_int32_t rqb_word_t;
45
46#endif
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/arm/signal.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.1 (Berkeley) 6/11/93
3230 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
3331 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
3432 */
lib/libc/include/aarch64-freebsd-none/arm/sysarch.h+2
......@@ -38,6 +38,8 @@
3838#ifndef _ARM_SYSARCH_H_
3939#define _ARM_SYSARCH_H_
4040
41#include <sys/cdefs.h>
42
4143#include <machine/armreg.h>
4244
4345#ifndef LOCORE
lib/libc/include/aarch64-freebsd-none/arm/sysreg.h+2-36
......@@ -127,11 +127,9 @@
127127
128128/* From ARMv6: */
129129#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */
130#if __ARM_ARCH >= 7
131130/* From ARMv7: */
132131#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */
133132#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */
134#endif
135133
136134/*
137135 * CP15 C6 registers
......@@ -147,7 +145,7 @@
147145/*
148146 * CP15 C7 registers
149147 */
150#if __ARM_ARCH >= 7 && defined(SMP)
148#if defined(SMP)
151149/* From ARMv7: */
152150#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */
153151#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */
......@@ -157,17 +155,9 @@
157155
158156#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */
159157#define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */
160#if __ARM_ARCH == 6
161/* Deprecated in ARMv7 */
162#define CP15_CP15ISB p15, 0, r0, c7, c5, 4 /* ISB */
163#endif
164158#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */
165159#define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */
166160
167#if __ARM_ARCH == 6
168/* Only ARMv6: */
169#define CP15_DCIALL p15, 0, r0, c7, c6, 0 /* Data cache invalidate all */
170#endif
171161#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */
172162#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */
173163
......@@ -176,43 +166,25 @@
176166#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */
177167#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */
178168
179#if __ARM_ARCH >= 7
180169/* From ARMv7: */
181170#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */
182171#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */
183172#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */
184173#define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */
185#endif
186174
187#if __ARM_ARCH == 6
188/* Only ARMv6: */
189#define CP15_DCCALL p15, 0, r0, c7, c10, 0 /* Data cache clean all */
190#endif
191175#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */
192176#define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */
193#if __ARM_ARCH == 6
194/* Only ARMv6: */
195#define CP15_CP15DSB p15, 0, r0, c7, c10, 4 /* DSB */
196#define CP15_CP15DMB p15, 0, r0, c7, c10, 5 /* DMB */
197#define CP15_CP15WFI p15, 0, r0, c7, c0, 4 /* WFI */
198#endif
199177
200#if __ARM_ARCH >= 7
201178/* From ARMv7: */
202179#define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */
203#endif
204180
205#if __ARM_ARCH == 6
206/* Only ARMv6: */
207#define CP15_DCCIALL p15, 0, r0, c7, c14, 0 /* Data cache clean and invalidate all */
208#endif
209181#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */
210182#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */
211183
212184/*
213185 * CP15 C8 registers
214186 */
215#if __ARM_ARCH >= 7 && defined(SMP)
187#if defined(SMP)
216188/* From ARMv7: */
217189#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */
218190#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */
......@@ -232,11 +204,6 @@
232204/*
233205 * CP15 C9 registers
234206 */
235#if __ARM_ARCH == 6 && defined(CPU_ARM1176)
236#define CP15_PMUSERENR(rr) p15, 0, rr, c15, c9, 0 /* Access Validation Control Register */
237#define CP15_PMCR(rr) p15, 0, rr, c15, c12, 0 /* Performance Monitor Control Register */
238#define CP15_PMCCNTR(rr) p15, 0, rr, c15, c12, 1 /* PM Cycle Count Register */
239#else
240207#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */
241208#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */
242209#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */
......@@ -250,7 +217,6 @@
250217#define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */
251218#define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */
252219#define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */
253#endif
254220
255221/*
256222 * CP15 C10 registers
lib/libc/include/aarch64-freebsd-none/arm/vmparam.h+1
......@@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address;
200200 * Need a page dump array for minidump.
201201 */
202202#define MINIDUMP_PAGE_TRACKING 1
203#define MINIDUMP_STARTUP_PAGE_TRACKING 0
203204
204205#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/fenv.h+1
......@@ -31,6 +31,7 @@
3131#ifndef _FENV_H_
3232#define _FENV_H_
3333
34#include <sys/cdefs.h>
3435#include <sys/_types.h>
3536
3637#ifndef __fenv_static
lib/libc/include/aarch64-freebsd-none/float.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3028 */
3129
3230#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/_align.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
3028 */
3129
3230#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/_bus.h deleted-43
......@@ -1,43 +0,0 @@
1/*-
2 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions, and the following disclaimer,
9 * without modification, immediately at the beginning of the file.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
19 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE__BUS_H_
29#define _MACHINE__BUS_H_
30
31/*
32 * Addresses (in bus space).
33 */
34typedef u_long bus_addr_t;
35typedef u_long bus_size_t;
36
37/*
38 * Access methods for bus space.
39 */
40typedef u_long bus_space_handle_t;
41typedef struct bus_space *bus_space_tag_t;
42
43#endif /* !_MACHINE__BUS_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/_limits.h-2
......@@ -22,8 +22,6 @@
2222 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2323 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2424 * SUCH DAMAGE.
25 *
26 * @(#)limits.h 8.3 (Berkeley) 1/4/94
2725 */
2826
2927#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/_types.h-3
......@@ -26,9 +26,6 @@
2626 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2727 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2828 * SUCH DAMAGE.
29 *
30 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
31 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
3229 */
3330
3431#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/armreg.h+477-166
......@@ -36,29 +36,6 @@
3636
3737#define INSN_SIZE 4
3838
39#define MRS_MASK 0xfff00000
40#define MRS_VALUE 0xd5300000
41#define MRS_SPECIAL(insn) ((insn) & 0x000fffe0)
42#define MRS_REGISTER(insn) ((insn) & 0x0000001f)
43#define MRS_Op0_SHIFT 19
44#define MRS_Op0_MASK 0x00080000
45#define MRS_Op1_SHIFT 16
46#define MRS_Op1_MASK 0x00070000
47#define MRS_CRn_SHIFT 12
48#define MRS_CRn_MASK 0x0000f000
49#define MRS_CRm_SHIFT 8
50#define MRS_CRm_MASK 0x00000f00
51#define MRS_Op2_SHIFT 5
52#define MRS_Op2_MASK 0x000000e0
53#define MRS_Rt_SHIFT 0
54#define MRS_Rt_MASK 0x0000001f
55#define __MRS_REG(op0, op1, crn, crm, op2) \
56 (((op0) << MRS_Op0_SHIFT) | ((op1) << MRS_Op1_SHIFT) | \
57 ((crn) << MRS_CRn_SHIFT) | ((crm) << MRS_CRm_SHIFT) | \
58 ((op2) << MRS_Op2_SHIFT))
59#define MRS_REG(reg) \
60 __MRS_REG(reg##_op0, reg##_op1, reg##_CRn, reg##_CRm, reg##_op2)
61
6239#define __MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \
6340 S##op0##_##op1##_C##crn##_C##crm##_##op2
6441#define _MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \
......@@ -231,8 +208,21 @@
231208#define CLIDR_CTYPE_ID 0x3 /* Split instruction and data */
232209#define CLIDR_CTYPE_UNIFIED 0x4 /* Unified */
233210
211/* CNTKCTL_EL1 - Counter-timer Kernel Control Register */
212#define CNTKCTL_EL1_op0 3
213#define CNTKCTL_EL1_op1 0
214#define CNTKCTL_EL1_CRn 14
215#define CNTKCTL_EL1_CRm 1
216#define CNTKCTL_EL1_op2 0
217
218/* CNTKCTL_EL12 - Counter-timer Kernel Control Register */
219#define CNTKCTL_EL12_op0 3
220#define CNTKCTL_EL12_op1 5
221#define CNTKCTL_EL12_CRn 14
222#define CNTKCTL_EL12_CRm 1
223#define CNTKCTL_EL12_op2 0
224
234225/* CNTP_CTL_EL0 - Counter-timer Physical Timer Control register */
235#define CNTP_CTL_EL0 MRS_REG(CNTP_CTL_EL0)
236226#define CNTP_CTL_EL0_op0 3
237227#define CNTP_CTL_EL0_op1 3
238228#define CNTP_CTL_EL0_CRn 14
......@@ -243,7 +233,6 @@
243233#define CNTP_CTL_ISTATUS (1 << 2)
244234
245235/* CNTP_CVAL_EL0 - Counter-timer Physical Timer CompareValue register */
246#define CNTP_CVAL_EL0 MRS_REG(CNTP_CVAL_EL0)
247236#define CNTP_CVAL_EL0_op0 3
248237#define CNTP_CVAL_EL0_op1 3
249238#define CNTP_CVAL_EL0_CRn 14
......@@ -251,7 +240,6 @@
251240#define CNTP_CVAL_EL0_op2 2
252241
253242/* CNTP_TVAL_EL0 - Counter-timer Physical Timer TimerValue register */
254#define CNTP_TVAL_EL0 MRS_REG(CNTP_TVAL_EL0)
255243#define CNTP_TVAL_EL0_op0 3
256244#define CNTP_TVAL_EL0_op1 3
257245#define CNTP_TVAL_EL0_CRn 14
......@@ -259,15 +247,42 @@
259247#define CNTP_TVAL_EL0_op2 0
260248
261249/* CNTPCT_EL0 - Counter-timer Physical Count register */
262#define CNTPCT_EL0 MRS_REG(CNTPCT_EL0)
250#define CNTPCT_EL0_ISS ISS_MSR_REG(CNTPCT_EL0)
263251#define CNTPCT_EL0_op0 3
264252#define CNTPCT_EL0_op1 3
265253#define CNTPCT_EL0_CRn 14
266254#define CNTPCT_EL0_CRm 0
267255#define CNTPCT_EL0_op2 1
268256
257/* CNTV_CTL_EL0 - Counter-timer Virtual Timer Control register */
258#define CNTV_CTL_EL0_op0 3
259#define CNTV_CTL_EL0_op1 3
260#define CNTV_CTL_EL0_CRn 14
261#define CNTV_CTL_EL0_CRm 3
262#define CNTV_CTL_EL0_op2 1
263
264/* CNTV_CTL_EL02 - Counter-timer Virtual Timer Control register */
265#define CNTV_CTL_EL02_op0 3
266#define CNTV_CTL_EL02_op1 5
267#define CNTV_CTL_EL02_CRn 14
268#define CNTV_CTL_EL02_CRm 3
269#define CNTV_CTL_EL02_op2 1
270
271/* CNTV_CVAL_EL0 - Counter-timer Virtual Timer CompareValue register */
272#define CNTV_CVAL_EL0_op0 3
273#define CNTV_CVAL_EL0_op1 3
274#define CNTV_CVAL_EL0_CRn 14
275#define CNTV_CVAL_EL0_CRm 3
276#define CNTV_CVAL_EL0_op2 2
277
278/* CNTV_CVAL_EL02 - Counter-timer Virtual Timer CompareValue register */
279#define CNTV_CVAL_EL02_op0 3
280#define CNTV_CVAL_EL02_op1 5
281#define CNTV_CVAL_EL02_CRn 14
282#define CNTV_CVAL_EL02_CRm 3
283#define CNTV_CVAL_EL02_op2 2
284
269285/* CONTEXTIDR_EL1 - Context ID register */
270#define CONTEXTIDR_EL1 MRS_REG(CONTEXTIDR_EL1)
271286#define CONTEXTIDR_EL1_REG MRS_REG_ALT_NAME(CONTEXTIDR_EL1)
272287#define CONTEXTIDR_EL1_op0 3
273288#define CONTEXTIDR_EL1_op1 0
......@@ -315,36 +330,52 @@
315330#define CSSELR_InD 0x00000001
316331
317332/* CTR_EL0 - Cache Type Register */
333#define CTR_EL0_REG MRS_REG_ALT_NAME(CTR_EL0)
334#define CTR_EL0_ISS ISS_MSR_REG(CTR_EL0)
335#define CTR_EL0_op0 3
336#define CTR_EL0_op1 3
337#define CTR_EL0_CRn 0
338#define CTR_EL0_CRm 0
339#define CTR_EL0_op2 1
318340#define CTR_RES1 (1 << 31)
319341#define CTR_TminLine_SHIFT 32
320342#define CTR_TminLine_MASK (UL(0x3f) << CTR_TminLine_SHIFT)
321343#define CTR_TminLine_VAL(reg) ((reg) & CTR_TminLine_MASK)
322344#define CTR_DIC_SHIFT 29
345#define CTR_DIC_WIDTH 1
323346#define CTR_DIC_MASK (0x1 << CTR_DIC_SHIFT)
324347#define CTR_DIC_VAL(reg) ((reg) & CTR_DIC_MASK)
348#define CTR_DIC_NONE (0x0 << CTR_DIC_SHIFT)
349#define CTR_DIC_IMPL (0x1 << CTR_DIC_SHIFT)
325350#define CTR_IDC_SHIFT 28
351#define CTR_IDC_WIDTH 1
326352#define CTR_IDC_MASK (0x1 << CTR_IDC_SHIFT)
327353#define CTR_IDC_VAL(reg) ((reg) & CTR_IDC_MASK)
354#define CTR_IDC_NONE (0x0 << CTR_IDC_SHIFT)
355#define CTR_IDC_IMPL (0x1 << CTR_IDC_SHIFT)
328356#define CTR_CWG_SHIFT 24
357#define CTR_CWG_WIDTH 4
329358#define CTR_CWG_MASK (0xf << CTR_CWG_SHIFT)
330359#define CTR_CWG_VAL(reg) ((reg) & CTR_CWG_MASK)
331360#define CTR_CWG_SIZE(reg) (4 << (CTR_CWG_VAL(reg) >> CTR_CWG_SHIFT))
332361#define CTR_ERG_SHIFT 20
362#define CTR_ERG_WIDTH 4
333363#define CTR_ERG_MASK (0xf << CTR_ERG_SHIFT)
334364#define CTR_ERG_VAL(reg) ((reg) & CTR_ERG_MASK)
335365#define CTR_ERG_SIZE(reg) (4 << (CTR_ERG_VAL(reg) >> CTR_ERG_SHIFT))
336366#define CTR_DLINE_SHIFT 16
367#define CTR_DLINE_WIDTH 4
337368#define CTR_DLINE_MASK (0xf << CTR_DLINE_SHIFT)
338369#define CTR_DLINE_VAL(reg) ((reg) & CTR_DLINE_MASK)
339370#define CTR_DLINE_SIZE(reg) (4 << (CTR_DLINE_VAL(reg) >> CTR_DLINE_SHIFT))
340371#define CTR_L1IP_SHIFT 14
372#define CTR_L1IP_WIDTH 2
341373#define CTR_L1IP_MASK (0x3 << CTR_L1IP_SHIFT)
342374#define CTR_L1IP_VAL(reg) ((reg) & CTR_L1IP_MASK)
343#define CTR_L1IP_VPIPT (0 << CTR_L1IP_SHIFT)
344#define CTR_L1IP_AIVIVT (1 << CTR_L1IP_SHIFT)
345375#define CTR_L1IP_VIPT (2 << CTR_L1IP_SHIFT)
346376#define CTR_L1IP_PIPT (3 << CTR_L1IP_SHIFT)
347377#define CTR_ILINE_SHIFT 0
378#define CTR_ILINE_WIDTH 4
348379#define CTR_ILINE_MASK (0xf << CTR_ILINE_SHIFT)
349380#define CTR_ILINE_VAL(reg) ((reg) & CTR_ILINE_MASK)
350381#define CTR_ILINE_SIZE(reg) (4 << (CTR_ILINE_VAL(reg) >> CTR_ILINE_SHIFT))
......@@ -363,7 +394,7 @@
363394#define DAIF_I (1 << 1)
364395#define DAIF_F (1 << 0)
365396#define DAIF_ALL (DAIF_D | DAIF_A | DAIF_I | DAIF_F)
366#define DAIF_INTR (DAIF_I) /* All exceptions that pass */
397#define DAIF_INTR (DAIF_I | DAIF_F) /* All exceptions that pass */
367398 /* through the intr framework */
368399
369400/* DBGBCR<n>_EL1 - Debug Breakpoint Control Registers */
......@@ -435,7 +466,6 @@
435466#define DCZID_BS_SIZE(reg) (((reg) & DCZID_BS_MASK) >> DCZID_BS_SHIFT)
436467
437468/* DBGAUTHSTATUS_EL1 */
438#define DBGAUTHSTATUS_EL1 MRS_REG(DBGAUTHSTATUS_EL1)
439469#define DBGAUTHSTATUS_EL1_op0 2
440470#define DBGAUTHSTATUS_EL1_op1 0
441471#define DBGAUTHSTATUS_EL1_CRn 7
......@@ -443,7 +473,6 @@
443473#define DBGAUTHSTATUS_EL1_op2 6
444474
445475/* DBGCLAIMCLR_EL1 */
446#define DBGCLAIMCLR_EL1 MRS_REG(DBGCLAIMCLR_EL1)
447476#define DBGCLAIMCLR_EL1_op0 2
448477#define DBGCLAIMCLR_EL1_op1 0
449478#define DBGCLAIMCLR_EL1_CRn 7
......@@ -451,7 +480,6 @@
451480#define DBGCLAIMCLR_EL1_op2 6
452481
453482/* DBGCLAIMSET_EL1 */
454#define DBGCLAIMSET_EL1 MRS_REG(DBGCLAIMSET_EL1)
455483#define DBGCLAIMSET_EL1_op0 2
456484#define DBGCLAIMSET_EL1_op1 0
457485#define DBGCLAIMSET_EL1_CRn 7
......@@ -459,7 +487,6 @@
459487#define DBGCLAIMSET_EL1_op2 6
460488
461489/* DBGPRCR_EL1 */
462#define DBGPRCR_EL1 MRS_REG(DBGPRCR_EL1)
463490#define DBGPRCR_EL1_op0 2
464491#define DBGPRCR_EL1_op1 0
465492#define DBGPRCR_EL1_CRn 1
......@@ -540,12 +567,14 @@
540567#define ISS_MSR_REG_MASK \
541568 (ISS_MSR_OP0_MASK | ISS_MSR_OP2_MASK | ISS_MSR_OP1_MASK | \
542569 ISS_MSR_CRn_MASK | ISS_MSR_CRm_MASK)
570#define __ISS_MSR_REG(op0, op1, crn, crm, op2) \
571 (((op0) << ISS_MSR_OP0_SHIFT) | \
572 ((op1) << ISS_MSR_OP1_SHIFT) | \
573 ((crn) << ISS_MSR_CRn_SHIFT) | \
574 ((crm) << ISS_MSR_CRm_SHIFT) | \
575 ((op2) << ISS_MSR_OP2_SHIFT))
543576#define ISS_MSR_REG(reg) \
544 (((reg ## _op0) << ISS_MSR_OP0_SHIFT) | \
545 ((reg ## _op1) << ISS_MSR_OP1_SHIFT) | \
546 ((reg ## _CRn) << ISS_MSR_CRn_SHIFT) | \
547 ((reg ## _CRm) << ISS_MSR_CRm_SHIFT) | \
548 ((reg ## _op2) << ISS_MSR_OP2_SHIFT))
577 __ISS_MSR_REG(reg##_op0, reg##_op1, reg##_CRn, reg##_CRm, reg##_op2)
549578
550579#define ISS_DATA_ISV_SHIFT 24
551580#define ISS_DATA_ISV (0x01 << ISS_DATA_ISV_SHIFT)
......@@ -667,7 +696,6 @@
667696#define ICC_PMR_EL1_PRIO_MASK (0xFFUL)
668697
669698/* ICC_SGI1R_EL1 */
670#define ICC_SGI1R_EL1 MRS_REG(ICC_SGI1R_EL1)
671699#define ICC_SGI1R_EL1_op0 3
672700#define ICC_SGI1R_EL1_op1 0
673701#define ICC_SGI1R_EL1_CRn 12
......@@ -697,8 +725,8 @@
697725#define ICC_SRE_EL1_SRE (1U << 0)
698726
699727/* ID_AA64AFR0_EL1 */
700#define ID_AA64AFR0_EL1 MRS_REG(ID_AA64AFR0_EL1)
701728#define ID_AA64AFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR0_EL1)
729#define ID_AA64AFR0_EL1_ISS ISS_MSR_REG(ID_AA64AFR0_EL1)
702730#define ID_AA64AFR0_EL1_op0 3
703731#define ID_AA64AFR0_EL1_op1 0
704732#define ID_AA64AFR0_EL1_CRn 0
......@@ -706,8 +734,8 @@
706734#define ID_AA64AFR0_EL1_op2 4
707735
708736/* ID_AA64AFR1_EL1 */
709#define ID_AA64AFR1_EL1 MRS_REG(ID_AA64AFR1_EL1)
710737#define ID_AA64AFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR1_EL1)
738#define ID_AA64AFR1_EL1_ISS ISS_MSR_REG(ID_AA64AFR1_EL1)
711739#define ID_AA64AFR1_EL1_op0 3
712740#define ID_AA64AFR1_EL1_op1 0
713741#define ID_AA64AFR1_EL1_CRn 0
......@@ -715,14 +743,15 @@
715743#define ID_AA64AFR1_EL1_op2 5
716744
717745/* ID_AA64DFR0_EL1 */
718#define ID_AA64DFR0_EL1 MRS_REG(ID_AA64DFR0_EL1)
719746#define ID_AA64DFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR0_EL1)
747#define ID_AA64DFR0_EL1_ISS ISS_MSR_REG(ID_AA64DFR0_EL1)
720748#define ID_AA64DFR0_EL1_op0 3
721749#define ID_AA64DFR0_EL1_op1 0
722750#define ID_AA64DFR0_EL1_CRn 0
723751#define ID_AA64DFR0_EL1_CRm 5
724752#define ID_AA64DFR0_EL1_op2 0
725753#define ID_AA64DFR0_DebugVer_SHIFT 0
754#define ID_AA64DFR0_DebugVer_WIDTH 4
726755#define ID_AA64DFR0_DebugVer_MASK (UL(0xf) << ID_AA64DFR0_DebugVer_SHIFT)
727756#define ID_AA64DFR0_DebugVer_VAL(x) ((x) & ID_AA64DFR0_DebugVer_MASK)
728757#define ID_AA64DFR0_DebugVer_8 (UL(0x6) << ID_AA64DFR0_DebugVer_SHIFT)
......@@ -730,12 +759,15 @@
730759#define ID_AA64DFR0_DebugVer_8_2 (UL(0x8) << ID_AA64DFR0_DebugVer_SHIFT)
731760#define ID_AA64DFR0_DebugVer_8_4 (UL(0x9) << ID_AA64DFR0_DebugVer_SHIFT)
732761#define ID_AA64DFR0_DebugVer_8_8 (UL(0xa) << ID_AA64DFR0_DebugVer_SHIFT)
762#define ID_AA64DFR0_DebugVer_8_9 (UL(0xb) << ID_AA64DFR0_DebugVer_SHIFT)
733763#define ID_AA64DFR0_TraceVer_SHIFT 4
764#define ID_AA64DFR0_TraceVer_WIDTH 4
734765#define ID_AA64DFR0_TraceVer_MASK (UL(0xf) << ID_AA64DFR0_TraceVer_SHIFT)
735766#define ID_AA64DFR0_TraceVer_VAL(x) ((x) & ID_AA64DFR0_TraceVer_MASK)
736767#define ID_AA64DFR0_TraceVer_NONE (UL(0x0) << ID_AA64DFR0_TraceVer_SHIFT)
737768#define ID_AA64DFR0_TraceVer_IMPL (UL(0x1) << ID_AA64DFR0_TraceVer_SHIFT)
738769#define ID_AA64DFR0_PMUVer_SHIFT 8
770#define ID_AA64DFR0_PMUVer_WIDTH 4
739771#define ID_AA64DFR0_PMUVer_MASK (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT)
740772#define ID_AA64DFR0_PMUVer_VAL(x) ((x) & ID_AA64DFR0_PMUVer_MASK)
741773#define ID_AA64DFR0_PMUVer_NONE (UL(0x0) << ID_AA64DFR0_PMUVer_SHIFT)
......@@ -745,25 +777,31 @@
745777#define ID_AA64DFR0_PMUVer_3_5 (UL(0x6) << ID_AA64DFR0_PMUVer_SHIFT)
746778#define ID_AA64DFR0_PMUVer_3_7 (UL(0x7) << ID_AA64DFR0_PMUVer_SHIFT)
747779#define ID_AA64DFR0_PMUVer_3_8 (UL(0x8) << ID_AA64DFR0_PMUVer_SHIFT)
780#define ID_AA64DFR0_PMUVer_3_9 (UL(0x9) << ID_AA64DFR0_PMUVer_SHIFT)
748781#define ID_AA64DFR0_PMUVer_IMPL (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT)
749782#define ID_AA64DFR0_BRPs_SHIFT 12
783#define ID_AA64DFR0_BRPs_WIDTH 4
750784#define ID_AA64DFR0_BRPs_MASK (UL(0xf) << ID_AA64DFR0_BRPs_SHIFT)
751785#define ID_AA64DFR0_BRPs_VAL(x) \
752786 ((((x) >> ID_AA64DFR0_BRPs_SHIFT) & 0xf) + 1)
753787#define ID_AA64DFR0_PMSS_SHIFT 16
788#define ID_AA64DFR0_PMSS_WIDTH 4
754789#define ID_AA64DFR0_PMSS_MASK (UL(0xf) << ID_AA64DFR0_PMSS_SHIFT)
755790#define ID_AA64DFR0_PMSS_VAL(x) ((x) & ID_AA64DFR0_PMSS_MASK)
756791#define ID_AA64DFR0_PMSS_NONE (UL(0x0) << ID_AA64DFR0_PMSS_SHIFT)
757792#define ID_AA64DFR0_PMSS_IMPL (UL(0x1) << ID_AA64DFR0_PMSS_SHIFT)
758793#define ID_AA64DFR0_WRPs_SHIFT 20
794#define ID_AA64DFR0_WRPs_WIDTH 4
759795#define ID_AA64DFR0_WRPs_MASK (UL(0xf) << ID_AA64DFR0_WRPs_SHIFT)
760796#define ID_AA64DFR0_WRPs_VAL(x) \
761797 ((((x) >> ID_AA64DFR0_WRPs_SHIFT) & 0xf) + 1)
762798#define ID_AA64DFR0_CTX_CMPs_SHIFT 28
799#define ID_AA64DFR0_CTX_CMPs_WIDTH 4
763800#define ID_AA64DFR0_CTX_CMPs_MASK (UL(0xf) << ID_AA64DFR0_CTX_CMPs_SHIFT)
764801#define ID_AA64DFR0_CTX_CMPs_VAL(x) \
765802 ((((x) >> ID_AA64DFR0_CTX_CMPs_SHIFT) & 0xf) + 1)
766803#define ID_AA64DFR0_PMSVer_SHIFT 32
804#define ID_AA64DFR0_PMSVer_WIDTH 4
767805#define ID_AA64DFR0_PMSVer_MASK (UL(0xf) << ID_AA64DFR0_PMSVer_SHIFT)
768806#define ID_AA64DFR0_PMSVer_VAL(x) ((x) & ID_AA64DFR0_PMSVer_MASK)
769807#define ID_AA64DFR0_PMSVer_NONE (UL(0x0) << ID_AA64DFR0_PMSVer_SHIFT)
......@@ -771,150 +809,192 @@
771809#define ID_AA64DFR0_PMSVer_SPE_1_1 (UL(0x2) << ID_AA64DFR0_PMSVer_SHIFT)
772810#define ID_AA64DFR0_PMSVer_SPE_1_2 (UL(0x3) << ID_AA64DFR0_PMSVer_SHIFT)
773811#define ID_AA64DFR0_PMSVer_SPE_1_3 (UL(0x4) << ID_AA64DFR0_PMSVer_SHIFT)
812#define ID_AA64DFR0_PMSVer_SPE_1_4 (UL(0x5) << ID_AA64DFR0_PMSVer_SHIFT)
774813#define ID_AA64DFR0_DoubleLock_SHIFT 36
814#define ID_AA64DFR0_DoubleLock_WIDTH 4
775815#define ID_AA64DFR0_DoubleLock_MASK (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT)
776816#define ID_AA64DFR0_DoubleLock_VAL(x) ((x) & ID_AA64DFR0_DoubleLock_MASK)
777817#define ID_AA64DFR0_DoubleLock_IMPL (UL(0x0) << ID_AA64DFR0_DoubleLock_SHIFT)
778818#define ID_AA64DFR0_DoubleLock_NONE (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT)
779819#define ID_AA64DFR0_TraceFilt_SHIFT 40
820#define ID_AA64DFR0_TraceFilt_WIDTH 4
780821#define ID_AA64DFR0_TraceFilt_MASK (UL(0xf) << ID_AA64DFR0_TraceFilt_SHIFT)
781822#define ID_AA64DFR0_TraceFilt_VAL(x) ((x) & ID_AA64DFR0_TraceFilt_MASK)
782823#define ID_AA64DFR0_TraceFilt_NONE (UL(0x0) << ID_AA64DFR0_TraceFilt_SHIFT)
783824#define ID_AA64DFR0_TraceFilt_8_4 (UL(0x1) << ID_AA64DFR0_TraceFilt_SHIFT)
784825#define ID_AA64DFR0_TraceBuffer_SHIFT 44
826#define ID_AA64DFR0_TraceBuffer_WIDTH 4
785827#define ID_AA64DFR0_TraceBuffer_MASK (UL(0xf) << ID_AA64DFR0_TraceBuffer_SHIFT)
786828#define ID_AA64DFR0_TraceBuffer_VAL(x) ((x) & ID_AA64DFR0_TraceBuffer_MASK)
787829#define ID_AA64DFR0_TraceBuffer_NONE (UL(0x0) << ID_AA64DFR0_TraceBuffer_SHIFT)
788830#define ID_AA64DFR0_TraceBuffer_IMPL (UL(0x1) << ID_AA64DFR0_TraceBuffer_SHIFT)
789831#define ID_AA64DFR0_MTPMU_SHIFT 48
832#define ID_AA64DFR0_MTPMU_WIDTH 4
790833#define ID_AA64DFR0_MTPMU_MASK (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT)
791834#define ID_AA64DFR0_MTPMU_VAL(x) ((x) & ID_AA64DFR0_MTPMU_MASK)
792835#define ID_AA64DFR0_MTPMU_NONE (UL(0x0) << ID_AA64DFR0_MTPMU_SHIFT)
793836#define ID_AA64DFR0_MTPMU_IMPL (UL(0x1) << ID_AA64DFR0_MTPMU_SHIFT)
794837#define ID_AA64DFR0_MTPMU_NONE_MT_RES0 (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT)
795838#define ID_AA64DFR0_BRBE_SHIFT 52
839#define ID_AA64DFR0_BRBE_WIDTH 4
796840#define ID_AA64DFR0_BRBE_MASK (UL(0xf) << ID_AA64DFR0_BRBE_SHIFT)
797841#define ID_AA64DFR0_BRBE_VAL(x) ((x) & ID_AA64DFR0_BRBE_MASK)
798842#define ID_AA64DFR0_BRBE_NONE (UL(0x0) << ID_AA64DFR0_BRBE_SHIFT)
799843#define ID_AA64DFR0_BRBE_IMPL (UL(0x1) << ID_AA64DFR0_BRBE_SHIFT)
800844#define ID_AA64DFR0_BRBE_EL3 (UL(0x2) << ID_AA64DFR0_BRBE_SHIFT)
801845#define ID_AA64DFR0_HPMN0_SHIFT 60
846#define ID_AA64DFR0_HPMN0_WIDTH 4
802847#define ID_AA64DFR0_HPMN0_MASK (UL(0xf) << ID_AA64DFR0_HPMN0_SHIFT)
803848#define ID_AA64DFR0_HPMN0_VAL(x) ((x) & ID_AA64DFR0_HPMN0_MASK)
804849#define ID_AA64DFR0_HPMN0_CONSTR (UL(0x0) << ID_AA64DFR0_HPMN0_SHIFT)
805850#define ID_AA64DFR0_HPMN0_DEFINED (UL(0x1) << ID_AA64DFR0_HPMN0_SHIFT)
806851
807852/* ID_AA64DFR1_EL1 */
808#define ID_AA64DFR1_EL1 MRS_REG(ID_AA64DFR1_EL1)
809853#define ID_AA64DFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR1_EL1)
854#define ID_AA64DFR1_EL1_ISS ISS_MSR_REG(ID_AA64DFR1_EL1)
810855#define ID_AA64DFR1_EL1_op0 3
811856#define ID_AA64DFR1_EL1_op1 0
812857#define ID_AA64DFR1_EL1_CRn 0
813858#define ID_AA64DFR1_EL1_CRm 5
814859#define ID_AA64DFR1_EL1_op2 1
860#define ID_AA64DFR1_SPMU_SHIFT 32
861#define ID_AA64DFR1_SPMU_WIDTH 4
862#define ID_AA64DFR1_SPMU_MASK (UL(0xf) << ID_AA64DFR1_SPMU_SHIFT)
863#define ID_AA64DFR1_SPMU_VAL(x) ((x) & ID_AA64DFR1_SPMU_MASK)
864#define ID_AA64DFR1_SPMU_NONE (UL(0x0) << ID_AA64DFR1_SPMU_SHIFT)
865#define ID_AA64DFR1_SPMU_IMPL (UL(0x1) << ID_AA64DFR1_SPMU_SHIFT)
866#define ID_AA64DFR1_PMICNTR_SHIFT 36
867#define ID_AA64DFR1_PMICNTR_WIDTH 4
868#define ID_AA64DFR1_PMICNTR_MASK (UL(0xf) << ID_AA64DFR1_PMICNTR_SHIFT)
869#define ID_AA64DFR1_PMICNTR_VAL(x) ((x) & ID_AA64DFR1_PMICNTR_MASK)
870#define ID_AA64DFR1_PMICNTR_NONE (UL(0x0) << ID_AA64DFR1_PMICNTR_SHIFT)
871#define ID_AA64DFR1_PMICNTR_IMPL (UL(0x1) << ID_AA64DFR1_PMICNTR_SHIFT)
872#define ID_AA64DFR1_DPFZS_SHIFT 52
873#define ID_AA64DFR1_DPFZS_WIDTH 4
874#define ID_AA64DFR1_DPFZS_MASK (UL(0xf) << ID_AA64DFR1_DPFZS_SHIFT)
875#define ID_AA64DFR1_DPFZS_VAL(x) ((x) & ID_AA64DFR1_DPFZS_MASK)
876#define ID_AA64DFR1_DPFZS_NONE (UL(0x0) << ID_AA64DFR1_DPFZS_SHIFT)
877#define ID_AA64DFR1_DPFZS_IMPL (UL(0x1) << ID_AA64DFR1_DPFZS_SHIFT)
815878
816879/* ID_AA64ISAR0_EL1 */
817#define ID_AA64ISAR0_EL1 MRS_REG(ID_AA64ISAR0_EL1)
818880#define ID_AA64ISAR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR0_EL1)
881#define ID_AA64ISAR0_EL1_ISS ISS_MSR_REG(ID_AA64ISAR0_EL1)
819882#define ID_AA64ISAR0_EL1_op0 3
820883#define ID_AA64ISAR0_EL1_op1 0
821884#define ID_AA64ISAR0_EL1_CRn 0
822885#define ID_AA64ISAR0_EL1_CRm 6
823886#define ID_AA64ISAR0_EL1_op2 0
824887#define ID_AA64ISAR0_AES_SHIFT 4
888#define ID_AA64ISAR0_AES_WIDTH 4
825889#define ID_AA64ISAR0_AES_MASK (UL(0xf) << ID_AA64ISAR0_AES_SHIFT)
826890#define ID_AA64ISAR0_AES_VAL(x) ((x) & ID_AA64ISAR0_AES_MASK)
827891#define ID_AA64ISAR0_AES_NONE (UL(0x0) << ID_AA64ISAR0_AES_SHIFT)
828892#define ID_AA64ISAR0_AES_BASE (UL(0x1) << ID_AA64ISAR0_AES_SHIFT)
829893#define ID_AA64ISAR0_AES_PMULL (UL(0x2) << ID_AA64ISAR0_AES_SHIFT)
830894#define ID_AA64ISAR0_SHA1_SHIFT 8
895#define ID_AA64ISAR0_SHA1_WIDTH 4
831896#define ID_AA64ISAR0_SHA1_MASK (UL(0xf) << ID_AA64ISAR0_SHA1_SHIFT)
832897#define ID_AA64ISAR0_SHA1_VAL(x) ((x) & ID_AA64ISAR0_SHA1_MASK)
833898#define ID_AA64ISAR0_SHA1_NONE (UL(0x0) << ID_AA64ISAR0_SHA1_SHIFT)
834899#define ID_AA64ISAR0_SHA1_BASE (UL(0x1) << ID_AA64ISAR0_SHA1_SHIFT)
835900#define ID_AA64ISAR0_SHA2_SHIFT 12
901#define ID_AA64ISAR0_SHA2_WIDTH 4
836902#define ID_AA64ISAR0_SHA2_MASK (UL(0xf) << ID_AA64ISAR0_SHA2_SHIFT)
837903#define ID_AA64ISAR0_SHA2_VAL(x) ((x) & ID_AA64ISAR0_SHA2_MASK)
838904#define ID_AA64ISAR0_SHA2_NONE (UL(0x0) << ID_AA64ISAR0_SHA2_SHIFT)
839905#define ID_AA64ISAR0_SHA2_BASE (UL(0x1) << ID_AA64ISAR0_SHA2_SHIFT)
840906#define ID_AA64ISAR0_SHA2_512 (UL(0x2) << ID_AA64ISAR0_SHA2_SHIFT)
841907#define ID_AA64ISAR0_CRC32_SHIFT 16
908#define ID_AA64ISAR0_CRC32_WIDTH 4
842909#define ID_AA64ISAR0_CRC32_MASK (UL(0xf) << ID_AA64ISAR0_CRC32_SHIFT)
843910#define ID_AA64ISAR0_CRC32_VAL(x) ((x) & ID_AA64ISAR0_CRC32_MASK)
844911#define ID_AA64ISAR0_CRC32_NONE (UL(0x0) << ID_AA64ISAR0_CRC32_SHIFT)
845912#define ID_AA64ISAR0_CRC32_BASE (UL(0x1) << ID_AA64ISAR0_CRC32_SHIFT)
846913#define ID_AA64ISAR0_Atomic_SHIFT 20
914#define ID_AA64ISAR0_Atomic_WIDTH 4
847915#define ID_AA64ISAR0_Atomic_MASK (UL(0xf) << ID_AA64ISAR0_Atomic_SHIFT)
848916#define ID_AA64ISAR0_Atomic_VAL(x) ((x) & ID_AA64ISAR0_Atomic_MASK)
849917#define ID_AA64ISAR0_Atomic_NONE (UL(0x0) << ID_AA64ISAR0_Atomic_SHIFT)
850918#define ID_AA64ISAR0_Atomic_IMPL (UL(0x2) << ID_AA64ISAR0_Atomic_SHIFT)
851919#define ID_AA64ISAR0_TME_SHIFT 24
920#define ID_AA64ISAR0_TME_WIDTH 4
852921#define ID_AA64ISAR0_TME_MASK (UL(0xf) << ID_AA64ISAR0_TME_SHIFT)
853922#define ID_AA64ISAR0_TME_NONE (UL(0x0) << ID_AA64ISAR0_TME_SHIFT)
854923#define ID_AA64ISAR0_TME_IMPL (UL(0x1) << ID_AA64ISAR0_TME_SHIFT)
855924#define ID_AA64ISAR0_RDM_SHIFT 28
925#define ID_AA64ISAR0_RDM_WIDTH 4
856926#define ID_AA64ISAR0_RDM_MASK (UL(0xf) << ID_AA64ISAR0_RDM_SHIFT)
857927#define ID_AA64ISAR0_RDM_VAL(x) ((x) & ID_AA64ISAR0_RDM_MASK)
858928#define ID_AA64ISAR0_RDM_NONE (UL(0x0) << ID_AA64ISAR0_RDM_SHIFT)
859929#define ID_AA64ISAR0_RDM_IMPL (UL(0x1) << ID_AA64ISAR0_RDM_SHIFT)
860930#define ID_AA64ISAR0_SHA3_SHIFT 32
931#define ID_AA64ISAR0_SHA3_WIDTH 4
861932#define ID_AA64ISAR0_SHA3_MASK (UL(0xf) << ID_AA64ISAR0_SHA3_SHIFT)
862933#define ID_AA64ISAR0_SHA3_VAL(x) ((x) & ID_AA64ISAR0_SHA3_MASK)
863934#define ID_AA64ISAR0_SHA3_NONE (UL(0x0) << ID_AA64ISAR0_SHA3_SHIFT)
864935#define ID_AA64ISAR0_SHA3_IMPL (UL(0x1) << ID_AA64ISAR0_SHA3_SHIFT)
865936#define ID_AA64ISAR0_SM3_SHIFT 36
937#define ID_AA64ISAR0_SM3_WIDTH 4
866938#define ID_AA64ISAR0_SM3_MASK (UL(0xf) << ID_AA64ISAR0_SM3_SHIFT)
867939#define ID_AA64ISAR0_SM3_VAL(x) ((x) & ID_AA64ISAR0_SM3_MASK)
868940#define ID_AA64ISAR0_SM3_NONE (UL(0x0) << ID_AA64ISAR0_SM3_SHIFT)
869941#define ID_AA64ISAR0_SM3_IMPL (UL(0x1) << ID_AA64ISAR0_SM3_SHIFT)
870942#define ID_AA64ISAR0_SM4_SHIFT 40
943#define ID_AA64ISAR0_SM4_WIDTH 4
871944#define ID_AA64ISAR0_SM4_MASK (UL(0xf) << ID_AA64ISAR0_SM4_SHIFT)
872945#define ID_AA64ISAR0_SM4_VAL(x) ((x) & ID_AA64ISAR0_SM4_MASK)
873946#define ID_AA64ISAR0_SM4_NONE (UL(0x0) << ID_AA64ISAR0_SM4_SHIFT)
874947#define ID_AA64ISAR0_SM4_IMPL (UL(0x1) << ID_AA64ISAR0_SM4_SHIFT)
875948#define ID_AA64ISAR0_DP_SHIFT 44
949#define ID_AA64ISAR0_DP_WIDTH 4
876950#define ID_AA64ISAR0_DP_MASK (UL(0xf) << ID_AA64ISAR0_DP_SHIFT)
877951#define ID_AA64ISAR0_DP_VAL(x) ((x) & ID_AA64ISAR0_DP_MASK)
878952#define ID_AA64ISAR0_DP_NONE (UL(0x0) << ID_AA64ISAR0_DP_SHIFT)
879953#define ID_AA64ISAR0_DP_IMPL (UL(0x1) << ID_AA64ISAR0_DP_SHIFT)
880954#define ID_AA64ISAR0_FHM_SHIFT 48
955#define ID_AA64ISAR0_FHM_WIDTH 4
881956#define ID_AA64ISAR0_FHM_MASK (UL(0xf) << ID_AA64ISAR0_FHM_SHIFT)
882957#define ID_AA64ISAR0_FHM_VAL(x) ((x) & ID_AA64ISAR0_FHM_MASK)
883958#define ID_AA64ISAR0_FHM_NONE (UL(0x0) << ID_AA64ISAR0_FHM_SHIFT)
884959#define ID_AA64ISAR0_FHM_IMPL (UL(0x1) << ID_AA64ISAR0_FHM_SHIFT)
885960#define ID_AA64ISAR0_TS_SHIFT 52
961#define ID_AA64ISAR0_TS_WIDTH 4
886962#define ID_AA64ISAR0_TS_MASK (UL(0xf) << ID_AA64ISAR0_TS_SHIFT)
887963#define ID_AA64ISAR0_TS_VAL(x) ((x) & ID_AA64ISAR0_TS_MASK)
888964#define ID_AA64ISAR0_TS_NONE (UL(0x0) << ID_AA64ISAR0_TS_SHIFT)
889965#define ID_AA64ISAR0_TS_CondM_8_4 (UL(0x1) << ID_AA64ISAR0_TS_SHIFT)
890966#define ID_AA64ISAR0_TS_CondM_8_5 (UL(0x2) << ID_AA64ISAR0_TS_SHIFT)
891967#define ID_AA64ISAR0_TLB_SHIFT 56
968#define ID_AA64ISAR0_TLB_WIDTH 4
892969#define ID_AA64ISAR0_TLB_MASK (UL(0xf) << ID_AA64ISAR0_TLB_SHIFT)
893970#define ID_AA64ISAR0_TLB_VAL(x) ((x) & ID_AA64ISAR0_TLB_MASK)
894971#define ID_AA64ISAR0_TLB_NONE (UL(0x0) << ID_AA64ISAR0_TLB_SHIFT)
895972#define ID_AA64ISAR0_TLB_TLBIOS (UL(0x1) << ID_AA64ISAR0_TLB_SHIFT)
896973#define ID_AA64ISAR0_TLB_TLBIOSR (UL(0x2) << ID_AA64ISAR0_TLB_SHIFT)
897974#define ID_AA64ISAR0_RNDR_SHIFT 60
975#define ID_AA64ISAR0_RNDR_WIDTH 4
898976#define ID_AA64ISAR0_RNDR_MASK (UL(0xf) << ID_AA64ISAR0_RNDR_SHIFT)
899977#define ID_AA64ISAR0_RNDR_VAL(x) ((x) & ID_AA64ISAR0_RNDR_MASK)
900978#define ID_AA64ISAR0_RNDR_NONE (UL(0x0) << ID_AA64ISAR0_RNDR_SHIFT)
901979#define ID_AA64ISAR0_RNDR_IMPL (UL(0x1) << ID_AA64ISAR0_RNDR_SHIFT)
902980
903981/* ID_AA64ISAR1_EL1 */
904#define ID_AA64ISAR1_EL1 MRS_REG(ID_AA64ISAR1_EL1)
905982#define ID_AA64ISAR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR1_EL1)
983#define ID_AA64ISAR1_EL1_ISS ISS_MSR_REG(ID_AA64ISAR1_EL1)
906984#define ID_AA64ISAR1_EL1_op0 3
907985#define ID_AA64ISAR1_EL1_op1 0
908986#define ID_AA64ISAR1_EL1_CRn 0
909987#define ID_AA64ISAR1_EL1_CRm 6
910988#define ID_AA64ISAR1_EL1_op2 1
911989#define ID_AA64ISAR1_DPB_SHIFT 0
990#define ID_AA64ISAR1_DPB_WIDTH 4
912991#define ID_AA64ISAR1_DPB_MASK (UL(0xf) << ID_AA64ISAR1_DPB_SHIFT)
913992#define ID_AA64ISAR1_DPB_VAL(x) ((x) & ID_AA64ISAR1_DPB_MASK)
914993#define ID_AA64ISAR1_DPB_NONE (UL(0x0) << ID_AA64ISAR1_DPB_SHIFT)
915994#define ID_AA64ISAR1_DPB_DCCVAP (UL(0x1) << ID_AA64ISAR1_DPB_SHIFT)
916995#define ID_AA64ISAR1_DPB_DCCVADP (UL(0x2) << ID_AA64ISAR1_DPB_SHIFT)
917996#define ID_AA64ISAR1_APA_SHIFT 4
997#define ID_AA64ISAR1_APA_WIDTH 4
918998#define ID_AA64ISAR1_APA_MASK (UL(0xf) << ID_AA64ISAR1_APA_SHIFT)
919999#define ID_AA64ISAR1_APA_VAL(x) ((x) & ID_AA64ISAR1_APA_MASK)
9201000#define ID_AA64ISAR1_APA_NONE (UL(0x0) << ID_AA64ISAR1_APA_SHIFT)
......@@ -924,6 +1004,7 @@
9241004#define ID_AA64ISAR1_APA_FPAC (UL(0x4) << ID_AA64ISAR1_APA_SHIFT)
9251005#define ID_AA64ISAR1_APA_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_APA_SHIFT)
9261006#define ID_AA64ISAR1_API_SHIFT 8
1007#define ID_AA64ISAR1_API_WIDTH 4
9271008#define ID_AA64ISAR1_API_MASK (UL(0xf) << ID_AA64ISAR1_API_SHIFT)
9281009#define ID_AA64ISAR1_API_VAL(x) ((x) & ID_AA64ISAR1_API_MASK)
9291010#define ID_AA64ISAR1_API_NONE (UL(0x0) << ID_AA64ISAR1_API_SHIFT)
......@@ -933,68 +1014,82 @@
9331014#define ID_AA64ISAR1_API_FPAC (UL(0x4) << ID_AA64ISAR1_API_SHIFT)
9341015#define ID_AA64ISAR1_API_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_API_SHIFT)
9351016#define ID_AA64ISAR1_JSCVT_SHIFT 12
1017#define ID_AA64ISAR1_JSCVT_WIDTH 4
9361018#define ID_AA64ISAR1_JSCVT_MASK (UL(0xf) << ID_AA64ISAR1_JSCVT_SHIFT)
9371019#define ID_AA64ISAR1_JSCVT_VAL(x) ((x) & ID_AA64ISAR1_JSCVT_MASK)
9381020#define ID_AA64ISAR1_JSCVT_NONE (UL(0x0) << ID_AA64ISAR1_JSCVT_SHIFT)
9391021#define ID_AA64ISAR1_JSCVT_IMPL (UL(0x1) << ID_AA64ISAR1_JSCVT_SHIFT)
9401022#define ID_AA64ISAR1_FCMA_SHIFT 16
1023#define ID_AA64ISAR1_FCMA_WIDTH 4
9411024#define ID_AA64ISAR1_FCMA_MASK (UL(0xf) << ID_AA64ISAR1_FCMA_SHIFT)
9421025#define ID_AA64ISAR1_FCMA_VAL(x) ((x) & ID_AA64ISAR1_FCMA_MASK)
9431026#define ID_AA64ISAR1_FCMA_NONE (UL(0x0) << ID_AA64ISAR1_FCMA_SHIFT)
9441027#define ID_AA64ISAR1_FCMA_IMPL (UL(0x1) << ID_AA64ISAR1_FCMA_SHIFT)
9451028#define ID_AA64ISAR1_LRCPC_SHIFT 20
1029#define ID_AA64ISAR1_LRCPC_WIDTH 4
9461030#define ID_AA64ISAR1_LRCPC_MASK (UL(0xf) << ID_AA64ISAR1_LRCPC_SHIFT)
9471031#define ID_AA64ISAR1_LRCPC_VAL(x) ((x) & ID_AA64ISAR1_LRCPC_MASK)
9481032#define ID_AA64ISAR1_LRCPC_NONE (UL(0x0) << ID_AA64ISAR1_LRCPC_SHIFT)
9491033#define ID_AA64ISAR1_LRCPC_RCPC_8_3 (UL(0x1) << ID_AA64ISAR1_LRCPC_SHIFT)
9501034#define ID_AA64ISAR1_LRCPC_RCPC_8_4 (UL(0x2) << ID_AA64ISAR1_LRCPC_SHIFT)
9511035#define ID_AA64ISAR1_GPA_SHIFT 24
1036#define ID_AA64ISAR1_GPA_WIDTH 4
9521037#define ID_AA64ISAR1_GPA_MASK (UL(0xf) << ID_AA64ISAR1_GPA_SHIFT)
9531038#define ID_AA64ISAR1_GPA_VAL(x) ((x) & ID_AA64ISAR1_GPA_MASK)
9541039#define ID_AA64ISAR1_GPA_NONE (UL(0x0) << ID_AA64ISAR1_GPA_SHIFT)
9551040#define ID_AA64ISAR1_GPA_IMPL (UL(0x1) << ID_AA64ISAR1_GPA_SHIFT)
9561041#define ID_AA64ISAR1_GPI_SHIFT 28
1042#define ID_AA64ISAR1_GPI_WIDTH 4
9571043#define ID_AA64ISAR1_GPI_MASK (UL(0xf) << ID_AA64ISAR1_GPI_SHIFT)
9581044#define ID_AA64ISAR1_GPI_VAL(x) ((x) & ID_AA64ISAR1_GPI_MASK)
9591045#define ID_AA64ISAR1_GPI_NONE (UL(0x0) << ID_AA64ISAR1_GPI_SHIFT)
9601046#define ID_AA64ISAR1_GPI_IMPL (UL(0x1) << ID_AA64ISAR1_GPI_SHIFT)
9611047#define ID_AA64ISAR1_FRINTTS_SHIFT 32
1048#define ID_AA64ISAR1_FRINTTS_WIDTH 4
9621049#define ID_AA64ISAR1_FRINTTS_MASK (UL(0xf) << ID_AA64ISAR1_FRINTTS_SHIFT)
9631050#define ID_AA64ISAR1_FRINTTS_VAL(x) ((x) & ID_AA64ISAR1_FRINTTS_MASK)
9641051#define ID_AA64ISAR1_FRINTTS_NONE (UL(0x0) << ID_AA64ISAR1_FRINTTS_SHIFT)
9651052#define ID_AA64ISAR1_FRINTTS_IMPL (UL(0x1) << ID_AA64ISAR1_FRINTTS_SHIFT)
9661053#define ID_AA64ISAR1_SB_SHIFT 36
1054#define ID_AA64ISAR1_SB_WIDTH 4
9671055#define ID_AA64ISAR1_SB_MASK (UL(0xf) << ID_AA64ISAR1_SB_SHIFT)
9681056#define ID_AA64ISAR1_SB_VAL(x) ((x) & ID_AA64ISAR1_SB_MASK)
9691057#define ID_AA64ISAR1_SB_NONE (UL(0x0) << ID_AA64ISAR1_SB_SHIFT)
9701058#define ID_AA64ISAR1_SB_IMPL (UL(0x1) << ID_AA64ISAR1_SB_SHIFT)
9711059#define ID_AA64ISAR1_SPECRES_SHIFT 40
1060#define ID_AA64ISAR1_SPECRES_WIDTH 4
9721061#define ID_AA64ISAR1_SPECRES_MASK (UL(0xf) << ID_AA64ISAR1_SPECRES_SHIFT)
9731062#define ID_AA64ISAR1_SPECRES_VAL(x) ((x) & ID_AA64ISAR1_SPECRES_MASK)
9741063#define ID_AA64ISAR1_SPECRES_NONE (UL(0x0) << ID_AA64ISAR1_SPECRES_SHIFT)
975#define ID_AA64ISAR1_SPECRES_IMPL (UL(0x1) << ID_AA64ISAR1_SPECRES_SHIFT)
1064#define ID_AA64ISAR1_SPECRES_8_5 (UL(0x1) << ID_AA64ISAR1_SPECRES_SHIFT)
1065#define ID_AA64ISAR1_SPECRES_8_9 (UL(0x2) << ID_AA64ISAR1_SPECRES_SHIFT)
9761066#define ID_AA64ISAR1_BF16_SHIFT 44
1067#define ID_AA64ISAR1_BF16_WIDTH 4
9771068#define ID_AA64ISAR1_BF16_MASK (UL(0xf) << ID_AA64ISAR1_BF16_SHIFT)
9781069#define ID_AA64ISAR1_BF16_VAL(x) ((x) & ID_AA64ISAR1_BF16_MASK)
9791070#define ID_AA64ISAR1_BF16_NONE (UL(0x0) << ID_AA64ISAR1_BF16_SHIFT)
9801071#define ID_AA64ISAR1_BF16_IMPL (UL(0x1) << ID_AA64ISAR1_BF16_SHIFT)
9811072#define ID_AA64ISAR1_BF16_EBF (UL(0x2) << ID_AA64ISAR1_BF16_SHIFT)
9821073#define ID_AA64ISAR1_DGH_SHIFT 48
1074#define ID_AA64ISAR1_DGH_WIDTH 4
9831075#define ID_AA64ISAR1_DGH_MASK (UL(0xf) << ID_AA64ISAR1_DGH_SHIFT)
9841076#define ID_AA64ISAR1_DGH_VAL(x) ((x) & ID_AA64ISAR1_DGH_MASK)
9851077#define ID_AA64ISAR1_DGH_NONE (UL(0x0) << ID_AA64ISAR1_DGH_SHIFT)
9861078#define ID_AA64ISAR1_DGH_IMPL (UL(0x1) << ID_AA64ISAR1_DGH_SHIFT)
9871079#define ID_AA64ISAR1_I8MM_SHIFT 52
1080#define ID_AA64ISAR1_I8MM_WIDTH 4
9881081#define ID_AA64ISAR1_I8MM_MASK (UL(0xf) << ID_AA64ISAR1_I8MM_SHIFT)
9891082#define ID_AA64ISAR1_I8MM_VAL(x) ((x) & ID_AA64ISAR1_I8MM_MASK)
9901083#define ID_AA64ISAR1_I8MM_NONE (UL(0x0) << ID_AA64ISAR1_I8MM_SHIFT)
9911084#define ID_AA64ISAR1_I8MM_IMPL (UL(0x1) << ID_AA64ISAR1_I8MM_SHIFT)
9921085#define ID_AA64ISAR1_XS_SHIFT 56
1086#define ID_AA64ISAR1_XS_WIDTH 4
9931087#define ID_AA64ISAR1_XS_MASK (UL(0xf) << ID_AA64ISAR1_XS_SHIFT)
9941088#define ID_AA64ISAR1_XS_VAL(x) ((x) & ID_AA64ISAR1_XS_MASK)
9951089#define ID_AA64ISAR1_XS_NONE (UL(0x0) << ID_AA64ISAR1_XS_SHIFT)
9961090#define ID_AA64ISAR1_XS_IMPL (UL(0x1) << ID_AA64ISAR1_XS_SHIFT)
9971091#define ID_AA64ISAR1_LS64_SHIFT 60
1092#define ID_AA64ISAR1_LS64_WIDTH 4
9981093#define ID_AA64ISAR1_LS64_MASK (UL(0xf) << ID_AA64ISAR1_LS64_SHIFT)
9991094#define ID_AA64ISAR1_LS64_VAL(x) ((x) & ID_AA64ISAR1_LS64_MASK)
10001095#define ID_AA64ISAR1_LS64_NONE (UL(0x0) << ID_AA64ISAR1_LS64_SHIFT)
......@@ -1003,29 +1098,33 @@
10031098#define ID_AA64ISAR1_LS64_ACCDATA (UL(0x3) << ID_AA64ISAR1_LS64_SHIFT)
10041099
10051100/* ID_AA64ISAR2_EL1 */
1006#define ID_AA64ISAR2_EL1 MRS_REG(ID_AA64ISAR2_EL1)
10071101#define ID_AA64ISAR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR2_EL1)
1102#define ID_AA64ISAR2_EL1_ISS ISS_MSR_REG(ID_AA64ISAR2_EL1)
10081103#define ID_AA64ISAR2_EL1_op0 3
10091104#define ID_AA64ISAR2_EL1_op1 0
10101105#define ID_AA64ISAR2_EL1_CRn 0
10111106#define ID_AA64ISAR2_EL1_CRm 6
10121107#define ID_AA64ISAR2_EL1_op2 2
10131108#define ID_AA64ISAR2_WFxT_SHIFT 0
1109#define ID_AA64ISAR2_WFxT_WIDTH 4
10141110#define ID_AA64ISAR2_WFxT_MASK (UL(0xf) << ID_AA64ISAR2_WFxT_SHIFT)
10151111#define ID_AA64ISAR2_WFxT_VAL(x) ((x) & ID_AA64ISAR2_WFxT_MASK)
10161112#define ID_AA64ISAR2_WFxT_NONE (UL(0x0) << ID_AA64ISAR2_WFxT_SHIFT)
1017#define ID_AA64ISAR2_WFxT_IMPL (UL(0x1) << ID_AA64ISAR2_WFxT_SHIFT)
1113#define ID_AA64ISAR2_WFxT_IMPL (UL(0x2) << ID_AA64ISAR2_WFxT_SHIFT)
10181114#define ID_AA64ISAR2_RPRES_SHIFT 4
1115#define ID_AA64ISAR2_RPRES_WIDTH 4
10191116#define ID_AA64ISAR2_RPRES_MASK (UL(0xf) << ID_AA64ISAR2_RPRES_SHIFT)
10201117#define ID_AA64ISAR2_RPRES_VAL(x) ((x) & ID_AA64ISAR2_RPRES_MASK)
10211118#define ID_AA64ISAR2_RPRES_NONE (UL(0x0) << ID_AA64ISAR2_RPRES_SHIFT)
10221119#define ID_AA64ISAR2_RPRES_IMPL (UL(0x1) << ID_AA64ISAR2_RPRES_SHIFT)
10231120#define ID_AA64ISAR2_GPA3_SHIFT 8
1121#define ID_AA64ISAR2_GPA3_WIDTH 4
10241122#define ID_AA64ISAR2_GPA3_MASK (UL(0xf) << ID_AA64ISAR2_GPA3_SHIFT)
10251123#define ID_AA64ISAR2_GPA3_VAL(x) ((x) & ID_AA64ISAR2_GPA3_MASK)
10261124#define ID_AA64ISAR2_GPA3_NONE (UL(0x0) << ID_AA64ISAR2_GPA3_SHIFT)
10271125#define ID_AA64ISAR2_GPA3_IMPL (UL(0x1) << ID_AA64ISAR2_GPA3_SHIFT)
10281126#define ID_AA64ISAR2_APA3_SHIFT 12
1127#define ID_AA64ISAR2_APA3_WIDTH 4
10291128#define ID_AA64ISAR2_APA3_MASK (UL(0xf) << ID_AA64ISAR2_APA3_SHIFT)
10301129#define ID_AA64ISAR2_APA3_VAL(x) ((x) & ID_AA64ISAR2_APA3_MASK)
10311130#define ID_AA64ISAR2_APA3_NONE (UL(0x0) << ID_AA64ISAR2_APA3_SHIFT)
......@@ -1035,30 +1134,64 @@
10351134#define ID_AA64ISAR2_APA3_FPAC (UL(0x4) << ID_AA64ISAR2_APA3_SHIFT)
10361135#define ID_AA64ISAR2_APA3_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR2_APA3_SHIFT)
10371136#define ID_AA64ISAR2_MOPS_SHIFT 16
1137#define ID_AA64ISAR2_MOPS_WIDTH 4
10381138#define ID_AA64ISAR2_MOPS_MASK (UL(0xf) << ID_AA64ISAR2_MOPS_SHIFT)
10391139#define ID_AA64ISAR2_MOPS_VAL(x) ((x) & ID_AA64ISAR2_MOPS_MASK)
10401140#define ID_AA64ISAR2_MOPS_NONE (UL(0x0) << ID_AA64ISAR2_MOPS_SHIFT)
10411141#define ID_AA64ISAR2_MOPS_IMPL (UL(0x1) << ID_AA64ISAR2_MOPS_SHIFT)
10421142#define ID_AA64ISAR2_BC_SHIFT 20
1143#define ID_AA64ISAR2_BC_WIDTH 4
10431144#define ID_AA64ISAR2_BC_MASK (UL(0xf) << ID_AA64ISAR2_BC_SHIFT)
10441145#define ID_AA64ISAR2_BC_VAL(x) ((x) & ID_AA64ISAR2_BC_MASK)
10451146#define ID_AA64ISAR2_BC_NONE (UL(0x0) << ID_AA64ISAR2_BC_SHIFT)
10461147#define ID_AA64ISAR2_BC_IMPL (UL(0x1) << ID_AA64ISAR2_BC_SHIFT)
1047#define ID_AA64ISAR2_PAC_frac_SHIFT 28
1148#define ID_AA64ISAR2_PAC_frac_SHIFT 24
1149#define ID_AA64ISAR2_PAC_frac_WIDTH 4
10481150#define ID_AA64ISAR2_PAC_frac_MASK (UL(0xf) << ID_AA64ISAR2_PAC_frac_SHIFT)
10491151#define ID_AA64ISAR2_PAC_frac_VAL(x) ((x) & ID_AA64ISAR2_PAC_frac_MASK)
10501152#define ID_AA64ISAR2_PAC_frac_NONE (UL(0x0) << ID_AA64ISAR2_PAC_frac_SHIFT)
10511153#define ID_AA64ISAR2_PAC_frac_IMPL (UL(0x1) << ID_AA64ISAR2_PAC_frac_SHIFT)
1154#define ID_AA64ISAR2_CLRBHB_SHIFT 28
1155#define ID_AA64ISAR2_CLRBHB_WIDTH 4
1156#define ID_AA64ISAR2_CLRBHB_MASK (UL(0xf) << ID_AA64ISAR2_CLRBHB_SHIFT)
1157#define ID_AA64ISAR2_CLRBHB_VAL(x) ((x) & ID_AA64ISAR2_CLRBHB_MASK)
1158#define ID_AA64ISAR2_CLRBHB_NONE (UL(0x0) << ID_AA64ISAR2_CLRBHB_SHIFT)
1159#define ID_AA64ISAR2_CLRBHB_IMPL (UL(0x1) << ID_AA64ISAR2_CLRBHB_SHIFT)
1160#define ID_AA64ISAR2_PRFMSLC_SHIFT 40
1161#define ID_AA64ISAR2_PRFMSLC_WIDTH 4
1162#define ID_AA64ISAR2_PRFMSLC_MASK (UL(0xf) << ID_AA64ISAR2_PRFMSLC_SHIFT)
1163#define ID_AA64ISAR2_PRFMSLC_VAL(x) ((x) & ID_AA64ISAR2_PRFMSLC_MASK)
1164#define ID_AA64ISAR2_PRFMSLC_NONE (UL(0x0) << ID_AA64ISAR2_PRFMSLC_SHIFT)
1165#define ID_AA64ISAR2_PRFMSLC_IMPL (UL(0x1) << ID_AA64ISAR2_PRFMSLC_SHIFT)
1166#define ID_AA64ISAR2_RPRFM_SHIFT 48
1167#define ID_AA64ISAR2_RPRFM_WIDTH 4
1168#define ID_AA64ISAR2_RPRFM_MASK (UL(0xf) << ID_AA64ISAR2_RPRFM_SHIFT)
1169#define ID_AA64ISAR2_RPRFM_VAL(x) ((x) & ID_AA64ISAR2_RPRFM_MASK)
1170#define ID_AA64ISAR2_RPRFM_NONE (UL(0x0) << ID_AA64ISAR2_RPRFM_SHIFT)
1171#define ID_AA64ISAR2_RPRFM_IMPL (UL(0x1) << ID_AA64ISAR2_RPRFM_SHIFT)
1172#define ID_AA64ISAR2_CSSC_SHIFT 52
1173#define ID_AA64ISAR2_CSSC_WIDTH 4
1174#define ID_AA64ISAR2_CSSC_MASK (UL(0xf) << ID_AA64ISAR2_CSSC_SHIFT)
1175#define ID_AA64ISAR2_CSSC_VAL(x) ((x) & ID_AA64ISAR2_CSSC_MASK)
1176#define ID_AA64ISAR2_CSSC_NONE (UL(0x0) << ID_AA64ISAR2_CSSC_SHIFT)
1177#define ID_AA64ISAR2_CSSC_IMPL (UL(0x1) << ID_AA64ISAR2_CSSC_SHIFT)
1178#define ID_AA64ISAR2_ATS1A_SHIFT 60
1179#define ID_AA64ISAR2_ATS1A_WIDTH 4
1180#define ID_AA64ISAR2_ATS1A_MASK (UL(0xf) << ID_AA64ISAR2_ATS1A_SHIFT)
1181#define ID_AA64ISAR2_ATS1A_VAL(x) ((x) & ID_AA64ISAR2_ATS1A_MASK)
1182#define ID_AA64ISAR2_ATS1A_NONE (UL(0x0) << ID_AA64ISAR2_ATS1A_SHIFT)
1183#define ID_AA64ISAR2_ATS1A_IMPL (UL(0x1) << ID_AA64ISAR2_ATS1A_SHIFT)
10521184
10531185/* ID_AA64MMFR0_EL1 */
1054#define ID_AA64MMFR0_EL1 MRS_REG(ID_AA64MMFR0_EL1)
10551186#define ID_AA64MMFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR0_EL1)
1187#define ID_AA64MMFR0_EL1_ISS ISS_MSR_REG(ID_AA64MMFR0_EL1)
10561188#define ID_AA64MMFR0_EL1_op0 3
10571189#define ID_AA64MMFR0_EL1_op1 0
10581190#define ID_AA64MMFR0_EL1_CRn 0
10591191#define ID_AA64MMFR0_EL1_CRm 7
10601192#define ID_AA64MMFR0_EL1_op2 0
10611193#define ID_AA64MMFR0_PARange_SHIFT 0
1194#define ID_AA64MMFR0_PARange_WIDTH 4
10621195#define ID_AA64MMFR0_PARange_MASK (UL(0xf) << ID_AA64MMFR0_PARange_SHIFT)
10631196#define ID_AA64MMFR0_PARange_VAL(x) ((x) & ID_AA64MMFR0_PARange_MASK)
10641197#define ID_AA64MMFR0_PARange_4G (UL(0x0) << ID_AA64MMFR0_PARange_SHIFT)
......@@ -1069,43 +1202,51 @@
10691202#define ID_AA64MMFR0_PARange_256T (UL(0x5) << ID_AA64MMFR0_PARange_SHIFT)
10701203#define ID_AA64MMFR0_PARange_4P (UL(0x6) << ID_AA64MMFR0_PARange_SHIFT)
10711204#define ID_AA64MMFR0_ASIDBits_SHIFT 4
1205#define ID_AA64MMFR0_ASIDBits_WIDTH 4
10721206#define ID_AA64MMFR0_ASIDBits_MASK (UL(0xf) << ID_AA64MMFR0_ASIDBits_SHIFT)
10731207#define ID_AA64MMFR0_ASIDBits_VAL(x) ((x) & ID_AA64MMFR0_ASIDBits_MASK)
10741208#define ID_AA64MMFR0_ASIDBits_8 (UL(0x0) << ID_AA64MMFR0_ASIDBits_SHIFT)
10751209#define ID_AA64MMFR0_ASIDBits_16 (UL(0x2) << ID_AA64MMFR0_ASIDBits_SHIFT)
10761210#define ID_AA64MMFR0_BigEnd_SHIFT 8
1211#define ID_AA64MMFR0_BigEnd_WIDTH 4
10771212#define ID_AA64MMFR0_BigEnd_MASK (UL(0xf) << ID_AA64MMFR0_BigEnd_SHIFT)
10781213#define ID_AA64MMFR0_BigEnd_VAL(x) ((x) & ID_AA64MMFR0_BigEnd_MASK)
10791214#define ID_AA64MMFR0_BigEnd_FIXED (UL(0x0) << ID_AA64MMFR0_BigEnd_SHIFT)
10801215#define ID_AA64MMFR0_BigEnd_MIXED (UL(0x1) << ID_AA64MMFR0_BigEnd_SHIFT)
10811216#define ID_AA64MMFR0_SNSMem_SHIFT 12
1217#define ID_AA64MMFR0_SNSMem_WIDTH 4
10821218#define ID_AA64MMFR0_SNSMem_MASK (UL(0xf) << ID_AA64MMFR0_SNSMem_SHIFT)
10831219#define ID_AA64MMFR0_SNSMem_VAL(x) ((x) & ID_AA64MMFR0_SNSMem_MASK)
10841220#define ID_AA64MMFR0_SNSMem_NONE (UL(0x0) << ID_AA64MMFR0_SNSMem_SHIFT)
10851221#define ID_AA64MMFR0_SNSMem_DISTINCT (UL(0x1) << ID_AA64MMFR0_SNSMem_SHIFT)
10861222#define ID_AA64MMFR0_BigEndEL0_SHIFT 16
1223#define ID_AA64MMFR0_BigEndEL0_WIDTH 4
10871224#define ID_AA64MMFR0_BigEndEL0_MASK (UL(0xf) << ID_AA64MMFR0_BigEndEL0_SHIFT)
10881225#define ID_AA64MMFR0_BigEndEL0_VAL(x) ((x) & ID_AA64MMFR0_BigEndEL0_MASK)
10891226#define ID_AA64MMFR0_BigEndEL0_FIXED (UL(0x0) << ID_AA64MMFR0_BigEndEL0_SHIFT)
10901227#define ID_AA64MMFR0_BigEndEL0_MIXED (UL(0x1) << ID_AA64MMFR0_BigEndEL0_SHIFT)
10911228#define ID_AA64MMFR0_TGran16_SHIFT 20
1229#define ID_AA64MMFR0_TGran16_WIDTH 4
10921230#define ID_AA64MMFR0_TGran16_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_SHIFT)
10931231#define ID_AA64MMFR0_TGran16_VAL(x) ((x) & ID_AA64MMFR0_TGran16_MASK)
10941232#define ID_AA64MMFR0_TGran16_NONE (UL(0x0) << ID_AA64MMFR0_TGran16_SHIFT)
10951233#define ID_AA64MMFR0_TGran16_IMPL (UL(0x1) << ID_AA64MMFR0_TGran16_SHIFT)
10961234#define ID_AA64MMFR0_TGran16_LPA2 (UL(0x2) << ID_AA64MMFR0_TGran16_SHIFT)
10971235#define ID_AA64MMFR0_TGran64_SHIFT 24
1236#define ID_AA64MMFR0_TGran64_WIDTH 4
10981237#define ID_AA64MMFR0_TGran64_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT)
10991238#define ID_AA64MMFR0_TGran64_VAL(x) ((x) & ID_AA64MMFR0_TGran64_MASK)
11001239#define ID_AA64MMFR0_TGran64_IMPL (UL(0x0) << ID_AA64MMFR0_TGran64_SHIFT)
11011240#define ID_AA64MMFR0_TGran64_NONE (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT)
11021241#define ID_AA64MMFR0_TGran4_SHIFT 28
1242#define ID_AA64MMFR0_TGran4_WIDTH 4
11031243#define ID_AA64MMFR0_TGran4_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT)
11041244#define ID_AA64MMFR0_TGran4_VAL(x) ((x) & ID_AA64MMFR0_TGran4_MASK)
11051245#define ID_AA64MMFR0_TGran4_IMPL (UL(0x0) << ID_AA64MMFR0_TGran4_SHIFT)
11061246#define ID_AA64MMFR0_TGran4_LPA2 (UL(0x1) << ID_AA64MMFR0_TGran4_SHIFT)
11071247#define ID_AA64MMFR0_TGran4_NONE (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT)
11081248#define ID_AA64MMFR0_TGran16_2_SHIFT 32
1249#define ID_AA64MMFR0_TGran16_2_WIDTH 4
11091250#define ID_AA64MMFR0_TGran16_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_2_SHIFT)
11101251#define ID_AA64MMFR0_TGran16_2_VAL(x) ((x) & ID_AA64MMFR0_TGran16_2_MASK)
11111252#define ID_AA64MMFR0_TGran16_2_TGran16 (UL(0x0) << ID_AA64MMFR0_TGran16_2_SHIFT)
......@@ -1113,12 +1254,14 @@
11131254#define ID_AA64MMFR0_TGran16_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran16_2_SHIFT)
11141255#define ID_AA64MMFR0_TGran16_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran16_2_SHIFT)
11151256#define ID_AA64MMFR0_TGran64_2_SHIFT 36
1257#define ID_AA64MMFR0_TGran64_2_WIDTH 4
11161258#define ID_AA64MMFR0_TGran64_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_2_SHIFT)
11171259#define ID_AA64MMFR0_TGran64_2_VAL(x) ((x) & ID_AA64MMFR0_TGran64_2_MASK)
11181260#define ID_AA64MMFR0_TGran64_2_TGran64 (UL(0x0) << ID_AA64MMFR0_TGran64_2_SHIFT)
11191261#define ID_AA64MMFR0_TGran64_2_NONE (UL(0x1) << ID_AA64MMFR0_TGran64_2_SHIFT)
11201262#define ID_AA64MMFR0_TGran64_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran64_2_SHIFT)
11211263#define ID_AA64MMFR0_TGran4_2_SHIFT 40
1264#define ID_AA64MMFR0_TGran4_2_WIDTH 4
11221265#define ID_AA64MMFR0_TGran4_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_2_SHIFT)
11231266#define ID_AA64MMFR0_TGran4_2_VAL(x) ((x) & ID_AA64MMFR0_TGran4_2_MASK)
11241267#define ID_AA64MMFR0_TGran4_2_TGran4 (UL(0x0) << ID_AA64MMFR0_TGran4_2_SHIFT)
......@@ -1126,229 +1269,328 @@
11261269#define ID_AA64MMFR0_TGran4_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran4_2_SHIFT)
11271270#define ID_AA64MMFR0_TGran4_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran4_2_SHIFT)
11281271#define ID_AA64MMFR0_ExS_SHIFT 44
1272#define ID_AA64MMFR0_ExS_WIDTH 4
11291273#define ID_AA64MMFR0_ExS_MASK (UL(0xf) << ID_AA64MMFR0_ExS_SHIFT)
11301274#define ID_AA64MMFR0_ExS_VAL(x) ((x) & ID_AA64MMFR0_ExS_MASK)
11311275#define ID_AA64MMFR0_ExS_ALL (UL(0x0) << ID_AA64MMFR0_ExS_SHIFT)
11321276#define ID_AA64MMFR0_ExS_IMPL (UL(0x1) << ID_AA64MMFR0_ExS_SHIFT)
11331277#define ID_AA64MMFR0_FGT_SHIFT 56
1278#define ID_AA64MMFR0_FGT_WIDTH 4
11341279#define ID_AA64MMFR0_FGT_MASK (UL(0xf) << ID_AA64MMFR0_FGT_SHIFT)
11351280#define ID_AA64MMFR0_FGT_VAL(x) ((x) & ID_AA64MMFR0_FGT_MASK)
11361281#define ID_AA64MMFR0_FGT_NONE (UL(0x0) << ID_AA64MMFR0_FGT_SHIFT)
1137#define ID_AA64MMFR0_FGT_IMPL (UL(0x1) << ID_AA64MMFR0_FGT_SHIFT)
1282#define ID_AA64MMFR0_FGT_8_6 (UL(0x1) << ID_AA64MMFR0_FGT_SHIFT)
1283#define ID_AA64MMFR0_FGT_8_9 (UL(0x2) << ID_AA64MMFR0_FGT_SHIFT)
11381284#define ID_AA64MMFR0_ECV_SHIFT 60
1285#define ID_AA64MMFR0_ECV_WIDTH 4
11391286#define ID_AA64MMFR0_ECV_MASK (UL(0xf) << ID_AA64MMFR0_ECV_SHIFT)
11401287#define ID_AA64MMFR0_ECV_VAL(x) ((x) & ID_AA64MMFR0_ECV_MASK)
11411288#define ID_AA64MMFR0_ECV_NONE (UL(0x0) << ID_AA64MMFR0_ECV_SHIFT)
11421289#define ID_AA64MMFR0_ECV_IMPL (UL(0x1) << ID_AA64MMFR0_ECV_SHIFT)
1143#define ID_AA64MMFR0_ECV_CNTHCTL (UL(0x2) << ID_AA64MMFR0_ECV_SHIFT)
1290#define ID_AA64MMFR0_ECV_POFF (UL(0x2) << ID_AA64MMFR0_ECV_SHIFT)
11441291
11451292/* ID_AA64MMFR1_EL1 */
1146#define ID_AA64MMFR1_EL1 MRS_REG(ID_AA64MMFR1_EL1)
11471293#define ID_AA64MMFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR1_EL1)
1294#define ID_AA64MMFR1_EL1_ISS ISS_MSR_REG(ID_AA64MMFR1_EL1)
11481295#define ID_AA64MMFR1_EL1_op0 3
11491296#define ID_AA64MMFR1_EL1_op1 0
11501297#define ID_AA64MMFR1_EL1_CRn 0
11511298#define ID_AA64MMFR1_EL1_CRm 7
11521299#define ID_AA64MMFR1_EL1_op2 1
11531300#define ID_AA64MMFR1_HAFDBS_SHIFT 0
1301#define ID_AA64MMFR1_HAFDBS_WIDTH 4
11541302#define ID_AA64MMFR1_HAFDBS_MASK (UL(0xf) << ID_AA64MMFR1_HAFDBS_SHIFT)
11551303#define ID_AA64MMFR1_HAFDBS_VAL(x) ((x) & ID_AA64MMFR1_HAFDBS_MASK)
11561304#define ID_AA64MMFR1_HAFDBS_NONE (UL(0x0) << ID_AA64MMFR1_HAFDBS_SHIFT)
11571305#define ID_AA64MMFR1_HAFDBS_AF (UL(0x1) << ID_AA64MMFR1_HAFDBS_SHIFT)
11581306#define ID_AA64MMFR1_HAFDBS_AF_DBS (UL(0x2) << ID_AA64MMFR1_HAFDBS_SHIFT)
11591307#define ID_AA64MMFR1_VMIDBits_SHIFT 4
1308#define ID_AA64MMFR1_VMIDBits_WIDTH 4
11601309#define ID_AA64MMFR1_VMIDBits_MASK (UL(0xf) << ID_AA64MMFR1_VMIDBits_SHIFT)
11611310#define ID_AA64MMFR1_VMIDBits_VAL(x) ((x) & ID_AA64MMFR1_VMIDBits_MASK)
11621311#define ID_AA64MMFR1_VMIDBits_8 (UL(0x0) << ID_AA64MMFR1_VMIDBits_SHIFT)
11631312#define ID_AA64MMFR1_VMIDBits_16 (UL(0x2) << ID_AA64MMFR1_VMIDBits_SHIFT)
11641313#define ID_AA64MMFR1_VH_SHIFT 8
1314#define ID_AA64MMFR1_VH_WIDTH 4
11651315#define ID_AA64MMFR1_VH_MASK (UL(0xf) << ID_AA64MMFR1_VH_SHIFT)
11661316#define ID_AA64MMFR1_VH_VAL(x) ((x) & ID_AA64MMFR1_VH_MASK)
11671317#define ID_AA64MMFR1_VH_NONE (UL(0x0) << ID_AA64MMFR1_VH_SHIFT)
11681318#define ID_AA64MMFR1_VH_IMPL (UL(0x1) << ID_AA64MMFR1_VH_SHIFT)
11691319#define ID_AA64MMFR1_HPDS_SHIFT 12
1320#define ID_AA64MMFR1_HPDS_WIDTH 4
11701321#define ID_AA64MMFR1_HPDS_MASK (UL(0xf) << ID_AA64MMFR1_HPDS_SHIFT)
11711322#define ID_AA64MMFR1_HPDS_VAL(x) ((x) & ID_AA64MMFR1_HPDS_MASK)
11721323#define ID_AA64MMFR1_HPDS_NONE (UL(0x0) << ID_AA64MMFR1_HPDS_SHIFT)
11731324#define ID_AA64MMFR1_HPDS_HPD (UL(0x1) << ID_AA64MMFR1_HPDS_SHIFT)
11741325#define ID_AA64MMFR1_HPDS_TTPBHA (UL(0x2) << ID_AA64MMFR1_HPDS_SHIFT)
11751326#define ID_AA64MMFR1_LO_SHIFT 16
1327#define ID_AA64MMFR1_LO_WIDTH 4
11761328#define ID_AA64MMFR1_LO_MASK (UL(0xf) << ID_AA64MMFR1_LO_SHIFT)
11771329#define ID_AA64MMFR1_LO_VAL(x) ((x) & ID_AA64MMFR1_LO_MASK)
11781330#define ID_AA64MMFR1_LO_NONE (UL(0x0) << ID_AA64MMFR1_LO_SHIFT)
11791331#define ID_AA64MMFR1_LO_IMPL (UL(0x1) << ID_AA64MMFR1_LO_SHIFT)
11801332#define ID_AA64MMFR1_PAN_SHIFT 20
1333#define ID_AA64MMFR1_PAN_WIDTH 4
11811334#define ID_AA64MMFR1_PAN_MASK (UL(0xf) << ID_AA64MMFR1_PAN_SHIFT)
11821335#define ID_AA64MMFR1_PAN_VAL(x) ((x) & ID_AA64MMFR1_PAN_MASK)
11831336#define ID_AA64MMFR1_PAN_NONE (UL(0x0) << ID_AA64MMFR1_PAN_SHIFT)
11841337#define ID_AA64MMFR1_PAN_IMPL (UL(0x1) << ID_AA64MMFR1_PAN_SHIFT)
11851338#define ID_AA64MMFR1_PAN_ATS1E1 (UL(0x2) << ID_AA64MMFR1_PAN_SHIFT)
1186#define ID_AA64MMFR1_PAN_EPAN (UL(0x2) << ID_AA64MMFR1_PAN_SHIFT)
1339#define ID_AA64MMFR1_PAN_EPAN (UL(0x3) << ID_AA64MMFR1_PAN_SHIFT)
11871340#define ID_AA64MMFR1_SpecSEI_SHIFT 24
1341#define ID_AA64MMFR1_SpecSEI_WIDTH 4
11881342#define ID_AA64MMFR1_SpecSEI_MASK (UL(0xf) << ID_AA64MMFR1_SpecSEI_SHIFT)
11891343#define ID_AA64MMFR1_SpecSEI_VAL(x) ((x) & ID_AA64MMFR1_SpecSEI_MASK)
11901344#define ID_AA64MMFR1_SpecSEI_NONE (UL(0x0) << ID_AA64MMFR1_SpecSEI_SHIFT)
11911345#define ID_AA64MMFR1_SpecSEI_IMPL (UL(0x1) << ID_AA64MMFR1_SpecSEI_SHIFT)
11921346#define ID_AA64MMFR1_XNX_SHIFT 28
1347#define ID_AA64MMFR1_XNX_WIDTH 4
11931348#define ID_AA64MMFR1_XNX_MASK (UL(0xf) << ID_AA64MMFR1_XNX_SHIFT)
11941349#define ID_AA64MMFR1_XNX_VAL(x) ((x) & ID_AA64MMFR1_XNX_MASK)
11951350#define ID_AA64MMFR1_XNX_NONE (UL(0x0) << ID_AA64MMFR1_XNX_SHIFT)
11961351#define ID_AA64MMFR1_XNX_IMPL (UL(0x1) << ID_AA64MMFR1_XNX_SHIFT)
11971352#define ID_AA64MMFR1_TWED_SHIFT 32
1353#define ID_AA64MMFR1_TWED_WIDTH 4
11981354#define ID_AA64MMFR1_TWED_MASK (UL(0xf) << ID_AA64MMFR1_TWED_SHIFT)
11991355#define ID_AA64MMFR1_TWED_VAL(x) ((x) & ID_AA64MMFR1_TWED_MASK)
12001356#define ID_AA64MMFR1_TWED_NONE (UL(0x0) << ID_AA64MMFR1_TWED_SHIFT)
12011357#define ID_AA64MMFR1_TWED_IMPL (UL(0x1) << ID_AA64MMFR1_TWED_SHIFT)
12021358#define ID_AA64MMFR1_ETS_SHIFT 36
1359#define ID_AA64MMFR1_ETS_WIDTH 4
12031360#define ID_AA64MMFR1_ETS_MASK (UL(0xf) << ID_AA64MMFR1_ETS_SHIFT)
12041361#define ID_AA64MMFR1_ETS_VAL(x) ((x) & ID_AA64MMFR1_ETS_MASK)
12051362#define ID_AA64MMFR1_ETS_NONE (UL(0x0) << ID_AA64MMFR1_ETS_SHIFT)
1206#define ID_AA64MMFR1_ETS_IMPL (UL(0x1) << ID_AA64MMFR1_ETS_SHIFT)
1363#define ID_AA64MMFR1_ETS_NONE2 (UL(0x1) << ID_AA64MMFR1_ETS_SHIFT)
1364#define ID_AA64MMFR1_ETS_IMPL (UL(0x2) << ID_AA64MMFR1_ETS_SHIFT)
12071365#define ID_AA64MMFR1_HCX_SHIFT 40
1366#define ID_AA64MMFR1_HCX_WIDTH 4
12081367#define ID_AA64MMFR1_HCX_MASK (UL(0xf) << ID_AA64MMFR1_HCX_SHIFT)
12091368#define ID_AA64MMFR1_HCX_VAL(x) ((x) & ID_AA64MMFR1_HCX_MASK)
12101369#define ID_AA64MMFR1_HCX_NONE (UL(0x0) << ID_AA64MMFR1_HCX_SHIFT)
12111370#define ID_AA64MMFR1_HCX_IMPL (UL(0x1) << ID_AA64MMFR1_HCX_SHIFT)
12121371#define ID_AA64MMFR1_AFP_SHIFT 44
1372#define ID_AA64MMFR1_AFP_WIDTH 4
12131373#define ID_AA64MMFR1_AFP_MASK (UL(0xf) << ID_AA64MMFR1_AFP_SHIFT)
12141374#define ID_AA64MMFR1_AFP_VAL(x) ((x) & ID_AA64MMFR1_AFP_MASK)
12151375#define ID_AA64MMFR1_AFP_NONE (UL(0x0) << ID_AA64MMFR1_AFP_SHIFT)
12161376#define ID_AA64MMFR1_AFP_IMPL (UL(0x1) << ID_AA64MMFR1_AFP_SHIFT)
12171377#define ID_AA64MMFR1_nTLBPA_SHIFT 48
1378#define ID_AA64MMFR1_nTLBPA_WIDTH 4
12181379#define ID_AA64MMFR1_nTLBPA_MASK (UL(0xf) << ID_AA64MMFR1_nTLBPA_SHIFT)
12191380#define ID_AA64MMFR1_nTLBPA_VAL(x) ((x) & ID_AA64MMFR1_nTLBPA_MASK)
12201381#define ID_AA64MMFR1_nTLBPA_NONE (UL(0x0) << ID_AA64MMFR1_nTLBPA_SHIFT)
12211382#define ID_AA64MMFR1_nTLBPA_IMPL (UL(0x1) << ID_AA64MMFR1_nTLBPA_SHIFT)
12221383#define ID_AA64MMFR1_TIDCP1_SHIFT 52
1384#define ID_AA64MMFR1_TIDCP1_WIDTH 4
12231385#define ID_AA64MMFR1_TIDCP1_MASK (UL(0xf) << ID_AA64MMFR1_TIDCP1_SHIFT)
12241386#define ID_AA64MMFR1_TIDCP1_VAL(x) ((x) & ID_AA64MMFR1_TIDCP1_MASK)
12251387#define ID_AA64MMFR1_TIDCP1_NONE (UL(0x0) << ID_AA64MMFR1_TIDCP1_SHIFT)
12261388#define ID_AA64MMFR1_TIDCP1_IMPL (UL(0x1) << ID_AA64MMFR1_TIDCP1_SHIFT)
12271389#define ID_AA64MMFR1_CMOVW_SHIFT 56
1390#define ID_AA64MMFR1_CMOVW_WIDTH 4
12281391#define ID_AA64MMFR1_CMOVW_MASK (UL(0xf) << ID_AA64MMFR1_CMOVW_SHIFT)
12291392#define ID_AA64MMFR1_CMOVW_VAL(x) ((x) & ID_AA64MMFR1_CMOVW_MASK)
12301393#define ID_AA64MMFR1_CMOVW_NONE (UL(0x0) << ID_AA64MMFR1_CMOVW_SHIFT)
12311394#define ID_AA64MMFR1_CMOVW_IMPL (UL(0x1) << ID_AA64MMFR1_CMOVW_SHIFT)
1395#define ID_AA64MMFR1_ECBHB_SHIFT 60
1396#define ID_AA64MMFR1_ECBHB_WIDTH 4
1397#define ID_AA64MMFR1_ECBHB_MASK (UL(0xf) << ID_AA64MMFR1_ECBHB_SHIFT)
1398#define ID_AA64MMFR1_ECBHB_VAL(x) ((x) & ID_AA64MMFR1_ECBHB_MASK)
1399#define ID_AA64MMFR1_ECBHB_NONE (UL(0x0) << ID_AA64MMFR1_ECBHB_SHIFT)
1400#define ID_AA64MMFR1_ECBHB_IMPL (UL(0x1) << ID_AA64MMFR1_ECBHB_SHIFT)
12321401
12331402/* ID_AA64MMFR2_EL1 */
1234#define ID_AA64MMFR2_EL1 MRS_REG(ID_AA64MMFR2_EL1)
12351403#define ID_AA64MMFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR2_EL1)
1404#define ID_AA64MMFR2_EL1_ISS ISS_MSR_REG(ID_AA64MMFR2_EL1)
12361405#define ID_AA64MMFR2_EL1_op0 3
12371406#define ID_AA64MMFR2_EL1_op1 0
12381407#define ID_AA64MMFR2_EL1_CRn 0
12391408#define ID_AA64MMFR2_EL1_CRm 7
12401409#define ID_AA64MMFR2_EL1_op2 2
12411410#define ID_AA64MMFR2_CnP_SHIFT 0
1411#define ID_AA64MMFR2_CnP_WIDTH 4
12421412#define ID_AA64MMFR2_CnP_MASK (UL(0xf) << ID_AA64MMFR2_CnP_SHIFT)
12431413#define ID_AA64MMFR2_CnP_VAL(x) ((x) & ID_AA64MMFR2_CnP_MASK)
12441414#define ID_AA64MMFR2_CnP_NONE (UL(0x0) << ID_AA64MMFR2_CnP_SHIFT)
12451415#define ID_AA64MMFR2_CnP_IMPL (UL(0x1) << ID_AA64MMFR2_CnP_SHIFT)
12461416#define ID_AA64MMFR2_UAO_SHIFT 4
1417#define ID_AA64MMFR2_UAO_WIDTH 4
12471418#define ID_AA64MMFR2_UAO_MASK (UL(0xf) << ID_AA64MMFR2_UAO_SHIFT)
12481419#define ID_AA64MMFR2_UAO_VAL(x) ((x) & ID_AA64MMFR2_UAO_MASK)
12491420#define ID_AA64MMFR2_UAO_NONE (UL(0x0) << ID_AA64MMFR2_UAO_SHIFT)
12501421#define ID_AA64MMFR2_UAO_IMPL (UL(0x1) << ID_AA64MMFR2_UAO_SHIFT)
12511422#define ID_AA64MMFR2_LSM_SHIFT 8
1423#define ID_AA64MMFR2_LSM_WIDTH 4
12521424#define ID_AA64MMFR2_LSM_MASK (UL(0xf) << ID_AA64MMFR2_LSM_SHIFT)
12531425#define ID_AA64MMFR2_LSM_VAL(x) ((x) & ID_AA64MMFR2_LSM_MASK)
12541426#define ID_AA64MMFR2_LSM_NONE (UL(0x0) << ID_AA64MMFR2_LSM_SHIFT)
12551427#define ID_AA64MMFR2_LSM_IMPL (UL(0x1) << ID_AA64MMFR2_LSM_SHIFT)
12561428#define ID_AA64MMFR2_IESB_SHIFT 12
1429#define ID_AA64MMFR2_IESB_WIDTH 4
12571430#define ID_AA64MMFR2_IESB_MASK (UL(0xf) << ID_AA64MMFR2_IESB_SHIFT)
12581431#define ID_AA64MMFR2_IESB_VAL(x) ((x) & ID_AA64MMFR2_IESB_MASK)
12591432#define ID_AA64MMFR2_IESB_NONE (UL(0x0) << ID_AA64MMFR2_IESB_SHIFT)
12601433#define ID_AA64MMFR2_IESB_IMPL (UL(0x1) << ID_AA64MMFR2_IESB_SHIFT)
12611434#define ID_AA64MMFR2_VARange_SHIFT 16
1435#define ID_AA64MMFR2_VARange_WIDTH 4
12621436#define ID_AA64MMFR2_VARange_MASK (UL(0xf) << ID_AA64MMFR2_VARange_SHIFT)
12631437#define ID_AA64MMFR2_VARange_VAL(x) ((x) & ID_AA64MMFR2_VARange_MASK)
12641438#define ID_AA64MMFR2_VARange_48 (UL(0x0) << ID_AA64MMFR2_VARange_SHIFT)
12651439#define ID_AA64MMFR2_VARange_52 (UL(0x1) << ID_AA64MMFR2_VARange_SHIFT)
12661440#define ID_AA64MMFR2_CCIDX_SHIFT 20
1441#define ID_AA64MMFR2_CCIDX_WIDTH 4
12671442#define ID_AA64MMFR2_CCIDX_MASK (UL(0xf) << ID_AA64MMFR2_CCIDX_SHIFT)
12681443#define ID_AA64MMFR2_CCIDX_VAL(x) ((x) & ID_AA64MMFR2_CCIDX_MASK)
12691444#define ID_AA64MMFR2_CCIDX_32 (UL(0x0) << ID_AA64MMFR2_CCIDX_SHIFT)
12701445#define ID_AA64MMFR2_CCIDX_64 (UL(0x1) << ID_AA64MMFR2_CCIDX_SHIFT)
12711446#define ID_AA64MMFR2_NV_SHIFT 24
1447#define ID_AA64MMFR2_NV_WIDTH 4
12721448#define ID_AA64MMFR2_NV_MASK (UL(0xf) << ID_AA64MMFR2_NV_SHIFT)
12731449#define ID_AA64MMFR2_NV_VAL(x) ((x) & ID_AA64MMFR2_NV_MASK)
12741450#define ID_AA64MMFR2_NV_NONE (UL(0x0) << ID_AA64MMFR2_NV_SHIFT)
12751451#define ID_AA64MMFR2_NV_8_3 (UL(0x1) << ID_AA64MMFR2_NV_SHIFT)
12761452#define ID_AA64MMFR2_NV_8_4 (UL(0x2) << ID_AA64MMFR2_NV_SHIFT)
12771453#define ID_AA64MMFR2_ST_SHIFT 28
1454#define ID_AA64MMFR2_ST_WIDTH 4
12781455#define ID_AA64MMFR2_ST_MASK (UL(0xf) << ID_AA64MMFR2_ST_SHIFT)
12791456#define ID_AA64MMFR2_ST_VAL(x) ((x) & ID_AA64MMFR2_ST_MASK)
12801457#define ID_AA64MMFR2_ST_NONE (UL(0x0) << ID_AA64MMFR2_ST_SHIFT)
12811458#define ID_AA64MMFR2_ST_IMPL (UL(0x1) << ID_AA64MMFR2_ST_SHIFT)
12821459#define ID_AA64MMFR2_AT_SHIFT 32
1460#define ID_AA64MMFR2_AT_WIDTH 4
12831461#define ID_AA64MMFR2_AT_MASK (UL(0xf) << ID_AA64MMFR2_AT_SHIFT)
12841462#define ID_AA64MMFR2_AT_VAL(x) ((x) & ID_AA64MMFR2_AT_MASK)
12851463#define ID_AA64MMFR2_AT_NONE (UL(0x0) << ID_AA64MMFR2_AT_SHIFT)
12861464#define ID_AA64MMFR2_AT_IMPL (UL(0x1) << ID_AA64MMFR2_AT_SHIFT)
12871465#define ID_AA64MMFR2_IDS_SHIFT 36
1466#define ID_AA64MMFR2_IDS_WIDTH 4
12881467#define ID_AA64MMFR2_IDS_MASK (UL(0xf) << ID_AA64MMFR2_IDS_SHIFT)
12891468#define ID_AA64MMFR2_IDS_VAL(x) ((x) & ID_AA64MMFR2_IDS_MASK)
12901469#define ID_AA64MMFR2_IDS_NONE (UL(0x0) << ID_AA64MMFR2_IDS_SHIFT)
12911470#define ID_AA64MMFR2_IDS_IMPL (UL(0x1) << ID_AA64MMFR2_IDS_SHIFT)
12921471#define ID_AA64MMFR2_FWB_SHIFT 40
1472#define ID_AA64MMFR2_FWB_WIDTH 4
12931473#define ID_AA64MMFR2_FWB_MASK (UL(0xf) << ID_AA64MMFR2_FWB_SHIFT)
12941474#define ID_AA64MMFR2_FWB_VAL(x) ((x) & ID_AA64MMFR2_FWB_MASK)
12951475#define ID_AA64MMFR2_FWB_NONE (UL(0x0) << ID_AA64MMFR2_FWB_SHIFT)
12961476#define ID_AA64MMFR2_FWB_IMPL (UL(0x1) << ID_AA64MMFR2_FWB_SHIFT)
12971477#define ID_AA64MMFR2_TTL_SHIFT 48
1478#define ID_AA64MMFR2_TTL_WIDTH 4
12981479#define ID_AA64MMFR2_TTL_MASK (UL(0xf) << ID_AA64MMFR2_TTL_SHIFT)
12991480#define ID_AA64MMFR2_TTL_VAL(x) ((x) & ID_AA64MMFR2_TTL_MASK)
13001481#define ID_AA64MMFR2_TTL_NONE (UL(0x0) << ID_AA64MMFR2_TTL_SHIFT)
13011482#define ID_AA64MMFR2_TTL_IMPL (UL(0x1) << ID_AA64MMFR2_TTL_SHIFT)
13021483#define ID_AA64MMFR2_BBM_SHIFT 52
1484#define ID_AA64MMFR2_BBM_WIDTH 4
13031485#define ID_AA64MMFR2_BBM_MASK (UL(0xf) << ID_AA64MMFR2_BBM_SHIFT)
13041486#define ID_AA64MMFR2_BBM_VAL(x) ((x) & ID_AA64MMFR2_BBM_MASK)
13051487#define ID_AA64MMFR2_BBM_LEVEL0 (UL(0x0) << ID_AA64MMFR2_BBM_SHIFT)
13061488#define ID_AA64MMFR2_BBM_LEVEL1 (UL(0x1) << ID_AA64MMFR2_BBM_SHIFT)
13071489#define ID_AA64MMFR2_BBM_LEVEL2 (UL(0x2) << ID_AA64MMFR2_BBM_SHIFT)
13081490#define ID_AA64MMFR2_EVT_SHIFT 56
1491#define ID_AA64MMFR2_EVT_WIDTH 4
13091492#define ID_AA64MMFR2_EVT_MASK (UL(0xf) << ID_AA64MMFR2_EVT_SHIFT)
13101493#define ID_AA64MMFR2_EVT_VAL(x) ((x) & ID_AA64MMFR2_EVT_MASK)
13111494#define ID_AA64MMFR2_EVT_NONE (UL(0x0) << ID_AA64MMFR2_EVT_SHIFT)
13121495#define ID_AA64MMFR2_EVT_8_2 (UL(0x1) << ID_AA64MMFR2_EVT_SHIFT)
13131496#define ID_AA64MMFR2_EVT_8_5 (UL(0x2) << ID_AA64MMFR2_EVT_SHIFT)
13141497#define ID_AA64MMFR2_E0PD_SHIFT 60
1498#define ID_AA64MMFR2_E0PD_WIDTH 4
13151499#define ID_AA64MMFR2_E0PD_MASK (UL(0xf) << ID_AA64MMFR2_E0PD_SHIFT)
13161500#define ID_AA64MMFR2_E0PD_VAL(x) ((x) & ID_AA64MMFR2_E0PD_MASK)
13171501#define ID_AA64MMFR2_E0PD_NONE (UL(0x0) << ID_AA64MMFR2_E0PD_SHIFT)
13181502#define ID_AA64MMFR2_E0PD_IMPL (UL(0x1) << ID_AA64MMFR2_E0PD_SHIFT)
13191503
13201504/* ID_AA64MMFR3_EL1 */
1321#define ID_AA64MMFR3_EL1 MRS_REG(ID_AA64MMFR3_EL1)
13221505#define ID_AA64MMFR3_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR3_EL1)
1506#define ID_AA64MMFR3_EL1_ISS ISS_MSR_REG(ID_AA64MMFR3_EL1)
13231507#define ID_AA64MMFR3_EL1_op0 3
13241508#define ID_AA64MMFR3_EL1_op1 0
13251509#define ID_AA64MMFR3_EL1_CRn 0
13261510#define ID_AA64MMFR3_EL1_CRm 7
13271511#define ID_AA64MMFR3_EL1_op2 3
13281512#define ID_AA64MMFR3_TCRX_SHIFT 0
1513#define ID_AA64MMFR3_TCRX_WIDTH 4
13291514#define ID_AA64MMFR3_TCRX_MASK (UL(0xf) << ID_AA64MMFR3_TCRX_SHIFT)
13301515#define ID_AA64MMFR3_TCRX_VAL(x) ((x) & ID_AA64MMFR3_TCRX_MASK)
13311516#define ID_AA64MMFR3_TCRX_NONE (UL(0x0) << ID_AA64MMFR3_TCRX_SHIFT)
13321517#define ID_AA64MMFR3_TCRX_IMPL (UL(0x1) << ID_AA64MMFR3_TCRX_SHIFT)
13331518#define ID_AA64MMFR3_SCTLRX_SHIFT 4
1519#define ID_AA64MMFR3_SCTLRX_WIDTH 4
13341520#define ID_AA64MMFR3_SCTLRX_MASK (UL(0xf) << ID_AA64MMFR3_SCTLRX_SHIFT)
13351521#define ID_AA64MMFR3_SCTLRX_VAL(x) ((x) & ID_AA64MMFR3_SCTLRX_MASK)
13361522#define ID_AA64MMFR3_SCTLRX_NONE (UL(0x0) << ID_AA64MMFR3_SCTLRX_SHIFT)
13371523#define ID_AA64MMFR3_SCTLRX_IMPL (UL(0x1) << ID_AA64MMFR3_SCTLRX_SHIFT)
1524#define ID_AA64MMFR3_S1PIE_SHIFT 8
1525#define ID_AA64MMFR3_S1PIE_WIDTH 4
1526#define ID_AA64MMFR3_S1PIE_MASK (UL(0xf) << ID_AA64MMFR3_S1PIE_SHIFT)
1527#define ID_AA64MMFR3_S1PIE_VAL(x) ((x) & ID_AA64MMFR3_S1PIE_MASK)
1528#define ID_AA64MMFR3_S1PIE_NONE (UL(0x0) << ID_AA64MMFR3_S1PIE_SHIFT)
1529#define ID_AA64MMFR3_S1PIE_IMPL (UL(0x1) << ID_AA64MMFR3_S1PIE_SHIFT)
1530#define ID_AA64MMFR3_S2PIE_SHIFT 12
1531#define ID_AA64MMFR3_S2PIE_WIDTH 4
1532#define ID_AA64MMFR3_S2PIE_MASK (UL(0xf) << ID_AA64MMFR3_S2PIE_SHIFT)
1533#define ID_AA64MMFR3_S2PIE_VAL(x) ((x) & ID_AA64MMFR3_S2PIE_MASK)
1534#define ID_AA64MMFR3_S2PIE_NONE (UL(0x0) << ID_AA64MMFR3_S2PIE_SHIFT)
1535#define ID_AA64MMFR3_S2PIE_IMPL (UL(0x1) << ID_AA64MMFR3_S2PIE_SHIFT)
1536#define ID_AA64MMFR3_S1POE_SHIFT 16
1537#define ID_AA64MMFR3_S1POE_WIDTH 4
1538#define ID_AA64MMFR3_S1POE_MASK (UL(0xf) << ID_AA64MMFR3_S1POE_SHIFT)
1539#define ID_AA64MMFR3_S1POE_VAL(x) ((x) & ID_AA64MMFR3_S1POE_MASK)
1540#define ID_AA64MMFR3_S1POE_NONE (UL(0x0) << ID_AA64MMFR3_S1POE_SHIFT)
1541#define ID_AA64MMFR3_S1POE_IMPL (UL(0x1) << ID_AA64MMFR3_S1POE_SHIFT)
1542#define ID_AA64MMFR3_S2POE_SHIFT 20
1543#define ID_AA64MMFR3_S2POE_WIDTH 4
1544#define ID_AA64MMFR3_S2POE_MASK (UL(0xf) << ID_AA64MMFR3_S2POE_SHIFT)
1545#define ID_AA64MMFR3_S2POE_VAL(x) ((x) & ID_AA64MMFR3_S2POE_MASK)
1546#define ID_AA64MMFR3_S2POE_NONE (UL(0x0) << ID_AA64MMFR3_S2POE_SHIFT)
1547#define ID_AA64MMFR3_S2POE_IMPL (UL(0x1) << ID_AA64MMFR3_S2POE_SHIFT)
1548#define ID_AA64MMFR3_AIE_SHIFT 24
1549#define ID_AA64MMFR3_AIE_WIDTH 4
1550#define ID_AA64MMFR3_AIE_MASK (UL(0xf) << ID_AA64MMFR3_AIE_SHIFT)
1551#define ID_AA64MMFR3_AIE_VAL(x) ((x) & ID_AA64MMFR3_AIE_MASK)
1552#define ID_AA64MMFR3_AIE_NONE (UL(0x0) << ID_AA64MMFR3_AIE_SHIFT)
1553#define ID_AA64MMFR3_AIE_IMPL (UL(0x1) << ID_AA64MMFR3_AIE_SHIFT)
13381554#define ID_AA64MMFR3_MEC_SHIFT 28
1555#define ID_AA64MMFR3_MEC_WIDTH 4
13391556#define ID_AA64MMFR3_MEC_MASK (UL(0xf) << ID_AA64MMFR3_MEC_SHIFT)
13401557#define ID_AA64MMFR3_MEC_VAL(x) ((x) & ID_AA64MMFR3_MEC_MASK)
13411558#define ID_AA64MMFR3_MEC_NONE (UL(0x0) << ID_AA64MMFR3_MEC_SHIFT)
13421559#define ID_AA64MMFR3_MEC_IMPL (UL(0x1) << ID_AA64MMFR3_MEC_SHIFT)
1560#define ID_AA64MMFR3_SNERR_SHIFT 40
1561#define ID_AA64MMFR3_SNERR_WIDTH 4
1562#define ID_AA64MMFR3_SNERR_MASK (UL(0xf) << ID_AA64MMFR3_SNERR_SHIFT)
1563#define ID_AA64MMFR3_SNERR_VAL(x) ((x) & ID_AA64MMFR3_SNERR_MASK)
1564#define ID_AA64MMFR3_SNERR_NONE (UL(0x0) << ID_AA64MMFR3_SNERR_SHIFT)
1565#define ID_AA64MMFR3_SNERR_ALL (UL(0x1) << ID_AA64MMFR3_SNERR_SHIFT)
1566#define ID_AA64MMFR3_ANERR_SHIFT 44
1567#define ID_AA64MMFR3_ANERR_WIDTH 4
1568#define ID_AA64MMFR3_ANERR_MASK (UL(0xf) << ID_AA64MMFR3_ANERR_SHIFT)
1569#define ID_AA64MMFR3_ANERR_VAL(x) ((x) & ID_AA64MMFR3_ANERR_MASK)
1570#define ID_AA64MMFR3_ANERR_NONE (UL(0x0) << ID_AA64MMFR3_ANERR_SHIFT)
1571#define ID_AA64MMFR3_ANERR_SOME (UL(0x1) << ID_AA64MMFR3_ANERR_SHIFT)
1572#define ID_AA64MMFR3_SDERR_SHIFT 52
1573#define ID_AA64MMFR3_SDERR_WIDTH 4
1574#define ID_AA64MMFR3_SDERR_MASK (UL(0xf) << ID_AA64MMFR3_SDERR_SHIFT)
1575#define ID_AA64MMFR3_SDERR_VAL(x) ((x) & ID_AA64MMFR3_SDERR_MASK)
1576#define ID_AA64MMFR3_SDERR_NONE (UL(0x0) << ID_AA64MMFR3_SDERR_SHIFT)
1577#define ID_AA64MMFR3_SDERR_ALL (UL(0x1) << ID_AA64MMFR3_SDERR_SHIFT)
1578#define ID_AA64MMFR3_ADERR_SHIFT 56
1579#define ID_AA64MMFR3_ADERR_WIDTH 4
1580#define ID_AA64MMFR3_ADERR_MASK (UL(0xf) << ID_AA64MMFR3_ADERR_SHIFT)
1581#define ID_AA64MMFR3_ADERR_VAL(x) ((x) & ID_AA64MMFR3_ADERR_MASK)
1582#define ID_AA64MMFR3_ADERR_NONE (UL(0x0) << ID_AA64MMFR3_ADERR_SHIFT)
1583#define ID_AA64MMFR3_ADERR_SOME (UL(0x1) << ID_AA64MMFR3_ADERR_SHIFT)
13431584#define ID_AA64MMFR3_Spec_FPACC_SHIFT 60
1585#define ID_AA64MMFR3_Spec_FPACC_WIDTH 4
13441586#define ID_AA64MMFR3_Spec_FPACC_MASK (UL(0xf) << ID_AA64MMFR3_Spec_FPACC_SHIFT)
13451587#define ID_AA64MMFR3_Spec_FPACC_VAL(x) ((x) & ID_AA64MMFR3_Spec_FPACC_MASK)
13461588#define ID_AA64MMFR3_Spec_FPACC_NONE (UL(0x0) << ID_AA64MMFR3_Spec_FPACC_SHIFT)
13471589#define ID_AA64MMFR3_Spec_FPACC_IMPL (UL(0x1) << ID_AA64MMFR3_Spec_FPACC_SHIFT)
13481590
13491591/* ID_AA64MMFR4_EL1 */
1350#define ID_AA64MMFR4_EL1 MRS_REG(ID_AA64MMFR4_EL1)
13511592#define ID_AA64MMFR4_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR4_EL1)
1593#define ID_AA64MMFR4_EL1_ISS ISS_MSR_REG(ID_AA64MMFR4_EL1)
13521594#define ID_AA64MMFR4_EL1_op0 3
13531595#define ID_AA64MMFR4_EL1_op1 0
13541596#define ID_AA64MMFR4_EL1_CRn 0
......@@ -1356,42 +1598,48 @@
13561598#define ID_AA64MMFR4_EL1_op2 4
13571599
13581600/* ID_AA64PFR0_EL1 */
1359#define ID_AA64PFR0_EL1 MRS_REG(ID_AA64PFR0_EL1)
13601601#define ID_AA64PFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR0_EL1)
1602#define ID_AA64PFR0_EL1_ISS ISS_MSR_REG(ID_AA64PFR0_EL1)
13611603#define ID_AA64PFR0_EL1_op0 3
13621604#define ID_AA64PFR0_EL1_op1 0
13631605#define ID_AA64PFR0_EL1_CRn 0
13641606#define ID_AA64PFR0_EL1_CRm 4
13651607#define ID_AA64PFR0_EL1_op2 0
13661608#define ID_AA64PFR0_EL0_SHIFT 0
1609#define ID_AA64PFR0_EL0_WIDTH 4
13671610#define ID_AA64PFR0_EL0_MASK (UL(0xf) << ID_AA64PFR0_EL0_SHIFT)
13681611#define ID_AA64PFR0_EL0_VAL(x) ((x) & ID_AA64PFR0_EL0_MASK)
13691612#define ID_AA64PFR0_EL0_64 (UL(0x1) << ID_AA64PFR0_EL0_SHIFT)
13701613#define ID_AA64PFR0_EL0_64_32 (UL(0x2) << ID_AA64PFR0_EL0_SHIFT)
13711614#define ID_AA64PFR0_EL1_SHIFT 4
1615#define ID_AA64PFR0_EL1_WIDTH 4
13721616#define ID_AA64PFR0_EL1_MASK (UL(0xf) << ID_AA64PFR0_EL1_SHIFT)
13731617#define ID_AA64PFR0_EL1_VAL(x) ((x) & ID_AA64PFR0_EL1_MASK)
13741618#define ID_AA64PFR0_EL1_64 (UL(0x1) << ID_AA64PFR0_EL1_SHIFT)
13751619#define ID_AA64PFR0_EL1_64_32 (UL(0x2) << ID_AA64PFR0_EL1_SHIFT)
13761620#define ID_AA64PFR0_EL2_SHIFT 8
1621#define ID_AA64PFR0_EL2_WIDTH 4
13771622#define ID_AA64PFR0_EL2_MASK (UL(0xf) << ID_AA64PFR0_EL2_SHIFT)
13781623#define ID_AA64PFR0_EL2_VAL(x) ((x) & ID_AA64PFR0_EL2_MASK)
13791624#define ID_AA64PFR0_EL2_NONE (UL(0x0) << ID_AA64PFR0_EL2_SHIFT)
13801625#define ID_AA64PFR0_EL2_64 (UL(0x1) << ID_AA64PFR0_EL2_SHIFT)
13811626#define ID_AA64PFR0_EL2_64_32 (UL(0x2) << ID_AA64PFR0_EL2_SHIFT)
13821627#define ID_AA64PFR0_EL3_SHIFT 12
1628#define ID_AA64PFR0_EL3_WIDTH 4
13831629#define ID_AA64PFR0_EL3_MASK (UL(0xf) << ID_AA64PFR0_EL3_SHIFT)
13841630#define ID_AA64PFR0_EL3_VAL(x) ((x) & ID_AA64PFR0_EL3_MASK)
13851631#define ID_AA64PFR0_EL3_NONE (UL(0x0) << ID_AA64PFR0_EL3_SHIFT)
13861632#define ID_AA64PFR0_EL3_64 (UL(0x1) << ID_AA64PFR0_EL3_SHIFT)
13871633#define ID_AA64PFR0_EL3_64_32 (UL(0x2) << ID_AA64PFR0_EL3_SHIFT)
13881634#define ID_AA64PFR0_FP_SHIFT 16
1635#define ID_AA64PFR0_FP_WIDTH 4
13891636#define ID_AA64PFR0_FP_MASK (UL(0xf) << ID_AA64PFR0_FP_SHIFT)
13901637#define ID_AA64PFR0_FP_VAL(x) ((x) & ID_AA64PFR0_FP_MASK)
13911638#define ID_AA64PFR0_FP_IMPL (UL(0x0) << ID_AA64PFR0_FP_SHIFT)
13921639#define ID_AA64PFR0_FP_HP (UL(0x1) << ID_AA64PFR0_FP_SHIFT)
13931640#define ID_AA64PFR0_FP_NONE (UL(0xf) << ID_AA64PFR0_FP_SHIFT)
13941641#define ID_AA64PFR0_AdvSIMD_SHIFT 20
1642#define ID_AA64PFR0_AdvSIMD_WIDTH 4
13951643#define ID_AA64PFR0_AdvSIMD_MASK (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT)
13961644#define ID_AA64PFR0_AdvSIMD_VAL(x) ((x) & ID_AA64PFR0_AdvSIMD_MASK)
13971645#define ID_AA64PFR0_AdvSIMD_IMPL (UL(0x0) << ID_AA64PFR0_AdvSIMD_SHIFT)
......@@ -1399,49 +1647,59 @@
13991647#define ID_AA64PFR0_AdvSIMD_NONE (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT)
14001648#define ID_AA64PFR0_GIC_BITS 0x4 /* Number of bits in GIC field */
14011649#define ID_AA64PFR0_GIC_SHIFT 24
1650#define ID_AA64PFR0_GIC_WIDTH 4
14021651#define ID_AA64PFR0_GIC_MASK (UL(0xf) << ID_AA64PFR0_GIC_SHIFT)
14031652#define ID_AA64PFR0_GIC_VAL(x) ((x) & ID_AA64PFR0_GIC_MASK)
14041653#define ID_AA64PFR0_GIC_CPUIF_NONE (UL(0x0) << ID_AA64PFR0_GIC_SHIFT)
14051654#define ID_AA64PFR0_GIC_CPUIF_EN (UL(0x1) << ID_AA64PFR0_GIC_SHIFT)
14061655#define ID_AA64PFR0_GIC_CPUIF_4_1 (UL(0x3) << ID_AA64PFR0_GIC_SHIFT)
14071656#define ID_AA64PFR0_RAS_SHIFT 28
1657#define ID_AA64PFR0_RAS_WIDTH 4
14081658#define ID_AA64PFR0_RAS_MASK (UL(0xf) << ID_AA64PFR0_RAS_SHIFT)
14091659#define ID_AA64PFR0_RAS_VAL(x) ((x) & ID_AA64PFR0_RAS_MASK)
14101660#define ID_AA64PFR0_RAS_NONE (UL(0x0) << ID_AA64PFR0_RAS_SHIFT)
14111661#define ID_AA64PFR0_RAS_IMPL (UL(0x1) << ID_AA64PFR0_RAS_SHIFT)
14121662#define ID_AA64PFR0_RAS_8_4 (UL(0x2) << ID_AA64PFR0_RAS_SHIFT)
1663#define ID_AA64PFR0_RAS_8_9 (UL(0x3) << ID_AA64PFR0_RAS_SHIFT)
14131664#define ID_AA64PFR0_SVE_SHIFT 32
1665#define ID_AA64PFR0_SVE_WIDTH 4
14141666#define ID_AA64PFR0_SVE_MASK (UL(0xf) << ID_AA64PFR0_SVE_SHIFT)
14151667#define ID_AA64PFR0_SVE_VAL(x) ((x) & ID_AA64PFR0_SVE_MASK)
14161668#define ID_AA64PFR0_SVE_NONE (UL(0x0) << ID_AA64PFR0_SVE_SHIFT)
14171669#define ID_AA64PFR0_SVE_IMPL (UL(0x1) << ID_AA64PFR0_SVE_SHIFT)
14181670#define ID_AA64PFR0_SEL2_SHIFT 36
1671#define ID_AA64PFR0_SEL2_WIDTH 4
14191672#define ID_AA64PFR0_SEL2_MASK (UL(0xf) << ID_AA64PFR0_SEL2_SHIFT)
14201673#define ID_AA64PFR0_SEL2_VAL(x) ((x) & ID_AA64PFR0_SEL2_MASK)
14211674#define ID_AA64PFR0_SEL2_NONE (UL(0x0) << ID_AA64PFR0_SEL2_SHIFT)
14221675#define ID_AA64PFR0_SEL2_IMPL (UL(0x1) << ID_AA64PFR0_SEL2_SHIFT)
14231676#define ID_AA64PFR0_MPAM_SHIFT 40
1677#define ID_AA64PFR0_MPAM_WIDTH 4
14241678#define ID_AA64PFR0_MPAM_MASK (UL(0xf) << ID_AA64PFR0_MPAM_SHIFT)
14251679#define ID_AA64PFR0_MPAM_VAL(x) ((x) & ID_AA64PFR0_MPAM_MASK)
14261680#define ID_AA64PFR0_MPAM_NONE (UL(0x0) << ID_AA64PFR0_MPAM_SHIFT)
14271681#define ID_AA64PFR0_MPAM_IMPL (UL(0x1) << ID_AA64PFR0_MPAM_SHIFT)
14281682#define ID_AA64PFR0_AMU_SHIFT 44
1683#define ID_AA64PFR0_AMU_WIDTH 4
14291684#define ID_AA64PFR0_AMU_MASK (UL(0xf) << ID_AA64PFR0_AMU_SHIFT)
14301685#define ID_AA64PFR0_AMU_VAL(x) ((x) & ID_AA64PFR0_AMU_MASK)
14311686#define ID_AA64PFR0_AMU_NONE (UL(0x0) << ID_AA64PFR0_AMU_SHIFT)
14321687#define ID_AA64PFR0_AMU_V1 (UL(0x1) << ID_AA64PFR0_AMU_SHIFT)
14331688#define ID_AA64PFR0_AMU_V1_1 (UL(0x2) << ID_AA64PFR0_AMU_SHIFT)
14341689#define ID_AA64PFR0_DIT_SHIFT 48
1690#define ID_AA64PFR0_DIT_WIDTH 4
14351691#define ID_AA64PFR0_DIT_MASK (UL(0xf) << ID_AA64PFR0_DIT_SHIFT)
14361692#define ID_AA64PFR0_DIT_VAL(x) ((x) & ID_AA64PFR0_DIT_MASK)
14371693#define ID_AA64PFR0_DIT_NONE (UL(0x0) << ID_AA64PFR0_DIT_SHIFT)
14381694#define ID_AA64PFR0_DIT_PSTATE (UL(0x1) << ID_AA64PFR0_DIT_SHIFT)
14391695#define ID_AA64PFR0_RME_SHIFT 52
1696#define ID_AA64PFR0_RME_WIDTH 4
14401697#define ID_AA64PFR0_RME_MASK (UL(0xf) << ID_AA64PFR0_RME_SHIFT)
14411698#define ID_AA64PFR0_RME_VAL(x) ((x) & ID_AA64PFR0_RME_MASK)
14421699#define ID_AA64PFR0_RME_NONE (UL(0x0) << ID_AA64PFR0_RME_SHIFT)
14431700#define ID_AA64PFR0_RME_IMPL (UL(0x1) << ID_AA64PFR0_RME_SHIFT)
14441701#define ID_AA64PFR0_CSV2_SHIFT 56
1702#define ID_AA64PFR0_CSV2_WIDTH 4
14451703#define ID_AA64PFR0_CSV2_MASK (UL(0xf) << ID_AA64PFR0_CSV2_SHIFT)
14461704#define ID_AA64PFR0_CSV2_VAL(x) ((x) & ID_AA64PFR0_CSV2_MASK)
14471705#define ID_AA64PFR0_CSV2_NONE (UL(0x0) << ID_AA64PFR0_CSV2_SHIFT)
......@@ -1449,31 +1707,35 @@
14491707#define ID_AA64PFR0_CSV2_SCXTNUM (UL(0x2) << ID_AA64PFR0_CSV2_SHIFT)
14501708#define ID_AA64PFR0_CSV2_3 (UL(0x3) << ID_AA64PFR0_CSV2_SHIFT)
14511709#define ID_AA64PFR0_CSV3_SHIFT 60
1710#define ID_AA64PFR0_CSV3_WIDTH 4
14521711#define ID_AA64PFR0_CSV3_MASK (UL(0xf) << ID_AA64PFR0_CSV3_SHIFT)
14531712#define ID_AA64PFR0_CSV3_VAL(x) ((x) & ID_AA64PFR0_CSV3_MASK)
14541713#define ID_AA64PFR0_CSV3_NONE (UL(0x0) << ID_AA64PFR0_CSV3_SHIFT)
14551714#define ID_AA64PFR0_CSV3_ISOLATED (UL(0x1) << ID_AA64PFR0_CSV3_SHIFT)
14561715
14571716/* ID_AA64PFR1_EL1 */
1458#define ID_AA64PFR1_EL1 MRS_REG(ID_AA64PFR1_EL1)
14591717#define ID_AA64PFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR1_EL1)
1718#define ID_AA64PFR1_EL1_ISS ISS_MSR_REG(ID_AA64PFR1_EL1)
14601719#define ID_AA64PFR1_EL1_op0 3
14611720#define ID_AA64PFR1_EL1_op1 0
14621721#define ID_AA64PFR1_EL1_CRn 0
14631722#define ID_AA64PFR1_EL1_CRm 4
14641723#define ID_AA64PFR1_EL1_op2 1
14651724#define ID_AA64PFR1_BT_SHIFT 0
1725#define ID_AA64PFR1_BT_WIDTH 4
14661726#define ID_AA64PFR1_BT_MASK (UL(0xf) << ID_AA64PFR1_BT_SHIFT)
14671727#define ID_AA64PFR1_BT_VAL(x) ((x) & ID_AA64PFR1_BT_MASK)
14681728#define ID_AA64PFR1_BT_NONE (UL(0x0) << ID_AA64PFR1_BT_SHIFT)
14691729#define ID_AA64PFR1_BT_IMPL (UL(0x1) << ID_AA64PFR1_BT_SHIFT)
14701730#define ID_AA64PFR1_SSBS_SHIFT 4
1731#define ID_AA64PFR1_SSBS_WIDTH 4
14711732#define ID_AA64PFR1_SSBS_MASK (UL(0xf) << ID_AA64PFR1_SSBS_SHIFT)
14721733#define ID_AA64PFR1_SSBS_VAL(x) ((x) & ID_AA64PFR1_SSBS_MASK)
14731734#define ID_AA64PFR1_SSBS_NONE (UL(0x0) << ID_AA64PFR1_SSBS_SHIFT)
14741735#define ID_AA64PFR1_SSBS_PSTATE (UL(0x1) << ID_AA64PFR1_SSBS_SHIFT)
14751736#define ID_AA64PFR1_SSBS_PSTATE_MSR (UL(0x2) << ID_AA64PFR1_SSBS_SHIFT)
14761737#define ID_AA64PFR1_MTE_SHIFT 8
1738#define ID_AA64PFR1_MTE_WIDTH 4
14771739#define ID_AA64PFR1_MTE_MASK (UL(0xf) << ID_AA64PFR1_MTE_SHIFT)
14781740#define ID_AA64PFR1_MTE_VAL(x) ((x) & ID_AA64PFR1_MTE_MASK)
14791741#define ID_AA64PFR1_MTE_NONE (UL(0x0) << ID_AA64PFR1_MTE_SHIFT)
......@@ -1481,41 +1743,77 @@
14811743#define ID_AA64PFR1_MTE_MTE2 (UL(0x2) << ID_AA64PFR1_MTE_SHIFT)
14821744#define ID_AA64PFR1_MTE_MTE3 (UL(0x3) << ID_AA64PFR1_MTE_SHIFT)
14831745#define ID_AA64PFR1_RAS_frac_SHIFT 12
1746#define ID_AA64PFR1_RAS_frac_WIDTH 4
14841747#define ID_AA64PFR1_RAS_frac_MASK (UL(0xf) << ID_AA64PFR1_RAS_frac_SHIFT)
14851748#define ID_AA64PFR1_RAS_frac_VAL(x) ((x) & ID_AA64PFR1_RAS_frac_MASK)
14861749#define ID_AA64PFR1_RAS_frac_p0 (UL(0x0) << ID_AA64PFR1_RAS_frac_SHIFT)
14871750#define ID_AA64PFR1_RAS_frac_p1 (UL(0x1) << ID_AA64PFR1_RAS_frac_SHIFT)
14881751#define ID_AA64PFR1_MPAM_frac_SHIFT 16
1752#define ID_AA64PFR1_MPAM_frac_WIDTH 4
14891753#define ID_AA64PFR1_MPAM_frac_MASK (UL(0xf) << ID_AA64PFR1_MPAM_frac_SHIFT)
14901754#define ID_AA64PFR1_MPAM_frac_VAL(x) ((x) & ID_AA64PFR1_MPAM_frac_MASK)
14911755#define ID_AA64PFR1_MPAM_frac_p0 (UL(0x0) << ID_AA64PFR1_MPAM_frac_SHIFT)
14921756#define ID_AA64PFR1_MPAM_frac_p1 (UL(0x1) << ID_AA64PFR1_MPAM_frac_SHIFT)
14931757#define ID_AA64PFR1_SME_SHIFT 24
1758#define ID_AA64PFR1_SME_WIDTH 4
14941759#define ID_AA64PFR1_SME_MASK (UL(0xf) << ID_AA64PFR1_SME_SHIFT)
14951760#define ID_AA64PFR1_SME_VAL(x) ((x) & ID_AA64PFR1_SME_MASK)
14961761#define ID_AA64PFR1_SME_NONE (UL(0x0) << ID_AA64PFR1_SME_SHIFT)
14971762#define ID_AA64PFR1_SME_SME (UL(0x1) << ID_AA64PFR1_SME_SHIFT)
14981763#define ID_AA64PFR1_SME_SME2 (UL(0x2) << ID_AA64PFR1_SME_SHIFT)
14991764#define ID_AA64PFR1_RNDR_trap_SHIFT 28
1765#define ID_AA64PFR1_RNDR_trap_WIDTH 4
15001766#define ID_AA64PFR1_RNDR_trap_MASK (UL(0xf) << ID_AA64PFR1_RNDR_trap_SHIFT)
15011767#define ID_AA64PFR1_RNDR_trap_VAL(x) ((x) & ID_AA64PFR1_RNDR_trap_MASK)
15021768#define ID_AA64PFR1_RNDR_trap_NONE (UL(0x0) << ID_AA64PFR1_RNDR_trap_SHIFT)
15031769#define ID_AA64PFR1_RNDR_trap_IMPL (UL(0x1) << ID_AA64PFR1_RNDR_trap_SHIFT)
15041770#define ID_AA64PFR1_CSV2_frac_SHIFT 32
1771#define ID_AA64PFR1_CSV2_frac_WIDTH 4
15051772#define ID_AA64PFR1_CSV2_frac_MASK (UL(0xf) << ID_AA64PFR1_CSV2_frac_SHIFT)
15061773#define ID_AA64PFR1_CSV2_frac_VAL(x) ((x) & ID_AA64PFR1_CSV2_frac_MASK)
15071774#define ID_AA64PFR1_CSV2_frac_p0 (UL(0x0) << ID_AA64PFR1_CSV2_frac_SHIFT)
15081775#define ID_AA64PFR1_CSV2_frac_p1 (UL(0x1) << ID_AA64PFR1_CSV2_frac_SHIFT)
15091776#define ID_AA64PFR1_CSV2_frac_p2 (UL(0x2) << ID_AA64PFR1_CSV2_frac_SHIFT)
15101777#define ID_AA64PFR1_NMI_SHIFT 36
1778#define ID_AA64PFR1_NMI_WIDTH 4
15111779#define ID_AA64PFR1_NMI_MASK (UL(0xf) << ID_AA64PFR1_NMI_SHIFT)
15121780#define ID_AA64PFR1_NMI_VAL(x) ((x) & ID_AA64PFR1_NMI_MASK)
15131781#define ID_AA64PFR1_NMI_NONE (UL(0x0) << ID_AA64PFR1_NMI_SHIFT)
15141782#define ID_AA64PFR1_NMI_IMPL (UL(0x1) << ID_AA64PFR1_NMI_SHIFT)
1783#define ID_AA64PFR1_MTE_frac_SHIFT 40
1784#define ID_AA64PFR1_MTE_frac_WIDTH 4
1785#define ID_AA64PFR1_MTE_frac_MASK (UL(0xf) << ID_AA64PFR1_MTE_frac_SHIFT)
1786#define ID_AA64PFR1_MTE_frac_VAL(x) ((x) & ID_AA64PFR1_MTE_frac_MASK)
1787#define ID_AA64PFR1_MTE_frac_IMPL (UL(0x0) << ID_AA64PFR1_MTE_frac_SHIFT)
1788#define ID_AA64PFR1_MTE_frac_NONE (UL(0xf) << ID_AA64PFR1_MTE_frac_SHIFT)
1789#define ID_AA64PFR1_THE_SHIFT 48
1790#define ID_AA64PFR1_THE_WIDTH 4
1791#define ID_AA64PFR1_THE_MASK (UL(0xf) << ID_AA64PFR1_THE_SHIFT)
1792#define ID_AA64PFR1_THE_VAL(x) ((x) & ID_AA64PFR1_THE_MASK)
1793#define ID_AA64PFR1_THE_NONE (UL(0x0) << ID_AA64PFR1_THE_SHIFT)
1794#define ID_AA64PFR1_THE_IMPL (UL(0x1) << ID_AA64PFR1_THE_SHIFT)
1795#define ID_AA64PFR1_MTEX_SHIFT 52
1796#define ID_AA64PFR1_MTEX_WIDTH 4
1797#define ID_AA64PFR1_MTEX_MASK (UL(0xf) << ID_AA64PFR1_MTEX_SHIFT)
1798#define ID_AA64PFR1_MTEX_VAL(x) ((x) & ID_AA64PFR1_MTEX_MASK)
1799#define ID_AA64PFR1_MTEX_NONE (UL(0x0) << ID_AA64PFR1_MTEX_SHIFT)
1800#define ID_AA64PFR1_MTEX_IMPL (UL(0x1) << ID_AA64PFR1_MTEX_SHIFT)
1801#define ID_AA64PFR1_DF2_SHIFT 56
1802#define ID_AA64PFR1_DF2_WIDTH 4
1803#define ID_AA64PFR1_DF2_MASK (UL(0xf) << ID_AA64PFR1_DF2_SHIFT)
1804#define ID_AA64PFR1_DF2_VAL(x) ((x) & ID_AA64PFR1_DF2_MASK)
1805#define ID_AA64PFR1_DF2_NONE (UL(0x0) << ID_AA64PFR1_DF2_SHIFT)
1806#define ID_AA64PFR1_DF2_IMPL (UL(0x1) << ID_AA64PFR1_DF2_SHIFT)
1807#define ID_AA64PFR1_PFAR_SHIFT 60
1808#define ID_AA64PFR1_PFAR_WIDTH 4
1809#define ID_AA64PFR1_PFAR_MASK (UL(0xf) << ID_AA64PFR1_PFAR_SHIFT)
1810#define ID_AA64PFR1_PFAR_VAL(x) ((x) & ID_AA64PFR1_PFAR_MASK)
1811#define ID_AA64PFR1_PFAR_NONE (UL(0x0) << ID_AA64PFR1_PFAR_SHIFT)
1812#define ID_AA64PFR1_PFAR_IMPL (UL(0x1) << ID_AA64PFR1_PFAR_SHIFT)
15151813
15161814/* ID_AA64PFR2_EL1 */
1517#define ID_AA64PFR2_EL1 MRS_REG(ID_AA64PFR2_EL1)
15181815#define ID_AA64PFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR2_EL1)
1816#define ID_AA64PFR2_EL1_ISS ISS_MSR_REG(ID_AA64PFR2_EL1)
15191817#define ID_AA64PFR2_EL1_op0 3
15201818#define ID_AA64PFR2_EL1_op1 0
15211819#define ID_AA64PFR2_EL1_CRn 0
......@@ -1523,101 +1821,117 @@
15231821#define ID_AA64PFR2_EL1_op2 2
15241822
15251823/* ID_AA64ZFR0_EL1 */
1526#define ID_AA64ZFR0_EL1 MRS_REG(ID_AA64ZFR0_EL1)
15271824#define ID_AA64ZFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ZFR0_EL1)
1825#define ID_AA64ZFR0_EL1_ISS ISS_MSR_REG(ID_AA64ZFR0_EL1)
15281826#define ID_AA64ZFR0_EL1_op0 3
15291827#define ID_AA64ZFR0_EL1_op1 0
15301828#define ID_AA64ZFR0_EL1_CRn 0
15311829#define ID_AA64ZFR0_EL1_CRm 4
15321830#define ID_AA64ZFR0_EL1_op2 4
15331831#define ID_AA64ZFR0_SVEver_SHIFT 0
1832#define ID_AA64ZFR0_SVEver_WIDTH 4
15341833#define ID_AA64ZFR0_SVEver_MASK (UL(0xf) << ID_AA64ZFR0_SVEver_SHIFT)
1535#define ID_AA64ZFR0_SVEver_VAL(x) ((x) & ID_AA64ZFR0_SVEver_MASK
1536#define ID_AA64ZFR0_SVEver_SVE1 (UL(0x0) << ID_AA64ZFR0_SVEver_SHIFT)
1537#define ID_AA64ZFR0_SVEver_SVE2 (UL(0x1) << ID_AA64ZFR0_SVEver_SHIFT)
1538#define ID_AA64ZFR0_SVEver_SVE2P1 (UL(0x2) << ID_AA64ZFR0_SVEver_SHIFT)
1834#define ID_AA64ZFR0_SVEver_VAL(x) ((x) & ID_AA64ZFR0_SVEver_MASK)
1835#define ID_AA64ZFR0_SVEver_SVE1 (UL(0x0) << ID_AA64ZFR0_SVEver_SHIFT)
1836#define ID_AA64ZFR0_SVEver_SVE2 (UL(0x1) << ID_AA64ZFR0_SVEver_SHIFT)
1837#define ID_AA64ZFR0_SVEver_SVE2P1 (UL(0x2) << ID_AA64ZFR0_SVEver_SHIFT)
15391838#define ID_AA64ZFR0_AES_SHIFT 4
1839#define ID_AA64ZFR0_AES_WIDTH 4
15401840#define ID_AA64ZFR0_AES_MASK (UL(0xf) << ID_AA64ZFR0_AES_SHIFT)
1541#define ID_AA64ZFR0_AES_VAL(x) ((x) & ID_AA64ZFR0_AES_MASK
1542#define ID_AA64ZFR0_AES_NONE (UL(0x0) << ID_AA64ZFR0_AES_SHIFT)
1543#define ID_AA64ZFR0_AES_BASE (UL(0x1) << ID_AA64ZFR0_AES_SHIFT)
1544#define ID_AA64ZFR0_AES_PMULL (UL(0x2) << ID_AA64ZFR0_AES_SHIFT)
1841#define ID_AA64ZFR0_AES_VAL(x) ((x) & ID_AA64ZFR0_AES_MASK)
1842#define ID_AA64ZFR0_AES_NONE (UL(0x0) << ID_AA64ZFR0_AES_SHIFT)
1843#define ID_AA64ZFR0_AES_BASE (UL(0x1) << ID_AA64ZFR0_AES_SHIFT)
1844#define ID_AA64ZFR0_AES_PMULL (UL(0x2) << ID_AA64ZFR0_AES_SHIFT)
15451845#define ID_AA64ZFR0_BitPerm_SHIFT 16
1846#define ID_AA64ZFR0_BitPerm_WIDTH 4
15461847#define ID_AA64ZFR0_BitPerm_MASK (UL(0xf) << ID_AA64ZFR0_BitPerm_SHIFT)
1547#define ID_AA64ZFR0_BitPerm_VAL(x) ((x) & ID_AA64ZFR0_BitPerm_MASK
1548#define ID_AA64ZFR0_BitPerm_NONE (UL(0x0) << ID_AA64ZFR0_BitPerm_SHIFT)
1549#define ID_AA64ZFR0_BitPerm_IMPL (UL(0x1) << ID_AA64ZFR0_BitPerm_SHIFT)
1848#define ID_AA64ZFR0_BitPerm_VAL(x) ((x) & ID_AA64ZFR0_BitPerm_MASK)
1849#define ID_AA64ZFR0_BitPerm_NONE (UL(0x0) << ID_AA64ZFR0_BitPerm_SHIFT)
1850#define ID_AA64ZFR0_BitPerm_IMPL (UL(0x1) << ID_AA64ZFR0_BitPerm_SHIFT)
15501851#define ID_AA64ZFR0_BF16_SHIFT 20
1852#define ID_AA64ZFR0_BF16_WIDTH 4
15511853#define ID_AA64ZFR0_BF16_MASK (UL(0xf) << ID_AA64ZFR0_BF16_SHIFT)
1552#define ID_AA64ZFR0_BF16_VAL(x) ((x) & ID_AA64ZFR0_BF16_MASK
1553#define ID_AA64ZFR0_BF16_NONE (UL(0x0) << ID_AA64ZFR0_BF16_SHIFT)
1554#define ID_AA64ZFR0_BF16_BASE (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)
1555#define ID_AA64ZFR0_BF16_EBF (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)
1854#define ID_AA64ZFR0_BF16_VAL(x) ((x) & ID_AA64ZFR0_BF16_MASK)
1855#define ID_AA64ZFR0_BF16_NONE (UL(0x0) << ID_AA64ZFR0_BF16_SHIFT)
1856#define ID_AA64ZFR0_BF16_BASE (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)
1857#define ID_AA64ZFR0_BF16_EBF (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)
15561858#define ID_AA64ZFR0_SHA3_SHIFT 32
1859#define ID_AA64ZFR0_SHA3_WIDTH 4
15571860#define ID_AA64ZFR0_SHA3_MASK (UL(0xf) << ID_AA64ZFR0_SHA3_SHIFT)
1558#define ID_AA64ZFR0_SHA3_VAL(x) ((x) & ID_AA64ZFR0_SHA3_MASK
1559#define ID_AA64ZFR0_SHA3_NONE (UL(0x0) << ID_AA64ZFR0_SHA3_SHIFT)
1560#define ID_AA64ZFR0_SHA3_IMPL (UL(0x1) << ID_AA64ZFR0_SHA3_SHIFT)
1861#define ID_AA64ZFR0_SHA3_VAL(x) ((x) & ID_AA64ZFR0_SHA3_MASK)
1862#define ID_AA64ZFR0_SHA3_NONE (UL(0x0) << ID_AA64ZFR0_SHA3_SHIFT)
1863#define ID_AA64ZFR0_SHA3_IMPL (UL(0x1) << ID_AA64ZFR0_SHA3_SHIFT)
15611864#define ID_AA64ZFR0_SM4_SHIFT 40
1865#define ID_AA64ZFR0_SM4_WIDTH 4
15621866#define ID_AA64ZFR0_SM4_MASK (UL(0xf) << ID_AA64ZFR0_SM4_SHIFT)
1563#define ID_AA64ZFR0_SM4_VAL(x) ((x) & ID_AA64ZFR0_SM4_MASK
1564#define ID_AA64ZFR0_SM4_NONE (UL(0x0) << ID_AA64ZFR0_SM4_SHIFT)
1565#define ID_AA64ZFR0_SM4_IMPL (UL(0x1) << ID_AA64ZFR0_SM4_SHIFT)
1867#define ID_AA64ZFR0_SM4_VAL(x) ((x) & ID_AA64ZFR0_SM4_MASK)
1868#define ID_AA64ZFR0_SM4_NONE (UL(0x0) << ID_AA64ZFR0_SM4_SHIFT)
1869#define ID_AA64ZFR0_SM4_IMPL (UL(0x1) << ID_AA64ZFR0_SM4_SHIFT)
15661870#define ID_AA64ZFR0_I8MM_SHIFT 44
1871#define ID_AA64ZFR0_I8MM_WIDTH 4
15671872#define ID_AA64ZFR0_I8MM_MASK (UL(0xf) << ID_AA64ZFR0_I8MM_SHIFT)
1568#define ID_AA64ZFR0_I8MM_VAL(x) ((x) & ID_AA64ZFR0_I8MM_MASK
1569#define ID_AA64ZFR0_I8MM_NONE (UL(0x0) << ID_AA64ZFR0_I8MM_SHIFT)
1570#define ID_AA64ZFR0_I8MM_IMPL (UL(0x1) << ID_AA64ZFR0_I8MM_SHIFT)
1873#define ID_AA64ZFR0_I8MM_VAL(x) ((x) & ID_AA64ZFR0_I8MM_MASK)
1874#define ID_AA64ZFR0_I8MM_NONE (UL(0x0) << ID_AA64ZFR0_I8MM_SHIFT)
1875#define ID_AA64ZFR0_I8MM_IMPL (UL(0x1) << ID_AA64ZFR0_I8MM_SHIFT)
15711876#define ID_AA64ZFR0_F32MM_SHIFT 52
1877#define ID_AA64ZFR0_F32MM_WIDTH 4
15721878#define ID_AA64ZFR0_F32MM_MASK (UL(0xf) << ID_AA64ZFR0_F32MM_SHIFT)
1573#define ID_AA64ZFR0_F32MM_VAL(x) ((x) & ID_AA64ZFR0_F32MM_MASK
1574#define ID_AA64ZFR0_F32MM_NONE (UL(0x0) << ID_AA64ZFR0_F32MM_SHIFT)
1575#define ID_AA64ZFR0_F32MM_IMPL (UL(0x1) << ID_AA64ZFR0_F32MM_SHIFT)
1879#define ID_AA64ZFR0_F32MM_VAL(x) ((x) & ID_AA64ZFR0_F32MM_MASK)
1880#define ID_AA64ZFR0_F32MM_NONE (UL(0x0) << ID_AA64ZFR0_F32MM_SHIFT)
1881#define ID_AA64ZFR0_F32MM_IMPL (UL(0x1) << ID_AA64ZFR0_F32MM_SHIFT)
15761882#define ID_AA64ZFR0_F64MM_SHIFT 56
1883#define ID_AA64ZFR0_F64MM_WIDTH 4
15771884#define ID_AA64ZFR0_F64MM_MASK (UL(0xf) << ID_AA64ZFR0_F64MM_SHIFT)
1578#define ID_AA64ZFR0_F64MM_VAL(x) ((x) & ID_AA64ZFR0_F64MM_MASK
1579#define ID_AA64ZFR0_F64MM_NONE (UL(0x0) << ID_AA64ZFR0_F64MM_SHIFT)
1580#define ID_AA64ZFR0_F64MM_IMPL (UL(0x1) << ID_AA64ZFR0_F64MM_SHIFT)
1885#define ID_AA64ZFR0_F64MM_VAL(x) ((x) & ID_AA64ZFR0_F64MM_MASK)
1886#define ID_AA64ZFR0_F64MM_NONE (UL(0x0) << ID_AA64ZFR0_F64MM_SHIFT)
1887#define ID_AA64ZFR0_F64MM_IMPL (UL(0x1) << ID_AA64ZFR0_F64MM_SHIFT)
15811888
15821889/* ID_ISAR5_EL1 */
1583#define ID_ISAR5_EL1 MRS_REG(ID_ISAR5_EL1)
1890#define ID_ISAR5_EL1_ISS ISS_MSR_REG(ID_ISAR5_EL1)
15841891#define ID_ISAR5_EL1_op0 0x3
15851892#define ID_ISAR5_EL1_op1 0x0
15861893#define ID_ISAR5_EL1_CRn 0x0
15871894#define ID_ISAR5_EL1_CRm 0x2
15881895#define ID_ISAR5_EL1_op2 0x5
15891896#define ID_ISAR5_SEVL_SHIFT 0
1897#define ID_ISAR5_SEVL_WIDTH 4
15901898#define ID_ISAR5_SEVL_MASK (UL(0xf) << ID_ISAR5_SEVL_SHIFT)
15911899#define ID_ISAR5_SEVL_VAL(x) ((x) & ID_ISAR5_SEVL_MASK)
15921900#define ID_ISAR5_SEVL_NOP (UL(0x0) << ID_ISAR5_SEVL_SHIFT)
15931901#define ID_ISAR5_SEVL_IMPL (UL(0x1) << ID_ISAR5_SEVL_SHIFT)
15941902#define ID_ISAR5_AES_SHIFT 4
1903#define ID_ISAR5_AES_WIDTH 4
15951904#define ID_ISAR5_AES_MASK (UL(0xf) << ID_ISAR5_AES_SHIFT)
15961905#define ID_ISAR5_AES_VAL(x) ((x) & ID_ISAR5_AES_MASK)
15971906#define ID_ISAR5_AES_NONE (UL(0x0) << ID_ISAR5_AES_SHIFT)
15981907#define ID_ISAR5_AES_BASE (UL(0x1) << ID_ISAR5_AES_SHIFT)
15991908#define ID_ISAR5_AES_VMULL (UL(0x2) << ID_ISAR5_AES_SHIFT)
16001909#define ID_ISAR5_SHA1_SHIFT 8
1910#define ID_ISAR5_SHA1_WIDTH 4
16011911#define ID_ISAR5_SHA1_MASK (UL(0xf) << ID_ISAR5_SHA1_SHIFT)
16021912#define ID_ISAR5_SHA1_VAL(x) ((x) & ID_ISAR5_SHA1_MASK)
16031913#define ID_ISAR5_SHA1_NONE (UL(0x0) << ID_ISAR5_SHA1_SHIFT)
16041914#define ID_ISAR5_SHA1_IMPL (UL(0x1) << ID_ISAR5_SHA1_SHIFT)
16051915#define ID_ISAR5_SHA2_SHIFT 12
1916#define ID_ISAR5_SHA2_WIDTH 4
16061917#define ID_ISAR5_SHA2_MASK (UL(0xf) << ID_ISAR5_SHA2_SHIFT)
16071918#define ID_ISAR5_SHA2_VAL(x) ((x) & ID_ISAR5_SHA2_MASK)
16081919#define ID_ISAR5_SHA2_NONE (UL(0x0) << ID_ISAR5_SHA2_SHIFT)
16091920#define ID_ISAR5_SHA2_IMPL (UL(0x1) << ID_ISAR5_SHA2_SHIFT)
16101921#define ID_ISAR5_CRC32_SHIFT 16
1922#define ID_ISAR5_CRC32_WIDTH 4
16111923#define ID_ISAR5_CRC32_MASK (UL(0xf) << ID_ISAR5_CRC32_SHIFT)
16121924#define ID_ISAR5_CRC32_VAL(x) ((x) & ID_ISAR5_CRC32_MASK)
16131925#define ID_ISAR5_CRC32_NONE (UL(0x0) << ID_ISAR5_CRC32_SHIFT)
16141926#define ID_ISAR5_CRC32_IMPL (UL(0x1) << ID_ISAR5_CRC32_SHIFT)
16151927#define ID_ISAR5_RDM_SHIFT 24
1928#define ID_ISAR5_RDM_WIDTH 4
16161929#define ID_ISAR5_RDM_MASK (UL(0xf) << ID_ISAR5_RDM_SHIFT)
16171930#define ID_ISAR5_RDM_VAL(x) ((x) & ID_ISAR5_RDM_MASK)
16181931#define ID_ISAR5_RDM_NONE (UL(0x0) << ID_ISAR5_RDM_SHIFT)
16191932#define ID_ISAR5_RDM_IMPL (UL(0x1) << ID_ISAR5_RDM_SHIFT)
16201933#define ID_ISAR5_VCMA_SHIFT 28
1934#define ID_ISAR5_VCMA_WIDTH 4
16211935#define ID_ISAR5_VCMA_MASK (UL(0xf) << ID_ISAR5_VCMA_SHIFT)
16221936#define ID_ISAR5_VCMA_VAL(x) ((x) & ID_ISAR5_VCMA_MASK)
16231937#define ID_ISAR5_VCMA_NONE (UL(0x0) << ID_ISAR5_VCMA_SHIFT)
......@@ -1647,7 +1961,6 @@
16471961#define MAIR_EL12_op2 0
16481962
16491963/* MDCCINT_EL1 */
1650#define MDCCINT_EL1 MRS_REG(MDCCINT_EL1)
16511964#define MDCCINT_EL1_op0 2
16521965#define MDCCINT_EL1_op1 0
16531966#define MDCCINT_EL1_CRn 0
......@@ -1655,7 +1968,6 @@
16551968#define MDCCINT_EL1_op2 0
16561969
16571970/* MDCCSR_EL0 */
1658#define MDCCSR_EL0 MRS_REG(MDCCSR_EL0)
16591971#define MDCCSR_EL0_op0 2
16601972#define MDCCSR_EL0_op1 3
16611973#define MDCCSR_EL0_CRn 0
......@@ -1663,7 +1975,6 @@
16631975#define MDCCSR_EL0_op2 0
16641976
16651977/* MDSCR_EL1 - Monitor Debug System Control Register */
1666#define MDSCR_EL1 MRS_REG(MDSCR_EL1)
16671978#define MDSCR_EL1_op0 2
16681979#define MDSCR_EL1_op1 0
16691980#define MDSCR_EL1_CRn 0
......@@ -1677,7 +1988,6 @@
16771988#define MDSCR_MDE (UL(0x1) << MDSCR_MDE_SHIFT)
16781989
16791990/* MIDR_EL1 - Main ID Register */
1680#define MIDR_EL1 MRS_REG(MIDR_EL1)
16811991#define MIDR_EL1_op0 3
16821992#define MIDR_EL1_op1 0
16831993#define MIDR_EL1_CRn 0
......@@ -1685,7 +1995,6 @@
16851995#define MIDR_EL1_op2 0
16861996
16871997/* MPIDR_EL1 - Multiprocessor Affinity Register */
1688#define MPIDR_EL1 MRS_REG(MPIDR_EL1)
16891998#define MPIDR_EL1_op0 3
16901999#define MPIDR_EL1_op1 0
16912000#define MPIDR_EL1_CRn 0
......@@ -1709,95 +2018,110 @@
17092018#define MPIDR_AFF3_VAL(x) ((x) & MPIDR_AFF3_MASK)
17102019
17112020/* MVFR0_EL1 */
1712#define MVFR0_EL1 MRS_REG(MVFR0_EL1)
2021#define MVFR0_EL1_ISS ISS_MSR_REG(MVFR0_EL1)
17132022#define MVFR0_EL1_op0 0x3
17142023#define MVFR0_EL1_op1 0x0
17152024#define MVFR0_EL1_CRn 0x0
17162025#define MVFR0_EL1_CRm 0x3
17172026#define MVFR0_EL1_op2 0x0
17182027#define MVFR0_SIMDReg_SHIFT 0
2028#define MVFR0_SIMDReg_WIDTH 4
17192029#define MVFR0_SIMDReg_MASK (UL(0xf) << MVFR0_SIMDReg_SHIFT)
17202030#define MVFR0_SIMDReg_VAL(x) ((x) & MVFR0_SIMDReg_MASK)
17212031#define MVFR0_SIMDReg_NONE (UL(0x0) << MVFR0_SIMDReg_SHIFT)
17222032#define MVFR0_SIMDReg_FP (UL(0x1) << MVFR0_SIMDReg_SHIFT)
17232033#define MVFR0_SIMDReg_AdvSIMD (UL(0x2) << MVFR0_SIMDReg_SHIFT)
17242034#define MVFR0_FPSP_SHIFT 4
2035#define MVFR0_FPSP_WIDTH 4
17252036#define MVFR0_FPSP_MASK (UL(0xf) << MVFR0_FPSP_SHIFT)
17262037#define MVFR0_FPSP_VAL(x) ((x) & MVFR0_FPSP_MASK)
17272038#define MVFR0_FPSP_NONE (UL(0x0) << MVFR0_FPSP_SHIFT)
17282039#define MVFR0_FPSP_VFP_v2 (UL(0x1) << MVFR0_FPSP_SHIFT)
17292040#define MVFR0_FPSP_VFP_v3_v4 (UL(0x2) << MVFR0_FPSP_SHIFT)
17302041#define MVFR0_FPDP_SHIFT 8
2042#define MVFR0_FPDP_WIDTH 4
17312043#define MVFR0_FPDP_MASK (UL(0xf) << MVFR0_FPDP_SHIFT)
17322044#define MVFR0_FPDP_VAL(x) ((x) & MVFR0_FPDP_MASK)
17332045#define MVFR0_FPDP_NONE (UL(0x0) << MVFR0_FPDP_SHIFT)
17342046#define MVFR0_FPDP_VFP_v2 (UL(0x1) << MVFR0_FPDP_SHIFT)
17352047#define MVFR0_FPDP_VFP_v3_v4 (UL(0x2) << MVFR0_FPDP_SHIFT)
17362048#define MVFR0_FPTrap_SHIFT 12
2049#define MVFR0_FPTrap_WIDTH 4
17372050#define MVFR0_FPTrap_MASK (UL(0xf) << MVFR0_FPTrap_SHIFT)
17382051#define MVFR0_FPTrap_VAL(x) ((x) & MVFR0_FPTrap_MASK)
17392052#define MVFR0_FPTrap_NONE (UL(0x0) << MVFR0_FPTrap_SHIFT)
17402053#define MVFR0_FPTrap_IMPL (UL(0x1) << MVFR0_FPTrap_SHIFT)
17412054#define MVFR0_FPDivide_SHIFT 16
2055#define MVFR0_FPDivide_WIDTH 4
17422056#define MVFR0_FPDivide_MASK (UL(0xf) << MVFR0_FPDivide_SHIFT)
17432057#define MVFR0_FPDivide_VAL(x) ((x) & MVFR0_FPDivide_MASK)
17442058#define MVFR0_FPDivide_NONE (UL(0x0) << MVFR0_FPDivide_SHIFT)
17452059#define MVFR0_FPDivide_IMPL (UL(0x1) << MVFR0_FPDivide_SHIFT)
17462060#define MVFR0_FPSqrt_SHIFT 20
2061#define MVFR0_FPSqrt_WIDTH 4
17472062#define MVFR0_FPSqrt_MASK (UL(0xf) << MVFR0_FPSqrt_SHIFT)
17482063#define MVFR0_FPSqrt_VAL(x) ((x) & MVFR0_FPSqrt_MASK)
17492064#define MVFR0_FPSqrt_NONE (UL(0x0) << MVFR0_FPSqrt_SHIFT)
17502065#define MVFR0_FPSqrt_IMPL (UL(0x1) << MVFR0_FPSqrt_SHIFT)
17512066#define MVFR0_FPShVec_SHIFT 24
2067#define MVFR0_FPShVec_WIDTH 4
17522068#define MVFR0_FPShVec_MASK (UL(0xf) << MVFR0_FPShVec_SHIFT)
17532069#define MVFR0_FPShVec_VAL(x) ((x) & MVFR0_FPShVec_MASK)
17542070#define MVFR0_FPShVec_NONE (UL(0x0) << MVFR0_FPShVec_SHIFT)
17552071#define MVFR0_FPShVec_IMPL (UL(0x1) << MVFR0_FPShVec_SHIFT)
17562072#define MVFR0_FPRound_SHIFT 28
2073#define MVFR0_FPRound_WIDTH 4
17572074#define MVFR0_FPRound_MASK (UL(0xf) << MVFR0_FPRound_SHIFT)
17582075#define MVFR0_FPRound_VAL(x) ((x) & MVFR0_FPRound_MASK)
17592076#define MVFR0_FPRound_NONE (UL(0x0) << MVFR0_FPRound_SHIFT)
17602077#define MVFR0_FPRound_IMPL (UL(0x1) << MVFR0_FPRound_SHIFT)
17612078
17622079/* MVFR1_EL1 */
1763#define MVFR1_EL1 MRS_REG(MVFR1_EL1)
2080#define MVFR1_EL1_ISS ISS_MSR_REG(MVFR1_EL1)
17642081#define MVFR1_EL1_op0 0x3
17652082#define MVFR1_EL1_op1 0x0
17662083#define MVFR1_EL1_CRn 0x0
17672084#define MVFR1_EL1_CRm 0x3
17682085#define MVFR1_EL1_op2 0x1
17692086#define MVFR1_FPFtZ_SHIFT 0
2087#define MVFR1_FPFtZ_WIDTH 4
17702088#define MVFR1_FPFtZ_MASK (UL(0xf) << MVFR1_FPFtZ_SHIFT)
17712089#define MVFR1_FPFtZ_VAL(x) ((x) & MVFR1_FPFtZ_MASK)
17722090#define MVFR1_FPFtZ_NONE (UL(0x0) << MVFR1_FPFtZ_SHIFT)
17732091#define MVFR1_FPFtZ_IMPL (UL(0x1) << MVFR1_FPFtZ_SHIFT)
17742092#define MVFR1_FPDNaN_SHIFT 4
2093#define MVFR1_FPDNaN_WIDTH 4
17752094#define MVFR1_FPDNaN_MASK (UL(0xf) << MVFR1_FPDNaN_SHIFT)
17762095#define MVFR1_FPDNaN_VAL(x) ((x) & MVFR1_FPDNaN_MASK)
17772096#define MVFR1_FPDNaN_NONE (UL(0x0) << MVFR1_FPDNaN_SHIFT)
17782097#define MVFR1_FPDNaN_IMPL (UL(0x1) << MVFR1_FPDNaN_SHIFT)
17792098#define MVFR1_SIMDLS_SHIFT 8
2099#define MVFR1_SIMDLS_WIDTH 4
17802100#define MVFR1_SIMDLS_MASK (UL(0xf) << MVFR1_SIMDLS_SHIFT)
17812101#define MVFR1_SIMDLS_VAL(x) ((x) & MVFR1_SIMDLS_MASK)
17822102#define MVFR1_SIMDLS_NONE (UL(0x0) << MVFR1_SIMDLS_SHIFT)
17832103#define MVFR1_SIMDLS_IMPL (UL(0x1) << MVFR1_SIMDLS_SHIFT)
17842104#define MVFR1_SIMDInt_SHIFT 12
2105#define MVFR1_SIMDInt_WIDTH 4
17852106#define MVFR1_SIMDInt_MASK (UL(0xf) << MVFR1_SIMDInt_SHIFT)
17862107#define MVFR1_SIMDInt_VAL(x) ((x) & MVFR1_SIMDInt_MASK)
17872108#define MVFR1_SIMDInt_NONE (UL(0x0) << MVFR1_SIMDInt_SHIFT)
17882109#define MVFR1_SIMDInt_IMPL (UL(0x1) << MVFR1_SIMDInt_SHIFT)
17892110#define MVFR1_SIMDSP_SHIFT 16
2111#define MVFR1_SIMDSP_WIDTH 4
17902112#define MVFR1_SIMDSP_MASK (UL(0xf) << MVFR1_SIMDSP_SHIFT)
17912113#define MVFR1_SIMDSP_VAL(x) ((x) & MVFR1_SIMDSP_MASK)
17922114#define MVFR1_SIMDSP_NONE (UL(0x0) << MVFR1_SIMDSP_SHIFT)
17932115#define MVFR1_SIMDSP_IMPL (UL(0x1) << MVFR1_SIMDSP_SHIFT)
17942116#define MVFR1_SIMDHP_SHIFT 20
2117#define MVFR1_SIMDHP_WIDTH 4
17952118#define MVFR1_SIMDHP_MASK (UL(0xf) << MVFR1_SIMDHP_SHIFT)
17962119#define MVFR1_SIMDHP_VAL(x) ((x) & MVFR1_SIMDHP_MASK)
17972120#define MVFR1_SIMDHP_NONE (UL(0x0) << MVFR1_SIMDHP_SHIFT)
17982121#define MVFR1_SIMDHP_CONV_SP (UL(0x1) << MVFR1_SIMDHP_SHIFT)
17992122#define MVFR1_SIMDHP_ARITH (UL(0x2) << MVFR1_SIMDHP_SHIFT)
18002123#define MVFR1_FPHP_SHIFT 24
2124#define MVFR1_FPHP_WIDTH 4
18012125#define MVFR1_FPHP_MASK (UL(0xf) << MVFR1_FPHP_SHIFT)
18022126#define MVFR1_FPHP_VAL(x) ((x) & MVFR1_FPHP_MASK)
18032127#define MVFR1_FPHP_NONE (UL(0x0) << MVFR1_FPHP_SHIFT)
......@@ -1805,13 +2129,13 @@
18052129#define MVFR1_FPHP_CONV_DP (UL(0x2) << MVFR1_FPHP_SHIFT)
18062130#define MVFR1_FPHP_ARITH (UL(0x3) << MVFR1_FPHP_SHIFT)
18072131#define MVFR1_SIMDFMAC_SHIFT 28
2132#define MVFR1_SIMDFMAC_WIDTH 4
18082133#define MVFR1_SIMDFMAC_MASK (UL(0xf) << MVFR1_SIMDFMAC_SHIFT)
18092134#define MVFR1_SIMDFMAC_VAL(x) ((x) & MVFR1_SIMDFMAC_MASK)
18102135#define MVFR1_SIMDFMAC_NONE (UL(0x0) << MVFR1_SIMDFMAC_SHIFT)
18112136#define MVFR1_SIMDFMAC_IMPL (UL(0x1) << MVFR1_SIMDFMAC_SHIFT)
18122137
18132138/* OSDLR_EL1 */
1814#define OSDLR_EL1 MRS_REG(OSDLR_EL1)
18152139#define OSDLR_EL1_op0 2
18162140#define OSDLR_EL1_op1 0
18172141#define OSDLR_EL1_CRn 1
......@@ -1819,20 +2143,23 @@
18192143#define OSDLR_EL1_op2 4
18202144
18212145/* OSLAR_EL1 */
1822#define OSLAR_EL1 MRS_REG(OSLAR_EL1)
18232146#define OSLAR_EL1_op0 2
18242147#define OSLAR_EL1_op1 0
18252148#define OSLAR_EL1_CRn 1
18262149#define OSLAR_EL1_CRm 0
18272150#define OSLAR_EL1_op2 4
2151#define OSLAR_OSLK (0x1ul << 0)
18282152
18292153/* OSLSR_EL1 */
1830#define OSLSR_EL1 MRS_REG(OSLSR_EL1)
18312154#define OSLSR_EL1_op0 2
18322155#define OSLSR_EL1_op1 0
18332156#define OSLSR_EL1_CRn 1
18342157#define OSLSR_EL1_CRm 1
18352158#define OSLSR_EL1_op2 4
2159#define OSLSR_OSLM_1 (0x1ul << 3)
2160#define OSLSR_nTT (0x1ul << 2)
2161#define OSLSR_OSLK (0x1ul << 1)
2162#define OSLSR_OSLM_0 (0x1ul << 0)
18362163
18372164/* PAR_EL1 - Physical Address Register */
18382165#define PAR_F_SHIFT 0
......@@ -1845,7 +2172,7 @@
18452172#define PAR_NS_SHIFT 9
18462173#define PAR_NS_MASK (0x3 << PAR_NS_SHIFT)
18472174#define PAR_PA_SHIFT 12
1848#define PAR_PA_MASK 0x0000fffffffff000
2175#define PAR_PA_MASK 0x000ffffffffff000
18492176#define PAR_ATTR_SHIFT 56
18502177#define PAR_ATTR_MASK (0xff << PAR_ATTR_SHIFT)
18512178/* When PAR_F == 1 (aborted) */
......@@ -1857,7 +2184,6 @@
18572184#define PAR_S_MASK (0x1 << PAR_S_SHIFT)
18582185
18592186/* PMBIDR_EL1 */
1860#define PMBIDR_EL1 MRS_REG(PMBIDR_EL1)
18612187#define PMBIDR_EL1_REG MRS_REG_ALT_NAME(PMBIDR_EL1)
18622188#define PMBIDR_EL1_op0 3
18632189#define PMBIDR_EL1_op1 0
......@@ -1872,7 +2198,6 @@
18722198#define PMBIDR_F (UL(0x1) << PMBIDR_F_SHIFT)
18732199
18742200/* PMBLIMITR_EL1 */
1875#define PMBLIMITR_EL1 MRS_REG(PMBLIMITR_EL1)
18762201#define PMBLIMITR_EL1_REG MRS_REG_ALT_NAME(PMBLIMITR_EL1)
18772202#define PMBLIMITR_EL1_op0 3
18782203#define PMBLIMITR_EL1_op1 0
......@@ -1890,7 +2215,6 @@
18902215 (UL(0xfffffffffffff) << PMBLIMITR_LIMIT_SHIFT)
18912216
18922217/* PMBPTR_EL1 */
1893#define PMBPTR_EL1 MRS_REG(PMBPTR_EL1)
18942218#define PMBPTR_EL1_REG MRS_REG_ALT_NAME(PMBPTR_EL1)
18952219#define PMBPTR_EL1_op0 3
18962220#define PMBPTR_EL1_op1 0
......@@ -1902,7 +2226,6 @@
19022226 (UL(0xffffffffffffffff) << PMBPTR_PTR_SHIFT)
19032227
19042228/* PMBSR_EL1 */
1905#define PMBSR_EL1 MRS_REG(PMBSR_EL1)
19062229#define PMBSR_EL1_REG MRS_REG_ALT_NAME(PMBSR_EL1)
19072230#define PMBSR_EL1_op0 3
19082231#define PMBSR_EL1_op1 0
......@@ -1925,7 +2248,6 @@
19252248#define PMBSR_EC_MASK (UL(0x3f) << PMBSR_EC_SHIFT)
19262249
19272250/* PMCCFILTR_EL0 */
1928#define PMCCFILTR_EL0 MRS_REG(PMCCFILTR_EL0)
19292251#define PMCCFILTR_EL0_op0 3
19302252#define PMCCFILTR_EL0_op1 3
19312253#define PMCCFILTR_EL0_CRn 14
......@@ -1933,7 +2255,6 @@
19332255#define PMCCFILTR_EL0_op2 7
19342256
19352257/* PMCCNTR_EL0 */
1936#define PMCCNTR_EL0 MRS_REG(PMCCNTR_EL0)
19372258#define PMCCNTR_EL0_op0 3
19382259#define PMCCNTR_EL0_op1 3
19392260#define PMCCNTR_EL0_CRn 9
......@@ -1941,7 +2262,6 @@
19412262#define PMCCNTR_EL0_op2 0
19422263
19432264/* PMCEID0_EL0 */
1944#define PMCEID0_EL0 MRS_REG(PMCEID0_EL0)
19452265#define PMCEID0_EL0_op0 3
19462266#define PMCEID0_EL0_op1 3
19472267#define PMCEID0_EL0_CRn 9
......@@ -1949,7 +2269,6 @@
19492269#define PMCEID0_EL0_op2 6
19502270
19512271/* PMCEID1_EL0 */
1952#define PMCEID1_EL0 MRS_REG(PMCEID1_EL0)
19532272#define PMCEID1_EL0_op0 3
19542273#define PMCEID1_EL0_op1 3
19552274#define PMCEID1_EL0_CRn 9
......@@ -1957,7 +2276,6 @@
19572276#define PMCEID1_EL0_op2 7
19582277
19592278/* PMCNTENCLR_EL0 */
1960#define PMCNTENCLR_EL0 MRS_REG(PMCNTENCLR_EL0)
19612279#define PMCNTENCLR_EL0_op0 3
19622280#define PMCNTENCLR_EL0_op1 3
19632281#define PMCNTENCLR_EL0_CRn 9
......@@ -1965,7 +2283,6 @@
19652283#define PMCNTENCLR_EL0_op2 2
19662284
19672285/* PMCNTENSET_EL0 */
1968#define PMCNTENSET_EL0 MRS_REG(PMCNTENSET_EL0)
19692286#define PMCNTENSET_EL0_op0 3
19702287#define PMCNTENSET_EL0_op1 3
19712288#define PMCNTENSET_EL0_CRn 9
......@@ -1973,24 +2290,24 @@
19732290#define PMCNTENSET_EL0_op2 1
19742291
19752292/* PMCR_EL0 - Perfomance Monitoring Counters */
1976#define PMCR_EL0 MRS_REG(PMCR_EL0)
19772293#define PMCR_EL0_op0 3
19782294#define PMCR_EL0_op1 3
19792295#define PMCR_EL0_CRn 9
19802296#define PMCR_EL0_CRm 12
19812297#define PMCR_EL0_op2 0
1982#define PMCR_E (1 << 0) /* Enable all counters */
1983#define PMCR_P (1 << 1) /* Reset all counters */
1984#define PMCR_C (1 << 2) /* Clock counter reset */
1985#define PMCR_D (1 << 3) /* CNTR counts every 64 clk cycles */
1986#define PMCR_X (1 << 4) /* Export to ext. monitoring (ETM) */
1987#define PMCR_DP (1 << 5) /* Disable CCNT if non-invasive debug*/
1988#define PMCR_LC (1 << 6) /* Long cycle count enable */
1989#define PMCR_IMP_SHIFT 24 /* Implementer code */
1990#define PMCR_IMP_MASK (0xff << PMCR_IMP_SHIFT)
1991#define PMCR_IMP_ARM 0x41
2298#define PMCR_E (1ul << 0) /* Enable all counters */
2299#define PMCR_P (1ul << 1) /* Reset all counters */
2300#define PMCR_C (1ul << 2) /* Clock counter reset */
2301#define PMCR_D (1ul << 3) /* CNTR counts every 64 clk cycles */
2302#define PMCR_X (1ul << 4) /* Export to ext. monitoring (ETM) */
2303#define PMCR_DP (1ul << 5) /* Disable CCNT if non-invasive debug*/
2304#define PMCR_LC (1ul << 6) /* Long cycle count enable */
2305#define PMCR_LP (1ul << 7) /* Long event count enable */
2306#define PMCR_FZO (1ul << 9) /* Freeze-on-overflow */
2307#define PMCR_N_SHIFT 11 /* Number of counters implemented */
2308#define PMCR_N_MASK (0x1ful << PMCR_N_SHIFT)
19922309#define PMCR_IDCODE_SHIFT 16 /* Identification code */
1993#define PMCR_IDCODE_MASK (0xff << PMCR_IDCODE_SHIFT)
2310#define PMCR_IDCODE_MASK (0xfful << PMCR_IDCODE_SHIFT)
19942311#define PMCR_IDCODE_CORTEX_A57 0x01
19952312#define PMCR_IDCODE_CORTEX_A72 0x02
19962313#define PMCR_IDCODE_CORTEX_A53 0x03
......@@ -2002,8 +2319,10 @@
20022319#define PMCR_IDCODE_CORTEX_A55 0x45
20032320#define PMCR_IDCODE_NEOVERSE_E1 0x46
20042321#define PMCR_IDCODE_CORTEX_A75 0x4a
2005#define PMCR_N_SHIFT 11 /* Number of counters implemented */
2006#define PMCR_N_MASK (0x1f << PMCR_N_SHIFT)
2322#define PMCR_IMP_SHIFT 24 /* Implementer code */
2323#define PMCR_IMP_MASK (0xfful << PMCR_IMP_SHIFT)
2324#define PMCR_IMP_ARM 0x41
2325#define PMCR_FZS (1ul << 32) /* Freeze-on-SPE event */
20072326
20082327/* PMEVCNTR<n>_EL0 */
20092328#define PMEVCNTR_EL0_op0 3
......@@ -2035,7 +2354,6 @@
20352354#define PMEVTYPER_P (1 << 31) /* Privileged filtering */
20362355
20372356/* PMINTENCLR_EL1 */
2038#define PMINTENCLR_EL1 MRS_REG(PMINTENCLR_EL1)
20392357#define PMINTENCLR_EL1_op0 3
20402358#define PMINTENCLR_EL1_op1 0
20412359#define PMINTENCLR_EL1_CRn 9
......@@ -2043,7 +2361,6 @@
20432361#define PMINTENCLR_EL1_op2 2
20442362
20452363/* PMINTENSET_EL1 */
2046#define PMINTENSET_EL1 MRS_REG(PMINTENSET_EL1)
20472364#define PMINTENSET_EL1_op0 3
20482365#define PMINTENSET_EL1_op1 0
20492366#define PMINTENSET_EL1_CRn 9
......@@ -2051,7 +2368,6 @@
20512368#define PMINTENSET_EL1_op2 1
20522369
20532370/* PMMIR_EL1 */
2054#define PMMIR_EL1 MRS_REG(PMMIR_EL1)
20552371#define PMMIR_EL1_op0 3
20562372#define PMMIR_EL1_op1 0
20572373#define PMMIR_EL1_CRn 9
......@@ -2059,7 +2375,6 @@
20592375#define PMMIR_EL1_op2 6
20602376
20612377/* PMOVSCLR_EL0 */
2062#define PMOVSCLR_EL0 MRS_REG(PMOVSCLR_EL0)
20632378#define PMOVSCLR_EL0_op0 3
20642379#define PMOVSCLR_EL0_op1 3
20652380#define PMOVSCLR_EL0_CRn 9
......@@ -2067,7 +2382,6 @@
20672382#define PMOVSCLR_EL0_op2 3
20682383
20692384/* PMOVSSET_EL0 */
2070#define PMOVSSET_EL0 MRS_REG(PMOVSSET_EL0)
20712385#define PMOVSSET_EL0_op0 3
20722386#define PMOVSSET_EL0_op1 3
20732387#define PMOVSSET_EL0_CRn 9
......@@ -2075,7 +2389,6 @@
20752389#define PMOVSSET_EL0_op2 3
20762390
20772391/* PMSCR_EL1 */
2078#define PMSCR_EL1 MRS_REG(PMSCR_EL1)
20792392#define PMSCR_EL1_REG MRS_REG_ALT_NAME(PMSCR_EL1)
20802393#define PMSCR_EL1_op0 3
20812394#define PMSCR_EL1_op1 0
......@@ -2096,7 +2409,6 @@
20962409#define PMSCR_PCT_MASK (UL(0x3) << PMSCR_PCT_SHIFT)
20972410
20982411/* PMSELR_EL0 */
2099#define PMSELR_EL0 MRS_REG(PMSELR_EL0)
21002412#define PMSELR_EL0_op0 3
21012413#define PMSELR_EL0_op1 3
21022414#define PMSELR_EL0_CRn 9
......@@ -2105,7 +2417,6 @@
21052417#define PMSELR_SEL_MASK 0x1f
21062418
21072419/* PMSEVFR_EL1 */
2108#define PMSEVFR_EL1 MRS_REG(PMSEVFR_EL1)
21092420#define PMSEVFR_EL1_REG MRS_REG_ALT_NAME(PMSEVFR_EL1)
21102421#define PMSEVFR_EL1_op0 3
21112422#define PMSEVFR_EL1_op1 0
......@@ -2114,7 +2425,6 @@
21142425#define PMSEVFR_EL1_op2 5
21152426
21162427/* PMSFCR_EL1 */
2117#define PMSFCR_EL1 MRS_REG(PMSFCR_EL1)
21182428#define PMSFCR_EL1_REG MRS_REG_ALT_NAME(PMSFCR_EL1)
21192429#define PMSFCR_EL1_op0 3
21202430#define PMSFCR_EL1_op1 0
......@@ -2137,7 +2447,6 @@
21372447#define PMSFCR_ST (UL(0x1) << PMSFCR_ST_SHIFT)
21382448
21392449/* PMSICR_EL1 */
2140#define PMSICR_EL1 MRS_REG(PMSICR_EL1)
21412450#define PMSICR_EL1_REG MRS_REG_ALT_NAME(PMSICR_EL1)
21422451#define PMSICR_EL1_op0 3
21432452#define PMSICR_EL1_op1 0
......@@ -2150,7 +2459,6 @@
21502459#define PMSICR_ECOUNT_MASK (UL(0xff) << PMSICR_ECOUNT_SHIFT)
21512460
21522461/* PMSIDR_EL1 */
2153#define PMSIDR_EL1 MRS_REG(PMSIDR_EL1)
21542462#define PMSIDR_EL1_REG MRS_REG_ALT_NAME(PMSIDR_EL1)
21552463#define PMSIDR_EL1_op0 3
21562464#define PMSIDR_EL1_op1 0
......@@ -2183,7 +2491,6 @@
21832491#define PMSIDR_PBT (UL(0x1) << PMSIDR_PBT_SHIFT)
21842492
21852493/* PMSIRR_EL1 */
2186#define PMSIRR_EL1 MRS_REG(PMSIRR_EL1)
21872494#define PMSIRR_EL1_REG MRS_REG_ALT_NAME(PMSIRR_EL1)
21882495#define PMSIRR_EL1_op0 3
21892496#define PMSIRR_EL1_op1 0
......@@ -2196,7 +2503,6 @@
21962503#define PMSIRR_INTERVAL_MASK (UL(0xffffff) << PMSIRR_INTERVAL_SHIFT)
21972504
21982505/* PMSLATFR_EL1 */
2199#define PMSLATFR_EL1 MRS_REG(PMSLATFR_EL1)
22002506#define PMSLATFR_EL1_REG MRS_REG_ALT_NAME(PMSLATFR_EL1)
22012507#define PMSLATFR_EL1_op0 3
22022508#define PMSLATFR_EL1_op1 0
......@@ -2207,7 +2513,6 @@
22072513#define PMSLATFR_MINLAT_MASK (UL(0xfff) << PMSLATFR_MINLAT_SHIFT)
22082514
22092515/* PMSNEVFR_EL1 */
2210#define PMSNEVFR_EL1 MRS_REG(PMSNEVFR_EL1)
22112516#define PMSNEVFR_EL1_REG MRS_REG_ALT_NAME(PMSNEVFR_EL1)
22122517#define PMSNEVFR_EL1_op0 3
22132518#define PMSNEVFR_EL1_op1 0
......@@ -2216,7 +2521,6 @@
22162521#define PMSNEVFR_EL1_op2 1
22172522
22182523/* PMSWINC_EL0 */
2219#define PMSWINC_EL0 MRS_REG(PMSWINC_EL0)
22202524#define PMSWINC_EL0_op0 3
22212525#define PMSWINC_EL0_op1 3
22222526#define PMSWINC_EL0_CRn 9
......@@ -2224,7 +2528,6 @@
22242528#define PMSWINC_EL0_op2 4
22252529
22262530/* PMUSERENR_EL0 */
2227#define PMUSERENR_EL0 MRS_REG(PMUSERENR_EL0)
22282531#define PMUSERENR_EL0_op0 3
22292532#define PMUSERENR_EL0_op1 3
22302533#define PMUSERENR_EL0_CRn 9
......@@ -2232,7 +2535,6 @@
22322535#define PMUSERENR_EL0_op2 0
22332536
22342537/* PMXEVCNTR_EL0 */
2235#define PMXEVCNTR_EL0 MRS_REG(PMXEVCNTR_EL0)
22362538#define PMXEVCNTR_EL0_op0 3
22372539#define PMXEVCNTR_EL0_op1 3
22382540#define PMXEVCNTR_EL0_CRn 9
......@@ -2240,7 +2542,6 @@
22402542#define PMXEVCNTR_EL0_op2 2
22412543
22422544/* PMXEVTYPER_EL0 */
2243#define PMXEVTYPER_EL0 MRS_REG(PMXEVTYPER_EL0)
22442545#define PMXEVTYPER_EL0_op0 3
22452546#define PMXEVTYPER_EL0_op1 3
22462547#define PMXEVTYPER_EL0_CRn 9
......@@ -2248,7 +2549,6 @@
22482549#define PMXEVTYPER_EL0_op2 1
22492550
22502551/* RNDRRS */
2251#define RNDRRS MRS_REG(RNDRRS)
22522552#define RNDRRS_REG MRS_REG_ALT_NAME(RNDRRS)
22532553#define RNDRRS_op0 3
22542554#define RNDRRS_op1 3
......@@ -2313,6 +2613,26 @@
23132613#define SCTLR_EnALS (UL(0x1) << 56)
23142614#define SCTLR_EPAN (UL(0x1) << 57)
23152615
2616#define SCTLR_MMU_OFF \
2617 (SCTLR_LSMAOE | SCTLR_nTLSMD | SCTLR_EIS | SCTLR_TSCXT | SCTLR_EOS)
2618#define SCTLR_MMU_ON \
2619 (SCTLR_MMU_OFF | \
2620 SCTLR_BT1 | \
2621 SCTLR_BT0 | \
2622 SCTLR_UCI | \
2623 SCTLR_SPAN | \
2624 SCTLR_nTWE | \
2625 SCTLR_nTWI | \
2626 SCTLR_UCT | \
2627 SCTLR_DZE | \
2628 SCTLR_I | \
2629 SCTLR_SED | \
2630 SCTLR_CP15BEN | \
2631 SCTLR_SA0 | \
2632 SCTLR_SA | \
2633 SCTLR_C | \
2634 SCTLR_M)
2635
23162636/* SCTLR_EL12 */
23172637#define SCTLR_EL12_REG MRS_REG_ALT_NAME(SCTLR_EL12)
23182638#define SCTLR_EL12_op0 3
......@@ -2354,7 +2674,8 @@
23542674#define PSR_D 0x00000200UL
23552675#define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F)
23562676/* The default DAIF mask. These bits are valid in spsr_el1 and daif */
2357#define PSR_DAIF_DEFAULT (PSR_F)
2677#define PSR_DAIF_DEFAULT (0)
2678#define PSR_DAIF_INTR (PSR_I | PSR_F)
23582679#define PSR_BTYPE 0x00000c00UL
23592680#define PSR_SSBS 0x00001000UL
23602681#define PSR_ALLINT 0x00002000UL
......@@ -2382,7 +2703,6 @@
23822703#define SPSR_EL12_op2 0
23832704
23842705/* REVIDR_EL1 - Revision ID Register */
2385#define REVIDR_EL1 MRS_REG(REVIDR_EL1)
23862706#define REVIDR_EL1_op0 3
23872707#define REVIDR_EL1_op1 0
23882708#define REVIDR_EL1_CRn 0
......@@ -2496,14 +2816,6 @@
24962816#define TCR_T0SZ(x) ((x) << TCR_T0SZ_SHIFT)
24972817#define TCR_TxSZ(x) (TCR_T1SZ(x) | TCR_T0SZ(x))
24982818
2499#define TCR_CACHE_ATTRS ((TCR_IRGN0_WBWA | TCR_IRGN1_WBWA) |\
2500 (TCR_ORGN0_WBWA | TCR_ORGN1_WBWA))
2501#ifdef SMP
2502#define TCR_SMP_ATTRS (TCR_SH0_IS | TCR_SH1_IS)
2503#else
2504#define TCR_SMP_ATTRS 0
2505#endif
2506
25072819/* TCR_EL12 */
25082820#define TCR_EL12_REG MRS_REG_ALT_NAME(TCR_EL12)
25092821#define TCR_EL12_op0 3
......@@ -2568,13 +2880,12 @@
25682880#define VBAR_EL12_op2 0
25692881
25702882/* ZCR_EL1 - SVE Control Register */
2571#define ZCR_EL1 MRS_REG(ZCR_EL1)
2572#define ZCR_EL1_REG MRS_REG_ALT_NAME(ZCR_EL1_REG)
2573#define ZCR_EL1_REG_op0 3
2574#define ZCR_EL1_REG_op1 0
2575#define ZCR_EL1_REG_CRn 1
2576#define ZCR_EL1_REG_CRm 2
2577#define ZCR_EL1_REG_op2 0
2883#define ZCR_EL1_REG MRS_REG_ALT_NAME(ZCR_EL1)
2884#define ZCR_EL1_op0 3
2885#define ZCR_EL1_op1 0
2886#define ZCR_EL1_CRn 1
2887#define ZCR_EL1_CRm 2
2888#define ZCR_EL1_op2 0
25782889#define ZCR_LEN_SHIFT 0
25792890#define ZCR_LEN_MASK (0xf << ZCR_LEN_SHIFT)
25802891#define ZCR_LEN_BYTES(x) ((((x) & ZCR_LEN_MASK) + 1) * 16)
lib/libc/include/aarch64-freebsd-none/machine/asm.h+20-3
......@@ -72,6 +72,17 @@
7272/* Alias for link register x30 */
7373#define lr x30
7474
75/*
76 * Check whether a given cpu feature is present, in the case it is not we jump
77 * to the given label. The tmp register should be a register able to hold the
78 * temporary data.
79 */
80#define CHECK_CPU_FEAT(tmp, feat_reg, feat, min_val, label) \
81 mrs tmp, ##feat_reg##_el1; \
82 ubfx tmp, tmp, ##feat_reg##_##feat##_SHIFT, ##feat_reg##_##feat##_WIDTH; \
83 cmp tmp, #(##feat_reg##_##feat##_##min_val## >> ##feat_reg##_##feat##_SHIFT); \
84 b.lt label
85
7586/*
7687 * Sets the trap fault handler. The exception handler will return to the
7788 * address in the handler register on a data abort or the xzr register to
......@@ -87,19 +98,25 @@
8798 ldr tmp, =has_pan; /* Get the addr of has_pan */ \
8899 ldr reg, [tmp]; /* Read it */ \
89100 cbz reg, 997f; /* If no PAN skip */ \
90 .inst 0xd500409f | (0 << 8); /* Clear PAN */ \
101 .arch_extension pan; \
102 msr pan, #0; /* Disable PAN checks */ \
103 .arch_extension nopan; \
91104 997:
92105
93106#define EXIT_USER_ACCESS(reg) \
94107 cbz reg, 998f; /* If no PAN skip */ \
95 .inst 0xd500409f | (1 << 8); /* Set PAN */ \
108 .arch_extension pan; \
109 msr pan, #1; /* Enable PAN checks */ \
110 .arch_extension nopan; \
96111 998:
97112
98113#define EXIT_USER_ACCESS_CHECK(reg, tmp) \
99114 ldr tmp, =has_pan; /* Get the addr of has_pan */ \
100115 ldr reg, [tmp]; /* Read it */ \
101116 cbz reg, 999f; /* If no PAN skip */ \
102 .inst 0xd500409f | (1 << 8); /* Set PAN */ \
117 .arch_extension pan; \
118 msr pan, #1; /* Enable PAN checks */ \
119 .arch_extension nopan; \
103120 999:
104121
105122/*
lib/libc/include/aarch64-freebsd-none/machine/atomic.h+3-1
......@@ -465,7 +465,7 @@ _ATOMIC_TEST_OP(set, orr, set)
465465
466466#define _ATOMIC_LOAD_ACQ_IMPL(t, w, s) \
467467static __inline uint##t##_t \
468atomic_load_acq_##t(volatile uint##t##_t *p) \
468atomic_load_acq_##t(const volatile uint##t##_t *p) \
469469{ \
470470 uint##t##_t ret; \
471471 \
......@@ -609,6 +609,8 @@ _ATOMIC_STORE_REL_IMPL(64, , )
609609#define atomic_set_ptr atomic_set_64
610610#define atomic_swap_ptr atomic_swap_64
611611#define atomic_subtract_ptr atomic_subtract_64
612#define atomic_testandclear_ptr atomic_testandclear_64
613#define atomic_testandset_ptr atomic_testandset_64
612614
613615#define atomic_add_acq_long atomic_add_acq_64
614616#define atomic_fcmpset_acq_long atomic_fcmpset_acq_64
lib/libc/include/aarch64-freebsd-none/machine/bus.h+1
......@@ -76,6 +76,7 @@
7676
7777#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL
7878#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL
79#define BUS_SPACE_MAXADDR_36BIT 0xFFFFFFFFFUL
7980#define BUS_SPACE_MAXADDR_40BIT 0xFFFFFFFFFFUL
8081#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL
8182#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL
lib/libc/include/aarch64-freebsd-none/machine/bus_dma.h+13-1
......@@ -61,7 +61,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
6161
6262/*
6363 * Free a piece of memory and it's allociated dmamap, that was allocated
64 * via bus_dmamem_alloc. Make the same choice for free/contigfree.
64 * via bus_dmamem_alloc.
6565 */
6666static inline void
6767bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
......@@ -148,4 +148,16 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
148148 return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
149149}
150150
151#ifdef KMSAN
152static inline void
153_bus_dmamap_load_kmsan(bus_dma_tag_t dmat, bus_dmamap_t map,
154 struct memdesc *mem)
155{
156 struct bus_dma_tag_common *tc;
157
158 tc = (struct bus_dma_tag_common *)dmat;
159 return (tc->impl->load_kmsan(map, mem));
160}
161#endif
162
151163#endif /* !_MACHINE_BUS_DMA_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/bus_dma_impl.h+7-11
......@@ -31,28 +31,23 @@
3131
3232struct bus_dma_tag_common {
3333 struct bus_dma_impl *impl;
34 struct bus_dma_tag_common *parent;
3534 bus_size_t alignment;
3635 bus_addr_t boundary;
3736 bus_addr_t lowaddr;
3837 bus_addr_t highaddr;
39 bus_dma_filter_t *filter;
40 void *filterarg;
4138 bus_size_t maxsize;
4239 u_int nsegments;
4340 bus_size_t maxsegsz;
4441 int flags;
4542 bus_dma_lock_t *lockfunc;
4643 void *lockfuncarg;
47 int ref_count;
4844 int domain;
4945};
5046
5147struct bus_dma_impl {
5248 int (*tag_create)(bus_dma_tag_t parent,
5349 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
54 bus_addr_t highaddr, bus_dma_filter_t *filter,
55 void *filterarg, bus_size_t maxsize, int nsegments,
50 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
5651 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
5752 void *lockfuncarg, bus_dma_tag_t *dmat);
5853 int (*tag_destroy)(bus_dma_tag_t dmat);
......@@ -80,14 +75,15 @@ struct bus_dma_impl {
8075 void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map);
8176 void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map,
8277 bus_dmasync_op_t op);
78#ifdef KMSAN
79 void (*load_kmsan)(bus_dmamap_t map, struct memdesc *mem);
80#endif
8381};
8482
85int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
8683int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
87 bus_size_t alignment,
88 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
89 bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,
90 int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
84 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
85 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
86 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
9187 void *lockfuncarg, size_t sz, void **dmat);
9288
9389extern struct bus_dma_impl bus_dma_bounce_impl;
lib/libc/include/aarch64-freebsd-none/machine/cpu.h+65-8
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
3735 * from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/29
3836 */
3937
......@@ -77,6 +75,7 @@
7775#define CPU_IMPL_CAVIUM 0x43
7876#define CPU_IMPL_DEC 0x44
7977#define CPU_IMPL_FUJITSU 0x46
78#define CPU_IMPL_HISILICON 0x48
8079#define CPU_IMPL_INFINEON 0x49
8180#define CPU_IMPL_FREESCALE 0x4D
8281#define CPU_IMPL_NVIDIA 0x4E
......@@ -86,6 +85,7 @@
8685#define CPU_IMPL_APPLE 0x61
8786#define CPU_IMPL_INTEL 0x69
8887#define CPU_IMPL_AMPERE 0xC0
88#define CPU_IMPL_MICROSOFT 0x6D
8989
9090/* ARM Part numbers */
9191#define CPU_PART_FOUNDATION 0xD00
......@@ -105,6 +105,7 @@
105105#define CPU_PART_AEM_V8 0xD0F
106106#define CPU_PART_NEOVERSE_V1 0xD40
107107#define CPU_PART_CORTEX_A78 0xD41
108#define CPU_PART_CORTEX_A78AE 0xD42
108109#define CPU_PART_CORTEX_A65AE 0xD43
109110#define CPU_PART_CORTEX_X1 0xD44
110111#define CPU_PART_CORTEX_A510 0xD46
......@@ -117,6 +118,18 @@
117118#define CPU_PART_CORTEX_A715 0xD4D
118119#define CPU_PART_CORTEX_X3 0xD4E
119120#define CPU_PART_NEOVERSE_V2 0xD4F
121#define CPU_PART_CORTEX_A520 0xD80
122#define CPU_PART_CORTEX_A720 0xD81
123#define CPU_PART_CORTEX_X4 0xD82
124#define CPU_PART_NEOVERSE_V3AE 0xD83
125#define CPU_PART_NEOVERSE_V3 0xD84
126#define CPU_PART_CORTEX_X925 0xD85
127#define CPU_PART_CORTEX_A725 0xD87
128#define CPU_PART_C1_NANO 0xD8A
129#define CPU_PART_C1_PRO 0xD8B
130#define CPU_PART_C1_ULTRA 0xD8C
131#define CPU_PART_NEOVERSE_N3 0xD8E
132#define CPU_PART_C1_PREMIUM 0xD90
120133
121134/* Cavium Part numbers */
122135#define CPU_PART_THUNDERX 0x0A1
......@@ -129,9 +142,16 @@
129142
130143#define CPU_REV_THUNDERX2_0 0x00
131144
132/* APM / Ampere Part Number */
145/* APM (now Ampere) Part number */
133146#define CPU_PART_EMAG8180 0x000
134147
148/* Ampere Part numbers */
149#define CPU_PART_AMPERE1 0xAC3
150#define CPU_PART_AMPERE1A 0xAC4
151
152/* Microsoft Part numbers */
153#define CPU_PART_AZURE_COBALT_100 0xD49
154
135155/* Qualcomm */
136156#define CPU_PART_KRYO400_GOLD 0x804
137157#define CPU_PART_KRYO400_SILVER 0x805
......@@ -177,8 +197,30 @@
177197 (((mask) & PCPU_GET(midr)) == \
178198 ((mask) & CPU_ID_RAW((impl), (part), (var), (rev))))
179199
180#define CPU_MATCH_RAW(mask, devid) \
181 (((mask) & PCPU_GET(midr)) == ((mask) & (devid)))
200#if !defined(__ASSEMBLER__)
201static inline bool
202midr_check_var_part_range(u_int midr, u_int impl, u_int part, u_int var_low,
203 u_int part_low, u_int var_high, u_int part_high)
204{
205 /* Check for the correct part */
206 if (CPU_IMPL(midr) != impl || CPU_PART(midr) != part)
207 return (false);
208
209 /* Check if the variant is between var_low and var_high inclusive */
210 if (CPU_VAR(midr) < var_low || CPU_VAR(midr) > var_high)
211 return (false);
212
213 /* If the variant is the low value, check if the part is high enough */
214 if (CPU_VAR(midr) == var_low && CPU_PART(midr) < part_low)
215 return (false);
216
217 /* If the variant is the high value, check if the part is low enough */
218 if (CPU_VAR(midr) == var_high && CPU_PART(midr) > part_high)
219 return (false);
220
221 return (true);
222}
223#endif
182224
183225/*
184226 * Chip-specific errata. This defines are intended to be
......@@ -210,6 +252,12 @@ extern uint64_t __cpu_affinity[];
210252
211253struct arm64_addr_mask;
212254extern struct arm64_addr_mask elf64_addr_mask;
255#ifdef COMPAT_FREEBSD14
256extern struct arm64_addr_mask elf64_addr_mask_14;
257#endif
258
259typedef void (*cpu_reset_hook_t)(void);
260extern cpu_reset_hook_t cpu_reset_hook;
213261
214262void cpu_halt(void) __dead2;
215263void cpu_reset(void) __dead2;
......@@ -231,9 +279,18 @@ void ptrauth_mp_start(uint64_t);
231279
232280/* Functions to read the sanitised view of the special registers */
233281void update_special_regs(u_int);
234bool extract_user_id_field(u_int, u_int, uint8_t *);
235bool get_kernel_reg(u_int, uint64_t *);
236bool get_kernel_reg_masked(u_int, uint64_t *, uint64_t);
282void update_special_reg_iss(u_int, uint64_t, uint64_t);
283#define update_special_reg(reg, clear, set) \
284 update_special_reg_iss(reg ## _ISS, clear, set)
285bool get_kernel_reg_iss(u_int, uint64_t *);
286#define get_kernel_reg(reg, valp) \
287 get_kernel_reg_iss(reg ## _ISS, valp)
288bool get_kernel_reg_iss_masked(u_int, uint64_t *, uint64_t);
289#define get_kernel_reg_masked(reg, valp, mask) \
290 get_kernel_reg_iss_masked(reg ## _ISS, valp, mask)
291bool get_user_reg_iss(u_int, uint64_t *, bool);
292#define get_user_reg(reg, valp, fbsd) \
293 get_user_reg_iss(reg ## _ISS, valp, fbsd)
237294
238295void cpu_desc_init(void);
239296
lib/libc/include/aarch64-freebsd-none/machine/cpu_feat.h created+136
......@@ -0,0 +1,136 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 Arm Ltd
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_CPU_FEAT_H_
29#define _MACHINE_CPU_FEAT_H_
30
31#include <sys/linker_set.h>
32#include <sys/sysctl.h>
33
34typedef enum {
35 ERRATA_UNKNOWN, /* Unknown erratum */
36 ERRATA_NONE, /* No errata for this feature on this system. */
37 ERRATA_AFFECTED, /* There is errata on this system. */
38 ERRATA_FW_MITIGAION, /* There is errata, and a firmware */
39 /* mitigation. The mitigation may need a */
40 /* kernel component. */
41} cpu_feat_errata;
42
43typedef enum {
44 /*
45 * Don't implement the feature or erratum wrokarount,
46 * e.g. the feature is not implemented or erratum is
47 * for another CPU.
48 */
49 FEAT_ALWAYS_DISABLE,
50
51 /*
52 * Disable by default, but allow the user to enable,
53 * e.g. For a rare erratum with a workaround, Arm
54 * Category B (rare) or similar.
55 */
56 FEAT_DEFAULT_DISABLE,
57
58 /*
59 * Enabled by default, bit allow the user to disable,
60 * e.g. For a common erratum with a workaround, Arm
61 * Category A or B or similar.
62 */
63 FEAT_DEFAULT_ENABLE,
64
65 /* We could add FEAT_ALWAYS_ENABLE if a need was found. */
66} cpu_feat_en;
67
68#define CPU_FEAT_STAGE_MASK 0x00000001
69#define CPU_FEAT_EARLY_BOOT 0x00000000
70#define CPU_FEAT_AFTER_DEV 0x00000001
71
72#define CPU_FEAT_SCOPE_MASK 0x00000010
73#define CPU_FEAT_PER_CPU 0x00000000
74#define CPU_FEAT_SYSTEM 0x00000010
75
76#define CPU_FEAT_USER_ENABLED 0x40000000
77#define CPU_FEAT_USER_DISABLED 0x80000000
78
79struct cpu_feat;
80
81typedef cpu_feat_en (cpu_feat_check)(const struct cpu_feat *, u_int);
82typedef bool (cpu_feat_has_errata)(const struct cpu_feat *, u_int,
83 u_int **, u_int *);
84typedef bool (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata,
85 u_int *, u_int);
86typedef void (cpu_feat_disabled)(const struct cpu_feat *);
87
88struct cpu_feat {
89 const char *feat_name;
90 cpu_feat_check *feat_check;
91 cpu_feat_has_errata *feat_has_errata;
92 cpu_feat_enable *feat_enable;
93 cpu_feat_disabled *feat_disabled;
94 uint32_t feat_flags;
95 bool feat_enabled;
96};
97SET_DECLARE(cpu_feat_set, struct cpu_feat);
98
99SYSCTL_DECL(_hw_feat);
100
101#define CPU_FEAT(name, descr, check, has_errata, enable, disabled, flags) \
102static struct cpu_feat name = { \
103 .feat_name = #name, \
104 .feat_check = check, \
105 .feat_has_errata = has_errata, \
106 .feat_enable = enable, \
107 .feat_disabled = disabled, \
108 .feat_flags = flags, \
109 .feat_enabled = false, \
110}; \
111DATA_SET(cpu_feat_set, name); \
112SYSCTL_BOOL(_hw_feat, OID_AUTO, name, CTLFLAG_RD, &name.feat_enabled, \
113 0, descr)
114
115/*
116 * Allow drivers to mark an erratum as worked around, e.g. the Errata
117 * Management ABI may know the workaround isn't needed on a given system.
118 */
119typedef cpu_feat_errata (*cpu_feat_errata_check_fn)(const struct cpu_feat *,
120 u_int);
121void cpu_feat_register_errata_check(cpu_feat_errata_check_fn);
122
123void enable_cpu_feat(uint32_t);
124
125/* Check if an erratum is in the list of errata */
126static inline bool
127cpu_feat_has_erratum(u_int *errata_list, u_int errata_count, u_int erratum)
128{
129 for (u_int i = 0; i < errata_count; i++)
130 if (errata_list[0] == erratum)
131 return (true);
132
133 return (false);
134}
135
136#endif /* _MACHINE_CPU_FEAT_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/cpufunc.h+29-11
......@@ -41,8 +41,6 @@ breakpoint(void)
4141#ifdef _KERNEL
4242#include <machine/armreg.h>
4343
44void pan_enable(void);
45
4644static __inline register_t
4745dbg_disable(void)
4846{
......@@ -160,6 +158,26 @@ invalidate_local_icache(void)
160158 "isb \n");
161159}
162160
161static __inline void
162wfet(uint64_t val)
163{
164 __asm __volatile(
165 "msr s0_3_c1_c0_0, %0\n"
166 :
167 : "r" ((val))
168 : "memory");
169}
170
171static __inline void
172wfit(uint64_t val)
173{
174 __asm __volatile(
175 "msr s0_3_c1_c0_1, %0\n"
176 :
177 : "r" ((val))
178 : "memory");
179}
180
163181extern bool icache_aliasing;
164182extern bool icache_vmid;
165183
......@@ -177,21 +195,21 @@ extern int64_t dczva_line_size;
177195#define cpu_dcache_inv_range(a, s) arm64_dcache_inv_range((a), (s))
178196#define cpu_dcache_wb_range(a, s) arm64_dcache_wb_range((a), (s))
179197
180extern void (*arm64_icache_sync_range)(vm_offset_t, vm_size_t);
198extern void (*arm64_icache_sync_range)(void *, vm_size_t);
181199
182200#define cpu_icache_sync_range(a, s) arm64_icache_sync_range((a), (s))
183201#define cpu_icache_sync_range_checked(a, s) arm64_icache_sync_range_checked((a), (s))
184202
185203void arm64_nullop(void);
186204void arm64_tlb_flushID(void);
187void arm64_dic_idc_icache_sync_range(vm_offset_t, vm_size_t);
188void arm64_idc_aliasing_icache_sync_range(vm_offset_t, vm_size_t);
189void arm64_aliasing_icache_sync_range(vm_offset_t, vm_size_t);
190int arm64_icache_sync_range_checked(vm_offset_t, vm_size_t);
191void arm64_dcache_wbinv_range(vm_offset_t, vm_size_t);
192void arm64_dcache_inv_range(vm_offset_t, vm_size_t);
193void arm64_dcache_wb_range(vm_offset_t, vm_size_t);
194bool arm64_get_writable_addr(vm_offset_t, vm_offset_t *);
205void arm64_dic_idc_icache_sync_range(void *, vm_size_t);
206void arm64_idc_aliasing_icache_sync_range(void *, vm_size_t);
207void arm64_aliasing_icache_sync_range(void *, vm_size_t);
208int arm64_icache_sync_range_checked(void *, vm_size_t);
209void arm64_dcache_wbinv_range(void *, vm_size_t);
210void arm64_dcache_inv_range(void *, vm_size_t);
211void arm64_dcache_wb_range(void *, vm_size_t);
212bool arm64_get_writable_addr(void *, void **);
195213
196214#endif /* _KERNEL */
197215#endif /* _MACHINE_CPUFUNC_H_ */
lib/libc/include/aarch64-freebsd-none/machine/db_machdep.h+3
......@@ -40,6 +40,9 @@
4040#define T_SINGLESTEP (EXCP_SOFTSTP_EL1)
4141#define T_WATCHPOINT (EXCP_WATCHPT_EL1)
4242
43#define HAS_HW_BREAKPOINT
44#define NHBREAKPOINTS 16
45
4346typedef vm_offset_t db_addr_t;
4447typedef long db_expr_t;
4548
lib/libc/include/aarch64-freebsd-none/machine/debug_monitor.h+1
......@@ -56,6 +56,7 @@ void dbg_monitor_init(void);
5656void dbg_register_sync(struct debug_monitor_state *);
5757
5858#ifdef DDB
59void dbg_show_breakpoint(void);
5960void dbg_show_watchpoint(void);
6061#endif
6162
lib/libc/include/aarch64-freebsd-none/machine/efi.h+3-1
......@@ -35,6 +35,8 @@
3535#ifndef __ARM64_INCLUDE_EFI_H_
3636#define __ARM64_INCLUDE_EFI_H_
3737
38#include <sys/types.h>
39
3840#define EFIABI_ATTR
3941
4042#ifdef _KERNEL
......@@ -44,7 +46,7 @@
4446#define EFI_TIME_UNLOCK()
4547#define EFI_TIME_OWNED()
4648
47#define EFI_RT_HANDLE_FAULTS_DEFAULT 0
49#define EFI_RT_HANDLE_FAULTS_DEFAULT 1
4850#endif
4951
5052struct efirt_callinfo {
lib/libc/include/aarch64-freebsd-none/machine/elf.h+100-77
......@@ -93,91 +93,114 @@ __ElfType(Auxinfo);
9393#define ET_DYN_LOAD_ADDR 0x100000
9494#endif
9595
96/* First __FreeBSD_version that supports Top Byte Ignore (TBI) */
97#define TBI_VERSION 1500058
98
9699/* HWCAP */
97#define HWCAP_FP 0x00000001
98#define HWCAP_ASIMD 0x00000002
99#define HWCAP_EVTSTRM 0x00000004
100#define HWCAP_AES 0x00000008
101#define HWCAP_PMULL 0x00000010
102#define HWCAP_SHA1 0x00000020
103#define HWCAP_SHA2 0x00000040
104#define HWCAP_CRC32 0x00000080
105#define HWCAP_ATOMICS 0x00000100
106#define HWCAP_FPHP 0x00000200
107#define HWCAP_ASIMDHP 0x00000400
100#define HWCAP_FP (1 << 0)
101#define HWCAP_ASIMD (1 << 1)
102#define HWCAP_EVTSTRM (1 << 2)
103#define HWCAP_AES (1 << 3)
104#define HWCAP_PMULL (1 << 4)
105#define HWCAP_SHA1 (1 << 5)
106#define HWCAP_SHA2 (1 << 6)
107#define HWCAP_CRC32 (1 << 7)
108#define HWCAP_ATOMICS (1 << 8)
109#define HWCAP_FPHP (1 << 9)
110#define HWCAP_ASIMDHP (1 << 10)
108111/*
109112 * XXX: The following bits (from CPUID to FLAGM) were originally incorrect,
110113 * but later changed to match the Linux definitions. No compatibility code is
111114 * provided, as the fix was expected to result in near-zero fallout.
112115 */
113#define HWCAP_CPUID 0x00000800
114#define HWCAP_ASIMDRDM 0x00001000
115#define HWCAP_JSCVT 0x00002000
116#define HWCAP_FCMA 0x00004000
117#define HWCAP_LRCPC 0x00008000
118#define HWCAP_DCPOP 0x00010000
119#define HWCAP_SHA3 0x00020000
120#define HWCAP_SM3 0x00040000
121#define HWCAP_SM4 0x00080000
122#define HWCAP_ASIMDDP 0x00100000
123#define HWCAP_SHA512 0x00200000
124#define HWCAP_SVE 0x00400000
125#define HWCAP_ASIMDFHM 0x00800000
126#define HWCAP_DIT 0x01000000
127#define HWCAP_USCAT 0x02000000
128#define HWCAP_ILRCPC 0x04000000
129#define HWCAP_FLAGM 0x08000000
130#define HWCAP_SSBS 0x10000000
131#define HWCAP_SB 0x20000000
132#define HWCAP_PACA 0x40000000
133#define HWCAP_PACG 0x80000000
116#define HWCAP_CPUID (1 << 11)
117#define HWCAP_ASIMDRDM (1 << 12)
118#define HWCAP_JSCVT (1 << 13)
119#define HWCAP_FCMA (1 << 14)
120#define HWCAP_LRCPC (1 << 15)
121#define HWCAP_DCPOP (1 << 16)
122#define HWCAP_SHA3 (1 << 17)
123#define HWCAP_SM3 (1 << 18)
124#define HWCAP_SM4 (1 << 19)
125#define HWCAP_ASIMDDP (1 << 20)
126#define HWCAP_SHA512 (1 << 21)
127#define HWCAP_SVE (1 << 22)
128#define HWCAP_ASIMDFHM (1 << 23)
129#define HWCAP_DIT (1 << 24)
130#define HWCAP_USCAT (1 << 25)
131#define HWCAP_ILRCPC (1 << 26)
132#define HWCAP_FLAGM (1 << 27)
133#define HWCAP_SSBS (1 << 28)
134#define HWCAP_SB (1 << 29)
135#define HWCAP_PACA (1 << 30)
136#define HWCAP_PACG (1UL << 31)
137#define HWCAP_GCS (1UL << 32)
134138
135139/* HWCAP2 */
136#define HWCAP2_DCPODP 0x0000000000000001ul
137#define HWCAP2_SVE2 0x0000000000000002ul
138#define HWCAP2_SVEAES 0x0000000000000004ul
139#define HWCAP2_SVEPMULL 0x0000000000000008ul
140#define HWCAP2_SVEBITPERM 0x0000000000000010ul
141#define HWCAP2_SVESHA3 0x0000000000000020ul
142#define HWCAP2_SVESM4 0x0000000000000040ul
143#define HWCAP2_FLAGM2 0x0000000000000080ul
144#define HWCAP2_FRINT 0x0000000000000100ul
145#define HWCAP2_SVEI8MM 0x0000000000000200ul
146#define HWCAP2_SVEF32MM 0x0000000000000400ul
147#define HWCAP2_SVEF64MM 0x0000000000000800ul
148#define HWCAP2_SVEBF16 0x0000000000001000ul
149#define HWCAP2_I8MM 0x0000000000002000ul
150#define HWCAP2_BF16 0x0000000000004000ul
151#define HWCAP2_DGH 0x0000000000008000ul
152#define HWCAP2_RNG 0x0000000000010000ul
153#define HWCAP2_BTI 0x0000000000020000ul
154#define HWCAP2_MTE 0x0000000000040000ul
155#define HWCAP2_ECV 0x0000000000080000ul
156#define HWCAP2_AFP 0x0000000000100000ul
157#define HWCAP2_RPRES 0x0000000000200000ul
158#define HWCAP2_MTE3 0x0000000000400000ul
159#define HWCAP2_SME 0x0000000000800000ul
160#define HWCAP2_SME_I16I64 0x0000000001000000ul
161#define HWCAP2_SME_F64F64 0x0000000002000000ul
162#define HWCAP2_SME_I8I32 0x0000000004000000ul
163#define HWCAP2_SME_F16F32 0x0000000008000000ul
164#define HWCAP2_SME_B16F32 0x0000000010000000ul
165#define HWCAP2_SME_F32F32 0x0000000020000000ul
166#define HWCAP2_SME_FA64 0x0000000040000000ul
167#define HWCAP2_WFXT 0x0000000080000000ul
168#define HWCAP2_EBF16 0x0000000100000000ul
169#define HWCAP2_SVE_EBF16 0x0000000200000000ul
170#define HWCAP2_CSSC 0x0000000400000000ul
171#define HWCAP2_RPRFM 0x0000000800000000ul
172#define HWCAP2_SVE2P1 0x0000001000000000ul
173#define HWCAP2_SME2 0x0000002000000000ul
174#define HWCAP2_SME2P1 0x0000004000000000ul
175#define HWCAP2_SME_I16I32 0x0000008000000000ul
176#define HWCAP2_SME_BI32I32 0x0000010000000000ul
177#define HWCAP2_SME_B16B16 0x0000020000000000ul
178#define HWCAP2_SME_F16F16 0x0000040000000000ul
179#define HWCAP2_MOPS 0x0000080000000000ul
180#define HWCAP2_HBC 0x0000100000000000ul
140#define HWCAP2_DCPODP (1 << 0)
141#define HWCAP2_SVE2 (1 << 1)
142#define HWCAP2_SVEAES (1 << 2)
143#define HWCAP2_SVEPMULL (1 << 3)
144#define HWCAP2_SVEBITPERM (1 << 4)
145#define HWCAP2_SVESHA3 (1 << 5)
146#define HWCAP2_SVESM4 (1 << 6)
147#define HWCAP2_FLAGM2 (1 << 7)
148#define HWCAP2_FRINT (1 << 8)
149#define HWCAP2_SVEI8MM (1 << 9)
150#define HWCAP2_SVEF32MM (1 << 10)
151#define HWCAP2_SVEF64MM (1 << 11)
152#define HWCAP2_SVEBF16 (1 << 12)
153#define HWCAP2_I8MM (1 << 13)
154#define HWCAP2_BF16 (1 << 14)
155#define HWCAP2_DGH (1 << 15)
156#define HWCAP2_RNG (1 << 16)
157#define HWCAP2_BTI (1 << 17)
158#define HWCAP2_MTE (1 << 18)
159#define HWCAP2_ECV (1 << 19)
160#define HWCAP2_AFP (1 << 20)
161#define HWCAP2_RPRES (1 << 21)
162#define HWCAP2_MTE3 (1 << 22)
163#define HWCAP2_SME (1 << 23)
164#define HWCAP2_SME_I16I64 (1 << 24)
165#define HWCAP2_SME_F64F64 (1 << 25)
166#define HWCAP2_SME_I8I32 (1 << 26)
167#define HWCAP2_SME_F16F32 (1 << 27)
168#define HWCAP2_SME_B16F32 (1 << 28)
169#define HWCAP2_SME_F32F32 (1 << 29)
170#define HWCAP2_SME_FA64 (1 << 30)
171#define HWCAP2_WFXT (1UL << 31)
172#define HWCAP2_EBF16 (1UL << 32)
173#define HWCAP2_SVE_EBF16 (1UL << 33)
174#define HWCAP2_CSSC (1UL << 34)
175#define HWCAP2_RPRFM (1UL << 35)
176#define HWCAP2_SVE2P1 (1UL << 36)
177#define HWCAP2_SME2 (1UL << 37)
178#define HWCAP2_SME2P1 (1UL << 38)
179#define HWCAP2_SME_I16I32 (1UL << 39)
180#define HWCAP2_SME_BI32I32 (1UL << 40)
181#define HWCAP2_SME_B16B16 (1UL << 41)
182#define HWCAP2_SME_F16F16 (1UL << 42)
183#define HWCAP2_MOPS (1UL << 43)
184#define HWCAP2_HBC (1UL << 44)
185#define HWCAP2_SVE_B16B16 (1UL << 45)
186#define HWCAP2_LRCPC3 (1UL << 46)
187#define HWCAP2_LSE128 (1UL << 47)
188#define HWCAP2_FPMR (1UL << 48)
189#define HWCAP2_LUT (1UL << 49)
190#define HWCAP2_FAMINMAX (1UL << 50)
191#define HWCAP2_F8CVT (1UL << 51)
192#define HWCAP2_F8FMA (1UL << 52)
193#define HWCAP2_F8DP4 (1UL << 53)
194#define HWCAP2_F8DP2 (1UL << 54)
195#define HWCAP2_F8E4M3 (1UL << 55)
196#define HWCAP2_F8E5M2 (1UL << 56)
197#define HWCAP2_SME_LUTV2 (1UL << 57)
198#define HWCAP2_SME_F8F16 (1UL << 58)
199#define HWCAP2_SME_F8F32 (1UL << 59)
200#define HWCAP2_SME_SF8FMA (1UL << 60)
201#define HWCAP2_SME_SF8DP4 (1UL << 61)
202#define HWCAP2_SME_SF8DP2 (1UL << 62)
203#define HWCAP2_POE (1UL << 63)
181204
182205#ifdef COMPAT_FREEBSD32
183206/* ARM HWCAP */
lib/libc/include/aarch64-freebsd-none/machine/endian.h-2
......@@ -24,8 +24,6 @@
2424 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2525 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2626 * SUCH DAMAGE.
27 *
28 * @(#)endian.h 8.1 (Berkeley) 6/10/93
2927 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
3028 */
3129
lib/libc/include/aarch64-freebsd-none/machine/float.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3028 */
3129
3230#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/frame.h+1-1
......@@ -70,7 +70,7 @@ struct frame {
7070
7171#ifdef COMPAT_FREEBSD32
7272struct sigframe32 {
73 struct siginfo32 sf_si;
73 struct __siginfo32 sf_si;
7474 ucontext32_t sf_uc;
7575 mcontext32_vfp_t sf_vfp;
7676};
lib/libc/include/aarch64-freebsd-none/machine/hypervisor.h+105-50
......@@ -41,21 +41,38 @@
4141#define CNTHCTL_EL1PCTEN (1 << 0) /* Allow physical counter access */
4242#define CNTHCTL_EL1PCEN (1 << 1) /* Allow physical timer access */
4343/* Valid if HCR_EL2.E2H == 1 */
44#define CNTHCTL_E2H_EL0PCTEN (1 << 0) /* Allow EL0 physical counter access */
45#define CNTHCTL_E2H_EL0VCTEN (1 << 1) /* Allow EL0 virtual counter access */
46#define CNTHCTL_E2H_EL0VTEN (1 << 8)
47#define CNTHCTL_E2H_EL0PTEN (1 << 9)
4448#define CNTHCTL_E2H_EL1PCTEN (1 << 10) /* Allow physical counter access */
4549#define CNTHCTL_E2H_EL1PTEN (1 << 11) /* Allow physical timer access */
4650/* Unconditionally valid */
4751#define CNTHCTL_EVNTDIR (1 << 3) /* Control transition trigger bit */
4852#define CNTHCTL_EVNTEN (1 << 2) /* Enable event stream */
4953
54/* CNTPOFF_EL2 - Counter-timer Physical Offset Register */
55#define CNTPOFF_EL2_REG MRS_REG_ALT_NAME(CNTPOFF_EL2)
56#define CNTPOFF_EL2_op0 3
57#define CNTPOFF_EL2_op1 4
58#define CNTPOFF_EL2_CRn 14
59#define CNTPOFF_EL2_CRm 0
60#define CNTPOFF_EL2_op2 6
61
5062/* CPTR_EL2 - Architecture feature trap register */
5163/* Valid if HCR_EL2.E2H == 0 */
64#define CPTR_TRAP_ALL 0xc01037ff /* Enable all traps */
5265#define CPTR_RES0 0x7fefc800
5366#define CPTR_RES1 0x000032ff
67#define CPTR_TZ 0x00000100
5468#define CPTR_TFP 0x00000400
69#define CPTR_TTA 0x00100000
5570/* Valid if HCR_EL2.E2H == 1 */
56#define CPTR_FPEN 0x00300000
71#define CPTR_E2H_TRAP_ALL 0xd0000000
72#define CPTR_E2H_ZPEN 0x00030000
73#define CPTR_E2H_FPEN 0x00300000
74#define CPTR_E2H_TTA 0x10000000
5775/* Unconditionally valid */
58#define CPTR_TTA 0x00100000
5976#define CPTR_TCPAC 0x80000000
6077
6178/* HCR_EL2 - Hypervisor Config Register */
......@@ -123,6 +140,41 @@
123140#define HCR_TWEDEn (UL(0x1) << 59)
124141#define HCR_TWEDEL_MASK (UL(0xf) << 60)
125142
143/* HCRX_EL2 - Extended Hypervisor Configuration Register */
144#define HCRX_EL2_REG MRS_REG_ALT_NAME(HCRX_EL2)
145#define HCRX_EL2_op0 3
146#define HCRX_EL2_op1 4
147#define HCRX_EL2_CRn 1
148#define HCRX_EL2_CRm 2
149#define HCRX_EL2_op2 2
150
151#define HCRX_EnAS0 (UL(0x1) << 0)
152#define HCRX_EnALS (UL(0x1) << 1)
153#define HCRX_EnASR (UL(0x1) << 2)
154#define HCRX_FnXS (UL(0x1) << 3)
155#define HCRX_FGTnXS (UL(0x1) << 4)
156#define HCRX_SMPME (UL(0x1) << 5)
157#define HCRX_TALLINT (UL(0x1) << 6)
158#define HCRX_VINMI (UL(0x1) << 7)
159#define HCRX_VFNMI (UL(0x1) << 8)
160#define HCRX_CMOW (UL(0x1) << 9)
161#define HCRX_MCE2 (UL(0x1) << 10)
162#define HCRX_MSCEn (UL(0x1) << 11)
163/* Bits 12 & 13 are reserved */
164#define HCRX_TCR2En (UL(0x1) << 14)
165#define HCRX_SCTLR2En (UL(0x1) << 15)
166#define HCRX_PTTWI (UL(0x1) << 16)
167#define HCRX_D128En (UL(0x1) << 17)
168#define HCRX_EnSNERR (UL(0x1) << 18)
169#define HCRX_TMEA (UL(0x1) << 19)
170#define HCRX_EnSDERR (UL(0x1) << 20)
171#define HCRX_EnIDCP128 (UL(0x1) << 21)
172#define HCRX_GCSEn (UL(0x1) << 22)
173#define HCRX_EnFPM (UL(0x1) << 23)
174#define HCRX_PACMEn (UL(0x1) << 24)
175/* Bit 25 is reserved */
176#define HCRX_SRMASKEn (UL(0x1) << 26)
177
126178/* HPFAR_EL2 - Hypervisor IPA Fault Address Register */
127179#define HPFAR_EL2_FIPA_SHIFT 4
128180#define HPFAR_EL2_FIPA_MASK 0xfffffffff0
......@@ -138,6 +190,54 @@
138190#define ICC_SRE_EL2_SRE (1UL << 0)
139191#define ICC_SRE_EL2_EN (1UL << 3)
140192
193/* MDCR_EL2 - Hyp Debug Control Register */
194#define MDCR_EL2_HPMN_MASK 0x1f
195#define MDCR_EL2_HPMN_SHIFT 0
196#define MDCR_EL2_TPMCR_SHIFT 5
197#define MDCR_EL2_TPMCR (0x1UL << MDCR_EL2_TPMCR_SHIFT)
198#define MDCR_EL2_TPM_SHIFT 6
199#define MDCR_EL2_TPM (0x1UL << MDCR_EL2_TPM_SHIFT)
200#define MDCR_EL2_HPME_SHIFT 7
201#define MDCR_EL2_HPME (0x1UL << MDCR_EL2_HPME_SHIFT)
202#define MDCR_EL2_TDE_SHIFT 8
203#define MDCR_EL2_TDE (0x1UL << MDCR_EL2_TDE_SHIFT)
204#define MDCR_EL2_TDA_SHIFT 9
205#define MDCR_EL2_TDA (0x1UL << MDCR_EL2_TDA_SHIFT)
206#define MDCR_EL2_TDOSA_SHIFT 10
207#define MDCR_EL2_TDOSA (0x1UL << MDCR_EL2_TDOSA_SHIFT)
208#define MDCR_EL2_TDRA_SHIFT 11
209#define MDCR_EL2_TDRA (0x1UL << MDCR_EL2_TDRA_SHIFT)
210#define MDCR_EL2_E2PB_SHIFT 12
211#define MDCR_EL2_E2PB_MASK (0x3UL << MDCR_EL2_E2PB_SHIFT)
212#define MDCR_EL2_TPMS_SHIFT 14
213#define MDCR_EL2_TPMS (0x1UL << MDCR_EL2_TPMS_SHIFT)
214#define MDCR_EL2_EnSPM_SHIFT 15
215#define MDCR_EL2_EnSPM (0x1UL << MDCR_EL2_EnSPM_SHIFT)
216#define MDCR_EL2_HPMD_SHIFT 17
217#define MDCR_EL2_HPMD (0x1UL << MDCR_EL2_HPMD_SHIFT)
218#define MDCR_EL2_TTRF_SHIFT 19
219#define MDCR_EL2_TTRF (0x1UL << MDCR_EL2_TTRF_SHIFT)
220#define MDCR_EL2_HCCD_SHIFT 23
221#define MDCR_EL2_HCCD (0x1UL << MDCR_EL2_HCCD_SHIFT)
222#define MDCR_EL2_E2TB_SHIFT 24
223#define MDCR_EL2_E2TB_MASK (0x3UL << MDCR_EL2_E2TB_SHIFT)
224#define MDCR_EL2_HLP_SHIFT 26
225#define MDCR_EL2_HLP (0x1UL << MDCR_EL2_HLP_SHIFT)
226#define MDCR_EL2_TDCC_SHIFT 27
227#define MDCR_EL2_TDCC (0x1UL << MDCR_EL2_TDCC_SHIFT)
228#define MDCR_EL2_MTPME_SHIFT 28
229#define MDCR_EL2_MTPME (0x1UL << MDCR_EL2_MTPME_SHIFT)
230#define MDCR_EL2_HPMFZO_SHIFT 29
231#define MDCR_EL2_HPMFZO (0x1UL << MDCR_EL2_HPMFZO_SHIFT)
232#define MDCR_EL2_PMSSE_SHIFT 30
233#define MDCR_EL2_PMSSE_MASK (0x3UL << MDCR_EL2_PMSSE_SHIFT)
234#define MDCR_EL2_HPMFZS_SHIFT 36
235#define MDCR_EL2_HPMFZS (0x1UL << MDCR_EL2_HPMFZS_SHIFT)
236#define MDCR_EL2_PMEE_SHIFT 40
237#define MDCR_EL2_PMEE_MASK (0x3UL << MDCR_EL2_PMEE_SHIFT)
238#define MDCR_EL2_EBWE_SHIFT 43
239#define MDCR_EL2_EBWE (0x1UL << MDCR_EL2_EBWE_SHIFT)
240
141241/* SCTLR_EL2 - System Control Register */
142242#define SCTLR_EL2_RES1 0x30c50830
143243#define SCTLR_EL2_M_SHIFT 0
......@@ -237,6 +337,9 @@
237337#define VTCR_EL2_PS_42BIT (0x3UL << VTCR_EL2_PS_SHIFT)
238338#define VTCR_EL2_PS_44BIT (0x4UL << VTCR_EL2_PS_SHIFT)
239339#define VTCR_EL2_PS_48BIT (0x5UL << VTCR_EL2_PS_SHIFT)
340#define VTCR_EL2_PS_52BIT (0x6UL << VTCR_EL2_PS_SHIFT)
341#define VTCR_EL2_DS_SHIFT 32
342#define VTCR_EL2_DS (0x1UL << VTCR_EL2_DS_SHIFT)
240343
241344/* VTTBR_EL2 - Virtualization Translation Table Base Register */
242345#define VTTBR_VMID_MASK 0xffff000000000000
......@@ -244,52 +347,4 @@
244347/* Assumed to be 0 by locore.S */
245348#define VTTBR_HOST 0x0000000000000000
246349
247/* MDCR_EL2 - Hyp Debug Control Register */
248#define MDCR_EL2_HPMN_MASK 0x1f
249#define MDCR_EL2_HPMN_SHIFT 0
250#define MDCR_EL2_TPMCR_SHIFT 5
251#define MDCR_EL2_TPMCR (0x1UL << MDCR_EL2_TPMCR_SHIFT)
252#define MDCR_EL2_TPM_SHIFT 6
253#define MDCR_EL2_TPM (0x1UL << MDCR_EL2_TPM_SHIFT)
254#define MDCR_EL2_HPME_SHIFT 7
255#define MDCR_EL2_HPME (0x1UL << MDCR_EL2_HPME_SHIFT)
256#define MDCR_EL2_TDE_SHIFT 8
257#define MDCR_EL2_TDE (0x1UL << MDCR_EL2_TDE_SHIFT)
258#define MDCR_EL2_TDA_SHIFT 9
259#define MDCR_EL2_TDA (0x1UL << MDCR_EL2_TDA_SHIFT)
260#define MDCR_EL2_TDOSA_SHIFT 10
261#define MDCR_EL2_TDOSA (0x1UL << MDCR_EL2_TDOSA_SHIFT)
262#define MDCR_EL2_TDRA_SHIFT 11
263#define MDCR_EL2_TDRA (0x1UL << MDCR_EL2_TDRA_SHIFT)
264#define MDCR_E2PB_SHIFT 12
265#define MDCR_E2PB_MASK (0x3UL << MDCR_E2PB_SHIFT)
266#define MDCR_TPMS_SHIFT 14
267#define MDCR_TPMS (0x1UL << MDCR_TPMS_SHIFT)
268#define MDCR_EnSPM_SHIFT 15
269#define MDCR_EnSPM (0x1UL << MDCR_EnSPM_SHIFT)
270#define MDCR_HPMD_SHIFT 17
271#define MDCR_HPMD (0x1UL << MDCR_HPMD_SHIFT)
272#define MDCR_TTRF_SHIFT 19
273#define MDCR_TTRF (0x1UL << MDCR_TTRF_SHIFT)
274#define MDCR_HCCD_SHIFT 23
275#define MDCR_HCCD (0x1UL << MDCR_HCCD_SHIFT)
276#define MDCR_E2TB_SHIFT 24
277#define MDCR_E2TB_MASK (0x3UL << MDCR_E2TB_SHIFT)
278#define MDCR_HLP_SHIFT 26
279#define MDCR_HLP (0x1UL << MDCR_HLP_SHIFT)
280#define MDCR_TDCC_SHIFT 27
281#define MDCR_TDCC (0x1UL << MDCR_TDCC_SHIFT)
282#define MDCR_MTPME_SHIFT 28
283#define MDCR_MTPME (0x1UL << MDCR_MTPME_SHIFT)
284#define MDCR_HPMFZO_SHIFT 29
285#define MDCR_HPMFZO (0x1UL << MDCR_HPMFZO_SHIFT)
286#define MDCR_PMSSE_SHIFT 30
287#define MDCR_PMSSE_MASK (0x3UL << MDCR_PMSSE_SHIFT)
288#define MDCR_HPMFZS_SHIFT 36
289#define MDCR_HPMFZS (0x1UL << MDCR_HPMFZS_SHIFT)
290#define MDCR_PMEE_SHIFT 40
291#define MDCR_PMEE_MASK (0x3UL << MDCR_PMEE_SHIFT)
292#define MDCR_EBWE_SHIFT 43
293#define MDCR_EBWE (0x1UL << MDCR_EBWE_SHIFT)
294
295350#endif /* !_MACHINE_HYPERVISOR_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/in_cksum.h-1
......@@ -27,7 +27,6 @@
2727 * SUCH DAMAGE.
2828 *
2929 * from tahoe: in_cksum.c 1.2 86/01/05
30 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
3130 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
3231 */
3332
lib/libc/include/aarch64-freebsd-none/machine/intr.h+10-6
......@@ -27,20 +27,20 @@
2727#ifndef _MACHINE_INTR_H_
2828#define _MACHINE_INTR_H_
2929
30#ifndef LOCORE
3031#ifdef FDT
3132#include <dev/ofw/openfirm.h>
3233#endif
3334
34#include <sys/intr.h>
35
36#ifndef NIRQ
37#define NIRQ 16384 /* XXX - It should be an option. */
38#endif
39
4035static inline void
4136arm_irq_memory_barrier(uintptr_t irq)
4237{
4338}
39#endif /* !LOCORE */
40
41#ifndef NIRQ
42#define NIRQ 16384 /* XXX - It should be an option. */
43#endif
4444
4545#ifdef DEV_ACPI
4646#define ACPI_INTR_XREF 1
......@@ -48,4 +48,8 @@ arm_irq_memory_barrier(uintptr_t irq)
4848#define ACPI_GPIO_XREF 3
4949#endif
5050
51#define INTR_ROOT_IRQ 0
52#define INTR_ROOT_FIQ 1
53#define INTR_ROOT_COUNT 2
54
5155#endif /* _MACHINE_INTR_H */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/kdb.h+3-1
......@@ -37,6 +37,8 @@
3737
3838void kdb_cpu_clear_singlestep(void);
3939void kdb_cpu_set_singlestep(void);
40int kdb_cpu_set_breakpoint(vm_offset_t addr);
41int kdb_cpu_clr_breakpoint(vm_offset_t addr);
4042int kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access);
4143int kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size);
4244
......@@ -44,7 +46,7 @@ static __inline void
4446kdb_cpu_sync_icache(unsigned char *addr, size_t size)
4547{
4648
47 cpu_icache_sync_range((vm_offset_t)addr, size);
49 cpu_icache_sync_range(addr, size);
4850}
4951
5052static __inline void
lib/libc/include/aarch64-freebsd-none/machine/machdep.h+1-1
......@@ -33,7 +33,6 @@ struct arm64_bootparams {
3333 vm_offset_t modulep;
3434 vm_offset_t kern_stack;
3535 vm_paddr_t kern_ttbr0;
36 uint64_t hcr_el2;
3736 int boot_el; /* EL the kernel booted from */
3837 int pad;
3938};
......@@ -48,6 +47,7 @@ extern enum arm64_bus arm64_bus_method;
4847
4948void dbg_init(void);
5049bool has_hyp(void);
50bool in_vhe(void);
5151void initarm(struct arm64_bootparams *);
5252vm_offset_t parse_boot_param(struct arm64_bootparams *abp);
5353#ifdef FDT
lib/libc/include/aarch64-freebsd-none/machine/md_var.h+4
......@@ -37,8 +37,12 @@ extern char sigcode[];
3737extern int szsigcode;
3838extern u_long elf_hwcap;
3939extern u_long elf_hwcap2;
40extern u_long elf_hwcap3;
41extern u_long elf_hwcap4;
4042extern u_long linux_elf_hwcap;
4143extern u_long linux_elf_hwcap2;
44extern u_long linux_elf_hwcap3;
45extern u_long linux_elf_hwcap4;
4246#ifdef COMPAT_FREEBSD32
4347extern u_long elf32_hwcap;
4448extern u_long elf32_hwcap2;
lib/libc/include/aarch64-freebsd-none/machine/metadata.h+8-3
......@@ -31,10 +31,15 @@
3131#define MODINFOMD_DTBP 0x1002
3232#define MODINFOMD_EFI_FB 0x1003
3333
34/*
35 * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though
36 * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table
37 * starting at a 16-byte alignment.
38 */
3439struct efi_map_header {
35 size_t memory_size;
36 size_t descriptor_size;
37 uint32_t descriptor_version;
40 size_t memory_size; /* Numnber of bytes that follow */
41 size_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
42 uint32_t descriptor_version; /* Currently '1' */
3843};
3944
4045struct efi_fb {
lib/libc/include/aarch64-freebsd-none/machine/msan.h created+91
......@@ -0,0 +1,91 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021 The FreeBSD Foundation
5 * Copyright (c) 2023 Juniper Networks, Inc.
6 *
7 * This software was developed by Mark Johnston under sponsorship from the
8 * FreeBSD Foundation.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_MSAN_H_
33#define _MACHINE_MSAN_H_
34
35#ifdef KMSAN
36
37#include <vm/vm.h>
38#include <vm/pmap.h>
39#include <vm/vm_page.h>
40#include <machine/vmparam.h>
41
42typedef uint32_t msan_orig_t;
43
44/*
45 * Our 32-bit origin cells encode a 2-bit type and 30-bit pointer to a kernel
46 * instruction. The pointer is compressed by making it a positive offset
47 * relative to KERNBASE.
48 */
49#define KMSAN_ORIG_TYPE_SHIFT 30u
50#define KMSAN_ORIG_PTR_MASK ((1ul << KMSAN_ORIG_TYPE_SHIFT) - 1)
51
52static inline msan_orig_t
53kmsan_md_orig_encode(int type, uintptr_t ptr)
54{
55 return ((type << KMSAN_ORIG_TYPE_SHIFT) |
56 ((ptr & KMSAN_ORIG_PTR_MASK)));
57}
58
59static inline void
60kmsan_md_orig_decode(msan_orig_t orig, int *type, uintptr_t *ptr)
61{
62 *type = orig >> KMSAN_ORIG_TYPE_SHIFT;
63 *ptr = (orig & KMSAN_ORIG_PTR_MASK) | KERNBASE;
64}
65
66static inline vm_offset_t
67kmsan_md_addr_to_shad(vm_offset_t addr)
68{
69 return (addr - VM_MIN_KERNEL_ADDRESS + KMSAN_SHAD_MIN_ADDRESS);
70}
71
72static inline vm_offset_t
73kmsan_md_addr_to_orig(vm_offset_t addr)
74{
75 return (addr - VM_MIN_KERNEL_ADDRESS + KMSAN_ORIG_MIN_ADDRESS);
76}
77
78static inline bool
79kmsan_md_unsupported(vm_offset_t addr)
80{
81 /*
82 * It would be cheaper to use VM_MAX_KERNEL_ADDRESS as the upper bound,
83 * but we need to exclude device mappings above kernel_vm_end but within
84 * the kernel map.
85 */
86 return (addr < VM_MIN_KERNEL_ADDRESS || addr >= kernel_vm_end);
87}
88
89#endif /* KMSAN */
90
91#endif /* !_MACHINE_MSAN_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/param.h+1-13
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
3028 */
3129
3230#ifdef __arm__
......@@ -45,8 +43,6 @@
4543#define STACKALIGNBYTES (16 - 1)
4644#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
4745
48#define __PCI_REROUTE_INTERRUPT
49
5046#ifndef MACHINE
5147#define MACHINE "arm64"
5248#endif
......@@ -99,7 +95,7 @@
9995#define PAGE_SIZE (1 << PAGE_SHIFT)
10096#define PAGE_MASK (PAGE_SIZE - 1)
10197
102#define MAXPAGESIZES 3 /* maximum number of supported page sizes */
98#define MAXPAGESIZES 4 /* maximum number of supported page sizes */
10399
104100#ifndef KSTACK_PAGES
105101#if defined(KASAN) || defined(KMSAN)
......@@ -121,17 +117,9 @@
121117/*
122118 * Mach derived conversion macros
123119 */
124#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK)
125#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK)
126
127#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT)
128#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT)
129
130120#define arm64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
131121#define arm64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
132122
133#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
134
135123#endif /* !_MACHINE_PARAM_H_ */
136124
137125#endif /* !__arm__ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/pci_cfgreg.h+2-5
......@@ -27,10 +27,7 @@
2727#define _MACHINE_PCI_CFGREG_H
2828
2929int pci_cfgregopen(void);
30uint32_t pci_cfgregread_domain(int, int, int, int, int, int);
31void pci_cfgregwrite_domain(int, int, int, int, int, uint32_t, int);
32
33#define pci_cfgregread pci_cfgregread_domain
34#define pci_cfgregwrite pci_cfgregwrite_domain
30uint32_t pci_cfgregread(int, int, int, int, int, int);
31void pci_cfgregwrite(int, int, int, int, int, uint32_t, int);
3532
3633#endif /* !_MACHINE_PCI_CFGREG_H */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/pcpu.h-1
......@@ -48,7 +48,6 @@ struct debug_monitor_state;
4848 pcpu_ssbd pc_ssbd; \
4949 struct pmap *pc_curpmap; \
5050 struct pmap *pc_curvmpmap; \
51 /* Store as two u_int values to preserve KBI */ \
5251 uint64_t pc_mpidr; \
5352 u_int pc_bcast_tlbi_workaround; \
5453 char __pad[197]
lib/libc/include/aarch64-freebsd-none/machine/pmap.h+16-8
......@@ -63,10 +63,13 @@ void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
6363 * Pmap stuff
6464 */
6565
66struct rangeset;
67
6668struct md_page {
6769 TAILQ_HEAD(,pv_entry) pv_list;
6870 int pv_gen;
6971 vm_memattr_t pv_memattr;
72 uint8_t pv_reserve[3];
7073};
7174
7275enum pmap_stage {
......@@ -87,7 +90,8 @@ struct pmap {
8790 struct asid_set *pm_asid_set; /* The ASID/VMID set to use */
8891 enum pmap_stage pm_stage;
8992 int pm_levels;
90 uint64_t pm_reserved[4];
93 struct rangeset *pm_bti;
94 uint64_t pm_reserved[3];
9195};
9296typedef struct pmap *pmap_t;
9397
......@@ -98,6 +102,8 @@ extern struct pmap kernel_pmap_store;
98102#define kernel_pmap (&kernel_pmap_store)
99103#define pmap_kernel() kernel_pmap
100104
105extern bool pmap_lpa_enabled;
106
101107#define PMAP_ASSERT_LOCKED(pmap) \
102108 mtx_assert(&(pmap)->pm_mtx, MA_OWNED)
103109#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)
......@@ -124,6 +130,8 @@ extern struct pmap kernel_pmap_store;
124130extern vm_offset_t virtual_avail;
125131extern vm_offset_t virtual_end;
126132
133extern pt_entry_t pmap_sh_attr;
134
127135/*
128136 * Macros to test if a mapping is mappable with an L1 Section mapping
129137 * or an L2 Large Page mapping.
......@@ -134,7 +142,8 @@ extern vm_offset_t virtual_end;
134142#define pmap_vm_page_alloc_check(m)
135143
136144void pmap_activate_vm(pmap_t);
137void pmap_bootstrap(vm_size_t);
145void pmap_bootstrap_dmap(vm_size_t);
146void pmap_bootstrap(void);
138147int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);
139148int pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot);
140149void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);
......@@ -166,18 +175,17 @@ int pmap_fault(pmap_t, uint64_t, uint64_t);
166175
167176struct pcb *pmap_switch(struct thread *);
168177
178void pmap_s1_invalidate_all_kernel(void);
179
169180extern void (*pmap_clean_stage2_tlbi)(void);
170extern void (*pmap_invalidate_vpipt_icache)(void);
171181extern void (*pmap_stage2_invalidate_range)(uint64_t, vm_offset_t, vm_offset_t,
172182 bool);
173183extern void (*pmap_stage2_invalidate_all)(uint64_t);
174184
175static inline int
176pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused)
177{
185int pmap_vmspace_copy(pmap_t, pmap_t);
178186
179 return (0);
180}
187int pmap_bti_set(pmap_t, vm_offset_t, vm_offset_t);
188int pmap_bti_clear(pmap_t, vm_offset_t, vm_offset_t);
181189
182190#if defined(KASAN) || defined(KMSAN)
183191struct arm64_bootparams;
lib/libc/include/aarch64-freebsd-none/machine/proc.h+12-4
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3028 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
3129 */
3230
......@@ -37,6 +35,7 @@
3735#ifndef _MACHINE_PROC_H_
3836#define _MACHINE_PROC_H_
3937
38#ifndef LOCORE
4039struct ptrauth_key {
4140 uint64_t pa_key_lo;
4241 uint64_t pa_key_hi;
......@@ -67,12 +66,21 @@ struct mdthread {
6766 struct ptrauth_key apia;
6867 } md_ptrauth_kern;
6968
70 uint64_t md_reserved[4];
69 uint64_t md_efirt_tmp;
70 int md_efirt_dis_pf;
71
72 int md_reserved0;
73 uint64_t md_reserved[2];
7174};
7275
7376struct mdproc {
74 long md_dummy;
77 uint64_t md_tcr; /* TCR_EL1 fields to update */
78 uint64_t md_reserved[2];
7579};
80#endif /* !LOCORE */
81
82/* Fields that can be set in md_tcr */
83#define MD_TCR_FIELDS TCR_TBI0
7684
7785#define KINFO_PROC_SIZE 1088
7886#define KINFO_PROC32_SIZE 816
lib/libc/include/aarch64-freebsd-none/machine/pte.h+73-9
......@@ -54,13 +54,6 @@ typedef uint64_t pt_entry_t; /* page table entry */
5454#define ATTR_MASK_L UINT64_C(0x0000000000000fff)
5555#define ATTR_MASK (ATTR_MASK_H | ATTR_MASK_L)
5656
57#define BASE_MASK ~ATTR_MASK
58#define BASE_ADDR(x) ((x) & BASE_MASK)
59
60#define PTE_TO_PHYS(pte) BASE_ADDR(pte)
61/* Convert a phys addr to the output address field of a PTE */
62#define PHYS_TO_PTE(pa) (pa)
63
6457/* Bits 58:55 are reserved for software */
6558#define ATTR_SW_UNUSED1 (1UL << 58)
6659#define ATTR_SW_NO_PROMOTE (1UL << 57)
......@@ -80,13 +73,37 @@ typedef uint64_t pt_entry_t; /* page table entry */
8073
8174#define ATTR_CONTIGUOUS (1UL << 52)
8275#define ATTR_DBM (1UL << 51)
76#define ATTR_S1_GP_SHIFT 50
77#define ATTR_S1_GP (1UL << ATTR_S1_GP_SHIFT)
78
79/*
80 * Largest possible output address field for a level 3 page. Block
81 * entries will use fewer low address bits, but these are res0 so
82 * should be safe to include.
83 *
84 * This is also safe to use for the next-level table address for
85 * table entries as they encode a physical address in the same way.
86 */
87#if PAGE_SIZE == PAGE_SIZE_4K
88#define ATTR_ADDR UINT64_C(0x0003fffffffff000)
89#elif PAGE_SIZE == PAGE_SIZE_16K
90#define ATTR_ADDR UINT64_C(0x0003ffffffffc000)
91#else
92#error Unsupported page size
93#endif
94
8395#define ATTR_S1_nG (1 << 11)
8496#define ATTR_AF (1 << 10)
97/* When TCR_EL1.DS == 0 */
8598#define ATTR_SH(x) ((x) << 8)
8699#define ATTR_SH_MASK ATTR_SH(3)
87100#define ATTR_SH_NS 0 /* Non-shareable */
88101#define ATTR_SH_OS 2 /* Outer-shareable */
89102#define ATTR_SH_IS 3 /* Inner-shareable */
103/* When TCR_EL1.DS == 1 */
104#define ATTR_OA_51_50_SHIFT 8
105#define ATTR_OA_51_50_MASK (3 << ATTR_OA_51_50_SHIFT)
106#define ATTR_OA_51_50_DELTA (50 - 8) /* Delta from address to pte */
90107
91108#define ATTR_S1_AP_RW_BIT (1 << 7)
92109#define ATTR_S1_AP(x) ((x) << 6)
......@@ -110,8 +127,6 @@ typedef uint64_t pt_entry_t; /* page table entry */
110127#define ATTR_S2_MEMATTR_WT 0xa
111128#define ATTR_S2_MEMATTR_WB 0xf
112129
113#define ATTR_DEFAULT (ATTR_AF | ATTR_SH(ATTR_SH_IS))
114
115130#define ATTR_DESCR_MASK 3
116131#define ATTR_DESCR_VALID 1
117132#define ATTR_DESCR_TYPE_MASK 2
......@@ -119,6 +134,35 @@ typedef uint64_t pt_entry_t; /* page table entry */
119134#define ATTR_DESCR_TYPE_PAGE 2
120135#define ATTR_DESCR_TYPE_BLOCK 0
121136
137/*
138 * Superpage promotion requires that the bits specified by the following
139 * mask all be identical in the constituent PTEs.
140 */
141#define ATTR_PROMOTE (ATTR_MASK & ~(ATTR_CONTIGUOUS | ATTR_AF))
142
143/* Read the output address or next-level table address from a PTE */
144#define PTE_TO_PHYS(x) ({ \
145 pt_entry_t _pte = (x); \
146 vm_paddr_t _pa; \
147 _pa = _pte & ATTR_ADDR; \
148 if (pmap_lpa_enabled) \
149 _pa |= (_pte & ATTR_OA_51_50_MASK) << ATTR_OA_51_50_DELTA; \
150 _pa; \
151})
152
153/*
154 * Convert a physical address to an output address or next-level
155 * table address in a PTE
156 */
157#define PHYS_TO_PTE(x) ({ \
158 vm_paddr_t _pa = (x); \
159 pt_entry_t _pte; \
160 _pte = _pa & ATTR_ADDR; \
161 if (pmap_lpa_enabled) \
162 _pte |= (_pa >> ATTR_OA_51_50_DELTA) & ATTR_OA_51_50_MASK; \
163 _pte; \
164})
165
122166#if PAGE_SIZE == PAGE_SIZE_4K
123167#define L0_SHIFT 39
124168#define L1_SHIFT 30
......@@ -186,6 +230,26 @@ typedef uint64_t pt_entry_t; /* page table entry */
186230#define Ln_ADDR_MASK (Ln_ENTRIES - 1)
187231#define Ln_TABLE_MASK ((1 << 12) - 1)
188232
233/*
234 * The number of contiguous Level 3 entries (with ATTR_CONTIGUOUS set) that
235 * can be coalesced into a single TLB entry
236 */
237#if PAGE_SIZE == PAGE_SIZE_4K
238#define L2C_ENTRIES 16
239#define L3C_ENTRIES 16
240#elif PAGE_SIZE == PAGE_SIZE_16K
241#define L2C_ENTRIES 32
242#define L3C_ENTRIES 128
243#else
244#error Unsupported page size
245#endif
246
247#define L2C_SIZE (L2C_ENTRIES * L2_SIZE)
248#define L2C_OFFSET (L2C_SIZE - 1)
249
250#define L3C_SIZE (L3C_ENTRIES * L3_SIZE)
251#define L3C_OFFSET (L3C_SIZE - 1)
252
189253#define pmap_l0_index(va) (((va) >> L0_SHIFT) & L0_ADDR_MASK)
190254#define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK)
191255#define pmap_l2_index(va) (((va) >> L2_SHIFT) & Ln_ADDR_MASK)
lib/libc/include/aarch64-freebsd-none/machine/resource.h-2
......@@ -44,9 +44,7 @@
4444#define SYS_RES_MEMORY 3 /* i/o memory */
4545#define SYS_RES_IOPORT 4 /* i/o ports */
4646#define SYS_RES_GPIO 5 /* general purpose i/o */
47#ifdef NEW_PCIB
4847#define PCI_RES_BUS 6 /* PCI bus numbers */
49#endif
5048
5149#endif /* !_MACHINE_RESOURCE_H_ */
5250
lib/libc/include/aarch64-freebsd-none/machine/runq.h deleted-50
......@@ -1,50 +0,0 @@
1/*-
2 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifdef __arm__
28#include <arm/runq.h>
29#else /* !__arm__ */
30
31#ifndef _MACHINE_RUNQ_H_
32#define _MACHINE_RUNQ_H_
33
34#define RQB_LEN (1) /* Number of priority status words. */
35#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */
36#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */
37
38#define RQB_BIT(pri) (1ul << ((pri) & (RQB_BPW - 1)))
39#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
40
41#define RQB_FFS(word) (ffsl(word) - 1)
42
43/*
44 * Type of run queue status word.
45 */
46typedef unsigned long rqb_word_t;
47
48#endif
49
50#endif /* !__arm__ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/signal.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * @(#)signal.h 8.1 (Berkeley) 6/11/93
3028 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
3129 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
3230 */
lib/libc/include/aarch64-freebsd-none/machine/sysarch.h+9
......@@ -39,6 +39,15 @@
3939#ifndef _MACHINE_SYSARCH_H_
4040#define _MACHINE_SYSARCH_H_
4141
42#include <sys/cdefs.h>
43
44#define ARM64_GUARD_PAGE 0x100
45
46struct arm64_guard_page_args {
47 __uintptr_t addr;
48 __size_t len;
49};
50
4251#define ARM64_GET_SVE_VL 0x200
4352/* Reserved ARM64_SET_SVE_VL 0x201 */
4453
lib/libc/include/aarch64-freebsd-none/machine/undefined.h+8-22
......@@ -35,31 +35,17 @@
3535
3636typedef int (*undef_handler_t)(vm_offset_t, uint32_t, struct trapframe *,
3737 uint32_t);
38
39static inline int
40mrs_Op0(uint32_t insn)
41{
42
43 /* op0 is encoded without the top bit in a mrs instruction */
44 return (2 | ((insn & MRS_Op0_MASK) >> MRS_Op0_SHIFT));
45}
46
47#define MRS_GET(op) \
48static inline int \
49mrs_##op(uint32_t insn) \
50{ \
51 \
52 return ((insn & MRS_##op##_MASK) >> MRS_##op##_SHIFT); \
53}
54MRS_GET(Op1)
55MRS_GET(CRn)
56MRS_GET(CRm)
57MRS_GET(Op2)
38typedef bool (*undef_sys_handler_t)(uint64_t, struct trapframe *);
5839
5940void undef_init(void);
60void *install_undef_handler(bool, undef_handler_t);
41void install_sys_handler(undef_sys_handler_t);
42void *install_undef_handler(undef_handler_t);
43#ifdef COMPAT_FREEBSD32
44void *install_undef32_handler(undef_handler_t);
45#endif
6146void remove_undef_handler(void *);
62int undef_insn(u_int, struct trapframe *);
47bool undef_sys(uint64_t, struct trapframe *);
48int undef_insn(struct trapframe *);
6349
6450#endif /* _KERNEL */
6551
lib/libc/include/aarch64-freebsd-none/machine/vmm.h created+348
......@@ -0,0 +1,348 @@
1/*
2 * Copyright (C) 2015 Mihai Carabas <mihai.carabas@gmail.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _VMM_H_
28#define _VMM_H_
29
30#include <sys/param.h>
31#include <sys/cpuset.h>
32#include <vm/vm.h>
33#include <vm/pmap.h>
34
35#include "pte.h"
36#include "pmap.h"
37
38struct vcpu;
39
40enum vm_suspend_how {
41 VM_SUSPEND_NONE,
42 VM_SUSPEND_RESET,
43 VM_SUSPEND_POWEROFF,
44 VM_SUSPEND_HALT,
45 VM_SUSPEND_DESTROY,
46 VM_SUSPEND_LAST
47};
48
49/*
50 * Identifiers for architecturally defined registers.
51 */
52enum vm_reg_name {
53 VM_REG_GUEST_X0 = 0,
54 VM_REG_GUEST_X1,
55 VM_REG_GUEST_X2,
56 VM_REG_GUEST_X3,
57 VM_REG_GUEST_X4,
58 VM_REG_GUEST_X5,
59 VM_REG_GUEST_X6,
60 VM_REG_GUEST_X7,
61 VM_REG_GUEST_X8,
62 VM_REG_GUEST_X9,
63 VM_REG_GUEST_X10,
64 VM_REG_GUEST_X11,
65 VM_REG_GUEST_X12,
66 VM_REG_GUEST_X13,
67 VM_REG_GUEST_X14,
68 VM_REG_GUEST_X15,
69 VM_REG_GUEST_X16,
70 VM_REG_GUEST_X17,
71 VM_REG_GUEST_X18,
72 VM_REG_GUEST_X19,
73 VM_REG_GUEST_X20,
74 VM_REG_GUEST_X21,
75 VM_REG_GUEST_X22,
76 VM_REG_GUEST_X23,
77 VM_REG_GUEST_X24,
78 VM_REG_GUEST_X25,
79 VM_REG_GUEST_X26,
80 VM_REG_GUEST_X27,
81 VM_REG_GUEST_X28,
82 VM_REG_GUEST_X29,
83 VM_REG_GUEST_LR,
84 VM_REG_GUEST_SP,
85 VM_REG_GUEST_PC,
86 VM_REG_GUEST_CPSR,
87
88 VM_REG_GUEST_SCTLR_EL1,
89 VM_REG_GUEST_TTBR0_EL1,
90 VM_REG_GUEST_TTBR1_EL1,
91 VM_REG_GUEST_TCR_EL1,
92 VM_REG_GUEST_TCR2_EL1,
93 VM_REG_GUEST_MPIDR_EL1,
94 VM_REG_LAST
95};
96
97#define VM_INTINFO_VECTOR(info) ((info) & 0xff)
98#define VM_INTINFO_DEL_ERRCODE 0x800
99#define VM_INTINFO_RSVD 0x7ffff000
100#define VM_INTINFO_VALID 0x80000000
101#define VM_INTINFO_TYPE 0x700
102#define VM_INTINFO_HWINTR (0 << 8)
103#define VM_INTINFO_NMI (2 << 8)
104#define VM_INTINFO_HWEXCEPTION (3 << 8)
105#define VM_INTINFO_SWINTR (4 << 8)
106
107#define VM_GUEST_BASE_IPA 0x80000000UL /* Guest kernel start ipa */
108
109/*
110 * The VM name has to fit into the pathname length constraints of devfs,
111 * governed primarily by SPECNAMELEN. The length is the total number of
112 * characters in the full path, relative to the mount point and not
113 * including any leading '/' characters.
114 * A prefix and a suffix are added to the name specified by the user.
115 * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters
116 * longer for future use.
117 * The suffix is a string that identifies a bootrom image or some similar
118 * image that is attached to the VM. A separator character gets added to
119 * the suffix automatically when generating the full path, so it must be
120 * accounted for, reducing the effective length by 1.
121 * The effective length of a VM name is 229 bytes for FreeBSD 13 and 37
122 * bytes for FreeBSD 12. A minimum length is set for safety and supports
123 * a SPECNAMELEN as small as 32 on old systems.
124 */
125#define VM_MAX_PREFIXLEN 10
126#define VM_MAX_SUFFIXLEN 15
127#define VM_MAX_NAMELEN \
128 (SPECNAMELEN - VM_MAX_PREFIXLEN - VM_MAX_SUFFIXLEN - 1)
129
130#ifdef _KERNEL
131struct vm;
132struct vm_exception;
133struct vm_exit;
134struct vm_run;
135struct vm_object;
136struct vm_guest_paging;
137struct vm_vgic_descr;
138struct pmap;
139
140struct vm_eventinfo {
141 void *rptr; /* rendezvous cookie */
142 int *sptr; /* suspend cookie */
143 int *iptr; /* reqidle cookie */
144};
145
146int vm_create(const char *name, struct vm **retvm);
147struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid);
148void vm_disable_vcpu_creation(struct vm *vm);
149void vm_slock_vcpus(struct vm *vm);
150void vm_unlock_vcpus(struct vm *vm);
151void vm_destroy(struct vm *vm);
152int vm_reinit(struct vm *vm);
153const char *vm_name(struct vm *vm);
154
155uint16_t vm_get_maxcpus(struct vm *vm);
156void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores,
157 uint16_t *threads, uint16_t *maxcpus);
158int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
159 uint16_t threads, uint16_t maxcpus);
160int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
161int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
162int vm_run(struct vcpu *vcpu);
163int vm_suspend(struct vm *vm, enum vm_suspend_how how);
164void* vm_get_cookie(struct vm *vm);
165int vcpu_vcpuid(struct vcpu *vcpu);
166void *vcpu_get_cookie(struct vcpu *vcpu);
167struct vm *vcpu_vm(struct vcpu *vcpu);
168struct vcpu *vm_vcpu(struct vm *vm, int cpu);
169int vm_get_capability(struct vcpu *vcpu, int type, int *val);
170int vm_set_capability(struct vcpu *vcpu, int type, int val);
171int vm_activate_cpu(struct vcpu *vcpu);
172int vm_suspend_cpu(struct vm *vm, struct vcpu *vcpu);
173int vm_resume_cpu(struct vm *vm, struct vcpu *vcpu);
174int vm_inject_exception(struct vcpu *vcpu, uint64_t esr, uint64_t far);
175int vm_attach_vgic(struct vm *vm, struct vm_vgic_descr *descr);
176int vm_assert_irq(struct vm *vm, uint32_t irq);
177int vm_deassert_irq(struct vm *vm, uint32_t irq);
178int vm_raise_msi(struct vm *vm, uint64_t msg, uint64_t addr, int bus, int slot,
179 int func);
180struct vm_exit *vm_exitinfo(struct vcpu *vcpu);
181void vm_exit_suspended(struct vcpu *vcpu, uint64_t pc);
182void vm_exit_debug(struct vcpu *vcpu, uint64_t pc);
183void vm_exit_rendezvous(struct vcpu *vcpu, uint64_t pc);
184void vm_exit_astpending(struct vcpu *vcpu, uint64_t pc);
185
186cpuset_t vm_active_cpus(struct vm *vm);
187cpuset_t vm_debug_cpus(struct vm *vm);
188cpuset_t vm_suspended_cpus(struct vm *vm);
189
190static __inline int
191vcpu_rendezvous_pending(struct vm_eventinfo *info)
192{
193
194 return (*((uintptr_t *)(info->rptr)) != 0);
195}
196
197static __inline int
198vcpu_suspended(struct vm_eventinfo *info)
199{
200
201 return (*info->sptr);
202}
203
204int vcpu_debugged(struct vcpu *vcpu);
205
206enum vcpu_state {
207 VCPU_IDLE,
208 VCPU_FROZEN,
209 VCPU_RUNNING,
210 VCPU_SLEEPING,
211};
212
213int vcpu_set_state(struct vcpu *vcpu, enum vcpu_state state, bool from_idle);
214enum vcpu_state vcpu_get_state(struct vcpu *vcpu, int *hostcpu);
215
216static int __inline
217vcpu_is_running(struct vcpu *vcpu, int *hostcpu)
218{
219 return (vcpu_get_state(vcpu, hostcpu) == VCPU_RUNNING);
220}
221
222#ifdef _SYS_PROC_H_
223static int __inline
224vcpu_should_yield(struct vcpu *vcpu)
225{
226 struct thread *td;
227
228 td = curthread;
229 return (td->td_ast != 0 || td->td_owepreempt != 0);
230}
231#endif
232
233void *vcpu_stats(struct vcpu *vcpu);
234void vcpu_notify_event(struct vcpu *vcpu);
235struct vmspace *vm_vmspace(struct vm *vm);
236struct vm_mem *vm_mem(struct vm *vm);
237
238enum vm_reg_name vm_segment_name(int seg_encoding);
239
240struct vm_copyinfo {
241 uint64_t gpa;
242 size_t len;
243 void *hva;
244 void *cookie;
245};
246
247#endif /* _KERNEL */
248
249#define VM_DIR_READ 0
250#define VM_DIR_WRITE 1
251
252#define VM_GP_M_MASK 0x1f
253#define VM_GP_MMU_ENABLED (1 << 5)
254
255struct vm_guest_paging {
256 uint64_t ttbr0_addr;
257 uint64_t ttbr1_addr;
258 uint64_t tcr_el1;
259 uint64_t tcr2_el1;
260 int flags;
261 int padding;
262};
263
264struct vie {
265 uint8_t access_size:4, sign_extend:1, dir:1, unused:2;
266 enum vm_reg_name reg;
267};
268
269struct vre {
270 uint32_t inst_syndrome;
271 uint8_t dir:1, unused:7;
272 enum vm_reg_name reg;
273};
274
275/*
276 * Identifiers for optional vmm capabilities
277 */
278enum vm_cap_type {
279 VM_CAP_HALT_EXIT,
280 VM_CAP_PAUSE_EXIT,
281 VM_CAP_UNRESTRICTED_GUEST,
282 VM_CAP_BRK_EXIT,
283 VM_CAP_SS_EXIT,
284 VM_CAP_MASK_HWINTR,
285 VM_CAP_MAX
286};
287
288enum vm_exitcode {
289 VM_EXITCODE_BOGUS,
290 VM_EXITCODE_INST_EMUL,
291 VM_EXITCODE_REG_EMUL,
292 VM_EXITCODE_HVC,
293 VM_EXITCODE_SUSPENDED,
294 VM_EXITCODE_HYP,
295 VM_EXITCODE_WFI,
296 VM_EXITCODE_PAGING,
297 VM_EXITCODE_SMCCC,
298 VM_EXITCODE_DEBUG,
299 VM_EXITCODE_BRK,
300 VM_EXITCODE_SS,
301 VM_EXITCODE_MAX
302};
303
304struct vm_exit {
305 enum vm_exitcode exitcode;
306 int inst_length;
307 uint64_t pc;
308 union {
309 /*
310 * ARM specific payload.
311 */
312 struct {
313 uint32_t exception_nr;
314 uint32_t pad;
315 uint64_t esr_el2; /* Exception Syndrome Register */
316 uint64_t far_el2; /* Fault Address Register */
317 uint64_t hpfar_el2; /* Hypervisor IPA Fault Address Register */
318 } hyp;
319 struct {
320 struct vre vre;
321 } reg_emul;
322 struct {
323 uint64_t gpa;
324 uint64_t esr;
325 } paging;
326 struct {
327 uint64_t gpa;
328 struct vm_guest_paging paging;
329 struct vie vie;
330 } inst_emul;
331
332 /*
333 * A SMCCC call, e.g. starting a core via PSCI.
334 * Further arguments can be read by asking the kernel for
335 * all register values.
336 */
337 struct {
338 uint64_t func_id;
339 uint64_t args[7];
340 } smccc_call;
341
342 struct {
343 enum vm_suspend_how how;
344 } suspended;
345 } u;
346};
347
348#endif /* _VMM_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/vmm_dev.h created+274
......@@ -0,0 +1,274 @@
1/*
2 * Copyright (C) 2015 Mihai Carabas <mihai.carabas@gmail.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _VMM_DEV_H_
28#define _VMM_DEV_H_
29
30#include <sys/domainset.h>
31
32#include <machine/vmm.h>
33
34struct vm_memmap {
35 vm_paddr_t gpa;
36 int segid; /* memory segment */
37 vm_ooffset_t segoff; /* offset into memory segment */
38 size_t len; /* mmap length */
39 int prot; /* RWX */
40 int flags;
41};
42#define VM_MEMMAP_F_WIRED 0x01
43
44struct vm_munmap {
45 vm_paddr_t gpa;
46 size_t len;
47};
48
49#define VM_MEMSEG_NAME(m) ((m)->name[0] != '\0' ? (m)->name : NULL)
50struct vm_memseg {
51 int segid;
52 size_t len;
53 char name[VM_MAX_SUFFIXLEN + 1];
54 domainset_t *ds_mask;
55 size_t ds_mask_size;
56 int ds_policy;
57};
58
59struct vm_register {
60 int cpuid;
61 int regnum; /* enum vm_reg_name */
62 uint64_t regval;
63};
64
65struct vm_register_set {
66 int cpuid;
67 unsigned int count;
68 const int *regnums; /* enum vm_reg_name */
69 uint64_t *regvals;
70};
71
72struct vm_run {
73 int cpuid;
74 cpuset_t *cpuset; /* CPU set storage */
75 size_t cpusetsize;
76 struct vm_exit *vm_exit;
77};
78
79struct vm_exception {
80 int cpuid;
81 uint64_t esr;
82 uint64_t far;
83};
84
85struct vm_msi {
86 uint64_t msg;
87 uint64_t addr;
88 int bus;
89 int slot;
90 int func;
91};
92
93struct vm_capability {
94 int cpuid;
95 enum vm_cap_type captype;
96 int capval;
97 int allcpus;
98};
99
100#define MAX_VM_STATS 64
101struct vm_stats {
102 int cpuid; /* in */
103 int index; /* in */
104 int num_entries; /* out */
105 struct timeval tv;
106 uint64_t statbuf[MAX_VM_STATS];
107};
108struct vm_stat_desc {
109 int index; /* in */
110 char desc[128]; /* out */
111};
112
113struct vm_suspend {
114 enum vm_suspend_how how;
115};
116
117struct vm_gla2gpa {
118 int vcpuid; /* inputs */
119 int prot; /* PROT_READ or PROT_WRITE */
120 uint64_t gla;
121 struct vm_guest_paging paging;
122 int fault; /* outputs */
123 uint64_t gpa;
124};
125
126struct vm_activate_cpu {
127 int vcpuid;
128};
129
130struct vm_cpuset {
131 int which;
132 int cpusetsize;
133 cpuset_t *cpus;
134};
135#define VM_ACTIVE_CPUS 0
136#define VM_SUSPENDED_CPUS 1
137#define VM_DEBUG_CPUS 2
138
139struct vm_vgic_version {
140 u_int version;
141 u_int flags;
142};
143
144struct vm_vgic_descr {
145 struct vm_vgic_version ver;
146 union {
147 struct {
148 uint64_t dist_start;
149 uint64_t dist_size;
150 uint64_t redist_start;
151 uint64_t redist_size;
152 } v3_regs;
153 };
154};
155
156struct vm_irq {
157 uint32_t irq;
158};
159
160struct vm_cpu_topology {
161 uint16_t sockets;
162 uint16_t cores;
163 uint16_t threads;
164 uint16_t maxcpus;
165};
166
167enum {
168 /* general routines */
169 IOCNUM_ABIVERS = 0,
170 IOCNUM_RUN = 1,
171 IOCNUM_SET_CAPABILITY = 2,
172 IOCNUM_GET_CAPABILITY = 3,
173 IOCNUM_SUSPEND = 4,
174 IOCNUM_REINIT = 5,
175
176 /* memory apis */
177 IOCNUM_GET_GPA_PMAP = 12,
178 IOCNUM_GLA2GPA_NOFAULT = 13,
179 IOCNUM_ALLOC_MEMSEG = 14,
180 IOCNUM_GET_MEMSEG = 15,
181 IOCNUM_MMAP_MEMSEG = 16,
182 IOCNUM_MMAP_GETNEXT = 17,
183 IOCNUM_MUNMAP_MEMSEG = 18,
184
185 /* register/state accessors */
186 IOCNUM_SET_REGISTER = 20,
187 IOCNUM_GET_REGISTER = 21,
188 IOCNUM_SET_REGISTER_SET = 24,
189 IOCNUM_GET_REGISTER_SET = 25,
190
191 /* statistics */
192 IOCNUM_VM_STATS = 50,
193 IOCNUM_VM_STAT_DESC = 51,
194
195 /* CPU Topology */
196 IOCNUM_SET_TOPOLOGY = 63,
197 IOCNUM_GET_TOPOLOGY = 64,
198
199 /* interrupt injection */
200 IOCNUM_ASSERT_IRQ = 80,
201 IOCNUM_DEASSERT_IRQ = 81,
202 IOCNUM_RAISE_MSI = 82,
203 IOCNUM_INJECT_EXCEPTION = 83,
204
205 /* vm_cpuset */
206 IOCNUM_ACTIVATE_CPU = 90,
207 IOCNUM_GET_CPUSET = 91,
208 IOCNUM_SUSPEND_CPU = 92,
209 IOCNUM_RESUME_CPU = 93,
210
211 /* vm_attach_vgic */
212 IOCNUM_GET_VGIC_VERSION = 110,
213 IOCNUM_ATTACH_VGIC = 111,
214};
215
216#define VM_RUN \
217 _IOWR('v', IOCNUM_RUN, struct vm_run)
218#define VM_SUSPEND \
219 _IOW('v', IOCNUM_SUSPEND, struct vm_suspend)
220#define VM_REINIT \
221 _IO('v', IOCNUM_REINIT)
222#define VM_ALLOC_MEMSEG \
223 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg)
224#define VM_GET_MEMSEG \
225 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg)
226#define VM_MMAP_MEMSEG \
227 _IOW('v', IOCNUM_MMAP_MEMSEG, struct vm_memmap)
228#define VM_MMAP_GETNEXT \
229 _IOWR('v', IOCNUM_MMAP_GETNEXT, struct vm_memmap)
230#define VM_MUNMAP_MEMSEG \
231 _IOW('v', IOCNUM_MUNMAP_MEMSEG, struct vm_munmap)
232#define VM_SET_REGISTER \
233 _IOW('v', IOCNUM_SET_REGISTER, struct vm_register)
234#define VM_GET_REGISTER \
235 _IOWR('v', IOCNUM_GET_REGISTER, struct vm_register)
236#define VM_SET_REGISTER_SET \
237 _IOW('v', IOCNUM_SET_REGISTER_SET, struct vm_register_set)
238#define VM_GET_REGISTER_SET \
239 _IOWR('v', IOCNUM_GET_REGISTER_SET, struct vm_register_set)
240#define VM_SET_CAPABILITY \
241 _IOW('v', IOCNUM_SET_CAPABILITY, struct vm_capability)
242#define VM_GET_CAPABILITY \
243 _IOWR('v', IOCNUM_GET_CAPABILITY, struct vm_capability)
244#define VM_STATS \
245 _IOWR('v', IOCNUM_VM_STATS, struct vm_stats)
246#define VM_STAT_DESC \
247 _IOWR('v', IOCNUM_VM_STAT_DESC, struct vm_stat_desc)
248#define VM_ASSERT_IRQ \
249 _IOW('v', IOCNUM_ASSERT_IRQ, struct vm_irq)
250#define VM_DEASSERT_IRQ \
251 _IOW('v', IOCNUM_DEASSERT_IRQ, struct vm_irq)
252#define VM_RAISE_MSI \
253 _IOW('v', IOCNUM_RAISE_MSI, struct vm_msi)
254#define VM_INJECT_EXCEPTION \
255 _IOW('v', IOCNUM_INJECT_EXCEPTION, struct vm_exception)
256#define VM_SET_TOPOLOGY \
257 _IOW('v', IOCNUM_SET_TOPOLOGY, struct vm_cpu_topology)
258#define VM_GET_TOPOLOGY \
259 _IOR('v', IOCNUM_GET_TOPOLOGY, struct vm_cpu_topology)
260#define VM_GLA2GPA_NOFAULT \
261 _IOWR('v', IOCNUM_GLA2GPA_NOFAULT, struct vm_gla2gpa)
262#define VM_ACTIVATE_CPU \
263 _IOW('v', IOCNUM_ACTIVATE_CPU, struct vm_activate_cpu)
264#define VM_GET_CPUS \
265 _IOW('v', IOCNUM_GET_CPUSET, struct vm_cpuset)
266#define VM_SUSPEND_CPU \
267 _IOW('v', IOCNUM_SUSPEND_CPU, struct vm_activate_cpu)
268#define VM_RESUME_CPU \
269 _IOW('v', IOCNUM_RESUME_CPU, struct vm_activate_cpu)
270#define VM_GET_VGIC_VERSION \
271 _IOR('v', IOCNUM_GET_VGIC_VERSION, struct vm_vgic_version)
272#define VM_ATTACH_VGIC \
273 _IOW('v', IOCNUM_ATTACH_VGIC, struct vm_vgic_descr)
274#endif
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/vmm_instruction_emul.h created+83
......@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2015 Mihai Carabas <mihai.carabas@gmail.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _VMM_INSTRUCTION_EMUL_H_
28#define _VMM_INSTRUCTION_EMUL_H_
29
30/*
31 * Callback functions to read and write memory regions.
32 */
33typedef int (*mem_region_read_t)(struct vcpu *vcpu, uint64_t gpa,
34 uint64_t *rval, int rsize, void *arg);
35typedef int (*mem_region_write_t)(struct vcpu *vcpu, uint64_t gpa,
36 uint64_t wval, int wsize, void *arg);
37
38/*
39 * Callback functions to read and write registers.
40 */
41typedef int (*reg_read_t)(struct vcpu *vcpu, uint64_t *rval, void *arg);
42typedef int (*reg_write_t)(struct vcpu *vcpu, uint64_t wval, void *arg);
43
44/*
45 * Emulate the decoded 'vie' instruction when it contains a memory operation.
46 *
47 * The callbacks 'mrr' and 'mrw' emulate reads and writes to the memory region
48 * containing 'gpa'. 'mrarg' is an opaque argument that is passed into the
49 * callback functions.
50 *
51 * 'void *vm' should be 'struct vm *' when called from kernel context and
52 * 'struct vmctx *' when called from user context.
53 *
54 */
55int vmm_emulate_instruction(struct vcpu *vcpu, uint64_t gpa, struct vie *vie,
56 struct vm_guest_paging *paging, mem_region_read_t mrr,
57 mem_region_write_t mrw, void *mrarg);
58
59/*
60 * Emulate the decoded 'vre' instruction when it contains a register access.
61 *
62 * The callbacks 'regread' and 'regwrite' emulate reads and writes to the
63 * register from 'vie'. 'regarg' is an opaque argument that is passed into the
64 * callback functions.
65 *
66 * 'void *vm' should be 'struct vm *' when called from kernel context and
67 * 'struct vmctx *' when called from user context.
68 *
69 */
70int vmm_emulate_register(struct vcpu *vcpu, struct vre *vre, reg_read_t regread,
71 reg_write_t regwrite, void *regarg);
72
73#ifdef _KERNEL
74void vm_register_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask,
75 reg_read_t reg_read, reg_write_t reg_write, void *arg);
76void vm_deregister_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask);
77
78void vm_register_inst_handler(struct vm *vm, uint64_t start, uint64_t size,
79 mem_region_read_t mmio_read, mem_region_write_t mmio_write);
80void vm_deregister_inst_handler(struct vm *vm, uint64_t start, uint64_t size);
81#endif
82
83#endif /* _VMM_INSTRUCTION_EMUL_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/vmparam.h+61-15
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
3533 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30
3634 */
3735
......@@ -75,14 +73,16 @@
7573#define VM_PHYSSEG_MAX 64
7674
7775/*
78 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
79 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
80 * the pool from which physical pages for small UMA objects are
81 * allocated.
76 * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool from
77 * which physical pages are allocated and VM_FREEPOOL_DIRECT is the pool from
78 * which physical pages for page tables and small UMA objects are allocated.
79 * VM_FREEPOOL_LAZYINIT is a special-purpose pool that is populated only during
80 * boot and is used to implement deferred initialization of page structures.
8281 */
83#define VM_NFREEPOOL 2
84#define VM_FREEPOOL_DEFAULT 0
85#define VM_FREEPOOL_DIRECT 1
82#define VM_NFREEPOOL 3
83#define VM_FREEPOOL_LAZYINIT 0
84#define VM_FREEPOOL_DEFAULT 1
85#define VM_FREEPOOL_DIRECT 2
8686
8787/*
8888 * Create two free page lists: VM_FREELIST_DMA32 is for physical pages that have
......@@ -101,21 +101,46 @@
101101 * are used by UMA, the physical memory allocator reduces the likelihood of
102102 * both 2MB page TLB misses and cache misses during the page table walk when
103103 * a 2MB page TLB miss does occur.
104 *
105 * When PAGE_SIZE is 16KB, an allocation size of 32MB is supported. This
106 * size is used by level 0 reservations and L2 BLOCK mappings.
104107 */
108#if PAGE_SIZE == PAGE_SIZE_4K
105109#define VM_NFREEORDER 13
110#elif PAGE_SIZE == PAGE_SIZE_16K
111#define VM_NFREEORDER 12
112#else
113#error Unsupported page size
114#endif
106115
107116/*
108 * Enable superpage reservations: 1 level.
117 * Enable superpage reservations: 2 levels.
109118 */
110119#ifndef VM_NRESERVLEVEL
111#define VM_NRESERVLEVEL 1
120#define VM_NRESERVLEVEL 2
112121#endif
113122
114123/*
115 * Level 0 reservations consist of 512 pages.
124 * Level 0 reservations consist of 16 pages when PAGE_SIZE is 4KB, and 128
125 * pages when PAGE_SIZE is 16KB. Level 1 reservations consist of 32 64KB
126 * pages when PAGE_SIZE is 4KB, and 16 2M pages when PAGE_SIZE is 16KB.
116127 */
128#if PAGE_SIZE == PAGE_SIZE_4K
117129#ifndef VM_LEVEL_0_ORDER
118#define VM_LEVEL_0_ORDER 9
130#define VM_LEVEL_0_ORDER 4
131#endif
132#ifndef VM_LEVEL_1_ORDER
133#define VM_LEVEL_1_ORDER 5
134#endif
135#elif PAGE_SIZE == PAGE_SIZE_16K
136#ifndef VM_LEVEL_0_ORDER
137#define VM_LEVEL_0_ORDER 7
138#endif
139#ifndef VM_LEVEL_1_ORDER
140#define VM_LEVEL_1_ORDER 4
141#endif
142#else
143#error Unsupported page size
119144#endif
120145
121146/**
......@@ -133,6 +158,12 @@
133158 * 0xfffffeffffffffff End of DMAP
134159 * 0xffffa00000000000 Start of DMAP
135160 *
161 * 0xffff027fffffffff End of KMSAN origin map
162 * 0xffff020000000000 Start of KMSAN origin map
163 *
164 * 0xffff017fffffffff End of KMSAN shadow map
165 * 0xffff010000000000 Start of KMSAN shadow map
166 *
136167 * 0xffff009fffffffff End of KASAN shadow map
137168 * 0xffff008000000000 Start of KASAN shadow map
138169 *
......@@ -169,11 +200,25 @@
169200#define KASAN_MIN_ADDRESS (0xffff008000000000UL)
170201#define KASAN_MAX_ADDRESS (0xffff00a000000000UL)
171202
203/* 512GiB KMSAN shadow map */
204#define KMSAN_SHAD_MIN_ADDRESS (0xffff010000000000UL)
205#define KMSAN_SHAD_MAX_ADDRESS (0xffff018000000000UL)
206
207/* 512GiB KMSAN origin map */
208#define KMSAN_ORIG_MIN_ADDRESS (0xffff020000000000UL)
209#define KMSAN_ORIG_MAX_ADDRESS (0xffff028000000000UL)
210
172211/* The address bits that hold a pointer authentication code */
173#define PAC_ADDR_MASK (0xff7f000000000000UL)
212#define PAC_ADDR_MASK (0x007f000000000000UL)
213#define PAC_ADDR_MASK_14 (0xff7f000000000000UL)
214
215/* The top-byte ignore address bits */
216#define TBI_ADDR_MASK 0xff00000000000000UL
174217
175218/* If true addr is in the kernel address space */
176219#define ADDR_IS_KERNEL(addr) (((addr) & (1ul << 55)) == (1ul << 55))
220/* If true addr is in the user address space */
221#define ADDR_IS_USER(addr) (((addr) & (1ul << 55)) == 0)
177222/* If true addr is in its canonical form (i.e. no TBI, PAC, etc.) */
178223#define ADDR_IS_CANONICAL(addr) \
179224 (((addr) & 0xffff000000000000UL) == 0 || \
......@@ -265,7 +310,7 @@
265310#endif
266311
267312#if !defined(KASAN) && !defined(KMSAN)
268#define UMA_MD_SMALL_ALLOC
313#define UMA_USE_DMAP
269314#endif
270315
271316#ifndef LOCORE
......@@ -289,6 +334,7 @@ extern vm_offset_t dmap_max_addr;
289334 * Need a page dump array for minidump.
290335 */
291336#define MINIDUMP_PAGE_TRACKING 1
337#define MINIDUMP_STARTUP_PAGE_TRACKING 1
292338
293339#endif /* !_MACHINE_VMPARAM_H_ */
294340
lib/libc/include/arm-freebsd-eabihf/fenv.h+1
......@@ -29,6 +29,7 @@
2929#ifndef _FENV_H_
3030#define _FENV_H_
3131
32#include <sys/cdefs.h>
3233#include <sys/_types.h>
3334
3435#ifndef __fenv_static
lib/libc/include/arm-freebsd-eabihf/float.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3230 */
3331
3432#ifndef _MACHINE_FLOAT_H_
lib/libc/include/arm-freebsd-eabihf/floatingpoint.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
3634 */
3735
3836#ifndef _FLOATINGPOINT_H_
lib/libc/include/arm-freebsd-eabihf/machine/_align.h-2
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
4038 */
4139
4240#ifndef _ARM_INCLUDE__ALIGN_H_
lib/libc/include/arm-freebsd-eabihf/machine/_bus.h+7-24
......@@ -1,30 +1,13 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
2 * Copyright (c) 2005 The FreeBSD Foundation.
53 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer,
11 * without modification, immediately at the beginning of the file.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
4 * SPDX-License-Identifier: BSD-2-Clause
165 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
6 * Derived in part from NetBSD's bus.h files by (alphabetically):
7 * Christopher G. Demetriou
8 * Charles M. Hannum
9 * Jason Thorpe
10 * The NetBSD Foundation.
2811 */
2912
3013#ifndef ARM_INCLUDE__BUS_H
lib/libc/include/arm-freebsd-eabihf/machine/_limits.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _MACHINE__LIMITS_H_
lib/libc/include/arm-freebsd-eabihf/machine/_types.h-3
......@@ -32,9 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
3835 */
3936
4037#ifndef _MACHINE__TYPES_H_
lib/libc/include/arm-freebsd-eabihf/machine/acle-compat.h+3-155
......@@ -1,5 +1,5 @@
11/*
2 * Copyright (c) 2014 ARM Ltd
2 * Copyright (c) 2024 Arm Ltd
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
......@@ -27,157 +27,5 @@
2727 */
2828
2929#ifndef __ARM_ARCH
30
31/* ACLE standardises a set of pre-defines that describe the ARM architecture.
32 These were mostly implemented in GCC around GCC-4.8; older versions
33 have no, or only partial support. To provide a level of backwards
34 compatibility we try to work out what the definitions should be, given
35 the older pre-defines that GCC did produce. This isn't complete, but
36 it should be enough for use by routines that depend on this header. */
37
38/* No need to handle ARMv8, GCC had ACLE support before that. */
39
40#define __ARM_ACLE 101
41
42# ifdef __ARM_ARCH_7__
43/* The common subset of ARMv7 in all profiles. */
44# define __ARM_ARCH 7
45# define __ARM_ARCH_ISA_THUMB 2
46# define __ARM_FEATURE_CLZ
47# define __ARM_FEATURE_LDREX 7
48# define __ARM_FEATURE_UNALIGNED
49# endif
50
51# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
52# define __ARM_ARCH 7
53# define __ARM_ARCH_ISA_THUMB 2
54# define __ARM_ARCH_ISA_ARM
55# define __ARM_FEATURE_CLZ
56# define __ARM_FEATURE_SIMD32
57# define __ARM_FEATURE_DSP
58# define __ARM_FEATURE_QBIT
59# define __ARM_FEATURE_SAT
60# define __ARM_FEATURE_LDREX 15
61# define __ARM_FEATURE_UNALIGNED
62# ifdef __ARM_ARCH_7A__
63# define __ARM_ARCH_PROFILE 'A'
64# else
65# define __ARM_ARCH_PROFILE 'R'
66# endif
67# endif
68
69# ifdef __ARM_ARCH_7EM__
70# define __ARM_ARCH 7
71# define __ARM_ARCH_ISA_THUMB 2
72# define __ARM_FEATURE_CLZ
73# define __ARM_FEATURE_SIMD32
74# define __ARM_FEATURE_DSP
75# define __ARM_FEATURE_QBIT
76# define __ARM_FEATURE_SAT
77# define __ARM_FEATURE_LDREX 7
78# define __ARM_FEATURE_UNALIGNED
79# define __ARM_ARCH_PROFILE 'M'
80# endif
81
82# ifdef __ARM_ARCH_7M__
83# define __ARM_ARCH 7
84# define __ARM_ARCH_ISA_THUMB 2
85# define __ARM_FEATURE_CLZ
86# define __ARM_FEATURE_QBIT
87# define __ARM_FEATURE_SAT
88# define __ARM_FEATURE_LDREX 7
89# define __ARM_FEATURE_UNALIGNED
90# define __ARM_ARCH_PROFILE 'M'
91# endif
92
93# ifdef __ARM_ARCH_6T2__
94# define __ARM_ARCH 6
95# define __ARM_ARCH_ISA_THUMB 2
96# define __ARM_ARCH_ISA_ARM
97# define __ARM_FEATURE_CLZ
98# define __ARM_FEATURE_SIMD32
99# define __ARM_FEATURE_DSP
100# define __ARM_FEATURE_QBIT
101# define __ARM_FEATURE_SAT
102# define __ARM_FEATURE_LDREX 4
103# define __ARM_FEATURE_UNALIGNED
104# endif
105
106# ifdef __ARM_ARCH_6M__
107# define __ARM_ARCH 6
108# define __ARM_ARCH_ISA_THUMB 1
109# define __ARM_ARCH_PROFILE 'M'
110# endif
111
112# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
113 || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
114 || defined (__ARM_ARCH_6ZK__)
115# define __ARM_ARCH 6
116# define __ARM_ARCH_ISA_THUMB 1
117# define __ARM_ARCH_ISA_ARM
118# define __ARM_FEATURE_CLZ
119# define __ARM_FEATURE_SIMD32
120# define __ARM_FEATURE_DSP
121# define __ARM_FEATURE_QBIT
122# define __ARM_FEATURE_SAT
123# define __ARM_FEATURE_UNALIGNED
124# ifndef __thumb__
125# if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
126# define __ARM_FEATURE_LDREX 15
127# else
128# define __ARM_FEATURE_LDREX 4
129# endif
130# endif
131# endif
132
133# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
134# define __ARM_ARCH 5
135# define __ARM_ARCH_ISA_ARM
136# ifdef __ARM_ARCH_5TE__
137# define __ARM_ARCH_ISA_THUMB 1
138# endif
139# define __ARM_FEATURE_CLZ
140# define __ARM_FEATURE_DSP
141# endif
142
143# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
144# define __ARM_ARCH 5
145# define __ARM_ARCH_ISA_ARM
146# ifdef __ARM_ARCH_5TE__
147# define __ARM_ARCH_ISA_THUMB 1
148# endif
149# define __ARM_FEATURE_CLZ
150# endif
151
152# ifdef __ARM_ARCH_4T__
153# define __ARM_ARCH 4
154# define __ARM_ARCH_ISA_ARM
155# define __ARM_ARCH_ISA_THUMB 1
156# endif
157
158# ifdef __ARM_ARCH_4__
159# define __ARM_ARCH 4
160# define __ARM_ARCH_ISA_ARM
161# endif
162
163# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
164# define __ARM_ARCH 3
165# define __ARM_ARCH_ISA_ARM
166# endif
167
168# ifdef __ARM_ARCH_2__
169# define __ARM_ARCH 2
170# define __ARM_ARCH_ISA_ARM
171# endif
172
173# ifdef __ARMEB__
174# define __ARM_BIG_ENDIAN
175# endif
176
177/* If we still don't know what the target architecture is, then we're
178 probably not using GCC. */
179# ifndef __ARM_ARCH
180# error Unable to determine architecture version.
181# endif
182
183#endif /* __ARM_ARCH */
\ No newline at end of file
30#error Your compiler is too old
31#endif
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/asm.h-10
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
3735 */
3836
3937#ifndef _MACHINE_ASM_H_
......@@ -176,7 +174,6 @@
176174# define RETne bxne lr
177175# define RETc(c) bx##c lr
178176
179#if __ARM_ARCH >= 7
180177#define ISB isb
181178#define DSB dsb
182179#define DMB dmb
......@@ -190,12 +187,5 @@
190187#define ERET .word 0xe160006e
191188#endif
192189
193#elif __ARM_ARCH == 6
194#include <machine/sysreg.h>
195#define ISB mcr CP15_CP15ISB
196#define DSB mcr CP15_CP15DSB
197#define DMB mcr CP15_CP15DMB
198#define WFI mcr CP15_CP15WFI
199#endif
200190
201191#endif /* !_MACHINE_ASM_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/atomic.h+28-21
......@@ -41,15 +41,9 @@
4141
4242#include <sys/atomic_common.h>
4343
44#if __ARM_ARCH >= 7
4544#define isb() __asm __volatile("isb" : : : "memory")
4645#define dsb() __asm __volatile("dsb" : : : "memory")
4746#define dmb() __asm __volatile("dmb" : : : "memory")
48#else
49#define isb() __asm __volatile("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : "memory")
50#define dsb() __asm __volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory")
51#define dmb() __asm __volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory")
52#endif
5347
5448#define mb() dmb()
5549#define wmb() dmb()
......@@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val)
614608}
615609
616610static __inline uint32_t
617atomic_load_acq_32(volatile uint32_t *p)
611atomic_load_acq_32(const volatile uint32_t *p)
618612{
619613 uint32_t v;
620614
......@@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p)
624618}
625619
626620static __inline uint64_t
627atomic_load_64(volatile uint64_t *p)
621atomic_load_64(const volatile uint64_t *p)
628622{
629623 uint64_t ret;
630624
......@@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p)
643637}
644638
645639static __inline uint64_t
646atomic_load_acq_64(volatile uint64_t *p)
640atomic_load_acq_64(const volatile uint64_t *p)
647641{
648642 uint64_t ret;
649643
......@@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p)
653647}
654648
655649static __inline u_long
656atomic_load_acq_long(volatile u_long *p)
650atomic_load_acq_long(const volatile u_long *p)
657651{
658652 u_long v;
659653
......@@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v)
898892
899893 return (atomic_testandclear_32((volatile uint32_t *)p, v));
900894}
901#define atomic_testandclear_long atomic_testandclear_long
902
903895
904896static __inline int
905897atomic_testandclear_64(volatile uint64_t *p, u_int v)
......@@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v)
958950
959951 return (atomic_testandset_32((volatile uint32_t *)p, v));
960952}
961#define atomic_testandset_long atomic_testandset_long
953
954static __inline int
955atomic_testandset_acq_long(volatile u_long *p, u_int v)
956{
957 int ret;
958
959 ret = atomic_testandset_32((volatile uint32_t *)p, v);
960 dmb();
961 return (ret);
962}
962963
963964static __inline int
964965atomic_testandset_64(volatile uint64_t *p, u_int v)
......@@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void)
10521053 dmb();
10531054}
10541055
1056#define atomic_add_ptr atomic_add_32
1057#define atomic_add_acq_ptr atomic_add_acq_32
1058#define atomic_add_rel_ptr atomic_add_rel_32
1059#define atomic_subtract_ptr atomic_subtract_32
1060#define atomic_subtract_acq_ptr atomic_subtract_acq_32
1061#define atomic_subtract_rel_ptr atomic_subtract_rel_32
10551062#define atomic_clear_ptr atomic_clear_32
10561063#define atomic_clear_acq_ptr atomic_clear_acq_32
10571064#define atomic_clear_rel_ptr atomic_clear_rel_32
......@@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void)
10591066#define atomic_set_acq_ptr atomic_set_acq_32
10601067#define atomic_set_rel_ptr atomic_set_rel_32
10611068#define atomic_fcmpset_ptr atomic_fcmpset_32
1062#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
10631069#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32
1070#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
10641071#define atomic_cmpset_ptr atomic_cmpset_32
10651072#define atomic_cmpset_acq_ptr atomic_cmpset_acq_32
10661073#define atomic_cmpset_rel_ptr atomic_cmpset_rel_32
1074#define atomic_fetchadd_ptr atomic_fetchadd_32
1075#define atomic_readandclear_ptr atomic_readandclear_32
10671076#define atomic_load_acq_ptr atomic_load_acq_32
10681077#define atomic_store_rel_ptr atomic_store_rel_32
10691078#define atomic_swap_ptr atomic_swap_32
1070#define atomic_readandclear_ptr atomic_readandclear_32
1079#define atomic_testandset_ptr atomic_testandset_32
1080#define atomic_testandclear_ptr atomic_testandclear_32
10711081
10721082#define atomic_add_int atomic_add_32
10731083#define atomic_add_acq_int atomic_add_acq_32
......@@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void)
10931103#define atomic_store_rel_int atomic_store_rel_32
10941104#define atomic_swap_int atomic_swap_32
10951105
1096/*
1097 * For:
1098 * - atomic_load_acq_8
1099 * - atomic_load_acq_16
1100 * - atomic_testandset_acq_long
1101 */
11021106#include <sys/_atomic_subword.h>
11031107
1108#define atomic_set_short atomic_set_16
1109#define atomic_clear_short atomic_clear_16
1110
11041111#endif /* _MACHINE_ATOMIC_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/cpu.h+11-45
......@@ -45,13 +45,7 @@ void cpu_halt(void);
4545 * unconditionally with -DSMP. Although it looks like a bug,
4646 * handle this case here and in #elif condition in ARM_SMP_UP macro.
4747 */
48#if __ARM_ARCH <= 6 && defined(SMP) && !defined(KLD_MODULE)
49#error SMP option is not supported on ARMv6
50#endif
5148
52#if __ARM_ARCH <= 6 && defined(SMP_ON_UP)
53#error SMP_ON_UP option is only supported on ARMv7+ CPUs
54#endif
5549
5650#if !defined(SMP) && defined(SMP_ON_UP)
5751#error SMP option must be defined for SMP_ON_UP option
......@@ -68,7 +62,7 @@ do { \
6862 up_code; \
6963 } \
7064} while (0)
71#elif defined(SMP) && __ARM_ARCH > 6
65#elif defined(SMP)
7266#define ARM_SMP_UP(smp_code, up_code) \
7367do { \
7468 smp_code; \
......@@ -146,15 +140,15 @@ fname(uint64_t reg) \
146140/* TLB */
147141
148142_WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */
149#if __ARM_ARCH >= 7 && defined(SMP)
143#if defined(SMP)
150144_WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */
151145#endif
152146_WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */
153#if __ARM_ARCH >= 7 && defined(SMP)
147#if defined(SMP)
154148_WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */
155149#endif
156150_WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */
157#if __ARM_ARCH >= 7 && defined(SMP)
151#if defined(SMP)
158152_WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */
159153#endif
160154_WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */
......@@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0))
164158/* Cache and Branch predictor */
165159
166160_WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */
167#if __ARM_ARCH >= 7 && defined(SMP)
161#if defined(SMP)
168162_WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */
169163#endif
170164_WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */
171165_WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */
172166_WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */
173167_WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */
174#if __ARM_ARCH >= 7
175168_WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */
176#endif
177169_WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */
178170_WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */
179171_WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */
180172_WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */
181#if __ARM_ARCH >= 7 && defined(SMP)
173#if defined(SMP)
182174_WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */
183175#endif
184176_WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */
......@@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0))
209201_WF1(cp15_nmrr_set, CP15_NMRR(%0))
210202_RF0(cp15_ttbr_get, CP15_TTBR0(%0))
211203_RF0(cp15_dfar_get, CP15_DFAR(%0))
212#if __ARM_ARCH >= 7
213204_RF0(cp15_ifar_get, CP15_IFAR(%0))
214205_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))
215#endif
216206_RF0(cp15_actlr_get, CP15_ACTLR(%0))
217207_WF1(cp15_actlr_set, CP15_ACTLR(%0))
218208_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0))
......@@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0))
251241
252242/* Performance Monitor registers */
253243
254#if __ARM_ARCH == 6 && defined(CPU_ARM1176)
255_RF0(cp15_pmuserenr_get, CP15_PMUSERENR(%0))
256_WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))
257_RF0(cp15_pmcr_get, CP15_PMCR(%0))
258_WF1(cp15_pmcr_set, CP15_PMCR(%0))
259_RF0(cp15_pmccntr_get, CP15_PMCCNTR(%0))
260_WF1(cp15_pmccntr_set, CP15_PMCCNTR(%0))
261#elif __ARM_ARCH > 6
262244_RF0(cp15_pmcr_get, CP15_PMCR(%0))
263245_WF1(cp15_pmcr_set, CP15_PMCR(%0))
264246_RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0))
......@@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))
280262_RF0(cp15_pminten_get, CP15_PMINTENSET(%0))
281263_WF1(cp15_pminten_set, CP15_PMINTENSET(%0))
282264_WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0))
283#endif
284265
285266_RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0))
286267_WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0))
......@@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size)
380361}
381362
382363/* Broadcasting operations. */
383#if __ARM_ARCH >= 7 && defined(SMP)
364#if defined(SMP)
384365
385366static __inline void
386367tlb_flush_all(void)
......@@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size)
442423 );
443424 dsb();
444425}
445#else /* __ARM_ARCH < 7 */
426#else /* !SMP */
446427
447428#define tlb_flush_all() tlb_flush_all_local()
448429#define tlb_flush_all_ng() tlb_flush_all_ng_local()
449430#define tlb_flush(va) tlb_flush_local(va)
450431#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)
451432
452#endif /* __ARM_ARCH < 7 */
433#endif /* !SMP */
453434
454435/*
455436 * Cache maintenance operations.
......@@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size)
465446 va &= ~cpuinfo.dcache_line_mask;
466447
467448 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
468#if __ARM_ARCH >= 7
469449 _CP15_DCCMVAU(va);
470#else
471 _CP15_DCCMVAC(va);
472#endif
473450 }
474451 dsb();
475452 ARM_SMP_UP(
......@@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size)
515492 dsb();
516493 va &= ~cpuinfo.dcache_line_mask;
517494 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
518#if __ARM_ARCH >= 7
519495 _CP15_DCCMVAU(va);
520#else
521 _CP15_DCCMVAC(va);
522#endif
523496 }
524497 dsb();
525498}
......@@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr)
686659static __inline uint64_t
687660get_cyclecount(void)
688661{
689#if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176))
690#if (__ARM_ARCH > 6) && defined(DEV_PMU)
662#if defined(DEV_PMU)
691663 if (pmu_attched) {
692664 u_int cpu;
693665 uint64_t h, h2;
......@@ -711,12 +683,6 @@ get_cyclecount(void)
711683 } else
712684#endif
713685 return cp15_pmccntr_get();
714#else /* No performance counters, so use nanotime(9). */
715 struct timespec tv;
716
717 nanotime(&tv);
718 return (tv.tv_sec * (uint64_t)1000000000ull + tv.tv_nsec);
719#endif
720686}
721687#endif
722688
......@@ -729,7 +695,7 @@ get_cyclecount(void)
729695#define cpu_spinwait() /* nothing */
730696#define cpu_lock_delay() DELAY(1)
731697
732#define ARM_NVEC 8
698#define ARM_NVEC 7
733699#define ARM_VEC_ALL 0xffffffff
734700
735701extern vm_offset_t vector_page;
lib/libc/include/arm-freebsd-eabihf/machine/cpufunc.h-3
......@@ -97,9 +97,6 @@ void armv7_cpu_sleep (int);
9797void pj4b_config (void);
9898#endif
9999
100#if defined(CPU_ARM1176)
101void arm11x6_sleep (int); /* no ref. for errata */
102#endif
103100
104101
105102/*
lib/libc/include/arm-freebsd-eabihf/machine/endian.h-2
......@@ -26,8 +26,6 @@
2626 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2727 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2828 * SUCH DAMAGE.
29 *
30 * @(#)endian.h 8.1 (Berkeley) 6/10/93
3129 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
3230 */
3331
lib/libc/include/arm-freebsd-eabihf/machine/exec.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_EXEC_H_
33#define _MACHINE_EXEC_H_
34
35#define __LDPGSZ 4096
36
37#endif /* !_MACHINE_EXEC_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/fiq.h deleted-71
......@@ -1,71 +0,0 @@
1/* $NetBSD: fiq.h,v 1.1 2001/12/20 01:20:23 thorpej Exp $ */
2
3/*-
4 * SPDX-License-Identifier: BSD-4-Clause
5 *
6 * Copyright (c) 2001 Wasabi Systems, Inc.
7 * All rights reserved.
8 *
9 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed for the NetBSD Project by
22 * Wasabi Systems, Inc.
23 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
24 * or promote products derived from this software without specific prior
25 * written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 *
39 */
40
41#ifndef _MACHINE_FIQ_H_
42#define _MACHINE_FIQ_H_
43
44#include <sys/queue.h>
45
46struct fiqregs {
47 u_int fr_r8; /* FIQ mode r8 */
48 u_int fr_r9; /* FIQ mode r9 */
49 u_int fr_r10; /* FIQ mode r10 */
50 u_int fr_r11; /* FIQ mode r11 */
51 u_int fr_r12; /* FIQ mode r12 */
52 u_int fr_r13; /* FIQ mode r13 */
53};
54
55struct fiqhandler {
56 TAILQ_ENTRY(fiqhandler) fh_list;/* link in the FIQ handler stack */
57 void *fh_func; /* FIQ handler routine */
58 size_t fh_size; /* size of FIQ handler */
59 int fh_flags; /* flags; see below */
60 struct fiqregs *fh_regs; /* pointer to regs structure */
61};
62
63#define FH_CANPUSH 0x01 /* can push this handler out of the way */
64
65int fiq_claim(struct fiqhandler *);
66void fiq_release(struct fiqhandler *);
67
68void fiq_getregs(struct fiqregs *);
69void fiq_setregs(struct fiqregs *);
70
71#endif /* _MACHINE_FIQ_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/float.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3230 */
3331
3432#ifndef _MACHINE_FLOAT_H_
lib/libc/include/arm-freebsd-eabihf/machine/floatingpoint.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
3634 */
3735
3836#ifndef _FLOATINGPOINT_H_
lib/libc/include/arm-freebsd-eabihf/machine/ieee.h-2
......@@ -39,8 +39,6 @@
3939 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4040 * SUCH DAMAGE.
4141 *
42 * @(#)ieee.h 8.1 (Berkeley) 6/11/93
43 *
4442 */
4543
4644/*
lib/libc/include/arm-freebsd-eabihf/machine/ieeefp.h+10
......@@ -49,4 +49,14 @@ typedef enum {
4949
5050#define fp_except_t int
5151
52/* Augment the userland declarations. */
53__BEGIN_DECLS
54extern fp_rnd_t fpgetround(void);
55extern fp_rnd_t fpsetround(fp_rnd_t);
56extern fp_except_t fpgetmask(void);
57extern fp_except_t fpsetmask(fp_except_t);
58extern fp_except_t fpgetsticky(void);
59extern fp_except_t fpsetsticky(fp_except_t);
60__END_DECLS
61
5262#endif /* _MACHINE_IEEEFP_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/in_cksum.h-1
......@@ -29,7 +29,6 @@
2929 * SUCH DAMAGE.
3030 *
3131 * from tahoe: in_cksum.c 1.2 86/01/05
32 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
3332 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
3433 */
3534
lib/libc/include/arm-freebsd-eabihf/machine/intr.h+6-3
......@@ -39,16 +39,19 @@
3939#ifndef _MACHINE_INTR_H_
4040#define _MACHINE_INTR_H_
4141
42#ifndef LOCORE
4243#ifdef FDT
4344#include <dev/ofw/openfirm.h>
4445#endif
4546
47void arm_irq_memory_barrier(uintptr_t);
48#endif /* !LOCORE */
49
4650#ifndef NIRQ
4751#define NIRQ 1024 /* XXX - It should be an option. */
4852#endif
4953
50#include <sys/intr.h>
51
52void arm_irq_memory_barrier(uintptr_t);
54#define INTR_ROOT_IRQ 0
55#define INTR_ROOT_COUNT 1
5356
5457#endif /* _MACHINE_INTR_H */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/machdep.h+7
......@@ -51,6 +51,13 @@ void arm_add_efi_map_entries(struct efi_map_header *efihdr,
5151 struct mem_region *mr, int *mrcnt);
5252#endif
5353
54#ifdef SOCDEV_PA
55/*
56 * The virtual address SOCDEV_PA is mapped at.
57 */
58extern uintptr_t socdev_va;
59#endif
60
5461/*
5562 * Symbols created by ldscript.arm which are accessible in the kernel as global
5663 * symbols. They have uint8 type because they mark the byte location where the
lib/libc/include/arm-freebsd-eabihf/machine/metadata.h+8-3
......@@ -33,10 +33,15 @@
3333#define MODINFOMD_DTBP 0x1002
3434#define MODINFOMD_EFI_MAP 0x1003
3535
36/*
37 * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though
38 * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table
39 * starting at a 16-byte alignment.
40 */
3641struct efi_map_header {
37 uint64_t memory_size;
38 uint64_t descriptor_size;
39 uint32_t descriptor_version;
42 uint64_t memory_size; /* Numnber of bytes that follow */
43 uint64_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
44 uint32_t descriptor_version; /* Currently '1' */
4045};
4146
4247/*
lib/libc/include/arm-freebsd-eabihf/machine/param.h+2-15
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
4038 */
4139
4240#ifndef _ARM_INCLUDE_PARAM_H_
......@@ -51,17 +49,11 @@
5149#define STACKALIGNBYTES (8 - 1)
5250#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)
5351
54#define __PCI_REROUTE_INTERRUPT
55
5652#ifndef MACHINE
5753#define MACHINE "arm"
5854#endif
5955#ifndef MACHINE_ARCH
60#if __ARM_ARCH >= 7
6156#define MACHINE_ARCH "armv7"
62#else
63#define MACHINE_ARCH "armv6"
64#endif
6557#endif
6658
6759#ifdef SMP
......@@ -76,6 +68,8 @@
7668#define MAXMEMDOM 1
7769#endif
7870
71#define __HAVE_STATIC_DEVMAP
72
7973#define ALIGNBYTES _ALIGNBYTES
8074#define ALIGN(p) _ALIGN(p)
8175/*
......@@ -129,17 +123,10 @@
129123/*
130124 * Mach derived conversion macros
131125 */
132#define trunc_page(x) ((x) & ~PAGE_MASK)
133#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
134126#define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK)
135127#define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK)
136128
137#define atop(x) ((unsigned)(x) >> PAGE_SHIFT)
138#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT)
139
140129#define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT)
141130#define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT)
142131
143#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
144
145132#endif /* !_ARM_INCLUDE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/pmap.h+3-12
......@@ -39,9 +39,6 @@
3939 * map the page tables using the pagetables themselves. This is done to
4040 * reduce the impact on kernel virtual memory for lots of sparse address
4141 * space, and to reduce the cost of memory to each process.
42 *
43 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
44 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
4542 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30
4643 */
4744
......@@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */
138135 * vtopte2().
139136 */
140137void pmap_bootstrap(vm_offset_t);
141void pmap_kenter(vm_offset_t, vm_paddr_t);
138void pmap_kenter(vm_offset_t, vm_size_t, vm_paddr_t, int);
142139void pmap_kremove(vm_offset_t);
143boolean_t pmap_page_is_mapped(vm_page_t);
140bool pmap_page_is_mapped(vm_page_t);
144141bool pmap_ps_enabled(pmap_t pmap);
145142
146143void pmap_tlb_flush(pmap_t, vm_offset_t);
......@@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
175172#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)
176173
177174void *pmap_mapdev(vm_paddr_t, vm_size_t);
175void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
178176void pmap_unmapdev(void *, vm_size_t);
179177
180static inline void *
181pmap_mapdev_attr(vm_paddr_t addr __unused, vm_size_t size __unused,
182 int attr __unused)
183{
184 panic("%s is not implemented yet!\n", __func__);
185}
186
187178struct pcb;
188179void pmap_set_pcb_pagedir(pmap_t, struct pcb *);
189180
lib/libc/include/arm-freebsd-eabihf/machine/pmap_var.h+10-10
......@@ -161,7 +161,7 @@ pte1_clear_bit(pt1_entry_t *pte1p, uint32_t bit)
161161 pte1_sync(pte1p);
162162}
163163
164static __inline boolean_t
164static __inline bool
165165pte1_is_link(pt1_entry_t pte1)
166166{
167167
......@@ -175,21 +175,21 @@ pte1_is_section(pt1_entry_t pte1)
175175 return ((pte1 & L1_TYPE_MASK) == L1_TYPE_S);
176176}
177177
178static __inline boolean_t
178static __inline bool
179179pte1_is_dirty(pt1_entry_t pte1)
180180{
181181
182182 return ((pte1 & (PTE1_NM | PTE1_RO)) == 0);
183183}
184184
185static __inline boolean_t
185static __inline bool
186186pte1_is_global(pt1_entry_t pte1)
187187{
188188
189189 return ((pte1 & PTE1_NG) == 0);
190190}
191191
192static __inline boolean_t
192static __inline bool
193193pte1_is_valid(pt1_entry_t pte1)
194194{
195195 int l1_type;
......@@ -198,7 +198,7 @@ pte1_is_valid(pt1_entry_t pte1)
198198 return ((l1_type == L1_TYPE_C) || (l1_type == L1_TYPE_S));
199199}
200200
201static __inline boolean_t
201static __inline bool
202202pte1_is_wired(pt1_entry_t pte1)
203203{
204204
......@@ -301,28 +301,28 @@ pte2_clear_bit(pt2_entry_t *pte2p, uint32_t bit)
301301 pte2_sync(pte2p);
302302}
303303
304static __inline boolean_t
304static __inline bool
305305pte2_is_dirty(pt2_entry_t pte2)
306306{
307307
308308 return ((pte2 & (PTE2_NM | PTE2_RO)) == 0);
309309}
310310
311static __inline boolean_t
311static __inline bool
312312pte2_is_global(pt2_entry_t pte2)
313313{
314314
315315 return ((pte2 & PTE2_NG) == 0);
316316}
317317
318static __inline boolean_t
318static __inline bool
319319pte2_is_valid(pt2_entry_t pte2)
320320{
321321
322322 return (pte2 & PTE2_V);
323323}
324324
325static __inline boolean_t
325static __inline bool
326326pte2_is_wired(pt2_entry_t pte2)
327327{
328328
......@@ -358,7 +358,7 @@ pte2_set_bit(pt2_entry_t *pte2p, uint32_t bit)
358358}
359359
360360static __inline void
361pte2_set_wired(pt2_entry_t *pte2p, boolean_t wired)
361pte2_set_wired(pt2_entry_t *pte2p, bool wired)
362362{
363363
364364 /*
lib/libc/include/arm-freebsd-eabihf/machine/proc.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3634 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
3735 */
3836
lib/libc/include/arm-freebsd-eabihf/machine/profile.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)profile.h 8.1 (Berkeley) 6/11/93
3634 */
3735
3836#ifndef _MACHINE_PROFILE_H_
lib/libc/include/arm-freebsd-eabihf/machine/reloc.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)reloc.h 8.1 (Berkeley) 6/10/93
3634 */
3735
3836#ifndef _MACHINE_RELOC_H_
lib/libc/include/arm-freebsd-eabihf/machine/resource.h-2
......@@ -40,8 +40,6 @@
4040#define SYS_RES_MEMORY 3 /* i/o memory */
4141#define SYS_RES_IOPORT 4 /* i/o ports */
4242#define SYS_RES_GPIO 5 /* general purpose i/o */
43#ifdef NEW_PCIB
4443#define PCI_RES_BUS 6 /* PCI bus numbers */
45#endif
4644
4745#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/runq.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RUNQ_H_
30#define _MACHINE_RUNQ_H_
31
32#define RQB_LEN (2) /* Number of priority status words. */
33#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */
34#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */
35
36#define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1)))
37#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
38
39#define RQB_FFS(word) (ffs(word) - 1)
40
41/*
42 * Type of run queue status word.
43 */
44typedef u_int32_t rqb_word_t;
45
46#endif
\ No newline at end of file
lib/libc/include/arm-freebsd-eabihf/machine/signal.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.1 (Berkeley) 6/11/93
3230 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
3331 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
3432 */
lib/libc/include/arm-freebsd-eabihf/machine/sysarch.h+2
......@@ -38,6 +38,8 @@
3838#ifndef _ARM_SYSARCH_H_
3939#define _ARM_SYSARCH_H_
4040
41#include <sys/cdefs.h>
42
4143#include <machine/armreg.h>
4244
4345#ifndef LOCORE
lib/libc/include/arm-freebsd-eabihf/machine/sysreg.h+2-36
......@@ -127,11 +127,9 @@
127127
128128/* From ARMv6: */
129129#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */
130#if __ARM_ARCH >= 7
131130/* From ARMv7: */
132131#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */
133132#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */
134#endif
135133
136134/*
137135 * CP15 C6 registers
......@@ -147,7 +145,7 @@
147145/*
148146 * CP15 C7 registers
149147 */
150#if __ARM_ARCH >= 7 && defined(SMP)
148#if defined(SMP)
151149/* From ARMv7: */
152150#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */
153151#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */
......@@ -157,17 +155,9 @@
157155
158156#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */
159157#define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */
160#if __ARM_ARCH == 6
161/* Deprecated in ARMv7 */
162#define CP15_CP15ISB p15, 0, r0, c7, c5, 4 /* ISB */
163#endif
164158#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */
165159#define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */
166160
167#if __ARM_ARCH == 6
168/* Only ARMv6: */
169#define CP15_DCIALL p15, 0, r0, c7, c6, 0 /* Data cache invalidate all */
170#endif
171161#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */
172162#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */
173163
......@@ -176,43 +166,25 @@
176166#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */
177167#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */
178168
179#if __ARM_ARCH >= 7
180169/* From ARMv7: */
181170#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */
182171#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */
183172#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */
184173#define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */
185#endif
186174
187#if __ARM_ARCH == 6
188/* Only ARMv6: */
189#define CP15_DCCALL p15, 0, r0, c7, c10, 0 /* Data cache clean all */
190#endif
191175#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */
192176#define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */
193#if __ARM_ARCH == 6
194/* Only ARMv6: */
195#define CP15_CP15DSB p15, 0, r0, c7, c10, 4 /* DSB */
196#define CP15_CP15DMB p15, 0, r0, c7, c10, 5 /* DMB */
197#define CP15_CP15WFI p15, 0, r0, c7, c0, 4 /* WFI */
198#endif
199177
200#if __ARM_ARCH >= 7
201178/* From ARMv7: */
202179#define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */
203#endif
204180
205#if __ARM_ARCH == 6
206/* Only ARMv6: */
207#define CP15_DCCIALL p15, 0, r0, c7, c14, 0 /* Data cache clean and invalidate all */
208#endif
209181#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */
210182#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */
211183
212184/*
213185 * CP15 C8 registers
214186 */
215#if __ARM_ARCH >= 7 && defined(SMP)
187#if defined(SMP)
216188/* From ARMv7: */
217189#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */
218190#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */
......@@ -232,11 +204,6 @@
232204/*
233205 * CP15 C9 registers
234206 */
235#if __ARM_ARCH == 6 && defined(CPU_ARM1176)
236#define CP15_PMUSERENR(rr) p15, 0, rr, c15, c9, 0 /* Access Validation Control Register */
237#define CP15_PMCR(rr) p15, 0, rr, c15, c12, 0 /* Performance Monitor Control Register */
238#define CP15_PMCCNTR(rr) p15, 0, rr, c15, c12, 1 /* PM Cycle Count Register */
239#else
240207#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */
241208#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */
242209#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */
......@@ -250,7 +217,6 @@
250217#define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */
251218#define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */
252219#define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */
253#endif
254220
255221/*
256222 * CP15 C10 registers
lib/libc/include/arm-freebsd-eabihf/machine/vm.h+1-1
......@@ -36,7 +36,7 @@
3636#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)4)
3737
3838#define VM_MEMATTR_DEFAULT VM_MEMATTR_WB_WA
39#define VM_MEMATTR_UNCACHEABLE VM_MEMATTR_SO /* misused by DMA */
39#define VM_MEMATTR_UNCACHEABLE VM_MEMATTR_NOCACHE /* used by BUSDMA */
4040#ifdef _KERNEL
4141/* Don't export aliased VM_MEMATTR to userland */
4242#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH /* for DRM */
lib/libc/include/arm-freebsd-eabihf/machine/vmparam.h+1
......@@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address;
200200 * Need a page dump array for minidump.
201201 */
202202#define MINIDUMP_PAGE_TRACKING 1
203#define MINIDUMP_STARTUP_PAGE_TRACKING 0
203204
204205#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/_ctype.h-2
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * From @(#)ctype.h 8.4 (Berkeley) 1/21/94
4038 * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp
4139 */
4240
lib/libc/include/generic-freebsd/_libsys.h created+881
......@@ -0,0 +1,881 @@
1/*
2 * Public system call stubs provided by libsys.
3 *
4 * Do not use directly, include <libsys.h> instead.
5 *
6 * DO NOT EDIT-- this file is automatically @generated.
7 */
8
9#ifndef __LIBSYS_H_
10#define __LIBSYS_H_
11
12#include <sys/_cpuset.h>
13#include <sys/_domainset.h>
14#include <sys/_ffcounter.h>
15#include <sys/_semaphore.h>
16#include <sys/_sigaltstack.h>
17#include <machine/ucontext.h> /* for mcontext_t */
18#include <sys/_ucontext.h>
19#include <sys/wait.h>
20
21struct __siginfo;
22struct __ucontext;
23struct __wrusage;
24struct acl;
25struct aiocb;
26struct auditinfo;
27struct auditinfo_addr;
28struct ffclock_estimate;
29struct fhandle;
30struct iovec;
31struct itimerspec;
32struct itimerval;
33struct jail;
34struct kevent;
35struct kld_file_stat;
36struct mac;
37struct module_stat;
38struct mq_attr;
39struct msghdr;
40struct msqid_ds;
41struct ntptimeval;
42struct pollfd;
43struct rlimit;
44struct rtprio;
45struct rusage;
46struct sched_param;
47struct sctp_sndrcvinfo;
48struct sembuf;
49struct setcred;
50struct sf_hdtr;
51struct shmid_ds;
52struct sigaction;
53struct sigaltstack;
54struct sigevent;
55struct sockaddr;
56struct spacectl_range;
57struct stat;
58struct statfs;
59struct thr_param;
60struct timespec;
61struct timeval;
62struct timex;
63struct timezone;
64struct uuid;
65union semun;
66
67__BEGIN_DECLS
68typedef void (__sys__exit_t)(int);
69typedef int (__sys_fork_t)(void);
70typedef ssize_t (__sys_read_t)(int, void *, size_t);
71typedef ssize_t (__sys_write_t)(int, const void *, size_t);
72typedef int (__sys_open_t)(const char *, int, mode_t);
73typedef int (__sys_close_t)(int);
74typedef int (__sys_wait4_t)(int, int *, int, struct rusage *);
75typedef int (__sys_link_t)(const char *, const char *);
76typedef int (__sys_unlink_t)(const char *);
77typedef int (__sys_chdir_t)(const char *);
78typedef int (__sys_fchdir_t)(int);
79typedef int (__sys_chmod_t)(const char *, mode_t);
80typedef int (__sys_chown_t)(const char *, int, int);
81typedef void * (__sys_break_t)(char *);
82typedef pid_t (__sys_getpid_t)(void);
83typedef int (__sys_mount_t)(const char *, const char *, int, void *);
84typedef int (__sys_unmount_t)(const char *, int);
85typedef int (__sys_setuid_t)(uid_t);
86typedef uid_t (__sys_getuid_t)(void);
87typedef uid_t (__sys_geteuid_t)(void);
88typedef int (__sys_ptrace_t)(int, pid_t, caddr_t, int);
89typedef ssize_t (__sys_recvmsg_t)(int, struct msghdr *, int);
90typedef ssize_t (__sys_sendmsg_t)(int, const struct msghdr *, int);
91typedef ssize_t (__sys_recvfrom_t)(int, void *, size_t, int, struct sockaddr *, __socklen_t *);
92typedef int (__sys_accept_t)(int, struct sockaddr *, __socklen_t *);
93typedef int (__sys_getpeername_t)(int, struct sockaddr *, __socklen_t *);
94typedef int (__sys_getsockname_t)(int, struct sockaddr *, __socklen_t *);
95typedef int (__sys_access_t)(const char *, int);
96typedef int (__sys_chflags_t)(const char *, u_long);
97typedef int (__sys_fchflags_t)(int, u_long);
98typedef int (__sys_sync_t)(void);
99typedef int (__sys_kill_t)(int, int);
100typedef pid_t (__sys_getppid_t)(void);
101typedef int (__sys_dup_t)(u_int);
102typedef gid_t (__sys_getegid_t)(void);
103typedef int (__sys_profil_t)(char *, size_t, size_t, u_int);
104typedef int (__sys_ktrace_t)(const char *, int, int, int);
105typedef gid_t (__sys_getgid_t)(void);
106typedef int (__sys_getlogin_t)(char *, u_int);
107typedef int (__sys_setlogin_t)(const char *);
108typedef int (__sys_acct_t)(const char *);
109typedef int (__sys_sigaltstack_t)(const struct sigaltstack *, struct sigaltstack *);
110typedef int (__sys_ioctl_t)(int, u_long, char *);
111typedef int (__sys_reboot_t)(int);
112typedef int (__sys_revoke_t)(const char *);
113typedef int (__sys_symlink_t)(const char *, const char *);
114typedef ssize_t (__sys_readlink_t)(const char *, char *, size_t);
115typedef int (__sys_execve_t)(const char *, char **, char **);
116typedef mode_t (__sys_umask_t)(mode_t);
117typedef int (__sys_chroot_t)(const char *);
118typedef int (__sys_msync_t)(void *, size_t, int);
119typedef int (__sys_vfork_t)(void);
120typedef int (__sys_munmap_t)(void *, size_t);
121typedef int (__sys_mprotect_t)(void *, size_t, int);
122typedef int (__sys_madvise_t)(void *, size_t, int);
123typedef int (__sys_mincore_t)(const void *, size_t, char *);
124typedef int (__sys_getpgrp_t)(void);
125typedef int (__sys_setpgid_t)(int, int);
126typedef int (__sys_setitimer_t)(int, const struct itimerval *, struct itimerval *);
127typedef int (__sys_swapon_t)(const char *);
128typedef int (__sys_getitimer_t)(int, struct itimerval *);
129typedef int (__sys_getdtablesize_t)(void);
130typedef int (__sys_dup2_t)(u_int, u_int);
131typedef int (__sys_fcntl_t)(int, int, intptr_t);
132typedef int (__sys_select_t)(int, fd_set *, fd_set *, fd_set *, struct timeval *);
133typedef int (__sys_fsync_t)(int);
134typedef int (__sys_setpriority_t)(int, int, int);
135typedef int (__sys_socket_t)(int, int, int);
136typedef int (__sys_connect_t)(int, const struct sockaddr *, __socklen_t);
137typedef int (__sys_getpriority_t)(int, int);
138typedef int (__sys_bind_t)(int, const struct sockaddr *, __socklen_t);
139typedef int (__sys_setsockopt_t)(int, int, int, const void *, __socklen_t);
140typedef int (__sys_listen_t)(int, int);
141typedef int (__sys_gettimeofday_t)(struct timeval *, struct timezone *);
142typedef int (__sys_getrusage_t)(int, struct rusage *);
143typedef int (__sys_getsockopt_t)(int, int, int, void *, __socklen_t *);
144typedef ssize_t (__sys_readv_t)(int, const struct iovec *, u_int);
145typedef ssize_t (__sys_writev_t)(int, const struct iovec *, u_int);
146typedef int (__sys_settimeofday_t)(const struct timeval *, const struct timezone *);
147typedef int (__sys_fchown_t)(int, int, int);
148typedef int (__sys_fchmod_t)(int, mode_t);
149typedef int (__sys_setreuid_t)(int, int);
150typedef int (__sys_setregid_t)(int, int);
151typedef int (__sys_rename_t)(const char *, const char *);
152typedef int (__sys_flock_t)(int, int);
153typedef int (__sys_mkfifo_t)(const char *, mode_t);
154typedef ssize_t (__sys_sendto_t)(int, const void *, size_t, int, const struct sockaddr *, __socklen_t);
155typedef int (__sys_shutdown_t)(int, int);
156typedef int (__sys_socketpair_t)(int, int, int, int *);
157typedef int (__sys_mkdir_t)(const char *, mode_t);
158typedef int (__sys_rmdir_t)(const char *);
159typedef int (__sys_utimes_t)(const char *, const struct timeval *);
160typedef int (__sys_adjtime_t)(const struct timeval *, struct timeval *);
161typedef int (__sys_setsid_t)(void);
162typedef int (__sys_quotactl_t)(const char *, int, int, void *);
163typedef int (__sys_nlm_syscall_t)(int, int, int, char **);
164typedef int (__sys_nfssvc_t)(int, void *);
165typedef int (__sys_lgetfh_t)(const char *, struct fhandle *);
166typedef int (__sys_getfh_t)(const char *, struct fhandle *);
167typedef int (__sys_sysarch_t)(int, char *);
168typedef int (__sys_rtprio_t)(int, pid_t, struct rtprio *);
169typedef int (__sys_semsys_t)(int, int, int, int, int);
170typedef int (__sys_msgsys_t)(int, int, int, int, int, int);
171typedef int (__sys_shmsys_t)(int, int, int, int);
172typedef int (__sys_setfib_t)(int);
173typedef int (__sys_ntp_adjtime_t)(struct timex *);
174typedef int (__sys_setgid_t)(gid_t);
175typedef int (__sys_setegid_t)(gid_t);
176typedef int (__sys_seteuid_t)(uid_t);
177typedef int (__sys_pathconf_t)(const char *, int);
178typedef int (__sys_fpathconf_t)(int, int);
179typedef int (__sys_getrlimit_t)(u_int, struct rlimit *);
180typedef int (__sys_setrlimit_t)(u_int, struct rlimit *);
181typedef int (__sys___sysctl_t)(const int *, u_int, void *, size_t *, const void *, size_t);
182typedef int (__sys_mlock_t)(const void *, size_t);
183typedef int (__sys_munlock_t)(const void *, size_t);
184typedef int (__sys_undelete_t)(const char *);
185typedef int (__sys_futimes_t)(int, const struct timeval *);
186typedef int (__sys_getpgid_t)(pid_t);
187typedef int (__sys_poll_t)(struct pollfd *, u_int, int);
188typedef int (__sys_semget_t)(key_t, int, int);
189typedef int (__sys_semop_t)(int, struct sembuf *, size_t);
190typedef int (__sys_msgget_t)(key_t, int);
191typedef int (__sys_msgsnd_t)(int, const void *, size_t, int);
192typedef ssize_t (__sys_msgrcv_t)(int, void *, size_t, long, int);
193typedef void * (__sys_shmat_t)(int, const void *, int);
194typedef int (__sys_shmdt_t)(const void *);
195typedef int (__sys_shmget_t)(key_t, size_t, int);
196typedef int (__sys_clock_gettime_t)(clockid_t, struct timespec *);
197typedef int (__sys_clock_settime_t)(clockid_t, const struct timespec *);
198typedef int (__sys_clock_getres_t)(clockid_t, struct timespec *);
199typedef int (__sys_ktimer_create_t)(clockid_t, struct sigevent *, int *);
200typedef int (__sys_ktimer_delete_t)(int);
201typedef int (__sys_ktimer_settime_t)(int, int, const struct itimerspec *, struct itimerspec *);
202typedef int (__sys_ktimer_gettime_t)(int, struct itimerspec *);
203typedef int (__sys_ktimer_getoverrun_t)(int);
204typedef int (__sys_nanosleep_t)(const struct timespec *, struct timespec *);
205typedef int (__sys_ffclock_getcounter_t)(ffcounter *);
206typedef int (__sys_ffclock_setestimate_t)(struct ffclock_estimate *);
207typedef int (__sys_ffclock_getestimate_t)(struct ffclock_estimate *);
208typedef int (__sys_clock_nanosleep_t)(clockid_t, int, const struct timespec *, struct timespec *);
209typedef int (__sys_clock_getcpuclockid2_t)(id_t, int, clockid_t *);
210typedef int (__sys_ntp_gettime_t)(struct ntptimeval *);
211typedef int (__sys_minherit_t)(void *, size_t, int);
212typedef int (__sys_rfork_t)(int);
213typedef int (__sys_issetugid_t)(void);
214typedef int (__sys_lchown_t)(const char *, int, int);
215typedef int (__sys_aio_read_t)(struct aiocb *);
216typedef int (__sys_aio_write_t)(struct aiocb *);
217typedef int (__sys_lio_listio_t)(int, struct aiocb * const *, int, struct sigevent *);
218typedef int (__sys_lchmod_t)(const char *, mode_t);
219typedef int (__sys_lutimes_t)(const char *, const struct timeval *);
220typedef ssize_t (__sys_preadv_t)(int, struct iovec *, u_int, off_t);
221typedef ssize_t (__sys_pwritev_t)(int, struct iovec *, u_int, off_t);
222typedef int (__sys_fhopen_t)(const struct fhandle *, int);
223typedef int (__sys_modnext_t)(int);
224typedef int (__sys_modstat_t)(int, struct module_stat *);
225typedef int (__sys_modfnext_t)(int);
226typedef int (__sys_modfind_t)(const char *);
227typedef int (__sys_kldload_t)(const char *);
228typedef int (__sys_kldunload_t)(int);
229typedef int (__sys_kldfind_t)(const char *);
230typedef int (__sys_kldnext_t)(int);
231typedef int (__sys_kldstat_t)(int, struct kld_file_stat *);
232typedef int (__sys_kldfirstmod_t)(int);
233typedef int (__sys_getsid_t)(pid_t);
234typedef int (__sys_setresuid_t)(uid_t, uid_t, uid_t);
235typedef int (__sys_setresgid_t)(gid_t, gid_t, gid_t);
236typedef ssize_t (__sys_aio_return_t)(struct aiocb *);
237typedef int (__sys_aio_suspend_t)(const struct aiocb * const *, int, const struct timespec *);
238typedef int (__sys_aio_cancel_t)(int, struct aiocb *);
239typedef int (__sys_aio_error_t)(struct aiocb *);
240typedef int (__sys_mlockall_t)(int);
241typedef int (__sys_munlockall_t)(void);
242typedef int (__sys___getcwd_t)(char *, size_t);
243typedef int (__sys_sched_setparam_t)(pid_t, const struct sched_param *);
244typedef int (__sys_sched_getparam_t)(pid_t, struct sched_param *);
245typedef int (__sys_sched_setscheduler_t)(pid_t, int, const struct sched_param *);
246typedef int (__sys_sched_getscheduler_t)(pid_t);
247typedef int (__sys_sched_yield_t)(void);
248typedef int (__sys_sched_get_priority_max_t)(int);
249typedef int (__sys_sched_get_priority_min_t)(int);
250typedef int (__sys_sched_rr_get_interval_t)(pid_t, struct timespec *);
251typedef int (__sys_utrace_t)(const void *, size_t);
252typedef int (__sys_kldsym_t)(int, int, void *);
253typedef int (__sys_jail_t)(struct jail *);
254typedef int (__sys_nnpfs_syscall_t)(int, char *, int, void *, int);
255typedef int (__sys_sigprocmask_t)(int, const sigset_t *, sigset_t *);
256typedef int (__sys_sigsuspend_t)(const sigset_t *);
257typedef int (__sys_sigpending_t)(sigset_t *);
258typedef int (__sys_sigtimedwait_t)(const sigset_t *, struct __siginfo *, const struct timespec *);
259typedef int (__sys_sigwaitinfo_t)(const sigset_t *, struct __siginfo *);
260typedef int (__sys___acl_get_file_t)(const char *, __acl_type_t, struct acl *);
261typedef int (__sys___acl_set_file_t)(const char *, __acl_type_t, struct acl *);
262typedef int (__sys___acl_get_fd_t)(int, __acl_type_t, struct acl *);
263typedef int (__sys___acl_set_fd_t)(int, __acl_type_t, struct acl *);
264typedef int (__sys___acl_delete_file_t)(const char *, __acl_type_t);
265typedef int (__sys___acl_delete_fd_t)(int, __acl_type_t);
266typedef int (__sys___acl_aclcheck_file_t)(const char *, __acl_type_t, struct acl *);
267typedef int (__sys___acl_aclcheck_fd_t)(int, __acl_type_t, struct acl *);
268typedef int (__sys_extattrctl_t)(const char *, int, const char *, int, const char *);
269typedef ssize_t (__sys_extattr_set_file_t)(const char *, int, const char *, void *, size_t);
270typedef ssize_t (__sys_extattr_get_file_t)(const char *, int, const char *, void *, size_t);
271typedef int (__sys_extattr_delete_file_t)(const char *, int, const char *);
272typedef ssize_t (__sys_aio_waitcomplete_t)(struct aiocb **, struct timespec *);
273typedef int (__sys_getresuid_t)(uid_t *, uid_t *, uid_t *);
274typedef int (__sys_getresgid_t)(gid_t *, gid_t *, gid_t *);
275typedef int (__sys_kqueue_t)(void);
276typedef ssize_t (__sys_extattr_set_fd_t)(int, int, const char *, void *, size_t);
277typedef ssize_t (__sys_extattr_get_fd_t)(int, int, const char *, void *, size_t);
278typedef int (__sys_extattr_delete_fd_t)(int, int, const char *);
279typedef int (__sys___setugid_t)(int);
280typedef int (__sys_eaccess_t)(const char *, int);
281typedef int (__sys_afs3_syscall_t)(long, long, long, long, long, long, long);
282typedef int (__sys_nmount_t)(struct iovec *, unsigned int, int);
283typedef int (__sys___mac_get_proc_t)(struct mac *);
284typedef int (__sys___mac_set_proc_t)(struct mac *);
285typedef int (__sys___mac_get_fd_t)(int, struct mac *);
286typedef int (__sys___mac_get_file_t)(const char *, struct mac *);
287typedef int (__sys___mac_set_fd_t)(int, struct mac *);
288typedef int (__sys___mac_set_file_t)(const char *, struct mac *);
289typedef int (__sys_kenv_t)(int, const char *, char *, int);
290typedef int (__sys_lchflags_t)(const char *, u_long);
291typedef int (__sys_uuidgen_t)(struct uuid *, int);
292typedef int (__sys_sendfile_t)(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int);
293typedef int (__sys_mac_syscall_t)(const char *, int, void *);
294typedef int (__sys_ksem_close_t)(semid_t);
295typedef int (__sys_ksem_post_t)(semid_t);
296typedef int (__sys_ksem_wait_t)(semid_t);
297typedef int (__sys_ksem_trywait_t)(semid_t);
298typedef int (__sys_ksem_init_t)(semid_t *, unsigned int);
299typedef int (__sys_ksem_open_t)(semid_t *, const char *, int, mode_t, unsigned int);
300typedef int (__sys_ksem_unlink_t)(const char *);
301typedef int (__sys_ksem_getvalue_t)(semid_t, int *);
302typedef int (__sys_ksem_destroy_t)(semid_t);
303typedef int (__sys___mac_get_pid_t)(pid_t, struct mac *);
304typedef int (__sys___mac_get_link_t)(const char *, struct mac *);
305typedef int (__sys___mac_set_link_t)(const char *, struct mac *);
306typedef ssize_t (__sys_extattr_set_link_t)(const char *, int, const char *, void *, size_t);
307typedef ssize_t (__sys_extattr_get_link_t)(const char *, int, const char *, void *, size_t);
308typedef int (__sys_extattr_delete_link_t)(const char *, int, const char *);
309typedef int (__sys___mac_execve_t)(const char *, char **, char **, struct mac *);
310typedef int (__sys_sigaction_t)(int, const struct sigaction *, struct sigaction *);
311typedef int (__sys_sigreturn_t)(const struct __ucontext *);
312typedef int (__sys_getcontext_t)(struct __ucontext *);
313typedef int (__sys_setcontext_t)(const struct __ucontext *);
314typedef int (__sys_swapcontext_t)(struct __ucontext *, const struct __ucontext *);
315typedef int (__sys___acl_get_link_t)(const char *, __acl_type_t, struct acl *);
316typedef int (__sys___acl_set_link_t)(const char *, __acl_type_t, struct acl *);
317typedef int (__sys___acl_delete_link_t)(const char *, __acl_type_t);
318typedef int (__sys___acl_aclcheck_link_t)(const char *, __acl_type_t, struct acl *);
319typedef int (__sys_sigwait_t)(const sigset_t *, int *);
320typedef int (__sys_thr_create_t)(ucontext_t *, long *, int);
321typedef void (__sys_thr_exit_t)(long *);
322typedef int (__sys_thr_self_t)(long *);
323typedef int (__sys_thr_kill_t)(long, int);
324typedef int (__sys_jail_attach_t)(int);
325typedef ssize_t (__sys_extattr_list_fd_t)(int, int, void *, size_t);
326typedef ssize_t (__sys_extattr_list_file_t)(const char *, int, void *, size_t);
327typedef ssize_t (__sys_extattr_list_link_t)(const char *, int, void *, size_t);
328typedef int (__sys_ksem_timedwait_t)(semid_t, const struct timespec *);
329typedef int (__sys_thr_suspend_t)(const struct timespec *);
330typedef int (__sys_thr_wake_t)(long);
331typedef int (__sys_kldunloadf_t)(int, int);
332typedef int (__sys_audit_t)(const void *, u_int);
333typedef int (__sys_auditon_t)(int, void *, u_int);
334typedef int (__sys_getauid_t)(uid_t *);
335typedef int (__sys_setauid_t)(uid_t *);
336typedef int (__sys_getaudit_t)(struct auditinfo *);
337typedef int (__sys_setaudit_t)(struct auditinfo *);
338typedef int (__sys_getaudit_addr_t)(struct auditinfo_addr *, u_int);
339typedef int (__sys_setaudit_addr_t)(struct auditinfo_addr *, u_int);
340typedef int (__sys_auditctl_t)(const char *);
341typedef int (__sys__umtx_op_t)(void *, int, u_long, void *, void *);
342typedef int (__sys_thr_new_t)(struct thr_param *, int);
343typedef int (__sys_sigqueue_t)(pid_t, int, void *);
344typedef int (__sys_kmq_open_t)(const char *, int, mode_t, const struct mq_attr *);
345typedef int (__sys_kmq_setattr_t)(int, const struct mq_attr *, struct mq_attr *);
346typedef int (__sys_kmq_timedreceive_t)(int, char *, size_t, unsigned *, const struct timespec *);
347typedef int (__sys_kmq_timedsend_t)(int, const char *, size_t, unsigned, const struct timespec *);
348typedef int (__sys_kmq_notify_t)(int, const struct sigevent *);
349typedef int (__sys_kmq_unlink_t)(const char *);
350typedef void (__sys_abort2_t)(const char *, int, void **);
351typedef int (__sys_thr_set_name_t)(long, const char *);
352typedef int (__sys_aio_fsync_t)(int, struct aiocb *);
353typedef int (__sys_rtprio_thread_t)(int, lwpid_t, struct rtprio *);
354typedef int (__sys_sctp_peeloff_t)(int, uint32_t);
355typedef int (__sys_sctp_generic_sendmsg_t)(int, void *, int, const struct sockaddr *, __socklen_t, struct sctp_sndrcvinfo *, int);
356typedef int (__sys_sctp_generic_sendmsg_iov_t)(int, struct iovec *, int, const struct sockaddr *, __socklen_t, struct sctp_sndrcvinfo *, int);
357typedef int (__sys_sctp_generic_recvmsg_t)(int, struct iovec *, int, struct sockaddr *, __socklen_t *, struct sctp_sndrcvinfo *, int *);
358typedef ssize_t (__sys_pread_t)(int, void *, size_t, off_t);
359typedef ssize_t (__sys_pwrite_t)(int, const void *, size_t, off_t);
360typedef void * (__sys_mmap_t)(void *, size_t, int, int, int, off_t);
361typedef off_t (__sys_lseek_t)(int, off_t, int);
362typedef int (__sys_truncate_t)(const char *, off_t);
363typedef int (__sys_ftruncate_t)(int, off_t);
364typedef int (__sys_thr_kill2_t)(pid_t, long, int);
365typedef int (__sys_shm_unlink_t)(const char *);
366typedef int (__sys_cpuset_t)(cpusetid_t *);
367typedef int (__sys_cpuset_setid_t)(cpuwhich_t, id_t, cpusetid_t);
368typedef int (__sys_cpuset_getid_t)(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
369typedef int (__sys_cpuset_getaffinity_t)(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t *);
370typedef int (__sys_cpuset_setaffinity_t)(cpulevel_t, cpuwhich_t, id_t, size_t, const cpuset_t *);
371typedef int (__sys_faccessat_t)(int, const char *, int, int);
372typedef int (__sys_fchmodat_t)(int, const char *, mode_t, int);
373typedef int (__sys_fchownat_t)(int, const char *, uid_t, gid_t, int);
374typedef int (__sys_fexecve_t)(int, char **, char **);
375typedef int (__sys_futimesat_t)(int, const char *, const struct timeval *);
376typedef int (__sys_linkat_t)(int, const char *, int, const char *, int);
377typedef int (__sys_mkdirat_t)(int, const char *, mode_t);
378typedef int (__sys_mkfifoat_t)(int, const char *, mode_t);
379typedef int (__sys_openat_t)(int, const char *, int, mode_t);
380typedef ssize_t (__sys_readlinkat_t)(int, const char *, char *, size_t);
381typedef int (__sys_renameat_t)(int, const char *, int, const char *);
382typedef int (__sys_symlinkat_t)(const char *, int, const char *);
383typedef int (__sys_unlinkat_t)(int, const char *, int);
384typedef int (__sys_posix_openpt_t)(int);
385typedef int (__sys_jail_get_t)(struct iovec *, unsigned int, int);
386typedef int (__sys_jail_set_t)(struct iovec *, unsigned int, int);
387typedef int (__sys_jail_remove_t)(int);
388typedef int (__sys___semctl_t)(int, int, int, union semun *);
389typedef int (__sys_msgctl_t)(int, int, struct msqid_ds *);
390typedef int (__sys_shmctl_t)(int, int, struct shmid_ds *);
391typedef int (__sys_lpathconf_t)(const char *, int);
392typedef int (__sys___cap_rights_get_t)(int, int, cap_rights_t *);
393typedef int (__sys_cap_enter_t)(void);
394typedef int (__sys_cap_getmode_t)(u_int *);
395typedef int (__sys_pdfork_t)(int *, int);
396typedef int (__sys_pdkill_t)(int, int);
397typedef int (__sys_pdgetpid_t)(int, pid_t *);
398typedef int (__sys_pselect_t)(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *);
399typedef int (__sys_getloginclass_t)(char *, size_t);
400typedef int (__sys_setloginclass_t)(const char *);
401typedef int (__sys_rctl_get_racct_t)(const void *, size_t, void *, size_t);
402typedef int (__sys_rctl_get_rules_t)(const void *, size_t, void *, size_t);
403typedef int (__sys_rctl_get_limits_t)(const void *, size_t, void *, size_t);
404typedef int (__sys_rctl_add_rule_t)(const void *, size_t, void *, size_t);
405typedef int (__sys_rctl_remove_rule_t)(const void *, size_t, void *, size_t);
406typedef int (__sys_posix_fallocate_t)(int, off_t, off_t);
407typedef int (__sys_posix_fadvise_t)(int, off_t, off_t, int);
408typedef int (__sys_wait6_t)(idtype_t, id_t, int *, int, struct __wrusage *, struct __siginfo *);
409typedef int (__sys_cap_rights_limit_t)(int, cap_rights_t *);
410typedef int (__sys_cap_ioctls_limit_t)(int, const u_long *, size_t);
411typedef ssize_t (__sys_cap_ioctls_get_t)(int, u_long *, size_t);
412typedef int (__sys_cap_fcntls_limit_t)(int, uint32_t);
413typedef int (__sys_cap_fcntls_get_t)(int, uint32_t *);
414typedef int (__sys_bindat_t)(int, int, const struct sockaddr *, __socklen_t);
415typedef int (__sys_connectat_t)(int, int, const struct sockaddr *, __socklen_t);
416typedef int (__sys_chflagsat_t)(int, const char *, u_long, int);
417typedef int (__sys_accept4_t)(int, struct sockaddr *, __socklen_t *, int);
418typedef int (__sys_pipe2_t)(int *, int);
419typedef int (__sys_aio_mlock_t)(struct aiocb *);
420typedef int (__sys_procctl_t)(idtype_t, id_t, int, void *);
421typedef int (__sys_ppoll_t)(struct pollfd *, u_int, const struct timespec *, const sigset_t *);
422typedef int (__sys_futimens_t)(int, const struct timespec *);
423typedef int (__sys_utimensat_t)(int, const char *, const struct timespec *, int);
424typedef int (__sys_fdatasync_t)(int);
425typedef int (__sys_fstat_t)(int, struct stat *);
426typedef int (__sys_fstatat_t)(int, const char *, struct stat *, int);
427typedef int (__sys_fhstat_t)(const struct fhandle *, struct stat *);
428typedef ssize_t (__sys_getdirentries_t)(int, char *, size_t, off_t *);
429typedef int (__sys_statfs_t)(const char *, struct statfs *);
430typedef int (__sys_fstatfs_t)(int, struct statfs *);
431typedef int (__sys_getfsstat_t)(struct statfs *, long, int);
432typedef int (__sys_fhstatfs_t)(const struct fhandle *, struct statfs *);
433typedef int (__sys_mknodat_t)(int, const char *, mode_t, dev_t);
434typedef int (__sys_kevent_t)(int, const struct kevent *, int, struct kevent *, int, const struct timespec *);
435typedef int (__sys_cpuset_getdomain_t)(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *, int *);
436typedef int (__sys_cpuset_setdomain_t)(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *, int);
437typedef int (__sys_getrandom_t)(void *, size_t, unsigned int);
438typedef int (__sys_getfhat_t)(int, char *, struct fhandle *, int);
439typedef int (__sys_fhlink_t)(struct fhandle *, const char *);
440typedef int (__sys_fhlinkat_t)(struct fhandle *, int, const char *);
441typedef int (__sys_fhreadlink_t)(struct fhandle *, char *, size_t);
442typedef int (__sys_funlinkat_t)(int, const char *, int, int);
443typedef ssize_t (__sys_copy_file_range_t)(int, off_t *, int, off_t *, size_t, unsigned int);
444typedef int (__sys___sysctlbyname_t)(const char *, size_t, void *, size_t *, void *, size_t);
445typedef int (__sys_shm_open2_t)(const char *, int, mode_t, int, const char *);
446typedef int (__sys_shm_rename_t)(const char *, const char *, int);
447typedef int (__sys_sigfastblock_t)(int, void *);
448typedef int (__sys___realpathat_t)(int, const char *, char *, size_t, int);
449typedef int (__sys_close_range_t)(u_int, u_int, int);
450typedef int (__sys_rpctls_syscall_t)(uint64_t);
451typedef int (__sys___specialfd_t)(int, const void *, size_t);
452typedef int (__sys_aio_writev_t)(struct aiocb *);
453typedef int (__sys_aio_readv_t)(struct aiocb *);
454typedef int (__sys_fspacectl_t)(int, int, const struct spacectl_range *, int, struct spacectl_range *);
455typedef int (__sys_sched_getcpu_t)(void);
456typedef int (__sys_swapoff_t)(const char *, u_int);
457typedef int (__sys_kqueuex_t)(u_int);
458typedef int (__sys_membarrier_t)(int, unsigned, int);
459typedef int (__sys_timerfd_create_t)(int, int);
460typedef int (__sys_timerfd_gettime_t)(int, struct itimerspec *);
461typedef int (__sys_timerfd_settime_t)(int, int, const struct itimerspec *, struct itimerspec *);
462typedef int (__sys_kcmp_t)(pid_t, pid_t, int, uintptr_t, uintptr_t);
463typedef int (__sys_getrlimitusage_t)(u_int, int, rlim_t *);
464typedef int (__sys_fchroot_t)(int);
465typedef int (__sys_setcred_t)(u_int, const struct setcred *, size_t);
466typedef int (__sys_exterrctl_t)(u_int, u_int, void *);
467typedef int (__sys_inotify_add_watch_at_t)(int, int, const char *, uint32_t);
468typedef int (__sys_inotify_rm_watch_t)(int, int);
469typedef int (__sys_getgroups_t)(int, gid_t *);
470typedef int (__sys_setgroups_t)(int, const gid_t *);
471typedef int (__sys_jail_attach_jd_t)(int);
472typedef int (__sys_jail_remove_jd_t)(int);
473
474_Noreturn void __sys__exit(int rval);
475int __sys_fork(void);
476ssize_t __sys_read(int fd, void * buf, size_t nbyte);
477ssize_t __sys_write(int fd, const void * buf, size_t nbyte);
478int __sys_open(const char * path, int flags, mode_t mode);
479int __sys_close(int fd);
480int __sys_wait4(int pid, int * status, int options, struct rusage * rusage);
481int __sys_link(const char * path, const char * link);
482int __sys_unlink(const char * path);
483int __sys_chdir(const char * path);
484int __sys_fchdir(int fd);
485int __sys_chmod(const char * path, mode_t mode);
486int __sys_chown(const char * path, int uid, int gid);
487void * __sys_break(char * nsize);
488pid_t __sys_getpid(void);
489int __sys_mount(const char * type, const char * path, int flags, void * data);
490int __sys_unmount(const char * path, int flags);
491int __sys_setuid(uid_t uid);
492uid_t __sys_getuid(void);
493uid_t __sys_geteuid(void);
494int __sys_ptrace(int req, pid_t pid, caddr_t addr, int data);
495ssize_t __sys_recvmsg(int s, struct msghdr * msg, int flags);
496ssize_t __sys_sendmsg(int s, const struct msghdr * msg, int flags);
497ssize_t __sys_recvfrom(int s, void * buf, size_t len, int flags, struct sockaddr * from, __socklen_t * fromlenaddr);
498int __sys_accept(int s, struct sockaddr * name, __socklen_t * anamelen);
499int __sys_getpeername(int fdes, struct sockaddr * asa, __socklen_t * alen);
500int __sys_getsockname(int fdes, struct sockaddr * asa, __socklen_t * alen);
501int __sys_access(const char * path, int amode);
502int __sys_chflags(const char * path, u_long flags);
503int __sys_fchflags(int fd, u_long flags);
504int __sys_sync(void);
505int __sys_kill(int pid, int signum);
506pid_t __sys_getppid(void);
507int __sys_dup(u_int fd);
508gid_t __sys_getegid(void);
509int __sys_profil(char * samples, size_t size, size_t offset, u_int scale);
510int __sys_ktrace(const char * fname, int ops, int facs, int pid);
511gid_t __sys_getgid(void);
512int __sys_getlogin(char * namebuf, u_int namelen);
513int __sys_setlogin(const char * namebuf);
514int __sys_acct(const char * path);
515int __sys_sigaltstack(const struct sigaltstack * ss, struct sigaltstack * oss);
516int __sys_ioctl(int fd, u_long com, char * data);
517int __sys_reboot(int opt);
518int __sys_revoke(const char * path);
519int __sys_symlink(const char * path, const char * link);
520ssize_t __sys_readlink(const char * path, char * buf, size_t count);
521int __sys_execve(const char * fname, char ** argv, char ** envv);
522mode_t __sys_umask(mode_t newmask);
523int __sys_chroot(const char * path);
524int __sys_msync(void * addr, size_t len, int flags);
525int __sys_vfork(void);
526int __sys_munmap(void * addr, size_t len);
527int __sys_mprotect(void * addr, size_t len, int prot);
528int __sys_madvise(void * addr, size_t len, int behav);
529int __sys_mincore(const void * addr, size_t len, char * vec);
530int __sys_getpgrp(void);
531int __sys_setpgid(int pid, int pgid);
532int __sys_setitimer(int which, const struct itimerval * itv, struct itimerval * oitv);
533int __sys_swapon(const char * name);
534int __sys_getitimer(int which, struct itimerval * itv);
535int __sys_getdtablesize(void);
536int __sys_dup2(u_int from, u_int to);
537int __sys_fcntl(int fd, int cmd, intptr_t arg);
538int __sys_select(int nd, fd_set * in, fd_set * ou, fd_set * ex, struct timeval * tv);
539int __sys_fsync(int fd);
540int __sys_setpriority(int which, int who, int prio);
541int __sys_socket(int domain, int type, int protocol);
542int __sys_connect(int s, const struct sockaddr * name, __socklen_t namelen);
543int __sys_getpriority(int which, int who);
544int __sys_bind(int s, const struct sockaddr * name, __socklen_t namelen);
545int __sys_setsockopt(int s, int level, int name, const void * val, __socklen_t valsize);
546int __sys_listen(int s, int backlog);
547int __sys_gettimeofday(struct timeval * tp, struct timezone * tzp);
548int __sys_getrusage(int who, struct rusage * rusage);
549int __sys_getsockopt(int s, int level, int name, void * val, __socklen_t * avalsize);
550ssize_t __sys_readv(int fd, const struct iovec * iovp, u_int iovcnt);
551ssize_t __sys_writev(int fd, const struct iovec * iovp, u_int iovcnt);
552int __sys_settimeofday(const struct timeval * tv, const struct timezone * tzp);
553int __sys_fchown(int fd, int uid, int gid);
554int __sys_fchmod(int fd, mode_t mode);
555int __sys_setreuid(int ruid, int euid);
556int __sys_setregid(int rgid, int egid);
557int __sys_rename(const char * from, const char * to);
558int __sys_flock(int fd, int how);
559int __sys_mkfifo(const char * path, mode_t mode);
560ssize_t __sys_sendto(int s, const void * buf, size_t len, int flags, const struct sockaddr * to, __socklen_t tolen);
561int __sys_shutdown(int s, int how);
562int __sys_socketpair(int domain, int type, int protocol, int * rsv);
563int __sys_mkdir(const char * path, mode_t mode);
564int __sys_rmdir(const char * path);
565int __sys_utimes(const char * path, const struct timeval * tptr);
566int __sys_adjtime(const struct timeval * delta, struct timeval * olddelta);
567int __sys_setsid(void);
568int __sys_quotactl(const char * path, int cmd, int uid, void * arg);
569int __sys_nlm_syscall(int debug_level, int grace_period, int addr_count, char ** addrs);
570int __sys_nfssvc(int flag, void * argp);
571int __sys_lgetfh(const char * fname, struct fhandle * fhp);
572int __sys_getfh(const char * fname, struct fhandle * fhp);
573int __sys_sysarch(int op, char * parms);
574int __sys_rtprio(int function, pid_t pid, struct rtprio * rtp);
575int __sys_semsys(int which, int a2, int a3, int a4, int a5);
576int __sys_msgsys(int which, int a2, int a3, int a4, int a5, int a6);
577int __sys_shmsys(int which, int a2, int a3, int a4);
578int __sys_setfib(int fibnum);
579int __sys_ntp_adjtime(struct timex * tp);
580int __sys_setgid(gid_t gid);
581int __sys_setegid(gid_t egid);
582int __sys_seteuid(uid_t euid);
583int __sys_pathconf(const char * path, int name);
584int __sys_fpathconf(int fd, int name);
585int __sys_getrlimit(u_int which, struct rlimit * rlp);
586int __sys_setrlimit(u_int which, struct rlimit * rlp);
587int __sys___sysctl(const int * name, u_int namelen, void * old, size_t * oldlenp, const void * new, size_t newlen);
588int __sys_mlock(const void * addr, size_t len);
589int __sys_munlock(const void * addr, size_t len);
590int __sys_undelete(const char * path);
591int __sys_futimes(int fd, const struct timeval * tptr);
592int __sys_getpgid(pid_t pid);
593int __sys_poll(struct pollfd * fds, u_int nfds, int timeout);
594int __sys_semget(key_t key, int nsems, int semflg);
595int __sys_semop(int semid, struct sembuf * sops, size_t nsops);
596int __sys_msgget(key_t key, int msgflg);
597int __sys_msgsnd(int msqid, const void * msgp, size_t msgsz, int msgflg);
598ssize_t __sys_msgrcv(int msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg);
599void * __sys_shmat(int shmid, const void * shmaddr, int shmflg);
600int __sys_shmdt(const void * shmaddr);
601int __sys_shmget(key_t key, size_t size, int shmflg);
602int __sys_clock_gettime(clockid_t clock_id, struct timespec * tp);
603int __sys_clock_settime(clockid_t clock_id, const struct timespec * tp);
604int __sys_clock_getres(clockid_t clock_id, struct timespec * tp);
605int __sys_ktimer_create(clockid_t clock_id, struct sigevent * evp, int * timerid);
606int __sys_ktimer_delete(int timerid);
607int __sys_ktimer_settime(int timerid, int flags, const struct itimerspec * value, struct itimerspec * ovalue);
608int __sys_ktimer_gettime(int timerid, struct itimerspec * value);
609int __sys_ktimer_getoverrun(int timerid);
610int __sys_nanosleep(const struct timespec * rqtp, struct timespec * rmtp);
611int __sys_ffclock_getcounter(ffcounter * ffcount);
612int __sys_ffclock_setestimate(struct ffclock_estimate * cest);
613int __sys_ffclock_getestimate(struct ffclock_estimate * cest);
614int __sys_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec * rqtp, struct timespec * rmtp);
615int __sys_clock_getcpuclockid2(id_t id, int which, clockid_t * clock_id);
616int __sys_ntp_gettime(struct ntptimeval * ntvp);
617int __sys_minherit(void * addr, size_t len, int inherit);
618int __sys_rfork(int flags);
619int __sys_issetugid(void);
620int __sys_lchown(const char * path, int uid, int gid);
621int __sys_aio_read(struct aiocb * aiocbp);
622int __sys_aio_write(struct aiocb * aiocbp);
623int __sys_lio_listio(int mode, struct aiocb * const * acb_list, int nent, struct sigevent * sig);
624int __sys_lchmod(const char * path, mode_t mode);
625int __sys_lutimes(const char * path, const struct timeval * tptr);
626ssize_t __sys_preadv(int fd, struct iovec * iovp, u_int iovcnt, off_t offset);
627ssize_t __sys_pwritev(int fd, struct iovec * iovp, u_int iovcnt, off_t offset);
628int __sys_fhopen(const struct fhandle * u_fhp, int flags);
629int __sys_modnext(int modid);
630int __sys_modstat(int modid, struct module_stat * stat);
631int __sys_modfnext(int modid);
632int __sys_modfind(const char * name);
633int __sys_kldload(const char * file);
634int __sys_kldunload(int fileid);
635int __sys_kldfind(const char * file);
636int __sys_kldnext(int fileid);
637int __sys_kldstat(int fileid, struct kld_file_stat * stat);
638int __sys_kldfirstmod(int fileid);
639int __sys_getsid(pid_t pid);
640int __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid);
641int __sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
642ssize_t __sys_aio_return(struct aiocb * aiocbp);
643int __sys_aio_suspend(const struct aiocb * const * aiocbp, int nent, const struct timespec * timeout);
644int __sys_aio_cancel(int fd, struct aiocb * aiocbp);
645int __sys_aio_error(struct aiocb * aiocbp);
646int __sys_mlockall(int how);
647int __sys_munlockall(void);
648int __sys___getcwd(char * buf, size_t buflen);
649int __sys_sched_setparam(pid_t pid, const struct sched_param * param);
650int __sys_sched_getparam(pid_t pid, struct sched_param * param);
651int __sys_sched_setscheduler(pid_t pid, int policy, const struct sched_param * param);
652int __sys_sched_getscheduler(pid_t pid);
653int __sys_sched_yield(void);
654int __sys_sched_get_priority_max(int policy);
655int __sys_sched_get_priority_min(int policy);
656int __sys_sched_rr_get_interval(pid_t pid, struct timespec * interval);
657int __sys_utrace(const void * addr, size_t len);
658int __sys_kldsym(int fileid, int cmd, void * data);
659int __sys_jail(struct jail * jail);
660int __sys_nnpfs_syscall(int operation, char * a_pathP, int a_opcode, void * a_paramsP, int a_followSymlinks);
661int __sys_sigprocmask(int how, const sigset_t * set, sigset_t * oset);
662int __sys_sigsuspend(const sigset_t * sigmask);
663int __sys_sigpending(sigset_t * set);
664int __sys_sigtimedwait(const sigset_t * set, struct __siginfo * info, const struct timespec * timeout);
665int __sys_sigwaitinfo(const sigset_t * set, struct __siginfo * info);
666int __sys___acl_get_file(const char * path, __acl_type_t type, struct acl * aclp);
667int __sys___acl_set_file(const char * path, __acl_type_t type, struct acl * aclp);
668int __sys___acl_get_fd(int filedes, __acl_type_t type, struct acl * aclp);
669int __sys___acl_set_fd(int filedes, __acl_type_t type, struct acl * aclp);
670int __sys___acl_delete_file(const char * path, __acl_type_t type);
671int __sys___acl_delete_fd(int filedes, __acl_type_t type);
672int __sys___acl_aclcheck_file(const char * path, __acl_type_t type, struct acl * aclp);
673int __sys___acl_aclcheck_fd(int filedes, __acl_type_t type, struct acl * aclp);
674int __sys_extattrctl(const char * path, int cmd, const char * filename, int attrnamespace, const char * attrname);
675ssize_t __sys_extattr_set_file(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
676ssize_t __sys_extattr_get_file(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
677int __sys_extattr_delete_file(const char * path, int attrnamespace, const char * attrname);
678ssize_t __sys_aio_waitcomplete(struct aiocb ** aiocbp, struct timespec * timeout);
679int __sys_getresuid(uid_t * ruid, uid_t * euid, uid_t * suid);
680int __sys_getresgid(gid_t * rgid, gid_t * egid, gid_t * sgid);
681int __sys_kqueue(void);
682ssize_t __sys_extattr_set_fd(int fd, int attrnamespace, const char * attrname, void * data, size_t nbytes);
683ssize_t __sys_extattr_get_fd(int fd, int attrnamespace, const char * attrname, void * data, size_t nbytes);
684int __sys_extattr_delete_fd(int fd, int attrnamespace, const char * attrname);
685int __sys___setugid(int flag);
686int __sys_eaccess(const char * path, int amode);
687int __sys_afs3_syscall(long syscall, long parm1, long parm2, long parm3, long parm4, long parm5, long parm6);
688int __sys_nmount(struct iovec * iovp, unsigned int iovcnt, int flags);
689int __sys___mac_get_proc(struct mac * mac_p);
690int __sys___mac_set_proc(struct mac * mac_p);
691int __sys___mac_get_fd(int fd, struct mac * mac_p);
692int __sys___mac_get_file(const char * path_p, struct mac * mac_p);
693int __sys___mac_set_fd(int fd, struct mac * mac_p);
694int __sys___mac_set_file(const char * path_p, struct mac * mac_p);
695int __sys_kenv(int what, const char * name, char * value, int len);
696int __sys_lchflags(const char * path, u_long flags);
697int __sys_uuidgen(struct uuid * store, int count);
698int __sys_sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr * hdtr, off_t * sbytes, int flags);
699int __sys_mac_syscall(const char * policy, int call, void * arg);
700int __sys_ksem_close(semid_t id);
701int __sys_ksem_post(semid_t id);
702int __sys_ksem_wait(semid_t id);
703int __sys_ksem_trywait(semid_t id);
704int __sys_ksem_init(semid_t * idp, unsigned int value);
705int __sys_ksem_open(semid_t * idp, const char * name, int oflag, mode_t mode, unsigned int value);
706int __sys_ksem_unlink(const char * name);
707int __sys_ksem_getvalue(semid_t id, int * val);
708int __sys_ksem_destroy(semid_t id);
709int __sys___mac_get_pid(pid_t pid, struct mac * mac_p);
710int __sys___mac_get_link(const char * path_p, struct mac * mac_p);
711int __sys___mac_set_link(const char * path_p, struct mac * mac_p);
712ssize_t __sys_extattr_set_link(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
713ssize_t __sys_extattr_get_link(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
714int __sys_extattr_delete_link(const char * path, int attrnamespace, const char * attrname);
715int __sys___mac_execve(const char * fname, char ** argv, char ** envv, struct mac * mac_p);
716int __sys_sigaction(int sig, const struct sigaction * act, struct sigaction * oact);
717int __sys_sigreturn(const struct __ucontext * sigcntxp);
718int __sys_getcontext(struct __ucontext * ucp);
719int __sys_setcontext(const struct __ucontext * ucp);
720int __sys_swapcontext(struct __ucontext * oucp, const struct __ucontext * ucp);
721int __sys___acl_get_link(const char * path, __acl_type_t type, struct acl * aclp);
722int __sys___acl_set_link(const char * path, __acl_type_t type, struct acl * aclp);
723int __sys___acl_delete_link(const char * path, __acl_type_t type);
724int __sys___acl_aclcheck_link(const char * path, __acl_type_t type, struct acl * aclp);
725int __sys_sigwait(const sigset_t * set, int * sig);
726int __sys_thr_create(ucontext_t * ctx, long * id, int flags);
727void __sys_thr_exit(long * state);
728int __sys_thr_self(long * id);
729int __sys_thr_kill(long id, int sig);
730int __sys_jail_attach(int jid);
731ssize_t __sys_extattr_list_fd(int fd, int attrnamespace, void * data, size_t nbytes);
732ssize_t __sys_extattr_list_file(const char * path, int attrnamespace, void * data, size_t nbytes);
733ssize_t __sys_extattr_list_link(const char * path, int attrnamespace, void * data, size_t nbytes);
734int __sys_ksem_timedwait(semid_t id, const struct timespec * abstime);
735int __sys_thr_suspend(const struct timespec * timeout);
736int __sys_thr_wake(long id);
737int __sys_kldunloadf(int fileid, int flags);
738int __sys_audit(const void * record, u_int length);
739int __sys_auditon(int cmd, void * data, u_int length);
740int __sys_getauid(uid_t * auid);
741int __sys_setauid(uid_t * auid);
742int __sys_getaudit(struct auditinfo * auditinfo);
743int __sys_setaudit(struct auditinfo * auditinfo);
744int __sys_getaudit_addr(struct auditinfo_addr * auditinfo_addr, u_int length);
745int __sys_setaudit_addr(struct auditinfo_addr * auditinfo_addr, u_int length);
746int __sys_auditctl(const char * path);
747int __sys__umtx_op(void * obj, int op, u_long val, void * uaddr1, void * uaddr2);
748int __sys_thr_new(struct thr_param * param, int param_size);
749int __sys_sigqueue(pid_t pid, int signum, void * value);
750int __sys_kmq_open(const char * path, int flags, mode_t mode, const struct mq_attr * attr);
751int __sys_kmq_setattr(int mqd, const struct mq_attr * attr, struct mq_attr * oattr);
752int __sys_kmq_timedreceive(int mqd, char * msg_ptr, size_t msg_len, unsigned * msg_prio, const struct timespec * abs_timeout);
753int __sys_kmq_timedsend(int mqd, const char * msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec * abs_timeout);
754int __sys_kmq_notify(int mqd, const struct sigevent * sigev);
755int __sys_kmq_unlink(const char * path);
756void __sys_abort2(const char * why, int nargs, void ** args);
757int __sys_thr_set_name(long id, const char * name);
758int __sys_aio_fsync(int op, struct aiocb * aiocbp);
759int __sys_rtprio_thread(int function, lwpid_t lwpid, struct rtprio * rtp);
760int __sys_sctp_peeloff(int sd, uint32_t name);
761int __sys_sctp_generic_sendmsg(int sd, void * msg, int mlen, const struct sockaddr * to, __socklen_t tolen, struct sctp_sndrcvinfo * sinfo, int flags);
762int __sys_sctp_generic_sendmsg_iov(int sd, struct iovec * iov, int iovlen, const struct sockaddr * to, __socklen_t tolen, struct sctp_sndrcvinfo * sinfo, int flags);
763int __sys_sctp_generic_recvmsg(int sd, struct iovec * iov, int iovlen, struct sockaddr * from, __socklen_t * fromlenaddr, struct sctp_sndrcvinfo * sinfo, int * msg_flags);
764ssize_t __sys_pread(int fd, void * buf, size_t nbyte, off_t offset);
765ssize_t __sys_pwrite(int fd, const void * buf, size_t nbyte, off_t offset);
766void * __sys_mmap(void * addr, size_t len, int prot, int flags, int fd, off_t pos);
767off_t __sys_lseek(int fd, off_t offset, int whence);
768int __sys_truncate(const char * path, off_t length);
769int __sys_ftruncate(int fd, off_t length);
770int __sys_thr_kill2(pid_t pid, long id, int sig);
771int __sys_shm_unlink(const char * path);
772int __sys_cpuset(cpusetid_t * setid);
773int __sys_cpuset_setid(cpuwhich_t which, id_t id, cpusetid_t setid);
774int __sys_cpuset_getid(cpulevel_t level, cpuwhich_t which, id_t id, cpusetid_t * setid);
775int __sys_cpuset_getaffinity(cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t * mask);
776int __sys_cpuset_setaffinity(cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, const cpuset_t * mask);
777int __sys_faccessat(int fd, const char * path, int amode, int flag);
778int __sys_fchmodat(int fd, const char * path, mode_t mode, int flag);
779int __sys_fchownat(int fd, const char * path, uid_t uid, gid_t gid, int flag);
780int __sys_fexecve(int fd, char ** argv, char ** envv);
781int __sys_futimesat(int fd, const char * path, const struct timeval * times);
782int __sys_linkat(int fd1, const char * path1, int fd2, const char * path2, int flag);
783int __sys_mkdirat(int fd, const char * path, mode_t mode);
784int __sys_mkfifoat(int fd, const char * path, mode_t mode);
785int __sys_openat(int fd, const char * path, int flag, mode_t mode);
786ssize_t __sys_readlinkat(int fd, const char * path, char * buf, size_t bufsize);
787int __sys_renameat(int oldfd, const char * old, int newfd, const char * new);
788int __sys_symlinkat(const char * path1, int fd, const char * path2);
789int __sys_unlinkat(int fd, const char * path, int flag);
790int __sys_posix_openpt(int flags);
791int __sys_jail_get(struct iovec * iovp, unsigned int iovcnt, int flags);
792int __sys_jail_set(struct iovec * iovp, unsigned int iovcnt, int flags);
793int __sys_jail_remove(int jid);
794int __sys___semctl(int semid, int semnum, int cmd, union semun * arg);
795int __sys_msgctl(int msqid, int cmd, struct msqid_ds * buf);
796int __sys_shmctl(int shmid, int cmd, struct shmid_ds * buf);
797int __sys_lpathconf(const char * path, int name);
798int __sys___cap_rights_get(int version, int fd, cap_rights_t * rightsp);
799int __sys_cap_enter(void);
800int __sys_cap_getmode(u_int * modep);
801int __sys_pdfork(int * fdp, int flags);
802int __sys_pdkill(int fd, int signum);
803int __sys_pdgetpid(int fd, pid_t * pidp);
804int __sys_pselect(int nd, fd_set * in, fd_set * ou, fd_set * ex, const struct timespec * ts, const sigset_t * sm);
805int __sys_getloginclass(char * namebuf, size_t namelen);
806int __sys_setloginclass(const char * namebuf);
807int __sys_rctl_get_racct(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
808int __sys_rctl_get_rules(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
809int __sys_rctl_get_limits(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
810int __sys_rctl_add_rule(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
811int __sys_rctl_remove_rule(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
812int __sys_posix_fallocate(int fd, off_t offset, off_t len);
813int __sys_posix_fadvise(int fd, off_t offset, off_t len, int advice);
814int __sys_wait6(idtype_t idtype, id_t id, int * status, int options, struct __wrusage * wrusage, struct __siginfo * info);
815int __sys_cap_rights_limit(int fd, cap_rights_t * rightsp);
816int __sys_cap_ioctls_limit(int fd, const u_long * cmds, size_t ncmds);
817ssize_t __sys_cap_ioctls_get(int fd, u_long * cmds, size_t maxcmds);
818int __sys_cap_fcntls_limit(int fd, uint32_t fcntlrights);
819int __sys_cap_fcntls_get(int fd, uint32_t * fcntlrightsp);
820int __sys_bindat(int fd, int s, const struct sockaddr * name, __socklen_t namelen);
821int __sys_connectat(int fd, int s, const struct sockaddr * name, __socklen_t namelen);
822int __sys_chflagsat(int fd, const char * path, u_long flags, int atflag);
823int __sys_accept4(int s, struct sockaddr * name, __socklen_t * anamelen, int flags);
824int __sys_pipe2(int * fildes, int flags);
825int __sys_aio_mlock(struct aiocb * aiocbp);
826int __sys_procctl(idtype_t idtype, id_t id, int com, void * data);
827int __sys_ppoll(struct pollfd * fds, u_int nfds, const struct timespec * ts, const sigset_t * set);
828int __sys_futimens(int fd, const struct timespec * times);
829int __sys_utimensat(int fd, const char * path, const struct timespec * times, int flag);
830int __sys_fdatasync(int fd);
831int __sys_fstat(int fd, struct stat * sb);
832int __sys_fstatat(int fd, const char * path, struct stat * buf, int flag);
833int __sys_fhstat(const struct fhandle * u_fhp, struct stat * sb);
834ssize_t __sys_getdirentries(int fd, char * buf, size_t count, off_t * basep);
835int __sys_statfs(const char * path, struct statfs * buf);
836int __sys_fstatfs(int fd, struct statfs * buf);
837int __sys_getfsstat(struct statfs * buf, long bufsize, int mode);
838int __sys_fhstatfs(const struct fhandle * u_fhp, struct statfs * buf);
839int __sys_mknodat(int fd, const char * path, mode_t mode, dev_t dev);
840int __sys_kevent(int fd, const struct kevent * changelist, int nchanges, struct kevent * eventlist, int nevents, const struct timespec * timeout);
841int __sys_cpuset_getdomain(cpulevel_t level, cpuwhich_t which, id_t id, size_t domainsetsize, domainset_t * mask, int * policy);
842int __sys_cpuset_setdomain(cpulevel_t level, cpuwhich_t which, id_t id, size_t domainsetsize, domainset_t * mask, int policy);
843int __sys_getrandom(void * buf, size_t buflen, unsigned int flags);
844int __sys_getfhat(int fd, char * path, struct fhandle * fhp, int flags);
845int __sys_fhlink(struct fhandle * fhp, const char * to);
846int __sys_fhlinkat(struct fhandle * fhp, int tofd, const char * to);
847int __sys_fhreadlink(struct fhandle * fhp, char * buf, size_t bufsize);
848int __sys_funlinkat(int dfd, const char * path, int fd, int flag);
849ssize_t __sys_copy_file_range(int infd, off_t * inoffp, int outfd, off_t * outoffp, size_t len, unsigned int flags);
850int __sys___sysctlbyname(const char * name, size_t namelen, void * old, size_t * oldlenp, void * new, size_t newlen);
851int __sys_shm_open2(const char * path, int flags, mode_t mode, int shmflags, const char * name);
852int __sys_shm_rename(const char * path_from, const char * path_to, int flags);
853int __sys_sigfastblock(int cmd, void * ptr);
854int __sys___realpathat(int fd, const char * path, char * buf, size_t size, int flags);
855int __sys_close_range(u_int lowfd, u_int highfd, int flags);
856int __sys_rpctls_syscall(uint64_t socookie);
857int __sys___specialfd(int type, const void * req, size_t len);
858int __sys_aio_writev(struct aiocb * aiocbp);
859int __sys_aio_readv(struct aiocb * aiocbp);
860int __sys_fspacectl(int fd, int cmd, const struct spacectl_range * rqsr, int flags, struct spacectl_range * rmsr);
861int __sys_sched_getcpu(void);
862int __sys_swapoff(const char * name, u_int flags);
863int __sys_kqueuex(u_int flags);
864int __sys_membarrier(int cmd, unsigned flags, int cpu_id);
865int __sys_timerfd_create(int clockid, int flags);
866int __sys_timerfd_gettime(int fd, struct itimerspec * curr_value);
867int __sys_timerfd_settime(int fd, int flags, const struct itimerspec * new_value, struct itimerspec * old_value);
868int __sys_kcmp(pid_t pid1, pid_t pid2, int type, uintptr_t idx1, uintptr_t idx2);
869int __sys_getrlimitusage(u_int which, int flags, rlim_t * res);
870int __sys_fchroot(int fd);
871int __sys_setcred(u_int flags, const struct setcred * wcred, size_t size);
872int __sys_exterrctl(u_int op, u_int flags, void * ptr);
873int __sys_inotify_add_watch_at(int fd, int dfd, const char * path, uint32_t mask);
874int __sys_inotify_rm_watch(int fd, int wd);
875int __sys_getgroups(int gidsetsize, gid_t * gidset);
876int __sys_setgroups(int gidsetsize, const gid_t * gidset);
877int __sys_jail_attach_jd(int fd);
878int __sys_jail_remove_jd(int fd);
879__END_DECLS
880
881#endif /* __LIBSYS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/a.out.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)a.out.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _AOUT_H_
lib/libc/include/generic-freebsd/aio.h+1-1
......@@ -97,7 +97,7 @@
9797struct __aiocb_private {
9898 long status;
9999 long error;
100 void *kernelinfo;
100 void *spare;
101101};
102102
103103/*
lib/libc/include/generic-freebsd/ar.h-2
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * @(#)ar.h 8.2 (Berkeley) 1/21/94
4038 */
4139
4240#ifndef _AR_H_
lib/libc/include/generic-freebsd/arpa/ftp.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ftp.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _ARPA_FTP_H_
lib/libc/include/generic-freebsd/arpa/inet.h-1
......@@ -52,7 +52,6 @@
5252 */
5353
5454/*%
55 * @(#)inet.h 8.1 (Berkeley) 6/2/93
5655 * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
5756 */
5857
lib/libc/include/generic-freebsd/arpa/telnet.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)telnet.h 8.2 (Berkeley) 12/15/93
3230 */
3331
3432#ifndef _ARPA_TELNET_H_
lib/libc/include/generic-freebsd/arpa/tftp.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tftp.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _ARPA_TFTP_H_
lib/libc/include/generic-freebsd/assert.h+7-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)assert.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#include <sys/cdefs.h>
......@@ -45,15 +43,22 @@
4543
4644#undef assert
4745#undef _assert
46#undef __assert_unreachable
4847
4948#ifdef NDEBUG
5049#define assert(e) ((void)0)
5150#define _assert(e) ((void)0)
51#if __BSD_VISIBLE
52#define __assert_unreachable() __unreachable()
53#endif /* __BSD_VISIBLE */
5254#else
5355#define _assert(e) assert(e)
5456
5557#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
5658 __LINE__, #e))
59#if __BSD_VISIBLE
60#define __assert_unreachable() assert(0 && "unreachable segment reached")
61#endif /* __BSD_VISIBLE */
5762#endif /* NDEBUG */
5863
5964#ifndef _ASSERT_H_
lib/libc/include/generic-freebsd/bsm/audit.h deleted-345
......@@ -1,345 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2005-2009 Apple Inc.
5 * Copyright (c) 2016 Robert N. M. Watson
6 * All rights reserved.
7 *
8 * Portions of this software were developed by BAE Systems, the University of
9 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL
10 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent
11 * Computing (TC) research program.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
23 * its contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
27 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _BSM_AUDIT_H
39#define _BSM_AUDIT_H
40
41#include <sys/param.h>
42#include <sys/types.h>
43
44#define AUDIT_RECORD_MAGIC 0x828a0f1b
45#define MAX_AUDIT_RECORDS 20
46#define MAXAUDITDATA (0x8000 - 1)
47#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA
48#define MIN_AUDIT_FILE_SIZE (512 * 1024)
49
50/*
51 * Minimum noumber of free blocks on the filesystem containing the audit
52 * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0
53 * as the kernel does an unsigned compare, plus we want to leave a few blocks
54 * free so userspace can terminate the log, etc.
55 */
56#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4
57
58/*
59 * Triggers for the audit daemon.
60 */
61#define AUDIT_TRIGGER_MIN 1
62#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */
63#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */
64#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */
65#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */
66#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */
67#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */
68#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */
69#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */
70#define AUDIT_TRIGGER_MAX 8
71
72/*
73 * The special device filename (FreeBSD).
74 */
75#define AUDITDEV_FILENAME "audit"
76#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME)
77
78/*
79 * Pre-defined audit IDs
80 */
81#define AU_DEFAUDITID (uid_t)(-1)
82#define AU_DEFAUDITSID 0
83#define AU_ASSIGN_ASID -1
84
85/*
86 * IPC types.
87 */
88#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */
89#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */
90#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */
91
92/*
93 * Audit conditions.
94 */
95#define AUC_UNSET 0
96#define AUC_AUDITING 1
97#define AUC_NOAUDIT 2
98#define AUC_DISABLED -1
99
100/*
101 * auditon(2) commands.
102 */
103#define A_OLDGETPOLICY 2
104#define A_OLDSETPOLICY 3
105#define A_GETKMASK 4
106#define A_SETKMASK 5
107#define A_OLDGETQCTRL 6
108#define A_OLDSETQCTRL 7
109#define A_GETCWD 8
110#define A_GETCAR 9
111#define A_GETSTAT 12
112#define A_SETSTAT 13
113#define A_SETUMASK 14
114#define A_SETSMASK 15
115#define A_OLDGETCOND 20
116#define A_OLDSETCOND 21
117#define A_GETCLASS 22
118#define A_SETCLASS 23
119#define A_GETPINFO 24
120#define A_SETPMASK 25
121#define A_SETFSIZE 26
122#define A_GETFSIZE 27
123#define A_GETPINFO_ADDR 28
124#define A_GETKAUDIT 29
125#define A_SETKAUDIT 30
126#define A_SENDTRIGGER 31
127#define A_GETSINFO_ADDR 32
128#define A_GETPOLICY 33
129#define A_SETPOLICY 34
130#define A_GETQCTRL 35
131#define A_SETQCTRL 36
132#define A_GETCOND 37
133#define A_SETCOND 38
134#define A_GETEVENT 39 /* Get audit event-to-name mapping. */
135#define A_SETEVENT 40 /* Set audit event-to-name mapping. */
136
137/*
138 * Audit policy controls.
139 */
140#define AUDIT_CNT 0x0001
141#define AUDIT_AHLT 0x0002
142#define AUDIT_ARGV 0x0004
143#define AUDIT_ARGE 0x0008
144#define AUDIT_SEQ 0x0010
145#define AUDIT_WINDATA 0x0020
146#define AUDIT_USER 0x0040
147#define AUDIT_GROUP 0x0080
148#define AUDIT_TRAIL 0x0100
149#define AUDIT_PATH 0x0200
150#define AUDIT_SCNT 0x0400
151#define AUDIT_PUBLIC 0x0800
152#define AUDIT_ZONENAME 0x1000
153#define AUDIT_PERZONE 0x2000
154
155/*
156 * Default audit queue control parameters.
157 */
158#define AQ_HIWATER 100
159#define AQ_MAXHIGH 10000
160#define AQ_LOWATER 10
161#define AQ_BUFSZ MAXAUDITDATA
162#define AQ_MAXBUFSZ 1048576
163
164/*
165 * Default minimum percentage free space on file system.
166 */
167#define AU_FS_MINFREE 20
168
169/*
170 * Type definitions used indicating the length of variable length addresses
171 * in tokens containing addresses, such as header fields.
172 */
173#define AU_IPv4 4
174#define AU_IPv6 16
175
176__BEGIN_DECLS
177
178typedef uid_t au_id_t;
179typedef pid_t au_asid_t;
180typedef u_int16_t au_event_t;
181typedef u_int16_t au_emod_t;
182typedef u_int32_t au_class_t;
183typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8)));
184
185struct au_tid {
186 u_int32_t port; /* XXX dev_t compatibility */
187 u_int32_t machine;
188};
189typedef struct au_tid au_tid_t;
190
191struct au_tid_addr {
192 u_int32_t at_port; /* XXX dev_t compatibility */
193 u_int32_t at_type;
194 u_int32_t at_addr[4];
195};
196typedef struct au_tid_addr au_tid_addr_t;
197
198struct au_mask {
199 unsigned int am_success; /* Success bits. */
200 unsigned int am_failure; /* Failure bits. */
201};
202typedef struct au_mask au_mask_t;
203
204struct auditinfo {
205 au_id_t ai_auid; /* Audit user ID. */
206 au_mask_t ai_mask; /* Audit masks. */
207 au_tid_t ai_termid; /* Terminal ID. */
208 au_asid_t ai_asid; /* Audit session ID. */
209};
210typedef struct auditinfo auditinfo_t;
211
212struct auditinfo_addr {
213 au_id_t ai_auid; /* Audit user ID. */
214 au_mask_t ai_mask; /* Audit masks. */
215 au_tid_addr_t ai_termid; /* Terminal ID. */
216 au_asid_t ai_asid; /* Audit session ID. */
217 au_asflgs_t ai_flags; /* Audit session flags. */
218};
219typedef struct auditinfo_addr auditinfo_addr_t;
220
221struct auditpinfo {
222 pid_t ap_pid; /* ID of target process. */
223 au_id_t ap_auid; /* Audit user ID. */
224 au_mask_t ap_mask; /* Audit masks. */
225 au_tid_t ap_termid; /* Terminal ID. */
226 au_asid_t ap_asid; /* Audit session ID. */
227};
228typedef struct auditpinfo auditpinfo_t;
229
230struct auditpinfo_addr {
231 pid_t ap_pid; /* ID of target process. */
232 au_id_t ap_auid; /* Audit user ID. */
233 au_mask_t ap_mask; /* Audit masks. */
234 au_tid_addr_t ap_termid; /* Terminal ID. */
235 au_asid_t ap_asid; /* Audit session ID. */
236 au_asflgs_t ap_flags; /* Audit session flags. */
237};
238typedef struct auditpinfo_addr auditpinfo_addr_t;
239
240struct au_session {
241 auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */
242 au_mask_t as_mask; /* Process Audit Masks. */
243};
244typedef struct au_session au_session_t;
245
246/*
247 * Contents of token_t are opaque outside of libbsm.
248 */
249typedef struct au_token token_t;
250
251/*
252 * Kernel audit queue control parameters:
253 * Default: Maximum:
254 * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000)
255 * aq_lowater: AQ_LOWATER (10) <aq_hiwater
256 * aq_bufsz: AQ_BUFSZ (32767) AQ_MAXBUFSZ (1048576)
257 * aq_delay: 20 20000 (not used)
258 */
259struct au_qctrl {
260 int aq_hiwater; /* Max # of audit recs in queue when */
261 /* threads with new ARs get blocked. */
262
263 int aq_lowater; /* # of audit recs in queue when */
264 /* blocked threads get unblocked. */
265
266 int aq_bufsz; /* Max size of audit record for audit(2). */
267 int aq_delay; /* Queue delay (not used). */
268 int aq_minfree; /* Minimum filesystem percent free space. */
269};
270typedef struct au_qctrl au_qctrl_t;
271
272/*
273 * Structure for the audit statistics.
274 */
275struct audit_stat {
276 unsigned int as_version;
277 unsigned int as_numevent;
278 int as_generated;
279 int as_nonattrib;
280 int as_kernel;
281 int as_audit;
282 int as_auditctl;
283 int as_enqueue;
284 int as_written;
285 int as_wblocked;
286 int as_rblocked;
287 int as_dropped;
288 int as_totalsize;
289 unsigned int as_memused;
290};
291typedef struct audit_stat au_stat_t;
292
293/*
294 * Structure for the audit file statistics.
295 */
296struct audit_fstat {
297 u_int64_t af_filesz;
298 u_int64_t af_currsz;
299};
300typedef struct audit_fstat au_fstat_t;
301
302/*
303 * Audit to event class mapping.
304 */
305struct au_evclass_map {
306 au_event_t ec_number;
307 au_class_t ec_class;
308};
309typedef struct au_evclass_map au_evclass_map_t;
310
311/*
312 * Event-to-name mapping.
313 */
314#define EVNAMEMAP_NAME_SIZE 64
315struct au_evname_map {
316 au_event_t en_number;
317 char en_name[EVNAMEMAP_NAME_SIZE];
318};
319typedef struct au_evname_map au_evname_map_t;
320
321/*
322 * Audit system calls.
323 */
324#if !defined(_KERNEL) && !defined(KERNEL)
325int audit(const void *, int);
326int auditon(int, void *, int);
327int auditctl(const char *);
328int getauid(au_id_t *);
329int setauid(const au_id_t *);
330int getaudit(struct auditinfo *);
331int setaudit(const struct auditinfo *);
332int getaudit_addr(struct auditinfo_addr *, int);
333int setaudit_addr(const struct auditinfo_addr *, int);
334
335#ifdef __APPLE_API_PRIVATE
336#include <mach/port.h>
337mach_port_name_t audit_session_self(void);
338au_asid_t audit_session_join(mach_port_name_t port);
339#endif /* __APPLE_API_PRIVATE */
340
341#endif /* defined(_KERNEL) || defined(KERNEL) */
342
343__END_DECLS
344
345#endif /* !_BSM_AUDIT_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_domain.h deleted-114
......@@ -1,114 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2008 Apple Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _BSM_AUDIT_DOMAIN_H_
33#define _BSM_AUDIT_DOMAIN_H_
34
35/*
36 * BSM protocol domain constants - protocol domains defined in Solaris.
37 */
38#define BSM_PF_UNSPEC 0
39#define BSM_PF_LOCAL 1
40#define BSM_PF_INET 2
41#define BSM_PF_IMPLINK 3
42#define BSM_PF_PUP 4
43#define BSM_PF_CHAOS 5
44#define BSM_PF_NS 6
45#define BSM_PF_NBS 7 /* Solaris-specific. */
46#define BSM_PF_ECMA 8
47#define BSM_PF_DATAKIT 9
48#define BSM_PF_CCITT 10
49#define BSM_PF_SNA 11
50#define BSM_PF_DECnet 12
51#define BSM_PF_DLI 13
52#define BSM_PF_LAT 14
53#define BSM_PF_HYLINK 15
54#define BSM_PF_APPLETALK 16
55#define BSM_PF_NIT 17 /* Solaris-specific. */
56#define BSM_PF_802 18 /* Solaris-specific. */
57#define BSM_PF_OSI 19
58#define BSM_PF_X25 20 /* Solaris/Linux-specific. */
59#define BSM_PF_OSINET 21 /* Solaris-specific. */
60#define BSM_PF_GOSIP 22 /* Solaris-specific. */
61#define BSM_PF_IPX 23
62#define BSM_PF_ROUTE 24
63#define BSM_PF_LINK 25
64#define BSM_PF_INET6 26
65#define BSM_PF_KEY 27
66#define BSM_PF_NCA 28 /* Solaris-specific. */
67#define BSM_PF_POLICY 29 /* Solaris-specific. */
68#define BSM_PF_INET_OFFLOAD 30 /* Solaris-specific. */
69
70/*
71 * BSM protocol domain constants - protocol domains not defined in Solaris.
72 */
73#define BSM_PF_NETBIOS 500 /* FreeBSD/Darwin-specific. */
74#define BSM_PF_ISO 501 /* FreeBSD/Darwin-specific. */
75#define BSM_PF_XTP 502 /* FreeBSD/Darwin-specific. */
76#define BSM_PF_COIP 503 /* FreeBSD/Darwin-specific. */
77#define BSM_PF_CNT 504 /* FreeBSD/Darwin-specific. */
78#define BSM_PF_RTIP 505 /* FreeBSD/Darwin-specific. */
79#define BSM_PF_SIP 506 /* FreeBSD/Darwin-specific. */
80#define BSM_PF_PIP 507 /* FreeBSD/Darwin-specific. */
81#define BSM_PF_ISDN 508 /* FreeBSD/Darwin-specific. */
82#define BSM_PF_E164 509 /* FreeBSD/Darwin-specific. */
83#define BSM_PF_NATM 510 /* FreeBSD/Darwin-specific. */
84#define BSM_PF_ATM 511 /* FreeBSD/Darwin-specific. */
85#define BSM_PF_NETGRAPH 512 /* FreeBSD/Darwin-specific. */
86#define BSM_PF_SLOW 513 /* FreeBSD-specific. */
87#define BSM_PF_SCLUSTER 514 /* FreeBSD-specific. */
88#define BSM_PF_ARP 515 /* FreeBSD-specific. */
89#define BSM_PF_BLUETOOTH 516 /* FreeBSD-specific. */
90 /* 517: unallocated. */
91#define BSM_PF_AX25 518 /* Linux-specific. */
92#define BSM_PF_ROSE 519 /* Linux-specific. */
93#define BSM_PF_NETBEUI 520 /* Linux-specific. */
94#define BSM_PF_SECURITY 521 /* Linux-specific. */
95#define BSM_PF_PACKET 522 /* Linux-specific. */
96#define BSM_PF_ASH 523 /* Linux-specific. */
97#define BSM_PF_ECONET 524 /* Linux-specific. */
98#define BSM_PF_ATMSVC 525 /* Linux-specific. */
99#define BSM_PF_IRDA 526 /* Linux-specific. */
100#define BSM_PF_PPPOX 527 /* Linux-specific. */
101#define BSM_PF_WANPIPE 528 /* Linux-specific. */
102#define BSM_PF_LLC 529 /* Linux-specific. */
103#define BSM_PF_CAN 530 /* Linux-specific. */
104#define BSM_PF_TIPC 531 /* Linux-specific. */
105#define BSM_PF_IUCV 532 /* Linux-specific. */
106#define BSM_PF_RXRPC 533 /* Linux-specific. */
107#define BSM_PF_PHONET 534 /* Linux-specific. */
108
109/*
110 * Used when there is no mapping from a local to BSM protocol domain.
111 */
112#define BSM_PF_UNKNOWN 700 /* OpenBSM-specific. */
113
114#endif /* !_BSM_AUDIT_DOMAIN_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_errno.h deleted-217
......@@ -1,217 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2008 Apple Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _BSM_AUDIT_ERRNO_H_
33#define _BSM_AUDIT_ERRNO_H_
34
35/*
36 * For the purposes of portable encoding, we convert between local error
37 * numbers and Solaris error numbers (as well as some extensions for error
38 * numbers that don't exist in Solaris). Although the first 35 or so
39 * constants are the same across all OS's, we don't handle that in any
40 * special way.
41 *
42 * When adding constants here, also add them to bsm_errno.c.
43 */
44#define BSM_ERRNO_ESUCCESS 0
45#define BSM_ERRNO_EPERM 1
46#define BSM_ERRNO_ENOENT 2
47#define BSM_ERRNO_ESRCH 3
48#define BSM_ERRNO_EINTR 4
49#define BSM_ERRNO_EIO 5
50#define BSM_ERRNO_ENXIO 6
51#define BSM_ERRNO_E2BIG 7
52#define BSM_ERRNO_ENOEXEC 8
53#define BSM_ERRNO_EBADF 9
54#define BSM_ERRNO_ECHILD 10
55#define BSM_ERRNO_EAGAIN 11
56#define BSM_ERRNO_ENOMEM 12
57#define BSM_ERRNO_EACCES 13
58#define BSM_ERRNO_EFAULT 14
59#define BSM_ERRNO_ENOTBLK 15
60#define BSM_ERRNO_EBUSY 16
61#define BSM_ERRNO_EEXIST 17
62#define BSM_ERRNO_EXDEV 18
63#define BSM_ERRNO_ENODEV 19
64#define BSM_ERRNO_ENOTDIR 20
65#define BSM_ERRNO_EISDIR 21
66#define BSM_ERRNO_EINVAL 22
67#define BSM_ERRNO_ENFILE 23
68#define BSM_ERRNO_EMFILE 24
69#define BSM_ERRNO_ENOTTY 25
70#define BSM_ERRNO_ETXTBSY 26
71#define BSM_ERRNO_EFBIG 27
72#define BSM_ERRNO_ENOSPC 28
73#define BSM_ERRNO_ESPIPE 29
74#define BSM_ERRNO_EROFS 30
75#define BSM_ERRNO_EMLINK 31
76#define BSM_ERRNO_EPIPE 32
77#define BSM_ERRNO_EDOM 33
78#define BSM_ERRNO_ERANGE 34
79#define BSM_ERRNO_ENOMSG 35
80#define BSM_ERRNO_EIDRM 36
81#define BSM_ERRNO_ECHRNG 37 /* Solaris/Linux-specific. */
82#define BSM_ERRNO_EL2NSYNC 38 /* Solaris/Linux-specific. */
83#define BSM_ERRNO_EL3HLT 39 /* Solaris/Linux-specific. */
84#define BSM_ERRNO_EL3RST 40 /* Solaris/Linux-specific. */
85#define BSM_ERRNO_ELNRNG 41 /* Solaris/Linux-specific. */
86#define BSM_ERRNO_EUNATCH 42 /* Solaris/Linux-specific. */
87#define BSM_ERRNO_ENOCSI 43 /* Solaris/Linux-specific. */
88#define BSM_ERRNO_EL2HLT 44 /* Solaris/Linux-specific. */
89#define BSM_ERRNO_EDEADLK 45
90#define BSM_ERRNO_ENOLCK 46
91#define BSM_ERRNO_ECANCELED 47
92#define BSM_ERRNO_ENOTSUP 48
93#define BSM_ERRNO_EDQUOT 49
94#define BSM_ERRNO_EBADE 50 /* Solaris/Linux-specific. */
95#define BSM_ERRNO_EBADR 51 /* Solaris/Linux-specific. */
96#define BSM_ERRNO_EXFULL 52 /* Solaris/Linux-specific. */
97#define BSM_ERRNO_ENOANO 53 /* Solaris/Linux-specific. */
98#define BSM_ERRNO_EBADRQC 54 /* Solaris/Linux-specific. */
99#define BSM_ERRNO_EBADSLT 55 /* Solaris/Linux-specific. */
100#define BSM_ERRNO_EDEADLOCK 56 /* Solaris-specific. */
101#define BSM_ERRNO_EBFONT 57 /* Solaris/Linux-specific. */
102#define BSM_ERRNO_EOWNERDEAD 58 /* Solaris/Linux-specific. */
103#define BSM_ERRNO_ENOTRECOVERABLE 59 /* Solaris/Linux-specific. */
104#define BSM_ERRNO_ENOSTR 60 /* Solaris/Darwin/Linux-specific. */
105#define BSM_ERRNO_ENODATA 61 /* Solaris/Darwin/Linux-specific. */
106#define BSM_ERRNO_ETIME 62 /* Solaris/Darwin/Linux-specific. */
107#define BSM_ERRNO_ENOSR 63 /* Solaris/Darwin/Linux-specific. */
108#define BSM_ERRNO_ENONET 64 /* Solaris/Linux-specific. */
109#define BSM_ERRNO_ENOPKG 65 /* Solaris/Linux-specific. */
110#define BSM_ERRNO_EREMOTE 66
111#define BSM_ERRNO_ENOLINK 67
112#define BSM_ERRNO_EADV 68 /* Solaris/Linux-specific. */
113#define BSM_ERRNO_ESRMNT 69 /* Solaris/Linux-specific. */
114#define BSM_ERRNO_ECOMM 70 /* Solaris/Linux-specific. */
115#define BSM_ERRNO_EPROTO 71
116#define BSM_ERRNO_ELOCKUNMAPPED 72 /* Solaris-specific. */
117#define BSM_ERRNO_ENOTACTIVE 73 /* Solaris-specific. */
118#define BSM_ERRNO_EMULTIHOP 74
119#define BSM_ERRNO_EBADMSG 77
120#define BSM_ERRNO_ENAMETOOLONG 78
121#define BSM_ERRNO_EOVERFLOW 79
122#define BSM_ERRNO_ENOTUNIQ 80 /* Solaris/Linux-specific. */
123#define BSM_ERRNO_EBADFD 81 /* Solaris/Linux-specific. */
124#define BSM_ERRNO_EREMCHG 82 /* Solaris/Linux-specific. */
125#define BSM_ERRNO_ELIBACC 83 /* Solaris/Linux-specific. */
126#define BSM_ERRNO_ELIBBAD 84 /* Solaris/Linux-specific. */
127#define BSM_ERRNO_ELIBSCN 85 /* Solaris/Linux-specific. */
128#define BSM_ERRNO_ELIBMAX 86 /* Solaris/Linux-specific. */
129#define BSM_ERRNO_ELIBEXEC 87 /* Solaris/Linux-specific. */
130#define BSM_ERRNO_EILSEQ 88
131#define BSM_ERRNO_ENOSYS 89
132#define BSM_ERRNO_ELOOP 90
133#define BSM_ERRNO_ERESTART 91
134#define BSM_ERRNO_ESTRPIPE 92 /* Solaris/Linux-specific. */
135#define BSM_ERRNO_ENOTEMPTY 93
136#define BSM_ERRNO_EUSERS 94
137#define BSM_ERRNO_ENOTSOCK 95
138#define BSM_ERRNO_EDESTADDRREQ 96
139#define BSM_ERRNO_EMSGSIZE 97
140#define BSM_ERRNO_EPROTOTYPE 98
141#define BSM_ERRNO_ENOPROTOOPT 99
142#define BSM_ERRNO_EPROTONOSUPPORT 120
143#define BSM_ERRNO_ESOCKTNOSUPPORT 121
144#define BSM_ERRNO_EOPNOTSUPP 122
145#define BSM_ERRNO_EPFNOSUPPORT 123
146#define BSM_ERRNO_EAFNOSUPPORT 124
147#define BSM_ERRNO_EADDRINUSE 125
148#define BSM_ERRNO_EADDRNOTAVAIL 126
149#define BSM_ERRNO_ENETDOWN 127
150#define BSM_ERRNO_ENETUNREACH 128
151#define BSM_ERRNO_ENETRESET 129
152#define BSM_ERRNO_ECONNABORTED 130
153#define BSM_ERRNO_ECONNRESET 131
154#define BSM_ERRNO_ENOBUFS 132
155#define BSM_ERRNO_EISCONN 133
156#define BSM_ERRNO_ENOTCONN 134
157#define BSM_ERRNO_ESHUTDOWN 143
158#define BSM_ERRNO_ETOOMANYREFS 144
159#define BSM_ERRNO_ETIMEDOUT 145
160#define BSM_ERRNO_ECONNREFUSED 146
161#define BSM_ERRNO_EHOSTDOWN 147
162#define BSM_ERRNO_EHOSTUNREACH 148
163#define BSM_ERRNO_EALREADY 149
164#define BSM_ERRNO_EINPROGRESS 150
165#define BSM_ERRNO_ESTALE 151
166
167/*
168 * OpenBSM constants for error numbers not defined in Solaris. In the event
169 * that these errors are added to Solaris, we will deprecate the OpenBSM
170 * numbers in the same way we do for audit event constants.
171 *
172 * ELAST doesn't get a constant in the BSM space.
173 */
174#define BSM_ERRNO_EPROCLIM 190 /* FreeBSD/Darwin-specific. */
175#define BSM_ERRNO_EBADRPC 191 /* FreeBSD/Darwin-specific. */
176#define BSM_ERRNO_ERPCMISMATCH 192 /* FreeBSD/Darwin-specific. */
177#define BSM_ERRNO_EPROGUNAVAIL 193 /* FreeBSD/Darwin-specific. */
178#define BSM_ERRNO_EPROGMISMATCH 194 /* FreeBSD/Darwin-specific. */
179#define BSM_ERRNO_EPROCUNAVAIL 195 /* FreeBSD/Darwin-specific. */
180#define BSM_ERRNO_EFTYPE 196 /* FreeBSD/Darwin-specific. */
181#define BSM_ERRNO_EAUTH 197 /* FreeBSD/Darwin-specific. */
182#define BSM_ERRNO_ENEEDAUTH 198 /* FreeBSD/Darwin-specific. */
183#define BSM_ERRNO_ENOATTR 199 /* FreeBSD/Darwin-specific. */
184#define BSM_ERRNO_EDOOFUS 200 /* FreeBSD-specific. */
185#define BSM_ERRNO_EJUSTRETURN 201 /* FreeBSD-specific. */
186#define BSM_ERRNO_ENOIOCTL 202 /* FreeBSD-specific. */
187#define BSM_ERRNO_EDIRIOCTL 203 /* FreeBSD-specific. */
188#define BSM_ERRNO_EPWROFF 204 /* Darwin-specific. */
189#define BSM_ERRNO_EDEVERR 205 /* Darwin-specific. */
190#define BSM_ERRNO_EBADEXEC 206 /* Darwin-specific. */
191#define BSM_ERRNO_EBADARCH 207 /* Darwin-specific. */
192#define BSM_ERRNO_ESHLIBVERS 208 /* Darwin-specific. */
193#define BSM_ERRNO_EBADMACHO 209 /* Darwin-specific. */
194#define BSM_ERRNO_EPOLICY 210 /* Darwin-specific. */
195#define BSM_ERRNO_EDOTDOT 211 /* Linux-specific. */
196#define BSM_ERRNO_EUCLEAN 212 /* Linux-specific. */
197#define BSM_ERRNO_ENOTNAM 213 /* Linux(Xenix?)-specific. */
198#define BSM_ERRNO_ENAVAIL 214 /* Linux(Xenix?)-specific. */
199#define BSM_ERRNO_EISNAM 215 /* Linux(Xenix?)-specific. */
200#define BSM_ERRNO_EREMOTEIO 216 /* Linux-specific. */
201#define BSM_ERRNO_ENOMEDIUM 217 /* Linux-specific. */
202#define BSM_ERRNO_EMEDIUMTYPE 218 /* Linux-specific. */
203#define BSM_ERRNO_ENOKEY 219 /* Linux-specific. */
204#define BSM_ERRNO_EKEYEXPIRED 220 /* Linux-specific. */
205#define BSM_ERRNO_EKEYREVOKED 221 /* Linux-specific. */
206#define BSM_ERRNO_EKEYREJECTED 222 /* Linux-specific. */
207#define BSM_ERRNO_ENOTCAPABLE 223 /* FreeBSD-specific. */
208#define BSM_ERRNO_ECAPMODE 224 /* FreeBSD-specific. */
209#define BSM_ERRNO_EINTEGRITY 225 /* FreeBSD-specific. */
210
211/*
212 * In the event that OpenBSM doesn't have a file representation of a local
213 * error number, use this.
214 */
215#define BSM_ERRNO_UNKNOWN 250 /* OpenBSM-specific. */
216
217#endif /* !_BSM_AUDIT_ERRNO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_fcntl.h deleted-140
......@@ -1,140 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2009 Apple Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _BSM_AUDIT_FCNTL_H_
33#define _BSM_AUDIT_FCNTL_H_
34
35/*
36 * Shared and Solaris-specific: (0-99).
37 */
38#define BSM_F_DUPFD 0
39#define BSM_F_GETFD 1
40#define BSM_F_SETFD 2
41#define BSM_F_GETFL 3
42#define BSM_F_SETFL 4
43#define BSM_F_O_GETLK 5 /* Solaris-specific. */
44#define BSM_F_SETLK 6
45#define BSM_F_SETLKW 7
46#define BSM_F_CHKFL 8 /* Solaris-specific. */
47#define BSM_F_DUP2FD 9 /* FreeBSD/Solaris-specific. */
48#define BSM_F_ALLOCSP 10 /* Solaris-specific. */
49#define BSM_F_FREESP 11 /* Solaris-specific. */
50
51#define BSM_F_ISSTREAM 13 /* Solaris-specific. */
52#define BSM_F_GETLK 14
53#define BSM_F_PRIV 15 /* Solaris-specific. */
54#define BSM_F_NPRIV 16 /* Solaris-specific. */
55#define BSM_F_QUOTACTL 17 /* Solaris-specific. */
56#define BSM_F_BLOCKS 18 /* Solaris-specific. */
57#define BSM_F_BLKSIZE 19 /* Solaris-specific. */
58
59#define BSM_F_GETOWN 23
60#define BSM_F_SETOWN 24
61#define BSM_F_REVOKE 25 /* Solaris-specific. */
62#define BSM_F_HASREMOTELOCKS 26 /* Solaris-specific. */
63#define BSM_F_FREESP64 27 /* Solaris-specific. */
64#define BSM_F_ALLOCSP64 28 /* Solaris-specific. */
65
66#define BSM_F_GETLK64 33 /* Solaris-specific. */
67#define BSM_F_SETLK64 34 /* Solaris-specific. */
68#define BSM_F_SETLKW64 35 /* Solaris-specific. */
69
70#define BSM_F_SHARE 40 /* Solaris-specific. */
71#define BSM_F_UNSHARE 41 /* Solaris-specific. */
72#define BSM_F_SETLK_NBMAND 42 /* Solaris-specific. */
73#define BSM_F_SHARE_NBMAND 43 /* Solaris-specific. */
74#define BSM_F_SETLK64_NBMAND 44 /* Solaris-specific. */
75#define BSM_F_GETXFL 45 /* Solaris-specific. */
76#define BSM_F_BADFD 46 /* Solaris-specific. */
77
78/*
79 * FreeBSD-specific (100-199).
80 */
81#define BSM_F_OGETLK 107 /* FreeBSD-specific. */
82#define BSM_F_OSETLK 108 /* FreeBSD-specific. */
83#define BSM_F_OSETLKW 109 /* FreeBSD-specific. */
84
85#define BSM_F_SETLK_REMOTE 114 /* FreeBSD-specific. */
86
87/*
88 * Linux-specific (200-299).
89 */
90#define BSM_F_SETSIG 210 /* Linux-specific. */
91#define BSM_F_GETSIG 211 /* Linux-specific. */
92
93/*
94 * Darwin-specific (300-399).
95 */
96#define BSM_F_CHKCLEAN 341 /* Darwin-specific. */
97#define BSM_F_PREALLOCATE 342 /* Darwin-specific. */
98#define BSM_F_SETSIZE 343 /* Darwin-specific. */
99#define BSM_F_RDADVISE 344 /* Darwin-specific. */
100#define BSM_F_RDAHEAD 345 /* Darwin-specific. */
101#define BSM_F_READBOOTSTRAP 346 /* Darwin-specific. */
102#define BSM_F_WRITEBOOTSTRAP 347 /* Darwin-specific. */
103#define BSM_F_NOCACHE 348 /* Darwin-specific. */
104#define BSM_F_LOG2PHYS 349 /* Darwin-specific. */
105#define BSM_F_GETPATH 350 /* Darwin-specific. */
106#define BSM_F_FULLFSYNC 351 /* Darwin-specific. */
107#define BSM_F_PATHPKG_CHECK 352 /* Darwin-specific. */
108#define BSM_F_FREEZE_FS 353 /* Darwin-specific. */
109#define BSM_F_THAW_FS 354 /* Darwin-specific. */
110#define BSM_F_GLOBAL_NOCACHE 355 /* Darwin-specific. */
111#define BSM_F_OPENFROM 356 /* Darwin-specific. */
112#define BSM_F_UNLINKFROM 357 /* Darwin-specific. */
113#define BSM_F_CHECK_OPENEVT 358 /* Darwin-specific. */
114#define BSM_F_ADDSIGS 359 /* Darwin-specific. */
115#define BSM_F_MARKDEPENDENCY 360 /* Darwin-specific. */
116
117/*
118 * Darwin file system specific (400-499).
119 */
120#define BSM_F_FS_SPECIFIC_0 400 /* Darwin-fs-specific. */
121#define BSM_F_FS_SPECIFIC_1 401 /* Darwin-fs-specific. */
122#define BSM_F_FS_SPECIFIC_2 402 /* Darwin-fs-specific. */
123#define BSM_F_FS_SPECIFIC_3 403 /* Darwin-fs-specific. */
124#define BSM_F_FS_SPECIFIC_4 404 /* Darwin-fs-specific. */
125#define BSM_F_FS_SPECIFIC_5 405 /* Darwin-fs-specific. */
126#define BSM_F_FS_SPECIFIC_6 406 /* Darwin-fs-specific. */
127#define BSM_F_FS_SPECIFIC_7 407 /* Darwin-fs-specific. */
128#define BSM_F_FS_SPECIFIC_8 408 /* Darwin-fs-specific. */
129#define BSM_F_FS_SPECIFIC_9 409 /* Darwin-fs-specific. */
130#define BSM_F_FS_SPECIFIC_10 410 /* Darwin-fs-specific. */
131#define BSM_F_FS_SPECIFIC_11 411 /* Darwin-fs-specific. */
132#define BSM_F_FS_SPECIFIC_12 412 /* Darwin-fs-specific. */
133#define BSM_F_FS_SPECIFIC_13 413 /* Darwin-fs-specific. */
134#define BSM_F_FS_SPECIFIC_14 414 /* Darwin-fs-specific. */
135#define BSM_F_FS_SPECIFIC_15 415 /* Darwin-fs-specific. */
136
137
138#define BSM_F_UNKNOWN 0xFFFF
139
140#endif /* !_BSM_AUDIT_FCNTL_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_internal.h deleted-117
......@@ -1,117 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2005-2008 Apple Inc.
5 * Copyright (c) 2005 SPARTA, Inc.
6 * All rights reserved.
7 *
8 * This code was developed in part by Robert N. M. Watson, Senior Principal
9 * Scientist, SPARTA, Inc.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
21 * its contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
25 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef _AUDIT_INTERNAL_H
37#define _AUDIT_INTERNAL_H
38
39#if defined(__linux__) && !defined(__unused)
40#define __unused
41#endif
42
43/*
44 * audit_internal.h contains private interfaces that are shared by user space
45 * and the kernel for the purposes of assembling audit records. Applications
46 * should not include this file or use the APIs found within, or it may be
47 * broken with future releases of OpenBSM, which may delete, modify, or
48 * otherwise break these interfaces or the assumptions they rely on.
49 */
50struct au_token {
51 u_char *t_data;
52 size_t len;
53 TAILQ_ENTRY(au_token) tokens;
54};
55
56struct au_record {
57 char used; /* Record currently in use? */
58 int desc; /* Descriptor for record. */
59 TAILQ_HEAD(, au_token) token_q; /* Queue of BSM tokens. */
60 u_char *data;
61 size_t len;
62 LIST_ENTRY(au_record) au_rec_q;
63};
64typedef struct au_record au_record_t;
65
66
67/*
68 * We could determined the header and trailer sizes by defining appropriate
69 * structures. We hold off that approach until we have a consistent way of
70 * using structures for all tokens. This is not straightforward since these
71 * token structures may contain pointers of whose contents we do not know the
72 * size (e.g text tokens).
73 */
74#define AUDIT_HEADER_EX_SIZE(a) ((a)->ai_termid.at_type+18+sizeof(u_int32_t))
75#define AUDIT_HEADER_SIZE 18
76#define MAX_AUDIT_HEADER_SIZE (5*sizeof(u_int32_t)+18)
77#define AUDIT_TRAILER_SIZE 7
78
79/*
80 * BSM token streams store fields in big endian byte order, so as to be
81 * portable; when encoding and decoding, we must convert byte orders for
82 * typed values.
83 */
84#define ADD_U_CHAR(loc, val) \
85 do { \
86 *(loc) = (val); \
87 (loc) += sizeof(u_char); \
88 } while(0)
89
90
91#define ADD_U_INT16(loc, val) \
92 do { \
93 be16enc((loc), (val)); \
94 (loc) += sizeof(u_int16_t); \
95 } while(0)
96
97#define ADD_U_INT32(loc, val) \
98 do { \
99 be32enc((loc), (val)); \
100 (loc) += sizeof(u_int32_t); \
101 } while(0)
102
103#define ADD_U_INT64(loc, val) \
104 do { \
105 be64enc((loc), (val)); \
106 (loc) += sizeof(u_int64_t); \
107 } while(0)
108
109#define ADD_MEM(loc, data, size) \
110 do { \
111 memcpy((loc), (data), (size)); \
112 (loc) += size; \
113 } while(0)
114
115#define ADD_STRING(loc, data, size) ADD_MEM(loc, data, size)
116
117#endif /* !_AUDIT_INTERNAL_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_kevents.h deleted-851
......@@ -1,851 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2005-2009 Apple Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _BSM_AUDIT_KEVENTS_H_
33#define _BSM_AUDIT_KEVENTS_H_
34
35/*
36 * The reserved event numbers for kernel events are 1...2047 and 43001..44999.
37 */
38#define AUE_IS_A_KEVENT(e) (((e) > 0 && (e) < 2048) || \
39 ((e) > 43000 && (e) < 45000))
40
41/*
42 * Values marked as AUE_NULL are not required to be audited as per CAPP.
43 *
44 * Some conflicts exist in the assignment of name to event number mappings
45 * between BSM implementations. In general, we prefer the OpenSolaris
46 * definition as we consider Solaris BSM to be authoritative. _DARWIN_ has
47 * been inserted for the Darwin variants. If necessary, other tags will be
48 * added in the future.
49 */
50#define AUE_NULL 0
51#define AUE_EXIT 1
52#define AUE_FORK 2
53#define AUE_FORKALL AUE_FORK /* Solaris-specific. */
54#define AUE_OPEN 3
55#define AUE_CREAT 4
56#define AUE_LINK 5
57#define AUE_UNLINK 6
58#define AUE_DELETE AUE_UNLINK /* Darwin-specific. */
59#define AUE_EXEC 7
60#define AUE_CHDIR 8
61#define AUE_MKNOD 9
62#define AUE_CHMOD 10
63#define AUE_CHOWN 11
64#define AUE_UMOUNT 12
65#define AUE_JUNK 13 /* Solaris-specific. */
66#define AUE_ACCESS 14
67#define AUE_KILL 15
68#define AUE_STAT 16
69#define AUE_LSTAT 17
70#define AUE_ACCT 18
71#define AUE_MCTL 19 /* Solaris-specific. */
72#define AUE_REBOOT 20 /* XXX: Darwin conflict. */
73#define AUE_SYMLINK 21
74#define AUE_READLINK 22
75#define AUE_EXECVE 23
76#define AUE_CHROOT 24
77#define AUE_VFORK 25
78#define AUE_SETGROUPS 26
79#define AUE_SETPGRP 27
80#define AUE_SWAPON 28
81#define AUE_SETHOSTNAME 29 /* XXX: Darwin conflict. */
82#define AUE_FCNTL 30
83#define AUE_SETPRIORITY 31 /* XXX: Darwin conflict. */
84#define AUE_CONNECT 32
85#define AUE_ACCEPT 33
86#define AUE_BIND 34
87#define AUE_SETSOCKOPT 35
88#define AUE_VTRACE 36 /* Solaris-specific. */
89#define AUE_SETTIMEOFDAY 37 /* XXX: Darwin conflict. */
90#define AUE_FCHOWN 38
91#define AUE_FCHMOD 39
92#define AUE_SETREUID 40
93#define AUE_SETREGID 41
94#define AUE_RENAME 42
95#define AUE_TRUNCATE 43 /* XXX: Darwin conflict. */
96#define AUE_FTRUNCATE 44 /* XXX: Darwin conflict. */
97#define AUE_FLOCK 45 /* XXX: Darwin conflict. */
98#define AUE_SHUTDOWN 46
99#define AUE_MKDIR 47
100#define AUE_RMDIR 48
101#define AUE_UTIMES 49
102#define AUE_ADJTIME 50
103#define AUE_SETRLIMIT 51
104#define AUE_KILLPG 52
105#define AUE_NFS_SVC 53 /* XXX: Darwin conflict. */
106#define AUE_STATFS 54
107#define AUE_FSTATFS 55
108#define AUE_UNMOUNT 56 /* XXX: Darwin conflict. */
109#define AUE_ASYNC_DAEMON 57
110#define AUE_NFS_GETFH 58 /* XXX: Darwin conflict. */
111#define AUE_SETDOMAINNAME 59
112#define AUE_QUOTACTL 60 /* XXX: Darwin conflict. */
113#define AUE_EXPORTFS 61
114#define AUE_MOUNT 62
115#define AUE_SEMSYS 63
116#define AUE_MSGSYS 64
117#define AUE_SHMSYS 65
118#define AUE_BSMSYS 66 /* Solaris-specific. */
119#define AUE_RFSSYS 67 /* Solaris-specific. */
120#define AUE_FCHDIR 68
121#define AUE_FCHROOT 69
122#define AUE_VPIXSYS 70 /* Solaris-specific. */
123#define AUE_PATHCONF 71
124#define AUE_OPEN_R 72
125#define AUE_OPEN_RC 73
126#define AUE_OPEN_RT 74
127#define AUE_OPEN_RTC 75
128#define AUE_OPEN_W 76
129#define AUE_OPEN_WC 77
130#define AUE_OPEN_WT 78
131#define AUE_OPEN_WTC 79
132#define AUE_OPEN_RW 80
133#define AUE_OPEN_RWC 81
134#define AUE_OPEN_RWT 82
135#define AUE_OPEN_RWTC 83
136#define AUE_MSGCTL 84
137#define AUE_MSGCTL_RMID 85
138#define AUE_MSGCTL_SET 86
139#define AUE_MSGCTL_STAT 87
140#define AUE_MSGGET 88
141#define AUE_MSGRCV 89
142#define AUE_MSGSND 90
143#define AUE_SHMCTL 91
144#define AUE_SHMCTL_RMID 92
145#define AUE_SHMCTL_SET 93
146#define AUE_SHMCTL_STAT 94
147#define AUE_SHMGET 95
148#define AUE_SHMAT 96
149#define AUE_SHMDT 97
150#define AUE_SEMCTL 98
151#define AUE_SEMCTL_RMID 99
152#define AUE_SEMCTL_SET 100
153#define AUE_SEMCTL_STAT 101
154#define AUE_SEMCTL_GETNCNT 102
155#define AUE_SEMCTL_GETPID 103
156#define AUE_SEMCTL_GETVAL 104
157#define AUE_SEMCTL_GETALL 105
158#define AUE_SEMCTL_GETZCNT 106
159#define AUE_SEMCTL_SETVAL 107
160#define AUE_SEMCTL_SETALL 108
161#define AUE_SEMGET 109
162#define AUE_SEMOP 110
163#define AUE_CORE 111 /* Solaris-specific, currently. */
164#define AUE_CLOSE 112
165#define AUE_SYSTEMBOOT 113 /* Solaris-specific. */
166#define AUE_ASYNC_DAEMON_EXIT 114 /* Solaris-specific. */
167#define AUE_NFSSVC_EXIT 115 /* Solaris-specific. */
168#define AUE_WRITEL 128 /* Solaris-specific. */
169#define AUE_WRITEVL 129 /* Solaris-specific. */
170#define AUE_GETAUID 130
171#define AUE_SETAUID 131
172#define AUE_GETAUDIT 132
173#define AUE_SETAUDIT 133
174#define AUE_GETUSERAUDIT 134 /* Solaris-specific. */
175#define AUE_SETUSERAUDIT 135 /* Solaris-specific. */
176#define AUE_AUDITSVC 136 /* Solaris-specific. */
177#define AUE_AUDITUSER 137 /* Solaris-specific. */
178#define AUE_AUDITON 138
179#define AUE_AUDITON_GTERMID 139 /* Solaris-specific. */
180#define AUE_AUDITON_STERMID 140 /* Solaris-specific. */
181#define AUE_AUDITON_GPOLICY 141
182#define AUE_AUDITON_SPOLICY 142
183#define AUE_AUDITON_GQCTRL 145
184#define AUE_AUDITON_SQCTRL 146
185#define AUE_GETKERNSTATE 147 /* Solaris-specific. */
186#define AUE_SETKERNSTATE 148 /* Solaris-specific. */
187#define AUE_GETPORTAUDIT 149 /* Solaris-specific. */
188#define AUE_AUDITSTAT 150 /* Solaris-specific. */
189#define AUE_REVOKE 151
190#define AUE_MAC 152 /* Solaris-specific. */
191#define AUE_ENTERPROM 153 /* Solaris-specific. */
192#define AUE_EXITPROM 154 /* Solaris-specific. */
193#define AUE_IFLOAT 155 /* Solaris-specific. */
194#define AUE_PFLOAT 156 /* Solaris-specific. */
195#define AUE_UPRIV 157 /* Solaris-specific. */
196#define AUE_IOCTL 158
197#define AUE_SOCKET 183
198#define AUE_SENDTO 184
199#define AUE_PIPE 185
200#define AUE_SOCKETPAIR 186 /* XXX: Darwin conflict. */
201#define AUE_SEND 187
202#define AUE_SENDMSG 188
203#define AUE_RECV 189
204#define AUE_RECVMSG 190
205#define AUE_RECVFROM 191
206#define AUE_READ 192
207#define AUE_GETDENTS 193
208#define AUE_LSEEK 194
209#define AUE_WRITE 195
210#define AUE_WRITEV 196
211#define AUE_NFS 197 /* Solaris-specific. */
212#define AUE_READV 198
213#define AUE_OSTAT 199 /* Solaris-specific. */
214#define AUE_SETUID 200 /* XXXRW: Solaris old setuid? */
215#define AUE_STIME 201 /* XXXRW: Solaris old stime? */
216#define AUE_UTIME 202 /* XXXRW: Solaris old utime? */
217#define AUE_NICE 203 /* XXXRW: Solaris old nice? */
218#define AUE_OSETPGRP 204 /* Solaris-specific. */
219#define AUE_SETGID 205
220#define AUE_READL 206 /* Solaris-specific. */
221#define AUE_READVL 207 /* Solaris-specific. */
222#define AUE_FSTAT 208
223#define AUE_DUP2 209
224#define AUE_MMAP 210
225#define AUE_AUDIT 211
226#define AUE_PRIOCNTLSYS 212 /* Solaris-specific. */
227#define AUE_MUNMAP 213
228#define AUE_SETEGID 214
229#define AUE_SETEUID 215
230#define AUE_PUTMSG 216 /* Solaris-specific. */
231#define AUE_GETMSG 217 /* Solaris-specific. */
232#define AUE_PUTPMSG 218 /* Solaris-specific. */
233#define AUE_GETPMSG 219 /* Solaris-specific. */
234#define AUE_AUDITSYS 220 /* Solaris-specific. */
235#define AUE_AUDITON_GETKMASK 221
236#define AUE_AUDITON_SETKMASK 222
237#define AUE_AUDITON_GETCWD 223
238#define AUE_AUDITON_GETCAR 224
239#define AUE_AUDITON_GETSTAT 225
240#define AUE_AUDITON_SETSTAT 226
241#define AUE_AUDITON_SETUMASK 227
242#define AUE_AUDITON_SETSMASK 228
243#define AUE_AUDITON_GETCOND 229
244#define AUE_AUDITON_SETCOND 230
245#define AUE_AUDITON_GETCLASS 231
246#define AUE_AUDITON_SETCLASS 232
247#define AUE_FUSERS 233 /* Solaris-specific; also UTSSYS? */
248#define AUE_STATVFS 234
249#define AUE_XSTAT 235 /* Solaris-specific. */
250#define AUE_LXSTAT 236 /* Solaris-specific. */
251#define AUE_LCHOWN 237
252#define AUE_MEMCNTL 238 /* Solaris-specific. */
253#define AUE_SYSINFO 239 /* Solaris-specific. */
254#define AUE_XMKNOD 240 /* Solaris-specific. */
255#define AUE_FORK1 241
256#define AUE_MODCTL 242 /* Solaris-specific. */
257#define AUE_MODLOAD 243
258#define AUE_MODUNLOAD 244
259#define AUE_MODCONFIG 245 /* Solaris-specific. */
260#define AUE_MODADDMAJ 246 /* Solaris-specific. */
261#define AUE_SOCKACCEPT 247 /* Solaris-specific. */
262#define AUE_SOCKCONNECT 248 /* Solaris-specific. */
263#define AUE_SOCKSEND 249 /* Solaris-specific. */
264#define AUE_SOCKRECEIVE 250 /* Solaris-specific. */
265#define AUE_ACLSET 251
266#define AUE_FACLSET 252
267#define AUE_DOORFS 253 /* Solaris-specific. */
268#define AUE_DOORFS_DOOR_CALL 254 /* Solaris-specific. */
269#define AUE_DOORFS_DOOR_RETURN 255 /* Solaris-specific. */
270#define AUE_DOORFS_DOOR_CREATE 256 /* Solaris-specific. */
271#define AUE_DOORFS_DOOR_REVOKE 257 /* Solaris-specific. */
272#define AUE_DOORFS_DOOR_INFO 258 /* Solaris-specific. */
273#define AUE_DOORFS_DOOR_CRED 259 /* Solaris-specific. */
274#define AUE_DOORFS_DOOR_BIND 260 /* Solaris-specific. */
275#define AUE_DOORFS_DOOR_UNBIND 261 /* Solaris-specific. */
276#define AUE_P_ONLINE 262 /* Solaris-specific. */
277#define AUE_PROCESSOR_BIND 263 /* Solaris-specific. */
278#define AUE_INST_SYNC 264 /* Solaris-specific. */
279#define AUE_SOCKCONFIG 265 /* Solaris-specific. */
280#define AUE_SETAUDIT_ADDR 266
281#define AUE_GETAUDIT_ADDR 267
282#define AUE_UMOUNT2 268 /* Solaris-specific. */
283#define AUE_FSAT 269 /* Solaris-specific. */
284#define AUE_OPENAT_R 270
285#define AUE_OPENAT_RC 271
286#define AUE_OPENAT_RT 272
287#define AUE_OPENAT_RTC 273
288#define AUE_OPENAT_W 274
289#define AUE_OPENAT_WC 275
290#define AUE_OPENAT_WT 276
291#define AUE_OPENAT_WTC 277
292#define AUE_OPENAT_RW 278
293#define AUE_OPENAT_RWC 279
294#define AUE_OPENAT_RWT 280
295#define AUE_OPENAT_RWTC 281
296#define AUE_RENAMEAT 282
297#define AUE_FSTATAT 283
298#define AUE_FCHOWNAT 284
299#define AUE_FUTIMESAT 285
300#define AUE_UNLINKAT 286
301#define AUE_CLOCK_SETTIME 287
302#define AUE_NTP_ADJTIME 288
303#define AUE_SETPPRIV 289 /* Solaris-specific. */
304#define AUE_MODDEVPLCY 290 /* Solaris-specific. */
305#define AUE_MODADDPRIV 291 /* Solaris-specific. */
306#define AUE_CRYPTOADM 292 /* Solaris-specific. */
307#define AUE_CONFIGKSSL 293 /* Solaris-specific. */
308#define AUE_BRANDSYS 294 /* Solaris-specific. */
309#define AUE_PF_POLICY_ADDRULE 295 /* Solaris-specific. */
310#define AUE_PF_POLICY_DELRULE 296 /* Solaris-specific. */
311#define AUE_PF_POLICY_CLONE 297 /* Solaris-specific. */
312#define AUE_PF_POLICY_FLIP 298 /* Solaris-specific. */
313#define AUE_PF_POLICY_FLUSH 299 /* Solaris-specific. */
314#define AUE_PF_POLICY_ALGS 300 /* Solaris-specific. */
315#define AUE_PORTFS 301 /* Solaris-specific. */
316
317/*
318 * Events added for Apple Darwin that potentially collide with future Solaris
319 * BSM events. These are assigned AUE_DARWIN prefixes, and are deprecated in
320 * new trails. Systems generating these events should switch to the new
321 * identifiers that avoid colliding with the Solaris identifier space.
322 */
323#define AUE_DARWIN_GETFSSTAT 301
324#define AUE_DARWIN_PTRACE 302
325#define AUE_DARWIN_CHFLAGS 303
326#define AUE_DARWIN_FCHFLAGS 304
327#define AUE_DARWIN_PROFILE 305
328#define AUE_DARWIN_KTRACE 306
329#define AUE_DARWIN_SETLOGIN 307
330#define AUE_DARWIN_REBOOT 308
331#define AUE_DARWIN_REVOKE 309
332#define AUE_DARWIN_UMASK 310
333#define AUE_DARWIN_MPROTECT 311
334#define AUE_DARWIN_SETPRIORITY 312
335#define AUE_DARWIN_SETTIMEOFDAY 313
336#define AUE_DARWIN_FLOCK 314
337#define AUE_DARWIN_MKFIFO 315
338#define AUE_DARWIN_POLL 316
339#define AUE_DARWIN_SOCKETPAIR 317
340#define AUE_DARWIN_FUTIMES 318
341#define AUE_DARWIN_SETSID 319
342#define AUE_DARWIN_SETPRIVEXEC 320 /* Darwin-specific. */
343#define AUE_DARWIN_NFSSVC 321
344#define AUE_DARWIN_GETFH 322
345#define AUE_DARWIN_QUOTACTL 323
346#define AUE_DARWIN_ADDPROFILE 324 /* Darwin-specific. */
347#define AUE_DARWIN_KDEBUGTRACE 325 /* Darwin-specific. */
348#define AUE_DARWIN_KDBUGTRACE AUE_KDEBUGTRACE
349#define AUE_DARWIN_FSTAT 326
350#define AUE_DARWIN_FPATHCONF 327
351#define AUE_DARWIN_GETDIRENTRIES 328
352#define AUE_DARWIN_TRUNCATE 329
353#define AUE_DARWIN_FTRUNCATE 330
354#define AUE_DARWIN_SYSCTL 331
355#define AUE_DARWIN_MLOCK 332
356#define AUE_DARWIN_MUNLOCK 333
357#define AUE_DARWIN_UNDELETE 334
358#define AUE_DARWIN_GETATTRLIST 335 /* Darwin-specific. */
359#define AUE_DARWIN_SETATTRLIST 336 /* Darwin-specific. */
360#define AUE_DARWIN_GETDIRENTRIESATTR 337 /* Darwin-specific. */
361#define AUE_DARWIN_EXCHANGEDATA 338 /* Darwin-specific. */
362#define AUE_DARWIN_SEARCHFS 339 /* Darwin-specific. */
363#define AUE_DARWIN_MINHERIT 340
364#define AUE_DARWIN_SEMCONFIG 341
365#define AUE_DARWIN_SEMOPEN 342
366#define AUE_DARWIN_SEMCLOSE 343
367#define AUE_DARWIN_SEMUNLINK 344
368#define AUE_DARWIN_SHMOPEN 345
369#define AUE_DARWIN_SHMUNLINK 346
370#define AUE_DARWIN_LOADSHFILE 347 /* Darwin-specific. */
371#define AUE_DARWIN_RESETSHFILE 348 /* Darwin-specific. */
372#define AUE_DARWIN_NEWSYSTEMSHREG 349 /* Darwin-specific. */
373#define AUE_DARWIN_PTHREADKILL 350 /* Darwin-specific. */
374#define AUE_DARWIN_PTHREADSIGMASK 351 /* Darwin-specific. */
375#define AUE_DARWIN_AUDITCTL 352
376#define AUE_DARWIN_RFORK 353
377#define AUE_DARWIN_LCHMOD 354
378#define AUE_DARWIN_SWAPOFF 355
379#define AUE_DARWIN_INITPROCESS 356 /* Darwin-specific. */
380#define AUE_DARWIN_MAPFD 357 /* Darwin-specific. */
381#define AUE_DARWIN_TASKFORPID 358 /* Darwin-specific. */
382#define AUE_DARWIN_PIDFORTASK 359 /* Darwin-specific. */
383#define AUE_DARWIN_SYSCTL_NONADMIN 360
384#define AUE_DARWIN_COPYFILE 361 /* Darwin-specific. */
385
386/*
387 * Audit event identifiers added as part of OpenBSM, generally corresponding
388 * to events in FreeBSD, Darwin, and Linux that were not present in Solaris.
389 * These often duplicate events added to the Solaris set by Darwin, but use
390 * event identifiers in a higher range in order to avoid colliding with
391 * future Solaris additions.
392 *
393 * If an event in this section is later added to Solaris, we prefer the
394 * Solaris event identifier, and add _OPENBSM_ to the OpenBSM-specific
395 * identifier so that old trails can still be processed, but new trails use
396 * the Solaris identifier.
397 */
398#define AUE_GETFSSTAT 43001
399#define AUE_PTRACE 43002
400#define AUE_CHFLAGS 43003
401#define AUE_FCHFLAGS 43004
402#define AUE_PROFILE 43005
403#define AUE_KTRACE 43006
404#define AUE_SETLOGIN 43007
405#define AUE_OPENBSM_REVOKE 43008 /* Solaris event now preferred. */
406#define AUE_UMASK 43009
407#define AUE_MPROTECT 43010
408#define AUE_MKFIFO 43011
409#define AUE_POLL 43012
410#define AUE_FUTIMES 43013
411#define AUE_SETSID 43014
412#define AUE_SETPRIVEXEC 43015 /* Darwin-specific. */
413#define AUE_ADDPROFILE 43016 /* Darwin-specific. */
414#define AUE_KDEBUGTRACE 43017 /* Darwin-specific. */
415#define AUE_KDBUGTRACE AUE_KDEBUGTRACE
416#define AUE_OPENBSM_FSTAT 43018 /* Solaris event now preferred. */
417#define AUE_FPATHCONF 43019
418#define AUE_GETDIRENTRIES 43020
419#define AUE_SYSCTL 43021
420#define AUE_MLOCK 43022
421#define AUE_MUNLOCK 43023
422#define AUE_UNDELETE 43024
423#define AUE_GETATTRLIST 43025 /* Darwin-specific. */
424#define AUE_SETATTRLIST 43026 /* Darwin-specific. */
425#define AUE_GETDIRENTRIESATTR 43027 /* Darwin-specific. */
426#define AUE_EXCHANGEDATA 43028 /* Darwin-specific. */
427#define AUE_SEARCHFS 43029 /* Darwin-specific. */
428#define AUE_MINHERIT 43030
429#define AUE_SEMCONFIG 43031
430#define AUE_SEMOPEN 43032
431#define AUE_SEMCLOSE 43033
432#define AUE_SEMUNLINK 43034
433#define AUE_SHMOPEN 43035
434#define AUE_SHMUNLINK 43036
435#define AUE_LOADSHFILE 43037 /* Darwin-specific. */
436#define AUE_RESETSHFILE 43038 /* Darwin-specific. */
437#define AUE_NEWSYSTEMSHREG 43039 /* Darwin-specific. */
438#define AUE_PTHREADKILL 43040 /* Darwin-specific. */
439#define AUE_PTHREADSIGMASK 43041 /* Darwin-specific. */
440#define AUE_AUDITCTL 43042
441#define AUE_RFORK 43043
442#define AUE_LCHMOD 43044
443#define AUE_SWAPOFF 43045
444#define AUE_INITPROCESS 43046 /* Darwin-specific. */
445#define AUE_MAPFD 43047 /* Darwin-specific. */
446#define AUE_TASKFORPID 43048 /* Darwin-specific. */
447#define AUE_PIDFORTASK 43049 /* Darwin-specific. */
448#define AUE_SYSCTL_NONADMIN 43050
449#define AUE_COPYFILE 43051 /* Darwin-specific. */
450
451/*
452 * Events added to OpenBSM for FreeBSD and Linux; may also be used by Darwin
453 * in the future.
454 */
455#define AUE_LUTIMES 43052
456#define AUE_LCHFLAGS 43053 /* FreeBSD-specific. */
457#define AUE_SENDFILE 43054 /* BSD/Linux-specific. */
458#define AUE_USELIB 43055 /* Linux-specific. */
459#define AUE_GETRESUID 43056
460#define AUE_SETRESUID 43057
461#define AUE_GETRESGID 43058
462#define AUE_SETRESGID 43059
463#define AUE_WAIT4 43060 /* FreeBSD-specific. */
464#define AUE_LGETFH 43061 /* FreeBSD-specific. */
465#define AUE_FHSTATFS 43062 /* FreeBSD-specific. */
466#define AUE_FHOPEN 43063 /* FreeBSD-specific. */
467#define AUE_FHSTAT 43064 /* FreeBSD-specific. */
468#define AUE_JAIL 43065 /* FreeBSD-specific. */
469#define AUE_EACCESS 43066 /* FreeBSD-specific. */
470#define AUE_KQUEUE 43067 /* FreeBSD-specific. */
471#define AUE_KEVENT 43068 /* FreeBSD-specific. */
472#define AUE_FSYNC 43069
473#define AUE_NMOUNT 43070 /* FreeBSD-specific. */
474#define AUE_BDFLUSH 43071 /* Linux-specific. */
475#define AUE_SETFSUID 43072 /* Linux-specific. */
476#define AUE_SETFSGID 43073 /* Linux-specific. */
477#define AUE_PERSONALITY 43074 /* Linux-specific. */
478#define AUE_SCHED_GETSCHEDULER 43075 /* POSIX.1b. */
479#define AUE_SCHED_SETSCHEDULER 43076 /* POSIX.1b. */
480#define AUE_PRCTL 43077 /* Linux-specific. */
481#define AUE_GETCWD 43078 /* FreeBSD/Linux-specific. */
482#define AUE_CAPGET 43079 /* Linux-specific. */
483#define AUE_CAPSET 43080 /* Linux-specific. */
484#define AUE_PIVOT_ROOT 43081 /* Linux-specific. */
485#define AUE_RTPRIO 43082 /* FreeBSD-specific. */
486#define AUE_SCHED_GETPARAM 43083 /* POSIX.1b. */
487#define AUE_SCHED_SETPARAM 43084 /* POSIX.1b. */
488#define AUE_SCHED_GET_PRIORITY_MAX 43085 /* POSIX.1b. */
489#define AUE_SCHED_GET_PRIORITY_MIN 43086 /* POSIX.1b. */
490#define AUE_SCHED_RR_GET_INTERVAL 43087 /* POSIX.1b. */
491#define AUE_ACL_GET_FILE 43088 /* FreeBSD. */
492#define AUE_ACL_SET_FILE 43089 /* FreeBSD. */
493#define AUE_ACL_GET_FD 43090 /* FreeBSD. */
494#define AUE_ACL_SET_FD 43091 /* FreeBSD. */
495#define AUE_ACL_DELETE_FILE 43092 /* FreeBSD. */
496#define AUE_ACL_DELETE_FD 43093 /* FreeBSD. */
497#define AUE_ACL_CHECK_FILE 43094 /* FreeBSD. */
498#define AUE_ACL_CHECK_FD 43095 /* FreeBSD. */
499#define AUE_ACL_GET_LINK 43096 /* FreeBSD. */
500#define AUE_ACL_SET_LINK 43097 /* FreeBSD. */
501#define AUE_ACL_DELETE_LINK 43098 /* FreeBSD. */
502#define AUE_ACL_CHECK_LINK 43099 /* FreeBSD. */
503#define AUE_SYSARCH 43100 /* FreeBSD. */
504#define AUE_EXTATTRCTL 43101 /* FreeBSD. */
505#define AUE_EXTATTR_GET_FILE 43102 /* FreeBSD. */
506#define AUE_EXTATTR_SET_FILE 43103 /* FreeBSD. */
507#define AUE_EXTATTR_LIST_FILE 43104 /* FreeBSD. */
508#define AUE_EXTATTR_DELETE_FILE 43105 /* FreeBSD. */
509#define AUE_EXTATTR_GET_FD 43106 /* FreeBSD. */
510#define AUE_EXTATTR_SET_FD 43107 /* FreeBSD. */
511#define AUE_EXTATTR_LIST_FD 43108 /* FreeBSD. */
512#define AUE_EXTATTR_DELETE_FD 43109 /* FreeBSD. */
513#define AUE_EXTATTR_GET_LINK 43110 /* FreeBSD. */
514#define AUE_EXTATTR_SET_LINK 43111 /* FreeBSD. */
515#define AUE_EXTATTR_LIST_LINK 43112 /* FreeBSD. */
516#define AUE_EXTATTR_DELETE_LINK 43113 /* FreeBSD. */
517#define AUE_KENV 43114 /* FreeBSD. */
518#define AUE_JAIL_ATTACH 43115 /* FreeBSD. */
519#define AUE_SYSCTL_WRITE 43116 /* FreeBSD. */
520#define AUE_IOPERM 43117 /* Linux. */
521#define AUE_READDIR 43118 /* Linux. */
522#define AUE_IOPL 43119 /* Linux. */
523#define AUE_VM86 43120 /* Linux. */
524#define AUE_MAC_GET_PROC 43121 /* FreeBSD/Darwin. */
525#define AUE_MAC_SET_PROC 43122 /* FreeBSD/Darwin. */
526#define AUE_MAC_GET_FD 43123 /* FreeBSD/Darwin. */
527#define AUE_MAC_GET_FILE 43124 /* FreeBSD/Darwin. */
528#define AUE_MAC_SET_FD 43125 /* FreeBSD/Darwin. */
529#define AUE_MAC_SET_FILE 43126 /* FreeBSD/Darwin. */
530#define AUE_MAC_SYSCALL 43127 /* FreeBSD. */
531#define AUE_MAC_GET_PID 43128 /* FreeBSD/Darwin. */
532#define AUE_MAC_GET_LINK 43129 /* FreeBSD/Darwin. */
533#define AUE_MAC_SET_LINK 43130 /* FreeBSD/Darwin. */
534#define AUE_MAC_EXECVE 43131 /* FreeBSD/Darwin. */
535#define AUE_GETPATH_FROMFD 43132 /* FreeBSD. */
536#define AUE_GETPATH_FROMADDR 43133 /* FreeBSD. */
537#define AUE_MQ_OPEN 43134 /* FreeBSD. */
538#define AUE_MQ_SETATTR 43135 /* FreeBSD. */
539#define AUE_MQ_TIMEDRECEIVE 43136 /* FreeBSD. */
540#define AUE_MQ_TIMEDSEND 43137 /* FreeBSD. */
541#define AUE_MQ_NOTIFY 43138 /* FreeBSD. */
542#define AUE_MQ_UNLINK 43139 /* FreeBSD. */
543#define AUE_LISTEN 43140 /* FreeBSD/Darwin/Linux. */
544#define AUE_MLOCKALL 43141 /* FreeBSD. */
545#define AUE_MUNLOCKALL 43142 /* FreeBSD. */
546#define AUE_CLOSEFROM 43143 /* FreeBSD. */
547#define AUE_FEXECVE 43144 /* FreeBSD. */
548#define AUE_FACCESSAT 43145 /* FreeBSD. */
549#define AUE_FCHMODAT 43146 /* FreeBSD. */
550#define AUE_LINKAT 43147 /* FreeBSD. */
551#define AUE_MKDIRAT 43148 /* FreeBSD. */
552#define AUE_MKFIFOAT 43149 /* FreeBSD. */
553#define AUE_MKNODAT 43150 /* FreeBSD. */
554#define AUE_READLINKAT 43151 /* FreeBSD. */
555#define AUE_SYMLINKAT 43152 /* FreeBSD. */
556#define AUE_MAC_GETFSSTAT 43153 /* Darwin. */
557#define AUE_MAC_GET_MOUNT 43154 /* Darwin. */
558#define AUE_MAC_GET_LCID 43155 /* Darwin. */
559#define AUE_MAC_GET_LCTX 43156 /* Darwin. */
560#define AUE_MAC_SET_LCTX 43157 /* Darwin. */
561#define AUE_MAC_MOUNT 43158 /* Darwin. */
562#define AUE_GETLCID 43159 /* Darwin. */
563#define AUE_SETLCID 43160 /* Darwin. */
564#define AUE_TASKNAMEFORPID 43161 /* Darwin. */
565#define AUE_ACCESS_EXTENDED 43162 /* Darwin. */
566#define AUE_CHMOD_EXTENDED 43163 /* Darwin. */
567#define AUE_FCHMOD_EXTENDED 43164 /* Darwin. */
568#define AUE_FSTAT_EXTENDED 43165 /* Darwin. */
569#define AUE_LSTAT_EXTENDED 43166 /* Darwin. */
570#define AUE_MKDIR_EXTENDED 43167 /* Darwin. */
571#define AUE_MKFIFO_EXTENDED 43168 /* Darwin. */
572#define AUE_OPEN_EXTENDED 43169 /* Darwin. */
573#define AUE_OPEN_EXTENDED_R 43170 /* Darwin. */
574#define AUE_OPEN_EXTENDED_RC 43171 /* Darwin. */
575#define AUE_OPEN_EXTENDED_RT 43172 /* Darwin. */
576#define AUE_OPEN_EXTENDED_RTC 43173 /* Darwin. */
577#define AUE_OPEN_EXTENDED_W 43174 /* Darwin. */
578#define AUE_OPEN_EXTENDED_WC 43175 /* Darwin. */
579#define AUE_OPEN_EXTENDED_WT 43176 /* Darwin. */
580#define AUE_OPEN_EXTENDED_WTC 43177 /* Darwin. */
581#define AUE_OPEN_EXTENDED_RW 43178 /* Darwin. */
582#define AUE_OPEN_EXTENDED_RWC 43179 /* Darwin. */
583#define AUE_OPEN_EXTENDED_RWT 43180 /* Darwin. */
584#define AUE_OPEN_EXTENDED_RWTC 43181 /* Darwin. */
585#define AUE_STAT_EXTENDED 43182 /* Darwin. */
586#define AUE_UMASK_EXTENDED 43183 /* Darwin. */
587#define AUE_OPENAT 43184 /* FreeBSD. */
588#define AUE_POSIX_OPENPT 43185 /* FreeBSD. */
589#define AUE_CAP_NEW 43186 /* TrustedBSD. */
590#define AUE_CAP_RIGHTS_GET 43187 /* TrustedBSD. */
591#define AUE_CAP_GETRIGHTS AUE_CAP_RIGHTS_GET
592#define AUE_CAP_ENTER 43188 /* TrustedBSD. */
593#define AUE_CAP_GETMODE 43189 /* TrustedBSD. */
594#define AUE_POSIX_SPAWN 43190 /* Darwin. */
595#define AUE_FSGETPATH 43191 /* Darwin. */
596#define AUE_PREAD 43192 /* Darwin/FreeBSD. */
597#define AUE_PWRITE 43193 /* Darwin/FreeBSD. */
598#define AUE_FSCTL 43194 /* Darwin. */
599#define AUE_FFSCTL 43195 /* Darwin. */
600#define AUE_LPATHCONF 43196 /* FreeBSD. */
601#define AUE_PDFORK 43197 /* FreeBSD. */
602#define AUE_PDKILL 43198 /* FreeBSD. */
603#define AUE_PDGETPID 43199 /* FreeBSD. */
604#define AUE_PDWAIT 43200 /* FreeBSD. */
605#define AUE_WAIT6 43201 /* FreeBSD. */
606#define AUE_CAP_RIGHTS_LIMIT 43202 /* TrustedBSD. */
607#define AUE_CAP_IOCTLS_LIMIT 43203 /* TrustedBSD. */
608#define AUE_CAP_IOCTLS_GET 43204 /* TrustedBSD. */
609#define AUE_CAP_FCNTLS_LIMIT 43205 /* TrustedBSD. */
610#define AUE_CAP_FCNTLS_GET 43206 /* TrustedBSD. */
611#define AUE_BINDAT 43207 /* TrustedBSD. */
612#define AUE_CONNECTAT 43208 /* TrustedBSD. */
613#define AUE_CHFLAGSAT 43209 /* FreeBSD-specific. */
614#define AUE_PREADV 43210 /* FreeBSD-specific. */
615#define AUE_PWRITEV 43211 /* FreeBSD-specific. */
616#define AUE_POSIX_FALLOCATE 43212 /* FreeBSD-specific. */
617#define AUE_AIO_MLOCK 43213 /* FreeBSD-specific. */
618#define AUE_PROCCTL 43214 /* FreeBSD-specific. */
619#define AUE_AIO_READ 43215 /* FreeBSD-specific. */
620#define AUE_AIO_WRITE 43216 /* FreeBSD-specific. */
621#define AUE_AIO_RETURN 43217 /* FreeBSD-specific. */
622#define AUE_AIO_SUSPEND 43218 /* FreeBSD-specific. */
623#define AUE_AIO_CANCEL 43219 /* FreeBSD-specific. */
624#define AUE_AIO_ERROR 43220 /* FreeBSD-specific. */
625#define AUE_AIO_WAITCOMPLETE 43221 /* FreeBSD-specific. */
626#define AUE_AIO_FSYNC 43222 /* FreeBSD-specific. */
627#define AUE_THR_CREATE 43223 /* FreeBSD-specific. */
628#define AUE_THR_NEW 43224 /* FreeBSD-specific. */
629#define AUE_THR_EXIT 43225 /* FreeBSD-specific. */
630#define AUE_THR_KILL 43226 /* FreeBSD-specific. */
631#define AUE_THR_KILL2 43227 /* FreeBSD-specific. */
632#define AUE_SETFIB 43228 /* FreeBSD-specific. */
633#define AUE_LIO_LISTIO 43229 /* FreeBSD-specific. */
634#define AUE_SETUGID 43230 /* FreeBSD-specific. */
635#define AUE_SCTP_PEELOFF 43231 /* FreeBSD-specific. */
636#define AUE_SCTP_GENERIC_SENDMSG 43232 /* FreeBSD-specific. */
637#define AUE_SCTP_GENERIC_RECVMSG 43233 /* FreeBSD-specific. */
638#define AUE_JAIL_GET 43234 /* FreeBSD-specific. */
639#define AUE_JAIL_SET 43235 /* FreeBSD-specific. */
640#define AUE_JAIL_REMOVE 43236 /* FreeBSD-specific. */
641#define AUE_GETLOGINCLASS 43237 /* FreeBSD-specific. */
642#define AUE_SETLOGINCLASS 43238 /* FreeBSD-specific. */
643#define AUE_POSIX_FADVISE 43239 /* FreeBSD-specific. */
644#define AUE_SCTP_GENERIC_SENDMSG_IOV 43240 /* FreeBSD-specific. */
645#define AUE_ABORT2 43241 /* FreeBSD-specific. */
646#define AUE_SEMTIMEDWAIT 43242 /* FreeBSD-specific. */
647#define AUE_SEMDESTROY 43243 /* FreeBSD-specific. */
648#define AUE_SEMGETVALUE 43244 /* FreeBSD-specific. */
649#define AUE_SEMINIT 43245 /* FreeBSD-specific. */
650#define AUE_SEMPOST 43246 /* FreeBSD-specific. */
651#define AUE_SEMTRYWAIT 43247 /* FreeBSD-specific. */
652#define AUE_SEMWAIT 43258 /* FreeBSD-specific. */
653#define AUE_FGETUUID 43259 /* CADETS. */
654#define AUE_GETUUID 43260 /* CADETS. */
655#define AUE_LGETUUID 43261 /* CADETS. */
656#define AUE_EXECVEAT 43262 /* FreeBSD/Linux. */
657#define AUE_SHMRENAME 43263 /* FreeBSD-specific. */
658#define AUE_REALPATHAT 43264 /* FreeBSD-specific. */
659#define AUE_CLOSERANGE 43265 /* FreeBSD-specific. */
660#define AUE_SPECIALFD 43266 /* FreeBSD-specific. */
661#define AUE_AIO_WRITEV 43267 /* FreeBSD-specific. */
662#define AUE_AIO_READV 43268 /* FreeBSD-specific. */
663#define AUE_FSPACECTL 43269 /* FreeBSD-specific. */
664#define AUE_TIMERFD 43270 /* FreeBSD/Linux. */
665
666/*
667 * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the
668 * normal Solaris BSM identifiers. _O_ refers to it being an old, or compat
669 * interface. In most cases, Darwin has never implemented these system calls
670 * but picked up the fields in their system call table from their FreeBSD
671 * import. Happily, these have different names than the AUE_O* definitions
672 * in Solaris BSM.
673 */
674#define AUE_O_CREAT AUE_OPEN_RWTC /* Darwin */
675#define AUE_O_EXECVE AUE_NULL /* Darwin */
676#define AUE_O_SBREAK AUE_NULL /* Darwin */
677#define AUE_O_LSEEK AUE_NULL /* Darwin */
678#define AUE_O_MOUNT AUE_NULL /* Darwin */
679#define AUE_O_UMOUNT AUE_NULL /* Darwin */
680#define AUE_O_STAT AUE_STAT /* Darwin */
681#define AUE_O_LSTAT AUE_LSTAT /* Darwin */
682#define AUE_O_FSTAT AUE_FSTAT /* Darwin */
683#define AUE_O_GETPAGESIZE AUE_NULL /* Darwin */
684#define AUE_O_VREAD AUE_NULL /* Darwin */
685#define AUE_O_VWRITE AUE_NULL /* Darwin */
686#define AUE_O_MMAP AUE_MMAP /* Darwin */
687#define AUE_O_VADVISE AUE_NULL /* Darwin */
688#define AUE_O_VHANGUP AUE_NULL /* Darwin */
689#define AUE_O_VLIMIT AUE_NULL /* Darwin */
690#define AUE_O_WAIT AUE_NULL /* Darwin */
691#define AUE_O_GETHOSTNAME AUE_NULL /* Darwin */
692#define AUE_O_SETHOSTNAME AUE_SYSCTL /* Darwin */
693#define AUE_O_GETDOPT AUE_NULL /* Darwin */
694#define AUE_O_SETDOPT AUE_NULL /* Darwin */
695#define AUE_O_ACCEPT AUE_NULL /* Darwin */
696#define AUE_O_SEND AUE_SENDMSG /* Darwin */
697#define AUE_O_RECV AUE_RECVMSG /* Darwin */
698#define AUE_O_VTIMES AUE_NULL /* Darwin */
699#define AUE_O_SIGVEC AUE_NULL /* Darwin */
700#define AUE_O_SIGBLOCK AUE_NULL /* Darwin */
701#define AUE_O_SIGSETMASK AUE_NULL /* Darwin */
702#define AUE_O_SIGSTACK AUE_NULL /* Darwin */
703#define AUE_O_RECVMSG AUE_RECVMSG /* Darwin */
704#define AUE_O_SENDMSG AUE_SENDMSG /* Darwin */
705#define AUE_O_VTRACE AUE_NULL /* Darwin */
706#define AUE_O_RESUBA AUE_NULL /* Darwin */
707#define AUE_O_RECVFROM AUE_RECVFROM /* Darwin */
708#define AUE_O_SETREUID AUE_SETREUID /* Darwin */
709#define AUE_O_SETREGID AUE_SETREGID /* Darwin */
710#define AUE_O_GETDIRENTRIES AUE_GETDIRENTRIES /* Darwin */
711#define AUE_O_TRUNCATE AUE_TRUNCATE /* Darwin */
712#define AUE_O_FTRUNCATE AUE_FTRUNCATE /* Darwin */
713#define AUE_O_GETPEERNAME AUE_NULL /* Darwin */
714#define AUE_O_GETHOSTID AUE_NULL /* Darwin */
715#define AUE_O_SETHOSTID AUE_NULL /* Darwin */
716#define AUE_O_GETRLIMIT AUE_NULL /* Darwin */
717#define AUE_O_SETRLIMIT AUE_SETRLIMIT /* Darwin */
718#define AUE_O_KILLPG AUE_KILL /* Darwin */
719#define AUE_O_SETQUOTA AUE_NULL /* Darwin */
720#define AUE_O_QUOTA AUE_NULL /* Darwin */
721#define AUE_O_GETSOCKNAME AUE_NULL /* Darwin */
722#define AUE_O_GETDIREENTRIES AUE_GETDIREENTRIES /* Darwin */
723#define AUE_O_ASYNCDAEMON AUE_NULL /* Darwin */
724#define AUE_O_GETDOMAINNAME AUE_NULL /* Darwin */
725#define AUE_O_SETDOMAINNAME AUE_SYSCTL /* Darwin */
726#define AUE_O_PCFS_MOUNT AUE_NULL /* Darwin */
727#define AUE_O_EXPORTFS AUE_NULL /* Darwin */
728#define AUE_O_USTATE AUE_NULL /* Darwin */
729#define AUE_O_WAIT3 AUE_NULL /* Darwin */
730#define AUE_O_RPAUSE AUE_NULL /* Darwin */
731#define AUE_O_GETDENTS AUE_NULL /* Darwin */
732
733/*
734 * Possible desired future values based on review of BSD/Darwin system calls.
735 */
736#define AUE_ATGETMSG AUE_NULL
737#define AUE_ATPUTMSG AUE_NULL
738#define AUE_ATSOCKET AUE_NULL
739#define AUE_ATPGETREQ AUE_NULL
740#define AUE_ATPGETRSP AUE_NULL
741#define AUE_ATPSNDREQ AUE_NULL
742#define AUE_ATPSNDRSP AUE_NULL
743#define AUE_BSDTHREADCREATE AUE_NULL
744#define AUE_BSDTHREADTERMINATE AUE_NULL
745#define AUE_BSDTHREADREGISTER AUE_NULL
746#define AUE_CHUD AUE_NULL
747#define AUE_CSOPS AUE_NULL
748#define AUE_DUP AUE_NULL
749#define AUE_FDATASYNC AUE_NULL
750#define AUE_FGETATTRLIST AUE_NULL
751#define AUE_FGETXATTR AUE_NULL
752#define AUE_FLISTXATTR AUE_NULL
753#define AUE_FREMOVEXATTR AUE_NULL
754#define AUE_FSETATTRLIST AUE_NULL
755#define AUE_FSETXATTR AUE_NULL
756#define AUE_FSTATFS64 AUE_NULL
757#define AUE_FSTATV AUE_NULL
758#define AUE_FSTAT64 AUE_NULL
759#define AUE_FSTAT64_EXTENDED AUE_NULL
760#define AUE_GCCONTROL AUE_NULL
761#define AUE_GETDIRENTRIES64 AUE_NULL
762#define AUE_GETDTABLESIZE AUE_NULL
763#define AUE_GETEGID AUE_NULL
764#define AUE_GETEUID AUE_NULL
765#define AUE_GETFSSTAT64 AUE_NULL
766#define AUE_GETGID AUE_NULL
767#define AUE_GETGROUPS AUE_NULL
768#define AUE_GETITIMER AUE_NULL
769#define AUE_GETLOGIN AUE_NULL
770#define AUE_GETPEERNAME AUE_NULL
771#define AUE_GETPGID AUE_NULL
772#define AUE_GETPGRP AUE_NULL
773#define AUE_GETPID AUE_NULL
774#define AUE_GETPPID AUE_NULL
775#define AUE_GETPRIORITY AUE_NULL
776#define AUE_GETRLIMIT AUE_NULL
777#define AUE_GETRUSAGE AUE_NULL
778#define AUE_GETSGROUPS AUE_NULL
779#define AUE_GETSID AUE_NULL
780#define AUE_GETSOCKNAME AUE_NULL
781#define AUE_GETTIMEOFDAY AUE_NULL
782#define AUE_GETTID AUE_NULL
783#define AUE_GETUID AUE_NULL
784#define AUE_GETSOCKOPT AUE_NULL
785#define AUE_GETWGROUPS AUE_NULL
786#define AUE_GETXATTR AUE_NULL
787#define AUE_IDENTITYSVC AUE_NULL
788#define AUE_INITGROUPS AUE_NULL
789#define AUE_IOPOLICYSYS AUE_NULL
790#define AUE_ISSETUGID AUE_NULL
791#define AUE_LIOLISTIO AUE_NULL
792#define AUE_LISTXATTR AUE_NULL
793#define AUE_LSTATV AUE_NULL
794#define AUE_LSTAT64 AUE_NULL
795#define AUE_LSTAT64_EXTENDED AUE_NULL
796#define AUE_MADVISE AUE_NULL
797#define AUE_MINCORE AUE_NULL
798#define AUE_MKCOMPLEX AUE_NULL
799#define AUE_MODWATCH AUE_NULL
800#define AUE_MSGCL AUE_NULL
801#define AUE_MSYNC AUE_NULL
802#define AUE_PROCINFO AUE_NULL
803#define AUE_PTHREADCANCELED AUE_NULL
804#define AUE_PTHREADCHDIR AUE_NULL
805#define AUE_PTHREADCONDBROADCAST AUE_NULL
806#define AUE_PTHREADCONDDESTORY AUE_NULL
807#define AUE_PTHREADCONDINIT AUE_NULL
808#define AUE_PTHREADCONDSIGNAL AUE_NULL
809#define AUE_PTHREADCONDWAIT AUE_NULL
810#define AUE_PTHREADFCHDIR AUE_NULL
811#define AUE_PTHREADMARK AUE_NULL
812#define AUE_PTHREADMUTEXDESTROY AUE_NULL
813#define AUE_PTHREADMUTEXINIT AUE_NULL
814#define AUE_PTHREADMUTEXTRYLOCK AUE_NULL
815#define AUE_PTHREADMUTEXUNLOCK AUE_NULL
816#define AUE_REMOVEXATTR AUE_NULL
817#define AUE_SBRK AUE_NULL
818#define AUE_SELECT AUE_NULL
819#define AUE_SEMWAITSIGNAL AUE_NULL
820#define AUE_SETITIMER AUE_NULL
821#define AUE_SETSGROUPS AUE_NULL
822#define AUE_SETTID AUE_NULL
823#define AUE_SETTIDWITHPID AUE_NULL
824#define AUE_SETWGROUPS AUE_NULL
825#define AUE_SETXATTR AUE_NULL
826#define AUE_SHAREDREGIONCHECK AUE_NULL
827#define AUE_SHAREDREGIONMAP AUE_NULL
828#define AUE_SIGACTION AUE_NULL
829#define AUE_SIGALTSTACK AUE_NULL
830#define AUE_SIGPENDING AUE_NULL
831#define AUE_SIGPROCMASK AUE_NULL
832#define AUE_SIGRETURN AUE_NULL
833#define AUE_SIGSUSPEND AUE_NULL
834#define AUE_SIGWAIT AUE_NULL
835#define AUE_SSTK AUE_NULL
836#define AUE_STACKSNAPSHOT AUE_NULL
837#define AUE_STATFS64 AUE_NULL
838#define AUE_STATV AUE_NULL
839#define AUE_STAT64 AUE_NULL
840#define AUE_STAT64_EXTENDED AUE_NULL
841#define AUE_SYNC AUE_NULL
842#define AUE_SYSCALL AUE_NULL
843#define AUE_TABLE AUE_NULL
844#define AUE_VMPRESSUREMONITOR AUE_NULL
845#define AUE_WAITEVENT AUE_NULL
846#define AUE_WAITID AUE_NULL
847#define AUE_WATCHEVENT AUE_NULL
848#define AUE_WORKQOPEN AUE_NULL
849#define AUE_WORKQOPS AUE_NULL
850
851#endif /* !_BSM_AUDIT_KEVENTS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_record.h deleted-311
......@@ -1,311 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2005-2009 Apple Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _BSM_AUDIT_RECORD_H_
33#define _BSM_AUDIT_RECORD_H_
34
35#include <sys/types.h>
36#include <sys/time.h> /* struct timeval */
37
38/*
39 * Token type identifiers.
40 */
41#define AUT_INVALID 0x00
42#define AUT_OTHER_FILE32 0x11
43#define AUT_OHEADER 0x12
44#define AUT_TRAILER 0x13
45#define AUT_HEADER32 0x14
46#define AUT_HEADER32_EX 0x15
47#define AUT_DATA 0x21
48#define AUT_IPC 0x22
49#define AUT_PATH 0x23
50#define AUT_SUBJECT32 0x24
51#define AUT_XATPATH 0x25
52#define AUT_PROCESS32 0x26
53#define AUT_RETURN32 0x27
54#define AUT_TEXT 0x28
55#define AUT_OPAQUE 0x29
56#define AUT_IN_ADDR 0x2a
57#define AUT_IP 0x2b
58#define AUT_IPORT 0x2c
59#define AUT_ARG32 0x2d
60#define AUT_SOCKET 0x2e
61#define AUT_SEQ 0x2f
62#define AUT_ACL 0x30
63#define AUT_ATTR 0x31
64#define AUT_IPC_PERM 0x32
65#define AUT_LABEL 0x33
66#define AUT_GROUPS 0x34
67#define AUT_ACE 0x35
68#define AUT_PRIV 0x38
69#define AUT_UPRIV 0x39
70#define AUT_LIAISON 0x3a
71#define AUT_NEWGROUPS 0x3b
72#define AUT_EXEC_ARGS 0x3c
73#define AUT_EXEC_ENV 0x3d
74#define AUT_ATTR32 0x3e
75#define AUT_UNAUTH 0x3f
76#define AUT_XATOM 0x40
77#define AUT_XOBJ 0x41
78#define AUT_XPROTO 0x42
79#define AUT_XSELECT 0x43
80#define AUT_XCOLORMAP 0x44
81#define AUT_XCURSOR 0x45
82#define AUT_XFONT 0x46
83#define AUT_XGC 0x47
84#define AUT_XPIXMAP 0x48
85#define AUT_XPROPERTY 0x49
86#define AUT_XWINDOW 0x4a
87#define AUT_XCLIENT 0x4b
88#define AUT_CMD 0x51
89#define AUT_EXIT 0x52
90#define AUT_ZONENAME 0x60
91#define AUT_HOST 0x70
92#define AUT_ARG64 0x71
93#define AUT_RETURN64 0x72
94#define AUT_ATTR64 0x73
95#define AUT_HEADER64 0x74
96#define AUT_SUBJECT64 0x75
97#define AUT_PROCESS64 0x77
98#define AUT_OTHER_FILE64 0x78
99#define AUT_HEADER64_EX 0x79
100#define AUT_SUBJECT32_EX 0x7a
101#define AUT_PROCESS32_EX 0x7b
102#define AUT_SUBJECT64_EX 0x7c
103#define AUT_PROCESS64_EX 0x7d
104#define AUT_IN_ADDR_EX 0x7e
105#define AUT_SOCKET_EX 0x7f
106
107/*
108 * Pre-64-bit BSM, 32-bit tokens weren't explicitly named as '32'. We have
109 * compatibility defines.
110 */
111#define AUT_HEADER AUT_HEADER32
112#define AUT_ARG AUT_ARG32
113#define AUT_RETURN AUT_RETURN32
114#define AUT_SUBJECT AUT_SUBJECT32
115#define AUT_PROCESS AUT_PROCESS32
116#define AUT_OTHER_FILE AUT_OTHER_FILE32
117
118/*
119 * The values for the following token ids are not defined by BSM.
120 *
121 * XXXRW: Not sure how to handle these in OpenBSM yet, but I'll give them
122 * names more consistent with Sun's BSM. These originally came from Apple's
123 * BSM.
124 */
125#define AUT_SOCKINET32 0x80 /* XXX */
126#define AUT_SOCKINET128 0x81 /* XXX */
127#define AUT_SOCKUNIX 0x82 /* XXX */
128
129#define AUT_RIGHTS 0x83
130
131/* print values for the arbitrary token */
132#define AUP_BINARY 0
133#define AUP_OCTAL 1
134#define AUP_DECIMAL 2
135#define AUP_HEX 3
136#define AUP_STRING 4
137
138/* data-types for the arbitrary token */
139#define AUR_BYTE 0
140#define AUR_CHAR AUR_BYTE
141#define AUR_SHORT 1
142#define AUR_INT32 2
143#define AUR_INT AUR_INT32
144#define AUR_INT64 3
145
146/* ... and their sizes */
147#define AUR_BYTE_SIZE sizeof(u_char)
148#define AUR_CHAR_SIZE AUR_BYTE_SIZE
149#define AUR_SHORT_SIZE sizeof(uint16_t)
150#define AUR_INT32_SIZE sizeof(uint32_t)
151#define AUR_INT_SIZE AUR_INT32_SIZE
152#define AUR_INT64_SIZE sizeof(uint64_t)
153
154/* Modifiers for the header token */
155#define PAD_NOTATTR 0x4000 /* nonattributable event */
156#define PAD_FAILURE 0x8000 /* fail audit event */
157
158#define AUDIT_MAX_GROUPS 16
159
160/*
161 * A number of BSM versions are floating around and defined. Here are
162 * constants for them. OpenBSM uses the same token types, etc, used in the
163 * Solaris BSM version, but has a separate version number in order to
164 * identify a potentially different event identifier name space.
165 */
166#define AUDIT_HEADER_VERSION_OLDDARWIN 1 /* In retrospect, a mistake. */
167#define AUDIT_HEADER_VERSION_SOLARIS 2
168#define AUDIT_HEADER_VERSION_TSOL25 3
169#define AUDIT_HEADER_VERSION_TSOL 4
170#define AUDIT_HEADER_VERSION_OPENBSM10 10
171#define AUDIT_HEADER_VERSION_OPENBSM11 11
172#define AUDIT_HEADER_VERSION_OPENBSM AUDIT_HEADER_VERSION_OPENBSM11
173
174#define AUT_TRAILER_MAGIC 0xb105
175
176/* BSM library calls */
177
178__BEGIN_DECLS
179
180struct in_addr;
181struct in6_addr;
182struct ip;
183struct ipc_perm;
184struct kevent;
185struct sockaddr;
186struct sockaddr_in;
187struct sockaddr_in6;
188struct sockaddr_un;
189#if defined(_KERNEL) || defined(KERNEL)
190struct vnode_au_info;
191#endif
192
193#ifndef _CAP_RIGHTS_T_DECLARED
194#define _CAP_RIGHTS_T_DECLARED
195struct cap_rights;
196
197typedef struct cap_rights cap_rights_t;
198#endif
199
200int au_open(void);
201int au_write(int d, token_t *m);
202int au_close(int d, int keep, short event);
203int au_close_buffer(int d, short event, u_char *buffer, size_t *buflen);
204int au_close_token(token_t *tok, u_char *buffer, size_t *buflen);
205
206token_t *au_to_file(const char *file, struct timeval tm);
207
208token_t *au_to_header32_tm(int rec_size, au_event_t e_type, au_emod_t e_mod,
209 struct timeval tm);
210token_t *au_to_header32_ex_tm(int rec_size, au_event_t e_type, au_emod_t e_mod,
211 struct timeval tm, struct auditinfo_addr *aia);
212token_t *au_to_header64_tm(int rec_size, au_event_t e_type, au_emod_t e_mod,
213 struct timeval tm);
214#if !defined(KERNEL) && !defined(_KERNEL)
215token_t *au_to_header(int rec_size, au_event_t e_type, au_emod_t e_mod);
216token_t *au_to_header_ex(int rec_size, au_event_t e_type, au_emod_t e_mod);
217token_t *au_to_header32(int rec_size, au_event_t e_type, au_emod_t e_mod);
218token_t *au_to_header64(int rec_size, au_event_t e_type, au_emod_t e_mod);
219token_t *au_to_header32_ex(int rec_size, au_event_t e_type, au_emod_t e_mod);
220#endif
221
222token_t *au_to_me(void);
223token_t *au_to_arg(char n, const char *text, uint32_t v);
224token_t *au_to_arg32(char n, const char *text, uint32_t v);
225token_t *au_to_arg64(char n, const char *text, uint64_t v);
226
227#if defined(_KERNEL) || defined(KERNEL)
228token_t *au_to_attr(struct vnode_au_info *vni);
229token_t *au_to_attr32(struct vnode_au_info *vni);
230token_t *au_to_attr64(struct vnode_au_info *vni);
231#endif
232
233token_t *au_to_data(char unit_print, char unit_type, char unit_count,
234 const char *p);
235token_t *au_to_exit(int retval, int err);
236token_t *au_to_groups(int *groups);
237token_t *au_to_newgroups(uint16_t n, gid_t *groups);
238token_t *au_to_in_addr(struct in_addr *internet_addr);
239token_t *au_to_in_addr_ex(struct in6_addr *internet_addr);
240token_t *au_to_ip(struct ip *ip);
241token_t *au_to_ipc(char type, int id);
242token_t *au_to_ipc_perm(struct ipc_perm *perm);
243token_t *au_to_iport(uint16_t iport);
244token_t *au_to_opaque(const char *data, uint16_t bytes);
245token_t *au_to_path(const char *path);
246token_t *au_to_privset(char *privtypestr, char *privstr);
247token_t *au_to_process(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
248 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid);
249token_t *au_to_process32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
250 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid);
251token_t *au_to_process64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
252 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid);
253token_t *au_to_process_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
254 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid);
255token_t *au_to_process32_ex(au_id_t auid, uid_t euid, gid_t egid,
256 uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid,
257 au_tid_addr_t *tid);
258token_t *au_to_process64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
259 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid);
260token_t *au_to_rights(cap_rights_t *rightsp);
261token_t *au_to_return(char status, uint32_t ret);
262token_t *au_to_return32(char status, uint32_t ret);
263token_t *au_to_return64(char status, uint64_t ret);
264token_t *au_to_seq(long audit_count);
265token_t *au_to_socket_ex(u_short so_domain, u_short so_type,
266 struct sockaddr *sa_local, struct sockaddr *sa_remote);
267token_t *au_to_sock_inet(struct sockaddr_in *so);
268token_t *au_to_sock_inet32(struct sockaddr_in *so);
269token_t *au_to_sock_inet128(struct sockaddr_in6 *so);
270token_t *au_to_sock_unix(struct sockaddr_un *so);
271token_t *au_to_subject(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
272 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid);
273token_t *au_to_subject32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
274 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid);
275token_t *au_to_subject64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
276 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid);
277token_t *au_to_subject_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
278 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid);
279token_t *au_to_subject32_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
280 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid);
281token_t *au_to_subject64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
282 gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid);
283#if defined(_KERNEL) || defined(KERNEL)
284token_t *au_to_exec_args(char *args, int argc);
285token_t *au_to_exec_env(char *envs, int envc);
286#else
287token_t *au_to_exec_args(char **argv);
288token_t *au_to_exec_env(char **envp);
289#endif
290token_t *au_to_text(const char *text);
291token_t *au_to_kevent(struct kevent *kev);
292token_t *au_to_trailer(int rec_size);
293token_t *au_to_upriv(char sorf, char *priv);
294token_t *au_to_zonename(const char *zonename);
295
296/*
297 * BSM library routines for converting between local and BSM constant spaces.
298 */
299int au_bsm_to_domain(u_short bsm_domain, int *local_domainp);
300int au_bsm_to_errno(u_char bsm_error, int *errorp);
301int au_bsm_to_fcntl_cmd(u_short bsm_fcntl_cmd, int *local_fcntl_cmdp);
302int au_bsm_to_socket_type(u_short bsm_socket_type,
303 int *local_socket_typep);
304u_short au_domain_to_bsm(int local_domain);
305u_char au_errno_to_bsm(int local_errno);
306u_short au_fcntl_cmd_to_bsm(int local_fcntl_command);
307u_short au_socket_type_to_bsm(int local_socket_type);
308
309__END_DECLS
310
311#endif /* ! _BSM_AUDIT_RECORD_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/bsm/audit_socket_type.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2008 Apple Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _BSM_AUDIT_SOCKET_TYPE_H_
33#define _BSM_AUDIT_SOCKET_TYPE_H_
34
35/*
36 * BSM socket type constants.
37 */
38#define BSM_SOCK_DGRAM 1
39#define BSM_SOCK_STREAM 2
40#define BSM_SOCK_RAW 4
41#define BSM_SOCK_RDM 5
42#define BSM_SOCK_SEQPACKET 6
43
44#define BSM_SOCK_UNKNOWN 500
45
46#endif /* !_BSM_AUDIT_SOCKET_TYPE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/cam/cam.h+6-1
......@@ -35,9 +35,9 @@
3535#include "opt_cam.h"
3636#endif
3737
38#include <sys/cdefs.h>
3938#ifndef _KERNEL
4039#include <stdbool.h>
40#include <stdio.h>
4141#endif
4242
4343typedef u_int path_id_t;
......@@ -350,6 +350,11 @@ typedef enum {
350350 CAM_EAF_PRINT_RESULT = 0x20
351351} cam_error_ata_flags;
352352
353typedef enum {
354 CAM_ENF_PRINT_NONE = 0x00,
355 CAM_ENF_PRINT_STATUS = 0x10,
356} cam_error_nvme_flags;
357
353358typedef enum {
354359 CAM_STRVIS_FLAG_NONE = 0x00,
355360 CAM_STRVIS_FLAG_NONASCII_MASK = 0x03,
lib/libc/include/generic-freebsd/cam/cam_ccb.h+39-2
......@@ -32,7 +32,6 @@
3232#define _CAM_CAM_CCB_H 1
3333
3434#include <sys/queue.h>
35#include <sys/cdefs.h>
3635#include <sys/time.h>
3736#include <sys/limits.h>
3837#ifndef _KERNEL
......@@ -298,15 +297,18 @@ typedef enum {
298297 XPORT_SRP, /* SCSI RDMA Protocol */
299298 XPORT_NVME, /* NVMe over PCIe */
300299 XPORT_MMCSD, /* MMC, SD, SDIO card */
300 XPORT_NVMF, /* NVMe over Fabrics */
301 XPORT_UFSHCI, /* Universal Flash Storage Host Interface */
301302} cam_xport;
302303
303#define XPORT_IS_NVME(t) ((t) == XPORT_NVME)
304#define XPORT_IS_NVME(t) ((t) == XPORT_NVME || (t) == XPORT_NVMF)
304305#define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA)
305306#define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \
306307 (t) != XPORT_UNSPECIFIED && \
307308 !XPORT_IS_ATA(t) && !XPORT_IS_NVME(t))
308309#define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \
309310 XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \
311 XPORT_IS_NVME(t) ? DEVSTAT_TYPE_IF_NVME : \
310312 DEVSTAT_TYPE_IF_OTHER)
311313
312314#define PROTO_VERSION_UNKNOWN (UINT_MAX - 1)
......@@ -653,6 +655,12 @@ struct ccb_pathinq_settings_nvme {
653655_Static_assert(sizeof(struct ccb_pathinq_settings_nvme) == 64,
654656 "ccb_pathinq_settings_nvme too big");
655657
658struct ccb_pathinq_settings_nvmf {
659 uint32_t nsid; /* Namespace ID for this path */
660 uint8_t trtype;
661 char dev_name[NVME_DEV_NAME_LEN]; /* nvme controller dev name for this device */
662};
663
656664#define PATHINQ_SETTINGS_SIZE 128
657665
658666struct ccb_pathinq {
......@@ -684,6 +692,7 @@ struct ccb_pathinq {
684692 struct ccb_pathinq_settings_fc fc;
685693 struct ccb_pathinq_settings_sas sas;
686694 struct ccb_pathinq_settings_nvme nvme;
695 struct ccb_pathinq_settings_nvmf nvmf;
687696 char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];
688697 } xport_specific;
689698 u_int maxio; /* Max supported I/O size, in bytes. */
......@@ -1050,6 +1059,31 @@ struct ccb_trans_settings_nvme
10501059 uint8_t max_speed; /* PCIe generation for each lane */
10511060};
10521061
1062struct ccb_trans_settings_nvmf
1063{
1064 u_int valid; /* Which fields to honor */
1065#define CTS_NVMF_VALID_TRTYPE 0x01
1066 uint8_t trtype;
1067};
1068
1069struct ccb_trans_settings_ufshci
1070{
1071 u_int valid; /* Which fields to honor */
1072 /*
1073 * Ensure the validity of the information for the Unipro link
1074 * (GEAR, SPEED, LANE)
1075 */
1076#define CTS_UFSHCI_VALID_LINK 0x01
1077 uint32_t speed;
1078 uint8_t hs_gear; /* High Speed Gear (G1, G2, G3...) */
1079 uint8_t tx_lanes;
1080 uint8_t rx_lanes;
1081 uint8_t max_hs_gear; /* Maximum HS Gear */
1082 uint8_t max_tx_lanes;
1083 uint8_t max_rx_lanes;
1084};
1085
1086
10531087#include <cam/mmc/mmc_bus.h>
10541088struct ccb_trans_settings_mmc {
10551089 struct mmc_ios ios;
......@@ -1122,6 +1156,8 @@ struct ccb_trans_settings {
11221156 struct ccb_trans_settings_pata ata;
11231157 struct ccb_trans_settings_sata sata;
11241158 struct ccb_trans_settings_nvme nvme;
1159 struct ccb_trans_settings_nvmf nvmf;
1160 struct ccb_trans_settings_ufshci ufshci;
11251161 } xport_specific;
11261162};
11271163
......@@ -1488,6 +1524,7 @@ cam_fill_mmcio(struct ccb_mmcio *mmcio, uint32_t retries,
14881524 mmcio->cmd.opcode = mmc_opcode;
14891525 mmcio->cmd.arg = mmc_arg;
14901526 mmcio->cmd.flags = mmc_flags;
1527 mmcio->cmd.error = 0;
14911528 mmcio->stop.opcode = 0;
14921529 mmcio->stop.arg = 0;
14931530 mmcio->stop.flags = 0;
lib/libc/include/generic-freebsd/cam/cam_debug.h+28-39
......@@ -81,57 +81,46 @@ extern uint32_t cam_dflags;
8181/* Printf delay value (to prevent scrolling) */
8282extern uint32_t cam_debug_delay;
8383
84/* Debugging macros. */
85#define CAM_DEBUGGED(path, flag) \
86 (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
87 && (cam_dpath != NULL) \
88 && (xpt_path_comp(cam_dpath, path) >= 0) \
89 && (xpt_path_comp(cam_dpath, path) < 2))
90
91#define CAM_DEBUG(path, flag, printfargs) \
92 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
93 && (cam_dpath != NULL) \
94 && (xpt_path_comp(cam_dpath, path) >= 0) \
95 && (xpt_path_comp(cam_dpath, path) < 2)) { \
96 xpt_print_path(path); \
97 printf printfargs; \
98 if (cam_debug_delay != 0) \
99 DELAY(cam_debug_delay); \
100 }
84/* Helper routines -- helps conserve stack */
85struct cam_ed;
86void xpt_cam_path_debug(struct cam_path *path, const char *fmt, ...);
87void xpt_cam_dev_debug(struct cam_ed *dev, const char *fmt, ...);
88void xpt_cam_debug(const char *fmt, ...);
10189
102#define CAM_DEBUG_DEV(dev, flag, printfargs) \
103 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
104 && (cam_dpath != NULL) \
105 && (xpt_path_comp_dev(cam_dpath, dev) >= 0) \
106 && (xpt_path_comp_dev(cam_dpath, dev) < 2)) { \
107 xpt_print_device(dev); \
108 printf printfargs; \
109 if (cam_debug_delay != 0) \
110 DELAY(cam_debug_delay); \
90/* Stupid macro to remove a layer of parens */
91#define _CAM_X(...) __VA_ARGS__
92
93/* Debugging macros. */
94#define CAM_DEBUGGED(path, flag) \
95 (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
96 && (cam_dpath != NULL) \
97 && (xpt_path_comp(cam_dpath, (path)) >= 0) \
98 && (xpt_path_comp(cam_dpath, (path)) < 2))
99
100#define CAM_DEBUG(path, flag, printfargs) \
101 if (CAM_DEBUGGED(path, flag)) { \
102 xpt_cam_path_debug(path, _CAM_X printfargs); \
111103 }
112104
113#define CAM_DEBUG_PRINT(flag, printfargs) \
114 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
115 printf("cam_debug: "); \
116 printf printfargs; \
117 if (cam_debug_delay != 0) \
118 DELAY(cam_debug_delay); \
105#define CAM_DEBUG_DEV(dev, flag, printfargs) \
106 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
107 && (cam_dpath != NULL) \
108 && (xpt_path_comp_dev(cam_dpath, (dev)) >= 0) \
109 && (xpt_path_comp_dev(cam_dpath, (dev)) < 2)) { \
110 xpt_cam_dev_debug(dev, _CAM_X printfargs); \
119111 }
120112
121#define CAM_DEBUG_PATH_PRINT(flag, path, printfargs) \
122 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
123 xpt_print(path, "cam_debug: "); \
124 printf printfargs; \
125 if (cam_debug_delay != 0) \
126 DELAY(cam_debug_delay); \
113#define CAM_DEBUG_PRINT(flag, printfargs) \
114 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
115 xpt_cam_debug(_CAM_X printfargs); \
127116 }
128117
129118#else /* !_KERNEL */
130119
131120#define CAM_DEBUGGED(A, B) 0
132121#define CAM_DEBUG(A, B, C)
122#define CAM_DEBUG_DEV(A, B, C)
133123#define CAM_DEBUG_PRINT(A, B)
134#define CAM_DEBUG_PATH_PRINT(A, B, C)
135124
136125#endif /* _KERNEL */
137126
lib/libc/include/generic-freebsd/cam/cam_iosched.h+3-1
......@@ -79,8 +79,10 @@ cam_iosched_sbintime_t(uintptr_t delta)
7979}
8080
8181typedef void (*cam_iosched_latfcn_t)(void *, sbintime_t, struct bio *);
82typedef void (*cam_iosched_schedule_t)(struct cam_periph *periph);
8283
83int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph);
84int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph,
85 const struct disk *dp, cam_iosched_schedule_t schedfnp);
8486void cam_iosched_fini(struct cam_iosched_softc *);
8587void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *);
8688struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc);
lib/libc/include/generic-freebsd/cam/cam_sim.h-9
......@@ -60,15 +60,6 @@ struct cam_sim * cam_sim_alloc(sim_action_func sim_action,
6060 int max_dev_transactions,
6161 int max_tagged_dev_transactions,
6262 struct cam_devq *queue);
63struct cam_sim * cam_sim_alloc_dev(sim_action_func sim_action,
64 sim_poll_func sim_poll,
65 const char *sim_name,
66 void *softc,
67 device_t dev,
68 struct mtx *mtx,
69 int max_dev_transactions,
70 int max_tagged_dev_transactions,
71 struct cam_devq *queue);
7263void cam_sim_free(struct cam_sim *sim, int free_devq);
7364void cam_sim_hold(struct cam_sim *sim);
7465void cam_sim_release(struct cam_sim *sim);
lib/libc/include/generic-freebsd/cam/cam_xpt.h+17-7
......@@ -33,16 +33,15 @@
3333#define _CAM_CAM_XPT_H 1
3434
3535#ifdef _KERNEL
36#include <sys/cdefs.h>
3736#include <cam/cam_ccb.h>
3837#endif
38#include <sys/sbuf.h>
3939
4040/* Forward Declarations */
4141union ccb;
4242struct cam_periph;
4343struct cam_ed;
4444struct cam_sim;
45struct sbuf;
4645
4746/*
4847 * Definition of a CAM path. Paths are created from bus, target, and lun ids
......@@ -113,7 +112,6 @@ struct cam_sim *xpt_path_sim(struct cam_path *path);
113112struct cam_periph *xpt_path_periph(struct cam_path *path);
114113device_t xpt_path_sim_device(const struct cam_path *path);
115114void xpt_print_path(struct cam_path *path);
116void xpt_print_device(struct cam_ed *device);
117115void xpt_print(struct cam_path *path, const char *fmt, ...);
118116void xpt_async(uint32_t async_code, struct cam_path *path,
119117 void *async_arg);
......@@ -147,19 +145,31 @@ uint32_t xpt_poll_setup(union ccb *start_ccb);
147145void xpt_sim_poll(struct cam_sim *sim);
148146
149147/*
150 * Perform a path inquiry at the request priority. The bzero may be
151 * unnecessary.
148 * Perform a path inquiry. bzero may be redundant for allocated CCBs, but for
149 * the on-stack CCBs it's required.
152150 */
153151static inline void
154152xpt_path_inq(struct ccb_pathinq *cpi, struct cam_path *path)
155153{
156
157154 bzero(cpi, sizeof(*cpi));
158 xpt_setup_ccb(&cpi->ccb_h, path, CAM_PRIORITY_NORMAL);
155 xpt_setup_ccb(&cpi->ccb_h, path, CAM_PRIORITY_NONE);
159156 cpi->ccb_h.func_code = XPT_PATH_INQ;
160157 xpt_action((union ccb *)cpi);
161158}
162159
160/*
161 * Perform get device type. bzero may be redundant for allocated CCBs, but for
162 * the on-stack CCBs it's required.
163 */
164static inline void
165xpt_gdev_type(struct ccb_getdev *cgd, struct cam_path *path)
166{
167 bzero(cgd, sizeof(*cgd));
168 xpt_setup_ccb(&cgd->ccb_h, path, CAM_PRIORITY_NONE);
169 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
170 xpt_action((union ccb *)cgd);
171}
172
163173#endif /* _KERNEL */
164174
165175#endif /* _CAM_CAM_XPT_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/cam/nvme/nvme_all.h+2-2
......@@ -42,10 +42,10 @@ struct sbuf;
4242void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *);
4343void nvme_print_ident_short(const struct nvme_controller_data *,
4444 const struct nvme_namespace_data *, struct sbuf *);
45const char *nvme_op_string(const struct nvme_command *, int admin);
46const char *nvme_cmd_string(const struct nvme_command *, char *, size_t);
4745void nvme_cmd_sbuf(const struct nvme_command *, struct sbuf *sb);
4846int nvme_command_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb);
47const char *nvme_command_string(struct ccb_nvmeio *nvmeio, char *, size_t);
48int nvme_status_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb);
4949const void *nvme_get_identify_cntrl(struct cam_periph *);
5050const void *nvme_get_identify_ns(struct cam_periph *);
5151
lib/libc/include/generic-freebsd/cam/scsi/scsi_all.h+8-15
......@@ -1,18 +1,12 @@
1/*-
2 * Largely written by Julian Elischer (julian@tfs.com)
3 * for TRW Financial Systems.
4 *
5 * TRW Financial Systems, in accordance with their agreement with Carnegie
6 * Mellon University, makes this software available to CMU to distribute
7 * or use in any manner that they see fit as long as this message is kept with
8 * the software. For this reason TFS also grants any other persons or
9 * organisations permission to use or modify this software.
1/*
2 * Copyright (c) 1997-2017 Kenneth D. Merry <ken@FreeBSD.org>
3 * Copyright (c) 2012-2020 Alexander Motin <mav@FreeBSD.org>
4 * Copyright (c) 1997-2011 Justin T. Gibbs <gibbs@FreeBSD.org>
105 *
11 * TFS supplies this software to be publicly redistributed
12 * on the understanding that TFS is not responsible for the correct
13 * functioning of this software in any circumstances.
6 * SPDX-License-Identifier: BSD-2-Clause
147 *
15 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
8 * Original scsi_all.h from 386BSD was by Julian Elischer at TRW Financial
9 * Services has been transformed into a new work by subsequent contributors.
1610 */
1711
1812/*
......@@ -22,10 +16,9 @@
2216#ifndef _SCSI_SCSI_ALL_H
2317#define _SCSI_SCSI_ALL_H 1
2418
25#include <sys/cdefs.h>
2619#ifdef _KERNEL
2720#include <sys/malloc.h>
28#include <machine/stdarg.h>
21#include <sys/stdarg.h>
2922#else
3023#include <stdarg.h>
3124#endif
lib/libc/include/generic-freebsd/cam/scsi/scsi_ch.h-1
......@@ -64,7 +64,6 @@
6464#ifndef _SCSI_SCSI_CH_H
6565#define _SCSI_SCSI_CH_H 1
6666
67#include <sys/cdefs.h>
6867
6968/*
7069 * SCSI command format
lib/libc/include/generic-freebsd/cam/scsi/scsi_da.h-1
......@@ -50,7 +50,6 @@
5050#ifndef _SCSI_SCSI_DA_H
5151#define _SCSI_SCSI_DA_H 1
5252
53#include <sys/cdefs.h>
5453
5554struct scsi_rezero_unit
5655{
lib/libc/include/generic-freebsd/cam/scsi/scsi_sa.h-1
......@@ -33,7 +33,6 @@
3333#ifndef _SCSI_SCSI_SA_H
3434#define _SCSI_SCSI_SA_H 1
3535
36#include <sys/cdefs.h>
3736
3837struct scsi_read_block_limits
3938{
lib/libc/include/generic-freebsd/crypto/cryptodev.h+1-1
......@@ -433,7 +433,7 @@ struct cryptop {
433433 int crp_flags;
434434
435435#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */
436#define CRYPTO_F_DONE 0x0020 /* Operation completed */
436#define CRYPTO_F_DONE 0x0020 /* Deprecated, do not use */
437437#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */
438438#define CRYPTO_F_ASYNC_ORDERED 0x0100 /* Completions must happen in order */
439439#define CRYPTO_F_IV_SEPARATE 0x0200 /* Use crp_iv[] as IV. */
lib/libc/include/generic-freebsd/ctype.h-2
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * @(#)ctype.h 8.4 (Berkeley) 1/21/94
4038 */
4139
4240#ifndef _CTYPE_H_
lib/libc/include/generic-freebsd/db.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)db.h 8.7 (Berkeley) 6/16/94
3230 */
3331
3432#ifndef _DB_H_
lib/libc/include/generic-freebsd/dev/ciss/cissreg.h+1-1
......@@ -684,7 +684,7 @@ struct ciss_bmic_id_table {
684684 u_int8_t percent_write_cache; /* Percent of memory allocated to write cache */
685685 u_int16_t daughterboard_size_mb; /* Total size (MB) of cache board */
686686 u_int8_t cache_batter_count; /* Number of cache batteries */
687 u_int16_t total_controller_mem_mb; /* Total size (MB) of atttached memory */
687 u_int16_t total_controller_mem_mb; /* Total size (MB) of attached memory */
688688 u_int8_t more_controller_flags; /* Additional controller flags byte */
689689 u_int8_t x_board_host_i2c_rev; /* 2nd byte of 3 byte autorev field */
690690 u_int8_t battery_pic_rev; /* BBWC PIC revision */
lib/libc/include/generic-freebsd/dev/ciss/cissvar.h+2-1
......@@ -184,7 +184,7 @@ struct ciss_softc
184184{
185185 /* bus connections */
186186 device_t ciss_dev; /* bus attachment */
187 struct cdev *ciss_dev_t; /* control device */
187 struct cdev *ciss_dev_t; /* control device */
188188
189189 struct resource *ciss_regs_resource; /* register interface window */
190190 int ciss_regs_rid; /* resource ID */
......@@ -236,6 +236,7 @@ struct ciss_softc
236236 int ciss_max_bus_number; /* maximum bus number */
237237 int ciss_max_logical_bus;
238238 int ciss_max_physical_bus;
239 int ciss_max_physical_target; /* highest physical target number */
239240
240241 struct cam_devq *ciss_cam_devq;
241242 struct cam_sim **ciss_cam_sim;
lib/libc/include/generic-freebsd/dev/firewire/firewirereg.h+1-1
......@@ -293,7 +293,7 @@ extern int firewire_debug;
293293extern devclass_t firewire_devclass;
294294extern int firewire_phydma_enable;
295295
296#define FWPRI ((PZERO + 8) | PCATCH)
296#define FWPRI (PWAIT | PCATCH)
297297
298298#define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */)
299299
lib/libc/include/generic-freebsd/dev/hid/hid.h+20-16
......@@ -57,6 +57,7 @@
5757#define HUP_SCALE 0x008c
5858#define HUP_CAMERA_CONTROL 0x0090
5959#define HUP_ARCADE 0x0091
60#define HUP_FIDO 0xf1d0
6061#define HUP_MICROSOFT 0xff00
6162
6263/* Usages, generic desktop */
......@@ -161,6 +162,9 @@
161162#define HUC_HEADPHONE 0x0005
162163#define HUC_AC_PAN 0x0238
163164
165/* Usages, FIDO */
166#define HUF_U2FHID 0x0001
167
164168#define HID_USAGE2(p,u) (((p) << 16) | (u))
165169#define HID_GET_USAGE(u) ((u) & 0xffff)
166170#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff)
......@@ -233,31 +237,31 @@ struct hid_location {
233237
234238struct hid_item {
235239 /* Global */
236 int32_t _usage_page;
240 uint32_t _usage_page;
237241 int32_t logical_minimum;
238242 int32_t logical_maximum;
239243 int32_t physical_minimum;
240244 int32_t physical_maximum;
241 int32_t unit_exponent;
242 int32_t unit;
243 int32_t report_ID;
245 uint32_t unit_exponent;
246 uint32_t unit;
247 uint32_t report_ID;
244248 /* Local */
245249 int nusages;
246250 union {
247 int32_t usage;
248 int32_t usages[HID_ITEM_MAXUSAGE];
251 uint32_t usage;
252 uint32_t usages[HID_ITEM_MAXUSAGE];
249253 };
250 int32_t usage_minimum;
251 int32_t usage_maximum;
252 int32_t designator_index;
253 int32_t designator_minimum;
254 int32_t designator_maximum;
255 int32_t string_index;
256 int32_t string_minimum;
257 int32_t string_maximum;
258 int32_t set_delimiter;
254 uint32_t usage_minimum;
255 uint32_t usage_maximum;
256 uint32_t designator_index;
257 uint32_t designator_minimum;
258 uint32_t designator_maximum;
259 uint32_t string_index;
260 uint32_t string_minimum;
261 uint32_t string_maximum;
262 uint32_t set_delimiter;
259263 /* Misc */
260 int32_t collection;
264 uint32_t collection;
261265 int collevel;
262266 enum hid_kind kind;
263267 uint32_t flags;
lib/libc/include/generic-freebsd/dev/hid/hidraw.h+4
......@@ -92,5 +92,9 @@ struct hidraw_devinfo {
9292#define HIDIOCSFEATURE(len) _IOC(IOC_IN, 'U', 35, len)
9393#define HIDIOCGFEATURE(len) _IOC(IOC_INOUT, 'U', 36, len)
9494#define HIDIOCGRAWUNIQ(len) _IOC(IOC_OUT, 'U', 37, len)
95#define HIDIOCSINPUT(len) _IOC(IOC_IN, 'U', 38, len)
96#define HIDIOCGINPUT(len) _IOC(IOC_INOUT, 'U', 39, len)
97#define HIDIOCSOUTPUT(len) _IOC(IOC_IN, 'U', 40, len)
98#define HIDIOCGOUTPUT(len) _IOC(IOC_INOUT, 'U', 41, len)
9599
96100#endif /* _HID_HIDRAW_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_amd.h+1-1
......@@ -31,7 +31,7 @@
3131#ifndef _DEV_HWPMC_AMD_H_
3232#define _DEV_HWPMC_AMD_H_ 1
3333
34/* AMD K7 and K8 PMCs */
34/* AMD K8 PMCs */
3535
3636#define AMD_PMC_EVSEL_0 0xC0010000
3737#define AMD_PMC_EVSEL_1 0xC0010001
lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_arm64.h+1-1
......@@ -42,7 +42,7 @@
4242#ifdef _KERNEL
4343/* MD extension for 'struct pmc' */
4444struct pmc_md_arm64_pmc {
45 uint32_t pm_arm64_evsel;
45 uint64_t pm_arm64_evsel;
4646};
4747#endif /* _KERNEL */
4848#endif /* _DEV_HWPMC_ARMV8_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_core.h-2
......@@ -198,11 +198,9 @@ int pmc_core_initialize(struct pmc_mdep *_md, int _maxcpu,
198198void pmc_core_finalize(struct pmc_mdep *_md);
199199
200200int pmc_iaf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width);
201void pmc_iaf_finalize(struct pmc_mdep *_md);
202201
203202int pmc_iap_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width,
204203 int _flags);
205void pmc_iap_finalize(struct pmc_mdep *_md);
206204
207205#endif /* _KERNEL */
208206#endif /* _DEV_HWPMC_CORE_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/hwpmc/pmc_events.h+1-36
......@@ -62,39 +62,6 @@ __PMC_EV_ALIAS("cycles", TSC_TSC)
6262#define PMC_EV_SOFT_FIRST 0x20000
6363#define PMC_EV_SOFT_LAST (PMC_EV_SOFT_FIRST + PMC_EV_DYN_COUNT - 1)
6464
65/*
66 * AMD K7 Events, from "The AMD Athlon(tm) Processor x86 Code
67 * Optimization Guide" [Doc#22007K, Feb 2002]
68 */
69
70#define __PMC_EV_K7() \
71__PMC_EV(K7, DC_ACCESSES) \
72__PMC_EV(K7, DC_MISSES) \
73__PMC_EV(K7, DC_REFILLS_FROM_L2) \
74__PMC_EV(K7, DC_REFILLS_FROM_SYSTEM) \
75__PMC_EV(K7, DC_WRITEBACKS) \
76__PMC_EV(K7, L1_DTLB_MISS_AND_L2_DTLB_HITS) \
77__PMC_EV(K7, L1_AND_L2_DTLB_MISSES) \
78__PMC_EV(K7, MISALIGNED_REFERENCES) \
79__PMC_EV(K7, IC_FETCHES) \
80__PMC_EV(K7, IC_MISSES) \
81__PMC_EV(K7, L1_ITLB_MISSES) \
82__PMC_EV(K7, L1_L2_ITLB_MISSES) \
83__PMC_EV(K7, RETIRED_INSTRUCTIONS) \
84__PMC_EV(K7, RETIRED_OPS) \
85__PMC_EV(K7, RETIRED_BRANCHES) \
86__PMC_EV(K7, RETIRED_BRANCHES_MISPREDICTED) \
87__PMC_EV(K7, RETIRED_TAKEN_BRANCHES) \
88__PMC_EV(K7, RETIRED_TAKEN_BRANCHES_MISPREDICTED) \
89__PMC_EV(K7, RETIRED_FAR_CONTROL_TRANSFERS) \
90__PMC_EV(K7, RETIRED_RESYNC_BRANCHES) \
91__PMC_EV(K7, INTERRUPTS_MASKED_CYCLES) \
92__PMC_EV(K7, INTERRUPTS_MASKED_WHILE_PENDING_CYCLES) \
93__PMC_EV(K7, HARDWARE_INTERRUPTS)
94
95#define PMC_EV_K7_FIRST PMC_EV_K7_DC_ACCESSES
96#define PMC_EV_K7_LAST PMC_EV_K7_HARDWARE_INTERRUPTS
97
9865/* AMD K8 PMCs */
9966
10067#define __PMC_EV_K8() \
......@@ -2431,7 +2398,7 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF)
24312398 * START #EVENTS DESCRIPTION
24322399 * 0 0x1000 Reserved
24332400 * 0x1000 0x0001 TSC
2434 * 0x2000 0x0080 AMD K7 events
2401 * 0x2000 0x0080 free (was AMD K7 events)
24352402 * 0x2080 0x0100 AMD K8 events
24362403 * 0x10000 0x0080 INTEL architectural fixed-function events
24372404 * 0x10080 0x0F80 free (was INTEL architectural programmable events)
......@@ -2457,8 +2424,6 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF)
24572424#define __PMC_EVENTS() \
24582425 __PMC_EV_BLOCK(TSC, 0x01000) \
24592426 __PMC_EV_TSC() \
2460 __PMC_EV_BLOCK(K7, 0x02000) \
2461 __PMC_EV_K7() \
24622427 __PMC_EV_BLOCK(K8, 0x02080) \
24632428 __PMC_EV_K8() \
24642429 __PMC_EV_BLOCK(IAF, 0x10000) \
lib/libc/include/generic-freebsd/dev/ic/nec765.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)nec765.h 7.1 (Berkeley) 5/9/91
3230 */
3331
3432/*
lib/libc/include/generic-freebsd/dev/ic/ns16550.h-5
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)ns16550.h 7.1 (Berkeley) 5/9/91
3230 */
3331
3432/*
......@@ -162,9 +160,6 @@
162160#define FIFO_XMT_RST FCR_XMT_RST
163161#define FCR_DMA 0x08
164162#define FIFO_DMA_MODE FCR_DMA
165#ifdef CPU_XBURST
166#define FCR_UART_ON 0x10
167#endif
168163#define FCR_RX_LOW 0x00
169164#define FIFO_RX_LOW FCR_RX_LOW
170165#define FCR_RX_MEDL 0x40
lib/libc/include/generic-freebsd/dev/iicbus/iiconf.h+1-1
......@@ -32,7 +32,7 @@
3232#include <dev/iicbus/iic.h>
3333
3434
35#define IICPRI (PZERO+8) /* XXX sleep/wakeup queue priority */
35#define IICPRI (PWAIT) /* XXX sleep/wakeup queue priority */
3636
3737#define LSB 0x1
3838
lib/libc/include/generic-freebsd/dev/mfi/mfireg.h+1-1
......@@ -1028,7 +1028,7 @@ struct mfi_evt_detail {
10281028 } pd_prog;
10291029
10301030 struct {
1031 struct mfi_evt_pd ld;
1031 struct mfi_evt_pd pd;
10321032 uint32_t prev_state;
10331033 uint32_t new_state;
10341034 } pd_state;
lib/libc/include/generic-freebsd/dev/mmc/bridge.h+5
......@@ -103,6 +103,10 @@ enum mmc_chip_select {
103103 cs_dontcare = 0, cs_high, cs_low
104104};
105105
106enum mmc_bus_type {
107 bus_type_default = 0, bus_type_spi
108};
109
106110enum mmc_bus_width {
107111 bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3
108112};
......@@ -123,6 +127,7 @@ struct mmc_ios {
123127 uint32_t clock; /* Speed of the clock in Hz to move data */
124128 enum mmc_vdd vdd; /* Voltage to apply to the power pins */
125129 enum mmc_vccq vccq; /* Voltage to use for signaling */
130 enum mmc_bus_type bus_type;
126131 enum mmc_bus_mode bus_mode;
127132 enum mmc_chip_select chip_select;
128133 enum mmc_bus_width bus_width;
lib/libc/include/generic-freebsd/dev/mmc/mmc_fdt_helpers.h+1-1
......@@ -31,7 +31,7 @@
3131#include <dev/gpio/gpiobusvar.h>
3232#include <dev/ofw/ofw_bus.h>
3333
34#include <dev/extres/regulator/regulator.h>
34#include <dev/regulator/regulator.h>
3535
3636#include <dev/mmc/mmc_helpers.h>
3737
lib/libc/include/generic-freebsd/dev/mmc/mmc_helpers.h+1-1
......@@ -30,7 +30,7 @@
3030
3131#include <dev/gpio/gpiobusvar.h>
3232
33#include <dev/extres/regulator/regulator.h>
33#include <dev/regulator/regulator.h>
3434
3535struct mmc_helper {
3636 device_t dev;
lib/libc/include/generic-freebsd/dev/mmc/mmcbrvar.h+12
......@@ -60,6 +60,7 @@
6060#include "mmcbr_if.h"
6161
6262enum mmcbr_device_ivars {
63 MMCBR_IVAR_BUS_TYPE,
6364 MMCBR_IVAR_BUS_MODE,
6465 MMCBR_IVAR_BUS_WIDTH,
6566 MMCBR_IVAR_CHIP_SELECT,
......@@ -113,6 +114,17 @@ mmcbr_get_retune_req(device_t dev)
113114 return ((int)v);
114115}
115116
117static int __inline
118mmcbr_get_bus_type(device_t dev)
119{
120 uintptr_t v;
121
122 if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev,
123 MMCBR_IVAR_BUS_TYPE, &v) != 0))
124 return (bus_type_default);
125 return ((int)v);
126}
127
116128/*
117129 * Convenience wrappers for the mmcbr interface
118130 */
lib/libc/include/generic-freebsd/dev/mmc/mmcreg.h+1
......@@ -80,6 +80,7 @@ struct mmc_command {
8080#define MMC_CMD_BC (2ul << 5) /* Broadcast command, no response */
8181#define MMC_CMD_BCR (3ul << 5) /* Broadcast command with response */
8282#define MMC_CMD_MASK (3ul << 5)
83#define MMC_CMD_IS_APP (1ul << 7) /* Next cmd after MMC_APP_CMD */
8384
8485/* Possible response types defined in the standard: */
8586#define MMC_RSP_NONE (0)
lib/libc/include/generic-freebsd/dev/nvme/nvme.h+80-7
......@@ -35,15 +35,23 @@
3535
3636#include <sys/param.h>
3737#include <sys/endian.h>
38#ifndef _KERNEL
39#include <stdbool.h>
40#endif
41
42struct sbuf;
3843
3944#define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command)
4045#define NVME_RESET_CONTROLLER _IO('n', 1)
4146#define NVME_GET_NSID _IOR('n', 2, struct nvme_get_nsid)
4247#define NVME_GET_MAX_XFER_SIZE _IOR('n', 3, uint64_t)
48#define NVME_GET_CONTROLLER_DATA _IOR('n', 4, struct nvme_controller_data)
4349
4450#define NVME_IO_TEST _IOWR('n', 100, struct nvme_io_test)
4551#define NVME_BIO_TEST _IOWR('n', 101, struct nvme_io_test)
4652
53/* NB: Fabrics-specific ioctls defined in nvmf.h start at 200. */
54
4755/*
4856 * Macros to deal with NVME revisions, as defined VS register
4957 */
......@@ -211,6 +219,11 @@
211219
212220/* Command field definitions */
213221
222enum nvme_fuse {
223 NVME_FUSE_NORMAL = 0x0,
224 NVME_FUSE_FIRST = 0x1,
225 NVME_FUSE_SECOND = 0x2
226};
214227#define NVME_CMD_FUSE_SHIFT (0)
215228#define NVME_CMD_FUSE_MASK (0x3)
216229
......@@ -390,9 +403,24 @@ enum nvme_psdt {
390403/* per namespace smart/health log page */
391404#define NVME_CTRLR_DATA_LPA_NS_SMART_SHIFT (0)
392405#define NVME_CTRLR_DATA_LPA_NS_SMART_MASK (0x1)
406/* Commands Supported and Effects log page */
407#define NVME_CTRLR_DATA_LPA_CMD_EFFECTS_SHIFT (1)
408#define NVME_CTRLR_DATA_LPA_CMD_EFFECTS_MASK (0x1)
393409/* extended data for Get Log Page command */
394410#define NVME_CTRLR_DATA_LPA_EXT_DATA_SHIFT (2)
395411#define NVME_CTRLR_DATA_LPA_EXT_DATA_MASK (0x1)
412/* telemetry */
413#define NVME_CTRLR_DATA_LPA_TELEMETRY_SHIFT (3)
414#define NVME_CTRLR_DATA_LPA_TELEMETRY_MASK (0x1)
415/* persistent event */
416#define NVME_CTRLR_DATA_LPA_PERSISTENT_EVENT_SHIFT (4)
417#define NVME_CTRLR_DATA_LPA_PERSISTENT_EVENT_MASK (0x1)
418/* Supported log pages, etc */
419#define NVME_CTRLR_DATA_LPA_LOG_PAGES_PAGE_SHIFT (5)
420#define NVME_CTRLR_DATA_LPA_LOG_PAGES_PAGE_MASK (0x1)
421/* Data Area 4 for Telemetry */
422#define NVME_CTRLR_DATA_LPA_DA4_TELEMETRY_SHIFT (6)
423#define NVME_CTRLR_DATA_LPA_DA4_TELEMETRY_MASK (0x1)
396424
397425/** AVSCC - admin vendor specific command configuration */
398426/* admin vendor specific commands use spec format */
......@@ -623,10 +651,19 @@ enum nvme_critical_warning_state {
623651 NVME_CRIT_WARN_ST_DEVICE_RELIABILITY = 0x4,
624652 NVME_CRIT_WARN_ST_READ_ONLY = 0x8,
625653 NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP = 0x10,
654 NVME_CRIT_WARN_ST_PERSISTENT_MEMORY_REGION = 0x20,
626655};
627#define NVME_CRIT_WARN_ST_RESERVED_MASK (0xE0)
628#define NVME_ASYNC_EVENT_NS_ATTRIBUTE (0x100)
629#define NVME_ASYNC_EVENT_FW_ACTIVATE (0x200)
656#define NVME_CRIT_WARN_ST_RESERVED_MASK (0xC0)
657#define NVME_ASYNC_EVENT_NS_ATTRIBUTE (1U << 8)
658#define NVME_ASYNC_EVENT_FW_ACTIVATE (1U << 9)
659#define NVME_ASYNC_EVENT_TELEMETRY_LOG (1U << 10)
660#define NVME_ASYNC_EVENT_ASYM_NS_ACC (1U << 11)
661#define NVME_ASYNC_EVENT_PRED_LAT_DELTA (1U << 12)
662#define NVME_ASYNC_EVENT_LBA_STATUS (1U << 13)
663#define NVME_ASYNC_EVENT_ENDURANCE_DELTA (1U << 14)
664#define NVME_ASYNC_EVENT_NVM_SHUTDOWN (1U << 15)
665#define NVME_ASYNC_EVENT_ZONE_DELTA (1U << 27)
666#define NVME_ASYNC_EVENT_DISCOVERY_DELTA (1U << 31)
630667
631668/* slot for current FW */
632669#define NVME_FIRMWARE_PAGE_AFI_SLOT_SHIFT (0)
......@@ -809,7 +846,7 @@ struct nvme_command {
809846 uint32_t cdw13; /* command-specific */
810847 uint32_t cdw14; /* command-specific */
811848 uint32_t cdw15; /* command-specific */
812};
849} __aligned(8);
813850
814851_Static_assert(sizeof(struct nvme_command) == 16 * 4, "bad size for nvme_command");
815852
......@@ -1578,7 +1615,7 @@ struct nvme_health_information_page {
15781615 uint32_t ttftmt2;
15791616
15801617 uint8_t reserved2[280];
1581} __packed __aligned(4);
1618} __packed __aligned(8);
15821619
15831620_Static_assert(sizeof(struct nvme_health_information_page) == 512, "bad size for nvme_health_information_page");
15841621
......@@ -1629,6 +1666,30 @@ struct nvme_device_self_test_page {
16291666_Static_assert(sizeof(struct nvme_device_self_test_page) == 564,
16301667 "bad size for nvme_device_self_test_page");
16311668
1669/*
1670 * Header structure for both host initiated telemetry (page 7) and controller
1671 * initiated telemetry (page 8).
1672 */
1673struct nvme_telemetry_log_page {
1674 uint8_t identifier;
1675 uint8_t rsvd[4];
1676 uint8_t oui[3];
1677 uint16_t da1_last;
1678 uint16_t da2_last;
1679 uint16_t da3_last;
1680 uint8_t rsvd2[2];
1681 uint32_t da4_last;
1682 uint8_t rsvd3[361];
1683 uint8_t hi_gen;
1684 uint8_t ci_avail;
1685 uint8_t ci_gen;
1686 uint8_t reason[128];
1687 /* Blocks of telemetry data follow */
1688} __packed __aligned(4);
1689
1690_Static_assert(sizeof(struct nvme_telemetry_log_page) == 512,
1691 "bad size for nvme_telemetry_log");
1692
16321693struct nvme_discovery_log_entry {
16331694 uint8_t trtype;
16341695 uint8_t adrfam;
......@@ -1845,6 +1906,9 @@ struct nvme_hmb_desc {
18451906#define nvme_completion_is_error(cpl) \
18461907 (NVME_STATUS_GET_SC((cpl)->status) != 0 || NVME_STATUS_GET_SCT((cpl)->status) != 0)
18471908
1909void nvme_cpl_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf);
1910void nvme_opcode_sbuf(bool admin, uint8_t opc, struct sbuf *sb);
1911void nvme_sc_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf);
18481912void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen);
18491913
18501914#ifdef _KERNEL
......@@ -1855,6 +1919,7 @@ struct thread;
18551919struct nvme_namespace;
18561920struct nvme_controller;
18571921struct nvme_consumer;
1922struct nvme_passthru_cmd;
18581923
18591924typedef void (*nvme_cb_fn_t)(void *, const struct nvme_completion *);
18601925
......@@ -1865,8 +1930,11 @@ typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *,
18651930typedef void (*nvme_cons_fail_fn_t)(void *);
18661931
18671932enum nvme_namespace_flags {
1868 NVME_NS_DEALLOCATE_SUPPORTED = 0x1,
1869 NVME_NS_FLUSH_SUPPORTED = 0x2,
1933 NVME_NS_DEALLOCATE_SUPPORTED = 0x01,
1934 NVME_NS_FLUSH_SUPPORTED = 0x02,
1935 NVME_NS_ADDED = 0x04,
1936 NVME_NS_CHANGED = 0x08,
1937 NVME_NS_GONE = 0x10,
18701938};
18711939
18721940int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
......@@ -1874,6 +1942,11 @@ int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
18741942 uint32_t nsid, int is_user_buffer,
18751943 int is_admin_cmd);
18761944
1945int nvme_ctrlr_linux_passthru_cmd(struct nvme_controller *ctrlr,
1946 struct nvme_passthru_cmd *npc,
1947 uint32_t nsid, bool is_user,
1948 bool is_admin);
1949
18771950/* Admin functions */
18781951void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr,
18791952 uint8_t feature, uint32_t cdw11,
lib/libc/include/generic-freebsd/dev/nvmf/nvmf.h created+132
......@@ -0,0 +1,132 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2022-2024 Chelsio Communications, Inc.
5 * Written by: John Baldwin <jhb@FreeBSD.org>
6 */
7
8#ifndef __NVMF_H__
9#define __NVMF_H__
10
11#include <sys/ioccom.h>
12#ifndef _KERNEL
13#include <stdbool.h>
14#endif
15
16/*
17 * Default settings in Fabrics controllers. These match values used by the
18 * Linux target.
19 */
20#define NVMF_MAX_IO_ENTRIES (1024)
21#define NVMF_CC_EN_TIMEOUT (15) /* In 500ms units */
22
23/* Allows for a 16k data buffer + SQE */
24#define NVMF_IOCCSZ (sizeof(struct nvme_command) + 16 * 1024)
25#define NVMF_IORCSZ (sizeof(struct nvme_completion))
26
27#define NVMF_NN (1024)
28
29/*
30 * Default timeouts for Fabrics hosts. These match values used by
31 * Linux.
32 */
33#define NVMF_DEFAULT_RECONNECT_DELAY 10
34#define NVMF_DEFAULT_CONTROLLER_LOSS 600
35
36/*
37 * (data, size) is the userspace buffer for a packed nvlist.
38 *
39 * For requests that copyout an nvlist, len is the amount of data
40 * copied out to *data. If size is zero, no data is copied and len is
41 * set to the required buffer size.
42 */
43struct nvmf_ioc_nv {
44 void *data;
45 size_t len;
46 size_t size;
47};
48
49/*
50 * The fields in a qpair handoff nvlist are:
51 *
52 * Transport independent:
53 *
54 * bool admin
55 * bool sq_flow_control
56 * number qsize
57 * number sqhd
58 * number sqtail host only
59 *
60 * TCP transport:
61 *
62 * number fd
63 * number rxpda
64 * number txpda
65 * bool header_digests
66 * bool data_digests
67 * number maxr2t
68 * number maxh2cdata
69 * number max_icd
70 */
71
72/*
73 * The fields in the nvlist for NVMF_HANDOFF_HOST and
74 * NVMF_RECONNECT_HOST are:
75 *
76 * number trtype
77 * number kato (optional)
78 * number reconnect_delay (optional)
79 * number controller_loss_timeout (optional)
80 * qpair handoff nvlist admin
81 * qpair handoff nvlist array io
82 * binary cdata struct nvme_controller_data
83 * NVMF_RECONNECT_PARAMS nvlist rparams
84 */
85
86/*
87 * The fields in the nvlist for NVMF_RECONNECT_PARAMS are:
88 *
89 * binary dle struct nvme_discovery_log_entry
90 * string hostnqn
91 * number num_io_queues
92 * number kato (optional)
93 * number reconnect_delay (optional)
94 * number controller_loss_timeout (optional)
95 * number io_qsize
96 * bool sq_flow_control
97 *
98 * TCP transport:
99 *
100 * bool header_digests
101 * bool data_digests
102 */
103
104/*
105 * The fields in the nvlist for NVMF_CONNECTION_STATUS are:
106 *
107 * bool connected
108 * timespec nvlist last_disconnect
109 * number tv_sec
110 * number tv_nsec
111 */
112
113/*
114 * The fields in the nvlist for handing off a controller qpair are:
115 *
116 * number trtype
117 * qpair handoff nvlist params
118 * binary cmd struct nvmf_fabric_connect_cmd
119 * binary data struct nvmf_fabric_connect_data
120 */
121
122/* Operations on /dev/nvmf */
123#define NVMF_HANDOFF_HOST _IOW('n', 200, struct nvmf_ioc_nv)
124#define NVMF_DISCONNECT_HOST _IOW('n', 201, const char *)
125#define NVMF_DISCONNECT_ALL _IO('n', 202)
126
127/* Operations on /dev/nvmeX */
128#define NVMF_RECONNECT_PARAMS _IOWR('n', 203, struct nvmf_ioc_nv)
129#define NVMF_RECONNECT_HOST _IOW('n', 204, struct nvmf_ioc_nv)
130#define NVMF_CONNECTION_STATUS _IOWR('n', 205, struct nvmf_ioc_nv)
131
132#endif /* !__NVMF_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/nvmf/nvmf_proto.h created+765
......@@ -0,0 +1,765 @@
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2016 Intel Corporation.
3 * All rights reserved.
4 */
5
6/* Derived from include/spdk/nvmf_spec.h from Intel's SPDK. */
7
8#ifndef __NVMF_PROTO_H__
9#define __NVMF_PROTO_H__
10
11#include <sys/types.h>
12#include <sys/cdefs.h>
13#ifdef _KERNEL
14#include <sys/stddef.h>
15#else
16#include <stddef.h>
17#endif
18#include <dev/nvme/nvme.h>
19
20/**
21 * \file
22 * NVMe over Fabrics specification definitions
23 */
24
25#define NVME_NQN_FIELD_SIZE 256
26
27struct nvmf_capsule_cmd {
28 uint8_t opcode;
29 uint8_t reserved1;
30 uint16_t cid;
31 uint8_t fctype;
32 uint8_t reserved2[35];
33 uint8_t fabric_specific[24];
34};
35_Static_assert(sizeof(struct nvmf_capsule_cmd) == 64, "Incorrect size");
36
37/* Fabric Command Set */
38enum nvmf_fabric_cmd_types {
39 NVMF_FABRIC_COMMAND_PROPERTY_SET = 0x00,
40 NVMF_FABRIC_COMMAND_CONNECT = 0x01,
41 NVMF_FABRIC_COMMAND_PROPERTY_GET = 0x04,
42 NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND = 0x05,
43 NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV = 0x06,
44 NVMF_FABRIC_COMMAND_DISCONNECT = 0x08,
45 NVMF_FABRIC_COMMAND_START_VENDOR_SPECIFIC = 0xC0,
46};
47
48enum nvmf_fabric_cmd_status_code {
49 NVMF_FABRIC_SC_INCOMPATIBLE_FORMAT = 0x80,
50 NVMF_FABRIC_SC_CONTROLLER_BUSY = 0x81,
51 NVMF_FABRIC_SC_INVALID_PARAM = 0x82,
52 NVMF_FABRIC_SC_RESTART_DISCOVERY = 0x83,
53 NVMF_FABRIC_SC_INVALID_HOST = 0x84,
54 NVMF_FABRIC_SC_INVALID_QUEUE_TYPE = 0x85,
55 NVMF_FABRIC_SC_LOG_RESTART_DISCOVERY = 0x90,
56 NVMF_FABRIC_SC_AUTH_REQUIRED = 0x91,
57};
58
59/**
60 * RDMA Queue Pair service types
61 */
62enum nvmf_rdma_qptype {
63 /** Reliable connected */
64 NVMF_RDMA_QPTYPE_RELIABLE_CONNECTED = 0x1,
65
66 /** Reliable datagram */
67 NVMF_RDMA_QPTYPE_RELIABLE_DATAGRAM = 0x2,
68};
69
70/**
71 * RDMA provider types
72 */
73enum nvmf_rdma_prtype {
74 /** No provider specified */
75 NVMF_RDMA_PRTYPE_NONE = 0x1,
76
77 /** InfiniBand */
78 NVMF_RDMA_PRTYPE_IB = 0x2,
79
80 /** RoCE v1 */
81 NVMF_RDMA_PRTYPE_ROCE = 0x3,
82
83 /** RoCE v2 */
84 NVMF_RDMA_PRTYPE_ROCE2 = 0x4,
85
86 /** iWARP */
87 NVMF_RDMA_PRTYPE_IWARP = 0x5,
88};
89
90/**
91 * RDMA connection management service types
92 */
93enum nvmf_rdma_cms {
94 /** Sockets based endpoint addressing */
95 NVMF_RDMA_CMS_RDMA_CM = 0x1,
96};
97
98/**
99 * NVMe over Fabrics transport types
100 */
101enum nvmf_trtype {
102 /** RDMA */
103 NVMF_TRTYPE_RDMA = 0x1,
104
105 /** Fibre Channel */
106 NVMF_TRTYPE_FC = 0x2,
107
108 /** TCP */
109 NVMF_TRTYPE_TCP = 0x3,
110
111 /** Intra-host transport (loopback) */
112 NVMF_TRTYPE_INTRA_HOST = 0xfe,
113};
114
115/**
116 * Address family types
117 */
118enum nvmf_adrfam {
119 /** IPv4 (AF_INET) */
120 NVMF_ADRFAM_IPV4 = 0x1,
121
122 /** IPv6 (AF_INET6) */
123 NVMF_ADRFAM_IPV6 = 0x2,
124
125 /** InfiniBand (AF_IB) */
126 NVMF_ADRFAM_IB = 0x3,
127
128 /** Fibre Channel address family */
129 NVMF_ADRFAM_FC = 0x4,
130
131 /** Intra-host transport (loopback) */
132 NVMF_ADRFAM_INTRA_HOST = 0xfe,
133};
134
135/**
136 * NVM subsystem types
137 */
138enum nvmf_subtype {
139 /** Referral to a discovery service */
140 NVMF_SUBTYPE_DISCOVERY = 0x1,
141
142 /** NVM Subsystem */
143 NVMF_SUBTYPE_NVME = 0x2,
144
145 /** Current Discovery Subsystem */
146 NVMF_SUBTYPE_DISCOVERY_CURRENT = 0x3
147};
148
149/* Discovery Log Entry Flags - Duplicate Returned Information */
150#define NVMF_DISCOVERY_LOG_EFLAGS_DUPRETINFO (1u << 0u)
151
152/* Discovery Log Entry Flags - Explicit Persistent Connection Support for Discovery */
153#define NVMF_DISCOVERY_LOG_EFLAGS_EPCSD (1u << 1u)
154
155/**
156 * Connections shall be made over a fabric secure channel
157 */
158enum nvmf_treq_secure_channel {
159 /** Not specified */
160 NVMF_TREQ_SECURE_CHANNEL_NOT_SPECIFIED = 0x0,
161
162 /** Required */
163 NVMF_TREQ_SECURE_CHANNEL_REQUIRED = 0x1,
164
165 /** Not required */
166 NVMF_TREQ_SECURE_CHANNEL_NOT_REQUIRED = 0x2,
167};
168
169struct nvmf_fabric_cmd {
170 uint8_t opcode;
171 uint8_t reserved1;
172 uint16_t cid;
173 uint8_t fctype;
174 uint8_t reserved2[59];
175} __aligned(8);
176
177struct nvmf_fabric_auth_recv_cmd {
178 uint8_t opcode;
179 uint8_t reserved1;
180 uint16_t cid;
181 uint8_t fctype; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV (0x06) */
182 uint8_t reserved2[19];
183 struct nvme_sgl_descriptor sgl1;
184 uint8_t reserved3;
185 uint8_t spsp0;
186 uint8_t spsp1;
187 uint8_t secp;
188 uint32_t al;
189 uint8_t reserved4[16];
190};
191_Static_assert(sizeof(struct nvmf_fabric_auth_recv_cmd) == 64, "Incorrect size");
192
193struct nvmf_fabric_auth_send_cmd {
194 uint8_t opcode;
195 uint8_t reserved1;
196 uint16_t cid;
197 uint8_t fctype; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND (0x05) */
198 uint8_t reserved2[19];
199 struct nvme_sgl_descriptor sgl1;
200 uint8_t reserved3;
201 uint8_t spsp0;
202 uint8_t spsp1;
203 uint8_t secp;
204 uint32_t tl;
205 uint8_t reserved4[16];
206};
207_Static_assert(sizeof(struct nvmf_fabric_auth_send_cmd) == 64, "Incorrect size");
208
209struct nvmf_fabric_connect_data {
210 uint8_t hostid[16];
211 uint16_t cntlid;
212 uint8_t reserved5[238];
213 uint8_t subnqn[NVME_NQN_FIELD_SIZE];
214 uint8_t hostnqn[NVME_NQN_FIELD_SIZE];
215 uint8_t reserved6[256];
216};
217_Static_assert(sizeof(struct nvmf_fabric_connect_data) == 1024, "Incorrect size");
218
219struct nvmf_fabric_connect_cmd {
220 uint8_t opcode;
221 uint8_t reserved1;
222 uint16_t cid;
223 uint8_t fctype;
224 uint8_t reserved2[19];
225 struct nvme_sgl_descriptor sgl1;
226 uint16_t recfmt; /* Connect Record Format */
227 uint16_t qid; /* Queue Identifier */
228 uint16_t sqsize; /* Submission Queue Size */
229 uint8_t cattr; /* queue attributes */
230 uint8_t reserved3;
231 uint32_t kato; /* keep alive timeout */
232 uint8_t reserved4[12];
233};
234_Static_assert(sizeof(struct nvmf_fabric_connect_cmd) == 64, "Incorrect size");
235
236#define NVMF_CNTLID_DYNAMIC 0xFFFF
237#define NVMF_CNTLID_STATIC_ANY 0xFFFE
238
239/*
240 * XXX: 5.3 in NVMe-over-Fabrics 1.1 gives this as an upper bound in
241 * the Discovery Log Entry.
242 */
243#define NVMF_CNTLID_STATIC_MAX 0xFFEF
244
245/* 5.21.1.15 in NVMe 1.4b */
246#define NVMF_KATO_DEFAULT (120000)
247
248#define NVMF_CONNECT_ATTR_PRIORITY_CLASS (0x3)
249#define NVMF_CONNECT_ATTR_DISABLE_SQ_FC (1u << 2)
250#define NVMF_CONNECT_ATTR_IO_QUEUE_DELETION (1u << 3)
251
252struct nvmf_fabric_connect_rsp {
253 union {
254 struct {
255 uint16_t cntlid;
256 uint16_t authreq;
257 } success;
258
259 struct {
260 uint16_t ipo;
261 uint8_t iattr;
262 uint8_t reserved;
263 } invalid;
264
265 uint32_t raw;
266 } status_code_specific;
267
268 uint32_t reserved0;
269 uint16_t sqhd;
270 uint16_t reserved1;
271 uint16_t cid;
272 uint16_t status;
273};
274_Static_assert(sizeof(struct nvmf_fabric_connect_rsp) == 16, "Incorrect size");
275
276struct nvmf_fabric_disconnect_cmd {
277 uint8_t opcode;
278 uint8_t reserved1;
279 uint16_t cid;
280 uint8_t fctype;
281 uint8_t reserved2[19];
282 struct nvme_sgl_descriptor sgl1;
283 uint16_t recfmt; /* Disconnect Record Format */
284 uint8_t reserved3[22];
285};
286_Static_assert(sizeof(struct nvmf_fabric_disconnect_cmd) == 64, "Incorrect size");
287
288#define NVMF_PROP_SIZE_4 0
289#define NVMF_PROP_SIZE_8 1
290
291#define NVMF_PROP_CAP 0x00 /* Controller Capabilities */
292#define NVMF_PROP_VS 0x08 /* Version */
293#define NVMF_PROP_CC 0x14 /* Controller Configuration */
294#define NVMF_PROP_CSTS 0x1C /* Controller Status */
295#define NVMF_PROP_NSSR 0x20 /* NVM Subsystem Reset */
296
297struct nvmf_fabric_prop_get_cmd {
298 uint8_t opcode;
299 uint8_t reserved1;
300 uint16_t cid;
301 uint8_t fctype;
302 uint8_t reserved2[35];
303 struct {
304 uint8_t size : 3;
305 uint8_t reserved : 5;
306 } attrib;
307 uint8_t reserved3[3];
308 uint32_t ofst;
309 uint8_t reserved4[16];
310};
311_Static_assert(sizeof(struct nvmf_fabric_prop_get_cmd) == 64, "Incorrect size");
312
313struct nvmf_fabric_prop_get_rsp {
314 union {
315 uint64_t u64;
316 struct {
317 uint32_t low;
318 uint32_t high;
319 } u32;
320 } value;
321
322 uint16_t sqhd;
323 uint16_t reserved0;
324 uint16_t cid;
325 uint16_t status;
326};
327_Static_assert(sizeof(struct nvmf_fabric_prop_get_rsp) == 16, "Incorrect size");
328
329struct nvmf_fabric_prop_set_cmd {
330 uint8_t opcode;
331 uint8_t reserved0;
332 uint16_t cid;
333 uint8_t fctype;
334 uint8_t reserved1[35];
335 struct {
336 uint8_t size : 3;
337 uint8_t reserved : 5;
338 } attrib;
339 uint8_t reserved2[3];
340 uint32_t ofst;
341
342 union {
343 uint64_t u64;
344 struct {
345 uint32_t low;
346 uint32_t high;
347 } u32;
348 } value;
349
350 uint8_t reserved4[8];
351};
352_Static_assert(sizeof(struct nvmf_fabric_prop_set_cmd) == 64, "Incorrect size");
353
354#define NVMF_NQN_MIN_LEN 11 /* The prefix in the spec is 11 characters */
355#define NVMF_NQN_MAX_LEN 223
356#define NVMF_NQN_UUID_PRE_LEN 32
357#define NVMF_UUID_STRING_LEN 36
358#define NVMF_NQN_UUID_PRE "nqn.2014-08.org.nvmexpress:uuid:"
359#define NVMF_DISCOVERY_NQN "nqn.2014-08.org.nvmexpress.discovery"
360
361#define NVMF_TRSTRING_MAX_LEN 32
362#define NVMF_TRADDR_MAX_LEN 256
363#define NVMF_TRSVCID_MAX_LEN 32
364
365/** RDMA transport-specific address subtype */
366struct nvmf_rdma_transport_specific_address_subtype {
367 /** RDMA QP service type (\ref nvmf_rdma_qptype) */
368 uint8_t rdma_qptype;
369
370 /** RDMA provider type (\ref nvmf_rdma_prtype) */
371 uint8_t rdma_prtype;
372
373 /** RDMA connection management service (\ref nvmf_rdma_cms) */
374 uint8_t rdma_cms;
375
376 uint8_t reserved0[5];
377
378 /** RDMA partition key for AF_IB */
379 uint16_t rdma_pkey;
380
381 uint8_t reserved2[246];
382};
383_Static_assert(sizeof(struct nvmf_rdma_transport_specific_address_subtype) == 256,
384 "Incorrect size");
385
386/** TCP Secure Socket Type */
387enum nvme_tcp_secure_socket_type {
388 /** No security */
389 NVME_TCP_SECURITY_NONE = 0,
390
391 /** TLS (Secure Sockets) version 1.2 */
392 NVME_TCP_SECURITY_TLS_1_2 = 1,
393
394 /** TLS (Secure Sockets) version 1.3 */
395 NVME_TCP_SECURITY_TLS_1_3 = 2,
396};
397
398/** TCP transport-specific address subtype */
399struct nvme_tcp_transport_specific_address_subtype {
400 /** Security type (\ref nvme_tcp_secure_socket_type) */
401 uint8_t sectype;
402
403 uint8_t reserved0[255];
404};
405_Static_assert(sizeof(struct nvme_tcp_transport_specific_address_subtype) == 256,
406 "Incorrect size");
407
408/** Transport-specific address subtype */
409union nvmf_transport_specific_address_subtype {
410 uint8_t raw[256];
411
412 /** RDMA */
413 struct nvmf_rdma_transport_specific_address_subtype rdma;
414
415 /** TCP */
416 struct nvme_tcp_transport_specific_address_subtype tcp;
417};
418_Static_assert(sizeof(union nvmf_transport_specific_address_subtype) == 256,
419 "Incorrect size");
420
421#define NVMF_MIN_ADMIN_MAX_SQ_SIZE 32
422
423/**
424 * Discovery Log Page entry
425 */
426struct nvmf_discovery_log_page_entry {
427 /** Transport type (\ref nvmf_trtype) */
428 uint8_t trtype;
429
430 /** Address family (\ref nvmf_adrfam) */
431 uint8_t adrfam;
432
433 /** Subsystem type (\ref nvmf_subtype) */
434 uint8_t subtype;
435
436 /** Transport requirements */
437 struct {
438 /** Secure channel requirements (\ref nvmf_treq_secure_channel) */
439 uint8_t secure_channel : 2;
440
441 uint8_t reserved : 6;
442 } treq;
443
444 /** NVM subsystem port ID */
445 uint16_t portid;
446
447 /** Controller ID */
448 uint16_t cntlid;
449
450 /** Admin max SQ size */
451 uint16_t asqsz;
452
453 /** Entry Flags */
454 uint16_t eflags;
455
456 uint8_t reserved0[20];
457
458 /** Transport service identifier */
459 uint8_t trsvcid[NVMF_TRSVCID_MAX_LEN];
460
461 uint8_t reserved1[192];
462
463 /** NVM subsystem qualified name */
464 uint8_t subnqn[256];
465
466 /** Transport address */
467 uint8_t traddr[NVMF_TRADDR_MAX_LEN];
468
469 /** Transport-specific address subtype */
470 union nvmf_transport_specific_address_subtype tsas;
471};
472_Static_assert(sizeof(struct nvmf_discovery_log_page_entry) == 1024, "Incorrect size");
473
474struct nvmf_discovery_log_page {
475 uint64_t genctr;
476 uint64_t numrec;
477 uint16_t recfmt;
478 uint8_t reserved0[1006];
479 struct nvmf_discovery_log_page_entry entries[0];
480};
481_Static_assert(sizeof(struct nvmf_discovery_log_page) == 1024, "Incorrect size");
482
483/* RDMA Fabric specific definitions below */
484
485#define NVME_SGL_SUBTYPE_INVALIDATE_KEY 0xF
486
487struct nvmf_rdma_request_private_data {
488 uint16_t recfmt; /* record format */
489 uint16_t qid; /* queue id */
490 uint16_t hrqsize; /* host receive queue size */
491 uint16_t hsqsize; /* host send queue size */
492 uint16_t cntlid; /* controller id */
493 uint8_t reserved[22];
494};
495_Static_assert(sizeof(struct nvmf_rdma_request_private_data) == 32, "Incorrect size");
496
497struct nvmf_rdma_accept_private_data {
498 uint16_t recfmt; /* record format */
499 uint16_t crqsize; /* controller receive queue size */
500 uint8_t reserved[28];
501};
502_Static_assert(sizeof(struct nvmf_rdma_accept_private_data) == 32, "Incorrect size");
503
504struct nvmf_rdma_reject_private_data {
505 uint16_t recfmt; /* record format */
506 uint16_t sts; /* status */
507};
508_Static_assert(sizeof(struct nvmf_rdma_reject_private_data) == 4, "Incorrect size");
509
510union nvmf_rdma_private_data {
511 struct nvmf_rdma_request_private_data pd_request;
512 struct nvmf_rdma_accept_private_data pd_accept;
513 struct nvmf_rdma_reject_private_data pd_reject;
514};
515_Static_assert(sizeof(union nvmf_rdma_private_data) == 32, "Incorrect size");
516
517enum nvmf_rdma_transport_error {
518 NVMF_RDMA_ERROR_INVALID_PRIVATE_DATA_LENGTH = 0x1,
519 NVMF_RDMA_ERROR_INVALID_RECFMT = 0x2,
520 NVMF_RDMA_ERROR_INVALID_QID = 0x3,
521 NVMF_RDMA_ERROR_INVALID_HSQSIZE = 0x4,
522 NVMF_RDMA_ERROR_INVALID_HRQSIZE = 0x5,
523 NVMF_RDMA_ERROR_NO_RESOURCES = 0x6,
524 NVMF_RDMA_ERROR_INVALID_IRD = 0x7,
525 NVMF_RDMA_ERROR_INVALID_ORD = 0x8,
526};
527
528/* TCP transport specific definitions below */
529
530/** NVMe/TCP PDU type */
531enum nvme_tcp_pdu_type {
532 /** Initialize Connection Request (ICReq) */
533 NVME_TCP_PDU_TYPE_IC_REQ = 0x00,
534
535 /** Initialize Connection Response (ICResp) */
536 NVME_TCP_PDU_TYPE_IC_RESP = 0x01,
537
538 /** Terminate Connection Request (TermReq) */
539 NVME_TCP_PDU_TYPE_H2C_TERM_REQ = 0x02,
540
541 /** Terminate Connection Response (TermResp) */
542 NVME_TCP_PDU_TYPE_C2H_TERM_REQ = 0x03,
543
544 /** Command Capsule (CapsuleCmd) */
545 NVME_TCP_PDU_TYPE_CAPSULE_CMD = 0x04,
546
547 /** Response Capsule (CapsuleRsp) */
548 NVME_TCP_PDU_TYPE_CAPSULE_RESP = 0x05,
549
550 /** Host To Controller Data (H2CData) */
551 NVME_TCP_PDU_TYPE_H2C_DATA = 0x06,
552
553 /** Controller To Host Data (C2HData) */
554 NVME_TCP_PDU_TYPE_C2H_DATA = 0x07,
555
556 /** Ready to Transfer (R2T) */
557 NVME_TCP_PDU_TYPE_R2T = 0x09,
558};
559
560/** Common NVMe/TCP PDU header */
561struct nvme_tcp_common_pdu_hdr {
562 /** PDU type (\ref nvme_tcp_pdu_type) */
563 uint8_t pdu_type;
564
565 /** pdu_type-specific flags */
566 uint8_t flags;
567
568 /** Length of PDU header (not including the Header Digest) */
569 uint8_t hlen;
570
571 /** PDU Data Offset from the start of the PDU */
572 uint8_t pdo;
573
574 /** Total number of bytes in PDU, including pdu_hdr */
575 uint32_t plen;
576};
577_Static_assert(sizeof(struct nvme_tcp_common_pdu_hdr) == 8, "Incorrect size");
578_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, pdu_type) == 0,
579 "Incorrect offset");
580_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, flags) == 1, "Incorrect offset");
581_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, hlen) == 2, "Incorrect offset");
582_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, pdo) == 3, "Incorrect offset");
583_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, plen) == 4, "Incorrect offset");
584
585#define NVME_TCP_CH_FLAGS_HDGSTF (1u << 0)
586#define NVME_TCP_CH_FLAGS_DDGSTF (1u << 1)
587
588/**
589 * ICReq
590 *
591 * common.pdu_type == NVME_TCP_PDU_TYPE_IC_REQ
592 */
593struct nvme_tcp_ic_req {
594 struct nvme_tcp_common_pdu_hdr common;
595 uint16_t pfv;
596 /** Specifies the data alignment for all PDUs transferred from the controller to the host that contain data */
597 uint8_t hpda;
598 union {
599 uint8_t raw;
600 struct {
601 uint8_t hdgst_enable : 1;
602 uint8_t ddgst_enable : 1;
603 uint8_t reserved : 6;
604 } bits;
605 } dgst;
606 uint32_t maxr2t;
607 uint8_t reserved16[112];
608};
609_Static_assert(sizeof(struct nvme_tcp_ic_req) == 128, "Incorrect size");
610_Static_assert(offsetof(struct nvme_tcp_ic_req, pfv) == 8, "Incorrect offset");
611_Static_assert(offsetof(struct nvme_tcp_ic_req, hpda) == 10, "Incorrect offset");
612_Static_assert(offsetof(struct nvme_tcp_ic_req, maxr2t) == 12, "Incorrect offset");
613
614#define NVME_TCP_HPDA_MAX 31
615#define NVME_TCP_CPDA_MAX 31
616#define NVME_TCP_PDU_PDO_MAX_OFFSET ((NVME_TCP_CPDA_MAX + 1) << 2)
617
618/**
619 * ICResp
620 *
621 * common.pdu_type == NVME_TCP_PDU_TYPE_IC_RESP
622 */
623struct nvme_tcp_ic_resp {
624 struct nvme_tcp_common_pdu_hdr common;
625 uint16_t pfv;
626 /** Specifies the data alignment for all PDUs transferred from the host to the controller that contain data */
627 uint8_t cpda;
628 union {
629 uint8_t raw;
630 struct {
631 uint8_t hdgst_enable : 1;
632 uint8_t ddgst_enable : 1;
633 uint8_t reserved : 6;
634 } bits;
635 } dgst;
636 /** Specifies the maximum number of PDU-Data bytes per H2C Data Transfer PDU */
637 uint32_t maxh2cdata;
638 uint8_t reserved16[112];
639};
640_Static_assert(sizeof(struct nvme_tcp_ic_resp) == 128, "Incorrect size");
641_Static_assert(offsetof(struct nvme_tcp_ic_resp, pfv) == 8, "Incorrect offset");
642_Static_assert(offsetof(struct nvme_tcp_ic_resp, cpda) == 10, "Incorrect offset");
643_Static_assert(offsetof(struct nvme_tcp_ic_resp, maxh2cdata) == 12, "Incorrect offset");
644
645/**
646 * TermReq
647 *
648 * common.pdu_type == NVME_TCP_PDU_TYPE_TERM_REQ
649 */
650struct nvme_tcp_term_req_hdr {
651 struct nvme_tcp_common_pdu_hdr common;
652 uint16_t fes;
653 uint8_t fei[4];
654 uint8_t reserved14[10];
655};
656
657_Static_assert(sizeof(struct nvme_tcp_term_req_hdr) == 24, "Incorrect size");
658_Static_assert(offsetof(struct nvme_tcp_term_req_hdr, fes) == 8, "Incorrect offset");
659_Static_assert(offsetof(struct nvme_tcp_term_req_hdr, fei) == 10, "Incorrect offset");
660
661enum nvme_tcp_term_req_fes {
662 NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD = 0x01,
663 NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR = 0x02,
664 NVME_TCP_TERM_REQ_FES_HDGST_ERROR = 0x03,
665 NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_OUT_OF_RANGE = 0x04,
666 NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_LIMIT_EXCEEDED = 0x05,
667 NVME_TCP_TERM_REQ_FES_R2T_LIMIT_EXCEEDED = 0x05,
668 NVME_TCP_TERM_REQ_FES_INVALID_DATA_UNSUPPORTED_PARAMETER = 0x06,
669};
670
671/* Total length of term req PDU (including PDU header and DATA) in bytes shall not exceed a limit of 152 bytes. */
672#define NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE 128
673#define NVME_TCP_TERM_REQ_PDU_MAX_SIZE (NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE + sizeof(struct nvme_tcp_term_req_hdr))
674
675/**
676 * CapsuleCmd
677 *
678 * common.pdu_type == NVME_TCP_PDU_TYPE_CAPSULE_CMD
679 */
680struct nvme_tcp_cmd {
681 struct nvme_tcp_common_pdu_hdr common;
682 struct nvme_command ccsqe;
683 /**< icdoff hdgst padding + in-capsule data + ddgst (if enabled) */
684};
685_Static_assert(sizeof(struct nvme_tcp_cmd) == 72, "Incorrect size");
686_Static_assert(offsetof(struct nvme_tcp_cmd, ccsqe) == 8, "Incorrect offset");
687
688/**
689 * CapsuleResp
690 *
691 * common.pdu_type == NVME_TCP_PDU_TYPE_CAPSULE_RESP
692 */
693struct nvme_tcp_rsp {
694 struct nvme_tcp_common_pdu_hdr common;
695 struct nvme_completion rccqe;
696};
697_Static_assert(sizeof(struct nvme_tcp_rsp) == 24, "incorrect size");
698_Static_assert(offsetof(struct nvme_tcp_rsp, rccqe) == 8, "Incorrect offset");
699
700
701/**
702 * H2CData
703 *
704 * hdr.pdu_type == NVME_TCP_PDU_TYPE_H2C_DATA
705 */
706struct nvme_tcp_h2c_data_hdr {
707 struct nvme_tcp_common_pdu_hdr common;
708 uint16_t cccid;
709 uint16_t ttag;
710 uint32_t datao;
711 uint32_t datal;
712 uint8_t reserved20[4];
713};
714_Static_assert(sizeof(struct nvme_tcp_h2c_data_hdr) == 24, "Incorrect size");
715_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, cccid) == 8, "Incorrect offset");
716_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, ttag) == 10, "Incorrect offset");
717_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, datao) == 12, "Incorrect offset");
718_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, datal) == 16, "Incorrect offset");
719
720#define NVME_TCP_H2C_DATA_FLAGS_LAST_PDU (1u << 2)
721#define NVME_TCP_H2C_DATA_FLAGS_SUCCESS (1u << 3)
722#define NVME_TCP_H2C_DATA_PDO_MULT 8u
723
724/**
725 * C2HData
726 *
727 * hdr.pdu_type == NVME_TCP_PDU_TYPE_C2H_DATA
728 */
729struct nvme_tcp_c2h_data_hdr {
730 struct nvme_tcp_common_pdu_hdr common;
731 uint16_t cccid;
732 uint8_t reserved10[2];
733 uint32_t datao;
734 uint32_t datal;
735 uint8_t reserved20[4];
736};
737_Static_assert(sizeof(struct nvme_tcp_c2h_data_hdr) == 24, "Incorrect size");
738_Static_assert(offsetof(struct nvme_tcp_c2h_data_hdr, cccid) == 8, "Incorrect offset");
739_Static_assert(offsetof(struct nvme_tcp_c2h_data_hdr, datao) == 12, "Incorrect offset");
740_Static_assert(offsetof(struct nvme_tcp_c2h_data_hdr, datal) == 16, "Incorrect offset");
741
742#define NVME_TCP_C2H_DATA_FLAGS_SUCCESS (1u << 3)
743#define NVME_TCP_C2H_DATA_FLAGS_LAST_PDU (1u << 2)
744#define NVME_TCP_C2H_DATA_PDO_MULT 8u
745
746/**
747 * R2T
748 *
749 * common.pdu_type == NVME_TCP_PDU_TYPE_R2T
750 */
751struct nvme_tcp_r2t_hdr {
752 struct nvme_tcp_common_pdu_hdr common;
753 uint16_t cccid;
754 uint16_t ttag;
755 uint32_t r2to;
756 uint32_t r2tl;
757 uint8_t reserved20[4];
758};
759_Static_assert(sizeof(struct nvme_tcp_r2t_hdr) == 24, "Incorrect size");
760_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, cccid) == 8, "Incorrect offset");
761_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, ttag) == 10, "Incorrect offset");
762_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, r2to) == 12, "Incorrect offset");
763_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, r2tl) == 16, "Incorrect offset");
764
765#endif /* __NVMF_PROTO_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/ofw/ofw_cpu.h+1-1
......@@ -30,6 +30,6 @@
3030#define _DEV_OFW_OFW_CPU_H_
3131
3232typedef bool (*ofw_cpu_foreach_cb)(u_int, phandle_t, u_int, pcell_t *);
33int ofw_cpu_early_foreach(ofw_cpu_foreach_cb, boolean_t);
33int ofw_cpu_early_foreach(ofw_cpu_foreach_cb, bool);
3434
3535#endif /* _DEV_OFW_OFW_CPU_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/ofw/openfirm.h+3-2
......@@ -83,8 +83,8 @@ MALLOC_DECLARE(M_OFWPROP);
8383 * interface as the Open Firmware access mechanism, OF_init initializes it.
8484 */
8585
86boolean_t OF_install(char *name, int prio);
87int OF_init(void *cookie);
86bool OF_install(char *name, int prio);
87int OF_init(void *cookie);
8888
8989/*
9090 * Known Open Firmware interface names
......@@ -149,6 +149,7 @@ phandle_t OF_xref_from_node(phandle_t node);
149149device_t OF_device_from_xref(phandle_t xref);
150150phandle_t OF_xref_from_device(device_t dev);
151151int OF_device_register_xref(phandle_t xref, device_t dev);
152void OF_device_unregister_xref(phandle_t xref, device_t dev);
152153
153154/* Device I/O functions */
154155ihandle_t OF_open(const char *path);
lib/libc/include/generic-freebsd/dev/ofw/openfirmio.h-2
......@@ -33,8 +33,6 @@
3333 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3434 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3535 * SUCH DAMAGE.
36 *
37 * @(#)openpromio.h 8.1 (Berkeley) 6/11/93
3836 */
3937
4038#ifndef _DEV_OFW_OPENFIRMIO_H_
lib/libc/include/generic-freebsd/dev/pci/pcireg.h+3
......@@ -616,6 +616,8 @@
616616#define PCIM_MSICTRL_MMC_16 0x0008
617617#define PCIM_MSICTRL_MMC_32 0x000A
618618#define PCIM_MSICTRL_MSI_ENABLE 0x0001
619#define PCI_MSI_MSGNUM(ctrl) \
620 (1 << (((ctrl) & PCIM_MSICTRL_MMC_MASK) >> 1))
619621#define PCIR_MSI_ADDR 0x4
620622#define PCIR_MSI_ADDR_HIGH 0x8
621623#define PCIR_MSI_DATA 0x8
......@@ -965,6 +967,7 @@
965967#define PCIM_MSIXCTRL_MSIX_ENABLE 0x8000
966968#define PCIM_MSIXCTRL_FUNCTION_MASK 0x4000
967969#define PCIM_MSIXCTRL_TABLE_SIZE 0x07FF
970#define PCI_MSIX_MSGNUM(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1)
968971#define PCIR_MSIX_TABLE 0x4
969972#define PCIR_MSIX_PBA 0x8
970973#define PCIM_MSIX_BIR_MASK 0x7
lib/libc/include/generic-freebsd/dev/powermac_nvram/powermac_nvramvar.h deleted-82
......@@ -1,82 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2006 Maxim Sobolev <sobomax@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_
30#define _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_
31
32#define NVRAM_SIZE 0x2000
33
34#define CORE99_SIGNATURE 0x5a
35
36#define SM_FLASH_CMD_ERASE_CONFIRM 0xd0
37#define SM_FLASH_CMD_ERASE_SETUP 0x20
38#define SM_FLASH_CMD_RESET 0xff
39#define SM_FLASH_CMD_WRITE_SETUP 0x40
40#define SM_FLASH_CMD_CLEAR_STATUS 0x50
41#define SM_FLASH_CMD_READ_STATUS 0x70
42
43#define SM_FLASH_STATUS_DONE 0x80
44#define SM_FLASH_STATUS_ERR 0x38
45
46#ifdef _KERNEL
47
48struct powermac_nvram_softc {
49 device_t sc_dev;
50 struct sx sc_lock;
51 phandle_t sc_node;
52 void * sc_bank;
53 void * sc_bank0;
54 void * sc_bank1;
55 uint8_t sc_data[NVRAM_SIZE];
56
57 struct cdev * sc_cdev;
58 int sc_type;
59#define FLASH_TYPE_SM 0
60#define FLASH_TYPE_AMD 1
61 int sc_isopen;
62 int sc_rpos;
63 int sc_wpos;
64};
65
66#endif /* _KERNEL */
67
68struct chrp_header {
69 uint8_t signature;
70 uint8_t chrp_checksum;
71 uint16_t length;
72 char name[12];
73};
74
75struct core99_header {
76 struct chrp_header chrp_header;
77 uint32_t adler_checksum;
78 uint32_t generation;
79 uint32_t reserved[2];
80};
81
82#endif /* _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dev/ppbus/lpt.h-1
......@@ -32,7 +32,6 @@
3232 * SUCH DAMAGE.
3333 *
3434 * Distantly from :
35 * @(#)lptreg.h 1.1 (Berkeley) 12/19/90
3635 * Id: lptreg.h,v 1.6 1997/02/22 09:36:52 peter Exp
3736 * From Id: nlpt.h,v 1.3 1999/01/10 12:04:54 nsouch Exp
3837 */
lib/libc/include/generic-freebsd/dev/ppbus/ppbconf.h+1-1
......@@ -63,7 +63,7 @@
6363/*
6464 * Parallel Port Bus sleep/wakeup queue.
6565 */
66#define PPBPRI (PZERO+8)
66#define PPBPRI (PWAIT)
6767
6868/*
6969 * Parallel Port Chipset mode masks.
lib/libc/include/generic-freebsd/dev/smbus/smbconf.h+1-1
......@@ -30,7 +30,7 @@
3030
3131#include <sys/queue.h>
3232
33#define SMBPRI (PZERO+8) /* XXX sleep/wakeup queue priority */
33#define SMBPRI (PWAIT) /* XXX sleep/wakeup queue priority */
3434
3535#define n(flags) (~(flags) & (flags))
3636
lib/libc/include/generic-freebsd/dev/usb/usb.h+1-1
......@@ -114,7 +114,7 @@ MALLOC_DECLARE(M_USBDEV);
114114/* Allow for marginal and non-conforming devices. */
115115#define USB_PORT_RESET_DELAY 50 /* ms */
116116#define USB_PORT_ROOT_RESET_DELAY 200 /* ms */
117#define USB_PORT_RESET_RECOVERY 10 /* ms */
117#define USB_PORT_RESET_RECOVERY 20 /* ms */
118118#define USB_PORT_POWERUP_DELAY 300 /* ms */
119119#define USB_PORT_RESUME_DELAY (20*2) /* ms */
120120#define USB_SET_ADDRESS_SETTLE 10 /* ms */
lib/libc/include/generic-freebsd/dev/usb/usb_bus.h+1-1
......@@ -86,7 +86,7 @@ struct usb_bus {
8686 struct usb_bus_msg shutdown_msg[2];
8787#if USB_HAVE_UGEN
8888 struct usb_bus_msg cleanup_msg[2];
89 LIST_HEAD(,usb_fs_privdata) pd_cleanup_list;
89 SLIST_HEAD(,usb_fs_privdata) pd_cleanup_list;
9090#endif
9191 /*
9292 * This mutex protects the USB hardware:
lib/libc/include/generic-freebsd/dev/usb/usb_dev.h+1-1
......@@ -96,7 +96,7 @@ struct usb_fs_privdata {
9696 int fifo_index;
9797 struct cdev *cdev;
9898
99 LIST_ENTRY(usb_fs_privdata) pd_next;
99 SLIST_ENTRY(usb_fs_privdata) pd_next;
100100};
101101
102102/*
lib/libc/include/generic-freebsd/dev/usb/usb_device.h+1-1
......@@ -225,7 +225,7 @@ struct usb_device {
225225 struct usb_fifo *fifo[USB_FIFO_MAX];
226226 struct usb_symlink *ugen_symlink; /* our generic symlink */
227227 struct usb_fs_privdata *ctrl_dev; /* Control Endpoint 0 device node */
228 LIST_HEAD(,usb_fs_privdata) pd_list;
228 SLIST_HEAD(,usb_fs_privdata) pd_list;
229229 char ugen_name[20]; /* name of ugenX.X device */
230230#endif
231231 usb_ticks_t plugtime; /* copy of "ticks" */
lib/libc/include/generic-freebsd/dev/usb/usb_freebsd.h+1
......@@ -42,6 +42,7 @@
4242#define USB_HAVE_TT_SUPPORT 1
4343#define USB_HAVE_POWERD 1
4444#define USB_HAVE_MSCTEST 1
45#define USB_HAVE_MSCTEST_AUTOQUIRK 0
4546#define USB_HAVE_MSCTEST_DETACH 1
4647#define USB_HAVE_PF 1
4748#define USB_HAVE_ROOT_MOUNT_HOLD 1
lib/libc/include/generic-freebsd/dev/usb/usb_freebsd_loader.h+1
......@@ -42,6 +42,7 @@
4242#define USB_HAVE_TT_SUPPORT 1
4343#define USB_HAVE_POWERD 1
4444#define USB_HAVE_MSCTEST 1
45#define USB_HAVE_MSCTEST_AUTOQUIRK 0
4546#define USB_HAVE_MSCTEST_DETACH 0
4647#define USB_HAVE_PF 0
4748#define USB_HAVE_ROOT_MOUNT_HOLD 0
lib/libc/include/generic-freebsd/dev/usb/usb_ioctl.h+1-1
......@@ -239,7 +239,7 @@ struct usb_gen_quirk {
239239#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)
240240#define USB_DEVICEENUMERATE _IOW ('U', 6, int)
241241
242/* Generic HID device. Numbers 26 and 30-39 are occupied by hidraw. */
242/* Generic HID device. Numbers 26 and 30-49 are occupied by hidraw. */
243243#define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor)
244244#define USB_SET_IMMED _IOW ('U', 22, int)
245245#define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor)
lib/libc/include/generic-freebsd/dev/usb/usb_process.h+1-1
......@@ -31,7 +31,6 @@
3131#ifndef USB_GLOBAL_INCLUDE_FILE
3232#include <sys/interrupt.h>
3333#include <sys/priority.h>
34#include <sys/runq.h>
3534#endif
3635
3736/* defines */
......@@ -76,6 +75,7 @@ int usb_proc_create(struct usb_process *up, struct mtx *p_mtx,
7675 const char *pmesg, uint8_t prio);
7776void usb_proc_drain(struct usb_process *up);
7877void usb_proc_mwait(struct usb_process *up, void *pm0, void *pm1);
78int usb_proc_mwait_sig(struct usb_process *up, void *pm0, void *pm1);
7979void usb_proc_free(struct usb_process *up);
8080void *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1);
8181void usb_proc_rewakeup(struct usb_process *up);
lib/libc/include/generic-freebsd/dev/usb/usbdi.h+5
......@@ -38,6 +38,7 @@ struct usb_process;
3838struct usb_proc_msg;
3939struct usb_mbuf;
4040struct usb_fs_privdata;
41struct usb_device_info;
4142struct mbuf;
4243
4344typedef enum { /* keep in sync with usb_errstr_table */
......@@ -525,6 +526,8 @@ struct usb_proc_msg {
525526 usb_size_t pm_num;
526527};
527528
529#define USB_PROC_MSG_ENQUEUED(msg) ((msg)->pm_qentry.tqe_prev != NULL)
530
528531#define USB_FIFO_TX 0
529532#define USB_FIFO_RX 1
530533
......@@ -585,6 +588,8 @@ usb_error_t usbd_set_endpoint_mode(struct usb_device *udev,
585588 struct usb_endpoint *ep, uint8_t ep_mode);
586589uint8_t usbd_get_endpoint_mode(struct usb_device *udev,
587590 struct usb_endpoint *ep);
591int usbd_fill_deviceinfo(struct usb_device *udev,
592 struct usb_device_info *di);
588593
589594const struct usb_device_id *usbd_lookup_id_by_info(
590595 const struct usb_device_id *id, usb_size_t sizeof_id,
lib/libc/include/generic-freebsd/dev/veriexec/veriexec_ioctl.h+1-1
......@@ -63,7 +63,7 @@ struct verified_exec_label_params {
6363#define VERIEXEC_DEBUG_OFF _IO('S', 0x6) /* reset debug */
6464#define VERIEXEC_GETSTATE _IOR('S', 0x7, int) /* get state */
6565#define VERIEXEC_SIGNED_LOAD32 _IOW('S', 0x8, struct verified_exec_params32)
66#define VERIEXEC_VERIFIED_FILD _IOW('S', 0x9, int) /* fd */
66#define VERIEXEC_VERIFIED_FILE _IOW('S', 0x9, int) /* fd */
6767#define VERIEXEC_GETVERSION _IOR('S', 0xa, int) /* get version */
6868#define VERIEXEC_LABEL_LOAD _IOW('S', 0xb, struct verified_exec_label_params)
6969#define VERIEXEC_SIGNED_LOAD _IOW('S', 0xc, struct verified_exec_params)
lib/libc/include/generic-freebsd/dev/wg/if_wg.h+6
......@@ -32,4 +32,10 @@ struct wg_data_io {
3232#define SIOCSWG _IOWR('i', 210, struct wg_data_io)
3333#define SIOCGWG _IOWR('i', 211, struct wg_data_io)
3434
35
36/* Keep these in sync with wireguard-tools:containers.h */
37#define WGALLOWEDIP_REMOVE_ME 0x0001
38
39#define WGALLOWEDIP_VALID_FLAGS WGALLOWEDIP_REMOVE_ME
40
3541#endif /* __IF_WG_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dirent.h+15-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)dirent.h 8.2 (Berkeley) 7/28/94
3230 */
3331
3432#ifndef _DIRENT_H_
......@@ -118,7 +116,8 @@ DIR *fdopendir(int);
118116struct dirent *
119117 readdir(DIR *);
120118#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
121int readdir_r(DIR *, struct dirent *, struct dirent **);
119int readdir_r(DIR *, struct dirent *, struct dirent **)
120 __deprecated1("Does not take variable {NAME_MAX} into account");
122121#endif
123122void rewinddir(DIR *);
124123#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700
......@@ -132,9 +131,22 @@ int scandir_b(const char *, struct dirent ***,
132131#endif
133132#endif
134133#if __BSD_VISIBLE
134int fdscandir(int, struct dirent ***,
135 int (*)(const struct dirent *), int (*)(const struct dirent **,
136 const struct dirent **));
137#ifdef __BLOCKS__
138int fdscandir_b(int, struct dirent ***,
139 int (^)(const struct dirent *),
140 int (^)(const struct dirent **, const struct dirent **));
141#endif
135142int scandirat(int, const char *, struct dirent ***,
136143 int (*)(const struct dirent *), int (*)(const struct dirent **,
137144 const struct dirent **));
145#ifdef __BLOCKS__
146int scandirat_b(int, const char *, struct dirent ***,
147 int (^)(const struct dirent *),
148 int (^)(const struct dirent **, const struct dirent **));
149#endif
138150#endif
139151#if __XSI_VISIBLE
140152void seekdir(DIR *, long);
lib/libc/include/generic-freebsd/dlfcn.h+1
......@@ -32,6 +32,7 @@
3232#ifndef _DLFCN_H_
3333#define _DLFCN_H_
3434
35#include <sys/cdefs.h>
3536#include <sys/_types.h>
3637
3738/*
lib/libc/include/generic-freebsd/endian.h+26-1
......@@ -11,9 +11,34 @@
1111#ifndef _ENDIAN_H_
1212#define _ENDIAN_H_
1313
14/*
15 * POSIX.1-2024 requires that endian.h define uint{16,32,64}_t. Although POSIX
16 * allows stdint.h symbols here, be conservative and only define there required
17 * ones. FreeBSD's sys/_endian.h doesn't need to expose those types since it
18 * implements all the [bl]eXtoh hto[bl]eX interfaces as macros calling builtin
19 * functions. POSIX.1-2024 allows functions, macros or both. We opt for macros
20 * only.
21 */
22#include <sys/_types.h>
23
24#ifndef _UINT16_T_DECLARED
25typedef __uint16_t uint16_t;
26#define _UINT16_T_DECLARED
27#endif
28
29#ifndef _UINT32_T_DECLARED
30typedef __uint32_t uint32_t;
31#define _UINT32_T_DECLARED
32#endif
33
34#ifndef _UINT64_T_DECLARED
35typedef __uint64_t uint64_t;
36#define _UINT64_T_DECLARED
37#endif
38
1439/*
1540 * FreeBSD's sys/_endian.h is very close to the interface provided on Linux by
16 * glibc's endian.h.
41 * glibc's endian.h as well as POSIX.1-2024's endian.h.
1742 */
1843#include <sys/_endian.h>
1944
lib/libc/include/generic-freebsd/err.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)err.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _ERR_H_
lib/libc/include/generic-freebsd/errno.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)errno.h 8.5 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_ERRNO_H_
lib/libc/include/generic-freebsd/execinfo.h+2
......@@ -32,6 +32,8 @@
3232#ifndef _EXECINFO_H_
3333#define _EXECINFO_H_
3434
35#include <sys/cdefs.h>
36
3537#include <stddef.h>
3638
3739__BEGIN_DECLS
lib/libc/include/generic-freebsd/exterr.h created+21
......@@ -0,0 +1,21 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8 * under sponsorship from the FreeBSD Foundation.
9 */
10
11#ifndef _EXTERR_H_
12#define _EXTERR_H_
13
14#include <sys/cdefs.h>
15#include <sys/exterr_cat.h>
16
17__BEGIN_DECLS
18int uexterr_gettext(char *buf, size_t bufsz);
19__END_DECLS
20
21#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/fcntl.h+31-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_FCNTL_H_
......@@ -142,8 +140,24 @@ typedef __pid_t pid_t;
142140#define O_DSYNC 0x01000000 /* POSIX data sync */
143141#if __BSD_VISIBLE
144142#define O_EMPTY_PATH 0x02000000
143#define O_NAMEDATTR 0x04000000 /* NFSv4 named attributes */
144#define O_XATTR O_NAMEDATTR /* Solaris compatibility */
145#endif
146
147#if __POSIX_VISIBLE >= 202405
148#define O_CLOFORK 0x08000000
145149#endif
146150
151/*
152 * !!! DANGER !!!
153 *
154 * There are very few bits left for O_* flags. Every bit we consume for
155 * local features is one bit we can't use for future source compatibility
156 * with other operating systems.
157 *
158 * All additions should be coordinated with srcmgr@.
159 */
160
147161/*
148162 * XXX missing O_RSYNC.
149163 */
......@@ -270,6 +284,16 @@ typedef __pid_t pid_t;
270284#define F_GET_SEALS 20
271285#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */
272286#define F_KINFO 22 /* Return kinfo_file for this fd */
287#endif /* __BSD_VISIBLE */
288
289#if __POSIX_VISIBLE >= 202405
290#define F_DUPFD_CLOFORK 23 /* Like F_DUPFD, but FD_CLOFORK is set */
291#endif
292
293#if __BSD_VISIBLE
294#define F_DUP3FD 24 /* Used with dup3() */
295
296#define F_DUP3FD_SHIFT 16 /* Shift used for F_DUP3FD */
273297
274298/* Seals (F_ADD_SEALS, F_GET_SEALS). */
275299#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */
......@@ -280,6 +304,11 @@ typedef __pid_t pid_t;
280304
281305/* file descriptor flags (F_GETFD, F_SETFD) */
282306#define FD_CLOEXEC 1 /* close-on-exec flag */
307#define FD_RESOLVE_BENEATH 2 /* all lookups relative to fd have
308 O_RESOLVE_BENEATH semantics */
309#if __POSIX_VISIBLE >= 202405
310#define FD_CLOFORK 4 /* close-on-fork flag */
311#endif
283312
284313/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
285314#define F_RDLCK 1 /* shared or read lock */
lib/libc/include/generic-freebsd/fenv.h+229-186
......@@ -29,276 +29,319 @@
2929#ifndef _FENV_H_
3030#define _FENV_H_
3131
32#include <sys/cdefs.h>
3233#include <sys/_types.h>
33#include <machine/endian.h>
34#include <ieeefp.h>
3435
3536#ifndef __fenv_static
3637#define __fenv_static static
3738#endif
3839
39typedef __uint32_t fenv_t;
40typedef __uint32_t fexcept_t;
40typedef __uint16_t fexcept_t;
4141
4242/* Exception flags */
43#ifdef __SPE__
44#define FE_OVERFLOW 0x00000100
45#define FE_UNDERFLOW 0x00000200
46#define FE_DIVBYZERO 0x00000400
47#define FE_INVALID 0x00000800
48#define FE_INEXACT 0x00001000
49
50#define FE_ALL_INVALID FE_INVALID
51
52#define _FPUSW_SHIFT 6
53#else
54#define FE_INEXACT 0x02000000
55#define FE_DIVBYZERO 0x04000000
56#define FE_UNDERFLOW 0x08000000
57#define FE_OVERFLOW 0x10000000
58#define FE_INVALID 0x20000000 /* all types of invalid FP ops */
59
60/*
61 * The PowerPC architecture has extra invalid flags that indicate the
62 * specific type of invalid operation occurred. These flags may be
63 * tested, set, and cleared---but not masked---separately. All of
64 * these bits are cleared when FE_INVALID is cleared, but only
65 * FE_VXSOFT is set when FE_INVALID is explicitly set in software.
66 */
67#define FE_VXCVI 0x00000100 /* invalid integer convert */
68#define FE_VXSQRT 0x00000200 /* square root of a negative */
69#define FE_VXSOFT 0x00000400 /* software-requested exception */
70#define FE_VXVC 0x00080000 /* ordered comparison involving NaN */
71#define FE_VXIMZ 0x00100000 /* inf * 0 */
72#define FE_VXZDZ 0x00200000 /* 0 / 0 */
73#define FE_VXIDI 0x00400000 /* inf / inf */
74#define FE_VXISI 0x00800000 /* inf - inf */
75#define FE_VXSNAN 0x01000000 /* operation on a signalling NaN */
76#define FE_ALL_INVALID (FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \
77 FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \
78 FE_VXSNAN | FE_INVALID)
79
80#define _FPUSW_SHIFT 22
81#endif
82#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
83 FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
43#define FE_INVALID 0x01
44#define FE_DENORMAL 0x02
45#define FE_DIVBYZERO 0x04
46#define FE_OVERFLOW 0x08
47#define FE_UNDERFLOW 0x10
48#define FE_INEXACT 0x20
49#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
50 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
8451
8552/* Rounding modes */
8653#define FE_TONEAREST 0x0000
87#define FE_TOWARDZERO 0x0001
88#define FE_UPWARD 0x0002
89#define FE_DOWNWARD 0x0003
54#define FE_DOWNWARD 0x0400
55#define FE_UPWARD 0x0800
56#define FE_TOWARDZERO 0x0c00
9057#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
9158 FE_UPWARD | FE_TOWARDZERO)
9259
60/*
61 * As compared to the x87 control word, the SSE unit's control word
62 * has the rounding control bits offset by 3 and the exception mask
63 * bits offset by 7.
64 */
65#define _SSE_ROUND_SHIFT 3
66#define _SSE_EMASK_SHIFT 7
67
68#ifdef __i386__
69/*
70 * To preserve binary compatibility with FreeBSD 5.3, we pack the
71 * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
72 */
73typedef struct {
74 __uint16_t __control;
75 __uint16_t __mxcsr_hi;
76 __uint16_t __status;
77 __uint16_t __mxcsr_lo;
78 __uint32_t __tag;
79 char __other[16];
80} fenv_t;
81#else /* __amd64__ */
82typedef struct {
83 struct {
84 __uint32_t __control;
85 __uint32_t __status;
86 __uint32_t __tag;
87 char __other[16];
88 } __x87;
89 __uint32_t __mxcsr;
90} fenv_t;
91#endif /* __i386__ */
92
9393__BEGIN_DECLS
9494
9595/* Default floating-point environment */
9696extern const fenv_t __fe_dfl_env;
9797#define FE_DFL_ENV (&__fe_dfl_env)
9898
99/* We need to be able to map status flag positions to mask flag positions */
100#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
101 FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)
102
103#ifndef _SOFT_FLOAT
104#ifdef __SPE__
105#define __mffs(__env) \
106 __asm __volatile("mfspr %0, 512" : "=r" ((__env)->__bits.__reg))
107#define __mtfsf(__env) \
108 __asm __volatile("mtspr 512,%0;isync" :: "r" ((__env).__bits.__reg))
109#else
110#define __mffs(__env) \
111 __asm __volatile("mffs %0" : "=f" ((__env)->__d))
112#define __mtfsf(__env) \
113 __asm __volatile("mtfsf 255,%0" :: "f" ((__env).__d))
114#endif
115#else
116#define __mffs(__env)
117#define __mtfsf(__env)
118#endif
99#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \
100 : "st", "st(1)", "st(2)", "st(3)", "st(4)", \
101 "st(5)", "st(6)", "st(7)")
102#define __fwait() __asm __volatile("fwait")
119103
120union __fpscr {
121 double __d;
122 struct {
123#if _BYTE_ORDER == _LITTLE_ENDIAN
124 fenv_t __reg;
125 __uint32_t __junk;
126#else
127 __uint32_t __junk;
128 fenv_t __reg;
129#endif
130 } __bits;
131};
104int fegetenv(fenv_t *__envp);
105int feholdexcept(fenv_t *__envp);
106int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
107int feraiseexcept(int __excepts);
108int feupdateenv(const fenv_t *__envp);
132109
133110__fenv_static inline int
134feclearexcept(int __excepts)
111fegetround(void)
135112{
136 union __fpscr __r;
137
138 if (__excepts & FE_INVALID)
139 __excepts |= FE_ALL_INVALID;
140 __mffs(&__r);
141 __r.__bits.__reg &= ~__excepts;
142 __mtfsf(__r);
143 return (0);
113 __uint16_t __control;
114
115 /*
116 * We assume that the x87 and the SSE unit agree on the
117 * rounding mode. Reading the control word on the x87 turns
118 * out to be about 5 times faster than reading it on the SSE
119 * unit on an Opteron 244.
120 */
121 __fnstcw(&__control);
122 return (__control & _ROUND_MASK);
144123}
145124
146__fenv_static inline int
147fegetexceptflag(fexcept_t *__flagp, int __excepts)
148{
149 union __fpscr __r;
125#if __BSD_VISIBLE
150126
151 __mffs(&__r);
152 *__flagp = __r.__bits.__reg & __excepts;
153 return (0);
154}
127int feenableexcept(int __mask);
128int fedisableexcept(int __mask);
155129
156__fenv_static inline int
157fesetexceptflag(const fexcept_t *__flagp, int __excepts)
130/* We currently provide no external definition of fegetexcept(). */
131static inline int
132fegetexcept(void)
158133{
159 union __fpscr __r;
160
161 if (__excepts & FE_INVALID)
162 __excepts |= FE_ALL_INVALID;
163 __mffs(&__r);
164 __r.__bits.__reg &= ~__excepts;
165 __r.__bits.__reg |= *__flagp & __excepts;
166 __mtfsf(__r);
167 return (0);
134 __uint16_t __control;
135
136 /*
137 * We assume that the masks for the x87 and the SSE unit are
138 * the same.
139 */
140 __fnstcw(&__control);
141 return (~__control & FE_ALL_EXCEPT);
168142}
169143
170#ifdef __SPE__
171extern int feraiseexcept(int __excepts);
144#endif /* __BSD_VISIBLE */
145
146#ifdef __i386__
147
148/* After testing for SSE support once, we cache the result in __has_sse. */
149enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
150extern enum __sse_support __has_sse;
151int __test_sse(void);
152#ifdef __SSE__
153#define __HAS_SSE() 1
172154#else
155#define __HAS_SSE() (__has_sse == __SSE_YES || \
156 (__has_sse == __SSE_UNK && __test_sse()))
157#endif
158
159#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \
160 ((env).__mxcsr_lo))
161#define __set_mxcsr(env, x) do { \
162 (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \
163 (env).__mxcsr_lo = (__uint16_t)(x); \
164} while (0)
165
173166__fenv_static inline int
174feraiseexcept(int __excepts)
167feclearexcept(int __excepts)
175168{
176 union __fpscr __r;
177
178 if (__excepts & FE_INVALID)
179 __excepts |= FE_VXSOFT;
180 __mffs(&__r);
181 __r.__bits.__reg |= __excepts;
182 __mtfsf(__r);
169 fenv_t __env;
170 __uint32_t __mxcsr;
171
172 if (__excepts == FE_ALL_EXCEPT) {
173 __fnclex();
174 } else {
175 __fnstenv(&__env);
176 __env.__status &= ~__excepts;
177 __fldenv(&__env);
178 }
179 if (__HAS_SSE()) {
180 __stmxcsr(&__mxcsr);
181 __mxcsr &= ~__excepts;
182 __ldmxcsr(&__mxcsr);
183 }
183184 return (0);
184185}
185#endif
186186
187187__fenv_static inline int
188fetestexcept(int __excepts)
188fegetexceptflag(fexcept_t *__flagp, int __excepts)
189189{
190 union __fpscr __r;
191
192 __mffs(&__r);
193 return (__r.__bits.__reg & __excepts);
190 __uint32_t __mxcsr;
191 __uint16_t __status;
192
193 __fnstsw(&__status);
194 if (__HAS_SSE())
195 __stmxcsr(&__mxcsr);
196 else
197 __mxcsr = 0;
198 *__flagp = (__mxcsr | __status) & __excepts;
199 return (0);
194200}
195201
196202__fenv_static inline int
197fegetround(void)
203fetestexcept(int __excepts)
198204{
199 union __fpscr __r;
200
201 __mffs(&__r);
202 return (__r.__bits.__reg & _ROUND_MASK);
205 __uint32_t __mxcsr;
206 __uint16_t __status;
207
208 __fnstsw(&__status);
209 if (__HAS_SSE())
210 __stmxcsr(&__mxcsr);
211 else
212 __mxcsr = 0;
213 return ((__status | __mxcsr) & __excepts);
203214}
204215
205216__fenv_static inline int
206217fesetround(int __round)
207218{
208 union __fpscr __r;
219 __uint32_t __mxcsr;
220 __uint16_t __control;
209221
210222 if (__round & ~_ROUND_MASK)
211223 return (-1);
212 __mffs(&__r);
213 __r.__bits.__reg &= ~_ROUND_MASK;
214 __r.__bits.__reg |= __round;
215 __mtfsf(__r);
216 return (0);
217}
218224
219__fenv_static inline int
220fegetenv(fenv_t *__envp)
221{
222 union __fpscr __r;
225 __fnstcw(&__control);
226 __control &= ~_ROUND_MASK;
227 __control |= __round;
228 __fldcw(&__control);
229
230 if (__HAS_SSE()) {
231 __stmxcsr(&__mxcsr);
232 __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
233 __mxcsr |= __round << _SSE_ROUND_SHIFT;
234 __ldmxcsr(&__mxcsr);
235 }
223236
224 __mffs(&__r);
225 *__envp = __r.__bits.__reg;
226237 return (0);
227238}
228239
229240__fenv_static inline int
230feholdexcept(fenv_t *__envp)
241fesetenv(const fenv_t *__envp)
231242{
232 union __fpscr __r;
233
234 __mffs(&__r);
235 *__envp = __r.__bits.__reg;
236 __r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
237 __mtfsf(__r);
243 fenv_t __env = *__envp;
244 __uint32_t __mxcsr;
245
246 __mxcsr = __get_mxcsr(__env);
247 __set_mxcsr(__env, 0xffffffff);
248 /*
249 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
250 * instruction clobbers the i387 register stack. This happens because
251 * we restore the tag word from the saved environment. Normally, this
252 * would happen anyway and we wouldn't care, because the ABI allows
253 * function calls to clobber the i387 regs. However, fesetenv() is
254 * inlined, so we need to be more careful.
255 */
256 __fldenvx(__env);
257 if (__HAS_SSE())
258 __ldmxcsr(&__mxcsr);
238259 return (0);
239260}
240261
262#else /* __amd64__ */
263
241264__fenv_static inline int
242fesetenv(const fenv_t *__envp)
265feclearexcept(int __excepts)
243266{
244 union __fpscr __r;
245
246 __r.__bits.__reg = *__envp;
247 __mtfsf(__r);
267 fenv_t __env;
268
269 if (__excepts == FE_ALL_EXCEPT) {
270 __fnclex();
271 } else {
272 __fnstenv(&__env.__x87);
273 __env.__x87.__status &= ~__excepts;
274 __fldenv(&__env.__x87);
275 }
276 __stmxcsr(&__env.__mxcsr);
277 __env.__mxcsr &= ~__excepts;
278 __ldmxcsr(&__env.__mxcsr);
248279 return (0);
249280}
250281
251282__fenv_static inline int
252feupdateenv(const fenv_t *__envp)
283fegetexceptflag(fexcept_t *__flagp, int __excepts)
253284{
254 union __fpscr __r;
285 __uint32_t __mxcsr;
286 __uint16_t __status;
255287
256 __mffs(&__r);
257 __r.__bits.__reg &= FE_ALL_EXCEPT;
258 __r.__bits.__reg |= *__envp;
259 __mtfsf(__r);
288 __stmxcsr(&__mxcsr);
289 __fnstsw(&__status);
290 *__flagp = (__mxcsr | __status) & __excepts;
260291 return (0);
261292}
262293
263#if __BSD_VISIBLE
264
265294__fenv_static inline int
266feenableexcept(int __mask)
295fetestexcept(int __excepts)
267296{
268 union __fpscr __r;
269 fenv_t __oldmask;
270
271 __mffs(&__r);
272 __oldmask = __r.__bits.__reg;
273 __r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT;
274 __mtfsf(__r);
275 return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
297 __uint32_t __mxcsr;
298 __uint16_t __status;
299
300 __stmxcsr(&__mxcsr);
301 __fnstsw(&__status);
302 return ((__status | __mxcsr) & __excepts);
276303}
277304
278305__fenv_static inline int
279fedisableexcept(int __mask)
306fesetround(int __round)
280307{
281 union __fpscr __r;
282 fenv_t __oldmask;
283
284 __mffs(&__r);
285 __oldmask = __r.__bits.__reg;
286 __r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT);
287 __mtfsf(__r);
288 return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
308 __uint32_t __mxcsr;
309 __uint16_t __control;
310
311 if (__round & ~_ROUND_MASK)
312 return (-1);
313
314 __fnstcw(&__control);
315 __control &= ~_ROUND_MASK;
316 __control |= __round;
317 __fldcw(&__control);
318
319 __stmxcsr(&__mxcsr);
320 __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
321 __mxcsr |= __round << _SSE_ROUND_SHIFT;
322 __ldmxcsr(&__mxcsr);
323
324 return (0);
289325}
290326
291/* We currently provide no external definition of fegetexcept(). */
292static inline int
293fegetexcept(void)
327__fenv_static inline int
328fesetenv(const fenv_t *__envp)
294329{
295 union __fpscr __r;
296330
297 __mffs(&__r);
298 return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT);
331 /*
332 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
333 * instruction clobbers the i387 register stack. This happens because
334 * we restore the tag word from the saved environment. Normally, this
335 * would happen anyway and we wouldn't care, because the ABI allows
336 * function calls to clobber the i387 regs. However, fesetenv() is
337 * inlined, so we need to be more careful.
338 */
339 __fldenvx(__envp->__x87);
340 __ldmxcsr(&__envp->__mxcsr);
341 return (0);
299342}
300343
301#endif /* __BSD_VISIBLE */
344#endif /* __i386__ */
302345
303346__END_DECLS
304347
lib/libc/include/generic-freebsd/float.h+2-97
......@@ -1,100 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1989 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
32 * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11
2 * This file is in the public domain.
333 */
344
35#ifndef _MACHINE_FLOAT_H_
36#define _MACHINE_FLOAT_H_ 1
37
38#include <sys/cdefs.h>
39
40#ifndef _SOFT_FLOAT
41__BEGIN_DECLS
42extern int __flt_rounds(void);
43__END_DECLS
44#define FLT_ROUNDS __flt_rounds()
45#else
46#define FLT_ROUNDS (-1)
47#endif
48
49#define FLT_RADIX 2 /* b */
50#if __ISO_C_VISIBLE >= 1999
51#define FLT_EVAL_METHOD 0
52#define DECIMAL_DIG 17 /* max precision in decimal digits */
53#endif
54
55#define FLT_MANT_DIG 24 /* p */
56#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
57#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
58#define FLT_MIN_EXP (-125) /* emin */
59#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
60#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
61#define FLT_MAX_EXP 128 /* emax */
62#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
63#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
64#if __ISO_C_VISIBLE >= 2011
65#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */
66#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */
67#define FLT_HAS_SUBNORM 1
68#endif /* __ISO_C_VISIBLE >= 2011 */
69
70#define DBL_MANT_DIG 53
71#define DBL_EPSILON 2.2204460492503131E-16
72#define DBL_DIG 15
73#define DBL_MIN_EXP (-1021)
74#define DBL_MIN 2.2250738585072014E-308
75#define DBL_MIN_10_EXP (-307)
76#define DBL_MAX_EXP 1024
77#define DBL_MAX 1.7976931348623157E+308
78#define DBL_MAX_10_EXP 308
79#if __ISO_C_VISIBLE >= 2011
80#define DBL_TRUE_MIN 4.9406564584124654E-324
81#define DBL_DECIMAL_DIG 17
82#define DBL_HAS_SUBNORM 1
83#endif /* __ISO_C_VISIBLE >= 2011 */
84
85#define LDBL_MANT_DIG DBL_MANT_DIG
86#define LDBL_EPSILON ((long double)DBL_EPSILON)
87#define LDBL_DIG DBL_DIG
88#define LDBL_MIN_EXP DBL_MIN_EXP
89#define LDBL_MIN ((long double)DBL_MIN)
90#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
91#define LDBL_MAX_EXP DBL_MAX_EXP
92#define LDBL_MAX ((long double)DBL_MAX)
93#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
94#if __ISO_C_VISIBLE >= 2011
95#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN)
96#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
97#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
98#endif /* __ISO_C_VISIBLE >= 2011 */
99
100#endif /* _MACHINE_FLOAT_H_ */
\ No newline at end of file
5#include <x86/float.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/floatingpoint.h+9-4
......@@ -1,7 +1,7 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
2 * SPDX-License-Identifier: BSD-4-Clause
33 *
4 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>
4 * Copyright (c) 1993 Andrew Moore, Talke Studio
55 * All rights reserved.
66 *
77 * Redistribution and use in source and binary forms, with or without
......@@ -12,11 +12,15 @@
1212 * 2. Redistributions in binary form must reproduce the above copyright
1313 * notice, this list of conditions and the following disclaimer in the
1414 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
1620 * may be used to endorse or promote products derived from this software
1721 * without specific prior written permission.
1822 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2024 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2125 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2226 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
......@@ -32,6 +36,7 @@
3236#ifndef _FLOATINGPOINT_H_
3337#define _FLOATINGPOINT_H_
3438
39#include <sys/cdefs.h>
3540#include <machine/ieeefp.h>
3641
3742#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/fnmatch.h-1
......@@ -27,7 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93
3130 */
3231
3332#ifndef _FNMATCH_H_
lib/libc/include/generic-freebsd/fs/devfs/devfs.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)kernfs.h 8.6 (Berkeley) 3/29/95
3634 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
3735 */
3836
lib/libc/include/generic-freebsd/fs/fdescfs/fdesc.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)fdesc.h 8.5 (Berkeley) 1/21/94
3533 */
3634
3735#ifndef _FS_FDESC_H_
lib/libc/include/generic-freebsd/fs/msdosfs/bootsect.h+1-1
......@@ -20,7 +20,7 @@
2020
2121/*
2222 * Format of a boot sector. This is the first sector on a DOS floppy disk
23 * or the fist sector of a partition on a hard disk. But, it is not the
23 * or the first sector of a partition on a hard disk. But, it is not the
2424 * first sector of a partitioned hard disk.
2525 */
2626struct bootsector33 {
lib/libc/include/generic-freebsd/fs/msdosfs/denode.h+2-2
......@@ -212,7 +212,7 @@ struct denode {
212212 ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \
213213 putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16))
214214
215#if defined(_KERNEL) || defined(MAKEFS)
215#if defined(_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS)
216216
217217#define VTODE(vp) ((struct denode *)(vp)->v_data)
218218#define DETOV(de) ((de)->de_vnode)
......@@ -294,5 +294,5 @@ int removede(struct denode *pdep, struct denode *dep);
294294int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred);
295295int doscheckpath( struct denode *source, struct denode *target,
296296 daddr_t *wait_scn);
297#endif /* _KERNEL || MAKEFS */
297#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */
298298#endif /* !_FS_MSDOSFS_DENODE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/fs/msdosfs/fat.h+2-2
......@@ -81,7 +81,7 @@
8181
8282#define MSDOSFSEOF(pmp, cn) ((((cn) | ~(pmp)->pm_fatmask) & CLUST_EOFS) == CLUST_EOFS)
8383
84#if defined (_KERNEL) || defined(MAKEFS)
84#if defined (_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS)
8585/*
8686 * These are the values for the function argument to the function
8787 * fatentry().
......@@ -110,5 +110,5 @@ markvoldirty(struct msdosfsmount *pmp, bool dirty)
110110 return (markvoldirty_upgrade(pmp, dirty, false));
111111}
112112
113#endif /* _KERNEL || MAKEFS */
113#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */
114114#endif /* !_FS_MSDOSFS_FAT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/fs/msdosfs/msdosfsmount.h+9-9
......@@ -52,14 +52,17 @@
5252#ifndef _MSDOSFS_MSDOSFSMOUNT_H_
5353#define _MSDOSFS_MSDOSFSMOUNT_H_
5454
55#if defined (_KERNEL) || defined(MAKEFS)
55#if defined(_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS)
5656
5757#include <sys/types.h>
58#ifndef MAKEFS
58#ifdef _KERNEL
5959#include <sys/lock.h>
6060#include <sys/lockmgr.h>
61#include <sys/_task.h>
61#else
62#include <sys/_lock.h>
63#include <sys/_lockmgr.h>
6264#endif
65#include <sys/_task.h>
6366#include <sys/tree.h>
6467
6568#ifdef MALLOC_DECLARE
......@@ -114,11 +117,8 @@ struct msdosfsmount {
114117 void *pm_w2u; /* Unicode->Local iconv handle */
115118 void *pm_u2d; /* Unicode->DOS iconv handle */
116119 void *pm_d2u; /* DOS->Local iconv handle */
117#ifndef MAKEFS
118120 struct lock pm_fatlock; /* lockmgr protecting allocations */
119 struct lock pm_checkpath_lock; /* protects doscheckpath result */
120121 struct task pm_rw2ro_task; /* context for emergency remount ro */
121#endif
122122};
123123
124124/*
......@@ -245,9 +245,9 @@ struct msdosfs_fileno {
245245#define MSDOSFS_ASSERT_MP_LOCKED(pmp) \
246246 lockmgr_assert(&(pmp)->pm_fatlock, KA_XLOCKED)
247247
248#endif /* _KERNEL || MAKEFS */
248#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */
249249
250#ifndef MAKEFS
250#ifdef _KERNEL
251251/*
252252 * Arguments to mount MSDOS filesystems.
253253 */
......@@ -265,7 +265,7 @@ struct msdosfs_args {
265265 char *cs_local; /* Local Charset */
266266 mode_t dirmask; /* dir mask to be applied for msdosfs perms */
267267};
268#endif /* MAKEFS */
268#endif /* _KERNEL */
269269
270270/*
271271 * Msdosfs mount options:
lib/libc/include/generic-freebsd/fs/nfs/nfs.h+2
......@@ -865,6 +865,8 @@ struct nfsslot {
865865/* Enumerated type for nfsuserd state. */
866866typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state;
867867
868typedef enum { UNKNOWN=0, DELETED=1, NLINK_ZERO=2, VALID=3 } nfsremove_status;
869
868870#endif /* _KERNEL */
869871
870872#endif /* _NFS_NFS_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/fs/nfs/nfs_var.h+36-19
......@@ -169,6 +169,7 @@ int nfsrv_mdscopymr(char *, char *, char *, char *, int *, char *, NFSPROC_T *,
169169 struct vnode **, struct vnode **, struct pnfsdsfile **, struct nfsdevice **,
170170 struct nfsdevice **);
171171void nfsrv_marknospc(char *, bool);
172void nfsrv_removedeleg(fhandle_t *, struct nfsrv_descript *, NFSPROC_T *);
172173
173174/* nfs_nfsdserv.c */
174175int nfsrvd_access(struct nfsrv_descript *, int,
......@@ -285,6 +286,8 @@ int nfsrvd_deallocate(struct nfsrv_descript *, int,
285286 vnode_t, struct nfsexstuff *);
286287int nfsrvd_copy_file_range(struct nfsrv_descript *, int,
287288 vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *);
289int nfsrvd_clone(struct nfsrv_descript *, int,
290 vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *);
288291int nfsrvd_seek(struct nfsrv_descript *, int,
289292 vnode_t, struct nfsexstuff *);
290293int nfsrvd_getxattr(struct nfsrv_descript *, int,
......@@ -340,7 +343,8 @@ int nfsv4_loadattr(struct nfsrv_descript *, vnode_t,
340343 struct nfsvattr *, struct nfsfh **, fhandle_t *, int,
341344 struct nfsv3_pathconf *, struct statfs *, struct nfsstatfs *,
342345 struct nfsfsinfo *, NFSACL_T *,
343 int, int *, u_int32_t *, u_int32_t *, NFSPROC_T *, struct ucred *);
346 int, int *, u_int32_t *, u_int32_t *, bool *, uint32_t *, NFSPROC_T *,
347 struct ucred *);
344348int nfsv4_lock(struct nfsv4lock *, int, int *, struct mtx *, struct mount *);
345349void nfsv4_unlock(struct nfsv4lock *, int);
346350void nfsv4_relref(struct nfsv4lock *);
......@@ -394,8 +398,9 @@ int nfsrv_putopbit(struct nfsrv_descript *, nfsopbit_t *);
394398void nfsrv_wcc(struct nfsrv_descript *, int, struct nfsvattr *, int,
395399 struct nfsvattr *);
396400int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,
397 struct vattr *, fhandle_t *, int, nfsattrbit_t *,
398 struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *);
401 struct vattr *, fhandle_t *, int, nfsattrbit_t *, struct ucred *,
402 NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *, bool, bool,
403 bool, uint32_t);
399404void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
400405struct mbuf *nfsrv_adj(struct mbuf *, int, int);
401406void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
......@@ -438,6 +443,7 @@ int nfs_supportsnfsv4acls(vnode_t);
438443/* nfs_commonacl.c */
439444int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *,
440445 bool, int *, int *, NFSPROC_T *);
446uint32_t nfs_aceperm(acl_perm_t);
441447int nfsrv_buildacl(struct nfsrv_descript *, NFSACL_T *, __enum_uint8(vtype),
442448 NFSPROC_T *);
443449int nfsrv_compareacl(NFSACL_T *, NFSACL_T *);
......@@ -481,11 +487,13 @@ int nfsrpc_mknod(vnode_t, char *, int, struct vattr *, u_int32_t,
481487int nfsrpc_create(vnode_t, char *, int, struct vattr *, nfsquad_t,
482488 int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,
483489 struct nfsfh **, int *, int *);
484int nfsrpc_remove(vnode_t, char *, int, vnode_t, struct ucred *, NFSPROC_T *,
485 struct nfsvattr *, int *);
486int nfsrpc_rename(vnode_t, vnode_t, char *, int, vnode_t, vnode_t, char *, int,
487 struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,
488 int *, int *);
490int nfsrpc_remove(struct vnode *, char *, int, struct vnode *,
491 struct nfsvattr *, int *, nfsremove_status *, struct nfsvattr *, int *,
492 struct ucred *, NFSPROC_T *);
493int nfsrpc_rename(struct vnode *, struct vnode *, char *, int, struct vnode *,
494 struct vnode *, char *, int, nfsremove_status *, struct nfsvattr *,
495 struct nfsvattr *, int *, int *, struct nfsvattr *, int *, struct ucred *,
496 NFSPROC_T *);
489497int nfsrpc_link(vnode_t, vnode_t, char *, int,
490498 struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,
491499 int *, int *);
......@@ -512,10 +520,10 @@ int nfsrpc_lock(struct nfsrv_descript *, struct nfsmount *, vnode_t,
512520 u_int8_t *, int, struct nfscllockowner *, int, int, u_int64_t,
513521 u_int64_t, short, struct ucred *, NFSPROC_T *, int);
514522int nfsrpc_statfs(vnode_t, struct nfsstatfs *, struct nfsfsinfo *, uint32_t *,
515 struct ucred *, NFSPROC_T *, struct nfsvattr *, int *);
523 uint32_t *, struct ucred *, NFSPROC_T *, struct nfsvattr *, int *);
516524int nfsrpc_fsinfo(vnode_t, struct nfsfsinfo *, struct ucred *,
517525 NFSPROC_T *, struct nfsvattr *, int *);
518int nfsrpc_pathconf(vnode_t, struct nfsv3_pathconf *,
526int nfsrpc_pathconf(vnode_t, struct nfsv3_pathconf *, bool *, uint32_t *,
519527 struct ucred *, NFSPROC_T *, struct nfsvattr *, int *);
520528int nfsrpc_renew(struct nfsclclient *, struct nfsclds *, struct ucred *,
521529 NFSPROC_T *);
......@@ -557,6 +565,8 @@ int nfsrpc_deallocate(vnode_t, off_t, off_t, struct nfsvattr *, int *,
557565int nfsrpc_copy_file_range(vnode_t, off_t *, vnode_t, off_t *, size_t *,
558566 unsigned int, int *, struct nfsvattr *, int *, struct nfsvattr *,
559567 struct ucred *, bool, bool *);
568int nfsrpc_clone(vnode_t, off_t *, vnode_t, off_t *, size_t *, bool,
569 int *, struct nfsvattr *, int *, struct nfsvattr *, struct ucred *);
560570int nfsrpc_seek(vnode_t, off_t *, bool *, int, struct ucred *,
561571 struct nfsvattr *, int *);
562572int nfsrpc_getextattr(vnode_t, const char *, struct uio *, ssize_t *,
......@@ -568,6 +578,9 @@ int nfsrpc_listextattr(vnode_t, uint64_t *, struct uio *, size_t *, bool *,
568578int nfsrpc_rmextattr(vnode_t, const char *, struct nfsvattr *, int *,
569579 struct ucred *, NFSPROC_T *);
570580void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *);
581int nfsrpc_openattr(struct nfsmount *, struct vnode *, uint8_t *, int,
582 bool, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsfh **,
583 int *);
571584
572585/* nfs_clstate.c */
573586int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,
......@@ -606,12 +619,12 @@ int nfscl_doclose(vnode_t, struct nfsclclient **, NFSPROC_T *);
606619int nfsrpc_doclose(struct nfsmount *, struct nfsclopen *, NFSPROC_T *, bool,
607620 bool);
608621int nfscl_deleg(mount_t, struct nfsclclient *, u_int8_t *, int,
609 struct ucred *, NFSPROC_T *, struct nfscldeleg **);
622 struct ucred *, NFSPROC_T *, struct nfscldeleg *);
610623void nfscl_lockinit(struct nfsv4lock *);
611624void nfscl_lockexcl(struct nfsv4lock *, void *);
612625void nfscl_lockunlock(struct nfsv4lock *);
613626void nfscl_lockderef(struct nfsv4lock *);
614void nfscl_delegreturnvp(vnode_t, NFSPROC_T *);
627void nfscl_delegreturnvp(struct vnode *, bool, NFSPROC_T *);
615628void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *);
616629void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *,
617630 int);
......@@ -626,7 +639,7 @@ int nfscl_renamedeleg(vnode_t, nfsv4stateid_t *, int *, vnode_t,
626639 nfsv4stateid_t *, int *, NFSPROC_T *);
627640void nfscl_reclaimnode(vnode_t);
628641void nfscl_newnode(vnode_t);
629void nfscl_delegmodtime(vnode_t);
642void nfscl_delegmodtime(struct vnode *, struct timespec *);
630643void nfscl_deleggetmodtime(vnode_t, struct timespec *);
631644int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *,
632645 struct nfsmount *, NFSPROC_T *);
......@@ -651,6 +664,8 @@ void nfscl_freelayout(struct nfscllayout *);
651664void nfscl_freeflayout(struct nfsclflayout *);
652665void nfscl_freedevinfo(struct nfscldevinfo *);
653666int nfscl_layoutcommit(vnode_t, NFSPROC_T *);
667int nfscl_delegacecheck(struct vnode *, accmode_t, struct ucred *);
668void nfscl_startdelegrecall(struct nfsclclient *, struct nfsfh *);
654669
655670/* nfs_clport.c */
656671int nfscl_nget(mount_t, vnode_t, struct nfsfh *,
......@@ -658,7 +673,7 @@ int nfscl_nget(mount_t, vnode_t, struct nfsfh *,
658673NFSPROC_T *nfscl_getparent(NFSPROC_T *);
659674void nfscl_start_renewthread(struct nfsclclient *);
660675void nfscl_loadsbinfo(struct nfsmount *, struct nfsstatfs *, void *);
661void nfscl_loadfsinfo (struct nfsmount *, struct nfsfsinfo *);
676void nfscl_loadfsinfo(struct nfsmount *, struct nfsfsinfo *, uint32_t);
662677void nfscl_delegreturn(struct nfscldeleg *, int, struct nfsmount *,
663678 struct ucred *, NFSPROC_T *);
664679void nfsrvd_cbinit(int);
......@@ -707,12 +722,12 @@ int nfsvno_symlink(struct nameidata *, struct nfsvattr *, char *, int, int,
707722 uid_t, struct ucred *, NFSPROC_T *, struct nfsexstuff *);
708723int nfsvno_getsymlink(struct nfsrv_descript *, struct nfsvattr *,
709724 NFSPROC_T *, char **, int *);
710int nfsvno_removesub(struct nameidata *, int, struct ucred *, NFSPROC_T *,
711 struct nfsexstuff *);
725int nfsvno_removesub(struct nameidata *, bool, struct nfsrv_descript *,
726 NFSPROC_T *, struct nfsexstuff *);
712727int nfsvno_rmdirsub(struct nameidata *, int, struct ucred *, NFSPROC_T *,
713728 struct nfsexstuff *);
714int nfsvno_rename(struct nameidata *, struct nameidata *, u_int32_t,
715 u_int32_t, struct ucred *, NFSPROC_T *);
729int nfsvno_rename(struct nameidata *, struct nameidata *,
730 struct nfsrv_descript *, NFSPROC_T *);
716731int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *,
717732 NFSPROC_T *, struct nfsexstuff *);
718733int nfsvno_fsync(vnode_t, u_int64_t, int, struct ucred *, NFSPROC_T *);
......@@ -726,7 +741,8 @@ int nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct nfsrv_descript *,
726741 NFSPROC_T *);
727742int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,
728743 struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *,
729 struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t);
744 struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, bool, bool,
745 bool, uint32_t);
730746int nfsrv_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,
731747 NFSACL_T *, NFSPROC_T *);
732748int nfsv4_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,
......@@ -780,6 +796,7 @@ int newnfs_request(struct nfsrv_descript *, struct nfsmount *,
780796 struct nfsclient *, struct nfssockreq *, vnode_t, NFSPROC_T *,
781797 struct ucred *, u_int32_t, u_int32_t, u_char *, int, u_int64_t *,
782798 struct nfsclsession *);
799void nfs_resetslots(struct nfsclsession *);
783800int newnfs_connect(struct nfsmount *, struct nfssockreq *,
784801 struct ucred *, NFSPROC_T *, int, bool, struct __rpc_client **);
785802void newnfs_disconnect(struct nfsmount *, struct nfssockreq *);
lib/libc/include/generic-freebsd/fs/nfs/nfscl.h+5-4
......@@ -68,10 +68,11 @@ struct nfsv4node {
6868 * These flag bits are used for the argument to nfscl_fillsattr() to
6969 * indicate special handling of the attributes.
7070 */
71#define NFSSATTR_FULL 0x1
72#define NFSSATTR_SIZE0 0x2
73#define NFSSATTR_SIZENEG1 0x4
74#define NFSSATTR_SIZERDEV 0x8
71#define NFSSATTR_FULL 0x01
72#define NFSSATTR_SIZE0 0x02
73#define NFSSATTR_SIZENEG1 0x04
74#define NFSSATTR_SIZERDEV 0x08
75#define NFSSATTR_NEWFILE 0x10
7576
7677/* Use this macro for debug printfs. */
7778#define NFSCL_DEBUG(level, ...) do { \
lib/libc/include/generic-freebsd/fs/nfs/nfsclstate.h+4
......@@ -116,6 +116,10 @@ struct nfsclclient {
116116 struct proc *nfsc_renewthread;
117117 struct nfsmount *nfsc_nmp;
118118 time_t nfsc_expire;
119 int nfsc_delegcnt;
120 int nfsc_deleghighwater;
121 int nfsc_layoutcnt;
122 int nfsc_layouthighwater;
119123 u_int32_t nfsc_clientidrev;
120124 u_int32_t nfsc_rev;
121125 u_int32_t nfsc_renew;
lib/libc/include/generic-freebsd/fs/nfs/nfsport.h+14-17
......@@ -439,10 +439,16 @@
439439/* Do an NFSv4 Verify+Write. */
440440#define NFSPROC_APPENDWRITE 69
441441
442/* Do a NFSv4 Openattr. */
443#define NFSPROC_OPENATTR 70
444
445/* Do a NFSv4.2 Clone. */
446#define NFSPROC_CLONE 71
447
442448/*
443449 * Must be defined as one higher than the last NFSv4.2 Proc# above.
444450 */
445#define NFSV42_NPROCS 70
451#define NFSV42_NPROCS 72
446452
447453/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */
448454#define NFSV42_OLDNPROCS 69
......@@ -474,7 +480,7 @@ struct nfsstatsv1 {
474480 uint64_t readlink_bios;
475481 uint64_t biocache_readdirs;
476482 uint64_t readdir_bios;
477 uint64_t rpccnt[NFSV42_NPROCS + 10];
483 uint64_t rpccnt[NFSV42_NPROCS + 8];
478484 uint64_t rpcretries;
479485 uint64_t srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];
480486 uint64_t srvlayouts;
......@@ -690,6 +696,7 @@ struct nfsvattr {
690696#define na_bytes na_vattr.va_bytes
691697#define na_filerev na_vattr.va_filerev
692698#define na_vaflags na_vattr.va_vaflags
699#define na_bsdflags na_vattr.va_bsdflags
693700
694701#include <fs/nfsclient/nfsnode.h>
695702
......@@ -901,15 +908,6 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *);
901908#define NFSBCMP(s, d, l) bcmp((s), (d), (l))
902909#define NFSBZERO(s, l) bzero((s), (l))
903910
904/*
905 * Some queue.h files don't have these dfined in them.
906 */
907#ifndef LIST_END
908#define LIST_END(head) NULL
909#define SLIST_END(head) NULL
910#define TAILQ_END(head) NULL
911#endif
912
913911/*
914912 * This must be defined to be a global variable that increments once
915913 * per second, but never stops or goes backwards, even when a "date"
......@@ -1019,7 +1017,7 @@ MALLOC_DECLARE(M_NEWNFSDSESSION);
10191017int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, int, int);
10201018int newnfs_realign(struct mbuf **, int);
10211019bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep);
1022void ncl_copy_vattr(struct vattr *dst, struct vattr *src);
1020void ncl_copy_vattr(struct vnode *vp, struct vattr *dst, struct vattr *src);
10231021
10241022/*
10251023 * If the port runs on an SMP box that can enforce Atomic ops with low
......@@ -1030,9 +1028,6 @@ void ncl_copy_vattr(struct vattr *dst, struct vattr *src);
10301028#define NFSINCRGLOBAL(a) ((a)++)
10311029#define NFSDECRGLOBAL(a) ((a)--)
10321030
1033/*
1034 * Assorted funky stuff to make things work under Darwin8.
1035 */
10361031/*
10371032 * These macros checks for a field in vattr being set.
10381033 */
......@@ -1180,9 +1175,11 @@ struct nfsreq {
11801175 */
11811176#ifdef VV_DISABLEDELEG
11821177#define NFSVNO_DELEGOK(v) \
1183 ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0)
1178 ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0 || \
1179 (vn_irflag_read(v) & VIRF_NAMEDATTR) == 0)
11841180#else
1185#define NFSVNO_DELEGOK(v) (1)
1181#define NFSVNO_DELEGOK(v) \
1182 ((v) == NULL || (vn_irflag_read(v) & VIRF_NAMEDATTR) == 0)
11861183#endif
11871184
11881185/*
lib/libc/include/generic-freebsd/fs/nfs/nfsproto.h+50-7
......@@ -275,6 +275,8 @@
275275#define NFSX_V4SESSIONID 16
276276#define NFSX_V4DEVICEID 16
277277#define NFSX_V4PNFSFH (sizeof(fhandle_t) + 1)
278#define NFSX_V4NAMEDDIRFH 2
279#define NFSX_V4NAMEDATTRFH 3
278280#define NFSX_V4FILELAYOUT (4 * NFSX_UNSIGNED + NFSX_V4DEVICEID + \
279281 NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH))
280282#define NFSX_V4FLEXLAYOUT(m) (NFSX_HYPER + 3 * NFSX_UNSIGNED + \
......@@ -406,10 +408,16 @@
406408/* Do an NFSv4 Verify+Write. */
407409#define NFSPROC_APPENDWRITE 69
408410
411/* Do a NFSv4 Openattr. */
412#define NFSPROC_OPENATTR 70
413
414/* Do a NFSv4.2 Clone. */
415#define NFSPROC_CLONE 71
416
409417/*
410418 * Must be defined as one higher than the last NFSv4.2 Proc# above.
411419 */
412#define NFSV42_NPROCS 70
420#define NFSV42_NPROCS 72
413421
414422/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */
415423#define NFSV42_OLDNPROCS 69
......@@ -744,6 +752,17 @@
744752#define NFSSECINFONONAME_CURFH 0
745753#define NFSSECINFONONAME_PARENT 1
746754
755/* Bits for CB_RECALL_ANY. */
756#define NFSRCA4_RDATA_DLG 0x00000001
757#define NFSRCA4_WDATA_DLG 0x00000002
758#define NFSRCA4_DIR_DLG 0x00000004
759#define NFSRCA4_FILE_LAYOUT 0x00000008
760#define NFSRCA4_BLK_LAYOUT 0x00000010
761#define NFSRCA4_OBJ_LAYOUT_MIN 0x00000100
762#define NFSRCA4_OBJ_LAYOUT_MAX 0x00000200
763#define NFSRCA4_FF_LAYOUT_READ 0x00010000
764#define NFSRCA4_FF_LAYOUT_RW 0x00020000
765
747766#if defined(_KERNEL) || defined(KERNEL)
748767/* Conversion macros */
749768#define vtonfsv2_mode(t,m) \
......@@ -1126,6 +1145,7 @@ struct nfsv3_sattr {
11261145 NFSATTRBM_FILESFREE | \
11271146 NFSATTRBM_FILESTOTAL | \
11281147 NFSATTRBM_FSLOCATIONS | \
1148 NFSATTRBM_HIDDEN | \
11291149 NFSATTRBM_HOMOGENEOUS | \
11301150 NFSATTRBM_MAXFILESIZE | \
11311151 NFSATTRBM_MAXLINK | \
......@@ -1147,6 +1167,7 @@ struct nfsv3_sattr {
11471167 NFSATTRBM_SPACEFREE | \
11481168 NFSATTRBM_SPACETOTAL | \
11491169 NFSATTRBM_SPACEUSED | \
1170 NFSATTRBM_SYSTEM | \
11501171 NFSATTRBM_TIMEACCESS | \
11511172 NFSATTRBM_TIMECREATE | \
11521173 NFSATTRBM_TIMEDELTA | \
......@@ -1176,6 +1197,8 @@ struct nfsv3_sattr {
11761197 NFSATTRBM_LAYOUTBLKSIZE | \
11771198 NFSATTRBM_LAYOUTALIGNMENT | \
11781199 NFSATTRBM_SUPPATTREXCLCREAT | \
1200 NFSATTRBM_CLONEBLKSIZE | \
1201 NFSATTRBM_CHANGEATTRTYPE | \
11791202 NFSATTRBM_XATTRSUPPORT)
11801203
11811204/*
......@@ -1183,7 +1206,8 @@ struct nfsv3_sattr {
11831206 */
11841207#define NFSATTRBIT_SUPPSETONLY1 (NFSATTRBM_TIMEACCESSSET | \
11851208 NFSATTRBM_TIMEMODIFYSET)
1186#define NFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED)
1209#define NFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED | \
1210 NFSATTRBM_MODEUMASK)
11871211
11881212/*
11891213 * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31
......@@ -1192,16 +1216,19 @@ struct nfsv3_sattr {
11921216 */
11931217#define NFSATTRBIT_SETABLE0 \
11941218 (NFSATTRBM_SIZE | \
1219 NFSATTRBM_HIDDEN | \
11951220 NFSATTRBM_ACL)
11961221#define NFSATTRBIT_SETABLE1 \
11971222 (NFSATTRBM_MODE | \
11981223 NFSATTRBM_OWNER | \
11991224 NFSATTRBM_OWNERGROUP | \
1200 NFSATTRBM_TIMECREATE | \
1225 NFSATTRBM_SYSTEM | \
1226 NFSATTRBM_TIMECREATE | \
12011227 NFSATTRBM_TIMEACCESSSET | \
12021228 NFSATTRBM_TIMEMODIFYSET)
12031229#define NFSATTRBIT_SETABLE2 \
1204 (NFSATTRBM_MODESETMASKED)
1230 (NFSATTRBM_MODESETMASKED | \
1231 NFSATTRBM_MODEUMASK)
12051232
12061233/*
12071234 * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1.
......@@ -1218,7 +1245,11 @@ struct nfsv3_sattr {
12181245/*
12191246 * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2.
12201247 */
1221#define NFSATTRBIT_NFSV42_2 NFSATTRBM_XATTRSUPPORT
1248#define NFSATTRBIT_NFSV42_2 \
1249 (NFSATTRBM_CLONEBLKSIZE | \
1250 NFSATTRBM_CHANGEATTRTYPE | \
1251 NFSATTRBM_XATTRSUPPORT | \
1252 NFSATTRBM_MODEUMASK)
12221253
12231254/*
12241255 * Set of attributes that the getattr vnode op needs.
......@@ -1232,6 +1263,7 @@ struct nfsv3_sattr {
12321263 NFSATTRBM_SIZE | \
12331264 NFSATTRBM_FSID | \
12341265 NFSATTRBM_FILEID | \
1266 NFSATTRBM_HIDDEN | \
12351267 NFSATTRBM_MAXREAD)
12361268
12371269/*
......@@ -1244,6 +1276,7 @@ struct nfsv3_sattr {
12441276 NFSATTRBM_OWNERGROUP | \
12451277 NFSATTRBM_RAWDEV | \
12461278 NFSATTRBM_SPACEUSED | \
1279 NFSATTRBM_SYSTEM | \
12471280 NFSATTRBM_TIMEACCESS | \
12481281 NFSATTRBM_TIMECREATE | \
12491282 NFSATTRBM_TIMEMETADATA | \
......@@ -1266,6 +1299,7 @@ struct nfsv3_sattr {
12661299 NFSATTRBM_SIZE | \
12671300 NFSATTRBM_FSID | \
12681301 NFSATTRBM_FILEID | \
1302 NFSATTRBM_HIDDEN | \
12691303 NFSATTRBM_MAXREAD)
12701304
12711305/*
......@@ -1276,6 +1310,7 @@ struct nfsv3_sattr {
12761310 NFSATTRBM_NUMLINKS | \
12771311 NFSATTRBM_RAWDEV | \
12781312 NFSATTRBM_SPACEUSED | \
1313 NFSATTRBM_SYSTEM | \
12791314 NFSATTRBM_TIMEACCESS | \
12801315 NFSATTRBM_TIMECREATE | \
12811316 NFSATTRBM_TIMEMETADATA | \
......@@ -1385,13 +1420,14 @@ struct nfsv3_sattr {
13851420/*
13861421 * NFSGETATTRBIT_STATFS2 - bits 64<->95
13871422 */
1388#define NFSGETATTRBIT_STATFS2 0
1423#define NFSGETATTRBIT_STATFS2 (NFSATTRBM_CLONEBLKSIZE)
13891424
13901425/*
13911426 * Set of attributes for the equivalent of an nfsv3 pathconf rpc.
13921427 * NFSGETATTRBIT_PATHCONF0 - bits 0<->31
13931428 */
13941429#define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 | \
1430 NFSATTRBM_NAMEDATTR | \
13951431 NFSATTRBM_CASEINSENSITIVE | \
13961432 NFSATTRBM_CASEPRESERVING | \
13971433 NFSATTRBM_CHOWNRESTRICTED | \
......@@ -1407,7 +1443,7 @@ struct nfsv3_sattr {
14071443/*
14081444 * NFSGETATTRBIT_PATHCONF2 - bits 64<->95
14091445 */
1410#define NFSGETATTRBIT_PATHCONF2 0
1446#define NFSGETATTRBIT_PATHCONF2 (NFSATTRBM_CLONEBLKSIZE)
14111447
14121448/*
14131449 * Sets of attributes required by readdir and readdirplus.
......@@ -1653,4 +1689,11 @@ typedef struct nfsv4stateid nfsv4stateid_t;
16531689#define NFSV4SXATTR_CREATE 1
16541690#define NFSV4SXATTR_REPLACE 2
16551691
1692/* Values for ChangeAttrType (RFC-7862). */
1693#define NFSV4CHANGETYPE_MONOTONIC_INCR 0
1694#define NFSV4CHANGETYPE_VERS_COUNTER 1
1695#define NFSV4CHANGETYPE_VERS_COUNTER_NOPNFS 2
1696#define NFSV4CHANGETYPE_TIME_METADATA 3
1697#define NFSV4CHANGETYPE_UNDEFINED 4
1698
16561699#endif /* _NFS_NFSPROTO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/fs/nullfs/null.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)null.h 8.3 (Berkeley) 8/20/94
3533 */
3634
3735#ifndef FS_NULL_H
lib/libc/include/generic-freebsd/fs/procfs/procfs.h-2
......@@ -32,8 +32,6 @@
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
3434 *
35 * @(#)procfs.h 8.9 (Berkeley) 5/14/95
36 *
3735 * From:
3836 */
3937
lib/libc/include/generic-freebsd/fs/smbfs/smbfs_node.h+1-1
......@@ -93,7 +93,7 @@ u_int32_t smbfs_hash(const u_char *name, int nmlen);
9393
9494int smbfs_getpages(struct vop_getpages_args *);
9595int smbfs_putpages(struct vop_putpages_args *);
96int smbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred);
96int smbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int *eofp);
9797int smbfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag);
9898void smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap);
9999int smbfs_attr_cachelookup(struct vnode *vp ,struct vattr *va);
lib/libc/include/generic-freebsd/fs/udf/ecma167-udf.h+2-2
......@@ -243,7 +243,7 @@ struct part_map_spare {
243243 uint8_t n_st; /* Number of Sparing Tables */
244244 uint8_t reserved1;
245245 uint32_t st_size;
246 uint32_t st_loc[1];
246 uint32_t st_loc[];
247247} __packed;
248248
249249union udf_pmap {
......@@ -266,7 +266,7 @@ struct udf_sparing_table {
266266 uint16_t rt_l; /* Relocation Table len */
267267 uint8_t reserved[2];
268268 uint32_t seq_num;
269 struct spare_map_entry entries[1];
269 struct spare_map_entry entries[];
270270} __packed;
271271
272272/* Partition Descriptor [3/10.5] */
lib/libc/include/generic-freebsd/fs/unionfs/union.h+17-19
......@@ -33,8 +33,6 @@
3333 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3434 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3535 * SUCH DAMAGE.
36 *
37 * @(#)union.h 8.9 (Berkeley) 12/10/94
3836 */
3937
4038#ifdef _KERNEL
......@@ -99,15 +97,17 @@ struct unionfs_node {
9997
10098 char *un_path; /* path */
10199 int un_pathlen; /* strlen of path */
102 int un_flag; /* unionfs node flag */
103};
104100
105/*
106 * unionfs node flags
107 * It needs the vnode with exclusive lock, when changing the un_flag variable.
108 */
109#define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */
110#define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */
101 /*
102 * unionfs node flags
103 * Changing these flags requires the vnode to be locked exclusive.
104 */
105 #define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */
106 #define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */
107 #define UNIONFS_COPY_IN_PROGRESS 0x04 /* copy/dir shadow in progres */
108 #define UNIONFS_LOOKUP_IN_PROGRESS 0x08
109 unsigned int un_flag; /* unionfs node flag */
110};
111111
112112extern struct vop_vector unionfs_vnodeops;
113113
......@@ -133,34 +133,32 @@ int unionfs_uninit(struct vfsconf *);
133133int unionfs_nodeget(struct mount *, struct vnode *, struct vnode *,
134134 struct vnode *, struct vnode **, struct componentname *);
135135void unionfs_noderem(struct vnode *);
136struct unionfs_node_status * unionfs_find_node_status(struct unionfs_node *,
137 struct thread *td);
136138void unionfs_get_node_status(struct unionfs_node *, struct thread *,
137139 struct unionfs_node_status **);
138140void unionfs_tryrem_node_status(struct unionfs_node *,
139141 struct unionfs_node_status *);
140142int unionfs_check_rmdir(struct vnode *, struct ucred *, struct thread *td);
141int unionfs_copyfile(struct unionfs_node *, int, struct ucred *,
143int unionfs_copyfile(struct vnode *, int, struct ucred *,
142144 struct thread *);
143145void unionfs_create_uppervattr_core(struct unionfs_mount *, struct vattr *,
144146 struct vattr *, struct thread *);
145147int unionfs_create_uppervattr(struct unionfs_mount *, struct vnode *,
146148 struct vattr *, struct ucred *, struct thread *);
147int unionfs_mkshadowdir(struct unionfs_mount *, struct vnode *,
148 struct unionfs_node *, struct componentname *, struct thread *);
149int unionfs_mkshadowdir(struct vnode *, struct vnode *,
150 struct componentname *, struct thread *);
149151int unionfs_mkwhiteout(struct vnode *, struct vnode *,
150152 struct componentname *, struct thread *, char *, int);
151153int unionfs_relookup(struct vnode *, struct vnode **,
152154 struct componentname *, struct componentname *, struct thread *,
153155 char *, int, u_long);
154int unionfs_relookup_for_create(struct vnode *, struct componentname *,
155 struct thread *);
156int unionfs_relookup_for_delete(struct vnode *, struct componentname *,
157 struct thread *);
158int unionfs_relookup_for_rename(struct vnode *, struct componentname *,
159 struct thread *);
160156void unionfs_forward_vop_start_pair(struct vnode *, int *,
161157 struct vnode *, int *);
162158bool unionfs_forward_vop_finish_pair(struct vnode *, struct vnode *, int,
163159 struct vnode *, struct vnode *, int);
160int unionfs_set_in_progress_flag(struct vnode *, unsigned int);
161void unionfs_clear_in_progress_flag(struct vnode *, unsigned int);
164162
165163static inline void
166164unionfs_forward_vop_start(struct vnode *basevp, int *lkflags)
lib/libc/include/generic-freebsd/fstab.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)fstab.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _FSTAB_H_
lib/libc/include/generic-freebsd/fts.h+43-22
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)fts.h 8.3 (Berkeley) 8/14/94
3230 */
3331
3432#ifndef _FTS_H_
......@@ -36,35 +34,54 @@
3634
3735#include <sys/_types.h>
3836
37typedef struct _ftsent FTSENT;
38
3939typedef struct {
40 struct _ftsent *fts_cur; /* current node */
41 struct _ftsent *fts_child; /* linked list of children */
42 struct _ftsent **fts_array; /* sort array */
40 FTSENT *fts_cur; /* current node */
41 FTSENT *fts_child; /* linked list of children */
42 FTSENT **fts_array; /* sort array */
4343 __dev_t fts_dev; /* starting device # */
4444 char *fts_path; /* path for this descent */
4545 int fts_rfd; /* fd for root */
4646 __size_t fts_pathlen; /* sizeof(path) */
4747 __size_t fts_nitems; /* elements in the sort array */
48 int (*fts_compar) /* compare function */
49 (const struct _ftsent * const *, const struct _ftsent * const *);
50
51#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */
52#define FTS_LOGICAL 0x002 /* logical walk */
53#define FTS_NOCHDIR 0x004 /* don't change directories */
54#define FTS_NOSTAT 0x008 /* don't get stat info */
55#define FTS_PHYSICAL 0x010 /* physical walk */
56#define FTS_SEEDOT 0x020 /* return dot and dot-dot */
57#define FTS_XDEV 0x040 /* don't cross devices */
58#define FTS_WHITEOUT 0x080 /* return whiteout information */
59#define FTS_OPTIONMASK 0x0ff /* valid user option mask */
60
61#define FTS_NAMEONLY 0x100 /* (private) child names only */
62#define FTS_STOP 0x200 /* (private) unrecoverable error */
48 union {
49 int (*fts_compar) /* compare function */
50 (const FTSENT * const *, const FTSENT * const *);
51#ifdef __BLOCKS__
52 int (^fts_compar_b)
53 (const FTSENT * const *, const FTSENT * const *);
54#else
55 void *fts_compar_b;
56#endif /* __BLOCKS__ */
57 };
58
59/* valid for fts_open() */
60#define FTS_COMFOLLOW 0x000001 /* follow command line symlinks */
61#define FTS_LOGICAL 0x000002 /* logical walk */
62#define FTS_NOCHDIR 0x000004 /* don't change directories */
63#define FTS_NOSTAT 0x000008 /* don't get stat info */
64#define FTS_PHYSICAL 0x000010 /* physical walk */
65#define FTS_SEEDOT 0x000020 /* return dot and dot-dot */
66#define FTS_XDEV 0x000040 /* don't cross devices */
67#define FTS_WHITEOUT 0x000080 /* return whiteout information */
68 /* 0x0100 is FTS_NAMEONLY below */
69 /* 0x0200 was previously FTS_STOP */
70#define FTS_COMFOLLOWDIR 0x00400 /* like COMFOLLOW but directories only */
71#define FTS_NOSTAT_TYPE 0x000800 /* like NOSTAT but use d_type */
72#define FTS_OPTIONMASK 0x000cff /* valid user option mask */
73
74/* valid only for fts_children() */
75#define FTS_NAMEONLY 0x000100 /* child names only */
76
77/* internal use only */
78#define FTS_STOP 0x010000 /* unrecoverable error */
79#define FTS_COMPAR_B 0x020000 /* compare function is a block */
6380 int fts_options; /* fts_open options, global flags */
6481 void *fts_clientptr; /* thunk for sort function */
6582} FTS;
6683
67typedef struct _ftsent {
84struct _ftsent {
6885 struct _ftsent *fts_cycle; /* cycle node */
6986 struct _ftsent *fts_parent; /* parent directory */
7087 struct _ftsent *fts_link; /* next file in directory */
......@@ -116,7 +133,7 @@ typedef struct _ftsent {
116133 struct stat *fts_statp; /* stat(2) information */
117134 char *fts_name; /* file name */
118135 FTS *fts_fts; /* back pointer to main FTS */
119} FTSENT;
136};
120137
121138#include <sys/cdefs.h>
122139
......@@ -129,6 +146,10 @@ FTS *fts_get_stream(FTSENT *);
129146#define fts_get_stream(ftsent) ((ftsent)->fts_fts)
130147FTS *fts_open(char * const *, int,
131148 int (*)(const FTSENT * const *, const FTSENT * const *));
149#ifdef __BLOCKS__
150FTS *fts_open_b(char * const *, int,
151 int (^)(const FTSENT * const *, const FTSENT * const *));
152#endif /* __BLOCKS__ */
132153FTSENT *fts_read(FTS *);
133154int fts_set(FTS *, FTSENT *, int);
134155void fts_set_clientptr(FTS *, void *);
lib/libc/include/generic-freebsd/geom/geom.h+2-2
......@@ -282,7 +282,7 @@ void g_detach(struct g_consumer *cp);
282282void g_error_provider(struct g_provider *pp, int error);
283283struct g_provider *g_provider_by_name(char const *arg);
284284int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
285#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
285#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof(*(v)))
286286int g_handleattr(struct bio *bp, const char *attribute, const void *val,
287287 int len);
288288int g_handleattr_int(struct bio *bp, const char *attribute, int val);
......@@ -417,7 +417,7 @@ g_free(void *ptr)
417417 static moduledata_t name##_mod = { \
418418 #name, g_modevent, &class \
419419 }; \
420 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
420 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD);
421421
422422int g_is_geom_thread(struct thread *td);
423423
lib/libc/include/generic-freebsd/geom/label/g_label.h+1-1
......@@ -73,12 +73,12 @@ extern struct g_label_desc g_label_ufs_volume;
7373extern struct g_label_desc g_label_iso9660;
7474extern struct g_label_desc g_label_msdosfs;
7575extern struct g_label_desc g_label_ext2fs;
76extern struct g_label_desc g_label_reiserfs;
7776extern struct g_label_desc g_label_ntfs;
7877extern struct g_label_desc g_label_gpt;
7978extern struct g_label_desc g_label_gpt_uuid;
8079extern struct g_label_desc g_label_disk_ident;
8180extern struct g_label_desc g_label_flashmap;
81extern struct g_label_desc g_label_swaplinux;
8282
8383extern void g_label_rtrim(char *label, size_t size);
8484#endif /* _KERNEL */
lib/libc/include/generic-freebsd/glob.h+14-4
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)glob.h 8.1 (Berkeley) 6/2/93
3533 */
3634
3735#ifndef _GLOB_H_
......@@ -52,8 +50,15 @@ typedef struct {
5250 size_t gl_offs; /* Reserved at beginning of gl_pathv. */
5351 int gl_flags; /* Copy of flags parameter to glob. */
5452 char **gl_pathv; /* List of paths matching pattern. */
55 /* Copy of errfunc parameter to glob. */
56 int (*gl_errfunc)(const char *, int);
53 /* Copy of error callback parameter to glob. */
54 union {
55 int (*gl_errfunc)(const char *, int);
56#ifdef __BLOCKS__
57 int (^gl_errblk)(const char *, int);
58#else
59 void *gl_errblk;
60#endif
61 };
5762
5863 /*
5964 * Alternate filesystem access methods for glob; replacement
......@@ -92,6 +97,7 @@ typedef struct {
9297#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
9398#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
9499#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
100#define _GLOB_ERR_BLOCK 0x08000000 /* (internal) error callback is a block */
95101
96102/* source compatibility, these are the old names */
97103#define GLOB_MAXPATH GLOB_LIMIT
......@@ -101,6 +107,10 @@ typedef struct {
101107__BEGIN_DECLS
102108int glob(const char * __restrict, int,
103109 int (*)(const char *, int), glob_t * __restrict);
110#if defined(__BLOCKS__) && __BSD_VISIBLE
111int glob_b(const char * __restrict, int,
112 int (^)(const char *, int), glob_t * __restrict);
113#endif
104114void globfree(glob_t *);
105115__END_DECLS
106116
lib/libc/include/generic-freebsd/grp.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)grp.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _GRP_H_
lib/libc/include/generic-freebsd/iconv.h-2
......@@ -33,12 +33,10 @@
3333#ifndef _ICONV_H_
3434#define _ICONV_H_
3535
36#include <sys/cdefs.h>
3736#include <sys/types.h>
3837
3938#include <wchar.h>
4039
41#include <sys/cdefs.h>
4240#include <sys/types.h>
4341
4442#ifdef __cplusplus
lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_mount.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)cd9660_mount.h 8.1 (Berkeley) 5/24/95
3735 */
3836
3937/*
lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_node.h+1-3
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95
3735 */
3836
3937/*
......@@ -58,7 +56,7 @@ typedef struct {
5856
5957struct iso_node {
6058 struct vnode *i_vnode; /* vnode associated with this inode */
61 cd_ino_t i_number; /* the identity of the inode */
59 ino_t i_number; /* the identity of the inode */
6260 /* we use the actual starting block of the file */
6361 struct iso_mnt *i_mnt; /* filesystem associated with this inode */
6462 struct lockf *i_lockf; /* head of byte-level lock list */
lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_rrip.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)cd9660_rrip.h 8.2 (Berkeley) 12/5/94
3735 */
3836
3937#ifndef _ISOFS_CD9660_CD9660_RRIP_H_
lib/libc/include/generic-freebsd/isofs/cd9660/iso.h+9-16
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)iso.h 8.6 (Berkeley) 5/10/95
3735 */
3836
3937#ifndef _ISOFS_CD9660_ISO_H_
......@@ -214,21 +212,12 @@ struct iso_extended_attributes {
214212 u_char len_au [ISODCL (247, 250)]; /* 723 */
215213};
216214
217#ifdef _KERNEL
215#if defined(_KERNEL) || defined(_WANT_ISO_MNT)
218216
219217/* CD-ROM Format type */
220218enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP,
221219 ISO_FTYPE_JOLIET, ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA };
222220
223#ifndef ISOFSMNT_ROOT
224#define ISOFSMNT_ROOT 0
225#endif
226
227/*
228 * When ino_t becomes 64-bit, we can remove this definition in favor of ino_t.
229 */
230typedef __uint64_t cd_ino_t;
231
232221struct iso_mnt {
233222 uint64_t im_flags;
234223
......@@ -264,12 +253,16 @@ struct iso_mnt {
264253 void *im_l2d;
265254};
266255
256#endif /* defined(_KERNEL) || defined(_WANT_ISO_MNT) */
257
258#ifdef _KERNEL
259
267260struct ifid {
268261 u_short ifid_len;
269262 u_short ifid_pad;
270 cd_ino_t ifid_ino;
263 ino_t ifid_ino;
271264 long ifid_start;
272};
265} __packed;
273266
274267#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data))
275268
......@@ -278,7 +271,7 @@ struct ifid {
278271#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift)
279272#define blksize(imp, ip, lbn) ((imp)->logical_block_size)
280273
281int cd9660_vget_internal(struct mount *, cd_ino_t, int, struct vnode **, int,
274int cd9660_vget_internal(struct mount *, ino_t , int, struct vnode **, int,
282275 struct iso_directory_record *);
283276#define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
284277 size_t, struct proc *))eopnotsupp)
......@@ -289,7 +282,7 @@ extern struct vop_vector cd9660_fifoops;
289282int isochar(u_char *, u_char *, int, u_short *, int *, int, void *);
290283int isofncmp(u_char *, int, u_char *, int, int, int, void *, void *);
291284void isofntrans(u_char *, int, u_char *, u_short *, int, int, int, int, void *);
292cd_ino_t isodirino(struct iso_directory_record *, struct iso_mnt *);
285ino_t isodirino(struct iso_directory_record *, struct iso_mnt *);
293286u_short sgetrune(const char *, size_t, char const **, int, void *);
294287
295288#endif /* _KERNEL */
lib/libc/include/generic-freebsd/isofs/cd9660/iso_rrip.h+2-4
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)iso_rrip.h 8.2 (Berkeley) 1/23/94
3735 */
3836
3937#ifndef _ISOFS_CD9660_ISO_RRIP_H_
......@@ -65,7 +63,7 @@ typedef struct {
6563 off_t iso_ce_off; /* offset of continuation area */
6664 int iso_ce_len; /* length of continuation area */
6765 struct iso_mnt *imp; /* mount structure */
68 cd_ino_t *inump; /* inode number pointer */
66 ino_t *inump; /* inode number pointer */
6967 char *outbuf; /* name/symbolic link output area */
7068 u_short *outlen; /* length of above */
7169 u_short maxlen; /* maximum length of above */
......@@ -78,7 +76,7 @@ int cd9660_rrip_analyze(struct iso_directory_record *isodir,
7876 struct iso_node *inop, struct iso_mnt *imp);
7977int cd9660_rrip_getname(struct iso_directory_record *isodir,
8078 char *outbuf, u_short *outlen,
81 cd_ino_t *inump, struct iso_mnt *imp);
79 ino_t *inump, struct iso_mnt *imp);
8280int cd9660_rrip_getsymname(struct iso_directory_record *isodir,
8381 char *outbuf, u_short *outlen,
8482 struct iso_mnt *imp);
lib/libc/include/generic-freebsd/libsys.h created+25
......@@ -0,0 +1,25 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 SRI International
5 *
6 * This software was developed by SRI International, the University of
7 * Cambridge Computer Laboratory (Department of Computer Science and
8 * Technology), and Capabilities Limited under Defense Advanced Research
9 * Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
10 */
11
12#ifndef _LIBSYS_H_
13#define _LIBSYS_H_
14
15#include <sys/types.h>
16
17#include <_libsys.h>
18
19typedef int (__sys_syscall_t)(int number, ...);
20typedef int (__sys___syscall_t)(int64_t number, ...);
21
22int __sys_syscall(int number, ...);
23off_t __sys___syscall(int64_t number, ...);
24
25#endif /* _LIBSYS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/libutil.h+16-3
......@@ -86,10 +86,17 @@ struct termios;
8686struct winsize;
8787
8888__BEGIN_DECLS
89char *auth_getval(const char *_name);
9089void clean_environment(const char * const *_white,
9190 const char * const *_more_white);
92int expand_number(const char *_buf, uint64_t *_num);
91int expand_number(const char *_buf, int64_t *_num);
92int expand_unsigned(const char *_buf, uint64_t *_num);
93#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
94 __has_extension(c_generic_selections)
95#define expand_number(_buf, _num) \
96 _Generic((_num), \
97 uint64_t *: expand_unsigned, \
98 default: expand_number)((_buf), (_num))
99#endif
93100int extattr_namespace_to_string(int _attrnamespace, char **_string);
94101int extattr_string_to_namespace(const char *_string, int *_attrnamespace);
95102int flopen(const char *_path, int _flags, ...);
......@@ -213,7 +220,13 @@ int cpuset_parselist(const char *list, cpuset_t *mask);
213220#define CPUSET_PARSE_OK 0
214221#define CPUSET_PARSE_GETAFFINITY -1
215222#define CPUSET_PARSE_ERROR -2
216#define CPUSET_PARSE_INVALID_CPU -3
223#define CPUSET_PARSE_OUT_OF_RANGE -3
224#define CPUSET_PARSE_GETDOMAIN -4
225#define CPUSET_PARSE_INVALID_CPU CPUSET_PARSE_OUT_OF_RANGE /* backwards compat */
226#endif
227
228#ifdef _SYS_DOMAINSET_H_
229int domainset_parselist(const char *list, domainset_t *mask, int *policyp);
217230#endif
218231
219232__END_DECLS
lib/libc/include/generic-freebsd/limits.h+5-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.2 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _LIMITS_H_
......@@ -139,6 +137,11 @@
139137
140138#define MB_LEN_MAX 6 /* 31-bit UTF-8 */
141139
140#if __POSIX_VISIBLE >= 202405
141#define GETENTROPY_MAX 256
142#define NSIG_MAX 128 /* _SIG_MAXSIG from <signal.h> */
143#endif
144
142145#include <sys/limits.h>
143146
144147#if __POSIX_VISIBLE
lib/libc/include/generic-freebsd/locale.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)locale.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _LOCALE_H_
lib/libc/include/generic-freebsd/machine/_align.h+2-50
......@@ -1,53 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
2 * This file is in the public domain.
403 */
414
42#ifndef _POWERPC_INCLUDE__ALIGN_H_
43#define _POWERPC_INCLUDE__ALIGN_H_
44
45/*
46 * Round p (pointer or byte index) up to a correctly-aligned value
47 * for all data types (int, long, ...). The result is unsigned int
48 * and must be cast to any desired pointer type.
49 */
50#define _ALIGNBYTES (sizeof(register_t) - 1)
51#define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
52
53#endif /* !_POWERPC_INCLUDE__ALIGN_H_ */
\ No newline at end of file
5#include <x86/_align.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/_bus.h+15-34
......@@ -1,47 +1,28 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
2 * Copyright (c) 2005 The FreeBSD Foundation.
53 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer,
11 * without modification, immediately at the beginning of the file.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
4 * SPDX-License-Identifier: BSD-2-Clause
165 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
6 * Derived in part from NetBSD's bus.h files by (alphabetically):
7 * Christopher G. Demetriou
8 * Charles M. Hannum
9 * Jason Thorpe
10 * The NetBSD Foundation.
2811 */
2912
30#ifndef POWERPC_INCLUDE__BUS_H
31#define POWERPC_INCLUDE__BUS_H
32
33#include <vm/vm_param.h>
13#ifndef _MACHINE__BUS_H_
14#define _MACHINE__BUS_H_
3415
3516/*
36 * Bus address and size types
17 * Addresses (in bus space).
3718 */
38typedef vm_paddr_t bus_addr_t;
39typedef vm_size_t bus_size_t;
19typedef u_long bus_addr_t;
20typedef u_long bus_size_t;
4021
4122/*
42 * Access methods for bus resources and address space.
23 * Access methods for bus space.
4324 */
25typedef u_long bus_space_handle_t;
4426typedef struct bus_space *bus_space_tag_t;
45typedef vm_offset_t bus_space_handle_t;
4627
47#endif /* POWERPC_INCLUDE__BUS_H */
\ No newline at end of file
28#endif /* !_MACHINE__BUS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/_inttypes.h+2-219
......@@ -1,222 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $
2 * This file is in the public domain.
323 */
334
34#ifndef _MACHINE_INTTYPES_H_
35#define _MACHINE_INTTYPES_H_
36
37/*
38 * Macros for format specifiers.
39 */
40
41#ifdef __LP64__
42#define __PRI64 "l"
43#define __PRIptr "l"
44#else
45#define __PRI64 "ll"
46#define __PRIptr
47#endif
48
49/* fprintf(3) macros for signed integers. */
50
51#define PRId8 "d" /* int8_t */
52#define PRId16 "d" /* int16_t */
53#define PRId32 "d" /* int32_t */
54#define PRId64 __PRI64"d" /* int64_t */
55#define PRIdLEAST8 "d" /* int_least8_t */
56#define PRIdLEAST16 "d" /* int_least16_t */
57#define PRIdLEAST32 "d" /* int_least32_t */
58#define PRIdLEAST64 __PRI64"d" /* int_least64_t */
59#define PRIdFAST8 "d" /* int_fast8_t */
60#define PRIdFAST16 "d" /* int_fast16_t */
61#define PRIdFAST32 "d" /* int_fast32_t */
62#define PRIdFAST64 __PRI64"d" /* int_fast64_t */
63#define PRIdMAX "jd" /* intmax_t */
64#define PRIdPTR __PRIptr"d" /* intptr_t */
65
66#define PRIi8 "i" /* int8_t */
67#define PRIi16 "i" /* int16_t */
68#define PRIi32 "i" /* int32_t */
69#define PRIi64 __PRI64"i" /* int64_t */
70#define PRIiLEAST8 "i" /* int_least8_t */
71#define PRIiLEAST16 "i" /* int_least16_t */
72#define PRIiLEAST32 "i" /* int_least32_t */
73#define PRIiLEAST64 __PRI64"i" /* int_least64_t */
74#define PRIiFAST8 "i" /* int_fast8_t */
75#define PRIiFAST16 "i" /* int_fast16_t */
76#define PRIiFAST32 "i" /* int_fast32_t */
77#define PRIiFAST64 __PRI64"i" /* int_fast64_t */
78#define PRIiMAX "ji" /* intmax_t */
79#define PRIiPTR __PRIptr"i" /* intptr_t */
80
81/* fprintf(3) macros for unsigned integers. */
82
83#define PRIo8 "o" /* uint8_t */
84#define PRIo16 "o" /* uint16_t */
85#define PRIo32 "o" /* uint32_t */
86#define PRIo64 __PRI64"o" /* uint64_t */
87#define PRIoLEAST8 "o" /* uint_least8_t */
88#define PRIoLEAST16 "o" /* uint_least16_t */
89#define PRIoLEAST32 "o" /* uint_least32_t */
90#define PRIoLEAST64 __PRI64"o" /* uint_least64_t */
91#define PRIoFAST8 "o" /* uint_fast8_t */
92#define PRIoFAST16 "o" /* uint_fast16_t */
93#define PRIoFAST32 "o" /* uint_fast32_t */
94#define PRIoFAST64 __PRI64"o" /* uint_fast64_t */
95#define PRIoMAX "jo" /* uintmax_t */
96#define PRIoPTR __PRIptr"o" /* uintptr_t */
97
98#define PRIu8 "u" /* uint8_t */
99#define PRIu16 "u" /* uint16_t */
100#define PRIu32 "u" /* uint32_t */
101#define PRIu64 __PRI64"u" /* uint64_t */
102#define PRIuLEAST8 "u" /* uint_least8_t */
103#define PRIuLEAST16 "u" /* uint_least16_t */
104#define PRIuLEAST32 "u" /* uint_least32_t */
105#define PRIuLEAST64 __PRI64"u" /* uint_least64_t */
106#define PRIuFAST8 "u" /* uint_fast8_t */
107#define PRIuFAST16 "u" /* uint_fast16_t */
108#define PRIuFAST32 "u" /* uint_fast32_t */
109#define PRIuFAST64 __PRI64"u" /* uint_fast64_t */
110#define PRIuMAX "ju" /* uintmax_t */
111#define PRIuPTR __PRIptr"u" /* uintptr_t */
112
113#define PRIx8 "x" /* uint8_t */
114#define PRIx16 "x" /* uint16_t */
115#define PRIx32 "x" /* uint32_t */
116#define PRIx64 __PRI64"x" /* uint64_t */
117#define PRIxLEAST8 "x" /* uint_least8_t */
118#define PRIxLEAST16 "x" /* uint_least16_t */
119#define PRIxLEAST32 "x" /* uint_least32_t */
120#define PRIxLEAST64 __PRI64"x" /* uint_least64_t */
121#define PRIxFAST8 "x" /* uint_fast8_t */
122#define PRIxFAST16 "x" /* uint_fast16_t */
123#define PRIxFAST32 "x" /* uint_fast32_t */
124#define PRIxFAST64 __PRI64"x" /* uint_fast64_t */
125#define PRIxMAX "jx" /* uintmax_t */
126#define PRIxPTR __PRIptr"x" /* uintptr_t */
127
128#define PRIX8 "X" /* uint8_t */
129#define PRIX16 "X" /* uint16_t */
130#define PRIX32 "X" /* uint32_t */
131#define PRIX64 __PRI64"X" /* uint64_t */
132#define PRIXLEAST8 "X" /* uint_least8_t */
133#define PRIXLEAST16 "X" /* uint_least16_t */
134#define PRIXLEAST32 "X" /* uint_least32_t */
135#define PRIXLEAST64 __PRI64"X" /* uint_least64_t */
136#define PRIXFAST8 "X" /* uint_fast8_t */
137#define PRIXFAST16 "X" /* uint_fast16_t */
138#define PRIXFAST32 "X" /* uint_fast32_t */
139#define PRIXFAST64 __PRI64"X" /* uint_fast64_t */
140#define PRIXMAX "jX" /* uintmax_t */
141#define PRIXPTR __PRIptr"X" /* uintptr_t */
142
143/* fscanf(3) macros for signed integers. */
144
145#define SCNd8 "hhd" /* int8_t */
146#define SCNd16 "hd" /* int16_t */
147#define SCNd32 "d" /* int32_t */
148#define SCNd64 __PRI64"d" /* int64_t */
149#define SCNdLEAST8 "hhd" /* int_least8_t */
150#define SCNdLEAST16 "hd" /* int_least16_t */
151#define SCNdLEAST32 "d" /* int_least32_t */
152#define SCNdLEAST64 __PRI64"d" /* int_least64_t */
153#define SCNdFAST8 "d" /* int_fast8_t */
154#define SCNdFAST16 "d" /* int_fast16_t */
155#define SCNdFAST32 "d" /* int_fast32_t */
156#define SCNdFAST64 __PRI64"d" /* int_fast64_t */
157#define SCNdMAX "jd" /* intmax_t */
158#define SCNdPTR __PRIptr"d" /* intptr_t */
159
160#define SCNi8 "hhi" /* int8_t */
161#define SCNi16 "hi" /* int16_t */
162#define SCNi32 "i" /* int32_t */
163#define SCNi64 __PRI64"i" /* int64_t */
164#define SCNiLEAST8 "hhi" /* int_least8_t */
165#define SCNiLEAST16 "hi" /* int_least16_t */
166#define SCNiLEAST32 "i" /* int_least32_t */
167#define SCNiLEAST64 __PRI64"i" /* int_least64_t */
168#define SCNiFAST8 "i" /* int_fast8_t */
169#define SCNiFAST16 "i" /* int_fast16_t */
170#define SCNiFAST32 "i" /* int_fast32_t */
171#define SCNiFAST64 __PRI64"i" /* int_fast64_t */
172#define SCNiMAX "ji" /* intmax_t */
173#define SCNiPTR __PRIptr"i" /* intptr_t */
174
175/* fscanf(3) macros for unsigned integers. */
176
177#define SCNo8 "hho" /* uint8_t */
178#define SCNo16 "ho" /* uint16_t */
179#define SCNo32 "o" /* uint32_t */
180#define SCNo64 __PRI64"o" /* uint64_t */
181#define SCNoLEAST8 "hho" /* uint_least8_t */
182#define SCNoLEAST16 "ho" /* uint_least16_t */
183#define SCNoLEAST32 "o" /* uint_least32_t */
184#define SCNoLEAST64 __PRI64"o" /* uint_least64_t */
185#define SCNoFAST8 "o" /* uint_fast8_t */
186#define SCNoFAST16 "o" /* uint_fast16_t */
187#define SCNoFAST32 "o" /* uint_fast32_t */
188#define SCNoFAST64 __PRI64"o" /* uint_fast64_t */
189#define SCNoMAX "jo" /* uintmax_t */
190#define SCNoPTR __PRIptr"o" /* uintptr_t */
191
192#define SCNu8 "hhu" /* uint8_t */
193#define SCNu16 "hu" /* uint16_t */
194#define SCNu32 "u" /* uint32_t */
195#define SCNu64 __PRI64"u" /* uint64_t */
196#define SCNuLEAST8 "hhu" /* uint_least8_t */
197#define SCNuLEAST16 "hu" /* uint_least16_t */
198#define SCNuLEAST32 "u" /* uint_least32_t */
199#define SCNuLEAST64 __PRI64"u" /* uint_least64_t */
200#define SCNuFAST8 "u" /* uint_fast8_t */
201#define SCNuFAST16 "u" /* uint_fast16_t */
202#define SCNuFAST32 "u" /* uint_fast32_t */
203#define SCNuFAST64 __PRI64"u" /* uint_fast64_t */
204#define SCNuMAX "ju" /* uintmax_t */
205#define SCNuPTR __PRIptr"u" /* uintptr_t */
206
207#define SCNx8 "hhx" /* uint8_t */
208#define SCNx16 "hx" /* uint16_t */
209#define SCNx32 "x" /* uint32_t */
210#define SCNx64 __PRI64"x" /* uint64_t */
211#define SCNxLEAST8 "hhx" /* uint_least8_t */
212#define SCNxLEAST16 "hx" /* uint_least16_t */
213#define SCNxLEAST32 "x" /* uint_least32_t */
214#define SCNxLEAST64 __PRI64"x" /* uint_least64_t */
215#define SCNxFAST8 "x" /* uint_fast8_t */
216#define SCNxFAST16 "x" /* uint_fast16_t */
217#define SCNxFAST32 "x" /* uint_fast32_t */
218#define SCNxFAST64 __PRI64"x" /* uint_fast64_t */
219#define SCNxMAX "jx" /* uintmax_t */
220#define SCNxPTR __PRIptr"x" /* uintptr_t */
221
222#endif /* !_MACHINE_INTTYPES_H_ */
\ No newline at end of file
5#include <x86/_inttypes.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/_limits.h+2-95
......@@ -1,98 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
2 * This file is in the public domain.
323 */
334
34#ifndef _MACHINE__LIMITS_H_
35#define _MACHINE__LIMITS_H_
36
37/*
38 * According to ANSI (section 2.2.4.2), the values below must be usable by
39 * #if preprocessing directives. Additionally, the expression must have the
40 * same type as would an expression that is an object of the corresponding
41 * type converted according to the integral promotions. The subtraction for
42 * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
43 * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
44 */
45
46#define __CHAR_BIT 8 /* number of bits in a char */
47
48#define __SCHAR_MAX 0x7f /* max value for a signed char */
49#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
50
51#define __UCHAR_MAX 0xff /* max value for an unsigned char */
52
53#define __USHRT_MAX 0xffff /* max value for an unsigned short */
54#define __SHRT_MAX 0x7fff /* max value for a short */
55#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
56
57#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
58#define __INT_MAX 0x7fffffff /* max value for an int */
59#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
60
61#ifdef __LP64__
62#define __ULONG_MAX 0xffffffffffffffff
63#define __LONG_MAX 0x7fffffffffffffff
64#define __LONG_MIN (-0x7fffffffffffffff - 1)
65#define __LONG_BIT 64
66#else
67#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
68#define __LONG_MAX 0x7fffffffL /* max value for a long */
69#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
70#define __LONG_BIT 32
71#endif
72
73#define __ULLONG_MAX 0xffffffffffffffffULL
74#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
75#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
76
77#ifdef __LP64__
78#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */
79#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */
80#else
81#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */
82#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */
83#endif
84
85#define __OFF_MAX __LLONG_MAX /* max value for an off_t */
86#define __OFF_MIN __LLONG_MIN /* min value for an off_t */
87
88/* Quads and long longs are the same size. Ensure they stay in sync. */
89#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
90#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
91#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
92
93#define __WORD_BIT 32
94
95/* Minimum signal stack size. */
96#define __MINSIGSTKSZ (512 * 4)
97
98#endif /* !_MACHINE__LIMITS_H_ */
\ No newline at end of file
5#include <x86/_limits.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/_stdint.h+2-197
......@@ -1,200 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
5 * Copyright (c) 2001 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Klaus Klein.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
2 * This file is in the public domain.
383 */
394
40#ifndef _MACHINE__STDINT_H_
41#define _MACHINE__STDINT_H_
42
43#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
44
45#define INT8_C(c) (c)
46#define INT16_C(c) (c)
47#define INT32_C(c) (c)
48
49#define UINT8_C(c) (c)
50#define UINT16_C(c) (c)
51#define UINT32_C(c) (c ## U)
52
53#ifdef __LP64__
54#define INT64_C(c) (c ## L)
55#define UINT64_C(c) (c ## UL)
56#else
57#define INT64_C(c) (c ## LL)
58#define UINT64_C(c) (c ## ULL)
59#endif
60
61#define INTMAX_C(c) INT64_C(c)
62#define UINTMAX_C(c) UINT64_C(c)
63
64#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
65
66#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
67
68#ifndef __INT64_C
69#ifdef __LP64__
70#define __INT64_C(c) (c ## L)
71#define __UINT64_C(c) (c ## UL)
72#else
73#define __INT64_C(c) (c ## LL)
74#define __UINT64_C(c) (c ## ULL)
75#endif
76#endif
77
78/*
79 * ISO/IEC 9899:1999
80 * 7.18.2.1 Limits of exact-width integer types
81 */
82/* Minimum values of exact-width signed integer types. */
83#define INT8_MIN (-0x7f-1)
84#define INT16_MIN (-0x7fff-1)
85#define INT32_MIN (-0x7fffffff-1)
86#define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1)
87
88/* Maximum values of exact-width signed integer types. */
89#define INT8_MAX 0x7f
90#define INT16_MAX 0x7fff
91#define INT32_MAX 0x7fffffff
92#define INT64_MAX __INT64_C(0x7fffffffffffffff)
93
94/* Maximum values of exact-width unsigned integer types. */
95#define UINT8_MAX 0xff
96#define UINT16_MAX 0xffff
97#define UINT32_MAX 0xffffffff
98#define UINT64_MAX __UINT64_C(0xffffffffffffffff)
99
100/*
101 * ISO/IEC 9899:1999
102 * 7.18.2.2 Limits of minimum-width integer types
103 */
104/* Minimum values of minimum-width signed integer types. */
105#define INT_LEAST8_MIN INT8_MIN
106#define INT_LEAST16_MIN INT16_MIN
107#define INT_LEAST32_MIN INT32_MIN
108#define INT_LEAST64_MIN INT64_MIN
109
110/* Maximum values of minimum-width signed integer types. */
111#define INT_LEAST8_MAX INT8_MAX
112#define INT_LEAST16_MAX INT16_MAX
113#define INT_LEAST32_MAX INT32_MAX
114#define INT_LEAST64_MAX INT64_MAX
115
116/* Maximum values of minimum-width unsigned integer types. */
117#define UINT_LEAST8_MAX UINT8_MAX
118#define UINT_LEAST16_MAX UINT16_MAX
119#define UINT_LEAST32_MAX UINT32_MAX
120#define UINT_LEAST64_MAX UINT64_MAX
121
122/*
123 * ISO/IEC 9899:1999
124 * 7.18.2.3 Limits of fastest minimum-width integer types
125 */
126/* Minimum values of fastest minimum-width signed integer types. */
127#define INT_FAST8_MIN INT32_MIN
128#define INT_FAST16_MIN INT32_MIN
129#define INT_FAST32_MIN INT32_MIN
130#define INT_FAST64_MIN INT64_MIN
131
132/* Maximum values of fastest minimum-width signed integer types. */
133#define INT_FAST8_MAX INT32_MAX
134#define INT_FAST16_MAX INT32_MAX
135#define INT_FAST32_MAX INT32_MAX
136#define INT_FAST64_MAX INT64_MAX
137
138/* Maximum values of fastest minimum-width unsigned integer types. */
139#define UINT_FAST8_MAX UINT32_MAX
140#define UINT_FAST16_MAX UINT32_MAX
141#define UINT_FAST32_MAX UINT32_MAX
142#define UINT_FAST64_MAX UINT64_MAX
143
144/*
145 * ISO/IEC 9899:1999
146 * 7.18.2.4 Limits of integer types capable of holding object pointers
147 */
148#ifdef __LP64__
149#define INTPTR_MIN INT64_MIN
150#define INTPTR_MAX INT64_MAX
151#define UINTPTR_MAX UINT64_MAX
152#else
153#define INTPTR_MIN INT32_MIN
154#define INTPTR_MAX INT32_MAX
155#define UINTPTR_MAX UINT32_MAX
156#endif
157
158/*
159 * ISO/IEC 9899:1999
160 * 7.18.2.5 Limits of greatest-width integer types
161 */
162#define INTMAX_MIN INT64_MIN
163#define INTMAX_MAX INT64_MAX
164#define UINTMAX_MAX UINT64_MAX
165
166/*
167 * ISO/IEC 9899:1999
168 * 7.18.3 Limits of other integer types
169 */
170#ifdef __LP64__
171/* Limits of ptrdiff_t. */
172#define PTRDIFF_MIN INT64_MIN
173#define PTRDIFF_MAX INT64_MAX
174
175/* Limits of sig_atomic_t. */
176#define SIG_ATOMIC_MIN INT64_MIN
177#define SIG_ATOMIC_MAX INT64_MAX
178
179/* Limit of size_t. */
180#define SIZE_MAX UINT64_MAX
181#else
182/* Limits of ptrdiff_t. */
183#define PTRDIFF_MIN INT32_MIN
184#define PTRDIFF_MAX INT32_MAX
185
186/* Limits of sig_atomic_t. */
187#define SIG_ATOMIC_MIN INT32_MIN
188#define SIG_ATOMIC_MAX INT32_MAX
189
190/* Limit of size_t. */
191#define SIZE_MAX UINT32_MAX
192#endif
193
194/* Limits of wint_t. */
195#define WINT_MIN INT32_MIN
196#define WINT_MAX INT32_MAX
197
198#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
199
200#endif /* !_MACHINE__STDINT_H_ */
\ No newline at end of file
5#include <x86/_stdint.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/_types.h+2-89
......@@ -1,92 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
2 * This file is in the public domain.
383 */
394
40#ifndef _MACHINE__TYPES_H_
41#define _MACHINE__TYPES_H_
42
43#ifndef _SYS__TYPES_H_
44#error do not include this header, use sys/_types.h
45#endif
46
47/*
48 * Standard type definitions.
49 */
50typedef __uint32_t __clock_t; /* clock()... */
51#ifndef _STANDALONE
52typedef double __double_t;
53typedef float __float_t;
54#endif
55#ifdef __LP64__
56typedef __int64_t __critical_t;
57#else
58typedef __int32_t __critical_t;
59#endif
60typedef __int32_t __int_fast8_t;
61typedef __int32_t __int_fast16_t;
62typedef __int32_t __int_fast32_t;
63typedef __int64_t __int_fast64_t;
64#ifdef __LP64__
65typedef __int64_t __register_t;
66typedef __int64_t __segsz_t; /* segment size (in pages) */
67#else
68typedef __int32_t __register_t;
69typedef __int32_t __segsz_t; /* segment size (in pages) */
70#endif
71typedef __int64_t __time_t; /* time()... */
72typedef __uint32_t __uint_fast8_t;
73typedef __uint32_t __uint_fast16_t;
74typedef __uint32_t __uint_fast32_t;
75typedef __uint64_t __uint_fast64_t;
76#ifdef __LP64__
77typedef __uint64_t __u_register_t;
78typedef __uint64_t __vm_paddr_t;
79#else
80typedef __uint32_t __u_register_t;
81#ifdef BOOKE
82typedef __uint64_t __vm_paddr_t;
83#else
84typedef __uint32_t __vm_paddr_t;
85#endif
86#endif
87typedef int ___wchar_t;
88
89#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
90#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */
91
92#endif /* !_MACHINE__TYPES_H_ */
\ No newline at end of file
5#include <x86/_types.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/altivec.h deleted-41
......@@ -1,41 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Nathan Whitehorn
5 * All rights reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_ALTIVEC_H_
30#define _MACHINE_ALTIVEC_H_
31
32#define ALTIVEC_VSCR_NJ 0x00010000 /* Enable non-Java mode */
33#define ALTIVEC_VSCR_SAT 0x00000001 /* Saturation status bit */
34
35void enable_vec(struct thread *);
36void save_vec(struct thread *);
37void save_vec_nodrop(struct thread *);
38void enable_vec_kern(void);
39void disable_vec(struct thread *td);
40
41#endif /* _MACHINE_ALTIVEC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/asm.h deleted-267
......@@ -1,267 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: asm.h,v 1.6.18.1 2000/07/25 08:37:14 kleink Exp $
34 */
35
36#ifndef _MACHINE_ASM_H_
37#define _MACHINE_ASM_H_
38
39#include <sys/cdefs.h>
40
41#if defined(PIC) && !defined(__powerpc64__)
42#define PIC_PROLOGUE XXX
43#define PIC_EPILOGUE XXX
44#define PIC_PLT(x) x@plt
45#ifdef __STDC__
46#define PIC_GOT(x) XXX
47#else /* not __STDC__ */
48#define PIC_GOT(x) XXX
49#endif /* __STDC__ */
50#else
51#define PIC_PROLOGUE
52#define PIC_EPILOGUE
53#define PIC_PLT(x) x
54#define PIC_GOT(x) x
55#endif
56
57#define CNAME(csym) csym
58#define ASMNAME(asmsym) asmsym
59#ifdef __powerpc64__
60#define HIDENAME(asmsym) __CONCAT(_,asmsym)
61#else
62#define HIDENAME(asmsym) __CONCAT(.,asmsym)
63#endif
64
65#if !defined(_CALL_ELF) || _CALL_ELF == 1
66#ifdef _KERNEL
67/* ELFv1 kernel uses global dot symbols */
68#define DOT_LABEL(name) __CONCAT(.,name)
69#define TYPE_ENTRY(name) .size name,24; \
70 .type DOT_LABEL(name),@function; \
71 .globl DOT_LABEL(name);
72#define END_SIZE(name) .size DOT_LABEL(name),.-DOT_LABEL(name);
73#else /* !_KERNEL */
74/* ELFv1 user code uses local function entry points */
75#define DOT_LABEL(name) __CONCAT(.L.,name)
76#define TYPE_ENTRY(name) .type name,@function;
77#define END_SIZE(name) .size name,.-DOT_LABEL(name);
78#endif /* _KERNEL */
79#else
80/* ELFv2 doesn't have any of this complication */
81#define DOT_LABEL(name) name
82#define TYPE_ENTRY(name) .type name,@function;
83#define END_SIZE(name) .size name,.-DOT_LABEL(name);
84#endif
85
86#define _GLOBAL(name) \
87 .data; \
88 .p2align 2; \
89 .globl name; \
90 name:
91
92#ifdef __powerpc64__
93#define TOC_NAME_FOR_REF(name) __CONCAT(.L,name)
94#define TOC_REF(name) TOC_NAME_FOR_REF(name)@toc
95#define TOC_ENTRY(name) \
96 .section ".toc","aw"; \
97 TOC_NAME_FOR_REF(name): \
98 .tc name[TC],name
99#endif
100
101#ifdef __powerpc64__
102
103#if !defined(_CALL_ELF) || _CALL_ELF == 1
104#define _ENTRY(name) \
105 .section ".text"; \
106 .p2align 2; \
107 .globl name; \
108 .section ".opd","aw"; \
109 .p2align 3; \
110name: \
111 .quad DOT_LABEL(name),.TOC.@tocbase,0; \
112 .previous; \
113 .p2align 4; \
114 TYPE_ENTRY(name) \
115DOT_LABEL(name): \
116 .cfi_startproc
117#define _NAKED_ENTRY(name) _ENTRY(name)
118#else
119#define _ENTRY(name) \
120 .text; \
121 .p2align 4; \
122 .globl name; \
123 .type name,@function; \
124name: \
125 .cfi_startproc; \
126 addis %r2, %r12, (.TOC.-name)@ha; \
127 addi %r2, %r2, (.TOC.-name)@l; \
128 .localentry name, .-name;
129
130/* "Naked" function entry. No TOC prologue for ELFv2. */
131#define _NAKED_ENTRY(name) \
132 .text; \
133 .p2align 4; \
134 .globl name; \
135 .type name,@function; \
136name: \
137 .cfi_startproc; \
138 .localentry name, .-name;
139#endif
140
141#define _END(name) \
142 .cfi_endproc; \
143 .long 0; \
144 .byte 0,0,0,0,0,0,0,0; \
145 END_SIZE(name)
146
147#define LOAD_ADDR(reg, var) \
148 lis reg, var@highest; \
149 ori reg, reg, var@higher; \
150 rldicr reg, reg, 32, 31; \
151 oris reg, reg, var@h; \
152 ori reg, reg, var@l;
153#else /* !__powerpc64__ */
154#define _ENTRY(name) \
155 .text; \
156 .p2align 4; \
157 .globl name; \
158 .type name,@function; \
159name: \
160 .cfi_startproc
161#define _END(name) \
162 .cfi_endproc; \
163 .size name, . - name
164
165#define _NAKED_ENTRY(name) _ENTRY(name)
166
167#define LOAD_ADDR(reg, var) \
168 lis reg, var@ha; \
169 ori reg, reg, var@l;
170#endif /* __powerpc64__ */
171
172#if defined(PROF) || (defined(_KERNEL) && defined(GPROF))
173# ifdef __powerpc64__
174# define _PROF_PROLOGUE mflr 0; \
175 std 3,48(1); \
176 std 4,56(1); \
177 std 5,64(1); \
178 std 0,16(1); \
179 stdu 1,-112(1); \
180 bl _mcount; \
181 nop; \
182 ld 0,112+16(1); \
183 ld 3,112+48(1); \
184 ld 4,112+56(1); \
185 ld 5,112+64(1); \
186 mtlr 0; \
187 addi 1,1,112
188# else
189# define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount
190# endif
191#else
192# define _PROF_PROLOGUE
193#endif
194
195#define ASEND(y) _END(ASMNAME(y))
196#define ASENTRY(y) _ENTRY(ASMNAME(y)); _PROF_PROLOGUE
197#define END(y) _END(CNAME(y))
198#define ENTRY(y) _ENTRY(CNAME(y)); _PROF_PROLOGUE
199#define GLOBAL(y) _GLOBAL(CNAME(y))
200
201#define ASENTRY_NOPROF(y) _ENTRY(ASMNAME(y))
202#define ENTRY_NOPROF(y) _ENTRY(CNAME(y))
203
204/* Load NIA without affecting branch prediction */
205#define LOAD_LR_NIA bcl 20, 31, .+4
206
207/*
208 * Magic sequence to return to native endian.
209 * Overwrites r0 and r11.
210 *
211 * The encoding of the instruction "tdi 0, %r0, 0x48" in opposite endian
212 * happens to be "b . + 8". This is useful because we can write a sequence
213 * of instructions that can execute in either endian.
214 *
215 * Use a sequence of handcoded instructions that switches contexts to the
216 * instruction following the sequence, but with the correct PSL_LE bit.
217 *
218 * The same sequence works for both BE and LE because the xori will flip
219 * the bit to the other state, and the code only runs when running in the
220 * wrong endian.
221 *
222 * This sequence is NMI-reentrant.
223 *
224 * Do not change the length of this sequence without looking at the users,
225 * this is used in size-constrained places like the reset vector!
226 */
227#define RETURN_TO_NATIVE_ENDIAN \
228 tdi 0, %r0, 0x48; /* Endian swapped: b . + 8 */\
229 b 1f; /* Will fall through to here if correct */\
230 .long 0xa600607d; /* mfmsr %r11 */\
231 .long 0x00000038; /* li %r0, 0 */\
232 .long 0x6401617d; /* mtmsrd %r0, 1 (L=1 EE,RI bits only) */\
233 .long 0x01006b69; /* xori %r11, %r11, 0x1 (PSL_LE) */\
234 .long 0xa602087c; /* mflr %r0 */\
235 .long 0x05009f42; /* LOAD_LR_NIA */\
236 .long 0xa6037b7d; /* 0: mtsrr1 %r11 */\
237 .long 0xa602687d; /* mflr %r11 */\
238 .long 0x18006b39; /* addi %r11, %r11, (1f - 0b) */\
239 .long 0xa6037a7d; /* mtsrr0 %r11 */\
240 .long 0xa603087c; /* mtlr %r0 */\
241 .long 0x2400004c; /* rfid */\
2421: /* RETURN_TO_NATIVE_ENDIAN */
243
244#define ASMSTR .asciz
245
246#define RCSID(x) .text; .asciz x
247
248#undef __FBSDID
249#if !defined(lint) && !defined(STRIP_FBSDID)
250#define __FBSDID(s) .ident s
251#else
252#define __FBSDID(s) /* nothing */
253#endif /* not lint and not STRIP_FBSDID */
254
255#define WEAK_REFERENCE(sym, alias) \
256 .weak alias; \
257 .equ alias,sym
258
259#ifdef __STDC__
260#define WARN_REFERENCES(_sym,_msg) \
261 .section .gnu.warning. ## _sym ; .ascii _msg ; .text
262#else
263#define WARN_REFERENCES(_sym,_msg) \
264 .section .gnu.warning./**/_sym ; .ascii _msg ; .text
265#endif /* __STDC__ */
266
267#endif /* !_MACHINE_ASM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/atomic.h deleted-1148
......@@ -1,1148 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Marcel Moolenaar
5 * Copyright (c) 2001 Benno Rice
6 * Copyright (c) 2001 David E. O'Brien
7 * Copyright (c) 1998 Doug Rabson
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_ATOMIC_H_
33#define _MACHINE_ATOMIC_H_
34
35#include <sys/atomic_common.h>
36
37#ifndef __powerpc64__
38#include <sys/_atomic64e.h>
39#endif
40
41/*
42 * The __ATOMIC_REL/ACQ() macros provide memory barriers only in conjunction
43 * with the atomic lXarx/stXcx. sequences below. They are not exposed outside
44 * of this file. See also Appendix B.2 of Book II of the architecture manual.
45 *
46 * Note that not all Book-E processors accept the light-weight sync variant.
47 * In particular, early models of E500 cores are known to wedge. Bank on all
48 * 64-bit capable CPUs to accept lwsync properly and pressimize 32-bit CPUs
49 * to use the heavier-weight sync.
50 */
51
52#ifdef __powerpc64__
53#define mb() __asm __volatile("sync" : : : "memory")
54#define rmb() __asm __volatile("lwsync" : : : "memory")
55#define wmb() __asm __volatile("lwsync" : : : "memory")
56#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory")
57#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory")
58#else
59#define mb() __asm __volatile("sync" : : : "memory")
60#define rmb() __asm __volatile("sync" : : : "memory")
61#define wmb() __asm __volatile("sync" : : : "memory")
62#define __ATOMIC_REL() __asm __volatile("sync" : : : "memory")
63#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory")
64#endif
65
66static __inline void
67powerpc_lwsync(void)
68{
69
70#ifdef __powerpc64__
71 __asm __volatile("lwsync" : : : "memory");
72#else
73 __asm __volatile("sync" : : : "memory");
74#endif
75}
76
77/*
78 * atomic_add(p, v)
79 * { *p += v; }
80 */
81
82#define __atomic_add_int(p, v, t) \
83 __asm __volatile( \
84 "1: lwarx %0, 0, %2\n" \
85 " add %0, %3, %0\n" \
86 " stwcx. %0, 0, %2\n" \
87 " bne- 1b\n" \
88 : "=&r" (t), "=m" (*p) \
89 : "r" (p), "r" (v), "m" (*p) \
90 : "cr0", "memory") \
91 /* __atomic_add_int */
92
93#ifdef __powerpc64__
94#define __atomic_add_long(p, v, t) \
95 __asm __volatile( \
96 "1: ldarx %0, 0, %2\n" \
97 " add %0, %3, %0\n" \
98 " stdcx. %0, 0, %2\n" \
99 " bne- 1b\n" \
100 : "=&r" (t), "=m" (*p) \
101 : "r" (p), "r" (v), "m" (*p) \
102 : "cr0", "memory") \
103 /* __atomic_add_long */
104#else
105#define __atomic_add_long(p, v, t) \
106 __asm __volatile( \
107 "1: lwarx %0, 0, %2\n" \
108 " add %0, %3, %0\n" \
109 " stwcx. %0, 0, %2\n" \
110 " bne- 1b\n" \
111 : "=&r" (t), "=m" (*p) \
112 : "r" (p), "r" (v), "m" (*p) \
113 : "cr0", "memory") \
114 /* __atomic_add_long */
115#endif
116
117#define _ATOMIC_ADD(type) \
118 static __inline void \
119 atomic_add_##type(volatile u_##type *p, u_##type v) { \
120 u_##type t; \
121 __atomic_add_##type(p, v, t); \
122 } \
123 \
124 static __inline void \
125 atomic_add_acq_##type(volatile u_##type *p, u_##type v) { \
126 u_##type t; \
127 __atomic_add_##type(p, v, t); \
128 __ATOMIC_ACQ(); \
129 } \
130 \
131 static __inline void \
132 atomic_add_rel_##type(volatile u_##type *p, u_##type v) { \
133 u_##type t; \
134 __ATOMIC_REL(); \
135 __atomic_add_##type(p, v, t); \
136 } \
137 /* _ATOMIC_ADD */
138
139_ATOMIC_ADD(int)
140_ATOMIC_ADD(long)
141
142#define atomic_add_32 atomic_add_int
143#define atomic_add_acq_32 atomic_add_acq_int
144#define atomic_add_rel_32 atomic_add_rel_int
145
146#ifdef __powerpc64__
147#define atomic_add_64 atomic_add_long
148#define atomic_add_acq_64 atomic_add_acq_long
149#define atomic_add_rel_64 atomic_add_rel_long
150
151#define atomic_add_ptr atomic_add_long
152#define atomic_add_acq_ptr atomic_add_acq_long
153#define atomic_add_rel_ptr atomic_add_rel_long
154#else
155#define atomic_add_ptr atomic_add_int
156#define atomic_add_acq_ptr atomic_add_acq_int
157#define atomic_add_rel_ptr atomic_add_rel_int
158#endif
159#undef _ATOMIC_ADD
160#undef __atomic_add_long
161#undef __atomic_add_int
162
163/*
164 * atomic_clear(p, v)
165 * { *p &= ~v; }
166 */
167
168#define __atomic_clear_int(p, v, t) \
169 __asm __volatile( \
170 "1: lwarx %0, 0, %2\n" \
171 " andc %0, %0, %3\n" \
172 " stwcx. %0, 0, %2\n" \
173 " bne- 1b\n" \
174 : "=&r" (t), "=m" (*p) \
175 : "r" (p), "r" (v), "m" (*p) \
176 : "cr0", "memory") \
177 /* __atomic_clear_int */
178
179#ifdef __powerpc64__
180#define __atomic_clear_long(p, v, t) \
181 __asm __volatile( \
182 "1: ldarx %0, 0, %2\n" \
183 " andc %0, %0, %3\n" \
184 " stdcx. %0, 0, %2\n" \
185 " bne- 1b\n" \
186 : "=&r" (t), "=m" (*p) \
187 : "r" (p), "r" (v), "m" (*p) \
188 : "cr0", "memory") \
189 /* __atomic_clear_long */
190#else
191#define __atomic_clear_long(p, v, t) \
192 __asm __volatile( \
193 "1: lwarx %0, 0, %2\n" \
194 " andc %0, %0, %3\n" \
195 " stwcx. %0, 0, %2\n" \
196 " bne- 1b\n" \
197 : "=&r" (t), "=m" (*p) \
198 : "r" (p), "r" (v), "m" (*p) \
199 : "cr0", "memory") \
200 /* __atomic_clear_long */
201#endif
202
203#define _ATOMIC_CLEAR(type) \
204 static __inline void \
205 atomic_clear_##type(volatile u_##type *p, u_##type v) { \
206 u_##type t; \
207 __atomic_clear_##type(p, v, t); \
208 } \
209 \
210 static __inline void \
211 atomic_clear_acq_##type(volatile u_##type *p, u_##type v) { \
212 u_##type t; \
213 __atomic_clear_##type(p, v, t); \
214 __ATOMIC_ACQ(); \
215 } \
216 \
217 static __inline void \
218 atomic_clear_rel_##type(volatile u_##type *p, u_##type v) { \
219 u_##type t; \
220 __ATOMIC_REL(); \
221 __atomic_clear_##type(p, v, t); \
222 } \
223 /* _ATOMIC_CLEAR */
224
225_ATOMIC_CLEAR(int)
226_ATOMIC_CLEAR(long)
227
228#define atomic_clear_32 atomic_clear_int
229#define atomic_clear_acq_32 atomic_clear_acq_int
230#define atomic_clear_rel_32 atomic_clear_rel_int
231
232#ifdef __powerpc64__
233#define atomic_clear_64 atomic_clear_long
234#define atomic_clear_acq_64 atomic_clear_acq_long
235#define atomic_clear_rel_64 atomic_clear_rel_long
236
237#define atomic_clear_ptr atomic_clear_long
238#define atomic_clear_acq_ptr atomic_clear_acq_long
239#define atomic_clear_rel_ptr atomic_clear_rel_long
240#else
241#define atomic_clear_ptr atomic_clear_int
242#define atomic_clear_acq_ptr atomic_clear_acq_int
243#define atomic_clear_rel_ptr atomic_clear_rel_int
244#endif
245#undef _ATOMIC_CLEAR
246#undef __atomic_clear_long
247#undef __atomic_clear_int
248
249/*
250 * atomic_cmpset(p, o, n)
251 */
252/* TODO -- see below */
253
254/*
255 * atomic_load_acq(p)
256 */
257/* TODO -- see below */
258
259/*
260 * atomic_readandclear(p)
261 */
262/* TODO -- see below */
263
264/*
265 * atomic_set(p, v)
266 * { *p |= v; }
267 */
268
269#define __atomic_set_int(p, v, t) \
270 __asm __volatile( \
271 "1: lwarx %0, 0, %2\n" \
272 " or %0, %3, %0\n" \
273 " stwcx. %0, 0, %2\n" \
274 " bne- 1b\n" \
275 : "=&r" (t), "=m" (*p) \
276 : "r" (p), "r" (v), "m" (*p) \
277 : "cr0", "memory") \
278 /* __atomic_set_int */
279
280#ifdef __powerpc64__
281#define __atomic_set_long(p, v, t) \
282 __asm __volatile( \
283 "1: ldarx %0, 0, %2\n" \
284 " or %0, %3, %0\n" \
285 " stdcx. %0, 0, %2\n" \
286 " bne- 1b\n" \
287 : "=&r" (t), "=m" (*p) \
288 : "r" (p), "r" (v), "m" (*p) \
289 : "cr0", "memory") \
290 /* __atomic_set_long */
291#else
292#define __atomic_set_long(p, v, t) \
293 __asm __volatile( \
294 "1: lwarx %0, 0, %2\n" \
295 " or %0, %3, %0\n" \
296 " stwcx. %0, 0, %2\n" \
297 " bne- 1b\n" \
298 : "=&r" (t), "=m" (*p) \
299 : "r" (p), "r" (v), "m" (*p) \
300 : "cr0", "memory") \
301 /* __atomic_set_long */
302#endif
303
304#define _ATOMIC_SET(type) \
305 static __inline void \
306 atomic_set_##type(volatile u_##type *p, u_##type v) { \
307 u_##type t; \
308 __atomic_set_##type(p, v, t); \
309 } \
310 \
311 static __inline void \
312 atomic_set_acq_##type(volatile u_##type *p, u_##type v) { \
313 u_##type t; \
314 __atomic_set_##type(p, v, t); \
315 __ATOMIC_ACQ(); \
316 } \
317 \
318 static __inline void \
319 atomic_set_rel_##type(volatile u_##type *p, u_##type v) { \
320 u_##type t; \
321 __ATOMIC_REL(); \
322 __atomic_set_##type(p, v, t); \
323 } \
324 /* _ATOMIC_SET */
325
326_ATOMIC_SET(int)
327_ATOMIC_SET(long)
328
329#define atomic_set_32 atomic_set_int
330#define atomic_set_acq_32 atomic_set_acq_int
331#define atomic_set_rel_32 atomic_set_rel_int
332
333#ifdef __powerpc64__
334#define atomic_set_64 atomic_set_long
335#define atomic_set_acq_64 atomic_set_acq_long
336#define atomic_set_rel_64 atomic_set_rel_long
337
338#define atomic_set_ptr atomic_set_long
339#define atomic_set_acq_ptr atomic_set_acq_long
340#define atomic_set_rel_ptr atomic_set_rel_long
341#else
342#define atomic_set_ptr atomic_set_int
343#define atomic_set_acq_ptr atomic_set_acq_int
344#define atomic_set_rel_ptr atomic_set_rel_int
345#endif
346#undef _ATOMIC_SET
347#undef __atomic_set_long
348#undef __atomic_set_int
349
350/*
351 * atomic_subtract(p, v)
352 * { *p -= v; }
353 */
354
355#define __atomic_subtract_int(p, v, t) \
356 __asm __volatile( \
357 "1: lwarx %0, 0, %2\n" \
358 " subf %0, %3, %0\n" \
359 " stwcx. %0, 0, %2\n" \
360 " bne- 1b\n" \
361 : "=&r" (t), "=m" (*p) \
362 : "r" (p), "r" (v), "m" (*p) \
363 : "cr0", "memory") \
364 /* __atomic_subtract_int */
365
366#ifdef __powerpc64__
367#define __atomic_subtract_long(p, v, t) \
368 __asm __volatile( \
369 "1: ldarx %0, 0, %2\n" \
370 " subf %0, %3, %0\n" \
371 " stdcx. %0, 0, %2\n" \
372 " bne- 1b\n" \
373 : "=&r" (t), "=m" (*p) \
374 : "r" (p), "r" (v), "m" (*p) \
375 : "cr0", "memory") \
376 /* __atomic_subtract_long */
377#else
378#define __atomic_subtract_long(p, v, t) \
379 __asm __volatile( \
380 "1: lwarx %0, 0, %2\n" \
381 " subf %0, %3, %0\n" \
382 " stwcx. %0, 0, %2\n" \
383 " bne- 1b\n" \
384 : "=&r" (t), "=m" (*p) \
385 : "r" (p), "r" (v), "m" (*p) \
386 : "cr0", "memory") \
387 /* __atomic_subtract_long */
388#endif
389
390#define _ATOMIC_SUBTRACT(type) \
391 static __inline void \
392 atomic_subtract_##type(volatile u_##type *p, u_##type v) { \
393 u_##type t; \
394 __atomic_subtract_##type(p, v, t); \
395 } \
396 \
397 static __inline void \
398 atomic_subtract_acq_##type(volatile u_##type *p, u_##type v) { \
399 u_##type t; \
400 __atomic_subtract_##type(p, v, t); \
401 __ATOMIC_ACQ(); \
402 } \
403 \
404 static __inline void \
405 atomic_subtract_rel_##type(volatile u_##type *p, u_##type v) { \
406 u_##type t; \
407 __ATOMIC_REL(); \
408 __atomic_subtract_##type(p, v, t); \
409 } \
410 /* _ATOMIC_SUBTRACT */
411
412_ATOMIC_SUBTRACT(int)
413_ATOMIC_SUBTRACT(long)
414
415#define atomic_subtract_32 atomic_subtract_int
416#define atomic_subtract_acq_32 atomic_subtract_acq_int
417#define atomic_subtract_rel_32 atomic_subtract_rel_int
418
419#ifdef __powerpc64__
420#define atomic_subtract_64 atomic_subtract_long
421#define atomic_subtract_acq_64 atomic_subract_acq_long
422#define atomic_subtract_rel_64 atomic_subtract_rel_long
423
424#define atomic_subtract_ptr atomic_subtract_long
425#define atomic_subtract_acq_ptr atomic_subtract_acq_long
426#define atomic_subtract_rel_ptr atomic_subtract_rel_long
427#else
428#define atomic_subtract_ptr atomic_subtract_int
429#define atomic_subtract_acq_ptr atomic_subtract_acq_int
430#define atomic_subtract_rel_ptr atomic_subtract_rel_int
431#endif
432#undef _ATOMIC_SUBTRACT
433#undef __atomic_subtract_long
434#undef __atomic_subtract_int
435
436/*
437 * atomic_store_rel(p, v)
438 */
439/* TODO -- see below */
440
441/*
442 * Old/original implementations that still need revisiting.
443 */
444
445static __inline u_int
446atomic_readandclear_int(volatile u_int *addr)
447{
448 u_int result,temp;
449
450 __asm __volatile (
451 "\tsync\n" /* drain writes */
452 "1:\tlwarx %0, 0, %3\n\t" /* load old value */
453 "li %1, 0\n\t" /* load new value */
454 "stwcx. %1, 0, %3\n\t" /* attempt to store */
455 "bne- 1b\n\t" /* spin if failed */
456 : "=&r"(result), "=&r"(temp), "=m" (*addr)
457 : "r" (addr), "m" (*addr)
458 : "cr0", "memory");
459
460 return (result);
461}
462
463#ifdef __powerpc64__
464static __inline u_long
465atomic_readandclear_long(volatile u_long *addr)
466{
467 u_long result,temp;
468
469 __asm __volatile (
470 "\tsync\n" /* drain writes */
471 "1:\tldarx %0, 0, %3\n\t" /* load old value */
472 "li %1, 0\n\t" /* load new value */
473 "stdcx. %1, 0, %3\n\t" /* attempt to store */
474 "bne- 1b\n\t" /* spin if failed */
475 : "=&r"(result), "=&r"(temp), "=m" (*addr)
476 : "r" (addr), "m" (*addr)
477 : "cr0", "memory");
478
479 return (result);
480}
481#endif
482
483#define atomic_readandclear_32 atomic_readandclear_int
484
485#ifdef __powerpc64__
486#define atomic_readandclear_64 atomic_readandclear_long
487
488#define atomic_readandclear_ptr atomic_readandclear_long
489#else
490static __inline u_long
491atomic_readandclear_long(volatile u_long *addr)
492{
493
494 return ((u_long)atomic_readandclear_int((volatile u_int *)addr));
495}
496
497#define atomic_readandclear_ptr atomic_readandclear_int
498#endif
499
500/*
501 * We assume that a = b will do atomic loads and stores.
502 */
503#define ATOMIC_STORE_LOAD(TYPE) \
504static __inline u_##TYPE \
505atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
506{ \
507 u_##TYPE v; \
508 \
509 v = *p; \
510 powerpc_lwsync(); \
511 return (v); \
512} \
513 \
514static __inline void \
515atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) \
516{ \
517 \
518 powerpc_lwsync(); \
519 *p = v; \
520}
521
522ATOMIC_STORE_LOAD(int)
523
524#define atomic_load_acq_32 atomic_load_acq_int
525#define atomic_store_rel_32 atomic_store_rel_int
526
527#ifdef __powerpc64__
528ATOMIC_STORE_LOAD(long)
529
530#define atomic_load_acq_64 atomic_load_acq_long
531#define atomic_store_rel_64 atomic_store_rel_long
532
533#define atomic_load_acq_ptr atomic_load_acq_long
534#define atomic_store_rel_ptr atomic_store_rel_long
535#else
536static __inline u_long
537atomic_load_acq_long(volatile u_long *addr)
538{
539
540 return ((u_long)atomic_load_acq_int((volatile u_int *)addr));
541}
542
543static __inline void
544atomic_store_rel_long(volatile u_long *addr, u_long val)
545{
546
547 atomic_store_rel_int((volatile u_int *)addr, (u_int)val);
548}
549
550#define atomic_load_acq_ptr atomic_load_acq_int
551#define atomic_store_rel_ptr atomic_store_rel_int
552#endif
553#undef ATOMIC_STORE_LOAD
554
555/*
556 * Atomically compare the value stored at *p with cmpval and if the
557 * two values are equal, update the value of *p with newval. Returns
558 * zero if the compare failed, nonzero otherwise.
559 */
560#ifdef ISA_206_ATOMICS
561static __inline int
562atomic_cmpset_char(volatile u_char *p, u_char cmpval, u_char newval)
563{
564 int ret;
565
566 __asm __volatile (
567 "1:\tlbarx %0, 0, %2\n\t" /* load old value */
568 "cmplw %3, %0\n\t" /* compare */
569 "bne- 2f\n\t" /* exit if not equal */
570 "stbcx. %4, 0, %2\n\t" /* attempt to store */
571 "bne- 1b\n\t" /* spin if failed */
572 "li %0, 1\n\t" /* success - retval = 1 */
573 "b 3f\n\t" /* we've succeeded */
574 "2:\n\t"
575 "stbcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
576 "li %0, 0\n\t" /* failure - retval = 0 */
577 "3:\n\t"
578 : "=&r" (ret), "=m" (*p)
579 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
580 : "cr0", "memory");
581
582 return (ret);
583}
584
585static __inline int
586atomic_cmpset_short(volatile u_short *p, u_short cmpval, u_short newval)
587{
588 int ret;
589
590 __asm __volatile (
591 "1:\tlharx %0, 0, %2\n\t" /* load old value */
592 "cmplw %3, %0\n\t" /* compare */
593 "bne- 2f\n\t" /* exit if not equal */
594 "sthcx. %4, 0, %2\n\t" /* attempt to store */
595 "bne- 1b\n\t" /* spin if failed */
596 "li %0, 1\n\t" /* success - retval = 1 */
597 "b 3f\n\t" /* we've succeeded */
598 "2:\n\t"
599 "sthcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
600 "li %0, 0\n\t" /* failure - retval = 0 */
601 "3:\n\t"
602 : "=&r" (ret), "=m" (*p)
603 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
604 : "cr0", "memory");
605
606 return (ret);
607}
608#else
609static __inline int
610atomic_cmpset_masked(uint32_t *p, uint32_t cmpval, uint32_t newval,
611 uint32_t mask)
612{
613 int ret;
614 uint32_t tmp;
615
616 __asm __volatile (
617 "1:\tlwarx %2, 0, %3\n\t" /* load old value */
618 "and %0, %2, %7\n\t"
619 "cmplw %4, %0\n\t" /* compare */
620 "bne- 2f\n\t" /* exit if not equal */
621 "andc %2, %2, %7\n\t"
622 "or %2, %2, %5\n\t"
623 "stwcx. %2, 0, %3\n\t" /* attempt to store */
624 "bne- 1b\n\t" /* spin if failed */
625 "li %0, 1\n\t" /* success - retval = 1 */
626 "b 3f\n\t" /* we've succeeded */
627 "2:\n\t"
628 "stwcx. %2, 0, %3\n\t" /* clear reservation (74xx) */
629 "li %0, 0\n\t" /* failure - retval = 0 */
630 "3:\n\t"
631 : "=&r" (ret), "=m" (*p), "+&r" (tmp)
632 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p),
633 "r" (mask)
634 : "cr0", "memory");
635
636 return (ret);
637}
638
639#define _atomic_cmpset_masked_word(a,o,v,m) atomic_cmpset_masked(a, o, v, m)
640#endif
641
642static __inline int
643atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval)
644{
645 int ret;
646
647 __asm __volatile (
648 "1:\tlwarx %0, 0, %2\n\t" /* load old value */
649 "cmplw %3, %0\n\t" /* compare */
650 "bne- 2f\n\t" /* exit if not equal */
651 "stwcx. %4, 0, %2\n\t" /* attempt to store */
652 "bne- 1b\n\t" /* spin if failed */
653 "li %0, 1\n\t" /* success - retval = 1 */
654 "b 3f\n\t" /* we've succeeded */
655 "2:\n\t"
656 "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
657 "li %0, 0\n\t" /* failure - retval = 0 */
658 "3:\n\t"
659 : "=&r" (ret), "=m" (*p)
660 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
661 : "cr0", "memory");
662
663 return (ret);
664}
665static __inline int
666atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval)
667{
668 int ret;
669
670 __asm __volatile (
671 #ifdef __powerpc64__
672 "1:\tldarx %0, 0, %2\n\t" /* load old value */
673 "cmpld %3, %0\n\t" /* compare */
674 "bne- 2f\n\t" /* exit if not equal */
675 "stdcx. %4, 0, %2\n\t" /* attempt to store */
676 #else
677 "1:\tlwarx %0, 0, %2\n\t" /* load old value */
678 "cmplw %3, %0\n\t" /* compare */
679 "bne- 2f\n\t" /* exit if not equal */
680 "stwcx. %4, 0, %2\n\t" /* attempt to store */
681 #endif
682 "bne- 1b\n\t" /* spin if failed */
683 "li %0, 1\n\t" /* success - retval = 1 */
684 "b 3f\n\t" /* we've succeeded */
685 "2:\n\t"
686 #ifdef __powerpc64__
687 "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
688 #else
689 "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
690 #endif
691 "li %0, 0\n\t" /* failure - retval = 0 */
692 "3:\n\t"
693 : "=&r" (ret), "=m" (*p)
694 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
695 : "cr0", "memory");
696
697 return (ret);
698}
699
700#define ATOMIC_CMPSET_ACQ_REL(type) \
701 static __inline int \
702 atomic_cmpset_acq_##type(volatile u_##type *p, \
703 u_##type cmpval, u_##type newval)\
704 {\
705 u_##type retval; \
706 retval = atomic_cmpset_##type(p, cmpval, newval);\
707 __ATOMIC_ACQ();\
708 return (retval);\
709 }\
710 static __inline int \
711 atomic_cmpset_rel_##type(volatile u_##type *p, \
712 u_##type cmpval, u_##type newval)\
713 {\
714 __ATOMIC_REL();\
715 return (atomic_cmpset_##type(p, cmpval, newval));\
716 }\
717 struct hack
718
719ATOMIC_CMPSET_ACQ_REL(int);
720ATOMIC_CMPSET_ACQ_REL(long);
721
722#ifdef ISA_206_ATOMICS
723#define atomic_cmpset_8 atomic_cmpset_char
724#endif
725#define atomic_cmpset_acq_8 atomic_cmpset_acq_char
726#define atomic_cmpset_rel_8 atomic_cmpset_rel_char
727
728#ifdef ISA_206_ATOMICS
729#define atomic_cmpset_16 atomic_cmpset_short
730#endif
731#define atomic_cmpset_acq_16 atomic_cmpset_acq_short
732#define atomic_cmpset_rel_16 atomic_cmpset_rel_short
733
734#define atomic_cmpset_32 atomic_cmpset_int
735#define atomic_cmpset_acq_32 atomic_cmpset_acq_int
736#define atomic_cmpset_rel_32 atomic_cmpset_rel_int
737
738#ifdef __powerpc64__
739#define atomic_cmpset_64 atomic_cmpset_long
740#define atomic_cmpset_acq_64 atomic_cmpset_acq_long
741#define atomic_cmpset_rel_64 atomic_cmpset_rel_long
742
743#define atomic_cmpset_ptr atomic_cmpset_long
744#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long
745#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long
746#else
747#define atomic_cmpset_ptr atomic_cmpset_int
748#define atomic_cmpset_acq_ptr atomic_cmpset_acq_int
749#define atomic_cmpset_rel_ptr atomic_cmpset_rel_int
750#endif
751
752/*
753 * Atomically compare the value stored at *p with *cmpval and if the
754 * two values are equal, update the value of *p with newval. Returns
755 * zero if the compare failed and sets *cmpval to the read value from *p,
756 * nonzero otherwise.
757 */
758#ifdef ISA_206_ATOMICS
759static __inline int
760atomic_fcmpset_char(volatile u_char *p, u_char *cmpval, u_char newval)
761{
762 int ret;
763
764 __asm __volatile (
765 "lbarx %0, 0, %3\n\t" /* load old value */
766 "cmplw %4, %0\n\t" /* compare */
767 "bne- 1f\n\t" /* exit if not equal */
768 "stbcx. %5, 0, %3\n\t" /* attempt to store */
769 "bne- 1f\n\t" /* exit if failed */
770 "li %0, 1\n\t" /* success - retval = 1 */
771 "b 2f\n\t" /* we've succeeded */
772 "1:\n\t"
773 "stbcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
774 "stbx %0, 0, %7\n\t"
775 "li %0, 0\n\t" /* failure - retval = 0 */
776 "2:\n\t"
777 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
778 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
779 : "cr0", "memory");
780
781 return (ret);
782}
783
784static __inline int
785atomic_fcmpset_short(volatile u_short *p, u_short *cmpval, u_short newval)
786{
787 int ret;
788
789 __asm __volatile (
790 "lharx %0, 0, %3\n\t" /* load old value */
791 "cmplw %4, %0\n\t" /* compare */
792 "bne- 1f\n\t" /* exit if not equal */
793 "sthcx. %5, 0, %3\n\t" /* attempt to store */
794 "bne- 1f\n\t" /* exit if failed */
795 "li %0, 1\n\t" /* success - retval = 1 */
796 "b 2f\n\t" /* we've succeeded */
797 "1:\n\t"
798 "sthcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
799 "sthx %0, 0, %7\n\t"
800 "li %0, 0\n\t" /* failure - retval = 0 */
801 "2:\n\t"
802 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
803 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
804 : "cr0", "memory");
805
806 return (ret);
807}
808#endif /* ISA_206_ATOMICS */
809
810static __inline int
811atomic_fcmpset_int(volatile u_int *p, u_int *cmpval, u_int newval)
812{
813 int ret;
814
815 __asm __volatile (
816 "lwarx %0, 0, %3\n\t" /* load old value */
817 "cmplw %4, %0\n\t" /* compare */
818 "bne- 1f\n\t" /* exit if not equal */
819 "stwcx. %5, 0, %3\n\t" /* attempt to store */
820 "bne- 1f\n\t" /* exit if failed */
821 "li %0, 1\n\t" /* success - retval = 1 */
822 "b 2f\n\t" /* we've succeeded */
823 "1:\n\t"
824 "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
825 "stwx %0, 0, %7\n\t"
826 "li %0, 0\n\t" /* failure - retval = 0 */
827 "2:\n\t"
828 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
829 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
830 : "cr0", "memory");
831
832 return (ret);
833}
834static __inline int
835atomic_fcmpset_long(volatile u_long *p, u_long *cmpval, u_long newval)
836{
837 int ret;
838
839 __asm __volatile (
840 #ifdef __powerpc64__
841 "ldarx %0, 0, %3\n\t" /* load old value */
842 "cmpld %4, %0\n\t" /* compare */
843 "bne- 1f\n\t" /* exit if not equal */
844 "stdcx. %5, 0, %3\n\t" /* attempt to store */
845 #else
846 "lwarx %0, 0, %3\n\t" /* load old value */
847 "cmplw %4, %0\n\t" /* compare */
848 "bne- 1f\n\t" /* exit if not equal */
849 "stwcx. %5, 0, %3\n\t" /* attempt to store */
850 #endif
851 "bne- 1f\n\t" /* exit if failed */
852 "li %0, 1\n\t" /* success - retval = 1 */
853 "b 2f\n\t" /* we've succeeded */
854 "1:\n\t"
855 #ifdef __powerpc64__
856 "stdcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
857 "stdx %0, 0, %7\n\t"
858 #else
859 "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
860 "stwx %0, 0, %7\n\t"
861 #endif
862 "li %0, 0\n\t" /* failure - retval = 0 */
863 "2:\n\t"
864 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
865 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
866 : "cr0", "memory");
867
868 return (ret);
869}
870
871#define ATOMIC_FCMPSET_ACQ_REL(type) \
872 static __inline int \
873 atomic_fcmpset_acq_##type(volatile u_##type *p, \
874 u_##type *cmpval, u_##type newval)\
875 {\
876 u_##type retval; \
877 retval = atomic_fcmpset_##type(p, cmpval, newval);\
878 __ATOMIC_ACQ();\
879 return (retval);\
880 }\
881 static __inline int \
882 atomic_fcmpset_rel_##type(volatile u_##type *p, \
883 u_##type *cmpval, u_##type newval)\
884 {\
885 __ATOMIC_REL();\
886 return (atomic_fcmpset_##type(p, cmpval, newval));\
887 }\
888 struct hack
889
890ATOMIC_FCMPSET_ACQ_REL(int);
891ATOMIC_FCMPSET_ACQ_REL(long);
892
893#ifdef ISA_206_ATOMICS
894#define atomic_fcmpset_8 atomic_fcmpset_char
895#endif
896#define atomic_fcmpset_acq_8 atomic_fcmpset_acq_char
897#define atomic_fcmpset_rel_8 atomic_fcmpset_rel_char
898
899#ifdef ISA_206_ATOMICS
900#define atomic_fcmpset_16 atomic_fcmpset_short
901#endif
902#define atomic_fcmpset_acq_16 atomic_fcmpset_acq_short
903#define atomic_fcmpset_rel_16 atomic_fcmpset_rel_short
904
905#define atomic_fcmpset_32 atomic_fcmpset_int
906#define atomic_fcmpset_acq_32 atomic_fcmpset_acq_int
907#define atomic_fcmpset_rel_32 atomic_fcmpset_rel_int
908
909#ifdef __powerpc64__
910#define atomic_fcmpset_64 atomic_fcmpset_long
911#define atomic_fcmpset_acq_64 atomic_fcmpset_acq_long
912#define atomic_fcmpset_rel_64 atomic_fcmpset_rel_long
913
914#define atomic_fcmpset_ptr atomic_fcmpset_long
915#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long
916#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long
917#else
918#define atomic_fcmpset_ptr atomic_fcmpset_int
919#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_int
920#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_int
921#endif
922
923static __inline u_int
924atomic_fetchadd_int(volatile u_int *p, u_int v)
925{
926 u_int value;
927
928 do {
929 value = *p;
930 } while (!atomic_cmpset_int(p, value, value + v));
931 return (value);
932}
933
934static __inline u_long
935atomic_fetchadd_long(volatile u_long *p, u_long v)
936{
937 u_long value;
938
939 do {
940 value = *p;
941 } while (!atomic_cmpset_long(p, value, value + v));
942 return (value);
943}
944
945static __inline u_int
946atomic_swap_32(volatile u_int *p, u_int v)
947{
948 u_int prev;
949
950 __asm __volatile(
951 "1: lwarx %0,0,%2\n"
952 " stwcx. %3,0,%2\n"
953 " bne- 1b\n"
954 : "=&r" (prev), "+m" (*(volatile u_int *)p)
955 : "r" (p), "r" (v)
956 : "cr0", "memory");
957
958 return (prev);
959}
960
961#ifdef __powerpc64__
962static __inline u_long
963atomic_swap_64(volatile u_long *p, u_long v)
964{
965 u_long prev;
966
967 __asm __volatile(
968 "1: ldarx %0,0,%2\n"
969 " stdcx. %3,0,%2\n"
970 " bne- 1b\n"
971 : "=&r" (prev), "+m" (*(volatile u_long *)p)
972 : "r" (p), "r" (v)
973 : "cr0", "memory");
974
975 return (prev);
976}
977#endif
978
979#define atomic_fetchadd_32 atomic_fetchadd_int
980#define atomic_swap_int atomic_swap_32
981
982#ifdef __powerpc64__
983#define atomic_fetchadd_64 atomic_fetchadd_long
984#define atomic_swap_long atomic_swap_64
985#define atomic_swap_ptr atomic_swap_64
986#else
987#define atomic_swap_long(p,v) atomic_swap_32((volatile u_int *)(p), v)
988#define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v)
989#endif
990
991static __inline int
992atomic_testandset_int(volatile u_int *p, u_int v)
993{
994 u_int m = (1u << (v & 0x1f));
995 u_int res;
996 u_int tmp;
997
998 __asm __volatile(
999 "1: lwarx %0,0,%3\n"
1000 " and %1,%0,%4\n"
1001 " or %0,%0,%4\n"
1002 " stwcx. %0,0,%3\n"
1003 " bne- 1b\n"
1004 : "=&r"(tmp), "=&r"(res), "+m"(*p)
1005 : "r"(p), "r"(m)
1006 : "cr0", "memory");
1007
1008 return (res != 0);
1009}
1010
1011static __inline int
1012atomic_testandclear_int(volatile u_int *p, u_int v)
1013{
1014 u_int m = (1u << (v & 0x1f));
1015 u_int res;
1016 u_int tmp;
1017
1018 __asm __volatile(
1019 "1: lwarx %0,0,%3\n"
1020 " and %1,%0,%4\n"
1021 " andc %0,%0,%4\n"
1022 " stwcx. %0,0,%3\n"
1023 " bne- 1b\n"
1024 : "=&r"(tmp), "=&r"(res), "+m"(*p)
1025 : "r"(p), "r"(m)
1026 : "cr0", "memory");
1027
1028 return (res != 0);
1029}
1030
1031#ifdef __powerpc64__
1032static __inline int
1033atomic_testandset_long(volatile u_long *p, u_int v)
1034{
1035 u_long m = (1ul << (v & 0x3f));
1036 u_long res;
1037 u_long tmp;
1038
1039 __asm __volatile(
1040 "1: ldarx %0,0,%3\n"
1041 " and %1,%0,%4\n"
1042 " or %0,%0,%4\n"
1043 " stdcx. %0,0,%3\n"
1044 " bne- 1b\n"
1045 : "=&r"(tmp), "=&r"(res), "+m"(*(volatile u_long *)p)
1046 : "r"(p), "r"(m)
1047 : "cr0", "memory");
1048
1049 return (res != 0);
1050}
1051
1052static __inline int
1053atomic_testandclear_long(volatile u_long *p, u_int v)
1054{
1055 u_long m = (1ul << (v & 0x3f));
1056 u_long res;
1057 u_long tmp;
1058
1059 __asm __volatile(
1060 "1: ldarx %0,0,%3\n"
1061 " and %1,%0,%4\n"
1062 " andc %0,%0,%4\n"
1063 " stdcx. %0,0,%3\n"
1064 " bne- 1b\n"
1065 : "=&r"(tmp), "=&r"(res), "+m"(*p)
1066 : "r"(p), "r"(m)
1067 : "cr0", "memory");
1068
1069 return (res != 0);
1070}
1071#else
1072static __inline int
1073atomic_testandset_long(volatile u_long *p, u_int v)
1074{
1075 return (atomic_testandset_int((volatile u_int *)p, v));
1076}
1077
1078static __inline int
1079atomic_testandclear_long(volatile u_long *p, u_int v)
1080{
1081 return (atomic_testandclear_int((volatile u_int *)p, v));
1082}
1083#endif
1084
1085#define atomic_testandclear_32 atomic_testandclear_int
1086#define atomic_testandset_32 atomic_testandset_int
1087
1088static __inline int
1089atomic_testandset_acq_long(volatile u_long *p, u_int v)
1090{
1091 u_int a = atomic_testandset_long(p, v);
1092 __ATOMIC_ACQ();
1093 return (a);
1094}
1095
1096#define atomic_testandclear_int atomic_testandclear_int
1097#define atomic_testandset_int atomic_testandset_int
1098#define atomic_testandclear_long atomic_testandclear_long
1099#define atomic_testandset_long atomic_testandset_long
1100#define atomic_testandset_acq_long atomic_testandset_acq_long
1101
1102static __inline void
1103atomic_thread_fence_acq(void)
1104{
1105
1106 powerpc_lwsync();
1107}
1108
1109static __inline void
1110atomic_thread_fence_rel(void)
1111{
1112
1113 powerpc_lwsync();
1114}
1115
1116static __inline void
1117atomic_thread_fence_acq_rel(void)
1118{
1119
1120 powerpc_lwsync();
1121}
1122
1123static __inline void
1124atomic_thread_fence_seq_cst(void)
1125{
1126
1127 __asm __volatile("sync" : : : "memory");
1128}
1129
1130#ifndef ISA_206_ATOMICS
1131#include <sys/_atomic_subword.h>
1132#define atomic_cmpset_char atomic_cmpset_8
1133#define atomic_cmpset_short atomic_cmpset_16
1134#define atomic_fcmpset_char atomic_fcmpset_8
1135#define atomic_fcmpset_short atomic_fcmpset_16
1136#endif
1137
1138/* These need sys/_atomic_subword.h on non-ISA-2.06-atomic platforms. */
1139ATOMIC_CMPSET_ACQ_REL(char);
1140ATOMIC_CMPSET_ACQ_REL(short);
1141
1142ATOMIC_FCMPSET_ACQ_REL(char);
1143ATOMIC_FCMPSET_ACQ_REL(short);
1144
1145#undef __ATOMIC_REL
1146#undef __ATOMIC_ACQ
1147
1148#endif /* ! _MACHINE_ATOMIC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/bat.h deleted-167
......@@ -1,167 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause
3 *
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*-
33 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
34 * Copyright (C) 1995, 1996 TooLs GmbH.
35 * All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by TooLs GmbH.
48 * 4. The name of TooLs GmbH may not be used to endorse or promote products
49 * derived from this software without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
52 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
54 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
56 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
57 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
58 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
59 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
60 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 * $NetBSD: bat.h,v 1.2 1999/12/18 01:36:06 thorpej Exp $
63 */
64
65#ifndef _MACHINE_BAT_H_
66#define _MACHINE_BAT_H_
67
68#ifndef LOCORE
69struct bat {
70 u_int32_t batu;
71 u_int32_t batl;
72};
73#endif
74
75/* Lower BAT bits (all but PowerPC 601): */
76#define BAT_PBS 0xfffe0000 /* physical block start */
77#define BAT_W 0x00000040 /* 1 = write-through, 0 = write-back */
78#define BAT_I 0x00000020 /* cache inhibit */
79#define BAT_M 0x00000010 /* memory coherency enable */
80#define BAT_G 0x00000008 /* guarded region */
81
82#define BAT_PP_NONE 0x00000000 /* no access permission */
83#define BAT_PP_RO_S 0x00000001 /* read-only (soft) */
84#define BAT_PP_RW 0x00000002 /* read/write */
85#define BAT_PP_RO 0x00000003 /* read-only */
86
87/* Upper BAT bits (all but PowerPC 601): */
88#define BAT_EBS 0xfffe0000 /* effective block start */
89#define BAT_BL 0x00001ffc /* block length */
90#define BAT_Vs 0x00000002 /* valid in supervisor mode */
91#define BAT_Vu 0x00000001 /* valid in user mode */
92
93#define BAT_V (BAT_Vs|BAT_Vu)
94
95/* Block Length encoding (all but PowerPC 601): */
96#define BAT_BL_128K 0x00000000
97#define BAT_BL_256K 0x00000004
98#define BAT_BL_512K 0x0000000c
99#define BAT_BL_1M 0x0000001c
100#define BAT_BL_2M 0x0000003c
101#define BAT_BL_4M 0x0000007c
102#define BAT_BL_8M 0x000000fc
103#define BAT_BL_16M 0x000001fc
104#define BAT_BL_32M 0x000003fc
105#define BAT_BL_64M 0x000007fc
106#define BAT_BL_128M 0x00000ffc
107#define BAT_BL_256M 0x00001ffc
108
109#define BATU(va, len, v) \
110 (((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V))
111
112#define BATL(pa, wimg, pp) \
113 (((pa) & BAT_PBS) | (wimg) | (pp))
114
115/* Lower BAT bits (PowerPC 601): */
116#define BAT601_PBN 0xfffe0000 /* physical block number */
117#define BAT601_V 0x00000040 /* valid */
118#define BAT601_BSM 0x0000003f /* block size mask */
119
120/* Upper BAT bits (PowerPC 601): */
121#define BAT601_BLPI 0xfffe0000 /* block logical page index */
122#define BAT601_W 0x00000040 /* 1 = write-through, 0 = write-back */
123#define BAT601_I 0x00000020 /* cache inhibit */
124#define BAT601_M 0x00000010 /* memory coherency enable */
125#define BAT601_Ks 0x00000008 /* key-supervisor */
126#define BAT601_Ku 0x00000004 /* key-user */
127
128/*
129 * Permission bits on the PowerPC 601 are modified by the appropriate
130 * Key bit:
131 *
132 * Key PP Access
133 * 0 NONE read/write
134 * 0 RO_S read/write
135 * 0 RW read/write
136 * 0 RO read-only
137 *
138 * 1 NONE none
139 * 1 RO_S read-only
140 * 1 RW read/write
141 * 1 RO read-only
142 */
143#define BAT601_PP_NONE 0x00000000 /* no access permission */
144#define BAT601_PP_RO_S 0x00000001 /* read-only (soft) */
145#define BAT601_PP_RW 0x00000002 /* read/write */
146#define BAT601_PP_RO 0x00000003 /* read-only */
147
148/* Block Size Mask encoding (PowerPC 601): */
149#define BAT601_BSM_128K 0x00000000
150#define BAT601_BSM_256K 0x00000001
151#define BAT601_BSM_512K 0x00000003
152#define BAT601_BSM_1M 0x00000007
153#define BAT601_BSM_2M 0x0000000f
154#define BAT601_BSM_4M 0x0000001f
155#define BAT601_BSM_8M 0x0000003f
156
157#define BATU601(va, wim, key, pp) \
158 (((va) & BAT601_BLPI) | (wim) | (key) | (pp))
159
160#define BATL601(pa, size, v) \
161 (((pa) & BAT601_PBN) | (v) | (size))
162
163#if defined(_KERNEL) && !defined(LOCORE)
164extern struct bat battable[16];
165#endif
166
167#endif /* _MACHINE_BAT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/bus.h+2-490
......@@ -1,493 +1,5 @@
1/* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */
2
31/*-
4 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause
5 *
6 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
11 * NASA Ames Research Center.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
2 * This file is in the public domain.
333 */
344
35/*-
36 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
37 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by Christopher G. Demetriou
50 * for the NetBSD Project.
51 * 4. The name of the author may not be used to endorse or promote products
52 * derived from this software without specific prior written permission
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
55 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
56 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
58 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
63 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 */
65
66#ifndef _MACHINE_BUS_H_
67#define _MACHINE_BUS_H_
68
69#include <machine/_bus.h>
70
71#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
72
73#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL
74#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL
75#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL
76#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL
77
78#ifdef __powerpc64__
79#define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL
80#define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL
81#else
82#ifdef BOOKE
83#define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL
84#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL
85#else
86#define BUS_SPACE_MAXADDR 0xFFFFFFFFUL
87#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL
88#endif
89#endif
90
91#define BUS_SPACE_MAP_CACHEABLE 0x01
92#define BUS_SPACE_MAP_LINEAR 0x02
93#define BUS_SPACE_MAP_PREFETCHABLE 0x04
94
95#define BUS_SPACE_UNRESTRICTED (~0)
96
97#define BUS_SPACE_BARRIER_READ 0x01
98#define BUS_SPACE_BARRIER_WRITE 0x02
99
100struct bus_space_access;
101
102struct bus_space {
103 /* mapping/unmapping */
104 int (*bs_map)(bus_addr_t, bus_size_t, int,
105 bus_space_handle_t *);
106 void (*bs_unmap)(bus_size_t);
107 int (*bs_subregion)(bus_space_handle_t, bus_size_t,
108 bus_size_t, bus_space_handle_t *);
109
110 /* allocation/deallocation */
111 int (*bs_alloc)(bus_addr_t, bus_addr_t, bus_size_t,
112 bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
113 void (*bs_free)(bus_space_handle_t, bus_size_t);
114
115 void (*bs_barrier)(bus_space_handle_t, bus_size_t,
116 bus_size_t, int);
117
118 /* Read single. */
119 uint8_t (*bs_r_1)(bus_space_handle_t, bus_size_t);
120 uint16_t (*bs_r_2)(bus_space_handle_t, bus_size_t);
121 uint32_t (*bs_r_4)(bus_space_handle_t, bus_size_t);
122 uint64_t (*bs_r_8)(bus_space_handle_t, bus_size_t);
123
124 uint16_t (*bs_r_s_2)(bus_space_handle_t, bus_size_t);
125 uint32_t (*bs_r_s_4)(bus_space_handle_t, bus_size_t);
126 uint64_t (*bs_r_s_8)(bus_space_handle_t, bus_size_t);
127
128 /* read multiple */
129 void (*bs_rm_1)(bus_space_handle_t, bus_size_t, uint8_t *,
130 bus_size_t);
131 void (*bs_rm_2)(bus_space_handle_t, bus_size_t, uint16_t *,
132 bus_size_t);
133 void (*bs_rm_4)(bus_space_handle_t, bus_size_t, uint32_t *,
134 bus_size_t);
135 void (*bs_rm_8)(bus_space_handle_t, bus_size_t, uint64_t *,
136 bus_size_t);
137
138 void (*bs_rm_s_2)(bus_space_handle_t, bus_size_t, uint16_t *,
139 bus_size_t);
140 void (*bs_rm_s_4)(bus_space_handle_t, bus_size_t, uint32_t *,
141 bus_size_t);
142 void (*bs_rm_s_8)(bus_space_handle_t, bus_size_t, uint64_t *,
143 bus_size_t);
144
145 /* read region */
146 void (*bs_rr_1)(bus_space_handle_t, bus_size_t, uint8_t *,
147 bus_size_t);
148 void (*bs_rr_2)(bus_space_handle_t, bus_size_t, uint16_t *,
149 bus_size_t);
150 void (*bs_rr_4)(bus_space_handle_t, bus_size_t, uint32_t *,
151 bus_size_t);
152 void (*bs_rr_8)(bus_space_handle_t, bus_size_t, uint64_t *,
153 bus_size_t);
154
155 void (*bs_rr_s_2)(bus_space_handle_t, bus_size_t, uint16_t *,
156 bus_size_t);
157 void (*bs_rr_s_4)(bus_space_handle_t, bus_size_t, uint32_t *,
158 bus_size_t);
159 void (*bs_rr_s_8)(bus_space_handle_t, bus_size_t, uint64_t *,
160 bus_size_t);
161
162 /* write */
163 void (*bs_w_1)(bus_space_handle_t, bus_size_t, uint8_t);
164 void (*bs_w_2)(bus_space_handle_t, bus_size_t, uint16_t);
165 void (*bs_w_4)(bus_space_handle_t, bus_size_t, uint32_t);
166 void (*bs_w_8)(bus_space_handle_t, bus_size_t, uint64_t);
167
168 void (*bs_w_s_2)(bus_space_handle_t, bus_size_t, uint16_t);
169 void (*bs_w_s_4)(bus_space_handle_t, bus_size_t, uint32_t);
170 void (*bs_w_s_8)(bus_space_handle_t, bus_size_t, uint64_t);
171
172 /* write multiple */
173 void (*bs_wm_1)(bus_space_handle_t, bus_size_t,
174 const uint8_t *, bus_size_t);
175 void (*bs_wm_2)(bus_space_handle_t, bus_size_t,
176 const uint16_t *, bus_size_t);
177 void (*bs_wm_4)(bus_space_handle_t, bus_size_t,
178 const uint32_t *, bus_size_t);
179 void (*bs_wm_8)(bus_space_handle_t, bus_size_t,
180 const uint64_t *, bus_size_t);
181
182 void (*bs_wm_s_2)(bus_space_handle_t, bus_size_t,
183 const uint16_t *, bus_size_t);
184 void (*bs_wm_s_4)(bus_space_handle_t, bus_size_t,
185 const uint32_t *, bus_size_t);
186 void (*bs_wm_s_8)(bus_space_handle_t, bus_size_t,
187 const uint64_t *, bus_size_t);
188
189 /* write region */
190 void (*bs_wr_1)(bus_space_handle_t, bus_size_t,
191 const uint8_t *, bus_size_t);
192 void (*bs_wr_2)(bus_space_handle_t, bus_size_t,
193 const uint16_t *, bus_size_t);
194 void (*bs_wr_4)(bus_space_handle_t, bus_size_t,
195 const uint32_t *, bus_size_t);
196 void (*bs_wr_8)(bus_space_handle_t, bus_size_t,
197 const uint64_t *, bus_size_t);
198
199 void (*bs_wr_s_2)(bus_space_handle_t, bus_size_t,
200 const uint16_t *, bus_size_t);
201 void (*bs_wr_s_4)(bus_space_handle_t, bus_size_t,
202 const uint32_t *, bus_size_t);
203 void (*bs_wr_s_8)(bus_space_handle_t, bus_size_t,
204 const uint64_t *, bus_size_t);
205
206 /* set multiple */
207 void (*bs_sm_1)(bus_space_handle_t, bus_size_t, uint8_t,
208 bus_size_t);
209 void (*bs_sm_2)(bus_space_handle_t, bus_size_t, uint16_t,
210 bus_size_t);
211 void (*bs_sm_4)(bus_space_handle_t, bus_size_t, uint32_t,
212 bus_size_t);
213 void (*bs_sm_8)(bus_space_handle_t, bus_size_t, uint64_t,
214 bus_size_t);
215
216 void (*bs_sm_s_2)(bus_space_handle_t, bus_size_t, uint16_t,
217 bus_size_t);
218 void (*bs_sm_s_4)(bus_space_handle_t, bus_size_t, uint32_t,
219 bus_size_t);
220 void (*bs_sm_s_8)(bus_space_handle_t, bus_size_t, uint64_t,
221 bus_size_t);
222
223 /* set region */
224 void (*bs_sr_1)(bus_space_handle_t, bus_size_t, uint8_t,
225 bus_size_t);
226 void (*bs_sr_2)(bus_space_handle_t, bus_size_t, uint16_t,
227 bus_size_t);
228 void (*bs_sr_4)(bus_space_handle_t, bus_size_t, uint32_t,
229 bus_size_t);
230 void (*bs_sr_8)(bus_space_handle_t, bus_size_t, uint64_t,
231 bus_size_t);
232
233 void (*bs_sr_s_2)(bus_space_handle_t, bus_size_t, uint16_t,
234 bus_size_t);
235 void (*bs_sr_s_4)(bus_space_handle_t, bus_size_t, uint32_t,
236 bus_size_t);
237 void (*bs_sr_s_8)(bus_space_handle_t, bus_size_t, uint64_t,
238 bus_size_t);
239
240 /* copy region */
241 void (*bs_cr_1)(bus_space_handle_t, bus_size_t,
242 bus_space_handle_t, bus_size_t, bus_size_t);
243 void (*bs_cr_2)(bus_space_handle_t, bus_size_t,
244 bus_space_handle_t, bus_size_t, bus_size_t);
245 void (*bs_cr_4)(bus_space_handle_t, bus_size_t,
246 bus_space_handle_t, bus_size_t, bus_size_t);
247 void (*bs_cr_8)(bus_space_handle_t, bus_size_t,
248 bus_space_handle_t, bus_size_t, bus_size_t);
249
250 void (*bs_cr_s_2)(bus_space_handle_t, bus_size_t,
251 bus_space_handle_t, bus_size_t, bus_size_t);
252 void (*bs_cr_s_4)(bus_space_handle_t, bus_size_t,
253 bus_space_handle_t, bus_size_t, bus_size_t);
254 void (*bs_cr_s_8)(bus_space_handle_t, bus_size_t,
255 bus_space_handle_t, bus_size_t, bus_size_t);
256};
257
258extern struct bus_space bs_be_tag;
259extern struct bus_space bs_le_tag;
260
261#define __bs_c(a,b) __CONCAT(a,b)
262#define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size)
263
264#define __bs_rs(sz, t, h, o) \
265 (*(t)->__bs_opname(r,sz))(h, o)
266#define __bs_ws(sz, t, h, o, v) \
267 (*(t)->__bs_opname(w,sz))(h, o, v)
268#define __bs_nonsingle(type, sz, t, h, o, a, c) \
269 (*(t)->__bs_opname(type,sz))(h, o, a, c)
270#define __bs_set(type, sz, t, h, o, v, c) \
271 (*(t)->__bs_opname(type,sz))(h, o, v, c)
272#define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \
273 (*(t)->__bs_opname(c,sz))(h1, o1, h2, o2, cnt)
274
275/*
276 * Mapping and unmapping operations.
277 */
278#define bus_space_map(t, a, s, c, hp) (*(t)->bs_map)(a, s, c, hp)
279#define bus_space_unmap(t, h, s) (*(t)->bs_unmap)(h, s)
280#define bus_space_subregion(t, h, o, s, hp) (*(t)->bs_subregion)(h, o, s, hp)
281
282/*
283 * Allocation and deallocation operations.
284 */
285#define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \
286 (*(t)->bs_alloc)(rs, re, s, a, b, c, ap, hp)
287#define bus_space_free(t, h, s) \
288 (*(t)->bs_free)(h, s)
289
290/*
291 * Bus barrier operations.
292 */
293#define bus_space_barrier(t, h, o, l, f) (*(t)->bs_barrier)(h, o, l, f)
294
295/*
296 * Bus read (single) operations.
297 */
298#define bus_space_read_1(t, h, o) __bs_rs(1,t,h,o)
299#define bus_space_read_2(t, h, o) __bs_rs(2,t,h,o)
300#define bus_space_read_4(t, h, o) __bs_rs(4,t,h,o)
301#define bus_space_read_8(t, h, o) __bs_rs(8,t,h,o)
302
303#define bus_space_read_stream_1 bus_space_read_1
304#define bus_space_read_stream_2(t, h, o) __bs_rs(s_2,t,h,o)
305#define bus_space_read_stream_4(t, h, o) __bs_rs(s_4,t,h,o)
306#define bus_space_read_stream_8(t, h, o) __bs_rs(s_8,t,h,o)
307
308/*
309 * Bus read multiple operations.
310 */
311#define bus_space_read_multi_1(t, h, o, a, c) \
312 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
313#define bus_space_read_multi_2(t, h, o, a, c) \
314 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
315#define bus_space_read_multi_4(t, h, o, a, c) \
316 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
317#define bus_space_read_multi_8(t, h, o, a, c) \
318 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
319
320#define bus_space_read_multi_stream_1 bus_space_read_multi_1
321#define bus_space_read_multi_stream_2(t, h, o, a, c) \
322 __bs_nonsingle(rm,s_2,(t),(h),(o),(a),(c))
323#define bus_space_read_multi_stream_4(t, h, o, a, c) \
324 __bs_nonsingle(rm,s_4,(t),(h),(o),(a),(c))
325#define bus_space_read_multi_stream_8(t, h, o, a, c) \
326 __bs_nonsingle(rm,s_8,(t),(h),(o),(a),(c))
327
328/*
329 * Bus read region operations.
330 */
331#define bus_space_read_region_1(t, h, o, a, c) \
332 __bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
333#define bus_space_read_region_2(t, h, o, a, c) \
334 __bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
335#define bus_space_read_region_4(t, h, o, a, c) \
336 __bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
337#define bus_space_read_region_8(t, h, o, a, c) \
338 __bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
339
340#define bus_space_read_region_stream_1 bus_space_read_region_1
341#define bus_space_read_region_stream_2(t, h, o, a, c) \
342 __bs_nonsingle(rr,s_2,(t),(h),(o),(a),(c))
343#define bus_space_read_region_stream_4(t, h, o, a, c) \
344 __bs_nonsingle(rr,s_4,(t),(h),(o),(a),(c))
345#define bus_space_read_region_stream_8(t, h, o, a, c) \
346 __bs_nonsingle(rr,s_8,(t),(h),(o),(a),(c))
347
348/*
349 * Bus write (single) operations.
350 */
351#define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v))
352#define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v))
353#define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v))
354#define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v))
355
356#define bus_space_write_stream_1 bus_space_write_1
357#define bus_space_write_stream_2(t, h, o, v) __bs_ws(s_2,(t),(h),(o),(v))
358#define bus_space_write_stream_4(t, h, o, v) __bs_ws(s_4,(t),(h),(o),(v))
359#define bus_space_write_stream_8(t, h, o, v) __bs_ws(s_8,(t),(h),(o),(v))
360
361/*
362 * Bus write multiple operations.
363 */
364#define bus_space_write_multi_1(t, h, o, a, c) \
365 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
366#define bus_space_write_multi_2(t, h, o, a, c) \
367 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
368#define bus_space_write_multi_4(t, h, o, a, c) \
369 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
370#define bus_space_write_multi_8(t, h, o, a, c) \
371 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
372
373#define bus_space_write_multi_stream_1 bus_space_write_multi_1
374#define bus_space_write_multi_stream_2(t, h, o, a, c) \
375 __bs_nonsingle(wm,s_2,(t),(h),(o),(a),(c))
376#define bus_space_write_multi_stream_4(t, h, o, a, c) \
377 __bs_nonsingle(wm,s_4,(t),(h),(o),(a),(c))
378#define bus_space_write_multi_stream_8(t, h, o, a, c) \
379 __bs_nonsingle(wm,s_8,(t),(h),(o),(a),(c))
380
381/*
382 * Bus write region operations.
383 */
384#define bus_space_write_region_1(t, h, o, a, c) \
385 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
386#define bus_space_write_region_2(t, h, o, a, c) \
387 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
388#define bus_space_write_region_4(t, h, o, a, c) \
389 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
390#define bus_space_write_region_8(t, h, o, a, c) \
391 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
392
393#define bus_space_write_region_stream_1 bus_space_write_region_1
394#define bus_space_write_region_stream_2(t, h, o, a, c) \
395 __bs_nonsingle(wr,s_2,(t),(h),(o),(a),(c))
396#define bus_space_write_region_stream_4(t, h, o, a, c) \
397 __bs_nonsingle(wr,s_4,(t),(h),(o),(a),(c))
398#define bus_space_write_region_stream_8(t, h, o, a, c) \
399 __bs_nonsingle(wr,s_8,(t),(h),(o),(a),(c))
400
401/*
402 * Set multiple operations.
403 */
404#define bus_space_set_multi_1(t, h, o, v, c) \
405 __bs_set(sm,1,(t),(h),(o),(v),(c))
406#define bus_space_set_multi_2(t, h, o, v, c) \
407 __bs_set(sm,2,(t),(h),(o),(v),(c))
408#define bus_space_set_multi_4(t, h, o, v, c) \
409 __bs_set(sm,4,(t),(h),(o),(v),(c))
410#define bus_space_set_multi_8(t, h, o, v, c) \
411 __bs_set(sm,8,(t),(h),(o),(v),(c))
412
413#define bus_space_set_multi_stream_1 bus_space_set_multi_1
414#define bus_space_set_multi_stream_2(t, h, o, v, c) \
415 __bs_set(sm,s_2,(t),(h),(o),(v),(c))
416#define bus_space_set_multi_stream_4(t, h, o, v, c) \
417 __bs_set(sm,s_4,(t),(h),(o),(v),(c))
418#define bus_space_set_multi_stream_8(t, h, o, v, c) \
419 __bs_set(sm,s_8,(t),(h),(o),(v),(c))
420
421/*
422 * Set region operations.
423 */
424#define bus_space_set_region_1(t, h, o, v, c) \
425 __bs_set(sr,1,(t),(h),(o),(v),(c))
426#define bus_space_set_region_2(t, h, o, v, c) \
427 __bs_set(sr,2,(t),(h),(o),(v),(c))
428#define bus_space_set_region_4(t, h, o, v, c) \
429 __bs_set(sr,4,(t),(h),(o),(v),(c))
430#define bus_space_set_region_8(t, h, o, v, c) \
431 __bs_set(sr,8,(t),(h),(o),(v),(c))
432
433#define bus_space_set_region_stream_1 bus_space_set_region_1
434#define bus_space_set_region_stream_2(t, h, o, v, c) \
435 __bs_set(sr,s_2,(t),(h),(o),(v),(c))
436#define bus_space_set_region_stream_4(t, h, o, v, c) \
437 __bs_set(sr,s_4,(t),(h),(o),(v),(c))
438#define bus_space_set_region_stream_8(t, h, o, v, c) \
439 __bs_set(sr,s_8,(t),(h),(o),(v),(c))
440
441#if 0
442/*
443 * Copy operations.
444 */
445#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
446 __bs_copy(1, t, h1, o1, h2, o2, c)
447#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
448 __bs_copy(2, t, h1, o1, h2, o2, c)
449#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
450 __bs_copy(4, t, h1, o1, h2, o2, c)
451#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
452 __bs_copy(8, t, h1, o1, h2, o2, c)
453
454#define bus_space_copy_region_stream_1 bus_space_copy_region_1
455#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
456 __bs_copy(s_2, t, h1, o1, h2, o2, c)
457#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
458 __bs_copy(s_4, t, h1, o1, h2, o2, c)
459#define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c) \
460 __bs_copy(s_8, t, h1, o1, h2, o2, c)
461#endif
462
463#define BUS_PEEK_FUNC(width, type) \
464 static inline int \
465 bus_space_peek_##width(bus_space_tag_t tag, \
466 bus_space_handle_t hnd, bus_size_t offset, type *value) \
467 { \
468 type tmp; \
469 tmp = bus_space_read_##width(tag, hnd, offset); \
470 *value = (type)tmp; \
471 return (0); \
472 }
473BUS_PEEK_FUNC(1, uint8_t)
474BUS_PEEK_FUNC(2, uint16_t)
475BUS_PEEK_FUNC(4, uint32_t)
476BUS_PEEK_FUNC(8, uint64_t)
477
478#define BUS_POKE_FUNC(width, type) \
479 static inline int \
480 bus_space_poke_##width(bus_space_tag_t tag, \
481 bus_space_handle_t hnd, bus_size_t offset, type value) \
482 { \
483 bus_space_write_##width(tag, hnd, offset, value); \
484 return (0); \
485 }
486BUS_POKE_FUNC(1, uint8_t)
487BUS_POKE_FUNC(2, uint16_t)
488BUS_POKE_FUNC(4, uint32_t)
489BUS_POKE_FUNC(8, uint64_t)
490
491#include <machine/bus_dma.h>
492
493#endif /* _MACHINE_BUS_H_ */
\ No newline at end of file
5#include <x86/bus.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/bus_dma.h deleted-37
......@@ -1,37 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 Scott Long
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _POWERPC_BUS_DMA_H_
30#define _POWERPC_BUS_DMA_H_
31
32#include <sys/bus_dma.h>
33#include <sys/bus_dma_internal.h>
34
35int bus_dma_tag_set_iommu(bus_dma_tag_t, device_t iommu, void *cookie);
36
37#endif /* _POWERPC_BUS_DMA_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/clock.h+2-15
......@@ -1,18 +1,5 @@
1/*-
2 * Kernel interface to machine-dependent clock driver.
3 * Garrett Wollman, September 1994.
1/*
42 * This file is in the public domain.
53 */
64
7#ifndef _MACHINE_CLOCK_H_
8#define _MACHINE_CLOCK_H_
9
10#ifdef _KERNEL
11
12struct trapframe;
13
14void decr_intr(struct trapframe *);
15
16#endif
17
18#endif /* !_MACHINE_CLOCK_H_ */
\ No newline at end of file
5#include <x86/clock.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/counter.h deleted-162
......@@ -1,162 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2012, 2013 Konstantin Belousov <kib@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef __MACHINE_COUNTER_H__
30#define __MACHINE_COUNTER_H__
31
32#include <sys/pcpu.h>
33#ifdef INVARIANTS
34#include <sys/proc.h>
35#endif
36
37#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter
38
39#ifdef __powerpc64__
40
41#define counter_enter() do {} while (0)
42#define counter_exit() do {} while (0)
43
44#ifdef IN_SUBR_COUNTER_C
45static inline uint64_t
46counter_u64_read_one(uint64_t *p, int cpu)
47{
48
49 return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu));
50}
51
52static inline uint64_t
53counter_u64_fetch_inline(uint64_t *p)
54{
55 uint64_t r;
56 int i;
57
58 r = 0;
59 CPU_FOREACH(i)
60 r += counter_u64_read_one((uint64_t *)p, i);
61
62 return (r);
63}
64
65static void
66counter_u64_zero_one_cpu(void *arg)
67{
68
69 *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE *
70 PCPU_GET(cpuid))) = 0;
71}
72
73static inline void
74counter_u64_zero_inline(counter_u64_t c)
75{
76
77 smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu,
78 smp_no_rendezvous_barrier, c);
79}
80#endif
81
82#define counter_u64_add_protected(c, i) counter_u64_add(c, i)
83
84static inline void
85counter_u64_add(counter_u64_t c, int64_t inc)
86{
87 uint64_t ccpu, old;
88
89 __asm __volatile("\n"
90 "1:\n\t"
91 "mfsprg %0, 0\n\t"
92 "ldarx %1, %0, %2\n\t"
93 "add %1, %1, %3\n\t"
94 "stdcx. %1, %0, %2\n\t"
95 "bne- 1b"
96 : "=&b" (ccpu), "=&r" (old)
97 : "r" ((char *)c - (char *)&__pcpu[0]), "r" (inc)
98 : "cr0", "memory");
99}
100
101#else /* !64bit */
102
103#define counter_enter() critical_enter()
104#define counter_exit() critical_exit()
105
106#ifdef IN_SUBR_COUNTER_C
107/* XXXKIB non-atomic 64bit read */
108static inline uint64_t
109counter_u64_read_one(uint64_t *p, int cpu)
110{
111
112 return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu));
113}
114
115static inline uint64_t
116counter_u64_fetch_inline(uint64_t *p)
117{
118 uint64_t r;
119 int i;
120
121 r = 0;
122 for (i = 0; i < mp_ncpus; i++)
123 r += counter_u64_read_one((uint64_t *)p, i);
124
125 return (r);
126}
127
128/* XXXKIB non-atomic 64bit store, might interrupt increment */
129static void
130counter_u64_zero_one_cpu(void *arg)
131{
132
133 *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE *
134 PCPU_GET(cpuid))) = 0;
135}
136
137static inline void
138counter_u64_zero_inline(counter_u64_t c)
139{
140
141 smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu,
142 smp_no_rendezvous_barrier, c);
143}
144#endif
145
146#define counter_u64_add_protected(c, inc) do { \
147 CRITICAL_ASSERT(curthread); \
148 *(uint64_t *)zpcpu_get(c) += (inc); \
149} while (0)
150
151static inline void
152counter_u64_add(counter_u64_t c, int64_t inc)
153{
154
155 counter_enter();
156 counter_u64_add_protected(c, inc);
157 counter_exit();
158}
159
160#endif /* 64bit */
161
162#endif /* ! __MACHINE_COUNTER_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/cpu.h deleted-157
......@@ -1,157 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995-1997 Wolfgang Solfrank.
5 * Copyright (C) 1995-1997 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $
34 */
35
36#ifndef _MACHINE_CPU_H_
37#define _MACHINE_CPU_H_
38
39#include <machine/frame.h>
40#include <machine/pcb.h>
41#include <machine/psl.h>
42
43/*
44 * CPU Feature Attributes
45 *
46 * These are defined in the PowerPC ELF ABI for the AT_HWCAP vector,
47 * and are exported to userland via the machdep.cpu_features
48 * sysctl.
49 */
50
51extern u_long cpu_features;
52extern u_long cpu_features2;
53
54#define PPC_FEATURE_32 0x80000000 /* Always true */
55#define PPC_FEATURE_64 0x40000000 /* Defined on a 64-bit CPU */
56#define PPC_FEATURE_601_INSTR 0x20000000 /* Defined on a 64-bit CPU */
57#define PPC_FEATURE_HAS_ALTIVEC 0x10000000
58#define PPC_FEATURE_HAS_FPU 0x08000000
59#define PPC_FEATURE_HAS_MMU 0x04000000
60#define PPC_FEATURE_UNIFIED_CACHE 0x01000000
61#define PPC_FEATURE_HAS_SPE 0x00800000
62#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000
63#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000
64#define PPC_FEATURE_NO_TB 0x00100000
65#define PPC_FEATURE_POWER4 0x00080000
66#define PPC_FEATURE_POWER5 0x00040000
67#define PPC_FEATURE_POWER5_PLUS 0x00020000
68#define PPC_FEATURE_CELL 0x00010000
69#define PPC_FEATURE_BOOKE 0x00008000
70#define PPC_FEATURE_SMT 0x00004000
71#define PPC_FEATURE_ICACHE_SNOOP 0x00002000
72#define PPC_FEATURE_ARCH_2_05 0x00001000
73#define PPC_FEATURE_HAS_DFP 0x00000400
74#define PPC_FEATURE_POWER6_EXT 0x00000200
75#define PPC_FEATURE_ARCH_2_06 0x00000100
76#define PPC_FEATURE_HAS_VSX 0x00000080
77#define PPC_FEATURE_TRUE_LE 0x00000002
78#define PPC_FEATURE_PPC_LE 0x00000001
79
80#define PPC_FEATURE2_ARCH_2_07 0x80000000
81#define PPC_FEATURE2_HTM 0x40000000
82#define PPC_FEATURE2_DSCR 0x20000000
83#define PPC_FEATURE2_EBB 0x10000000
84#define PPC_FEATURE2_ISEL 0x08000000
85#define PPC_FEATURE2_TAR 0x04000000
86#define PPC_FEATURE2_HAS_VEC_CRYPTO 0x02000000
87#define PPC_FEATURE2_HTM_NOSC 0x01000000
88#define PPC_FEATURE2_ARCH_3_00 0x00800000
89#define PPC_FEATURE2_HAS_IEEE128 0x00400000
90#define PPC_FEATURE2_DARN 0x00200000
91#define PPC_FEATURE2_SCV 0x00100000
92#define PPC_FEATURE2_HTM_NOSUSPEND 0x00080000
93#define PPC_FEATURE2_ARCH_3_1 0x00040000
94#define PPC_FEATURE2_MMA 0x00020000
95
96#define PPC_FEATURE_BITMASK \
97 "\20" \
98 "\040PPC32\037PPC64\036PPC601\035ALTIVEC\034FPU\033MMU\031UNIFIEDCACHE" \
99 "\030SPE\027SPESFP\026DPESFP\025NOTB\024POWER4\023POWER5\022P5PLUS\021CELL"\
100 "\020BOOKE\017SMT\016ISNOOP\015ARCH205\013DFP\011ARCH206\010VSX"\
101 "\002TRUELE\001PPCLE"
102#define PPC_FEATURE2_BITMASK \
103 "\20" \
104 "\040ARCH207\037HTM\036DSCR\034ISEL\033TAR\032VCRYPTO\031HTMNOSC" \
105 "\030ARCH300\027IEEE128\026DARN\025SCV\024HTMNOSUSP"
106
107#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0)
108#define TRAPF_PC(frame) ((frame)->srr0)
109
110/*
111 * CTL_MACHDEP definitions.
112 */
113#define CPU_CACHELINE 1
114
115static __inline u_int64_t
116get_cyclecount(void)
117{
118 u_int32_t _upper, _lower;
119 u_int64_t _time;
120
121 __asm __volatile(
122 "mftb %0\n"
123 "mftbu %1"
124 : "=r" (_lower), "=r" (_upper));
125
126 _time = (u_int64_t)_upper;
127 _time = (_time << 32) + _lower;
128 return (_time);
129}
130
131#define cpu_getstack(td) ((td)->td_frame->fixreg[1])
132#define cpu_spinwait() __asm __volatile("or 27,27,27") /* yield */
133#define cpu_lock_delay() DELAY(1)
134
135extern char btext[];
136extern char etext[];
137
138struct thread;
139
140#ifdef __powerpc64__
141extern void enter_idle_powerx(void);
142extern uint64_t can_wakeup;
143extern register_t lpcr;
144#endif
145
146void cpu_halt(void);
147void cpu_reset(void);
148void flush_disable_caches(void);
149void fork_trampoline(void);
150int cpu_machine_check(struct thread *, struct trapframe *, int *);
151
152
153#ifndef __powerpc64__
154void mpc745x_sleep(void);
155#endif
156
157#endif /* _MACHINE_CPU_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/cpufunc.h deleted-298
......@@ -1,298 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 1998 Doug Rabson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_CPUFUNC_H_
30#define _MACHINE_CPUFUNC_H_
31
32#ifdef _KERNEL
33
34#include <sys/types.h>
35
36#include <machine/psl.h>
37#include <machine/spr.h>
38
39struct thread;
40
41#ifdef KDB
42void breakpoint(void);
43#else
44static __inline void
45breakpoint(void)
46{
47
48 return;
49}
50#endif
51
52/* CPU register mangling inlines */
53
54static __inline void
55mtmsr(register_t value)
56{
57
58 __asm __volatile ("mtmsr %0; isync" :: "r"(value));
59}
60
61#ifdef __powerpc64__
62static __inline void
63mtmsrd(register_t value)
64{
65
66 __asm __volatile ("mtmsrd %0; isync" :: "r"(value));
67}
68#endif
69
70static __inline register_t
71mfmsr(void)
72{
73 register_t value;
74
75 __asm __volatile ("mfmsr %0" : "=r"(value));
76
77 return (value);
78}
79
80#ifndef __powerpc64__
81static __inline void
82mtsrin(vm_offset_t va, register_t value)
83{
84
85 __asm __volatile ("mtsrin %0,%1; isync" :: "r"(value), "r"(va));
86}
87
88static __inline register_t
89mfsrin(vm_offset_t va)
90{
91 register_t value;
92
93 __asm __volatile ("mfsrin %0,%1" : "=r"(value) : "r"(va));
94
95 return (value);
96}
97#endif
98
99static __inline register_t
100mfctrl(void)
101{
102 register_t value;
103
104 __asm __volatile ("mfspr %0,136" : "=r"(value));
105
106 return (value);
107}
108
109static __inline void
110mtdec(register_t value)
111{
112
113 __asm __volatile ("mtdec %0" :: "r"(value));
114}
115
116static __inline register_t
117mfdec(void)
118{
119 register_t value;
120
121 __asm __volatile ("mfdec %0" : "=r"(value));
122
123 return (value);
124}
125
126static __inline uint32_t
127mfpvr(void)
128{
129 uint32_t value;
130
131 __asm __volatile ("mfpvr %0" : "=r"(value));
132
133 return (value);
134}
135
136static __inline u_quad_t
137mftb(void)
138{
139 u_quad_t tb;
140 #ifdef __powerpc64__
141 __asm __volatile ("mftb %0" : "=r"(tb));
142 #else
143 uint32_t *tbup = (uint32_t *)&tb;
144 uint32_t *tblp = tbup + 1;
145
146 do {
147 *tbup = mfspr(TBR_TBU);
148 *tblp = mfspr(TBR_TBL);
149 } while (*tbup != mfspr(TBR_TBU));
150 #endif
151
152 return (tb);
153}
154
155static __inline void
156mttb(u_quad_t time)
157{
158
159 mtspr(TBR_TBWL, 0);
160 mtspr(TBR_TBWU, (uint32_t)(time >> 32));
161 mtspr(TBR_TBWL, (uint32_t)(time & 0xffffffff));
162}
163
164static __inline register_t
165mffs(void)
166{
167 uint64_t value;
168
169 __asm __volatile ("mffs 0; stfd 0,0(%0)"
170 :: "b"(&value));
171
172 return ((register_t)value);
173}
174
175static __inline void
176mtfsf(uint64_t value)
177{
178
179 __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0"
180 :: "b"(&value));
181}
182
183static __inline void
184eieio(void)
185{
186
187 __asm __volatile ("eieio" : : : "memory");
188}
189
190static __inline void
191isync(void)
192{
193
194 __asm __volatile ("isync" : : : "memory");
195}
196
197static __inline void
198powerpc_sync(void)
199{
200
201 __asm __volatile ("sync" : : : "memory");
202}
203
204static __inline int
205cntlzd(uint64_t word)
206{
207 uint64_t result;
208 /* cntlzd %0, %1 */
209 __asm __volatile(".long 0x7c000074 | (%1 << 21) | (%0 << 16)" :
210 "=r"(result) : "r"(word));
211
212 return (int)result;
213}
214
215static __inline int
216cnttzd(uint64_t word)
217{
218 uint64_t result;
219 /* cnttzd %0, %1 */
220 __asm __volatile(".long 0x7c000474 | (%1 << 21) | (%0 << 16)" :
221 "=r"(result) : "r"(word));
222
223 return (int)result;
224}
225
226static __inline void
227ptesync(void)
228{
229 __asm __volatile("ptesync");
230}
231
232static __inline register_t
233intr_disable(void)
234{
235 register_t msr;
236
237 msr = mfmsr();
238 mtmsr(msr & ~PSL_EE);
239 return (msr);
240}
241
242static __inline void
243intr_restore(register_t msr)
244{
245
246 mtmsr(msr);
247}
248
249static __inline struct pcpu *
250get_pcpu(void)
251{
252 struct pcpu *ret;
253
254 __asm __volatile("mfsprg %0, 0" : "=r"(ret));
255
256 return (ret);
257}
258
259/* "NOP" operations to signify priorities to the kernel. */
260static __inline void
261nop_prio_vlow(void)
262{
263 __asm __volatile("or 31,31,31");
264}
265
266static __inline void
267nop_prio_low(void)
268{
269 __asm __volatile("or 1,1,1");
270}
271
272static __inline void
273nop_prio_mlow(void)
274{
275 __asm __volatile("or 6,6,6");
276}
277
278static __inline void
279nop_prio_medium(void)
280{
281 __asm __volatile("or 2,2,2");
282}
283
284static __inline void
285nop_prio_mhigh(void)
286{
287 __asm __volatile("or 5,5,5");
288}
289
290static __inline void
291nop_prio_high(void)
292{
293 __asm __volatile("or 3,3,3");
294}
295
296#endif /* _KERNEL */
297
298#endif /* !_MACHINE_CPUFUNC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/db_machdep.h deleted-87
......@@ -1,87 +0,0 @@
1/*-
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 *
26 * $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $
27 * $NetBSD: db_machdep.h,v 1.4.22.1 2000/08/05 11:10:43 wiz Exp $
28 */
29
30/*
31 * Machine-dependent defines for new kernel debugger.
32 */
33#ifndef _POWERPC_DB_MACHDEP_H_
34#define _POWERPC_DB_MACHDEP_H_
35
36#include <vm/vm_param.h>
37#include <machine/elf.h>
38
39#define DB_ELF_SYMBOLS
40#define DB_ELFSIZE __ELF_WORD_SIZE
41
42typedef vm_offset_t db_addr_t; /* address - unsigned */
43typedef intptr_t db_expr_t; /* expression - signed */
44
45#define PC_REGS(regs) ((db_addr_t)kdb_thrctx->pcb_lr)
46
47#define BKPT_INST 0x7C810808 /* breakpoint instruction */
48
49#define BKPT_SIZE (4) /* size of breakpoint inst */
50#define BKPT_SET(inst) (BKPT_INST)
51
52#define db_clear_single_step kdb_cpu_clear_singlestep
53#define db_set_single_step kdb_cpu_set_singlestep
54
55#if 0
56#define SR_SINGLESTEP 0x400
57#define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP)
58#define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP)
59#endif
60
61#define T_BREAKPOINT 0xffff
62#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT)
63
64#define T_WATCHPOINT 0xeeee
65#ifdef T_WATCHPOINT
66#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT)
67#else
68#define IS_WATCHPOINT_TRAP(type, code) 0
69#endif
70
71#define M_RTS 0xfc0007fe
72#define I_RTS 0x4c000020
73#define M_BC 0xfc000000
74#define I_BC 0x40000000
75#define M_B 0xfc000000
76#define I_B 0x50000000
77#define M_RFI 0xfc0007fe
78#define I_RFI 0x4c000064
79
80#define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI)
81#define inst_return(ins) (((ins)&M_RTS) == I_RTS)
82#define inst_call(ins) (((ins)&M_BC ) == I_BC || \
83 ((ins)&M_B ) == I_B )
84#define inst_load(ins) 0
85#define inst_store(ins) 0
86
87#endif /* _POWERPC_DB_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/dbdma.h deleted-153
......@@ -1,153 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Nathan Whitehorn
5 * All rights reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_DBDMA_H_
30#define _MACHINE_DBDMA_H_
31
32#include <sys/param.h>
33#include <machine/bus.h>
34
35/*
36 * Apple's DBDMA (Descriptor-based DMA) interface is a common DMA engine
37 * used by a variety of custom Apple ASICs. It is described in the CHRP
38 * specification and in the book Macintosh Technology in the Common
39 * Hardware Reference Platform, copyright 1995 Apple Computer.
40 */
41
42/* DBDMA Command Values */
43
44enum {
45 DBDMA_OUTPUT_MORE = 0,
46 DBDMA_OUTPUT_LAST = 1,
47 DBDMA_INPUT_MORE = 2,
48 DBDMA_INPUT_LAST = 3,
49
50 DBDMA_STORE_QUAD = 4,
51 DBDMA_LOAD_QUAD = 5,
52 DBDMA_NOP = 6,
53 DBDMA_STOP = 7
54};
55
56/* These codes are for the interrupt, branch, and wait flags */
57
58enum {
59 DBDMA_NEVER = 0,
60 DBDMA_COND_TRUE = 1,
61 DBDMA_COND_FALSE = 2,
62 DBDMA_ALWAYS = 3
63};
64
65/* Channel status bits */
66#define DBDMA_STATUS_RUN (0x01 << 15)
67#define DBDMA_STATUS_PAUSE (0x01 << 14)
68#define DBDMA_STATUS_FLUSH (0x01 << 13)
69#define DBDMA_STATUS_WAKE (0x01 << 12)
70#define DBDMA_STATUS_DEAD (0x01 << 11)
71#define DBDMA_STATUS_ACTIVE (0x01 << 10)
72
73/* Set by hardware if a branch was taken */
74#define DBDMA_STATUS_BRANCH 8
75
76struct dbdma_command;
77typedef struct dbdma_command dbdma_command_t;
78struct dbdma_channel;
79typedef struct dbdma_channel dbdma_channel_t;
80
81int dbdma_allocate_channel(struct resource *dbdma_regs, u_int offset,
82 bus_dma_tag_t parent_dma, int slots, dbdma_channel_t **chan);
83
84int dbdma_resize_channel(dbdma_channel_t *chan, int newslots);
85int dbdma_free_channel(dbdma_channel_t *chan);
86
87void dbdma_run(dbdma_channel_t *chan);
88void dbdma_stop(dbdma_channel_t *chan);
89void dbdma_reset(dbdma_channel_t *chan);
90void dbdma_set_current_cmd(dbdma_channel_t *chan, int slot);
91
92void dbdma_pause(dbdma_channel_t *chan);
93void dbdma_wake(dbdma_channel_t *chan);
94
95/*
96 * DBDMA uses a 16 bit channel control register to describe the current
97 * state of DMA on the channel. The high-order bits (8-15) contain information
98 * on the run state and are listed in the DBDMA_STATUS_* constants above. These
99 * are manipulated with the dbdma_run/stop/reset() routines above.
100 *
101 * The low order bits (0-7) are device dependent status bits. These can be set
102 * and read by both hardware and software. The mask is the set of bits to
103 * modify; if mask is 0x03 and value is 0, the lowest order 2 bits will be
104 * zeroed.
105 */
106
107uint16_t dbdma_get_chan_status(dbdma_channel_t *chan);
108
109uint8_t dbdma_get_device_status(dbdma_channel_t *chan);
110void dbdma_set_device_status(dbdma_channel_t *chan, uint8_t mask,
111 uint8_t value);
112
113/*
114 * Each DBDMA command word has the current channel status register and the
115 * number of residual bytes (requested - actually transferred) written to it
116 * at time of command completion.
117 */
118
119uint16_t dbdma_get_cmd_status(dbdma_channel_t *chan, int slot);
120uint16_t dbdma_get_residuals(dbdma_channel_t *chan, int slot);
121
122void dbdma_clear_cmd_status(dbdma_channel_t *chan, int slot);
123
124/*
125 * The interrupt/branch/wait selector let you specify a set of values
126 * of the device dependent status bits that will cause intterupt/branch/wait
127 * conditions to be taken if the flags for these are set to one of the
128 * DBDMA_COND_* values.
129 *
130 * The condition is considered true if (status & mask) == value.
131 */
132
133void dbdma_set_interrupt_selector(dbdma_channel_t *chan, uint8_t mask,
134 uint8_t value);
135void dbdma_set_branch_selector(dbdma_channel_t *chan, uint8_t mask,
136 uint8_t value);
137void dbdma_set_wait_selector(dbdma_channel_t *chan, uint8_t mask,
138 uint8_t value);
139
140void dbdma_insert_command(dbdma_channel_t *chan, int slot, int command,
141 int stream, bus_addr_t data, size_t count, uint8_t interrupt,
142 uint8_t branch, uint8_t wait, uint32_t branch_slot);
143
144void dbdma_insert_stop(dbdma_channel_t *chan, int slot);
145void dbdma_insert_nop(dbdma_channel_t *chan, int slot);
146void dbdma_insert_branch(dbdma_channel_t *chan, int slot, int to_slot);
147
148void dbdma_sync_commands(dbdma_channel_t *chan, bus_dmasync_op_t op);
149
150void dbdma_save_state(dbdma_channel_t *chan);
151void dbdma_restore_state(dbdma_channel_t *chan);
152
153#endif /* _MACHINE_DBDMA_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/dump.h+2-70
......@@ -1,73 +1,5 @@
11/*-
2 * Copyright (c) 2014 EMC Corp.
3 * Author: Conrad Meyer <conrad.meyer@isilon.com>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
2 * This file is in the public domain.
263 */
274
28#ifndef _MACHINE_DUMP_H_
29#define _MACHINE_DUMP_H_
30
31#define KERNELDUMP_ARCH_VERSION KERNELDUMP_POWERPC_VERSION
32#define EM_VALUE ELF_ARCH /* Defined in powerpc/include/elf.h */
33#define DUMPSYS_MD_PA_NPAIRS (PHYS_AVAIL_SZ + 1)
34#define DUMPSYS_NUM_AUX_HDRS 0
35
36/* How often to check the dump progress bar? */
37#define DUMPSYS_PB_CHECK_BITS 20 /* Every 1MB */
38
39void dumpsys_pa_init(void);
40void dumpsys_unmap_chunk(vm_paddr_t, size_t, void *);
41size_t dumpsys_scan_pmap(struct bitset *);
42void *dumpsys_dump_pmap_init(unsigned blkpgs);
43void *dumpsys_dump_pmap(void *ctx, void *buf, u_long *nbytes);
44
45static inline struct dump_pa *
46dumpsys_pa_next(struct dump_pa *p)
47{
48
49 return (dumpsys_gen_pa_next(p));
50}
51
52static inline void
53dumpsys_wbinv_all(void)
54{
55
56 dumpsys_gen_wbinv_all();
57}
58
59static inline int
60dumpsys_write_aux_headers(struct dumperinfo *di)
61{
62
63 return (dumpsys_gen_write_aux_headers(di));
64}
65
66static inline int
67dumpsys(struct dumperinfo *di)
68{
69
70 return (dumpsys_generic(di));
71}
72
73#endif /* !_MACHINE_DUMP_H_ */
\ No newline at end of file
5#include <x86/dump.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/efi.h deleted-12
......@@ -1,12 +0,0 @@
1/*-
2 * This file is in the public domain since it's just boilerplate.
3 */
4
5#ifndef __POWERPC_INCLUDE_EFI_H_
6#define __POWERPC_INCLUDE_EFI_H_
7
8#define EFIABI_ATTR
9
10/* Note: we don't actually support this on powerpc */
11
12#endif /* __POWERPC_INCLUDE_EFI_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/elf.h+2-143
......@@ -1,146 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * Copyright (c) 1996-1997 John D. Polstra.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
2 * This file is in the public domain.
283 */
294
30#ifndef _MACHINE_ELF_H_
31#define _MACHINE_ELF_H_ 1
32
33/*
34 * EABI ELF definitions for the PowerPC architecture.
35 * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation"
36 * [ppc-eabi-1995-01.pdf] for details.
37 */
38
39#ifndef __ELF_WORD_SIZE
40#ifdef __powerpc64__
41#define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */
42#else
43#define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */
44#endif
45#endif
46
47#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */
48#include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */
49#include <sys/elf_generic.h>
50
51#if __ELF_WORD_SIZE == 64
52#define ELF_ARCH EM_PPC64
53#define ELF_MACHINE_OK(x) ((x) == EM_PPC64)
54#else
55#define ELF_ARCH EM_PPC
56#define ELF_ARCH32 EM_PPC
57#define ELF_MACHINE_OK(x) ((x) == EM_PPC)
58#endif
59
60/*
61 * Auxiliary vector entries for passing information to the interpreter.
62 *
63 * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t",
64 * but POSIX lays claim to all symbols ending with "_t".
65 */
66
67typedef struct { /* Auxiliary vector entry on initial stack */
68 int a_type; /* Entry type. */
69 union {
70#ifdef __powerpc64__
71 int a_val; /* Integer value */
72#else
73 long a_val; /* Integer value. */
74 void *a_ptr; /* Address. */
75 void (*a_fcn)(void); /* Function pointer (not used). */
76#endif
77 } a_un;
78} Elf32_Auxinfo;
79
80typedef struct { /* Auxiliary vector entry on initial stack */
81 long a_type; /* Entry type. */
82 union {
83 long a_val; /* Integer value. */
84 void *a_ptr; /* Address. */
85 void (*a_fcn)(void); /* Function pointer (not used). */
86 } a_un;
87} Elf64_Auxinfo;
88
89__ElfType(Auxinfo);
90
91/*
92 * Relocation types.
93 */
94
95#define R_PPC_COUNT 37 /* Count of defined relocation types. */
96
97 /* Count of defined relocation types. */
98#define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1)
99
100/* Define "machine" characteristics */
101#if BYTE_ORDER == LITTLE_ENDIAN
102#define ELF_TARG_DATA ELFDATA2LSB
103#else
104#define ELF_TARG_DATA ELFDATA2MSB
105#endif
106#if __ELF_WORD_SIZE == 64
107#define ELF_TARG_CLASS ELFCLASS64
108#define ELF_TARG_MACH EM_PPC64
109#define ELF_TARG_VER 1
110#else
111#define ELF_TARG_CLASS ELFCLASS32
112#define ELF_TARG_MACH EM_PPC
113#define ELF_TARG_VER 1
114#endif
115
116#define ET_DYN_LOAD_ADDR 0x01010000
117
118#define AT_OLD_NULL AT_NULL
119#define AT_OLD_IGNORE AT_IGNORE
120#define AT_OLD_EXECFD AT_EXECFD
121#define AT_OLD_PHDR AT_PHDR
122#define AT_OLD_PHENT AT_PHENT
123#define AT_OLD_PHNUM AT_PHNUM
124#define AT_OLD_PAGESZ AT_PAGESZ
125#define AT_OLD_BASE AT_BASE
126#define AT_OLD_FLAGS AT_FLAGS
127#define AT_OLD_ENTRY AT_ENTRY
128#define AT_OLD_NOTELF AT_NOTELF
129#define AT_OLD_UID AT_UID
130#define AT_OLD_EUID AT_EUID
131#define AT_OLD_EXECPATH 13
132#define AT_OLD_CANARY 14
133#define AT_OLD_CANARYLEN 15
134#define AT_OLD_OSRELDATE 16
135#define AT_OLD_NCPUS 17
136#define AT_OLD_PAGESIZES 18
137#define AT_OLD_PAGESIZESLEN 19
138#define AT_OLD_STACKPROT 21
139#define AT_OLD_TIMEKEEP AT_TIMEKEEP
140#define AT_OLD_EHDRFLAGS AT_EHDRFLAGS
141#define AT_OLD_HWCAP AT_HWCAP
142#define AT_OLD_HWCAP2 AT_HWCAP2
143
144#define AT_OLD_COUNT 27 /* Count of defined aux entry types. */
145
146#endif /* !_MACHINE_ELF_H_ */
\ No newline at end of file
5#include <x86/elf.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/endian.h+2-37
......@@ -1,40 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1987, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)endian.h 8.1 (Berkeley) 6/10/93
2 * This file is in the public domain.
323 */
334
34#ifndef _MACHINE_ENDIAN_H_
35#define _MACHINE_ENDIAN_H_
36
37#include <sys/_types.h>
38#include <sys/_endian.h>
39
40#endif /* !_MACHINE_ENDIAN_H_ */
\ No newline at end of file
5#include <x86/endian.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/exec.h+4-4
......@@ -1,8 +1,8 @@
11/*-
22 * SPDX-License-Identifier: BSD-3-Clause
33 *
4 * Copyright (c) 2001 David E. O'Brien
5 * All rights reserved.
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
66 *
77 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions
......@@ -12,11 +12,11 @@
1212 * 2. Redistributions in binary form must reproduce the above copyright
1313 * notice, this list of conditions and the following disclaimer in the
1414 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
15 * 3. Neither the name of the University nor the names of its contributors
1616 * may be used to endorse or promote products derived from this software
1717 * without specific prior written permission.
1818 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2121 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2222 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
lib/libc/include/generic-freebsd/machine/float.h+2-97
......@@ -1,100 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1989 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
32 * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11
2 * This file is in the public domain.
333 */
344
35#ifndef _MACHINE_FLOAT_H_
36#define _MACHINE_FLOAT_H_ 1
37
38#include <sys/cdefs.h>
39
40#ifndef _SOFT_FLOAT
41__BEGIN_DECLS
42extern int __flt_rounds(void);
43__END_DECLS
44#define FLT_ROUNDS __flt_rounds()
45#else
46#define FLT_ROUNDS (-1)
47#endif
48
49#define FLT_RADIX 2 /* b */
50#if __ISO_C_VISIBLE >= 1999
51#define FLT_EVAL_METHOD 0
52#define DECIMAL_DIG 17 /* max precision in decimal digits */
53#endif
54
55#define FLT_MANT_DIG 24 /* p */
56#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
57#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
58#define FLT_MIN_EXP (-125) /* emin */
59#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
60#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
61#define FLT_MAX_EXP 128 /* emax */
62#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
63#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
64#if __ISO_C_VISIBLE >= 2011
65#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */
66#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */
67#define FLT_HAS_SUBNORM 1
68#endif /* __ISO_C_VISIBLE >= 2011 */
69
70#define DBL_MANT_DIG 53
71#define DBL_EPSILON 2.2204460492503131E-16
72#define DBL_DIG 15
73#define DBL_MIN_EXP (-1021)
74#define DBL_MIN 2.2250738585072014E-308
75#define DBL_MIN_10_EXP (-307)
76#define DBL_MAX_EXP 1024
77#define DBL_MAX 1.7976931348623157E+308
78#define DBL_MAX_10_EXP 308
79#if __ISO_C_VISIBLE >= 2011
80#define DBL_TRUE_MIN 4.9406564584124654E-324
81#define DBL_DECIMAL_DIG 17
82#define DBL_HAS_SUBNORM 1
83#endif /* __ISO_C_VISIBLE >= 2011 */
84
85#define LDBL_MANT_DIG DBL_MANT_DIG
86#define LDBL_EPSILON ((long double)DBL_EPSILON)
87#define LDBL_DIG DBL_DIG
88#define LDBL_MIN_EXP DBL_MIN_EXP
89#define LDBL_MIN ((long double)DBL_MIN)
90#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
91#define LDBL_MAX_EXP DBL_MAX_EXP
92#define LDBL_MAX ((long double)DBL_MAX)
93#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
94#if __ISO_C_VISIBLE >= 2011
95#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN)
96#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
97#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
98#endif /* __ISO_C_VISIBLE >= 2011 */
99
100#endif /* _MACHINE_FLOAT_H_ */
\ No newline at end of file
5#include <x86/float.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/floatingpoint.h+9-4
......@@ -1,7 +1,7 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
2 * SPDX-License-Identifier: BSD-4-Clause
33 *
4 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>
4 * Copyright (c) 1993 Andrew Moore, Talke Studio
55 * All rights reserved.
66 *
77 * Redistribution and use in source and binary forms, with or without
......@@ -12,11 +12,15 @@
1212 * 2. Redistributions in binary form must reproduce the above copyright
1313 * notice, this list of conditions and the following disclaimer in the
1414 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
1620 * may be used to endorse or promote products derived from this software
1721 * without specific prior written permission.
1822 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2024 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2125 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2226 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
......@@ -32,6 +36,7 @@
3236#ifndef _FLOATINGPOINT_H_
3337#define _FLOATINGPOINT_H_
3438
39#include <sys/cdefs.h>
3540#include <machine/ieeefp.h>
3641
3742#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/fpu.h deleted-102
......@@ -1,102 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1996 Wolfgang Solfrank.
5 * Copyright (C) 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: fpu.h,v 1.2 1999/12/07 15:14:56 danw Exp $
34 */
35
36#ifndef _MACHINE_FPU_H_
37#define _MACHINE_FPU_H_
38
39#define FPSCR_FX 0x80000000
40#define FPSCR_FEX 0x40000000
41#define FPSCR_VX 0x20000000
42#define FPSCR_OX 0x10000000
43#define FPSCR_UX 0x08000000
44#define FPSCR_ZX 0x04000000
45#define FPSCR_XX 0x02000000
46#define FPSCR_VXSNAN 0x01000000
47#define FPSCR_VXISI 0x00800000
48#define FPSCR_VXIDI 0x00400000
49#define FPSCR_VXZDZ 0x00200000
50#define FPSCR_VXIMZ 0x00100000
51#define FPSCR_VXVC 0x00080000
52#define FPSCR_FR 0x00040000
53#define FPSCR_FI 0x00020000
54#define FPSCR_FPRF 0x0001f000
55#define FPSCR_C 0x00010000
56#define FPSCR_FPCC 0x0000f000
57#define FPSCR_FL 0x00008000
58#define FPSCR_FG 0x00004000
59#define FPSCR_FE 0x00002000
60#define FPSCR_FU 0x00001000
61#define FPSCR_VXSOFT 0x00000400
62#define FPSCR_VXSQRT 0x00000200
63#define FPSCR_VXCVI 0x00000100
64#define FPSCR_VE 0x00000080
65#define FPSCR_OE 0x00000040
66#define FPSCR_UE 0x00000020
67#define FPSCR_ZE 0x00000010
68#define FPSCR_XE 0x00000008
69#define FPSCR_NI 0x00000004
70#define FPSCR_RN 0x00000003
71
72#ifdef _KERNEL
73
74void enable_fpu(struct thread *);
75void save_fpu(struct thread *);
76void save_fpu_nodrop(struct thread *);
77void cleanup_fpscr(void);
78u_int get_fpu_exception(struct thread *);
79void enable_fpu_kern(void);
80void disable_fpu(struct thread *td);
81
82/*
83 * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread().
84 */
85#define FPU_KERN_NORMAL 0x0000
86#define FPU_KERN_NOWAIT 0x0001
87#define FPU_KERN_KTHR 0x0002
88#define FPU_KERN_NOCTX 0x0004
89
90struct fpu_kern_ctx;
91
92struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
93void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
94void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
95 u_int flags);
96int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
97int fpu_kern_thread(u_int flags);
98int is_fpu_kern_thread(u_int flags);
99
100#endif /* _KERNEL */
101
102#endif /* _MACHINE_FPU_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/frame.h deleted-114
......@@ -1,114 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: frame.h,v 1.2 1999/01/10 10:13:15 tsubai Exp $
34 */
35
36#ifndef _MACHINE_FRAME_H_
37#define _MACHINE_FRAME_H_
38
39#include <sys/types.h>
40
41/*
42 * We have to save all registers on every trap, because
43 * 1. user could attach this process every time
44 * 2. we must be able to restore all user registers in case of fork
45 * Actually, we do not save the fp registers on trap, since
46 * these are not used by the kernel. They are saved only when switching
47 * between processes using the FPU.
48 *
49 * Change ordering to cluster together these register_t's. XXX
50 */
51struct trapframe {
52 register_t fixreg[32];
53 register_t lr;
54 register_t cr;
55 register_t xer;
56 register_t ctr;
57 register_t srr0;
58 register_t srr1;
59 register_t exc;
60 register_t dar; /* DAR/DEAR filled in on DSI traps */
61 union {
62 struct {
63 /* dsisr only filled on a DSI trap */
64 register_t dsisr;
65 } aim;
66 struct {
67 register_t esr;
68 register_t dbcr0;
69 } booke;
70 } cpu;
71};
72
73/*
74 * FRAMELEN is the size of the stack region used by the low-level trap
75 * handler. It is the size of its data (trapframe) plus the callframe
76 * header (sizeof(struct callframe) - 3 register widths). It must also
77 * be 16-byte aligned.
78 */
79#define FRAMELEN roundup(sizeof(struct trapframe) + \
80 sizeof(struct callframe) - 3*sizeof(register_t), 16)
81#define trapframe(td) ((td)->td_frame)
82
83/*
84 * Call frame for PowerPC used during fork.
85 */
86#ifdef __powerpc64__
87struct callframe {
88 register_t cf_dummy_fp; /* dummy frame pointer */
89 register_t cf_cr;
90 register_t cf_lr;
91 register_t cf_compiler;
92 register_t cf_linkeditor;
93 register_t cf_toc;
94 register_t cf_func;
95 register_t cf_arg0;
96 register_t cf_arg1;
97 register_t _padding; /* Maintain 16-byte alignment */
98};
99#else
100struct callframe {
101 register_t cf_dummy_fp; /* dummy frame pointer */
102 register_t cf_lr; /* space for link register save */
103 register_t cf_func;
104 register_t cf_arg0;
105 register_t cf_arg1;
106 register_t _padding; /* Maintain 16-byte alignment */
107};
108#endif
109
110/* Definitions for syscalls */
111#define FIRSTARG 3 /* first arg in reg 3 */
112#define NARGREG 8 /* 8 args in regs */
113
114#endif /* _MACHINE_FRAME_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/gdb_machdep.h deleted-140
......@@ -1,140 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2006 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_GDB_MACHDEP_H_
30#define _MACHINE_GDB_MACHDEP_H_
31
32#ifdef BOOKE
33#define PPC_GDB_NREGS0 1
34#define PPC_GDB_NREGS4 (70 + 1)
35#define PPC_GDB_NREGS8 (1 + 32)
36#define PPC_GDB_NREGS16 0
37
38#else
39/*
40 * 0 - 32*GPR(4/8)
41 * 32 - 32*FPR(8)
42 * 64 - PC, PS (4/8)
43 * 66 - CR (4)
44 * 67 - LR, CTR (4/8)
45 * 69 - XER, FPSCR (4)
46 * 71 - 32*VR(16)
47 * 103 - VSCR, VRSAVE (4)
48 */
49
50#define PPC_REGNUM_R0 0
51#define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31)
52#define PPC_REGNUM_FR0 32
53#define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31)
54#define PPC_REGNUM_PC 64
55#define PPC_REGNUM_PS 65
56#define PPC_REGNUM_CR 66
57#define PPC_REGNUM_LR 67
58#define PPC_REGNUM_CTR 68
59#define PPC_REGNUM_XER 69
60#define PPC_REGNUM_FPSCR 70
61#define PPC_REGNUM_VR0 71
62#define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31)
63
64#define PPC_GDB_NREGS0 0
65
66#ifdef __powerpc64__
67#define PPC_GDB_NREGS4 5
68#define PPC_GDB_NREGS8 (64 + 4)
69#else
70#define PPC_GDB_NREGS4 (32 + 7 + 2)
71#define PPC_GDB_NREGS8 32
72#endif
73
74#define PPC_GDB_NREGS16 32
75#endif
76
77#define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \
78 PPC_GDB_NREGS8 + PPC_GDB_NREGS16)
79#define GDB_REG_PC 64
80
81#define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \
82 PPC_GDB_NREGS8 * 16 + \
83 PPC_GDB_NREGS16 * 32)
84
85static __inline size_t
86gdb_cpu_regsz(int regnum)
87{
88
89#ifdef BOOKE
90 if (regnum == 70)
91 return (0);
92 if (regnum == 71 || regnum >= 73)
93 return (8);
94#else
95#ifdef __powerpc64__
96 if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) ||
97 regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR)
98 return (8);
99#else
100 if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31)
101 return (8);
102#endif
103 if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31)
104 return (16);
105#endif
106 return (4);
107}
108
109static __inline int
110gdb_cpu_query(void)
111{
112
113 return (0);
114}
115
116static __inline void *
117gdb_begin_write(void)
118{
119
120 return (NULL);
121}
122
123static __inline void
124gdb_end_write(void *arg __unused)
125{
126
127}
128
129static __inline void
130gdb_cpu_stop_reason(int type __unused, int code __unused)
131{
132
133}
134
135void *gdb_cpu_getreg(int, size_t *);
136void gdb_cpu_setreg(int, void *);
137int gdb_cpu_signal(int, int);
138void gdb_cpu_do_offsets(void);
139
140#endif /* !_MACHINE_GDB_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/hid.h deleted-223
......@@ -1,223 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $NetBSD: hid.h,v 1.2 2001/08/22 21:05:25 matt Exp $
29 */
30
31#ifndef _POWERPC_HID_H_
32#define _POWERPC_HID_H_
33
34/* Hardware Implementation Dependent registers for the PowerPC */
35#define HID0_RADIX 0x0080000000000000 /* Enable Radix page tables (POWER9) */
36
37#define HID0_EMCP 0x80000000 /* Enable machine check pin */
38#define HID0_DBP 0x40000000 /* Disable 60x bus parity generation */
39#define HID0_EBA 0x20000000 /* Enable 60x bus address parity checking */
40#define HID0_EBD 0x10000000 /* Enable 60x bus data parity checking */
41#define HID0_BCLK 0x08000000 /* CLK_OUT clock type selection */
42#define HID0_EICE 0x04000000 /* Enable ICE output */
43#define HID0_ECLK 0x02000000 /* CLK_OUT clock type selection */
44#define HID0_PAR 0x01000000 /* Disable precharge of ARTRY */
45#define HID0_STEN 0x01000000 /* Software table search enable (7450) */
46#define HID0_DEEPNAP 0x01000000 /* Enable deep nap mode (970) */
47#define HID0_HBATEN 0x00800000 /* High BAT enable (74[45][578]) */
48#define HID0_DOZE 0x00800000 /* Enable doze mode */
49#define HID0_NAP 0x00400000 /* Enable nap mode */
50#define HID0_SLEEP 0x00200000 /* Enable sleep mode */
51#define HID0_DPM 0x00100000 /* Enable Dynamic power management */
52#define HID0_RISEG 0x00080000 /* Read I-SEG */
53#define HID0_TG 0x00040000 /* Timebase Granularity (OEA64) */
54#define HID0_BHTCLR 0x00040000 /* Clear branch history table (7450) */
55#define HID0_EIEC 0x00040000 /* Enable internal error checking */
56#define HID0_XAEN 0x00020000 /* Enable eXtended Addressing (7450) */
57#define HID0_NHR 0x00010000 /* Not hard reset */
58#define HID0_ICE 0x00008000 /* Enable i-cache */
59#define HID0_DCE 0x00004000 /* Enable d-cache */
60#define HID0_ILOCK 0x00002000 /* i-cache lock */
61#define HID0_DLOCK 0x00001000 /* d-cache lock */
62#define HID0_ICFI 0x00000800 /* i-cache flush invalidate */
63#define HID0_DCFI 0x00000400 /* d-cache flush invalidate */
64#define HID0_SPD 0x00000200 /* Disable speculative cache access */
65#define HID0_XBSEN 0x00000100 /* Extended BAT block-size enable (7457) */
66#define HID0_IFEM 0x00000100 /* Enable M-bit for I-fetch */
67#define HID0_XBSEN 0x00000100 /* Extended BAT block size enable (7455+)*/
68#define HID0_SGE 0x00000080 /* Enable store gathering */
69#define HID0_DCFA 0x00000040 /* Data cache flush assist */
70#define HID0_BTIC 0x00000020 /* Enable BTIC */
71#define HID0_LRSTK 0x00000010 /* Link register stack enable (7450) */
72#define HID0_ABE 0x00000008 /* Enable address broadcast */
73#define HID0_FOLD 0x00000008 /* Branch folding enable (7450) */
74#define HID0_BHT 0x00000004 /* Enable branch history table */
75#define HID0_NOPTI 0x00000001 /* No-op the dcbt(st) */
76
77#define HID0_AIM_TBEN 0x04000000 /* Time base enable (7450) */
78
79#define HID0_E500_TBEN 0x00004000 /* Time Base and decr. enable */
80#define HID0_E500_SEL_TBCLK 0x00002000 /* Select Time Base clock */
81#define HID0_E500_MAS7UPDEN 0x00000080 /* Enable MAS7 update (e500v2) */
82
83#define HID0_E500MC_L2MMU_MHD 0x40000000 /* L2MMU Multiple Hit Detection */
84
85#define HID0_BITMASK \
86 "\20" \
87 "\040EMCP\037DBP\036EBA\035EBD\034BCLK\033EICE\032ECLK\031PAR" \
88 "\030DOZE\027NAP\026SLEEP\025DPM\024RISEG\023EIEC\022res\021NHR" \
89 "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011IFEM" \
90 "\010SGE\007DCFA\006BTIC\005FBIOB\004ABE\003BHT\002NOPDST\001NOPTI"
91
92#define HID0_7450_BITMASK \
93 "\20" \
94 "\040EMCP\037b1\036b2\035b3\034b4\033TBEN\032b6\031STEN" \
95 "\030HBATEN\027NAP\026SLEEP\025DPM\024b12\023BHTCLR\022XAEN\021NHR" \
96 "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011XBSEN" \
97 "\010SGE\007b25\006BTIC\005LRSTK\004FOLD\003BHT\002NOPDST\001NOPTI"
98
99#define HID0_E500_BITMASK \
100 "\20" \
101 "\040EMCP\037b1\036b2\035b3\034b4\033b5\032b6\031b7" \
102 "\030DOZE\027NAP\026SLEEP\025b11\024b12\023b13\022b14\021b15" \
103 "\020b16\017TBEN\016SEL_TBCLK\015b19\014b20\013b21\012b22\011b23" \
104 "\010EN_MAS7_UPDATE\007DCFA\006b26\005b27\004b28\003b29\002b30\001NOPTI"
105
106#define HID0_970_BITMASK \
107 "\20" \
108 "\040ONEPPC\037SINGLE\036ISYNCSC\035SERGP\031DEEPNAP\030DOZE" \
109 "\027NAP\025DPM\023TG\022HANGDETECT\021NHR\020INORDER" \
110 "\016TBCTRL\015TBEN\012CIABREN\011HDICEEN\001ENATTN"
111
112#define HID0_E500MC_BITMASK \
113 "\20" \
114 "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \
115 "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \
116 "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \
117 "\010EN_MAS7_UPDATE\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI"
118
119#define HID0_E5500_BITMASK \
120 "\20" \
121 "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \
122 "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \
123 "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \
124 "\010b24\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI"
125
126/*
127 * HID0 bit definitions per cpu model
128 *
129 * bit 603 604 750 7400 7410 7450 7457 e500
130 * 0 EMCP EMCP EMCP EMCP EMCP - - EMCP
131 * 1 - ECP DBP - - - - -
132 * 2 EBA EBA EBA EBA EDA - - -
133 * 3 EBD EBD EBD EBD EBD - - -
134 * 4 SBCLK - BCLK BCKL BCLK - - -
135 * 5 EICE - - - - TBEN TBEN -
136 * 6 ECLK - ECLK ECLK ECLK - - -
137 * 7 PAR PAR PAR PAR PAR STEN STEN -
138 * 8 DOZE - DOZE DOZE DOZE - HBATEN DOZE
139 * 9 NAP - NAP NAP NAP NAP NAP NAP
140 * 10 SLEEP - SLEEP SLEEP SLEEP SLEEP SLEEP SLEEP
141 * 11 DPM - DPM DPM DPM DPM DPM -
142 * 12 RISEG - - RISEG - - - -
143 * 13 - - - EIEC EIEC BHTCLR BHTCLR -
144 * 14 - - - - - XAEN XAEN -
145 * 15 - NHR NHR NHR NHR NHR NHR -
146 * 16 ICE ICE ICE ICE ICE ICE ICE -
147 * 17 DCE DCE DCE DCE DCE DCE DCE TBEN
148 * 18 ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK SEL_TBCLK
149 * 19 DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK -
150 * 20 ICFI ICFI ICFI ICFI ICFI ICFI ICFI -
151 * 21 DCFI DCFI DCFI DCFI DCFI DCFI DCFI -
152 * 22 - - SPD SPD SPG SPD SPD -
153 * 23 - - IFEM IFTT IFTT - XBSEN -
154 * 24 - SIE SGE SGE SGE SGE SGE EN_MAS7_UPDATE
155 * 25 - - DCFA DCFA DCFA - - DCFA
156 * 26 - - BTIC BTIC BTIC BTIC BTIC -
157 * 27 FBIOB - - - - LRSTK LRSTK -
158 * 28 - - ABE - - FOLD FOLD -
159 * 29 - BHT BHT BHT BHT BHT BHT -
160 * 30 - - - NOPDST NOPDST NOPDST NOPDST -
161 * 31 NOOPTI - NOOPTI NOPTI NOPTI NOPTI NOPTI NOPTI
162 *
163 * bit e500mc e5500
164 * 0 EMCP EMCP
165 * 1 EN_L2MMU_MHD EN_L2MMU_MHD
166 * 2 - -
167 * 3 - -
168 * 4 - -
169 * 5 - -
170 * 6 - -
171 * 7 - -
172 * 8 - -
173 * 9 - -
174 * 10 - -
175 * 11 - -
176 * 12 - -
177 * 13 - -
178 * 14 - -
179 * 15 - -
180 * 16 - -
181 * 17 - -
182 * 18 - -
183 * 19 - -
184 * 20 - -
185 * 21 - -
186 * 22 - -
187 * 23 - -
188 * 24 EN_MAS7_UPDATE -
189 * 25 DCFA DCFA
190 * 26 - -
191 * 27 CIGLSO CIGLSO
192 * 28 - -
193 * 29 - -
194 * 30 - -
195 * 31 NOPTI NOPTI
196 *
197 * 604: ECP = Enable cache parity checking
198 * 604: SIE = Serial instruction execution disable
199 * 7450: TBEN = Time Base Enable
200 * 7450: STEN = Software table lookup enable
201 * 7450: BHTCLR = Branch history clear
202 * 7450: XAEN = Extended Addressing Enabled
203 * 7450: LRSTK = Link Register Stack Enable
204 * 7450: FOLD = Branch folding enable
205 * 7457: HBATEN = High BAT Enable
206 * 7457: XBSEN = Extended BAT Block Size Enable
207 */
208
209#define HID1_E500_ABE 0x00001000 /* Address broadcast enable */
210#define HID1_E500_ASTME 0x00002000 /* Address bus streaming mode enable */
211#define HID1_E500_RFXE 0x00020000 /* Read fault exception enable */
212
213#define HID0_E500_DEFAULT_SET (HID0_EMCP | HID0_E500_TBEN | \
214 HID0_E500_MAS7UPDEN)
215#define HID1_E500_DEFAULT_SET (HID1_E500_ABE | HID1_E500_ASTME)
216#define HID0_E500MC_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD | \
217 HID0_E500_MAS7UPDEN)
218#define HID0_E5500_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD)
219
220#define HID5_970_DCBZ_SIZE_HI 0x00000080UL /* dcbz does a 32-byte store */
221#define HID4_970_DISABLE_LG_PG 0x00000004ULL /* disables large pages */
222
223#endif /* _POWERPC_HID_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/ieee.h deleted-143
......@@ -1,143 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
10 *
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * @(#)ieee.h 8.1 (Berkeley) 6/11/93
41 * from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp
42 */
43
44#ifndef _MACHINE_IEEE_H_
45#define _MACHINE_IEEE_H_
46
47/*
48 * ieee.h defines the machine-dependent layout of the machine's IEEE
49 * floating point. It does *not* define (yet?) any of the rounding
50 * mode bits, exceptions, and so forth.
51 */
52
53/*
54 * Define the number of bits in each fraction and exponent.
55 *
56 * k k+1
57 * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented
58 *
59 * (-exp_bias+1)
60 * as fractions that look like 0.fffff x 2 . This means that
61 *
62 * -126
63 * the number 0.10000 x 2 , for instance, is the same as the normalized
64 *
65 * -127 -128
66 * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero
67 *
68 * -129
69 * in the fraction; to represent 2 , we need two, and so on. This
70 *
71 * (-exp_bias-fracbits+1)
72 * implies that the smallest denormalized number is 2
73 *
74 * for whichever format we are talking about: for single precision, for
75 *
76 * -126 -149
77 * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and
78 *
79 * -149 == -127 - 23 + 1.
80 */
81#define SNG_EXPBITS 8
82#define SNG_FRACBITS 23
83
84#define DBL_EXPBITS 11
85#define DBL_FRACBITS 52
86
87#ifdef notyet
88#define E80_EXPBITS 15
89#define E80_FRACBITS 64
90#endif
91
92#define EXT_EXPBITS 15
93#define EXT_FRACBITS 112
94
95struct ieee_single {
96 u_int sng_sign:1;
97 u_int sng_exp:8;
98 u_int sng_frac:23;
99};
100
101struct ieee_double {
102 u_int dbl_sign:1;
103 u_int dbl_exp:11;
104 u_int dbl_frach:20;
105 u_int dbl_fracl;
106};
107
108struct ieee_ext {
109 u_int ext_sign:1;
110 u_int ext_exp:15;
111 u_int ext_frach:16;
112 u_int ext_frachm;
113 u_int ext_fraclm;
114 u_int ext_fracl;
115};
116
117/*
118 * Floats whose exponent is in [1..INFNAN) (of whatever type) are
119 * `normal'. Floats whose exponent is INFNAN are either Inf or NaN.
120 * Floats whose exponent is zero are either zero (iff all fraction
121 * bits are zero) or subnormal values.
122 *
123 * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
124 * high fraction; if the bit is set, it is a `quiet NaN'.
125 */
126#define SNG_EXP_INFNAN 255
127#define DBL_EXP_INFNAN 2047
128#define EXT_EXP_INFNAN 32767
129
130#if 0
131#define SNG_QUIETNAN (1 << 22)
132#define DBL_QUIETNAN (1 << 19)
133#define EXT_QUIETNAN (1 << 15)
134#endif
135
136/*
137 * Exponent biases.
138 */
139#define SNG_EXP_BIAS 127
140#define DBL_EXP_BIAS 1023
141#define EXT_EXP_BIAS 16383
142
143#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/ieeefp.h deleted-42
......@@ -1,42 +0,0 @@
1/* -
2 * Written by J.T. Conklin, Apr 6, 1995
3 * Public domain.
4 * $NetBSD: ieeefp.h,v 1.2 1999/07/07 01:52:26 danw Exp $
5 */
6
7#ifndef _MACHINE_IEEEFP_H_
8#define _MACHINE_IEEEFP_H_
9
10/* Deprecated historical FPU control interface */
11
12typedef int fp_except_t;
13#ifdef __SPE__
14#define FP_X_OFL 0x01 /* overflow exception */
15#define FP_X_UFL 0x02 /* underflow exception */
16#define FP_X_DZ 0x04 /* divide-by-zero exception */
17#define FP_X_INV 0x08 /* invalid operation exception */
18#define FP_X_IMP 0x10 /* imprecise (loss of precision) */
19#else
20#define FP_X_IMP 0x01 /* imprecise (loss of precision) */
21#define FP_X_DZ 0x02 /* divide-by-zero exception */
22#define FP_X_UFL 0x04 /* underflow exception */
23#define FP_X_OFL 0x08 /* overflow exception */
24#define FP_X_INV 0x10 /* invalid operation exception */
25#endif
26
27typedef enum {
28 FP_RN=0, /* round to nearest representable number */
29 FP_RZ=1, /* round to zero (truncate) */
30 FP_RP=2, /* round toward positive infinity */
31 FP_RM=3 /* round toward negative infinity */
32} fp_rnd_t;
33
34__BEGIN_DECLS
35extern fp_rnd_t fpgetround(void);
36extern fp_rnd_t fpsetround(fp_rnd_t);
37extern fp_except_t fpgetmask(void);
38extern fp_except_t fpsetmask(fp_except_t);
39extern fp_except_t fpgetsticky(void);
40__END_DECLS
41
42#endif /* _MACHINE_IEEEFP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/ifunc.h deleted-58
......@@ -1,58 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2019 Brandon Bergren <bdragon@FreeBSD.org>
5 * Copyright (c) 2015-2018 The FreeBSD Foundation. All rights reserved.
6 *
7 * Part of this software was developed by
8 * Konstantin Belousov <kib@FreeBSD.org>
9 * under sponsorship from the FreeBSD Foundation.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef __POWERPC_IFUNC_H
34#define __POWERPC_IFUNC_H
35
36#include <sys/types.h>
37
38#define DEFINE_IFUNC(qual, ret_type, name, args) \
39 static ret_type (*name##_resolver(void))args __used; \
40 qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
41 static ret_type (*name##_resolver(void))args
42
43#define DEFINE_UIFUNC(qual, ret_type, name, args) \
44 static ret_type (*name##_resolver(register_t, register_t, \
45 register_t, register_t, register_t, register_t, register_t, \
46 register_t))args __used; \
47 qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
48 static ret_type (*name##_resolver( \
49 register_t cpu_features, \
50 register_t cpu_features2, \
51 register_t arg3 __unused, \
52 register_t arg4 __unused, \
53 register_t arg5 __unused, \
54 register_t arg6 __unused, \
55 register_t arg7 __unused, \
56 register_t arg8 __unused))args
57
58#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/in_cksum.h-1
......@@ -29,7 +29,6 @@
2929 * SUCH DAMAGE.
3030 *
3131 * from tahoe: in_cksum.c 1.2 86/01/05
32 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
3332 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
3433 */
3534
lib/libc/include/generic-freebsd/machine/intr_machdep.h deleted-64
......@@ -1,64 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2002 Benno Rice.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_INTR_MACHDEP_H_
29#define _MACHINE_INTR_MACHDEP_H_
30
31#define INTR_VECTORS 256
32
33#define MAX_PICS 32
34#define MAP_IRQ(node, pin) powerpc_get_irq(node, pin)
35
36/*
37 * Default base address for MSI messages on PowerPC
38 */
39#define MSI_INTEL_ADDR_BASE 0xfee00000
40
41extern device_t root_pic;
42
43struct trapframe;
44
45driver_filter_t powerpc_ipi_handler;
46
47void intrcnt_add(const char *name, u_long **countp);
48
49u_int powerpc_register_pic(device_t, uint32_t, u_int, u_int, u_int);
50u_int powerpc_get_irq(uint32_t, u_int);
51
52void powerpc_dispatch_intr(u_int, struct trapframe *);
53int powerpc_enable_intr(void);
54int powerpc_setup_intr(const char *, u_int, driver_filter_t, driver_intr_t,
55 void *, enum intr_type, void **, int);
56int powerpc_teardown_intr(void *);
57int powerpc_bind_intr(u_int irq, u_char cpu);
58int powerpc_config_intr(int, enum intr_trigger, enum intr_polarity);
59int powerpc_fw_config_intr(int irq, int sense_code);
60
61void powerpc_intr_mask(u_int irq);
62void powerpc_intr_unmask(u_int irq);
63
64#endif /* _MACHINE_INTR_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/kdb.h deleted-67
......@@ -1,67 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2004 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_KDB_H_
30#define _MACHINE_KDB_H_
31
32#include <machine/cpufunc.h>
33#include <machine/frame.h>
34#include <machine/md_var.h>
35#include <machine/psl.h>
36#include <machine/spr.h>
37
38void kdb_cpu_clear_singlestep(void);
39void kdb_cpu_set_singlestep(void);
40
41static __inline void
42kdb_cpu_sync_icache(unsigned char *addr, size_t size)
43{
44
45 __syncicache(addr, size);
46}
47
48static __inline void
49kdb_cpu_trap(int vector, int _)
50{
51}
52
53static __inline int
54kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access)
55{
56
57 return (ENXIO);
58}
59
60static __inline int
61kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size)
62{
63
64 return (0);
65}
66
67#endif /* _MACHINE_KDB_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/limits.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _MACHINE_LIMITS_H_
lib/libc/include/generic-freebsd/machine/machdep.h deleted-37
......@@ -1,37 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2011-2012 Semihalf
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _POWERPC_MACHDEP_H_
30#define _POWERPC_MACHDEP_H_
31
32void booke_disable_l2_cache(void);
33void booke_enable_l1_cache(void);
34void booke_enable_l2_cache(void);
35void booke_enable_bpred(void);
36
37#endif /* _POWERPC_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/md_var.h deleted-71
......@@ -1,71 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 1998 Doug Rabson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_MD_VAR_H_
30#define _MACHINE_MD_VAR_H_
31
32/*
33 * Miscellaneous machine-dependent declarations.
34 */
35
36extern char sigcode32[];
37extern int szsigcode32;
38
39#ifdef __powerpc64__
40extern char sigcode64[], sigcode64_elfv2[];
41extern int szsigcode64, szsigcode64_elfv2;
42
43struct dumperinfo;
44struct minidumpstate;
45int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *);
46#endif
47
48extern long Maxmem;
49
50extern vm_offset_t kstack0;
51extern vm_offset_t kstack0_phys;
52
53extern int powerpc_pow_enabled;
54extern int cacheline_size;
55extern int hw_direct_map;
56
57void __syncicache(void *, int);
58
59int mem_valid(vm_offset_t addr, int len);
60
61void decr_init(void);
62void decr_ap_init(void);
63void decr_tc_init(void);
64
65void cpu_feature_setup(void);
66void cpu_setup(u_int);
67
68struct trapframe;
69void powerpc_interrupt(struct trapframe *);
70
71#endif /* !_MACHINE_MD_VAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/metadata.h+2-35
......@@ -1,38 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
2 * This file is in the public domain.
273 */
284
29#ifndef _MACHINE_METADATA_H_
30#define _MACHINE_METADATA_H_
31
32#define MODINFOMD_ENVP 0x1001
33#define MODINFOMD_HOWTO 0x1002
34#define MODINFOMD_KERNEND 0x1003
35#define MODINFOMD_BOOTINFO 0x1004
36#define MODINFOMD_DTBP 0x1005
37
38#endif /* !_MACHINE_METADATA_H_ */
\ No newline at end of file
5#include <x86/metadata.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/minidump.h deleted-52
......@@ -1,52 +0,0 @@
1/*-
2 * Copyright (c) 2006 Peter Wemm
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * From i386: FreeBSD: 157909 2006-04-21 04:28:43Z peter
27 */
28
29#ifndef _MACHINE_MINIDUMP_H_
30#define _MACHINE_MINIDUMP_H_ 1
31
32#define MINIDUMP_MAGIC "minidump FreeBSD/powerpc64"
33#define MINIDUMP_VERSION 2
34
35struct minidumphdr {
36 char magic[32];
37 char mmu_name[32];
38 uint32_t version;
39 uint32_t msgbufsize;
40 uint32_t bitmapsize;
41 uint32_t pmapsize;
42 uint64_t kernbase;
43 uint64_t kernend;
44 uint64_t dmapbase;
45 uint64_t dmapend;
46 int hw_direct_map;
47 uint64_t startkernel;
48 uint64_t endkernel;
49 uint32_t dumpavailsize;
50};
51
52#endif /* _MACHINE_MINIDUMP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/mmuvar.h deleted-224
......@@ -1,224 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 Peter Grehan
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_MMUVAR_H_
30#define _MACHINE_MMUVAR_H_
31
32typedef void (*pmap_bootstrap_t)(vm_offset_t, vm_offset_t);
33typedef void (*pmap_cpu_bootstrap_t)(int);
34typedef void (*pmap_kenter_t)(vm_offset_t, vm_paddr_t pa);
35typedef void (*pmap_kenter_attr_t)(vm_offset_t, vm_paddr_t, vm_memattr_t);
36typedef void (*pmap_kremove_t)(vm_offset_t);
37typedef void *(*pmap_mapdev_t)(vm_paddr_t, vm_size_t);
38typedef void *(*pmap_mapdev_attr_t)(vm_paddr_t, vm_size_t, vm_memattr_t);
39typedef void (*pmap_unmapdev_t)(void *, vm_size_t);
40typedef void (*pmap_page_set_memattr_t)(vm_page_t, vm_memattr_t);
41typedef int (*pmap_change_attr_t)(vm_offset_t, vm_size_t, vm_memattr_t);
42typedef int (*pmap_map_user_ptr_t)(pmap_t, volatile const void *,
43 void **, size_t, size_t *);
44typedef int (*pmap_decode_kernel_ptr_t)(vm_offset_t, int *, vm_offset_t *);
45typedef vm_paddr_t (*pmap_kextract_t)(vm_offset_t);
46typedef int (*pmap_dev_direct_mapped_t)(vm_paddr_t, vm_size_t);
47
48typedef void (*pmap_page_array_startup_t)(long);
49typedef void (*pmap_advise_t)(pmap_t, vm_offset_t, vm_offset_t, int);
50typedef void (*pmap_clear_modify_t)(vm_page_t);
51typedef void (*pmap_remove_write_t)(vm_page_t);
52typedef void (*pmap_copy_t)(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t);
53typedef void (*pmap_copy_page_t)(vm_page_t, vm_page_t);
54typedef void (*pmap_copy_pages_t)(vm_page_t *, vm_offset_t,
55 vm_page_t *, vm_offset_t, int);
56typedef int (*pmap_enter_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t,
57 u_int, int8_t);
58typedef void (*pmap_enter_object_t)(pmap_t, vm_offset_t, vm_offset_t,
59 vm_page_t, vm_prot_t);
60typedef void (*pmap_enter_quick_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t);
61typedef vm_paddr_t (*pmap_extract_t)(pmap_t, vm_offset_t);
62typedef vm_page_t (*pmap_extract_and_hold_t)(pmap_t, vm_offset_t, vm_prot_t);
63typedef void (*pmap_growkernel_t)(vm_offset_t);
64typedef void (*pmap_init_t)(void);
65typedef boolean_t (*pmap_is_modified_t)(vm_page_t);
66typedef boolean_t (*pmap_is_prefaultable_t)(pmap_t, vm_offset_t);
67typedef boolean_t (*pmap_is_referenced_t)(vm_page_t);
68typedef int (*pmap_ts_referenced_t)(vm_page_t);
69typedef vm_offset_t (*pmap_map_t)(vm_offset_t *, vm_paddr_t, vm_paddr_t, int);
70typedef void (*pmap_object_init_pt_t)(pmap_t, vm_offset_t, vm_object_t,
71 vm_pindex_t, vm_size_t);
72typedef boolean_t (*pmap_page_exists_quick_t)(pmap_t, vm_page_t);
73typedef boolean_t (*pmap_page_is_mapped_t)(vm_page_t);
74typedef void (*pmap_page_init_t)(vm_page_t);
75typedef int (*pmap_page_wired_mappings_t)(vm_page_t);
76typedef void (*pmap_pinit0_t)(pmap_t);
77typedef void (*pmap_protect_t)(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t);
78typedef void (*pmap_qenter_t)(vm_offset_t, vm_page_t *, int);
79typedef void (*pmap_qremove_t)(vm_offset_t, int);
80typedef void (*pmap_release_t)(pmap_t);
81typedef void (*pmap_remove_t)(pmap_t, vm_offset_t, vm_offset_t);
82typedef void (*pmap_remove_all_t)(vm_page_t);
83typedef void (*pmap_remove_pages_t)(pmap_t);
84typedef void (*pmap_unwire_t)(pmap_t, vm_offset_t, vm_offset_t);
85typedef void (*pmap_zero_page_t)(vm_page_t);
86typedef void (*pmap_zero_page_area_t)(vm_page_t, int, int);
87typedef int (*pmap_mincore_t)(pmap_t, vm_offset_t, vm_paddr_t *);
88typedef void (*pmap_activate_t)(struct thread *);
89typedef void (*pmap_deactivate_t)(struct thread *);
90typedef void (*pmap_align_superpage_t)(vm_object_t, vm_ooffset_t,
91 vm_offset_t *, vm_size_t);
92
93typedef void (*pmap_sync_icache_t)(pmap_t, vm_offset_t, vm_size_t);
94typedef void (*pmap_dumpsys_map_chunk_t)(vm_paddr_t, size_t, void **);
95typedef void (*pmap_dumpsys_unmap_chunk_t)(vm_paddr_t, size_t, void *);
96typedef void (*pmap_dumpsys_pa_init_t)(void);
97typedef size_t (*pmap_dumpsys_scan_pmap_t)(struct bitset *dump_bitset);
98typedef void *(*pmap_dumpsys_dump_pmap_init_t)(unsigned);
99typedef void *(*pmap_dumpsys_dump_pmap_t)(void *, void *, u_long *);
100typedef vm_offset_t (*pmap_quick_enter_page_t)(vm_page_t);
101typedef void (*pmap_quick_remove_page_t)(vm_offset_t);
102typedef bool (*pmap_ps_enabled_t)(pmap_t);
103typedef void (*pmap_tlbie_all_t)(void);
104typedef void (*pmap_installer_t)(void);
105
106struct pmap_funcs {
107 pmap_installer_t install;
108 pmap_bootstrap_t bootstrap;
109 pmap_cpu_bootstrap_t cpu_bootstrap;
110 pmap_kenter_t kenter;
111 pmap_kenter_attr_t kenter_attr;
112 pmap_kremove_t kremove;
113 pmap_mapdev_t mapdev;
114 pmap_mapdev_attr_t mapdev_attr;
115 pmap_unmapdev_t unmapdev;
116 pmap_page_set_memattr_t page_set_memattr;
117 pmap_change_attr_t change_attr;
118 pmap_map_user_ptr_t map_user_ptr;
119 pmap_decode_kernel_ptr_t decode_kernel_ptr;
120 pmap_kextract_t kextract;
121 pmap_dev_direct_mapped_t dev_direct_mapped;
122 pmap_advise_t advise;
123 pmap_clear_modify_t clear_modify;
124 pmap_remove_write_t remove_write;
125 pmap_copy_t copy;
126 pmap_copy_page_t copy_page;
127 pmap_copy_pages_t copy_pages;
128 pmap_enter_t enter;
129 pmap_enter_object_t enter_object;
130 pmap_enter_quick_t enter_quick;
131 pmap_extract_t extract;
132 pmap_extract_and_hold_t extract_and_hold;
133 pmap_growkernel_t growkernel;
134 pmap_init_t init;
135 pmap_is_modified_t is_modified;
136 pmap_is_prefaultable_t is_prefaultable;
137 pmap_is_referenced_t is_referenced;
138 pmap_ts_referenced_t ts_referenced;
139 pmap_page_is_mapped_t page_is_mapped;
140 pmap_ps_enabled_t ps_enabled;
141 pmap_map_t map;
142 pmap_object_init_pt_t object_init_pt;
143 pmap_page_exists_quick_t page_exists_quick;
144 pmap_page_init_t page_init;
145 pmap_page_wired_mappings_t page_wired_mappings;
146 pmap_pinit_t pinit;
147 pmap_pinit0_t pinit0;
148 pmap_protect_t protect;
149 pmap_qenter_t qenter;
150 pmap_qremove_t qremove;
151 pmap_release_t release;
152 pmap_remove_t remove;
153 pmap_remove_all_t remove_all;
154 pmap_remove_pages_t remove_pages;
155 pmap_unwire_t unwire;
156 pmap_zero_page_t zero_page;
157 pmap_zero_page_area_t zero_page_area;
158 pmap_mincore_t mincore;
159 pmap_activate_t activate;
160 pmap_deactivate_t deactivate;
161 pmap_align_superpage_t align_superpage;
162 pmap_sync_icache_t sync_icache;
163 pmap_quick_enter_page_t quick_enter_page;
164 pmap_quick_remove_page_t quick_remove_page;
165 pmap_page_array_startup_t page_array_startup;
166 pmap_dumpsys_map_chunk_t dumpsys_map_chunk;
167 pmap_dumpsys_unmap_chunk_t dumpsys_unmap_chunk;
168 pmap_dumpsys_pa_init_t dumpsys_pa_init;
169 pmap_dumpsys_scan_pmap_t dumpsys_scan_pmap;
170 pmap_dumpsys_dump_pmap_init_t dumpsys_dump_pmap_init;
171 pmap_dumpsys_dump_pmap_t dumpsys_dump_pmap;
172 pmap_tlbie_all_t tlbie_all;
173
174};
175struct mmu_kobj {
176 const char *name;
177 const struct mmu_kobj *base;
178 const struct pmap_funcs *funcs;
179};
180
181typedef struct mmu_kobj *mmu_t;
182
183/* The currently installed pmap object. */
184extern mmu_t mmu_obj;
185
186/*
187 * Resolve a given pmap function.
188 * 'func' is the function name less the 'pmap_' * prefix.
189 */
190#define PMAP_RESOLVE_FUNC(func) \
191 ({ \
192 pmap_##func##_t f; \
193 const struct mmu_kobj *mmu = mmu_obj; \
194 do { \
195 f = mmu->funcs->func; \
196 if (f != NULL) break; \
197 mmu = mmu->base; \
198 } while (mmu != NULL); \
199 f;})
200
201#define MMU_DEF(name, ident, methods) \
202 \
203const struct mmu_kobj name = { \
204 ident, NULL, &methods \
205}; \
206DATA_SET(mmu_set, name)
207
208#define MMU_DEF_INHERIT(name, ident, methods, base1) \
209 \
210const struct mmu_kobj name = { \
211 ident, &base1, &methods, \
212}; \
213DATA_SET(mmu_set, name)
214
215/*
216 * Known MMU names
217 */
218#define MMU_TYPE_BOOKE "mmu_booke" /* Book-E MMU specification */
219#define MMU_TYPE_OEA "mmu_oea" /* 32-bit OEA */
220#define MMU_TYPE_G5 "mmu_g5" /* 64-bit bridge (ibm 970) */
221#define MMU_TYPE_RADIX "mmu_radix" /* 64-bit native ISA 3.0 (POWER9) radix */
222#define MMU_TYPE_8xx "mmu_8xx" /* 8xx quicc TLB */
223
224#endif /* _MACHINE_MMUVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/ofw_machdep.h+2-55
......@@ -1,58 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 by Thomas Moestl <tmm@FreeBSD.org>.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 * This file is in the public domain.
263 */
274
28#ifndef _MACHINE_OFW_MACHDEP_H_
29#define _MACHINE_OFW_MACHDEP_H_
30
31#include <sys/cdefs.h>
32#include <sys/types.h>
33#include <sys/rman.h>
34#include <sys/bus.h>
35#include <dev/ofw/openfirm.h>
36#include <machine/platform.h>
37
38struct mem_region;
39struct numa_mem_region;
40
41typedef uint32_t cell_t;
42
43void OF_getetheraddr(device_t dev, u_char *addr);
44
45void OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *));
46boolean_t OF_bootstrap(void);
47
48void OF_reboot(void);
49
50void ofw_mem_regions(struct mem_region *, int *, struct mem_region *, int *);
51void ofw_numa_mem_regions(struct numa_mem_region *, int *);
52void ofw_quiesce(void); /* Must be called before VM is up! */
53void ofw_save_trap_vec(char *);
54int ofw_pcibus_get_domain(device_t dev, device_t child, int *domain);
55int ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op,
56 size_t setsize, cpuset_t *cpuset);
57
58#endif /* _MACHINE_OFW_MACHDEP_H_ */
\ No newline at end of file
5#include <x86/ofw_machdep.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/openpicreg.h deleted-141
......@@ -1,141 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp
29 */
30
31/*
32 * Size of OpenPIC register space
33 */
34#define OPENPIC_SIZE 0x40000
35
36/*
37 * Per Processor Registers [private access] (0x00000 - 0x00fff)
38 */
39
40/* IPI dispatch command reg */
41#define OPENPIC_IPI_DISPATCH(ipi) (0x40 + (ipi) * 0x10)
42
43/* current task priority reg */
44#define OPENPIC_TPR 0x80
45#define OPENPIC_TPR_MASK 0x0000000f
46
47#define OPENPIC_WHOAMI 0x90
48
49/* interrupt acknowledge reg */
50#define OPENPIC_IACK 0xa0
51
52/* end of interrupt reg */
53#define OPENPIC_EOI 0xb0
54
55/*
56 * Global registers (0x01000-0x0ffff)
57 */
58
59/* feature reporting reg 0 */
60#define OPENPIC_FEATURE 0x1000
61#define OPENPIC_FEATURE_VERSION_MASK 0x000000ff
62#define OPENPIC_FEATURE_LAST_CPU_MASK 0x00001f00
63#define OPENPIC_FEATURE_LAST_CPU_SHIFT 8
64#define OPENPIC_FEATURE_LAST_IRQ_MASK 0x07ff0000
65#define OPENPIC_FEATURE_LAST_IRQ_SHIFT 16
66
67/* global config reg 0 */
68#define OPENPIC_CONFIG 0x1020
69#define OPENPIC_CONFIG_RESET 0x80000000
70#define OPENPIC_CONFIG_8259_PASSTHRU_DISABLE 0x20000000
71
72/* interrupt configuration mode (direct or serial) */
73#define OPENPIC_ICR 0x1030
74#define OPENPIC_ICR_SERIAL_MODE (1 << 27)
75#define OPENPIC_ICR_SERIAL_RATIO_MASK (0x7 << 28)
76#define OPENPIC_ICR_SERIAL_RATIO_SHIFT 28
77
78/* vendor ID */
79#define OPENPIC_VENDOR_ID 0x1080
80
81/* processor initialization reg */
82#define OPENPIC_PROC_INIT 0x1090
83
84/* IPI vector/priority reg */
85#define OPENPIC_IPI_VECTOR(ipi) (0x10a0 + (ipi) * 0x10)
86
87/* spurious intr. vector */
88#define OPENPIC_SPURIOUS_VECTOR 0x10e0
89
90/* Timer registers */
91#define OPENPIC_TIMERS 4
92#define OPENPIC_TFREQ 0x10f0
93#define OPENPIC_TCNT(t) (0x1100 + (t) * 0x40)
94#define OPENPIC_TBASE(t) (0x1110 + (t) * 0x40)
95#define OPENPIC_TVEC(t) (0x1120 + (t) * 0x40)
96#define OPENPIC_TDST(t) (0x1130 + (t) * 0x40)
97
98/*
99 * Interrupt Source Configuration Registers (0x10000 - 0x1ffff)
100 */
101
102/* interrupt vector/priority reg */
103#define OPENPIC_SRC_VECTOR_COUNT 64
104#ifndef OPENPIC_SRC_VECTOR
105#define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20)
106#endif
107#define OPENPIC_SENSE_LEVEL 0x00400000
108#define OPENPIC_SENSE_EDGE 0x00000000
109#define OPENPIC_POLARITY_POSITIVE 0x00800000
110#define OPENPIC_POLARITY_NEGATIVE 0x00000000
111#define OPENPIC_IMASK 0x80000000
112#define OPENPIC_ACTIVITY 0x40000000
113#define OPENPIC_PRIORITY_MASK 0x000f0000
114#define OPENPIC_PRIORITY_SHIFT 16
115#define OPENPIC_VECTOR_MASK 0x000000ff
116
117/* interrupt destination cpu */
118#ifndef OPENPIC_IDEST
119#define OPENPIC_IDEST(irq) (0x10010 + (irq) * 0x20)
120#endif
121
122/*
123 * Per Processor Registers [global access] (0x20000 - 0x3ffff)
124 */
125
126#define OPENPIC_PCPU_BASE(cpu) (0x20000 + (cpu) * 0x1000)
127
128#define OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi) \
129 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi))
130
131#define OPENPIC_PCPU_TPR(cpu) \
132 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR)
133
134#define OPENPIC_PCPU_WHOAMI(cpu) \
135 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI)
136
137#define OPENPIC_PCPU_IACK(cpu) \
138 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK)
139
140#define OPENPIC_PCPU_EOI(cpu) \
141 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI)
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/openpicvar.h deleted-90
......@@ -1,90 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2002 Benno Rice.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _POWERPC_OPENPICVAR_H_
29#define _POWERPC_OPENPICVAR_H_
30
31#define OPENPIC_DEVSTR "OpenPIC Interrupt Controller"
32
33#define OPENPIC_IRQMAX 256 /* h/w allows more */
34
35#define OPENPIC_QUIRK_SINGLE_BIND 1 /* Bind interrupts to only 1 CPU */
36#define OPENPIC_QUIRK_HIDDEN_IRQS 2 /* May have IRQs beyond FRR[NIRQ] */
37
38/* Names match the macros in openpicreg.h. */
39struct openpic_timer {
40 uint32_t tcnt;
41 uint32_t tbase;
42 uint32_t tvec;
43 uint32_t tdst;
44};
45
46struct openpic_softc {
47 device_t sc_dev;
48 struct resource *sc_memr;
49 struct resource *sc_intr;
50 bus_space_tag_t sc_bt;
51 bus_space_handle_t sc_bh;
52 char *sc_version;
53 int sc_rid;
54 int sc_irq;
55 void *sc_icookie;
56 u_int sc_ncpu;
57 u_int sc_nirq;
58 int sc_psim;
59 u_int sc_quirks;
60
61 /* Saved states. */
62 uint32_t sc_saved_config;
63 uint32_t sc_saved_ipis[4];
64 uint32_t sc_saved_prios[4];
65 struct openpic_timer sc_saved_timers[OPENPIC_TIMERS];
66 uint32_t sc_saved_vectors[OPENPIC_SRC_VECTOR_COUNT];
67
68};
69
70/*
71 * Bus-independent attach i/f
72 */
73int openpic_common_attach(device_t, uint32_t);
74
75/*
76 * PIC interface.
77 */
78void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **);
79void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity);
80void openpic_dispatch(device_t, struct trapframe *);
81void openpic_enable(device_t, u_int, u_int, void **);
82void openpic_eoi(device_t, u_int, void *);
83void openpic_ipi(device_t, u_int);
84void openpic_mask(device_t, u_int, void *);
85void openpic_unmask(device_t, u_int, void *);
86
87int openpic_suspend(device_t dev);
88int openpic_resume(device_t dev);
89
90#endif /* _POWERPC_OPENPICVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/param.h deleted-162
......@@ -1,162 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
40 */
41
42#ifndef _POWERPC_INCLUDE_PARAM_H_
43#define _POWERPC_INCLUDE_PARAM_H_
44
45/*
46 * Machine dependent constants for PowerPC
47 */
48
49#include <machine/_align.h>
50
51/* Needed to display interrupts on OFW PCI */
52#define __PCI_REROUTE_INTERRUPT
53
54#ifndef MACHINE
55#define MACHINE "powerpc"
56#endif
57#ifndef MACHINE_ARCH
58#ifdef __powerpc64__
59#if defined(__LITTLE_ENDIAN__)
60#define MACHINE_ARCH "powerpc64le"
61#else
62#define MACHINE_ARCH "powerpc64"
63#endif
64#else
65#ifdef __SPE__
66#define MACHINE_ARCH "powerpcspe"
67#else
68#define MACHINE_ARCH "powerpc"
69#endif
70#endif
71#endif
72#define MID_MACHINE MID_POWERPC
73#ifdef __powerpc64__
74#ifndef MACHINE_ARCH32
75#define MACHINE_ARCH32 "powerpc"
76#endif
77#endif
78
79#ifdef SMP
80#ifndef MAXCPU
81#define MAXCPU 256
82#endif
83#else
84#define MAXCPU 1
85#endif
86
87#ifndef MAXMEMDOM
88#define MAXMEMDOM 8
89#endif
90
91#define ALIGNBYTES _ALIGNBYTES
92#define ALIGN(p) _ALIGN(p)
93/*
94 * ALIGNED_POINTER is a boolean macro that checks whether an address
95 * is valid to fetch data elements of type t from on this architecture.
96 * This does not reflect the optimal alignment, just the possibility
97 * (within reasonable limits).
98 */
99#define ALIGNED_POINTER(p, t) ((((uintptr_t)(p)) & (sizeof (t) - 1)) == 0)
100
101/*
102 * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
103 * architecture. It should be used with appropriate caution.
104 */
105#define CACHE_LINE_SHIFT 7
106#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT)
107
108#define PAGE_SHIFT 12
109#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */
110#define PAGE_MASK (PAGE_SIZE - 1)
111#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
112#define NPDEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
113
114#define L1_PAGE_SIZE_SHIFT 39
115#define L1_PAGE_SIZE (1UL<<L1_PAGE_SIZE_SHIFT)
116#define L1_PAGE_MASK (L1_PAGE_SIZE-1)
117
118#define L2_PAGE_SIZE_SHIFT 30
119#define L2_PAGE_SIZE (1UL<<L2_PAGE_SIZE_SHIFT)
120#define L2_PAGE_MASK (L2_PAGE_SIZE-1)
121
122#define L3_PAGE_SIZE_SHIFT 21
123#define L3_PAGE_SIZE (1UL<<L3_PAGE_SIZE_SHIFT)
124#define L3_PAGE_MASK (L3_PAGE_SIZE-1)
125
126#define MAXPAGESIZES 3 /* maximum number of supported page sizes */
127
128#define RELOCATABLE_KERNEL 1 /* kernel may relocate during startup */
129
130#ifndef KSTACK_PAGES
131#ifdef __powerpc64__
132#define KSTACK_PAGES 12 /* includes pcb */
133#else
134#define KSTACK_PAGES 4 /* includes pcb */
135#endif
136#endif
137#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */
138#define USPACE (kstack_pages * PAGE_SIZE) /* total size of pcb */
139
140#define COPYFAULT 0x1
141#define FUSUFAULT 0x2
142
143/*
144 * Mach derived conversion macros
145 */
146#define trunc_page(x) ((x) & ~(PAGE_MASK))
147#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
148#define trunc_2mpage(x) ((unsigned long)(x) & ~L3_PAGE_MASK)
149#define round_2mpage(x) ((((unsigned long)(x)) + L3_PAGE_MASK) & ~L3_PAGE_MASK)
150#define trunc_1gpage(x) ((unsigned long)(x) & ~L2_PAGE_MASK)
151
152#define atop(x) ((x) >> PAGE_SHIFT)
153#define ptoa(x) ((x) << PAGE_SHIFT)
154
155#define powerpc_btop(x) ((x) >> PAGE_SHIFT)
156#define powerpc_ptob(x) ((x) << PAGE_SHIFT)
157
158#define pgtok(x) ((x) * (PAGE_SIZE / 1024UL))
159
160#define btoc(x) ((vm_offset_t)(((x)+PAGE_MASK)>>PAGE_SHIFT))
161
162#endif /* !_POWERPC_INCLUDE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/pcb.h deleted-137
......@@ -1,137 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: pcb.h,v 1.4 2000/06/04 11:57:17 tsubai Exp $
34 */
35
36#ifndef _MACHINE_PCB_H_
37#define _MACHINE_PCB_H_
38
39#include <sys/endian.h>
40
41#include <machine/setjmp.h>
42
43#ifndef _STANDALONE
44struct pcb {
45 register_t pcb_context[20]; /* non-volatile r12-r31 */
46 register_t pcb_cr; /* Condition register */
47 register_t pcb_sp; /* stack pointer */
48 register_t pcb_toc; /* toc pointer */
49 register_t pcb_lr; /* link register */
50 register_t pcb_dscr; /* dscr value */
51 register_t pcb_fscr;
52 register_t pcb_tar;
53 struct pmap *pcb_pm; /* pmap of our vmspace */
54 jmp_buf *pcb_onfault; /* For use during
55 copyin/copyout */
56 int pcb_flags;
57#define PCB_FPU 0x1 /* Process uses FPU */
58#define PCB_FPREGS 0x2 /* Process had FPU registers initialized */
59#define PCB_VEC 0x4 /* Process uses Altivec */
60#define PCB_VSX 0x8 /* Process had VSX initialized */
61#define PCB_CDSCR 0x10 /* Process had Custom DSCR initialized */
62#define PCB_HTM 0x20 /* Process had HTM initialized */
63#define PCB_CFSCR 0x40 /* Process had FSCR updated */
64#define PCB_KERN_FPU 0x80 /* Kernel is using FPU/Vector unit */
65#define PCB_KERN_FPU_NOSAVE 0x100 /* FPU/Vec state not saved for kernel use */
66#define PCB_VECREGS 0x200 /* Process had Altivec registers initialized */
67 struct fpu {
68 union {
69#if _BYTE_ORDER == _BIG_ENDIAN
70 double fpr;
71 uint32_t vsr[4];
72#else
73 uint32_t vsr[4];
74 struct {
75 double padding;
76 double fpr;
77 };
78#endif
79 } fpr[32];
80 double fpscr; /* FPSCR stored as double for easier access */
81 } pcb_fpu; /* Floating point processor */
82 unsigned int pcb_fpcpu; /* which CPU had our FPU
83 stuff. */
84 struct vec {
85 uint32_t vr[32][4];
86 uint32_t spare[2];
87 uint32_t vrsave;
88 uint32_t vscr; /* aligned at vector element 3 */
89 } pcb_vec __aligned(16); /* Vector processor */
90 unsigned int pcb_veccpu; /* which CPU had our vector
91 stuff. */
92 struct htm {
93 uint64_t tfhar;
94 uint64_t texasr;
95 uint64_t tfiar;
96 } pcb_htm;
97
98 struct ebb {
99 uint64_t ebbhr;
100 uint64_t ebbrr;
101 uint64_t bescr;
102 } pcb_ebb;
103
104 struct lmon {
105 uint64_t lmrr;
106 uint64_t lmser;
107 } pcb_lm;
108
109 union {
110 struct {
111 vm_offset_t usr_segm; /* Base address */
112 register_t usr_vsid; /* USER_SR segment */
113 } aim;
114 struct {
115 register_t dbcr0;
116 } booke;
117 } pcb_cpu;
118 vm_offset_t pcb_lastill; /* Last illegal instruction */
119};
120#endif
121
122#ifdef _KERNEL
123
124struct trapframe;
125
126#ifndef curpcb
127extern struct pcb *curpcb;
128#endif
129
130extern struct pmap *curpm;
131extern struct proc *fpuproc;
132
133void makectx(struct trapframe *, struct pcb *);
134void savectx(struct pcb *) __returns_twice;
135
136#endif
137#endif /* _MACHINE_PCB_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/pcpu.h deleted-174
......@@ -1,174 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org>
5 * Copyright (c) Peter Wemm <peter@netplex.com.au>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_PCPU_H_
31#define _MACHINE_PCPU_H_
32
33#include <machine/cpufunc.h>
34#include <machine/slb.h>
35#include <machine/tlb.h>
36
37struct pmap;
38struct pvo_entry;
39#define CPUSAVE_LEN 9
40
41#define PCPU_MD_COMMON_FIELDS \
42 int pc_inside_intr; \
43 struct pmap *pc_curpmap; /* current pmap */ \
44 struct thread *pc_fputhread; /* current fpu user */ \
45 struct thread *pc_vecthread; /* current vec user */ \
46 struct thread *pc_htmthread; /* current htm user */ \
47 uintptr_t pc_hwref; \
48 int pc_bsp; \
49 volatile int pc_awake; \
50 uint32_t pc_ipimask; \
51 uint32_t pc_flags; /* cpu feature flags */ \
52 register_t pc_tempsave[CPUSAVE_LEN]; \
53 register_t pc_disisave[CPUSAVE_LEN]; \
54 register_t pc_dbsave[CPUSAVE_LEN]; \
55 void *pc_restore; \
56 vm_offset_t pc_qmap_addr;
57
58#define PCPU_MD_AIM32_FIELDS \
59 struct pvo_entry *qmap_pvo; \
60 struct mtx qmap_lock; \
61 char __pad[128];
62
63#define PCPU_MD_AIM64_FIELDS \
64 struct slb slb[64]; \
65 struct slb **userslb; \
66 register_t slbsave[18]; \
67 uint8_t slbstack[1024]; \
68 struct pvo_entry *qmap_pvo; \
69 struct mtx qmap_lock; \
70 uint64_t opal_hmi_flags; \
71 char __pad[1337];
72
73#ifdef __powerpc64__
74#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM64_FIELDS
75#else
76#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM32_FIELDS
77#endif
78
79/* CPU feature flags, can be used for cached flow control. */
80#define PC_FLAG_NOSRS 0x80000000
81
82#define BOOKE_CRITSAVE_LEN (CPUSAVE_LEN + 2)
83#define BOOKE_TLB_MAXNEST 4
84#define BOOKE_TLB_SAVELEN 16
85#define BOOKE_TLBSAVE_LEN (BOOKE_TLB_SAVELEN * BOOKE_TLB_MAXNEST)
86
87#ifdef __powerpc64__
88#define BOOKE_PCPU_PAD 901
89#else
90#define BOOKE_PCPU_PAD 365
91#endif
92#define PCPU_MD_BOOKE_FIELDS \
93 register_t critsave[BOOKE_CRITSAVE_LEN]; \
94 register_t mchksave[CPUSAVE_LEN]; \
95 register_t tlbsave[BOOKE_TLBSAVE_LEN]; \
96 register_t tlb_level; \
97 uintptr_t *tlb_lock; \
98 int tid_next; \
99 char __pad[BOOKE_PCPU_PAD];
100
101/* Definitions for register offsets within the exception tmp save areas */
102#define CPUSAVE_R27 0 /* where r27 gets saved */
103#define CPUSAVE_R28 1 /* where r28 gets saved */
104#define CPUSAVE_R29 2 /* where r29 gets saved */
105#define CPUSAVE_R30 3 /* where r30 gets saved */
106#define CPUSAVE_R31 4 /* where r31 gets saved */
107#define CPUSAVE_AIM_DAR 5 /* where SPR_DAR gets saved */
108#define CPUSAVE_AIM_DSISR 6 /* where SPR_DSISR gets saved */
109#define CPUSAVE_BOOKE_DEAR 5 /* where SPR_DEAR gets saved */
110#define CPUSAVE_BOOKE_ESR 6 /* where SPR_ESR gets saved */
111#define CPUSAVE_SRR0 7 /* where SRR0 gets saved */
112#define CPUSAVE_SRR1 8 /* where SRR1 gets saved */
113#define BOOKE_CRITSAVE_SRR0 9 /* where real SRR0 gets saved (critical) */
114#define BOOKE_CRITSAVE_SRR1 10 /* where real SRR0 gets saved (critical) */
115
116/* Book-E TLBSAVE is more elaborate */
117#define TLBSAVE_BOOKE_LR 0
118#define TLBSAVE_BOOKE_CR 1
119#define TLBSAVE_BOOKE_SRR0 2
120#define TLBSAVE_BOOKE_SRR1 3
121#define TLBSAVE_BOOKE_R20 4
122#define TLBSAVE_BOOKE_R21 5
123#define TLBSAVE_BOOKE_R22 6
124#define TLBSAVE_BOOKE_R23 7
125#define TLBSAVE_BOOKE_R24 8
126#define TLBSAVE_BOOKE_R25 9
127#define TLBSAVE_BOOKE_R26 10
128#define TLBSAVE_BOOKE_R27 11
129#define TLBSAVE_BOOKE_R28 12
130#define TLBSAVE_BOOKE_R29 13
131#define TLBSAVE_BOOKE_R30 14
132#define TLBSAVE_BOOKE_R31 15
133
134#define PCPU_MD_FIELDS \
135 PCPU_MD_COMMON_FIELDS \
136 union { \
137 struct { \
138 PCPU_MD_AIM_FIELDS \
139 } pc_aim; \
140 struct { \
141 PCPU_MD_BOOKE_FIELDS \
142 } pc_booke; \
143 }
144
145#ifdef _KERNEL
146
147#define pcpup (get_pcpu())
148
149static __inline __pure2 struct thread *
150__curthread(void)
151{
152 struct thread *td;
153#ifdef __powerpc64__
154 __asm __volatile("mr %0,13" : "=r"(td));
155#else
156 __asm __volatile("mr %0,2" : "=r"(td));
157#endif
158 return (td);
159}
160#define curthread (__curthread())
161
162#define PCPU_GET(member) (pcpup->pc_ ## member)
163
164/*
165 * XXX The implementation of this operation should be made atomic
166 * with respect to preemption.
167 */
168#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value))
169#define PCPU_PTR(member) (&pcpup->pc_ ## member)
170#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
171
172#endif /* _KERNEL */
173
174#endif /* !_MACHINE_PCPU_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/pio.h deleted-304
......@@ -1,304 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed under OpenBSD by
17 * Per Fogelstrom Opsycon AB for RTMX Inc, North Carolina, USA.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $NetBSD: pio.h,v 1.1 1998/05/15 10:15:54 tsubai Exp $
34 * $OpenBSD: pio.h,v 1.1 1997/10/13 10:53:47 pefo Exp $
35 */
36
37#ifndef _MACHINE_PIO_H_
38#define _MACHINE_PIO_H_
39/*
40 * I/O macros.
41 */
42
43/*
44 * Use sync so that bus space operations cannot sneak out the bottom of
45 * mutex-protected sections (mutex release does not guarantee completion of
46 * accesses to caching-inhibited memory on some systems)
47 */
48#define powerpc_iomb() __asm __volatile("sync" : : : "memory")
49
50static __inline void
51__outb(volatile u_int8_t *a, u_int8_t v)
52{
53 *a = v;
54 powerpc_iomb();
55}
56
57static __inline void
58__outw(volatile u_int16_t *a, u_int16_t v)
59{
60 *a = v;
61 powerpc_iomb();
62}
63
64static __inline void
65__outl(volatile u_int32_t *a, u_int32_t v)
66{
67 *a = v;
68 powerpc_iomb();
69}
70
71static __inline void
72__outll(volatile u_int64_t *a, u_int64_t v)
73{
74 *a = v;
75 powerpc_iomb();
76}
77
78static __inline void
79__outwrb(volatile u_int16_t *a, u_int16_t v)
80{
81 __asm__ volatile("sthbrx %0, 0, %1" :: "r"(v), "r"(a));
82 powerpc_iomb();
83}
84
85static __inline void
86__outlrb(volatile u_int32_t *a, u_int32_t v)
87{
88 __asm__ volatile("stwbrx %0, 0, %1" :: "r"(v), "r"(a));
89 powerpc_iomb();
90}
91
92static __inline u_int8_t
93__inb(volatile u_int8_t *a)
94{
95 u_int8_t _v_;
96
97 _v_ = *a;
98 powerpc_iomb();
99 return _v_;
100}
101
102static __inline u_int16_t
103__inw(volatile u_int16_t *a)
104{
105 u_int16_t _v_;
106
107 _v_ = *a;
108 powerpc_iomb();
109 return _v_;
110}
111
112static __inline u_int32_t
113__inl(volatile u_int32_t *a)
114{
115 u_int32_t _v_;
116
117 _v_ = *a;
118 powerpc_iomb();
119 return _v_;
120}
121
122static __inline u_int64_t
123__inll(volatile u_int64_t *a)
124{
125 u_int64_t _v_;
126
127 _v_ = *a;
128 powerpc_iomb();
129 return _v_;
130}
131
132static __inline u_int16_t
133__inwrb(volatile u_int16_t *a)
134{
135 u_int16_t _v_;
136
137 __asm__ volatile("lhbrx %0, 0, %1" : "=r"(_v_) : "r"(a));
138 powerpc_iomb();
139 return _v_;
140}
141
142static __inline u_int32_t
143__inlrb(volatile u_int32_t *a)
144{
145 u_int32_t _v_;
146
147 __asm__ volatile("lwbrx %0, 0, %1" : "=r"(_v_) : "r"(a));
148 powerpc_iomb();
149 return _v_;
150}
151
152#define outb(a,v) (__outb((volatile u_int8_t *)(a), v))
153#define out8(a,v) outb(a,v)
154#define outw(a,v) (__outw((volatile u_int16_t *)(a), v))
155#define out16(a,v) outw(a,v)
156#define outl(a,v) (__outl((volatile u_int32_t *)(a), v))
157#define out32(a,v) outl(a,v)
158#define outll(a,v) (__outll((volatile u_int64_t *)(a), v))
159#define out64(a,v) outll(a,v)
160#define inb(a) (__inb((volatile u_int8_t *)(a)))
161#define in8(a) inb(a)
162#define inw(a) (__inw((volatile u_int16_t *)(a)))
163#define in16(a) inw(a)
164#define inl(a) (__inl((volatile u_int32_t *)(a)))
165#define in32(a) inl(a)
166#define inll(a) (__inll((volatile u_int64_t *)(a)))
167#define in64(a) inll(a)
168
169#define out8rb(a,v) outb(a,v)
170#define outwrb(a,v) (__outwrb((volatile u_int16_t *)(a), v))
171#define out16rb(a,v) outwrb(a,v)
172#define outlrb(a,v) (__outlrb((volatile u_int32_t *)(a), v))
173#define out32rb(a,v) outlrb(a,v)
174#define in8rb(a) inb(a)
175#define inwrb(a) (__inwrb((volatile u_int16_t *)(a)))
176#define in16rb(a) inwrb(a)
177#define inlrb(a) (__inlrb((volatile u_int32_t *)(a)))
178#define in32rb(a) inlrb(a)
179
180static __inline void
181__outsb(volatile u_int8_t *a, const u_int8_t *s, size_t c)
182{
183 while (c--)
184 *a = *s++;
185 powerpc_iomb();
186}
187
188static __inline void
189__outsw(volatile u_int16_t *a, const u_int16_t *s, size_t c)
190{
191 while (c--)
192 *a = *s++;
193 powerpc_iomb();
194}
195
196static __inline void
197__outsl(volatile u_int32_t *a, const u_int32_t *s, size_t c)
198{
199 while (c--)
200 *a = *s++;
201 powerpc_iomb();
202}
203
204static __inline void
205__outsll(volatile u_int64_t *a, const u_int64_t *s, size_t c)
206{
207 while (c--)
208 *a = *s++;
209 powerpc_iomb();
210}
211
212static __inline void
213__outswrb(volatile u_int16_t *a, const u_int16_t *s, size_t c)
214{
215 while (c--)
216 __asm__ volatile("sthbrx %0, 0, %1" :: "r"(*s++), "r"(a));
217 powerpc_iomb();
218}
219
220static __inline void
221__outslrb(volatile u_int32_t *a, const u_int32_t *s, size_t c)
222{
223 while (c--)
224 __asm__ volatile("stwbrx %0, 0, %1" :: "r"(*s++), "r"(a));
225 powerpc_iomb();
226}
227
228static __inline void
229__insb(volatile u_int8_t *a, u_int8_t *d, size_t c)
230{
231 while (c--)
232 *d++ = *a;
233 powerpc_iomb();
234}
235
236static __inline void
237__insw(volatile u_int16_t *a, u_int16_t *d, size_t c)
238{
239 while (c--)
240 *d++ = *a;
241 powerpc_iomb();
242}
243
244static __inline void
245__insl(volatile u_int32_t *a, u_int32_t *d, size_t c)
246{
247 while (c--)
248 *d++ = *a;
249 powerpc_iomb();
250}
251
252static __inline void
253__insll(volatile u_int64_t *a, u_int64_t *d, size_t c)
254{
255 while (c--)
256 *d++ = *a;
257 powerpc_iomb();
258}
259
260static __inline void
261__inswrb(volatile u_int16_t *a, u_int16_t *d, size_t c)
262{
263 while (c--)
264 __asm__ volatile("lhbrx %0, 0, %1" : "=r"(*d++) : "r"(a));
265 powerpc_iomb();
266}
267
268static __inline void
269__inslrb(volatile u_int32_t *a, u_int32_t *d, size_t c)
270{
271 while (c--)
272 __asm__ volatile("lwbrx %0, 0, %1" : "=r"(*d++) : "r"(a));
273 powerpc_iomb();
274}
275
276#define outsb(a,s,c) (__outsb((volatile u_int8_t *)(a), s, c))
277#define outs8(a,s,c) outsb(a,s,c)
278#define outsw(a,s,c) (__outsw((volatile u_int16_t *)(a), s, c))
279#define outs16(a,s,c) outsw(a,s,c)
280#define outsl(a,s,c) (__outsl((volatile u_int32_t *)(a), s, c))
281#define outs32(a,s,c) outsl(a,s,c)
282#define outsll(a,s,c) (__outsll((volatile u_int64_t *)(a), s, c))
283#define outs64(a,s,c) outsll(a,s,c)
284#define insb(a,d,c) (__insb((volatile u_int8_t *)(a), d, c))
285#define ins8(a,d,c) insb(a,d,c)
286#define insw(a,d,c) (__insw((volatile u_int16_t *)(a), d, c))
287#define ins16(a,d,c) insw(a,d,c)
288#define insl(a,d,c) (__insl((volatile u_int32_t *)(a), d, c))
289#define ins32(a,d,c) insl(a,d,c)
290#define insll(a,d,c) (__insll((volatile u_int64_t *)(a), d, c))
291#define ins64(a,d,c) insll(a,d,c)
292
293#define outs8rb(a,s,c) outsb(a,s,c)
294#define outswrb(a,s,c) (__outswrb((volatile u_int16_t *)(a), s, c))
295#define outs16rb(a,s,c) outswrb(a,s,c)
296#define outslrb(a,s,c) (__outslrb((volatile u_int32_t *)(a), s, c))
297#define outs32rb(a,s,c) outslrb(a,s,c)
298#define ins8rb(a,d,c) insb(a,d,c)
299#define inswrb(a,d,c) (__inswrb((volatile u_int16_t *)(a), d, c))
300#define ins16rb(a,d,c) inswrb(a,d,c)
301#define inslrb(a,d,c) (__inslrb((volatile u_int32_t *)(a), d, c))
302#define ins32rb(a,d,c) inslrb(a,d,c)
303
304#endif /*_MACHINE_PIO_H_*/
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/platform.h deleted-76
......@@ -1,76 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1996 Wolfgang Solfrank.
5 * Copyright (C) 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: powerpc.h,v 1.3 2000/06/01 00:49:59 matt Exp $
34 */
35
36#ifndef _MACHINE_PLATFORM_H_
37#define _MACHINE_PLATFORM_H_
38
39#include <machine/ofw_machdep.h>
40#include <machine/smp.h>
41#include <machine/pcpu.h>
42
43struct mem_region {
44 uint64_t mr_start;
45 uint64_t mr_size;
46};
47
48struct numa_mem_region {
49 uint64_t mr_start;
50 uint64_t mr_size;
51 uint64_t mr_domain;
52};
53
54/* Documentation for these functions is in platform_if.m */
55
56void mem_regions(struct mem_region **, int *, struct mem_region **, int *);
57void numa_mem_regions(struct numa_mem_region **, int *);
58vm_offset_t platform_real_maxaddr(void);
59
60u_long platform_timebase_freq(struct cpuref *);
61
62int platform_smp_first_cpu(struct cpuref *);
63int platform_smp_next_cpu(struct cpuref *);
64int platform_smp_get_bsp(struct cpuref *);
65int platform_smp_start_cpu(struct pcpu *);
66void platform_smp_timebase_sync(u_long tb, int ap);
67void platform_smp_ap_init(void);
68void platform_smp_probe_threads(void);
69int platform_node_numa_domain(phandle_t);
70
71const char *installed_platform(void);
72void platform_probe_and_attach(void);
73
74void platform_sleep(void);
75
76#endif /* _MACHINE_PLATFORM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/platformvar.h deleted-89
......@@ -1,89 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 Peter Grehan
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_PLATFORMVAR_H_
30#define _MACHINE_PLATFORMVAR_H_
31
32/*
33 * A PowerPC platform implementation is declared with a kernel object and
34 * an associated method table, similar to a device driver.
35 *
36 * e.g.
37 *
38 * static platform_method_t chrp_methods[] = {
39 * PLATFORMMETHOD(platform_probe, chrp_probe),
40 * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions),
41 * ...
42 * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu),
43 * { 0, 0 }
44 * };
45 *
46 * static platform_def_t chrp_platform = {
47 * "chrp",
48 * chrp_methods,
49 * sizeof(chrp_platform_softc), // or 0 if no softc
50 * };
51 *
52 * PLATFORM_DEF(chrp_platform);
53 */
54
55#include <sys/kobj.h>
56
57struct platform_kobj {
58 /*
59 * A platform instance is a kernel object
60 */
61 KOBJ_FIELDS;
62
63 /*
64 * Utility elements that an instance may use
65 */
66 struct mtx platform_mtx; /* available for instance use */
67 void *platform_iptr; /* instance data pointer */
68
69 /*
70 * Opaque data that can be overlaid with an instance-private
71 * structure. Platform code can test that this is large enough at
72 * compile time with a sizeof() test againt it's softc. There
73 * is also a run-time test when the platform kernel object is
74 * registered.
75 */
76#define PLATFORM_OPAQUESZ 64
77 u_int platform_opaque[PLATFORM_OPAQUESZ];
78};
79
80typedef struct platform_kobj *platform_t;
81typedef struct kobj_class platform_def_t;
82#define platform_method_t kobj_method_t
83
84#define PLATFORMMETHOD KOBJMETHOD
85#define PLATFORMMETHOD_END KOBJMETHOD_END
86
87#define PLATFORM_DEF(name) DATA_SET(platform_set, name)
88
89#endif /* _MACHINE_PLATFORMVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/pmap.h deleted-361
......@@ -1,361 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-4-Clause
3 *
4 * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com>
5 * All rights reserved.
6 *
7 * Adapted for Freescale's e500 core CPUs.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31/*-
32 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
33 * Copyright (C) 1995, 1996 TooLs GmbH.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by TooLs GmbH.
47 * 4. The name of TooLs GmbH may not be used to endorse or promote products
48 * derived from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
51 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
55 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
56 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
57 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
58 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
59 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 * from: $NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $
62 */
63
64#ifndef _MACHINE_PMAP_H_
65#define _MACHINE_PMAP_H_
66
67#include <sys/queue.h>
68#include <sys/tree.h>
69#include <sys/_cpuset.h>
70#include <sys/_lock.h>
71#include <sys/_mutex.h>
72#include <machine/sr.h>
73#include <machine/pte.h>
74#include <machine/slb.h>
75#include <machine/tlb.h>
76#include <machine/vmparam.h>
77#ifdef __powerpc64__
78#include <vm/vm_radix.h>
79#endif
80
81/*
82 * The radix page table structure is described by levels 1-4.
83 * See Fig 33. on p. 1002 of Power ISA v3.0B
84 *
85 * Page directories and tables must be size aligned.
86 */
87
88/* Root page directory - 64k -- each entry covers 512GB */
89typedef uint64_t pml1_entry_t;
90/* l2 page directory - 4k -- each entry covers 1GB */
91typedef uint64_t pml2_entry_t;
92/* l3 page directory - 4k -- each entry covers 2MB */
93typedef uint64_t pml3_entry_t;
94/* l4 page directory - 256B/4k -- each entry covers 64k/4k */
95typedef uint64_t pml4_entry_t;
96
97typedef uint64_t pt_entry_t;
98
99struct pmap;
100typedef struct pmap *pmap_t;
101
102#define PMAP_ENTER_QUICK_LOCKED 0x10000000
103
104#if !defined(NPMAPS)
105#define NPMAPS 32768
106#endif /* !defined(NPMAPS) */
107
108struct slbtnode;
109
110struct pvo_entry {
111 LIST_ENTRY(pvo_entry) pvo_vlink; /* Link to common virt page */
112#ifndef __powerpc64__
113 LIST_ENTRY(pvo_entry) pvo_olink; /* Link to overflow entry */
114#endif
115 union {
116 RB_ENTRY(pvo_entry) pvo_plink; /* Link to pmap entries */
117 SLIST_ENTRY(pvo_entry) pvo_dlink; /* Link to delete enty */
118 };
119 struct {
120#ifndef __powerpc64__
121 /* 32-bit fields */
122 pte_t pte;
123#endif
124 /* 64-bit fields */
125 uintptr_t slot;
126 vm_paddr_t pa;
127 vm_prot_t prot;
128 } pvo_pte;
129 pmap_t pvo_pmap; /* Owning pmap */
130 vm_offset_t pvo_vaddr; /* VA of entry */
131 uint64_t pvo_vpn; /* Virtual page number */
132};
133LIST_HEAD(pvo_head, pvo_entry);
134SLIST_HEAD(pvo_dlist, pvo_entry);
135RB_HEAD(pvo_tree, pvo_entry);
136int pvo_vaddr_compare(struct pvo_entry *, struct pvo_entry *);
137RB_PROTOTYPE(pvo_tree, pvo_entry, pvo_plink, pvo_vaddr_compare);
138
139/* Used by 32-bit PMAP */
140#define PVO_PTEGIDX_MASK 0x007UL /* which PTEG slot */
141#define PVO_PTEGIDX_VALID 0x008UL /* slot is valid */
142/* Used by 64-bit PMAP */
143#define PVO_HID 0x008UL /* PVO entry in alternate hash*/
144/* Used by both */
145#define PVO_WIRED 0x010UL /* PVO entry is wired */
146#define PVO_MANAGED 0x020UL /* PVO entry is managed */
147#define PVO_BOOTSTRAP 0x080UL /* PVO entry allocated during
148 bootstrap */
149#define PVO_DEAD 0x100UL /* waiting to be deleted */
150#define PVO_LARGE 0x200UL /* large page */
151#define PVO_VADDR(pvo) ((pvo)->pvo_vaddr & ~ADDR_POFF)
152#define PVO_PTEGIDX_GET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_MASK)
153#define PVO_PTEGIDX_ISSET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_VALID)
154#define PVO_PTEGIDX_CLR(pvo) \
155 ((void)((pvo)->pvo_vaddr &= ~(PVO_PTEGIDX_VALID|PVO_PTEGIDX_MASK)))
156#define PVO_PTEGIDX_SET(pvo, i) \
157 ((void)((pvo)->pvo_vaddr |= (i)|PVO_PTEGIDX_VALID))
158#define PVO_VSID(pvo) ((pvo)->pvo_vpn >> 16)
159
160struct pmap {
161 struct pmap_statistics pm_stats;
162 struct mtx pm_mtx;
163 cpuset_t pm_active;
164 union {
165 struct {
166 #ifdef __powerpc64__
167 struct slbtnode *pm_slb_tree_root;
168 struct slb **pm_slb;
169 int pm_slb_len;
170 #else
171 register_t pm_sr[16];
172 #endif
173
174 struct pmap *pmap_phys;
175 struct pvo_tree pmap_pvo;
176 };
177#ifdef __powerpc64__
178 /* Radix support */
179 struct {
180 pml1_entry_t *pm_pml1; /* KVA of root page directory */
181 struct vm_radix pm_radix; /* spare page table pages */
182 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
183 uint64_t pm_pid; /* PIDR value */
184 int pm_flags;
185 };
186#endif
187 struct {
188 /* TID to identify this pmap entries in TLB */
189 tlbtid_t pm_tid[MAXCPU];
190
191#ifdef __powerpc64__
192 /*
193 * Page table directory,
194 * array of pointers to page directories.
195 */
196 pte_t ****pm_root;
197#else
198 /*
199 * Page table directory,
200 * array of pointers to page tables.
201 */
202 pte_t **pm_pdir;
203
204 /* List of allocated ptbl bufs (ptbl kva regions). */
205 TAILQ_HEAD(, ptbl_buf) pm_ptbl_list;
206#endif
207 };
208 } __aligned(CACHE_LINE_SIZE);
209};
210
211/*
212 * pv_entries are allocated in chunks per-process. This avoids the
213 * need to track per-pmap assignments.
214 */
215#define _NPCPV 126
216#define _NPCM howmany(_NPCPV, 64)
217
218#define PV_CHUNK_HEADER \
219 pmap_t pc_pmap; \
220 TAILQ_ENTRY(pv_chunk) pc_list; \
221 uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ \
222 TAILQ_ENTRY(pv_chunk) pc_lru;
223
224struct pv_entry {
225 pmap_t pv_pmap;
226 vm_offset_t pv_va;
227 TAILQ_ENTRY(pv_entry) pv_link;
228};
229typedef struct pv_entry *pv_entry_t;
230
231struct pv_chunk_header {
232 PV_CHUNK_HEADER
233};
234struct pv_chunk {
235 PV_CHUNK_HEADER
236 uint64_t reserved;
237 struct pv_entry pc_pventry[_NPCPV];
238};
239
240struct md_page {
241 union {
242 struct {
243 volatile int32_t mdpg_attrs;
244 vm_memattr_t mdpg_cache_attrs;
245 struct pvo_head mdpg_pvoh;
246 int pv_gen; /* (p) */
247 };
248 struct {
249 int pv_tracked;
250 };
251 };
252 TAILQ_HEAD(, pv_entry) pv_list; /* (p) */
253};
254
255#ifdef AIM
256#define pmap_page_get_memattr(m) ((m)->md.mdpg_cache_attrs)
257#else
258#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT
259#endif /* AIM */
260
261/*
262 * Return the VSID corresponding to a given virtual address.
263 * If no VSID is currently defined, it will allocate one, and add
264 * it to a free slot if available.
265 *
266 * NB: The PMAP MUST be locked already.
267 */
268uint64_t va_to_vsid(pmap_t pm, vm_offset_t va);
269
270/* Lock-free, non-allocating lookup routines */
271uint64_t kernel_va_to_slbv(vm_offset_t va);
272struct slb *user_va_to_slb_entry(pmap_t pm, vm_offset_t va);
273
274uint64_t allocate_user_vsid(pmap_t pm, uint64_t esid, int large);
275void free_vsid(pmap_t pm, uint64_t esid, int large);
276void slb_insert_user(pmap_t pm, struct slb *slb);
277void slb_insert_kernel(uint64_t slbe, uint64_t slbv);
278
279struct slbtnode *slb_alloc_tree(void);
280void slb_free_tree(pmap_t pm);
281struct slb **slb_alloc_user_cache(void);
282void slb_free_user_cache(struct slb **);
283
284extern struct pmap kernel_pmap_store;
285#define kernel_pmap (&kernel_pmap_store)
286
287#ifdef _KERNEL
288
289#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)
290#define PMAP_LOCK_ASSERT(pmap, type) \
291 mtx_assert(&(pmap)->pm_mtx, (type))
292#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx)
293#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, \
294 (pmap == kernel_pmap) ? "kernelpmap" : \
295 "pmap", NULL, MTX_DEF | MTX_DUPOK)
296#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx)
297#define PMAP_MTX(pmap) (&(pmap)->pm_mtx)
298#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx)
299#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx)
300
301#define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0)
302
303#define pmap_vm_page_alloc_check(m)
304
305void pmap_bootstrap(vm_offset_t, vm_offset_t);
306void pmap_kenter(vm_offset_t va, vm_paddr_t pa);
307void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t);
308void pmap_kremove(vm_offset_t);
309void *pmap_mapdev(vm_paddr_t, vm_size_t);
310void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
311void pmap_unmapdev(void *, vm_size_t);
312void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
313int pmap_change_attr(vm_offset_t, vm_size_t, vm_memattr_t);
314int pmap_map_user_ptr(pmap_t pm, volatile const void *uaddr,
315 void **kaddr, size_t ulen, size_t *klen);
316int pmap_decode_kernel_ptr(vm_offset_t addr, int *is_user,
317 vm_offset_t *decoded_addr);
318void pmap_deactivate(struct thread *);
319vm_paddr_t pmap_kextract(vm_offset_t);
320int pmap_dev_direct_mapped(vm_paddr_t, vm_size_t);
321boolean_t pmap_mmu_install(char *name, int prio);
322void pmap_mmu_init(void);
323const char *pmap_mmu_name(void);
324bool pmap_ps_enabled(pmap_t pmap);
325int pmap_nofault(pmap_t pmap, vm_offset_t va, vm_prot_t flags);
326boolean_t pmap_page_is_mapped(vm_page_t m);
327#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)
328
329void pmap_page_array_startup(long count);
330
331#define vtophys(va) pmap_kextract((vm_offset_t)(va))
332
333extern vm_offset_t virtual_avail;
334extern vm_offset_t virtual_end;
335extern caddr_t crashdumpmap;
336
337extern vm_offset_t msgbuf_phys;
338
339extern int pmap_bootstrapped;
340extern int radix_mmu;
341extern int superpages_enabled;
342
343#ifdef AIM
344void pmap_early_io_map_init(void);
345#endif
346vm_offset_t pmap_early_io_map(vm_paddr_t pa, vm_size_t size);
347void pmap_early_io_unmap(vm_offset_t va, vm_size_t size);
348void pmap_track_page(pmap_t pmap, vm_offset_t va);
349void pmap_page_print_mappings(vm_page_t m);
350void pmap_tlbie_all(void);
351
352static inline int
353pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused)
354{
355
356 return (0);
357}
358
359#endif
360
361#endif /* !_MACHINE_PMAP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/pmc_mdep.h deleted-95
......@@ -1,95 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#ifndef _MACHINE_PMC_MDEP_H_
6#define _MACHINE_PMC_MDEP_H_
7
8#define PMC_MDEP_CLASS_INDEX_POWERPC 1
9
10union pmc_md_op_pmcallocate {
11 uint32_t pm_event;
12 uint64_t __pad[4];
13};
14
15/* Logging */
16#ifdef __powerpc64__
17#define PMCLOG_READADDR PMCLOG_READ64
18#define PMCLOG_EMITADDR PMCLOG_EMIT64
19#else
20#define PMCLOG_READADDR PMCLOG_READ32
21#define PMCLOG_EMITADDR PMCLOG_EMIT32
22#endif
23
24#define mtpmr(reg, val) \
25 __asm __volatile("mtpmr %0,%1" : : "K"(reg), "r"(val))
26#define mfpmr(reg) \
27 ( { register_t val; \
28 __asm __volatile("mfpmr %0,%1" : "=r"(val) : "K"(reg)); \
29 val; } )
30
31#define PMR_PMC0 16
32#define PMR_PMC1 17
33#define PMR_PMC2 18
34#define PMR_PMC3 19
35#define PMR_PMLCa0 144
36#define PMLCax_FC 0x80000000
37#define PMLCax_FCS 0x40000000
38#define PMLCax_FCU 0x20000000
39#define PMLCax_FCM1 0x10000000
40#define PMLCax_FCM0 0x08000000
41#define PMLCax_CE 0x04000000
42#define PMLCax_EVENT(x) ((x) << 16)
43#define PMLCax_FCGS1 0x00000002
44#define PMLCax_FCGS0 0x00000001
45#define PMR_PMLCa1 145
46#define PMR_PMLCa2 146
47#define PMR_PMLCa3 147
48#define PMR_PMLCb0 272
49#define PMLCbx_TRIGONCTL(x) ((x) << 28)
50#define PMLCbx_TRIGOFFCTL(x) ((x) << 24)
51#define PMLCbx_PMCC 0x00800000
52#define PMLCbx_PMP(x) ((x) << 13)
53#define PMLCbx_TREHMUL(x) ((x) << 8)
54#define PMLCbx_TRESHOLD(x) ((x) << 0)
55#define PMR_PMLCb1 273
56#define PMR_PMLCb2 274
57#define PMR_PMLCb3 275
58#define PMR_PMGC0 400
59#define PMGC_FAC 0x80000000
60#define PMGC_PMIE 0x40000000
61#define PMGC_FCECE 0x20000000
62#define PMGC_TBSEL(x) ((x) << 11)
63#define PMGC_TBEE 0x00000100
64#define PMR_UPMC0 0
65#define PMR_UPMC1 1
66#define PMR_UPMC2 2
67#define PMR_UPMC3 3
68#define PMR_UPMLCa0 128
69#define PMR_UPMLCa1 129
70#define PMR_UPMLCa2 130
71#define PMR_UPMLCa3 131
72#define PMR_UPMLCb0 256
73#define PMR_UPMLCb1 257
74#define PMR_UPMLCb2 258
75#define PMR_UPMLCb3 259
76#define PMR_UPMGC0 384
77
78#if _KERNEL
79
80struct pmc_md_powerpc_pmc {
81 uint64_t pm_powerpc_overflowcnt;
82 uint32_t pm_powerpc_evsel;
83};
84
85union pmc_md_pmc {
86 struct pmc_md_powerpc_pmc pm_powerpc;
87};
88
89#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->srr0)
90#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->fixreg[1])
91#define PMC_TRAPFRAME_TO_SP(TF) (0)
92
93#endif
94
95#endif /* !_MACHINE_PMC_MDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/proc.h deleted-61
......@@ -1,61 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: proc.h,v 1.2 1997/04/16 22:57:48 thorpej Exp $
34 */
35
36#ifndef _MACHINE_PROC_H_
37#define _MACHINE_PROC_H_
38
39/*
40 * Machine-dependent part of the proc structure
41 */
42struct mdthread {
43 int md_spinlock_count; /* (k) */
44 register_t md_saved_msr; /* (k) */
45};
46
47struct mdproc {
48 /*
49 * Avoid empty structs because they are undefined behavior.
50 */
51 long md_spare;
52};
53
54#ifdef __powerpc64__
55#define KINFO_PROC_SIZE 1088
56#define KINFO_PROC32_SIZE 816
57#else
58#define KINFO_PROC_SIZE 816
59#endif
60
61#endif /* !_MACHINE_PROC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/profile.h deleted-234
......@@ -1,234 +0,0 @@
1/*-
2 * SPDX-License-Identifier: MIT-CMU
3 *
4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 *
29 * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp
30 * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29
31 */
32
33#ifndef _MACHINE_PROFILE_H_
34#define _MACHINE_PROFILE_H_
35
36#define _MCOUNT_DECL void __mcount
37
38#define FUNCTION_ALIGNMENT 4
39
40typedef __ptrdiff_t fptrdiff_t;
41
42/*
43 * The mcount trampoline macro, expanded in libc/gmon/mcount.c
44 *
45 * For PowerPC SVR4 ABI profiling, the compiler will insert
46 * a data declaration and code sequence at the start of a routine of the form
47 *
48 * .function_mc: .data
49 * .align 2
50 * .long 0
51 * .text
52 *
53 * function: mflr %r0
54 * addis %r11,%r0, .function_mc@ha
55 * stw %r0,4(%r1)
56 * addi %r0,%r11, .function_mc@l
57 * bl _mcount
58 *
59 * The link register is saved in the LR save word in the caller's
60 * stack frame, r0 is set up to point to the allocated longword,
61 * and control is transferred to _mcount.
62 *
63 * On return from _mcount, the routine should function as it would
64 * with no profiling so _mcount must restore register state to that upon
65 * entry. Any routine called by the _mcount trampoline will save
66 * callee-save registers, so _mcount must make sure it saves volatile
67 * registers that may have state after it returns i.e. parameter registers.
68 *
69 * The FreeBSD libc mcount routine ignores the r0 longword pointer, but
70 * instead requires as parameters the current PC and called PC. The current
71 * PC is obtained from the link register, as a result of "bl _mcount" in
72 * the stub, while the caller's PC is obtained from the LR save word.
73 *
74 * On return from libc mcount, the return is done indirectly with the
75 * ctr register rather than the link register, to allow the link register
76 * to be restored to what it was on entry to the profiled routine.
77 */
78
79#if defined(__powerpc64__)
80
81#if !defined(_CALL_ELF) || _CALL_ELF == 1
82#define MCOUNT_PREAMBLE \
83 " .align 2 \n" \
84 " .globl _mcount \n" \
85 " .section \".opd\",\"aw\" \n" \
86 " .align 3 \n" \
87 "_mcount: \n" \
88 " .quad .L._mcount,.TOC.@tocbase,0\n" \
89 " .previous \n" \
90 " .size _mcount,24 \n" \
91 " .type _mcount,@function \n" \
92 " .align 4 \n" \
93 ".L._mcount: \n"
94#else
95#define MCOUNT_PREAMBLE \
96 " .globl _mcount \n" \
97 " .type _mcount,@function \n" \
98 " .align 4 \n" \
99 "_mcount: \n"
100#endif
101
102#define MCOUNT \
103__asm( MCOUNT_PREAMBLE \
104 " stdu %r1,-(288+128)(%r1) \n" \
105 " std %r3,48(%r1) \n" \
106 " std %r4,56(%r1) \n" \
107 " std %r5,64(%r1) \n" \
108 " std %r6,72(%r1) \n" \
109 " std %r7,80(%r1) \n" \
110 " std %r8,88(%r1) \n" \
111 " std %r9,96(%r1) \n" \
112 " std %r10,104(%r1) \n" \
113 " mflr %r4 \n" \
114 " std %r4,112(%r1) \n" \
115 " ld %r3,0(%r1) \n" \
116 " ld %r3,0(%r3) \n" \
117 " ld %r3,16(%r3) \n" \
118 " bl __mcount \n" \
119 " nop \n" \
120 " ld %r4,112(%r1) \n" \
121 " mtlr %r4 \n" \
122 " ld %r3,48(%r1) \n" \
123 " ld %r4,56(%r1) \n" \
124 " ld %r5,64(%r1) \n" \
125 " ld %r6,72(%r1) \n" \
126 " ld %r7,80(%r1) \n" \
127 " ld %r8,88(%r1) \n" \
128 " ld %r9,96(%r1) \n" \
129 " ld %r10,104(%r1) \n" \
130 " addi %r1,%r1,(288+128) \n" \
131 " blr \n");
132#else
133
134#ifdef PIC
135#define _PLT "@plt"
136#else
137#define _PLT
138#endif
139
140#define MCOUNT \
141__asm( " .globl _mcount \n" \
142 " .type _mcount,@function \n" \
143 " .align 4 \n" \
144 "_mcount: \n" \
145 " stwu %r1,-64(%r1) \n" \
146 " stw %r3,16(%r1) \n" \
147 " stw %r4,20(%r1) \n" \
148 " stw %r5,24(%r1) \n" \
149 " stw %r6,28(%r1) \n" \
150 " stw %r7,32(%r1) \n" \
151 " stw %r8,36(%r1) \n" \
152 " stw %r9,40(%r1) \n" \
153 " stw %r10,44(%r1) \n" \
154 " mflr %r4 \n" \
155 " stw %r4,48(%r1) \n" \
156 " lwz %r3,68(%r1) \n" \
157 " bl __mcount" _PLT " \n" \
158 " lwz %r3,68(%r1) \n" \
159 " mtlr %r3 \n" \
160 " lwz %r4,48(%r1) \n" \
161 " mtctr %r4 \n" \
162 " lwz %r3,16(%r1) \n" \
163 " lwz %r4,20(%r1) \n" \
164 " lwz %r5,24(%r1) \n" \
165 " lwz %r6,28(%r1) \n" \
166 " lwz %r7,32(%r1) \n" \
167 " lwz %r8,36(%r1) \n" \
168 " lwz %r9,40(%r1) \n" \
169 " lwz %r10,44(%r1) \n" \
170 " addi %r1,%r1,64 \n" \
171 " bctr \n" \
172 "_mcount_end: \n" \
173 " .size _mcount,_mcount_end-_mcount");
174#endif
175
176#ifdef _KERNEL
177#define MCOUNT_ENTER(s) s = intr_disable()
178#define MCOUNT_EXIT(s) intr_restore(s)
179#define MCOUNT_DECL(s) register_t s;
180
181#ifndef COMPILING_LINT
182#ifdef AIM
183#include <machine/trap.h>
184#define __PROFILE_VECTOR_BASE EXC_RST
185#define __PROFILE_VECTOR_TOP (EXC_LAST + 0x100)
186#endif /* AIM */
187#if defined(BOOKE)
188extern char interrupt_vector_base[];
189extern char interrupt_vector_top[];
190#define __PROFILE_VECTOR_BASE (uintfptr_t)interrupt_vector_base
191#define __PROFILE_VECTOR_TOP (uintfptr_t)interrupt_vector_top
192#endif /* BOOKE_E500 */
193
194#endif /* !COMPILING_LINT */
195
196#ifndef __PROFILE_VECTOR_BASE
197#define __PROFILE_VECTOR_BASE 0
198#endif
199#ifndef __PROFILE_VECTOR_TOP
200#define __PROFILE_VECTOR_TOP 1
201#endif
202
203static __inline void
204powerpc_profile_interrupt(void)
205{
206}
207
208static __inline void
209powerpc_profile_userspace(void)
210{
211}
212
213#define MCOUNT_FROMPC_USER(pc) \
214 ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? \
215 (uintfptr_t)powerpc_profile_userspace : pc)
216
217#define MCOUNT_FROMPC_INTR(pc) \
218 ((pc >= __PROFILE_VECTOR_BASE && \
219 pc < __PROFILE_VECTOR_TOP) ? \
220 (uintfptr_t)powerpc_profile_interrupt : ~0U)
221
222void __mcount(uintfptr_t frompc, uintfptr_t selfpc);
223
224#else /* !_KERNEL */
225
226#ifdef __powerpc64__
227typedef u_long uintfptr_t;
228#else
229typedef u_int uintfptr_t;
230#endif
231
232#endif /* _KERNEL */
233
234#endif /* !_MACHINE_PROFILE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/psl.h+2-98
......@@ -1,101 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: psl.h,v 1.5 2000/11/19 19:52:37 matt Exp $
2 * This file is in the public domain.
343 */
354
36#ifndef _MACHINE_PSL_H_
37#define _MACHINE_PSL_H_
38
39/*
40 * Machine State Register (MSR) - All cores
41 */
42#define PSL_VEC 0x02000000UL /* AltiVec/SPE vector unit available */
43#define PSL_VSX 0x00800000UL /* Vector-Scalar unit available */
44#define PSL_EE 0x00008000UL /* external interrupt enable */
45#define PSL_PR 0x00004000UL /* privilege mode (1 == user) */
46#define PSL_FP 0x00002000UL /* floating point enable */
47#define PSL_ME 0x00001000UL /* machine check enable */
48#define PSL_FE0 0x00000800UL /* floating point interrupt mode 0 */
49#define PSL_FE1 0x00000100UL /* floating point interrupt mode 1 */
50#define PSL_PMM 0x00000004UL /* performance monitor mark */
51#define PSL_RI 0x00000002UL /* recoverable interrupt */
52
53/* Machine State Register - Book-E cores */
54#ifdef __powerpc64__
55#define PSL_CM 0x80000000UL /* Computation Mode (64-bit) */
56#endif
57
58#define PSL_GS 0x10000000UL /* Guest state */
59#define PSL_UCLE 0x04000000UL /* User mode cache lock enable */
60#define PSL_WE 0x00040000UL /* Wait state enable */
61#define PSL_CE 0x00020000UL /* Critical interrupt enable */
62#define PSL_UBLE 0x00000400UL /* BTB lock enable - e500 only */
63#define PSL_DWE 0x00000400UL /* Debug Wait Enable - 440 only*/
64#define PSL_DE 0x00000200UL /* Debug interrupt enable */
65#define PSL_IS 0x00000020UL /* Instruction address space */
66#define PSL_DS 0x00000010UL /* Data address space */
67
68/* Machine State Register (MSR) - AIM cores */
69#ifdef __powerpc64__
70#define PSL_SF 0x8000000000000000UL /* 64-bit addressing */
71#define PSL_HV 0x1000000000000000UL /* hyper-privileged mode */
72#endif
73
74#define PSL_POW 0x00040000UL /* power management */
75#define PSL_ILE 0x00010000UL /* interrupt endian mode (1 == le) */
76#define PSL_SE 0x00000400UL /* single-step trace enable */
77#define PSL_BE 0x00000200UL /* branch trace enable */
78#define PSL_IP 0x00000040UL /* interrupt prefix - 601 only */
79#define PSL_IR 0x00000020UL /* instruction address relocation */
80#define PSL_DR 0x00000010UL /* data address relocation */
81#define PSL_LE 0x00000001UL /* endian mode (1 == le) */
82
83/*
84 * Floating-point exception modes:
85 */
86#define PSL_FE_DIS 0 /* none */
87#define PSL_FE_NONREC PSL_FE1 /* imprecise non-recoverable */
88#define PSL_FE_REC PSL_FE0 /* imprecise recoverable */
89#define PSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */
90#define PSL_FE_DFLT PSL_FE_PREC /* default == precise */
91
92#ifndef LOCORE
93extern register_t psl_kernset; /* Default MSR values for kernel */
94extern register_t psl_userset; /* Default MSR values for userland */
95#ifdef __powerpc64__
96extern register_t psl_userset32; /* Default user MSR values for 32-bit */
97#endif
98extern register_t psl_userstatic; /* Bits of SRR1 userland may not set */
99#endif
100
101#endif /* _MACHINE_PSL_H_ */
\ No newline at end of file
5#include <x86/psl.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/pte.h deleted-432
......@@ -1,432 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: pte.h,v 1.2 1998/08/31 14:43:40 tsubai Exp $
34 */
35
36#ifndef _MACHINE_PTE_H_
37#define _MACHINE_PTE_H_
38
39#if defined(AIM)
40
41/*
42 * Page Table Entries
43 */
44#ifndef LOCORE
45
46/* 32-bit PTE */
47struct pte {
48 u_int32_t pte_hi;
49 u_int32_t pte_lo;
50};
51
52struct pteg {
53 struct pte pt[8];
54};
55
56/* 64-bit (long) PTE */
57struct lpte {
58 u_int64_t pte_hi;
59 u_int64_t pte_lo;
60};
61
62struct lpteg {
63 struct lpte pt[8];
64};
65
66/* Partition table entry */
67struct pate {
68 u_int64_t pagetab;
69 u_int64_t proctab;
70};
71
72/* Process table entry */
73struct prte {
74 u_int64_t proctab0;
75 u_int64_t proctab1;
76};
77
78typedef struct pte pte_t;
79typedef struct lpte lpte_t;
80#endif /* LOCORE */
81
82/* 32-bit PTE definitions */
83
84/* High word: */
85#define PTE_VALID 0x80000000
86#define PTE_VSID_SHFT 7
87#define PTE_HID 0x00000040
88#define PTE_API 0x0000003f
89/* Low word: */
90#define PTE_RPGN 0xfffff000
91#define PTE_REF 0x00000100
92#define PTE_CHG 0x00000080
93#define PTE_WIMG 0x00000078
94#define PTE_W 0x00000040
95#define PTE_I 0x00000020
96#define PTE_M 0x00000010
97#define PTE_G 0x00000008
98#define PTE_PP 0x00000003
99#define PTE_SO 0x00000000 /* Super. Only (U: XX, S: RW) */
100#define PTE_SW 0x00000001 /* Super. Write-Only (U: RO, S: RW) */
101#define PTE_BW 0x00000002 /* Supervisor (U: RW, S: RW) */
102#define PTE_BR 0x00000003 /* Both Read Only (U: RO, S: RO) */
103#define PTE_RW PTE_BW
104#define PTE_RO PTE_BR
105
106#define PTE_EXEC 0x00000200 /* pseudo bit in attrs; page is exec */
107
108/* 64-bit PTE definitions */
109
110/* High quadword: */
111#define LPTE_VSID_SHIFT 12
112#define LPTE_AVPN_MASK 0xFFFFFFFFFFFFFF80ULL
113#define LPTE_AVA_MASK 0x3FFFFFFFFFFFFF80ULL
114#define LPTE_API 0x0000000000000F80ULL
115#define LPTE_SWBITS 0x0000000000000078ULL
116#define LPTE_WIRED 0x0000000000000010ULL
117#define LPTE_LOCKED 0x0000000000000008ULL
118#define LPTE_BIG 0x0000000000000004ULL /* 4kb/16Mb page */
119#define LPTE_HID 0x0000000000000002ULL
120#define LPTE_VALID 0x0000000000000001ULL
121
122/* Low quadword: */
123#define LP_4K_16M 0x38 /* 4KB base, 16MB actual page size */
124
125#define EXTEND_PTE(x) UINT64_C(x) /* make constants 64-bit */
126#define LPTE_RPGN 0xfffffffffffff000ULL
127#define LPTE_LP_MASK 0x00000000000ff000ULL
128#define LPTE_LP_SHIFT 12
129#define LPTE_LP_4K_16M ((unsigned long long)(LP_4K_16M) << LPTE_LP_SHIFT)
130#define LPTE_REF EXTEND_PTE( PTE_REF )
131#define LPTE_CHG EXTEND_PTE( PTE_CHG )
132#define LPTE_WIMG EXTEND_PTE( PTE_WIMG )
133#define LPTE_W EXTEND_PTE( PTE_W )
134#define LPTE_I EXTEND_PTE( PTE_I )
135#define LPTE_M EXTEND_PTE( PTE_M )
136#define LPTE_G EXTEND_PTE( PTE_G )
137#define LPTE_NOEXEC 0x0000000000000004ULL
138#define LPTE_PP EXTEND_PTE( PTE_PP )
139
140#define LPTE_SO EXTEND_PTE( PTE_SO ) /* Super. Only */
141#define LPTE_SW EXTEND_PTE( PTE_SW ) /* Super. Write-Only */
142#define LPTE_BW EXTEND_PTE( PTE_BW ) /* Supervisor */
143#define LPTE_BR EXTEND_PTE( PTE_BR ) /* Both Read Only */
144#define LPTE_RW LPTE_BW
145#define LPTE_RO LPTE_BR
146
147/* HPT superpage definitions */
148#define HPT_SP_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT)
149#define HPT_SP_SIZE (1 << HPT_SP_SHIFT)
150#define HPT_SP_MASK (HPT_SP_SIZE - 1)
151#define HPT_SP_PAGES (1 << VM_LEVEL_0_ORDER)
152
153/* POWER ISA 3.0 Radix Table Definitions */
154#define RPTE_VALID 0x8000000000000000ULL
155#define RPTE_LEAF 0x4000000000000000ULL /* is a PTE: always 1 */
156#define RPTE_SW0 0x2000000000000000ULL
157#define RPTE_RPN_MASK 0x00FFFFFFFFFFF000ULL
158#define RPTE_RPN_SHIFT 12
159#define RPTE_SW1 0x0000000000000800ULL
160#define RPTE_SW2 0x0000000000000400ULL
161#define RPTE_SW3 0x0000000000000200ULL
162#define RPTE_R 0x0000000000000100ULL
163#define RPTE_C 0x0000000000000080ULL
164
165#define RPTE_MANAGED RPTE_SW1
166#define RPTE_WIRED RPTE_SW2
167#define RPTE_PROMOTED RPTE_SW3
168
169#define RPTE_ATTR_MASK 0x0000000000000030ULL
170#define RPTE_ATTR_MEM 0x0000000000000000ULL /* PTE M */
171#define RPTE_ATTR_SAO 0x0000000000000010ULL /* PTE WIM */
172#define RPTE_ATTR_GUARDEDIO 0x0000000000000020ULL /* PTE IMG */
173#define RPTE_ATTR_UNGUARDEDIO 0x0000000000000030ULL /* PTE IM */
174
175#define RPTE_EAA_MASK 0x000000000000000FULL
176#define RPTE_EAA_P 0x0000000000000008ULL /* Supervisor only */
177#define RPTE_EAA_R 0x0000000000000004ULL /* Read allowed */
178#define RPTE_EAA_W 0x0000000000000002ULL /* Write (+read) */
179#define RPTE_EAA_X 0x0000000000000001ULL /* Execute allowed */
180
181#define RPDE_VALID RPTE_VALID
182#define RPDE_LEAF RPTE_LEAF /* is a PTE: always 0 */
183#define RPDE_NLB_MASK 0x00FFFFFFFFFFFF00ULL
184#define RPDE_NLB_SHIFT 8
185#define RPDE_NLS_MASK 0x000000000000001FULL
186
187#define PG_FRAME (0x000ffffffffff000ul)
188#define PG_PS_FRAME (0x000fffffffe00000ul)
189/*
190 * Extract bits from address
191 */
192#define ADDR_SR_SHFT 28
193#define ADDR_PIDX 0x0ffff000UL
194#define ADDR_PIDX_SHFT 12
195#define ADDR_API_SHFT 22
196#define ADDR_API_SHFT64 16
197#define ADDR_POFF 0x00000fffUL
198
199/*
200 * Bits in DSISR:
201 */
202#define DSISR_DIRECT 0x80000000
203#define DSISR_NOTFOUND 0x40000000
204#define DSISR_PROTECT 0x08000000
205#define DSISR_INVRX 0x04000000
206#define DSISR_STORE 0x02000000
207#define DSISR_DABR 0x00400000
208#define DSISR_SEGMENT 0x00200000
209#define DSISR_EAR 0x00100000
210
211/*
212 * Bits in SRR1 on ISI:
213 */
214#define ISSRR1_NOTFOUND 0x40000000
215#define ISSRR1_DIRECT 0x10000000
216#define ISSRR1_PROTECT 0x08000000
217#define ISSRR1_SEGMENT 0x00200000
218
219#else /* BOOKE */
220
221#include <machine/tlb.h>
222
223/*
224 * Flags for pte_remove() routine.
225 */
226#define PTBL_HOLD 0x00000001 /* do not unhold ptbl pages */
227#define PTBL_UNHOLD 0x00000002 /* unhold and attempt to free ptbl pages */
228
229#define PTBL_HOLD_FLAG(pmap) (((pmap) == kernel_pmap) ? PTBL_HOLD : PTBL_UNHOLD)
230
231/*
232 * Page Table Entry definitions and macros.
233 *
234 * RPN need only be 32-bit because Book-E has 36-bit addresses, and the smallest
235 * page size is 4k (12-bit mask), so RPN can really fit into 24 bits.
236 */
237#ifndef LOCORE
238typedef uint64_t pte_t;
239#endif
240
241/* RPN mask, TLB0 4K pages */
242#define PTE_PA_MASK PAGE_MASK
243
244#if defined(BOOKE_E500)
245
246/* PTE bits assigned to MAS2, MAS3 flags */
247#define PTE_MAS2_SHIFT 19
248#define PTE_W (MAS2_W << PTE_MAS2_SHIFT)
249#define PTE_I (MAS2_I << PTE_MAS2_SHIFT)
250#define PTE_M (MAS2_M << PTE_MAS2_SHIFT)
251#define PTE_G (MAS2_G << PTE_MAS2_SHIFT)
252#define PTE_MAS2_MASK (MAS2_G | MAS2_M | MAS2_I | MAS2_W)
253
254#define PTE_MAS3_SHIFT 2
255#define PTE_UX (MAS3_UX << PTE_MAS3_SHIFT)
256#define PTE_SX (MAS3_SX << PTE_MAS3_SHIFT)
257#define PTE_UW (MAS3_UW << PTE_MAS3_SHIFT)
258#define PTE_SW (MAS3_SW << PTE_MAS3_SHIFT)
259#define PTE_UR (MAS3_UR << PTE_MAS3_SHIFT)
260#define PTE_SR (MAS3_SR << PTE_MAS3_SHIFT)
261#define PTE_MAS3_MASK ((MAS3_UX | MAS3_SX | MAS3_UW \
262 | MAS3_SW | MAS3_UR | MAS3_SR) << PTE_MAS3_SHIFT)
263
264#define PTE_PS_SHIFT 8
265#define PTE_PS_4KB (2 << PTE_PS_SHIFT)
266
267#endif
268
269/* Other PTE flags */
270#define PTE_VALID 0x00000001 /* Valid */
271#define PTE_MODIFIED 0x00001000 /* Modified */
272#define PTE_WIRED 0x00002000 /* Wired */
273#define PTE_MANAGED 0x00000002 /* Managed */
274#define PTE_REFERENCED 0x00040000 /* Referenced */
275
276/*
277 * Page Table Entry definitions and macros.
278 *
279 * We use the hardware page table entry format:
280 *
281 * 63 24 23 19 18 17 14 13 12 11 8 7 6 5 4 3 2 1 0
282 * ---------------------------------------------------------------
283 * ARPN(12:51) WIMGE R U0:U3 SW0 C PSIZE UX SX UW SW UR SR SW1 V
284 * ---------------------------------------------------------------
285 */
286
287/* PTE fields. */
288#define PTE_TSIZE_SHIFT (63-54)
289#define PTE_TSIZE_MASK 0x7
290#define PTE_TSIZE_SHIFT_DIRECT (63-55)
291#define PTE_TSIZE_MASK_DIRECT 0xf
292#define PTE_PS_DIRECT(ps) (ps<<PTE_TSIZE_SHIFT_DIRECT) /* Direct Entry Page Size */
293#define PTE_PS(ps) (ps<<PTE_TSIZE_SHIFT) /* Page Size */
294
295/* Macro argument must of pte_t type. */
296#define PTE_TSIZE(pte) (int)((*pte >> PTE_TSIZE_SHIFT) & PTE_TSIZE_MASK)
297#define PTE_TSIZE_DIRECT(pte) (int)((*pte >> PTE_TSIZE_SHIFT_DIRECT) & PTE_TSIZE_MASK_DIRECT)
298
299/* Macro argument must of pte_t type. */
300#define PTE_ARPN_SHIFT 12
301#define PTE_FLAGS_MASK 0x00ffffff
302#define PTE_RPN_FROM_PA(pa) (((pa) & ~PAGE_MASK) << PTE_ARPN_SHIFT)
303#define PTE_PA(pte) ((vm_paddr_t)(*pte >> PTE_ARPN_SHIFT) & ~PAGE_MASK)
304#define PTE_ISVALID(pte) ((*pte) & PTE_VALID)
305#define PTE_ISWIRED(pte) ((*pte) & PTE_WIRED)
306#define PTE_ISMANAGED(pte) ((*pte) & PTE_MANAGED)
307#define PTE_ISMODIFIED(pte) ((*pte) & PTE_MODIFIED)
308#define PTE_ISREFERENCED(pte) ((*pte) & PTE_REFERENCED)
309
310#endif /* BOOKE */
311
312/* Book-E page table format, broken out for the generic pmap.h. */
313#ifdef __powerpc64__
314
315#include <machine/tlb.h>
316
317/*
318 * The virtual address is:
319 *
320 * 4K page size
321 * +-----+-----------+-------+-------------+-------------+----------------+
322 * | - | pg_root |pdir_l1| dir# | pte# | off in 4K page |
323 * +-----+-----------+-------+-------------+-------------+----------------+
324 * 63 52 51 39 38 30 29 ^ 21 20 ^ 12 11 0
325 * | |
326 * index in 1 page of pointers
327 *
328 * 1st level - Root page table
329 *
330 * pp2d consists of PG_ROOT_NENTRIES entries, each being a pointer to
331 * second level entity, i.e. the page table directory (pdir).
332 */
333#define PG_ROOT_H 51
334#define PG_ROOT_L 39
335#define PG_ROOT_SIZE (1UL << PG_ROOT_L) /* va range mapped by pp2d */
336#define PG_ROOT_SHIFT PG_ROOT_L
337#define PG_ROOT_NUM (PG_ROOT_H - PG_ROOT_L + 1)
338#define PG_ROOT_MASK ((1 << PG_ROOT_NUM) - 1)
339#define PG_ROOT_IDX(va) ((va >> PG_ROOT_SHIFT) & PG_ROOT_MASK)
340#define PG_ROOT_NENTRIES (1 << PG_ROOT_NUM)
341#define PG_ROOT_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry **)) */
342
343/*
344 * 2nd level - page directory directory (pdir l1)
345 *
346 * pdir consists of PDIR_NENTRIES entries, each being a pointer to
347 * second level entity, i.e. the actual page table (ptbl).
348 */
349#define PDIR_L1_H (PG_ROOT_L-1)
350#define PDIR_L1_L 30
351#define PDIR_L1_NUM (PDIR_L1_H-PDIR_L1_L+1)
352#define PDIR_L1_SIZE (1 << PDIR_L1_L) /* va range mapped by pdir */
353#define PDIR_L1_MASK ((1<<PDIR_L1_NUM)-1)
354#define PDIR_L1_SHIFT PDIR_L1_L
355#define PDIR_L1_NENTRIES (1<<PDIR_L1_NUM)
356#define PDIR_L1_IDX(va) (((va) >> PDIR_L1_SHIFT) & PDIR_L1_MASK)
357#define PDIR_L1_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */
358#define PDIR_L1_PAGES ((PDIR_L1_NENTRIES * (1<<PDIR_L1_ENTRY_SHIFT)) / PAGE_SIZE)
359
360/*
361 * 3rd level - page table directory (pdir)
362 *
363 * pdir consists of PDIR_NENTRIES entries, each being a pointer to
364 * second level entity, i.e. the actual page table (ptbl).
365 */
366#define PDIR_H (PDIR_L1_L-1)
367#define PDIR_L 21
368#define PDIR_NUM (PDIR_H-PDIR_L+1)
369#define PDIR_SIZE (1 << PDIR_L) /* va range mapped by pdir */
370#define PDIR_MASK ((1<<PDIR_NUM)-1)
371#define PDIR_SHIFT PDIR_L
372#define PDIR_NENTRIES (1<<PDIR_NUM)
373#define PDIR_IDX(va) (((va) >> PDIR_SHIFT) & PDIR_MASK)
374#define PDIR_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */
375#define PDIR_PAGES ((PDIR_NENTRIES * (1<<PDIR_ENTRY_SHIFT)) / PAGE_SIZE)
376
377/*
378 * 4th level - page table (ptbl)
379 *
380 * Page table covers PTBL_NENTRIES page table entries. Page
381 * table entry (pte) is 64 bit wide and defines mapping
382 * for a single page.
383 */
384#define PTBL_H (PDIR_L-1)
385#define PTBL_L PAGE_SHIFT
386#define PTBL_NUM (PTBL_H-PTBL_L+1)
387#define PTBL_MASK ((1<<PTBL_NUM)-1)
388#define PTBL_SHIFT PTBL_L
389#define PTBL_SIZE PAGE_SIZE /* va range mapped by ptbl entry */
390#define PTBL_NENTRIES (1<<PTBL_NUM)
391#define PTBL_IDX(va) ((va >> PTBL_SHIFT) & PTBL_MASK)
392#define PTBL_ENTRY_SHIFT 3 /* log2 (sizeof (struct pte_entry)) */
393#define PTBL_PAGES ((PTBL_NENTRIES * (1<<PTBL_ENTRY_SHIFT)) / PAGE_SIZE)
394
395#else
396/*
397 * 1st level - page table directory (pdir)
398 *
399 * pdir consists of 1024 entries, each being a pointer to
400 * second level entity, i.e. the actual page table (ptbl).
401 */
402#define PDIR_SHIFT 22
403#define PDIR_SIZE (1 << PDIR_SHIFT) /* va range mapped by pdir */
404#define PDIR_MASK (~(PDIR_SIZE - 1))
405#define PDIR_NENTRIES 1024 /* number of page tables in pdir */
406
407/* Returns pdir entry number for given va */
408#define PDIR_IDX(va) ((va) >> PDIR_SHIFT)
409
410#define PDIR_ENTRY_SHIFT 2 /* entry size is 2^2 = 4 bytes */
411
412/*
413 * 2nd level - page table (ptbl)
414 *
415 * Page table covers 1024 page table entries. Page
416 * table entry (pte) is 32 bit wide and defines mapping
417 * for a single page.
418 */
419#define PTBL_SHIFT PAGE_SHIFT
420#define PTBL_SIZE PAGE_SIZE /* va range mapped by ptbl entry */
421#define PTBL_MASK ((PDIR_SIZE - 1) & ~((1 << PAGE_SHIFT) - 1))
422#define PTBL_NENTRIES 1024 /* number of pages mapped by ptbl */
423
424/* Returns ptbl entry number for given va */
425#define PTBL_IDX(va) (((va) & PTBL_MASK) >> PTBL_SHIFT)
426
427/* Size of ptbl in pages, 1024 entries, each sizeof(struct pte_entry). */
428#define PTBL_PAGES 2
429#define PTBL_ENTRY_SHIFT 3 /* entry size is 2^3 = 8 bytes */
430
431#endif
432#endif /* _MACHINE_PTE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/ptrace.h+2-41
......@@ -1,44 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2014 Justin Hibbits
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)ptrace.h 8.1 (Berkeley) 6/11/93
2 * This file is in the public domain.
323 */
334
34#ifndef _MACHINE_PTRACE_H_
35#define _MACHINE_PTRACE_H_
36
37#define __HAVE_PTRACE_MACHDEP
38
39#define PT_GETVRREGS (PT_FIRSTMACH + 0)
40#define PT_SETVRREGS (PT_FIRSTMACH + 1)
41#define PT_GETVSRREGS (PT_FIRSTMACH + 2)
42#define PT_SETVSRREGS (PT_FIRSTMACH + 3)
43
44#endif
\ No newline at end of file
5#include <x86/ptrace.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/reg.h+3-90
......@@ -1,92 +1,5 @@
1/* $NetBSD: reg.h,v 1.4 2000/06/04 09:30:44 tsubai Exp $ */
2
3#ifndef _POWERPC_REG_H_
4#define _POWERPC_REG_H_
5
6#include <sys/_types.h>
7
8/* Must match struct trapframe */
9struct reg {
10 __register_t fixreg[32];
11 __register_t lr;
12 __register_t cr;
13 __register_t xer;
14 __register_t ctr;
15 __register_t pc;
16};
17
18struct fpreg {
19 double fpreg[32];
20 double fpscr;
21};
22
23/* Must match pcb.pcb_vec */
24struct vmxreg {
25 __uint32_t vr[32][4];
26 __uint32_t pad[2];
27 __uint32_t vrsave;
28 __uint32_t vscr;
29};
30
31struct dbreg {
32 unsigned int junk;
33};
34
35#ifdef __LP64__
36/* Must match struct trapframe */
37struct reg32 {
38 __int32_t fixreg[32];
39 __int32_t lr;
40 __int32_t cr;
41 __int32_t xer;
42 __int32_t ctr;
43 __int32_t pc;
44};
45
46struct fpreg32 {
47 struct fpreg data;
48};
49
50struct vmxreg32 {
51 struct vmxreg data;
52};
53
54struct dbreg32 {
55 struct dbreg data;
56};
57
58#define __HAVE_REG32
59#endif
60
61#ifdef _KERNEL
62/*
63 * XXX these interfaces are MI, so they should be declared in a MI place.
64 */
65int fill_regs(struct thread *, struct reg *);
66int set_regs(struct thread *, struct reg *);
67int fill_fpregs(struct thread *, struct fpreg *);
68int set_fpregs(struct thread *, struct fpreg *);
69int fill_dbregs(struct thread *, struct dbreg *);
70int set_dbregs(struct thread *, struct dbreg *);
71
72/*
73 * MD interfaces.
1/*-
2 * This file is in the public domain.
743 */
75void cpu_save_thread_regs(struct thread *);
76
77#ifdef COMPAT_FREEBSD32
78struct image_params;
79
80int fill_regs32(struct thread *, struct reg32 *);
81int set_regs32(struct thread *, struct reg32 *);
82void ppc32_setregs(struct thread *, struct image_params *, uintptr_t);
83
84#define fill_fpregs32(td, reg) fill_fpregs(td,(struct fpreg *)reg)
85#define set_fpregs32(td, reg) set_fpregs(td,(struct fpreg *)reg)
86#define fill_dbregs32(td, reg) fill_dbregs(td,(struct dbreg *)reg)
87#define set_dbregs32(td, reg) set_dbregs(td,(struct dbreg *)reg)
88#endif
89
90#endif
914
92#endif /* _POWERPC_REG_H_ */
\ No newline at end of file
5#include <x86/reg.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/reloc.h+23-5
......@@ -1,8 +1,8 @@
11/*-
22 * SPDX-License-Identifier: BSD-3-Clause
33 *
4 * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
5 * All rights reserved.
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
66 *
77 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions
......@@ -12,11 +12,11 @@
1212 * 2. Redistributions in binary form must reproduce the above copyright
1313 * notice, this list of conditions and the following disclaimer in the
1414 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
15 * 3. Neither the name of the University nor the names of its contributors
1616 * may be used to endorse or promote products derived from this software
1717 * without specific prior written permission.
1818 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2121 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2222 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
......@@ -27,4 +27,22 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 */
\ No newline at end of file
30 */
31
32#ifndef _I386_MACHINE_RELOC_H_
33#define _I386_MACHINE_RELOC_H_
34
35/* Relocation format. */
36struct relocation_info {
37 int r_address; /* offset in text or data segment */
38 unsigned int r_symbolnum : 24, /* ordinal number of add symbol */
39 r_pcrel : 1, /* 1 if value should be pc-relative */
40 r_length : 2, /* log base 2 of value's width */
41 r_extern : 1, /* 1 if need to add symbol to value */
42 r_baserel : 1, /* linkage table relative */
43 r_jmptable : 1, /* relocate to jump table */
44 r_relative : 1, /* load address relative */
45 r_copy : 1; /* run time copy */
46};
47
48#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/resource.h deleted-44
......@@ -1,44 +0,0 @@
1/*-
2 * Copyright 1998 Massachusetts Institute of Technology
3 *
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose and without fee is hereby
6 * granted, provided that both the above copyright notice and this
7 * permission notice appear in all copies, that both the above
8 * copyright notice and this permission notice appear in all
9 * supporting documentation, and that the name of M.I.T. not be used
10 * in advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission. M.I.T. makes
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied
14 * warranty.
15 *
16 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
17 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_RESOURCE_H_
31#define _MACHINE_RESOURCE_H_ 1
32
33/*
34 * Definitions of resource types for Intel Architecture machines
35 * with support for legacy ISA devices and drivers.
36 */
37
38#define SYS_RES_IRQ 1 /* interrupt lines */
39#define SYS_RES_DRQ 2 /* isa dma lines */
40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */
42#define PCI_RES_BUS 5 /* PCI bus numbers */
43
44#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/rtas.h deleted-60
......@@ -1,60 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2011 Nathan Whitehorn
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RTAS_H_
30#define _MACHINE_RTAS_H_
31
32#include <sys/cdefs.h>
33#include <sys/types.h>
34#include <dev/ofw/openfirm.h>
35
36/*
37 * RTAS functions are defined by 32-bit integer tokens. These vary from
38 * system to system, and can be looked up from their standardized names
39 * using rtas_token_lookup(). If RTAS is not available, rtas_token_lookup()
40 * and rtas_call_method() return -1; this can be checked in advance using
41 * rtas_exists(). Otherwise, rtas_call_method() returns one of the RTAS
42 * status codes from the bottom of this file.
43 */
44
45int rtas_exists(void);
46int rtas_call_method(cell_t token, int nargs, int nreturns, ...);
47cell_t rtas_token_lookup(const char *method);
48
49/* RTAS Status Codes: see CHRP or PAPR specification */
50#define RTAS_OK 0
51#define RTAS_HW_ERROR -1
52#define RTAS_BUSY -2
53#define RTAS_PARAM_ERROR -3
54#define RTAS_STATE_CHANGE -7
55#define RTAS_VENDOR_BEGIN 9000
56#define RTAS_EXTENDED_DELAY 9900
57#define RTAS_ISOLATION_ERROR -9000
58#define RTAS_VENDOR_ERROR_BEGIN -9004
59
60#endif /* _MACHINE_RTAS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/runq.h deleted-55
......@@ -1,55 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RUNQ_H_
30#define _MACHINE_RUNQ_H_
31
32#ifdef __powerpc64__
33#define RQB_LEN (1UL) /* Number of priority status words. */
34#define RQB_L2BPW (6UL) /* Log2(sizeof(rqb_word_t) * NBBY)). */
35#else
36#define RQB_LEN (2) /* Number of priority status words. */
37#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */
38#endif
39#define RQB_BPW (1UL<<RQB_L2BPW) /* Bits in an rqb_word_t. */
40
41#define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1)))
42#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
43
44#define RQB_FFS(word) (ffsl(word) - 1)
45
46/*
47 * Type of run queue status word.
48 */
49#ifdef __powerpc64__
50typedef u_int64_t rqb_word_t;
51#else
52typedef u_int32_t rqb_word_t;
53#endif
54
55#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/sdt_machdep.h created+12
......@@ -0,0 +1,12 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org>
5 */
6
7#ifndef _SYS_SDT_MACHDEP_H_
8#define _SYS_SDT_MACHDEP_H_
9
10#define _SDT_ASM_PATCH_INSTR "nop"
11
12#endif /* _SYS_SDT_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/setjmp.h+2-24
......@@ -1,27 +1,5 @@
11/*-
2 * $NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $
2 * This file is in the public domain.
33 */
44
5#ifndef _MACHINE_SETJMP_H_
6#define _MACHINE_SETJMP_H_
7
8#include <sys/cdefs.h>
9
10#ifdef _KERNEL
11#define _JBLEN 25 /* Kernel doesn't save FP and Altivec regs */
12#else
13#define _JBLEN 100
14#endif
15
16/*
17 * jmp_buf and sigjmp_buf are encapsulated in different structs to force
18 * compile-time diagnostics for mismatches. The structs are the same
19 * internally to avoid some run-time errors for mismatches.
20 */
21#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE
22typedef struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1];
23#endif
24
25typedef struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1];
26
27#endif /* !_MACHINE_SETJMP_H_ */
\ No newline at end of file
5#include <x86/setjmp.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/signal.h deleted-54
......@@ -1,54 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $
34 */
35
36#ifndef _MACHINE_SIGNAL_H_
37#define _MACHINE_SIGNAL_H_
38
39#include <sys/cdefs.h>
40
41typedef int sig_atomic_t;
42
43#if __BSD_VISIBLE
44#include <machine/frame.h>
45
46struct sigcontext {
47 int sc_onstack; /* saved onstack flag */
48 int __sc_mask13; /* saved signal mask (old style) */
49 struct trapframe sc_frame; /* saved registers */
50 struct __sigset sc_mask; /* saved signal mask (new style) */
51};
52#endif
53
54#endif /* !_MACHINE_SIGNAL_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/slb.h deleted-92
......@@ -1,92 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2009 Nathan Whitehorn
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_SLB_H_
29#define _MACHINE_SLB_H_
30
31/*
32 * Bit definitions for segment lookaside buffer entries.
33 *
34 * PowerPC Microprocessor Family: The Programming Environments for 64-bit
35 * Microprocessors, section 7.4.2.1
36 *
37 * Note that these bitmasks are relative to the values for one of the two
38 * values for slbmte, slbmfee, and slbmfev, not the internal SLB
39 * representation.
40 */
41
42#define SLBV_KS 0x0000000000000800UL /* Supervisor-state prot key */
43#define SLBV_KP 0x0000000000000400UL /* User-state prot key */
44#define SLBV_N 0x0000000000000200UL /* No-execute protection */
45#define SLBV_L 0x0000000000000100UL /* Large page selector */
46#define SLBV_CLASS 0x0000000000000080UL /* Class selector */
47#define SLBV_VSID_MASK 0xfffffffffffff000UL /* Virtual segment ID mask */
48#define SLBV_VSID_SHIFT 12
49
50/*
51 * Make a predictable 1:1 map from ESIDs to VSIDs for the kernel. Hash table
52 * coverage is increased by swizzling the ESID and multiplying by a prime
53 * number (0x13bb).
54 */
55#define KERNEL_VSID_BIT 0x0000001000000000UL /* Bit set in all kernel VSIDs */
56#define KERNEL_VSID(esid) ((((((uint64_t)esid << 8) | ((uint64_t)esid >> 28)) \
57 * 0x13bbUL) & (KERNEL_VSID_BIT - 1)) | \
58 KERNEL_VSID_BIT)
59
60#define SLBE_VALID 0x0000000008000000UL /* SLB entry valid */
61#define SLBE_INDEX_MASK 0x0000000000000fffUL /* SLB index mask*/
62#define SLBE_ESID_MASK 0xfffffffff0000000UL /* Effective segment ID mask */
63#define SLBE_ESID_SHIFT 28
64
65/*
66 * SLB page sizes encoding, as present in property ibm,segment-page-sizes
67 * of CPU device tree node.
68 *
69 * See LoPAPR: CPU Node Properties, section C.6.1.4.
70 */
71#define SLB_PGSZ_4K_4K 0
72
73/* Virtual real-mode VSID in LPARs */
74#define VSID_VRMA 0x1ffffff
75
76/*
77 * User segment for copyin/out
78 */
79#define USER_SLB_SLOT 0
80#define USER_SLB_SLBE (((USER_ADDR >> ADDR_SR_SHFT) << SLBE_ESID_SHIFT) | \
81 SLBE_VALID | USER_SLB_SLOT)
82
83struct slb {
84 uint64_t slbv;
85 uint64_t slbe;
86};
87
88struct pmap;
89void handle_kernel_slb_spill(int, register_t, register_t);
90int handle_user_slb_spill(struct pmap *pm, vm_offset_t addr);
91
92#endif /* !_MACHINE_SLB_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/smp.h deleted-64
......@@ -1,64 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_SMP_H_
30#define _MACHINE_SMP_H_
31
32#ifdef _KERNEL
33
34#define IPI_AST 0
35#define IPI_PREEMPT 1
36#define IPI_RENDEZVOUS 2
37#define IPI_STOP 3
38#define IPI_STOP_HARD 3
39#define IPI_HARDCLOCK 4
40
41#ifndef LOCORE
42
43#include <machine/pcb.h>
44#include <sys/_cpuset.h>
45
46void ipi_all_but_self(int ipi);
47void ipi_cpu(int cpu, u_int ipi);
48void ipi_selected(cpuset_t cpus, int ipi);
49
50struct cpuref {
51 uintptr_t cr_hwref;
52 u_int cr_cpuid;
53 u_int cr_domain;
54};
55
56void pmap_cpu_bootstrap(int);
57void cpudep_ap_early_bootstrap(void);
58uintptr_t cpudep_ap_bootstrap(void);
59void cpudep_ap_setup(void);
60void machdep_ap_bootstrap(void);
61
62#endif /* !LOCORE */
63#endif /* _KERNEL */
64#endif /* !_MACHINE_SMP_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/spr.h deleted-863
......@@ -1,863 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $NetBSD: spr.h,v 1.25 2002/08/14 15:38:40 matt Exp $
29 */
30#ifndef _POWERPC_SPR_H_
31#define _POWERPC_SPR_H_
32
33#ifndef _LOCORE
34#define mtspr(reg, val) \
35 __asm __volatile("mtspr %0,%1" : : "K"(reg), "r"(val))
36#define mfspr(reg) \
37 ( { register_t val; \
38 __asm __volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \
39 val; } )
40
41#ifndef __powerpc64__
42
43/* The following routines allow manipulation of the full 64-bit width
44 * of SPRs on 64 bit CPUs in bridge mode */
45
46#define mtspr64(reg,valhi,vallo,scratch) \
47 __asm __volatile(" \
48 mfmsr %0; \
49 insrdi %0,%5,1,0; \
50 mtmsrd %0; \
51 isync; \
52 \
53 sld %1,%1,%4; \
54 or %1,%1,%2; \
55 mtspr %3,%1; \
56 srd %1,%1,%4; \
57 \
58 clrldi %0,%0,1; \
59 mtmsrd %0; \
60 isync;" \
61 : "=r"(scratch), "=r"(valhi) : "r"(vallo), "K"(reg), "r"(32), "r"(1))
62
63#define mfspr64upper(reg,scratch) \
64 ( { register_t val; \
65 __asm __volatile(" \
66 mfmsr %0; \
67 insrdi %0,%4,1,0; \
68 mtmsrd %0; \
69 isync; \
70 \
71 mfspr %1,%2; \
72 srd %1,%1,%3; \
73 \
74 clrldi %0,%0,1; \
75 mtmsrd %0; \
76 isync;" \
77 : "=r"(scratch), "=r"(val) : "K"(reg), "r"(32), "r"(1)); \
78 val; } )
79
80#endif
81
82#endif /* _LOCORE */
83
84/*
85 * Special Purpose Register declarations.
86 *
87 * The first column in the comments indicates which PowerPC
88 * architectures the SPR is valid on - 4 for 4xx series,
89 * 6 for 6xx/7xx series and 8 for 8xx and 8xxx series.
90 */
91
92#define SPR_MQ 0x000 /* .6. 601 MQ register */
93#define SPR_XER 0x001 /* 468 Fixed Point Exception Register */
94#define SPR_DSCR 0x003 /* .6. Data Stream Control Register (Unprivileged) */
95#define SPR_RTCU_R 0x004 /* .6. 601 RTC Upper - Read */
96#define SPR_RTCL_R 0x005 /* .6. 601 RTC Lower - Read */
97#define SPR_LR 0x008 /* 468 Link Register */
98#define SPR_CTR 0x009 /* 468 Count Register */
99#define SPR_DSCRP 0x011 /* Data Stream Control Register (Privileged) */
100#define SPR_DSISR 0x012 /* .68 DSI exception source */
101#define DSISR_DIRECT 0x80000000 /* Direct-store error exception */
102#define DSISR_NOTFOUND 0x40000000 /* Translation not found */
103#define DSISR_PROTECT 0x08000000 /* Memory access not permitted */
104#define DSISR_INVRX 0x04000000 /* Reserve-indexed insn direct-store access */
105#define DSISR_STORE 0x02000000 /* Store operation */
106#define DSISR_DABR 0x00400000 /* DABR match */
107#define DSISR_SEGMENT 0x00200000 /* XXX; not in 6xx PEM */
108#define DSISR_EAR 0x00100000 /* eciwx/ecowx && EAR[E] == 0 */
109#define DSISR_MC_UE_DEFERRED 0x00008000 /* UE deferred error */
110#define DSISR_MC_UE_TABLEWALK 0x00004000 /* UE deferred error during tablewalk */
111#define DSISR_MC_DERAT_MULTIHIT 0x00000800 /* D-ERAT multi-hit */
112#define DSISR_MC_TLB_MULTIHIT 0x00000400 /* TLB multi-hit */
113#define DSISR_MC_TLBIE_ERR 0x00000200 /* TLBIE or TLBIEL programming error */
114#define DSISR_MC_SLB_PARITY 0x00000100 /* SLB parity error */
115#define DSISR_MC_SLB_MULTIHIT 0x00000080 /* SLB Multi-hit detected (D-side) */
116#define DSISR_MC_BAD_REAL_LD 0x00000040 /* Bad real address for load. */
117#define DSISR_MC_BAD_ADDR 0x00000020 /* Bad address for load or store tablewalk */
118#define SPR_DAR 0x013 /* .68 Data Address Register */
119#define SPR_RTCU_W 0x014 /* .6. 601 RTC Upper - Write */
120#define SPR_RTCL_W 0x015 /* .6. 601 RTC Lower - Write */
121#define SPR_DEC 0x016 /* .68 DECrementer register */
122#define SPR_SDR1 0x019 /* .68 Page table base address register */
123#define SPR_SRR0 0x01a /* 468 Save/Restore Register 0 */
124#define SPR_SRR1 0x01b /* 468 Save/Restore Register 1 */
125#define SRR1_ISI_PFAULT 0x40000000 /* ISI page not found */
126#define SRR1_ISI_NOEXECUTE 0x10000000 /* Memory marked no-execute */
127#define SRR1_ISI_PP 0x08000000 /* PP bits forbid access */
128#define SRR1_MCHK_DATA 0x00200000 /* Machine check data in DSISR */
129#define SRR1_MCHK_IFETCH_M 0x081c0000 /* Machine check instr fetch mask */
130#define SRR1_MCHK_IFETCH_SLBMH 0x000c0000 /* SLB multihit */
131#define SPR_CFAR 0x01c /* Come From Address Register */
132#define SPR_AMR 0x01d /* Authority Mask Register */
133
134#define SPR_PID 0x030 /* 4.. Process ID */
135
136#define SPR_DECAR 0x036 /* ..8 Decrementer auto reload */
137#define SPR_IAMR 0x03d /* Instr. Authority Mask Reg */
138
139#define SPR_EIE 0x050 /* ..8 Exception Interrupt ??? */
140#define SPR_EID 0x051 /* ..8 Exception Interrupt ??? */
141#define SPR_NRI 0x052 /* ..8 Exception Interrupt ??? */
142#define SPR_FSCR 0x099 /* Facility Status and Control Register */
143#define FSCR_IC_MASK 0xFF00000000000000ULL /* FSCR[0:7] is Interrupt Cause */
144#define FSCR_IC_FP 0x0000000000000000ULL /* FP unavailable */
145#define FSCR_IC_VSX 0x0100000000000000ULL /* VSX unavailable */
146#define FSCR_IC_DSCR 0x0200000000000000ULL /* Access to the DSCR at SPRs 3 or 17 */
147#define FSCR_IC_PM 0x0300000000000000ULL /* Read or write access of a Performance Monitor SPR in group A */
148#define FSCR_IC_BHRB 0x0400000000000000ULL /* Execution of a BHRB Instruction */
149#define FSCR_IC_HTM 0x0500000000000000ULL /* Access to a Transactional Memory */
150/* Reserved 0x0600000000000000ULL */
151#define FSCR_IC_EBB 0x0700000000000000ULL /* Access to Event-Based Branch */
152#define FSCR_IC_TAR 0x0800000000000000ULL /* Access to Target Address Register */
153#define FSCR_IC_STOP 0x0900000000000000ULL /* Access to the 'stop' instruction in privileged non-hypervisor state */
154#define FSCR_IC_MSG 0x0A00000000000000ULL /* Access to 'msgsndp' or 'msgclrp' instructions */
155#define FSCR_IC_LM 0x0A00000000000000ULL /* Access to load monitored facility */
156#define FSCR_IC_SCV 0x0C00000000000000ULL /* Execution of a 'scv' instruction */
157#define FSCR_SCV 0x0000000000001000 /* scv instruction available */
158#define FSCR_LM 0x0000000000000800 /* Load monitored facilities available */
159#define FSCR_MSGP 0x0000000000000400 /* msgsndp and SPRs available */
160#define FSCR_TAR 0x0000000000000100 /* TAR register available */
161#define FSCR_EBB 0x0000000000000080 /* Event-based branch available */
162#define FSCR_DSCR 0x0000000000000004 /* DSCR available in PR state */
163#define SPR_UAMOR 0x09d /* User Authority Mask Override Register */
164#define SPR_DPDES 0x0b0 /* .6. Directed Privileged Doorbell Exception State Register */
165#define SPR_USPRG0 0x100 /* 4.8 User SPR General 0 */
166#define SPR_VRSAVE 0x100 /* .6. AltiVec VRSAVE */
167#define SPR_SPRG0 0x110 /* 468 SPR General 0 */
168#define SPR_SPRG1 0x111 /* 468 SPR General 1 */
169#define SPR_SPRG2 0x112 /* 468 SPR General 2 */
170#define SPR_SPRG3 0x113 /* 468 SPR General 3 */
171#define SPR_SPRG4 0x114 /* 4.8 SPR General 4 */
172#define SPR_SPRG5 0x115 /* 4.8 SPR General 5 */
173#define SPR_SPRG6 0x116 /* 4.8 SPR General 6 */
174#define SPR_SPRG7 0x117 /* 4.8 SPR General 7 */
175#define SPR_SCOMC 0x114 /* ... SCOM Address Register (970) */
176#define SPR_SCOMD 0x115 /* ... SCOM Data Register (970) */
177#define SPR_ASR 0x118 /* ... Address Space Register (PPC64) */
178#define SPR_EAR 0x11a /* .68 External Access Register */
179#define SPR_PVR 0x11f /* 468 Processor Version Register */
180#define MPC601 0x0001
181#define MPC603 0x0003
182#define MPC604 0x0004
183#define MPC602 0x0005
184#define MPC603e 0x0006
185#define MPC603ev 0x0007
186#define MPC750 0x0008
187#define MPC750CL 0x7000 /* Nintendo Wii's Broadway */
188#define MPC604ev 0x0009
189#define MPC7400 0x000c
190#define MPC620 0x0014
191#define IBM403 0x0020
192#define IBM401A1 0x0021
193#define IBM401B2 0x0022
194#define IBM401C2 0x0023
195#define IBM401D2 0x0024
196#define IBM401E2 0x0025
197#define IBM401F2 0x0026
198#define IBM401G2 0x0027
199#define IBMRS64II 0x0033
200#define IBMRS64III 0x0034
201#define IBMPOWER4 0x0035
202#define IBMRS64III_2 0x0036
203#define IBMRS64IV 0x0037
204#define IBMPOWER4PLUS 0x0038
205#define IBM970 0x0039
206#define IBMPOWER5 0x003a
207#define IBMPOWER5PLUS 0x003b
208#define IBM970FX 0x003c
209#define IBMPOWER6 0x003e
210#define IBMPOWER7 0x003f
211#define IBMPOWER3 0x0040
212#define IBMPOWER3PLUS 0x0041
213#define IBM970MP 0x0044
214#define IBM970GX 0x0045
215#define IBMPOWERPCA2 0x0049
216#define IBMPOWER7PLUS 0x004a
217#define IBMPOWER8E 0x004b
218#define IBMPOWER8NVL 0x004c
219#define IBMPOWER8 0x004d
220#define IBMPOWER9 0x004e
221#define MPC860 0x0050
222#define IBMCELLBE 0x0070
223#define IBMPOWER10 0x0080
224#define MPC8240 0x0081
225#define IBMPOWER11 0x0082
226#define PA6T 0x0090
227#define IBM405GP 0x4011
228#define IBM405L 0x4161
229#define IBM750FX 0x7000
230#define MPC745X_P(v) ((v & 0xFFF8) == 0x8000)
231#define MPC7450 0x8000
232#define MPC7455 0x8001
233#define MPC7457 0x8002
234#define MPC7447A 0x8003
235#define MPC7448 0x8004
236#define MPC7410 0x800c
237#define MPC8245 0x8081
238#define FSL_E500v1 0x8020
239#define FSL_E500v2 0x8021
240#define FSL_E500mc 0x8023
241#define FSL_E5500 0x8024
242#define FSL_E6500 0x8040
243#define FSL_E300C1 0x8083
244#define FSL_E300C2 0x8084
245#define FSL_E300C3 0x8085
246#define FSL_E300C4 0x8086
247
248#define LPCR_PECE_WAKESET (LPCR_PECE_EXT | LPCR_PECE_DECR | LPCR_PECE_ME)
249
250#define SPR_DBSR 0x130 /* ..8 Debug Status Register */
251#define DBSR_IDE 0x80000000 /* Imprecise debug event. */
252#define DBSR_UDE 0x40000000 /* Unconditional debug event. */
253#define DBSR_MRR 0x30000000 /* Most recent Reset (mask). */
254#define DBSR_ICMP 0x08000000 /* Instr. complete debug event. */
255#define DBSR_BRT 0x04000000 /* Branch taken debug event. */
256#define DBSR_IRPT 0x02000000 /* Interrupt taken debug event. */
257#define DBSR_TRAP 0x01000000 /* Trap instr. debug event. */
258#define DBSR_IAC1 0x00800000 /* Instr. address compare #1. */
259#define DBSR_IAC2 0x00400000 /* Instr. address compare #2. */
260#define DBSR_IAC3 0x00200000 /* Instr. address compare #3. */
261#define DBSR_IAC4 0x00100000 /* Instr. address compare #4. */
262#define DBSR_DAC1R 0x00080000 /* Data addr. read compare #1. */
263#define DBSR_DAC1W 0x00040000 /* Data addr. write compare #1. */
264#define DBSR_DAC2R 0x00020000 /* Data addr. read compare #2. */
265#define DBSR_DAC2W 0x00010000 /* Data addr. write compare #2. */
266#define DBSR_RET 0x00008000 /* Return debug event. */
267#define SPR_EPCR 0x133
268#define EPCR_EXTGS 0x80000000
269#define EPCR_DTLBGS 0x40000000
270#define EPCR_ITLBGS 0x20000000
271#define EPCR_DSIGS 0x10000000
272#define EPCR_ISIGS 0x08000000
273#define EPCR_DUVGS 0x04000000
274#define EPCR_ICM 0x02000000
275#define EPCR_GICMGS 0x01000000
276#define EPCR_DGTMI 0x00800000
277#define EPCR_DMIUH 0x00400000
278#define EPCR_PMGS 0x00200000
279#define SPR_DBCR0 0x134 /* ..8 Debug Control Register 0 */
280#define SPR_DBCR1 0x135 /* ..8 Debug Control Register 1 */
281#define SPR_DBCR2 0x136 /* ..8 Debug Control Register 2 */
282#define SPR_IAC1 0x138 /* ..8 Instruction Address Compare 1 */
283#define SPR_IAC2 0x139 /* ..8 Instruction Address Compare 2 */
284#define SPR_IAC3 0x13a /* ..8 Instruction Address Compare 3 */
285#define SPR_IAC4 0x13b /* ..8 Instruction Address Compare 4 */
286
287#define SPR_HSRR0 0x13a
288#define SPR_HSRR1 0x13b
289#define SPR_DAC1 0x13c /* ..8 Data Address Compare 1 */
290#define SPR_DAC2 0x13d /* ..8 Data Address Compare 2 */
291#define SPR_DVC1 0x13e /* ..8 Data Value Compare 1 */
292#define SPR_DVC2 0x13f /* ..8 Data Value Compare 2 */
293
294#define SPR_LPCR 0x13e /* .6. Logical Partitioning Control */
295#define LPCR_LPES 0x008 /* Bit 60 */
296#define LPCR_HVICE 0x002 /* Hypervisor Virtualization Interrupt (Arch 3.0) */
297#define LPCR_ILE (1ULL << 25) /* Interrupt Little-Endian (ISA 2.07) */
298#define LPCR_UPRT (1ULL << 22) /* Use Process Table (ISA 3) */
299#define LPCR_HR (1ULL << 20) /* Host Radix mode */
300#define LPCR_PECE_DRBL (1ULL << 16) /* Directed Privileged Doorbell */
301#define LPCR_PECE_HDRBL (1ULL << 15) /* Directed Hypervisor Doorbell */
302#define LPCR_PECE_EXT (1ULL << 14) /* External exceptions */
303#define LPCR_PECE_DECR (1ULL << 13) /* Decrementer exceptions */
304#define LPCR_PECE_ME (1ULL << 12) /* Machine Check and Hypervisor */
305 /* Maintenance exceptions */
306#define SPR_LPID 0x13f /* .6. Logical Partitioning Control */
307#define SPR_HMER 0x150 /* Hypervisor Maintenance Exception Register */
308#define SPR_HMEER 0x151 /* Hypervisor Maintenance Exception Enable Register */
309#define SPR_AMOR 0x15d /* Authority Mask Override Register */
310
311#define SPR_TIR 0x1be /* .6. Thread Identification Register */
312#define SPR_PTCR 0x1d0 /* Partition Table Control Register */
313#define SPR_SPEFSCR 0x200 /* ..8 Signal Processing Engine FSCR. */
314#define SPEFSCR_SOVH 0x80000000
315#define SPEFSCR_OVH 0x40000000
316#define SPEFSCR_FGH 0x20000000
317#define SPEFSCR_FXH 0x10000000
318#define SPEFSCR_FINVH 0x08000000
319#define SPEFSCR_FDBZH 0x04000000
320#define SPEFSCR_FUNFH 0x02000000
321#define SPEFSCR_FOVFH 0x01000000
322#define SPEFSCR_FINXS 0x00200000
323#define SPEFSCR_FINVS 0x00100000
324#define SPEFSCR_FDBZS 0x00080000
325#define SPEFSCR_FUNFS 0x00040000
326#define SPEFSCR_FOVFS 0x00020000
327#define SPEFSCR_SOV 0x00008000
328#define SPEFSCR_OV 0x00004000
329#define SPEFSCR_FG 0x00002000
330#define SPEFSCR_FX 0x00001000
331#define SPEFSCR_FINV 0x00000800
332#define SPEFSCR_FDBZ 0x00000400
333#define SPEFSCR_FUNF 0x00000200
334#define SPEFSCR_FOVF 0x00000100
335#define SPEFSCR_FINXE 0x00000040
336#define SPEFSCR_FINVE 0x00000020
337#define SPEFSCR_FDBZE 0x00000010
338#define SPEFSCR_FUNFE 0x00000008
339#define SPEFSCR_FOVFE 0x00000004
340#define SPEFSCR_FRMC_M 0x00000003
341#define SPEFSCR_DFLT (SPEFSCR_FINVE | SPEFSCR_FDBZE | \
342 SPEFSCR_FUNFE | SPEFSCR_FOVFE)
343#define SPR_IBAT0U 0x210 /* .6. Instruction BAT Reg 0 Upper */
344#define SPR_IBAT0L 0x211 /* .6. Instruction BAT Reg 0 Lower */
345#define SPR_IBAT1U 0x212 /* .6. Instruction BAT Reg 1 Upper */
346#define SPR_IBAT1L 0x213 /* .6. Instruction BAT Reg 1 Lower */
347#define SPR_IBAT2U 0x214 /* .6. Instruction BAT Reg 2 Upper */
348#define SPR_IBAT2L 0x215 /* .6. Instruction BAT Reg 2 Lower */
349#define SPR_IBAT3U 0x216 /* .6. Instruction BAT Reg 3 Upper */
350#define SPR_IBAT3L 0x217 /* .6. Instruction BAT Reg 3 Lower */
351#define SPR_DBAT0U 0x218 /* .6. Data BAT Reg 0 Upper */
352#define SPR_DBAT0L 0x219 /* .6. Data BAT Reg 0 Lower */
353#define SPR_DBAT1U 0x21a /* .6. Data BAT Reg 1 Upper */
354#define SPR_DBAT1L 0x21b /* .6. Data BAT Reg 1 Lower */
355#define SPR_DBAT2U 0x21c /* .6. Data BAT Reg 2 Upper */
356#define SPR_DBAT2L 0x21d /* .6. Data BAT Reg 2 Lower */
357#define SPR_DBAT3U 0x21e /* .6. Data BAT Reg 3 Upper */
358#define SPR_DBAT3L 0x21f /* .6. Data BAT Reg 3 Lower */
359#define SPR_IBAT4U 0x230 /* .6. Instruction BAT Reg 4 Upper */
360#define SPR_DBCR3 0x231 /* ..8 Debug Control Register 3 */
361#define SPR_IBAT4L 0x231 /* .6. Instruction BAT Reg 4 Lower */
362#define SPR_IBAT5U 0x232 /* .6. Instruction BAT Reg 5 Upper */
363#define SPR_IBAT5L 0x233 /* .6. Instruction BAT Reg 5 Lower */
364#define SPR_DBCR4 0x233 /* ..8 Debug Control Register 4 */
365#define SPR_IBAT6U 0x234 /* .6. Instruction BAT Reg 6 Upper */
366#define SPR_DBCR5 0x234 /* ..8 Debug Control Register 5 */
367#define SPR_IBAT6L 0x235 /* .6. Instruction BAT Reg 6 Lower */
368#define SPR_IAC5 0x235 /* ..8 Instruction Address Compare 5 */
369#define SPR_IBAT7U 0x236 /* .6. Instruction BAT Reg 7 Upper */
370#define SPR_IAC6 0x236 /* ..8 Instruction Address Compare 6 */
371#define SPR_IBAT7L 0x237 /* .6. Instruction BAT Reg 7 Lower */
372#define SPR_IAC7 0x237 /* ..8 Instruction Address Compare 7 */
373#define SPR_DBAT4U 0x238 /* .6. Data BAT Reg 4 Upper */
374#define SPR_IAC8 0x238 /* ..8 Instruction Address Compare 8 */
375#define SPR_DBAT4L 0x239 /* .6. Data BAT Reg 4 Lower */
376#define SPR_DBAT5U 0x23a /* .6. Data BAT Reg 5 Upper */
377#define SPR_DBAT5L 0x23b /* .6. Data BAT Reg 5 Lower */
378#define SPR_DBAT6U 0x23c /* .6. Data BAT Reg 6 Upper */
379#define SPR_DBAT6L 0x23d /* .6. Data BAT Reg 6 Lower */
380#define SPR_DBAT7U 0x23e /* .6. Data BAT Reg 7 Upper */
381#define SPR_DBAT7L 0x23f /* .6. Data BAT Reg 7 Lower */
382#define SPR_DBCR6 0x25b /* ..8 Debug Control Register 6 */
383#define SPR_SPRG8 0x25c /* ..8 SPR General 8 */
384
385#define SPR_MMCRA 0x312 /* ... Monitor Mode Control Register A */
386#define SPR_PMC1 0x313 /* ... PMC 1 */
387#define SPR_PMC2 0x314 /* ... PMC 2 */
388#define SPR_PMC3 0x315 /* ... PMC 3 */
389#define SPR_PMC4 0x316 /* ... PMC 4 */
390#define SPR_PMC5 0x317 /* ... PMC 5 */
391#define SPR_PMC6 0x318 /* ... PMC 6 */
392#define SPR_PMC7 0x319 /* ... PMC 7 */
393#define SPR_PMC8 0x31a /* ... PMC 8 */
394
395#define SPR_MMCR0 0x31b /* ... Monitor Mode Control Register 0 */
396#define SPR_MMCR0_FC 0x80000000 /* Freeze counters */
397#define SPR_MMCR0_FCS 0x40000000 /* Freeze counters in supervisor mode */
398#define SPR_MMCR0_FCP 0x20000000 /* Freeze counters in user mode */
399#define SPR_MMCR0_FCM1 0x10000000 /* Freeze counters when mark=1 */
400#define SPR_MMCR0_FCM0 0x08000000 /* Freeze counters when mark=0 */
401#define SPR_MMCR0_PMXE 0x04000000 /* Enable PM interrupt */
402#define SPR_MMCR0_PMAE 0x04000000 /* PM Alert Enable */
403#define SPR_MMCR0_FCECE 0x02000000 /* Freeze counters after event */
404#define SPR_MMCR0_TBSEL_15 0x01800000 /* Count bit 15 of TBL */
405#define SPR_MMCR0_TBSEL_19 0x01000000 /* Count bit 19 of TBL */
406#define SPR_MMCR0_TBSEL_23 0x00800000 /* Count bit 23 of TBL */
407#define SPR_MMCR0_TBSEL_31 0x00000000 /* Count bit 31 of TBL */
408#define SPR_MMCR0_TBEE 0x00400000 /* Time-base event enable */
409#define SPR_MMCR0_THRESHOLD(x) ((x) << 16) /* Threshold value */
410#define SPR_MMCR0_PMC1CE 0x00008000 /* PMC1 condition enable */
411#define SPR_MMCR0_PMCNCE 0x00004000 /* PMCn condition enable */
412#define SPR_MMCR0_TRIGGER 0x00002000 /* Trigger */
413#define SPR_MMCR0_PMAO 0x00000080 /* PM Alert Occurred */
414#define SPR_MMCR0_FCPC 0x00001000 /* Freeze Counters in Problem State Cond. */
415#define SPR_MMCR0_FC56 0x00000010 /* Freeze Counters 5-6 */
416#define SPR_MMCR0_PMC1SEL(x) ((x) << 8) /* PMC1 selector (970) */
417#define SPR_MMCR0_PMC2SEL(x) ((x) << 1) /* PMC2 selector (970) */
418#define SPR_MMCR0_74XX_PMC1SEL(x) (((x) & 0x3f) << 6) /* PMC1 selector */
419#define SPR_MMCR0_74XX_PMC2SEL(x) (((x) & 0x3f) << 0) /* PMC2 selector */
420
421#define SPR_MMCR1 0x31e /* ... Monitor Mode Control Register 1 */
422#define SPR_MMCR1_PMC3SEL(x) (((x) & 0x1f) << 27) /* PMC 3 selector */
423#define SPR_MMCR1_PMC4SEL(x) (((x) & 0x1f) << 22) /* PMC 4 selector */
424#define SPR_MMCR1_PMC5SEL(x) (((x) & 0x1f) << 17) /* PMC 5 selector */
425#define SPR_MMCR1_PMC6SEL(x) (((x) & 0x1f) << 12) /* PMC 6 selector */
426#define SPR_MMCR1_74XX_PMC6SEL(x) (((x) & 0x3f) << 11) /* PMC 6 selector */
427#define SPR_MMCR1_PMC7SEL(x) (((x) & 0x1f) << 7) /* PMC 7 selector */
428#define SPR_MMCR1_PMC8SEL(x) (((x) & 0x1f) << 2) /* PMC 8 selector */
429#define SPR_MMCR1_P8_PMCSEL_ALL 0xffffffff
430#define SPR_MMCR1_P8_PMCNSEL_MASK(n) (0xffUL << ((3-(n))*8))
431#define SPR_MMCR1_P8_PMCNSEL(n, v) ((unsigned long)(v) << ((3-(n))*8))
432
433#define SPR_MMCR2 0x311
434#define SPR_MMCR2_CNBIT(n, bit) ((bit) << (((5 - (n)) * 9) + 10))
435#define SPR_MMCR2_FCNS(n) SPR_MMCR2_CNBIT(n, 0x100ULL)
436#define SPR_MMCR2_FCNP0(n) SPR_MMCR2_CNBIT(n, 0x080ULL)
437#define SPR_MMCR2_FCNP1(n) SPR_MMCR2_CNBIT(n, 0x040ULL)
438#define SPR_MMCR2_FCNM1(n) SPR_MMCR2_CNBIT(n, 0x020ULL)
439#define SPR_MMCR2_FCNM0(n) SPR_MMCR2_CNBIT(n, 0x010ULL)
440#define SPR_MMCR2_FCNWAIT(n) SPR_MMCR2_CNBIT(n, 0x008ULL)
441#define SPR_MMCR2_FCNH(n) SPR_MMCR2_CNBIT(n, 0x004ULL)
442/* Freeze Counter N in Hypervisor/Supervisor/Problem states */
443#define SPR_MMCR2_FCNHSP(n) \
444 (SPR_MMCR2_FCNS(n) | SPR_MMCR2_FCNP0(n) | \
445 SPR_MMCR2_FCNP1(n) | SPR_MMCR2_FCNH(n))
446
447#define SPR_M_TWB 0x31c /* ..8 MMU tablewalk base */
448#define M_TWB_L1TB 0xfffff000 /* level-1 translation base */
449#define M_TWB_L1INDX 0x00000ffc /* level-1 index */
450#define SPR_MD_TWC 0x31d /* ..8 DMMU tablewalk control */
451#define SPR_MD_RPN 0x31e /* ..8 DMMU real (phys) page number */
452#define SPR_MD_TW 0x31f /* ..8 MMU tablewalk scratch */
453#define SPR_BESCRS 0x320 /* .6. Branch Event Status and Control Set Register */
454#define SPR_BESCRSU 0x321 /* .6. Branch Event Status and Control Set Register (upper 32-bit) */
455#define SPR_BESCRR 0x322 /* .6. Branch Event Status and Control Reset Register */
456#define SPR_BESCRRU 0x323 /* .6. Branch Event Status and Control Register (upper 32-bit) */
457#define SPR_EBBHR 0x324 /* .6. Event-based Branch Handler Register */
458#define SPR_EBBRR 0x325 /* .6. Event-based Branch Return Register */
459#define SPR_BESCR 0x326 /* .6. Branch Event Status and Control Register */
460#define SPR_LMRR 0x32d /* .6. Load Monitored Region Register */
461#define SPR_LMSER 0x32e /* .6. Load Monitored Section Enable Register */
462#define SPR_TAR 0x32f /* .6. Branch Target Address Register */
463#define SPR_MI_CAM 0x330 /* ..8 IMMU CAM entry read */
464#define SPR_MI_RAM0 0x331 /* ..8 IMMU RAM entry read reg 0 */
465#define SPR_MI_RAM1 0x332 /* ..8 IMMU RAM entry read reg 1 */
466#define SPR_MD_CAM 0x338 /* ..8 IMMU CAM entry read */
467#define SPR_MD_RAM0 0x339 /* ..8 IMMU RAM entry read reg 0 */
468#define SPR_MD_RAM1 0x33a /* ..8 IMMU RAM entry read reg 1 */
469#define SPR_PSSCR 0x357 /* Processor Stop Status and Control Register (ISA 3.0) */
470#define PSSCR_PLS_S 60
471#define PSSCR_PLS_M (0xf << PSSCR_PLS_S)
472#define PSSCR_SD (1 << 22)
473#define PSSCR_ESL (1 << 21)
474#define PSSCR_EC (1 << 20)
475#define PSSCR_PSLL_S 16
476#define PSSCR_PSLL_M (0xf << PSSCR_PSLL_S)
477#define PSSCR_TR_S 8
478#define PSSCR_TR_M (0x3 << PSSCR_TR_S)
479#define PSSCR_MTL_S 4
480#define PSSCR_MTL_M (0xf << PSSCR_MTL_S)
481#define PSSCR_RL_S 0
482#define PSSCR_RL_M (0xf << PSSCR_RL_S)
483#define SPR_PMCR 0x374 /* Processor Management Control Register */
484#define SPR_UMMCR2 0x3a0 /* .6. User Monitor Mode Control Register 2 */
485#define SPR_UMMCR0 0x3a8 /* .6. User Monitor Mode Control Register 0 */
486#define SPR_USIA 0x3ab /* .6. User Sampled Instruction Address */
487#define SPR_UMMCR1 0x3ac /* .6. User Monitor Mode Control Register 1 */
488#define SPR_MMCR2_74XX 0x3b0 /* .6. Monitor Mode Control Register 2 */
489#define SPR_MMCR2_74XX_THRESHMULT_32 0x80000000 /* Multiply MMCR0 threshold by 32 */
490#define SPR_MMCR2_74XX_THRESHMULT_2 0x00000000 /* Multiply MMCR0 threshold by 2 */
491#define SPR_PMC5_74XX 0x3b1 /* .6. Performance Counter Register 5 */
492#define SPR_PMC6_74XX 0x3b2 /* .6. Performance Counter Register 6 */
493#define SPR_MMCR0_74XX 0x3b8 /* .6. Monitor Mode Control Register 0 */
494#define SPR_PMC1_74XX 0x3b9 /* .6. Performance Counter Register 1 */
495#define SPR_PMC2_74XX 0x3ba /* .6. Performance Counter Register 2 */
496#define SPR_SIA 0x3bb /* .6. Sampled Instruction Address */
497#define SPR_MMCR1_74XX 0x3bc /* .6. Monitor Mode Control Register 2 */
498
499#define SPR_PMC3_74XX 0x3bd /* .6. Performance Counter Register 3 */
500#define SPR_PMC4_74XX 0x3be /* .6. Performance Counter Register 4 */
501#define SPR_DMISS 0x3d0 /* .68 Data TLB Miss Address Register */
502#define SPR_DCMP 0x3d1 /* .68 Data TLB Compare Register */
503#define SPR_HASH1 0x3d2 /* .68 Primary Hash Address Register */
504#define SPR_HASH2 0x3d3 /* .68 Secondary Hash Address Register */
505#define SPR_IMISS 0x3d4 /* .68 Instruction TLB Miss Address Register */
506#define SPR_TLBMISS 0x3d4 /* .6. TLB Miss Address Register */
507#define SPR_DEAR 0x03d /* ..8 Data Exception Address Register */
508#define SPR_ICMP 0x3d5 /* .68 Instruction TLB Compare Register */
509#define SPR_PTEHI 0x3d5 /* .6. Instruction TLB Compare Register */
510#define SPR_RPA 0x3d6 /* .68 Required Physical Address Register */
511#define SPR_PTELO 0x3d6 /* .6. Required Physical Address Register */
512
513#define SPR_TSR 0x150 /* ..8 Timer Status Register */
514#define SPR_TCR 0x154 /* ..8 Timer Control Register */
515
516#define TSR_ENW 0x80000000 /* Enable Next Watchdog */
517#define TSR_WIS 0x40000000 /* Watchdog Interrupt Status */
518#define TSR_WRS_MASK 0x30000000 /* Watchdog Reset Status */
519#define TSR_WRS_NONE 0x00000000 /* No watchdog reset has occurred */
520#define TSR_WRS_CORE 0x10000000 /* Core reset was forced by the watchdog */
521#define TSR_WRS_CHIP 0x20000000 /* Chip reset was forced by the watchdog */
522#define TSR_WRS_SYSTEM 0x30000000 /* System reset was forced by the watchdog */
523#define TSR_PIS 0x08000000 /* PIT Interrupt Status */
524#define TSR_DIS 0x08000000 /* Decrementer Interrupt Status */
525#define TSR_FIS 0x04000000 /* FIT Interrupt Status */
526
527#define TCR_WP_MASK 0xc0000000 /* Watchdog Period mask */
528#define TCR_WP_2_17 0x00000000 /* 2**17 clocks */
529#define TCR_WP_2_21 0x40000000 /* 2**21 clocks */
530#define TCR_WP_2_25 0x80000000 /* 2**25 clocks */
531#define TCR_WP_2_29 0xc0000000 /* 2**29 clocks */
532#define TCR_WRC_MASK 0x30000000 /* Watchdog Reset Control mask */
533#define TCR_WRC_NONE 0x00000000 /* No watchdog reset */
534#define TCR_WRC_CORE 0x10000000 /* Core reset */
535#define TCR_WRC_CHIP 0x20000000 /* Chip reset */
536#define TCR_WRC_SYSTEM 0x30000000 /* System reset */
537#define TCR_WIE 0x08000000 /* Watchdog Interrupt Enable */
538#define TCR_PIE 0x04000000 /* PIT Interrupt Enable */
539#define TCR_DIE 0x04000000 /* Pecrementer Interrupt Enable */
540#define TCR_FP_MASK 0x03000000 /* FIT Period */
541#define TCR_FP_2_9 0x00000000 /* 2**9 clocks */
542#define TCR_FP_2_13 0x01000000 /* 2**13 clocks */
543#define TCR_FP_2_17 0x02000000 /* 2**17 clocks */
544#define TCR_FP_2_21 0x03000000 /* 2**21 clocks */
545#define TCR_FIE 0x00800000 /* FIT Interrupt Enable */
546#define TCR_ARE 0x00400000 /* Auto Reload Enable */
547
548#define SPR_HID0 0x3f0 /* ..8 Hardware Implementation Register 0 */
549#define SPR_HID1 0x3f1 /* ..8 Hardware Implementation Register 1 */
550#define SPR_HID2 0x3f3 /* ..8 Hardware Implementation Register 2 */
551#define SPR_HID4 0x3f4 /* ..8 Hardware Implementation Register 4 */
552#define SPR_HID5 0x3f6 /* ..8 Hardware Implementation Register 5 */
553#define SPR_HID6 0x3f9 /* ..8 Hardware Implementation Register 6 */
554
555#define SPR_CELL_TSRL 0x380 /* ... Cell BE Thread Status Register */
556#define SPR_CELL_TSCR 0x399 /* ... Cell BE Thread Switch Register */
557
558#if defined(AIM)
559#define SPR_PIR 0x3ff /* .6. Processor Identification Register */
560#elif defined(BOOKE)
561#define SPR_PIR 0x11e /* ..8 Processor Identification Register */
562#endif
563
564#define DBCR0_EDM 0x80000000 /* External Debug Mode */
565#define DBCR0_IDM 0x40000000 /* Internal Debug Mode */
566#define DBCR0_RST_MASK 0x30000000 /* ReSeT */
567#define DBCR0_RST_NONE 0x00000000 /* No action */
568#define DBCR0_RST_CORE 0x10000000 /* Core reset */
569#define DBCR0_RST_CHIP 0x20000000 /* Chip reset */
570#define DBCR0_RST_SYSTEM 0x30000000 /* System reset */
571#define DBCR0_IC 0x08000000 /* Instruction Completion debug event */
572#define DBCR0_BT 0x04000000 /* Branch Taken debug event */
573#define DBCR0_EDE 0x02000000 /* Exception Debug Event */
574#define DBCR0_TDE 0x01000000 /* Trap Debug Event */
575#define DBCR0_IA1 0x00800000 /* IAC (Instruction Address Compare) 1 debug event */
576#define DBCR0_IA2 0x00400000 /* IAC 2 debug event */
577#define DBCR0_IA12 0x00200000 /* Instruction Address Range Compare 1-2 */
578#define DBCR0_IA12X 0x00100000 /* IA12 eXclusive */
579#define DBCR0_IA3 0x00080000 /* IAC 3 debug event */
580#define DBCR0_IA4 0x00040000 /* IAC 4 debug event */
581#define DBCR0_IA34 0x00020000 /* Instruction Address Range Compare 3-4 */
582#define DBCR0_IA34X 0x00010000 /* IA34 eXclusive */
583#define DBCR0_IA12T 0x00008000 /* Instruction Address Range Compare 1-2 range Toggle */
584#define DBCR0_IA34T 0x00004000 /* Instruction Address Range Compare 3-4 range Toggle */
585#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */
586
587#define SPR_IABR 0x3f2 /* ..8 Instruction Address Breakpoint Register 0 */
588#define SPR_DABR 0x3f5 /* .6. Data Address Breakpoint Register */
589#define SPR_MSSCR0 0x3f6 /* .6. Memory SubSystem Control Register */
590#define MSSCR0_SHDEN 0x80000000 /* 0: Shared-state enable */
591#define MSSCR0_SHDPEN3 0x40000000 /* 1: ~SHD[01] signal enable in MEI mode */
592#define MSSCR0_L1INTVEN 0x38000000 /* 2-4: L1 data cache ~HIT intervention enable */
593#define MSSCR0_L2INTVEN 0x07000000 /* 5-7: L2 data cache ~HIT intervention enable*/
594#define MSSCR0_DL1HWF 0x00800000 /* 8: L1 data cache hardware flush */
595#define MSSCR0_MBO 0x00400000 /* 9: must be one */
596#define MSSCR0_EMODE 0x00200000 /* 10: MPX bus mode (read-only) */
597#define MSSCR0_ABD 0x00100000 /* 11: address bus driven (read-only) */
598#define MSSCR0_MBZ 0x000fffff /* 12-31: must be zero */
599#define MSSCR0_L2PFE 0x00000003 /* 30-31: L2 prefetch enable */
600#define SPR_MSSSR0 0x3f7 /* .6. Memory Subsystem Status Register (MPC745x) */
601#define MSSSR0_L2TAG 0x00040000 /* 13: L2 tag parity error */
602#define MSSSR0_L2DAT 0x00020000 /* 14: L2 data parity error */
603#define MSSSR0_L3TAG 0x00010000 /* 15: L3 tag parity error */
604#define MSSSR0_L3DAT 0x00008000 /* 16: L3 data parity error */
605#define MSSSR0_APE 0x00004000 /* 17: Address parity error */
606#define MSSSR0_DPE 0x00002000 /* 18: Data parity error */
607#define MSSSR0_TEA 0x00001000 /* 19: Bus transfer error acknowledge */
608#define SPR_LDSTCR 0x3f8 /* .6. Load/Store Control Register */
609#define SPR_L2PM 0x3f8 /* .6. L2 Private Memory Control Register */
610#define SPR_L2CR 0x3f9 /* .6. L2 Control Register */
611#define L2CR_L2E 0x80000000 /* 0: L2 enable */
612#define L2CR_L2PE 0x40000000 /* 1: L2 data parity enable */
613#define L2CR_L2SIZ 0x30000000 /* 2-3: L2 size */
614#define L2SIZ_2M 0x00000000
615#define L2SIZ_256K 0x10000000
616#define L2SIZ_512K 0x20000000
617#define L2SIZ_1M 0x30000000
618#define L2CR_L2CLK 0x0e000000 /* 4-6: L2 clock ratio */
619#define L2CLK_DIS 0x00000000 /* disable L2 clock */
620#define L2CLK_10 0x02000000 /* core clock / 1 */
621#define L2CLK_15 0x04000000 /* / 1.5 */
622#define L2CLK_20 0x08000000 /* / 2 */
623#define L2CLK_25 0x0a000000 /* / 2.5 */
624#define L2CLK_30 0x0c000000 /* / 3 */
625#define L2CR_L2RAM 0x01800000 /* 7-8: L2 RAM type */
626#define L2RAM_FLOWTHRU_BURST 0x00000000
627#define L2RAM_PIPELINE_BURST 0x01000000
628#define L2RAM_PIPELINE_LATE 0x01800000
629#define L2CR_L2DO 0x00400000 /* 9: L2 data-only.
630 Setting this bit disables instruction
631 caching. */
632#define L2CR_L2I 0x00200000 /* 10: L2 global invalidate. */
633#define L2CR_L2IO_7450 0x00010000 /* 11: L2 instruction-only (MPC745x). */
634#define L2CR_L2CTL 0x00100000 /* 11: L2 RAM control (ZZ enable).
635 Enables automatic operation of the
636 L2ZZ (low-power mode) signal. */
637#define L2CR_L2WT 0x00080000 /* 12: L2 write-through. */
638#define L2CR_L2TS 0x00040000 /* 13: L2 test support. */
639#define L2CR_L2OH 0x00030000 /* 14-15: L2 output hold. */
640#define L2CR_L2DO_7450 0x00010000 /* 15: L2 data-only (MPC745x). */
641#define L2CR_L2SL 0x00008000 /* 16: L2 DLL slow. */
642#define L2CR_L2DF 0x00004000 /* 17: L2 differential clock. */
643#define L2CR_L2BYP 0x00002000 /* 18: L2 DLL bypass. */
644#define L2CR_L2FA 0x00001000 /* 19: L2 flush assist (for software flush). */
645#define L2CR_L2HWF 0x00000800 /* 20: L2 hardware flush. */
646#define L2CR_L2IO 0x00000400 /* 21: L2 instruction-only. */
647#define L2CR_L2CLKSTP 0x00000200 /* 22: L2 clock stop. */
648#define L2CR_L2DRO 0x00000100 /* 23: L2DLL rollover checkstop enable. */
649#define L2CR_L2IP 0x00000001 /* 31: L2 global invalidate in */
650 /* progress (read only). */
651#define SPR_L3CR 0x3fa /* .6. L3 Control Register */
652#define L3CR_L3E 0x80000000 /* 0: L3 enable */
653#define L3CR_L3PE 0x40000000 /* 1: L3 data parity enable */
654#define L3CR_L3APE 0x20000000
655#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */
656#define L3CR_L3CLKEN 0x08000000 /* 4: Enables L3_CLK[0:1] */
657#define L3CR_L3CLK 0x03800000
658#define L3CR_L3IO 0x00400000
659#define L3CR_L3CLKEXT 0x00200000
660#define L3CR_L3CKSPEXT 0x00100000
661#define L3CR_L3OH1 0x00080000
662#define L3CR_L3SPO 0x00040000
663#define L3CR_L3CKSP 0x00030000
664#define L3CR_L3PSP 0x0000e000
665#define L3CR_L3REP 0x00001000
666#define L3CR_L3HWF 0x00000800
667#define L3CR_L3I 0x00000400 /* 21: L3 global invalidate */
668#define L3CR_L3RT 0x00000300
669#define L3CR_L3NIRCA 0x00000080
670#define L3CR_L3DO 0x00000040
671#define L3CR_PMEN 0x00000004
672#define L3CR_PMSIZ 0x00000003
673
674#define SPR_THRM1 0x3fc /* .6. Thermal Management Register */
675#define SPR_THRM2 0x3fd /* .6. Thermal Management Register */
676#define SPR_THRM_TIN 0x80000000 /* Thermal interrupt bit (RO) */
677#define SPR_THRM_TIV 0x40000000 /* Thermal interrupt valid (RO) */
678#define SPR_THRM_THRESHOLD(x) ((x) << 23) /* Thermal sensor threshold */
679#define SPR_THRM_TID 0x00000004 /* Thermal interrupt direction */
680#define SPR_THRM_TIE 0x00000002 /* Thermal interrupt enable */
681#define SPR_THRM_VALID 0x00000001 /* Valid bit */
682#define SPR_THRM3 0x3fe /* .6. Thermal Management Register */
683#define SPR_THRM_TIMER(x) ((x) << 1) /* Sampling interval timer */
684#define SPR_THRM_ENABLE 0x00000001 /* TAU Enable */
685#define SPR_FPECR 0x3fe /* .6. Floating-Point Exception Cause Register */
686
687/* Time Base Register declarations */
688#define TBR_TBL 0x10c /* 468 Time Base Lower - read */
689#define TBR_TBU 0x10d /* 468 Time Base Upper - read */
690#define TBR_TBWL 0x11c /* 468 Time Base Lower - supervisor, write */
691#define TBR_TBWU 0x11d /* 468 Time Base Upper - supervisor, write */
692
693/* Performance counter declarations */
694#define PMC_OVERFLOW 0x80000000 /* Counter has overflowed */
695
696/* The first five countable [non-]events are common to many PMC's */
697#define PMCN_NONE 0 /* Count nothing */
698#define PMCN_CYCLES 1 /* Processor cycles */
699#define PMCN_ICOMP 2 /* Instructions completed */
700#define PMCN_TBLTRANS 3 /* TBL bit transitions */
701#define PCMN_IDISPATCH 4 /* Instructions dispatched */
702
703/* Similar things for the 970 PMC direct counters */
704#define PMC970N_NONE 0x8 /* Count nothing */
705#define PMC970N_CYCLES 0xf /* Processor cycles */
706#define PMC970N_ICOMP 0x9 /* Instructions completed */
707
708#if defined(BOOKE)
709
710#define SPR_MCARU 0x239 /* ..8 Machine Check Address register upper bits */
711#define SPR_MCSR 0x23c /* ..8 Machine Check Syndrome register */
712#define MCSR_MCP 0x80000000 /* Machine check input signal to core */
713#define MCSR_L2MMU_MHIT 0x08000000 /* L2 MMU simultaneous hit */
714#define MCSR_NMI 0x00100000 /* Non-maskable interrupt */
715#define MCSR_MAV 0x00080000 /* MCAR address valid */
716#define MCSR_MEA 0x00040000 /* MCAR effective address */
717#define MCSR_IF 0x00010000 /* Instruction fetch error report */
718#define MCSR_LD 0x00008000 /* Load instruction error report */
719#define MCSR_ST 0x00004000 /* Store instruction error report */
720#define MCSR_LDG 0x00002000 /* Guarded load instruction error report */
721#define MCSR_TLBSYNC 0x00000002 /* Simultaneous TLBSYNC detected */
722#define SPR_MCAR 0x23d /* ..8 Machine Check Address register */
723
724#define SPR_ESR 0x003e /* ..8 Exception Syndrome Register */
725#define ESR_PIL 0x08000000 /* Program interrupt - illegal */
726#define ESR_PPR 0x04000000 /* Program interrupt - privileged */
727#define ESR_PTR 0x02000000 /* Program interrupt - trap */
728#define ESR_ST 0x00800000 /* Store operation */
729#define ESR_DLK 0x00200000 /* Data storage, D cache locking */
730#define ESR_ILK 0x00100000 /* Data storage, I cache locking */
731#define ESR_BO 0x00020000 /* Data/instruction storage, byte ordering */
732#define ESR_SPE 0x00000080 /* SPE exception bit */
733
734#define SPR_CSRR0 0x03a /* ..8 58 Critical SRR0 */
735#define SPR_CSRR1 0x03b /* ..8 59 Critical SRR1 */
736#define SPR_MCSRR0 0x23a /* ..8 570 Machine check SRR0 */
737#define SPR_MCSRR1 0x23b /* ..8 571 Machine check SRR1 */
738#define SPR_DSRR0 0x23e /* ..8 574 Debug SRR0<E.ED> */
739#define SPR_DSRR1 0x23f /* ..8 575 Debug SRR1<E.ED> */
740
741#define SPR_MMUCSR0 0x3f4 /* ..8 1012 MMU Control and Status Register 0 */
742#define MMUCSR0_L2TLB0_FI 0x04 /* TLB0 flash invalidate */
743#define MMUCSR0_L2TLB1_FI 0x02 /* TLB1 flash invalidate */
744
745#define SPR_SVR 0x3ff /* ..8 1023 System Version Register */
746#define SVR_MPC8533 0x8034
747#define SVR_MPC8533E 0x803c
748#define SVR_MPC8541 0x8072
749#define SVR_MPC8541E 0x807a
750#define SVR_MPC8548 0x8031
751#define SVR_MPC8548E 0x8039
752#define SVR_MPC8555 0x8071
753#define SVR_MPC8555E 0x8079
754#define SVR_MPC8572 0x80e0
755#define SVR_MPC8572E 0x80e8
756#define SVR_P1011 0x80e5
757#define SVR_P1011E 0x80ed
758#define SVR_P1013 0x80e7
759#define SVR_P1013E 0x80ef
760#define SVR_P1020 0x80e4
761#define SVR_P1020E 0x80ec
762#define SVR_P1022 0x80e6
763#define SVR_P1022E 0x80ee
764#define SVR_P2010 0x80e3
765#define SVR_P2010E 0x80eb
766#define SVR_P2020 0x80e2
767#define SVR_P2020E 0x80ea
768#define SVR_P2041 0x8210
769#define SVR_P2041E 0x8218
770#define SVR_P3041 0x8211
771#define SVR_P3041E 0x8219
772#define SVR_P4040 0x8200
773#define SVR_P4040E 0x8208
774#define SVR_P4080 0x8201
775#define SVR_P4080E 0x8209
776#define SVR_P5010 0x8221
777#define SVR_P5010E 0x8229
778#define SVR_P5020 0x8220
779#define SVR_P5020E 0x8228
780#define SVR_P5021 0x8205
781#define SVR_P5021E 0x820d
782#define SVR_P5040 0x8204
783#define SVR_P5040E 0x820c
784#define SVR_VER(svr) (((svr) >> 16) & 0xffff)
785
786#define SPR_PID0 0x030 /* ..8 Process ID Register 0 */
787#define SPR_PID1 0x279 /* ..8 Process ID Register 1 */
788#define SPR_PID2 0x27a /* ..8 Process ID Register 2 */
789
790#define SPR_TLB0CFG 0x2B0 /* ..8 TLB 0 Config Register */
791#define SPR_TLB1CFG 0x2B1 /* ..8 TLB 1 Config Register */
792#define TLBCFG_ASSOC_MASK 0xff000000 /* Associativity of TLB */
793#define TLBCFG_ASSOC_SHIFT 24
794#define TLBCFG_NENTRY_MASK 0x00000fff /* Number of entries in TLB */
795
796#define SPR_IVPR 0x03f /* ..8 Interrupt Vector Prefix Register */
797#define SPR_IVOR0 0x190 /* ..8 Critical input */
798#define SPR_IVOR1 0x191 /* ..8 Machine check */
799#define SPR_IVOR2 0x192
800#define SPR_IVOR3 0x193
801#define SPR_IVOR4 0x194
802#define SPR_IVOR5 0x195
803#define SPR_IVOR6 0x196
804#define SPR_IVOR7 0x197
805#define SPR_IVOR8 0x198
806#define SPR_IVOR9 0x199
807#define SPR_IVOR10 0x19a
808#define SPR_IVOR11 0x19b
809#define SPR_IVOR12 0x19c
810#define SPR_IVOR13 0x19d
811#define SPR_IVOR14 0x19e
812#define SPR_IVOR15 0x19f
813#define SPR_IVOR32 0x210
814#define SPR_IVOR33 0x211
815#define SPR_IVOR34 0x212
816#define SPR_IVOR35 0x213
817
818#define SPR_MAS0 0x270 /* ..8 MMU Assist Register 0 Book-E/e500 */
819#define SPR_MAS1 0x271 /* ..8 MMU Assist Register 1 Book-E/e500 */
820#define SPR_MAS2 0x272 /* ..8 MMU Assist Register 2 Book-E/e500 */
821#define SPR_MAS3 0x273 /* ..8 MMU Assist Register 3 Book-E/e500 */
822#define SPR_MAS4 0x274 /* ..8 MMU Assist Register 4 Book-E/e500 */
823#define SPR_MAS5 0x275 /* ..8 MMU Assist Register 5 Book-E */
824#define SPR_MAS6 0x276 /* ..8 MMU Assist Register 6 Book-E/e500 */
825#define SPR_MAS7 0x3B0 /* ..8 MMU Assist Register 7 Book-E/e500 */
826#define SPR_MAS8 0x155 /* ..8 MMU Assist Register 8 Book-E/e500 */
827
828#define SPR_L1CFG0 0x203 /* ..8 L1 cache configuration register 0 */
829#define SPR_L1CFG1 0x204 /* ..8 L1 cache configuration register 1 */
830
831#define SPR_CCR1 0x378
832#define CCR1_L2COBE 0x00000040
833
834#define DCR_L2DCDCRAI 0x0000 /* L2 D-Cache DCR Address Pointer */
835#define DCR_L2DCDCRDI 0x0001 /* L2 D-Cache DCR Data Indirect */
836#define DCR_L2CR0 0x00 /* L2 Cache Configuration Register 0 */
837#define L2CR0_AS 0x30000000
838
839#define SPR_L1CSR0 0x3F2 /* ..8 L1 Cache Control and Status Register 0 */
840#define L1CSR0_DCPE 0x00010000 /* Data Cache Parity Enable */
841#define L1CSR0_DCLFR 0x00000100 /* Data Cache Lock Bits Flash Reset */
842#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */
843#define L1CSR0_DCE 0x00000001 /* Data Cache Enable */
844#define SPR_L1CSR1 0x3F3 /* ..8 L1 Cache Control and Status Register 1 */
845#define L1CSR1_ICPE 0x00010000 /* Instruction Cache Parity Enable */
846#define L1CSR1_ICUL 0x00000400 /* Instr Cache Unable to Lock */
847#define L1CSR1_ICLFR 0x00000100 /* Instruction Cache Lock Bits Flash Reset */
848#define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */
849#define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */
850
851#define SPR_L2CFG0 0x207 /* ..8 L2 Configuration Register 0 */
852#define SPR_L2CSR0 0x3F9 /* ..8 L2 Cache Control and Status Register 0 */
853#define L2CSR0_L2E 0x80000000 /* L2 Cache Enable */
854#define L2CSR0_L2PE 0x40000000 /* L2 Cache Parity Enable */
855#define L2CSR0_L2FI 0x00200000 /* L2 Cache Flash Invalidate */
856#define L2CSR0_L2LFC 0x00000400 /* L2 Cache Lock Flags Clear */
857
858#define SPR_BUCSR 0x3F5 /* ..8 Branch Unit Control and Status Register */
859#define BUCSR_BPEN 0x00000001 /* Branch Prediction Enable */
860#define BUCSR_BBFI 0x00000200 /* Branch Buffer Flash Invalidate */
861
862#endif /* BOOKE */
863#endif /* !_POWERPC_SPR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/sr.h deleted-62
......@@ -1,62 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2002 Benno Rice.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_SR_H_
29#define _MACHINE_SR_H_
30
31/*
32 * Bit definitions for segment registers.
33 *
34 * PowerPC Microprocessor Family: The Programming Environments for 32-bit
35 * Microprocessors, section 2.3.5
36 */
37
38#define SR_TYPE 0x80000000 /* Type selector */
39#define SR_KS 0x40000000 /* Supervisor-state protection key */
40#define SR_KP 0x20000000 /* User-state protection key */
41#define SR_N 0x10000000 /* No-execute protection */
42#define SR_VSID_MASK 0x00ffffff /* Virtual Segment ID mask */
43
44/* Kernel segment register usage */
45#define USER_SR 12
46#define KERNEL_SR 13
47#define KERNEL2_SR 14
48#define KERNEL3_SR 15
49#define KERNEL_VSIDBITS 0xfffffUL
50#define KERNEL_SEGMENT (0xfffff0 + KERNEL_SR)
51#define KERNEL2_SEGMENT (0xfffff0 + KERNEL2_SR)
52#define EMPTY_SEGMENT 0xfffff0
53#ifdef __powerpc64__
54#define USER_ADDR 0xc00ffffff0000000UL
55#else
56#define USER_ADDR ((uintptr_t)USER_SR << ADDR_SR_SHFT)
57#endif
58#define SEGMENT_LENGTH 0x10000000UL
59#define SEGMENT_INVMASK 0x0fffffffUL
60#define SEGMENT_MASK ~SEGMENT_INVMASK
61
62#endif /* !_MACHINE_SR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/stack.h deleted-54
......@@ -1,54 +0,0 @@
1/*-
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26
27#ifndef _MACHINE_STACK_H_
28#define _MACHINE_STACK_H_
29
30extern int trapexit[];
31extern int asttrapexit[];
32extern int end[];
33
34#ifdef _SYS_PROC_H_
35
36#include <machine/pcb.h>
37
38/* Get the current kernel thread stack usage. */
39#define GET_STACK_USAGE(total, used) do { \
40 struct thread *td = curthread; \
41 (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
42 (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
43} while (0)
44
45static __inline bool
46kstack_contains(struct thread *td, vm_offset_t va, size_t len)
47{
48 return (va >= td->td_kstack && va + len >= va &&
49 va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
50 sizeof(struct pcb));
51}
52#endif /* _SYS_PROC_H_ */
53
54#endif /* !_MACHINE_STACK_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/sysarch.h+2-40
......@@ -1,43 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1993 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
2 * This file is in the public domain.
303 */
314
32#ifndef _MACHINE_SYSARCH_H_
33#define _MACHINE_SYSARCH_H_
34
35#ifndef _KERNEL
36#include <sys/cdefs.h>
37
38__BEGIN_DECLS
39int sysarch(int, void *);
40__END_DECLS
41#endif
42
43#endif /* !_MACHINE_SYSARCH_H_ */
\ No newline at end of file
5#include <x86/sysarch.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/tlb.h deleted-181
......@@ -1,181 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (C) 2006-2012 Semihalf.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
21 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_TLB_H_
31#define _MACHINE_TLB_H_
32
33#if defined(BOOKE_E500)
34
35/* PowerPC E500 MAS registers */
36#define MAS0_TLBSEL(x) ((x << 28) & 0x10000000)
37#define MAS0_ESEL(x) ((x << 16) & 0x003F0000)
38
39#define MAS0_TLBSEL1 0x10000000
40#define MAS0_TLBSEL0 0x00000000
41#define MAS0_ESEL_TLB1MASK 0x000F0000
42#define MAS0_ESEL_TLB0MASK 0x00030000
43#define MAS0_ESEL_SHIFT 16
44#define MAS0_NV_MASK 0x00000003
45#define MAS0_NV_SHIFT 0
46
47#define MAS1_VALID 0x80000000
48#define MAS1_IPROT 0x40000000
49#define MAS1_TID_MASK 0x00FF0000
50#define MAS1_TID_SHIFT 16
51#define MAS1_TS_MASK 0x00001000
52#define MAS1_TS_SHIFT 12
53#define MAS1_TSIZE_MASK 0x00000F00
54#define MAS1_TSIZE_SHIFT 8
55
56#define TLB_SIZE_4K 1
57#define TLB_SIZE_16K 2
58#define TLB_SIZE_64K 3
59#define TLB_SIZE_256K 4
60#define TLB_SIZE_1M 5
61#define TLB_SIZE_4M 6
62#define TLB_SIZE_16M 7
63#define TLB_SIZE_64M 8
64#define TLB_SIZE_256M 9
65#define TLB_SIZE_1G 10
66#define TLB_SIZE_4G 11
67
68#ifdef __powerpc64__
69#define MAS2_EPN_MASK 0xFFFFFFFFFFFFF000UL
70#else
71#define MAS2_EPN_MASK 0xFFFFF000
72#endif
73#define MAS2_EPN_SHIFT 12
74#define MAS2_X0 0x00000040
75#define MAS2_X1 0x00000020
76#define MAS2_W 0x00000010
77#define MAS2_I 0x00000008
78#define MAS2_M 0x00000004
79#define MAS2_G 0x00000002
80#define MAS2_E 0x00000001
81#define MAS2_WIMGE_MASK 0x0000007F
82
83#define MAS3_RPN 0xFFFFF000
84#define MAS3_RPN_SHIFT 12
85#define MAS3_U0 0x00000200
86#define MAS3_U1 0x00000100
87#define MAS3_U2 0x00000080
88#define MAS3_U3 0x00000040
89#define MAS3_UX 0x00000020
90#define MAS3_SX 0x00000010
91#define MAS3_UW 0x00000008
92#define MAS3_SW 0x00000004
93#define MAS3_UR 0x00000002
94#define MAS3_SR 0x00000001
95
96#define MAS4_TLBSELD1 0x10000000
97#define MAS4_TLBSELD0 0x00000000
98#define MAS4_TIDSELD_MASK 0x00030000
99#define MAS4_TIDSELD_SHIFT 16
100#define MAS4_TSIZED_MASK 0x00000F00
101#define MAS4_TSIZED_SHIFT 8
102#define MAS4_X0D 0x00000040
103#define MAS4_X1D 0x00000020
104#define MAS4_WD 0x00000010
105#define MAS4_ID 0x00000008
106#define MAS4_MD 0x00000004
107#define MAS4_GD 0x00000002
108#define MAS4_ED 0x00000001
109
110#define MAS6_SPID0_MASK 0x00FF0000
111#define MAS6_SPID0_SHIFT 16
112#define MAS6_SAS 0x00000001
113
114#define MAS7_RPN 0x0000000F
115
116#define MAS1_GETTID(mas1) (((mas1) & MAS1_TID_MASK) >> MAS1_TID_SHIFT)
117
118#define MAS2_TLB0_ENTRY_IDX_MASK 0x0007f000
119#define MAS2_TLB0_ENTRY_IDX_SHIFT 12
120
121/*
122 * Maximum number of TLB1 entries used for a permanent mapping of kernel
123 * region (kernel image plus statically allocated data).
124 */
125#define KERNEL_REGION_MAX_TLB_ENTRIES 4
126
127/*
128 * Use MAS2_X0 to mark entries which will be copied
129 * to AP CPUs during SMP bootstrap. As result entries
130 * marked with _TLB_ENTRY_SHARED will be shared by all CPUs.
131 */
132#define _TLB_ENTRY_SHARED (MAS2_X0) /* XXX under SMP? */
133#define _TLB_ENTRY_IO (MAS2_I | MAS2_G)
134#define _TLB_ENTRY_MEM (MAS2_M)
135
136#define TLB1_MAX_ENTRIES 64
137
138#if !defined(LOCORE)
139typedef struct tlb_entry {
140 vm_paddr_t phys;
141 vm_offset_t virt;
142 vm_size_t size;
143 uint32_t mas1;
144#ifdef __powerpc64__
145 uint64_t mas2;
146#else
147 uint32_t mas2;
148#endif
149 uint32_t mas3;
150 uint32_t mas7;
151} tlb_entry_t;
152
153void tlb1_inval_entry(unsigned int);
154void tlb1_init(void);
155#endif /* !LOCORE */
156
157#endif /* BOOKE_E500 */
158
159#define TID_KERNEL 0 /* TLB TID to use for kernel (shared) translations */
160#define TID_KRESERVED 1 /* Number of TIDs reserved for kernel */
161#define TID_URESERVED 0 /* Number of TIDs reserved for user */
162#define TID_MIN (TID_KRESERVED + TID_URESERVED)
163#define TID_MAX 255
164#define TID_NONE -1
165
166#define TLB_UNLOCKED 0
167
168#if !defined(LOCORE)
169
170typedef int tlbtid_t;
171
172struct pmap;
173
174void tlb_lock(uintptr_t *);
175void tlb_unlock(uintptr_t *);
176void tlb1_ap_prep(void);
177int tlb1_set_entry(vm_offset_t, vm_paddr_t, vm_size_t, uint32_t);
178
179#endif /* !LOCORE */
180
181#endif /* _MACHINE_TLB_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/tls.h+2-63
......@@ -1,66 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright 2004 by Peter Grehan. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
2 * This file is in the public domain.
283 */
294
30#ifndef _MACHINE_TLS_H_
31#define _MACHINE_TLS_H_
32
33#include <sys/_tls_variant_i.h>
34
35#define TLS_DTV_OFFSET 0x8000
36#define TLS_TCB_ALIGN TLS_TCB_SIZE
37#define TLS_TP_OFFSET 0x7000
38
39static __inline void
40_tcb_set(struct tcb *tcb)
41{
42#ifdef __powerpc64__
43 __asm __volatile("mr 13,%0" ::
44 "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE));
45#else
46 __asm __volatile("mr 2,%0" ::
47 "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE));
48#endif
49}
50
51static __inline struct tcb *
52_tcb_get(void)
53{
54 struct tcb *tcb;
55
56#ifdef __powerpc64__
57 __asm __volatile("addi %0,13,%1" : "=r" (tcb) :
58 "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE)));
59#else
60 __asm __volatile("addi %0,2,%1" : "=r" (tcb) :
61 "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE)));
62#endif
63 return (tcb);
64}
65
66#endif /* !_MACHINE_TLS_H_ */
\ No newline at end of file
5#include <x86/tls.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/trap.h+2-157
......@@ -1,160 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: trap.h,v 1.7 2002/02/22 13:51:40 kleink Exp $
2 * This file is in the public domain.
343 */
354
36#ifndef _POWERPC_TRAP_H_
37#define _POWERPC_TRAP_H_
38
39#define EXC_RSVD 0x0000 /* Reserved */
40#define EXC_RST 0x0100 /* Reset; all but IBM4xx */
41#define EXC_MCHK 0x0200 /* Machine Check */
42#define EXC_DSI 0x0300 /* Data Storage Interrupt */
43#define EXC_DSE 0x0380 /* Data Segment Interrupt */
44#define EXC_ISI 0x0400 /* Instruction Storage Interrupt */
45#define EXC_ISE 0x0480 /* Instruction Segment Interrupt */
46#define EXC_EXI 0x0500 /* External Interrupt */
47#define EXC_ALI 0x0600 /* Alignment Interrupt */
48#define EXC_PGM 0x0700 /* Program Interrupt */
49#define EXC_FPU 0x0800 /* Floating-point Unavailable */
50#define EXC_DECR 0x0900 /* Decrementer Interrupt */
51#define EXC_SC 0x0c00 /* System Call */
52#define EXC_TRC 0x0d00 /* Trace */
53#define EXC_FPA 0x0e00 /* Floating-point Assist */
54
55/* The following is only available on the 601: */
56#define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */
57
58/* The following are only available on 970(G5): */
59#define EXC_VECAST_G5 0x1700 /* AltiVec Assist */
60
61/* The following are only available on 7400(G4): */
62#define EXC_VEC 0x0f20 /* AltiVec Unavailable */
63#define EXC_VECAST_G4 0x1600 /* AltiVec Assist */
64
65/* The following are only available on 604/750/7400: */
66#define EXC_PERF 0x0f00 /* Performance Monitoring */
67#define EXC_BPT 0x1300 /* Instruction Breakpoint */
68#define EXC_SMI 0x1400 /* System Managment Interrupt */
69
70/* The following are only available on 750/7400: */
71#define EXC_THRM 0x1700 /* Thermal Management Interrupt */
72
73/* And these are only on the 603: */
74#define EXC_IMISS 0x1000 /* Instruction translation miss */
75#define EXC_DLMISS 0x1100 /* Data load translation miss */
76#define EXC_DSMISS 0x1200 /* Data store translation miss */
77
78/* Power ISA 2.06+: */
79#define EXC_HDSI 0x0e00 /* Hypervisor Data Storage */
80#define EXC_HISI 0x0e20 /* Hypervisor Instruction Storage */
81#define EXC_HEA 0x0e40 /* Hypervisor Emulation Assistance */
82#define EXC_HMI 0x0e60 /* Hypervisor Maintenance */
83#define EXC_VSX 0x0f40 /* VSX Unavailable */
84
85/* Power ISA 2.07+: */
86#define EXC_FAC 0x0f60 /* Facility Unavailable */
87#define EXC_HFAC 0x0f80 /* Hypervisor Facility Unavailable */
88
89/* Power ISA 3.0+: */
90#define EXC_HVI 0x0ea0 /* Hypervisor Virtualization */
91
92/* The following are available on 4xx and 85xx */
93#define EXC_CRIT 0x0100 /* Critical Input Interrupt */
94#define EXC_PIT 0x1000 /* Programmable Interval Timer */
95#define EXC_FIT 0x1010 /* Fixed Interval Timer */
96#define EXC_WDOG 0x1020 /* Watchdog Timer */
97#define EXC_DTMISS 0x1100 /* Data TLB Miss */
98#define EXC_ITMISS 0x1200 /* Instruction TLB Miss */
99#define EXC_APU 0x1300 /* Auxiliary Processing Unit */
100#define EXC_DEBUG 0x2f10 /* Debug trap */
101#define EXC_VECAST_E 0x2f20 /* Altivec Assist (Book-E) */
102#define EXC_SPFPD 0x2f30 /* SPE Floating-point Data */
103#define EXC_SPFPR 0x2f40 /* SPE Floating-point Round */
104
105/* POWER8 */
106#define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */
107
108#define EXC_LAST 0x2f00 /* Last possible exception vector */
109
110#define EXC_AST 0x3000 /* Fake AST vector */
111
112/* Trap was in user mode */
113#define EXC_USER 0x10000
114
115/*
116 * EXC_ALI sets bits in the DSISR and DAR to provide enough
117 * information to recover from the unaligned access without needing to
118 * parse the offending instruction. This includes certain bits of the
119 * opcode, and information about what registers are used. The opcode
120 * indicator values below come from Appendix F of Book III of "The
121 * PowerPC Architecture".
122 */
123
124#define EXC_ALI_OPCODE_INDICATOR(dsisr) ((dsisr >> 10) & 0x7f)
125#define EXC_ALI_LFD 0x09
126#define EXC_ALI_STFD 0x0b
127
128/* Macros to extract register information */
129#define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */
130#define EXC_ALI_RA(dsisr) (dsisr & 0x1f)
131#define EXC_ALI_INST_RST(instr) ((instr >> 21) & 0x1f)
132
133/*
134 * SRR1 bits for program exception traps. These identify what caused
135 * the program exception. See section 6.5.9 of the Power ISA Version
136 * 2.05.
137 */
138
139#define EXC_PGM_FPENABLED (1UL << 20)
140#define EXC_PGM_ILLEGAL (1UL << 19)
141#define EXC_PGM_PRIV (1UL << 18)
142#define EXC_PGM_TRAP (1UL << 17)
143
144/* DTrace trap opcode. */
145#define EXC_DTRACE 0x7ffff808
146
147/* Magic pointer to store TOC base and other info for trap handlers on ppc64 */
148#define TRAP_ENTRY 0x1e8
149#define TRAP_GENTRAP 0x1f0
150#define TRAP_TOCBASE 0x1f8
151
152#ifndef LOCORE
153struct trapframe;
154struct thread;
155extern int (*hmi_handler)(struct trapframe *);
156void trap(struct trapframe *);
157int ppc_instr_emulate(struct trapframe *, struct thread *);
158#endif
159
160#endif /* _POWERPC_TRAP_H_ */
\ No newline at end of file
5#include <x86/trap.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/ucontext.h deleted-91
......@@ -1,91 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $
34 */
35
36#ifndef _MACHINE_UCONTEXT_H_
37#define _MACHINE_UCONTEXT_H_
38
39typedef struct __mcontext {
40 int mc_vers;
41 int mc_flags;
42#define _MC_FP_VALID 0x01
43#define _MC_AV_VALID 0x02
44 int mc_onstack; /* saved onstack flag */
45 int mc_len; /* sizeof(__mcontext) */
46 __uint64_t mc_avec[32*2]; /* vector register file */
47 __uint32_t mc_av[2];
48 __register_t mc_frame[42];
49 __uint64_t mc_fpreg[33];
50 __uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */
51} mcontext_t __aligned(16);
52
53#if defined(_KERNEL) && defined(__powerpc64__)
54typedef struct __mcontext32 {
55 int mc_vers;
56 int mc_flags;
57#define _MC_FP_VALID 0x01
58#define _MC_AV_VALID 0x02
59 int mc_onstack; /* saved onstack flag */
60 int mc_len; /* sizeof(__mcontext) */
61 uint64_t mc_avec[32*2]; /* vector register file */
62 uint32_t mc_av[2];
63 uint32_t mc_frame[42];
64 uint64_t mc_fpreg[33];
65 uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */
66} mcontext32_t __aligned(16);
67#endif
68
69/* GPRs and supervisor-level regs */
70#define mc_gpr mc_frame
71#define mc_lr mc_frame[32]
72#define mc_cr mc_frame[33]
73#define mc_xer mc_frame[34]
74#define mc_ctr mc_frame[35]
75#define mc_srr0 mc_frame[36]
76#define mc_srr1 mc_frame[37]
77#define mc_exc mc_frame[38]
78#define mc_dar mc_frame[39]
79#define mc_dsisr mc_frame[40]
80
81/* floating-point state */
82#define mc_fpscr mc_fpreg[32]
83
84/* altivec state */
85#define mc_vscr mc_av[0]
86#define mc_vrsave mc_av[1]
87
88#define _MC_VERSION 0x1
89#define _MC_VERSION_KSE 0xee /* partial ucontext for libpthread */
90
91#endif /* !_MACHINE_UCONTEXT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/vdso.h+2-40
......@@ -1,43 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright 2012 Konstantin Belousov <kib@FreeBSD.ORG>.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 * This file is in the public domain.
263 */
274
28#ifndef _POWERPC_VDSO_H
29#define _POWERPC_VDSO_H
30
31#define VDSO_TIMEHANDS_MD \
32 uint32_t th_res[8];
33
34#define VDSO_TH_ALGO_PPC_TB VDSO_TH_ALGO_1
35
36#ifdef _KERNEL
37#ifdef COMPAT_FREEBSD32
38
39#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD
40
41#endif
42#endif
43#endif
\ No newline at end of file
5#include <x86/vdso.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/vm.h+11-10
......@@ -1,7 +1,8 @@
11/*-
22 * SPDX-License-Identifier: BSD-2-Clause
33 *
4 * Copyright (c) 2009 Alan L. Cox <alc@cs.rice.edu>
4 * Copyright (c) 2009 Hudson River Trading LLC
5 * Written by: John H. Baldwin <jhb@FreeBSD.org>
56 * All rights reserved.
67 *
78 * Redistribution and use in source and binary forms, with or without
......@@ -29,17 +30,17 @@
2930#ifndef _MACHINE_VM_H_
3031#define _MACHINE_VM_H_
3132
32#include <machine/pte.h>
33#include <machine/specialreg.h>
3334
3435/* Memory attributes. */
35#define VM_MEMATTR_DEFAULT 0
36#define VM_MEMATTR_UNCACHEABLE 0x01
37#define VM_MEMATTR_CACHEABLE 0x02
38#define VM_MEMATTR_WRITE_COMBINING 0x04
39#define VM_MEMATTR_WRITE_BACK 0x08
40#define VM_MEMATTR_WRITE_THROUGH 0x10
41#define VM_MEMATTR_PREFETCHABLE 0x20
36#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE)
37#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING)
38#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH)
39#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED)
40#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK)
41#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED)
4242
43#define VM_MEMATTR_DEVICE VM_MEMATTR_DEFAULT
43#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
44#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE
4445
4546#endif /* !_MACHINE_VM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/vmm_snapshot.h created+1
......@@ -0,0 +1 @@
1/* $FreeBSD$ */
\ No newline at end of file
lib/libc/include/generic-freebsd/machine/vmparam.h deleted-329
......@@ -1,329 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $
34 */
35
36#ifndef _MACHINE_VMPARAM_H_
37#define _MACHINE_VMPARAM_H_
38
39#ifndef LOCORE
40#include <machine/md_var.h>
41#endif
42
43#define USRSTACK SHAREDPAGE
44
45#ifndef MAXTSIZ
46#define MAXTSIZ (1*1024*1024*1024) /* max text size */
47#endif
48
49#ifndef DFLDSIZ
50#define DFLDSIZ (128*1024*1024) /* default data size */
51#endif
52
53#ifndef MAXDSIZ
54#ifdef __powerpc64__
55#define MAXDSIZ (32UL*1024*1024*1024) /* max data size */
56#else
57#define MAXDSIZ (1*1024*1024*1024) /* max data size */
58#endif
59#endif
60
61#ifndef DFLSSIZ
62#define DFLSSIZ (8*1024*1024) /* default stack size */
63#endif
64
65#ifndef MAXSSIZ
66#ifdef __powerpc64__
67#define MAXSSIZ (512*1024*1024) /* max stack size */
68#else
69#define MAXSSIZ (64*1024*1024) /* max stack size */
70#endif
71#endif
72
73#ifdef AIM
74#define VM_MAXUSER_ADDRESS32 0xfffff000
75#else
76#define VM_MAXUSER_ADDRESS32 0x7ffff000
77#endif
78
79/*
80 * Would like to have MAX addresses = 0, but this doesn't (currently) work
81 */
82#ifdef __powerpc64__
83/*
84 * Virtual addresses of things. Derived from the page directory and
85 * page table indexes from pmap.h for precision.
86 *
87 * kernel map should be able to start at 0xc008000000000000 -
88 * but at least the functional simulator doesn't like it
89 *
90 * 0x0000000000000000 - 0x000fffffffffffff user map
91 * 0xc000000000000000 - 0xc007ffffffffffff direct map
92 * 0xc008000000000000 - 0xc00fffffffffffff kernel map
93 *
94 */
95#define VM_MIN_ADDRESS 0x0000000000000000
96#define VM_MAXUSER_ADDRESS 0x000fffffc0000000
97#define VM_MAX_ADDRESS 0xc00fffffffffffff
98#define VM_MIN_KERNEL_ADDRESS 0xc008000000000000
99#define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff
100#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
101#else
102#define VM_MIN_ADDRESS 0
103#define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32
104#define VM_MAX_ADDRESS 0xffffffff
105#endif
106
107#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
108
109#define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
110#define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE
111
112#define KERNBASE 0x00100100 /* start of kernel virtual */
113
114#ifdef AIM
115#ifndef __powerpc64__
116#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
117#define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
118#define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
119#endif
120
121/*
122 * Use the direct-mapped BAT registers for UMA small allocs. This
123 * takes pressure off the small amount of available KVA.
124 */
125#define UMA_MD_SMALL_ALLOC
126
127#else /* Book-E */
128
129/* Use the direct map for UMA small allocs on powerpc64. */
130#ifdef __powerpc64__
131#define UMA_MD_SMALL_ALLOC
132#else
133#define VM_MIN_KERNEL_ADDRESS 0xc0000000
134#define VM_MAX_KERNEL_ADDRESS 0xffffefff
135#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
136#endif
137
138#endif /* AIM/E500 */
139
140#if !defined(LOCORE)
141struct pmap_physseg {
142 struct pv_entry *pvent;
143 char *attrs;
144};
145#endif
146
147#ifdef __powerpc64__
148#define VM_PHYSSEG_MAX 63 /* 1? */
149#else
150#define VM_PHYSSEG_MAX 16 /* 1? */
151#endif
152
153#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with
154 * logical memory block size of 64MB.
155 * For more Ram increase the lmb or this value.
156 */
157
158/* XXX This is non-sensical. Phys avail should hold contiguous regions. */
159#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ
160
161/*
162 * The physical address space is densely populated on 32-bit systems,
163 * but may not be on 64-bit ones.
164 */
165#ifdef __powerpc64__
166#define VM_PHYSSEG_SPARSE
167#else
168#define VM_PHYSSEG_DENSE
169#endif
170
171/*
172 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
173 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
174 * the pool from which physical pages for small UMA objects are
175 * allocated.
176 */
177#define VM_NFREEPOOL 2
178#define VM_FREEPOOL_DEFAULT 0
179#define VM_FREEPOOL_DIRECT 1
180
181/*
182 * Create one free page list.
183 */
184#define VM_NFREELIST 1
185#define VM_FREELIST_DEFAULT 0
186
187#ifdef __powerpc64__
188/* The largest allocation size is 16MB. */
189#define VM_NFREEORDER 13
190#else
191/* The largest allocation size is 4MB. */
192#define VM_NFREEORDER 11
193#endif
194
195#ifndef VM_NRESERVLEVEL
196#ifdef __powerpc64__
197/* Enable superpage reservations: 1 level. */
198#define VM_NRESERVLEVEL 1
199#else
200/* Disable superpage reservations. */
201#define VM_NRESERVLEVEL 0
202#endif
203#endif
204
205#ifndef VM_LEVEL_0_ORDER
206/* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */
207#define VM_LEVEL_0_ORDER vm_level_0_order
208#ifndef __ASSEMBLER__
209extern int vm_level_0_order;
210#endif
211#endif
212
213#ifndef VM_LEVEL_0_ORDER_MAX
214#define VM_LEVEL_0_ORDER_MAX 12
215#endif
216
217#ifdef __powerpc64__
218#ifdef SMP
219#define PA_LOCK_COUNT 256
220#endif
221#endif
222
223#ifndef VM_INITIAL_PAGEIN
224#define VM_INITIAL_PAGEIN 16
225#endif
226
227#ifndef SGROWSIZ
228#define SGROWSIZ (128UL*1024) /* amount to grow stack */
229#endif
230
231/*
232 * How many physical pages per kmem arena virtual page.
233 */
234#ifndef VM_KMEM_SIZE_SCALE
235#define VM_KMEM_SIZE_SCALE (3)
236#endif
237
238/*
239 * Optional floor (in bytes) on the size of the kmem arena.
240 */
241#ifndef VM_KMEM_SIZE_MIN
242#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
243#endif
244
245/*
246 * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
247 * usable KVA space.
248 */
249#ifndef VM_KMEM_SIZE_MAX
250#define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \
251 VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
252#endif
253
254#ifdef __powerpc64__
255#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
256#else
257#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
258#endif
259
260/*
261 * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
262 * an opaque pointer required by the machine-independent parts of the kernel.
263 * That pointer references the vm_page that is "mapped" by the sf_buf. The
264 * actual mapping is provided by the direct virtual-to-physical mapping.
265 *
266 * On OEA64 and Book-E, we need to do something a little more complicated. Use
267 * the runtime-detected hw_direct_map to pick between the two cases. Our
268 * friends in vm_machdep.c will do the same to ensure nothing gets confused.
269 */
270#define SFBUF
271#define SFBUF_NOMD
272
273/*
274 * We (usually) have a direct map of all physical memory, so provide
275 * a macro to use to get the kernel VA address for a given PA. Check the
276 * value of PMAP_HAS_PMAP before using.
277 */
278#ifndef LOCORE
279#ifdef __powerpc64__
280#define DMAP_BASE_ADDRESS 0xc000000000000000UL
281#define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS
282#define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL
283#else
284#define DMAP_BASE_ADDRESS 0x00000000UL
285#define DMAP_MAX_ADDRESS 0xbfffffffUL
286#endif
287#endif
288
289#if defined(__powerpc64__) || defined(BOOKE)
290/*
291 * powerpc64 and Book-E will provide their own page array allocators.
292 *
293 * On AIM, this will allocate a single virtual array, with pages from the
294 * correct memory domains.
295 * On Book-E this will let us put the array in TLB1, removing the need for TLB
296 * thrashing.
297 *
298 * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver.
299 */
300#define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS
301#define PMAP_HAS_PAGE_ARRAY 1
302#endif
303
304#if defined(__powerpc64__)
305/*
306 * Need a page dump array for minidump.
307 */
308#define MINIDUMP_PAGE_TRACKING 1
309#else
310/*
311 * No minidump with 32-bit powerpc.
312 */
313#define MINIDUMP_PAGE_TRACKING 0
314#endif
315
316#define PMAP_HAS_DMAP (hw_direct_map)
317#define PHYS_TO_DMAP(x) ({ \
318 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \
319 (x) | DMAP_BASE_ADDRESS; })
320#define DMAP_TO_PHYS(x) ({ \
321 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \
322 (x) &~ DMAP_BASE_ADDRESS; })
323
324/*
325 * No non-transparent large page support in the pmap.
326 */
327#define PMAP_HAS_LARGEPAGES 0
328
329#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/math.h+24-13
......@@ -10,12 +10,12 @@
1010 */
1111
1212/*
13 * from: @(#)fdlibm.h 5.1 93/09/24
1413 */
1514
1615#ifndef _MATH_H_
1716#define _MATH_H_
1817
18#include <sys/cdefs.h>
1919#include <sys/_types.h>
2020#include <machine/_limits.h>
2121
......@@ -32,13 +32,8 @@ extern const union __nan_un {
3232 float __uf;
3333} __nan;
3434
35#if __GNUC_PREREQ__(3, 3)
3635#define __MATH_BUILTIN_CONSTANTS
37#endif
38
39#if __GNUC_PREREQ__(3, 0)
4036#define __MATH_BUILTIN_RELOPS
41#endif
4237
4338#ifdef __MATH_BUILTIN_CONSTANTS
4439#define HUGE_VAL __builtin_huge_val()
......@@ -77,10 +72,10 @@ extern const union __nan_un {
7772
7873#if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections)
7974#define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \
80 float: f(x), \
81 double: d(x), \
82 long double: ld(x))
83#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
75 float: f, \
76 double: d, \
77 long double: ld)(x)
78#elif !defined(__cplusplus)
8479#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
8580 __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
8681 __builtin_choose_expr( \
......@@ -143,6 +138,22 @@ typedef __float_t float_t;
143138#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
144139#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
145140
141#if __BSD_VISIBLE || __XSI_VISIBLE >= 800
142#define M_El 2.718281828459045235360287471352662498L /* e */
143#define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */
144#define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */
145#define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */
146#define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */
147#define M_PIl 3.141592653589793238462643383279502884L /* pi */
148#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
149#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
150#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
151#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
152#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
153#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
154#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
155#endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 800 */
156
146157#define MAXFLOAT ((float)3.40282346638528860e+38)
147158extern int signgam;
148159#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
......@@ -182,21 +193,21 @@ int __signbitf(float) __pure2;
182193int __signbitl(long double) __pure2;
183194
184195static __inline int
185__inline_isnan(__const double __x)
196__inline_isnan(const double __x)
186197{
187198
188199 return (__x != __x);
189200}
190201
191202static __inline int
192__inline_isnanf(__const float __x)
203__inline_isnanf(const float __x)
193204{
194205
195206 return (__x != __x);
196207}
197208
198209static __inline int
199__inline_isnanl(__const long double __x)
210__inline_isnanl(const long double __x)
200211{
201212
202213 return (__x != __x);
lib/libc/include/generic-freebsd/memory.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)memory.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#include <string.h>
\ No newline at end of file
lib/libc/include/generic-freebsd/mntopts.h created+114
......@@ -0,0 +1,114 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MNTOPTS_H_
33#define _MNTOPTS_H_
34
35struct mntopt {
36 const char *m_option; /* option name */
37 int m_inverse; /* if a negative option, e.g. "atime" */
38 long long m_flag; /* bit to set, e.g. MNT_RDONLY */
39 int m_altloc; /* 1 => set bit in altflags */
40};
41
42/* User-visible MNT_ flags. */
43#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 }
44#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 }
45#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 }
46#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 }
47#define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 }
48#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 }
49#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 }
50#define MOPT_UNION { "union", 0, MNT_UNION, 0 }
51#define MOPT_USERQUOTA { "userquota", 0, 0, 0 }
52#define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 }
53#define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 }
54#define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 }
55#define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 }
56#define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 }
57#define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 }
58#define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 }
59#define MOPT_NFS4ACLS { "nfsv4acls", 0, MNT_NFS4ACLS, 0 }
60#define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 }
61#define MOPT_UNTRUSTED { "untrusted", 0, MNT_UNTRUSTED, 0 }
62
63/* Control flags. */
64#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
65#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
66#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
67#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
68#define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 }
69#define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 }
70/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
71#define MOPT_AUTO { "auto", 0, 0, 0 }
72
73/* A handy macro as terminator of MNT_ array. */
74#define MOPT_END { NULL, 0, 0, 0 }
75
76#define MOPT_FSTAB_COMPAT \
77 MOPT_RO, \
78 MOPT_RW, \
79 MOPT_AUTO
80
81/* Standard options which all mounts can understand. */
82#define MOPT_STDOPTS \
83 MOPT_USERQUOTA, \
84 MOPT_GROUPQUOTA, \
85 MOPT_FSTAB_COMPAT, \
86 MOPT_NOATIME, \
87 MOPT_NOEXEC, \
88 MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \
89 MOPT_NOSUID, \
90 MOPT_NOSYMFOLLOW, \
91 MOPT_RDONLY, \
92 MOPT_UNION, \
93 MOPT_NOCLUSTERR, \
94 MOPT_NOCLUSTERW, \
95 MOPT_MULTILABEL, \
96 MOPT_ACLS, \
97 MOPT_NFS4ACLS, \
98 MOPT_AUTOMOUNTED, \
99 MOPT_UNTRUSTED, \
100 MOPT_NOCOVER, \
101 MOPT_EMPTYDIR
102
103void getmntopts(const char *, const struct mntopt *, int *, int *);
104void rmslashes(char *, char *);
105int checkpath(const char *, char resolved_path[]);
106int checkpath_allow_file(const char *, char resolved_path[]);
107struct statfs *getmntpoint(const char *);
108int chkdoreload(struct statfs *, void (*)(const char *, ...) __printflike(1,2));
109extern int getmnt_silent;
110void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len);
111void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...);
112void free_iovec(struct iovec **iovec, int *iovlen);
113
114#endif /* !_MNTOPTS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/mpool.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)mpool.h 8.4 (Berkeley) 11/2/95
3230 */
3331
3432#ifndef _MPOOL_H_
lib/libc/include/generic-freebsd/mqueue.h-1
......@@ -29,7 +29,6 @@
2929#ifndef _MQUEUE_H_
3030#define _MQUEUE_H_
3131
32#include <sys/cdefs.h>
3332#include <sys/types.h>
3433#include <sys/mqueue.h>
3534#include <sys/signal.h>
lib/libc/include/generic-freebsd/ndbm.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)ndbm.h 8.1 (Berkeley) 6/2/93
3533 */
3634
3735#ifndef _NDBM_H_
lib/libc/include/generic-freebsd/net/altq/altq_rmclass.h-2
......@@ -38,8 +38,6 @@
3838
3939#include <net/altq/altq_classq.h>
4040
41/* #pragma ident "@(#)rm_class.h 1.20 97/10/23 SMI" */
42
4341#ifdef __cplusplus
4442extern "C" {
4543#endif
lib/libc/include/generic-freebsd/net/altq/altq_rmclass_debug.h-2
......@@ -33,8 +33,6 @@
3333#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_
3434#define _ALTQ_ALTQ_RMCLASS_DEBUG_H_
3535
36/* #pragma ident "@(#)rm_class_debug.h 1.7 98/05/04 SMI" */
37
3836/*
3937 * Cbq debugging macros
4038 */
lib/libc/include/generic-freebsd/net/bpf.h+2-3
......@@ -32,14 +32,12 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)bpf.h 8.1 (Berkeley) 6/10/93
37 * @(#)bpf.h 1.34 (LBL) 6/16/96
3835 */
3936
4037#ifndef _NET_BPF_H_
4138#define _NET_BPF_H_
4239
40#include <sys/types.h>
4341#include <sys/_eventhandler.h>
4442#include <sys/ck.h>
4543#include <net/dlt.h>
......@@ -431,6 +429,7 @@ void bpfdetach(struct ifnet *);
431429bool bpf_peers_present_if(struct ifnet *);
432430#ifdef VIMAGE
433431int bpf_get_bp_params(struct bpf_if *, u_int *, u_int *);
432void bpf_ifdetach(struct ifnet *);
434433#endif
435434
436435void bpfilterattach(int);
lib/libc/include/generic-freebsd/net/bpfdesc.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93
3735 */
3836
3937#ifndef _NET_BPFDESC_H_
lib/libc/include/generic-freebsd/net/dlt.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)bpf.h 7.1 (Berkeley) 5/7/91
3533 */
3634
3735#ifndef _NET_DLT_H_
lib/libc/include/generic-freebsd/net/ethernet.h+28-1
......@@ -40,7 +40,6 @@
4040/*
4141 * Ethernet-specific mbuf flags.
4242 */
43#define M_HASFCS M_PROTO5 /* FCS included at end of frame */
4443#define M_BRIDGE_INJECT M_PROTO6 /* if_bridge-injected frame */
4544
4645/*
......@@ -63,6 +62,8 @@ struct ether_header {
6362 u_char ether_shost[ETHER_ADDR_LEN];
6463 u_short ether_type;
6564} __packed;
65_Static_assert(sizeof(struct ether_header) == ETHER_HDR_LEN,
66 "size of struct ether_header is wrong");
6667
6768/*
6869 * Structure of a 48-bit Ethernet address.
......@@ -70,6 +71,8 @@ struct ether_header {
7071struct ether_addr {
7172 u_char octet[ETHER_ADDR_LEN];
7273} __packed;
74_Static_assert(sizeof(struct ether_addr) == ETHER_ADDR_LEN,
75 "size of struct ether_addr is wrong");
7376
7477#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
7578#define ETHER_IS_IPV6_MULTICAST(addr) \
......@@ -81,6 +84,28 @@ struct ether_addr {
8184 (((addr)[0] | (addr)[1] | (addr)[2] | \
8285 (addr)[3] | (addr)[4] | (addr)[5]) == 0x00)
8386
87/*
88 * 802.1q VID constants from IEEE 802.1Q-2014, table 9-2.
89 */
90
91/* Null VID: The tag contains only PCP (priority) and DEI information. */
92#define DOT1Q_VID_NULL 0x0
93/* The default PVID for a bridge port. NB: bridge(4) does not honor this. */
94#define DOT1Q_VID_DEF_PVID 0x1
95/* The default SR_PVID for SRP Stream related traffic. */
96#define DOT1Q_VID_DEF_SR_PVID 0x2
97/* A VID reserved for implementation use, not permitted on the wire. */
98#define DOT1Q_VID_RSVD_IMPL 0xfff
99/* The lowest valid VID. */
100#define DOT1Q_VID_MIN 0x1
101/* The highest valid VID. */
102#define DOT1Q_VID_MAX 0xffe
103
104/*
105 * This is the type of the VLAN ID inside the tag, not the tag itself.
106 */
107typedef uint16_t ether_vlanid_t;
108
84109/*
85110 * 802.1q Virtual LAN header.
86111 */
......@@ -91,6 +116,8 @@ struct ether_vlan_header {
91116 uint16_t evl_tag;
92117 uint16_t evl_proto;
93118} __packed;
119_Static_assert(sizeof(struct ether_vlan_header) == ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN,
120 "size of struct ether_vlan_header is wrong");
94121
95122#define EVL_VLID_MASK 0x0FFF
96123#define EVL_PRI_MASK 0xE000
lib/libc/include/generic-freebsd/net/if.h+3-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)if.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IF_H_
......@@ -257,7 +255,8 @@ struct if_data {
257255#define IFCAP_B_TXTLS_RTLMT 31 /* can do TLS with rate limiting */
258256#define IFCAP_B_RXTLS4 32 /* can to TLS receive for TCP */
259257#define IFCAP_B_RXTLS6 33 /* can to TLS receive for TCP6 */
260#define __IFCAP_B_SIZE 34
258#define IFCAP_B_IPSEC_OFFLOAD 34 /* inline IPSEC offload */
259#define __IFCAP_B_SIZE 35
261260
262261#define IFCAP_B_MAX (__IFCAP_B_MAX - 1)
263262#define IFCAP_B_SIZE (__IFCAP_B_SIZE)
......@@ -300,6 +299,7 @@ struct if_data {
300299/* IFCAP2_* are integers, not bits. */
301300#define IFCAP2_RXTLS4 (IFCAP_B_RXTLS4 - 32)
302301#define IFCAP2_RXTLS6 (IFCAP_B_RXTLS6 - 32)
302#define IFCAP2_IPSEC_OFFLOAD (IFCAP_B_IPSEC_OFFLOAD - 32)
303303
304304#define IFCAP2_BIT(x) (1UL << (x))
305305
lib/libc/include/generic-freebsd/net/if_arp.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)if_arp.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IF_ARP_H_
lib/libc/include/generic-freebsd/net/if_bridgevar.h+58-5
......@@ -74,7 +74,12 @@
7474 * Data structure and control definitions for bridge interfaces.
7575 */
7676
77#ifndef _NET_IF_BRIDGEVAR_H_
78#define _NET_IF_BRIDGEVAR_H_
79
7780#include <sys/types.h>
81#include <sys/_bitset.h>
82#include <sys/bitset.h>
7883#include <sys/callout.h>
7984#include <sys/queue.h>
8085#include <sys/condvar.h>
......@@ -119,6 +124,22 @@
119124#define BRDGSPROTO 28 /* set protocol (ifbrparam) */
120125#define BRDGSTXHC 29 /* set tx hold count (ifbrparam) */
121126#define BRDGSIFAMAX 30 /* set max interface addrs (ifbreq) */
127#define BRDGSIFPVID 31 /* set if PVID */
128#define BRDGSIFVLANSET 32 /* set if vlan set */
129#define BRDGGIFVLANSET 33 /* get if vlan set */
130#define BRDGGFLAGS 34 /* get bridge flags (ifbrparam) */
131#define BRDGSFLAGS 35 /* set bridge flags (ifbrparam) */
132#define BRDGGDEFPVID 36 /* get default pvid (ifbrparam) */
133#define BRDGSDEFPVID 37 /* set default pvid (ifbrparam) */
134#define BRDGSIFVLANPROTO 38 /* set if vlan protocol (ifbreq) */
135
136/* BRDGSFLAGS, Bridge flags (non-interface-specific) */
137typedef uint32_t ifbr_flags_t;
138
139#define IFBRF_VLANFILTER (1U<<0) /* VLAN filtering enabled */
140#define IFBRF_DEFQINQ (1U<<1) /* 802.1ad Q-in-Q allowed by default */
141
142#define IFBRFBITS "\020\01VLANFILTER\02DEFQINQ"
122143
123144/*
124145 * Generic bridge control request.
......@@ -136,7 +157,9 @@ struct ifbreq {
136157 uint32_t ifbr_addrcnt; /* member if addr number */
137158 uint32_t ifbr_addrmax; /* member if addr max */
138159 uint32_t ifbr_addrexceeded; /* member if addr violations */
139 uint8_t pad[32];
160 ether_vlanid_t ifbr_pvid; /* member if PVID */
161 uint16_t ifbr_vlanproto; /* member if VLAN protocol */
162 uint8_t pad[28];
140163};
141164
142165/* BRDGGIFFLAGS, BRDGSIFFLAGS */
......@@ -152,10 +175,11 @@ struct ifbreq {
152175#define IFBIF_BSTP_ADMEDGE 0x0200 /* member stp admin edge enabled */
153176#define IFBIF_BSTP_ADMCOST 0x0400 /* member stp admin path cost */
154177#define IFBIF_PRIVATE 0x0800 /* if is a private segment */
178#define IFBIF_QINQ 0x1000 /* if allows 802.1ad Q-in-Q */
155179
156180#define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \
157181 "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \
158 "\011AUTOPTP"
182 "\011AUTOPTP\015QINQ"
159183#define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \
160184 IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \
161185 IFBIF_BSTP_ADMCOST) /* not saved */
......@@ -185,7 +209,7 @@ struct ifbareq {
185209 unsigned long ifba_expire; /* address expire time */
186210 uint8_t ifba_flags; /* address flags */
187211 uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */
188 uint16_t ifba_vlan; /* vlan id */
212 ether_vlanid_t ifba_vlan; /* vlan id */
189213};
190214
191215#define IFBAF_TYPEMASK 0x03 /* address type mask */
......@@ -227,7 +251,11 @@ struct ifbrparam {
227251#define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */
228252#define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */
229253#define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32 /* # of cache dropped
230 * adresses */
254 * addresses */
255#define ifbrp_flags ifbrp_ifbrpu.ifbrpu_int32 /* bridge flags */
256#define ifbrp_defpvid ifbrp_ifbrpu.ifbrpu_int16 /* default pvid */
257#define ifbrp_vlanproto ifbrp_ifbrpu.ifbrpu_int8 /* vlan protocol */
258
231259/*
232260 * Bridge current operational parameters structure.
233261 */
......@@ -301,6 +329,26 @@ struct ifbpstpconf {
301329 eaddr[5] = pv >> 0; \
302330} while (0)
303331
332/*
333 * Bridge VLAN access request.
334 */
335#define BRVLAN_SETSIZE 4096
336typedef __BITSET_DEFINE(ifbvlan_set, BRVLAN_SETSIZE) ifbvlan_set_t;
337
338#define BRVLAN_SET(set, bit) __BIT_SET(BRVLAN_SETSIZE, (bit), set)
339#define BRVLAN_CLR(set, bit) __BIT_CLR(BRVLAN_SETSIZE, (bit), set)
340#define BRVLAN_TEST(set, bit) __BIT_ISSET(BRVLAN_SETSIZE, (bit), set)
341
342#define BRDG_VLAN_OP_SET 1 /* replace current vlan set */
343#define BRDG_VLAN_OP_ADD 2 /* add vlans to current set */
344#define BRDG_VLAN_OP_DEL 3 /* remove vlans from current set */
345
346struct ifbif_vlan_req {
347 char bv_ifname[IFNAMSIZ];
348 uint8_t bv_op;
349 ifbvlan_set_t bv_set;
350};
351
304352#ifdef _KERNEL
305353
306354#define BRIDGE_INPUT(_ifp, _m) do { \
......@@ -320,5 +368,10 @@ struct ifbpstpconf {
320368} while (0)
321369
322370extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *);
371extern bool (*bridge_same_p)(const void *, const void *);
372extern void *(*bridge_get_softc_p)(struct ifnet *);
373extern bool (*bridge_member_ifaddrs_p)(void);
374
375#endif /* _KERNEL */
323376
324#endif /* _KERNEL */
\ No newline at end of file
377#endif /* _NET_IF_BRIDGEVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_clone.h+1-4
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IF_CLONE_H_
......@@ -150,13 +148,12 @@ typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);
150148EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
151149
152150/* The below interfaces used only by net/if.c. */
153void vnet_if_clone_init(void);
154151int if_clone_create(char *, size_t, caddr_t);
155152int if_clone_destroy(const char *);
156153int if_clone_list(struct if_clonereq *);
157154void if_clone_restoregroup(struct ifnet *);
158155
159/* The below interfaces are used only by epair(4). */
156/* The below interfaces are used only by epair(4) and tun(4)/tap(4). */
160157void if_clone_addif(struct if_clone *, struct ifnet *);
161158int if_clone_destroyif(struct if_clone *, struct ifnet *);
162159
lib/libc/include/generic-freebsd/net/if_dl.h+11-8
......@@ -27,13 +27,13 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)if_dl.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IF_DL_H_
3533#define _NET_IF_DL_H_
3634
35#include <sys/_types.h>
36
3737/*
3838 * A Link-Level Sockaddr may specify the interface in one of two
3939 * ways: either by means of a system-provided index number (computed
......@@ -67,22 +67,25 @@ struct sockaddr_dl {
6767 contains both if name and ll address */
6868};
6969
70#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
71#define CLLADDR(s) ((c_caddr_t)((s)->sdl_data + (s)->sdl_nlen))
70#define LLADDR(s) (&(s)->sdl_data[(s)->sdl_nlen])
7271#define LLINDEX(s) ((s)->sdl_index)
7372
73#ifdef _KERNEL
74
7475struct ifnet;
75struct sockaddr_dl *link_alloc_sdl(size_t, int);
76struct sockaddr_dl *link_alloc_sdl(size_t size, int flags);
7677void link_free_sdl(struct sockaddr *sa);
77struct sockaddr_dl *link_init_sdl(struct ifnet *, struct sockaddr *, u_char);
78struct sockaddr_dl *link_init_sdl(struct ifnet *ifp, struct sockaddr *paddr,
79 u_char iftypes);
7880
79#ifndef _KERNEL
81#else /* !_KERNEL */
8082
8183#include <sys/cdefs.h>
8284
8385__BEGIN_DECLS
84void link_addr(const char *, struct sockaddr_dl *);
86int link_addr(const char *, struct sockaddr_dl *);
8587char *link_ntoa(const struct sockaddr_dl *);
88int link_ntoa_r(const struct sockaddr_dl *, char *, size_t *);
8689__END_DECLS
8790
8891#endif /* !_KERNEL */
lib/libc/include/generic-freebsd/net/if_gif.h+2-1
......@@ -120,7 +120,8 @@ int in6_gif_setopts(struct gif_softc *, u_int);
120120#define GIFGOPTS _IOWR('i', 150, struct ifreq)
121121#define GIFSOPTS _IOW('i', 151, struct ifreq)
122122
123#define GIF_NOCLAMP 0x0001
123124#define GIF_IGNORE_SOURCE 0x0002
124#define GIF_OPTMASK (GIF_IGNORE_SOURCE)
125#define GIF_OPTMASK (GIF_NOCLAMP|GIF_IGNORE_SOURCE)
125126
126127#endif /* _NET_IF_GIF_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_llc.h-2
......@@ -29,8 +29,6 @@
2929 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3030 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3131 * SUCH DAMAGE.
32 *
33 * @(#)if_llc.h 8.1 (Berkeley) 6/10/93
3432 */
3533
3634#ifndef _NET_IF_LLC_H_
lib/libc/include/generic-freebsd/net/if_media.h+6
......@@ -258,6 +258,8 @@ uint64_t ifmedia_baudrate(int);
258258#define IFM_400G_AUI8 IFM_X(117) /* 400G-AUI8 */
259259#define IFM_50G_KR4 IFM_X(118) /* 50GBase-KR4 */
260260#define IFM_40G_LM4 IFM_X(119) /* 40GBase-LM4 */
261#define IFM_100_BX IFM_X(120) /* 100Base-BX */
262#define IFM_1000_BX IFM_X(121) /* 1000Base-BX */
261263
262264/*
263265 * Please update ieee8023ad_lacp.c:lacp_compose_key()
......@@ -437,11 +439,13 @@ struct ifmedia_description {
437439 { IFM_100_T4, "100baseT4" }, \
438440 { IFM_100_VG, "100baseVG" }, \
439441 { IFM_100_T2, "100baseT2" }, \
442 { IFM_100_BX, "100baseBX" }, \
440443 { IFM_10_STP, "10baseSTP" }, \
441444 { IFM_10_FL, "10baseFL" }, \
442445 { IFM_1000_SX, "1000baseSX" }, \
443446 { IFM_1000_LX, "1000baseLX" }, \
444447 { IFM_1000_CX, "1000baseCX" }, \
448 { IFM_1000_BX, "1000baseBX" }, \
445449 { IFM_1000_T, "1000baseT" }, \
446450 { IFM_HPNA_1, "homePNA" }, \
447451 { IFM_10G_LR, "10Gbase-LR" }, \
......@@ -784,11 +788,13 @@ struct ifmedia_baudrate {
784788 { IFM_ETHER | IFM_100_T4, IF_Mbps(100) }, \
785789 { IFM_ETHER | IFM_100_VG, IF_Mbps(100) }, \
786790 { IFM_ETHER | IFM_100_T2, IF_Mbps(100) }, \
791 { IFM_ETHER | IFM_100_BX, IF_Mbps(100) }, \
787792 { IFM_ETHER | IFM_1000_SX, IF_Mbps(1000) }, \
788793 { IFM_ETHER | IFM_10_STP, IF_Mbps(10) }, \
789794 { IFM_ETHER | IFM_10_FL, IF_Mbps(10) }, \
790795 { IFM_ETHER | IFM_1000_LX, IF_Mbps(1000) }, \
791796 { IFM_ETHER | IFM_1000_CX, IF_Mbps(1000) }, \
797 { IFM_ETHER | IFM_1000_BX, IF_Mbps(1000) }, \
792798 { IFM_ETHER | IFM_1000_T, IF_Mbps(1000) }, \
793799 { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \
794800 { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \
lib/libc/include/generic-freebsd/net/if_ovpn.h+1
......@@ -37,6 +37,7 @@
3737enum ovpn_notif_type {
3838 OVPN_NOTIF_DEL_PEER,
3939 OVPN_NOTIF_ROTATE_KEY,
40 OVPN_NOTIF_FLOAT,
4041};
4142
4243enum ovpn_del_reason {
lib/libc/include/generic-freebsd/net/if_pflog.h+5-5
......@@ -33,8 +33,6 @@
3333
3434#include <net/if.h>
3535
36#define PFLOGIFS_MAX 16
37
3836#define PFLOG_RULESET_NAME_SIZE 16
3937
4038struct pfloghdr {
......@@ -51,7 +49,9 @@ struct pfloghdr {
5149 uid_t rule_uid;
5250 pid_t rule_pid;
5351 u_int8_t dir;
54 u_int8_t pad[3];
52 u_int8_t pad1; /* rewritten, on OpenBSD */
53 sa_family_t naf;
54 u_int8_t pad[1];
5555 u_int32_t ridentifier;
5656 u_int8_t reserve; /* Appease broken software like Wireshark. */
5757 u_int8_t pad2[3];
......@@ -69,9 +69,9 @@ struct pf_ruleset;
6969struct pfi_kif;
7070struct pf_pdesc;
7171
72#define PFLOG_PACKET(i,a,b,c,d,e,f,g,di) do { \
72#define PFLOG_PACKET(b,t,c,d,e,f,g,h) do { \
7373 if (pflog_packet_ptr != NULL) \
74 pflog_packet_ptr(i,a,b,c,d,e,f,g,di); \
74 pflog_packet_ptr(b,t,c,d,e,f,g,h); \
7575} while (0)
7676#endif /* _KERNEL */
7777#endif /* _NET_IF_PFLOG_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_pfsync.h+7-4
......@@ -62,9 +62,10 @@ enum pfsync_msg_versions {
6262 PFSYNC_MSG_VERSION_UNSPECIFIED = 0,
6363 PFSYNC_MSG_VERSION_1301 = 1301,
6464 PFSYNC_MSG_VERSION_1400 = 1400,
65 PFSYNC_MSG_VERSION_1500 = 1500,
6566};
6667
67#define PFSYNC_MSG_VERSION_DEFAULT PFSYNC_MSG_VERSION_1400
68#define PFSYNC_MSG_VERSION_DEFAULT PFSYNC_MSG_VERSION_1500
6869
6970#define PFSYNC_ACT_CLR 0 /* clear all states */
7071#define PFSYNC_ACT_INS_1301 1 /* insert state */
......@@ -81,7 +82,9 @@ enum pfsync_msg_versions {
8182#define PFSYNC_ACT_EOF 12 /* end of frame */
8283#define PFSYNC_ACT_INS_1400 13 /* insert state */
8384#define PFSYNC_ACT_UPD_1400 14 /* update state */
84#define PFSYNC_ACT_MAX 15
85#define PFSYNC_ACT_INS_1500 15 /* insert state */
86#define PFSYNC_ACT_UPD_1500 16 /* update state */
87#define PFSYNC_ACT_MAX 17
8588
8689/*
8790 * A pfsync frame is built from a header followed by several sections which
......@@ -160,8 +163,8 @@ struct pfsync_ins_ack {
160163
161164struct pfsync_upd_c {
162165 u_int64_t id;
163 struct pfsync_state_peer src;
164 struct pfsync_state_peer dst;
166 struct pf_state_peer_export src;
167 struct pf_state_peer_export dst;
165168 u_int32_t creatorid;
166169 u_int32_t expire;
167170 u_int8_t timeout;
lib/libc/include/generic-freebsd/net/if_private.h+2-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IF_PRIVATE_H_
......@@ -140,6 +138,8 @@ struct ifnet {
140138 int (*if_requestencap) /* make link header from request */
141139 (struct ifnet *, struct if_encap_req *);
142140
141 const struct if_ipsec_accel_methods *if_ipsec_accel_m;
142
143143 /* Statistics. */
144144 counter_u64_t if_counters[IFCOUNTERS];
145145
lib/libc/include/generic-freebsd/net/if_strings.h+5
......@@ -60,10 +60,13 @@
6060#define IFCAP_TXTLS_RTLMT_NAME "TXTLS_RTLMT"
6161#define IFCAP_RXTLS4_NAME "RXTLS4"
6262#define IFCAP_RXTLS6_NAME "RXTLS6"
63#define IFCAP_IPSEC_OFFLOAD_NAME "IPSEC"
6364
6465#define IFCAP2_RXTLS4_NAME IFCAP_RXTLS4_NAME
6566#define IFCAP2_RXTLS6_NAME IFCAP_RXTLS6_NAME
67#define IFCAP2_IPSEC_OFFLOAD_NAME IFCAP_IPSEC_OFFLOAD_NAME
6668
69#ifdef _WANT_IFCAP_BIT_NAMES
6770static const char *ifcap_bit_names[] = {
6871 IFCAP_RXCSUM_NAME,
6972 IFCAP_TXCSUM_NAME,
......@@ -99,11 +102,13 @@ static const char *ifcap_bit_names[] = {
99102 IFCAP_TXTLS_RTLMT_NAME,
100103 IFCAP_RXTLS4_NAME,
101104 IFCAP_RXTLS6_NAME,
105 IFCAP_IPSEC_OFFLOAD_NAME,
102106};
103107
104108#ifdef IFCAP_B_SIZE
105109_Static_assert(sizeof(ifcap_bit_names) >= IFCAP_B_SIZE * sizeof(char *),
106110 "ifcap bit names missing from ifcap_bit_names");
107111#endif
112#endif
108113
109114#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_tap.h+2
......@@ -57,6 +57,8 @@
5757#define TAPGIFNAME TUNGIFNAME
5858#define TAPSVNETHDR _IOW('t', 91, int)
5959#define TAPGVNETHDR _IOR('t', 94, int)
60#define TAPSTRANSIENT TUNSTRANSIENT
61#define TAPGTRANSIENT TUNGTRANSIENT
6062
6163/* VMware ioctl's */
6264#define VMIO_SIOCSIFFLAGS _IOWINT('V', 0)
lib/libc/include/generic-freebsd/net/if_tun.h+2
......@@ -43,5 +43,7 @@ struct tuninfo {
4343#define TUNSIFPID _IO('t', 95)
4444#define TUNSIFHEAD _IOW('t', 96, int)
4545#define TUNGIFHEAD _IOR('t', 97, int)
46#define TUNSTRANSIENT _IOW('t', 98, int)
47#define TUNGTRANSIENT _IOR('t', 99, int)
4648
4749#endif /* !_NET_IF_TUN_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_types.h+1-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)if_types.h 8.3 (Berkeley) 4/28/95
3230 * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $
3331 */
3432
......@@ -256,6 +254,7 @@ typedef enum {
256254 IFT_PFLOG = 0xf6, /* PF packet filter logging */
257255 IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */
258256 IFT_WIREGUARD = 0xf8, /* WireGuard tunnel */
257 IFT_MBIM = 0xf9, /* Mobile Broadband Interface Model */
259258} ifType;
260259
261260/*
lib/libc/include/generic-freebsd/net/if_var.h+37-6
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IF_VAR_H_
......@@ -133,6 +131,25 @@ typedef void (*if_qflush_fn_t)(if_t);
133131typedef int (*if_transmit_fn_t)(if_t, struct mbuf *);
134132typedef uint64_t (*if_get_counter_t)(if_t, ift_counter);
135133typedef void (*if_reassign_fn_t)(if_t, struct vnet *, char *);
134typedef int (*if_spdadd_fn_t)(if_t ifp, void *sp, void *inp, void **priv);
135typedef int (*if_spddel_fn_t)(if_t ifp, void *sp, void *priv);
136typedef int (*if_sa_newkey_fn_t)(if_t ifp, void *sav, u_int drv_spi,
137 void **privp);
138typedef int (*if_sa_deinstall_fn_t)(if_t ifp, u_int drv_spi, void *priv);
139struct seclifetime;
140#define IF_SA_CNT_UPD 0x80000000
141enum IF_SA_CNT_WHICH {
142 IF_SA_CNT_IFP_HW_VAL = 1,
143 IF_SA_CNT_TOTAL_SW_VAL,
144 IF_SA_CNT_TOTAL_HW_VAL,
145 IF_SA_CNT_IFP_HW_UPD = IF_SA_CNT_IFP_HW_VAL | IF_SA_CNT_UPD,
146 IF_SA_CNT_TOTAL_SW_UPD = IF_SA_CNT_TOTAL_SW_VAL | IF_SA_CNT_UPD,
147 IF_SA_CNT_TOTAL_HW_UPD = IF_SA_CNT_TOTAL_HW_VAL | IF_SA_CNT_UPD,
148};
149typedef int (*if_sa_cnt_fn_t)(if_t ifp, void *sa,
150 uint32_t drv_spi, void *priv, struct seclifetime *lt);
151typedef int (*if_ipsec_hwassist_fn_t)(if_t ifp, void *sav,
152 u_int drv_spi,void *priv);
136153
137154struct ifnet_hw_tsomax {
138155 u_int tsomaxbytes; /* TSO total burst length limit in bytes */
......@@ -280,12 +297,14 @@ typedef int (if_snd_tag_modify_t)(struct m_snd_tag *, union if_snd_tag_modify_pa
280297typedef int (if_snd_tag_query_t)(struct m_snd_tag *, union if_snd_tag_query_params *);
281298typedef void (if_snd_tag_free_t)(struct m_snd_tag *);
282299typedef struct m_snd_tag *(if_next_send_tag_t)(struct m_snd_tag *);
300typedef int (if_snd_tag_status_str_t)(struct m_snd_tag *, char *buf, size_t *sz);
283301
284302struct if_snd_tag_sw {
285303 if_snd_tag_modify_t *snd_tag_modify;
286304 if_snd_tag_query_t *snd_tag_query;
287305 if_snd_tag_free_t *snd_tag_free;
288306 if_next_send_tag_t *next_snd_tag;
307 if_snd_tag_status_str_t *snd_tag_status_str;
289308 u_int type; /* One of IF_SND_TAG_TYPE_*. */
290309};
291310
......@@ -603,6 +622,7 @@ int if_setmtu(if_t ifp, int mtu);
603622int if_getmtu(const if_t ifp);
604623int if_getmtu_family(const if_t ifp, int family);
605624void if_notifymtu(if_t ifp);
625void if_setppromisc(const if_t ifp, bool ppromisc);
606626int if_setflagbits(if_t ifp, int set, int clear);
607627int if_setflags(if_t ifp, int flags);
608628int if_getflags(const if_t ifp);
......@@ -626,11 +646,9 @@ void if_setrcvif(struct mbuf *m, if_t ifp);
626646void if_setvtag(struct mbuf *m, u_int16_t tag);
627647u_int16_t if_getvtag(struct mbuf *m);
628648int if_vlantrunkinuse(if_t ifp);
629caddr_t if_getlladdr(const if_t ifp);
649char *if_getlladdr(const if_t ifp);
630650struct vnet *if_getvnet(const if_t ifp);
631651void *if_gethandle(u_char);
632void if_bpfmtap(if_t ifp, struct mbuf *m);
633void if_etherbpfmtap(if_t ifp, struct mbuf *m);
634652void if_vlancap(if_t ifp);
635653int if_transmit(if_t ifp, struct mbuf *m);
636654void if_init(if_t ifp, void *ctx);
......@@ -703,6 +721,20 @@ void if_setdebugnet_methods(if_t, struct debugnet_methods *);
703721void if_setreassignfn(if_t ifp, if_reassign_fn_t);
704722void if_setratelimitqueryfn(if_t ifp, if_ratelimit_query_t);
705723
724/*
725 * NB: The interface is not yet stable, drivers implementing IPSEC
726 * offload need to be prepared to adapt to changes.
727 */
728struct if_ipsec_accel_methods {
729 if_spdadd_fn_t if_spdadd;
730 if_spddel_fn_t if_spddel;
731 if_sa_newkey_fn_t if_sa_newkey;
732 if_sa_deinstall_fn_t if_sa_deinstall;
733 if_sa_cnt_fn_t if_sa_cnt;
734 if_ipsec_hwassist_fn_t if_hwassist;
735};
736void if_setipsec_accel_methods(if_t ifp, const struct if_ipsec_accel_methods *);
737
706738/* TSO */
707739void if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *);
708740int if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsomax *);
......@@ -724,7 +756,6 @@ int ether_poll_deregister(if_t ifp);
724756
725757#endif /* _KERNEL */
726758
727#include <net/if_private.h> /* XXX: temporary until drivers converted. */
728759#include <net/ifq.h> /* XXXAO: temporary unconditional include */
729760
730761#endif /* !_NET_IF_VAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_vlan_var.h+1-5
......@@ -126,11 +126,6 @@ struct vlanreq {
126126
127127#define VLAN_PCP_MAX 7
128128
129#define DOT1Q_VID_NULL 0x0
130#define DOT1Q_VID_DEF_PVID 0x1
131#define DOT1Q_VID_DEF_SR_PVID 0x2
132#define DOT1Q_VID_RSVD_IMPL 0xfff
133
134129/*
135130 * 802.1q full tag. Proto and vid are stored in host byte order.
136131 */
......@@ -166,6 +161,7 @@ extern int (*vlan_tag_p)(struct ifnet *, uint16_t *);
166161extern int (*vlan_pcp_p)(struct ifnet *, uint16_t *);
167162extern int (*vlan_setcookie_p)(struct ifnet *, void *);
168163extern void *(*vlan_cookie_p)(struct ifnet *);
164extern void (*vlan_input_p)(struct ifnet *, struct mbuf *);
169165
170166#include <sys/_eventhandler.h>
171167
lib/libc/include/generic-freebsd/net/iflib.h+6-6
......@@ -121,13 +121,13 @@ typedef struct if_pkt_info {
121121 uint16_t ipi_tso_segsz; /* tso segment size */
122122 uint16_t ipi_vtag; /* VLAN tag */
123123 uint16_t ipi_etype; /* ether header type */
124 uint8_t ipi_tcp_hflags; /* tcp header flags */
125 uint8_t ipi_mflags; /* packet mbuf flags */
124 uint16_t ipi_tcp_hflags; /* tcp header flags */
126125
127126 uint32_t ipi_tcp_seq; /* tcp seqno */
128127 uint8_t ipi_ip_tos; /* IP ToS field data */
128 uint8_t ipi_mflags; /* packet mbuf flags */
129129 uint8_t __spare0__;
130 uint16_t __spare1__;
130 uint8_t __spare1__;
131131} *if_pkt_info_t;
132132
133133typedef struct if_irq {
......@@ -470,9 +470,9 @@ void iflib_irq_free(if_ctx_t ctx, if_irq_t irq);
470470void iflib_io_tqg_attach(struct grouptask *gt, void *uniq, int cpu,
471471 const char *name);
472472
473void iflib_config_gtask_init(void *ctx, struct grouptask *gtask,
474 gtask_fn_t *fn, const char *name);
475void iflib_config_gtask_deinit(struct grouptask *gtask);
473void iflib_config_task_init(if_ctx_t ctx, struct task *config_task,
474 task_fn_t *fn);
475void iflib_config_task_enqueue(if_ctx_t ctx, struct task *config_task);
476476
477477void iflib_tx_intr_deferred(if_ctx_t ctx, int txqid);
478478void iflib_rx_intr_deferred(if_ctx_t ctx, int rxqid);
lib/libc/include/generic-freebsd/net/ifq.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NET_IFQ_H_
lib/libc/include/generic-freebsd/net/pfkeyv2.h+15-5
......@@ -296,6 +296,13 @@ struct sadb_x_sa_replay {
296296};
297297_Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");
298298
299struct sadb_x_if_hw_offl {
300 u_int16_t sadb_x_if_hw_offl_len;
301 u_int16_t sadb_x_if_hw_offl_exttype;
302 u_int32_t sadb_x_if_hw_offl_flags;
303 u_int8_t sadb_x_if_hw_offl_if[32]; /* IF_NAMESIZE is 16, keep room */
304};
305
299306#define SADB_EXT_RESERVED 0
300307#define SADB_EXT_SA 1
301308#define SADB_EXT_LIFETIME_CURRENT 2
......@@ -326,7 +333,10 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");
326333#define SADB_X_EXT_SA_REPLAY 26 /* Replay window override. */
327334#define SADB_X_EXT_NEW_ADDRESS_SRC 27
328335#define SADB_X_EXT_NEW_ADDRESS_DST 28
329#define SADB_EXT_MAX 28
336#define SADB_X_EXT_LFT_CUR_SW_OFFL 29
337#define SADB_X_EXT_LFT_CUR_HW_OFFL 30
338#define SADB_X_EXT_IF_HW_OFFL 31
339#define SADB_EXT_MAX 31
330340
331341#define SADB_SATYPE_UNSPEC 0
332342#define SADB_SATYPE_AH 2
......@@ -444,13 +454,13 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");
444454/* Utilities */
445455#define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1)))
446456#define PFKEY_EXTLEN(msg) \
447 PFKEY_UNUNIT64(((struct sadb_ext *)(msg))->sadb_ext_len)
457 PFKEY_UNUNIT64(((const struct sadb_ext *)(msg))->sadb_ext_len)
448458#define PFKEY_ADDR_PREFIX(ext) \
449 (((struct sadb_address *)(ext))->sadb_address_prefixlen)
459 (((const struct sadb_address *)(ext))->sadb_address_prefixlen)
450460#define PFKEY_ADDR_PROTO(ext) \
451 (((struct sadb_address *)(ext))->sadb_address_proto)
461 (((const struct sadb_address *)(ext))->sadb_address_proto)
452462#define PFKEY_ADDR_SADDR(ext) \
453 ((struct sockaddr *)((caddr_t)(ext) + sizeof(struct sadb_address)))
463 ((const struct sockaddr *)((c_caddr_t)(ext) + sizeof(struct sadb_address)))
454464
455465/* in 64bits */
456466#define PFKEY_UNUNIT64(a) ((a) << 3)
lib/libc/include/generic-freebsd/net/pflow.h created+382
......@@ -0,0 +1,382 @@
1/* $OpenBSD: if_pflow.h,v 1.19 2022/11/23 15:12:27 mvs Exp $ */
2
3/*
4 * Copyright (c) 2008 Henning Brauer <henning@openbsd.org>
5 * Copyright (c) 2008 Joerg Goltermann <jg@osn.de>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
16 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef _NET_IF_PFLOW_H_
21#define _NET_IF_PFLOW_H_
22
23#include <sys/cdefs.h>
24#include <sys/types.h>
25#include <sys/socket.h>
26
27#include <netinet/in.h>
28
29#ifdef _KERNEL
30#include <sys/param.h>
31#include <sys/lock.h>
32#include <sys/rmlock.h>
33#include <sys/interrupt.h>
34#include <net/if.h>
35#include <net/if_var.h>
36#include <net/if_private.h>
37#include <net/pfvar.h>
38
39#include <netinet/ip.h>
40#endif
41
42#define PFLOW_MAX_ENTRIES 128
43
44#define PFLOW_ID_LEN sizeof(u_int64_t)
45
46#define PFLOW_MAXFLOWS 30
47#define PFLOW_ENGINE_TYPE 42
48#define PFLOW_ENGINE_ID 42
49#define PFLOW_MAXBYTES 0xffffffff
50#define PFLOW_TIMEOUT 30
51#define PFLOW_TMPL_TIMEOUT 30 /* rfc 5101 10.3.6 (p.40) recommends 600 */
52
53#define PFLOW_IPFIX_TMPL_SET_ID 2
54
55/* RFC 5102 Information Element Identifiers */
56
57#define PFIX_IE_octetDeltaCount 1
58#define PFIX_IE_packetDeltaCount 2
59#define PFIX_IE_protocolIdentifier 4
60#define PFIX_IE_ipClassOfService 5
61#define PFIX_IE_sourceTransportPort 7
62#define PFIX_IE_sourceIPv4Address 8
63#define PFIX_IE_ingressInterface 10
64#define PFIX_IE_destinationTransportPort 11
65#define PFIX_IE_destinationIPv4Address 12
66#define PFIX_IE_egressInterface 14
67#define PFIX_IE_flowEndSysUpTime 21
68#define PFIX_IE_flowStartSysUpTime 22
69#define PFIX_IE_sourceIPv6Address 27
70#define PFIX_IE_destinationIPv6Address 28
71#define PFIX_IE_flowStartMilliseconds 152
72#define PFIX_IE_flowEndMilliseconds 153
73#define PFIX_IE_postNATSourceIPv4Address 225
74#define PFIX_IE_postNATDestinationIPv4Address 226
75#define PFIX_IE_postNAPTSourceTransportPort 227
76#define PFIX_IE_postNAPTDestinationTransportPort 228
77#define PFIX_IE_natEvent 230
78#define PFIX_NAT_EVENT_SESSION_CREATE 4
79#define PFIX_NAT_EVENT_SESSION_DELETE 5
80#define PFIX_IE_timeStamp 323
81
82struct pflow_flow {
83 u_int32_t src_ip;
84 u_int32_t dest_ip;
85 u_int32_t nexthop_ip;
86 u_int16_t if_index_in;
87 u_int16_t if_index_out;
88 u_int32_t flow_packets;
89 u_int32_t flow_octets;
90 u_int32_t flow_start;
91 u_int32_t flow_finish;
92 u_int16_t src_port;
93 u_int16_t dest_port;
94 u_int8_t pad1;
95 u_int8_t tcp_flags;
96 u_int8_t protocol;
97 u_int8_t tos;
98 u_int16_t src_as;
99 u_int16_t dest_as;
100 u_int8_t src_mask;
101 u_int8_t dest_mask;
102 u_int16_t pad2;
103} __packed;
104
105struct pflow_set_header {
106 u_int16_t set_id;
107 u_int16_t set_length; /* total length of the set,
108 in octets, including the set header */
109} __packed;
110
111#define PFLOW_SET_HDRLEN sizeof(struct pflow_set_header)
112
113struct pflow_tmpl_hdr {
114 u_int16_t tmpl_id;
115 u_int16_t field_count;
116} __packed;
117
118struct pflow_tmpl_fspec {
119 u_int16_t field_id;
120 u_int16_t len;
121} __packed;
122
123/* update pflow_clone_create() when changing pflow_ipfix_tmpl_ipv4 */
124struct pflow_ipfix_tmpl_ipv4 {
125 struct pflow_tmpl_hdr h;
126 struct pflow_tmpl_fspec src_ip;
127 struct pflow_tmpl_fspec dest_ip;
128 struct pflow_tmpl_fspec if_index_in;
129 struct pflow_tmpl_fspec if_index_out;
130 struct pflow_tmpl_fspec packets;
131 struct pflow_tmpl_fspec octets;
132 struct pflow_tmpl_fspec start;
133 struct pflow_tmpl_fspec finish;
134 struct pflow_tmpl_fspec src_port;
135 struct pflow_tmpl_fspec dest_port;
136 struct pflow_tmpl_fspec tos;
137 struct pflow_tmpl_fspec protocol;
138#define PFLOW_IPFIX_TMPL_IPV4_FIELD_COUNT 12
139#define PFLOW_IPFIX_TMPL_IPV4_ID 256
140} __packed;
141
142/* update pflow_clone_create() when changing pflow_ipfix_tmpl_v6 */
143struct pflow_ipfix_tmpl_ipv6 {
144 struct pflow_tmpl_hdr h;
145 struct pflow_tmpl_fspec src_ip;
146 struct pflow_tmpl_fspec dest_ip;
147 struct pflow_tmpl_fspec if_index_in;
148 struct pflow_tmpl_fspec if_index_out;
149 struct pflow_tmpl_fspec packets;
150 struct pflow_tmpl_fspec octets;
151 struct pflow_tmpl_fspec start;
152 struct pflow_tmpl_fspec finish;
153 struct pflow_tmpl_fspec src_port;
154 struct pflow_tmpl_fspec dest_port;
155 struct pflow_tmpl_fspec tos;
156 struct pflow_tmpl_fspec protocol;
157#define PFLOW_IPFIX_TMPL_IPV6_FIELD_COUNT 12
158#define PFLOW_IPFIX_TMPL_IPV6_ID 257
159} __packed;
160
161struct pflow_ipfix_tmpl_nat44 {
162 struct pflow_tmpl_hdr h;
163 struct pflow_tmpl_fspec timestamp;
164 struct pflow_tmpl_fspec nat_event;
165 struct pflow_tmpl_fspec protocol;
166 struct pflow_tmpl_fspec src_ip;
167 struct pflow_tmpl_fspec src_port;
168 struct pflow_tmpl_fspec postnat_src_ip;
169 struct pflow_tmpl_fspec postnat_src_port;
170 struct pflow_tmpl_fspec dst_ip;
171 struct pflow_tmpl_fspec dst_port;
172 struct pflow_tmpl_fspec postnat_dst_ip;
173 struct pflow_tmpl_fspec postnat_dst_port;
174#define PFLOW_IPFIX_TMPL_NAT44_FIELD_COUNT 11
175#define PFLOW_IPFIX_TMPL_NAT44_ID 258
176};
177
178struct pflow_ipfix_tmpl {
179 struct pflow_set_header set_header;
180 struct pflow_ipfix_tmpl_ipv4 ipv4_tmpl;
181 struct pflow_ipfix_tmpl_ipv6 ipv6_tmpl;
182 struct pflow_ipfix_tmpl_nat44 nat44_tmpl;
183} __packed;
184
185struct pflow_ipfix_flow4 {
186 u_int32_t src_ip; /* sourceIPv4Address*/
187 u_int32_t dest_ip; /* destinationIPv4Address */
188 u_int32_t if_index_in; /* ingressInterface */
189 u_int32_t if_index_out; /* egressInterface */
190 u_int64_t flow_packets; /* packetDeltaCount */
191 u_int64_t flow_octets; /* octetDeltaCount */
192 int64_t flow_start; /* flowStartMilliseconds */
193 int64_t flow_finish; /* flowEndMilliseconds */
194 u_int16_t src_port; /* sourceTransportPort */
195 u_int16_t dest_port; /* destinationTransportPort */
196 u_int8_t tos; /* ipClassOfService */
197 u_int8_t protocol; /* protocolIdentifier */
198 /* XXX padding needed? */
199} __packed;
200
201struct pflow_ipfix_flow6 {
202 struct in6_addr src_ip; /* sourceIPv6Address */
203 struct in6_addr dest_ip; /* destinationIPv6Address */
204 u_int32_t if_index_in; /* ingressInterface */
205 u_int32_t if_index_out; /* egressInterface */
206 u_int64_t flow_packets; /* packetDeltaCount */
207 u_int64_t flow_octets; /* octetDeltaCount */
208 int64_t flow_start; /* flowStartMilliseconds */
209 int64_t flow_finish; /* flowEndMilliseconds */
210 u_int16_t src_port; /* sourceTransportPort */
211 u_int16_t dest_port; /* destinationTransportPort */
212 u_int8_t tos; /* ipClassOfService */
213 u_int8_t protocol; /* protocolIdentifier */
214 /* XXX padding needed? */
215} __packed;
216
217struct pflow_ipfix_nat4 {
218 u_int64_t timestamp; /* timeStamp */
219 u_int8_t nat_event; /* natEvent */
220 u_int8_t protocol; /* protocolIdentifier */
221 u_int32_t src_ip; /* sourceIPv4Address */
222 u_int16_t src_port; /* sourceTransportPort */
223 u_int32_t postnat_src_ip; /* postNATSourceIPv4Address */
224 u_int16_t postnat_src_port;/* postNAPTSourceTransportPort */
225 u_int32_t dest_ip; /* destinationIPv4Address */
226 u_int16_t dest_port; /* destinationTransportPort */
227 u_int32_t postnat_dest_ip;/* postNATDestinationIPv4Address */
228 u_int16_t postnat_dest_port;/* postNAPTDestinationTransportPort */
229} __packed;
230
231#ifdef _KERNEL
232
233struct pflow_softc {
234 int sc_id;
235
236 struct mtx sc_lock;
237
238 int sc_dying; /* [N] */
239 struct vnet *sc_vnet;
240
241 unsigned int sc_count;
242 unsigned int sc_count4;
243 unsigned int sc_count6;
244 unsigned int sc_count_nat4;
245 unsigned int sc_maxcount;
246 unsigned int sc_maxcount4;
247 unsigned int sc_maxcount6;
248 unsigned int sc_maxcount_nat4;
249 u_int32_t sc_gcounter;
250 u_int32_t sc_sequence;
251 struct callout sc_tmo;
252 struct callout sc_tmo6;
253 struct callout sc_tmo_nat4;
254 struct callout sc_tmo_tmpl;
255 struct intr_event *sc_swi_ie;
256 void *sc_swi_cookie;
257 struct mbufq sc_outputqueue;
258 struct task sc_outputtask;
259 struct socket *so; /* [p] */
260 struct sockaddr *sc_flowsrc;
261 struct sockaddr *sc_flowdst;
262 struct pflow_ipfix_tmpl sc_tmpl_ipfix;
263 u_int8_t sc_version;
264 u_int32_t sc_observation_dom;
265 struct mbuf *sc_mbuf; /* current cumulative mbuf */
266 struct mbuf *sc_mbuf6; /* current cumulative mbuf */
267 struct mbuf *sc_mbuf_nat4;
268 CK_LIST_ENTRY(pflow_softc) sc_next;
269 struct epoch_context sc_epoch_ctx;
270};
271
272#endif /* _KERNEL */
273
274struct pflow_header {
275 u_int16_t version;
276 u_int16_t count;
277 u_int32_t uptime_ms;
278 u_int32_t time_sec;
279 u_int32_t time_nanosec;
280 u_int32_t flow_sequence;
281 u_int8_t engine_type;
282 u_int8_t engine_id;
283 u_int8_t reserved1;
284 u_int8_t reserved2;
285} __packed;
286
287#define PFLOW_HDRLEN sizeof(struct pflow_header)
288
289struct pflow_v10_header {
290 u_int16_t version;
291 u_int16_t length;
292 u_int32_t time_sec;
293 u_int32_t flow_sequence;
294 u_int32_t observation_dom;
295} __packed;
296
297#define PFLOW_IPFIX_HDRLEN sizeof(struct pflow_v10_header)
298
299struct pflowstats {
300 u_int64_t pflow_flows;
301 u_int64_t pflow_packets;
302 u_int64_t pflow_onomem;
303 u_int64_t pflow_oerrors;
304};
305
306/* Supported flow protocols */
307#define PFLOW_PROTO_5 5 /* original pflow */
308#define PFLOW_PROTO_10 10 /* ipfix */
309#define PFLOW_PROTO_MAX 11
310
311#define PFLOW_PROTO_DEFAULT PFLOW_PROTO_5
312
313struct pflow_protos {
314 const char *ppr_name;
315 u_int8_t ppr_proto;
316};
317
318#define PFLOW_PROTOS { \
319 { "5", PFLOW_PROTO_5 }, \
320 { "10", PFLOW_PROTO_10 }, \
321}
322
323#define PFLOWNL_FAMILY_NAME "pflow"
324
325enum {
326 PFLOWNL_CMD_UNSPEC = 0,
327 PFLOWNL_CMD_LIST = 1,
328 PFLOWNL_CMD_CREATE = 2,
329 PFLOWNL_CMD_DEL = 3,
330 PFLOWNL_CMD_SET = 4,
331 PFLOWNL_CMD_GET = 5,
332 __PFLOWNL_CMD_MAX,
333};
334#define PFLOWNL_CMD_MAX (__PFLOWNL_CMD_MAX - 1)
335
336enum pflow_list_type_t {
337 PFLOWNL_L_UNSPEC,
338 PFLOWNL_L_ID = 1, /* u32 */
339};
340
341enum pflow_create_type_t {
342 PFLOWNL_CREATE_UNSPEC,
343 PFLOWNL_CREATE_ID = 1, /* u32 */
344};
345
346enum pflow_del_type_t {
347 PFLOWNL_DEL_UNSPEC,
348 PFLOWNL_DEL_ID = 1, /* u32 */
349};
350
351enum pflow_addr_type_t {
352 PFLOWNL_ADDR_UNSPEC,
353 PFLOWNL_ADDR_FAMILY = 1, /* u8 */
354 PFLOWNL_ADDR_PORT = 2, /* u16 */
355 PFLOWNL_ADDR_IP = 3, /* struct in_addr */
356 PFLOWNL_ADDR_IP6 = 4, /* struct in6_addr */
357};
358
359enum pflow_get_type_t {
360 PFLOWNL_GET_UNSPEC,
361 PFLOWNL_GET_ID = 1, /* u32 */
362 PFLOWNL_GET_VERSION = 2, /* u16 */
363 PFLOWNL_GET_SRC = 3, /* struct sockaddr_storage */
364 PFLOWNL_GET_DST = 4, /* struct sockaddr_storage */
365 PFLOWNL_GET_OBSERVATION_DOMAIN = 5, /* u32 */
366 PFLOWNL_GET_SOCKET_STATUS = 6, /* u8 */
367};
368
369enum pflow_set_type_t {
370 PFLOWNL_SET_UNSPEC,
371 PFLOWNL_SET_ID = 1, /* u32 */
372 PFLOWNL_SET_VERSION = 2, /* u16 */
373 PFLOWNL_SET_SRC = 3, /* struct sockaddr_storage */
374 PFLOWNL_SET_DST = 4, /* struct sockaddr_storage */
375 PFLOWNL_SET_OBSERVATION_DOMAIN = 5, /* u32 */
376};
377
378#ifdef _KERNEL
379int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t);
380#endif /* _KERNEL */
381
382#endif /* _NET_IF_PFLOW_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/pfvar.h+497-254
......@@ -70,6 +70,8 @@
7070
7171#ifdef _KERNEL
7272
73#define PF_PFIL_NOREFRAGMENT 0x80000000
74
7375#if defined(__arm__)
7476#define PF_WANT_32_TO_64_COUNTER
7577#endif
......@@ -127,6 +129,14 @@ pf_counter_u64_critical_exit(void)
127129 critical_exit();
128130}
129131
132static inline void
133pf_counter_u64_rollup_protected(struct pf_counter_u64 *pfcu64, uint64_t n)
134{
135
136 MPASS(curthread->td_critnest > 0);
137 pfcu64->pfcu64_value += n;
138}
139
130140static inline void
131141pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)
132142{
......@@ -250,6 +260,13 @@ pf_counter_u64_critical_exit(void)
250260
251261}
252262
263static inline void
264pf_counter_u64_rollup_protected(struct pf_counter_u64 *pfcu64, uint64_t n)
265{
266
267 counter_u64_add(pfcu64->counter, n);
268}
269
253270static inline void
254271pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)
255272{
......@@ -309,10 +326,20 @@ pf_counter_u64_zero(struct pf_counter_u64 *pfcu64)
309326_Static_assert(sizeof(time_t) == 4 || sizeof(time_t) == 8, "unexpected time_t size");
310327
311328SYSCTL_DECL(_net_pf);
329MALLOC_DECLARE(M_PF);
312330MALLOC_DECLARE(M_PFHASH);
313331MALLOC_DECLARE(M_PF_RULE_ITEM);
314332
315333SDT_PROVIDER_DECLARE(pf);
334SDT_PROBE_DECLARE(pf, , test, reason_set);
335SDT_PROBE_DECLARE(pf, , log, log);
336
337#define DPFPRINTF(n, fmt, x...) \
338 do { \
339 SDT_PROBE2(pf, , log, log, (n), fmt); \
340 if (V_pf_status.debug >= (n)) \
341 printf(fmt "\n", ##x); \
342 } while (0)
316343
317344struct pfi_dynaddr {
318345 TAILQ_ENTRY(pfi_dynaddr) entry;
......@@ -329,14 +356,6 @@ struct pfi_dynaddr {
329356 u_int8_t pfid_iflags; /* PFI_AFLAG_* */
330357};
331358
332/*
333 * Address manipulation macros
334 */
335#define HTONL(x) (x) = htonl((__uint32_t)(x))
336#define HTONS(x) (x) = htons((__uint16_t)(x))
337#define NTOHL(x) (x) = ntohl((__uint32_t)(x))
338#define NTOHS(x) (x) = ntohs((__uint16_t)(x))
339
340359#define PF_NAME "pf"
341360
342361#define PF_HASHROW_ASSERT(h) mtx_assert(&(h)->lock, MA_OWNED)
......@@ -433,6 +452,16 @@ VNET_DECLARE(struct rmlock, pf_rules_lock);
433452#define PF_RULES_RASSERT() rm_assert(&V_pf_rules_lock, RA_RLOCKED)
434453#define PF_RULES_WASSERT() rm_assert(&V_pf_rules_lock, RA_WLOCKED)
435454
455VNET_DECLARE(struct rmlock, pf_tags_lock);
456#define V_pf_tags_lock VNET(pf_tags_lock)
457
458#define PF_TAGS_RLOCK_TRACKER struct rm_priotracker _pf_tags_tracker
459#define PF_TAGS_RLOCK() rm_rlock(&V_pf_tags_lock, &_pf_tags_tracker)
460#define PF_TAGS_RUNLOCK() rm_runlock(&V_pf_tags_lock, &_pf_tags_tracker)
461#define PF_TAGS_WLOCK() rm_wlock(&V_pf_tags_lock)
462#define PF_TAGS_WUNLOCK() rm_wunlock(&V_pf_tags_lock)
463#define PF_TAGS_WASSERT() rm_assert(&V_pf_tags_lock, RA_WLOCKED)
464
436465extern struct mtx_padalign pf_table_stats_lock;
437466#define PF_TABLE_STATS_LOCK() mtx_lock(&pf_table_stats_lock)
438467#define PF_TABLE_STATS_UNLOCK() mtx_unlock(&pf_table_stats_lock)
......@@ -498,18 +527,6 @@ extern struct sx pf_end_lock;
498527 (c == AF_INET6 && !(a)->addr32[0] && !(a)->addr32[1] && \
499528 !(a)->addr32[2] && !(a)->addr32[3] )) \
500529
501#define PF_MATCHA(n, a, m, b, f) \
502 pf_match_addr(n, a, m, b, f)
503
504#define PF_ACPY(a, b, f) \
505 pf_addrcpy(a, b, f)
506
507#define PF_AINC(a, f) \
508 pf_addr_inc(a, f)
509
510#define PF_POOLMASK(a, b, c, d, f) \
511 pf_poolmask(a, b, c, d, f)
512
513530#else
514531
515532/* Just IPv6 */
......@@ -534,18 +551,6 @@ extern struct sx pf_end_lock;
534551 !(a)->addr32[2] && \
535552 !(a)->addr32[3] ) \
536553
537#define PF_MATCHA(n, a, m, b, f) \
538 pf_match_addr(n, a, m, b, f)
539
540#define PF_ACPY(a, b, f) \
541 pf_addrcpy(a, b, f)
542
543#define PF_AINC(a, f) \
544 pf_addr_inc(a, f)
545
546#define PF_POOLMASK(a, b, c, d, f) \
547 pf_poolmask(a, b, c, d, f)
548
549554#else
550555
551556/* Just IPv4 */
......@@ -560,27 +565,34 @@ extern struct sx pf_end_lock;
560565#define PF_AZERO(a, c) \
561566 (!(a)->addr32[0])
562567
563#define PF_MATCHA(n, a, m, b, f) \
564 pf_match_addr(n, a, m, b, f)
565
566#define PF_ACPY(a, b, f) \
567 (a)->v4.s_addr = (b)->v4.s_addr
568
569#define PF_AINC(a, f) \
570 do { \
571 (a)->addr32[0] = htonl(ntohl((a)->addr32[0]) + 1); \
572 } while (0)
573
574#define PF_POOLMASK(a, b, c, d, f) \
575 do { \
576 (a)->addr32[0] = ((b)->addr32[0] & (c)->addr32[0]) | \
577 (((c)->addr32[0] ^ 0xffffffff ) & (d)->addr32[0]); \
578 } while (0)
579
580568#endif /* PF_INET_ONLY */
581569#endif /* PF_INET6_ONLY */
582570#endif /* PF_INET_INET6 */
583571
572#ifdef _KERNEL
573
574void unhandled_af(int) __dead2;
575
576static void inline
577pf_addrcpy(struct pf_addr *dst, const struct pf_addr *src, sa_family_t af)
578{
579 switch (af) {
580#ifdef INET
581 case AF_INET:
582 memcpy(&dst->v4, &src->v4, sizeof(dst->v4));
583 break;
584#endif /* INET */
585#ifdef INET6
586 case AF_INET6:
587 memcpy(&dst->v6, &src->v6, sizeof(dst->v6));
588 break;
589#endif /* INET6 */
590 default:
591 unhandled_af(af);
592 }
593}
594#endif
595
584596/*
585597 * XXX callers not FIB-aware in our version of pf yet.
586598 * OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio.
......@@ -600,19 +612,35 @@ extern struct sx pf_end_lock;
600612 &(aw)->v.a.mask, (x), (af))) || \
601613 ((aw)->type == PF_ADDR_ADDRMASK && \
602614 !PF_AZERO(&(aw)->v.a.mask, (af)) && \
603 !PF_MATCHA(0, &(aw)->v.a.addr, \
615 !pf_match_addr(0, &(aw)->v.a.addr, \
604616 &(aw)->v.a.mask, (x), (af))))) != \
605617 (neg) \
606618 )
607619
608620#define PF_ALGNMNT(off) (((off) % 2) == 0)
609621
622/*
623 * At the moment there are no rules which have both NAT and RDR actions,
624 * apart from af-to rules, but those don't to source tracking for address
625 * translation. And the r->rdr pool is used for both NAT and RDR.
626 * So there is no PF_SN_RDR.
627 */
628enum pf_sn_types { PF_SN_LIMIT, PF_SN_NAT, PF_SN_ROUTE, PF_SN_MAX };
629typedef enum pf_sn_types pf_sn_types_t;
630#define PF_SN_TYPE_NAMES { \
631 "limit source-track", \
632 "NAT/RDR sticky-address", \
633 "route sticky-address", \
634 NULL \
635}
636
610637#ifdef _KERNEL
611638
612639struct pf_kpooladdr {
613640 struct pf_addr_wrap addr;
614641 TAILQ_ENTRY(pf_kpooladdr) entries;
615642 char ifname[IFNAMSIZ];
643 sa_family_t af;
616644 struct pfi_kkif *kif;
617645};
618646
......@@ -628,20 +656,27 @@ struct pf_kpool {
628656 int tblidx;
629657 u_int16_t proxy_port[2];
630658 u_int8_t opts;
659 sa_family_t ipv6_nexthop_af;
631660};
632661
633662struct pf_rule_actions {
663 struct pf_addr rt_addr;
664 struct pfi_kkif *rt_kif;
634665 int32_t rtableid;
666 uint32_t flags;
635667 uint16_t qid;
636668 uint16_t pqid;
637669 uint16_t max_mss;
670 uint16_t dnpipe;
671 uint16_t dnrpipe; /* Reverse direction pipe */
672 sa_family_t rt_af;
638673 uint8_t log;
639674 uint8_t set_tos;
640675 uint8_t min_ttl;
641 uint16_t dnpipe;
642 uint16_t dnrpipe; /* Reverse direction pipe */
643 uint32_t flags;
644676 uint8_t set_prio[2];
677 uint8_t rt;
678 uint8_t allow_opts;
679 uint16_t max_pkt_size;
645680};
646681
647682union pf_keth_rule_ptr {
......@@ -667,7 +702,6 @@ struct pf_keth_ruleset {
667702 int open;
668703 uint32_t ticket;
669704 } active, inactive;
670 struct epoch_context epoch_ctx;
671705 struct vnet *vnet;
672706 struct pf_keth_anchor *anchor;
673707};
......@@ -746,9 +780,10 @@ struct pf_keth_rule {
746780 uint32_t ridentifier;
747781};
748782
749union pf_krule_ptr {
750 struct pf_krule *ptr;
751 u_int32_t nr;
783struct pf_kthreshold {
784 uint32_t limit;
785 uint32_t seconds;
786 struct counter_rate *cr;
752787};
753788
754789RB_HEAD(pf_krule_global, pf_krule);
......@@ -757,10 +792,11 @@ RB_PROTOTYPE(pf_krule_global, pf_krule, entry_global, pf_krule_compare);
757792struct pf_krule {
758793 struct pf_rule_addr src;
759794 struct pf_rule_addr dst;
760 union pf_krule_ptr skip[PF_SKIP_COUNT];
795 struct pf_krule *skip[PF_SKIP_COUNT];
761796 char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE];
762797 uint32_t ridentifier;
763798 char ifname[IFNAMSIZ];
799 char rcv_ifname[IFNAMSIZ];
764800 char qname[PF_QNAME_SIZE];
765801 char pqname[PF_QNAME_SIZE];
766802 char tagname[PF_TAG_NAME_SIZE];
......@@ -769,7 +805,10 @@ struct pf_krule {
769805 char overload_tblname[PF_TABLE_NAME_SIZE];
770806
771807 TAILQ_ENTRY(pf_krule) entries;
772 struct pf_kpool rpool;
808 struct pf_kpool nat;
809 struct pf_kpool rdr;
810 struct pf_kpool route;
811 struct pf_kthreshold pktrate;
773812
774813 struct pf_counter_u64 evaluations;
775814 struct pf_counter_u64 packets[2];
......@@ -777,6 +816,7 @@ struct pf_krule {
777816 time_t *timestamp;
778817
779818 struct pfi_kkif *kif;
819 struct pfi_kkif *rcv_kif;
780820 struct pf_kanchor *anchor;
781821 struct pfr_ktable *overload_tbl;
782822
......@@ -792,6 +832,7 @@ struct pf_krule {
792832 u_int32_t limit;
793833 u_int32_t seconds;
794834 } max_src_conn_rate;
835 uint16_t max_pkt_size;
795836 u_int16_t qid;
796837 u_int16_t pqid;
797838 u_int16_t dnpipe;
......@@ -804,7 +845,7 @@ struct pf_krule {
804845
805846 counter_u64_t states_cur;
806847 counter_u64_t states_tot;
807 counter_u64_t src_nodes;
848 counter_u64_t src_nodes[PF_SN_MAX];
808849
809850 u_int16_t return_icmp;
810851 u_int16_t return_icmp6;
......@@ -830,8 +871,8 @@ struct pf_krule {
830871 u_int8_t keep_state;
831872 sa_family_t af;
832873 u_int8_t proto;
833 u_int8_t type;
834 u_int8_t code;
874 uint16_t type;
875 uint16_t code;
835876 u_int8_t flags;
836877 u_int8_t flagset;
837878 u_int8_t min_ttl;
......@@ -846,6 +887,8 @@ struct pf_krule {
846887 u_int8_t flush;
847888 u_int8_t prio;
848889 u_int8_t set_prio[2];
890 sa_family_t naf;
891 u_int8_t rcvifnot;
849892
850893 struct {
851894 struct pf_addr addr;
......@@ -869,21 +912,23 @@ SLIST_HEAD(pf_krule_slist, pf_krule_item);
869912
870913struct pf_ksrc_node {
871914 LIST_ENTRY(pf_ksrc_node) entry;
872 struct pf_addr addr;
873 struct pf_addr raddr;
915 struct pf_addr addr;
916 struct pf_addr raddr;
874917 struct pf_krule_slist match_rules;
875 union pf_krule_ptr rule;
876 struct pfi_kkif *rkif;
877 counter_u64_t bytes[2];
878 counter_u64_t packets[2];
879 u_int32_t states;
880 u_int32_t conn;
881 struct pf_threshold conn_rate;
882 u_int32_t creation;
883 u_int32_t expire;
884 sa_family_t af;
885 u_int8_t ruletype;
886 struct mtx *lock;
918 struct pf_krule *rule;
919 struct pfi_kkif *rkif;
920 counter_u64_t bytes[2];
921 counter_u64_t packets[2];
922 u_int32_t states;
923 u_int32_t conn;
924 struct pf_kthreshold conn_rate;
925 u_int32_t creation;
926 u_int32_t expire;
927 sa_family_t af;
928 sa_family_t raf;
929 u_int8_t ruletype;
930 pf_sn_types_t type;
931 struct mtx *lock;
887932};
888933#endif
889934
......@@ -925,6 +970,29 @@ struct pf_state_peer {
925970 u_int8_t pad[1];
926971};
927972
973/* Keep synced with struct pf_udp_endpoint. */
974struct pf_udp_endpoint_cmp {
975 struct pf_addr addr;
976 uint16_t port;
977 sa_family_t af;
978 uint8_t pad[1];
979};
980
981struct pf_udp_endpoint {
982 struct pf_addr addr;
983 uint16_t port;
984 sa_family_t af;
985 uint8_t pad[1];
986
987 struct pf_udp_mapping *mapping;
988 LIST_ENTRY(pf_udp_endpoint) entry;
989};
990
991struct pf_udp_mapping {
992 struct pf_udp_endpoint endpoints[2];
993 u_int refs;
994};
995
928996/* Keep synced with struct pf_state_key. */
929997struct pf_state_key_cmp {
930998 struct pf_addr addr[2];
......@@ -945,6 +1013,11 @@ struct pf_state_key {
9451013 TAILQ_HEAD(, pf_kstate) states[2];
9461014};
9471015
1016#define PF_REVERSED_KEY(state, family) \
1017 (((state)->key[PF_SK_WIRE]->af != (state)->key[PF_SK_STACK]->af) && \
1018 ((state)->key[PF_SK_WIRE]->af != (family)) && \
1019 ((state)->direction == PF_IN))
1020
9481021/* Keep synced with struct pf_kstate. */
9491022struct pf_state_cmp {
9501023 u_int64_t id;
......@@ -959,7 +1032,7 @@ struct pf_state_scrub_export {
9591032#define PF_SCRUB_FLAG_VALID 0x01
9601033 uint8_t scrub_flag;
9611034 uint32_t pfss_ts_mod; /* timestamp modulation */
962};
1035} __packed;
9631036
9641037struct pf_state_key_export {
9651038 struct pf_addr addr[2];
......@@ -976,7 +1049,7 @@ struct pf_state_peer_export {
9761049 uint8_t state; /* active state level */
9771050 uint8_t wscale; /* window scaling factor */
9781051 uint8_t dummy[6];
979};
1052} __packed;
9801053_Static_assert(sizeof(struct pf_state_peer_export) == 32, "size incorrect");
9811054
9821055struct pf_state_export {
......@@ -1040,7 +1113,7 @@ struct pf_kstate {
10401113 u_int16_t state_flags;
10411114 u_int8_t timeout;
10421115 u_int8_t sync_state; /* PFSYNC_S_x */
1043 u_int8_t sync_updates; /* XXX */
1116 u_int8_t sync_updates;
10441117 u_int refs;
10451118 struct mtx *lock;
10461119 TAILQ_ENTRY(pf_kstate) sync_list;
......@@ -1049,56 +1122,74 @@ struct pf_kstate {
10491122 struct pf_state_peer src;
10501123 struct pf_state_peer dst;
10511124 struct pf_krule_slist match_rules;
1052 union pf_krule_ptr rule;
1053 union pf_krule_ptr anchor;
1054 union pf_krule_ptr nat_rule;
1055 struct pf_addr rt_addr;
1125 struct pf_krule *rule;
1126 struct pf_krule *anchor;
1127 struct pf_krule *nat_rule;
10561128 struct pf_state_key *key[2]; /* addresses stack and wire */
1129 struct pf_udp_mapping *udp_mapping;
10571130 struct pfi_kkif *kif;
10581131 struct pfi_kkif *orig_kif; /* The real kif, even if we're a floating state (i.e. if == V_pfi_all). */
1059 struct pfi_kkif *rt_kif;
1060 struct pf_ksrc_node *src_node;
1061 struct pf_ksrc_node *nat_src_node;
1132 struct pf_ksrc_node *sns[PF_SN_MAX];/* source nodes */
10621133 u_int64_t packets[2];
10631134 u_int64_t bytes[2];
1064 u_int32_t creation;
1065 u_int32_t expire;
1135 u_int64_t creation;
1136 u_int64_t expire;
10661137 u_int32_t pfsync_time;
10671138 struct pf_rule_actions act;
10681139 u_int16_t tag;
1069 u_int8_t rt;
1140 u_int16_t if_index_in;
1141 u_int16_t if_index_out;
10701142};
10711143
10721144/*
1073 * Size <= fits 11 objects per page on LP64. Try to not grow the struct beyond that.
1145 * 6 cache lines per struct, 10 structs per page.
1146 * Try to not grow the struct beyond that.
10741147 */
1075_Static_assert(sizeof(struct pf_kstate) <= 368, "pf_kstate size crosses 368 bytes");
1148_Static_assert(sizeof(struct pf_kstate) <= 384, "pf_kstate size crosses 384 bytes");
1149
1150enum pf_test_status {
1151 PF_TEST_FAIL = -1,
1152 PF_TEST_OK,
1153 PF_TEST_QUICK
1154};
1155
1156struct pf_test_ctx {
1157 enum pf_test_status test_status;
1158 struct pf_pdesc *pd;
1159 struct pf_rule_actions act;
1160 uint8_t icmpcode;
1161 uint8_t icmptype;
1162 int icmp_dir;
1163 int state_icmp;
1164 int tag;
1165 int rewrite;
1166 u_short reason;
1167 struct pf_src_node *sns[PF_SN_MAX];
1168 struct pf_krule *nr;
1169 struct pf_krule *tr;
1170 struct pf_krule **rm;
1171 struct pf_krule *a;
1172 struct pf_krule **am;
1173 struct pf_kruleset **rsm;
1174 struct pf_kruleset *arsm;
1175 struct pf_kruleset *aruleset;
1176 struct pf_state_key *sk;
1177 struct pf_state_key *nk;
1178 struct tcphdr *th;
1179 struct pf_udp_mapping *udp_mapping;
1180 struct pf_kpool *nat_pool;
1181 uint16_t virtual_type;
1182 uint16_t virtual_id;
1183 int depth;
1184};
1185
1186#define PF_ANCHOR_STACK_MAX 32
10761187#endif
10771188
10781189/*
10791190 * Unified state structures for pulling states out of the kernel
10801191 * used by pfsync(4) and the pf(4) ioctl.
10811192 */
1082struct pfsync_state_scrub {
1083 u_int16_t pfss_flags;
1084 u_int8_t pfss_ttl; /* stashed TTL */
1085#define PFSYNC_SCRUB_FLAG_VALID 0x01
1086 u_int8_t scrub_flag;
1087 u_int32_t pfss_ts_mod; /* timestamp modulation */
1088} __packed;
1089
1090struct pfsync_state_peer {
1091 struct pfsync_state_scrub scrub; /* state is scrubbed */
1092 u_int32_t seqlo; /* Max sequence number sent */
1093 u_int32_t seqhi; /* Max the other end ACKd + win */
1094 u_int32_t seqdiff; /* Sequence number modulator */
1095 u_int16_t max_win; /* largest window (pre scaling) */
1096 u_int16_t mss; /* Maximum segment size option */
1097 u_int8_t state; /* active state level */
1098 u_int8_t wscale; /* window scaling factor */
1099 u_int8_t pad[6];
1100} __packed;
1101
11021193struct pfsync_state_key {
11031194 struct pf_addr addr[2];
11041195 u_int16_t port[2];
......@@ -1108,8 +1199,8 @@ struct pfsync_state_1301 {
11081199 u_int64_t id;
11091200 char ifname[IFNAMSIZ];
11101201 struct pfsync_state_key key[2];
1111 struct pfsync_state_peer src;
1112 struct pfsync_state_peer dst;
1202 struct pf_state_peer_export src;
1203 struct pf_state_peer_export dst;
11131204 struct pf_addr rt_addr;
11141205 u_int32_t rule;
11151206 u_int32_t anchor;
......@@ -1127,16 +1218,16 @@ struct pfsync_state_1301 {
11271218 u_int8_t state_flags;
11281219 u_int8_t timeout;
11291220 u_int8_t sync_flags;
1130 u_int8_t updates;
1221 u_int8_t updates; /* unused */
11311222} __packed;
11321223
11331224struct pfsync_state_1400 {
1134 /* The beginning of the struct is compatible with previous versions */
1225 /* The beginning of the struct is compatible with pfsync_state_1301 */
11351226 u_int64_t id;
11361227 char ifname[IFNAMSIZ];
11371228 struct pfsync_state_key key[2];
1138 struct pfsync_state_peer src;
1139 struct pfsync_state_peer dst;
1229 struct pf_state_peer_export src;
1230 struct pf_state_peer_export dst;
11401231 struct pf_addr rt_addr;
11411232 u_int32_t rule;
11421233 u_int32_t anchor;
......@@ -1154,7 +1245,7 @@ struct pfsync_state_1400 {
11541245 u_int8_t __spare;
11551246 u_int8_t timeout;
11561247 u_int8_t sync_flags;
1157 u_int8_t updates;
1248 u_int8_t updates; /* unused */
11581249 /* The rest is not */
11591250 u_int16_t qid;
11601251 u_int16_t pqid;
......@@ -1167,12 +1258,54 @@ struct pfsync_state_1400 {
11671258 u_int8_t set_prio[2];
11681259 u_int8_t rt;
11691260 char rt_ifname[IFNAMSIZ];
1261} __packed;
11701262
1263struct pfsync_state_1500 {
1264 /* The beginning of the struct is compatible with pfsync_state_1301 */
1265 u_int64_t id;
1266 char ifname[IFNAMSIZ];
1267 struct pfsync_state_key key[2];
1268 struct pf_state_peer_export src;
1269 struct pf_state_peer_export dst;
1270 struct pf_addr rt_addr;
1271 u_int32_t rule;
1272 u_int32_t anchor;
1273 u_int32_t nat_rule;
1274 u_int32_t creation;
1275 u_int32_t expire;
1276 u_int32_t packets[2][2];
1277 u_int32_t bytes[2][2];
1278 u_int32_t creatorid;
1279 /* The rest is not, use the opportunity to fix alignment */
1280 char tagname[PF_TAG_NAME_SIZE];
1281 char rt_ifname[IFNAMSIZ];
1282 char orig_ifname[IFNAMSIZ];
1283 int32_t rtableid;
1284 u_int16_t state_flags;
1285 u_int16_t qid;
1286 u_int16_t pqid;
1287 u_int16_t dnpipe;
1288 u_int16_t dnrpipe;
1289 u_int16_t max_mss;
1290 sa_family_t wire_af;
1291 sa_family_t stack_af;
1292 sa_family_t rt_af;
1293 u_int8_t wire_proto;
1294 u_int8_t stack_proto;
1295 u_int8_t log;
1296 u_int8_t timeout;
1297 u_int8_t direction;
1298 u_int8_t rt;
1299 u_int8_t min_ttl;
1300 u_int8_t set_tos;
1301 u_int8_t set_prio[2];
1302 u_int8_t spare[3]; /* Improve struct alignment */
11711303} __packed;
11721304
11731305union pfsync_state_union {
11741306 struct pfsync_state_1301 pfs_1301;
11751307 struct pfsync_state_1400 pfs_1400;
1308 struct pfsync_state_1500 pfs_1500;
11761309} __packed;
11771310
11781311#ifdef _KERNEL
......@@ -1184,6 +1317,8 @@ typedef void pfsync_delete_state_t(struct pf_kstate *);
11841317typedef void pfsync_clear_states_t(u_int32_t, const char *);
11851318typedef int pfsync_defer_t(struct pf_kstate *, struct mbuf *);
11861319typedef void pfsync_detach_ifnet_t(struct ifnet *);
1320typedef void pflow_export_state_t(const struct pf_kstate *);
1321typedef bool pf_addr_filter_func_t(const sa_family_t, const struct pf_addr *);
11871322
11881323VNET_DECLARE(pfsync_state_import_t *, pfsync_state_import_ptr);
11891324#define V_pfsync_state_import_ptr VNET(pfsync_state_import_ptr)
......@@ -1197,6 +1332,8 @@ VNET_DECLARE(pfsync_clear_states_t *, pfsync_clear_states_ptr);
11971332#define V_pfsync_clear_states_ptr VNET(pfsync_clear_states_ptr)
11981333VNET_DECLARE(pfsync_defer_t *, pfsync_defer_ptr);
11991334#define V_pfsync_defer_ptr VNET(pfsync_defer_ptr)
1335VNET_DECLARE(pflow_export_state_t *, pflow_export_state_ptr);
1336#define V_pflow_export_state_ptr VNET(pflow_export_state_ptr)
12001337extern pfsync_detach_ifnet_t *pfsync_detach_ifnet_ptr;
12011338
12021339void pfsync_state_export(union pfsync_state_union *,
......@@ -1207,9 +1344,9 @@ void pf_state_export(struct pf_state_export *,
12071344/* pflog */
12081345struct pf_kruleset;
12091346struct pf_pdesc;
1210typedef int pflog_packet_t(struct pfi_kkif *, struct mbuf *, sa_family_t,
1211 u_int8_t, struct pf_krule *, struct pf_krule *, struct pf_kruleset *,
1212 struct pf_pdesc *, int);
1347typedef int pflog_packet_t(uint8_t, u_int8_t,
1348 struct pf_krule *, struct pf_krule *, struct pf_kruleset *,
1349 struct pf_pdesc *, int, struct pf_krule *);
12131350extern pflog_packet_t *pflog_packet_ptr;
12141351
12151352#endif /* _KERNEL */
......@@ -1219,39 +1356,10 @@ extern pflog_packet_t *pflog_packet_ptr;
12191356
12201357/* for copies to/from network byte order */
12211358/* ioctl interface also uses network byte order */
1222#define pf_state_peer_hton(s,d) do { \
1223 (d)->seqlo = htonl((s)->seqlo); \
1224 (d)->seqhi = htonl((s)->seqhi); \
1225 (d)->seqdiff = htonl((s)->seqdiff); \
1226 (d)->max_win = htons((s)->max_win); \
1227 (d)->mss = htons((s)->mss); \
1228 (d)->state = (s)->state; \
1229 (d)->wscale = (s)->wscale; \
1230 if ((s)->scrub) { \
1231 (d)->scrub.pfss_flags = \
1232 htons((s)->scrub->pfss_flags & PFSS_TIMESTAMP); \
1233 (d)->scrub.pfss_ttl = (s)->scrub->pfss_ttl; \
1234 (d)->scrub.pfss_ts_mod = htonl((s)->scrub->pfss_ts_mod);\
1235 (d)->scrub.scrub_flag = PFSYNC_SCRUB_FLAG_VALID; \
1236 } \
1237} while (0)
1238
1239#define pf_state_peer_ntoh(s,d) do { \
1240 (d)->seqlo = ntohl((s)->seqlo); \
1241 (d)->seqhi = ntohl((s)->seqhi); \
1242 (d)->seqdiff = ntohl((s)->seqdiff); \
1243 (d)->max_win = ntohs((s)->max_win); \
1244 (d)->mss = ntohs((s)->mss); \
1245 (d)->state = (s)->state; \
1246 (d)->wscale = (s)->wscale; \
1247 if ((s)->scrub.scrub_flag == PFSYNC_SCRUB_FLAG_VALID && \
1248 (d)->scrub != NULL) { \
1249 (d)->scrub->pfss_flags = \
1250 ntohs((s)->scrub.pfss_flags) & PFSS_TIMESTAMP; \
1251 (d)->scrub->pfss_ttl = (s)->scrub.pfss_ttl; \
1252 (d)->scrub->pfss_ts_mod = ntohl((s)->scrub.pfss_ts_mod);\
1253 } \
1254} while (0)
1359void pf_state_peer_hton(const struct pf_state_peer *,
1360 struct pf_state_peer_export *);
1361void pf_state_peer_ntoh(const struct pf_state_peer_export *,
1362 struct pf_state_peer *);
12551363
12561364#define pf_state_counter_hton(s,d) do { \
12571365 d[0] = htonl((s>>32)&0xffffffff); \
......@@ -1276,7 +1384,6 @@ struct pf_kruleset {
12761384 struct pf_krulequeue queues[2];
12771385 struct {
12781386 struct pf_krulequeue *ptr;
1279 struct pf_krule **ptr_array;
12801387 u_int32_t rcount;
12811388 u_int32_t ticket;
12821389 int open;
......@@ -1329,7 +1436,6 @@ RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare);
13291436 PFR_TFLAG_REFDANCHOR | \
13301437 PFR_TFLAG_COUNTERS)
13311438
1332struct pf_kanchor_stackframe;
13331439struct pf_keth_anchor_stackframe;
13341440
13351441struct pfr_table {
......@@ -1366,7 +1472,7 @@ struct pfr_astats {
13661472 struct pfr_addr pfras_a;
13671473 u_int64_t pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
13681474 u_int64_t pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
1369 long pfras_tzero;
1475 time_t pfras_tzero;
13701476};
13711477
13721478enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX };
......@@ -1377,7 +1483,7 @@ struct pfr_tstats {
13771483 u_int64_t pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
13781484 u_int64_t pfrts_match;
13791485 u_int64_t pfrts_nomatch;
1380 long pfrts_tzero;
1486 time_t pfrts_tzero;
13811487 int pfrts_cnt;
13821488 int pfrts_refcnt[PFR_REFCNT_MAX];
13831489};
......@@ -1439,7 +1545,7 @@ struct pfr_ktstats {
14391545 struct pfr_kstate_counter pfrkts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
14401546 struct pfr_kstate_counter pfrkts_match;
14411547 struct pfr_kstate_counter pfrkts_nomatch;
1442 long pfrkts_tzero;
1548 time_t pfrkts_tzero;
14431549 int pfrkts_cnt;
14441550 int pfrkts_refcnt[PFR_REFCNT_MAX];
14451551};
......@@ -1460,7 +1566,7 @@ union sockaddr_union {
14601566
14611567struct pfr_kcounters {
14621568 counter_u64_t pfrkc_counters;
1463 long pfrkc_tzero;
1569 time_t pfrkc_tzero;
14641570};
14651571#define pfr_kentry_counter(kc, dir, op, t) \
14661572 ((kc)->pfrkc_counters + \
......@@ -1518,7 +1624,7 @@ struct pfi_kkif {
15181624#define pfik_list _pfik_glue._pfik_list
15191625 struct pf_counter_u64 pfik_packets[2][2][2];
15201626 struct pf_counter_u64 pfik_bytes[2][2][2];
1521 u_int32_t pfik_tzero;
1627 time_t pfik_tzero;
15221628 u_int pfik_flags;
15231629 struct ifnet *pfik_ifp;
15241630 struct ifg_group *pfik_group;
......@@ -1532,6 +1638,7 @@ struct pfi_kkif {
15321638
15331639#define PFI_IFLAG_REFS 0x0001 /* has state references */
15341640#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */
1641#define PFI_IFLAG_ANY 0x0200 /* match any non-loopback interface */
15351642
15361643#ifdef _KERNEL
15371644struct pf_sctp_multihome_job;
......@@ -1555,25 +1662,49 @@ struct pf_pdesc {
15551662 char any[0];
15561663 } hdr;
15571664
1558 struct pf_krule *nat_rule; /* nat/rdr rule applied to packet */
1665 struct pf_addr nsaddr; /* src address after NAT */
1666 struct pf_addr ndaddr; /* dst address after NAT */
1667
1668 struct pfi_kkif *kif; /* incomming interface */
1669 struct mbuf *m;
1670
15591671 struct pf_addr *src; /* src address */
15601672 struct pf_addr *dst; /* dst address */
1561 u_int16_t *sport;
1562 u_int16_t *dport;
1673 struct pf_addr osrc;
1674 struct pf_addr odst;
1675 u_int16_t *pcksum; /* proto cksum */
1676 u_int16_t *sport;
1677 u_int16_t *dport;
1678 u_int16_t osport;
1679 u_int16_t odport;
1680 u_int16_t nsport; /* src port after NAT */
1681 u_int16_t ndport; /* dst port after NAT */
15631682 struct pf_mtag *pf_mtag;
15641683 struct pf_rule_actions act;
15651684
1566 u_int32_t p_len; /* total length of payload */
1685 u_int32_t off; /* protocol header offset */
1686 bool df; /* IPv4 Don't fragment flag. */
1687 u_int32_t hdrlen; /* protocol header length */
1688 u_int32_t p_len; /* total length of protocol payload */
1689 u_int32_t extoff; /* extentsion header offset */
1690 u_int32_t fragoff; /* fragment header offset */
1691 u_int32_t jumbolen; /* length from v6 jumbo header */
1692 u_int32_t badopts; /* v4 options or v6 routing headers */
1693#define PF_OPT_OTHER 0x0001
1694#define PF_OPT_JUMBO 0x0002
1695#define PF_OPT_ROUTER_ALERT 0x0004
15671696
15681697 u_int16_t *ip_sum;
1569 u_int16_t *proto_sum;
15701698 u_int16_t flags; /* Let SCRUB trigger behavior in
15711699 * state code. Easier than tags */
15721700#define PFDESC_TCP_NORM 0x0001 /* TCP shall be statefully scrubbed */
1573#define PFDESC_IP_REAS 0x0002 /* IP frags would've been reassembled */
1701 u_int16_t virtual_proto;
1702#define PF_VPROTO_FRAGMENT 256
15741703 sa_family_t af;
1704 sa_family_t naf;
15751705 u_int8_t proto;
15761706 u_int8_t tos;
1707 u_int8_t ttl;
15771708 u_int8_t dir; /* direction */
15781709 u_int8_t sidx; /* key index for source */
15791710 u_int8_t didx; /* key index for destination */
......@@ -1592,6 +1723,8 @@ struct pf_pdesc {
15921723#define PFDESC_SCTP_ADD_IP 0x1000
15931724 u_int16_t sctp_flags;
15941725 u_int32_t sctp_initiate_tag;
1726 u_int16_t sctp_dummy_sum;
1727 struct pf_krule *related_rule;
15951728
15961729 struct pf_sctp_multihome_jobs sctp_multihome_jobs;
15971730};
......@@ -1601,7 +1734,6 @@ struct pf_sctp_multihome_job {
16011734 struct pf_pdesc pd;
16021735 struct pf_addr src;
16031736 struct pf_addr dst;
1604 struct mbuf *m;
16051737 int op;
16061738};
16071739
......@@ -1647,6 +1779,7 @@ struct pf_sctp_multihome_job {
16471779
16481780#define REASON_SET(a, x) \
16491781 do { \
1782 SDT_PROBE2(pf, , test, reason_set, x, __LINE__); \
16501783 if ((a) != NULL) \
16511784 *(a) = (x); \
16521785 if (x < PFRES_MAX) \
......@@ -1697,6 +1830,13 @@ struct pf_divert {
16971830#define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */
16981831#define PFR_KENTRY_HIWAT 200000 /* Number of table entries */
16991832
1833struct pf_fragment_tag {
1834 uint16_t ft_hdrlen; /* header length of reassembled pkt */
1835 uint16_t ft_extoff; /* last extension header offset or 0 */
1836 uint16_t ft_maxlen; /* maximum fragment payload length */
1837 uint32_t ft_id; /* fragment id */
1838};
1839
17001840/*
17011841 * Limit the length of the fragment queue traversal. Remember
17021842 * search entry points based on the fragment offset.
......@@ -1773,6 +1913,7 @@ struct pf_kstate_kill {
17731913 char psk_label[PF_RULE_LABEL_SIZE];
17741914 u_int psk_killed;
17751915 bool psk_kill_match;
1916 bool psk_nat;
17761917};
17771918#endif
17781919
......@@ -1944,29 +2085,25 @@ struct pfioc_iface {
19442085#define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule)
19452086#define DIOCADDRULENV _IOWR('D', 4, struct pfioc_nv)
19462087#define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule)
1947#define DIOCGETRULE _IOWR('D', 7, struct pfioc_rule)
19482088#define DIOCGETRULENV _IOWR('D', 7, struct pfioc_nv)
1949/* XXX cut 8 - 17 */
1950#define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill)
19512089#define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv)
19522090#define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state)
19532091#define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv)
19542092#define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if)
1955#define DIOCGETSTATUS _IOWR('D', 21, struct pf_status)
19562093#define DIOCGETSTATUSNV _IOWR('D', 21, struct pfioc_nv)
19572094#define DIOCCLRSTATUS _IO ('D', 22)
19582095#define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook)
19592096#define DIOCSETDEBUG _IOWR('D', 24, u_int32_t)
2097#ifdef COMPAT_FREEBSD14
19602098#define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states)
2099#endif
19612100#define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule)
1962/* XXX cut 26 - 28 */
19632101#define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm)
19642102#define DIOCGETTIMEOUT _IOWR('D', 30, struct pfioc_tm)
19652103#define DIOCADDSTATE _IOWR('D', 37, struct pfioc_state)
19662104#define DIOCCLRRULECTRS _IO ('D', 38)
19672105#define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit)
19682106#define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit)
1969#define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill)
19702107#define DIOCKILLSTATESNV _IOWR('D', 41, struct pfioc_nv)
19712108#define DIOCSTARTALTQ _IO ('D', 42)
19722109#define DIOCSTOPALTQ _IO ('D', 43)
......@@ -1985,7 +2122,6 @@ struct pfioc_iface {
19852122#define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr)
19862123#define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr)
19872124#define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr)
1988/* XXX cut 55 - 57 */
19892125#define DIOCGETRULESETS _IOWR('D', 58, struct pfioc_ruleset)
19902126#define DIOCGETRULESET _IOWR('D', 59, struct pfioc_ruleset)
19912127#define DIOCRCLRTABLES _IOWR('D', 60, struct pfioc_table)
......@@ -2019,7 +2155,9 @@ struct pfioc_iface {
20192155#define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill)
20202156#define DIOCGIFSPEEDV0 _IOWR('D', 92, struct pf_ifspeed_v0)
20212157#define DIOCGIFSPEEDV1 _IOWR('D', 92, struct pf_ifspeed_v1)
2158#ifdef COMPAT_FREEBSD14
20222159#define DIOCGETSTATESV2 _IOWR('D', 93, struct pfioc_states_v2)
2160#endif
20232161#define DIOCGETSYNCOOKIES _IOWR('D', 94, struct pfioc_nv)
20242162#define DIOCSETSYNCOOKIES _IOWR('D', 95, struct pfioc_nv)
20252163#define DIOCKEEPCOUNTERS _IOWR('D', 96, struct pfioc_nv)
......@@ -2103,21 +2241,33 @@ struct pf_idhash {
21032241 struct mtx lock;
21042242};
21052243
2244struct pf_udpendpointhash {
2245 LIST_HEAD(, pf_udp_endpoint) endpoints;
2246 /* refcont is synchronized on the source endpoint's row lock */
2247 struct mtx lock;
2248};
2249
21062250extern u_long pf_ioctl_maxcount;
21072251VNET_DECLARE(u_long, pf_hashmask);
21082252#define V_pf_hashmask VNET(pf_hashmask)
21092253VNET_DECLARE(u_long, pf_srchashmask);
21102254#define V_pf_srchashmask VNET(pf_srchashmask)
2255VNET_DECLARE(u_long, pf_udpendpointhashmask);
2256#define V_pf_udpendpointhashmask VNET(pf_udpendpointhashmask)
21112257#define PF_HASHSIZ (131072)
21122258#define PF_SRCHASHSIZ (PF_HASHSIZ/4)
2259#define PF_UDPENDHASHSIZ (PF_HASHSIZ/4)
21132260VNET_DECLARE(struct pf_keyhash *, pf_keyhash);
21142261VNET_DECLARE(struct pf_idhash *, pf_idhash);
2262VNET_DECLARE(struct pf_udpendpointhash *, pf_udpendpointhash);
21152263#define V_pf_keyhash VNET(pf_keyhash)
21162264#define V_pf_idhash VNET(pf_idhash)
2265#define V_pf_udpendpointhash VNET(pf_udpendpointhash)
21172266VNET_DECLARE(struct pf_srchash *, pf_srchash);
21182267#define V_pf_srchash VNET(pf_srchash)
21192268
2120#define PF_IDHASH(s) (be64toh((s)->id) % (V_pf_hashmask + 1))
2269#define PF_IDHASHID(id) (be64toh(id) % (V_pf_hashmask + 1))
2270#define PF_IDHASH(s) PF_IDHASHID((s)->id)
21212271
21222272VNET_DECLARE(void *, pf_swi_cookie);
21232273#define V_pf_swi_cookie VNET(pf_swi_cookie)
......@@ -2130,7 +2280,7 @@ VNET_DECLARE(struct unrhdr64, pf_stateid);
21302280TAILQ_HEAD(pf_altqqueue, pf_altq);
21312281VNET_DECLARE(struct pf_altqqueue, pf_altqs[4]);
21322282#define V_pf_altqs VNET(pf_altqs)
2133VNET_DECLARE(struct pf_kpalist, pf_pabuf);
2283VNET_DECLARE(struct pf_kpalist, pf_pabuf[3]);
21342284#define V_pf_pabuf VNET(pf_pabuf)
21352285
21362286VNET_DECLARE(u_int32_t, ticket_altqs_active);
......@@ -2171,6 +2321,8 @@ VNET_DECLARE(struct pf_krule *, pf_rulemarker);
21712321#define V_pf_rulemarker VNET(pf_rulemarker)
21722322#endif
21732323
2324int pf_start(void);
2325int pf_stop(void);
21742326void pf_initialize(void);
21752327void pf_mtag_initialize(void);
21762328void pf_mtag_cleanup(void);
......@@ -2186,15 +2338,21 @@ VNET_DECLARE(uma_zone_t, pf_state_z);
21862338#define V_pf_state_z VNET(pf_state_z)
21872339VNET_DECLARE(uma_zone_t, pf_state_key_z);
21882340#define V_pf_state_key_z VNET(pf_state_key_z)
2341VNET_DECLARE(uma_zone_t, pf_udp_mapping_z);
2342#define V_pf_udp_mapping_z VNET(pf_udp_mapping_z)
21892343VNET_DECLARE(uma_zone_t, pf_state_scrub_z);
21902344#define V_pf_state_scrub_z VNET(pf_state_scrub_z)
2345VNET_DECLARE(uma_zone_t, pf_anchor_z);
2346#define V_pf_anchor_z VNET(pf_anchor_z)
2347VNET_DECLARE(uma_zone_t, pf_eth_anchor_z);
2348#define V_pf_eth_anchor_z VNET(pf_eth_anchor_z)
21912349
21922350extern void pf_purge_thread(void *);
21932351extern void pf_unload_vnet_purge(void);
21942352extern void pf_intr(void *);
21952353extern void pf_purge_expired_src_nodes(void);
21962354
2197extern int pf_unlink_state(struct pf_kstate *);
2355extern int pf_remove_state(struct pf_kstate *);
21982356extern int pf_state_insert(struct pfi_kkif *,
21992357 struct pfi_kkif *,
22002358 struct pf_state_key *,
......@@ -2202,6 +2360,9 @@ extern int pf_state_insert(struct pfi_kkif *,
22022360 struct pf_kstate *);
22032361extern struct pf_kstate *pf_alloc_state(int);
22042362extern void pf_free_state(struct pf_kstate *);
2363extern void pf_killstates(struct pf_kstate_kill *,
2364 unsigned int *);
2365extern unsigned int pf_clear_states(const struct pf_kstate_kill *);
22052366
22062367static __inline void
22072368pf_ref_state(struct pf_kstate *s)
......@@ -2232,6 +2393,22 @@ pf_release_staten(struct pf_kstate *s, u_int n)
22322393 return (0);
22332394}
22342395
2396static __inline uint64_t
2397pf_get_uptime(void)
2398{
2399 struct timeval t;
2400 microuptime(&t);
2401 return ((t.tv_sec * 1000) + (t.tv_usec / 1000));
2402}
2403
2404static __inline uint64_t
2405pf_get_time(void)
2406{
2407 struct timeval t;
2408 microtime(&t);
2409 return ((t.tv_sec * 1000) + (t.tv_usec / 1000));
2410}
2411
22352412extern struct pf_kstate *pf_find_state_byid(uint64_t, uint32_t);
22362413extern struct pf_kstate *pf_find_state_all(
22372414 const struct pf_state_key_cmp *,
......@@ -2239,13 +2416,25 @@ extern struct pf_kstate *pf_find_state_all(
22392416extern bool pf_find_state_all_exists(
22402417 const struct pf_state_key_cmp *,
22412418 u_int);
2419extern struct pf_udp_mapping *pf_udp_mapping_find(struct pf_udp_endpoint_cmp
2420 *endpoint);
2421extern struct pf_udp_mapping *pf_udp_mapping_create(sa_family_t af,
2422 struct pf_addr *src_addr, uint16_t src_port,
2423 struct pf_addr *nat_addr, uint16_t nat_port);
2424extern int pf_udp_mapping_insert(struct pf_udp_mapping
2425 *mapping);
2426extern void pf_udp_mapping_release(struct pf_udp_mapping
2427 *mapping);
2428uint32_t pf_hashsrc(struct pf_addr *, sa_family_t);
2429extern bool pf_src_node_exists(struct pf_ksrc_node **,
2430 struct pf_srchash *);
22422431extern struct pf_ksrc_node *pf_find_src_node(struct pf_addr *,
22432432 struct pf_krule *, sa_family_t,
2244 struct pf_srchash **, bool);
2433 struct pf_srchash **, pf_sn_types_t, bool);
22452434extern void pf_unlink_src_node(struct pf_ksrc_node *);
22462435extern u_int pf_free_src_nodes(struct pf_ksrc_node_list *);
22472436extern void pf_print_state(struct pf_kstate *);
2248extern void pf_print_flags(u_int8_t);
2437extern void pf_print_flags(uint16_t);
22492438extern int pf_addr_wrap_neq(struct pf_addr_wrap *,
22502439 struct pf_addr_wrap *);
22512440extern u_int16_t pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t,
......@@ -2257,80 +2446,85 @@ VNET_DECLARE(struct ifnet *, sync_ifp);
22572446#define V_sync_ifp VNET(sync_ifp);
22582447VNET_DECLARE(struct pf_krule, pf_default_rule);
22592448#define V_pf_default_rule VNET(pf_default_rule)
2260extern void pf_addrcpy(struct pf_addr *, struct pf_addr *,
2449extern void pf_addrcpy(struct pf_addr *, const struct pf_addr *,
22612450 sa_family_t);
22622451void pf_free_rule(struct pf_krule *);
22632452
22642453int pf_test_eth(int, int, struct ifnet *, struct mbuf **, struct inpcb *);
2265#ifdef INET
2266int pf_test(int, int, struct ifnet *, struct mbuf **, struct inpcb *,
2454int pf_scan_sctp(struct pf_pdesc *);
2455#if defined(INET) || defined(INET6)
2456int pf_test(sa_family_t, int, int, struct ifnet *, struct mbuf **, struct inpcb *,
22672457 struct pf_rule_actions *);
2268int pf_normalize_ip(struct mbuf **, struct pfi_kkif *, u_short *,
2269 struct pf_pdesc *);
2458#endif
2459#ifdef INET
2460int pf_normalize_ip(u_short *, struct pf_pdesc *);
22702461#endif /* INET */
22712462
2272#ifdef INET6
2273int pf_test6(int, int, struct ifnet *, struct mbuf **, struct inpcb *,
2274 struct pf_rule_actions *);
2275int pf_normalize_ip6(struct mbuf **, struct pfi_kkif *, u_short *,
2276 struct pf_pdesc *);
22772463void pf_poolmask(struct pf_addr *, struct pf_addr*,
22782464 struct pf_addr *, struct pf_addr *, sa_family_t);
22792465void pf_addr_inc(struct pf_addr *, sa_family_t);
2280int pf_refragment6(struct ifnet *, struct mbuf **, struct m_tag *, bool);
2466#ifdef INET6
2467int pf_normalize_ip6(int, u_short *, struct pf_pdesc *);
2468int pf_max_frag_size(struct mbuf *);
2469int pf_refragment6(struct ifnet *, struct mbuf **, struct m_tag *,
2470 struct ifnet *, bool);
22812471#endif /* INET6 */
22822472
2283int pf_multihome_scan_init(struct mbuf *, int, int, struct pf_pdesc *,
2284 struct pfi_kkif *);
2285int pf_multihome_scan_asconf(struct mbuf *, int, int, struct pf_pdesc *,
2286 struct pfi_kkif *);
2473int pf_multihome_scan_init(int, int, struct pf_pdesc *);
2474int pf_multihome_scan_asconf(int, int, struct pf_pdesc *);
22872475
22882476u_int32_t pf_new_isn(struct pf_kstate *);
2289void *pf_pull_hdr(struct mbuf *, int, void *, int, u_short *, u_short *,
2477void *pf_pull_hdr(const struct mbuf *, int, void *, int, u_short *, u_short *,
22902478 sa_family_t);
22912479void pf_change_a(void *, u_int16_t *, u_int32_t, u_int8_t);
22922480void pf_change_proto_a(struct mbuf *, void *, u_int16_t *, u_int32_t,
22932481 u_int8_t);
22942482void pf_change_tcp_a(struct mbuf *, void *, u_int16_t *, u_int32_t);
2295void pf_patch_16_unaligned(struct mbuf *, u_int16_t *, void *, u_int16_t,
2296 bool, u_int8_t);
2297void pf_patch_32_unaligned(struct mbuf *, u_int16_t *, void *, u_int32_t,
2298 bool, u_int8_t);
2483int pf_patch_16(struct pf_pdesc *, void *, u_int16_t, bool);
2484int pf_patch_32(struct pf_pdesc *, void *, u_int32_t, bool);
22992485void pf_send_deferred_syn(struct pf_kstate *);
2300int pf_match_addr(u_int8_t, struct pf_addr *, struct pf_addr *,
2301 struct pf_addr *, sa_family_t);
2302int pf_match_addr_range(struct pf_addr *, struct pf_addr *,
2303 struct pf_addr *, sa_family_t);
2486int pf_match_addr(u_int8_t, const struct pf_addr *,
2487 const struct pf_addr *, const struct pf_addr *, sa_family_t);
2488int pf_match_addr_range(const struct pf_addr *, const struct pf_addr *,
2489 const struct pf_addr *, sa_family_t);
23042490int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t);
23052491
23062492void pf_normalize_init(void);
23072493void pf_normalize_cleanup(void);
2308int pf_normalize_tcp(struct pfi_kkif *, struct mbuf *, int, int, void *,
2309 struct pf_pdesc *);
2494int pf_normalize_tcp(struct pf_pdesc *);
23102495void pf_normalize_tcp_cleanup(struct pf_kstate *);
2311int pf_normalize_tcp_init(struct mbuf *, int, struct pf_pdesc *,
2312 struct tcphdr *, struct pf_state_peer *, struct pf_state_peer *);
2313int pf_normalize_tcp_stateful(struct mbuf *, int, struct pf_pdesc *,
2496int pf_normalize_tcp_init(struct pf_pdesc *,
2497 struct tcphdr *, struct pf_state_peer *);
2498int pf_normalize_tcp_stateful(struct pf_pdesc *,
23142499 u_short *, struct tcphdr *, struct pf_kstate *,
23152500 struct pf_state_peer *, struct pf_state_peer *, int *);
2316int pf_normalize_sctp_init(struct mbuf *, int, struct pf_pdesc *,
2501int pf_normalize_sctp_init(struct pf_pdesc *,
23172502 struct pf_state_peer *, struct pf_state_peer *);
2318int pf_normalize_sctp(int, struct pfi_kkif *, struct mbuf *, int,
2319 int, void *, struct pf_pdesc *);
2503int pf_normalize_sctp(struct pf_pdesc *);
23202504u_int32_t
23212505 pf_state_expires(const struct pf_kstate *);
23222506void pf_purge_expired_fragments(void);
23232507void pf_purge_fragments(uint32_t);
23242508int pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kkif *,
23252509 int);
2326int pf_socket_lookup(struct pf_pdesc *, struct mbuf *);
2510int pf_socket_lookup(struct pf_pdesc *);
23272511struct pf_state_key *pf_alloc_state_key(int);
2512int pf_translate(struct pf_pdesc *, struct pf_addr *, u_int16_t,
2513 struct pf_addr *, u_int16_t, u_int16_t, int);
2514int pf_translate_af(struct pf_pdesc *);
2515bool pf_init_threshold(struct pf_kthreshold *, uint32_t, uint32_t);
2516uint16_t pf_tagname2tag(const char *);
2517#ifdef ALTQ
2518uint16_t pf_qname2qid(const char *, bool);
2519#endif /* ALTQ */
2520
23282521void pfr_initialize(void);
23292522void pfr_cleanup(void);
23302523int pfr_match_addr(struct pfr_ktable *, struct pf_addr *, sa_family_t);
23312524void pfr_update_stats(struct pfr_ktable *, struct pf_addr *, sa_family_t,
23322525 u_int64_t, int, int, int);
2333int pfr_pool_get(struct pfr_ktable *, int *, struct pf_addr *, sa_family_t);
2526int pfr_pool_get(struct pfr_ktable *, int *, struct pf_addr *, sa_family_t,
2527 pf_addr_filter_func_t, bool);
23342528void pfr_dynaddr_update(struct pfr_ktable *, struct pfi_dynaddr *);
23352529struct pfr_ktable *
23362530 pfr_attach_table(struct pf_kruleset *, char *);
......@@ -2346,7 +2540,7 @@ int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int);
23462540int pfr_clr_tstats(struct pfr_table *, int, int *, int);
23472541int pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int);
23482542int pfr_clr_addrs(struct pfr_table *, int *, int);
2349int pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, long);
2543int pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, time_t);
23502544int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
23512545 int);
23522546int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
......@@ -2364,6 +2558,8 @@ int pfr_ina_rollback(struct pfr_table *, u_int32_t, int *, int);
23642558int pfr_ina_commit(struct pfr_table *, u_int32_t, int *, int *, int);
23652559int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,
23662560 int *, u_int32_t, int);
2561struct pfr_ktable
2562 *pfr_ktable_select_active(struct pfr_ktable *);
23672563
23682564MALLOC_DECLARE(PFI_MTYPE);
23692565VNET_DECLARE(struct pfi_kkif *, pfi_all);
......@@ -2390,21 +2586,23 @@ int pfi_set_flags(const char *, int);
23902586int pfi_clear_flags(const char *, int);
23912587
23922588int pf_match_tag(struct mbuf *, struct pf_krule *, int *, int);
2393int pf_tag_packet(struct mbuf *, struct pf_pdesc *, int);
2589int pf_tag_packet(struct pf_pdesc *, int);
23942590int pf_addr_cmp(struct pf_addr *, struct pf_addr *,
23952591 sa_family_t);
23962592
2397u_int16_t pf_get_mss(struct mbuf *, int, u_int16_t, sa_family_t);
2398u_int8_t pf_get_wscale(struct mbuf *, int, u_int16_t, sa_family_t);
2593uint8_t* pf_find_tcpopt(u_int8_t *, u_int8_t *, size_t,
2594 u_int8_t, u_int8_t);
2595u_int16_t pf_get_mss(struct pf_pdesc *);
2596u_int8_t pf_get_wscale(struct pf_pdesc *);
23992597struct mbuf *pf_build_tcp(const struct pf_krule *, sa_family_t,
24002598 const struct pf_addr *, const struct pf_addr *,
24012599 u_int16_t, u_int16_t, u_int32_t, u_int32_t,
2402 u_int8_t, u_int16_t, u_int16_t, u_int8_t, bool,
2403 u_int16_t, u_int16_t, int);
2600 u_int8_t, u_int16_t, u_int16_t, u_int8_t, int,
2601 u_int16_t, u_int16_t, u_int, int);
24042602void pf_send_tcp(const struct pf_krule *, sa_family_t,
24052603 const struct pf_addr *, const struct pf_addr *,
24062604 u_int16_t, u_int16_t, u_int32_t, u_int32_t,
2407 u_int8_t, u_int16_t, u_int16_t, u_int8_t, bool,
2605 u_int8_t, u_int16_t, u_int16_t, u_int8_t, int,
24082606 u_int16_t, u_int16_t, int);
24092607
24102608void pf_syncookies_init(void);
......@@ -2412,12 +2610,10 @@ void pf_syncookies_cleanup(void);
24122610int pf_get_syncookies(struct pfioc_nv *);
24132611int pf_set_syncookies(struct pfioc_nv *);
24142612int pf_synflood_check(struct pf_pdesc *);
2415void pf_syncookie_send(struct mbuf *m, int off,
2416 struct pf_pdesc *);
2613void pf_syncookie_send(struct pf_pdesc *);
24172614bool pf_syncookie_check(struct pf_pdesc *);
24182615u_int8_t pf_syncookie_validate(struct pf_pdesc *);
2419struct mbuf * pf_syncookie_recreate_syn(uint8_t, int,
2420 struct pf_pdesc *);
2616struct mbuf * pf_syncookie_recreate_syn(struct pf_pdesc *);
24212617
24222618VNET_DECLARE(struct pf_kstatus, pf_status);
24232619#define V_pf_status VNET(pf_status)
......@@ -2432,6 +2628,20 @@ VNET_DECLARE(struct pf_limit, pf_limits[PF_LIMIT_MAX]);
24322628#endif /* _KERNEL */
24332629
24342630#ifdef _KERNEL
2631struct pf_nl_pooladdr {
2632 u_int32_t action;
2633 u_int32_t ticket;
2634 u_int32_t nr;
2635 u_int32_t r_num;
2636 u_int8_t r_action;
2637 u_int8_t r_last;
2638 u_int8_t af;
2639 char anchor[MAXPATHLEN];
2640 struct pf_pooladdr addr;
2641 /* Above this is identical to pfioc_pooladdr */
2642 int which;
2643};
2644
24352645VNET_DECLARE(struct pf_kanchor_global, pf_anchors);
24362646#define V_pf_anchors VNET(pf_anchors)
24372647VNET_DECLARE(struct pf_kanchor, pf_main_anchor);
......@@ -2449,15 +2659,17 @@ void pf_init_kruleset(struct pf_kruleset *);
24492659void pf_init_keth(struct pf_keth_ruleset *);
24502660int pf_kanchor_setup(struct pf_krule *,
24512661 const struct pf_kruleset *, const char *);
2662int pf_kanchor_copyout(const struct pf_kruleset *,
2663 const struct pf_krule *, char *, size_t);
24522664int pf_kanchor_nvcopyout(const struct pf_kruleset *,
24532665 const struct pf_krule *, nvlist_t *);
2454int pf_kanchor_copyout(const struct pf_kruleset *,
2455 const struct pf_krule *, struct pfioc_rule *);
2456void pf_kanchor_remove(struct pf_krule *);
2666void pf_remove_kanchor(struct pf_krule *);
24572667void pf_remove_if_empty_kruleset(struct pf_kruleset *);
24582668struct pf_kruleset *pf_find_kruleset(const char *);
2669struct pf_kruleset *pf_get_leaf_kruleset(char *, char **);
24592670struct pf_kruleset *pf_find_or_create_kruleset(const char *);
24602671void pf_rs_initialize(void);
2672void pf_rule_tree_free(struct pf_krule_global *);
24612673
24622674
24632675struct pf_krule *pf_krule_alloc(void);
......@@ -2474,15 +2686,33 @@ int pf_keth_anchor_nvcopyout(
24742686struct pf_keth_ruleset *pf_find_or_create_keth_ruleset(const char *);
24752687void pf_keth_anchor_remove(struct pf_keth_rule *);
24762688
2689int pf_ioctl_getrules(struct pfioc_rule *);
2690int pf_ioctl_addrule(struct pf_krule *, uint32_t,
2691 uint32_t, const char *, const char *, uid_t uid,
2692 pid_t);
2693void pf_ioctl_clear_status(void);
2694int pf_ioctl_get_timeout(int, int *);
2695int pf_ioctl_set_timeout(int, int, int *);
2696int pf_ioctl_get_limit(int, unsigned int *);
2697int pf_ioctl_set_limit(int, unsigned int, unsigned int *);
2698int pf_ioctl_begin_addrs(uint32_t *);
2699int pf_ioctl_add_addr(struct pf_nl_pooladdr *);
2700int pf_ioctl_get_addrs(struct pf_nl_pooladdr *);
2701int pf_ioctl_get_addr(struct pf_nl_pooladdr *);
2702int pf_ioctl_get_rulesets(struct pfioc_ruleset *);
2703int pf_ioctl_get_ruleset(struct pfioc_ruleset *);
2704int pf_ioctl_natlook(struct pfioc_natlook *);
2705
24772706void pf_krule_free(struct pf_krule *);
2707void pf_krule_clear_counters(struct pf_krule *);
2708void pf_addr_copyout(struct pf_addr_wrap *);
24782709#endif
24792710
24802711/* The fingerprint functions can be linked into userland programs (tcpdump) */
24812712int pf_osfp_add(struct pf_osfp_ioctl *);
24822713#ifdef _KERNEL
24832714struct pf_osfp_enlist *
2484 pf_osfp_fingerprint(struct pf_pdesc *, struct mbuf *, int,
2485 const struct tcphdr *);
2715 pf_osfp_fingerprint(struct pf_pdesc *, const struct tcphdr *);
24862716#endif /* _KERNEL */
24872717void pf_osfp_flush(void);
24882718int pf_osfp_get(struct pf_osfp_ioctl *);
......@@ -2491,12 +2721,10 @@ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t);
24912721#ifdef _KERNEL
24922722void pf_print_host(struct pf_addr *, u_int16_t, sa_family_t);
24932723
2494void pf_step_into_anchor(struct pf_kanchor_stackframe *, int *,
2495 struct pf_kruleset **, int, struct pf_krule **,
2496 struct pf_krule **, int *);
2497int pf_step_out_of_anchor(struct pf_kanchor_stackframe *, int *,
2498 struct pf_kruleset **, int, struct pf_krule **,
2499 struct pf_krule **, int *);
2724enum pf_test_status pf_step_into_anchor(struct pf_test_ctx *, struct pf_krule *,
2725 struct pf_krule_slist *match_rules);
2726enum pf_test_status pf_match_rule(struct pf_test_ctx *, struct pf_kruleset *,
2727 struct pf_krule_slist *);
25002728void pf_step_into_keth_anchor(struct pf_keth_anchor_stackframe *,
25012729 int *, struct pf_keth_ruleset **,
25022730 struct pf_keth_rule **, struct pf_keth_rule **,
......@@ -2506,33 +2734,48 @@ int pf_step_out_of_keth_anchor(struct pf_keth_anchor_stackframe *,
25062734 struct pf_keth_rule **, struct pf_keth_rule **,
25072735 int *);
25082736
2509u_short pf_map_addr(u_int8_t, struct pf_krule *,
2737u_short pf_map_addr(sa_family_t, struct pf_krule *,
25102738 struct pf_addr *, struct pf_addr *,
2511 struct pfi_kkif **nkif, struct pf_addr *,
2512 struct pf_ksrc_node **);
2513struct pf_krule *pf_get_translation(struct pf_pdesc *, struct mbuf *,
2514 int, struct pfi_kkif *, struct pf_ksrc_node **,
2515 struct pf_state_key **, struct pf_state_key **,
2739 struct pfi_kkif **nkif, sa_family_t *,
2740 struct pf_addr *, struct pf_kpool *);
2741u_short pf_map_addr_sn(u_int8_t, struct pf_krule *,
25162742 struct pf_addr *, struct pf_addr *,
2517 uint16_t, uint16_t, struct pf_kanchor_stackframe *);
2518
2519struct pf_state_key *pf_state_key_setup(struct pf_pdesc *, struct mbuf *, int,
2520 struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_t);
2743 sa_family_t *, struct pfi_kkif **,
2744 struct pf_addr *, struct pf_kpool *,
2745 pf_sn_types_t);
2746int pf_get_transaddr_af(struct pf_krule *,
2747 struct pf_pdesc *);
2748u_short pf_get_translation(struct pf_test_ctx *);
2749u_short pf_get_transaddr(struct pf_test_ctx *,
2750 struct pf_krule *,
2751 u_int8_t, struct pf_kpool *);
2752int pf_translate_compat(struct pf_test_ctx *);
2753
2754int pf_state_key_setup(struct pf_pdesc *,
2755 u_int16_t, u_int16_t,
2756 struct pf_state_key **sk, struct pf_state_key **nk);
25212757struct pf_state_key *pf_state_key_clone(const struct pf_state_key *);
25222758void pf_rule_to_actions(struct pf_krule *,
25232759 struct pf_rule_actions *);
2524int pf_normalize_mss(struct mbuf *m, int off,
2525 struct pf_pdesc *pd);
2526#ifdef INET
2527void pf_scrub_ip(struct mbuf **, struct pf_pdesc *);
2528#endif /* INET */
2529#ifdef INET6
2530void pf_scrub_ip6(struct mbuf **, struct pf_pdesc *);
2531#endif /* INET6 */
2760int pf_normalize_mss(struct pf_pdesc *pd);
2761#if defined(INET) || defined(INET6)
2762void pf_scrub(struct pf_pdesc *);
2763#endif
25322764
25332765struct pfi_kkif *pf_kkif_create(int);
25342766void pf_kkif_free(struct pfi_kkif *);
25352767void pf_kkif_zero(struct pfi_kkif *);
2768
2769
2770/* NAT64 functions. */
2771int inet_nat64(int, const void *, void *, const void *, u_int8_t);
2772int inet_nat64_inet(const void *, void *, const void *, u_int8_t);
2773int inet_nat64_inet6(const void *, void *, const void *, u_int8_t);
2774
2775int inet_nat46(int, const void *, void *, const void *, u_int8_t);
2776int inet_nat46_inet(const void *, void *, const void *, u_int8_t);
2777int inet_nat46_inet6(const void *, void *, const void *, u_int8_t);
2778
25362779#endif /* _KERNEL */
25372780
25382781#endif /* _NET_PFVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/radix.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)radix.h 8.2 (Berkeley) 10/31/94
3230 */
3331
3432#ifndef _RADIX_H_
lib/libc/include/generic-freebsd/net/rndis.h+1-1
......@@ -339,7 +339,7 @@ struct rndis_diag_info {
339339 uint32_t rm_erroffset;
340340};
341341
342/* Keepalive messsage. May be sent by device. */
342/* Keepalive message. May be sent by device. */
343343#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008
344344#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008
345345
lib/libc/include/generic-freebsd/net/route.h+2-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)route.h 8.4 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _NET_ROUTE_H_
......@@ -241,6 +239,7 @@ struct rtstat {
241239 uint64_t rts_add_retry; /* # of route addition retries */
242240 uint64_t rts_del_failure; /* # of route deletion failure */
243241 uint64_t rts_del_retry; /* # of route deletion retries */
242 uint64_t rts_spare[5];
244243};
245244
246245/*
......@@ -296,6 +295,7 @@ struct rt_msghdr {
296295#define RTM_DELMADDR 0x10 /* (4) mcast group membership being deleted */
297296#define RTM_IFANNOUNCE 0x11 /* (5) iface arrival/departure */
298297#define RTM_IEEE80211 0x12 /* (5) IEEE80211 wireless event */
298#define RTM_IPFWLOG 0x13 /* (1) IPFW rule match log event */
299299
300300#endif /* NETLINK_COMPAT*/
301301
lib/libc/include/generic-freebsd/net/route/route_ctl.h+5-5
......@@ -61,11 +61,11 @@ int rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen,
6161 const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc);
6262
6363/* operation flags */
64#define RTM_F_CREATE 0x01
65#define RTM_F_EXCL 0x02
66#define RTM_F_REPLACE 0x04
67#define RTM_F_APPEND 0x08
68#define RTM_F_FORCE 0x10
64#define RTM_F_CREATE 0x01 /* Create object if not exists */
65#define RTM_F_EXCL 0x02 /* (Deprecated) Do not replace or append if exists */
66#define RTM_F_REPLACE 0x04 /* Replace if route (even multipath) if exists */
67#define RTM_F_APPEND 0x08 /* Append path to the route */
68#define RTM_F_FORCE 0x10 /* Bump operation priority to highest */
6969
7070int rib_add_route(uint32_t fibnum, struct rt_addrinfo *info,
7171 struct rib_cmd_info *rc);
lib/libc/include/generic-freebsd/net/route/route_debug.h+5-4
......@@ -116,10 +116,11 @@ SYSCTL_DECL(_net_route_debug);
116116 * Example: [nhop_neigh] nhops_update_neigh: <message>
117117 */
118118#define RT_LOG(_l, _fmt, ...) RT_LOG_##_l(_l, _fmt, ## __VA_ARGS__)
119#define _RT_LOG(_l, _fmt, ...) if (_DEBUG_PASS_MSG(_l)) { \
120 _output("[" DEBUG_PREFIX_NAME "] %s: " _fmt "\n", __func__, ##__VA_ARGS__); \
121}
122
119#define _RT_LOG(_l, _fmt, ...) do { \
120 if (_DEBUG_PASS_MSG(_l)) \
121 _output("[" DEBUG_PREFIX_NAME "] %s: " _fmt "\n", \
122 __func__, ##__VA_ARGS__); \
123} while (0)
123124
124125/*
125126 * Wrapper logic to avoid compiling high levels of debugging messages for
lib/libc/include/generic-freebsd/net/sff8472.h+8-1
......@@ -26,6 +26,9 @@
2626 * SUCH DAMAGE.
2727 */
2828
29#ifndef _NET_SFF8472_H_
30#define _NET_SFF8472_H_
31
2932/*
3033 * The following set of constants are from Document SFF-8472
3134 * "Diagnostic Monitoring Interface for Optical Transceivers" revision
......@@ -415,6 +418,7 @@ enum {
415418 SFF_8024_ID_LAST = SFF_8024_ID_QSFP_CMIS
416419};
417420
421#if defined(_WANT_SFF_8024_ID) || defined(_WANT_SFF_8472_ID)
418422static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {
419423 "Unknown",
420424 "GBIC",
......@@ -448,6 +452,7 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {
448452 "x8MiniLink",
449453 "QSFP+(CIMS)"
450454};
455#endif
451456
452457/* Keep compatibility with old definitions */
453458#define SFF_8472_ID_UNKNOWN SFF_8024_ID_UNKNOWN
......@@ -523,4 +528,6 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {
523528 * yielding a total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm).
524529 */
525530
526#define SFF_8472_POWER_FACTOR 10000.0
\ No newline at end of file
531#define SFF_8472_POWER_FACTOR 10000.0
532
533#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/net/vnet.h+7-1
......@@ -311,6 +311,12 @@ void *vnet_data_alloc(int size);
311311void vnet_data_copy(void *start, int size);
312312void vnet_data_free(void *start_arg, int size);
313313
314/*
315 * Interfaces to manipulate the initial values of virtualized global variables.
316 */
317void vnet_save_init(void *, size_t);
318void vnet_restore_init(void *, size_t);
319
314320/*
315321 * Virtual sysinit mechanism, allowing network stack components to declare
316322 * startup and shutdown methods to be run when virtual network stack
......@@ -400,7 +406,7 @@ do { \
400406#define CURVNET_SET(arg)
401407#define CURVNET_SET_QUIET(arg)
402408#define CURVNET_RESTORE()
403#define CURVNET_ASSERT_SET() \
409#define CURVNET_ASSERT_SET()
404410
405411#define VNET_LIST_RLOCK()
406412#define VNET_LIST_RLOCK_NOSLEEP()
lib/libc/include/generic-freebsd/net80211/_ieee80211.h+26-2
......@@ -536,6 +536,27 @@ struct ieee80211_mimo_info {
536536 "\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS\32TXLDPC\33RXAMSDUAMPDU" \
537537 "\34TXAMSDUAMPDU"
538538
539/*
540 * AKM (key management) suite capability list.
541 *
542 * These represent what's in 802.11-2016 - Table 9-133 - AKM Suite Selectors.
543 * Note that they do not match what the table values are, in case other key
544 * management suites want to be added with different OUIs.
545 */
546#define IEEE80211_KEYMGMT_RSN_UNSPEC_802_1X 0x00000001 /* RSN suite 1 */
547#define IEEE80211_KEYMGMT_RSN_PSK_OVER_802_1X 0x00000002 /* RSN suite 2 */
548#define IEEE80211_KEYMGMT_RSN_FT_OVER_802_1X 0x00000004 /* RSN suite 3 */
549#define IEEE80211_KEYMGMT_RSN_FT_PSK 0x00000008 /* RSN suite 4 */
550#define IEEE80211_KEYMGMT_RSN_802_1X_SHA256 0x00000010 /* RSN suite 5 */
551#define IEEE80211_KEYMGMT_RSN_PSK_SHA256 0x00000020 /* RSN suite 6 */
552#define IEEE80211_KEYMGMT_RSN_TPK_HANDSHAKE 0x00000040 /* RSN suite 7 */
553#define IEEE80211_KEYMGMT_RSN_SAE 0x00000080 /* RSN suite 8 */
554#define IEEE80211_KEYMGMT_RSN_FT_SAE 0x00000100 /* RSN suite 9 */
555#define IEEE80211_KEYMGMT_RSN_APPEERKEY_SHA256 0x00000200 /* RSN suite 10 */
556#define IEEE80211_KEYMGMT_RSN_802_1X_SUITE_B 0x00000400 /* RSN suite 11 */
557#define IEEE80211_KEYMGMT_RSN_802_1X_SUITE_B_192 0x00000800 /* RSN suite 12 */
558#define IEEE80211_KEYMGMT_RSN_FT_802_1X_SHA384 0x00001000 /* RSN suite 13 */
559
539560/*
540561 * RX status notification - which fields are valid.
541562 */
......@@ -564,15 +585,18 @@ struct ieee80211_mimo_info {
564585#define IEEE80211_RX_F_AMPDU 0x00000010 /* This is the start of an decap AMPDU list */
565586#define IEEE80211_RX_F_AMPDU_MORE 0x00000020 /* This is another decap AMPDU frame in the batch */
566587#define IEEE80211_RX_F_FAIL_FCSCRC 0x00000040 /* Failed CRC/FCS */
567#define IEEE80211_RX_F_FAIL_MIC 0x00000080 /* Failed MIC check */
588#define IEEE80211_RX_F_FAIL_MMIC 0x00000080 /* Failed Michael MIC (MMIC) check */
568589#define IEEE80211_RX_F_DECRYPTED 0x00000100 /* Hardware decrypted */
569590#define IEEE80211_RX_F_IV_STRIP 0x00000200 /* Decrypted; IV stripped */
570#define IEEE80211_RX_F_MMIC_STRIP 0x00000400 /* Decrypted; MMIC stripped */
591#define IEEE80211_RX_F_MMIC_STRIP 0x00000400 /* Decrypted; Michael MIC (MMIC) stripped */
571592#define IEEE80211_RX_F_SHORTGI 0x00000800 /* This is a short-GI frame */
572593#define IEEE80211_RX_F_CCK 0x00001000
573594#define IEEE80211_RX_F_OFDM 0x00002000
574595#define IEEE80211_RX_F_HT 0x00004000
575596#define IEEE80211_RX_F_VHT 0x00008000
597#define IEEE80211_RX_F_PN_VALIDATED 0x00010000 /* Decrypted; PN validated */
598#define IEEE80211_RX_F_MIC_STRIP 0x00020000 /* Decrypted; MIC stripped */
599#define IEEE80211_RX_F_ICV_STRIP 0x00040000 /* Decrypted: ICV (ic_trailer) stripped */
576600
577601/* Channel width */
578602#define IEEE80211_RX_FW_20MHZ 1
lib/libc/include/generic-freebsd/net80211/ieee80211.h+665-45
......@@ -4,6 +4,10 @@
44 * Copyright (c) 2001 Atsushi Onoe
55 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
66 * All rights reserved.
7 * Copyright (c) 2020-2025 The FreeBSD Foundation
8 *
9 * Portions of this software were developed by Björn Zeeb
10 * under sponsorship from the FreeBSD Foundation.
711 *
812 * Redistribution and use in source and binary forms, with or without
913 * modification, are permitted provided that the following conditions
......@@ -28,6 +32,12 @@
2832#ifndef _NET80211_IEEE80211_H_
2933#define _NET80211_IEEE80211_H_
3034
35#include <sys/types.h>
36
37#ifndef _KERNEL
38#include <stdbool.h>
39#endif
40
3141/*
3242 * 802.11 protocol definitions.
3343 */
......@@ -161,6 +171,7 @@ struct ieee80211_qosframe_addr4 {
161171/* 0001-0011 Reserved 0x10-0x30 */ /* Were: CF_ACK, CF_POLL, CF_ACPL */
162172#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 /* Null */
163173/* 0101-0111 Reserved 0x50-0x70 */ /* Were: CFACK, CFPOLL, CF_ACK_CF_ACK */
174#define IEEE80211_FC0_SUBTYPE_QOS_MASK_ANY 0x80 /* QoS mask - matching any subtypes 8..15 */
164175#define IEEE80211_FC0_SUBTYPE_QOS_DATA 0x80 /* QoS Data */
165176#define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFACK 0x90 /* QoS Data +CF-Ack */
166177#define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFPOLL 0xa0 /* QoS Data +CF-Poll */
......@@ -190,24 +201,98 @@ struct ieee80211_qosframe_addr4 {
190201#define IEEE80211_CTL_EXT_TDD_BF 0x0b /* TDD Beamforming, 80211ay-2021 */
191202/* 1100-1111 Reserved 0xc-0xf */
192203
193#define IEEE80211_IS_MGMT(wh) \
194 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \
195 == IEEE80211_FC0_TYPE_MGT))
204/* Check the version field */
205#define IEEE80211_IS_FC0_CHECK_VER(wh, v) \
206 (((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))
207
208/* Check the version and type field */
209#define IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, v, t) \
210 (((((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))) && \
211 (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == (t)))
212
213/* Check the version, type and subtype field */
214#define IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, v, t, st) \
215 (((((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))) && \
216 (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == (t)) && \
217 (((wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == (st)))
218
219#define IEEE80211_IS_MGMT(wh) \
220 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
221 IEEE80211_FC0_TYPE_MGT))
196222#define IEEE80211_IS_CTL(wh) \
197 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \
198 == IEEE80211_FC0_TYPE_CTL))
223 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
224 IEEE80211_FC0_TYPE_CTL))
199225#define IEEE80211_IS_DATA(wh) \
200 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \
201 == IEEE80211_FC0_TYPE_DATA))
226 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
227 IEEE80211_FC0_TYPE_DATA))
202228#define IEEE80211_IS_EXT(wh) \
203 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \
204 == IEEE80211_FC0_TYPE_EXT))
229 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
230 IEEE80211_FC0_TYPE_EXT))
231
232/* Management frame types */
233
234#define IEEE80211_IS_MGMT_BEACON(wh) \
235 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
236 IEEE80211_FC0_VERSION_0, \
237 IEEE80211_FC0_TYPE_MGT, \
238 IEEE80211_FC0_SUBTYPE_BEACON))
205239
206#define IEEE80211_FC0_QOSDATA \
207 (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS_DATA|IEEE80211_FC0_VERSION_0)
240#define IEEE80211_IS_MGMT_PROBE_RESP(wh) \
241 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
242 IEEE80211_FC0_VERSION_0, \
243 IEEE80211_FC0_TYPE_MGT, \
244 IEEE80211_FC0_SUBTYPE_PROBE_RESP))
245
246#define IEEE80211_IS_MGMT_ACTION(wh) \
247 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
248 IEEE80211_FC0_VERSION_0, \
249 IEEE80211_FC0_TYPE_MGT, \
250 IEEE80211_FC0_SUBTYPE_ACTION))
251
252/* Control frame types */
253
254#define IEEE80211_IS_CTL_PS_POLL(wh) \
255 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
256 IEEE80211_FC0_VERSION_0, \
257 IEEE80211_FC0_TYPE_CTL, \
258 IEEE80211_FC0_SUBTYPE_PS_POLL))
259
260#define IEEE80211_IS_CTL_BAR(wh) \
261 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
262 IEEE80211_FC0_VERSION_0, \
263 IEEE80211_FC0_TYPE_CTL, \
264 IEEE80211_FC0_SUBTYPE_BAR))
265
266/* Data frame types */
267
268/*
269 * Return true if the frame is any of the QOS frame types, not just
270 * data frames. Matching on the IEEE80211_FC0_SUBTYPE_QOS_ANY bit
271 * being set also matches on subtypes 8..15.
272 */
273#define IEEE80211_IS_QOS_ANY(wh) \
274 ((IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
275 IEEE80211_FC0_TYPE_DATA)) && \
276 ((wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS_MASK_ANY))
277
278/*
279 * Return true if this frame is QOS data, and only QOS data.
280 */
281#define IEEE80211_IS_QOSDATA(wh) \
282 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
283 IEEE80211_FC0_VERSION_0, \
284 IEEE80211_FC0_TYPE_DATA, \
285 IEEE80211_FC0_SUBTYPE_QOS_DATA))
286
287/*
288 * Return true if this frame is a QoS NULL data frame.
289 */
290#define IEEE80211_IS_QOS_NULL(wh) \
291 (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \
292 IEEE80211_FC0_VERSION_0, \
293 IEEE80211_FC0_TYPE_DATA, \
294 IEEE80211_FC0_SUBTYPE_QOS_NULL))
208295
209#define IEEE80211_IS_QOSDATA(wh) \
210 ((wh)->i_fc[0] == IEEE80211_FC0_QOSDATA)
211296
212297#define IEEE80211_FC1_DIR_MASK 0x03
213298#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
......@@ -421,7 +506,7 @@ struct ieee80211_action {
421506#define IEEE80211_ACTION_CAT_BA 3 /* 9.6.4 Block Ack */
422507#define IEEE80211_ACTION_CAT_PUBLIC 4 /* 9.6.7 Public */
423508#define IEEE80211_ACTION_CAT_RADIO_MEASUREMENT 5 /* 9.6.6 Radio Measurement */
424#define IEEE80211_ACTION_CAT_FAST_BBS_TRANSITION 6 /* 9.6.8 Fast BSS Transition */
509#define IEEE80211_ACTION_CAT_FAST_BSS_TRANSITION 6 /* 9.6.8 Fast BSS Transition */
425510#define IEEE80211_ACTION_CAT_HT 7 /* 9.6.11 HT */
426511#define IEEE80211_ACTION_CAT_SA_QUERY 8 /* 9.6.9 SA Query */
427512#define IEEE80211_ACTION_CAT_PROTECTED_DUAL_OF_PUBLIC_ACTION 9 /* 9.6.10 Protected Dual of Public Action */
......@@ -856,6 +941,7 @@ enum ieee80211_vht_mcs_support {
856941 IEEE80211_VHT_MCS_NOT_SUPPORTED = 3 /* not supported */
857942};
858943
944/* 802.11ac-2013, 8.4.2.160.3 Supported VHT-MCS and NSS Set field */
859945struct ieee80211_vht_mcs_info {
860946 uint16_t rx_mcs_map;
861947 uint16_t rx_highest;
......@@ -869,12 +955,15 @@ struct ieee80211_vht_cap {
869955 struct ieee80211_vht_mcs_info supp_mcs;
870956} __packed;
871957
872/* 802.11ac-2013, Table 8-183x-VHT Operation Information subfields */
958/*
959 * 802.11ac-2013, Table 8-183x-VHT Operation Information subfields.
960 * 802.11-2020, Table 9-274-VHT Operation Information subfields (for deprecations)
961 */
873962enum ieee80211_vht_chanwidth {
874963 IEEE80211_VHT_CHANWIDTH_USE_HT = 0, /* 20 MHz or 40 MHz */
875964 IEEE80211_VHT_CHANWIDTH_80MHZ = 1, /* 80MHz */
876 IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz */
877 IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz */
965 IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz (deprecated) */
966 IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz (deprecated) */
878967 /* 4..255 reserved. */
879968};
880969
......@@ -898,7 +987,7 @@ struct ieee80211_vht_operation {
898987
899988#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
900989#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S 2
901#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NONE 0
990#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NO160 0
902991#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ 1
903992#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ 2
904993#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_RESERVED 3
......@@ -969,11 +1058,15 @@ struct ieee80211_vht_operation {
9691058#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN 0x20000000
9701059#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN_S 29
9711060
1061/* 802.11-2016, 9.4.2.158.2 VHT Capabilities Information field. */
1062#define IEEE80211_VHTCAP_EXT_NSS_BW 0xc0000000
1063#define IEEE80211_VHTCAP_EXT_NSS_BW_S 30
1064
9721065/*
9731066 * XXX TODO: add the rest of the bits
9741067 */
9751068#define IEEE80211_VHTCAP_BITS \
976 "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN8080\5RXLDPC\6SHORTGI80" \
1069 "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN160+80P80\5RXLDPC\6SHORTGI80" \
9771070 "\7SHORTGI160\10RXSTBC1\11RXSTBC2\12RXSTBC3\13RXSTBC4\14BFERCAP" \
9781071 "\15BFEECAP\27VHT\37RXANTPTN\40TXANTPTN"
9791072
......@@ -1015,22 +1108,296 @@ struct ieee80211_ie_vht_txpwrenv {
10151108#define WLAN_ACTION_VHT_GROUPID_MGMT 1
10161109#define WLAN_ACTION_VHT_OPMODE_NOTIF 2
10171110
1111#if defined(_KERNEL) || defined(WANT_NET80211)
1112/*
1113 * HE
1114 */
1115
1116/*
1117 * 802.11ax-2021, 9.4.2.248.2 HE MAC Capabilities Information field.
1118 */
1119/* B0..B7 */
1120#define IEEE80211_HE_MAC_CAP0_HTC_HE (1<<0)
1121#define IEEE80211_HE_MAC_CAP0_TWT_REQ (1<<1)
1122#define IEEE80211_HE_MAC_CAP0_TWT_RES (1<<2)
1123
1124/* B8..B15 */
1125#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US (1<<3)
1126#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK (1<<3 | 1<<2)
1127#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8 (1<<6 | 1<<5 | 1<<4)
1128#define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION (1<<7)
1129/* Note: B15|B16 are split between octets %!$@??? */
1130
1131/* B16..B23 */
1132#define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION (1<<0)
1133#define IEEE80211_HE_MAC_CAP2_ALL_ACK (1<<1)
1134#define IEEE80211_HE_MAC_CAP2_TRS (1<<2)
1135#define IEEE80211_HE_MAC_CAP2_BSR (1<<3)
1136#define IEEE80211_HE_MAC_CAP2_BCAST_TWT (1<<4)
1137#define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP (1<<5)
1138#define IEEE80211_HE_MAC_CAP2_MU_CASCADING (1<<6)
1139#define IEEE80211_HE_MAC_CAP2_ACK_EN (1<<7)
1140
1141/* B24..B31 */
1142#define IEEE80211_HE_MAC_CAP3_OMI_CONTROL (1<<1)
1143#define IEEE80211_HE_MAC_CAP3_OFDMA_RA (1<<2)
1144#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1 (1<<3)
1145#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2 (1<<4)
1146#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3 (1<<4 | 1<<3)
1147#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK (1<<4 | 1<<3)
1148#define IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED (1<<6)
1149#define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS (1<<7)
1150
1151/* B32..B39 */
1152#define IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG (1<<0)
1153#define IEEE80211_HE_MAC_CAP4_BQR (1<<2)
1154#define IEEE80211_HE_MAC_CAP4_OPS (1<<5)
1155#define IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU (1<<6)
1156#define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39 (1<<7)
1157/* Note: B39|B40|B41 are split between octets %!$@??? */
1158
1159/* B40..B47 */
1160#define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40 (1<<0)
1161#define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41 (1<<1)
1162#define IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION (1<<2)
1163#define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU (1<<3)
1164#define IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX (1<<4)
1165#define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS (1<<5)
1166#define IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING (1<<6)
1167#define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX (1<<7)
1168
1169/*
1170 * 802.11ax-2021, 9.4.2.248.3 HE PHY Capabilities Information field.
1171 */
1172/* B0..B7 */
1173#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G (1<<1)
1174#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G (1<<2)
1175#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G (1<<3)
1176#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G (1<<4)
1177#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK_ALL (1<<4 | 1<<3 | 1<<2 | 1<<1)
1178#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G (1<<5)
1179#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G (1<<6)
1180#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1)
1181
1182/* B8..B15 */
1183#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK (1<<3 | 1<<2 | 1<<1 | 1<<0)
1184#define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A (1<<4)
1185#define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD (1<<5)
1186#define IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US (1<<6)
1187#define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS (1<<7)
1188/* Note: B15|B16 are split between octets %!$@??? */
1189
1190/* B16..B23 */
1191#define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS (1<<0)
1192#define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US (1<<1)
1193#define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ (1<<2)
1194#define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ (1<<3)
1195#define IEEE80211_HE_PHY_CAP2_DOPPLER_TX (1<<4)
1196#define IEEE80211_HE_PHY_CAP2_DOPPLER_RX (1<<5)
1197#define IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO (1<<6)
1198#define IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO (1<<7)
1199
1200/* B24..B31 */
1201#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM 0x00
1202#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK (1<<0)
1203#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK (1<<1)
1204#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM (1<<1 | 1<<0)
1205#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK (1<<1 | 1<<0)
1206#define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 0x00
1207#define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2 (1<<2)
1208#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM 0x00
1209#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK (1<<3)
1210#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK (1<<4)
1211#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM (1<<4 | 1<<3)
1212#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK (1<<4 | 1<<3)
1213#define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1 0x00
1214#define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2 (1<<5)
1215#define IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU (1<<6)
1216#define IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER (1<<7)
1217
1218/* B32..B39 */
1219#define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE (1<<0)
1220#define IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER (1<<1)
1221#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 (1<<3 | 1<<2)
1222#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5 (1<<4)
1223#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8 (1<<4 | 1<<3 | 1<<2)
1224#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK (1<<4 | 1<<3 | 1<<2)
1225#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 (1<<6 | 1<<5)
1226#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5 (1<<7)
1227#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8 (1<<7 | 1<<6 | 1<<5)
1228#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK (1<<7 | 1<<6 | 1<<5)
1229
1230/* B40..B47 */
1231#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2 (1<<0)
1232#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK (1<<2 | 1<<1 | 1<<0)
1233#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2 (1<<3)
1234#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK (1<<5 | 1<<4 | 1<<3)
1235#define IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK (1<<6)
1236#define IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK (1<<7)
1237
1238/* B48..B55 */
1239#define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU (1<<0)
1240#define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU (1<<1)
1241#define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB (1<<2)
1242#define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB (1<<3)
1243#define IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB (1<<4)
1244#define IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE (1<<5)
1245#define IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO (1<<6)
1246#define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT (1<<7)
1247
1248/* B56..B63 */
1249#define IEEE80211_HE_PHY_CAP7_PSR_BASED_SR (1<<0)
1250#define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP (1<<1)
1251#define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI (1<<2)
1252#define IEEE80211_HE_PHY_CAP7_MAX_NC_1 (1<<3)
1253#define IEEE80211_HE_PHY_CAP7_MAX_NC_2 (1<<4)
1254#define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK (1<<5 | 1<<4 | 1<<3)
1255#define IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ (1<<6)
1256#define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ (1<<7)
1257
1258/* B64..B71 */
1259#define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI (1<<0)
1260#define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G (1<<1)
1261#define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU (1<<2)
1262#define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU (1<<3)
1263#define IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI (1<<4)
1264#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 0x00
1265#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484 (1<<6)
1266#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996 (1<<7)
1267#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996 (1<<7 | 1<<6)
1268#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK (1<<7 | 1<<6)
1269
1270/* B72..B79 */
1271#define IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM (1<<0)
1272#define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK (1<<1)
1273#define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU (1<<2)
1274#define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU (1<<3)
1275#define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB (1<<4)
1276#define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB (1<<5)
1277#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US 0x00
1278#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US 1
1279#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US 2
1280#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED 3
1281#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS 6
1282#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK (1<<7 | 1<<6)
1283
1284/* B80..B87 */
1285#define IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF (1<<0)
1286
1287/*
1288 * 802.11ax-2021,
1289 * 9.4.2.248.2 HE MAC Capabilities Information field.
1290 * 9.4.2.248.3 HE PHY Capabilities Information field.
1291 */
1292struct ieee80211_he_cap_elem {
1293 uint8_t mac_cap_info[6];
1294 uint8_t phy_cap_info[11];
1295} __packed;
1296
1297/* 802.11ax-2021, 9.4.2.248.4 Supported HE-MCS And NSS Set field. */
1298enum ieee80211_he_mcs_support {
1299 IEEE80211_HE_MCS_SUPPORT_0_7 = 0, /* HE-MCS 0-7 for n NSS */
1300 IEEE80211_HE_MCS_SUPPORT_0_9 = 1, /* HE-MCS 0-9 for n NSS */
1301 IEEE80211_HE_MCS_SUPPORT_0_11 = 2, /* HE-MCS 0-11 for n NSS */
1302 IEEE80211_HE_MCS_NOT_SUPPORTED = 3 /* n NSS not supported. */
1303};
1304
1305struct ieee80211_he_mcs_nss_supp {
1306 uint16_t rx_mcs_80;
1307 uint16_t tx_mcs_80;
1308 uint16_t rx_mcs_160;
1309 uint16_t tx_mcs_160;
1310 uint16_t rx_mcs_80p80;
1311 uint16_t tx_mcs_80p80;
1312} __packed;
1313
1314#define IEEE80211_HE_CAP_PPE_THRES_MAX 25
1315
1316/* XXX this should only be internal. */
1317struct net80211_he_cap {
1318 bool has_he;
1319 struct ieee80211_he_cap_elem he_cap_elem;
1320 struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
1321 uint8_t ppe_thres[IEEE80211_HE_CAP_PPE_THRES_MAX];
1322};
1323
1324/* 802.11ax-2021, 9.4.2.249 HE Operation element. */
1325#define IEEE80211_HE_OPERATION_ER_SU_DISABLE (1<<16)
1326#define IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET 24
1327#define IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED (1<<31)
1328
1329struct ieee80211_he_operation {
1330 uint32_t he_oper_params; /* (3) params | (1) bss color info */
1331 uint16_t he_mcs_nss_set;
1332 uint8_t optional[0];
1333} __packed;
1334
1335/* 802.11ax-2021, 9.4.2.251 MU EDCA Parameter Set element. */
1336struct ieee80211_he_mu_edca_param_ac_rec {
1337 uint8_t aifsn;
1338 uint8_t ecw_min_max;
1339 uint8_t mu_edca_timer;
1340} __packed;
1341
1342struct ieee80211_mu_edca_param_set {
1343 uint8_t mu_qos_info;
1344 union {
1345 struct {
1346 struct ieee80211_he_mu_edca_param_ac_rec ac_be;
1347 struct ieee80211_he_mu_edca_param_ac_rec ac_bk;
1348 struct ieee80211_he_mu_edca_param_ac_rec ac_vi;
1349 struct ieee80211_he_mu_edca_param_ac_rec ac_vo;
1350 };
1351 struct ieee80211_he_mu_edca_param_ac_rec param_ac_recs[4];
1352 };
1353} __packed;
1354
1355/* 802.11ax-2021, 9.4.2.252 Spatial Reuse Parameter Set element */
1356/* Figure 9-788r-SR Control field format */
1357#define IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED (1<<1)
1358#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT (1<<2)
1359#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT (1<<3)
1360#define IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED (1<<4)
1361
1362/* 802.11ax-2021, 9.4.2.263 HE 6 GHz Band Capabilities element */
1363/* Figure 9-788aj-Capabilities Information field format */
1364#define IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START (1<<2 | 1<<1 | 1<<0)
1365#define IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP (1<<5 | 1<<4 | 1<<3)
1366#define IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN (1<<7 | 1<<6)
1367#define IEEE80211_HE_6GHZ_CAP_SM_PS (1<<10 | 1<<9)
1368#define IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS (1<<12)
1369#define IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS (1<<13)
1370
1371struct ieee80211_he_6ghz_capa {
1372 uint16_t capa;
1373};
1374#endif /* _KERNEL || WANT_NET80211 */
1375
10181376/*
10191377 * Management information element payloads.
1378 *
1379 * 802.11-2020 Table 9-92 (Element IDs).
1380 * 802.11ax-2021
10201381 */
10211382
10221383enum {
10231384 IEEE80211_ELEMID_SSID = 0,
10241385 IEEE80211_ELEMID_RATES = 1,
1025 IEEE80211_ELEMID_FHPARMS = 2,
1386 /* 2 Reserved */
1387 IEEE80211_ELEMID_FHPARMS = 2, /* remove? */
10261388 IEEE80211_ELEMID_DSPARMS = 3,
1027 IEEE80211_ELEMID_CFPARMS = 4,
1389 /* 4 Reserved */
1390 IEEE80211_ELEMID_CFPARMS = 4, /* remove? */
10281391 IEEE80211_ELEMID_TIM = 5,
10291392 IEEE80211_ELEMID_IBSSPARMS = 6,
10301393 IEEE80211_ELEMID_COUNTRY = 7,
1394 /* 8, 9 reserved */
1395 IEEE80211_ELEMID_REQUEST = 10,
10311396 IEEE80211_ELEMID_BSSLOAD = 11,
1397 IEEE80211_ELEMID_EDCA_PARAM_SET = 12,
10321398 IEEE80211_ELEMID_TSPEC = 13,
10331399 IEEE80211_ELEMID_TCLAS = 14,
1400 IEEE80211_ELEMID_SCHEDULE = 15,
10341401 IEEE80211_ELEMID_CHALLENGE = 16,
10351402 /* 17-31 reserved for challenge text extension */
10361403 IEEE80211_ELEMID_PWRCNSTR = 32,
......@@ -1044,28 +1411,77 @@ enum {
10441411 IEEE80211_ELEMID_QUIET = 40,
10451412 IEEE80211_ELEMID_IBSSDFS = 41,
10461413 IEEE80211_ELEMID_ERP = 42,
1414 IEEE80211_ELEMID_TS_DELAY = 43,
1415 IEEE80211_ELEMID_TCLAS_PROCES = 44,
10471416 IEEE80211_ELEMID_HTCAP = 45,
10481417 IEEE80211_ELEMID_QOS = 46,
1418 /* 47 reserved */
10491419 IEEE80211_ELEMID_RESERVED_47 = 47,
10501420 IEEE80211_ELEMID_RSN = 48,
1421 /* 49 reserved */
10511422 IEEE80211_ELEMID_XRATES = 50,
10521423 IEEE80211_ELEMID_APCHANREP = 51,
1053 IEEE80211_ELEMID_MOBILITY_DOMAIN = 54,
1054 IEEE80211_ELEMID_HTINFO = 61,
1424 IEEE80211_ELEMID_NEIGHBOR_REP = 52,
1425 IEEE80211_ELEMID_RCPI = 53,
1426 IEEE80211_ELEMID_MOBILITY_DOMAIN = 54, /* MDE */
1427 IEEE80211_ELEMID_FAST_BSS_TRANS = 55, /* FTE */
1428 IEEE80211_ELEMID_TIMEOUT_INTVL = 56,
1429 IEEE80211_ELEMID_RIC_DATA = 57, /* RDE */
1430 IEEE80211_ELEMID_DSE_REG_LOC = 58,
1431 IEEE80211_ELEMID_SUP_OP_CLASS = 59,
1432 IEEE80211_ELEMID_EXT_CSA = 60,
1433 IEEE80211_ELEMID_HTINFO = 61, /* HTOPER */
10551434 IEEE80211_ELEMID_SECCHAN_OFFSET = 62,
1056 IEEE80211_ELEMID_RRM_ENACAPS = 70,
1435 IEEE80211_ELEMID_BSS_AVG_ACC_DELAY = 63,
1436 IEEE80211_ELEMID_ANTENNA = 64,
1437 IEEE80211_ELEMID_RSNI = 65,
1438 IEEE80211_ELEMID_MEAS_PILOT_TRANS = 66,
1439 IEEE80211_ELEMID_BSS_AVAIL_AD_CAP = 67,
1440 IEEE80211_ELEMID_BSS_AC_ACC_DELAY = 68,
1441 IEEE80211_ELEMID_TIME_ADV = 69,
1442 IEEE80211_ELEMID_RRM_ENACAPS = 70, /* RM_ENCAPS */
10571443 IEEE80211_ELEMID_MULTIBSSID = 71,
10581444 IEEE80211_ELEMID_COEX_2040 = 72,
1059 IEEE80211_ELEMID_INTOL_CHN_REPORT = 73,
1445 IEEE80211_ELEMID_2040_INTOL_CHAN_REPORT = 73,
10601446 IEEE80211_ELEMID_OVERLAP_BSS_SCAN_PARAM = 74,
1447 IEEE80211_ELEMID_RIC_DESC = 75,
1448 IEEE80211_ELEMID_MGMT_MIC = 76,
1449 /* 77 reserved */
1450 IEEE80211_ELEMID_EVENT_REQ = 78,
1451 IEEE80211_ELEMID_EVENT_REP = 79,
1452 IEEE80211_ELEMID_DIAGNOSTIC_REQ = 80,
1453 IEEE80211_ELEMID_DIAGNOSTIC_REP = 81,
1454 IEEE80211_ELEMID_LOCATION_PARAM = 82,
1455 IEEE80211_ELEMID_NONTRANS_BSSID_CAP = 83,
1456 IEEE80211_ELEMID_SSID_LIST = 84,
1457 IEEE80211_ELEMID_MULTI_BSSID_IDX = 85,
1458 IEEE80211_ELEMID_FMS_DESC = 86,
1459 IEEE80211_ELEMID_FMS_REQ = 87,
1460 IEEE80211_ELEMID_FMS_RESP = 88,
1461 IEEE80211_ELEMID_QOS_TRAFFIC_CAP = 89,
1462 IEEE80211_ELEMID_BSS_MAX_IDLE_P = 90,
10611463 IEEE80211_ELEMID_TSF_REQ = 91,
10621464 IEEE80211_ELEMID_TSF_RESP = 92,
10631465 IEEE80211_ELEMID_WNM_SLEEP_MODE = 93,
10641466 IEEE80211_ELEMID_TIM_BCAST_REQ = 94,
10651467 IEEE80211_ELEMID_TIM_BCAST_RESP = 95,
1066 IEEE80211_ELEMID_TPC = 150,
1067 IEEE80211_ELEMID_CCKM = 156,
1068 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
1468 IEEE80211_ELEMID_COL_INTERF_REP = 96,
1469 IEEE80211_ELEMID_CHAN_USAGE = 97,
1470 IEEE80211_ELEMID_TIME_ZONE = 98,
1471 IEEE80211_ELEMID_DMS_REQ = 99,
1472 IEEE80211_ELEMID_DMS_RESP = 100,
1473 IEEE80211_ELEMID_LINK_ID = 101,
1474 IEEE80211_ELEMID_WAKEUP_SCHED = 102,
1475 /* 103 reserved */
1476 IEEE80211_ELEMID_CHAN_SW_TIMING = 104,
1477 IEEE80211_ELEMID_PTI_CONTROL = 105,
1478 IEEE80211_ELEMID_TPU_BUF_STATUS = 106,
1479 IEEE80211_ELEMID_INTERWORKING = 107,
1480 IEEE80211_ELEMID_ADV_PROTO = 108,
1481 IEEE80211_ELEMID_EXP_BW_REQ = 109,
1482 IEEE80211_ELEMID_QOS_MAP = 110,
1483 IEEE80211_ELEMID_ROAM_CONSORT = 111,
1484 IEEE80211_ELEMID_EMERG_ALERT_ID = 112,
10691485
10701486 /*
10711487 * 802.11s IEs
......@@ -1095,17 +1511,180 @@ enum {
10951511 IEEE80211_ELEMID_MESHPXU = 137,
10961512 IEEE80211_ELEMID_MESHPXUC = 138,
10971513 IEEE80211_ELEMID_MESHAH = 60, /* XXX: remove */
1098
1099 /* 802.11ac-2013, Table 8-54-Element IDs */
1514 /* XXX 139 */
1515
1516 IEEE80211_ELEMID_MIC = 140,
1517 IEEE80211_ELEMID_DEST_URI = 141,
1518 IEEE80211_ELEMID_U_APSD_COEX = 142,
1519 IEEE80211_ELEMID_DMG_WAKEUP_SCHED = 143,
1520 IEEE80211_ELEMID_EXT_SCHED = 144,
1521 IEEE80211_ELEMID_STA_AVAIL = 145,
1522 IEEE80211_ELEMID_DMG_TSPEC = 146,
1523 IEEE80211_ELEMID_NEXT_DMG_ATI = 147,
1524 IEEE80211_ELEMID_DMG_CAP = 148,
1525 /* 149-150 reserved. */
1526 IEEE80211_ELEMID_TPC = 150, /* XXX: remove */
1527 IEEE80211_ELEMID_DMG_OPER = 151,
1528 IEEE80211_ELEMID_DMG_BSS_PARAM_CHANGE = 152,
1529 IEEE80211_ELEMID_DMG_BEAM_REF = 153,
1530 IEEE80211_ELEMID_CHAN_MEAS_FEEDB = 154,
1531 /* 155-156 reserved. */
1532 IEEE80211_ELEMID_CCKM = 156, /* XXX: remove? */
1533 IEEE80211_ELEMID_AWAKE_WIN = 157,
1534 IEEE80211_ELEMID_MULTI_BAND = 158,
1535 IEEE80211_ELEMID_ADDBA_EXT = 159,
1536 IEEE80211_ELEMID_NEXTPCP_LIST = 160,
1537 IEEE80211_ELEMID_PCP_HANDOVER = 161,
1538 IEEE80211_ELEMID_DMG_LINK_MARGIN = 162,
1539 IEEE80211_ELEMID_SW_STREAM = 163,
1540 IEEE80211_ELEMID_SESS_TRANS = 164,
1541 /* 165 reserved. */
1542 IEEE80211_ELEMID_CLUSTER_REP = 166,
1543 IEEE80211_ELEMID_RELAY_CAP = 167,
1544 IEEE80211_ELEMID_RELAY_TRANS_PARAM_SET = 168,
1545 IEEE80211_ELEMID_BEAMLINK_MAINT = 169,
1546 IEEE80211_ELEMID_MULTI_MAC_SUBL = 170,
1547 IEEE80211_ELEMID_U_PID = 171,
1548 IEEE80211_ELEMID_DMG_LINK_ADAP_ACK = 172,
1549 /* 173 reserved. */
1550 IEEE80211_ELEMID_MCCAOP_ADV_OV = 174,
1551 IEEE80211_ELEMID_QUIET_PERIOD_REQ = 175,
1552 /* 176 reserved. */
1553 IEEE80211_ELEMID_QUIET_PERIOD_RESP = 177,
1554 /* 178-180 reserved. */
1555 IEEE80211_ELEMID_QMF_POLICY = 181,
1556 IEEE80211_ELEMID_ECAPC_POLICY = 182,
1557 IEEE80211_ELEMID_CLUSTER_TIME_OFFSET = 183,
1558 IEEE80211_ELEMID_INTRA_ACC_CAT_PRIO = 184,
1559 IEEE80211_ELEMID_SCS_DESCR = 185,
1560 IEEE80211_ELEMID_QLOAD_REPORT = 186,
1561 IEEE80211_ELEMID_HCCA_TXOP_UP_CNT = 187,
1562 IEEE80211_ELEMID_HL_STREAM_ID = 188,
1563 IEEE80211_ELEMID_GCR_GROUP_ADDR = 189,
1564 IEEE80211_ELEMID_ANTENNA_SECTOR_ID_PAT = 190,
11001565 IEEE80211_ELEMID_VHT_CAP = 191,
11011566 IEEE80211_ELEMID_VHT_OPMODE = 192,
11021567 IEEE80211_ELEMID_EXTENDED_BSS_LOAD = 193,
1103 IEEE80211_ELEMID_WIDE_BW_CHANNEL_SWITCH = 194,
1104 IEEE80211_ELEMID_VHT_PWR_ENV = 195,
1568 IEEE80211_ELEMID_WIDE_BW_CHAN_SW = 194,
1569 IEEE80211_ELEMID_VHT_PWR_ENV = 195, /* TX_PWR_ENV */
11051570 IEEE80211_ELEMID_CHANNEL_SWITCH_WRAPPER = 196,
11061571 IEEE80211_ELEMID_AID = 197,
11071572 IEEE80211_ELEMID_QUIET_CHANNEL = 198,
11081573 IEEE80211_ELEMID_OPMODE_NOTIF = 199,
1574 IEEE80211_ELEMID_UPSIM = 200,
1575 IEEE80211_ELEMID_RED_NEIGH_REP = 201,
1576 IEEE80211_ELEMID_TVHT_OP = 202,
1577 /* 203 reserved. */
1578 IEEE80211_ELEMID_DEVICE_LOC = 204,
1579 IEEE80211_ELEMID_WHITE_SPACE_MAP = 205,
1580 IEEE80211_ELEMID_FINE_TIME_MEAS_PARAM = 206,
1581 IEEE80211_ELEMID_SIG_OPEN_LOOP_LINK_MARGIN_IDX = 207,
1582 IEEE80211_ELEMID_RPS = 208,
1583 IEEE80211_ELEMID_PAGE_SLICE = 209,
1584 IEEE80211_ELEMID_AID_REQ = 210,
1585 IEEE80211_ELEMID_AID_RESP = 211,
1586 IEEE80211_ELEMID_SIG_SECTOR_OP = 212,
1587 IEEE80211_ELEMID_SIG_BEACON_COMPAT = 213,
1588 IEEE80211_ELEMID_SHORT_BEACON_INTVL = 214,
1589 IEEE80211_ELEMID_CHANGE_SEQ = 215,
1590 IEEE80211_ELEMID_TWT = 216,
1591 IEEE80211_ELEMID_SIG_CAPS = 217,
1592 /* 218-219 reserved. */
1593 IEEE80211_ELEMID_SUBCHAN_SELECT_TRANS = 220,
1594 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */
1595 IEEE80211_ELEMID_AUTH_CONTROL = 222,
1596 IEEE80211_ELEMID_TSF_TIMER_ACC = 223,
1597 IEEE80211_ELEMID_S1G_RELAY = 224,
1598 IEEE80211_ELEMID_REACHABLE_ADDR = 225,
1599 IEEE80211_ELEMID_SIG_RELAY_DISC = 226,
1600 /* 227 reserved. */
1601 IEEE80211_ELEMID_AID_ANNOUNCEMENT = 228,
1602 IEEE80211_ELEMID_PV1_PROBE_RESP_OPT = 229,
1603 IEEE80211_ELEMID_EL_OP = 230,
1604 IEEE80211_ELEMID_SECTORIZED_GRP_ID_LIST = 231,
1605 IEEE80211_ELEMID_SIG_OP = 232,
1606 IEEE80211_ELEMID_HDR_COMPRESSION = 233,
1607 IEEE80211_ELEMID_SST_OP = 234,
1608 IEEE80211_ELEMID_MAD = 235,
1609 IEEE80211_ELEMID_SIG_RELAY_ACT = 236,
1610 IEEE80211_ELEMID_CAG_NUMBER = 237,
1611 /* 238 reserved. */
1612 IEEE80211_ELEMID_AP_CSN = 239,
1613 IEEE80211_ELEMID_FILS_INDICATION = 240,
1614 IEEE80211_ELEMID_DILS = 241,
1615 IEEE80211_ELEMID_FRAGMENT = 242,
1616 /* 243 reserved. */
1617 IEEE80211_ELEMID_RSN_EXT = 244,
1618 /* 245-254 reserved. */
1619 IEEE80211_ELEMID_EXTFIELD = 255
1620};
1621
1622enum ieee80211_elemid_ext {
1623 IEEE80211_ELEMID_EXT_ASSOC_DELAY_INFO = 1,
1624 IEEE80211_ELEMID_EXT_FILS_REQ_PARAMS = 2,
1625 IEEE80211_ELEMID_EXT_FILS_KEY_CONFIRM = 3,
1626 IEEE80211_ELEMID_EXT_FILS_SESSION = 4,
1627 IEEE80211_ELEMID_EXT_FILS_HLP_CONTAINER = 5,
1628 IEEE80211_ELEMID_EXT_FILS_IP_ADDR_ASSIGNMENT = 6,
1629 IEEE80211_ELEMID_EXT_KEY_DELIVERY = 7,
1630 IEEE80211_ELEMID_EXT_FILS_WRAPPED_DATA = 8,
1631 IEEE80211_ELEMID_EXT_FTM_SYNC_INFO = 9,
1632 IEEE80211_ELEMID_EXT_EXT_REQ = 10,
1633 IEEE80211_ELEMID_EXT_EST_SERVICE_PARAM_INBOUND = 11,
1634 IEEE80211_ELEMID_EXT_FILS_PUBLIC_KEY = 12,
1635 IEEE80211_ELEMID_EXT_FILS_NONCE = 13,
1636 IEEE80211_ELEMID_EXT_FUTURE_CHAN_GUIDANCE = 14,
1637 IEEE80211_ELEMID_EXT_SERVICE_HINT = 15,
1638 IEEE80211_ELEMID_EXT_SERVICE_HASH = 16,
1639 IEEE80211_ELEMID_EXT_CDMG_CAPA = 17,
1640 IEEE80211_ELEMID_EXT_DYN_BW_CTRL = 18,
1641 IEEE80211_ELEMID_EXT_CDMG_EXT_SCHEDULE = 19,
1642 IEEE80211_ELEMID_EXT_SSW_REPORT = 20,
1643 IEEE80211_ELEMID_EXT_CLUSTER_PROBE = 21,
1644 IEEE80211_ELEMID_EXT_EXT_CLUSTER_REPORT = 22,
1645 IEEE80211_ELEMID_EXT_CLUSTER_SW_ANNOUNCEMENT = 23,
1646 IEEE80211_ELEMID_EXT_ENHANCED_BEAM_TRACKING = 24,
1647 IEEE80211_ELEMID_EXT_SPSH_REPORT = 25,
1648 IEEE80211_ELEMID_EXT_CLUSTER_INTERF_ASSESS = 26,
1649 IEEE80211_ELEMID_EXT_CMMG_CAPA = 27,
1650 IEEE80211_ELEMID_EXT_CMMG_OPER = 28,
1651 IEEE80211_ELEMID_EXT_CMMG_OPMODE_NOTIF = 29,
1652 IEEE80211_ELEMID_EXT_CMMG_LINK_MARGIN = 30,
1653 IEEE80211_ELEMID_EXT_CMMG_LINK_ADAP_ACK = 31,
1654 /* 32 reserved. */
1655 IEEE80211_ELEMID_EXT_PASSWORD_ID = 33,
1656 IEEE80211_ELEMID_EXT_GLK_GCR_PARAM_SET = 34,
1657 IEEE80211_ELEMID_EXT_HE_CAPA = 35,
1658 IEEE80211_ELEMID_EXT_HE_OPER = 36,
1659 IEEE80211_ELEMID_EXT_UORA_PARAM_SET = 37,
1660 IEEE80211_ELEMID_EXT_MU_EDCA_PARAM_SET = 38,
1661 IEEE80211_ELEMID_EXT_SPATIAL_REUSE_PARAM_SET = 39,
1662 IEEE80211_ELEMID_EXT_GAS_EXTENSION = 40,
1663 IEEE80211_ELEMID_EXT_NDP_FEEDB_REPORT_PARAM = 41,
1664 IEEE80211_ELEMID_EXT_BSS_COLOR_CHG_ANNOUNCE = 42,
1665 IEEE80211_ELEMID_EXT_QUIET_TIMME_PERIOD = 43,
1666 IEEE80211_ELEMID_EXT_VENDOR_SPECIFIC_REQ_ELEM = 44,
1667 IEEE80211_ELEMID_EXT_ESS_REPORT = 45,
1668 IEEE80211_ELEMID_EXT_OPS = 46,
1669 IEEE80211_ELEMID_EXT_HE_BSS_LOAD = 47,
1670 /* 48-51 reserved. */
1671 IEEE80211_ELEMID_EXT_MAC_CH_SW_TIME = 52,
1672 IEEE80211_ELEMID_EXT_EST_SERVICE_PARAM_OUTBOUND = 53,
1673 IEEE80211_ELEMID_EXT_OCI = 54,
1674 IEEE80211_ELEMID_EXT_MULTI_BSSID_CONFIG = 55,
1675 IEEE80211_ELEMID_EXT_NON_INHERITANCE = 56,
1676 IEEE80211_ELEMID_EXT_KNOWN_BSSID = 57,
1677 IEEE80211_ELEMID_EXT_SHORT_SSID_LIST = 58,
1678 IEEE80211_ELEMID_EXT_HE_6GHZ_BAND_CAPA = 59,
1679 IEEE80211_ELEMID_EXT_ULMU_POWER_CAAP = 60,
1680 /* 61-87 reserved. */
1681 IEEE80211_ELEMID_EXT_MSCS_DESCRIPTOR = 88,
1682 IEEE80211_ELEMID_EXT_TCLAS_MASK = 89,
1683 IEEE80211_ELEMID_EXT_SUPPL_CLASS_2_CAPA = 90,
1684 IEEE80211_ELEMID_EXT_OCT_SOURCE = 91,
1685 IEEE80211_ELEMID_EXT_REJECTED_GROUPS = 92,
1686 IEEE80211_ELEMID_EXT_ANTI_CLOGGING_TAOKEN_CONTAINER = 93,
1687 /* 94-255 reserved. */
11091688};
11101689
11111690struct ieee80211_tim_ie {
......@@ -1266,7 +1845,7 @@ struct ieee80211_csa_ie {
12661845#define WPA_CSE_NULL 0x00
12671846#define WPA_CSE_WEP40 0x01
12681847#define WPA_CSE_TKIP 0x02
1269#define WPA_CSE_CCMP 0x04
1848#define WPA_CSE_CCMP 0x04 /* CCMP 128-bit */
12701849#define WPA_CSE_WEP104 0x05
12711850
12721851#define WPA_ASE_NONE 0x00
......@@ -1275,21 +1854,62 @@ struct ieee80211_csa_ie {
12751854
12761855#define WPS_OUI_TYPE 0x04
12771856
1857/* 802.11-2016 Table 9-131 - Cipher Suite Selectors */
12781858#define RSN_OUI 0xac0f00
12791859#define RSN_VERSION 1 /* current supported version */
12801860
1281#define RSN_CSE_NULL 0x00
1282#define RSN_CSE_WEP40 0x01
1283#define RSN_CSE_TKIP 0x02
1284#define RSN_CSE_WRAP 0x03
1285#define RSN_CSE_CCMP 0x04
1286#define RSN_CSE_WEP104 0x05
1287
1288#define RSN_ASE_NONE 0x00
1289#define RSN_ASE_8021X_UNSPEC 0x01
1290#define RSN_ASE_8021X_PSK 0x02
1291
1292#define RSN_CAP_PREAUTH 0x01
1861/* RSN cipher suite element */
1862#define RSN_CSE_NULL 0
1863#define RSN_CSE_WEP40 1
1864#define RSN_CSE_TKIP 2
1865#define RSN_CSE_WRAP 3 /* Reserved in the 802.11-2016 */
1866#define RSN_CSE_CCMP 4 /* CCMP 128 bit */
1867#define RSN_CSE_WEP104 5
1868#define RSN_CSE_BIP_CMAC_128 6
1869/* 7 - "Group addressed traffic not allowed" */
1870#define RSN_CSE_GCMP_128 8
1871#define RSN_CSE_GCMP_256 9
1872#define RSN_CSE_CCMP_256 10
1873#define RSN_CSE_BIP_GMAC_128 11
1874#define RSN_CSE_BIP_GMAC_256 12
1875#define RSN_CSE_BIP_CMAC_256 13
1876
1877/* 802.11-2016 Table 9-133 - AKM suite selectors */
1878/* RSN AKM suite element */
1879#define RSN_ASE_NONE 0
1880#define RSN_ASE_8021X_UNSPEC 1
1881#define RSN_ASE_8021X_PSK 2
1882#define RSN_ASE_FT_8021X 3 /* SHA-256 */
1883#define RSN_ASE_FT_PSK 4 /* SHA-256 */
1884#define RSN_ASE_8021X_UNSPEC_SHA256 5
1885#define RSN_ASE_8021X_PSK_SHA256 6
1886#define RSN_ASE_8021X_TDLS 7 /* SHA-256 */
1887#define RSN_ASE_SAE_UNSPEC 8 /* SHA-256 */
1888#define RSN_ASE_FT_SAE 9 /* SHA-256 */
1889#define RSN_ASE_AP_PEERKEY 10 /* SHA-256 */
1890#define RSN_ASE_8021X_SUITE_B_SHA256 11
1891#define RSN_ASE_8021X_SUITE_B_SHA384 12
1892#define RSN_ASE_FT_8021X_SHA384 13
1893
1894/* 802.11-2016 Figure 9-257 - RSN Capabilities (2 byte field) */
1895#define RSN_CAP_PREAUTH 0x0001
1896#define RSN_CAP_NO_PAIRWISE 0x0002
1897#define RSN_CAP_PTKSA_REPLAY_COUNTER 0x000c /* 2 bit field */
1898#define RSN_CAP_GTKSA_REPLAY_COUNTER 0x0030 /* 2 bit field */
1899#define RSN_CAP_MFP_REQUIRED 0x0040
1900#define RSN_CAP_MFP_CAPABLE 0x0080
1901#define RSN_CAP_JOINT_MULTIBAND_RSNA 0x0100
1902#define RSN_CAP_PEERKEY_ENABLED 0x0200
1903#define RSN_CAP_SPP_AMSDU_CAPABLE 0x0400
1904#define RSN_CAP_SPP_AMSDU_REQUIRED 0x0800
1905#define RSN_CAP_PBAC_CAPABLE 0x1000
1906#define RSN_CAP_EXT_KEYID_CAPABLE 0x0200
1907
1908/* 802.11-2016 Table 9-134 PTKSA/GTKSA/STKSA replay counters usage */
1909#define RSN_CAP_REPLAY_COUNTER_1_PER 0
1910#define RSN_CAP_REPLAY_COUNTER_2_PER 1
1911#define RSN_CAP_REPLAY_COUNTER_4_PER 2
1912#define RSN_CAP_REPLAY_COUNTER_16_PER 3
12931913
12941914#define WME_OUI 0xf25000
12951915#define WME_OUI_TYPE 0x02
lib/libc/include/generic-freebsd/net80211/ieee80211_amrr.h+4
......@@ -49,6 +49,10 @@ struct ieee80211_amrr_node {
4949 struct ieee80211_amrr *amn_amrr;/* backpointer */
5050 int amn_rix; /* current rate index */
5151 int amn_ticks; /* time of last update */
52 /* for VHT, since there's no VHT RIX right now */
53 int amn_vht_mcs;
54 int amn_vht_nss;
55
5256 /* statistics */
5357 u_int amn_txcnt;
5458 u_int amn_success;
lib/libc/include/generic-freebsd/net80211/ieee80211_crypto.h+57-7
......@@ -118,8 +118,8 @@ struct ieee80211_key {
118118 IEEE80211_KEY_NOIVMGT|IEEE80211_KEY_NOMIC|IEEE80211_KEY_NOMICMGT)
119119
120120#define IEEE80211_KEY_BITS \
121 "\20\1XMIT\2RECV\3GROUP\4SWENCRYPT\5SWDECRYPT\6SWENMIC\7SWDEMIC" \
122 "\10DEVKEY\11CIPHER0\12CIPHER1"
121 "\20\1XMIT\2RECV\3GROUP\4NOREPLAY\5SWENCRYPT\6SWDECRYPT\7SWENMIC\10SWDEMIC" \
122 "\11DEVKEY\12CIPHER0\13CIPHER1\14NOIV\15NOIVMGT\16NOMIC\17NOMICMGT"
123123
124124#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1)
125125
......@@ -137,8 +137,17 @@ struct ieee80211_key {
137137#define IEEE80211_CIPHER_TKIPMIC 4 /* TKIP MIC capability */
138138#define IEEE80211_CIPHER_CKIP 5
139139#define IEEE80211_CIPHER_NONE 6 /* pseudo value */
140#define IEEE80211_CIPHER_AES_CCM_256 7
141#define IEEE80211_CIPHER_BIP_CMAC_128 8
142#define IEEE80211_CIPHER_BIP_CMAC_256 9
143#define IEEE80211_CIPHER_BIP_GMAC_128 10
144#define IEEE80211_CIPHER_BIP_GMAC_256 11
145#define IEEE80211_CIPHER_AES_GCM_128 12
146#define IEEE80211_CIPHER_AES_GCM_256 13
140147
141#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
148#define IEEE80211_CIPHER_LAST 13
149
150#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_LAST+1)
142151
143152/* capability bits in ic_cryptocaps/iv_cryptocaps */
144153#define IEEE80211_CRYPTO_WEP (1<<IEEE80211_CIPHER_WEP)
......@@ -147,9 +156,18 @@ struct ieee80211_key {
147156#define IEEE80211_CRYPTO_AES_CCM (1<<IEEE80211_CIPHER_AES_CCM)
148157#define IEEE80211_CRYPTO_TKIPMIC (1<<IEEE80211_CIPHER_TKIPMIC)
149158#define IEEE80211_CRYPTO_CKIP (1<<IEEE80211_CIPHER_CKIP)
159#define IEEE80211_CRYPTO_AES_CCM_256 (1<<IEEE80211_CIPHER_AES_CCM_256)
160#define IEEE80211_CRYPTO_BIP_CMAC_128 (1<<IEEE80211_CIPHER_BIP_CMAC_128)
161#define IEEE80211_CRYPTO_BIP_CMAC_256 (1<<IEEE80211_CIPHER_BIP_CMAC_256)
162#define IEEE80211_CRYPTO_BIP_GMAC_128 (1<<IEEE80211_CIPHER_BIP_GMAC_128)
163#define IEEE80211_CRYPTO_BIP_GMAC_256 (1<<IEEE80211_CIPHER_BIP_GMAC_256)
164#define IEEE80211_CRYPTO_AES_GCM_128 (1<<IEEE80211_CIPHER_AES_GCM_128)
165#define IEEE80211_CRYPTO_AES_GCM_256 (1<<IEEE80211_CIPHER_AES_GCM_256)
150166
151167#define IEEE80211_CRYPTO_BITS \
152 "\20\1WEP\2TKIP\3AES\4AES_CCM\5TKIPMIC\6CKIP"
168 "\20\1WEP\2TKIP\3AES\4AES_CCM\5TKIPMIC\6CKIP\10AES_CCM_256" \
169 "\11BIP_CMAC_128\12BIP_CMAC_256\13BIP_GMAC_128\14BIP_CMAC_256" \
170 "\15AES_GCM_128\16AES_GCM_256"
153171
154172#if defined(__KERNEL__) || defined(_KERNEL)
155173
......@@ -162,6 +180,12 @@ MALLOC_DECLARE(M_80211_CRYPTO);
162180
163181void ieee80211_crypto_attach(struct ieee80211com *);
164182void ieee80211_crypto_detach(struct ieee80211com *);
183void ieee80211_crypto_set_supported_software_ciphers(struct ieee80211com *,
184 uint32_t cipher_set);
185void ieee80211_crypto_set_supported_hardware_ciphers(struct ieee80211com *,
186 uint32_t cipher_set);
187void ieee80211_crypto_set_supported_driver_keymgmt(struct ieee80211com *,
188 uint32_t keymgmt_set);
165189void ieee80211_crypto_vattach(struct ieee80211vap *);
166190void ieee80211_crypto_vdetach(struct ieee80211vap *);
167191int ieee80211_crypto_newkey(struct ieee80211vap *,
......@@ -192,6 +216,11 @@ struct ieee80211_cipher {
192216 void (*ic_setiv)(struct ieee80211_key *, uint8_t *);
193217 int (*ic_encap)(struct ieee80211_key *, struct mbuf *);
194218 int (*ic_decap)(struct ieee80211_key *, struct mbuf *, int);
219 /*
220 * ic_enmic() and ic_demic() are currently only used by TKIP.
221 * Please see ieee80211_crypto_enmic() and ieee80211_crypto_demic()
222 * for more information.
223 */
195224 int (*ic_enmic)(struct ieee80211_key *, struct mbuf *, int);
196225 int (*ic_demic)(struct ieee80211_key *, struct mbuf *, int);
197226};
......@@ -216,8 +245,24 @@ int ieee80211_crypto_decap(struct ieee80211_node *,
216245 struct mbuf *, int, struct ieee80211_key **);
217246int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
218247 struct mbuf *, int);
219/*
220 * Add any MIC.
248/**
249 * @brief Add any pre-fragmentation MIC to an MSDU.
250 *
251 * This is called before 802.11 fragmentation. Crypto types that implement
252 * a MIC/ICV check per MSDU will not implement this function.
253 *
254 * As an example, TKIP implements a Michael MIC check over the entire
255 * unencrypted MSDU before fragmenting it into MPDUs and passing each
256 * MPDU to be separately encrypted with their own MIC/ICV.
257 *
258 * Please see 802.11-2020 12.5.2.1.2 (TKIP cryptographic encapsulation)
259 * for more information.
260 *
261 * @param vap the current VAP
262 * @param k the current key
263 * @param m the mbuf representing the MSDU
264 * @param f set to 1 to force a MSDU MIC check, even if HW encrypted
265 * @returns 0 if error / MIC encap failed, 1 if OK
221266 */
222267static __inline int
223268ieee80211_crypto_enmic(struct ieee80211vap *vap,
......@@ -249,6 +294,11 @@ void ieee80211_notify_replay_failure(struct ieee80211vap *,
249294 const struct ieee80211_frame *, const struct ieee80211_key *,
250295 uint64_t rsc, int tid);
251296void ieee80211_notify_michael_failure(struct ieee80211vap *,
252 const struct ieee80211_frame *, u_int keyix);
297 const struct ieee80211_frame *, ieee80211_keyix keyix);
298
299/* AAD assembly for CCMP/GCMP. */
300uint16_t ieee80211_crypto_init_aad(const struct ieee80211_frame *,
301 uint8_t *, int);
302
253303#endif /* defined(__KERNEL__) || defined(_KERNEL) */
254304#endif /* _NET80211_IEEE80211_CRYPTO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net80211/ieee80211_crypto_gcm.h created+58
......@@ -0,0 +1,58 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2012, Jouni Malinen <j@w1.fi>
5 * All rights reserved.
6 *
7 * Galois/Counter Mode (GCM) and GMAC with AES
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#ifndef __IEEE80211_CRYPTO_GCM_H__
30#define __IEEE80211_CRYPTO_GCM_H__
31
32#if defined(__KERNEL__) || defined(_KERNEL)
33
34#include <crypto/rijndael/rijndael.h>
35
36#define AES_BLOCK_LEN 16
37
38/*
39 * buffer is 2x the AES_BLOCK_LEN, but the AAD contents may be variable
40 * and are padded.
41 */
42#define GCM_AAD_LEN (AES_BLOCK_LEN * 2)
43
44/* GCMP is always 128 bit / 16 byte MIC */
45#define GCMP_MIC_LEN 16
46
47void ieee80211_crypto_aes_gcm_ae(rijndael_ctx *aes, const uint8_t *iv,
48 size_t iv_len, const uint8_t *plain, size_t plain_len,
49 const uint8_t *aad, size_t aad_len, uint8_t *crypt, uint8_t *tag);
50
51int ieee80211_crypto_aes_gcm_ad(rijndael_ctx *aes, const uint8_t *iv,
52 size_t iv_len, const uint8_t *crypt, size_t crypt_len,
53 const uint8_t *aad, size_t aad_len, const uint8_t *tag,
54 uint8_t *plain);
55
56#endif /* __KERNEL__ */
57
58#endif /* __IEEE80211_CRYPTO_GCM_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net80211/ieee80211_freebsd.h+49-14
......@@ -73,6 +73,8 @@ typedef struct {
7373 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED)
7474#define IEEE80211_UNLOCK_ASSERT(_ic) \
7575 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_NOTOWNED)
76#define IEEE80211_IS_LOCKED(_ic) \
77 mtx_owned(IEEE80211_LOCK_OBJ(_ic))
7678
7779/*
7880 * Transmit lock.
......@@ -91,12 +93,22 @@ typedef struct {
9193} while (0)
9294#define IEEE80211_TX_LOCK_OBJ(_ic) (&(_ic)->ic_txlock.mtx)
9395#define IEEE80211_TX_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_TX_LOCK_OBJ(_ic))
94#define IEEE80211_TX_LOCK(_ic) mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic))
95#define IEEE80211_TX_UNLOCK(_ic) mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic))
96#define IEEE80211_TX_LOCK_ASSERT(_ic) \
97 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED)
98#define IEEE80211_TX_UNLOCK_ASSERT(_ic) \
99 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED)
96#define IEEE80211_TX_LOCK(_ic) do { \
97 if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \
98 mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic)); \
99 } while (0);
100#define IEEE80211_TX_UNLOCK(_ic) do { \
101 if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \
102 mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic)); \
103 } while (0);
104#define IEEE80211_TX_LOCK_ASSERT(_ic) do { \
105 if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \
106 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED); \
107 } while (0)
108#define IEEE80211_TX_UNLOCK_ASSERT(_ic) { \
109 if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \
110 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED); \
111 } while (0)
100112
101113/*
102114 * Stageq / ni_tx_superg lock
......@@ -260,9 +272,9 @@ void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
260272void ieee80211_vap_destroy(struct ieee80211vap *);
261273const char * ieee80211_get_vap_ifname(struct ieee80211vap *);
262274
263#define IFNET_IS_UP_RUNNING(_ifp) \
264 (((_ifp)->if_flags & IFF_UP) && \
265 ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
275#define IFNET_IS_UP_RUNNING(_ifp) \
276 (((if_getflags(_ifp) & IFF_UP) != 0) && \
277 ((if_getdrvflags(_ifp) & IFF_DRV_RUNNING) != 0))
266278
267279#define msecs_to_ticks(ms) MSEC_2_TICKS(ms)
268280#define ticks_to_msecs(t) TICKS_2_MSEC(t)
......@@ -329,11 +341,16 @@ struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
329341#define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)
330342
331343/*
332 * Store the sequence number.
344 * Store / retrieve the sequence number in an mbuf.
345 *
346 * The sequence number being stored/retreived is the 12 bit
347 * base sequence number, not the 16 bit sequence number field.
348 * I.e., it's from 0..4095 inclusive, with no 4 bit padding for
349 * fragment numbers.
333350 */
334351#define M_SEQNO_SET(m, seqno) \
335 ((m)->m_pkthdr.tso_segsz = (seqno))
336#define M_SEQNO_GET(m) ((m)->m_pkthdr.tso_segsz)
352 ((m)->m_pkthdr.tso_segsz = ((seqno) % IEEE80211_SEQ_RANGE))
353#define M_SEQNO_GET(m) (((m)->m_pkthdr.tso_segsz) % IEEE80211_SEQ_RANGE)
337354
338355#define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */
339356
......@@ -417,8 +434,7 @@ MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
417434/*
418435 * Crypto modules implement cipher support.
419436 */
420#define IEEE80211_CRYPTO_MODULE(name, version) \
421_IEEE80211_POLICY_MODULE(crypto, name, version); \
437#define IEEE80211_CRYPTO_MODULE_ADD(name) \
422438static void \
423439name##_modevent(int type) \
424440{ \
......@@ -429,6 +445,10 @@ name##_modevent(int type) \
429445} \
430446TEXT_SET(crypto##_set, name##_modevent)
431447
448#define IEEE80211_CRYPTO_MODULE(name, version) \
449 _IEEE80211_POLICY_MODULE(crypto, name, version); \
450 IEEE80211_CRYPTO_MODULE_ADD(name)
451
432452/*
433453 * Scanner modules provide scanning policy.
434454 */
......@@ -535,6 +555,21 @@ struct debugnet80211_methods {
535555#define DEBUGNET80211_SET(ic, driver)
536556#endif /* DEBUGNET */
537557
558void ieee80211_vap_sync_mac_address(struct ieee80211vap *);
559void ieee80211_vap_copy_mac_address(struct ieee80211vap *);
560void ieee80211_vap_deliver_data(struct ieee80211vap *, struct mbuf *);
561bool ieee80211_vap_ifp_check_is_monitor(struct ieee80211vap *);
562bool ieee80211_vap_ifp_check_is_simplex(struct ieee80211vap *);
563bool ieee80211_vap_ifp_check_is_running(struct ieee80211vap *);
564void ieee80211_vap_ifp_set_running_state(struct ieee80211vap *, bool);
565const uint8_t * ieee80211_vap_get_broadcast_address(struct ieee80211vap *);
566
567void net80211_printf(const char *fmt, ...) __printflike(1, 2);
568void net80211_vap_printf(const struct ieee80211vap *, const char *fmt, ...)
569 __printflike(2, 3);
570void net80211_ic_printf(const struct ieee80211com *, const char *fmt, ...)
571 __printflike(2, 3);
572
538573#endif /* _KERNEL */
539574
540575/* XXX this stuff belongs elsewhere */
lib/libc/include/generic-freebsd/net80211/ieee80211_ht.h+8-1
......@@ -87,7 +87,8 @@ struct ieee80211_tx_ampdu {
8787 (IEEE80211_AGGR_RUNNING|IEEE80211_AGGR_XCHGPEND|IEEE80211_AGGR_NAK)) != 0)
8888
8989#define IEEE80211_AGGR_BITS \
90 "\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK"
90 "\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK" \
91 "\6BARPEND\7WAITRX\10AMSDU"
9192
9293/*
9394 * Traffic estimator support. We estimate packets/sec for
......@@ -240,5 +241,11 @@ int ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid);
240241int ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni,
241242 int tid, int status);
242243void ieee80211_htinfo_notify(struct ieee80211vap *vap);
244int ieee80211_ht_get_node_ampdu_density(const struct ieee80211_node *ni);
245int ieee80211_ht_get_node_ampdu_limit(const struct ieee80211_node *ni);
246bool ieee80211_ht_check_tx_shortgi_20(const struct ieee80211_node *ni);
247bool ieee80211_ht_check_tx_shortgi_40(const struct ieee80211_node *ni);
248bool ieee80211_ht_check_tx_ht40(const struct ieee80211_node *ni);
249bool ieee80211_ht_check_tx_ht(const struct ieee80211_node *ht);
243250
244251#endif /* _NET80211_IEEE80211_HT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net80211/ieee80211_ioctl.h+10-2
......@@ -253,6 +253,14 @@ struct ieee80211_stats {
253253 uint32_t is_ff_encapfail; /* failed FF encap */
254254 uint32_t is_amsdu_encapfail; /* failed A-MSDU encap */
255255
256 uint32_t is_crypto_gcmp; /* gcmp crypto done in s/w */
257 uint32_t is_rx_gcmpreplay; /* rx seq# violation (GCMP) */
258 uint32_t is_rx_gcmpformat; /* rx format bad (GCMP) */
259 uint32_t is_rx_gcmpmic; /* rx MIC check failed (GCMP) */
260 uint32_t is_crypto_gcmp_nomem; /* gcmp crypto failed; no mem */
261 uint32_t is_crypto_gcmp_nospc; /* gcmp crypto failed; no mbuf space */
262 uint32_t is_crypto_swcipherfail; /* no support for SW cipher */
263
256264 uint32_t is_spare[5];
257265};
258266
......@@ -551,13 +559,13 @@ struct ieee80211_regdomain_req {
551559 IEEE80211_REGDOMAIN_SIZE((_req)->chaninfo.ic_nchans)
552560
553561/*
554 * Get driver capabilities. Driver, hardware crypto, and
562 * Get driver capabilities. Driver, hardware/software crypto, and
555563 * HT/802.11n capabilities, and a table that describes what
556564 * the radio can do.
557565 */
558566struct ieee80211_devcaps_req {
559567 uint32_t dc_drivercaps; /* general driver caps */
560 uint32_t dc_cryptocaps; /* hardware crypto support */
568 uint32_t dc_cryptocaps; /* software + hardware crypto support */
561569 uint32_t dc_htcaps; /* HT/802.11n support */
562570 uint32_t dc_vhtcaps; /* VHT/802.11ac capabilities */
563571 struct ieee80211req_chaninfo dc_chaninfo;
lib/libc/include/generic-freebsd/net80211/ieee80211_node.h+91-5
......@@ -108,6 +108,69 @@ enum ieee80211_mesh_mlstate {
108108#define IEEE80211_MESH_MLSTATE_BITS \
109109 "\20\1IDLE\2OPENSNT\2OPENRCV\3CONFIRMRCV\4ESTABLISHED\5HOLDING"
110110
111/*
112 * This enum was shared with the LinuxKPI enum ieee80211_sta_rx_bandwidth
113 * describing up-to which channel width the station can receive.
114 * Rather than using hardcoded MHz values for the channel width use an enum with
115 * flags. This allows us to keep the uint8_t slot for ni_chw in
116 * struct ieee80211_node it means we do not have to sync to the value for
117 * LinuxKPI (just the names).
118 *
119 * NB: BW_20 needs to 0 and values need to be sorted! Cannot make it
120 * bitfield-alike for use with %b.
121 */
122enum net80211_sta_rx_bw {
123 NET80211_STA_RX_BW_20 = 0x00,
124 NET80211_STA_RX_BW_40,
125 NET80211_STA_RX_BW_80,
126 NET80211_STA_RX_BW_160,
127 NET80211_STA_RX_BW_320,
128} __packed;
129
130static inline const char *
131net80211_ni_chw_to_str(enum net80211_sta_rx_bw bw)
132{
133 switch (bw) {
134 case NET80211_STA_RX_BW_20: return ("BW_20");
135 case NET80211_STA_RX_BW_40: return ("BW_40");
136 case NET80211_STA_RX_BW_80: return ("BW_80");
137 case NET80211_STA_RX_BW_160: return ("BW_160");
138 case NET80211_STA_RX_BW_320: return ("BW_320");
139 }
140}
141
142enum ieee80211_node_txrate_type {
143 IEEE80211_NODE_TXRATE_UNDEFINED = 0,
144 IEEE80211_NODE_TXRATE_LEGACY = 1, /* CCK/OFDM, HT for now */
145 IEEE80211_NODE_TXRATE_HT = 2, /* HT */
146 IEEE80211_NODE_TXRATE_VHT = 3, /* VHT */
147};
148
149struct ieee80211_node_txrate {
150 enum ieee80211_node_txrate_type type;
151 uint8_t nss; /* VHT - number of spatial streams */
152 uint8_t mcs; /* HT/VHT - MCS */
153 uint8_t dot11rate; /* Legacy/HT - dot11rate / ratecode */
154};
155
156#define IEEE80211_NODE_TXRATE_INIT_LEGACY(rate) \
157 (struct ieee80211_node_txrate) { .type = IEEE80211_NODE_TXRATE_LEGACY, \
158 .nss = 0, \
159 .mcs = 0, \
160 .dot11rate = (rate) }
161
162#define IEEE80211_NODE_TXRATE_INIT_HT(i_mcs) \
163 (struct ieee80211_node_txrate) { .type = IEEE80211_NODE_TXRATE_HT, \
164 .nss = 0, \
165 .mcs = (i_mcs), \
166 .dot11rate = (i_mcs) | IEEE80211_RATE_MCS }
167
168#define IEEE80211_NODE_TXRATE_INIT_VHT(i_nss, i_mcs) \
169 (struct ieee80211_node_txrate) { .type = IEEE80211_NODE_TXRATE_VHT, \
170 .nss = (i_nss), \
171 .mcs = (i_mcs), \
172 .dot11rate = 0 }
173
111174/*
112175 * Node specific information. Note that drivers are expected
113176 * to derive from this structure to add device-specific per-node
......@@ -222,15 +285,15 @@ struct ieee80211_node {
222285 uint8_t ni_ht2ndchan; /* HT 2nd channel */
223286 uint8_t ni_htopmode; /* HT operating mode */
224287 uint8_t ni_htstbc; /* HT */
225 uint8_t ni_chw; /* negotiated channel width */
288 enum net80211_sta_rx_bw ni_chw; /* negotiated channel width */
226289 struct ieee80211_htrateset ni_htrates; /* negotiated ht rate set */
227290 struct ieee80211_tx_ampdu ni_tx_ampdu[WME_NUM_TID];
228291 struct ieee80211_rx_ampdu ni_rx_ampdu[WME_NUM_TID];
229292
230293 /* VHT state */
231294 uint32_t ni_vhtcap;
232 uint16_t ni_vht_basicmcs;
233 uint16_t ni_vht_pad2;
295 uint16_t ni_vht_basicmcs; /* Basic VHT MCS bitmap from IE */
296 uint16_t ni_vht_tx_map; /* Negotiated MCS TX map with peer */
234297 struct ieee80211_vht_mcs_info ni_vht_mcsinfo;
235298 uint8_t ni_vht_chan1; /* 20/40/80/160 - VHT chan1 */
236299 uint8_t ni_vht_chan2; /* 80+80 - VHT chan2 */
......@@ -244,7 +307,7 @@ struct ieee80211_node {
244307 /* others */
245308 short ni_inact; /* inactivity mark count */
246309 short ni_inact_reload;/* inactivity reload value */
247 int ni_txrate; /* legacy rate/MCS */
310 struct ieee80211_node_txrate ni_txrate; /* current transmit rate */
248311 struct ieee80211_psq ni_psq; /* power save queue */
249312 struct ieee80211_nodestats ni_stats; /* per-node statistics */
250313
......@@ -279,7 +342,7 @@ MALLOC_DECLARE(M_80211_NODE_IE);
279342#define IEEE80211_NODE_BITS \
280343 "\20\1AUTH\2QOS\3ERP\5PWR_MGT\6AREF\7HT\10HTCOMPAT\11WPS\12TSN" \
281344 "\13AMPDU_RX\14AMPDU_TX\15MIMO_PS\16MIMO_RTS\17RIFS\20SGI20\21SGI40" \
282 "\22ASSOCID"
345 "\22ASSOCID\23AMSDU_RX\24AMSDU_TX\25VHT\26LDPC\27UAPSD"
283346
284347#define IEEE80211_NODE_AID(ni) IEEE80211_AID(ni->ni_associd)
285348
......@@ -467,4 +530,27 @@ void ieee80211_node_join(struct ieee80211_node *,int);
467530void ieee80211_node_leave(struct ieee80211_node *);
468531int8_t ieee80211_getrssi(struct ieee80211vap *);
469532void ieee80211_getsignal(struct ieee80211vap *, int8_t *, int8_t *);
533
534/* TX sequence space related routines */
535ieee80211_seq ieee80211_tx_seqno_fetch_incr(struct ieee80211_node *,
536 uint8_t);
537ieee80211_seq ieee80211_tx_seqno_fetch(const struct ieee80211_node *,
538 uint8_t);
539
540/*
541 * Node transmit rate specific manipulation.
542 *
543 * This should eventually be refactored into its own type.
544 */
545uint8_t ieee80211_node_get_txrate_dot11rate(struct ieee80211_node *);
546void ieee80211_node_get_txrate(struct ieee80211_node *,
547 struct ieee80211_node_txrate *);
548void ieee80211_node_set_txrate(struct ieee80211_node *,
549 const struct ieee80211_node_txrate *);
550void ieee80211_node_set_txrate_dot11rate(struct ieee80211_node *, uint8_t);
551void ieee80211_node_set_txrate_ht_mcsrate(struct ieee80211_node *, uint8_t);
552uint32_t ieee80211_node_get_txrate_kbit(struct ieee80211_node *);
553void ieee80211_node_set_txrate_vht_rate(struct ieee80211_node *ni,
554 uint8_t nss, uint8_t mcs);
555
470556#endif /* _NET80211_IEEE80211_NODE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net80211/ieee80211_phy.h+9
......@@ -221,5 +221,14 @@ uint32_t ieee80211_compute_duration_ht(uint32_t frameLen,
221221 uint16_t rate, int streams, int isht40,
222222 int isShortGI);
223223
224enum net80211_sta_rx_bw;
225
226uint16_t ieee80211_phy_vht_get_mcs_mask(enum net80211_sta_rx_bw,
227 uint8_t);
228bool ieee80211_phy_vht_validate_mcs(enum net80211_sta_rx_bw,
229 uint8_t, uint8_t);
230uint32_t ieee80211_phy_vht_get_mcs_kbit(enum net80211_sta_rx_bw,
231 uint8_t, uint8_t, bool);
232
224233#endif /* _KERNEL */
225234#endif /* !_NET80211_IEEE80211_PHY_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net80211/ieee80211_proto.h+4
......@@ -123,6 +123,10 @@ struct mbuf * ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *,
123123 const struct ether_header *);
124124void ieee80211_tx_complete(struct ieee80211_node *,
125125 struct mbuf *, int);
126void ieee80211_output_seqno_assign(struct ieee80211_node *,
127 int, struct mbuf *);
128void ieee80211_output_beacon_seqno_assign(struct ieee80211_node *,
129 struct mbuf *);
126130
127131/*
128132 * The formation of ProbeResponse frames requires guidance to
lib/libc/include/generic-freebsd/net80211/ieee80211_ratectl.h+2-2
......@@ -127,12 +127,12 @@ ieee80211_ratectl_node_deinit(struct ieee80211_node *ni)
127127 vap->iv_rate->ir_node_deinit(ni);
128128}
129129
130static int __inline
130static void __inline
131131ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg)
132132{
133133 const struct ieee80211vap *vap = ni->ni_vap;
134134
135 return vap->iv_rate->ir_rate(ni, arg, iarg);
135 vap->iv_rate->ir_rate(ni, arg, iarg);
136136}
137137
138138static __inline void
lib/libc/include/generic-freebsd/net80211/ieee80211_var.h+45-9
......@@ -100,6 +100,8 @@
100100 ((ic)->ic_flags_ext & IEEE80211_FEXT_SEQNO_OFFLOAD)
101101#define IEEE80211_CONF_FRAG_OFFLOAD(ic) \
102102 ((ic)->ic_flags_ext & IEEE80211_FEXT_FRAG_OFFLOAD)
103#define IEEE80211_CONF_AMPDU_OFFLOAD(ic) \
104 ((ic)->ic_flags_ext & IEEE80211_FEXT_AMPDU_OFFLOAD)
103105
104106/*
105107 * 802.11 control state is split into a common portion that maps
......@@ -163,8 +165,12 @@ struct ieee80211com {
163165 uint32_t ic_caps; /* capabilities */
164166 uint32_t ic_htcaps; /* HT capabilities */
165167 uint32_t ic_htextcaps; /* HT extended capabilities */
166 uint32_t ic_cryptocaps; /* crypto capabilities */
168 /* driver-supported software crypto caps */
169 uint32_t ic_sw_cryptocaps;
170 uint32_t ic_cryptocaps; /* hardware crypto caps */
167171 /* set of mode capabilities */
172 /* driver/net80211 sw KEYMGMT capabilities */
173 uint32_t ic_sw_keymgmtcaps;
168174 uint8_t ic_modecaps[IEEE80211_MODE_BYTES];
169175 uint8_t ic_promisc; /* vap's needing promisc mode */
170176 uint8_t ic_allmulti; /* vap's needing all multicast*/
......@@ -693,13 +699,14 @@ MALLOC_DECLARE(M_80211_VAP);
693699#define IEEE80211_FEXT_VHT 0x00400000 /* CONF: VHT support */
694700#define IEEE80211_FEXT_QUIET_IE 0x00800000 /* STATUS: quiet IE in a beacon has been added */
695701#define IEEE80211_FEXT_UAPSD 0x01000000 /* CONF: enable U-APSD */
702#define IEEE80211_FEXT_AMPDU_OFFLOAD 0x02000000 /* CONF: driver/fw handles AMPDU[-TX] itself */
696703
697704#define IEEE80211_FEXT_BITS \
698705 "\20\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \
699706 "\0114ADDR\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\16STATEWAIT\17REINIT" \
700707 "\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC\24SCAN_OFFLOAD\25SEQNO_OFFLOAD" \
701708 "\26FRAG_OFFLOAD\27VHT" \
702 "\30QUIET_IE\31UAPSD"
709 "\30QUIET_IE\31UAPSD\32AMPDU_OFFLOAD"
703710
704711/* ic_flags_ht/iv_flags_ht */
705712#define IEEE80211_FHT_NONHT_PR 0x00000001 /* STATUS: non-HT sta present */
......@@ -728,17 +735,29 @@ MALLOC_DECLARE(M_80211_VAP);
728735
729736#define IEEE80211_FVEN_BITS "\20"
730737
738/*
739 * These flags are compared in ieee80211_setupcurchan().
740 * Thus 160 should be > 80P80.
741 */
731742#define IEEE80211_FVHT_VHT 0x000000001 /* CONF: VHT supported */
732743#define IEEE80211_FVHT_USEVHT40 0x000000002 /* CONF: Use VHT40 */
733744#define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */
734#define IEEE80211_FVHT_USEVHT160 0x000000008 /* CONF: Use VHT160 */
735#define IEEE80211_FVHT_USEVHT80P80 0x000000010 /* CONF: Use VHT 80+80 */
736#define IEEE80211_FVHT_MASK \
745#define IEEE80211_FVHT_USEVHT80P80 0x000000008 /* CONF: Use VHT 80+80 */
746#define IEEE80211_FVHT_USEVHT160 0x000000010 /* CONF: Use VHT160 */
747#define IEEE80211_FVHT_STBC_TX 0x00000020 /* CONF: STBC tx enabled */
748#define IEEE80211_FVHT_STBC_RX 0x00000040 /* CONF: STBC rx enabled */
749
750#define IEEE80211_FVHT_CHANWIDTH_MASK \
737751 (IEEE80211_FVHT_VHT | IEEE80211_FVHT_USEVHT40 | \
738752 IEEE80211_FVHT_USEVHT80 | IEEE80211_FVHT_USEVHT160 | \
739753 IEEE80211_FVHT_USEVHT80P80)
754
755#define IEEE80211_FVHT_MASK \
756 (IEEE80211_FVHT_CHANWIDTH_MASK | \
757 IEEE80211_FVHT_STBC_TX | IEEE80211_FVHT_STBC_RX)
758
740759#define IEEE80211_VFHT_BITS \
741 "\20\1VHT\2VHT40\3VHT80\4VHT160\5VHT80P80"
760 "\20\1VHT\2VHT40\3VHT80\4VHT80P80\5VHT160\6STBC_TX\7STBC_RX"
742761
743762#define IEEE80211_COM_DETACHED 0x00000001 /* ieee80211_ifdetach called */
744763#define IEEE80211_COM_REF_ADD 0x00000002 /* add / remove reference */
......@@ -746,9 +765,17 @@ MALLOC_DECLARE(M_80211_VAP);
746765#define IEEE80211_COM_REF_S 1
747766#define IEEE80211_COM_REF_MAX (IEEE80211_COM_REF >> IEEE80211_COM_REF_S)
748767
749int ic_printf(struct ieee80211com *, const char *, ...) __printflike(2, 3);
768/* TODO: Transition macro */
769#define ic_printf net80211_ic_printf
770
750771void ieee80211_ifattach(struct ieee80211com *);
751772void ieee80211_ifdetach(struct ieee80211com *);
773void ieee80211_set_software_ciphers(struct ieee80211com *,
774 uint32_t cipher_suite);
775void ieee80211_set_hardware_ciphers(struct ieee80211com *,
776 uint32_t cipher_suite);
777void ieee80211_set_driver_keymgmt_suites(struct ieee80211com *ic,
778 uint32_t keymgmt_set);
752779int ieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *,
753780 const char name[IFNAMSIZ], int unit,
754781 enum ieee80211_opmode opmode, int flags,
......@@ -772,7 +799,8 @@ void ieee80211_iterate_coms(ieee80211_com_iter_func *, void *);
772799int ieee80211_media_change(struct ifnet *);
773800void ieee80211_media_status(struct ifnet *, struct ifmediareq *);
774801int ieee80211_ioctl(struct ifnet *, u_long, caddr_t);
775int ieee80211_rate2media(struct ieee80211com *, int,
802int ieee80211_rate2media(struct ieee80211com *,
803 const struct ieee80211_node_txrate *,
776804 enum ieee80211_phymode);
777805int ieee80211_media2rate(int);
778806int ieee80211_mhz2ieee(u_int, u_int);
......@@ -814,6 +842,14 @@ char ieee80211_channel_type_char(const struct ieee80211_channel *c);
814842#define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan)
815843#define ieee80211_get_vap_desired_channel(_iv) ((_iv)->iv_des_chan)
816844
845bool ieee80211_is_key_global(const struct ieee80211vap *vap,
846 const struct ieee80211_key *key);
847bool ieee80211_is_key_unicast(const struct ieee80211vap *vap,
848 const struct ieee80211_key *key);
849
850bool ieee80211_is_ctl_frame_for_vap(struct ieee80211_node *,
851 const struct mbuf *);
852
817853void ieee80211_radiotap_attach(struct ieee80211com *,
818854 struct ieee80211_radiotap_header *th, int tlen,
819855 uint32_t tx_radiotap,
......@@ -976,7 +1012,7 @@ ieee80211_get_node_txpower(struct ieee80211_node *ni)
9761012 * Debugging facilities compiled in when IEEE80211_DEBUG is defined.
9771013 *
9781014 * The intent is that any problem in the net80211 layer can be
979 * diagnosed by inspecting the statistics (dumped by the wlanstats
1015 * diagnosed by inspecting the statistics (dumped by the wlanstat
9801016 * program) and/or the msgs generated by net80211. Messages are
9811017 * broken into functional classes and can be controlled with the
9821018 * wlandebug program. Certain of these msg groups are for facilities
lib/libc/include/generic-freebsd/net80211/ieee80211_vht.h+8-4
......@@ -40,8 +40,7 @@ void ieee80211_parse_vhtcap(struct ieee80211_node *, const uint8_t *);
4040
4141int ieee80211_vht_updateparams(struct ieee80211_node *,
4242 const uint8_t *, const uint8_t *);
43void ieee80211_setup_vht_rates(struct ieee80211_node *,
44 const uint8_t *, const uint8_t *);
43void ieee80211_setup_vht_rates(struct ieee80211_node *);
4544
4645void ieee80211_vht_timeout(struct ieee80211vap *vap);
4746
......@@ -53,8 +52,7 @@ uint8_t * ieee80211_add_vhtinfo(uint8_t *frm, struct ieee80211_node *);
5352uint8_t *ieee80211_add_vhtcap_ch(uint8_t *, struct ieee80211vap *,
5453 struct ieee80211_channel *);
5554
56void ieee80211_vht_update_cap(struct ieee80211_node *,
57 const uint8_t *, const uint8_t *);
55void ieee80211_vht_update_cap(struct ieee80211_node *, const uint8_t *);
5856
5957struct ieee80211_channel *
6058 ieee80211_vht_adjust_channel(struct ieee80211com *,
......@@ -65,4 +63,10 @@ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
6563void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni,
6664 struct ieee80211_vht_operation *, int);
6765
66bool ieee80211_vht_check_tx_vht(const struct ieee80211_node *);
67bool ieee80211_vht_check_tx_bw(const struct ieee80211_node *,
68 enum net80211_sta_rx_bw);
69bool ieee80211_vht_node_check_tx_valid_mcs(const struct ieee80211_node *,
70 enum net80211_sta_rx_bw bw, uint8_t, uint8_t);
71
6872#endif /* _NET80211_IEEE80211_VHT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netdb.h-1
......@@ -51,7 +51,6 @@
5151 */
5252
5353/*
54 * @(#)netdb.h 8.1 (Berkeley) 6/2/93
5554 * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
5655 */
5756
lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_hci_raw.h+1-2
......@@ -78,11 +78,10 @@ int ng_btsocket_hci_raw_control (struct socket *, u_long, void *,
7878int ng_btsocket_hci_raw_ctloutput (struct socket *, struct sockopt *);
7979void ng_btsocket_hci_raw_detach (struct socket *);
8080int ng_btsocket_hci_raw_disconnect (struct socket *);
81int ng_btsocket_hci_raw_peeraddr (struct socket *, struct sockaddr **);
8281int ng_btsocket_hci_raw_send (struct socket *, int, struct mbuf *,
8382 struct sockaddr *, struct mbuf *,
8483 struct thread *);
85int ng_btsocket_hci_raw_sockaddr (struct socket *, struct sockaddr **);
84int ng_btsocket_hci_raw_sockaddr (struct socket *, struct sockaddr *);
8685
8786#endif /* _KERNEL */
8887
lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_l2cap.h+4-5
......@@ -105,11 +105,11 @@ int ng_btsocket_l2cap_raw_control (struct socket *, u_long, void *,
105105 struct ifnet *, struct thread *);
106106void ng_btsocket_l2cap_raw_detach (struct socket *);
107107int ng_btsocket_l2cap_raw_disconnect (struct socket *);
108int ng_btsocket_l2cap_raw_peeraddr (struct socket *, struct sockaddr **);
108int ng_btsocket_l2cap_raw_peeraddr (struct socket *, struct sockaddr *);
109109int ng_btsocket_l2cap_raw_send (struct socket *, int, struct mbuf *,
110110 struct sockaddr *, struct mbuf *,
111111 struct thread *);
112int ng_btsocket_l2cap_raw_sockaddr (struct socket *, struct sockaddr **);
112int ng_btsocket_l2cap_raw_sockaddr (struct socket *, struct sockaddr *);
113113
114114#endif /* _KERNEL */
115115
......@@ -191,7 +191,6 @@ typedef struct ng_btsocket_l2cap_pcb * ng_btsocket_l2cap_pcb_p;
191191
192192void ng_btsocket_l2cap_abort (struct socket *);
193193void ng_btsocket_l2cap_close (struct socket *);
194int ng_btsocket_l2cap_accept (struct socket *, struct sockaddr **);
195194int ng_btsocket_l2cap_attach (struct socket *, int, struct thread *);
196195int ng_btsocket_l2cap_bind (struct socket *, struct sockaddr *,
197196 struct thread *);
......@@ -203,11 +202,11 @@ int ng_btsocket_l2cap_ctloutput (struct socket *, struct sockopt *);
203202void ng_btsocket_l2cap_detach (struct socket *);
204203int ng_btsocket_l2cap_disconnect (struct socket *);
205204int ng_btsocket_l2cap_listen (struct socket *, int, struct thread *);
206int ng_btsocket_l2cap_peeraddr (struct socket *, struct sockaddr **);
205int ng_btsocket_l2cap_peeraddr (struct socket *, struct sockaddr *);
207206int ng_btsocket_l2cap_send (struct socket *, int, struct mbuf *,
208207 struct sockaddr *, struct mbuf *,
209208 struct thread *);
210int ng_btsocket_l2cap_sockaddr (struct socket *, struct sockaddr **);
209int ng_btsocket_l2cap_sockaddr (struct socket *, struct sockaddr *);
211210
212211#endif /* _KERNEL */
213212
lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_rfcomm.h+3-3
......@@ -316,7 +316,7 @@ typedef struct ng_btsocket_rfcomm_pcb * ng_btsocket_rfcomm_pcb_p;
316316
317317void ng_btsocket_rfcomm_abort (struct socket *);
318318void ng_btsocket_rfcomm_close (struct socket *);
319int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr **);
319int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr *);
320320int ng_btsocket_rfcomm_attach (struct socket *, int, struct thread *);
321321int ng_btsocket_rfcomm_bind (struct socket *, struct sockaddr *,
322322 struct thread *);
......@@ -328,11 +328,11 @@ int ng_btsocket_rfcomm_ctloutput (struct socket *, struct sockopt *);
328328void ng_btsocket_rfcomm_detach (struct socket *);
329329int ng_btsocket_rfcomm_disconnect (struct socket *);
330330int ng_btsocket_rfcomm_listen (struct socket *, int, struct thread *);
331int ng_btsocket_rfcomm_peeraddr (struct socket *, struct sockaddr **);
331int ng_btsocket_rfcomm_peeraddr (struct socket *, struct sockaddr *);
332332int ng_btsocket_rfcomm_send (struct socket *, int, struct mbuf *,
333333 struct sockaddr *, struct mbuf *,
334334 struct thread *);
335int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr **);
335int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr *);
336336
337337#endif /* _KERNEL */
338338
lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_sco.h+3-3
......@@ -106,7 +106,7 @@ typedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p;
106106
107107void ng_btsocket_sco_abort (struct socket *);
108108void ng_btsocket_sco_close (struct socket *);
109int ng_btsocket_sco_accept (struct socket *, struct sockaddr **);
109int ng_btsocket_sco_accept (struct socket *, struct sockaddr *);
110110int ng_btsocket_sco_attach (struct socket *, int, struct thread *);
111111int ng_btsocket_sco_bind (struct socket *, struct sockaddr *,
112112 struct thread *);
......@@ -118,11 +118,11 @@ int ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *);
118118void ng_btsocket_sco_detach (struct socket *);
119119int ng_btsocket_sco_disconnect (struct socket *);
120120int ng_btsocket_sco_listen (struct socket *, int, struct thread *);
121int ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr **);
121int ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr *);
122122int ng_btsocket_sco_send (struct socket *, int, struct mbuf *,
123123 struct sockaddr *, struct mbuf *,
124124 struct thread *);
125int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr **);
125int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr *);
126126
127127#endif /* _KERNEL */
128128
lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_hci.h+79-1
......@@ -114,6 +114,8 @@
114114#define NG_HCI_LMP_FLOW_CONTROL_LAG0 0x10
115115#define NG_HCI_LMP_FLOW_CONTROL_LAG1 0x20
116116#define NG_HCI_LMP_FLOW_CONTROL_LAG2 0x40
117/* ------------------- byte 6 --------------------*/
118#define NG_HCI_LMP_SECURE_SIMPLE_PAIRING 0x08
117119
118120/* Link types */
119121#define NG_HCI_LINK_SCO 0x00 /* Voice */
......@@ -446,7 +448,7 @@ typedef struct {
446448typedef bdaddr_t * bdaddr_p;
447449
448450/* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */
449#define NG_HCI_BDADDR_ANY ((bdaddr_p) "\000\000\000\000\000\000")
451#define NG_HCI_BDADDR_ANY (&(const bdaddr_t){"\000\000\000\000\000\000"})
450452
451453/* HCI status return parameter */
452454typedef struct {
......@@ -860,6 +862,50 @@ typedef struct {
860862} __attribute__ ((packed)) ng_hci_read_clock_offset_cp;
861863/* No return parameter(s) */
862864
865#define NG_HCI_IO_CAPABILITY_REQUEST_REPLY 0x002b
866typedef struct {
867 bdaddr_t bdaddr;
868 u_int8_t io_capability;
869 u_int8_t oob_data_present;
870 u_int8_t authentication_requirements;
871} __attribute__ ((packed)) ng_hci_io_capability_request_reply_cp;
872
873typedef struct {
874 u_int8_t status;
875 bdaddr_t bdaddr;
876} __attribute__ ((packed)) ng_hci_io_capability_request_reply_rp;
877
878#define NG_HCI_USER_CONFIRMATION_REQUEST_REPLY 0x002c
879typedef struct {
880 bdaddr_t bdaddr;
881} __attribute__ ((packed)) ng_hci_user_confirmation_request_reply_cp;
882
883typedef struct {
884 u_int8_t status;
885 bdaddr_t bdaddr;
886} __attribute__ ((packed)) ng_hci_user_confirmation_request_reply_rp;
887
888#define NG_HCI_USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY 0x002d
889typedef struct {
890 bdaddr_t bdaddr;
891} __attribute__((packed)) ng_hci_user_confirmation_request_negative_reply_cp;
892
893typedef struct {
894 u_int8_t status;
895 bdaddr_t bdaddr;
896} __attribute__ ((packed)) ng_hci_user_confirmation_request_negative_reply_rp;
897
898#define NG_HCI_IO_CAPABILITY_REQUEST_NEGATIVE_REPLY 0x0034
899typedef struct {
900 bdaddr_t bdaddr;
901 u_int8_t reason;
902} __attribute__ ((packed)) ng_hci_io_capability_request_negative_reply_cp;
903
904typedef struct {
905 u_int8_t status;
906 bdaddr_t bdaddr;
907} __attribute__ ((packed)) ng_hci_io_capability_request_negative_reply_rp;
908
863909/**************************************************************************
864910 **************************************************************************
865911 ** Link policy commands and return parameters
......@@ -1374,6 +1420,13 @@ typedef struct {
13741420
13751421typedef ng_hci_status_rp ng_hci_write_page_scan_rp;
13761422
1423#define NG_HCI_OCF_WRITE_SIMPLE_PAIRING 0x0056
1424typedef struct {
1425 u_int8_t simple_pairing; /* 1 -> enabled, 0 -> disabled */
1426} __attribute__ ((packed)) ng_hci_write_simple_pairing_cp;
1427
1428typedef ng_hci_status_rp ng_hci_write_simple_pairing_rp;
1429
13771430#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c
13781431typedef struct {
13791432 u_int8_t status; /* 0x00 - success */
......@@ -1389,6 +1442,13 @@ typedef struct {
13891442
13901443typedef ng_hci_status_rp ng_hci_write_le_host_supported_rp;
13911444
1445#define NG_HCI_OCF_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT 0x007a
1446typedef struct {
1447 u_int8_t support; /* 0 - disabled, 1 - enabled */
1448} __attribute__ ((packed)) ng_hci_write_secure_connections_host_support_cp;
1449
1450typedef ng_hci_status_rp ng_hci_write_secure_connections_host_support_rp;
1451
13921452/**************************************************************************
13931453 **************************************************************************
13941454 ** Informational commands and return parameters
......@@ -2025,6 +2085,24 @@ typedef struct {
20252085 bdaddr_t bdaddr; /* destination address */
20262086 u_int8_t page_scan_rep_mode; /* page scan repetition mode */
20272087} __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep;
2088
2089#define NG_HCI_EVENT_IO_CAPABILITY_REQUEST 0x31
2090typedef struct {
2091 bdaddr_t bdaddr;
2092} __attribute__ ((packed)) ng_hci_io_capability_request_ep;
2093
2094#define NG_HCI_EVENT_USER_CONFIRMATION_REQUEST 0x33
2095typedef struct {
2096 bdaddr_t bdaddr;
2097 u_int32_t numeric_value;
2098} __attribute__ ((packed)) ng_hci_user_confirmation_request_ep;
2099
2100#define NG_HCI_EVENT_SIMPLE_PAIRING_COMPLETE 0x36
2101typedef struct {
2102 u_int8_t status;
2103 bdaddr_t bdaddr;
2104} __attribute__ ((packed)) ng_hci_simple_pairing_complete_ep;
2105
20282106#define NG_HCI_EVENT_LE 0x3e
20292107typedef struct {
20302108 u_int8_t subevent_code;
lib/libc/include/generic-freebsd/netgraph/netflow/ng_netflow.h+2-2
......@@ -259,7 +259,7 @@ struct flow_entry_data {
259259 u_long bytes;
260260 long first; /* uptime on first packet */
261261 long last; /* uptime on last packet */
262 u_char tcp_flags; /* cumulative OR */
262 uint16_t tcp_flags; /* cumulative OR */
263263};
264264
265265struct flow6_entry_data {
......@@ -277,7 +277,7 @@ struct flow6_entry_data {
277277 u_long bytes;
278278 long first; /* uptime on first packet */
279279 long last; /* uptime on last packet */
280 u_char tcp_flags; /* cumulative OR */
280 uint16_t tcp_flags; /* cumulative OR */
281281};
282282
283283/*
lib/libc/include/generic-freebsd/netgraph/netgraph.h+14-5
......@@ -69,11 +69,20 @@
6969 * modules.
7070 */
7171#define _NG_ABI_VERSION 12
72#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/
73#define NG_ABI_VERSION (_NG_ABI_VERSION + 0x10000)
74#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
75#define NG_ABI_VERSION _NG_ABI_VERSION
76#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
72
73#ifdef NETGRAPH_DEBUG
74#define _NG_ABI_PREFIX1 0x10000
75#else
76#define _NG_ABI_PREFIX1 0
77#endif
78
79#ifdef INVARIANTS
80#define _NG_ABI_PREFIX2 0x20000
81#else
82#define _NG_ABI_PREFIX2 0
83#endif
84
85#define NG_ABI_VERSION (_NG_ABI_PREFIX1 + _NG_ABI_PREFIX2 + _NG_ABI_VERSION)
7786
7887/*
7988 * Forward references for the basic structures so we can
lib/libc/include/generic-freebsd/netgraph/ng_message.h+4-1
......@@ -42,7 +42,10 @@
4242#ifndef _NETGRAPH_NG_MESSAGE_H_
4343#define _NETGRAPH_NG_MESSAGE_H_
4444
45/* ASCII string size limits */
45/*
46 * ASCII string size limits
47 * Check with struct sockaddr_ng if changing.
48 */
4649#define NG_TYPESIZ 32 /* max type name len (including null) */
4750#define NG_HOOKSIZ 32 /* max hook name len (including null) */
4851#define NG_NODESIZ 32 /* max node name len (including null) */
lib/libc/include/generic-freebsd/netgraph/ng_nat.h+1
......@@ -53,6 +53,7 @@ struct ng_nat_mode {
5353#define NG_NAT_PROXY_ONLY 0x40
5454#define NG_NAT_REVERSE 0x80
5555#define NG_NAT_UNREGISTERED_CGN 0x100
56#define NG_NAT_UDP_EIM 0x200
5657
5758#define NG_NAT_DESC_LENGTH 64
5859#define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */
lib/libc/include/generic-freebsd/netgraph/ng_socket.h+1-1
......@@ -60,7 +60,7 @@ enum {
6060struct sockaddr_ng {
6161 unsigned char sg_len; /* total length */
6262 sa_family_t sg_family; /* address family */
63 char sg_data[14]; /* actually longer; address value */
63 char sg_data[32]; /* see NG_NODESIZ in ng_message.h */
6464};
6565
6666#endif /* _NETGRAPH_NG_SOCKET_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/cc/cc.h+31-35
......@@ -87,21 +87,12 @@ int cc_deregister_algo(struct cc_algo *remove_cc);
8787#endif /* _KERNEL */
8888
8989#if defined(_KERNEL) || defined(_WANT_TCPCB)
90/*
91 * Wrapper around transport structs that contain same-named congestion
92 * control variables. Allows algos to be shared amongst multiple CC aware
93 * transprots.
94 */
9590struct cc_var {
9691 void *cc_data; /* Per-connection private CC algorithm data. */
9792 int bytes_this_ack; /* # bytes acked by the current ACK. */
9893 tcp_seq curack; /* Most recent ACK. */
9994 uint32_t flags; /* Flags for cc_var (see below) */
100 int type; /* Indicates which ptr is valid in ccvc. */
101 union ccv_container {
102 struct tcpcb *tcp;
103 struct sctp_nets *sctp;
104 } ccvc;
95 struct tcpcb *tp; /* Pointer to tcpcb */
10596 uint16_t nsegs; /* # segments coalesced into current chain. */
10697 uint8_t labc; /* Dont use system abc use passed in */
10798};
......@@ -113,32 +104,34 @@ struct cc_var {
113104#define CCF_ACKNOW 0x0008 /* Will this ack be sent now? */
114105#define CCF_IPHDR_CE 0x0010 /* Does this packet set CE bit? */
115106#define CCF_TCPHDR_CWR 0x0020 /* Does this packet set CWR bit? */
116#define CCF_MAX_CWND 0x0040 /* Have we reached maximum cwnd? */
117#define CCF_CHG_MAX_CWND 0x0080 /* CUBIC max_cwnd changed, for K */
118#define CCF_USR_IWND 0x0100 /* User specified initial window */
119#define CCF_USR_IWND_INIT_NSEG 0x0200 /* Convert segs to bytes on conn init */
107#define CCF_UNUSED1 0x0040
108#define CCF_UNUSED2 0x0080
109#define CCF_UNUSED3 0x0100
110#define CCF_UNUSED4 0x0200
120111#define CCF_HYSTART_ALLOWED 0x0400 /* If the CC supports it Hystart is allowed */
121112#define CCF_HYSTART_CAN_SH_CWND 0x0800 /* Can hystart when going CSS -> CA slam the cwnd */
122113#define CCF_HYSTART_CONS_SSTH 0x1000 /* Should hystart use the more conservative ssthresh */
123114
124/* ACK types passed to the ack_received() hook. */
125#define CC_ACK 0x0001 /* Regular in sequence ACK. */
126#define CC_DUPACK 0x0002 /* Duplicate ACK. */
127#define CC_PARTIALACK 0x0004 /* Not yet. */
128#define CC_SACK 0x0008 /* Not yet. */
129115#endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */
130
131/*
132 * Congestion signal types passed to the cong_signal() hook. The highest order 8
133 * bits (0x01000000 - 0x80000000) are reserved for CC algos to declare their own
134 * congestion signal types.
135 */
136#define CC_ECN 0x00000001 /* ECN marked packet received. */
137#define CC_RTO 0x00000002 /* RTO fired. */
138#define CC_RTO_ERR 0x00000004 /* RTO fired in error. */
139#define CC_NDUPACK 0x00000008 /* Threshold of dupack's reached. */
140
141#define CC_SIGPRIVMASK 0xFF000000 /* Mask to check if sig is private. */
116typedef enum {
117#if defined(_KERNEL) || defined(_WANT_TCPCB)
118 /* ACK types passed to the ack_received() hook. */
119 CC_ACK = 0x0001, /* Regular in sequence ACK. */
120 CC_DUPACK = 0x0002, /* Duplicate ACK. */
121 CC_PARTIALACK = 0x0004, /* Not yet. */
122 CC_SACK = 0x0008, /* Not yet. */
123#endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */
124 /* Congestion signal types passed to the cong_signal() hook. */
125 CC_ECN = 0x0100, /* ECN marked packet received. */
126 CC_RTO = 0x0200, /* RTO fired. */
127 CC_RTO_ERR = 0x0400, /* RTO fired in error. */
128 CC_NDUPACK = 0x0800, /* Threshold of dupack's reached. */
129 /*
130 * The highest order 8 bits (0x01000000 - 0x80000000) are reserved
131 * for CC algos to declare their own congestion signal types.
132 */
133 CC_SIGPRIVMASK = 0xFF000000 /* Mask to check if sig is private. */
134} ccsignal_t;
142135
143136#ifdef _KERNEL
144137/*
......@@ -175,10 +168,10 @@ struct cc_algo {
175168 void (*conn_init)(struct cc_var *ccv);
176169
177170 /* Called on receipt of an ack. */
178 void (*ack_received)(struct cc_var *ccv, uint16_t type);
171 void (*ack_received)(struct cc_var *ccv, ccsignal_t type);
179172
180173 /* Called on detection of a congestion signal. */
181 void (*cong_signal)(struct cc_var *ccv, uint32_t type);
174 void (*cong_signal)(struct cc_var *ccv, ccsignal_t type);
182175
183176 /* Called after exiting congestion recovery. */
184177 void (*post_recovery)(struct cc_var *ccv);
......@@ -236,8 +229,11 @@ extern struct rwlock cc_list_lock;
236229 */
237230void newreno_cc_post_recovery(struct cc_var *);
238231void newreno_cc_after_idle(struct cc_var *);
239void newreno_cc_cong_signal(struct cc_var *, uint32_t );
240void newreno_cc_ack_received(struct cc_var *, uint16_t);
232void newreno_cc_cong_signal(struct cc_var *, ccsignal_t);
233void newreno_cc_ack_received(struct cc_var *, ccsignal_t);
234u_int newreno_cc_cwnd_on_multiplicative_decrease(struct cc_var *ccv, uint32_t mss);
235u_int newreno_cc_cwnd_in_cong_avoid(struct cc_var *ccv);
236u_int newreno_cc_cwnd_in_slow_start(struct cc_var *ccv);
241237
242238/* Called to temporarily keep an algo from going away during change */
243239void cc_refer(struct cc_algo *algo);
lib/libc/include/generic-freebsd/netinet/cc/cc_cubic.h+102-88
......@@ -83,26 +83,28 @@
8383#define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */
8484#define CUBICFLAG_HYSTART_ENABLED 0x00000010 /* Hystart++ is enabled */
8585#define CUBICFLAG_HYSTART_IN_CSS 0x00000020 /* We are in Hystart++ CSS */
86#define CUBICFLAG_IN_TF 0x00000040 /* We are in TCP friendly region */
8687
8788/* Kernel only bits */
8889#ifdef _KERNEL
8990struct cubic {
90 /* CUBIC K in fixed point form with CUBIC_SHIFT worth of precision. */
91 /*
92 * CUBIC K in fixed point form with CUBIC_SHIFT worth of precision.
93 * Also means the time period in seconds it takes to increase the
94 * congestion window size at the beginning of the current congestion
95 * avoidance stage to W_max.
96 */
9197 int64_t K;
9298 /* Sum of RTT samples across an epoch in usecs. */
9399 int64_t sum_rtt_usecs;
94 /* Size of cwnd just before cwnd was reduced in the last congestion event */
95 uint64_t W_max;
96 /* An estimate for the congestion window in the Reno-friendly region */
97 uint64_t W_est;
98 /* The cwnd at the beginning of the current congestion avoidance stage */
99 uint64_t cwnd_epoch;
100 /*
101 * Size of cwnd at the time of setting ssthresh most recently,
102 * either upon exiting the first slow start, or just before cwnd
103 * was reduced in the last congestion event
104 */
105 uint64_t cwnd_prior;
100 /* Size of cwnd (in bytes) just before cwnd was reduced in the last congestion event. */
101 uint32_t W_max;
102 /* An estimate (in bytes) for the congestion window in the Reno-friendly region */
103 uint32_t W_est;
104 /* An estimate (in bytes) for the congestion window in the CUBIC region */
105 uint32_t W_cubic;
106 /* The cwnd (in bytes) at the beginning of the current congestion avoidance stage. */
107 uint32_t cwnd_epoch;
106108 /* various flags */
107109 uint32_t flags;
108110 /* Minimum observed rtt in usecs. */
......@@ -117,12 +119,8 @@ struct cubic {
117119 int undo_t_epoch;
118120 /* Few variables to restore the state after RTO_ERR */
119121 int64_t undo_K;
120 uint64_t undo_cwnd_prior;
121 uint64_t undo_W_max;
122 uint64_t undo_W_est;
123 uint64_t undo_cwnd_epoch;
124 /* Number of congestion events experienced */
125 uint64_t num_cong_events;
122 uint32_t undo_W_max;
123 uint32_t undo_cwnd_epoch;
126124 uint32_t css_baseline_minrtt;
127125 uint32_t css_current_round_minrtt;
128126 uint32_t css_lastround_minrtt;
......@@ -141,60 +139,103 @@ struct cubic {
141139extern int hz;
142140
143141/*
144 * Implementation based on the formulae found in the CUBIC Internet Draft
145 * "draft-ietf-tcpm-cubic-04".
142 * Implementation based on the formulas in RFC9438.
146143 *
147144 */
148145
149static __inline float
150theoretical_cubic_k(double wmax_pkts)
146
147/*
148 * Returns K, the time period in seconds it takes to increase the congestion
149 * window size at the beginning of the current congestion avoidance stage to
150 * W_max.
151 */
152static inline float
153theoretical_cubic_k(uint32_t wmax_segs, uint32_t cwnd_epoch_segs)
151154{
152155 double C;
153156
154157 C = 0.4;
158 if (wmax_segs <= cwnd_epoch_segs)
159 return 0.0;
155160
156 return (pow((wmax_pkts * 0.3) / C, (1.0 / 3.0)) * pow(2, CUBIC_SHIFT));
161 /*
162 * Figure 2: K = ((W_max - cwnd_epoch) / C)^(1/3)
163 */
164 return (pow((wmax_segs - cwnd_epoch_segs) / C, (1.0 / 3.0)) * pow(2, CUBIC_SHIFT));
157165}
158166
159static __inline unsigned long
160theoretical_cubic_cwnd(int ticks_since_epoch, unsigned long wmax, uint32_t smss)
167/*
168 * Returns the congestion window in segments at time t in seconds based on the
169 * cubic increase function, where t is the elapsed time in seconds from the
170 * beginning of the current congestion avoidance stage, as described in RFC9438
171 * Section 4.2.
172 */
173static inline unsigned long
174theoretical_cubic_cwnd(int ticks_elapsed, uint32_t wmax_segs, uint32_t cwnd_epoch_segs)
161175{
162 double C, wmax_pkts;
176 double C, t;
177 float K;
163178
164179 C = 0.4;
165 wmax_pkts = wmax / (double)smss;
180 t = ticks_elapsed / (double)hz;
181 K = theoretical_cubic_k(wmax_segs, cwnd_epoch_segs);
166182
167 return (smss * (wmax_pkts +
168 (C * pow(ticks_since_epoch / (double)hz -
169 theoretical_cubic_k(wmax_pkts) / pow(2, CUBIC_SHIFT), 3.0))));
183 /*
184 * Figure 1: W_cubic(t) = C * (t - K)^3 + W_max
185 */
186 return (C * pow(t - K / pow(2, CUBIC_SHIFT), 3.0) + wmax_segs);
170187}
171188
172static __inline unsigned long
173theoretical_reno_cwnd(int ticks_since_epoch, int rtt_ticks, unsigned long wmax,
174 uint32_t smss)
189/*
190 * Returns estimated Reno congestion window in segments.
191 */
192static inline unsigned long
193theoretical_reno_cwnd(int ticks_elapsed, int rtt_ticks, uint32_t wmax_segs)
175194{
176195
177 return ((wmax * 0.5) + ((ticks_since_epoch / (float)rtt_ticks) * smss));
196 return (wmax_segs * 0.5 + ticks_elapsed / (float)rtt_ticks);
178197}
179198
180static __inline unsigned long
181theoretical_tf_cwnd(int ticks_since_epoch, int rtt_ticks, unsigned long wmax,
182 uint32_t smss)
199/*
200 * Returns an estimate for the congestion window in segments in the
201 * Reno-friendly region -- that is, an estimate for the congestion window of
202 * Reno, as described in RFC9438 Section 4.3, where:
203 * cwnd: Current congestion window in segments.
204 * cwnd_prior: Size of cwnd in segments at the time of setting ssthresh most
205 * recently, either upon exiting the first slow start or just before
206 * cwnd was reduced in the last congestion event.
207 * W_est: An estimate for the congestion window in segments in the Reno-friendly
208 * region -- that is, an estimate for the congestion window of Reno.
209 */
210static inline unsigned long
211theoretical_tf_cwnd(unsigned long W_est, unsigned long segs_acked, unsigned long cwnd,
212 unsigned long cwnd_prior)
183213{
214 float cubic_alpha, cubic_beta;
184215
185 return ((wmax * 0.7) + ((3 * 0.3) / (2 - 0.3) *
186 (ticks_since_epoch / (float)rtt_ticks) * smss));
216 /* RFC9438 Section 4.6: The parameter β_cubic SHOULD be set to 0.7. */
217 cubic_beta = 0.7;
218
219 if (W_est >= cwnd_prior)
220 cubic_alpha = 1.0;
221 else
222 cubic_alpha = (3.0 * (1.0 - cubic_beta)) / (1.0 + cubic_beta);
223
224 /*
225 * Figure 4: W_est = W_est + α_cubic * segments_acked / cwnd
226 */
227 return (W_est + cubic_alpha * segs_acked / cwnd);
187228}
188229
189230#endif /* !_KERNEL */
190231
191232/*
192233 * Compute the CUBIC K value used in the cwnd calculation, using an
193 * implementation of eqn 2 in the I-D. The method used
194 * here is adapted from Apple Computer Technical Report #KT-32.
234 * implementation mentioned in Figure. 2 of RFC9438.
235 * The method used here is adapted from Apple Computer Technical Report #KT-32.
195236 */
196static __inline int64_t
197cubic_k(unsigned long wmax_pkts)
237static inline int64_t
238cubic_k(uint32_t wmax_segs, uint32_t cwnd_epoch_segs)
198239{
199240 int64_t s, K;
200241 uint16_t p;
......@@ -202,8 +243,13 @@ cubic_k(unsigned long wmax_pkts)
202243 K = s = 0;
203244 p = 0;
204245
205 /* (wmax * beta)/C with CUBIC_SHIFT worth of precision. */
206 s = ((wmax_pkts * ONE_SUB_CUBIC_BETA) << CUBIC_SHIFT) / CUBIC_C_FACTOR;
246 /* Handle the corner case where W_max <= cwnd_epoch */
247 if (wmax_segs <= cwnd_epoch_segs) {
248 return 0;
249 }
250
251 /* (wmax - cwnd_epoch) / C with CUBIC_SHIFT worth of precision. */
252 s = ((wmax_segs - cwnd_epoch_segs) << (2 * CUBIC_SHIFT)) / CUBIC_C_FACTOR;
207253
208254 /* Rebase s to be between 1 and 1/8 with a shift of CUBIC_SHIFT. */
209255 while (s >= 256) {
......@@ -224,13 +270,14 @@ cubic_k(unsigned long wmax_pkts)
224270}
225271
226272/*
227 * Compute the new cwnd value using an implementation of eqn 1 from the I-D.
273 * Compute and return the new cwnd value in bytes using an implementation
274 * mentioned in Figure. 1 of RFC9438.
228275 * Thanks to Kip Macy for help debugging this function.
229276 *
230277 * XXXLAS: Characterise bounds for overflow.
231278 */
232static __inline unsigned long
233cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)
279static inline uint32_t
280cubic_cwnd(int usecs_since_epoch, uint32_t wmax, uint32_t smss, int64_t K)
234281{
235282 int64_t cwnd;
236283
......@@ -249,7 +296,7 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)
249296 cwnd *= (cwnd * cwnd);
250297
251298 /*
252 * C(t - K)^3 + wmax
299 * Figure 1: C * (t - K)^3 + wmax
253300 * The down shift by CUBIC_SHIFT_4 is because cwnd has 4 lots of
254301 * CUBIC_SHIFT included in the value. 3 from the cubing of cwnd above,
255302 * and an extra from multiplying through by CUBIC_C_FACTOR.
......@@ -264,46 +311,13 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)
264311}
265312
266313/*
267 * Compute an approximation of the NewReno cwnd some number of usecs after a
268 * congestion event. RTT should be the average RTT estimate for the path
269 * measured over the previous congestion epoch and wmax is the value of cwnd at
270 * the last congestion event. The "TCP friendly" concept in the CUBIC I-D is
271 * rather tricky to understand and it turns out this function is not required.
272 * It is left here for reference.
273 *
274 * XXX: Not used
314 * Compute the "TCP friendly" cwnd by newreno in congestion avoidance state.
275315 */
276static __inline unsigned long
277reno_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax,
278 uint32_t smss)
316static inline uint32_t
317tf_cwnd(struct cc_var *ccv)
279318{
280
281 /*
282 * For NewReno, beta = 0.5, therefore: W_tcp(t) = wmax*0.5 + t/RTT
283 * W_tcp(t) deals with cwnd/wmax in pkts, so because our cwnd is in
284 * bytes, we have to multiply by smss.
285 */
286 return (((wmax * RENO_BETA) + (((usecs_since_epoch * smss)
287 << CUBIC_SHIFT) / rtt_usecs)) >> CUBIC_SHIFT);
288}
289
290/*
291 * Compute an approximation of the "TCP friendly" cwnd some number of usecs
292 * after a congestion event that is designed to yield the same average cwnd as
293 * NewReno while using CUBIC's beta of 0.7. RTT should be the average RTT
294 * estimate for the path measured over the previous congestion epoch and wmax is
295 * the value of cwnd at the last congestion event.
296 */
297static __inline unsigned long
298tf_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax,
299 uint32_t smss)
300{
301
302 /* Equation 4 of I-D. */
303 return (((wmax * CUBIC_BETA) +
304 (((THREE_X_PT3 * (unsigned long)usecs_since_epoch *
305 (unsigned long)smss) << CUBIC_SHIFT) / (TWO_SUB_PT3 * rtt_usecs)))
306 >> CUBIC_SHIFT);
319 /* newreno is "TCP friendly" */
320 return newreno_cc_cwnd_in_cong_avoid(ccv);
307321}
308322
309323#endif /* _NETINET_CC_CUBIC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/cc/cc_module.h+1-12
......@@ -43,18 +43,7 @@
4343#ifndef _NETINET_CC_MODULE_H_
4444#define _NETINET_CC_MODULE_H_
4545
46/*
47 * Allows a CC algorithm to manipulate a commonly named CC variable regardless
48 * of the transport protocol and associated C struct.
49 * XXXLAS: Out of action until the work to support SCTP is done.
50 *
51#define CCV(ccv, what) \
52(*( \
53 (ccv)->type == IPPROTO_TCP ? &(ccv)->ccvc.tcp->what : \
54 &(ccv)->ccvc.sctp->what \
55))
56 */
57#define CCV(ccv, what) (ccv)->ccvc.tcp->what
46#define CCV(ccv, what) (ccv)->tp->what
5847
5948#define DECLARE_CC_MODULE(ccname, ccalgo) \
6049 static moduledata_t cc_##ccname = { \
lib/libc/include/generic-freebsd/netinet/dccp.h+1-1
......@@ -64,7 +64,7 @@ struct dccphdr {
6464 uint8_t seq[6];
6565 } longseq;
6666 } d_seqno;
67};
67} __packed;
6868
6969#define d_seqno_short d_seqno.shortseq;
7070#define d_seqno_long d_seqno.longseq.seq;
lib/libc/include/generic-freebsd/netinet/icmp6.h+43-46
......@@ -58,13 +58,13 @@
5858 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5959 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6060 * SUCH DAMAGE.
61 *
62 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
6361 */
6462
6563#ifndef _NETINET_ICMP6_H_
6664#define _NETINET_ICMP6_H_
6765
66#include <sys/stdint.h>
67
6868#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
6969 - sizeof(struct icmp6_hdr) */
7070
......@@ -309,7 +309,8 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
309309#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */
310310#define ND_OPT_RDNSS 25 /* RFC 6106 */
311311#define ND_OPT_DNSSL 31 /* RFC 6106 */
312#define ND_OPT_MAX 31
312#define ND_OPT_PREF64 38 /* RFC 8781 */
313#define ND_OPT_MAX 38
313314
314315struct nd_opt_prefix_info { /* prefix information */
315316 u_int8_t nd_opt_pi_type;
......@@ -375,6 +376,14 @@ struct nd_opt_dnssl { /* DNSSL option (RFC 6106) */
375376 /* followed by list of DNS search domains */
376377} __packed;
377378
379struct nd_opt_pref64 { /* PREF64 option (RFC 8781) */
380 uint8_t nd_opt_pref64_type;
381 uint8_t nd_opt_pref64_len;
382 /* bits 0-12 are the SL, bits 13-15 are the PLC */
383 uint16_t nd_opt_pref64_sl_plc;
384 char nd_opt_prefix[12];
385} __packed;
386
378387/*
379388 * icmp6 namelookup
380389 */
......@@ -574,22 +583,6 @@ do { \
574583 * Variables related to this implementation
575584 * of the internet control message protocol version 6.
576585 */
577struct icmp6errstat {
578 uint64_t icp6errs_dst_unreach_noroute;
579 uint64_t icp6errs_dst_unreach_admin;
580 uint64_t icp6errs_dst_unreach_beyondscope;
581 uint64_t icp6errs_dst_unreach_addr;
582 uint64_t icp6errs_dst_unreach_noport;
583 uint64_t icp6errs_packet_too_big;
584 uint64_t icp6errs_time_exceed_transit;
585 uint64_t icp6errs_time_exceed_reassembly;
586 uint64_t icp6errs_paramprob_header;
587 uint64_t icp6errs_paramprob_nextheader;
588 uint64_t icp6errs_paramprob_option;
589 uint64_t icp6errs_redirect; /* we regard redirect as an error here */
590 uint64_t icp6errs_unknown;
591};
592
593586struct icmp6stat {
594587/* statistics related to icmp6 packets generated */
595588 uint64_t icp6s_error; /* # of calls to icmp6_error */
......@@ -609,25 +602,19 @@ struct icmp6stat {
609602 uint64_t icp6s_reflect;
610603 uint64_t icp6s_inhist[256];
611604 uint64_t icp6s_nd_toomanyopt; /* too many ND options */
612 struct icmp6errstat icp6s_outerrhist;
613#define icp6s_odst_unreach_noroute \
614 icp6s_outerrhist.icp6errs_dst_unreach_noroute
615#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
616#define icp6s_odst_unreach_beyondscope \
617 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
618#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
619#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
620#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
621#define icp6s_otime_exceed_transit \
622 icp6s_outerrhist.icp6errs_time_exceed_transit
623#define icp6s_otime_exceed_reassembly \
624 icp6s_outerrhist.icp6errs_time_exceed_reassembly
625#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
626#define icp6s_oparamprob_nextheader \
627 icp6s_outerrhist.icp6errs_paramprob_nextheader
628#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
629#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
630#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
605 uint64_t icp6s_odst_unreach_noroute;
606 uint64_t icp6s_odst_unreach_admin;
607 uint64_t icp6s_odst_unreach_beyondscope;
608 uint64_t icp6s_odst_unreach_addr;
609 uint64_t icp6s_odst_unreach_noport;
610 uint64_t icp6s_opacket_too_big;
611 uint64_t icp6s_otime_exceed_transit;
612 uint64_t icp6s_otime_exceed_reassembly;
613 uint64_t icp6s_oparamprob_header;
614 uint64_t icp6s_oparamprob_nextheader;
615 uint64_t icp6s_oparamprob_option;
616 uint64_t icp6s_oredirect;
617 uint64_t icp6s_ounknown;
631618 uint64_t icp6s_pmtuchg; /* path MTU changes */
632619 uint64_t icp6s_nd_badopt; /* bad ND options */
633620 uint64_t icp6s_badns; /* bad neighbor solicitation */
......@@ -645,6 +632,7 @@ struct icmp6stat {
645632
646633#ifdef _KERNEL
647634#include <sys/counter.h>
635#include <netinet/in_kdtrace.h>
648636
649637#ifdef SYSCTL_DECL
650638SYSCTL_DECL(_net_inet6_icmp6);
......@@ -655,16 +643,28 @@ VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat);
655643 * In-kernel consumers can use these accessor macros directly to update
656644 * stats.
657645 */
658#define ICMP6STAT_ADD(name, val) \
659 VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val))
660#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1)
646#define ICMP6STAT_ADD(name, val) \
647 do { \
648 MIB_SDT_PROBE1(icmp6, count, name, (val)); \
649 VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val)); \
650 } while (0)
651#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1)
652#define ICMP6STAT_INC2(name, type) \
653 do { \
654 MIB_SDT_PROBE2(icmp6, count, name, 1, type); \
655 VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name[type], 1); \
656 } while (0)
661657
662658/*
663659 * Kernel module consumers must use this accessor macro.
664660 */
665661void kmod_icmp6stat_inc(int statnum);
666#define KMOD_ICMP6STAT_INC(name) \
667 kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(uint64_t))
662#define KMOD_ICMP6STAT_INC(name) \
663 do { \
664 MIB_SDT_PROBE1(icmp6, count, name, 1); \
665 kmod_icmp6stat_inc( \
666 offsetof(struct icmp6stat, name) / sizeof(uint64_t)); \
667 } while (0)
668668#endif
669669
670670/*
......@@ -713,9 +713,6 @@ void icmp6_redirect_input(struct mbuf *, int);
713713void icmp6_redirect_output(struct mbuf *, struct nhop_object *);
714714int icmp6_ratelimit(const struct in6_addr *, const int, const int);
715715
716struct ip6ctlparam;
717void icmp6_mtudisc_update(struct ip6ctlparam *, int);
718
719716/* XXX: is this the right place for these macros? */
720717#define icmp6_ifstat_inc(ifp, tag) \
721718do { \
lib/libc/include/generic-freebsd/netinet/icmp_var.h+22-12
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NETINET_ICMP_VAR_H_
......@@ -59,22 +57,36 @@ struct icmpstat {
5957
6058#ifdef _KERNEL
6159#include <sys/counter.h>
60#include <netinet/in_kdtrace.h>
6261
6362VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);
6463/*
6564 * In-kernel consumers can use these accessor macros directly to update
6665 * stats.
6766 */
68#define ICMPSTAT_ADD(name, val) \
69 VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val))
67#define ICMPSTAT_ADD(name, val) \
68 do { \
69 MIB_SDT_PROBE1(icmp, count, name, (val)); \
70 VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)); \
71 } while (0)
72
7073#define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1)
74#define ICMPSTAT_INC2(name, type) \
75 do { \
76 MIB_SDT_PROBE2(icmp, count, name, 1, type); \
77 VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name[type], 1); \
78 } while (0)
7179
7280/*
7381 * Kernel module consumers must use this accessor macro.
7482 */
7583void kmod_icmpstat_inc(int statnum);
76#define KMOD_ICMPSTAT_INC(name) \
77 kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t))
84#define KMOD_ICMPSTAT_INC(name) \
85 do { \
86 MIB_SDT_PROBE1(icmp, count, name, 1); \
87 kmod_icmpstat_inc( \
88 offsetof(struct icmpstat, name) / sizeof(uint64_t)); \
89 } while (0)
7890#endif
7991
8092/*
......@@ -88,15 +100,13 @@ void kmod_icmpstat_inc(int statnum);
88100SYSCTL_DECL(_net_inet_icmp);
89101
90102extern int badport_bandlim(int);
91#define BANDLIM_UNLIMITED -1
92103#define BANDLIM_ICMP_UNREACH 0
93104#define BANDLIM_ICMP_ECHO 1
94105#define BANDLIM_ICMP_TSTAMP 2
95#define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */
96#define BANDLIM_RST_OPENPORT 4 /* No connection, listener */
97#define BANDLIM_ICMP6_UNREACH 5
98#define BANDLIM_SCTP_OOTB 6
99#define BANDLIM_MAX 7
106#define BANDLIM_TCP_RST 3
107#define BANDLIM_ICMP6_UNREACH 4
108#define BANDLIM_SCTP_OOTB 5
109#define BANDLIM_MAX 6
100110#endif
101111
102112#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/if_ether.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
3230 */
3331
3432#ifndef _NETINET_IF_ETHER_H_
lib/libc/include/generic-freebsd/netinet/igmp.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)igmp.h 8.1 (Berkeley) 6/10/93
3634 */
3735
3836#ifndef _NETINET_IGMP_H_
lib/libc/include/generic-freebsd/netinet/igmp_var.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)igmp_var.h 8.1 (Berkeley) 7/19/93
3634 */
3735
3836#ifndef _NETINET_IGMP_VAR_H_
lib/libc/include/generic-freebsd/netinet/in.h+12-7
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)in.h 8.3 (Berkeley) 1/3/94
3230 */
3331
3432#ifndef _NETINET_IN_H_
......@@ -674,13 +672,13 @@ int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
674672struct ifnet; struct mbuf; /* forward declarations for Standard C */
675673struct in_ifaddr;
676674
677int in_broadcast(struct in_addr, struct ifnet *);
678int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
679int in_canforward(struct in_addr);
680int in_localaddr(struct in_addr);
675bool in_ifnet_broadcast(struct in_addr, struct ifnet *);
676bool in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
677bool in_canforward(struct in_addr);
678bool in_localaddr(struct in_addr);
681679bool in_localip(struct in_addr);
682680bool in_localip_fib(struct in_addr, uint16_t);
683int in_ifhasaddr(struct ifnet *, struct in_addr);
681bool in_ifhasaddr(struct ifnet *, struct in_addr);
684682struct in_ifaddr *in_findlocal(uint32_t, bool);
685683int inet_aton(const char *, struct in_addr *); /* in libkern */
686684char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
......@@ -688,6 +686,13 @@ char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
688686int inet_pton(int af, const char *, void *); /* in libkern */
689687void in_ifdetach(struct ifnet *);
690688
689static inline bool
690in_broadcast(struct in_addr in)
691{
692 return (in.s_addr == __htonl(INADDR_BROADCAST) ||
693 in.s_addr == __htonl(INADDR_ANY));
694}
695
691696#define in_hosteq(s, t) ((s).s_addr == (t).s_addr)
692697#define in_nullhost(x) ((x).s_addr == INADDR_ANY)
693698#define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP))
lib/libc/include/generic-freebsd/netinet/in_kdtrace.h+367
......@@ -28,6 +28,8 @@
2828#ifndef _SYS_IN_KDTRACE_H_
2929#define _SYS_IN_KDTRACE_H_
3030
31#include <sys/sdt.h>
32
3133#define IP_PROBE(probe, arg0, arg1, arg2, arg3, arg4, arg5) \
3234 SDT_PROBE6(ip, , , probe, arg0, arg1, arg2, arg3, arg4, arg5)
3335#define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4) \
......@@ -52,6 +54,371 @@ SDT_PROVIDER_DECLARE(tcp);
5254SDT_PROVIDER_DECLARE(udp);
5355SDT_PROVIDER_DECLARE(udplite);
5456
57#ifdef KDTRACE_MIB_SDT
58SDT_PROVIDER_DECLARE(mib);
59
60SDT_PROBE_DECLARE(mib, ip, count, ips_total);
61SDT_PROBE_DECLARE(mib, ip, count, ips_badsum);
62SDT_PROBE_DECLARE(mib, ip, count, ips_tooshort);
63SDT_PROBE_DECLARE(mib, ip, count, ips_toosmall);
64SDT_PROBE_DECLARE(mib, ip, count, ips_badhlen);
65SDT_PROBE_DECLARE(mib, ip, count, ips_badlen);
66SDT_PROBE_DECLARE(mib, ip, count, ips_fragments);
67SDT_PROBE_DECLARE(mib, ip, count, ips_fragdropped);
68SDT_PROBE_DECLARE(mib, ip, count, ips_fragtimeout);
69SDT_PROBE_DECLARE(mib, ip, count, ips_forward);
70SDT_PROBE_DECLARE(mib, ip, count, ips_fastforward);
71SDT_PROBE_DECLARE(mib, ip, count, ips_cantforward);
72SDT_PROBE_DECLARE(mib, ip, count, ips_redirectsent);
73SDT_PROBE_DECLARE(mib, ip, count, ips_noproto);
74SDT_PROBE_DECLARE(mib, ip, count, ips_delivered);
75SDT_PROBE_DECLARE(mib, ip, count, ips_localout);
76SDT_PROBE_DECLARE(mib, ip, count, ips_odropped);
77SDT_PROBE_DECLARE(mib, ip, count, ips_reassembled);
78SDT_PROBE_DECLARE(mib, ip, count, ips_fragmented);
79SDT_PROBE_DECLARE(mib, ip, count, ips_ofragments);
80SDT_PROBE_DECLARE(mib, ip, count, ips_cantfrag);
81SDT_PROBE_DECLARE(mib, ip, count, ips_badoptions);
82SDT_PROBE_DECLARE(mib, ip, count, ips_noroute);
83SDT_PROBE_DECLARE(mib, ip, count, ips_badvers);
84SDT_PROBE_DECLARE(mib, ip, count, ips_rawout);
85SDT_PROBE_DECLARE(mib, ip, count, ips_toolong);
86SDT_PROBE_DECLARE(mib, ip, count, ips_notmember);
87SDT_PROBE_DECLARE(mib, ip, count, ips_nogif);
88SDT_PROBE_DECLARE(mib, ip, count, ips_badaddr);
89
90SDT_PROBE_DECLARE(mib, ip6, count, ip6s_total);
91SDT_PROBE_DECLARE(mib, ip6, count, ip6s_tooshort);
92SDT_PROBE_DECLARE(mib, ip6, count, ip6s_toosmall);
93SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragments);
94SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragdropped);
95SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragtimeout);
96SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragoverflow);
97SDT_PROBE_DECLARE(mib, ip6, count, ip6s_forward);
98SDT_PROBE_DECLARE(mib, ip6, count, ip6s_cantforward);
99SDT_PROBE_DECLARE(mib, ip6, count, ip6s_redirectsent);
100SDT_PROBE_DECLARE(mib, ip6, count, ip6s_delivered);
101SDT_PROBE_DECLARE(mib, ip6, count, ip6s_localout);
102SDT_PROBE_DECLARE(mib, ip6, count, ip6s_odropped);
103SDT_PROBE_DECLARE(mib, ip6, count, ip6s_reassembled);
104SDT_PROBE_DECLARE(mib, ip6, count, ip6s_atomicfrags);
105SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragmented);
106SDT_PROBE_DECLARE(mib, ip6, count, ip6s_ofragments);
107SDT_PROBE_DECLARE(mib, ip6, count, ip6s_cantfrag);
108SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badoptions);
109SDT_PROBE_DECLARE(mib, ip6, count, ip6s_noroute);
110SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badvers);
111SDT_PROBE_DECLARE(mib, ip6, count, ip6s_rawout);
112SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badscope);
113SDT_PROBE_DECLARE(mib, ip6, count, ip6s_notmember);
114SDT_PROBE_DECLARE(mib, ip6, count, ip6s_nxthist);
115SDT_PROBE_DECLARE(mib, ip6, count, ip6s_m1);
116SDT_PROBE_DECLARE(mib, ip6, count, ip6s_m2m);
117SDT_PROBE_DECLARE(mib, ip6, count, ip6s_mext1);
118SDT_PROBE_DECLARE(mib, ip6, count, ip6s_mext2m);
119SDT_PROBE_DECLARE(mib, ip6, count, ip6s_exthdrtoolong);
120SDT_PROBE_DECLARE(mib, ip6, count, ip6s_nogif);
121SDT_PROBE_DECLARE(mib, ip6, count, ip6s_toomanyhdr);
122SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_none);
123SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_sameif);
124SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_otherif);
125SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_samescope);
126SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_otherscope);
127SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_deprecated);
128SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_rule);
129
130SDT_PROBE_DECLARE(mib, icmp, count, icps_error);
131SDT_PROBE_DECLARE(mib, icmp, count, icps_oldshort);
132SDT_PROBE_DECLARE(mib, icmp, count, icps_oldicmp);
133SDT_PROBE_DECLARE(mib, icmp, count, icps_outhist);
134SDT_PROBE_DECLARE(mib, icmp, count, icps_badcode);
135SDT_PROBE_DECLARE(mib, icmp, count, icps_tooshort);
136SDT_PROBE_DECLARE(mib, icmp, count, icps_checksum);
137SDT_PROBE_DECLARE(mib, icmp, count, icps_badlen);
138SDT_PROBE_DECLARE(mib, icmp, count, icps_reflect);
139SDT_PROBE_DECLARE(mib, icmp, count, icps_inhist);
140SDT_PROBE_DECLARE(mib, icmp, count, icps_bmcastecho);
141SDT_PROBE_DECLARE(mib, icmp, count, icps_bmcasttstamp);
142SDT_PROBE_DECLARE(mib, icmp, count, icps_badaddr);
143SDT_PROBE_DECLARE(mib, icmp, count, icps_noroute);
144
145SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_error);
146SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_canterror);
147SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_toofreq);
148SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_outhist);
149SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badcode);
150SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_tooshort);
151SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_checksum);
152SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badlen);
153SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_dropped);
154SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_reflect);
155SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_inhist);
156SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_nd_toomanyopt);
157SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_noroute);
158SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_admin);
159SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_beyondscope);
160SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_addr);
161SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_noport);
162SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_opacket_too_big);
163SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_otime_exceed_transit);
164SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_otime_exceed_reassembly);
165SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_header);
166SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_nextheader);
167SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_option);
168SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oredirect);
169SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_ounknown);
170SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_pmtuchg);
171SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_nd_badopt);
172SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badns);
173SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badna);
174SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badrs);
175SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badra);
176SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badredirect);
177SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowdefrtr);
178SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowprfx);
179SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflownndp);
180SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowredirect);
181SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_invlhlim);
182
183SDT_PROBE_DECLARE(mib, udp, count, udps_ipackets);
184SDT_PROBE_DECLARE(mib, udp, count, udps_hdrops);
185SDT_PROBE_DECLARE(mib, udp, count, udps_badsum);
186SDT_PROBE_DECLARE(mib, udp, count, udps_nosum);
187SDT_PROBE_DECLARE(mib, udp, count, udps_badlen);
188SDT_PROBE_DECLARE(mib, udp, count, udps_noport);
189SDT_PROBE_DECLARE(mib, udp, count, udps_noportbcast);
190SDT_PROBE_DECLARE(mib, udp, count, udps_fullsock);
191SDT_PROBE_DECLARE(mib, udp, count, udps_pcbcachemiss);
192SDT_PROBE_DECLARE(mib, udp, count, udps_pcbhashmiss);
193SDT_PROBE_DECLARE(mib, udp, count, udps_opackets);
194SDT_PROBE_DECLARE(mib, udp, count, udps_fastout);
195SDT_PROBE_DECLARE(mib, udp, count, udps_noportmcast);
196SDT_PROBE_DECLARE(mib, udp, count, udps_filtermcast);
197
198SDT_PROBE_DECLARE(mib, tcp, count, tcps_connattempt);
199SDT_PROBE_DECLARE(mib, tcp, count, tcps_accepts);
200SDT_PROBE_DECLARE(mib, tcp, count, tcps_connects);
201SDT_PROBE_DECLARE(mib, tcp, count, tcps_drops);
202SDT_PROBE_DECLARE(mib, tcp, count, tcps_conndrops);
203SDT_PROBE_DECLARE(mib, tcp, count, tcps_minmssdrops);
204SDT_PROBE_DECLARE(mib, tcp, count, tcps_closed);
205SDT_PROBE_DECLARE(mib, tcp, count, tcps_segstimed);
206SDT_PROBE_DECLARE(mib, tcp, count, tcps_rttupdated);
207SDT_PROBE_DECLARE(mib, tcp, count, tcps_delack);
208SDT_PROBE_DECLARE(mib, tcp, count, tcps_timeoutdrop);
209SDT_PROBE_DECLARE(mib, tcp, count, tcps_rexmttimeo);
210SDT_PROBE_DECLARE(mib, tcp, count, tcps_persisttimeo);
211SDT_PROBE_DECLARE(mib, tcp, count, tcps_keeptimeo);
212SDT_PROBE_DECLARE(mib, tcp, count, tcps_keepprobe);
213SDT_PROBE_DECLARE(mib, tcp, count, tcps_keepdrops);
214SDT_PROBE_DECLARE(mib, tcp, count, tcps_progdrops);
215
216SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndtotal);
217SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndpack);
218SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndbyte);
219SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitpack);
220SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitbyte);
221SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitbad);
222SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndacks);
223SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndprobe);
224SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndurg);
225SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndwinup);
226SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndctrl);
227
228SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvtotal);
229SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpack);
230SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbyte);
231SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbadsum);
232SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbadoff);
233SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvreassfull);
234SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvshort);
235SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvduppack);
236SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvdupbyte);
237SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpartduppack);
238SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpartdupbyte);
239SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvoopack);
240SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvoobyte);
241SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpackafterwin);
242SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbyteafterwin);
243SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvafterclose);
244SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvwinprobe);
245SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvdupack);
246SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvacktoomuch);
247SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvackpack);
248SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvackbyte);
249SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvwinupd);
250SDT_PROBE_DECLARE(mib, tcp, count, tcps_pawsdrop);
251SDT_PROBE_DECLARE(mib, tcp, count, tcps_predack);
252SDT_PROBE_DECLARE(mib, tcp, count, tcps_preddat);
253SDT_PROBE_DECLARE(mib, tcp, count, tcps_pcbcachemiss);
254SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrtt);
255SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrttvar);
256SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedssthresh);
257SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrtt);
258SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrttvar);
259SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedssthresh);
260SDT_PROBE_DECLARE(mib, tcp, count, tcps_persistdrop);
261SDT_PROBE_DECLARE(mib, tcp, count, tcps_badsyn);
262SDT_PROBE_DECLARE(mib, tcp, count, tcps_mturesent);
263SDT_PROBE_DECLARE(mib, tcp, count, tcps_listendrop);
264SDT_PROBE_DECLARE(mib, tcp, count, tcps_badrst);
265
266SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_added);
267SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_retransmitted);
268SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_dupsyn);
269SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_dropped);
270SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_completed);
271SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_bucketoverflow);
272SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_cacheoverflow);
273SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_reset);
274SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_stale);
275SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_aborted);
276SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_badack);
277SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_unreach);
278SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_zonefail);
279SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_sendcookie);
280SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_recvcookie);
281SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_spurcookie);
282SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_failcookie);
283
284SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_added);
285SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_bucketoverflow);
286
287SDT_PROBE_DECLARE(mib, tcp, count, tcps_finwait2_drops);
288
289SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_recovery_episode);
290SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmits);
291SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmits_tso);
292SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmit_bytes);
293SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rcv_blocks);
294SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_send_blocks);
295SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_lostrexmt);
296SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_sboverflow);
297
298SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvce);
299SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvect0);
300SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvect1);
301SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_shs);
302SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcwnd);
303
304SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_rcvgoodsig);
305SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_rcvbadsig);
306SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_buildsig);
307SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_sigopt);
308SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_nosigopt);
309
310SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_activated);
311SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_activated_min_mss);
312SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_failed);
313
314SDT_PROBE_DECLARE(mib, tcp, count, tcps_tunneled_pkts);
315SDT_PROBE_DECLARE(mib, tcp, count, tcps_tunneled_errs);
316
317SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_count);
318SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_bytes);
319SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_tlp_bytes);
320
321SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_recycles);
322SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_resets);
323SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_responds);
324
325SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_nect);
326SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ect1);
327SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ect0);
328SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ce);
329
330SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_sndect0);
331SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_sndect1);
332
333SDT_PROBE_DECLARE(mib, tcp, count, tcps_tlpresends);
334SDT_PROBE_DECLARE(mib, tcp, count, tcps_tlpresend_bytes);
335
336SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvghostack);
337SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvacktooold);
338
339SDT_PROBE_DECLARE(mib, ipsec, count, ips_in_polvio);
340SDT_PROBE_DECLARE(mib, ipsec, count, ips_in_nomem);
341SDT_PROBE_DECLARE(mib, ipsec, count, ips_in_inval);
342SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_polvio);
343SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_nosa);
344SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_nomem);
345SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_noroute);
346SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_inval);
347SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_bundlesa);
348
349SDT_PROBE_DECLARE(mib, ipsec, count, ips_spdcache_hits);
350SDT_PROBE_DECLARE(mib, ipsec, count, ips_spdcache_misses);
351
352SDT_PROBE_DECLARE(mib, ipsec, count, ips_clcopied);
353SDT_PROBE_DECLARE(mib, ipsec, count, ips_mbinserted);
354SDT_PROBE_DECLARE(mib, ipsec, count, ips_input_front);
355SDT_PROBE_DECLARE(mib, ipsec, count, ips_input_middle);
356SDT_PROBE_DECLARE(mib, ipsec, count, ips_input_end);
357
358SDT_PROBE_DECLARE(mib, esp, count, esps_hdrops);
359SDT_PROBE_DECLARE(mib, esp, count, esps_nopf);
360SDT_PROBE_DECLARE(mib, esp, count, esps_notdb);
361SDT_PROBE_DECLARE(mib, esp, count, esps_badkcr);
362SDT_PROBE_DECLARE(mib, esp, count, esps_qfull);
363SDT_PROBE_DECLARE(mib, esp, count, esps_noxform);
364SDT_PROBE_DECLARE(mib, esp, count, esps_badilen);
365SDT_PROBE_DECLARE(mib, esp, count, esps_wrap);
366SDT_PROBE_DECLARE(mib, esp, count, esps_badenc);
367SDT_PROBE_DECLARE(mib, esp, count, esps_badauth);
368SDT_PROBE_DECLARE(mib, esp, count, esps_replay);
369SDT_PROBE_DECLARE(mib, esp, count, esps_input);
370SDT_PROBE_DECLARE(mib, esp, count, esps_output);
371SDT_PROBE_DECLARE(mib, esp, count, esps_invalid);
372SDT_PROBE_DECLARE(mib, esp, count, esps_ibytes);
373SDT_PROBE_DECLARE(mib, esp, count, esps_obytes);
374SDT_PROBE_DECLARE(mib, esp, count, esps_toobig);
375SDT_PROBE_DECLARE(mib, esp, count, esps_pdrops);
376SDT_PROBE_DECLARE(mib, esp, count, esps_crypto);
377SDT_PROBE_DECLARE(mib, esp, count, esps_tunnel);
378SDT_PROBE_DECLARE(mib, esp, count, esps_hist);
379
380SDT_PROBE_DECLARE(mib, ah, count, ahs_hdrops);
381SDT_PROBE_DECLARE(mib, ah, count, ahs_nopf);
382SDT_PROBE_DECLARE(mib, ah, count, ahs_notdb);
383SDT_PROBE_DECLARE(mib, ah, count, ahs_badkcr);
384SDT_PROBE_DECLARE(mib, ah, count, ahs_badauth);
385SDT_PROBE_DECLARE(mib, ah, count, ahs_noxform);
386SDT_PROBE_DECLARE(mib, ah, count, ahs_qfull);
387SDT_PROBE_DECLARE(mib, ah, count, ahs_wrap);
388SDT_PROBE_DECLARE(mib, ah, count, ahs_replay);
389SDT_PROBE_DECLARE(mib, ah, count, ahs_badauthl);
390SDT_PROBE_DECLARE(mib, ah, count, ahs_input);
391SDT_PROBE_DECLARE(mib, ah, count, ahs_output);
392SDT_PROBE_DECLARE(mib, ah, count, ahs_invalid);
393SDT_PROBE_DECLARE(mib, ah, count, ahs_ibytes);
394SDT_PROBE_DECLARE(mib, ah, count, ahs_obytes);
395SDT_PROBE_DECLARE(mib, ah, count, ahs_toobig);
396SDT_PROBE_DECLARE(mib, ah, count, ahs_pdrops);
397SDT_PROBE_DECLARE(mib, ah, count, ahs_crypto);
398SDT_PROBE_DECLARE(mib, ah, count, ahs_tunnel);
399SDT_PROBE_DECLARE(mib, ah, count, ahs_hist);
400
401SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_hdrops);
402SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_nopf);
403SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_notdb);
404SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_badkcr);
405SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_qfull);
406SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_noxform);
407SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_wrap);
408SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_input);
409SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_output);
410SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_invalid);
411SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_ibytes);
412SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_obytes);
413SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_toobig);
414SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_pdrops);
415SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_crypto);
416SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_hist);
417SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_threshold);
418SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_uncompr);
419
420#endif
421
55422SDT_PROBE_DECLARE(ip, , , receive);
56423SDT_PROBE_DECLARE(ip, , , send);
57424
lib/libc/include/generic-freebsd/netinet/in_pcb.h+45-58
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
3735 */
3836
3937#ifndef _NETINET_IN_PCB_H_
......@@ -66,7 +64,6 @@
6664 * protocol-specific control block) are stored here.
6765 */
6866CK_LIST_HEAD(inpcbhead, inpcb);
69CK_LIST_HEAD(inpcbporthead, inpcbport);
7067CK_LIST_HEAD(inpcblbgrouphead, inpcblbgroup);
7168typedef uint64_t inp_gen_t;
7269
......@@ -135,8 +132,9 @@ struct in_conninfo {
135132/*
136133 * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4 and
137134 * IPv6 sockets. In the case of TCP and UDP, further per-connection state is
138 * hung off of inp_ppcb most of the time. Almost all fields of struct inpcb
139 * are static after creation or protected by a per-inpcb rwlock, inp_lock.
135 * located in a larger protocol specific structure that embeds inpcb in it.
136 * Almost all fields of struct inpcb are static after creation or protected by
137 * a per-inpcb rwlock, inp_lock.
140138 *
141139 * A inpcb database is indexed by addresses/ports hash as well as list of
142140 * all pcbs that belong to a certain proto. Database lookups or list traversals
......@@ -168,7 +166,10 @@ struct inpcbpolicy;
168166struct m_snd_tag;
169167struct inpcb {
170168 /* Cache line #1 (amd64) */
171 CK_LIST_ENTRY(inpcb) inp_hash_exact; /* hash table linkage */
169 union {
170 CK_LIST_ENTRY(inpcb) inp_hash_exact; /* hash table linkage */
171 LIST_ENTRY(inpcb) inp_lbgroup_list; /* lb group list */
172 };
172173 CK_LIST_ENTRY(inpcb) inp_hash_wild; /* hash table linkage */
173174 struct rwlock inp_lock;
174175 /* Cache line #2 (amd64) */
......@@ -179,7 +180,6 @@ struct inpcb {
179180 int inp_flags; /* (i) generic IP/datagram flags */
180181 int inp_flags2; /* (i) generic IP/datagram flags #2*/
181182 uint8_t inp_numa_domain; /* numa domain */
182 void *inp_ppcb; /* (i) pointer to per-protocol pcb */
183183 struct socket *inp_socket; /* (i) back pointer to socket */
184184 struct inpcbinfo *inp_pcbinfo; /* (c) PCB list info */
185185 struct ucred *inp_cred; /* (c) cache of socket cred */
......@@ -220,7 +220,6 @@ struct inpcb {
220220 short in6p_hops;
221221 };
222222 CK_LIST_ENTRY(inpcb) inp_portlist; /* (r:e/w:h) port list */
223 struct inpcbport *inp_phd; /* (r:e/w:h) head of this list */
224223 inp_gen_t inp_gencnt; /* (c) generation count */
225224 void *spare_ptr; /* Spare pointer. */
226225 rt_gen_t inp_rt_cookie; /* generation for route entry */
......@@ -268,8 +267,7 @@ struct xinpcb {
268267 struct xsocket xi_socket; /* (s,p) */
269268 struct in_conninfo inp_inc; /* (s,p) */
270269 uint64_t inp_gencnt; /* (s,p) */
271 kvaddr_t inp_ppcb; /* (s) netstat(1) */
272 int64_t inp_spare64[4];
270 int64_t inp_spare64[5];
273271 uint32_t inp_flow; /* (s) */
274272 uint32_t inp_flowid; /* (s) */
275273 uint32_t inp_flowtype; /* (s) */
......@@ -305,6 +303,30 @@ struct sockopt_parameters {
305303 char sop_optval[];
306304};
307305
306#ifdef _SYS_KTLS_H_
307struct xktls_session {
308 uint32_t tsz; /* total sz of elm, next elm is at this+tsz */
309 uint32_t fsz; /* size of the struct up to keys */
310 uint64_t inp_gencnt;
311 kvaddr_t so_pcb;
312 struct in_conninfo coninf;
313 u_short rx_vlan_id;
314 struct xktls_session_onedir rcv;
315 struct xktls_session_onedir snd;
316/*
317 * Next are
318 * - keydata for rcv, first cipher of length rcv.cipher_key_len, then
319 * authentication of length rcv.auth_key_len;
320 * - driver data (string) of length rcv.drv_st_len, if the rcv session is
321 * offloaded to ifnet rcv.ifnet;
322 * - keydata for snd, first cipher of length snd.cipher_key_len, then
323 * authentication of length snd.auth_key_len;
324 * - driver data (string) of length snd.drv_st_len, if the snd session is
325 * offloaded to ifnet snd.ifnet;
326 */
327};
328#endif /* _SYS_KTLS_H_ */
329
308330#ifdef _KERNEL
309331int sysctl_setsockopt(SYSCTL_HANDLER_ARGS, struct inpcbinfo *pcbinfo,
310332 int (*ctloutput_set)(struct inpcb *, struct sockopt *));
......@@ -370,7 +392,7 @@ struct inpcbinfo {
370392 /*
371393 * Global hash of inpcbs, hashed by only local port number.
372394 */
373 struct inpcbporthead *ipi_porthashbase; /* (h) */
395 struct inpcbhead *ipi_porthashbase; /* (h) */
374396 u_long ipi_porthashmask; /* (h) */
375397
376398 /*
......@@ -392,11 +414,9 @@ struct inpcbinfo {
392414 */
393415struct inpcbstorage {
394416 uma_zone_t ips_zone;
395 uma_zone_t ips_portzone;
396417 uma_init ips_pcbinit;
397418 size_t ips_size;
398419 const char * ips_zone_name;
399 const char * ips_portzone_name;
400420 const char * ips_infolock_name;
401421 const char * ips_hashlock_name;
402422};
......@@ -414,7 +434,6 @@ static struct inpcbstorage prot = { \
414434 .ips_size = sizeof(struct ppcb), \
415435 .ips_pcbinit = prot##_inpcb_init, \
416436 .ips_zone_name = zname, \
417 .ips_portzone_name = zname " ports", \
418437 .ips_infolock_name = iname, \
419438 .ips_hashlock_name = hname, \
420439}; \
......@@ -423,28 +442,6 @@ SYSINIT(prot##_inpcbstorage_init, SI_SUB_PROTO_DOMAIN, \
423442SYSUNINIT(prot##_inpcbstorage_uninit, SI_SUB_PROTO_DOMAIN, \
424443 SI_ORDER_SECOND, in_pcbstorage_destroy, &prot)
425444
426/*
427 * Load balance groups used for the SO_REUSEPORT_LB socket option. Each group
428 * (or unique address:port combination) can be re-used at most
429 * INPCBLBGROUP_SIZMAX (256) times. The inpcbs are stored in il_inp which
430 * is dynamically resized as processes bind/unbind to that specific group.
431 */
432struct inpcblbgroup {
433 CK_LIST_ENTRY(inpcblbgroup) il_list;
434 struct epoch_context il_epoch_ctx;
435 struct ucred *il_cred;
436 uint16_t il_lport; /* (c) */
437 u_char il_vflag; /* (c) */
438 uint8_t il_numa_domain;
439 uint32_t il_pad2;
440 union in_dependaddr il_dependladdr; /* (c) */
441#define il_laddr il_dependladdr.id46_addr.ia46_addr4
442#define il6_laddr il_dependladdr.id6_addr
443 uint32_t il_inpsiz; /* max count in il_inp[] (h) */
444 uint32_t il_inpcnt; /* cur count in il_inp[] (h) */
445 struct inpcb *il_inp[]; /* (h) */
446};
447
448445#define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock)
449446#define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock)
450447#define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock)
......@@ -481,12 +478,8 @@ void inp_unlock_assert(struct inpcb *);
481478
482479void inp_apply_all(struct inpcbinfo *, void (*func)(struct inpcb *, void *),
483480 void *arg);
484int inp_ip_tos_get(const struct inpcb *inp);
485void inp_ip_tos_set(struct inpcb *inp, int val);
486481struct socket *
487482 inp_inpcbtosocket(struct inpcb *inp);
488struct tcpcb *
489 inp_inpcbtotcpcb(struct inpcb *inp);
490483void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
491484 uint32_t *faddr, uint16_t *fp);
492485
......@@ -578,7 +571,7 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
578571#define INP_DROPPED 0x04000000 /* protocol drop flag */
579572#define INP_SOCKREF 0x08000000 /* strong socket reference */
580573#define INP_RESERVED_0 0x10000000 /* reserved field */
581#define INP_RESERVED_1 0x20000000 /* reserved field */
574#define INP_BOUNDFIB 0x20000000 /* Bound to a specific FIB. */
582575#define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */
583576#define IN6P_MTU 0x80000000 /* receive path MTU */
584577
......@@ -624,10 +617,11 @@ typedef enum {
624617 INPLOOKUP_WILDCARD = 0x00000001, /* Allow wildcard sockets. */
625618 INPLOOKUP_RLOCKPCB = 0x00000002, /* Return inpcb read-locked. */
626619 INPLOOKUP_WLOCKPCB = 0x00000004, /* Return inpcb write-locked. */
620 INPLOOKUP_FIB = 0x00000008, /* inp must be from same FIB. */
627621} inp_lookup_t;
628622
629623#define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB | \
630 INPLOOKUP_WLOCKPCB)
624 INPLOOKUP_WLOCKPCB | INPLOOKUP_FIB)
631625#define INPLOOKUP_LOCKMASK (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)
632626
633627#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
......@@ -665,34 +659,29 @@ void in_pcbstorage_destroy(void *);
665659
666660void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
667661int in_pcballoc(struct socket *, struct inpcbinfo *);
668int in_pcbbind(struct inpcb *, struct sockaddr_in *, struct ucred *);
662#define INPBIND_FIB 0x0001 /* bind to the PCB's FIB only */
663int in_pcbbind(struct inpcb *, struct sockaddr_in *, int, struct ucred *);
669664int in_pcbbind_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *,
670 u_short *, struct ucred *);
671int in_pcbconnect(struct inpcb *, struct sockaddr_in *, struct ucred *,
672 bool);
673int in_pcbconnect_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *,
674 u_short *, in_addr_t *, u_short *, struct ucred *);
665 u_short *, int, struct ucred *);
666int in_pcbconnect(struct inpcb *, struct sockaddr_in *, struct ucred *);
675667void in_pcbdisconnect(struct inpcb *);
676668void in_pcbdrop(struct inpcb *);
677669void in_pcbfree(struct inpcb *);
678int in_pcbinshash(struct inpcb *);
679int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *,
670int in_pcbladdr(const struct inpcb *, struct in_addr *, struct in_addr *,
680671 struct ucred *);
681672int in_pcblbgroup_numa(struct inpcb *, int arg);
673void in_pcblisten(struct inpcb *);
682674struct inpcb *
683675 in_pcblookup(struct inpcbinfo *, struct in_addr, u_int,
684676 struct in_addr, u_int, int, struct ifnet *);
685677struct inpcb *
686678 in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int,
687679 struct in_addr, u_int, int, struct ifnet *, struct mbuf *);
688void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr,
689 int, struct inpcb *(*)(struct inpcb *, int));
690680void in_pcbref(struct inpcb *);
691void in_pcbrehash(struct inpcb *);
692void in_pcbremhash_locked(struct inpcb *);
693681bool in_pcbrele(struct inpcb *, inp_lookup_t);
694682bool in_pcbrele_rlocked(struct inpcb *);
695683bool in_pcbrele_wlocked(struct inpcb *);
684bool in_pcbrele_rlock(struct inpcb *inp);
696685
697686typedef bool inp_match_t(const struct inpcb *, void *);
698687struct inpcb_iterator {
......@@ -724,10 +713,8 @@ struct inpcb_iterator {
724713struct inpcb *inp_next(struct inpcb_iterator *);
725714void in_losing(struct inpcb *);
726715void in_pcbsetsolabel(struct socket *so);
727int in_getpeeraddr(struct socket *so, struct sockaddr **nam);
728int in_getsockaddr(struct socket *so, struct sockaddr **nam);
729struct sockaddr *
730 in_sockaddr(in_port_t port, struct in_addr *addr);
716int in_getpeeraddr(struct socket *, struct sockaddr *sa);
717int in_getsockaddr(struct socket *, struct sockaddr *sa);
731718void in_pcbsosetlabel(struct socket *so);
732719#ifdef RATELIMIT
733720int
lib/libc/include/generic-freebsd/netinet/in_pcb_var.h+28-9
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
3735 */
3836
3937#ifndef _NETINET_IN_PCB_VAR_H_
......@@ -52,16 +50,37 @@ int inp_trylock(struct inpcb *inp, const inp_lookup_t lock);
5250bool inp_smr_lock(struct inpcb *, const inp_lookup_t);
5351int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,
5452 struct ucred *, int);
55int in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa,
53int in_pcb_lport_dest(const struct inpcb *inp, struct sockaddr *lsa,
5654 u_short *lportp, struct sockaddr *fsa, u_short fport,
5755 struct ucred *cred, int lookupflags);
58struct inpcb * in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short,
59 int, struct ucred *);
56struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short,
57 int, int, struct ucred *);
58int in_pcbinshash(struct inpcb *);
59void in_pcbrehash(struct inpcb *);
60void in_pcbremhash_locked(struct inpcb *);
6061
61struct inpcbport {
62 struct inpcbhead phd_pcblist;
63 CK_LIST_ENTRY(inpcbport) phd_hash;
64 u_short phd_port;
62/*
63 * Load balance groups used for the SO_REUSEPORT_LB socket option. Each group
64 * (or unique address:port combination) can be re-used at most
65 * INPCBLBGROUP_SIZMAX (256) times. The inpcbs are stored in il_inp which
66 * is dynamically resized as processes bind/unbind to that specific group.
67 */
68struct inpcblbgroup {
69 CK_LIST_ENTRY(inpcblbgroup) il_list;
70 LIST_HEAD(, inpcb) il_pending; /* PCBs waiting for listen() */
71 struct epoch_context il_epoch_ctx;
72 struct ucred *il_cred;
73 uint16_t il_lport; /* (c) */
74 u_char il_vflag; /* (c) */
75 uint8_t il_numa_domain;
76 int il_fibnum;
77 union in_dependaddr il_dependladdr; /* (c) */
78#define il_laddr il_dependladdr.id46_addr.ia46_addr4
79#define il6_laddr il_dependladdr.id6_addr
80 uint32_t il_inpsiz; /* max count in il_inp[] (h) */
81 uint32_t il_inpcnt; /* cur count in il_inp[] (h) */
82 uint32_t il_pendcnt; /* cur count in il_pending (h) */
83 struct inpcb *il_inp[]; /* (h) */
6584};
6685
6786#endif /* !_NETINET_IN_PCB_VAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/in_systm.h+4-2
......@@ -27,13 +27,13 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)in_systm.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NETINET_IN_SYSTM_H_
3533#define _NETINET_IN_SYSTM_H_
3634
35#include <sys/types.h>
36
3737/*
3838 * Miscellaneous internetwork
3939 * definitions for kernel.
......@@ -58,8 +58,10 @@ typedef u_int32_t n_time; /* ms since 00:00 UTC, byte rev */
5858#ifdef _KERNEL
5959struct inpcb;
6060struct ucred;
61struct thread;
6162
6263int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp);
64bool cr_canexport_ktlskeys(struct thread *td, struct inpcb *inp);
6365
6466uint32_t iptime(void);
6567#endif
lib/libc/include/generic-freebsd/netinet/in_var.h+6-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)in_var.h 8.2 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _NETINET_IN_VAR_H_
......@@ -99,6 +97,11 @@ struct in_ifaddr {
9997#define IN_LNAOF(in, ifa) \
10098 ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask))
10199
100#ifdef _KERNEL
101#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
102 ((((d).s_addr ^ (a).s_addr) & (m).s_addr)) == 0 )
103#endif
104
102105#define LLTABLE(ifp) \
103106 ((struct in_ifinfo *)(ifp)->if_afdata[AF_INET])->ii_llt
104107/*
......@@ -456,6 +459,7 @@ int in_joingroup_locked(struct ifnet *, const struct in_addr *,
456459int in_leavegroup(struct in_multi *, /*const*/ struct in_mfilter *);
457460int in_leavegroup_locked(struct in_multi *,
458461 /*const*/ struct in_mfilter *);
462int in_mask2len(struct in_addr *);
459463int in_control(struct socket *, u_long, void *, struct ifnet *,
460464 struct thread *);
461465int in_control_ioctl(u_long, void *, struct ifnet *,
lib/libc/include/generic-freebsd/netinet/ip.h+4-5
......@@ -28,14 +28,13 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * @(#)ip.h 8.2 (Berkeley) 6/1/94
3331 */
3432
3533#ifndef _NETINET_IP_H_
3634#define _NETINET_IP_H_
3735
38#include <sys/cdefs.h>
36#include <sys/types.h>
37#include <netinet/in.h>
3938
4039/*
4140 * Definitions for internet protocol version 4.
......@@ -68,7 +67,7 @@ struct ip {
6867 u_char ip_p; /* protocol */
6968 u_short ip_sum; /* checksum */
7069 struct in_addr ip_src,ip_dst; /* source and dest address */
71} __packed __aligned(2);
70} __packed;
7271
7372#define IP_MAXPACKET 65535 /* maximum packet size */
7473
......@@ -188,7 +187,7 @@ struct ip_timestamp {
188187 uint32_t ipt_time; /* network format */
189188 } ipt_ta[1];
190189 } ipt_timestamp;
191};
190} __packed;
192191
193192/* Flag bits for ipt_flg. */
194193#define IPOPT_TS_TSONLY 0 /* timestamps only */
lib/libc/include/generic-freebsd/netinet/ip6.h-2
......@@ -58,8 +58,6 @@
5858 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5959 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6060 * SUCH DAMAGE.
61 *
62 * @(#)ip.h 8.1 (Berkeley) 6/10/93
6361 */
6462
6563#ifndef _NETINET_IP6_H_
lib/libc/include/generic-freebsd/netinet/ip_carp.h+51-4
......@@ -31,6 +31,7 @@
3131#ifndef _IP_CARP_H
3232#define _IP_CARP_H
3333
34#ifdef _KERNEL
3435/*
3536 * The CARP header layout is as follows:
3637 *
......@@ -77,14 +78,53 @@ struct carp_header {
7778 unsigned char carp_md[20]; /* SHA1 HMAC */
7879} __packed;
7980
80#ifdef CTASSERT
8181CTASSERT(sizeof(struct carp_header) == 36);
82
83/*
84 * The VRRPv3 header layout is as follows:
85 * See RFC9568, 5.1. VRRP Packet Format
86 *
87 * 0 1 2 3
88 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
89 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 * |Version| Type | Virtual Rtr ID| Priority |Count IPvX Addr|
91 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 * |(rsvd) | Max Adver Int | Checksum |
93 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
94 * | |
95 * + +
96 * | IPvX Address(es) |
97 * + +
98 * + +
99 * + +
100 * + +
101 * | |
102 * + +
103 * | |
104 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
105 *
106 */
107
108struct vrrpv3_header {
109#if BYTE_ORDER == LITTLE_ENDIAN
110 uint8_t vrrp_type:4,
111 vrrp_version:4;
112#endif
113#if BYTE_ORDER == BIG_ENDIAN
114 uint8_t vrrp_version:4,
115 vrrp_type:4;
82116#endif
117 uint8_t vrrp_vrtid;
118 uint8_t vrrp_priority;
119 uint8_t vrrp_count_addr;
120 uint16_t vrrp_max_adver_int;
121 uint16_t vrrp_checksum;
122} __packed;
83123
84#define CARP_DFLTTL 255
124CTASSERT(sizeof(struct vrrpv3_header) == 8);
125#endif /* _KERNEL */
85126
86/* carp_version */
87#define CARP_VERSION 2
127#define CARP_DFLTTL 255
88128
89129/* carp_type */
90130#define CARP_ADVERTISEMENT 0x01
......@@ -94,6 +134,8 @@ CTASSERT(sizeof(struct carp_header) == 36);
94134/* carp_advbase */
95135#define CARP_DFLTINTV 1
96136
137#define VRRP_TYPE_ADVERTISEMENT 0x01
138#define VRRP_MAX_INTERVAL (0x1000 - 1)
97139/*
98140 * Statistics.
99141 */
......@@ -136,6 +178,11 @@ struct carpreq {
136178#define SIOCSVH _IOWR('i', 245, struct ifreq)
137179#define SIOCGVH _IOWR('i', 246, struct ifreq)
138180
181typedef enum carp_version {
182 CARP_VERSION_CARP = 2,
183 CARP_VERSION_VRRPv3 = 3,
184} carp_version_t;
185
139186#ifdef _KERNEL
140187int carp_ioctl(struct ifreq *, u_long, struct thread *);
141188int carp_attach(struct ifaddr *, int);
lib/libc/include/generic-freebsd/netinet/ip_carp_nl.h+3
......@@ -32,6 +32,9 @@ enum carp_nl_type_t {
3232 CARP_NL_ADDR = 7, /* in_addr_t */
3333 CARP_NL_ADDR6 = 8, /* in6_addr_t */
3434 CARP_NL_IFNAME = 9, /* string */
35 CARP_NL_VERSION = 10, /* u8 */
36 CARP_NL_VRRP_PRIORITY = 11, /* u8 */
37 CARP_NL_VRRP_ADV_INTER = 12, /* u16, 12-bit field in centiseconds*/
3538};
3639
3740#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/ip_compat.h+4-12
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_compat.h 1.8 1/14/96
75 * Id: ip_compat.h,v 2.142.2.57 2007/10/10 09:51:42 darrenr Exp $
86 */
97
......@@ -689,12 +687,6 @@ typedef struct tcpiphdr tcpiphdr_t;
689687#ifndef IP_HL_A
690688# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf)
691689#endif
692#ifndef TCP_X2
693# define TCP_X2(x) (x)->th_x2
694#endif
695#ifndef TCP_X2_A
696# define TCP_X2_A(x,y) (x)->th_x2 = (y)
697#endif
698690#ifndef TCP_OFF
699691# define TCP_OFF(x) (x)->th_off
700692#endif
......@@ -703,9 +695,6 @@ typedef struct tcpiphdr tcpiphdr_t;
703695#endif
704696#define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h)))
705697
706#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\
707 TH_ECN|TH_CWR)
708
709698#if !SOLARIS && !defined(m_act)
710699# define m_act m_nextpkt
711700#endif
......@@ -1136,7 +1125,10 @@ typedef struct tcpiphdr tcpiphdr_t;
11361125#ifndef TH_CWR
11371126# define TH_CWR 0x80
11381127#endif
1139#define TH_ECNALL (TH_ECN|TH_CWR)
1128#ifndef TH_AE
1129# define TH_AE 0x100
1130#endif
1131#define TH_ECNALL (TH_ECN|TH_CWR|TH_AE)
11401132
11411133/*
11421134 * TCP States
lib/libc/include/generic-freebsd/netinet/ip_dummynet.h+2-1
......@@ -145,7 +145,7 @@ struct dn_fs {
145145 uint32_t fs_nr; /* the flowset number */
146146 uint32_t flags; /* userland flags */
147147 int qsize; /* queue size in slots or bytes */
148 int32_t plr; /* PLR, pkt loss rate (2^31-1 means 100%) */
148 int32_t pl_state; /* packet loss state */
149149 uint32_t buckets; /* buckets used for the queue hash table */
150150
151151 struct ipfw_flow_id flow_mask;
......@@ -168,6 +168,7 @@ struct dn_fs {
168168 int min_th ; /* minimum threshold for queue (scaled) */
169169 int max_p ; /* maximum value for p_b (scaled) */
170170
171 int32_t plr[4]; /* PLR, pkt loss rate (2^31-1 means 100%) */
171172};
172173
173174/*
lib/libc/include/generic-freebsd/netinet/ip_fil.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_fil.h 1.35 6/5/96
75 * Id: ip_fil.h,v 2.170.2.51 2007/10/10 09:48:03 darrenr Exp $
86 */
97
lib/libc/include/generic-freebsd/netinet/ip_frag.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_frag.h 1.5 3/24/96
75 * Id: ip_frag.h,v 2.23.2.1 2004/03/29 16:21:56 darrenr Exp
86 */
97
lib/libc/include/generic-freebsd/netinet/ip_fw.h+251-176
......@@ -75,6 +75,10 @@ typedef struct _ip_fw3_opheader {
7575 uint16_t reserved[2]; /* Align to 64-bit boundary */
7676} ip_fw3_opheader;
7777
78#define IP_FW3_OPVER_0 0
79#define IP_FW3_OPVER_1 1 /* 32bit rulenum */
80#define IP_FW3_OPVER IP_FW3_OPVER_1
81
7882/* IP_FW3 opcodes */
7983#define IP_FW_TABLE_XADD 86 /* add entry */
8084#define IP_FW_TABLE_XDEL 87 /* delete entry */
......@@ -109,6 +113,7 @@ typedef struct _ip_fw3_opheader {
109113
110114#define IP_FW_DUMP_SOPTCODES 116 /* Dump available sopts/versions */
111115#define IP_FW_DUMP_SRVOBJECTS 117 /* Dump existing named objects */
116#define IP_FW_SKIPTO_CACHE 118 /* Manage skipto cache */
112117
113118#define IP_FW_NAT64STL_CREATE 130 /* Create stateless NAT64 instance */
114119#define IP_FW_NAT64STL_DESTROY 131 /* Destroy stateless NAT64 instance */
......@@ -162,162 +167,153 @@ typedef struct _ip_fw3_opheader {
162167 */
163168
164169enum ipfw_opcodes { /* arguments (4 byte each) */
165 O_NOP,
166
167 O_IP_SRC, /* u32 = IP */
168 O_IP_SRC_MASK, /* ip = IP/mask */
169 O_IP_SRC_ME, /* none */
170 O_IP_SRC_SET, /* u32=base, arg1=len, bitmap */
171
172 O_IP_DST, /* u32 = IP */
173 O_IP_DST_MASK, /* ip = IP/mask */
174 O_IP_DST_ME, /* none */
175 O_IP_DST_SET, /* u32=base, arg1=len, bitmap */
176
177 O_IP_SRCPORT, /* (n)port list:mask 4 byte ea */
178 O_IP_DSTPORT, /* (n)port list:mask 4 byte ea */
179 O_PROTO, /* arg1=protocol */
180
181 O_MACADDR2, /* 2 mac addr:mask */
182 O_MAC_TYPE, /* same as srcport */
183
184 O_LAYER2, /* none */
185 O_IN, /* none */
186 O_FRAG, /* none */
187
188 O_RECV, /* none */
189 O_XMIT, /* none */
190 O_VIA, /* none */
191
192 O_IPOPT, /* arg1 = 2*u8 bitmap */
193 O_IPLEN, /* arg1 = len */
194 O_IPID, /* arg1 = id */
195
196 O_IPTOS, /* arg1 = id */
197 O_IPPRECEDENCE, /* arg1 = precedence << 5 */
198 O_IPTTL, /* arg1 = TTL */
199
200 O_IPVER, /* arg1 = version */
201 O_UID, /* u32 = id */
202 O_GID, /* u32 = id */
203 O_ESTAB, /* none (tcp established) */
204 O_TCPFLAGS, /* arg1 = 2*u8 bitmap */
205 O_TCPWIN, /* arg1 = desired win */
206 O_TCPSEQ, /* u32 = desired seq. */
207 O_TCPACK, /* u32 = desired seq. */
208 O_ICMPTYPE, /* u32 = icmp bitmap */
209 O_TCPOPTS, /* arg1 = 2*u8 bitmap */
210
211 O_VERREVPATH, /* none */
212 O_VERSRCREACH, /* none */
213
214 O_PROBE_STATE, /* none */
215 O_KEEP_STATE, /* none */
216 O_LIMIT, /* ipfw_insn_limit */
217 O_LIMIT_PARENT, /* dyn_type, not an opcode. */
170 O_NOP = 0,
171
172 O_IP_SRC = 1, /* u32 = IP */
173 O_IP_SRC_MASK = 2, /* ip = IP/mask */
174 O_IP_SRC_ME = 3, /* none */
175 O_IP_SRC_SET = 4, /* u32=base, arg1=len, bitmap */
176
177 O_IP_DST = 5, /* u32 = IP */
178 O_IP_DST_MASK = 6, /* ip = IP/mask */
179 O_IP_DST_ME = 7, /* none */
180 O_IP_DST_SET = 8, /* u32=base, arg1=len, bitmap */
181
182 O_IP_SRCPORT = 9, /* (n)port list:mask 4 byte ea */
183 O_IP_DSTPORT = 10, /* (n)port list:mask 4 byte ea */
184 O_PROTO = 11, /* arg1=protocol */
185
186 O_MACADDR2 = 12, /* 2 mac addr:mask */
187 O_MAC_TYPE = 13, /* same as srcport */
188
189 O_LAYER2 = 14, /* none */
190 O_IN = 15, /* none */
191 O_FRAG = 16, /* none */
192
193 O_RECV = 17, /* none */
194 O_XMIT = 18, /* none */
195 O_VIA = 19, /* none */
196
197 O_IPOPT = 20, /* arg1 = 2*u8 bitmap */
198 O_IPLEN = 21, /* arg1 = len */
199 O_IPID = 22, /* arg1 = id */
200
201 O_IPTOS = 23, /* arg1 = id */
202 O_IPPRECEDENCE = 24, /* arg1 = precedence << 5 */
203 O_IPTTL = 25, /* arg1 = TTL */
204
205 O_IPVER = 26, /* arg1 = version */
206 O_UID = 27, /* u32 = id */
207 O_GID = 28, /* u32 = id */
208 O_ESTAB = 29, /* none (tcp established) */
209 O_TCPFLAGS = 30, /* arg1 = 2*u8 bitmap */
210 O_TCPWIN = 31, /* arg1 = desired win */
211 O_TCPSEQ = 32, /* u32 = desired seq. */
212 O_TCPACK = 33, /* u32 = desired seq. */
213 O_ICMPTYPE = 34, /* u32 = icmp bitmap */
214 O_TCPOPTS = 35, /* arg1 = 2*u8 bitmap */
215
216 O_VERREVPATH = 36, /* none */
217 O_VERSRCREACH = 37, /* none */
218
219 O_PROBE_STATE = 38, /* v0:arg1=kidx, v1:kidx=kidx */
220 O_KEEP_STATE = 39, /* v0:arg1=kidx, v1:kidx=kidx */
221 O_LIMIT = 40, /* ipfw_insn_limit */
222 O_LIMIT_PARENT = 41, /* dyn_type, not an opcode. */
218223
219224 /*
220225 * These are really 'actions'.
221226 */
222227
223 O_LOG, /* ipfw_insn_log */
224 O_PROB, /* u32 = match probability */
225
226 O_CHECK_STATE, /* none */
227 O_ACCEPT, /* none */
228 O_DENY, /* none */
229 O_REJECT, /* arg1=icmp arg (same as deny) */
230 O_COUNT, /* none */
231 O_SKIPTO, /* arg1=next rule number */
232 O_PIPE, /* arg1=pipe number */
233 O_QUEUE, /* arg1=queue number */
234 O_DIVERT, /* arg1=port number */
235 O_TEE, /* arg1=port number */
236 O_FORWARD_IP, /* fwd sockaddr */
237 O_FORWARD_MAC, /* fwd mac */
238 O_NAT, /* nope */
239 O_REASS, /* none */
228 O_LOG = 42, /* ipfw_insn_log */
229 O_PROB = 43, /* u32 = match probability */
230
231 O_CHECK_STATE = 44, /* v0:arg1=kidx, v1:kidx=kidx */
232 O_ACCEPT = 45, /* none */
233 O_DENY = 46, /* none */
234 O_REJECT = 47, /* arg1=icmp arg (same as deny) */
235 O_COUNT = 48, /* none */
236 O_SKIPTO = 49, /* v0:arg1=next rule number */
237 /* v1:kidx= next rule number */
238 O_PIPE = 50, /* arg1=pipe number */
239 O_QUEUE = 51, /* arg1=queue number */
240 O_DIVERT = 52, /* arg1=port number */
241 O_TEE = 53, /* arg1=port number */
242 O_FORWARD_IP = 54, /* fwd sockaddr */
243 O_FORWARD_MAC = 55, /* fwd mac */
244 O_NAT = 56, /* nope */
245 O_REASS = 57, /* none */
240246
241247 /*
242248 * More opcodes.
243249 */
244 O_IPSEC, /* has ipsec history */
245 O_IP_SRC_LOOKUP, /* arg1=table number, u32=value */
246 O_IP_DST_LOOKUP, /* arg1=table number, u32=value */
247 O_ANTISPOOF, /* none */
248 O_JAIL, /* u32 = id */
249 O_ALTQ, /* u32 = altq classif. qid */
250 O_DIVERTED, /* arg1=bitmap (1:loop, 2:out) */
251 O_TCPDATALEN, /* arg1 = tcp data len */
252 O_IP6_SRC, /* address without mask */
253 O_IP6_SRC_ME, /* my addresses */
254 O_IP6_SRC_MASK, /* address with the mask */
255 O_IP6_DST,
256 O_IP6_DST_ME,
257 O_IP6_DST_MASK,
258 O_FLOW6ID, /* for flow id tag in the ipv6 pkt */
259 O_ICMP6TYPE, /* icmp6 packet type filtering */
260 O_EXT_HDR, /* filtering for ipv6 extension header */
261 O_IP6,
250 O_IPSEC = 58, /* has ipsec history */
251 O_IP_SRC_LOOKUP = 59, /* v0:arg1=table number, u32=value */
252 /* v1:kidx=name, u32=value, arg1=key */
253 O_IP_DST_LOOKUP = 60, /* arg1=table number, u32=value */
254 /* v1:kidx=name, u32=value, arg1=key */
255 O_ANTISPOOF = 61, /* none */
256 O_JAIL = 62, /* u32 = id */
257 O_ALTQ = 63, /* u32 = altq classif. qid */
258 O_DIVERTED = 64, /* arg1=bitmap (1:loop, 2:out) */
259 O_TCPDATALEN = 65, /* arg1 = tcp data len */
260 O_IP6_SRC = 66, /* address without mask */
261 O_IP6_SRC_ME = 67, /* my addresses */
262 O_IP6_SRC_MASK = 68, /* address with the mask */
263 O_IP6_DST = 69,
264 O_IP6_DST_ME = 70,
265 O_IP6_DST_MASK = 71,
266 O_FLOW6ID = 72, /* for flow id tag in the ipv6 pkt */
267 O_ICMP6TYPE = 73, /* icmp6 packet type filtering */
268 O_EXT_HDR = 74, /* filtering for ipv6 extension header */
269 O_IP6 = 75,
262270
263271 /*
264272 * actions for ng_ipfw
265273 */
266 O_NETGRAPH, /* send to ng_ipfw */
267 O_NGTEE, /* copy to ng_ipfw */
274 O_NETGRAPH = 76, /* send to ng_ipfw */
275 O_NGTEE = 77, /* copy to ng_ipfw */
268276
269 O_IP4,
277 O_IP4 = 78,
270278
271 O_UNREACH6, /* arg1=icmpv6 code arg (deny) */
279 O_UNREACH6 = 79, /* arg1=icmpv6 code arg (deny) */
272280
273 O_TAG, /* arg1=tag number */
274 O_TAGGED, /* arg1=tag number */
281 O_TAG = 80, /* arg1=tag number */
282 O_TAGGED = 81, /* arg1=tag number */
275283
276 O_SETFIB, /* arg1=FIB number */
277 O_FIB, /* arg1=FIB desired fib number */
284 O_SETFIB = 82, /* arg1=FIB number */
285 O_FIB = 83, /* arg1=FIB desired fib number */
278286
279 O_SOCKARG, /* socket argument */
287 O_SOCKARG = 84, /* socket argument */
280288
281 O_CALLRETURN, /* arg1=called rule number */
289 O_CALLRETURN = 85, /* v0:arg1=called rule number */
290 /* v1:kidx=called rule number */
282291
283 O_FORWARD_IP6, /* fwd sockaddr_in6 */
292 O_FORWARD_IP6 = 86, /* fwd sockaddr_in6 */
284293
285 O_DSCP, /* 2 u32 = DSCP mask */
286 O_SETDSCP, /* arg1=DSCP value */
287 O_IP_FLOW_LOOKUP, /* arg1=table number, u32=value */
294 O_DSCP = 87, /* 2 u32 = DSCP mask */
295 O_SETDSCP = 88, /* arg1=DSCP value */
296 O_IP_FLOW_LOOKUP = 89, /* v0:arg1=table number, u32=value */
297 /* v1:kidx=name, u32=value */
288298
289 O_EXTERNAL_ACTION, /* arg1=id of external action handler */
290 O_EXTERNAL_INSTANCE, /* arg1=id of eaction handler instance */
291 O_EXTERNAL_DATA, /* variable length data */
299 O_EXTERNAL_ACTION = 90, /* v0:arg1=id of external action handler */
300 /* v1:kidx=id of external action handler */
301 O_EXTERNAL_INSTANCE = 91, /* v0:arg1=id of eaction handler instance */
302 /* v1:kidx=id of eaction handler instance */
303 O_EXTERNAL_DATA = 92, /* variable length data */
292304
293 O_SKIP_ACTION, /* none */
294 O_TCPMSS, /* arg1=MSS value */
305 O_SKIP_ACTION = 93, /* none */
306 O_TCPMSS = 94, /* arg1=MSS value */
295307
296 O_MAC_SRC_LOOKUP, /* arg1=table number, u32=value */
297 O_MAC_DST_LOOKUP, /* arg1=table number, u32=value */
308 O_MAC_SRC_LOOKUP = 95, /* kidx=name, u32=value, arg1=key */
309 O_MAC_DST_LOOKUP = 96, /* kidx=name, u32=value, arg1=key */
298310
299 O_SETMARK, /* u32 = value */
300 O_MARK, /* 2 u32 = value, bitmask */
311 O_SETMARK = 97, /* u32 = value */
312 O_MARK = 98, /* 2 u32 = value, bitmask */
301313
302314 O_LAST_OPCODE /* not an opcode! */
303315};
304316
305/*
306 * Defines key types used by lookup instruction
307 */
308enum ipfw_table_lookup_type {
309 LOOKUP_DST_IP,
310 LOOKUP_SRC_IP,
311 LOOKUP_DST_PORT,
312 LOOKUP_SRC_PORT,
313 LOOKUP_UID,
314 LOOKUP_JAIL,
315 LOOKUP_DSCP,
316 LOOKUP_DST_MAC,
317 LOOKUP_SRC_MAC,
318 LOOKUP_MARK,
319};
320
321317/*
322318 * The extension header are filtered only for presence using a bit
323319 * vector with a flag for each header.
......@@ -392,6 +388,11 @@ typedef struct _ipfw_insn_u32 {
392388 u_int32_t d[1]; /* one or more */
393389} ipfw_insn_u32;
394390
391typedef struct _ipfw_insn_kidx {
392 ipfw_insn o;
393 uint32_t kidx;
394} ipfw_insn_kidx;
395
395396/*
396397 * This is used to store IP addr-mask pairs.
397398 */
......@@ -401,6 +402,47 @@ typedef struct _ipfw_insn_ip {
401402 struct in_addr mask;
402403} ipfw_insn_ip;
403404
405typedef struct _ipfw_insn_table {
406 ipfw_insn o; /* arg1 is optional lookup key */
407 uint32_t kidx; /* table name index */
408 uint32_t value; /* table value */
409} ipfw_insn_table;
410
411#define IPFW_LOOKUP_TYPE_MASK 0x00FF
412#define IPFW_LOOKUP_TYPE(insn) ((insn)->arg1 & IPFW_LOOKUP_TYPE_MASK)
413#define IPFW_SET_LOOKUP_TYPE(insn, type) do { \
414 (insn)->arg1 &= ~IPFW_LOOKUP_TYPE_MASK; \
415 (insn)->arg1 |= (type) & IPFW_LOOKUP_TYPE_MASK; \
416} while (0)
417
418/*
419 * Defines key types used by lookup instruction
420 */
421enum ipfw_table_lookup_type {
422 LOOKUP_NONE = 0,
423 LOOKUP_DST_IP,
424 LOOKUP_SRC_IP,
425 LOOKUP_DST_PORT,
426 LOOKUP_SRC_PORT,
427 LOOKUP_UID,
428 LOOKUP_JAIL,
429 LOOKUP_DSCP,
430 LOOKUP_DST_MAC,
431 LOOKUP_SRC_MAC,
432 LOOKUP_MARK,
433 LOOKUP_RULENUM,
434};
435
436enum ipfw_return_type {
437 RETURN_NEXT_RULENUM = 0,
438 RETURN_NEXT_RULE,
439};
440
441enum ipfw_skipto_cache_op {
442 SKIPTO_CACHE_DISABLE = 0,
443 SKIPTO_CACHE_ENABLE,
444};
445
404446/*
405447 * This is used to forward to a given address (ip).
406448 */
......@@ -434,7 +476,8 @@ typedef struct _ipfw_insn_if {
434476 union {
435477 struct in_addr ip;
436478 int glob;
437 uint16_t kidx;
479 uint16_t kidx_v0;
480 uint32_t kidx;
438481 } p;
439482 char name[IFNAMSIZ];
440483} ipfw_insn_if;
......@@ -452,6 +495,7 @@ typedef struct _ipfw_insn_altq {
452495 */
453496typedef struct _ipfw_insn_limit {
454497 ipfw_insn o;
498 u_int32_t kidx;
455499 u_int8_t _pad;
456500 u_int8_t limit_mask; /* combination of DYN_* below */
457501#define DYN_SRC_ADDR 0x1
......@@ -462,6 +506,9 @@ typedef struct _ipfw_insn_limit {
462506 u_int16_t conn_limit;
463507} ipfw_insn_limit;
464508
509/* MAC/InfiniBand/etc address length */
510#define IPFW_MAX_L2_ADDR_LEN 20
511
465512/*
466513 * This is used for log instructions.
467514 */
......@@ -471,6 +518,22 @@ typedef struct _ipfw_insn_log {
471518 u_int32_t log_left; /* how many left to log */
472519} ipfw_insn_log;
473520
521/* ipfw_insn_log->o.arg1 bitmasks */
522#define IPFW_LOG_DEFAULT 0x0000
523#define IPFW_LOG_SYSLOG (1 << 15)
524#define IPFW_LOG_IPFW0 (1 << 14)
525#define IPFW_LOG_RTSOCK (1 << 13)
526
527typedef struct _ipfwlog_rtsock_hdr_v2 {
528 uint32_t rulenum;
529 uint32_t tablearg;
530 ipfw_insn cmd;
531 u_char ether_shost[IPFW_MAX_L2_ADDR_LEN];
532 u_char ether_dhost[IPFW_MAX_L2_ADDR_LEN];
533 uint32_t mark;
534 char comment[0];
535} ipfwlog_rtsock_hdr_v2;
536
474537/* Legacy NAT structures, compat only */
475538#ifndef _KERNEL
476539/*
......@@ -604,6 +667,10 @@ typedef struct _ipfw_insn_icmp6 {
604667 */
605668} ipfw_insn_icmp6;
606669
670/* Convert pointer to instruction with specified type */
671#define insntod(p, type) ((ipfw_insn_ ## type *)(p))
672#define insntoc(p, type) ((const ipfw_insn_ ## type *)(p))
673
607674/*
608675 * Here we have the structure representing an ipfw rule.
609676 *
......@@ -719,30 +786,29 @@ struct ipfw_flow_id {
719786/*
720787 * Dynamic ipfw rule.
721788 */
722typedef struct _ipfw_dyn_rule ipfw_dyn_rule;
723
724struct _ipfw_dyn_rule {
725 ipfw_dyn_rule *next; /* linked list of rules. */
726 struct ip_fw *rule; /* pointer to rule */
727 /* 'rule' is used to pass up the rule number (from the parent) */
789#define IPFW_DYN_ORPHANED 0x40000 /* state's parent rule was deleted */
728790
729 ipfw_dyn_rule *parent; /* pointer to parent rule */
730 u_int64_t pcnt; /* packet match counter */
731 u_int64_t bcnt; /* byte match counter */
791typedef struct _ipfw_dyn_rule {
732792 struct ipfw_flow_id id; /* (masked) flow id */
733 u_int32_t expire; /* expire time */
734 u_int32_t bucket; /* which bucket in hash table */
735 u_int32_t state; /* state of this rule (typically a
793 uint8_t set;
794 uint8_t type; /* rule type */
795 uint16_t pad;
796 uint32_t expire; /* expire time */
797 uint32_t rulenum; /* parent's rule number */
798 uint32_t kidx; /* index of named object */
799 uint64_t pcnt; /* packet match counter */
800 uint64_t bcnt; /* byte match counter */
801 uint32_t hashval; /* hash value */
802 union {
803 uint32_t state; /* state of this rule (typically a
736804 * combination of TCP flags)
737805 */
738#define IPFW_DYN_ORPHANED 0x40000 /* state's parent rule was deleted */
739 u_int32_t ack_fwd; /* most recent ACKs in forward */
740 u_int32_t ack_rev; /* and reverse directions (used */
806 uint32_t count; /* number of linked states */
807 };
808 uint32_t ack_fwd; /* most recent ACKs in forward */
809 uint32_t ack_rev; /* and reverse directions (used */
741810 /* to generate keepalives) */
742 u_int16_t dyn_type; /* rule type */
743 u_int16_t count; /* refcount */
744 u_int16_t kidx; /* index of named object */
745} __packed __aligned(8);
811} __packed __aligned(8) ipfw_dyn_rule;
746812
747813/*
748814 * Definitions for IP option names.
......@@ -794,16 +860,6 @@ struct _ipfw_dyn_rule {
794860#define IPFW_VTYPE_NH6 0x00000400 /* IPv6 nexthop */
795861#define IPFW_VTYPE_MARK 0x00000800 /* [fw]mark */
796862
797/* MAC/InfiniBand/etc address length */
798#define IPFW_MAX_L2_ADDR_LEN 20
799
800typedef struct _ipfw_table_entry {
801 in_addr_t addr; /* network address */
802 u_int32_t value; /* value */
803 u_int16_t tbl; /* table number */
804 u_int8_t masklen; /* mask length */
805} ipfw_table_entry;
806
807863typedef struct _ipfw_table_xentry {
808864 uint16_t len; /* Total entry length */
809865 uint8_t type; /* entry type */
......@@ -819,13 +875,6 @@ typedef struct _ipfw_table_xentry {
819875} ipfw_table_xentry;
820876#define IPFW_TCF_INET 0x01 /* CIDR flags: IPv4 record */
821877
822typedef struct _ipfw_table {
823 u_int32_t size; /* size of entries in bytes */
824 u_int32_t cnt; /* # of entries */
825 u_int16_t tbl; /* table number */
826 ipfw_table_entry ent[0]; /* entries */
827} ipfw_table;
828
829878typedef struct _ipfw_xtable {
830879 ip_fw3_opheader opheader; /* IP_FW3 opcode */
831880 uint32_t size; /* size of entries in bytes */
......@@ -865,10 +914,10 @@ typedef struct _ipfw_obj_data {
865914/* Object name TLV */
866915typedef struct _ipfw_obj_ntlv {
867916 ipfw_obj_tlv head; /* TLV header */
868 uint16_t idx; /* Name index */
917 uint32_t idx; /* Name index */
869918 uint8_t set; /* set, if applicable */
870919 uint8_t type; /* object type, if applicable */
871 uint32_t spare; /* unused */
920 uint16_t spare; /* unused */
872921 char name[64]; /* Null-terminated name */
873922} ipfw_obj_ntlv;
874923
......@@ -891,19 +940,40 @@ struct tflow_entry {
891940 } a;
892941};
893942
943#define IPFW_TVALUE_TYPE_MASK 0xFF00
944#define IPFW_TVALUE_TYPE(insn) (((insn)->arg1 & IPFW_TVALUE_TYPE_MASK) >> 8)
945#define IPFW_SET_TVALUE_TYPE(insn, type) do { \
946 (insn)->arg1 &= ~IPFW_TVALUE_TYPE_MASK; \
947 (insn)->arg1 |= ((type) << 8) & IPFW_TVALUE_TYPE_MASK; \
948} while (0)
949
950enum ipfw_table_value_type {
951 TVALUE_TAG = 0,
952 TVALUE_PIPE,
953 TVALUE_DIVERT,
954 TVALUE_SKIPTO,
955 TVALUE_NETGRAPH,
956 TVALUE_FIB,
957 TVALUE_NAT,
958 TVALUE_NH4,
959 TVALUE_DSCP,
960 TVALUE_LIMIT,
961 TVALUE_MARK,
962};
963
894964/* 64-byte structure representing multi-field table value */
895965typedef struct _ipfw_table_value {
896966 uint32_t tag; /* O_TAG/O_TAGGED */
897 uint32_t pipe; /* O_PIPE/O_QUEUE */
967 uint16_t pipe; /* O_PIPE/O_QUEUE */
898968 uint16_t divert; /* O_DIVERT/O_TEE */
899 uint16_t skipto; /* skipto, CALLRET */
969 uint32_t skipto; /* skipto, CALLRET */
900970 uint32_t netgraph; /* O_NETGRAPH/O_NGTEE */
901 uint32_t fib; /* O_SETFIB */
902971 uint32_t nat; /* O_NAT */
903972 uint32_t nh4;
973 uint16_t fib; /* O_SETFIB */
904974 uint8_t dscp;
905975 uint8_t spare0;
906 uint16_t kidx; /* value kernel index */
976 uint32_t kidx; /* value kernel index */
907977 struct in6_addr nh6;
908978 uint32_t limit; /* O_LIMIT */
909979 uint32_t zoneid; /* scope zone id for nh6 */
......@@ -918,8 +988,7 @@ typedef struct _ipfw_obj_tentry {
918988 uint8_t masklen; /* mask length */
919989 uint8_t result; /* request result */
920990 uint8_t spare0;
921 uint16_t idx; /* Table name index */
922 uint16_t spare1;
991 uint32_t idx; /* Table name index */
923992 union {
924993 /* Longest field needs to be aligned by 8-byte boundary */
925994 struct in_addr addr; /* IPv4 address */
......@@ -966,8 +1035,8 @@ typedef struct _ipfw_obj_ctlv {
9661035typedef struct _ipfw_range_tlv {
9671036 ipfw_obj_tlv head; /* TLV header */
9681037 uint32_t flags; /* Range flags */
969 uint16_t start_rule; /* Range start */
970 uint16_t end_rule; /* Range end */
1038 uint32_t start_rule; /* Range start */
1039 uint32_t end_rule; /* Range end */
9711040 uint32_t set; /* Range set to match */
9721041 uint32_t new_set; /* New set to move/swap to */
9731042} ipfw_range_tlv;
......@@ -1051,10 +1120,16 @@ typedef struct _ipfw_ta_info {
10511120 uint64_t spare1;
10521121} ipfw_ta_info;
10531122
1123typedef struct _ipfw_cmd_header { /* control command header */
1124 ip_fw3_opheader opheader; /* IP_FW3 opcode */
1125 uint32_t size; /* Total size (incl. header) */
1126 uint32_t cmd; /* command */
1127} ipfw_cmd_header;
1128
10541129typedef struct _ipfw_obj_header {
10551130 ip_fw3_opheader opheader; /* IP_FW3 opcode */
1056 uint32_t spare;
1057 uint16_t idx; /* object name index */
1131 uint32_t idx; /* object name index */
1132 uint16_t spare;
10581133 uint8_t objtype; /* object type */
10591134 uint8_t objsubtype; /* object subtype */
10601135 ipfw_obj_ntlv ntlv; /* object name tlv */
lib/libc/include/generic-freebsd/netinet/ip_icmp.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NETINET_IP_ICMP_H_
lib/libc/include/generic-freebsd/netinet/ip_mroute.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93
3634 */
3735
3836#ifndef _NETINET_IP_MROUTE_H_
lib/libc/include/generic-freebsd/netinet/ip_nat.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_nat.h 1.5 2/4/96
75 * Id: ip_nat.h,v 2.90.2.20 2007/09/25 08:27:32 darrenr Exp $
86 */
97
lib/libc/include/generic-freebsd/netinet/ip_scan.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_fil.h 1.35 6/5/96
75 * $Id$
86 */
97
lib/libc/include/generic-freebsd/netinet/ip_state.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_state.h 1.3 1/12/96 (C) 1995 Darren Reed
75 * Id: ip_state.h,v 2.68.2.10 2007/10/16 09:33:24 darrenr Exp $
86 */
97#ifndef __IP_STATE_H__
lib/libc/include/generic-freebsd/netinet/ip_sync.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_fil.h 1.35 6/5/96
75 * $Id$
86 */
97
lib/libc/include/generic-freebsd/netinet/ip_var.h+25-12
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ip_var.h 8.2 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _NETINET_IP_VAR_H_
......@@ -49,7 +47,7 @@ struct ipovly {
4947 u_short ih_len; /* protocol length */
5048 struct in_addr ih_src; /* source internet address */
5149 struct in_addr ih_dst; /* destination internet address */
52};
50} __packed;
5351
5452#ifdef _KERNEL
5553/*
......@@ -138,15 +136,19 @@ struct ipstat {
138136
139137#include <sys/counter.h>
140138#include <net/vnet.h>
139#include <netinet/in_kdtrace.h>
141140
142141VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);
143142/*
144143 * In-kernel consumers can use these accessor macros directly to update
145144 * stats.
146145 */
147#define IPSTAT_ADD(name, val) \
148 VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val))
149#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val))
146#define IPSTAT_ADD(name, val) \
147 do { \
148 MIB_SDT_PROBE1(ip, count, name, (val)); \
149 VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val)); \
150 } while (0)
151#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val))
150152#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)
151153#define IPSTAT_DEC(name) IPSTAT_SUB(name, 1)
152154
......@@ -154,11 +156,19 @@ VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);
154156 * Kernel module consumers must use this accessor macro.
155157 */
156158void kmod_ipstat_inc(int statnum);
157#define KMOD_IPSTAT_INC(name) \
158 kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t))
159void kmod_ipstat_dec(int statnum);
160#define KMOD_IPSTAT_DEC(name) \
161 kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t))
159#define KMOD_IPSTAT_INC(name) \
160 do { \
161 MIB_SDT_PROBE1(ip, count, name, 1); \
162 kmod_ipstat_inc( \
163 offsetof(struct ipstat, name) / sizeof(uint64_t)); \
164 } while (0)
165void kmod_ipstat_dec(int statnum);
166#define KMOD_IPSTAT_DEC(name) \
167 do { \
168 MIB_SDT_PROBE1(ip, count, name, -1); \
169 kmod_ipstat_dec( \
170 offsetof(struct ipstat, name) / sizeof(uint64_t)); \
171 } while (0)
162172
163173/* flags passed to ip_output as last parameter */
164174#define IP_FORWARDING 0x1 /* most of ip header exists */
......@@ -194,6 +204,7 @@ extern int (*legal_vif_num)(int);
194204extern u_long (*ip_mcast_src)(int);
195205VNET_DECLARE(int, rsvp_on);
196206VNET_DECLARE(int, drop_redirect);
207VNET_DECLARE(int, ip_random_id);
197208
198209#define V_ip_id VNET(ip_id)
199210#define V_ip_defttl VNET(ip_defttl)
......@@ -206,6 +217,7 @@ VNET_DECLARE(int, drop_redirect);
206217#define V_ip_mrouter VNET(ip_mrouter)
207218#define V_rsvp_on VNET(rsvp_on)
208219#define V_drop_redirect VNET(drop_redirect)
220#define V_ip_random_id VNET(ip_random_id)
209221
210222void inp_freemoptions(struct ip_moptions *);
211223int inp_getmoptions(struct inpcb *, struct sockopt *);
......@@ -225,7 +237,7 @@ struct mbuf *
225237 ip_reass(struct mbuf *);
226238void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,
227239 struct mbuf *);
228void ip_fillid(struct ip *);
240void ip_fillid(struct ip *, bool);
229241int rip_ctloutput(struct socket *, struct sockopt *);
230242int ipip_input(struct mbuf **, int *, int);
231243int rsvp_input(struct mbuf **, int *, int);
......@@ -259,6 +271,7 @@ VNET_DECLARE(struct pfil_head *, inet_local_pfil_head);
259271#define PFIL_INET_LOCAL_NAME "inet-local"
260272
261273void in_delayed_cksum(struct mbuf *m);
274void in_delayed_cksum_o(struct mbuf *m, uint16_t o);
262275
263276/* Hooks for ipfw, dummynet, divert etc. Most are declared in raw_ip.c */
264277/*
lib/libc/include/generic-freebsd/netinet/ipf_rb.h-2
......@@ -305,13 +305,11 @@ _n##_rb_walktree(struct _n##_rb_head *head, _n##_rb_walker_t func, void *arg)\
305305 _t *prev; \
306306 _t *next; \
307307 _t *node = head->top._f.right; \
308 _t *base; \
309308 \
310309 while (node != &_n##_rb_zero) \
311310 node = node->_f.left; \
312311 \
313312 for (;;) { \
314 base = node; \
315313 prev = node; \
316314 while ((node->_f.parent->_f.right == node) && \
317315 (node != &_n##_rb_zero)) { \
lib/libc/include/generic-freebsd/netinet/ipl.h-2
......@@ -2,8 +2,6 @@
22 * Copyright (C) 2012 by Darren Reed.
33 *
44 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ipl.h 1.21 6/5/96
75 * Id: ipl.h,v 2.52.2.30 2007/10/16 09:41:00 darrenr Exp $
86 */
97
lib/libc/include/generic-freebsd/netinet/pim.h+1-1
......@@ -71,7 +71,7 @@ struct pim {
7171#endif /* ! _PIM_VT */
7272 uint8_t pim_reserved; /* Reserved */
7373 uint16_t pim_cksum; /* IP-style checksum */
74};
74} __packed;
7575/* KAME-related name backward compatibility */
7676#define pim_ver pim_vers
7777#define pim_rsv pim_reserved
lib/libc/include/generic-freebsd/netinet/sctp.h-1
......@@ -35,7 +35,6 @@
3535#ifndef _NETINET_SCTP_H_
3636#define _NETINET_SCTP_H_
3737
38#include <sys/cdefs.h>
3938#include <sys/types.h>
4039
4140#define SCTP_PACKED __attribute__((packed))
lib/libc/include/generic-freebsd/netinet/sctp_os.h-3
......@@ -39,9 +39,6 @@
3939 * General kernel memory allocation:
4040 * SCTP_MALLOC(element, type, size, name)
4141 * SCTP_FREE(element)
42 * Kernel memory allocation for "soname"- memory must be zeroed.
43 * SCTP_MALLOC_SONAME(name, type, size)
44 * SCTP_FREE_SONAME(name)
4542 */
4643
4744/*
lib/libc/include/generic-freebsd/netinet/sctp_os_bsd.h+1-8
......@@ -219,13 +219,6 @@ MALLOC_DECLARE(SCTP_M_MCORE);
219219
220220#define SCTP_FREE(var, type) free(var, type)
221221
222#define SCTP_MALLOC_SONAME(var, type, size) \
223 do { \
224 var = (type)malloc(size, M_SONAME, M_WAITOK | M_ZERO); \
225 } while (0)
226
227#define SCTP_FREE_SONAME(var) free(var, M_SONAME)
228
229222#define SCTP_PROCESS_STRUCT struct proc *
230223
231224/*
......@@ -349,7 +342,7 @@ typedef struct callout sctp_os_timer_t;
349342 } while(0)
350343
351344/* Other m_pkthdr type things */
352#define SCTP_IS_IT_BROADCAST(dst, m) ((m->m_flags & M_PKTHDR) ? in_broadcast(dst, m->m_pkthdr.rcvif) : 0)
345#define SCTP_IS_IT_BROADCAST(dst, m) ((m->m_flags & M_PKTHDR) ? in_ifnet_broadcast(dst, m->m_pkthdr.rcvif) : 0)
353346#define SCTP_IS_IT_LOOPBACK(m) ((m->m_flags & M_PKTHDR) && ((m->m_pkthdr.rcvif == NULL) || (m->m_pkthdr.rcvif->if_type == IFT_LOOP)))
354347
355348/* This converts any input packet header
lib/libc/include/generic-freebsd/netinet/sctp_var.h+4-4
......@@ -331,17 +331,17 @@ void
331331sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
332332 uint8_t, uint8_t, uint16_t, uint32_t);
333333int sctp_flush(struct socket *, int);
334int sctp_shutdown(struct socket *);
334int sctp_shutdown(struct socket *, enum shutdown_how);
335335int
336336sctp_bindx(struct socket *, int, struct sockaddr_storage *,
337337 int, int, struct proc *);
338338
339339/* can't use sctp_assoc_t here */
340340int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
341int sctp_ingetaddr(struct socket *, struct sockaddr **);
342int sctp_peeraddr(struct socket *, struct sockaddr **);
341int sctp_ingetaddr(struct socket *, struct sockaddr *);
342int sctp_peeraddr(struct socket *, struct sockaddr *);
343343int sctp_listen(struct socket *, int, struct thread *);
344int sctp_accept(struct socket *, struct sockaddr **);
344int sctp_accept(struct socket *, struct sockaddr *);
345345
346346#endif /* _KERNEL */
347347
lib/libc/include/generic-freebsd/netinet/tcp.h+204-166
......@@ -27,14 +27,11 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcp.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NETINET_TCP_H_
3533#define _NETINET_TCP_H_
3634
37#include <sys/cdefs.h>
3835#include <sys/types.h>
3936
4037#if __BSD_VISIBLE
......@@ -74,13 +71,31 @@ struct tcphdr {
7471#define TH_RES3 0x200
7572#define TH_RES2 0x400
7673#define TH_RES1 0x800
77#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR)
74#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR|TH_AE)
7875#define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR\11AE"
7976
8077 u_short th_win; /* window */
8178 u_short th_sum; /* checksum */
8279 u_short th_urp; /* urgent pointer */
83};
80} __packed;
81
82static __inline uint16_t
83__tcp_get_flags(const struct tcphdr *th)
84{
85 return (((uint16_t)th->th_x2 << 8) | th->th_flags);
86}
87
88static __inline void
89__tcp_set_flags(struct tcphdr *th, uint16_t flags)
90{
91 th->th_x2 = (flags >> 8) & 0x0f;
92 th->th_flags = flags & 0xff;
93}
94
95#ifdef _KERNEL
96#define tcp_get_flags(th) __tcp_get_flags(th)
97#define tcp_set_flags(th, flags) __tcp_set_flags(th, flags)
98#endif
8499
85100#define PADTCPOLEN(len) ((((len) / 4) + !!((len) % 4)) * 4)
86101
......@@ -151,8 +166,6 @@ struct tcphdr {
151166
152167#define TCP_MAX_WINSHIFT 14 /* maximum window shift */
153168
154#define TCP_MAXBURST 4 /* maximum segments in a burst */
155
156169#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */
157170#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr))
158171 /* max space left for options */
......@@ -167,165 +180,170 @@ struct tcphdr {
167180 * values and are not masked together. Some values appear to be
168181 * bitmasks for historical reasons.
169182 */
170#define TCP_NODELAY 1 /* don't delay send to coalesce packets */
183#define TCP_NODELAY 1 /* don't delay send to coalesce packets */
171184#if __BSD_VISIBLE
172#define TCP_MAXSEG 2 /* set maximum segment size */
173#define TCP_NOPUSH 4 /* don't push last block of write */
174#define TCP_NOOPT 8 /* don't use TCP options */
175#define TCP_MD5SIG 16 /* use MD5 digests (RFC2385) */
176#define TCP_INFO 32 /* retrieve tcp_info structure */
177#define TCP_STATS 33 /* retrieve stats blob structure */
178#define TCP_LOG 34 /* configure event logging for connection */
179#define TCP_LOGBUF 35 /* retrieve event log for connection */
180#define TCP_LOGID 36 /* configure log ID to correlate connections */
181#define TCP_LOGDUMP 37 /* dump connection log events to device */
182#define TCP_LOGDUMPID 38 /* dump events from connections with same ID to
183 device */
184#define TCP_TXTLS_ENABLE 39 /* TLS framing and encryption for transmit */
185#define TCP_TXTLS_MODE 40 /* Transmit TLS mode */
186#define TCP_RXTLS_ENABLE 41 /* TLS framing and encryption for receive */
187#define TCP_RXTLS_MODE 42 /* Receive TLS mode */
188#define TCP_IWND_NB 43 /* Override initial window (units: bytes) */
189#define TCP_IWND_NSEG 44 /* Override initial window (units: MSS segs) */
185#define TCP_MAXSEG 2 /* set maximum segment size */
186#define TCP_NOPUSH 4 /* don't push last block of write */
187#define TCP_NOOPT 8 /* don't use TCP options */
188#define TCP_MD5SIG 16 /* use MD5 digests (RFC2385) */
189#define TCP_INFO 32 /* retrieve tcp_info structure */
190#define TCP_STATS 33 /* retrieve stats blob structure */
191#define TCP_LOG 34 /* configure event logging for connection */
192#define TCP_LOGBUF 35 /* retrieve event log for connection */
193#define TCP_LOGID 36 /* configure log ID to correlate connections */
194#define TCP_LOGDUMP 37 /* dump connection log events to device */
195#define TCP_LOGDUMPID 38 /* dump events from connections with same ID to
196 device */
197#define TCP_TXTLS_ENABLE 39 /* TLS framing and encryption for transmit */
198#define TCP_TXTLS_MODE 40 /* Transmit TLS mode */
199#define TCP_RXTLS_ENABLE 41 /* TLS framing and encryption for receive */
200#define TCP_RXTLS_MODE 42 /* Receive TLS mode */
201#define TCP_IWND_NB 43 /* Override initial window (units: bytes) */
202#define TCP_IWND_NSEG 44 /* Override initial window (units: MSS segs) */
190203#ifdef _KERNEL
191#define TCP_USE_DDP 45 /* Use direct data placement for so_rcvbuf */
204#define TCP_USE_DDP 45 /* Use direct data placement for so_rcvbuf */
192205#endif
193#define TCP_LOGID_CNT 46 /* get number of connections with the same ID */
194#define TCP_LOG_TAG 47 /* configure tag for grouping logs */
195#define TCP_USER_LOG 48 /* userspace log event */
196#define TCP_CONGESTION 64 /* get/set congestion control algorithm */
197#define TCP_CCALGOOPT 65 /* get/set cc algorithm specific options */
198#define TCP_MAXUNACKTIME 68 /* maximum time without making progress (sec) */
199#define TCP_MAXPEAKRATE 69 /* maximum peak rate allowed (kbps) */
200#define TCP_IDLE_REDUCE 70 /* Reduce cwnd on idle input */
201#define TCP_REMOTE_UDP_ENCAPS_PORT 71 /* Enable TCP over UDP tunneling via the specified port */
202#define TCP_DELACK 72 /* socket option for delayed ack */
203#define TCP_FIN_IS_RST 73 /* A fin from the peer is treated has a RST */
204#define TCP_LOG_LIMIT 74 /* Limit to number of records in tcp-log */
205#define TCP_SHARED_CWND_ALLOWED 75 /* Use of a shared cwnd is allowed */
206#define TCP_PROC_ACCOUNTING 76 /* Do accounting on tcp cpu usage and counts */
207#define TCP_USE_CMP_ACKS 77 /* The transport can handle the Compressed mbuf acks */
208#define TCP_PERF_INFO 78 /* retrieve accounting counters */
209#define TCP_LRD 79 /* toggle Lost Retransmission Detection for A/B testing */
210#define TCP_KEEPINIT 128 /* N, time to establish connection */
211#define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */
212#define TCP_KEEPINTVL 512 /* L,N interval between keepalives */
213#define TCP_KEEPCNT 1024 /* L,N number of keepalives before close */
214#define TCP_FASTOPEN 1025 /* enable TFO / was created via TFO */
215#define TCP_PCAP_OUT 2048 /* number of output packets to keep */
216#define TCP_PCAP_IN 4096 /* number of input packets to keep */
217#define TCP_FUNCTION_BLK 8192 /* Set the tcp function pointers to the specified stack */
218#define TCP_FUNCTION_ALIAS 8193 /* Get the current tcp function pointer name alias */
206#define TCP_LOGID_CNT 46 /* get number of connections with the same ID */
207#define TCP_LOG_TAG 47 /* configure tag for grouping logs */
208#define TCP_USER_LOG 48 /* userspace log event */
209#define TCP_CONGESTION 64 /* get/set congestion control algorithm */
210#define TCP_CCALGOOPT 65 /* get/set cc algorithm specific options */
211#define TCP_MAXUNACKTIME 68 /* maximum time without making progress (sec) */
212/* unused 69 */
213#define TCP_IDLE_REDUCE 70 /* Reduce cwnd on idle input */
214#define TCP_REMOTE_UDP_ENCAPS_PORT 71 /* Enable TCP over UDP tunneling via the specified port */
215#define TCP_DELACK 72 /* socket option for delayed ack */
216#define TCP_FIN_IS_RST 73 /* A fin from the peer is treated has a RST */
217#define TCP_LOG_LIMIT 74 /* Limit to number of records in tcp-log */
218#define TCP_SHARED_CWND_ALLOWED 75 /* Use of a shared cwnd is allowed */
219#define TCP_PROC_ACCOUNTING 76 /* Do accounting on tcp cpu usage and counts */
220#define TCP_USE_CMP_ACKS 77 /* The transport can handle the Compressed mbuf acks */
221#define TCP_PERF_INFO 78 /* retrieve accounting counters */
222#define TCP_KEEPINIT 128 /* N, time to establish connection */
223#define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */
224#define TCP_KEEPINTVL 512 /* L,N interval between keepalives */
225#define TCP_KEEPCNT 1024 /* L,N number of keepalives before close */
226#define TCP_FASTOPEN 1025 /* enable TFO / was created via TFO */
227/* unused 2048 was TCP_PCAP_OUT */
228/* unused 4096 was TCP_PCAP_IN */
229#define TCP_FUNCTION_BLK 8192 /* Set the tcp function pointers to the specified stack */
230#define TCP_FUNCTION_ALIAS 8193 /* Get the current tcp function pointer name alias */
219231/* Options for Rack and BBR */
220#define TCP_REUSPORT_LB_NUMA 1026 /* set listen socket numa domain */
221#define TCP_RACK_MBUF_QUEUE 1050 /* Do we allow mbuf queuing if supported */
222#define TCP_RACK_PROP 1051 /* Not used */
223#define TCP_RACK_TLP_REDUCE 1052 /* RACK TLP cwnd reduction (bool) */
224#define TCP_RACK_PACE_REDUCE 1053 /* RACK Pacingv reduction factor (divisor) */
225#define TCP_RACK_PACE_MAX_SEG 1054 /* Max TSO size we will send */
226#define TCP_RACK_PACE_ALWAYS 1055 /* Use the always pace method */
227#define TCP_RACK_PROP_RATE 1056 /* Not used */
228#define TCP_RACK_PRR_SENDALOT 1057 /* Allow PRR to send more than one seg */
229#define TCP_RACK_MIN_TO 1058 /* Minimum time between rack t-o's in ms */
230#define TCP_RACK_EARLY_RECOV 1059 /* Not used */
231#define TCP_RACK_EARLY_SEG 1060 /* If early recovery max segments */
232#define TCP_RACK_REORD_THRESH 1061 /* RACK reorder threshold (shift amount) */
233#define TCP_RACK_REORD_FADE 1062 /* Does reordering fade after ms time */
234#define TCP_RACK_TLP_THRESH 1063 /* RACK TLP theshold i.e. srtt+(srtt/N) */
235#define TCP_RACK_PKT_DELAY 1064 /* RACK added ms i.e. rack-rtt + reord + N */
236#define TCP_RACK_TLP_INC_VAR 1065 /* Does TLP include rtt variance in t-o */
237#define TCP_BBR_IWINTSO 1067 /* Initial TSO window for BBRs first sends */
238#define TCP_BBR_RECFORCE 1068 /* Enter recovery force out a segment disregard pacer no longer valid */
239#define TCP_BBR_STARTUP_PG 1069 /* Startup pacing gain */
240#define TCP_BBR_DRAIN_PG 1070 /* Drain pacing gain */
241#define TCP_BBR_RWND_IS_APP 1071 /* Rwnd limited is considered app limited */
242#define TCP_BBR_PROBE_RTT_INT 1072 /* How long in useconds between probe-rtt */
243#define TCP_BBR_ONE_RETRAN 1073 /* Is only one segment allowed out during retran */
244#define TCP_BBR_STARTUP_LOSS_EXIT 1074 /* Do we exit a loss during startup if not 20% incr */
245#define TCP_BBR_USE_LOWGAIN 1075 /* lower the gain in PROBE_BW enable */
246#define TCP_BBR_LOWGAIN_THRESH 1076 /* Unused after 2.3 morphs to TSLIMITS >= 2.3 */
247#define TCP_BBR_TSLIMITS 1076 /* Do we use experimental Timestamp limiting for our algo */
248#define TCP_BBR_LOWGAIN_HALF 1077 /* Unused after 2.3 */
249#define TCP_BBR_PACE_OH 1077 /* Reused in 4.2 for pacing overhead setting */
250#define TCP_BBR_LOWGAIN_FD 1078 /* Unused after 2.3 */
251#define TCP_BBR_HOLD_TARGET 1078 /* For 4.3 on */
252#define TCP_BBR_USEDEL_RATE 1079 /* Enable use of delivery rate for loss recovery */
253#define TCP_BBR_MIN_RTO 1080 /* Min RTO in milliseconds */
254#define TCP_BBR_MAX_RTO 1081 /* Max RTO in milliseconds */
255#define TCP_BBR_REC_OVER_HPTS 1082 /* Recovery override htps settings 0/1/3 */
256#define TCP_BBR_UNLIMITED 1083 /* Not used before 2.3 and morphs to algorithm >= 2.3 */
257#define TCP_BBR_ALGORITHM 1083 /* What measurement algo does BBR use netflix=0, google=1 */
258#define TCP_BBR_DRAIN_INC_EXTRA 1084 /* Does the 3/4 drain target include the extra gain */
259#define TCP_BBR_STARTUP_EXIT_EPOCH 1085 /* what epoch gets us out of startup */
260#define TCP_BBR_PACE_PER_SEC 1086
261#define TCP_BBR_PACE_DEL_TAR 1087
262#define TCP_BBR_PACE_SEG_MAX 1088
263#define TCP_BBR_PACE_SEG_MIN 1089
264#define TCP_BBR_PACE_CROSS 1090
265#define TCP_RACK_IDLE_REDUCE_HIGH 1092 /* Reduce the highest cwnd seen to IW on idle */
266#define TCP_RACK_MIN_PACE 1093 /* Do we enforce rack min pace time */
267#define TCP_RACK_MIN_PACE_SEG 1094 /* If so what is the seg threshould */
268#define TCP_RACK_GP_INCREASE 1094 /* After 4.1 its the GP increase in older rack */
269#define TCP_RACK_TLP_USE 1095
270#define TCP_BBR_ACK_COMP_ALG 1096 /* Not used */
271#define TCP_BBR_TMR_PACE_OH 1096 /* Recycled in 4.2 */
272#define TCP_BBR_EXTRA_GAIN 1097
273#define TCP_RACK_DO_DETECTION 1097 /* Recycle of extra gain for rack, attack detection */
274#define TCP_BBR_RACK_RTT_USE 1098 /* what RTT should we use 0, 1, or 2? */
275#define TCP_BBR_RETRAN_WTSO 1099
276#define TCP_DATA_AFTER_CLOSE 1100
277#define TCP_BBR_PROBE_RTT_GAIN 1101
278#define TCP_BBR_PROBE_RTT_LEN 1102
279#define TCP_BBR_SEND_IWND_IN_TSO 1103 /* Do we burst out whole iwin size chunks at start? */
280#define TCP_BBR_USE_RACK_RR 1104 /* Do we use the rack rapid recovery for pacing rxt's */
281#define TCP_BBR_USE_RACK_CHEAT TCP_BBR_USE_RACK_RR /* Compat. */
282#define TCP_BBR_HDWR_PACE 1105 /* Enable/disable hardware pacing */
283#define TCP_BBR_UTTER_MAX_TSO 1106 /* Do we enforce an utter max TSO size */
284#define TCP_BBR_EXTRA_STATE 1107 /* Special exit-persist catch up */
285#define TCP_BBR_FLOOR_MIN_TSO 1108 /* The min tso size */
286#define TCP_BBR_MIN_TOPACEOUT 1109 /* Do we suspend pacing until */
287#define TCP_BBR_TSTMP_RAISES 1110 /* Can a timestamp measurement raise the b/w */
288#define TCP_BBR_POLICER_DETECT 1111 /* Turn on/off google mode policer detection */
289#define TCP_BBR_RACK_INIT_RATE 1112 /* Set an initial pacing rate for when we have no b/w in kbits per sec */
290#define TCP_RACK_RR_CONF 1113 /* Rack rapid recovery configuration control*/
291#define TCP_RACK_CHEAT_NOT_CONF_RATE TCP_RACK_RR_CONF
292#define TCP_RACK_GP_INCREASE_CA 1114 /* GP increase for Congestion Avoidance */
293#define TCP_RACK_GP_INCREASE_SS 1115 /* GP increase for Slow Start */
294#define TCP_RACK_GP_INCREASE_REC 1116 /* GP increase for Recovery */
295#define TCP_RACK_FORCE_MSEG 1117 /* Override to use the user set max-seg value */
296#define TCP_RACK_PACE_RATE_CA 1118 /* Pacing rate for Congestion Avoidance */
297#define TCP_RACK_PACE_RATE_SS 1119 /* Pacing rate for Slow Start */
298#define TCP_RACK_PACE_RATE_REC 1120 /* Pacing rate for Recovery */
299#define TCP_NO_PRR 1122 /* If pacing, don't use prr */
300#define TCP_RACK_NONRXT_CFG_RATE 1123 /* In recovery does a non-rxt use the cfg rate */
301#define TCP_SHARED_CWND_ENABLE 1124 /* Use a shared cwnd if allowed */
302#define TCP_TIMELY_DYN_ADJ 1125 /* Do we attempt dynamic multipler adjustment with timely. */
303#define TCP_RACK_NO_PUSH_AT_MAX 1126 /* For timely do not push if we are over max rtt */
304#define TCP_RACK_PACE_TO_FILL 1127 /* If we are not in recovery, always pace to fill the cwnd in 1 RTT */
305#define TCP_SHARED_CWND_TIME_LIMIT 1128 /* we should limit to low time values the scwnd life */
306#define TCP_RACK_PROFILE 1129 /* Select a profile that sets multiple options */
307#define TCP_HDWR_RATE_CAP 1130 /* Allow hardware rates to cap pacing rate */
308#define TCP_PACING_RATE_CAP 1131 /* Highest rate allowed in pacing in bytes per second (uint64_t) */
309#define TCP_HDWR_UP_ONLY 1132 /* Allow the pacing rate to climb but not descend (with the exception of fill-cw */
310#define TCP_RACK_ABC_VAL 1133 /* Set a local ABC value different then the system default */
311#define TCP_REC_ABC_VAL 1134 /* Do we use the ABC value for recovery or the override one from sysctl */
312#define TCP_RACK_MEASURE_CNT 1135 /* How many measurements are required in GP pacing */
313#define TCP_DEFER_OPTIONS 1136 /* Defer options until the proper number of measurements occur, does not defer TCP_RACK_MEASURE_CNT */
314#define TCP_FAST_RSM_HACK 1137 /* Not used in modern stacks */
315#define TCP_RACK_PACING_BETA 1138 /* Changing the beta for pacing */
316#define TCP_RACK_PACING_BETA_ECN 1139 /* Changing the beta for ecn with pacing */
317#define TCP_RACK_TIMER_SLOP 1140 /* Set or get the timer slop used */
318#define TCP_RACK_DSACK_OPT 1141 /* How do we setup rack timer DSACK options bit 1/2 */
319#define TCP_RACK_ENABLE_HYSTART 1142 /* Do we allow hystart in the CC modules */
320#define TCP_RACK_SET_RXT_OPTIONS 1143 /* Set the bits in the retransmit options */
321#define TCP_RACK_HI_BETA 1144 /* Turn on/off high beta */
322#define TCP_RACK_SPLIT_LIMIT 1145 /* Set a split limit for split allocations */
323#define TCP_RACK_PACING_DIVISOR 1146 /* Pacing divisor given to rate-limit code for burst sizing */
324#define TCP_RACK_PACE_MIN_SEG 1147 /* Pacing min seg size rack will use */
325#define TCP_RACK_DGP_IN_REC 1148 /* Do we use full DGP in recovery? */
326#define TCP_RXT_CLAMP 1149 /* Do we apply a threshold to rack so if excess rxt clamp cwnd? */
327#define TCP_HYBRID_PACING 1150 /* Hybrid pacing enablement */
328#define TCP_PACING_DND 1151 /* When pacing with rr_config=3 can sacks disturb us */
232#define TCP_REUSPORT_LB_NUMA 1026 /* set listen socket numa domain */
233#define TCP_RACK_MBUF_QUEUE 1050 /* Do we allow mbuf queuing if supported */
234/* unused 1051 */
235#define TCP_RACK_TLP_REDUCE 1052 /* RACK TLP cwnd reduction (bool) */
236/* unused 1053 */
237#define TCP_RACK_PACE_MAX_SEG 1054 /* Max TSO size we will send */
238#define TCP_RACK_PACE_ALWAYS 1055 /* Use the always pace method */
239/* unused 1056 */
240#define TCP_RACK_PRR_SENDALOT 1057 /* Allow PRR to send more than one seg */
241#define TCP_RACK_MIN_TO 1058 /* Minimum time between rack t-o's in ms */
242/* unused 1059 */
243#define TCP_RACK_EARLY_SEG 1060 /* If early recovery max segments */
244#define TCP_RACK_REORD_THRESH 1061 /* RACK reorder threshold (shift amount) */
245#define TCP_RACK_REORD_FADE 1062 /* Does reordering fade after ms time */
246#define TCP_RACK_TLP_THRESH 1063 /* RACK TLP theshold i.e. srtt+(srtt/N) */
247#define TCP_RACK_PKT_DELAY 1064 /* RACK added ms i.e. rack-rtt + reord + N */
248/* unused 1065 */
249/* unused 1066 */
250#define TCP_BBR_IWINTSO 1067 /* Initial TSO window for BBRs first sends */
251/* unused 1068 */
252#define TCP_BBR_STARTUP_PG 1069 /* Startup pacing gain */
253#define TCP_BBR_DRAIN_PG 1070 /* Drain pacing gain */
254/* unused 1071 */
255#define TCP_BBR_PROBE_RTT_INT 1072 /* How long in useconds between probe-rtt */
256/* unused 1073 */
257#define TCP_BBR_STARTUP_LOSS_EXIT 1074 /* Do we exit a loss during startup if not 20% incr */
258/* unused 1075 */
259#define TCP_BBR_TSLIMITS 1076 /* Do we use experimental Timestamp limiting for our algo */
260#define TCP_BBR_PACE_OH 1077 /* pacing overhead setting */
261/* unused 1078 */
262#define TCP_BBR_USEDEL_RATE 1079 /* Enable use of delivery rate for loss recovery */
263#define TCP_BBR_MIN_RTO 1080 /* Min RTO in milliseconds */
264#define TCP_BBR_MAX_RTO 1081 /* Max RTO in milliseconds */
265/* unused 1082 */
266#define TCP_BBR_ALGORITHM 1083 /* What measurement algo does BBR use netflix=0, google=1 */
267/* unused 1084 */
268/* unused 1085 */
269#define TCP_BBR_PACE_PER_SEC 1086
270#define TCP_BBR_PACE_DEL_TAR 1087
271#define TCP_BBR_PACE_SEG_MAX 1088
272#define TCP_BBR_PACE_SEG_MIN 1089
273#define TCP_BBR_PACE_CROSS 1090
274/* unused 1091 */
275/* unused 1092 */
276/* unused 1093 */
277/* unused 1094 */
278#define TCP_RACK_TLP_USE 1095
279#define TCP_BBR_TMR_PACE_OH 1096 /* ??? */
280#define TCP_RACK_DO_DETECTION 1097 /* Recycle of extra gain for rack, attack detection */
281#define TCP_BBR_RACK_RTT_USE 1098 /* what RTT should we use 0, 1, or 2? */
282#define TCP_BBR_RETRAN_WTSO 1099
283#define TCP_DATA_AFTER_CLOSE 1100
284#define TCP_BBR_PROBE_RTT_GAIN 1101
285#define TCP_BBR_PROBE_RTT_LEN 1102
286#define TCP_BBR_SEND_IWND_IN_TSO 1103 /* Do we burst out whole iwin size chunks at start? */
287#define TCP_BBR_USE_RACK_RR 1104 /* Do we use the rack rapid recovery for pacing rxt's */
288#define TCP_BBR_USE_RACK_CHEAT TCP_BBR_USE_RACK_RR /* Compat. */
289#define TCP_BBR_HDWR_PACE 1105 /* Enable/disable hardware pacing */
290#define TCP_BBR_UTTER_MAX_TSO 1106 /* Do we enforce an utter max TSO size */
291#define TCP_BBR_EXTRA_STATE 1107 /* Special exit-persist catch up */
292#define TCP_BBR_FLOOR_MIN_TSO 1108 /* The min tso size */
293#define TCP_BBR_MIN_TOPACEOUT 1109 /* Do we suspend pacing until */
294#define TCP_BBR_TSTMP_RAISES 1110 /* Can a timestamp measurement raise the b/w */
295#define TCP_BBR_POLICER_DETECT 1111 /* Turn on/off google mode policer detection */
296#define TCP_BBR_RACK_INIT_RATE 1112 /* Set an initial pacing rate for when we have no b/w in kbits per sec */
297#define TCP_RACK_RR_CONF 1113 /* Rack rapid recovery configuration control*/
298#define TCP_RACK_GP_INCREASE_CA 1114 /* GP increase for Congestion Avoidance */
299#define TCP_RACK_GP_INCREASE_SS 1115 /* GP increase for Slow Start */
300#define TCP_RACK_GP_INCREASE_REC 1116 /* GP increase for Recovery */
301#define TCP_RACK_FORCE_MSEG 1117 /* Override to use the user set max-seg value */
302#define TCP_RACK_PACE_RATE_CA 1118 /* Pacing rate for Congestion Avoidance */
303#define TCP_RACK_PACE_RATE_SS 1119 /* Pacing rate for Slow Start */
304#define TCP_RACK_PACE_RATE_REC 1120 /* Pacing rate for Recovery */
305#define TCP_NO_PRR 1122 /* If pacing, don't use prr */
306#define TCP_RACK_NONRXT_CFG_RATE 1123 /* In recovery does a non-rxt use the cfg rate */
307#define TCP_SHARED_CWND_ENABLE 1124 /* Use a shared cwnd if allowed */
308#define TCP_TIMELY_DYN_ADJ 1125 /* Do we attempt dynamic multipler adjustment with timely. */
309#define TCP_RACK_NO_PUSH_AT_MAX 1126 /* For timely do not push if we are over max rtt */
310#define TCP_RACK_PACE_TO_FILL 1127 /* If we are not in recovery, always pace to fill the cwnd in 1 RTT */
311#define TCP_SHARED_CWND_TIME_LIMIT 1128 /* we should limit to low time values the scwnd life */
312#define TCP_RACK_PROFILE 1129 /* Select a profile that sets multiple options */
313#define TCP_HDWR_RATE_CAP 1130 /* Allow hardware rates to cap pacing rate */
314#define TCP_PACING_RATE_CAP 1131 /* Highest rate allowed in pacing in bytes per second (uint64_t) */
315#define TCP_HDWR_UP_ONLY 1132 /* Allow the pacing rate to climb but not descend (with the exception of fill-cw */
316#define TCP_RACK_ABC_VAL 1133 /* Set a local ABC value different then the system default */
317#define TCP_REC_ABC_VAL 1134 /* Do we use the ABC value for recovery or the override one from sysctl */
318#define TCP_RACK_MEASURE_CNT 1135 /* How many measurements are required in GP pacing */
319#define TCP_DEFER_OPTIONS 1136 /* Defer options until the proper number of measurements occur, does not defer TCP_RACK_MEASURE_CNT */
320/* unused 1137 */
321#define TCP_RACK_PACING_BETA 1138 /* Changing the beta for pacing */
322#define TCP_RACK_PACING_BETA_ECN 1139 /* Changing the beta for ecn with pacing */
323#define TCP_RACK_TIMER_SLOP 1140 /* Set or get the timer slop used */
324#define TCP_RACK_DSACK_OPT 1141 /* How do we setup rack timer DSACK options bit 1/2 */
325#define TCP_RACK_ENABLE_HYSTART 1142 /* Do we allow hystart in the CC modules */
326#define TCP_RACK_SET_RXT_OPTIONS 1143 /* Set the bits in the retransmit options */
327#define TCP_RACK_HI_BETA 1144 /* Turn on/off high beta */
328#define TCP_RACK_SPLIT_LIMIT 1145 /* Set a split limit for split allocations */
329#define TCP_RACK_PACING_DIVISOR 1146 /* Pacing divisor given to rate-limit code for burst sizing */
330#define TCP_RACK_PACE_MIN_SEG 1147 /* Pacing min seg size rack will use */
331#define TCP_RACK_DGP_IN_REC 1148 /* Do we use full DGP in recovery? */
332/* unused 1149 */
333#define TCP_HYBRID_PACING 1150 /* Hybrid pacing enablement */
334#define TCP_PACING_DND 1151 /* When pacing with rr_config=3 can sacks disturb us */
335#define TCP_SS_EEXIT 1152 /* Do we do early exit from slowtart if no b/w growth */
336#define TCP_DGP_UPPER_BOUNDS 1153 /* SS and CA upper bound in percentage */
337#define TCP_NO_TIMELY 1154 /* Disable/enable Timely */
338#define TCP_HONOR_HPTS_MIN 1155 /* Do we honor hpts min to */
339#define TCP_REC_IS_DYN 1156 /* Do we allow timely to change recovery multiplier? */
340#define TCP_SIDECHAN_DIS 1157 /* Disable/enable the side-channel */
341#define TCP_FILLCW_RATE_CAP 1158 /* Set a cap for DGP's fillcw */
342/* unused 1159 */
343#define TCP_STACK_SPEC_INFO 1160 /* Get stack specific information (if present) */
344#define RACK_CSPR_IS_FCC 1161
345#define TCP_GP_USE_LTBW 1162 /* how we use lt_bw 0=not, 1=min, 2=max */
346
329347
330348/* Start of reserved space for third-party user-settable options. */
331349#define TCP_VENDOR SO_VENDOR
......@@ -436,8 +454,9 @@ struct tcp_info {
436454 u_int32_t tcpi_rcv_adv; /* Peer advertised window */
437455 u_int32_t tcpi_dupacks; /* Consecutive dup ACKs recvd */
438456
457 u_int32_t tcpi_rttmin; /* Min observed RTT */
439458 /* Padding to grow without breaking ABI. */
440 u_int32_t __tcpi_pad[10]; /* Padding. */
459 u_int32_t __tcpi_pad[14]; /* Padding. */
441460};
442461
443462/*
......@@ -449,9 +468,23 @@ struct tcp_fastopen {
449468 int enable;
450469 uint8_t psk[TCP_FASTOPEN_PSK_LEN];
451470};
452#endif
471
453472#define TCP_FUNCTION_NAME_LEN_MAX 32
454473
474struct stack_specific_info {
475 char stack_name[TCP_FUNCTION_NAME_LEN_MAX];
476 uint64_t policer_last_bw; /* Only valid if detection enabled and policer detected */
477 uint64_t bytes_transmitted;
478 uint64_t bytes_retransmitted;
479 uint32_t policer_detection_enabled: 1,
480 policer_detected : 1, /* transport thinks a policer is on path */
481 highly_buffered : 1, /* transport considers the path highly buffered */
482 spare : 29;
483 uint32_t policer_bucket_size; /* Only valid if detection enabled and policer detected */
484 uint32_t current_round;
485 uint32_t _rack_i_pad[18];
486};
487
455488struct tcp_function_set {
456489 char function_set_name[TCP_FUNCTION_NAME_LEN_MAX];
457490 uint32_t pcbcnt;
......@@ -477,6 +510,7 @@ struct tcp_snd_req {
477510 uint64_t start;
478511 uint64_t end;
479512 uint32_t flags;
513 uint32_t playout_ms;
480514};
481515
482516union tcp_log_userdata {
......@@ -507,9 +541,12 @@ struct tcp_log_user {
507541#define TCP_HYBRID_PACING_H_MS 0x0008 /* A client hint for maxseg is present */
508542#define TCP_HYBRID_PACING_ENABLE 0x0010 /* We are enabling hybrid pacing else disable */
509543#define TCP_HYBRID_PACING_S_MSS 0x0020 /* Clent wants us to set the mss overriding gp est in CU */
510#define TCP_HYBRID_PACING_SETMSS 0x1000 /* Internal flag that tellsus we set the mss on this entry */
544#define TCP_HAS_PLAYOUT_MS 0x0040 /* The client included the chunk playout milliseconds: deprecate */
545/* the below are internal only flags */
546#define TCP_HYBRID_PACING_USER_MASK 0x0FFF /* Non-internal flags mask */
547#define TCP_HYBRID_PACING_SETMSS 0x1000 /* Internal flag that tells us we set the mss on this entry */
511548#define TCP_HYBRID_PACING_WASSET 0x2000 /* We init to this to know if a hybrid command was issued */
512
549#define TCP_HYBRID_PACING_SENDTIME 0x4000 /* Duplicate tm to last, use sendtime for catch up mode */
513550
514551struct tcp_hybrid_req {
515552 struct tcp_snd_req req;
......@@ -536,4 +573,5 @@ struct tcp_hybrid_req {
536573#define TCP_REUSPORT_LB_NUMA_NODOM (-2) /* remove numa binding */
537574#define TCP_REUSPORT_LB_NUMA_CURDOM (-1) /* bind to current domain */
538575
576#endif /* __BSD_VISIBLE */
539577#endif /* !_NETINET_TCP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_ecn.h+2-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcp_ecn.h 8.4 (Berkeley) 5/24/95
3230 */
3331
3432#ifndef _NETINET_TCP_ECN_H_
......@@ -40,6 +38,8 @@
4038#include <netinet/tcp_var.h>
4139#include <netinet/tcp_syncache.h>
4240
41#define TH_ACE_SHIFT 6
42
4343void tcp_ecn_input_syn_sent(struct tcpcb *, uint16_t, int);
4444void tcp_ecn_input_parallel_syn(struct tcpcb *, uint16_t, int);
4545int tcp_ecn_input_segment(struct tcpcb *, uint16_t, int, int, int);
......@@ -48,7 +48,6 @@ int tcp_ecn_output_established(struct tcpcb *, uint16_t *, int, bool);
4848void tcp_ecn_syncache_socket(struct tcpcb *, struct syncache *);
4949int tcp_ecn_syncache_add(uint16_t, int);
5050uint16_t tcp_ecn_syncache_respond(uint16_t, struct syncache *);
51int tcp_ecn_get_ace(uint16_t);
5251
5352#endif /* _KERNEL */
5453
lib/libc/include/generic-freebsd/netinet/tcp_fastopen.h+1
......@@ -79,6 +79,7 @@ struct tcp_fastopen_ccache {
7979 uint32_t secret;
8080};
8181
82struct tcpcb;
8283#ifdef TCP_RFC7413
8384void tcp_fastopen_init(void);
8485void tcp_fastopen_destroy(void);
lib/libc/include/generic-freebsd/netinet/tcp_fsm.h-2
......@@ -28,8 +28,6 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93
3331 */
3432
3533#ifndef _NETINET_TCP_FSM_H_
lib/libc/include/generic-freebsd/netinet/tcp_hpts.h+46-91
......@@ -26,14 +26,38 @@
2626#ifndef __tcp_hpts_h__
2727#define __tcp_hpts_h__
2828
29/* Number of useconds in a hpts tick */
30#define HPTS_TICKS_PER_SLOT 10
29/* Number of useconds represented by an hpts slot */
30#define HPTS_USECS_PER_SLOT 10
3131#define HPTS_MS_TO_SLOTS(x) ((x * 100) + 1)
3232#define HPTS_USEC_TO_SLOTS(x) ((x+9) /10)
3333#define HPTS_USEC_IN_SEC 1000000
3434#define HPTS_MSEC_IN_SEC 1000
3535#define HPTS_USEC_IN_MSEC 1000
3636
37static inline uint32_t
38tcp_tv_to_hpts_slot(const struct timeval *sv)
39{
40 return ((sv->tv_sec * 100000) + (sv->tv_usec / HPTS_USECS_PER_SLOT));
41}
42
43static inline uint32_t
44tcp_tv_to_usec(const struct timeval *sv)
45{
46 return ((uint32_t) ((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec));
47}
48
49static inline uint32_t
50tcp_tv_to_msec(const struct timeval *sv)
51{
52 return ((uint32_t) ((sv->tv_sec * HPTS_MSEC_IN_SEC) + (sv->tv_usec/HPTS_USEC_IN_MSEC)));
53}
54
55static inline uint64_t
56tcp_tv_to_lusec(const struct timeval *sv)
57{
58 return ((uint64_t)((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec));
59}
60
3761struct hpts_diag {
3862 uint32_t p_hpts_active; /* bbr->flex7 x */
3963 uint32_t p_nxt_slot; /* bbr->flex1 x */
......@@ -66,52 +90,16 @@ struct hpts_diag {
6690#define PACE_PKT_OUTPUT 0x40 /* Output Packets being paced */
6791#define PACE_TMR_MASK (PACE_TMR_KEEP|PACE_TMR_PERSIT|PACE_TMR_RXT|PACE_TMR_TLP|PACE_TMR_RACK|PACE_TMR_DELACK)
6892
69#define DEFAULT_CONNECTION_THESHOLD 100
93#ifdef _KERNEL
7094
7195/*
72 * When using the hpts, a TCP stack must make sure
73 * that once a INP_DROPPED flag is applied to a INP
74 * that it does not expect tcp_output() to ever be
75 * called by the hpts. The hpts will *not* call
76 * any output (or input) functions on a TCB that
77 * is in the DROPPED state.
78 *
79 * This implies final ACK's and RST's that might
80 * be sent when a TCB is still around must be
81 * sent from a routine like tcp_respond().
82 */
83#define LOWEST_SLEEP_ALLOWED 50
84#define DEFAULT_MIN_SLEEP 250 /* How many usec's is default for hpts sleep
85 * this determines min granularity of the
86 * hpts. If 1, granularity is 10useconds at
87 * the cost of more CPU (context switching).
88 * Note do not set this to 0.
89 */
90#define DYNAMIC_MIN_SLEEP DEFAULT_MIN_SLEEP
91#define DYNAMIC_MAX_SLEEP 5000 /* 5ms */
92
93/* Thresholds for raising/lowering sleep */
94#define TICKS_INDICATE_MORE_SLEEP 100 /* This would be 1ms */
95#define TICKS_INDICATE_LESS_SLEEP 1000 /* This would indicate 10ms */
96/**
97 *
98 * Dynamic adjustment of sleeping times is done in "new" mode
99 * where we are depending on syscall returns and lro returns
100 * to push hpts forward mainly and the timer is only a backstop.
101 *
102 * When we are in the "new" mode i.e. conn_cnt > conn_cnt_thresh
103 * then we do a dynamic adjustment on the time we sleep.
104 * Our threshold is if the lateness of the first client served (in ticks) is
105 * greater than or equal too ticks_indicate_more_sleep (10ms
106 * or 10000 ticks). If we were that late, the actual sleep time
107 * is adjusted down by 50%. If the ticks_ran is less than
108 * ticks_indicate_more_sleep (100 ticks or 1000usecs).
109 *
110 */
96 * The following are the definitions for the kernel HPTS interface for managing
97 * the HPTS ring and the TCBs on it.
98*/
11199
112#ifdef _KERNEL
113100void tcp_hpts_init(struct tcpcb *);
114101void tcp_hpts_remove(struct tcpcb *);
102
115103static inline bool
116104tcp_in_hpts(struct tcpcb *tp)
117105{
......@@ -149,57 +137,17 @@ uint32_t tcp_hpts_insert_diag(struct tcpcb *tp, uint32_t slot, int32_t line,
149137#define tcp_hpts_insert(inp, slot) \
150138 tcp_hpts_insert_diag((inp), (slot), __LINE__, NULL)
151139
152void __tcp_set_hpts(struct tcpcb *tp, int32_t line);
153#define tcp_set_hpts(a) __tcp_set_hpts(a, __LINE__)
154
155void tcp_set_inp_to_drop(struct inpcb *inp, uint16_t reason);
156
157void tcp_lro_hpts_init(void);
158void tcp_lro_hpts_uninit(void);
159
160extern int32_t tcp_min_hptsi_time;
161
162#endif /* _KERNEL */
163
164/*
165 * The following functions should also be available
166 * to userspace as well.
167 */
168static __inline uint32_t
169tcp_tv_to_hptstick(const struct timeval *sv)
170{
171 return ((sv->tv_sec * 100000) + (sv->tv_usec / HPTS_TICKS_PER_SLOT));
172}
173
174static __inline uint32_t
175tcp_tv_to_usectick(const struct timeval *sv)
176{
177 return ((uint32_t) ((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec));
178}
179
180static __inline uint32_t
181tcp_tv_to_mssectick(const struct timeval *sv)
182{
183 return ((uint32_t) ((sv->tv_sec * HPTS_MSEC_IN_SEC) + (sv->tv_usec/HPTS_USEC_IN_MSEC)));
184}
185
186static __inline uint64_t
187tcp_tv_to_lusectick(const struct timeval *sv)
188{
189 return ((uint64_t)((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec));
190}
191
192#ifdef _KERNEL
140void tcp_set_hpts(struct tcpcb *tp);
193141
194142extern int32_t tcp_min_hptsi_time;
195143
196144static inline int32_t
197145get_hpts_min_sleep_time(void)
198146{
199 return (tcp_min_hptsi_time + HPTS_TICKS_PER_SLOT);
147 return (tcp_min_hptsi_time + HPTS_USECS_PER_SLOT);
200148}
201149
202static __inline uint32_t
150static inline uint32_t
203151tcp_gethptstick(struct timeval *sv)
204152{
205153 struct timeval tv;
......@@ -207,10 +155,10 @@ tcp_gethptstick(struct timeval *sv)
207155 if (sv == NULL)
208156 sv = &tv;
209157 microuptime(sv);
210 return (tcp_tv_to_hptstick(sv));
158 return (tcp_tv_to_hpts_slot(sv));
211159}
212160
213static __inline uint64_t
161static inline uint64_t
214162tcp_get_u64_usecs(struct timeval *tv)
215163{
216164 struct timeval tvd;
......@@ -218,10 +166,10 @@ tcp_get_u64_usecs(struct timeval *tv)
218166 if (tv == NULL)
219167 tv = &tvd;
220168 microuptime(tv);
221 return (tcp_tv_to_lusectick(tv));
169 return (tcp_tv_to_lusec(tv));
222170}
223171
224static __inline uint32_t
172static inline uint32_t
225173tcp_get_usecs(struct timeval *tv)
226174{
227175 struct timeval tvd;
......@@ -229,8 +177,15 @@ tcp_get_usecs(struct timeval *tv)
229177 if (tv == NULL)
230178 tv = &tvd;
231179 microuptime(tv);
232 return (tcp_tv_to_usectick(tv));
180 return (tcp_tv_to_usec(tv));
233181}
234182
183/*
184 * LRO HPTS initialization and uninitialization, only for internal use by the
185 * HPTS code.
186 */
187void tcp_lro_hpts_init(void);
188void tcp_lro_hpts_uninit(void);
189
235190#endif /* _KERNEL */
236191#endif /* __tcp_hpts_h__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_log_buf.h+22-26
......@@ -60,14 +60,6 @@ struct tcp_log_verbose
6060 uint8_t _pad[4];
6161} ALIGN_TCP_LOG;
6262
63/* Internal RACK state variables. */
64struct tcp_log_rack
65{
66 uint32_t tlr_rack_rtt; /* rc_rack_rtt */
67 uint8_t tlr_state; /* Internal RACK state */
68 uint8_t _pad[3]; /* Padding */
69};
70
7163struct tcp_log_bbr {
7264 uint64_t cur_del_rate;
7365 uint64_t delRate;
......@@ -126,7 +118,6 @@ struct tcp_log_sendfile {
126118 */
127119union tcp_log_stackspecific
128120{
129 struct tcp_log_rack u_rack;
130121 struct tcp_log_bbr u_bbr;
131122 struct tcp_log_sendfile u_sf;
132123 struct tcp_log_raw u_raw; /* "raw" log access */
......@@ -185,7 +176,6 @@ struct tcp_log_buffer
185176 uint8_t _pad[3]; /* Padding */
186177 /* Per-stack info */
187178 union tcp_log_stackspecific tlb_stackinfo;
188#define tlb_rack tlb_stackinfo.u_rack
189179
190180 /* The packet */
191181 uint32_t tlb_len; /* The packet's data length */
......@@ -201,14 +191,14 @@ enum tcp_log_events {
201191 TCP_LOG_OUT, /* Transmit (without other event) 2 */
202192 TCP_LOG_RTO, /* Retransmit timeout 3 */
203193 TCP_LOG_SB_WAKE, /* Awaken socket buffer 4 */
204 TCP_LOG_BAD_RETRAN, /* Detected bad retransmission 5 */
194 TCP_UNUSED_5, /* Detected bad retransmission 5 */
205195 TCP_LOG_PRR, /* Doing PRR 6 */
206 TCP_LOG_REORDER, /* Detected reorder 7 */
196 TCP_UNUSED_7, /* Detected reorder 7 */
207197 TCP_LOG_HPTS, /* Hpts sending a packet 8 */
208198 BBR_LOG_BBRUPD, /* We updated BBR info 9 */
209199 BBR_LOG_BBRSND, /* We did a slot calculation and sending is done 10 */
210200 BBR_LOG_ACKCLEAR, /* A ack clears all outstanding 11 */
211 BBR_LOG_INQUEUE, /* The tcb had a packet input to it 12 */
201 TCP_UNUSED_12, /* The tcb had a packet input to it 12 */
212202 BBR_LOG_TIMERSTAR, /* Start a timer 13 */
213203 BBR_LOG_TIMERCANC, /* Cancel a timer 14 */
214204 BBR_LOG_ENTREC, /* Entered recovery 15 */
......@@ -245,7 +235,7 @@ enum tcp_log_events {
245235 BBR_LOG_REDUCE, /* old bbr log reduce for 4.1 and earlier 46*/
246236 TCP_LOG_RTT, /* A rtt (in useconds) is being sampled and applied to the srtt algo 47 */
247237 BBR_LOG_SETTINGS_CHG, /* Settings changed for loss response 48 */
248 BBR_LOG_SRTT_GAIN_EVENT, /* SRTT gaining -- now not used 49 */
238 TCP_UNUSED_49, /* SRTT gaining -- now not used 49 */
249239 TCP_LOG_REASS, /* Reassembly buffer logging 50 */
250240 TCP_HDWR_PACE_SIZE, /* TCP pacing size set (rl and rack uses this) 51 */
251241 BBR_LOG_HDWR_PACE, /* TCP Hardware pacing log 52 */
......@@ -253,9 +243,9 @@ enum tcp_log_events {
253243 TCP_LOG_CONNEND, /* End of connection 54 */
254244 TCP_LOG_LRO, /* LRO entry 55 */
255245 TCP_SACK_FILTER_RES, /* Results of SACK Filter 56 */
256 TCP_SAD_DETECT, /* Sack Attack Detection 57 */
246 TCP_UNUSED_57, /* Sack Attack Detection 57 */
257247 TCP_TIMELY_WORK, /* Logs regarding Timely CC tweaks 58 */
258 TCP_LOG_USER_EVENT, /* User space event data 59 */
248 TCP_UNUSED_59, /* User space event data 59 */
259249 TCP_LOG_SENDFILE, /* sendfile() logging for TCP connections 60 */
260250 TCP_LOG_REQ_T, /* logging of request tracking 61 */
261251 TCP_LOG_ACCOUNTING, /* Log of TCP Accounting data 62 */
......@@ -267,7 +257,9 @@ enum tcp_log_events {
267257 TCP_RACK_TP_TRIGGERED, /* A rack tracepoint is triggered 68 */
268258 TCP_HYBRID_PACING_LOG, /* Hybrid pacing log 69 */
269259 TCP_LOG_PRU, /* TCP protocol user request 70 */
270 TCP_LOG_END /* End (keep at end) 71 */
260 TCP_UNUSED_71, /* old TCP Policer detectionn, not used 71 */
261 TCP_PCM_MEASURE, /* TCP Path Capacity Measurement 72 */
262 TCP_LOG_END /* End (keep at end) 73 */
271263};
272264
273265enum tcp_log_states {
......@@ -371,10 +363,11 @@ struct tcp_log_dev_log_queue {
371363#define TCP_TP_COLLAPSED_RXT 0x00000004 /* When we actually retransmit a collapsed window rsm */
372364#define TCP_TP_REQ_LOG_FAIL 0x00000005 /* We tried to allocate a Request log but had no space */
373365#define TCP_TP_RESET_RCV 0x00000006 /* Triggers when we receive a RST */
374#define TCP_TP_EXCESS_RXT 0x00000007 /* When we get excess RXT's clamping the cwnd */
366#define TCP_TP_POLICER_DET 0x00000007 /* When we detect a policer */
367#define TCP_TP_EXCESS_RXT TCP_TP_POLICER_DET /* alias */
375368#define TCP_TP_SAD_TRIGGERED 0x00000008 /* Sack Attack Detection triggers */
376
377369#define TCP_TP_SAD_SUSPECT 0x0000000a /* A sack has supicious information in it */
370#define TCP_TP_PACED_BOTTOM 0x0000000b /* We have paced at the bottom */
378371
379372#ifdef _KERNEL
380373
......@@ -384,12 +377,12 @@ extern int32_t tcp_trace_point_count;
384377
385378/*
386379 * Returns true if any sort of BB logging is enabled,
387 * commonly used throughout the codebase.
380 * commonly used throughout the codebase.
388381 */
389382static inline int
390383tcp_bblogging_on(struct tcpcb *tp)
391384{
392 if (tp->_t_logstate <= TCP_LOG_STATE_OFF)
385 if (tp->_t_logstate <= TCP_LOG_STATE_OFF)
393386 return (0);
394387 if (tp->_t_logstate == TCP_LOG_VIA_BBPOINTS)
395388 return (0);
......@@ -434,7 +427,7 @@ tcp_set_bblog_state(struct tcpcb *tp, uint8_t ls, uint8_t bbpoint)
434427 }
435428}
436429
437static inline uint32_t
430static inline uint32_t
438431tcp_get_bblog_state(struct tcpcb *tp)
439432{
440433 return (tp->_t_logstate);
......@@ -546,12 +539,12 @@ struct tcpcb;
546539 NULL, NULL, 0, NULL); \
547540 } while (0)
548541#endif /* TCP_LOG_FORCEVERBOSE */
542/* Assumes/requires the caller has already checked tcp_bblogging_on(tp). */
549543#define TCP_LOG_EVENTP(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder, tv) \
550544 do { \
551 if (tcp_bblogging_on(tp)) \
552 tcp_log_event(tp, th, rxbuf, txbuf, eventid, \
553 errornum, len, stackinfo, th_hostorder, \
554 NULL, NULL, 0, tv); \
545 KASSERT(tcp_bblogging_on(tp), ("bblogging is off")); \
546 tcp_log_event(tp, th, rxbuf, txbuf, eventid, errornum, len, \
547 stackinfo, th_hostorder, NULL, NULL, 0, tv); \
555548 } while (0)
556549
557550#ifdef TCP_BLACKBOX
......@@ -577,6 +570,9 @@ void tcp_log_flowend(struct tcpcb *tp);
577570void tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes,
578571 int flags);
579572int tcp_log_apply_ratio(struct tcpcb *tp, int ratio);
573#ifdef DDB
574void db_print_bblog_entries(struct tcp_log_stailq *log_entries, int indent);
575#endif
580576#else /* !TCP_BLACKBOX */
581577#define tcp_log_verbose (false)
582578
lib/libc/include/generic-freebsd/netinet/tcp_offload.h+2
......@@ -38,6 +38,8 @@
3838
3939extern int registered_toedevs;
4040
41struct tcpcb;
42
4143int tcp_offload_connect(struct socket *, struct sockaddr *);
4244void tcp_offload_listen_start(struct tcpcb *);
4345void tcp_offload_listen_stop(struct tcpcb *);
lib/libc/include/generic-freebsd/netinet/tcp_pcap.h deleted-39
......@@ -1,39 +0,0 @@
1/*-
2 * Copyright (c) 2015
3 * Jonathan Looney. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _NETINET_TCP_PCAP_H_
28#define _NETINET_TCP_PCAP_H_
29
30void tcp_pcap_init(void);
31void tcp_pcap_add(struct tcphdr *th, struct mbuf *m, struct mbufq *queue);
32void tcp_pcap_drain(struct mbufq *queue);
33void tcp_pcap_tcpcb_init(struct tcpcb *tp);
34void tcp_pcap_set_sock_max(struct mbufq *queue, int newval);
35int tcp_pcap_get_sock_max(struct mbufq *queue);
36
37extern int tcp_pcap_aggressive_free;
38
39#endif /* _NETINET_TCP_PCAP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_ratelimit.h+9
......@@ -94,6 +94,8 @@ CK_LIST_HEAD(head_tcp_rate_set, tcp_rate_set);
9494#ifndef ETHERNET_SEGMENT_SIZE
9595#define ETHERNET_SEGMENT_SIZE 1514
9696#endif
97struct tcpcb;
98
9799#ifdef RATELIMIT
98100#define DETAILED_RATELIMIT_SYSCTL 1 /*
99101 * Undefine this if you don't want
......@@ -131,6 +133,9 @@ tcp_get_pacing_burst_size_w_divisor(struct tcpcb *tp, uint64_t bw, uint32_t segs
131133void
132134tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte);
133135
136void
137tcp_rl_release_ifnet(struct ifnet *ifp);
138
134139#else
135140static inline const struct tcp_hwrate_limit_table *
136141tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *ifp,
......@@ -218,6 +223,10 @@ tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte)
218223{
219224}
220225
226static inline void
227tcp_rl_release_ifnet(struct ifnet *ifp)
228{
229}
221230#endif
222231
223232/*
lib/libc/include/generic-freebsd/netinet/tcp_seq.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcp_seq.h 8.3 (Berkeley) 6/21/95
3230 */
3331
3432#ifndef _NETINET_TCP_SEQ_H_
lib/libc/include/generic-freebsd/netinet/tcp_stacks/rack_bbr_common.h+9-14
......@@ -89,30 +89,25 @@ int ctf_do_queued_segments(struct tcpcb *tp, int have_pkt);
8989uint32_t ctf_outstanding(struct tcpcb *tp);
9090uint32_t ctf_flight_size(struct tcpcb *tp, uint32_t rc_sacked);
9191int
92_ctf_drop_checks(struct tcpopt *to, struct mbuf *m, struct tcphdr *th,
92ctf_drop_checks(struct tcpopt *to, struct mbuf *m, struct tcphdr *th,
9393 struct tcpcb *tp, int32_t *tlenp,
94 int32_t *thf, int32_t *drop_hdrlen, int32_t *ret_val,
95 uint32_t *ts, uint32_t *cnt);
96void ctf_ack_war_checks(struct tcpcb *tp, uint32_t *ts, uint32_t *cnt);
97#define ctf_drop_checks(a, b, c, d, e, f, g, h) _ctf_drop_checks(a, b, c, d, e, f, g, h, NULL, NULL)
94 int32_t *thf, int32_t *drop_hdrlen, int32_t *ret_val);
95void ctf_ack_war_checks(struct tcpcb *tp);
9896
9997void
100__ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp,
98ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp,
10199 struct tcphdr *th, int32_t thflags, int32_t tlen,
102 int32_t *ret_val, uint32_t *ts, uint32_t *cnt);
103
104#define ctf_do_dropafterack(a, b, c, d, e, f) __ctf_do_dropafterack(a, b, c, d, e, f, NULL, NULL)
100 int32_t *ret_val);
105101
106102void
107103ctf_do_dropwithreset(struct mbuf *m, struct tcpcb *tp,
108 struct tcphdr *th, int32_t rstreason, int32_t tlen);
104 struct tcphdr *th, int32_t tlen);
109105void
110106ctf_do_drop(struct mbuf *m, struct tcpcb *tp);
111107
112108int
113__ctf_process_rst(struct mbuf *m, struct tcphdr *th,
114 struct socket *so, struct tcpcb *tp, uint32_t *ts, uint32_t *cnt);
115#define ctf_process_rst(m, t, s, p) __ctf_process_rst(m, t, s, p, NULL, NULL)
109ctf_process_rst(struct mbuf *m, struct tcphdr *th,
110 struct socket *so, struct tcpcb *tp);
116111
117112void
118113ctf_challenge_ack(struct mbuf *m, struct tcphdr *th,
......@@ -130,7 +125,7 @@ ctf_calc_rwin(struct socket *so, struct tcpcb *tp);
130125
131126void
132127ctf_do_dropwithreset_conn(struct mbuf *m, struct tcpcb *tp, struct tcphdr *th,
133 int32_t rstreason, int32_t tlen);
128 int32_t tlen);
134129
135130uint32_t
136131ctf_fixed_maxseg(struct tcpcb *tp);
lib/libc/include/generic-freebsd/netinet/tcp_stacks/sack_filter.h+83-13
......@@ -25,19 +25,84 @@
2525 * SUCH DAMAGE.
2626 */
2727
28/*
29 * Seven entry's is carefully choosen to
30 * fit in one cache line. We can easily
31 * change this to 15 (but it gets very
32 * little extra filtering). To change it
33 * to be larger than 15 would require either
34 * sf_bits becoming a uint32_t and then you
35 * could go to 31.. or change it to a full
36 * bitstring.. It is really doubtful you
37 * will get much benefit beyond 7, in testing
38 * there was a small amount but very very small.
28/**
29 *
30 * The Sack filter is designed to do two functions, first it trys to reduce
31 * the processing of sacks. Consider that often times you get something like
32 *
33 * ack 1 (sack 100:200)
34 * ack 1 (sack 100:300)
35 * ack 1 (sack(100:400)
36 *
37 * You really want to process the 100:200 and then on the next sack process
38 * only 200:300 (the new data) and then finally on the third 300:400. The filter
39 * removes from your processing routines the already processed sack information so
40 * that after the filter completes you only have "new" sacks that you have not
41 * processed. This saves computation time so you do not need to worry about
42 * previously processed sack information.
43 *
44 * The second thing that the sack filter does is help protect against malicious
45 * attackers that are trying to attack any linked lists (or other data structures)
46 * that are used in sack processing. Consider an attacker sending in sacks for
47 * every other byte of data outstanding. This could in theory drastically split
48 * up any scoreboard you are maintaining and make you search through a very large
49 * linked list (or other structure) eating up CPU. If you split far enough and
50 * fracture your data structure enough you could potentially be crippled by a malicious
51 * peer. How the filter works here is it filters out sacks that are less than an MSS.
52 * We do this because generally a packet (aka MSS) should be kept whole. The only place
53 * we allow a smaller SACK is when the SACK touches the end of our socket buffer. This allows
54 * TLP to still work properly and yet protects us from splitting. The filter also only allows
55 * a set number of splits (defined in SACK_FILTER_BLOCKS). If more than that many sacks locations
56 * are being sent we discard additional ones until the earlier holes are filled up. The maximum
57 * the current filter can be is 15, which we have moved to since we want to be as generous as
58 * possible with allowing for loss. However, in previous testing of the filter it was found
59 * that there was very little benefit from moving from 7 to 15 sack points. Though at
60 * that previous set of tests, we would just discard earlier information in the filter. Now
61 * that we do not do that i.e. discard information and instead drop sack data we have raised
62 * the value to the max i.e. 15. If you want to expand beyond 15 one would have to either increase
63 * the size of the sf_bits to a uint32_t which could then get you a maximum of 31 splits or
64 * move to a true bitstring. If this is done however it further increases your risk to
65 * sack attacks, the bigger the number of splits (filter blocks) that are allowed
66 * the larger your processing arrays will grow as well as the filter.
67 *
68 * Note that this protection does not prevent an attacker from asking for a 20 byte
69 * MSS, that protection must be done elsewhere during the negotiation of the connection
70 * and is done now by just ignoring sack's from connections with too small of MSS which
71 * prevents sack from working and thus makes the connection less efficient but protects
72 * the system from harm.
73 *
74 * We may actually want to consider dropping the size of the array back to 7 to further
75 * protect the system which would be a more cautious approach.
76 *
77 * TCP Developer information:
78 *
79 * To use the sack filter its actually pretty simple. All you do is the normal sorting
80 * and sanity checks of your sacks but then after that you call out to sack_filter_blks()
81 * passing in the tcpcb, the sack-filter you are using (memory you have allocated) the
82 * pointer to the sackblk array and how many sorted valid blocks there are as well
83 * as what the new th_ack point is. The filter will return to you the number of
84 * blocks left after filtering. It will reshape the blocks based on the previous
85 * sacks you have received and processed. If sack_filter_blks() returns 0 then no
86 * new sack data is present to be processed.
87 *
88 * Whenever you reach the point of snd_una == snd_max, you should call sack_filter_clear with
89 * the snd_una point. You also need to call this if you invalidate your sack array for any
90 * reason (such as RTO's or MTU changes or some other thing that makes you think all
91 * data is now un-acknowledged). You can also pass in sack_filter_blks(tp, sf, NULL, 0, th_ack) to
92 * advance the cum-ack point. You can use sack_filter_blks_used(sf) to determine if you have filter blocks as
93 * well. So putting these two together, anytime the cum-ack moves forward you probably want to
94 * do:
95 * if (sack_filter_blks_used(sf))
96 * sack_filter_blks(tp, sf, NULL, 0, th_ack);
97 *
98 * If for some reason you have ran the sack-filter and something goes wrong (you can't allocate space
99 * for example to split your sack-array. You can "undo" the data within the sack filter by calling
100 * sack_filter_rject(sf, in) passing in the list of blocks to be "removed" from the sack-filter.
101 * You can see an example of this use in bbr.c though rack.c has never found it needed.
102 *
39103 */
40#define SACK_FILTER_BLOCKS 7
104
105#define SACK_FILTER_BLOCKS 15
41106
42107struct sack_filter {
43108 tcp_seq sf_ack;
......@@ -48,8 +113,13 @@ struct sack_filter {
48113};
49114#ifdef _KERNEL
50115void sack_filter_clear(struct sack_filter *sf, tcp_seq seq);
51int sack_filter_blks(struct sack_filter *sf, struct sackblk *in, int numblks,
116int sack_filter_blks(struct tcpcb *tp, struct sack_filter *sf, struct sackblk *in, int numblks,
52117 tcp_seq th_ack);
53118void sack_filter_reject(struct sack_filter *sf, struct sackblk *in);
119static inline uint8_t sack_filter_blks_used(struct sack_filter *sf)
120{
121 return (sf->sf_used);
122}
123
54124#endif
55125#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_stacks/tailq_hash.h+7-1
......@@ -13,10 +13,12 @@
1313#define MAX_ALLOWED_SEQ_RANGE (SEQ_BUCKET_SIZE * (MAX_HASH_ENTRIES-1))
1414
1515struct tailq_hash {
16 struct rack_head ht[MAX_HASH_ENTRIES];
1716 uint32_t min;
1817 uint32_t max;
1918 uint32_t count;
19 struct rack_sendmap *rsm_min;
20 struct rack_sendmap *rsm_max;
21 struct rack_head ht[MAX_HASH_ENTRIES];
2022};
2123
2224struct rack_sendmap *
......@@ -53,6 +55,10 @@ tqhash_init(struct tailq_hash *hs);
5355int
5456tqhash_trim(struct tailq_hash *hs, uint32_t th_ack);
5557
58void
59tqhash_update_end(struct tailq_hash *hs, struct rack_sendmap *rsm,
60 uint32_t th_ack);
61
5662
5763#define TQHASH_FOREACH(var, head) \
5864 for ((var) = tqhash_min((head)); \
lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_bbr.h-2
......@@ -347,8 +347,6 @@ struct bbr_log_sysctl_out {
347347/*
348348 * Locking for the rack control block.
349349 * a) Locked by INP_WLOCK
350 * b) Locked by the hpts-mutex
351 *
352350 */
353351#define BBR_STATE_STARTUP 0x01
354352#define BBR_STATE_DRAIN 0x02
lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_rack.h+89-66
......@@ -48,6 +48,8 @@
4848#define RACK_MERGED 0x080000/* The RSM was merged */
4949#define RACK_PMTU_CHG 0x100000/* The path mtu changed on this guy */
5050#define RACK_STRADDLE 0x200000/* The seq straddles the bucket line */
51#define RACK_WAS_LOST 0x400000/* Is the rsm considered lost */
52#define RACK_IS_PCM 0x800000/* A PCM measurement is being taken */
5153#define RACK_NUM_OF_RETRANS 3
5254
5355#define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */
......@@ -63,6 +65,7 @@ struct rack_sendmap {
6365 uint32_t r_rtr_bytes; /* How many bytes have been retransmitted */
6466 uint32_t r_flags : 24, /* Flags as defined above */
6567 r_rtr_cnt : 8; /* Retran count, index this -1 to get time */
68 uint32_t r_act_rxt_cnt; /* The actual total count of transmits */
6669 struct mbuf *m;
6770 uint32_t soff;
6871 uint32_t orig_m_len; /* The original mbuf len when we sent (can update) */
......@@ -174,6 +177,8 @@ struct rack_rtt_sample {
174177#define RACK_TO_FRM_PERSIST 5
175178#define RACK_TO_FRM_DELACK 6
176179
180#define RCV_PATH_RTT_MS 10 /* How many ms between recv path RTT's */
181
177182struct rack_opts_stats {
178183 uint64_t tcp_rack_tlp_reduce;
179184 uint64_t tcp_rack_pace_always;
......@@ -194,7 +199,6 @@ struct rack_opts_stats {
194199 uint64_t tcp_rack_min_pace_seg;
195200 uint64_t tcp_rack_pace_rate_ca;
196201 uint64_t tcp_rack_rr;
197 uint64_t tcp_rack_do_detection;
198202 uint64_t tcp_rack_rrr_no_conf_rate;
199203 uint64_t tcp_initial_rate;
200204 uint64_t tcp_initial_win;
......@@ -232,7 +236,7 @@ struct rack_opts_stats {
232236 uint64_t tcp_rack_rtt_use;
233237 uint64_t tcp_data_after_close;
234238 uint64_t tcp_defer_opt;
235 uint64_t tcp_rxt_clamp;
239 uint64_t tcp_pol_detect;
236240 uint64_t tcp_rack_beta;
237241 uint64_t tcp_rack_beta_ecn;
238242 uint64_t tcp_rack_timer_slop;
......@@ -242,6 +246,11 @@ struct rack_opts_stats {
242246 uint64_t tcp_rack_pacing_divisor;
243247 uint64_t tcp_rack_min_seg;
244248 uint64_t tcp_dgp_in_rec;
249 uint64_t tcp_notimely;
250 uint64_t tcp_honor_hpts;
251 uint64_t tcp_dyn_rec;
252 uint64_t tcp_fillcw_rate_cap;
253 uint64_t tcp_pol_mss;
245254};
246255
247256/* RTT shrink reasons */
......@@ -263,6 +272,9 @@ struct rack_opts_stats {
263272#define TLP_USE_TWO_TWO 3 /* Use 2.2 behavior */
264273#define RACK_MIN_BW 8000 /* 64kbps in Bps */
265274
275#define CCSP_DIS_MASK 0x0001
276#define HYBRID_DIS_MASK 0x0002
277
266278/* Rack quality indicators for GPUT measurements */
267279#define RACK_QUALITY_NONE 0 /* No quality stated */
268280#define RACK_QUALITY_HIGH 1 /* A normal measurement of a GP RTT */
......@@ -315,10 +327,9 @@ extern counter_u64_t rack_opts_arry[RACK_OPTS_SIZE];
315327/*
316328 * Locking for the rack control block.
317329 * a) Locked by INP_WLOCK
318 * b) Locked by the hpts-mutex
319 *
320330 */
321331#define RACK_GP_HIST 4 /* How much goodput history do we maintain? */
332#define RETRAN_CNT_SIZE 16
322333
323334#define RACK_NUM_FSB_DEBUG 16
324335#ifdef _KERNEL
......@@ -342,6 +353,26 @@ struct rack_fast_send_blk {
342353
343354struct tailq_hash;
344355
356struct rack_pcm_info {
357 /* Base send time and s/e filled in by rack_log_output */
358 uint64_t send_time;
359 uint32_t sseq;
360 uint32_t eseq;
361 /* Ack's fill in the rest of the data */
362 uint16_t cnt;
363 /* Maximum acks present */
364 uint16_t cnt_alloc;
365};
366
367#define RACK_DEFAULT_PCM_ARRAY 16
368
369struct rack_pcm_stats {
370 uint32_t sseq;
371 uint32_t eseq;
372 uint64_t ack_time;
373};
374
375
345376struct rack_control {
346377 /* Second cache line 0x40 from tcp_rack */
347378 struct tailq_hash *tqh; /* Tree of all segments Lock(a) */
......@@ -423,20 +454,14 @@ struct rack_control {
423454 uint16_t rack_per_of_gp_rec; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
424455 uint16_t rack_per_of_gp_probertt; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
425456 uint32_t rc_high_rwnd;
426 uint32_t ack_count;
427 uint32_t sack_count;
428 uint32_t sack_noextra_move;
429 uint32_t sack_moved_extra;
430457 struct rack_rtt_sample rack_rs;
431458 const struct tcp_hwrate_limit_table *crte;
432459 uint32_t rc_agg_early;
433460 uint32_t rc_agg_delayed;
434461 uint32_t rc_tlp_rxt_last_time;
435 uint32_t rc_saved_cwnd;
436462 uint64_t rc_gp_output_ts; /* chg*/
437463 uint64_t rc_gp_cumack_ts; /* chg*/
438464 struct timeval act_rcv_time;
439 struct timeval rc_last_time_decay; /* SAD time decay happened here */
440465 uint64_t gp_bw;
441466 uint64_t init_rate;
442467#ifdef NETFLIX_SHARED_CWND
......@@ -452,19 +477,29 @@ struct rack_control {
452477 struct tcp_sendfile_track *rc_last_sft;
453478 uint32_t lt_seq; /* Seq at start of lt_bw gauge */
454479 int32_t rc_rtt_diff; /* Timely style rtt diff of our gp_srtt */
455 uint64_t last_sndbytes;
456 uint64_t last_snd_rxt_bytes;
457 uint64_t rxt_threshold;
458480 uint64_t last_tmit_time_acked; /* Holds the last cumack point's last send time */
459 uint32_t last_rnd_rxt_clamped;
460 uint32_t num_of_clamps_applied;
461 uint32_t clamp_options;
462 uint32_t max_clamps;
481 /* Recovery stats */
482 uint64_t last_sendtime;
483
484 uint64_t last_gpest;
485 uint64_t last_tm_mark; /* Last tm mark used */
486 uint64_t fillcw_cap; /* B/W cap on fill cw */
487 struct rack_pcm_info pcm_i;
488 struct rack_pcm_stats *pcm_s;
489 uint32_t gp_gain_req; /* Percent off gp gain req */
490 uint32_t last_rnd_of_gp_rise;
491 uint32_t gp_rnd_thresh;
492 uint32_t ss_hi_fs;
493 uint32_t gate_to_fs;
494 uint32_t pcm_max_seg;
495 uint32_t last_pcm_round;
496 uint32_t pcm_idle_rounds;
463497
464498 uint32_t rc_gp_srtt; /* Current GP srtt */
465499 uint32_t rc_prev_gp_srtt; /* Previous RTT */
466500 uint32_t rc_entry_gp_rtt; /* Entry to PRTT gp-rtt */
467501 uint32_t rc_loss_at_start; /* At measurement window where was our lost value */
502 uint32_t rc_considered_lost; /* Count in recovery of non-retransmitted bytes considered lost */
468503
469504 uint32_t dsack_round_end; /* In a round of seeing a DSACK */
470505 uint32_t current_round; /* Starting at zero */
......@@ -491,22 +526,23 @@ struct rack_control {
491526 uint32_t rc_snd_max_at_rto; /* For non-sack when the RTO occurred what was snd-max */
492527 uint32_t rc_out_at_rto;
493528 int32_t rc_scw_index;
529 uint32_t max_reduction;
530 uint32_t side_chan_dis_mask; /* Bit mask of socket opt's disabled */
494531 uint32_t rc_tlp_threshold; /* Socket option value Lock(a) */
495532 uint32_t rc_last_timeout_snduna;
496533 uint32_t last_tlp_acked_start;
497534 uint32_t last_tlp_acked_end;
498 uint32_t challenge_ack_ts;
499 uint32_t challenge_ack_cnt;
500535 uint32_t rc_min_to; /* Socket option value Lock(a) */
501536 uint32_t rc_pkt_delay; /* Socket option value Lock(a) */
502537 uint32_t persist_lost_ends;
503 uint32_t ack_during_sd;
504 uint32_t input_pkt;
505 uint32_t saved_input_pkt;
506 uint32_t saved_rxt_clamp_val; /* The encoded value we used to setup clamping */
507 struct newreno rc_saved_beta; /*
508 * For newreno cc:
509 * rc_saved_cc are the values we have had
538 uint32_t cleared_app_ack_seq;
539 uint32_t last_rcv_tstmp_for_rtt;
540 uint32_t last_time_of_arm_rcv;
541 uint32_t rto_ssthresh;
542 uint32_t rc_saved_beta;
543 uint32_t rc_saved_beta_ecn; /*
544 * For newreno cc: rc_saved_beta and
545 * rc_saved_beta_ecn are the values we have had
510546 * set by the user, if pacing is not happening
511547 * (i.e. its early and we have not turned on yet
512548 * or it was turned off). The minute pacing
......@@ -516,10 +552,12 @@ struct rack_control {
516552 * we also set the flag (if ecn_beta is set) to make
517553 * new_reno do less of a backoff for ecn (think abe).
518554 */
555 uint16_t rc_cnt_of_retran[RETRAN_CNT_SIZE];
519556 uint16_t rc_early_recovery_segs; /* Socket option value Lock(a) */
520557 uint16_t rc_reorder_shift; /* Socket option value Lock(a) */
521558 uint8_t rack_per_upper_bound_ss;
522559 uint8_t rack_per_upper_bound_ca;
560 uint8_t cleared_app_ack;
523561 uint8_t dsack_persist;
524562 uint8_t rc_no_push_at_mrtt; /* No push when we exceed max rtt */
525563 uint8_t num_measurements; /* Number of measurements (up to 0xff, we freeze at 0xff) */
......@@ -528,37 +566,15 @@ struct rack_control {
528566 uint8_t rc_tlp_cwnd_reduce; /* Socket option value Lock(a) */
529567 uint8_t rc_prr_sendalot;/* Socket option value Lock(a) */
530568 uint8_t rc_rate_sample_method;
531 uint8_t rc_dgp_bl_agg; /* Buffer Level aggression during DGP */
532 uint8_t full_dgp_in_rec; /* Flag to say if we do full DGP in recovery */
533569 uint8_t client_suggested_maxseg; /* Not sure what to do with this yet */
534 uint8_t pacing_discount_amm; /*
535 * This is a multipler to the base discount that
536 * can be used to increase the discount.
537 */
538 uint8_t already_had_a_excess;
570 uint8_t use_gp_not_last;
571 uint8_t pacing_method; /* If pace_always, what type of pacing */
539572};
540573#endif
541574
542/* DGP with no buffer level mitigations */
543#define DGP_LEVEL0 0
544
545/*
546 * DGP with buffer level mitigation where BL:4 caps fillcw and BL:5
547 * turns off fillcw.
548 */
549#define DGP_LEVEL1 1
550
551/*
552 * DGP with buffer level mitigation where BL:3 caps fillcw and BL:4 turns off fillcw
553 * and BL:5 reduces by 10%
554 */
555#define DGP_LEVEL2 2
556
557/*
558 * DGP with buffer level mitigation where BL:2 caps fillcw and BL:3 turns off
559 * fillcw BL:4 reduces by 10% and BL:5 reduces by 20%
560 */
561#define DGP_LEVEL3 3
575#define RACK_PACING_NONE 0x00
576#define RACK_DGP_PACING 0x01
577#define RACK_REG_PACING 0x02
562578
563579/* Hybrid pacing log defines */
564580#define HYBRID_LOG_NO_ROOM 0 /* No room for the clients request */
......@@ -579,7 +595,6 @@ struct rack_control {
579595#define HYBRID_LOG_SENT_LOST 15 /* A closing sent/lost report */
580596
581597#define RACK_TIMELY_CNT_BOOST 5 /* At 5th increase boost */
582#define RACK_MINRTT_FILTER_TIM 10 /* Seconds */
583598
584599#define RACK_HYSTART_OFF 0
585600#define RACK_HYSTART_ON 1 /* hystart++ on */
......@@ -590,19 +605,20 @@ struct rack_control {
590605 */
591606
592607#define MAX_USER_SET_SEG 0x3f /* The max we can set is 63 which is probably too many */
608#define RACK_FREE_CNT_MAX 0x2f /* Max our counter can do */
593609
594610#ifdef _KERNEL
595611
596612struct tcp_rack {
597613 /* First cache line 0x00 */
598 TAILQ_ENTRY(tcp_rack) r_hpts; /* hptsi queue next Lock(b) */
599614 int32_t(*r_substate) (struct mbuf *, struct tcphdr *,
600615 struct socket *, struct tcpcb *, struct tcpopt *,
601616 int32_t, int32_t, uint32_t, int, int, uint8_t); /* Lock(a) */
602617 struct tcpcb *rc_tp; /* The tcpcb Lock(a) */
603618 struct inpcb *rc_inp; /* The inpcb Lock(a) */
604 uint8_t rc_free_cnt; /* Number of free entries on the rc_free list
605 * Lock(a) */
619 uint8_t rc_free_cnt : 6,
620 rc_skip_timely : 1,
621 pcm_enabled : 1; /* Is PCM enabled */
606622 uint8_t client_bufferlvl : 3, /* Expected range [0,5]: 0=unset, 1=low/empty */
607623 rack_deferred_inited : 1,
608624 /* ******************************************************************** */
......@@ -612,11 +628,11 @@ struct tcp_rack {
612628 shape_rxt_to_pacing_min : 1,
613629 /* ******************************************************************** */
614630 rc_ack_required: 1,
615 r_pacing_discount : 1;
631 r_use_hpts_min : 1;
616632 uint8_t no_prr_addback : 1,
617633 gp_ready : 1,
618634 defer_options: 1,
619 excess_rxt_on: 1, /* Are actions on for excess retransmissions? */
635 dis_lt_bw : 1,
620636 rc_ack_can_sendout_data: 1, /*
621637 * If set it will override pacing restrictions on not sending
622638 * data when the pacing timer is running. I.e. you set this
......@@ -659,7 +675,7 @@ struct tcp_rack {
659675 r_rack_hw_rate_caps: 1,
660676 r_up_only: 1,
661677 r_via_fill_cw : 1,
662 r_fill_less_agg : 1;
678 r_rcvpath_rtt_up : 1;
663679
664680 uint8_t rc_user_set_max_segs : 7, /* Socket option value Lock(a) */
665681 rc_fillcw_apply_discount;
......@@ -673,7 +689,7 @@ struct tcp_rack {
673689 rc_highly_buffered: 1, /* The path is highly buffered */
674690 rc_dragged_bottom: 1,
675691 rc_pace_dnd : 1, /* The pace do not disturb bit */
676 rc_avali2 : 1,
692 rc_initial_ss_comp : 1,
677693 rc_gp_filled : 1,
678694 rc_hw_nobuf : 1;
679695 uint8_t r_state : 4, /* Current rack state Lock(a) */
......@@ -696,8 +712,8 @@ struct tcp_rack {
696712 uint8_t app_limited_needs_set : 1,
697713 use_fixed_rate : 1,
698714 rc_has_collapsed : 1,
699 r_cwnd_was_clamped : 1,
700 r_clamped_gets_lower : 1,
715 use_lesser_lt_bw : 1,
716 cspr_is_fcc : 1,
701717 rack_hdrw_pacing : 1, /* We are doing Hardware pacing */
702718 rack_hdw_pace_ena : 1, /* Is hardware pacing enabled? */
703719 rack_attempt_hdwr_pace : 1; /* Did we attempt hdwr pacing (if allowed) */
......@@ -712,8 +728,7 @@ struct tcp_rack {
712728 set_pacing_done_a_iw : 1,
713729 use_rack_rr : 1,
714730 alloc_limit_reported : 1,
715 sack_attack_disable : 1,
716 do_detection : 1,
731 rack_avail : 2,
717732 rc_force_max_seg : 1;
718733 uint8_t r_early : 1,
719734 r_late : 1,
......@@ -722,7 +737,11 @@ struct tcp_rack {
722737 r_persist_lt_bw_off : 1,
723738 r_collapse_point_valid : 1,
724739 dgp_on : 1;
725 uint16_t rc_init_win : 8,
740 uint16_t rto_from_rec: 1,
741 avail_bit: 4,
742 pcm_in_progress: 1,
743 pcm_needed: 1,
744 rc_sendvars_notset : 1, /* Inside rack_init send variables (snd_max/una etc) were not set */
726745 rc_gp_rtt_set : 1,
727746 rc_gp_dyn_mul : 1,
728747 rc_gp_saw_rec : 1,
......@@ -735,5 +754,9 @@ struct tcp_rack {
735754 struct rack_control r_ctl;
736755} __aligned(CACHE_LINE_SIZE);
737756
757
758void rack_update_pcm_ack(struct tcp_rack *rack, int was_cumack,
759 uint32_t ss, uint32_t es);
760
738761#endif
739762#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_syncache.h+7-6
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
3230 */
3331
3432#ifndef _NETINET_TCP_SYNCACHE_H_
......@@ -47,12 +45,11 @@ struct socket * syncache_add(struct in_conninfo *, struct tcpopt *,
4745 void *, void *, uint8_t, uint16_t);
4846void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *,
4947 uint16_t);
50void syncache_badack(struct in_conninfo *, uint16_t);
5148int syncache_pcblist(struct sysctl_req *);
5249
5350struct syncache {
5451 TAILQ_ENTRY(syncache) sc_hash;
55 struct in_conninfo sc_inc; /* addresses */
52 struct in_conninfo sc_inc; /* addresses */
5653 int sc_rxttime; /* retransmit time */
5754 u_int16_t sc_rxmits; /* retransmit counter */
5855 u_int16_t sc_port; /* remote UDP encaps port */
......@@ -61,7 +58,7 @@ struct syncache {
6158 u_int32_t sc_flowlabel; /* IPv6 flowlabel */
6259 tcp_seq sc_irs; /* seq from peer */
6360 tcp_seq sc_iss; /* our ISS */
64 struct mbuf *sc_ipopts; /* source route */
61 struct mbuf *sc_ipopts; /* source route */
6562 u_int16_t sc_peer_mss; /* peer's MSS */
6663 u_int16_t sc_wnd; /* advertised window */
6764 u_int8_t sc_ip_ttl; /* TTL / Hop Limit */
......@@ -69,7 +66,9 @@ struct syncache {
6966 u_int8_t sc_requested_s_scale:4,
7067 sc_requested_r_scale:4;
7168 u_int16_t sc_flags;
72#if defined(TCP_OFFLOAD) || !defined(TCP_OFFLOAD_DISABLE)
69 u_int32_t sc_challenge_ack_cnt; /* chall. ACKs sent in epoch */
70 sbintime_t sc_challenge_ack_end; /* End of chall. ack epoch */
71#if defined(TCP_OFFLOAD)
7372 struct toedev *sc_tod; /* entry added by this TOE */
7473 void *sc_todctx; /* TOE driver context */
7574#endif
......@@ -129,7 +128,9 @@ struct tcp_syncache {
129128 u_int cache_limit;
130129 u_int rexmt_limit;
131130 uint32_t hash_secret;
131#ifdef VIMAGE
132132 struct vnet *vnet;
133#endif
133134 struct syncookie_secret secret;
134135 struct mtx pause_mtx;
135136 struct callout pause_co;
lib/libc/include/generic-freebsd/netinet/tcp_timer.h+18-18
......@@ -27,13 +27,13 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NETINET_TCP_TIMER_H_
3533#define _NETINET_TCP_TIMER_H_
3634
35#ifdef _KERNEL
36
3737/*
3838 * The TCPT_REXMT timer is used to force retransmissions.
3939 * The TCP has the TCPT_REXMT timer set whenever segments
......@@ -73,21 +73,22 @@
7373/*
7474 * Time constants.
7575 */
76#define TCPTV_MSL ( 30*hz) /* max seg lifetime (hah!) */
76#define TCPTV_MSL MSEC_2_TICKS(30000) /* max seg lifetime (hah!) */
77#define TCPTV_MSL_LOCAL MSEC_2_TICKS(10) /* max seg lifetime for local comm */
7778#define TCPTV_SRTTBASE 0 /* base roundtrip time;
7879 if 0, no idea yet */
79#define TCPTV_RTOBASE ( 1*hz) /* assumed RTO if no info */
80#define TCPTV_RTOBASE MSEC_2_TICKS(1000) /* assumed RTO if no info */
8081
81#define TCPTV_PERSMIN ( 5*hz) /* minimum persist interval */
82#define TCPTV_PERSMAX ( 60*hz) /* maximum persist interval */
82#define TCPTV_PERSMIN MSEC_2_TICKS(5000) /* minimum persist interval */
83#define TCPTV_PERSMAX MSEC_2_TICKS(60000) /* maximum persist interval */
8384
84#define TCPTV_KEEP_INIT ( 75*hz) /* initial connect keepalive */
85#define TCPTV_KEEP_IDLE (120*60*hz) /* dflt time before probing */
86#define TCPTV_KEEPINTVL ( 75*hz) /* default probe interval */
85#define TCPTV_KEEP_INIT MSEC_2_TICKS(75000) /* initial connect keepalive */
86#define TCPTV_KEEP_IDLE MSEC_2_TICKS(120*60*1000) /* dflt time before probing */
87#define TCPTV_KEEPINTVL MSEC_2_TICKS(75000) /* default probe interval */
8788#define TCPTV_KEEPCNT 8 /* max probes before drop */
8889#define TCPTV_MAXUNACKTIME 0 /* max time without making progress */
8990
90#define TCPTV_FINWAIT2_TIMEOUT (60*hz) /* FIN_WAIT_2 timeout if no receiver */
91#define TCPTV_FINWAIT2_TIMEOUT MSEC_2_TICKS(60000) /* FIN_WAIT_2 timeout if no receiver */
9192
9293/*
9394 * Minimum retransmit timer is 3 ticks, for algorithmic stability.
......@@ -109,15 +110,13 @@
109110 * The prior minimum of 1*hz (1 second) badly breaks throughput on any
110111 * networks faster then a modem that has minor (e.g. 1%) packet loss.
111112 */
112#define TCPTV_MIN ( hz/33 ) /* minimum allowable value */
113#define TCPTV_CPU_VAR ( hz/5 ) /* cpu variance allowed (200ms) */
114#define TCPTV_REXMTMAX ( 64*hz) /* max allowable REXMT value */
115
116#define TCPTV_TWTRUNC 8 /* RTO factor to truncate TW */
113#define TCPTV_MIN MSEC_2_TICKS(30) /* minimum allowable value */
114#define TCPTV_CPU_VAR MSEC_2_TICKS(200) /* cpu variance allowed (200ms) */
115#define TCPTV_REXMTMAX MSEC_2_TICKS(64000) /* max allowable REXMT value */
117116
118117#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */
119118
120#define TCPTV_DELACK ( hz/25 ) /* 40ms timeout */
119#define TCPTV_DELACK MSEC_2_TICKS(40) /* 40ms timeout */
121120
122121/*
123122 * If we exceed this number of retransmits for a single segment, we'll consider
......@@ -137,8 +136,6 @@
137136 (tv) = (tvmax); \
138137} while(0)
139138
140#ifdef _KERNEL
141
142139#define TP_KEEPINIT(tp) ((tp)->t_keepinit ? (tp)->t_keepinit : tcp_keepinit)
143140#define TP_KEEPIDLE(tp) ((tp)->t_keepidle ? (tp)->t_keepidle : tcp_keepidle)
144141#define TP_KEEPINTVL(tp) ((tp)->t_keepintvl ? (tp)->t_keepintvl : tcp_keepintvl)
......@@ -167,6 +164,7 @@ extern int tcp_maxunacktime; /* max time without making progress */
167164extern int tcp_maxpersistidle;
168165extern int tcp_rexmit_initial;
169166extern int tcp_rexmit_min;
167extern int tcp_rexmit_max;
170168extern int tcp_rexmit_slop;
171169extern int tcp_ttl; /* time to live for TCP segs */
172170extern int tcp_backoff[];
......@@ -186,6 +184,8 @@ VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss);
186184#define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss)
187185VNET_DECLARE(int, tcp_msl);
188186#define V_tcp_msl VNET(tcp_msl)
187VNET_DECLARE(int, tcp_msl_local);
188#define V_tcp_msl_local VNET(tcp_msl_local)
189189
190190#endif /* _KERNEL */
191191
lib/libc/include/generic-freebsd/netinet/tcp_var.h+89-112
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
3230 */
3331
3432#ifndef _NETINET_TCP_VAR_H_
......@@ -130,6 +128,8 @@ struct sackhint {
130128 uint32_t recover_fs; /* Flight Size at the start of Loss recovery */
131129 uint32_t prr_delivered; /* Total bytes delivered using PRR */
132130 uint32_t prr_out; /* Bytes sent during IN_RECOVERY */
131 int32_t hole_bytes; /* current number of bytes in scoreboard holes */
132 int32_t lost_bytes; /* number of rfc6675 IsLost() bytes */
133133};
134134
135135#define SEGQ_EMPTY(tp) TAILQ_EMPTY(&(tp)->t_segq)
......@@ -141,7 +141,8 @@ STAILQ_HEAD(tcp_log_stailq, tcp_log_mem);
141141#define TCP_TRK_TRACK_FLG_OPEN 0x02 /* End is not valid (open range request) */
142142#define TCP_TRK_TRACK_FLG_SEQV 0x04 /* We had a sendfile that touched it */
143143#define TCP_TRK_TRACK_FLG_COMP 0x08 /* Sendfile as placed the last bits (range req only) */
144#define TCP_TRK_TRACK_FLG_FSND 0x10 /* First send has been done into the seq space */
144#define TCP_TRK_TRACK_FLG_FSND 0x10 /* First send has been done into the seq space */
145#define TCP_TRK_TRACK_FLG_LSND 0x20 /* We were able to set the Last Sent */
145146#define MAX_TCP_TRK_REQ 5 /* Max we will have at once */
146147
147148struct tcp_sendfile_track {
......@@ -154,11 +155,14 @@ struct tcp_sendfile_track {
154155 uint64_t cspr; /* Client suggested pace rate */
155156 uint64_t sent_at_fs; /* What was t_sndbytes as we begun sending */
156157 uint64_t rxt_at_fs; /* What was t_snd_rxt_bytes as we begun sending */
158 uint64_t sent_at_ls; /* Sent value at the last send */
159 uint64_t rxt_at_ls; /* Retransmit value at the last send */
157160 tcp_seq start_seq; /* First TCP Seq assigned */
158161 tcp_seq end_seq; /* If range req last seq */
159162 uint32_t flags; /* Type of request open etc */
160163 uint32_t sbcc_at_s; /* When we allocate what is the sb_cc */
161164 uint32_t hint_maxseg; /* Client hinted maxseg */
165 uint32_t playout_ms; /* Client playout ms */
162166 uint32_t hybrid_flags; /* Hybrid flags on this request */
163167};
164168
......@@ -178,7 +182,7 @@ struct tcp_sendfile_track {
178182 * snd_una). When the response comes back indicating
179183 * that there was data (return value 1), then the caller
180184 * can build a sendmap entry based on the range and the
181 * times. The next query would then be done at the
185 * times. The next query would then be done at the
182186 * newly created sendmap_end. Repeated until sendmap_end == snd_max.
183187 *
184188 * Flags in sendmap_flags are defined below as well.
......@@ -193,7 +197,7 @@ struct tcp_sendfile_track {
193197 * The rack_times are a misc collection of information that
194198 * the old stack might possibly fill in. Of course its possible
195199 * that an old stack may not have a piece of information. If so
196 * then setting that value to zero is advised. Setting any
200 * then setting that value to zero is advised. Setting any
197201 * timestamp passed should only place a zero in it when it
198202 * is unfilled. This may mean that a time is off by a micro-second
199203 * but this is ok in the grand scheme of things.
......@@ -201,13 +205,13 @@ struct tcp_sendfile_track {
201205 * When switching stacks it is desireable to get as much information
202206 * from the old stack to the new stack as possible. Though not always
203207 * will the stack be compatible in the types of information. The
204 * init() function needs to take care when it begins changing
208 * init() function needs to take care when it begins changing
205209 * things such as inp_flags2 and the timer units to position these
206210 * changes at a point where it is unlikely they will fail after
207211 * making such changes. A stack optionally can have an "undo"
208 * function
212 * function
209213 *
210 * To transfer information to the old stack from the new in
214 * To transfer information to the old stack from the new in
211215 * respect to LRO and the inp_flags2, the new stack should set
212216 * the inp_flags2 to what it supports. The old stack in its
213217 * fini() function should call the tcp_handle_orphaned_packets()
......@@ -448,7 +452,6 @@ struct tcpcb {
448452 tcp_seq gput_seq; /* Outbound measurement seq */
449453 tcp_seq gput_ack; /* Inbound measurement ack */
450454 int32_t t_stats_gput_prev; /* XXXLAS: Prev gput measurement */
451 uint32_t t_maxpeakrate; /* max peak rate set by user, bytes/s */
452455 uint32_t t_sndtlppack; /* tail loss probe packets sent */
453456 uint64_t t_sndtlpbyte; /* total tail loss probe bytes sent */
454457 uint64_t t_sndbytes; /* total bytes sent */
......@@ -496,10 +499,6 @@ struct tcpcb {
496499 uint64_t tcp_cnt_counters[TCP_NUM_CNT_COUNTERS];
497500 uint64_t tcp_proc_time[TCP_NUM_CNT_COUNTERS];
498501#endif
499#ifdef TCPPCAP
500 struct mbufq t_inpkts; /* List of saved input packets. */
501 struct mbufq t_outpkts; /* List of saved output packets. */
502#endif
503502};
504503#endif /* _KERNEL || _WANT_TCPCB */
505504
......@@ -529,31 +528,12 @@ typedef enum {
529528/* Minimum map entries limit value, if set */
530529#define TCP_MIN_MAP_ENTRIES_LIMIT 128
531530
532/*
533 * TODO: We yet need to brave plowing in
534 * to tcp_input() and the pru_usrreq() block.
535 * Right now these go to the old standards which
536 * are somewhat ok, but in the long term may
537 * need to be changed. If we do tackle tcp_input()
538 * then we need to get rid of the tcp_do_segment()
539 * function below.
540 */
541531/* Flags for tcp functions */
542532#define TCP_FUNC_BEING_REMOVED 0x01 /* Can no longer be referenced */
543533#define TCP_FUNC_OUTPUT_CANDROP 0x02 /* tfb_tcp_output may ask tcp_drop */
544534#define TCP_FUNC_DEFAULT_OK 0x04 /* Can be used as default */
545535
546536/**
547 * If defining the optional tcp_timers, in the
548 * tfb_tcp_timer_stop call you must use the
549 * callout_async_drain() function with the
550 * tcp_timer_discard callback. You should check
551 * the return of callout_async_drain() and if 0
552 * increment tt_draincnt. Since the timer sub-system
553 * does not know your callbacks you must provide a
554 * stop_all function that loops through and calls
555 * tcp_timer_stop() with each of your defined timers.
556 *
557537 * tfb_tcp_handoff_ok is a mandatory function allowing
558538 * to query a stack, if it can take over a tcpcb.
559539 * You return 0 to say you can take over and run your stack,
......@@ -564,13 +544,13 @@ typedef enum {
564544 * do is:
565545 * a) Make sure that the inp_flags2 is setup correctly
566546 * for LRO. There are two flags that the previous
567 * stack may have set INP_MBUF_ACKCMP and
547 * stack may have set INP_MBUF_ACKCMP and
568548 * INP_SUPPORTS_MBUFQ. If the new stack does not
569549 * support these it *should* clear the flags.
570550 * b) Make sure that the timers are in the proper
571551 * granularity that the stack wants. The stack
572552 * should check the t_tmr_granularity field. Currently
573 * there are two values that it may hold
553 * there are two values that it may hold
574554 * TCP_TMR_GRANULARITY_TICKS and TCP_TMR_GRANULARITY_USEC.
575555 * Use the functions tcp_timer_convert(tp, granularity);
576556 * to move the timers to the correct format for your stack.
......@@ -578,14 +558,14 @@ typedef enum {
578558 * The new stack may also optionally query the tfb_chg_query
579559 * function if the old stack has one. The new stack may ask
580560 * for one of three entries and can also state to the old
581 * stack its support for the INP_MBUF_ACKCMP and
561 * stack its support for the INP_MBUF_ACKCMP and
582562 * INP_SUPPORTS_MBUFQ. This is important since if there are
583563 * queued ack's without that statement the old stack will
584564 * be forced to discard the queued acks. The requests that
585565 * can be made for information by the new stacks are:
586566 *
587567 * Note also that the tfb_tcp_fb_init() when called can
588 * determine if a query is needed by looking at the
568 * determine if a query is needed by looking at the
589569 * value passed in the ptr. The ptr is designed to be
590570 * set in with any allocated memory, but the address
591571 * of the condtion (ptr == &tp->t_fb_ptr) will be
......@@ -593,17 +573,17 @@ typedef enum {
593573 * setup of a tcb (which means no query would be needed).
594574 * If, however, the value is not t_fb_ptr, then the caller
595575 * is in the middle of a stack switch and is the new stack.
596 * A query would be appropriate (if the new stack support
576 * A query would be appropriate (if the new stack support
597577 * the query mechanism).
598578 *
599579 * TCP_QUERY_SENDMAP - Query of outstanding data.
600580 * TCP_QUERY_TIMERS_UP - Query about running timers.
601 * TCP_SUPPORTED_LRO - Declaration in req_param of
602 * the inp_flags2 supported by
581 * TCP_SUPPORTED_LRO - Declaration in req_param of
582 * the inp_flags2 supported by
603583 * the new stack.
604584 * TCP_QUERY_RACK_TIMES - Enquire about various timestamps
605585 * and states the old stack may be in.
606 *
586 *
607587 * tfb_tcp_fb_fini is changed to add a flag to tell
608588 * the old stack if the tcb is being destroyed or
609589 * not. A one in the flag means the TCB is being
......@@ -639,6 +619,8 @@ struct tcp_function_block {
639619 void (*tfb_switch_failed)(struct tcpcb *);
640620 bool (*tfb_early_wake_check)(struct tcpcb *);
641621 int (*tfb_compute_pipe)(struct tcpcb *tp);
622 int (*tfb_stack_info)(struct tcpcb *tp, struct stack_specific_info *);
623 void (*tfb_inherit)(struct tcpcb *tp, struct inpcb *h_inp);
642624 volatile uint32_t tfb_refcnt;
643625 uint32_t tfb_flags;
644626 uint8_t tfb_id;
......@@ -807,7 +789,7 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
807789#define TF_TSO 0x01000000 /* TSO enabled on this connection */
808790#define TF_TOE 0x02000000 /* this connection is offloaded */
809791#define TF_CLOSED 0x04000000 /* close(2) called on socket */
810#define TF_UNUSED1 0x08000000 /* unused */
792#define TF_SENTSYN 0x08000000 /* At least one syn has been sent */
811793#define TF_LRD 0x10000000 /* Lost Retransmission Detection */
812794#define TF_CONGRECOVERY 0x20000000 /* congestion recovery mode */
813795#define TF_WASCRECOVERY 0x40000000 /* was in congestion recovery */
......@@ -825,14 +807,6 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
825807#define ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY)
826808#define EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY | TF_FASTRECOVERY)
827809
828#if defined(_KERNEL)
829#if !defined(TCP_RFC7413)
830#define IS_FASTOPEN(t_flags) (false)
831#else
832#define IS_FASTOPEN(t_flags) (t_flags & TF_FASTOPEN)
833#endif
834#endif
835
836810#define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una)
837811
838812/*
......@@ -864,6 +838,8 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
864838#define TF2_MBUF_QUEUE_READY 0x00020000 /* Inputs can be queued */
865839#define TF2_DONT_SACK_QUEUE 0x00040000 /* Don't wake on sack */
866840#define TF2_CANNOT_DO_ECN 0x00080000 /* The stack does not do ECN */
841#define TF2_PROC_SACK_PROHIBIT 0x00100000 /* Due to small MSS size do not process sack's */
842#define TF2_IPSEC_TSO 0x00200000 /* IPSEC + TSO supported */
867843#define TF2_NO_ISS_CHECK 0x00400000 /* Don't check SEG.ACK against ISS */
868844
869845/*
......@@ -902,24 +878,13 @@ struct tcpopt {
902878#define TO_SYN 0x01 /* parse SYN-only options */
903879
904880struct hc_metrics_lite { /* must stay in sync with hc_metrics */
905 uint32_t rmx_mtu; /* MTU for this path */
906 uint32_t rmx_ssthresh; /* outbound gateway buffer limit */
907 uint32_t rmx_rtt; /* estimated round trip time */
908 uint32_t rmx_rttvar; /* estimated rtt variance */
909 uint32_t rmx_cwnd; /* congestion window */
910 uint32_t rmx_sendpipe; /* outbound delay-bandwidth product */
911 uint32_t rmx_recvpipe; /* inbound delay-bandwidth product */
912};
913
914/*
915 * Used by tcp_maxmtu() to communicate interface specific features
916 * and limits at the time of connection setup.
917 */
918struct tcp_ifcap {
919 int ifcap;
920 u_int tsomax;
921 u_int tsomaxsegcount;
922 u_int tsomaxsegsize;
881 uint32_t hc_mtu; /* MTU for this path */
882 uint32_t hc_ssthresh; /* outbound gateway buffer limit */
883 uint32_t hc_rtt; /* estimated round trip time */
884 uint32_t hc_rttvar; /* estimated rtt variance */
885 uint32_t hc_cwnd; /* congestion window */
886 uint32_t hc_sendpipe; /* outbound delay-bandwidth product */
887 uint32_t hc_recvpipe; /* inbound delay-bandwidth product */
923888};
924889
925890#ifndef _NETINET_IN_PCB_H_
......@@ -962,9 +927,12 @@ struct in_conninfo;
962927 + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
963928
964929/*
965 * TCP statistics.
966 * Many of these should be kept per connection,
967 * but that's inconvenient at the moment.
930 * Global (per-VNET) TCP statistics. The below structure represents what we
931 * export to the userland, but in the kernel we have an array of counter_u64_t
932 * with as many elements as there are members in the structure. The counters
933 * shall be increased by TCPSTAT_INC() or KMOD_TCPSTAT_INC(). Adding a new
934 * counter also requires adding corresponding SDT probes into in_kdtrace.h and
935 * into in_kdtrace.c.
968936 */
969937struct tcpstat {
970938 uint64_t tcps_connattempt; /* connections initiated */
......@@ -1050,6 +1018,8 @@ struct tcpstat {
10501018 uint64_t tcps_sc_zonefail; /* zalloc() failed */
10511019 uint64_t tcps_sc_sendcookie; /* SYN cookie sent */
10521020 uint64_t tcps_sc_recvcookie; /* SYN cookie received */
1021 uint64_t tcps_sc_spurcookie; /* SYN cookie spurious, rejected */
1022 uint64_t tcps_sc_failcookie; /* SYN cookie failed, rejected */
10531023
10541024 uint64_t tcps_hc_added; /* entry added to hostcache */
10551025 uint64_t tcps_hc_bucketoverflow;/* hostcache per bucket limit hit */
......@@ -1059,6 +1029,7 @@ struct tcpstat {
10591029 /* SACK related stats */
10601030 uint64_t tcps_sack_recovery_episode; /* SACK recovery episodes */
10611031 uint64_t tcps_sack_rexmits; /* SACK rexmit segments */
1032 uint64_t tcps_sack_rexmits_tso; /* SACK rexmit TSO chunks */
10621033 uint64_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */
10631034 uint64_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */
10641035 uint64_t tcps_sack_send_blocks; /* SACK blocks (options) sent */
......@@ -1120,31 +1091,39 @@ struct tcpstat {
11201091 uint64_t tcps_rcvghostack; /* received ACK for data never sent */
11211092 uint64_t tcps_rcvacktooold; /* received ACK for data too long ago */
11221093
1123 uint64_t _pad[2]; /* 2 TBD placeholder for STABLE */
1094
1095 uint64_t _pad[1]; /* 1 TBD placeholder for STABLE */
11241096};
11251097
11261098#define tcps_rcvmemdrop tcps_rcvreassfull /* compat */
11271099
11281100#ifdef _KERNEL
1129#define TI_UNLOCKED 1
1130#define TI_RLOCKED 2
11311101#include <sys/counter.h>
1102#include <netinet/in_kdtrace.h>
11321103
11331104VNET_PCPUSTAT_DECLARE(struct tcpstat, tcpstat); /* tcp statistics */
11341105/*
11351106 * In-kernel consumers can use these accessor macros directly to update
11361107 * stats.
11371108 */
1138#define TCPSTAT_ADD(name, val) \
1139 VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val))
1109#define TCPSTAT_ADD(name, val) \
1110 do { \
1111 MIB_SDT_PROBE1(tcp, count, name, (val)); \
1112 VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val)); \
1113 } while (0)
11401114#define TCPSTAT_INC(name) TCPSTAT_ADD(name, 1)
11411115
11421116/*
11431117 * Kernel module consumers must use this accessor macro.
11441118 */
11451119void kmod_tcpstat_add(int statnum, int val);
1146#define KMOD_TCPSTAT_ADD(name, val) \
1147 kmod_tcpstat_add(offsetof(struct tcpstat, name) / sizeof(uint64_t), val)
1120#define KMOD_TCPSTAT_ADD(name, val) \
1121 do { \
1122 MIB_SDT_PROBE1(tcp, count, name, (val)); \
1123 kmod_tcpstat_add(offsetof(struct tcpstat, name) / \
1124 sizeof(uint64_t), \
1125 val); \
1126 } while (0)
11481127#define KMOD_TCPSTAT_INC(name) KMOD_TCPSTAT_ADD(name, 1)
11491128
11501129/*
......@@ -1260,6 +1239,9 @@ struct tcp_function_info {
12601239#define TCPCTL_SACK 14 /* Selective Acknowledgement,rfc 2018 */
12611240#define TCPCTL_DROP 15 /* drop tcp connection */
12621241#define TCPCTL_STATES 16 /* connection counts by TCP state */
1242#define TCPCTL_KTLSLIST 17 /* connections with active ktls
1243 session */
1244#define TCPCTL_KTLSLIST_WKEYS 18 /* KTLSLIST with key data exported */
12631245
12641246#ifdef _KERNEL
12651247#ifdef SYSCTL_DECL
......@@ -1283,6 +1265,7 @@ VNET_DECLARE(uint32_t, tcp_ack_war_time_window);
12831265VNET_DECLARE(int, tcp_autorcvbuf_max);
12841266VNET_DECLARE(int, tcp_autosndbuf_inc);
12851267VNET_DECLARE(int, tcp_autosndbuf_max);
1268VNET_DECLARE(int, tcp_bind_all_fibs);
12861269VNET_DECLARE(int, tcp_delack_enabled);
12871270VNET_DECLARE(int, tcp_do_autorcvbuf);
12881271VNET_DECLARE(int, tcp_do_autosndbuf);
......@@ -1317,6 +1300,7 @@ VNET_DECLARE(int, tcp_retries);
13171300VNET_DECLARE(int, tcp_sack_globalholes);
13181301VNET_DECLARE(int, tcp_sack_globalmaxholes);
13191302VNET_DECLARE(int, tcp_sack_maxholes);
1303VNET_DECLARE(int, tcp_sack_tso);
13201304VNET_DECLARE(int, tcp_sc_rst_sock_fail);
13211305VNET_DECLARE(int, tcp_sendspace);
13221306VNET_DECLARE(int, tcp_udp_tunneling_overhead);
......@@ -1335,6 +1319,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo);
13351319#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max)
13361320#define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc)
13371321#define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max)
1322#define V_tcp_bind_all_fibs VNET(tcp_bind_all_fibs)
13381323#define V_tcp_delack_enabled VNET(tcp_delack_enabled)
13391324#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf)
13401325#define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf)
......@@ -1366,6 +1351,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo);
13661351#define V_tcp_sack_globalholes VNET(tcp_sack_globalholes)
13671352#define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes)
13681353#define V_tcp_sack_maxholes VNET(tcp_sack_maxholes)
1354#define V_tcp_sack_tso VNET(tcp_sack_tso)
13691355#define V_tcp_sc_rst_sock_fail VNET(tcp_sc_rst_sock_fail)
13701356#define V_tcp_sendspace VNET(tcp_sendspace)
13711357#define V_tcp_udp_tunneling_overhead VNET(tcp_udp_tunneling_overhead)
......@@ -1393,8 +1379,7 @@ int tcp_reass(struct tcpcb *, struct tcphdr *, tcp_seq *, int *,
13931379void tcp_reass_global_init(void);
13941380void tcp_reass_flush(struct tcpcb *);
13951381void tcp_dooptions(struct tcpopt *, u_char *, int, int);
1396void tcp_dropwithreset(struct mbuf *, struct tcphdr *,
1397 struct tcpcb *, int, int);
1382void tcp_dropwithreset(struct mbuf *, struct tcphdr *, struct tcpcb *, int);
13981383void tcp_pulloutofband(struct socket *,
13991384 struct tcphdr *, struct mbuf *, int);
14001385void tcp_xmit_timer(struct tcpcb *, int);
......@@ -1447,24 +1432,23 @@ extern counter_u64_t tcp_comp_total;
14471432extern counter_u64_t tcp_uncomp_total;
14481433extern counter_u64_t tcp_bad_csums;
14491434
1450#ifdef TCP_SAD_DETECTION
1451/* Various SACK attack thresholds */
1452extern int32_t tcp_force_detection;
1453extern int32_t tcp_sad_limit;
1454extern int32_t tcp_sack_to_ack_thresh;
1455extern int32_t tcp_sack_to_move_thresh;
1456extern int32_t tcp_restoral_thresh;
1457extern int32_t tcp_sad_decay_val;
1458extern int32_t tcp_sad_pacing_interval;
1459extern int32_t tcp_sad_low_pps;
1460extern int32_t tcp_map_minimum;
1461extern int32_t tcp_attack_on_turns_on_logging;
1462#endif
14631435extern uint32_t tcp_ack_war_time_window;
14641436extern uint32_t tcp_ack_war_cnt;
14651437
1438/*
1439 * Used by tcp_maxmtu() to communicate interface specific features
1440 * and limits at the time of connection setup.
1441 */
1442struct tcp_ifcap {
1443 int ifcap;
1444 u_int tsomax;
1445 u_int tsomaxsegcount;
1446 u_int tsomaxsegsize;
1447 bool ipsec_tso;
1448};
14661449uint32_t tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *);
14671450uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *);
1451
14681452void tcp6_use_min_mtu(struct tcpcb *);
14691453u_int tcp_maxseg(const struct tcpcb *);
14701454u_int tcp_fixed_maxseg(const struct tcpcb *);
......@@ -1478,6 +1462,7 @@ int tcp_default_output(struct tcpcb *);
14781462void tcp_state_change(struct tcpcb *, int);
14791463void tcp_respond(struct tcpcb *, void *,
14801464 struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, uint16_t);
1465bool tcp_challenge_ack_check(sbintime_t *, uint32_t *);
14811466void tcp_send_challenge_ack(struct tcpcb *, struct tcphdr *, struct mbuf *);
14821467bool tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *,
14831468 struct mbuf *, int);
......@@ -1497,10 +1482,10 @@ void tcp_hc_init(void);
14971482#ifdef VIMAGE
14981483void tcp_hc_destroy(void);
14991484#endif
1500void tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *);
1501uint32_t tcp_hc_getmtu(struct in_conninfo *);
1502void tcp_hc_updatemtu(struct in_conninfo *, uint32_t);
1503void tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *);
1485void tcp_hc_get(const struct in_conninfo *, struct hc_metrics_lite *);
1486uint32_t tcp_hc_getmtu(const struct in_conninfo *);
1487void tcp_hc_updatemtu(const struct in_conninfo *, uint32_t);
1488void tcp_hc_update(const struct in_conninfo *, struct hc_metrics_lite *);
15041489void cc_after_idle(struct tcpcb *tp);
15051490
15061491extern struct protosw tcp_protosw; /* shared for TOE */
......@@ -1513,14 +1498,17 @@ sackstatus_t
15131498 tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq);
15141499int tcp_dsack_block_exists(struct tcpcb *);
15151500void tcp_update_dsack_list(struct tcpcb *, tcp_seq, tcp_seq);
1516void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend);
1501void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart,
1502 tcp_seq rcv_lastend);
15171503void tcp_clean_dsack_blocks(struct tcpcb *tp);
15181504void tcp_clean_sackreport(struct tcpcb *tp);
15191505int tcp_sack_adjust(struct tcpcb *tp);
15201506struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt);
1521void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *, sackstatus_t);
1507void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *,
1508 sackstatus_t, u_int *);
15221509void tcp_lost_retransmission(struct tcpcb *, struct tcphdr *);
1523void tcp_sack_partialack(struct tcpcb *, struct tcphdr *);
1510void tcp_sack_partialack(struct tcpcb *, struct tcphdr *, u_int *);
1511void tcp_resend_sackholes(struct tcpcb *tp);
15241512void tcp_free_sackholes(struct tcpcb *tp);
15251513void tcp_sack_lost_retransmission(struct tcpcb *, struct tcphdr *);
15261514int tcp_newreno(struct tcpcb *, struct tcphdr *);
......@@ -1530,6 +1518,8 @@ void tcp_sndbuf_autoscale(struct tcpcb *, struct socket *, uint32_t);
15301518int tcp_stats_sample_rollthedice(struct tcpcb *tp, void *seed_bytes,
15311519 size_t seed_len);
15321520int tcp_can_enable_pacing(void);
1521int tcp_incr_dgp_pacing_cnt(void);
1522void tcp_dec_dgp_pacing_cnt(void);
15331523void tcp_decrement_paced_conn(void);
15341524void tcp_change_time_units(struct tcpcb *, int);
15351525void tcp_handle_orphaned_packets(struct tcpcb *);
......@@ -1598,19 +1588,6 @@ tcp_fields_to_net(struct tcphdr *th)
15981588 th->th_win = htons(th->th_win);
15991589 th->th_urp = htons(th->th_urp);
16001590}
1601
1602static inline uint16_t
1603tcp_get_flags(const struct tcphdr *th)
1604{
1605 return (((uint16_t)th->th_x2 << 8) | th->th_flags);
1606}
1607
1608static inline void
1609tcp_set_flags(struct tcphdr *th, uint16_t flags)
1610{
1611 th->th_x2 = (flags >> 8) & 0x0f;
1612 th->th_flags = flags & 0xff;
1613}
16141591#endif /* _KERNEL */
16151592
16161593#endif /* _NETINET_TCP_VAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcpip.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)tcpip.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _NETINET_TCPIP_H_
lib/libc/include/generic-freebsd/netinet/toecore.h+2-1
......@@ -36,6 +36,7 @@
3636#include <netinet/tcp.h>
3737#include <sys/_eventhandler.h>
3838
39struct tcpcb;
3940struct tcpopt;
4041struct tcphdr;
4142struct in_conninfo;
......@@ -65,7 +66,7 @@ struct toedev {
6566 void (*tod_input)(struct toedev *, struct tcpcb *, struct mbuf *);
6667
6768 /*
68 * This is called by the kernel during pru_rcvd for an offloaded TCP
69 * This is called by the kernel during pr_rcvd() for an offloaded TCP
6970 * connection and provides an opportunity for the TOE driver to manage
7071 * its rx window and credits.
7172 */
lib/libc/include/generic-freebsd/netinet/udp.h+1-3
......@@ -28,8 +28,6 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * @(#)udp.h 8.1 (Berkeley) 6/10/93
3331 */
3432
3533#ifndef _NETINET_UDP_H_
......@@ -46,7 +44,7 @@ struct udphdr {
4644 u_short uh_dport; /* destination port */
4745 u_short uh_ulen; /* udp length */
4846 u_short uh_sum; /* udp checksum */
49};
47} __packed;
5048
5149/*
5250 * User-settable options (used with setsockopt).
lib/libc/include/generic-freebsd/netinet/udp_var.h+20-11
......@@ -28,8 +28,6 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93
3331 */
3432
3533#ifndef _NETINET_UDP_VAR_H_
......@@ -95,6 +93,7 @@ struct udpstat {
9593#ifdef _KERNEL
9694#include <netinet/in_pcb.h>
9795#include <sys/counter.h>
96#include <netinet/in_kdtrace.h>
9897struct mbuf;
9998
10099typedef bool udp_tun_func_t(struct mbuf *, int, struct inpcb *,
......@@ -121,7 +120,7 @@ struct udpcb {
121120 void *u_tun_ctx; /* Tunneling callback context. */
122121};
123122
124#define intoudpcb(ip) __containerof((inp), struct udpcb, u_inpcb)
123#define intoudpcb(ip) __containerof((ip), struct udpcb, u_inpcb)
125124#define sotoudpcb(so) (intoudpcb(sotoinpcb(so)))
126125
127126VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);
......@@ -129,18 +128,26 @@ VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);
129128 * In-kernel consumers can use these accessor macros directly to update
130129 * stats.
131130 */
132#define UDPSTAT_ADD(name, val) \
133 VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val))
134#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1)
131#define UDPSTAT_ADD(name, val) \
132 do { \
133 MIB_SDT_PROBE1(udp, count, name, (val)); \
134 VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val)); \
135 } while (0)
136#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1)
135137
136138/*
137139 * Kernel module consumers must use this accessor macro.
138140 */
139141void kmod_udpstat_inc(int statnum);
140#define KMOD_UDPSTAT_INC(name) \
141 kmod_udpstat_inc(offsetof(struct udpstat, name) / sizeof(uint64_t))
142#define KMOD_UDPSTAT_INC(name) \
143 do { \
144 MIB_SDT_PROBE1(udp, count, name, 1); \
145 kmod_udpstat_inc( \
146 offsetof(struct udpstat, name) / sizeof(uint64_t)); \
147 } while (0)
142148
143149SYSCTL_DECL(_net_inet_udp);
150SYSCTL_DECL(_net_inet_udplite);
144151
145152VNET_DECLARE(struct inpcbinfo, udbinfo);
146153VNET_DECLARE(struct inpcbinfo, ulitecbinfo);
......@@ -149,13 +156,15 @@ VNET_DECLARE(struct inpcbinfo, ulitecbinfo);
149156
150157extern u_long udp_sendspace;
151158extern u_long udp_recvspace;
152VNET_DECLARE(int, udp_cksum);
159VNET_DECLARE(int, udp_bind_all_fibs);
153160VNET_DECLARE(int, udp_blackhole);
154161VNET_DECLARE(bool, udp_blackhole_local);
162VNET_DECLARE(int, udp_cksum);
155163VNET_DECLARE(int, udp_log_in_vain);
156#define V_udp_cksum VNET(udp_cksum)
164#define V_udp_bind_all_fibs VNET(udp_bind_all_fibs)
157165#define V_udp_blackhole VNET(udp_blackhole)
158166#define V_udp_blackhole_local VNET(udp_blackhole_local)
167#define V_udp_cksum VNET(udp_cksum)
159168#define V_udp_log_in_vain VNET(udp_log_in_vain)
160169
161170VNET_DECLARE(int, zero_checksum_port);
......@@ -170,7 +179,7 @@ udp_get_inpcbinfo(int protocol)
170179int udp_ctloutput(struct socket *, struct sockopt *);
171180void udplite_input(struct mbuf *, int);
172181struct inpcb *udp_notify(struct inpcb *inp, int errno);
173int udp_shutdown(struct socket *so);
182int udp_shutdown(struct socket *, enum shutdown_how);
174183
175184int udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f,
176185 udp_tun_icmp_t i, void *ctx);
lib/libc/include/generic-freebsd/netinet6/in6.h+7-8
......@@ -58,8 +58,6 @@
5858 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5959 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6060 * SUCH DAMAGE.
61 *
62 * @(#)in.h 8.3 (Berkeley) 1/3/94
6361 */
6462
6563#ifndef __KAME_NETINET_IN_H_INCLUDED_
......@@ -360,11 +358,11 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
360358
361359#define IFA6_IS_DEPRECATED(a) \
362360 ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
363 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
361 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) >= \
364362 (a)->ia6_lifetime.ia6t_pltime)
365363#define IFA6_IS_INVALID(a) \
366364 ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
367 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
365 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) >= \
368366 (a)->ia6_lifetime.ia6t_vltime)
369367#endif /* _KERNEL */
370368
......@@ -666,6 +664,8 @@ struct ip6_hdr;
666664
667665int in6_cksum(struct mbuf *, uint8_t, uint32_t, uint32_t);
668666int in6_cksum_partial(struct mbuf *, uint8_t, uint32_t, uint32_t, uint32_t);
667int in6_cksum_partial_l2(struct mbuf *m, uint8_t nxt, uint32_t off_l3,
668 uint32_t off_l4, uint32_t len, uint32_t cov);
669669int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t);
670670
671671int in6_localaddr(struct in6_addr *);
......@@ -679,11 +679,10 @@ extern void in6_if_up(struct ifnet *);
679679struct sockaddr;
680680
681681void in6_sin6_2_sin(struct sockaddr_in *sin,
682 struct sockaddr_in6 *sin6);
683void in6_sin_2_v4mapsin6(struct sockaddr_in *sin,
684 struct sockaddr_in6 *sin6);
682 const struct sockaddr_in6 *sin6);
683void in6_sin_2_v4mapsin6(const struct sockaddr_in *sin,
684 struct sockaddr_in6 *sin6);
685685void in6_sin6_2_sin_in_sock(struct sockaddr *nam);
686void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam);
687686extern void addrsel_policy_init(void);
688687
689688#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
lib/libc/include/generic-freebsd/netinet6/in6_ifattach.h-1
......@@ -39,7 +39,6 @@ void in6_ifattach(struct ifnet *, struct ifnet *);
3939void in6_ifattach_destroy(void);
4040void in6_ifdetach(struct ifnet *);
4141void in6_ifdetach_destroy(struct ifnet *);
42int in6_get_tmpifid(struct ifnet *, u_int8_t *, const u_int8_t *, int);
4342void in6_tmpaddrtimer(void *);
4443int in6_get_hw_ifid(struct ifnet *, struct in6_addr *);
4544int in6_nigroup(struct ifnet *, const char *, int, struct in6_addr *);
lib/libc/include/generic-freebsd/netinet6/in6_pcb.h+14-26
......@@ -58,8 +58,6 @@
5858 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5959 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6060 * SUCH DAMAGE.
61 *
62 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
6361 */
6462
6563#ifndef _NETINET6_IN6_PCB_H_
......@@ -72,40 +70,30 @@
7270
7371void in6_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
7472void in6_losing(struct inpcb *);
75int in6_pcbbind(struct inpcb *, struct sockaddr_in6 *, struct ucred *);
73int in6_pcbbind(struct inpcb *, struct sockaddr_in6 *, int, struct ucred *);
7674int in6_pcbconnect(struct inpcb *, struct sockaddr_in6 *, struct ucred *,
7775 bool);
7876void in6_pcbdisconnect(struct inpcb *);
79struct inpcb *
80 in6_pcblookup_local(struct inpcbinfo *,
81 struct in6_addr *, u_short, int,
82 struct ucred *);
83struct inpcb *
84 in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo,
77struct inpcb *in6_pcblookup_local(struct inpcbinfo *, const struct in6_addr *,
78 u_short, int, int, struct ucred *);
79struct inpcb *in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo,
8580 const struct in6_addr *faddr, u_int fport_arg,
8681 const struct in6_addr *laddr, u_int lport_arg,
87 int lookupflags, uint8_t);
88struct inpcb *
89 in6_pcblookup(struct inpcbinfo *, struct in6_addr *,
90 u_int, struct in6_addr *, u_int, int,
91 struct ifnet *);
92struct inpcb *
93 in6_pcblookup_mbuf(struct inpcbinfo *, struct in6_addr *,
94 u_int, struct in6_addr *, u_int, int,
95 struct ifnet *ifp, struct mbuf *);
82 int lookupflags, uint8_t numa_domain, int fib);
83struct inpcb *in6_pcblookup(struct inpcbinfo *, const struct in6_addr *, u_int,
84 const struct in6_addr *, u_int, int, struct ifnet *);
85struct inpcb *in6_pcblookup_mbuf(struct inpcbinfo *, const struct in6_addr *,
86 u_int, const struct in6_addr *, u_int, int, struct ifnet *ifp,
87 struct mbuf *);
9688void in6_pcbnotify(struct inpcbinfo *, struct sockaddr_in6 *, u_int,
9789 const struct sockaddr_in6 *, u_int, int, void *,
9890 struct inpcb *(*)(struct inpcb *, int));
9991struct inpcb *
10092 in6_rtchange(struct inpcb *, int);
101struct sockaddr *
102 in6_sockaddr(in_port_t port, struct in6_addr *addr_p);
103struct sockaddr *
104 in6_v4mapsin6_sockaddr(in_port_t port, struct in_addr *addr_p);
105int in6_getpeeraddr(struct socket *so, struct sockaddr **nam);
106int in6_getsockaddr(struct socket *so, struct sockaddr **nam);
107int in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam);
108int in6_mapped_peeraddr(struct socket *so, struct sockaddr **nam);
93int in6_getpeeraddr(struct socket *, struct sockaddr *);
94int in6_getsockaddr(struct socket *, struct sockaddr *);
95int in6_mapped_sockaddr(struct socket *, struct sockaddr *);
96int in6_mapped_peeraddr(struct socket *, struct sockaddr *);
10997int in6_selecthlim(struct inpcb *, struct ifnet *);
11098int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *);
11199void init_sin6(struct sockaddr_in6 *sin6, struct mbuf *m, int);
lib/libc/include/generic-freebsd/netinet6/in6_var.h+2-10
......@@ -58,8 +58,6 @@
5858 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5959 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6060 * SUCH DAMAGE.
61 *
62 * @(#)in_var.h 8.1 (Berkeley) 6/10/93
6361 */
6462
6563#ifndef _NETINET6_IN6_VAR_H_
......@@ -117,7 +115,7 @@ struct in6_ifextra {
117115SLIST_HEAD(in6_multi_head, in6_multi);
118116MALLOC_DECLARE(M_IP6MADDR);
119117
120struct in6_ifaddr {
118struct in6_ifaddr {
121119 struct ifaddr ia_ifa; /* protocol-independent info */
122120#define ia_ifp ia_ifa.ifa_ifp
123121#define ia_flags ia_ifa.ifa_flags
......@@ -325,8 +323,7 @@ struct in6_prflags {
325323 struct prf_ra {
326324 u_char onlink : 1;
327325 u_char autonomous : 1;
328 u_char ra_derived: 1;
329 u_char reserved : 5;
326 u_char reserved : 6;
330327 } prf_ra;
331328 u_char prf_reserved1;
332329 u_short prf_reserved2;
......@@ -357,7 +354,6 @@ struct in6_prefixreq {
357354
358355#define ipr_raf_onlink ipr_flags.prf_ra.onlink
359356#define ipr_raf_auto ipr_flags.prf_ra.autonomous
360#define ipr_raf_ra_derived ipr_flags.prf_ra.ra_derived
361357
362358#define ipr_statef_onlink ipr_flags.prf_state.onlink
363359
......@@ -551,9 +547,6 @@ do { \
551547 ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[ \
552548 offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\
553549} while (/*CONSTCOND*/ 0)
554
555VNET_DECLARE(unsigned long, in6_maxmtu);
556#define V_in6_maxmtu VNET(in6_maxmtu)
557550#endif /* _KERNEL */
558551
559552/*
......@@ -877,7 +870,6 @@ void in6_domifdetach(struct ifnet *, void *);
877870int in6_domifmtu(struct ifnet *);
878871struct rib_head *in6_inithead(uint32_t fibnum);
879872void in6_detachhead(struct rib_head *rh);
880void in6_setmaxmtu(void);
881873int in6_if2idlen(struct ifnet *);
882874struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
883875struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, const struct in6_addr *);
lib/libc/include/generic-freebsd/netinet6/ip6_var.h+51-26
......@@ -58,8 +58,6 @@
5858 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5959 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6060 * SUCH DAMAGE.
61 *
62 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
6361 */
6462
6563#ifndef _NETINET6_IP6_VAR_H_
......@@ -132,27 +130,26 @@ struct ip6po_nhinfo {
132130#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
133131#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route
134132
133/*
134 * Note that fields with valid data must be flagged in ip6po_valid.
135 * This is done to reduce cache misses in ip6_output(). Before
136 * ip6po_valid, ip6_output needed to check all the individual fields
137 * of ip6_pktopts needed to be checked themselves, and they are spread
138 * across 4 cachelines. ip6_output() is currently the only consumer of
139 * these flags, as it is in the critical path of every packet sent.
140 */
135141struct ip6_pktopts {
136 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */
137 int ip6po_hlim; /* Hoplimit for outgoing packets */
138
139 /* Outgoing IF/address information */
140 struct in6_pktinfo *ip6po_pktinfo;
141
142 /* Next-hop address information */
143 struct ip6po_nhinfo ip6po_nhinfo;
144
145 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
146
147 /* Destination options header (before a routing header) */
148 struct ip6_dest *ip6po_dest1;
149
150 /* Routing header related info. */
151 struct ip6po_rhinfo ip6po_rhinfo;
152
153 /* Destination options header (after a routing header) */
154 struct ip6_dest *ip6po_dest2;
142 uint32_t ip6po_valid;
143#define IP6PO_VALID_HLIM 0x0001
144#define IP6PO_VALID_PKTINFO 0x0002
145#define IP6PO_VALID_NHINFO 0x0004
146#define IP6PO_VALID_HBH 0x0008
147#define IP6PO_VALID_DEST1 0x0010
148#define IP6PO_VALID_RHINFO 0x0020
149#define IP6PO_VALID_DEST2 0x0040
150#define IP6PO_VALID_TC 0x0080
155151
152 int ip6po_hlim; /* Hoplimit for outgoing packets */
156153 int ip6po_tclass; /* traffic class */
157154
158155 int ip6po_minmtu; /* fragment vs PMTU discovery policy */
......@@ -173,6 +170,25 @@ struct ip6_pktopts {
173170#endif
174171#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
175172#define IP6PO_USECOA 0x08 /* use care of address */
173
174 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */
175
176 /* Outgoing IF/address information */
177 struct in6_pktinfo *ip6po_pktinfo;
178
179 /* Next-hop address information */
180 struct ip6po_nhinfo ip6po_nhinfo;
181
182 struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
183
184 /* Destination options header (before a routing header) */
185 struct ip6_dest *ip6po_dest1;
186
187 /* Routing header related info. */
188 struct ip6po_rhinfo ip6po_rhinfo;
189
190 /* Destination options header (after a routing header) */
191 struct ip6_dest *ip6po_dest2;
176192};
177193
178194/*
......@@ -247,13 +263,22 @@ struct ip6stat {
247263
248264#ifdef _KERNEL
249265#include <sys/counter.h>
266#include <netinet/in_kdtrace.h>
250267
251268VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat);
252#define IP6STAT_ADD(name, val) \
253 VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val))
254#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val))
269#define IP6STAT_ADD(name, val) \
270 do { \
271 MIB_SDT_PROBE1(ip6, count, name, (val)); \
272 VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)); \
273 } while (0)
274#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val))
255275#define IP6STAT_INC(name) IP6STAT_ADD(name, 1)
256#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1)
276#define IP6STAT_INC2(name, type) \
277 do { \
278 MIB_SDT_PROBE2(ip6, count, name, 1, type); \
279 VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, 1); \
280 } while (0)
281#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1)
257282#endif
258283
259284#ifdef _KERNEL
......@@ -389,7 +414,7 @@ int route6_input(struct mbuf **, int *, int);
389414void frag6_init(void);
390415void frag6_destroy(void);
391416int frag6_input(struct mbuf **, int *, int);
392void frag6_drain(void);
417void frag6_drain(void *, int);
393418
394419void rip6_init(void);
395420int rip6_ctloutput(struct socket *, struct sockopt *);
lib/libc/include/generic-freebsd/netinet6/ip_fw_nat64.h+7-3
......@@ -84,9 +84,9 @@ struct ipfw_nat64lsn_stats {
8484 uint64_t spgcreated; /* Number of portgroups created */
8585 uint64_t spgdeleted; /* Number of portgroups deleted */
8686 uint64_t hostcount; /* Number of hosts */
87 uint64_t tcpchunks; /* Number of TCP chunks */
88 uint64_t udpchunks; /* Number of UDP chunks */
89 uint64_t icmpchunks; /* Number of ICMP chunks */
87 uint64_t tcpchunks; /* Number of TCP portgroups */
88 uint64_t udpchunks; /* Number of UDP portgroups */
89 uint64_t icmpchunks; /* Number of ICMP portgroups */
9090
9191 uint64_t _reserved[4];
9292};
......@@ -95,6 +95,10 @@ struct ipfw_nat64lsn_stats {
9595#define NAT64_ALLOW_PRIVATE 0x0002 /* Allow private IPv4 address
9696 * translation
9797 */
98#define NAT64LSN_ALLOW_SWAPCONF 0x0004 /* Allow configuration exchange
99 * between NAT64LSN instances
100 * during the sets swapping.
101 */
98102typedef struct _ipfw_nat64stl_cfg {
99103 char name[64]; /* NAT name */
100104 ipfw_obj_ntlv ntlv6; /* object name tlv */
lib/libc/include/generic-freebsd/netinet6/nd6.h+4-3
......@@ -184,10 +184,10 @@ struct in6_ndifreq {
184184#define RETRANS_TIMER 1000 /* msec */
185185#define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
186186#define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */
187#define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */
187#define DEF_TEMP_VALID_LIFETIME 172800 /* 2 days */
188188#define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
189189#define TEMPADDR_REGEN_ADVANCE 5 /* sec */
190#define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */
190#define TEMP_MAX_DESYNC_FACTOR_BASE 300 /* 5 min */
191191#define ND_COMPUTE_RTIME(x) \
192192 (((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \
193193 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
......@@ -242,7 +242,6 @@ struct nd_prefix {
242242#define ndpr_raf ndpr_flags
243243#define ndpr_raf_onlink ndpr_flags.onlink
244244#define ndpr_raf_auto ndpr_flags.autonomous
245#define ndpr_raf_ra_derived ndpr_flags.ra_derived
246245#define ndpr_raf_router ndpr_flags.router
247246
248247struct nd_pfxrouter {
......@@ -293,11 +292,13 @@ VNET_DECLARE(struct mtx, nd6_onlink_mtx);
293292/* nd6_rtr.c */
294293VNET_DECLARE(int, nd6_defifindex);
295294VNET_DECLARE(int, ip6_desync_factor); /* seconds */
295VNET_DECLARE(uint32_t, ip6_temp_max_desync_factor); /* seconds */
296296VNET_DECLARE(u_int32_t, ip6_temp_preferred_lifetime); /* seconds */
297297VNET_DECLARE(u_int32_t, ip6_temp_valid_lifetime); /* seconds */
298298VNET_DECLARE(int, ip6_temp_regen_advance); /* seconds */
299299#define V_nd6_defifindex VNET(nd6_defifindex)
300300#define V_ip6_desync_factor VNET(ip6_desync_factor)
301#define V_ip6_temp_max_desync_factor VNET(ip6_temp_max_desync_factor)
301302#define V_ip6_temp_preferred_lifetime VNET(ip6_temp_preferred_lifetime)
302303#define V_ip6_temp_valid_lifetime VNET(ip6_temp_valid_lifetime)
303304#define V_ip6_temp_regen_advance VNET(ip6_temp_regen_advance)
lib/libc/include/generic-freebsd/netinet6/tcp6_var.h-2
......@@ -56,8 +56,6 @@
5656 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5757 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5858 * SUCH DAMAGE.
59 *
60 * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
6159 */
6260
6361#ifndef _NETINET_TCP6_VAR_H_
lib/libc/include/generic-freebsd/netinet6/udp6_var.h-2
......@@ -57,8 +57,6 @@
5757 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5858 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5959 * SUCH DAMAGE.
60 *
61 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93
6260 */
6361
6462#ifndef _NETINET6_UDP6_VAR_H_
lib/libc/include/generic-freebsd/netipsec/ah_var.h+11-2
......@@ -71,13 +71,22 @@ struct ahstat {
7171
7272#ifdef _KERNEL
7373#include <sys/counter.h>
74#include <netinet/in_kdtrace.h>
7475
7576VNET_DECLARE(int, ah_enable);
7677VNET_DECLARE(int, ah_cleartos);
7778VNET_PCPUSTAT_DECLARE(struct ahstat, ahstat);
7879
79#define AHSTAT_ADD(name, val) \
80 VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name , (val))
80#define AHSTAT_ADD(name, val) \
81 do { \
82 MIB_SDT_PROBE1(ah, count, name, (val)); \
83 VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name, (val)); \
84 } while (0)
85#define AHSTAT_INC2(name, type) \
86 do { \
87 MIB_SDT_PROBE2(ah, count, name, 1, (type)); \
88 VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name[type], 1); \
89 } while (0)
8190#define AHSTAT_INC(name) AHSTAT_ADD(name, 1)
8291#define V_ah_enable VNET(ah_enable)
8392#define V_ah_cleartos VNET(ah_cleartos)
lib/libc/include/generic-freebsd/netipsec/esp_var.h+14-2
......@@ -72,13 +72,25 @@ struct espstat {
7272
7373#ifdef _KERNEL
7474#include <sys/counter.h>
75#include <netinet/in_kdtrace.h>
7576
7677VNET_DECLARE(int, esp_enable);
78VNET_DECLARE(int, esp_ctr_compatibility);
79#define V_esp_ctr_compatibility VNET(esp_ctr_compatibility)
7780VNET_PCPUSTAT_DECLARE(struct espstat, espstat);
7881
79#define ESPSTAT_ADD(name, val) \
80 VNET_PCPUSTAT_ADD(struct espstat, espstat, name, (val))
82#define ESPSTAT_ADD(name, val) \
83 do { \
84 MIB_SDT_PROBE1(esp, count, name, (val)); \
85 VNET_PCPUSTAT_ADD(struct espstat, espstat, name, (val)); \
86 } while (0)
8187#define ESPSTAT_INC(name) ESPSTAT_ADD(name, 1)
88#define ESPSTAT_INC2(name, type) \
89 do { \
90 MIB_SDT_PROBE2(esp, count, name, 1, (type)); \
91 VNET_PCPUSTAT_ADD(struct espstat, espstat, name[type], 1); \
92 } while (0)
93
8294#define V_esp_enable VNET(esp_enable)
8395#endif /* _KERNEL */
8496#endif /*_NETIPSEC_ESP_VAR_H_*/
\ No newline at end of file
lib/libc/include/generic-freebsd/netipsec/ipcomp_var.h+12-2
......@@ -66,12 +66,22 @@ struct ipcompstat {
6666
6767#ifdef _KERNEL
6868#include <sys/counter.h>
69#include <netinet/in_kdtrace.h>
6970
7071VNET_DECLARE(int, ipcomp_enable);
7172VNET_PCPUSTAT_DECLARE(struct ipcompstat, ipcompstat);
7273
73#define IPCOMPSTAT_ADD(name, val) \
74 VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, name, (val))
74#define IPCOMPSTAT_ADD(name, val) \
75 do { \
76 MIB_SDT_PROBE1(ipcomp, count, name, (val)); \
77 VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, name, (val)); \
78 } while (0)
79#define IPCOMPSTAT_INC2(name, type) \
80 do { \
81 MIB_SDT_PROBE2(ipcomp, count, name, 1, (type)); \
82 VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, name[type], \
83 1); \
84 } while (0)
7585#define IPCOMPSTAT_INC(name) IPCOMPSTAT_ADD(name, 1)
7686#define V_ipcomp_enable VNET(ipcomp_enable)
7787#endif /* _KERNEL */
lib/libc/include/generic-freebsd/netipsec/ipsec.h+44-17
......@@ -46,6 +46,9 @@
4646#include <sys/_lock.h>
4747#include <sys/_mutex.h>
4848#include <sys/_rwlock.h>
49#include <sys/sysctl.h>
50
51#include <netinet/in_kdtrace.h>
4952
5053#define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m)
5154
......@@ -71,6 +74,12 @@ struct ipsecrequest {
7174 u_int level; /* IPsec level defined below. */
7275};
7376
77struct ipsec_accel_adddel_sp_tq {
78 struct vnet *adddel_vnet;
79 struct task adddel_task;
80 int adddel_scheduled;
81};
82
7483/* Security Policy Data Base */
7584struct secpolicy {
7685 TAILQ_ENTRY(secpolicy) chain;
......@@ -93,7 +102,7 @@ struct secpolicy {
93102 uint32_t id; /* It's unique number on the system. */
94103 /*
95104 * lifetime handler.
96 * the policy can be used without limitiation if both lifetime and
105 * the policy can be used without limitation if both lifetime and
97106 * validtime are zero.
98107 * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime.
99108 * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime.
......@@ -102,6 +111,11 @@ struct secpolicy {
102111 time_t lastused; /* updated every when kernel sends a packet */
103112 long lifetime; /* duration of the lifetime of this policy */
104113 long validtime; /* duration this policy is valid without use */
114 CK_LIST_HEAD(, ifp_handle_sp) accel_ifps;
115 struct ipsec_accel_adddel_sp_tq accel_add_tq;
116 struct ipsec_accel_adddel_sp_tq accel_del_tq;
117 struct inpcb *ipsec_accel_add_sp_inp;
118 const char *accel_ifname;
105119};
106120
107121/*
......@@ -246,6 +260,7 @@ struct ipsecstat {
246260#define IPSECCTL_DEBUG 12
247261#define IPSECCTL_ESP_RANDPAD 13
248262#define IPSECCTL_MIN_PMTU 14
263#define IPSECCTL_RANDOM_ID 15
249264
250265#ifdef _KERNEL
251266#include <sys/counter.h>
......@@ -279,12 +294,17 @@ VNET_DECLARE(int, ip4_ah_net_deflev);
279294VNET_DECLARE(int, ip4_ipsec_dfbit);
280295VNET_DECLARE(int, ip4_ipsec_min_pmtu);
281296VNET_DECLARE(int, ip4_ipsec_ecn);
297VNET_DECLARE(int, ip4_ipsec_random_id);
282298VNET_DECLARE(int, crypto_support);
283299VNET_DECLARE(int, async_crypto);
284300VNET_DECLARE(int, natt_cksum_policy);
285301
286#define IPSECSTAT_INC(name) \
287 VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1)
302#define IPSECSTAT_INC(name) \
303 do { \
304 MIB_SDT_PROBE1(ipsec, count, name, 1); \
305 VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1); \
306 } while (0)
307
288308#define V_ip4_esp_trans_deflev VNET(ip4_esp_trans_deflev)
289309#define V_ip4_esp_net_deflev VNET(ip4_esp_net_deflev)
290310#define V_ip4_ah_trans_deflev VNET(ip4_ah_trans_deflev)
......@@ -292,6 +312,7 @@ VNET_DECLARE(int, natt_cksum_policy);
292312#define V_ip4_ipsec_dfbit VNET(ip4_ipsec_dfbit)
293313#define V_ip4_ipsec_min_pmtu VNET(ip4_ipsec_min_pmtu)
294314#define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn)
315#define V_ip4_ipsec_random_id VNET(ip4_ipsec_random_id)
295316#define V_crypto_support VNET(crypto_support)
296317#define V_async_crypto VNET(async_crypto)
297318#define V_natt_cksum_policy VNET(natt_cksum_policy)
......@@ -307,6 +328,7 @@ VNET_DECLARE(int, natt_cksum_policy);
307328#endif
308329
309330struct inpcb;
331struct ip;
310332struct m_tag;
311333struct secasvar;
312334struct sockopt;
......@@ -318,7 +340,7 @@ int ipsec_if_input(struct mbuf *, struct secasvar *, uint32_t);
318340struct ipsecrequest *ipsec_newisr(void);
319341void ipsec_delisr(struct ipsecrequest *);
320342struct secpolicy *ipsec4_checkpolicy(const struct mbuf *, struct inpcb *,
321 int *, int);
343 struct ip *, int *, int);
322344
323345u_int ipsec_get_reqlevel(struct secpolicy *, u_int);
324346
......@@ -333,27 +355,32 @@ size_t ipsec_hdrsiz_internal(struct secpolicy *);
333355
334356void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int);
335357
336void ipsec4_setsockaddrs(const struct mbuf *, union sockaddr_union *,
337 union sockaddr_union *);
358void ipsec4_setsockaddrs(const struct mbuf *, const struct ip *,
359 union sockaddr_union *, union sockaddr_union *);
338360int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int);
339int ipsec4_check_pmtu(struct mbuf *, struct secpolicy *, int);
340int ipsec4_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *);
361int ipsec4_check_pmtu(struct ifnet *, struct mbuf *, struct ip *ip1,
362 struct secpolicy *, int);
363int ipsec4_process_packet(struct ifnet *, struct mbuf *, struct ip *ip1,
364 struct secpolicy *, struct inpcb *, u_long);
341365int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *,
342366 u_int);
343367
344extern void m_checkalignment(const char* where, struct mbuf *m0,
345 int off, int len);
346extern struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off);
347extern caddr_t m_pad(struct mbuf *m, int n);
348extern int m_striphdr(struct mbuf *m, int skip, int hlen);
368void m_checkalignment(const char* where, struct mbuf *m0,
369 int off, int len);
370struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off);
371caddr_t m_pad(struct mbuf *m, int n);
372int m_striphdr(struct mbuf *m, int skip, int hlen);
373
374SYSCTL_DECL(_net_inet_ipsec);
375SYSCTL_DECL(_net_inet6_ipsec6);
349376
350377#endif /* _KERNEL */
351378
352379#ifndef _KERNEL
353extern caddr_t ipsec_set_policy(char *, int);
354extern int ipsec_get_policylen(caddr_t);
355extern char *ipsec_dump_policy(caddr_t, char *);
356extern const char *ipsec_strerror(void);
380caddr_t ipsec_set_policy(const char *, int);
381int ipsec_get_policylen(c_caddr_t);
382char *ipsec_dump_policy(c_caddr_t, const char *);
383const char *ipsec_strerror(void);
357384
358385#endif /* ! KERNEL */
359386
lib/libc/include/generic-freebsd/netipsec/ipsec6.h+3-2
......@@ -66,8 +66,9 @@ struct secpolicy *ipsec6_checkpolicy(const struct mbuf *,
6666void ipsec6_setsockaddrs(const struct mbuf *, union sockaddr_union *,
6767 union sockaddr_union *);
6868int ipsec6_common_input_cb(struct mbuf *, struct secasvar *, int, int);
69int ipsec6_check_pmtu(struct mbuf *, struct secpolicy *, int);
70int ipsec6_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *);
69int ipsec6_check_pmtu(struct ifnet *, struct mbuf *, struct secpolicy *, int);
70int ipsec6_process_packet(struct ifnet *, struct mbuf *, struct secpolicy *,
71 struct inpcb *, u_long);
7172
7273int ip6_ipsec_filtertunnel(struct mbuf *);
7374int ip6_ipsec_pcbctl(struct inpcb *, struct sockopt *);
lib/libc/include/generic-freebsd/netipsec/ipsec_offload.h created+217
......@@ -0,0 +1,217 @@
1/*-
2 * Copyright (c) 2021,2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#ifndef _NETIPSEC_IPSEC_OFFLOAD_H_
27#define _NETIPSEC_IPSEC_OFFLOAD_H_
28
29#ifdef _KERNEL
30#include <sys/errno.h>
31#include <net/if.h>
32#include <net/if_var.h>
33#include <netipsec/xform.h>
34
35struct secpolicy;
36struct secasvar;
37struct inpcb;
38
39struct ipsec_accel_out_tag {
40 struct m_tag tag;
41 uint16_t drv_spi;
42};
43
44struct ipsec_accel_in_tag {
45 struct m_tag tag;
46 struct xform_history xh; /* Must be first to mimic IPSEC_IN_DONE */
47 uint16_t drv_spi;
48};
49
50#define IPSEC_ACCEL_DRV_SPI_BYPASS 2
51#define IPSEC_ACCEL_DRV_SPI_MIN 3
52#define IPSEC_ACCEL_DRV_SPI_MAX 0xffff
53
54extern void (*ipsec_accel_sa_newkey_p)(struct secasvar *sav);
55extern void (*ipsec_accel_sa_install_input_p)(struct secasvar *sav,
56 const union sockaddr_union *dst_address, int sproto, uint32_t spi);
57extern void (*ipsec_accel_forget_sav_p)(struct secasvar *sav);
58extern void (*ipsec_accel_spdadd_p)(struct secpolicy *sp, struct inpcb *inp);
59extern void (*ipsec_accel_spddel_p)(struct secpolicy *sp);
60extern int (*ipsec_accel_sa_lifetime_op_p)(struct secasvar *sav,
61 struct seclifetime *lft_c, if_t ifp, enum IF_SA_CNT_WHICH op,
62 struct rm_priotracker *sahtree_trackerp);
63extern void (*ipsec_accel_sync_p)(void);
64extern bool (*ipsec_accel_is_accel_sav_p)(struct secasvar *sav);
65extern struct mbuf *(*ipsec_accel_key_setaccelif_p)(struct secasvar *sav);
66extern void (*ipsec_accel_on_ifdown_p)(struct ifnet *ifp);
67extern void (*ipsec_accel_drv_sa_lifetime_update_p)(struct secasvar *sav,
68 if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs);
69extern int (*ipsec_accel_drv_sa_lifetime_fetch_p)(struct secasvar *sav,
70 if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs);
71extern bool (*ipsec_accel_fill_xh_p)(if_t ifp, uint32_t drv_spi,
72 struct xform_history *xh);
73
74#ifdef IPSEC_OFFLOAD
75/*
76 * Have to use ipsec_accel_sa_install_input_p indirection because
77 * key.c is unconditionally included into the static kernel.
78 */
79static inline void
80ipsec_accel_sa_newkey(struct secasvar *sav)
81{
82 void (*p)(struct secasvar *sav);
83
84 p = atomic_load_ptr(&ipsec_accel_sa_newkey_p);
85 if (p != NULL)
86 p(sav);
87}
88
89static inline void
90ipsec_accel_forget_sav(struct secasvar *sav)
91{
92 void (*p)(struct secasvar *sav);
93
94 p = atomic_load_ptr(&ipsec_accel_forget_sav_p);
95 if (p != NULL)
96 p(sav);
97}
98
99static inline void
100ipsec_accel_spdadd(struct secpolicy *sp, struct inpcb *inp)
101{
102 void (*p)(struct secpolicy *sp, struct inpcb *inp);
103
104 p = atomic_load_ptr(&ipsec_accel_spdadd_p);
105 if (p != NULL)
106 p(sp, inp);
107}
108
109static inline void
110ipsec_accel_spddel(struct secpolicy *sp)
111{
112 void (*p)(struct secpolicy *sp);
113
114 p = atomic_load_ptr(&ipsec_accel_spddel_p);
115 if (p != NULL)
116 p(sp);
117}
118
119static inline int
120ipsec_accel_sa_lifetime_op(struct secasvar *sav,
121 struct seclifetime *lft_c, if_t ifp, enum IF_SA_CNT_WHICH op,
122 struct rm_priotracker *sahtree_trackerp)
123{
124 int (*p)(struct secasvar *sav, struct seclifetime *lft_c, if_t ifp,
125 enum IF_SA_CNT_WHICH op, struct rm_priotracker *sahtree_trackerp);
126
127 p = atomic_load_ptr(&ipsec_accel_sa_lifetime_op_p);
128 if (p != NULL)
129 return (p(sav, lft_c, ifp, op, sahtree_trackerp));
130 return (ENOTSUP);
131}
132
133static inline void
134ipsec_accel_sync(void)
135{
136 void (*p)(void);
137
138 p = atomic_load_ptr(&ipsec_accel_sync_p);
139 if (p != NULL)
140 p();
141}
142
143static inline bool
144ipsec_accel_is_accel_sav(struct secasvar *sav)
145{
146 bool (*p)(struct secasvar *sav);
147
148 p = atomic_load_ptr(&ipsec_accel_is_accel_sav_p);
149 if (p != NULL)
150 return (p(sav));
151 return (false);
152}
153
154static inline struct mbuf *
155ipsec_accel_key_setaccelif(struct secasvar *sav)
156{
157 struct mbuf *(*p)(struct secasvar *sav);
158
159 p = atomic_load_ptr(&ipsec_accel_key_setaccelif_p);
160 if (p != NULL)
161 return (p(sav));
162 return (NULL);
163}
164
165static inline bool
166ipsec_accel_fill_xh(if_t ifp, uint32_t drv_spi, struct xform_history *xh)
167{
168 bool (*p)(if_t ifp, uint32_t drv_spi, struct xform_history *xh);
169
170 p = atomic_load_ptr(&ipsec_accel_fill_xh_p);
171 if (p != NULL)
172 return (p(ifp, drv_spi, xh));
173 return (false);
174}
175
176#else
177#define ipsec_accel_sa_newkey(a)
178#define ipsec_accel_forget_sav(a)
179#define ipsec_accel_spdadd(a, b)
180#define ipsec_accel_spddel(a)
181#define ipsec_accel_sa_lifetime_op(a, b, c, d, e)
182#define ipsec_accel_sync()
183#define ipsec_accel_is_accel_sav(a)
184#define ipsec_accel_key_setaccelif(a)
185#define ipsec_accel_fill_xh(a, b, c) (false)
186#endif
187
188void ipsec_accel_forget_sav_impl(struct secasvar *sav);
189void ipsec_accel_spdadd_impl(struct secpolicy *sp, struct inpcb *inp);
190void ipsec_accel_spddel_impl(struct secpolicy *sp);
191
192#ifdef IPSEC_OFFLOAD
193int ipsec_accel_input(struct mbuf *m, int offset, int proto);
194bool ipsec_accel_output(struct ifnet *ifp, struct mbuf *m,
195 struct inpcb *inp, struct secpolicy *sp, struct secasvar *sav, int af,
196 int mtu, int *hwassist);
197void ipsec_accel_forget_sav(struct secasvar *sav);
198struct xform_history;
199#else
200#define ipsec_accel_input(a, b, c) (ENXIO)
201#define ipsec_accel_output(a, b, c, d, e, f, g, h) ({ \
202 *h = 0; \
203 false; \
204})
205#define ipsec_accel_forget_sav(a)
206#endif
207
208struct ipsec_accel_in_tag *ipsec_accel_input_tag_lookup(const struct mbuf *);
209void ipsec_accel_on_ifdown(struct ifnet *ifp);
210void ipsec_accel_drv_sa_lifetime_update(struct secasvar *sav, if_t ifp,
211 u_int drv_spi, uint64_t octets, uint64_t allocs);
212int ipsec_accel_drv_sa_lifetime_fetch(struct secasvar *sav,
213 if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs);
214
215#endif /* _KERNEL */
216
217#endif /* _NETIPSEC_IPSEC_OFFLOAD_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netipsec/ipsec_support.h+20-14
......@@ -29,6 +29,8 @@
2929
3030#ifdef _KERNEL
3131#if defined(IPSEC) || defined(IPSEC_SUPPORT)
32struct ifnet;
33struct ip;
3234struct mbuf;
3335struct inpcb;
3436struct tcphdr;
......@@ -49,14 +51,17 @@ int ipsec_init_pcbpolicy(struct inpcb *);
4951int ipsec_delete_pcbpolicy(struct inpcb *);
5052int ipsec_copy_pcbpolicy(struct inpcb *, struct inpcb *);
5153
52#ifdef INET
54#if defined(INET) || defined(INET6)
5355int udp_ipsec_input(struct mbuf *, int, int);
5456int udp_ipsec_pcbctl(struct inpcb *, struct sockopt *);
57#endif
58#ifdef INET
5559int ipsec4_in_reject(const struct mbuf *, struct inpcb *);
60int ipsec4_in_reject1(const struct mbuf *m, struct ip *ip1, struct inpcb *inp);
5661int ipsec4_input(struct mbuf *, int, int);
5762int ipsec4_forward(struct mbuf *);
5863int ipsec4_pcbctl(struct inpcb *, struct sockopt *);
59int ipsec4_output(struct mbuf *, struct inpcb *);
64int ipsec4_output(struct ifnet *, struct mbuf *, struct inpcb *, u_long);
6065int ipsec4_capability(struct mbuf *, u_int);
6166int ipsec4_ctlinput(ipsec_ctlinput_param_t);
6267#endif /* INET */
......@@ -66,7 +71,7 @@ int ipsec6_input(struct mbuf *, int, int);
6671int ipsec6_in_reject(const struct mbuf *, struct inpcb *);
6772int ipsec6_forward(struct mbuf *);
6873int ipsec6_pcbctl(struct inpcb *, struct sockopt *);
69int ipsec6_output(struct mbuf *, struct inpcb *);
74int ipsec6_output(struct ifnet *, struct mbuf *, struct inpcb *, u_long);
7075int ipsec6_capability(struct mbuf *, u_int);
7176int ipsec6_ctlinput(ipsec_ctlinput_param_t);
7277#endif /* INET6 */
......@@ -75,7 +80,8 @@ struct ipsec_methods {
7580 int (*input)(struct mbuf *, int, int);
7681 int (*check_policy)(const struct mbuf *, struct inpcb *);
7782 int (*forward)(struct mbuf *);
78 int (*output)(struct mbuf *, struct inpcb *);
83 int (*output)(struct ifnet *, struct mbuf *, struct inpcb *,
84 u_long);
7985 int (*pcbctl)(struct inpcb *, struct sockopt *);
8086 size_t (*hdrsize)(struct inpcb *);
8187 int (*capability)(struct mbuf *, u_int);
......@@ -164,10 +170,10 @@ extern const struct ipsec_support * const ipv6_ipsec_support;
164170#define IPSEC_CTLINPUT(proto, param) \
165171 (*(proto ## _ipsec_support)->methods->ctlinput)(param)
166172
167#define UDPENCAP_INPUT(m, ...) \
168 (*ipv4_ipsec_support->methods->udp_input)(m, __VA_ARGS__)
169#define UDPENCAP_PCBCTL(inp, sopt) \
170 (*ipv4_ipsec_support->methods->udp_pcbctl)(inp, sopt)
173#define UDPENCAP_INPUT(proto, m, ...) \
174 (*(proto ## _ipsec_support)->methods->udp_input)(m, __VA_ARGS__)
175#define UDPENCAP_PCBCTL(proto, inp, sopt) \
176 (*(proto ## _ipsec_support)->methods->udp_pcbctl)(inp, sopt)
171177
172178#elif defined(IPSEC_SUPPORT)
173179struct ipsec_support {
......@@ -185,8 +191,8 @@ int ipsec_kmod_input(struct ipsec_support * const, struct mbuf *, int, int);
185191int ipsec_kmod_check_policy(struct ipsec_support * const, struct mbuf *,
186192 struct inpcb *);
187193int ipsec_kmod_forward(struct ipsec_support * const, struct mbuf *);
188int ipsec_kmod_output(struct ipsec_support * const, struct mbuf *,
189 struct inpcb *);
194int ipsec_kmod_output(struct ipsec_support * const, struct ifnet *,
195 struct mbuf *, struct inpcb *, u_long);
190196int ipsec_kmod_pcbctl(struct ipsec_support * const, struct inpcb *,
191197 struct sockopt *);
192198int ipsec_kmod_capability(struct ipsec_support * const, struct mbuf *, u_int);
......@@ -196,10 +202,10 @@ int ipsec_kmod_udp_input(struct ipsec_support * const, struct mbuf *, int, int);
196202int ipsec_kmod_udp_pcbctl(struct ipsec_support * const, struct inpcb *,
197203 struct sockopt *);
198204
199#define UDPENCAP_INPUT(m, ...) \
200 ipsec_kmod_udp_input(ipv4_ipsec_support, m, __VA_ARGS__)
201#define UDPENCAP_PCBCTL(inp, sopt) \
202 ipsec_kmod_udp_pcbctl(ipv4_ipsec_support, inp, sopt)
205#define UDPENCAP_INPUT(proto, m, ...) \
206 ipsec_kmod_udp_input(proto ## _ipsec_support, m, __VA_ARGS__)
207#define UDPENCAP_PCBCTL(proto, inp, sopt) \
208 ipsec_kmod_udp_pcbctl(proto ## _ipsec_support, inp, sopt)
203209
204210#define IPSEC_INPUT(proto, ...) \
205211 ipsec_kmod_input(proto ## _ipsec_support, __VA_ARGS__)
lib/libc/include/generic-freebsd/netipsec/key.h+7
......@@ -36,6 +36,7 @@
3636
3737#ifdef _KERNEL
3838
39struct mbuf;
3940struct secpolicy;
4041struct secpolicyindex;
4142struct secasvar;
......@@ -49,6 +50,7 @@ struct xformsw;
4950
5051struct secpolicy *key_newsp(void);
5152struct secpolicy *key_allocsp(struct secpolicyindex *, u_int);
53struct secpolicy *key_do_allocsp(struct secpolicyindex *spidx, u_int dir);
5254struct secpolicy *key_msg2sp(struct sadb_x_policy *, size_t, int *);
5355int key_sp2msg(struct secpolicy *, void *, size_t *);
5456void key_addref(struct secpolicy *);
......@@ -59,6 +61,7 @@ int key_havesp_any(void);
5961void key_bumpspgen(void);
6062uint32_t key_getspgen(void);
6163uint32_t key_newreqid(void);
64struct mbuf *key_setaccelif(const char *ifname);
6265
6366struct secasvar *key_allocsa(union sockaddr_union *, uint8_t, uint32_t);
6467struct secasvar *key_allocsa_tunnel(union sockaddr_union *,
......@@ -84,6 +87,10 @@ extern void key_sa_recordxfer(struct secasvar *, struct mbuf *);
8487uint16_t key_portfromsaddr(struct sockaddr *);
8588void key_porttosaddr(struct sockaddr *, uint16_t port);
8689
90struct rm_priotracker;
91void ipsec_sahtree_runlock(struct rm_priotracker *);
92void ipsec_sahtree_rlock(struct rm_priotracker *);
93
8794#ifdef MALLOC_DECLARE
8895MALLOC_DECLARE(M_IPSEC_SA);
8996MALLOC_DECLARE(M_IPSEC_SAH);
lib/libc/include/generic-freebsd/netipsec/keydb.h+14
......@@ -36,9 +36,11 @@
3636
3737#ifdef _KERNEL
3838#include <sys/counter.h>
39#include <sys/ck.h>
3940#include <sys/lock.h>
4041#include <sys/mutex.h>
4142#include <sys/rmlock.h>
43#include <sys/_task.h>
4244
4345#include <netipsec/key_var.h>
4446#include <opencrypto/_cryptodev.h>
......@@ -125,6 +127,7 @@ struct xformsw;
125127struct enc_xform;
126128struct auth_hash;
127129struct comp_algo;
130struct ifp_handle_sav;
128131
129132/*
130133 * Security Association
......@@ -185,8 +188,19 @@ struct secasvar {
185188
186189 uint64_t cntr; /* counter for GCM and CTR */
187190 volatile u_int refcnt; /* reference count */
191 CK_LIST_HEAD(, ifp_handle_sav) accel_ifps;
192 uintptr_t accel_forget_tq;
193 const char *accel_ifname;
194 uint32_t accel_flags;
195 counter_u64_t accel_lft_sw;
196 uint64_t accel_hw_allocs;
197 uint64_t accel_hw_octets;
198 uint64_t accel_firstused;
188199};
189200
201#define SADB_KEY_ACCEL_INST 0x00000001
202#define SADB_KEY_ACCEL_DEINST 0x00000002
203
190204#define SECASVAR_RLOCK_TRACKER struct rm_priotracker _secas_tracker
191205#define SECASVAR_RLOCK(_sav) rm_rlock((_sav)->lock, &_secas_tracker)
192206#define SECASVAR_RUNLOCK(_sav) rm_runlock((_sav)->lock, &_secas_tracker)
lib/libc/include/generic-freebsd/netlink/ktest_netlink_message_writer.h+3-17
......@@ -30,28 +30,14 @@
3030
3131#if defined(_KERNEL) && defined(INVARIANTS)
3232
33bool nlmsg_get_buf_type_wrapper(struct nl_writer *nw, int size, int type, bool waitok);
34void nlmsg_set_callback_wrapper(struct nl_writer *nw);
35struct mbuf *nl_get_mbuf_chain_wrapper(int len, int malloc_flags);
33bool nlmsg_get_buf_wrapper(struct nl_writer *nw, size_t size, bool waitok);
3634
3735#ifndef KTEST_CALLER
3836
3937bool
40nlmsg_get_buf_type_wrapper(struct nl_writer *nw, int size, int type, bool waitok)
38nlmsg_get_buf_wrapper(struct nl_writer *nw, size_t size, bool waitok)
4139{
42 return (nlmsg_get_buf_type(nw, size, type, waitok));
43}
44
45void
46nlmsg_set_callback_wrapper(struct nl_writer *nw)
47{
48 nlmsg_set_callback(nw);
49}
50
51struct mbuf *
52nl_get_mbuf_chain_wrapper(int len, int malloc_flags)
53{
54 return (nl_get_mbuf_chain(len, malloc_flags));
40 return (nlmsg_get_buf(nw, size, waitok));
5541}
5642#endif
5743
lib/libc/include/generic-freebsd/netlink/netlink.h+11-15
......@@ -61,7 +61,7 @@
6161#ifndef _NETLINK_NETLINK_H_
6262#define _NETLINK_NETLINK_H_
6363
64#include <sys/types.h>
64#include <sys/param.h>
6565#include <sys/socket.h>
6666
6767struct sockaddr_nl {
......@@ -194,11 +194,8 @@ enum nlmsginfo_attrs {
194194};
195195
196196
197#ifndef roundup2
198#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
199#endif
200197#define NL_ITEM_ALIGN_SIZE sizeof(uint32_t)
201#define NL_ITEM_ALIGN(_len) roundup2(_len, NL_ITEM_ALIGN_SIZE)
198#define NL_ITEM_ALIGN(_len) __align_up(_len, NL_ITEM_ALIGN_SIZE)
202199#define NL_ITEM_DATA(_ptr, _off) ((void *)((char *)(_ptr) + _off))
203200#define NL_ITEM_DATA_CONST(_ptr, _off) ((const void *)((const char *)(_ptr) + _off))
204201
......@@ -208,25 +205,24 @@ enum nlmsginfo_attrs {
208205#define NL_ITEM_ITER(_ptr, _len, _LEN_MACRO) \
209206 ((_len) -= _LEN_MACRO(_ptr), NL_ITEM_NEXT(_ptr, _LEN_MACRO))
210207
208/* part of netlink(3) API */
209#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE
210#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len)
211211
212212#ifndef _KERNEL
213213/* part of netlink(3) API */
214#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE
215#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len)
216#define NLMSG_HDRLEN ((int)sizeof(struct nlmsghdr))
217#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN)
218#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len))
219#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN)
220#define _NLMSG_LEN(_hdr) ((int)(_hdr)->nlmsg_len)
214#define NLMSG_HDRLEN (sizeof(struct nlmsghdr))
215#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN)
216#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len))
217#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN)
218#define _NLMSG_LEN(_hdr) ((_hdr)->nlmsg_len)
221219#define _NLMSG_ALIGNED_LEN(_hdr) NLMSG_ALIGN(_NLMSG_LEN(_hdr))
222220#define NLMSG_OK(_hdr, _len) NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)
223221#define NLMSG_PAYLOAD(_hdr,_len) (_NLMSG_LEN(_hdr) - NLMSG_SPACE((_len)))
224222#define NLMSG_NEXT(_hdr, _len) NL_ITEM_ITER(_hdr, _len, _NLMSG_ALIGNED_LEN)
225223
226224#else
227#define NLMSG_ALIGNTO 4U
228#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
229#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr)))
225#define NLMSG_HDRLEN (NLMSG_ALIGN(sizeof(struct nlmsghdr)))
230226#endif
231227
232228/*
lib/libc/include/generic-freebsd/netlink/netlink_ctl.h+11-16
......@@ -47,8 +47,8 @@ MALLOC_DECLARE(M_NETLINK);
4747
4848#define NLA_ALIGN_SIZE sizeof(uint32_t)
4949#define NLA_ALIGN(_len) _roundup2(_len, NLA_ALIGN_SIZE)
50#define NLA_HDRLEN ((int)sizeof(struct nlattr))
51#define NLA_DATA_LEN(_nla) ((int)((_nla)->nla_len - NLA_HDRLEN))
50#define NLA_HDRLEN ((uint16_t)sizeof(struct nlattr))
51#define NLA_DATA_LEN(_nla) ((_nla)->nla_len - NLA_HDRLEN)
5252#define NLA_DATA(_nla) NL_ITEM_DATA(_nla, NLA_HDRLEN)
5353#define NLA_DATA_CONST(_nla) NL_ITEM_DATA_CONST(_nla, NLA_HDRLEN)
5454#define NLA_TYPE(_nla) ((_nla)->nla_type & 0x3FFF)
......@@ -65,8 +65,6 @@ MALLOC_DECLARE(M_NETLINK);
6565 ((char *)NLA_NEXT(_attr) <= (char *)_end); \
6666 _attr = (_len -= NLA_ALIGN(_attr->nla_len), NLA_NEXT(_attr)))
6767
68#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0]))
69
7068#include <netlink/netlink_message_writer.h>
7169#include <netlink/netlink_message_parser.h>
7270
......@@ -79,7 +77,6 @@ bool netlink_register_proto(int proto, const char *proto_name, nl_handler_f hand
7977bool netlink_unregister_proto(int proto);
8078
8179/* Common helpers */
82bool nl_has_listeners(int netlink_family, uint32_t groups_mask);
8380bool nlp_has_priv(struct nlpcb *nlp, int priv);
8481struct ucred *nlp_get_cred(struct nlpcb *nlp);
8582uint32_t nlp_get_pid(const struct nlpcb *nlp);
......@@ -94,18 +91,16 @@ struct genl_cmd {
9491 uint32_t cmd_num;
9592};
9693
97uint32_t genl_register_family(const char *family_name, size_t hdrsize,
98 int family_version, int max_attr_idx);
99bool genl_unregister_family(const char *family_name);
100bool genl_register_cmds(const char *family_name, const struct genl_cmd *cmds,
101 int count);
102uint32_t genl_register_group(const char *family_name, const char *group_name);
103
104struct genl_family;
105const char *genl_get_family_name(const struct genl_family *gf);
106uint32_t genl_get_family_id(const struct genl_family *gf);
94uint16_t genl_register_family(const char *family_name, size_t hdrsize,
95 uint16_t family_version, uint16_t max_attr_idx);
96void genl_unregister_family(uint16_t family);
97bool genl_register_cmds(uint16_t family, const struct genl_cmd *cmds,
98 u_int count);
99uint32_t genl_register_group(uint16_t family, const char *group_name);
100void genl_unregister_group(uint16_t family, uint32_t group);
107101
108typedef void (*genl_family_event_handler_t)(void *arg, const struct genl_family *gf, int action);
102typedef void (*genl_family_event_handler_t)(void *arg, const char *family_name,
103 uint16_t family_id, u_int action);
109104EVENTHANDLER_DECLARE(genl_family_event, genl_family_event_handler_t);
110105
111106struct thread;
lib/libc/include/generic-freebsd/netlink/netlink_linux.h+5-6
......@@ -27,6 +27,7 @@
2727
2828#ifndef _NETLINK_LINUX_VAR_H_
2929#define _NETLINK_LINUX_VAR_H_
30#ifdef _KERNEL
3031
3132/*
3233 * The file contains headers for the bridge interface between
......@@ -34,16 +35,13 @@
3435 */
3536struct nlpcb;
3637struct nl_pstate;
38struct nl_writer;
3739
38typedef struct mbuf *mbufs_to_linux_cb_t(int netlink_family, struct mbuf *m,
39 struct nlpcb *nlp);
40typedef struct mbuf *msgs_to_linux_cb_t(int netlink_family, char *buf, int data_length,
41 struct nlpcb *nlp);
42typedef struct nlmsghdr *msg_from_linux_cb_t(int netlink_family, struct nlmsghdr *hdr,
40typedef struct nl_buf * msgs_to_linux_cb_t(struct nl_buf *, struct nlpcb *);
41typedef int msg_from_linux_cb_t(int netlink_family, struct nlmsghdr **hdr,
4342 struct nl_pstate *npt);
4443
4544struct linux_netlink_provider {
46 mbufs_to_linux_cb_t *mbufs_to_linux;
4745 msgs_to_linux_cb_t *msgs_to_linux;
4846 msg_from_linux_cb_t *msg_from_linux;
4947
......@@ -51,4 +49,5 @@ struct linux_netlink_provider {
5149
5250extern struct linux_netlink_provider *linux_netlink_p;
5351
52#endif
5453#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netlink/netlink_message_parser.h+80-56
......@@ -64,15 +64,15 @@ lb_clear(struct linear_buffer *lb)
6464#define NL_MAX_ERROR_BUF 128
6565#define SCRATCH_BUFFER_SIZE (1024 + NL_MAX_ERROR_BUF)
6666struct nl_pstate {
67 struct linear_buffer lb; /* Per-message scratch buffer */
68 struct nlpcb *nlp; /* Originator socket */
69 struct nl_writer *nw; /* Message writer to use */
70 struct nlmsghdr *hdr; /* Current parsed message header */
71 uint32_t err_off; /* error offset from hdr start */
72 int error; /* last operation error */
73 char *err_msg; /* Description of last error */
74 struct nlattr *cookie; /* NLA to return to the userspace */
75 bool strict; /* Strict parsing required */
67 struct linear_buffer lb; /* Per-message scratch buffer */
68 struct nlpcb *nlp; /* Originator socket */
69 struct nl_writer *nw; /* Message writer to use */
70 struct nlmsghdr *hdr; /* Current parsed message header */
71 uint32_t err_off; /* error offset from hdr start */
72 int error; /* last operation error */
73 char *err_msg; /* Description of last error */
74 struct nlattr *cookie; /* NLA to return to the userspace */
75 bool strict; /* Strict parsing required */
7676};
7777
7878static inline void *
......@@ -80,10 +80,10 @@ npt_alloc(struct nl_pstate *npt, int len)
8080{
8181 return (lb_alloc(&npt->lb, len));
8282}
83#define npt_alloc_sockaddr(_npt, _len) ((struct sockaddr *)(npt_alloc(_npt, _len)))
83#define npt_alloc_sockaddr(_npt, _len) \
84 ((struct sockaddr *)(npt_alloc((_npt), (_len))))
8485
85typedef int parse_field_f(void *hdr, struct nl_pstate *npt,
86 void *target);
86typedef int parse_field_f(void *hdr, struct nl_pstate *npt, void *target);
8787struct nlfield_parser {
8888 uint16_t off_in;
8989 uint16_t off_out;
......@@ -98,29 +98,28 @@ int nlf_get_u16(void *src, struct nl_pstate *npt, void *target);
9898int nlf_get_u32(void *src, struct nl_pstate *npt, void *target);
9999int nlf_get_u8_u32(void *src, struct nl_pstate *npt, void *target);
100100
101
102101struct nlattr_parser;
103102typedef int parse_attr_f(struct nlattr *attr, struct nl_pstate *npt,
104103 const void *arg, void *target);
105104struct nlattr_parser {
106 uint16_t type; /* Attribute type */
107 uint16_t off; /* field offset in the target structure */
108 parse_attr_f *cb; /* parser function to call */
109 const void *arg;
105 uint16_t type; /* Attribute type */
106 uint16_t off; /* field offset in the target structure */
107 parse_attr_f *cb; /* parser function to call */
108 const void *arg;
110109};
111110
112111typedef bool strict_parser_f(void *hdr, struct nl_pstate *npt);
113112typedef bool post_parser_f(void *parsed_attrs, struct nl_pstate *npt);
114113
115114struct nlhdr_parser {
116 int nl_hdr_off; /* aligned netlink header size */
117 int out_hdr_off; /* target header size */
118 int fp_size;
119 int np_size;
115 u_int nl_hdr_off; /* aligned netlink header size */
116 u_int out_hdr_off; /* target header size */
117 u_int fp_size;
118 u_int np_size;
120119 const struct nlfield_parser *fp; /* array of header field parsers */
121120 const struct nlattr_parser *np; /* array of attribute parsers */
122 strict_parser_f *sp; /* Pre-parse strict validation function */
123 post_parser_f *post_parse;
121 strict_parser_f *sp; /* Pre-parse strict validation function */
122 post_parser_f *post_parse;
124123};
125124
126125#define NL_DECLARE_PARSER_EXT(_name, _t, _sp, _fp, _np, _pp) \
......@@ -128,8 +127,8 @@ static const struct nlhdr_parser _name = { \
128127 .nl_hdr_off = sizeof(_t), \
129128 .fp = &((_fp)[0]), \
130129 .np = &((_np)[0]), \
131 .fp_size = NL_ARRAY_LEN(_fp), \
132 .np_size = NL_ARRAY_LEN(_np), \
130 .fp_size = nitems(_fp), \
131 .np_size = nitems(_np), \
133132 .sp = _sp, \
134133 .post_parse = _pp, \
135134}
......@@ -146,29 +145,37 @@ static const struct nlhdr_parser _name = { \
146145 .out_hdr_off = sizeof(_o), \
147146 .fp = &((_fp)[0]), \
148147 .np = &((_np)[0]), \
149 .fp_size = NL_ARRAY_LEN(_fp), \
150 .np_size = NL_ARRAY_LEN(_np), \
148 .fp_size = nitems(_fp), \
149 .np_size = nitems(_np), \
151150}
152151
153#define NL_DECLARE_ATTR_PARSER(_name, _np) \
152#define NL_DECLARE_ATTR_PARSER_EXT(_name, _np, _pp) \
154153static const struct nlhdr_parser _name = { \
155154 .np = &((_np)[0]), \
156 .np_size = NL_ARRAY_LEN(_np), \
155 .np_size = nitems(_np), \
156 .post_parse = (_pp) \
157157}
158158
159#define NL_DECLARE_ATTR_PARSER(_name, _np) \
160 NL_DECLARE_ATTR_PARSER_EXT(_name, _np, NULL)
161
159162#define NL_ATTR_BMASK_SIZE 128
160163BITSET_DEFINE(nlattr_bmask, NL_ATTR_BMASK_SIZE);
161164
162void nl_get_attrs_bmask_raw(struct nlattr *nla_head, int len, struct nlattr_bmask *bm);
163bool nl_has_attr(const struct nlattr_bmask *bm, unsigned int nla_type);
165void nl_get_attrs_bmask_raw(struct nlattr *nla_head, uint32_t len,
166 struct nlattr_bmask *bm);
167bool nl_has_attr(const struct nlattr_bmask *bm, uint16_t nla_type);
164168
165int nl_parse_attrs_raw(struct nlattr *nla_head, int len, const struct nlattr_parser *ps,
166 int pslen, struct nl_pstate *npt, void *target);
169int nl_parse_attrs_raw(struct nlattr *nla_head, uint16_t len,
170 const struct nlattr_parser *ps, u_int pslen, struct nl_pstate *npt,
171 void *target);
167172
168173int nlattr_get_flag(struct nlattr *nla, struct nl_pstate *npt,
169174 const void *arg, void *target);
170175int nlattr_get_ip(struct nlattr *nla, struct nl_pstate *npt,
171176 const void *arg, void *target);
177int nlattr_get_bool(struct nlattr *nla, struct nl_pstate *npt,
178 const void *arg, void *target);
172179int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt,
173180 const void *arg, void *target);
174181int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt,
......@@ -187,16 +194,23 @@ int nlattr_get_ifpz(struct nlattr *nla, struct nl_pstate *npt,
187194 const void *arg, void *target);
188195int nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt,
189196 const void *arg, void *target);
197int nlattr_get_chara(struct nlattr *nla, struct nl_pstate *npt,
198 const void *arg, void *target);
190199int nlattr_get_string(struct nlattr *nla, struct nl_pstate *npt,
191200 const void *arg, void *target);
192201int nlattr_get_stringn(struct nlattr *nla, struct nl_pstate *npt,
193202 const void *arg, void *target);
203int nlattr_get_bytes(struct nlattr *nla, struct nl_pstate *npt,
204 const void *arg, void *target);
194205int nlattr_get_nla(struct nlattr *nla, struct nl_pstate *npt,
195206 const void *arg, void *target);
196207int nlattr_get_nested(struct nlattr *nla, struct nl_pstate *npt,
197208 const void *arg, void *target);
209int nlattr_get_nested_ptr(struct nlattr *nla, struct nl_pstate *npt,
210 const void *arg, void *target);
198211
199bool nlmsg_report_err_msg(struct nl_pstate *npt, const char *fmt, ...);
212bool nlmsg_report_err_msg(struct nl_pstate *npt, const char *fmt, ...)
213 __printflike(2, 3);
200214
201215#define NLMSG_REPORT_ERR_MSG(_npt, _fmt, ...) { \
202216 nlmsg_report_err_msg(_npt, _fmt, ## __VA_ARGS__); \
......@@ -213,20 +227,26 @@ void nlmsg_report_cookie_u32(struct nl_pstate *npt, uint32_t val);
213227 * the list of direct function calls without iteration.
214228 */
215229static inline int
216nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,
230nl_parse_header(void *hdr, uint32_t len, const struct nlhdr_parser *parser,
217231 struct nl_pstate *npt, void *target)
218232{
219233 int error;
220234
221235 if (__predict_false(len < parser->nl_hdr_off)) {
236 void *tmp_hdr;
237
222238 if (npt->strict) {
223 nlmsg_report_err_msg(npt, "header too short: expected %d, got %d",
239 nlmsg_report_err_msg(npt,
240 "header too short: expected %d, got %d",
224241 parser->nl_hdr_off, len);
225242 return (EINVAL);
226243 }
227244
228 /* Compat with older applications: pretend there's a full header */
229 void *tmp_hdr = npt_alloc(npt, parser->nl_hdr_off);
245 /*
246 * Compatibility with older applications:
247 * pretend there's a full header.
248 */
249 tmp_hdr = npt_alloc(npt, parser->nl_hdr_off);
230250 if (tmp_hdr == NULL)
231251 return (EINVAL);
232252 memcpy(tmp_hdr, hdr, len);
......@@ -238,7 +258,7 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,
238258 return (EINVAL);
239259
240260 /* Extract fields first */
241 for (int i = 0; i < parser->fp_size; i++) {
261 for (u_int i = 0; i < parser->fp_size; i++) {
242262 const struct nlfield_parser *fp = &parser->fp[i];
243263 void *src = (char *)hdr + fp->off_in;
244264 void *dst = (char *)target + fp->off_out;
......@@ -248,9 +268,9 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,
248268 return (error);
249269 }
250270
251 struct nlattr *nla_head = (struct nlattr *)((char *)hdr + parser->nl_hdr_off);
252 error = nl_parse_attrs_raw(nla_head, len - parser->nl_hdr_off, parser->np,
253 parser->np_size, npt, target);
271 error = nl_parse_attrs_raw(
272 (struct nlattr *)((char *)hdr + parser->nl_hdr_off),
273 len - parser->nl_hdr_off, parser->np, parser->np_size, npt, target);
254274
255275 if (parser->post_parse != NULL && error == 0) {
256276 if (!parser->post_parse(target, npt))
......@@ -264,10 +284,8 @@ static inline int
264284nl_parse_nested(struct nlattr *nla, const struct nlhdr_parser *parser,
265285 struct nl_pstate *npt, void *target)
266286{
267 struct nlattr *nla_head = (struct nlattr *)NLA_DATA(nla);
268
269 return (nl_parse_attrs_raw(nla_head, NLA_DATA_LEN(nla), parser->np,
270 parser->np_size, npt, target));
287 return (nl_parse_attrs_raw((struct nlattr *)NLA_DATA(nla),
288 NLA_DATA_LEN(nla), parser->np, parser->np_size, npt, target));
271289}
272290
273291/*
......@@ -283,30 +301,36 @@ nl_verify_parsers(const struct nlhdr_parser **parser, int count)
283301 for (int j = 0; j < p->np_size; j++) {
284302 MPASS(p->np[j].type > attr_type);
285303 attr_type = p->np[j].type;
304
305 /* Recurse into nested objects. */
306 if (p->np[j].cb == nlattr_get_nested ||
307 p->np[j].cb == nlattr_get_nested_ptr) {
308 const struct nlhdr_parser *np =
309 (const struct nlhdr_parser *)p->np[j].arg;
310 nl_verify_parsers(&np, 1);
311 }
286312 }
287313 }
288314#endif
289315}
290316void nl_verify_parsers(const struct nlhdr_parser **parser, int count);
291#define NL_VERIFY_PARSERS(_p) nl_verify_parsers((_p), NL_ARRAY_LEN(_p))
317#define NL_VERIFY_PARSERS(_p) nl_verify_parsers((_p), nitems(_p))
292318
293319static inline int
294320nl_parse_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser,
295321 struct nl_pstate *npt, void *target)
296322{
297 return (nl_parse_header(hdr + 1, hdr->nlmsg_len - sizeof(*hdr), parser, npt, target));
323 return (nl_parse_header(hdr + 1, hdr->nlmsg_len - sizeof(*hdr), parser,
324 npt, target));
298325}
299326
300327static inline void
301nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser,
302 struct nlattr_bmask *bm)
328nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr,
329 const struct nlhdr_parser *parser, struct nlattr_bmask *bm)
303330{
304 struct nlattr *nla_head;
305
306 nla_head = (struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off);
307 int len = hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off;
308
309 nl_get_attrs_bmask_raw(nla_head, len, bm);
331 nl_get_attrs_bmask_raw(
332 (struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off),
333 hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off, bm);
310334}
311335
312336#endif
lib/libc/include/generic-freebsd/netlink/netlink_message_writer.h+59-115
......@@ -37,62 +37,45 @@
3737 * It is not meant to be included directly
3838 */
3939
40struct mbuf;
40struct nl_buf;
4141struct nl_writer;
42typedef bool nl_writer_cb(struct nl_writer *nw, void *buf, int buflen, int cnt);
42typedef bool nl_writer_cb(struct nl_writer *nw);
4343
4444struct nl_writer {
45 int alloc_len; /* allocated buffer length */
46 int offset; /* offset from the start of the buffer */
47 struct nlmsghdr *hdr; /* Pointer to the currently-filled msg */
48 char *data; /* pointer to the contiguous storage */
49 void *_storage; /* Underlying storage pointer */
50 nl_writer_cb *cb; /* Callback to flush data */
45 struct nl_buf *buf; /* Underlying storage pointer */
46 struct nlmsghdr *hdr; /* Pointer to the currently-filled msg */
47 nl_writer_cb *cb; /* Callback to flush data */
5148 union {
52 void *ptr;
49 struct nlpcb *nlp;
5350 struct {
5451 uint16_t proto;
5552 uint16_t id;
53 int priv;
5654 } group;
57 } arg;
58 int num_messages; /* Number of messages in the buffer */
59 int malloc_flag; /* M_WAITOK or M_NOWAIT */
60 uint8_t writer_type; /* NS_WRITER_TYPE_* */
61 uint8_t writer_target; /* NS_WRITER_TARGET_* */
62 bool ignore_limit; /* If true, ignores RCVBUF limit */
63 bool enomem; /* True if ENOMEM occured */
64 bool suppress_ack; /* If true, don't send NLMSG_ERR */
55 };
56 u_int num_messages; /* Number of messages in the buffer */
57 int malloc_flag; /* M_WAITOK or M_NOWAIT */
58 bool ignore_limit; /* If true, ignores RCVBUF limit */
59 bool enomem; /* True if ENOMEM occured */
60 bool suppress_ack; /* If true, don't send NLMSG_ERR */
6561};
66#define NS_WRITER_TARGET_SOCKET 0
67#define NS_WRITER_TARGET_GROUP 1
68#define NS_WRITER_TARGET_CHAIN 2
69
70#define NS_WRITER_TYPE_MBUF 0
71#define NS_WRITER_TYPE_BUF 1
72#define NS_WRITER_TYPE_LBUF 2
73#define NS_WRITER_TYPE_MBUFC 3
74#define NS_WRITER_TYPE_STUB 4
75
7662
7763#define NLMSG_SMALL 128
7864#define NLMSG_LARGE 2048
7965
8066/* Message and attribute writing */
81
82struct nlpcb;
83
8467#if defined(NETLINK) || defined(NETLINK_MODULE)
8568/* Provide optimized calls to the functions inside the same linking unit */
8669
87bool _nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp);
88bool _nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id);
89bool _nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm);
70bool _nl_writer_unicast(struct nl_writer *, size_t, struct nlpcb *nlp, bool);
71bool _nl_writer_group(struct nl_writer *, size_t, uint16_t, uint16_t, int,
72 bool);
9073bool _nlmsg_flush(struct nl_writer *nw);
9174void _nlmsg_ignore_limit(struct nl_writer *nw);
9275
93bool _nlmsg_refill_buffer(struct nl_writer *nw, int required_size);
94bool _nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,
95 uint16_t flags, uint32_t len);
76bool _nlmsg_refill_buffer(struct nl_writer *nw, size_t required_len);
77bool _nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq,
78 uint16_t type, uint16_t flags, uint32_t len);
9679bool _nlmsg_end(struct nl_writer *nw);
9780void _nlmsg_abort(struct nl_writer *nw);
9881
......@@ -100,21 +83,17 @@ bool _nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr);
10083
10184
10285static inline bool
103nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp)
104{
105 return (_nlmsg_get_unicast_writer(nw, expected_size, nlp));
106}
107
108static inline bool
109nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id)
86nl_writer_unicast(struct nl_writer *nw, size_t size, struct nlpcb *nlp,
87 bool waitok)
11088{
111 return (_nlmsg_get_group_writer(nw, expected_size, proto, group_id));
89 return (_nl_writer_unicast(nw, size, nlp, waitok));
11290}
11391
11492static inline bool
115nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm)
93nl_writer_group(struct nl_writer *nw, size_t size, uint16_t proto,
94 uint16_t group_id, int priv, bool waitok)
11695{
117 return (_nlmsg_get_chain_writer(nw, expected_size, pm));
96 return (_nl_writer_group(nw, size, proto, group_id, priv, waitok));
11897}
11998
12099static inline bool
......@@ -130,7 +109,7 @@ nlmsg_ignore_limit(struct nl_writer *nw)
130109}
131110
132111static inline bool
133nlmsg_refill_buffer(struct nl_writer *nw, int required_size)
112nlmsg_refill_buffer(struct nl_writer *nw, size_t required_size)
134113{
135114 return (_nlmsg_refill_buffer(nw, required_size));
136115}
......@@ -163,15 +142,15 @@ nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr)
163142#else
164143/* Provide access to the functions via netlink_glue.c */
165144
166bool nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp);
167bool nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id);
168bool nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm);
145bool nl_writer_unicast(struct nl_writer *, size_t, struct nlpcb *, bool waitok);
146bool nl_writer_group(struct nl_writer *, size_t, uint16_t, uint16_t, int,
147 bool waitok);
169148bool nlmsg_flush(struct nl_writer *nw);
170149void nlmsg_ignore_limit(struct nl_writer *nw);
171150
172bool nlmsg_refill_buffer(struct nl_writer *nw, int required_size);
173bool nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,
174 uint16_t flags, uint32_t len);
151bool nlmsg_refill_buffer(struct nl_writer *nw, size_t required_size);
152bool nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq,
153 uint16_t type, uint16_t flags, uint32_t len);
175154bool nlmsg_end(struct nl_writer *nw);
176155void nlmsg_abort(struct nl_writer *nw);
177156
......@@ -186,18 +165,12 @@ nlmsg_reply(struct nl_writer *nw, const struct nlmsghdr *hdr, int payload_len)
186165 hdr->nlmsg_flags, payload_len));
187166}
188167
189#define nlmsg_data(_hdr) ((void *)((_hdr) + 1))
190
191168/*
192169 * KPI similar to mtodo():
193170 * current (uncompleted) header is guaranteed to be contiguous,
194171 * but can be reallocated, thus pointers may need to be readjusted.
195172 */
196static inline int
197nlattr_save_offset(const struct nl_writer *nw)
198{
199 return (nw->offset - ((char *)nw->hdr - nw->data));
200}
173u_int nlattr_save_offset(const struct nl_writer *nw);
201174
202175static inline void *
203176_nlattr_restore_offset(const struct nl_writer *nw, int off)
......@@ -213,22 +186,7 @@ nlattr_set_len(const struct nl_writer *nw, int off)
213186 nla->nla_len = nlattr_save_offset(nw) - off;
214187}
215188
216static inline void *
217nlmsg_reserve_data_raw(struct nl_writer *nw, size_t sz)
218{
219 sz = NETLINK_ALIGN(sz);
220
221 if (__predict_false(nw->offset + sz > nw->alloc_len)) {
222 if (!nlmsg_refill_buffer(nw, sz))
223 return (NULL);
224 }
225
226 void *data_ptr = &nw->data[nw->offset];
227 nw->offset += sz;
228 bzero(data_ptr, sz);
229
230 return (data_ptr);
231}
189void *nlmsg_reserve_data_raw(struct nl_writer *nw, size_t sz);
232190#define nlmsg_reserve_object(_ns, _t) ((_t *)nlmsg_reserve_data_raw(_ns, sizeof(_t)))
233191#define nlmsg_reserve_data(_ns, _sz, _t) ((_t *)nlmsg_reserve_data_raw(_ns, _sz))
234192
......@@ -258,109 +216,95 @@ _nlmsg_reserve_attr(struct nl_writer *nw, uint16_t nla_type, uint16_t sz)
258216}
259217#define nlmsg_reserve_attr(_ns, _at, _t) ((_t *)_nlmsg_reserve_attr(_ns, _at, NLA_ALIGN(sizeof(_t))))
260218
261static inline bool
262nlattr_add(struct nl_writer *nw, int attr_type, int attr_len, const void *data)
263{
264 int required_len = NLA_ALIGN(attr_len + sizeof(struct nlattr));
265
266 if (__predict_false(nw->offset + required_len > nw->alloc_len)) {
267 if (!nlmsg_refill_buffer(nw, required_len))
268 return (false);
269 }
270
271 struct nlattr *nla = (struct nlattr *)(&nw->data[nw->offset]);
272
273 nla->nla_len = attr_len + sizeof(struct nlattr);
274 nla->nla_type = attr_type;
275 if (attr_len > 0) {
276 if ((attr_len % 4) != 0) {
277 /* clear padding bytes */
278 bzero((char *)nla + required_len - 4, 4);
279 }
280 memcpy((nla + 1), data, attr_len);
281 }
282 nw->offset += required_len;
283 return (true);
284}
219bool nlattr_add(struct nl_writer *nw, uint16_t attr_type, uint16_t attr_len,
220 const void *data);
285221
286222static inline bool
287223nlattr_add_raw(struct nl_writer *nw, const struct nlattr *nla_src)
288224{
289 int attr_len = nla_src->nla_len - sizeof(struct nlattr);
225 MPASS(nla_src->nla_len >= sizeof(struct nlattr));
290226
291 MPASS(attr_len >= 0);
227 return (nlattr_add(nw, nla_src->nla_type,
228 nla_src->nla_len - sizeof(struct nlattr),
229 (const void *)(nla_src + 1)));
230}
292231
293 return (nlattr_add(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1)));
232static inline bool
233nlattr_add_bool(struct nl_writer *nw, uint16_t attrtype, bool value)
234{
235 return (nlattr_add(nw, attrtype, sizeof(bool), &value));
294236}
295237
296238static inline bool
297nlattr_add_u8(struct nl_writer *nw, int attrtype, uint8_t value)
239nlattr_add_u8(struct nl_writer *nw, uint16_t attrtype, uint8_t value)
298240{
299241 return (nlattr_add(nw, attrtype, sizeof(uint8_t), &value));
300242}
301243
302244static inline bool
303nlattr_add_u16(struct nl_writer *nw, int attrtype, uint16_t value)
245nlattr_add_u16(struct nl_writer *nw, uint16_t attrtype, uint16_t value)
304246{
305247 return (nlattr_add(nw, attrtype, sizeof(uint16_t), &value));
306248}
307249
308250static inline bool
309nlattr_add_u32(struct nl_writer *nw, int attrtype, uint32_t value)
251nlattr_add_u32(struct nl_writer *nw, uint16_t attrtype, uint32_t value)
310252{
311253 return (nlattr_add(nw, attrtype, sizeof(uint32_t), &value));
312254}
313255
314256static inline bool
315nlattr_add_u64(struct nl_writer *nw, int attrtype, uint64_t value)
257nlattr_add_u64(struct nl_writer *nw, uint16_t attrtype, uint64_t value)
316258{
317259 return (nlattr_add(nw, attrtype, sizeof(uint64_t), &value));
318260}
319261
320262static inline bool
321nlattr_add_s8(struct nl_writer *nw, int attrtype, int8_t value)
263nlattr_add_s8(struct nl_writer *nw, uint16_t attrtype, int8_t value)
322264{
323265 return (nlattr_add(nw, attrtype, sizeof(int8_t), &value));
324266}
325267
326268static inline bool
327nlattr_add_s16(struct nl_writer *nw, int attrtype, int16_t value)
269nlattr_add_s16(struct nl_writer *nw, uint16_t attrtype, int16_t value)
328270{
329271 return (nlattr_add(nw, attrtype, sizeof(int16_t), &value));
330272}
331273
332274static inline bool
333nlattr_add_s32(struct nl_writer *nw, int attrtype, int32_t value)
275nlattr_add_s32(struct nl_writer *nw, uint16_t attrtype, int32_t value)
334276{
335277 return (nlattr_add(nw, attrtype, sizeof(int32_t), &value));
336278}
337279
338280static inline bool
339nlattr_add_s64(struct nl_writer *nw, int attrtype, int64_t value)
281nlattr_add_s64(struct nl_writer *nw, uint16_t attrtype, int64_t value)
340282{
341283 return (nlattr_add(nw, attrtype, sizeof(int64_t), &value));
342284}
343285
344286static inline bool
345nlattr_add_flag(struct nl_writer *nw, int attrtype)
287nlattr_add_flag(struct nl_writer *nw, uint16_t attrtype)
346288{
347289 return (nlattr_add(nw, attrtype, 0, NULL));
348290}
349291
350292static inline bool
351nlattr_add_string(struct nl_writer *nw, int attrtype, const char *str)
293nlattr_add_string(struct nl_writer *nw, uint16_t attrtype, const char *str)
352294{
353295 return (nlattr_add(nw, attrtype, strlen(str) + 1, str));
354296}
355297
356298static inline bool
357nlattr_add_in_addr(struct nl_writer *nw, int attrtype, const struct in_addr *in)
299nlattr_add_in_addr(struct nl_writer *nw, uint16_t attrtype,
300 const struct in_addr *in)
358301{
359302 return (nlattr_add(nw, attrtype, sizeof(*in), in));
360303}
361304
362305static inline bool
363nlattr_add_in6_addr(struct nl_writer *nw, int attrtype, const struct in6_addr *in6)
306nlattr_add_in6_addr(struct nl_writer *nw, uint16_t attrtype,
307 const struct in6_addr *in6)
364308{
365309 return (nlattr_add(nw, attrtype, sizeof(*in6), in6));
366310}
lib/libc/include/generic-freebsd/netlink/netlink_snl.h+70-31
......@@ -31,6 +31,12 @@
3131 * Simple Netlink Library
3232 */
3333
34#include <sys/param.h>
35#include <sys/socket.h>
36
37#include <netlink/netlink.h>
38#include <netlink/netlink_bitset.h>
39
3440#include <assert.h>
3541#include <errno.h>
3642#include <stdalign.h>
......@@ -41,11 +47,6 @@
4147#include <string.h>
4248#include <unistd.h>
4349
44#include <sys/types.h>
45#include <sys/socket.h>
46#include <netlink/netlink.h>
47#include <netlink/netlink_bitset.h>
48
4950#define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1)))
5051
5152#define NETLINK_ALIGN_SIZE sizeof(uint32_t)
......@@ -68,8 +69,6 @@
6869 ((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len)); \
6970 _attr = NLA_NEXT(_attr))
7071
71#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0]))
72
7372struct linear_buffer {
7473 char *base; /* Base allocated memory pointer */
7574 uint32_t offset; /* Currently used offset */
......@@ -133,6 +132,7 @@ struct snl_field_parser {
133132 uint16_t off_out;
134133 snl_parse_field_f *cb;
135134};
135static const struct snl_field_parser snl_f_p_empty[] = {};
136136
137137typedef bool snl_parse_attr_f(struct snl_state *ss, struct nlattr *attr,
138138 const void *arg, void *target);
......@@ -166,8 +166,8 @@ static const struct snl_hdr_parser _name = { \
166166 .out_size = _sz_out, \
167167 .fp = &((_fp)[0]), \
168168 .np = &((_np)[0]), \
169 .fp_size = NL_ARRAY_LEN(_fp), \
170 .np_size = NL_ARRAY_LEN(_np), \
169 .fp_size = nitems(_fp), \
170 .np_size = nitems(_np), \
171171 .cb_post = _cb, \
172172}
173173
......@@ -179,7 +179,7 @@ static const struct snl_hdr_parser _name = { \
179179 .in_hdr_size = _sz_h_in, \
180180 .out_size = _sz_out, \
181181 .fp = &((_fp)[0]), \
182 .fp_size = NL_ARRAY_LEN(_fp), \
182 .fp_size = nitems(_fp), \
183183 .cb_post = _cb, \
184184}
185185
......@@ -190,7 +190,7 @@ static const struct snl_hdr_parser _name = { \
190190static const struct snl_hdr_parser _name = { \
191191 .out_size = _sz_out, \
192192 .np = &((_np)[0]), \
193 .np_size = NL_ARRAY_LEN(_np), \
193 .np_size = nitems(_np), \
194194 .cb_post = _cb, \
195195}
196196
......@@ -240,14 +240,13 @@ snl_clear_lb(struct snl_state *ss)
240240static void
241241snl_free(struct snl_state *ss)
242242{
243 if (ss->init_done) {
243 if (ss->init_done)
244244 close(ss->fd);
245 if (ss->buf != NULL)
246 free(ss->buf);
247 if (ss->lb != NULL) {
248 snl_clear_lb(ss);
249 lb_free(ss->lb);
250 }
245 if (ss->buf != NULL)
246 free(ss->buf);
247 if (ss->lb != NULL) {
248 snl_clear_lb(ss);
249 lb_free(ss->lb);
251250 }
252251}
253252
......@@ -290,6 +289,16 @@ snl_init(struct snl_state *ss, int netlink_family)
290289 return (true);
291290}
292291
292static inline bool
293snl_clone(struct snl_state *ss, const struct snl_state *orig)
294{
295 *ss = (struct snl_state){
296 .fd = orig->fd,
297 .init_done = false,
298 };
299 return ((ss->lb = lb_init(SCRATCH_BUFFER_SIZE)) != NULL);
300}
301
293302static inline bool
294303snl_send(struct snl_state *ss, void *data, int sz)
295304{
......@@ -418,7 +427,7 @@ snl_verify_parsers(const struct snl_hdr_parser **parser, int count)
418427 }
419428 }
420429}
421#define SNL_VERIFY_PARSERS(_p) snl_verify_parsers((_p), NL_ARRAY_LEN(_p))
430#define SNL_VERIFY_PARSERS(_p) snl_verify_parsers((_p), nitems(_p))
422431
423432static const struct snl_attr_parser *
424433find_parser(const struct snl_attr_parser *ps, int pslen, int key)
......@@ -526,6 +535,29 @@ snl_attr_get_flag(struct snl_state *ss __unused, struct nlattr *nla, const void
526535 return (false);
527536}
528537
538static inline bool
539snl_attr_get_bytes(struct snl_state *ss __unused, struct nlattr *nla, const void *arg,
540 void *target)
541{
542 if ((size_t)NLA_DATA_LEN(nla) != (size_t)arg)
543 return (false);
544
545 memcpy(target, NLA_DATA_CONST(nla), (size_t)arg);
546
547 return (true);
548}
549
550static inline bool
551snl_attr_get_bool(struct snl_state *ss __unused, struct nlattr *nla,
552 const void *arg __unused, void *target)
553{
554 if (NLA_DATA_LEN(nla) == sizeof(bool)) {
555 *((bool *)target) = *((const bool *)NLA_DATA_CONST(nla));
556 return (true);
557 }
558 return (false);
559}
560
529561static inline bool
530562snl_attr_get_uint8(struct snl_state *ss __unused, struct nlattr *nla,
531563 const void *arg __unused, void *target)
......@@ -1086,20 +1118,22 @@ snl_reserve_msg_data_raw(struct snl_writer *nw, size_t sz)
10861118#define snl_reserve_msg_object(_ns, _t) ((_t *)snl_reserve_msg_data_raw(_ns, sizeof(_t)))
10871119#define snl_reserve_msg_data(_ns, _sz, _t) ((_t *)snl_reserve_msg_data_raw(_ns, _sz))
10881120
1089static inline void *
1090_snl_reserve_msg_attr(struct snl_writer *nw, uint16_t nla_type, uint16_t sz)
1121static inline struct nlattr *
1122snl_reserve_msg_attr_raw(struct snl_writer *nw, uint16_t nla_type, uint16_t sz)
10911123{
1092 sz += sizeof(struct nlattr);
1124 struct nlattr *nla;
10931125
1094 struct nlattr *nla = snl_reserve_msg_data(nw, sz, struct nlattr);
1126 sz += sizeof(struct nlattr);
1127 nla = snl_reserve_msg_data(nw, sz, struct nlattr);
10951128 if (__predict_false(nla == NULL))
10961129 return (NULL);
10971130 nla->nla_type = nla_type;
10981131 nla->nla_len = sz;
10991132
1100 return ((void *)(nla + 1));
1133 return (nla);
11011134}
1102#define snl_reserve_msg_attr(_ns, _at, _t) ((_t *)_snl_reserve_msg_attr(_ns, _at, sizeof(_t)))
1135#define snl_reserve_msg_attr(_ns, _at, _t) \
1136 ((_t *)(snl_reserve_msg_attr_raw(_ns, _at, sizeof(_t)) + 1))
11031137
11041138static inline bool
11051139snl_add_msg_attr(struct snl_writer *nw, int attr_type, int attr_len, const void *data)
......@@ -1136,6 +1170,12 @@ snl_add_msg_attr_raw(struct snl_writer *nw, const struct nlattr *nla_src)
11361170 return (snl_add_msg_attr(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1)));
11371171}
11381172
1173static inline bool
1174snl_add_msg_attr_bool(struct snl_writer *nw, int attrtype, bool value)
1175{
1176 return (snl_add_msg_attr(nw, attrtype, sizeof(bool), &value));
1177}
1178
11391179static inline bool
11401180snl_add_msg_attr_u8(struct snl_writer *nw, int attrtype, uint8_t value)
11411181{
......@@ -1233,9 +1273,13 @@ snl_end_attr_nested(const struct snl_writer *nw, int off)
12331273static inline struct nlmsghdr *
12341274snl_create_msg_request(struct snl_writer *nw, int nlmsg_type)
12351275{
1276 struct nlmsghdr *hdr;
1277
12361278 assert(nw->hdr == NULL);
12371279
1238 struct nlmsghdr *hdr = snl_reserve_msg_object(nw, struct nlmsghdr);
1280 if (__predict_false((hdr =
1281 snl_reserve_msg_object(nw, struct nlmsghdr)) == NULL))
1282 return (NULL);
12391283 hdr->nlmsg_type = nlmsg_type;
12401284 hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
12411285 nw->hdr = hdr;
......@@ -1283,9 +1327,4 @@ snl_send_msgs(struct snl_writer *nw)
12831327 return (snl_send(nw->ss, nw->base, offset));
12841328}
12851329
1286static const struct snl_hdr_parser *snl_all_core_parsers[] = {
1287 &snl_errmsg_parser, &snl_donemsg_parser,
1288 &_nla_bit_parser, &_nla_bitset_parser,
1289};
1290
12911330#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netlink/netlink_snl_generic.h+64-23
......@@ -33,16 +33,24 @@
3333
3434/* Genetlink helpers */
3535static inline struct nlmsghdr *
36snl_create_genl_msg_request(struct snl_writer *nw, int genl_family, uint8_t genl_cmd)
36snl_create_genl_msg_request(struct snl_writer *nw, uint16_t genl_family,
37 uint8_t genl_cmd)
3738{
39 struct nlmsghdr *hdr;
40 struct genlmsghdr *ghdr;
41
3842 assert(nw->hdr == NULL);
3943
40 struct nlmsghdr *hdr = snl_reserve_msg_object(nw, struct nlmsghdr);
44 hdr = snl_reserve_msg_object(nw, struct nlmsghdr);
45 if (__predict_false(hdr == NULL))
46 return (NULL);
4147 hdr->nlmsg_type = genl_family;
4248 hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
43 nw->hdr = hdr;
44 struct genlmsghdr *ghdr = snl_reserve_msg_object(nw, struct genlmsghdr);
49 ghdr = snl_reserve_msg_object(nw, struct genlmsghdr);
50 if (__predict_false(ghdr == NULL))
51 return (NULL);
4552 ghdr->cmd = genl_cmd;
53 nw->hdr = hdr;
4654
4755 return (hdr);
4856}
......@@ -52,37 +60,52 @@ static struct snl_field_parser snl_fp_genl[] = {};
5260#define SNL_DECLARE_GENL_PARSER(_name, _np) SNL_DECLARE_PARSER(_name,\
5361 struct genlmsghdr, snl_fp_genl, _np)
5462
55struct snl_genl_ctrl_mcast_group {
63struct _snl_genl_ctrl_mcast_group {
5664 uint32_t mcast_grp_id;
57 char *mcast_grp_name;
65 const char *mcast_grp_name;
5866};
5967
60struct snl_genl_ctrl_mcast_groups {
68struct _snl_genl_ctrl_mcast_groups {
6169 uint32_t num_groups;
62 struct snl_genl_ctrl_mcast_group **groups;
70 struct _snl_genl_ctrl_mcast_group **groups;
6371};
6472
65#define _OUT(_field) offsetof(struct snl_genl_ctrl_mcast_group, _field)
73#define _OUT(_field) offsetof(struct _snl_genl_ctrl_mcast_group, _field)
6674static struct snl_attr_parser _nla_p_getmc[] = {
67 { .type = CTRL_ATTR_MCAST_GRP_NAME, .off = _OUT(mcast_grp_name), .cb = snl_attr_get_string },
68 { .type = CTRL_ATTR_MCAST_GRP_ID, .off = _OUT(mcast_grp_id), .cb = snl_attr_get_uint32 },
75 {
76 .type = CTRL_ATTR_MCAST_GRP_NAME,
77 .off = _OUT(mcast_grp_name),
78 .cb = snl_attr_get_string,
79 },
80 {
81 .type = CTRL_ATTR_MCAST_GRP_ID,
82 .off = _OUT(mcast_grp_id),
83 .cb = snl_attr_get_uint32,
84 },
6985};
7086#undef _OUT
7187SNL_DECLARE_ATTR_PARSER_EXT(_genl_ctrl_mc_parser,
72 sizeof(struct snl_genl_ctrl_mcast_group),
73 _nla_p_getmc, NULL);
88 sizeof(struct _snl_genl_ctrl_mcast_group), _nla_p_getmc, NULL);
7489
7590struct _getfamily_attrs {
7691 uint16_t family_id;
77 char *family_name;
78 struct snl_genl_ctrl_mcast_groups mcast_groups;
92 const char *family_name;
93 struct _snl_genl_ctrl_mcast_groups mcast_groups;
7994};
8095
8196#define _IN(_field) offsetof(struct genlmsghdr, _field)
8297#define _OUT(_field) offsetof(struct _getfamily_attrs, _field)
8398static struct snl_attr_parser _nla_p_getfam[] = {
84 { .type = CTRL_ATTR_FAMILY_ID , .off = _OUT(family_id), .cb = snl_attr_get_uint16 },
85 { .type = CTRL_ATTR_FAMILY_NAME, .off = _OUT(family_name), .cb = snl_attr_get_string },
99 {
100 .type = CTRL_ATTR_FAMILY_ID,
101 .off = _OUT(family_id),
102 .cb = snl_attr_get_uint16,
103 },
104 {
105 .type = CTRL_ATTR_FAMILY_NAME,
106 .off = _OUT(family_name),
107 .cb = snl_attr_get_string,
108 },
86109 {
87110 .type = CTRL_ATTR_MCAST_GROUPS,
88111 .off = _OUT(mcast_groups),
......@@ -95,7 +118,7 @@ static struct snl_attr_parser _nla_p_getfam[] = {
95118SNL_DECLARE_GENL_PARSER(_genl_ctrl_getfam_parser, _nla_p_getfam);
96119
97120static bool
98snl_get_genl_family_info(struct snl_state *ss, const char *family_name,
121_snl_get_genl_family_info(struct snl_state *ss, const char *family_name,
99122 struct _getfamily_attrs *attrs)
100123{
101124 struct snl_writer nw;
......@@ -104,7 +127,7 @@ snl_get_genl_family_info(struct snl_state *ss, const char *family_name,
104127 memset(attrs, 0, sizeof(*attrs));
105128
106129 snl_init_writer(ss, &nw);
107 hdr = snl_create_genl_msg_request(&nw, GENL_ID_CTRL, CTRL_CMD_GETFAMILY);
130 snl_create_genl_msg_request(&nw, GENL_ID_CTRL, CTRL_CMD_GETFAMILY);
108131 snl_add_msg_attr_string(&nw, CTRL_ATTR_FAMILY_NAME, family_name);
109132 if ((hdr = snl_finalize_msg(&nw)) == NULL || !snl_send_message(ss, hdr))
110133 return (false);
......@@ -123,12 +146,30 @@ snl_get_genl_family(struct snl_state *ss, const char *family_name)
123146{
124147 struct _getfamily_attrs attrs = {};
125148
126 snl_get_genl_family_info(ss, family_name, &attrs);
149 if (__predict_false(!_snl_get_genl_family_info(ss, family_name,
150 &attrs)))
151 return (0);
127152 return (attrs.family_id);
128153}
129154
130static const struct snl_hdr_parser *snl_all_genl_parsers[] = {
131 &_genl_ctrl_getfam_parser, &_genl_ctrl_mc_parser,
132};
155static inline uint16_t
156snl_get_genl_mcast_group(struct snl_state *ss, const char *family_name,
157 const char *group_name, uint16_t *family_id)
158{
159 struct _getfamily_attrs attrs = {};
160
161 if (__predict_false(!_snl_get_genl_family_info(ss, family_name,
162 &attrs)))
163 return (0);
164 if (attrs.family_id == 0)
165 return (0);
166 if (family_id != NULL)
167 *family_id = attrs.family_id;
168 for (u_int i = 0; i < attrs.mcast_groups.num_groups; i++)
169 if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name,
170 group_name) == 0)
171 return (attrs.mcast_groups.groups[i]->mcast_grp_id);
172 return (0);
173}
133174
134175#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netlink/netlink_snl_route_parsers.h-7
......@@ -389,11 +389,4 @@ _cb_p_nh(struct snl_state *ss __unused, void *_target)
389389SNL_DECLARE_PARSER_EXT(snl_nhmsg_parser, sizeof(struct nhmsg),
390390 sizeof(struct snl_parsed_nhop), _fp_p_nh, _nla_p_nh, _cb_p_nh);
391391
392static const struct snl_hdr_parser *snl_all_route_parsers[] = {
393 &_metrics_mp_nh_parser, &_mpath_nh_parser, &_metrics_parser, &snl_rtm_route_parser,
394 &_link_fbsd_parser, &snl_rtm_link_parser, &snl_rtm_link_parser_simple,
395 &_neigh_fbsd_parser, &snl_rtm_neigh_parser,
396 &_addr_fbsd_parser, &snl_rtm_addr_parser, &_nh_fbsd_parser, &snl_nhmsg_parser,
397};
398
399392#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netlink/netlink_var.h+23-58
......@@ -43,33 +43,32 @@
4343
4444struct ucred;
4545
46struct nl_io_queue {
47 STAILQ_HEAD(, mbuf) head;
48 int length;
49 int hiwat;
46struct nl_buf {
47 TAILQ_ENTRY(nl_buf) tailq;
48 u_int buflen;
49 u_int datalen;
50 u_int offset;
51 char data[];
5052};
5153
5254#define NLP_MAX_GROUPS 128
5355
56BITSET_DEFINE(nl_groups, NLP_MAX_GROUPS);
5457struct nlpcb {
5558 struct socket *nl_socket;
56 uint64_t nl_groups[NLP_MAX_GROUPS / 64];
59 struct nl_groups nl_groups;
5760 uint32_t nl_port;
5861 uint32_t nl_flags;
5962 uint32_t nl_process_id;
6063 int nl_proto;
61 bool nl_active;
6264 bool nl_bound;
6365 bool nl_task_pending;
6466 bool nl_tx_blocked; /* No new requests accepted */
6567 bool nl_linux; /* true if running under compat */
6668 bool nl_unconstrained_vnet; /* true if running under VNET jail (or without jail) */
6769 bool nl_need_thread_setup;
68 struct nl_io_queue rx_queue;
69 struct nl_io_queue tx_queue;
7070 struct taskqueue *nl_taskqueue;
7171 struct task nl_task;
72 struct ucred *nl_cred; /* Copy of nl_socket->so_cred */
7372 uint64_t nl_dropped_bytes;
7473 uint64_t nl_dropped_messages;
7574 CK_LIST_ENTRY(nlpcb) nl_next;
......@@ -96,31 +95,19 @@ struct nlpcb {
9695SYSCTL_DECL(_net_netlink);
9796SYSCTL_DECL(_net_netlink_debug);
9897
99struct nl_io {
100 struct callout callout;
101 struct mbuf *head;
102 struct mbuf *last;
103 int64_t length;
104};
105
10698struct nl_control {
10799 CK_LIST_HEAD(nl_pid_head, nlpcb) ctl_port_head;
108100 CK_LIST_HEAD(nlpcb_head, nlpcb) ctl_pcb_head;
109101 CK_LIST_ENTRY(nl_control) ctl_next;
110 struct nl_io ctl_io;
111102 struct rmlock ctl_lock;
112103};
113VNET_DECLARE(struct nl_control *, nl_ctl);
104VNET_DECLARE(struct nl_control, nl_ctl);
114105#define V_nl_ctl VNET(nl_ctl)
115106
116
117107struct sockaddr_nl;
118108struct sockaddr;
119109struct nlmsghdr;
120110
121/* netlink_module.c */
122struct nl_control *vnet_nl_ctl_init(void);
123
124111int nl_verify_proto(int proto);
125112const char *nl_get_proto_name(int proto);
126113
......@@ -133,57 +120,34 @@ struct nl_proto_handler {
133120extern struct nl_proto_handler *nl_handlers;
134121
135122/* netlink_domain.c */
136void nl_send_group(struct mbuf *m, int cnt, int proto, int group_id);
123bool nl_send_group(struct nl_writer *);
124void nl_clear_group(u_int);
137125void nl_osd_register(void);
138126void nl_osd_unregister(void);
139127void nl_set_thread_nlp(struct thread *td, struct nlpcb *nlp);
140128
141129/* netlink_io.c */
142#define NL_IOF_UNTRANSLATED 0x01
143#define NL_IOF_IGNORE_LIMIT 0x02
144bool nl_send_one(struct mbuf *m, struct nlpcb *nlp, int cnt, int io_flags);
130bool nl_send(struct nl_writer *, struct nlpcb *);
145131void nlmsg_ack(struct nlpcb *nlp, int error, struct nlmsghdr *nlmsg,
146132 struct nl_pstate *npt);
147133void nl_on_transmit(struct nlpcb *nlp);
148void nl_init_io(struct nlpcb *nlp);
149void nl_free_io(struct nlpcb *nlp);
150134
151135void nl_taskqueue_handler(void *_arg, int pending);
152int nl_receive_async(struct mbuf *m, struct socket *so);
136void nl_schedule_taskqueue(struct nlpcb *nlp);
153137void nl_process_receive_locked(struct nlpcb *nlp);
154138void nl_set_source_metadata(struct mbuf *m, int num_messages);
155void nl_add_msg_info(struct mbuf *m);
156
157/* netlink_message_writer.c */
158void nl_init_msg_zone(void);
159void nl_destroy_msg_zone(void);
160
161/* netlink_generic.c */
162struct genl_family {
163 const char *family_name;
164 uint16_t family_hdrsize;
165 uint16_t family_id;
166 uint16_t family_version;
167 uint16_t family_attr_max;
168 uint16_t family_cmd_size;
169 uint16_t family_num_groups;
170 struct genl_cmd *family_cmds;
171};
172
173struct genl_group {
174 struct genl_family *group_family;
175 const char *group_name;
176};
177
178struct genl_family *genl_get_family(uint32_t family_id);
179struct genl_group *genl_get_group(uint32_t group_id);
139struct nl_buf *nl_buf_alloc(size_t len, int mflag);
140void nl_buf_free(struct nl_buf *nb);
180141
181142#define MAX_FAMILIES 20
182143#define MAX_GROUPS 64
183144
184145#define MIN_GROUP_NUM 48
185146
147#define CTRL_FAMILY_ID 0
186148#define CTRL_FAMILY_NAME "nlctrl"
149#define CTRL_GROUP_ID 0
150#define CTRL_GROUP_NAME "notify"
187151
188152struct ifnet;
189153struct nl_parsed_link;
......@@ -194,14 +158,15 @@ struct nl_pstate;
194158struct nl_function_wrapper {
195159 bool (*nlmsg_add)(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,
196160 uint16_t flags, uint32_t len);
197 bool (*nlmsg_refill_buffer)(struct nl_writer *nw, int required_len);
161 bool (*nlmsg_refill_buffer)(struct nl_writer *nw, size_t required_len);
198162 bool (*nlmsg_flush)(struct nl_writer *nw);
199163 bool (*nlmsg_end)(struct nl_writer *nw);
200164 void (*nlmsg_abort)(struct nl_writer *nw);
201165 void (*nlmsg_ignore_limit)(struct nl_writer *nw);
202 bool (*nlmsg_get_unicast_writer)(struct nl_writer *nw, int size, struct nlpcb *nlp);
203 bool (*nlmsg_get_group_writer)(struct nl_writer *nw, int size, int protocol, int group_id);
204 bool (*nlmsg_get_chain_writer)(struct nl_writer *nw, int size, struct mbuf **pm);
166 bool (*nl_writer_unicast)(struct nl_writer *nw, size_t size,
167 struct nlpcb *nlp, bool waitok);
168 bool (*nl_writer_group)(struct nl_writer *nw, size_t size,
169 uint16_t protocol, uint16_t group_id, int priv, bool waitok);
205170 bool (*nlmsg_end_dump)(struct nl_writer *nw, int error, struct nlmsghdr *hdr);
206171 int (*nl_modify_ifp_generic)(struct ifnet *ifp, struct nl_parsed_link *lattrs,
207172 const struct nlattr_bmask *bm, struct nl_pstate *npt);
lib/libc/include/generic-freebsd/netlink/route/route.h+4-3
......@@ -134,9 +134,10 @@ enum rt_scope_t {
134134
135135/*
136136 * Routing table identifiers.
137 * FreeBSD route table numbering starts from 0, where 0 is a valid default routing table.
138 * Indicating "all tables" via netlink can be done by not including RTA_TABLE attribute
139 * and keeping rtm_table=0 (compatibility) or setting RTA_TABLE value to RT_TABLE_UNSPEC.
137 * FreeBSD route table numbering starts from 0, where 0 is a valid default
138 * routing table. Indicating "all tables" via netlink can be done by not
139 * including RTA_TABLE attribute and keeping rtm_table=0 (compatibility) or
140 * setting RTA_TABLE value to RT_TABLE_UNSPEC.
140141 */
141142#define RT_TABLE_MAIN 0 /* RT_DEFAULT_FIB */
142143#define RT_TABLE_UNSPEC 0xFFFFFFFF /* RT_ALL_FIBS */
lib/libc/include/generic-freebsd/netlink/route/route_var.h+1
......@@ -69,6 +69,7 @@ struct nl_parsed_link {
6969 char *ifla_cloner;
7070 char *ifla_ifalias;
7171 struct nlattr *ifla_idata;
72 struct nlattr *ifla_address;
7273 unsigned short ifi_type;
7374 int ifi_index;
7475 uint32_t ifla_link;
lib/libc/include/generic-freebsd/netpfil/pf/pf.h+33-9
......@@ -49,7 +49,7 @@
4949enum { PF_INOUT, PF_IN, PF_OUT };
5050enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT,
5151 PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP, PF_DEFER,
52 PF_MATCH };
52 PF_MATCH, PF_AFRT, PF_RT };
5353enum { PF_RULESET_SCRUB, PF_RULESET_FILTER, PF_RULESET_NAT,
5454 PF_RULESET_BINAT, PF_RULESET_RDR, PF_RULESET_MAX };
5555enum { PF_OP_NONE, PF_OP_IRG, PF_OP_EQ, PF_OP_NE, PF_OP_LT,
......@@ -113,29 +113,38 @@ enum {
113113#define PFTM_OTHER_FIRST_PACKET_VAL 60 /* First packet */
114114#define PFTM_OTHER_SINGLE_VAL 30 /* Unidirectional */
115115#define PFTM_OTHER_MULTIPLE_VAL 60 /* Bidirectional */
116#define PFTM_FRAG_VAL 30 /* Fragment expire */
116#define PFTM_FRAG_VAL 60 /* Fragment expire */
117117#define PFTM_INTERVAL_VAL 10 /* Expire interval */
118118#define PFTM_SRC_NODE_VAL 0 /* Source tracking */
119119#define PFTM_TS_DIFF_VAL 30 /* Allowed TS diff */
120120
121121enum { PF_NOPFROUTE, PF_FASTROUTE, PF_ROUTETO, PF_DUPTO, PF_REPLYTO };
122122enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS,
123 PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX };
123 PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_ANCHORS, PF_LIMIT_ETH_ANCHORS,
124 PF_LIMIT_MAX };
124125#define PF_POOL_IDMASK 0x0f
125126enum { PF_POOL_NONE, PF_POOL_BITMASK, PF_POOL_RANDOM,
126127 PF_POOL_SRCHASH, PF_POOL_ROUNDROBIN };
127128enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
128129 PF_ADDR_TABLE, PF_ADDR_URPFFAILED,
129 PF_ADDR_RANGE };
130 PF_ADDR_RANGE, PF_ADDR_NONE };
130131#define PF_POOL_TYPEMASK 0x0f
131132#define PF_POOL_STICKYADDR 0x20
133#define PF_POOL_ENDPI 0x40
134#define PF_POOL_IPV6NH 0x80
132135#define PF_WSCALE_FLAG 0x80
133136#define PF_WSCALE_MASK 0x0f
134137
138#define PF_POOL_DYNTYPE(_o) \
139 ((((_o) & PF_POOL_TYPEMASK) == PF_POOL_ROUNDROBIN) || \
140 (((_o) & PF_POOL_TYPEMASK) == PF_POOL_RANDOM) || \
141 (((_o) & PF_POOL_TYPEMASK) == PF_POOL_SRCHASH))
142
135143#define PF_LOG 0x01
136144#define PF_LOG_ALL 0x02
137#define PF_LOG_SOCKET_LOOKUP 0x04
145#define PF_LOG_USER 0x04
138146#define PF_LOG_FORCE 0x08
147#define PF_LOG_MATCHES 0x10
139148
140149/* Reasons code for passing/dropping a packet */
141150#define PFRES_MATCH 0 /* Explicit match of a rule */
......@@ -154,7 +163,8 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
154163#define PFRES_SRCLIMIT 13 /* Source node/conn limit */
155164#define PFRES_SYNPROXY 14 /* SYN proxy */
156165#define PFRES_MAPFAILED 15 /* pf_map_addr() failed */
157#define PFRES_MAX 16 /* total+1 */
166#define PFRES_TRANSLATE 16 /* No translation address available */
167#define PFRES_MAX 17 /* total+1 */
158168
159169#define PFRES_NAMES { \
160170 "match", \
......@@ -173,6 +183,7 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
173183 "src-limit", \
174184 "synproxy", \
175185 "map-failed", \
186 "translate", \
176187 NULL \
177188}
178189
......@@ -480,6 +491,9 @@ struct pf_osfp_ioctl {
480491};
481492
482493#define PF_ANCHOR_NAME_SIZE 64
494#define PF_ANCHOR_MAXPATH (MAXPATHLEN - PF_ANCHOR_NAME_SIZE - 1)
495#define PF_ANCHOR_HIWAT 512
496#define PF_OPTIMIZER_TABLE_PFX "__automatic_"
483497
484498struct pf_rule {
485499 struct pf_rule_addr src;
......@@ -489,8 +503,8 @@ struct pf_rule {
489503#define PF_SKIP_AF 2
490504#define PF_SKIP_PROTO 3
491505#define PF_SKIP_SRC_ADDR 4
492#define PF_SKIP_SRC_PORT 5
493#define PF_SKIP_DST_ADDR 6
506#define PF_SKIP_DST_ADDR 5
507#define PF_SKIP_SRC_PORT 6
494508#define PF_SKIP_DST_PORT 7
495509#define PF_SKIP_COUNT 8
496510 union pf_rule_ptr skip[PF_SKIP_COUNT];
......@@ -614,6 +628,9 @@ struct pf_rule {
614628#define PFRULE_SET_TOS 0x00002000
615629#define PFRULE_IFBOUND 0x00010000 /* if-bound */
616630#define PFRULE_STATESLOPPY 0x00020000 /* sloppy state tracking */
631#define PFRULE_PFLOW 0x00040000
632#define PFRULE_ALLOW_RELATED 0x00080000
633#define PFRULE_AFTO 0x00200000 /* af-to rule */
617634
618635#ifdef _KERNEL
619636#define PFRULE_REFS 0x0080 /* rule has references */
......@@ -626,7 +643,7 @@ struct pf_rule {
626643/* pf_state->state_flags, pf_rule_actions->flags, pf_krule->scrub_flags */
627644#define PFSTATE_ALLOWOPTS 0x0001
628645#define PFSTATE_SLOPPY 0x0002
629/* was PFSTATE_PFLOW 0x0004 */
646#define PFSTATE_PFLOW 0x0004
630647#define PFSTATE_NOSYNC 0x0008
631648#define PFSTATE_ACK 0x0010
632649#define PFSTATE_NODF 0x0020
......@@ -642,6 +659,12 @@ struct pf_rule {
642659#define PFSTATE_SCRUBMASK (PFSTATE_NODF|PFSTATE_RANDOMID|PFSTATE_SCRUB_TCP)
643660#define PFSTATE_SETMASK (PFSTATE_SETTOS|PFSTATE_SETPRIO)
644661
662/* pfctl_state->src_node_flags */
663#define PFSTATE_SRC_NODE_LIMIT 0x01
664#define PFSTATE_SRC_NODE_NAT 0x02
665#define PFSTATE_SRC_NODE_ROUTE 0x04
666#define PFSTATE_SRC_NODE_LIMIT_GLOBAL 0x10
667
645668#define PFSTATE_HIWAT 100000 /* default state table size */
646669#define PFSTATE_ADAPT_START 60000 /* default adaptive timeout start */
647670#define PFSTATE_ADAPT_END 120000 /* default adaptive timeout end */
......@@ -670,6 +693,7 @@ struct pf_src_node {
670693 u_int32_t creation;
671694 u_int32_t expire;
672695 sa_family_t af;
696 sa_family_t naf;
673697 u_int8_t ruletype;
674698};
675699
lib/libc/include/generic-freebsd/netpfil/pf/pf_mtag.h+1-1
......@@ -41,7 +41,7 @@
4141#define PF_MTAG_FLAG_TRANSLATE_LOCALHOST 0x04
4242#define PF_MTAG_FLAG_PACKET_LOOPED 0x08
4343#define PF_MTAG_FLAG_FASTFWD_OURS_PRESENT 0x10
44/* 0x20 unused */
44#define PF_MTAG_FLAG_DUMMYNETED 0x20
4545#define PF_MTAG_FLAG_DUPLICATED 0x40
4646#define PF_MTAG_FLAG_SYNCOOKIE_RECREATED 0x80
4747
lib/libc/include/generic-freebsd/netpfil/pf/pf_nl.h created+492
......@@ -0,0 +1,492 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2023 Alexander V. Chernikov <melifaro@FreeBSD.org>
5 * Copyright (c) 2023 Rubicon Communications, LLC (Netgate)
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29
30#ifndef _NETPFIL_PF_PF_NL_H_
31#define _NETPFIL_PF_PF_NL_H_
32
33/* Genetlink family */
34#define PFNL_FAMILY_NAME "pfctl"
35
36/* available commands */
37enum {
38 PFNL_CMD_UNSPEC = 0,
39 PFNL_CMD_GETSTATES = 1,
40 PFNL_CMD_GETCREATORS = 2,
41 PFNL_CMD_START = 3,
42 PFNL_CMD_STOP = 4,
43 PFNL_CMD_ADDRULE = 5,
44 PFNL_CMD_GETRULES = 6,
45 PFNL_CMD_GETRULE = 7,
46 PFNL_CMD_CLRSTATES = 8,
47 PFNL_CMD_KILLSTATES = 9,
48 PFNL_CMD_SET_STATUSIF = 10,
49 PFNL_CMD_GET_STATUS = 11,
50 PFNL_CMD_CLEAR_STATUS = 12,
51 PFNL_CMD_NATLOOK = 13,
52 PFNL_CMD_SET_DEBUG = 14,
53 PFNL_CMD_SET_TIMEOUT = 15,
54 PFNL_CMD_GET_TIMEOUT = 16,
55 PFNL_CMD_SET_LIMIT = 17,
56 PFNL_CMD_GET_LIMIT = 18,
57 PFNL_CMD_BEGIN_ADDRS = 19,
58 PFNL_CMD_ADD_ADDR = 20,
59 PFNL_CMD_GET_ADDRS = 21,
60 PFNL_CMD_GET_ADDR = 22,
61 PFNL_CMD_GET_RULESETS = 23,
62 PFNL_CMD_GET_RULESET = 24,
63 PFNL_CMD_GET_SRCNODES = 25,
64 PFNL_CMD_CLEAR_TABLES = 26,
65 PFNL_CMD_ADD_TABLE = 27,
66 PFNL_CMD_DEL_TABLE = 28,
67 PFNL_CMD_GET_TSTATS = 29,
68 PFNL_CMD_CLR_TSTATS = 30,
69 PFNL_CMD_CLR_ADDRS = 31,
70 PFNL_CMD_TABLE_ADD_ADDR = 32,
71 PFNL_CMD_TABLE_DEL_ADDR = 33,
72 __PFNL_CMD_MAX,
73};
74#define PFNL_CMD_MAX (__PFNL_CMD_MAX -1)
75
76enum pfstate_key_type_t {
77 PF_STK_UNSPEC,
78 PF_STK_ADDR0 = 1, /* ip */
79 PF_STK_ADDR1 = 2, /* ip */
80 PF_STK_PORT0 = 3, /* u16 */
81 PF_STK_PORT1 = 4, /* u16 */
82 PF_STK_AF = 5, /* u8 */
83 PF_STK_PROTO = 6, /* u16 */
84};
85
86enum pfstate_peer_type_t {
87 PF_STP_UNSPEC,
88 PF_STP_PFSS_FLAGS = 1, /* u16 */
89 PF_STP_PFSS_TTL = 2, /* u8 */
90 PF_STP_SCRUB_FLAG = 3, /* u8 */
91 PF_STP_PFSS_TS_MOD = 4, /* u32 */
92 PF_STP_SEQLO = 5, /* u32 */
93 PF_STP_SEQHI = 6, /* u32 */
94 PF_STP_SEQDIFF = 7, /* u32 */
95 PF_STP_MAX_WIN = 8, /* u16 */
96 PF_STP_MSS = 9, /* u16 */
97 PF_STP_STATE = 10, /* u8 */
98 PF_STP_WSCALE = 11, /* u8 */
99};
100
101enum pfstate_type_t {
102 PF_ST_UNSPEC,
103 PF_ST_ID = 1, /* u32, state id */
104 PF_ST_CREATORID = 2, /* u32, */
105 PF_ST_IFNAME = 3, /* string */
106 PF_ST_ORIG_IFNAME = 4, /* string */
107 PF_ST_KEY_WIRE = 5, /* nested, pfstate_key_type_t */
108 PF_ST_KEY_STACK = 6, /* nested, pfstate_key_type_t */
109 PF_ST_PEER_SRC = 7, /* nested, pfstate_peer_type_t*/
110 PF_ST_PEER_DST = 8, /* nested, pfstate_peer_type_t */
111 PF_ST_RT_ADDR = 9, /* ip */
112 PF_ST_RULE = 10, /* u32 */
113 PF_ST_ANCHOR = 11, /* u32 */
114 PF_ST_NAT_RULE = 12, /* u32 */
115 PF_ST_CREATION = 13, /* u32 */
116 PF_ST_EXPIRE = 14, /* u32 */
117 PF_ST_PACKETS0 = 15, /* u64 */
118 PF_ST_PACKETS1 = 16, /* u64 */
119 PF_ST_BYTES0 = 17, /* u64 */
120 PF_ST_BYTES1 = 18, /* u64 */
121 PF_ST_AF = 19, /* u8 */
122 PF_ST_PROTO = 21, /* u8 */
123 PF_ST_DIRECTION = 22, /* u8 */
124 PF_ST_LOG = 23, /* u8 */
125 PF_ST_TIMEOUT = 24, /* u8 */
126 PF_ST_STATE_FLAGS = 25, /* u8 */
127 PF_ST_SYNC_FLAGS = 26, /* u8 */
128 PF_ST_UPDATES = 27, /* u8 */
129 PF_ST_VERSION = 28, /* u64 */
130 PF_ST_FILTER_ADDR = 29, /* in6_addr */
131 PF_ST_FILTER_MASK = 30, /* in6_addr */
132 PF_ST_RTABLEID = 31, /* i32 */
133 PF_ST_MIN_TTL = 32, /* u8 */
134 PF_ST_MAX_MSS = 33, /* u16 */
135 PF_ST_DNPIPE = 34, /* u16 */
136 PF_ST_DNRPIPE = 35, /* u16 */
137 PF_ST_RT = 36, /* u8 */
138 PF_ST_RT_IFNAME = 37, /* string */
139 PF_ST_SRC_NODE_FLAGS = 38, /* u8 */
140 PF_ST_RT_AF = 39, /* u8 */
141};
142
143enum pf_addr_type_t {
144 PF_AT_UNSPEC,
145 PF_AT_ADDR = 1, /* in6_addr */
146 PF_AT_MASK = 2, /* in6_addr */
147 PF_AT_IFNAME = 3, /* string */
148 PF_AT_TABLENAME = 4, /* string */
149 PF_AT_TYPE = 5, /* u8 */
150 PF_AT_IFLAGS = 6, /* u8 */
151 PF_AT_TBLCNT = 7, /* u32 */
152 PF_AT_DYNCNT = 8, /* u32 */
153};
154
155enum pfrule_addr_type_t {
156 PF_RAT_UNSPEC,
157 PF_RAT_ADDR = 1, /* nested, pf_addr_type_t */
158 PF_RAT_SRC_PORT = 2, /* u16 */
159 PF_RAT_DST_PORT = 3, /* u16 */
160 PF_RAT_NEG = 4, /* u8 */
161 PF_RAT_OP = 5, /* u8 */
162};
163
164enum pf_labels_type_t {
165 PF_LT_UNSPEC,
166 PF_LT_LABEL = 1, /* string */
167};
168
169enum pf_mape_portset_type_t
170{
171 PF_MET_UNSPEC,
172 PF_MET_OFFSET = 1, /* u8 */
173 PF_MET_PSID_LEN = 2, /* u8 */
174 PF_MET_PSID = 3, /* u16 */
175};
176
177enum pf_rpool_type_t
178{
179 PF_PT_UNSPEC,
180 PF_PT_KEY = 1, /* bytes, sizeof(struct pf_poolhashkey) */
181 PF_PT_COUNTER = 2, /* in6_addr */
182 PF_PT_TBLIDX = 3, /* u32 */
183 PF_PT_PROXY_SRC_PORT = 4, /* u16 */
184 PF_PT_PROXY_DST_PORT = 5, /* u16 */
185 PF_PT_OPTS = 6, /* u8 */
186 PF_PT_MAPE = 7, /* nested, pf_mape_portset_type_t */
187};
188
189enum pf_timeout_type_t {
190 PF_TT_UNSPEC,
191 PF_TT_TIMEOUT = 1, /* u32 */
192};
193
194enum pf_rule_uid_type_t {
195 PF_RUT_UNSPEC,
196 PF_RUT_UID_LOW = 1, /* u32 */
197 PF_RUT_UID_HIGH = 2, /* u32 */
198 PF_RUT_OP = 3, /* u8 */
199};
200
201enum pf_rule_type_t {
202 PF_RT_UNSPEC,
203 PF_RT_SRC = 1, /* nested, pf_rule_addr_type_t */
204 PF_RT_DST = 2, /* nested, pf_rule_addr_type_t */
205 PF_RT_RIDENTIFIER = 3, /* u32 */
206 PF_RT_LABELS = 4, /* nested, pf_labels_type_t */
207 PF_RT_IFNAME = 5, /* string */
208 PF_RT_QNAME = 6, /* string */
209 PF_RT_PQNAME = 7, /* string */
210 PF_RT_TAGNAME = 8, /* string */
211 PF_RT_MATCH_TAGNAME = 9, /* string */
212 PF_RT_OVERLOAD_TBLNAME = 10, /* string */
213 PF_RT_RPOOL_RDR = 11, /* nested, pf_rpool_type_t */
214 PF_RT_OS_FINGERPRINT = 12, /* u32 */
215 PF_RT_RTABLEID = 13, /* u32 */
216 PF_RT_TIMEOUT = 14, /* nested, pf_timeout_type_t */
217 PF_RT_MAX_STATES = 15, /* u32 */
218 PF_RT_MAX_SRC_NODES = 16, /* u32 */
219 PF_RT_MAX_SRC_STATES = 17, /* u32 */
220 PF_RT_MAX_SRC_CONN_RATE_LIMIT = 18, /* u32 */
221 PF_RT_MAX_SRC_CONN_RATE_SECS = 19, /* u32 */
222 PF_RT_DNPIPE = 20, /* u16 */
223 PF_RT_DNRPIPE = 21, /* u16 */
224 PF_RT_DNFLAGS = 22, /* u32 */
225 PF_RT_NR = 23, /* u32 */
226 PF_RT_PROB = 24, /* u32 */
227 PF_RT_CUID = 25, /* u32 */
228 PF_RT_CPID = 26, /* u32 */
229 PF_RT_RETURN_ICMP = 27, /* u16 */
230 PF_RT_RETURN_ICMP6 = 28, /* u16 */
231 PF_RT_MAX_MSS = 29, /* u16 */
232 PF_RT_SCRUB_FLAGS = 30, /* u16 */
233 PF_RT_UID = 31, /* nested, pf_rule_uid_type_t */
234 PF_RT_GID = 32, /* nested, pf_rule_uid_type_t */
235 PF_RT_RULE_FLAG = 33, /* u32 */
236 PF_RT_ACTION = 34, /* u8 */
237 PF_RT_DIRECTION = 35, /* u8 */
238 PF_RT_LOG = 36, /* u8 */
239 PF_RT_LOGIF = 37, /* u8 */
240 PF_RT_QUICK = 38, /* u8 */
241 PF_RT_IF_NOT = 39, /* u8 */
242 PF_RT_MATCH_TAG_NOT = 40, /* u8 */
243 PF_RT_NATPASS = 41, /* u8 */
244 PF_RT_KEEP_STATE = 42, /* u8 */
245 PF_RT_AF = 43, /* u8 */
246 PF_RT_PROTO = 44, /* u8 */
247 PF_RT_TYPE = 45, /* u8 */
248 PF_RT_CODE = 46, /* u8 */
249 PF_RT_FLAGS = 47, /* u8 */
250 PF_RT_FLAGSET = 48, /* u8 */
251 PF_RT_MIN_TTL = 49, /* u8 */
252 PF_RT_ALLOW_OPTS = 50, /* u8 */
253 PF_RT_RT = 51, /* u8 */
254 PF_RT_RETURN_TTL = 52, /* u8 */
255 PF_RT_TOS = 53, /* u8 */
256 PF_RT_SET_TOS = 54, /* u8 */
257 PF_RT_ANCHOR_RELATIVE = 55, /* u8 */
258 PF_RT_ANCHOR_WILDCARD = 56, /* u8 */
259 PF_RT_FLUSH = 57, /* u8 */
260 PF_RT_PRIO = 58, /* u8 */
261 PF_RT_SET_PRIO = 59, /* u8 */
262 PF_RT_SET_PRIO_REPLY = 60, /* u8 */
263 PF_RT_DIVERT_ADDRESS = 61, /* in6_addr */
264 PF_RT_DIVERT_PORT = 62, /* u16 */
265 PF_RT_PACKETS_IN = 63, /* u64 */
266 PF_RT_PACKETS_OUT = 64, /* u64 */
267 PF_RT_BYTES_IN = 65, /* u64 */
268 PF_RT_BYTES_OUT = 66, /* u64 */
269 PF_RT_EVALUATIONS = 67, /* u64 */
270 PF_RT_TIMESTAMP = 68, /* u64 */
271 PF_RT_STATES_CUR = 69, /* u64 */
272 PF_RT_STATES_TOTAL = 70, /* u64 */
273 PF_RT_SRC_NODES = 71, /* u64 */
274 PF_RT_ANCHOR_CALL = 72, /* string */
275 PF_RT_RCV_IFNAME = 73, /* string */
276 PF_RT_MAX_SRC_CONN = 74, /* u32 */
277 PF_RT_RPOOL_NAT = 75, /* nested, pf_rpool_type_t */
278 PF_RT_NAF = 76, /* u8 */
279 PF_RT_RPOOL_RT = 77, /* nested, pf_rpool_type_t */
280 PF_RT_RCV_IFNOT = 78, /* bool */
281 PF_RT_SRC_NODES_LIMIT = 79, /* u64 */
282 PF_RT_SRC_NODES_NAT = 80, /* u64 */
283 PF_RT_SRC_NODES_ROUTE = 81, /* u64 */
284 PF_RT_PKTRATE = 82, /* nested, pf_threshold_type_t */
285 PF_RT_MAX_PKT_SIZE = 83, /* u16 */
286 PF_RT_TYPE_2 = 84, /* u16 */
287 PF_RT_CODE_2 = 85, /* u16 */
288};
289
290enum pf_addrule_type_t {
291 PF_ART_UNSPEC,
292 PF_ART_TICKET = 1, /* u32 */
293 PF_ART_POOL_TICKET = 2, /* u32 */
294 PF_ART_ANCHOR = 3, /* string */
295 PF_ART_ANCHOR_CALL = 4, /* string */
296 PF_ART_RULE = 5, /* nested, pfrule_type_t */
297};
298
299enum pf_getrules_type_t {
300 PF_GR_UNSPEC,
301 PF_GR_ANCHOR = 1, /* string */
302 PF_GR_ACTION = 2, /* u8 */
303 PF_GR_NR = 3, /* u32 */
304 PF_GR_TICKET = 4, /* u32 */
305 PF_GR_CLEAR = 5, /* u8 */
306};
307
308enum pf_clear_states_type_t {
309 PF_CS_UNSPEC,
310 PF_CS_CMP_ID = 1, /* u64 */
311 PF_CS_CMP_CREATORID = 2, /* u32 */
312 PF_CS_CMP_DIR = 3, /* u8 */
313 PF_CS_AF = 4, /* u8 */
314 PF_CS_PROTO = 5, /* u8 */
315 PF_CS_SRC = 6, /* nested, pf_addr_wrap */
316 PF_CS_DST = 7, /* nested, pf_addr_wrap */
317 PF_CS_RT_ADDR = 8, /* nested, pf_addr_wrap */
318 PF_CS_IFNAME = 9, /* string */
319 PF_CS_LABEL = 10, /* string */
320 PF_CS_KILL_MATCH = 11, /* bool */
321 PF_CS_NAT = 12, /* bool */
322 PF_CS_KILLED = 13, /* u32 */
323};
324
325enum pf_set_statusif_types_t {
326 PF_SS_UNSPEC,
327 PF_SS_IFNAME = 1, /* string */
328};
329
330enum pf_counter_types_t {
331 PF_C_UNSPEC,
332 PF_C_COUNTER = 1, /* u64 */
333 PF_C_NAME = 2, /* string */
334 PF_C_ID = 3, /* u32 */
335};
336
337enum pf_get_status_types_t {
338 PF_GS_UNSPEC,
339 PF_GS_IFNAME = 1, /* string */
340 PF_GS_RUNNING = 2, /* bool */
341 PF_GS_SINCE = 3, /* u32 */
342 PF_GS_DEBUG = 4, /* u32 */
343 PF_GS_HOSTID = 5, /* u32 */
344 PF_GS_STATES = 6, /* u32 */
345 PF_GS_SRC_NODES = 7, /* u32 */
346 PF_GS_REASSEMBLE = 8, /* u32 */
347 PF_GS_SYNCOOKIES_ACTIVE = 9, /* bool */
348 PF_GS_COUNTERS = 10, /* nested, */
349 PF_GS_LCOUNTERS = 11, /* nested, */
350 PF_GS_FCOUNTERS = 12, /* nested, */
351 PF_GS_SCOUNTERS = 13, /* nested, */
352 PF_GS_CHKSUM = 14, /* byte array */
353 PF_GS_PCOUNTERS = 15, /* u64 array */
354 PF_GS_BCOUNTERS = 16, /* u64 array */
355};
356
357enum pf_natlook_types_t {
358 PF_NL_UNSPEC,
359 PF_NL_AF = 1, /* u8 */
360 PF_NL_DIRECTION = 2, /* u8 */
361 PF_NL_PROTO = 3, /* u8 */
362 PF_NL_SRC_ADDR = 4, /* in6_addr */
363 PF_NL_DST_ADDR = 5, /* in6_addr */
364 PF_NL_SRC_PORT = 6, /* u16 */
365 PF_NL_DST_PORT = 7, /* u16 */
366};
367
368enum pf_set_debug_types_t {
369 PF_SD_UNSPEC,
370 PF_SD_LEVEL = 1, /* u32 */
371};
372
373enum pf_timeout_types_t {
374 PF_TO_UNSPEC,
375 PF_TO_TIMEOUT = 1, /* u32 */
376 PF_TO_SECONDS = 2, /* u32 */
377};
378
379enum pf_limit_types_t {
380 PF_LI_UNSPEC,
381 PF_LI_INDEX = 1, /* u32 */
382 PF_LI_LIMIT = 2, /* u32 */
383};
384
385enum pf_begin_addrs_types_t {
386 PF_BA_UNSPEC,
387 PF_BA_TICKET = 1, /* u32 */
388};
389
390enum pf_pool_addr_types_t {
391 PF_PA_UNSPEC,
392 PF_PA_ADDR = 1, /* nested, pf_addr_wrap */
393 PF_PA_IFNAME = 2, /* string */
394};
395
396enum pf_add_addr_types_t {
397 PF_AA_UNSPEC,
398 PF_AA_ACTION = 1, /* u32 */
399 PF_AA_TICKET = 2, /* u32 */
400 PF_AA_NR = 3, /* u32 */
401 PF_AA_R_NUM = 4, /* u32 */
402 PF_AA_R_ACTION = 5, /* u8 */
403 PF_AA_R_LAST = 6, /* u8 */
404 PF_AA_AF = 7, /* u8 */
405 PF_AA_ANCHOR = 8, /* string */
406 PF_AA_ADDR = 9, /* nested, pf_pooladdr */
407 PF_AA_WHICH = 10, /* u32 */
408};
409
410enum pf_get_rulesets_types_t {
411 PF_RS_UNSPEC,
412 PF_RS_PATH = 1, /* string */
413 PF_RS_NR = 2, /* u32 */
414 PF_RS_NAME = 3, /* string */
415};
416
417enum pf_threshold_types_t {
418 PF_TH_UNSPEC,
419 PF_TH_LIMIT = 1, /* u32 */
420 PF_TH_SECONDS = 2, /* u32 */
421 PF_TH_COUNT = 3, /* u32 */
422 PF_TH_LAST = 4, /* u32 */
423};
424
425enum pf_srcnodes_types_t {
426 PF_SN_UNSPEC,
427 PF_SN_ADDR = 1, /* nested, pf_addr */
428 PF_SN_RADDR = 2, /* nested, pf_addr */
429 PF_SN_RULE_NR = 3, /* u32 */
430 PF_SN_BYTES_IN = 4, /* u64 */
431 PF_SN_BYTES_OUT = 5, /* u64 */
432 PF_SN_PACKETS_IN = 6, /* u64 */
433 PF_SN_PACKETS_OUT = 7, /* u64 */
434 PF_SN_STATES = 8, /* u32 */
435 PF_SN_CONNECTIONS = 9, /* u32 */
436 PF_SN_AF = 10, /* u8 */
437 PF_SN_RULE_TYPE = 11, /* u8 */
438 PF_SN_CREATION = 12, /* u64 */
439 PF_SN_EXPIRE = 13, /* u64 */
440 PF_SN_CONNECTION_RATE = 14, /* nested, pf_threshold */
441 PF_SN_RAF = 15, /* u8 */
442 PF_SN_NODE_TYPE = 16, /* u8 */
443};
444
445enum pf_tables_t {
446 PF_T_UNSPEC,
447 PF_T_ANCHOR = 1, /* string */
448 PF_T_NAME = 2, /* string */
449 PF_T_TABLE_FLAGS = 3, /* u32 */
450 PF_T_FLAGS = 4, /* u32 */
451 PF_T_NBR_DELETED = 5, /* u32 */
452 PF_T_NBR_ADDED = 6, /* u32 */
453};
454
455enum pf_tstats_t {
456 PF_TS_UNSPEC,
457 PF_TS_TABLE = 1, /* nested, pfr_table */
458 PF_TS_PACKETS = 2, /* u64 array */
459 PF_TS_BYTES = 3, /* u64 array */
460 PF_TS_MATCH = 4, /* u64 */
461 PF_TS_NOMATCH = 5, /* u64 */
462 PF_TS_TZERO = 6, /* u64 */
463 PF_TS_CNT = 7, /* u64 */
464 PF_TS_REFCNT = 8, /* u64 array */
465 PF_TS_NZERO = 9, /* u64 */
466};
467
468enum pfr_addr_t {
469 PFR_A_UNSPEC,
470 PFR_A_AF = 1, /* uint8_t */
471 PFR_A_NET = 2, /* uint8_t */
472 PFR_A_NOT = 3, /* bool */
473 PFR_A_ADDR = 4, /* in6_addr */
474};
475
476enum pf_table_addrs_t {
477 PF_TA_UNSPEC,
478 PF_TA_TABLE = 1, /* nested, pf_table_t */
479 PF_TA_ADDR = 2, /* nested, pfr_addr_t */
480 PF_TA_FLAGS = 3, /* u32 */
481 PF_TA_NBR_ADDED = 4, /* u32 */
482 PF_TA_NBR_DELETED = 5, /* u32 */
483};
484
485#ifdef _KERNEL
486
487void pf_nl_register(void);
488void pf_nl_unregister(void);
489
490#endif
491
492#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/nfs/nfsdiskless.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfsdiskless.h 8.2 (Berkeley) 3/30/95
3533 */
3634
3735#ifndef _NFSCLIENT_NFSDISKLESS_H_
lib/libc/include/generic-freebsd/nfs/nfsproto.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
3533 */
3634
3735#ifndef _NFS_NFSPROTO_H_
lib/libc/include/generic-freebsd/nfs/xdr_subs.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95
3533 */
3634
3735#ifndef _NFS_XDR_SUBS_H_
lib/libc/include/generic-freebsd/nfsclient/nfs.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
3533 */
3634
3735#ifndef _NFSCLIENT_NFS_H_
lib/libc/include/generic-freebsd/nfsclient/nfsargs.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
3533 */
3634
3735#ifndef _NFSCLIENT_NFSARGS_H_
lib/libc/include/generic-freebsd/nfsclient/nfsmount.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfsmount.h 8.3 (Berkeley) 3/30/95
3533 */
3634
3735#ifndef _NFSCLIENT_NFSMOUNT_H_
lib/libc/include/generic-freebsd/nfsclient/nfsnode.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95
3533 */
3634
3735#ifndef _NFSCLIENT_NFSNODE_H_
lib/libc/include/generic-freebsd/nfsclient/nfsstats.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
3533 */
3634
3735#ifndef _NFSCLIENT_NFSSTATS_H_
lib/libc/include/generic-freebsd/nfsserver/nfs.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
3533 */
3634
3735#ifndef _NFSSERVER_NFS_H_
lib/libc/include/generic-freebsd/nfsserver/nfsrvstats.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
3533 */
3634
3735#ifndef _NFSSERVER_NFSRVSTATS_H_
lib/libc/include/generic-freebsd/nl_types.h-1
......@@ -34,7 +34,6 @@
3434#ifndef _NL_TYPES_H_
3535#define _NL_TYPES_H_
3636
37#include <sys/cdefs.h>
3837#include <sys/types.h>
3938
4039#ifdef _NLS_PRIVATE
lib/libc/include/generic-freebsd/nlist.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)nlist.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _NLIST_H_
lib/libc/include/generic-freebsd/osreldate.h+1-1
......@@ -1,5 +1,5 @@
11/*-
2 * Copyright (c) 1992-2023 The FreeBSD Project.
2 * Copyright (c) 1992-2025 The FreeBSD Project.
33 *
44 */
55#ifdef _KERNEL
lib/libc/include/generic-freebsd/paths.h+1-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)paths.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _PATHS_H_
......@@ -63,7 +61,6 @@
6361#define _PATH_FIRMWARE "/usr/share/firmware"
6462#define _PATH_FTPUSERS "/etc/ftpusers"
6563#define _PATH_FWMEM "/dev/fwmem"
66#define _PATH_GBDE "/sbin/gbde"
6764#define _PATH_GELI "/sbin/geli"
6865#define _PATH_HALT "/sbin/halt"
6966#ifdef COMPAT_libcompat
......@@ -84,6 +81,7 @@
8481#define _PATH_MOUNT "/sbin/mount"
8582#define _PATH_NEWFS "/sbin/newfs"
8683#define _PATH_NOLOGIN "/var/run/nologin"
84#define _PATH_NOSHUTDOWN "/var/run/noshutdown"
8785#define _PATH_RCP "/bin/rcp"
8886#define _PATH_REBOOT "/sbin/reboot"
8987#define _PATH_RLOGIN "/usr/bin/rlogin"
lib/libc/include/generic-freebsd/poll.h+6-2
......@@ -96,7 +96,7 @@ struct pollfd {
9696
9797#ifndef _KERNEL
9898
99#if __BSD_VISIBLE
99#if __POSIX_VISIBLE >= 202405
100100#include <sys/_types.h>
101101
102102#include <sys/_sigset.h>
......@@ -109,9 +109,13 @@ typedef __sigset_t sigset_t;
109109
110110#endif
111111
112#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
113#include <ssp/poll.h>
114#endif
115
112116__BEGIN_DECLS
113117int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
114#if __BSD_VISIBLE
118#if __POSIX_VISIBLE >= 202405
115119int ppoll(struct pollfd _pfd[], nfds_t _nfds,
116120 const struct timespec *__restrict _timeout,
117121 const sigset_t *__restrict _newsigmask);
lib/libc/include/generic-freebsd/protocols/dumprestore.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _PROTOCOLS_DUMPRESTORE_H_
lib/libc/include/generic-freebsd/protocols/routed.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)routed.h 8.1 (Berkeley) 6/2/93
3230 * $Revision: 2.26 $
3331 */
3432
lib/libc/include/generic-freebsd/protocols/rwhod.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)rwhod.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _PROTOCOLS_RWHOD_H_
lib/libc/include/generic-freebsd/protocols/talkd.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)talkd.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _PROTOCOLS_TALKD_H_
lib/libc/include/generic-freebsd/protocols/timed.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)timed.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _PROTOCOLS_TIMED_H_
lib/libc/include/generic-freebsd/pthread_np.h+2-7
......@@ -34,11 +34,6 @@
3434#include <sys/param.h>
3535#include <sys/cpuset.h>
3636
37/*
38 * Non-POSIX type definitions:
39 */
40typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t);
41
4237/*
4338 * Non-POSIX thread function prototype definitions:
4439 */
......@@ -64,11 +59,11 @@ int pthread_resume_np(pthread_t);
6459int pthread_peekjoin_np(pthread_t, void **);
6560void pthread_set_name_np(pthread_t, const char *);
6661int pthread_setaffinity_np(pthread_t, size_t, const cpuset_t *);
62void pthread_signals_block_np(void);
63void pthread_signals_unblock_np(void);
6764int pthread_single_np(void);
6865void pthread_suspend_all_np(void);
6966int pthread_suspend_np(pthread_t);
70int pthread_switch_add_np(pthread_switch_routine_t);
71int pthread_switch_delete_np(pthread_switch_routine_t);
7267int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
7368__END_DECLS
7469
lib/libc/include/generic-freebsd/pwd.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)pwd.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _PWD_H_
lib/libc/include/generic-freebsd/ranlib.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ranlib.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _RANLIB_H_
lib/libc/include/generic-freebsd/regex.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)regex.h 8.2 (Berkeley) 1/3/94
3634 */
3735
3836#ifndef _REGEX_H_
lib/libc/include/generic-freebsd/resolv.h-1
......@@ -47,7 +47,6 @@
4747 */
4848
4949/*%
50 * @(#)resolv.h 8.1 (Berkeley) 6/2/93
5150 * $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $
5251 */
5352
lib/libc/include/generic-freebsd/rpc/auth.h-4
......@@ -28,10 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)auth.h 1.17 88/02/08 SMI
33 * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
34 * from: @(#)auth.h 1.43 98/02/02 SMI
3531 */
3632
3733/*
lib/libc/include/generic-freebsd/rpc/auth_des.h-3
......@@ -1,4 +1,3 @@
1/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */
21/*-
32 * SPDX-License-Identifier: BSD-3-Clause
43 *
......@@ -28,8 +27,6 @@
2827 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2928 * POSSIBILITY OF SUCH DAMAGE.
3029 *
31 * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC
32 * from: @(#)auth_des.h 1.14 94/04/25 SMI
3330 */
3431
3532/*
lib/libc/include/generic-freebsd/rpc/auth_unix.h-3
......@@ -26,9 +26,6 @@
2626 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2727 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2828 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * from: @(#)auth_unix.h 1.8 88/02/08 SMI
31 * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC
3229 */
3330
3431/*
lib/libc/include/generic-freebsd/rpc/clnt.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)clnt.h 1.31 94/04/29 SMI
33 * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/clnt_nl.h created+42
......@@ -0,0 +1,42 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 Gleb Smirnoff <glebius@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _RPC_CLNT_NL_H
29#define _RPC_CLNT_NL_H
30
31enum rpcnl_cmds_t {
32 RPCNL_REQUEST = 1, /* mcast: kernel -> userland */
33 RPCNL_REPLY, /* unicast: userland -> kernel */
34};
35
36enum rpcnl_attr_t {
37 RPCNL_REQUEST_GROUP = 1,
38 RPCNL_REQUEST_BODY,
39 RPCNL_REPLY_GROUP,
40 RPCNL_REPLY_BODY,
41};
42#endif /* _RPC_CLNT_NL_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/rpc/clnt_stat.h-2
......@@ -11,8 +11,6 @@
1111#ifndef _RPC_CLNT_STAT_H
1212#define _RPC_CLNT_STAT_H
1313
14/* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */
15
1614#ifdef __cplusplus
1715extern "C" {
1816#endif
lib/libc/include/generic-freebsd/rpc/des.h-21
......@@ -1,4 +1,3 @@
1/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
21/*-
32 * SPDX-License-Identifier: BSD-3-Clause
43 *
......@@ -57,26 +56,6 @@ struct desparams {
5756# define des_buf UDES.UDES_buf /* otherwise, pointer to data */
5857};
5958
60#ifdef notdef
61
62/*
63 * These ioctls are only implemented in SunOS. Maybe someday
64 * if somebody writes a driver for DES hardware that works
65 * with FreeBSD, we can being that back.
66 */
67
68/*
69 * Encrypt an arbitrary sized buffer
70 */
71#define DESIOCBLOCK _IOWR('d', 6, struct desparams)
72
73/*
74 * Encrypt of small amount of data, quickly
75 */
76#define DESIOCQUICK _IOWR('d', 7, struct desparams)
77
78#endif
79
8059/*
8160 * Software DES.
8261 */
lib/libc/include/generic-freebsd/rpc/des_crypt.h-1
......@@ -1,5 +1,4 @@
11/*
2 * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI
32 *
43 * des_crypt.h, des library routine interface
54 * Copyright (C) 1986, Sun Microsystems, Inc.
lib/libc/include/generic-freebsd/rpc/key_prot.h-4
......@@ -42,10 +42,6 @@ extern "C" {
4242 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4343 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4444 */
45/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */
46/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
47#include <sys/cdefs.h>
48
4945/*
5046 * Compiled from key_prot.x using rpcgen.
5147 * DO NOT EDIT THIS FILE!
lib/libc/include/generic-freebsd/rpc/pmap_clnt.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI
33 * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/pmap_prot.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)pmap_prot.h 1.14 88/02/08 SMI
33 * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/pmap_rmt.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI
33 * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/raw.h-3
......@@ -36,9 +36,6 @@
3636#ifndef _RPC_RAW_H
3737#define _RPC_RAW_H
3838
39/* from: @(#)raw.h 1.11 94/04/25 SMI */
40/* from: @(#)raw.h 1.2 88/10/25 SMI */
41
4239#ifdef __cplusplus
4340extern "C" {
4441#endif
lib/libc/include/generic-freebsd/rpc/rpc.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)rpc.h 1.9 88/02/08 SMI
33 * from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/rpc_com.h-2
......@@ -44,8 +44,6 @@
4444
4545#include <sys/cdefs.h>
4646
47/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */
48
4947/*
5048 * The max size of the transport, if the size cannot be determined
5149 * by other means.
lib/libc/include/generic-freebsd/rpc/rpc_msg.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)rpc_msg.h 1.7 86/07/16 SMI
33 * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/rpcb_clnt.h-1
......@@ -55,7 +55,6 @@
5555#ifndef _RPC_RPCB_CLNT_H
5656#define _RPC_RPCB_CLNT_H
5757
58/* #pragma ident "@(#)rpcb_clnt.h 1.13 94/04/25 SMI" */
5958/* rpcb_clnt.h 1.3 88/12/05 SMI */
6059
6160#include <rpc/types.h>
lib/libc/include/generic-freebsd/rpc/rpcb_prot.h-2
......@@ -44,8 +44,6 @@ extern "C" {
4444 */
4545/* from rpcb_prot.x */
4646
47/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */
48
4947#ifndef _KERNEL
5048
5149
lib/libc/include/generic-freebsd/rpc/rpcb_prot.x-2
......@@ -33,8 +33,6 @@
3333
3434#ifdef RPC_HDR
3535%
36%/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */
37%
3836%#ifndef _KERNEL
3937%
4038#endif
lib/libc/include/generic-freebsd/rpc/rpcent.h-4
......@@ -42,10 +42,6 @@
4242#ifndef _RPC_RPCENT_H
4343#define _RPC_RPCENT_H
4444
45/* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */
46/* @(#)rpcent.h 1.1 88/12/06 SMI */
47
48
4945struct rpcent {
5046 char *r_name; /* name of server for this rpc program */
5147 char **r_aliases; /* alias list */
lib/libc/include/generic-freebsd/rpc/rpcsec_tls.h+7-26
......@@ -28,20 +28,8 @@
2828#ifndef _RPC_RPCSEC_TLS_H_
2929#define _RPC_RPCSEC_TLS_H_
3030
31/* Operation values for rpctls syscall. */
32#define RPCTLS_SYSC_CLSETPATH 1
33#define RPCTLS_SYSC_CLSOCKET 2
34#define RPCTLS_SYSC_CLSHUTDOWN 3
35#define RPCTLS_SYSC_SRVSETPATH 4
36#define RPCTLS_SYSC_SRVSOCKET 5
37#define RPCTLS_SYSC_SRVSHUTDOWN 6
38#define RPCTLS_SYSC_SRVSTARTUP 7
39
40/* Max nprocs for SRV startup */
41#define RPCTLS_SRV_MAXNPROCS 16
42
43/* System call used by the rpctlscd, rpctlssd daemons. */
44int rpctls_syscall(int, const char *);
31/* System call used by the rpc.tlsclntd(8), rpc.tlsservd(8) daemons. */
32int rpctls_syscall(uint64_t);
4533
4634/* Flag bits to indicate certificate results. */
4735#define RPCTLS_FLAGS_HANDSHAKE 0x01
......@@ -61,15 +49,11 @@ int rpctls_syscall(int, const char *);
6149#ifdef _KERNEL
6250/* Functions that perform upcalls to the rpctlsd daemon. */
6351enum clnt_stat rpctls_connect(CLIENT *newclient, char *certname,
64 struct socket *so, uint64_t *sslp, uint32_t *reterr);
65enum clnt_stat rpctls_cl_handlerecord(uint64_t sec, uint64_t usec,
66 uint64_t ssl, uint32_t *reterr);
67enum clnt_stat rpctls_srv_handlerecord(uint64_t sec, uint64_t usec,
68 uint64_t ssl, int procpos, uint32_t *reterr);
69enum clnt_stat rpctls_cl_disconnect(uint64_t sec, uint64_t usec,
70 uint64_t ssl, uint32_t *reterr);
71enum clnt_stat rpctls_srv_disconnect(uint64_t sec, uint64_t usec,
72 uint64_t ssl, int procpos, uint32_t *reterr);
52 struct socket *so, uint32_t *reterr);
53enum clnt_stat rpctls_cl_handlerecord(void *socookie, uint32_t *reterr);
54enum clnt_stat rpctls_srv_handlerecord(void *socookie, uint32_t *reterr);
55enum clnt_stat rpctls_cl_disconnect(void *socookie, uint32_t *reterr);
56enum clnt_stat rpctls_srv_disconnect(void *socookie, uint32_t *reterr);
7357
7458/* Initialization function for rpcsec_tls. */
7559int rpctls_init(void);
......@@ -81,9 +65,6 @@ bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run,
8165/* String for AUTH_TLS reply verifier. */
8266#define RPCTLS_START_STRING "STARTTLS"
8367
84/* ssl refno value to indicate TLS handshake being done. */
85#define RPCTLS_REFNO_HANDSHAKE 0xFFFFFFFFFFFFFFFFULL
86
8768/* Macros for VIMAGE. */
8869/* Just define the KRPC_VNETxxx() macros as VNETxxx() macros. */
8970#define KRPC_VNET_NAME(n) VNET_NAME(n)
lib/libc/include/generic-freebsd/rpc/svc.h+13-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)svc.h 1.35 88/12/17 SMI
33 * from: @(#)svc.h 1.27 94/04/25 SMI
3431 */
3532
3633/*
......@@ -458,6 +455,19 @@ extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
458455 */
459456extern SVCXPRT *svcunixfd_create(int, u_int, u_int);
460457
458/*
459 * netlink(4) server creation. To be used to service requests that
460 * originate from an in-kernel client.
461 */
462extern SVCXPRT *svc_nl_create(const char *);
463
464/*
465 * Arguments to SVC_CONTROL(svc_nl)
466 */
467enum {
468 SVCNL_GET_XIDKEY = 1, /* obtain pthread specific key for xid */
469};
470
461471/*
462472 * Memory based rpc (for speed check and testing)
463473 */
lib/libc/include/generic-freebsd/rpc/svc_auth.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)svc_auth.h 1.6 86/07/16 SMI
33 * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/svc_soc.h-1
......@@ -41,7 +41,6 @@
4141#define _RPC_SVC_SOC_H
4242#include <sys/cdefs.h>
4343
44/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */
4544/* svc_soc.h 1.8 89/05/01 SMI */
4645
4746/*
lib/libc/include/generic-freebsd/rpc/types.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)types.h 1.18 87/07/24 SMI
33 * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpc/xdr.h-3
......@@ -28,9 +28,6 @@
2828 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2929 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * from: @(#)xdr.h 1.19 87/04/22 SMI
33 * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
3431 */
3532
3633/*
lib/libc/include/generic-freebsd/rpcsvc/bootparam_prot.x-6
......@@ -45,12 +45,6 @@
4545%#include <sys/errno.h>
4646%#include <sys/param.h>
4747%#include <sys/syslimits.h>
48#else
49%#ifndef lint
50%/*static char sccsid[] = "from: @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro";*/
51%/*static char sccsid[] = "from: @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
52%#endif /* not lint */
53%#include <sys/cdefs.h>
5448#endif
5549
5650const MAX_MACHINE_NAME = 255;
lib/libc/include/generic-freebsd/rpcsvc/crypt.x-4
......@@ -30,10 +30,6 @@
3030 * SUCH DAMAGE.
3131 */
3232
33#ifndef RPC_HDR
34%#include <sys/cdefs.h>
35#endif
36
3733/*
3834 * This protocol definition exists because of the U.S. government and
3935 * its stupid export laws. We can't export DES code from the United
lib/libc/include/generic-freebsd/rpcsvc/key_prot.h-4
......@@ -42,10 +42,6 @@ extern "C" {
4242 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4343 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4444 */
45/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */
46/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
47#include <sys/cdefs.h>
48
4945/*
5046 * Compiled from key_prot.x using rpcgen.
5147 * DO NOT EDIT THIS FILE!
lib/libc/include/generic-freebsd/rpcsvc/key_prot.x-4
......@@ -45,10 +45,6 @@
4545 * requirements.
4646 */
4747
48%/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */
49%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
50%#include <sys/cdefs.h>
51%
5248%/*
5349% * Compiled from key_prot.x using rpcgen.
5450% * DO NOT EDIT THIS FILE!
lib/libc/include/generic-freebsd/rpcsvc/klm_prot.x-8
......@@ -38,14 +38,6 @@
3838 * above the kernel.
3939 */
4040
41#ifndef RPC_HDR
42%#ifndef lint
43%/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/
44%/*static char sccsid[] = "from: @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
45%#endif /* not lint */
46%#include <sys/cdefs.h>
47#endif
48
4941const LM_MAXSTRLEN = 1024;
5042
5143/*
lib/libc/include/generic-freebsd/rpcsvc/mount.x-8
......@@ -33,14 +33,6 @@
3333 * Protocol description for the mount program
3434 */
3535
36#ifndef RPC_HDR
37%#ifndef lint
38%/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
39%/*static char sccsid[] = "from: @(#)mount.x 2.1 88/08/01 4.0 RPCSRC";*/
40%#endif /* not lint */
41%#include <sys/cdefs.h>
42#endif
43
4436const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */
4537const MNTNAMLEN = 255; /* maximum bytes in a name argument */
4638const FHSIZE = 32; /* size in bytes of a file handle */
lib/libc/include/generic-freebsd/rpcsvc/nfs_prot.x-8
......@@ -29,14 +29,6 @@
2929 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030 */
3131
32#ifndef RPC_HDR
33%#ifndef lint
34%/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/
35%/*static char sccsid[] = "from: @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
36%#endif /* not lint */
37%#include <sys/cdefs.h>
38#endif
39
4032const NFS_PORT = 2049;
4133const NFS_MAXDATA = 8192;
4234const NFS_MAXPATHLEN = 1024;
lib/libc/include/generic-freebsd/rpcsvc/nis.x-5
......@@ -29,12 +29,7 @@
2929% * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030% */
3131
32#ifndef RPC_HDR
33%#include <sys/cdefs.h>
34#endif
35
3632/*
37 * From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems
3833 *
3934 * RPC Language Protocol description file for NIS Plus
4035 * This version : 1.61
lib/libc/include/generic-freebsd/rpcsvc/nis_cache.x-6
......@@ -35,12 +35,6 @@
3535 * All Rights Reserved.
3636 */
3737
38/* From: %#pragma ident "@(#)nis_cache.x 1.11 94/05/03 SMI" */
39
40#ifndef RPC_HDR
41%#include <sys/cdefs.h>
42#endif
43
4438#ifdef RPC_HDR
4539%#include <rpc/types.h>
4640%#include <rpcsvc/nis.h>
lib/libc/include/generic-freebsd/rpcsvc/nis_callback.x-7
......@@ -36,14 +36,7 @@
3636 * All Rights Reserved.
3737 */
3838
39/* From: %#pragma ident "@(#)nis_callback.x 1.7 94/05/03 SMI" */
40
41#ifndef RPC_HDR
42%#include <sys/cdefs.h>
43#endif
44
4539/*
46 * "@(#)zns_cback.x 1.2 90/09/10 Copyr 1990 Sun Micro"
4740 *
4841 * RPCL description of the Callback Service.
4942 */
lib/libc/include/generic-freebsd/rpcsvc/nis_db.h-2
......@@ -42,8 +42,6 @@
4242#define _RPCSVC_NIS_DB_H
4343
4444
45/* From: #pragma ident "@(#)nis_db.h 1.8 94/05/03 SMI" */
46
4745/*
4846 * Note: although the version of <rpcsvc/nis_db.h> shipped with Solaris
4947 * 2.5/2.5.x is actually older than this one (according to the ident
lib/libc/include/generic-freebsd/rpcsvc/nis_object.x-2
......@@ -36,8 +36,6 @@
3636 * All Rights Reserved.
3737 */
3838
39/* From: %#pragma ident "@(#)nis_object.x 1.10 94/05/03 SMI" */
40
4139#if RPC_HDR
4240%
4341%#ifndef __nis_object_h
lib/libc/include/generic-freebsd/rpcsvc/nis_tags.h-1
......@@ -45,7 +45,6 @@
4545#ifndef _RPCSVC_NIS_TAGS_H
4646#define _RPCSVC_NIS_TAGS_H
4747
48/* From: #pragma ident "@(#)nis_tags.h 1.10 94/05/03 SMI" */
4948/* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */
5049
5150#ifdef __cplusplus
lib/libc/include/generic-freebsd/rpcsvc/nislib.h-2
......@@ -39,8 +39,6 @@
3939#ifndef _RPCSVC_NISLIB_H
4040#define _RPCSVC_NISLIB_H
4141
42/* From: #pragma ident "@(#)nislib.h 1.16 94/05/03 SMI" */
43
4442#ifdef __cplusplus
4543extern "C" {
4644#endif
lib/libc/include/generic-freebsd/rpcsvc/nlm_prot.x+1-7
......@@ -8,14 +8,8 @@
88#ifdef RPC_HDR
99%#define LM_MAXSTRLEN 1024
1010%#define MAXNAMELEN LM_MAXSTRLEN+1
11#else
12%#include <sys/cdefs.h>
13%#ifndef lint
14%/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
15%/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
16%__RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $");
17%#endif /* not lint */
1811#endif
12/* $NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $ */
1913
2014/*
2115 * status of a call to the lock manager
lib/libc/include/generic-freebsd/rpcsvc/rex.x-8
......@@ -33,14 +33,6 @@
3333 * Remote execution (rex) protocol specification
3434 */
3535
36#ifndef RPC_HDR
37%#ifndef lint
38%/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/
39%/*static char sccsid[] = "from: @(#)rex.x 2.1 88/08/01 4.0 RPCSRC";*/
40%#endif /* not lint */
41%#include <sys/cdefs.h>
42#endif
43
4436const STRINGSIZE = 1024;
4537typedef string rexstring<1024>;
4638
lib/libc/include/generic-freebsd/rpcsvc/rnusers.x-8
......@@ -33,14 +33,6 @@
3333 * Find out about remote users
3434 */
3535
36#ifndef RPC_HDR
37%#ifndef lint
38%/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
39%/*static char sccsid[] = "from: @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC";*/
40%#endif /* not lint */
41%#include <sys/cdefs.h>
42#endif
43
4436const MAXUSERS = 100;
4537const MAXUTLEN = 256;
4638
lib/libc/include/generic-freebsd/rpcsvc/rquota.x-7
......@@ -1,15 +1,8 @@
1/* @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC */
2/* @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro */
3
41/*
52 * Remote quota protocol
63 * Requires unix authentication
74 */
85
9#ifndef RPC_HDR
10%#include <sys/cdefs.h>
11#endif
12
136const RQ_PATHLEN = 1024;
147
158struct sq_dqblk {
lib/libc/include/generic-freebsd/rpcsvc/rstat.x-7
......@@ -44,13 +44,6 @@
4444%
4545%#endif /* ndef FSCALE */
4646
47#else
48
49%#ifndef lint
50%/*static char sccsid[] = "from: @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
51%/*static char sccsid[] = "from: @(#)rstat.x 2.2 88/08/01 4.0 RPCSRC";*/
52%#endif /* not lint */
53%#include <sys/cdefs.h>
5447#endif /* def RPC_HDR */
5548
5649const RSTAT_CPUSTATES = 4;
lib/libc/include/generic-freebsd/rpcsvc/rwall.h-2
......@@ -45,8 +45,6 @@ extern "C" {
4545 * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.
4646 */
4747
48/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */
49
5048#ifndef _rpcsvc_rwall_h
5149#define _rpcsvc_rwall_h
5250
lib/libc/include/generic-freebsd/rpcsvc/rwall.x-2
......@@ -31,8 +31,6 @@
3131%/*
3232% * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.
3333% */
34%
35%/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */
3634
3735#ifdef RPC_HDR
3836%
lib/libc/include/generic-freebsd/rpcsvc/sm_inter.x-7
......@@ -1,6 +1,3 @@
1/* @(#)sm_inter.x 2.2 88/08/01 4.0 RPCSRC */
2/* @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro */
3
41/*-
52 * Copyright (c) 2010, Oracle America, Inc.
63 *
......@@ -38,10 +35,6 @@
3835 *
3936 */
4037
41#ifndef RPC_HDR
42%#include <sys/cdefs.h>
43#endif
44
4538program SM_PROG {
4639 version SM_VERS {
4740 /* res_stat = stat_succ if status monitor agrees to monitor */
lib/libc/include/generic-freebsd/rpcsvc/spray.x-8
......@@ -34,14 +34,6 @@
3434 * Useful for testing flakiness of network interfaces
3535 */
3636
37#ifndef RPC_HDR
38%#ifndef lint
39%/*static char sccsid[] = "from: @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/
40%/*static char sccsid[] = "from: @(#)spray.x 2.1 88/08/01 4.0 RPCSRC";*/
41%#endif /* not lint */
42%#include <sys/cdefs.h>
43#endif
44
4537const SPRAYMAX = 8845; /* max amount can spray */
4638
4739/*
lib/libc/include/generic-freebsd/rpcsvc/yp.x-6
......@@ -1,5 +1,3 @@
1/* @(#)yp.x 2.1 88/08/01 4.0 RPCSRC */
2
31/*-
42 * Copyright (c) 2010, Oracle America, Inc.
53 *
......@@ -35,10 +33,6 @@
3533 * Protocol description file for the Yellow Pages Service
3634 */
3735
38#ifndef RPC_HDR
39%#include <sys/cdefs.h>
40#endif
41
4236const YPMAXRECORD = 16777216;
4337const YPMAXDOMAIN = 64;
4438const YPMAXMAP = 64;
lib/libc/include/generic-freebsd/rpcsvc/yp_prot.h+1-1
......@@ -271,7 +271,7 @@ struct ypbind_setdom {
271271 *
272272 * Sun says:
273273 * "Protocol between clients (ypxfr, only) and yppush
274 * yppush speaks a protocol in the transient range, which
274 * speaks a protocol in the transient range, which
275275 * is supplied to ypxfr as a command-line parameter when it
276276 * is activated by ypserv."
277277 *
lib/libc/include/generic-freebsd/rpcsvc/yppasswd.x-8
......@@ -34,14 +34,6 @@
3434 * Requires unix authentication
3535 */
3636
37#ifndef RPC_HDR
38%#ifndef lint
39%/*static char sccsid[] = "from: @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro";*/
40%/*static char sccsid[] = "from: @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC";*/
41%#endif /* not lint */
42%#include <sys/cdefs.h>
43#endif
44
4537program YPPASSWDPROG {
4638 version YPPASSWDVERS {
4739 /*
lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.h-1
......@@ -45,7 +45,6 @@ extern "C" {
4545 * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.
4646 */
4747
48/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */
4948
5049/*
5150 * Compiled from ypupdate_prot.x using rpcgen
lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.x-1
......@@ -32,7 +32,6 @@
3232% * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.
3333% */
3434%
35%/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */
3635#ifndef RPC_HDR
3736%#include <sys/cdefs.h>
3837#endif
lib/libc/include/generic-freebsd/runetype.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)runetype.h 8.1 (Berkeley) 6/2/93
3533 */
3634
3735#ifndef _RUNETYPE_H_
lib/libc/include/generic-freebsd/sched.h-1
......@@ -29,7 +29,6 @@
2929#ifndef __SCHED_H__
3030#define __SCHED_H__
3131
32#include <sys/cdefs.h>
3332#include <sys/types.h>
3433#include <sys/sched.h>
3534#if __BSD_VISIBLE
lib/libc/include/generic-freebsd/security/audit/audit.h+439-303
......@@ -1,19 +1,18 @@
11/*-
22 * SPDX-License-Identifier: BSD-3-Clause
33 *
4 * Copyright (c) 2005-2009 Apple Inc.
5 * Copyright (c) 2016 Robert N. M. Watson
4 * Copyright (c) 1999-2005 Apple Inc.
5 * Copyright (c) 2016-2018 Robert N. M. Watson
66 * All rights reserved.
77 *
8 * Portions of this software were developed by BAE Systems, the University of
9 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL
10 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent
11 * Computing (TC) research program.
8 * This software was developed by BAE Systems, the University of Cambridge
9 * Computer Laboratory, and Memorial University under DARPA/AFRL contract
10 * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing
11 * (TC) research program.
1212 *
1313 * Redistribution and use in source and binary forms, with or without
1414 * modification, are permitted provided that the following conditions
1515 * are met:
16 *
1716 * 1. Redistributions of source code must retain the above copyright
1817 * notice, this list of conditions and the following disclaimer.
1918 * 2. Redistributions in binary form must reproduce the above copyright
......@@ -23,323 +22,460 @@
2322 * its contributors may be used to endorse or promote products derived
2423 * from this software without specific prior written permission.
2524 *
26 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
27 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _BSM_AUDIT_H
39#define _BSM_AUDIT_H
40
41#include <sys/param.h>
42#include <sys/types.h>
43
44#define AUDIT_RECORD_MAGIC 0x828a0f1b
45#define MAX_AUDIT_RECORDS 20
46#define MAXAUDITDATA (0x8000 - 1)
47#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA
48#define MIN_AUDIT_FILE_SIZE (512 * 1024)
49
50/*
51 * Minimum noumber of free blocks on the filesystem containing the audit
52 * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0
53 * as the kernel does an unsigned compare, plus we want to leave a few blocks
54 * free so userspace can terminate the log, etc.
55 */
56#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4
57
58/*
59 * Triggers for the audit daemon.
25 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
6036 */
61#define AUDIT_TRIGGER_MIN 1
62#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */
63#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */
64#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */
65#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */
66#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */
67#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */
68#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */
69#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */
70#define AUDIT_TRIGGER_MAX 8
7137
7238/*
73 * The special device filename (FreeBSD).
39 * This header includes function prototypes and type definitions that are
40 * necessary for the kernel as a whole to interact with the audit subsystem.
7441 */
75#define AUDITDEV_FILENAME "audit"
76#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME)
7742
78/*
79 * Pre-defined audit IDs
80 */
81#define AU_DEFAUDITID (uid_t)(-1)
82#define AU_DEFAUDITSID 0
83#define AU_ASSIGN_ASID -1
43#ifndef _SECURITY_AUDIT_KERNEL_H_
44#define _SECURITY_AUDIT_KERNEL_H_
8445
85/*
86 * IPC types.
87 */
88#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */
89#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */
90#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */
46#ifndef _KERNEL
47#error "no user-serviceable parts inside"
48#endif
9149
92/*
93 * Audit conditions.
94 */
95#define AUC_UNSET 0
96#define AUC_AUDITING 1
97#define AUC_NOAUDIT 2
98#define AUC_DISABLED -1
50#include <bsm/audit.h>
9951
100/*
101 * auditon(2) commands.
102 */
103#define A_OLDGETPOLICY 2
104#define A_OLDSETPOLICY 3
105#define A_GETKMASK 4
106#define A_SETKMASK 5
107#define A_OLDGETQCTRL 6
108#define A_OLDSETQCTRL 7
109#define A_GETCWD 8
110#define A_GETCAR 9
111#define A_GETSTAT 12
112#define A_SETSTAT 13
113#define A_SETUMASK 14
114#define A_SETSMASK 15
115#define A_OLDGETCOND 20
116#define A_OLDSETCOND 21
117#define A_GETCLASS 22
118#define A_SETCLASS 23
119#define A_GETPINFO 24
120#define A_SETPMASK 25
121#define A_SETFSIZE 26
122#define A_GETFSIZE 27
123#define A_GETPINFO_ADDR 28
124#define A_GETKAUDIT 29
125#define A_SETKAUDIT 30
126#define A_SENDTRIGGER 31
127#define A_GETSINFO_ADDR 32
128#define A_GETPOLICY 33
129#define A_SETPOLICY 34
130#define A_GETQCTRL 35
131#define A_SETQCTRL 36
132#define A_GETCOND 37
133#define A_SETCOND 38
134#define A_GETEVENT 39 /* Get audit event-to-name mapping. */
135#define A_SETEVENT 40 /* Set audit event-to-name mapping. */
52#include <sys/file.h>
53#include <sys/sysctl.h>
13654
13755/*
138 * Audit policy controls.
139 */
140#define AUDIT_CNT 0x0001
141#define AUDIT_AHLT 0x0002
142#define AUDIT_ARGV 0x0004
143#define AUDIT_ARGE 0x0008
144#define AUDIT_SEQ 0x0010
145#define AUDIT_WINDATA 0x0020
146#define AUDIT_USER 0x0040
147#define AUDIT_GROUP 0x0080
148#define AUDIT_TRAIL 0x0100
149#define AUDIT_PATH 0x0200
150#define AUDIT_SCNT 0x0400
151#define AUDIT_PUBLIC 0x0800
152#define AUDIT_ZONENAME 0x1000
153#define AUDIT_PERZONE 0x2000
154
155/*
156 * Default audit queue control parameters.
157 */
158#define AQ_HIWATER 100
159#define AQ_MAXHIGH 10000
160#define AQ_LOWATER 10
161#define AQ_BUFSZ MAXAUDITDATA
162#define AQ_MAXBUFSZ 1048576
163
164/*
165 * Default minimum percentage free space on file system.
166 */
167#define AU_FS_MINFREE 20
168
169/*
170 * Type definitions used indicating the length of variable length addresses
171 * in tokens containing addresses, such as header fields.
172 */
173#define AU_IPv4 4
174#define AU_IPv6 16
175
176__BEGIN_DECLS
177
178typedef uid_t au_id_t;
179typedef pid_t au_asid_t;
180typedef u_int16_t au_event_t;
181typedef u_int16_t au_emod_t;
182typedef u_int32_t au_class_t;
183typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8)));
184
185struct au_tid {
186 u_int32_t port; /* XXX dev_t compatibility */
187 u_int32_t machine;
188};
189typedef struct au_tid au_tid_t;
190
191struct au_tid_addr {
192 u_int32_t at_port; /* XXX dev_t compatibility */
193 u_int32_t at_type;
194 u_int32_t at_addr[4];
195};
196typedef struct au_tid_addr au_tid_addr_t;
197
198struct au_mask {
199 unsigned int am_success; /* Success bits. */
200 unsigned int am_failure; /* Failure bits. */
201};
202typedef struct au_mask au_mask_t;
203
204struct auditinfo {
205 au_id_t ai_auid; /* Audit user ID. */
206 au_mask_t ai_mask; /* Audit masks. */
207 au_tid_t ai_termid; /* Terminal ID. */
208 au_asid_t ai_asid; /* Audit session ID. */
209};
210typedef struct auditinfo auditinfo_t;
211
212struct auditinfo_addr {
213 au_id_t ai_auid; /* Audit user ID. */
214 au_mask_t ai_mask; /* Audit masks. */
215 au_tid_addr_t ai_termid; /* Terminal ID. */
216 au_asid_t ai_asid; /* Audit session ID. */
217 au_asflgs_t ai_flags; /* Audit session flags. */
218};
219typedef struct auditinfo_addr auditinfo_addr_t;
220
221struct auditpinfo {
222 pid_t ap_pid; /* ID of target process. */
223 au_id_t ap_auid; /* Audit user ID. */
224 au_mask_t ap_mask; /* Audit masks. */
225 au_tid_t ap_termid; /* Terminal ID. */
226 au_asid_t ap_asid; /* Audit session ID. */
227};
228typedef struct auditpinfo auditpinfo_t;
229
230struct auditpinfo_addr {
231 pid_t ap_pid; /* ID of target process. */
232 au_id_t ap_auid; /* Audit user ID. */
233 au_mask_t ap_mask; /* Audit masks. */
234 au_tid_addr_t ap_termid; /* Terminal ID. */
235 au_asid_t ap_asid; /* Audit session ID. */
236 au_asflgs_t ap_flags; /* Audit session flags. */
237};
238typedef struct auditpinfo_addr auditpinfo_addr_t;
239
240struct au_session {
241 auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */
242 au_mask_t as_mask; /* Process Audit Masks. */
243};
244typedef struct au_session au_session_t;
245
246/*
247 * Contents of token_t are opaque outside of libbsm.
248 */
249typedef struct au_token token_t;
250
251/*
252 * Kernel audit queue control parameters:
253 * Default: Maximum:
254 * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000)
255 * aq_lowater: AQ_LOWATER (10) <aq_hiwater
256 * aq_bufsz: AQ_BUFSZ (32767) AQ_MAXBUFSZ (1048576)
257 * aq_delay: 20 20000 (not used)
56 * Audit subsystem condition flags. The audit_trail_enabled flag is set and
57 * removed automatically as a result of configuring log files, and can be
58 * observed but should not be directly manipulated. The audit suspension
59 * flag permits audit to be temporarily disabled without reconfiguring the
60 * audit target.
61 *
62 * As DTrace can also request system-call auditing, a further
63 * audit_syscalls_enabled flag tracks whether newly entering system calls
64 * should be considered for auditing or not.
65 *
66 * XXXRW: Move trail flags to audit_private.h, as they no longer need to be
67 * visible outside the audit code...?
25868 */
259struct au_qctrl {
260 int aq_hiwater; /* Max # of audit recs in queue when */
261 /* threads with new ARs get blocked. */
69extern u_int audit_dtrace_enabled;
70extern int audit_trail_enabled;
71extern int audit_trail_suspended;
72extern bool audit_syscalls_enabled;
26273
263 int aq_lowater; /* # of audit recs in queue when */
264 /* blocked threads get unblocked. */
265
266 int aq_bufsz; /* Max size of audit record for audit(2). */
267 int aq_delay; /* Queue delay (not used). */
268 int aq_minfree; /* Minimum filesystem percent free space. */
269};
270typedef struct au_qctrl au_qctrl_t;
271
272/*
273 * Structure for the audit statistics.
274 */
275struct audit_stat {
276 unsigned int as_version;
277 unsigned int as_numevent;
278 int as_generated;
279 int as_nonattrib;
280 int as_kernel;
281 int as_audit;
282 int as_auditctl;
283 int as_enqueue;
284 int as_written;
285 int as_wblocked;
286 int as_rblocked;
287 int as_dropped;
288 int as_totalsize;
289 unsigned int as_memused;
290};
291typedef struct audit_stat au_stat_t;
74void audit_syscall_enter(unsigned short code, struct thread *td);
75void audit_syscall_exit(int error, struct thread *td);
29276
29377/*
294 * Structure for the audit file statistics.
78 * The remaining kernel functions are conditionally compiled in as they are
79 * wrapped by a macro, and the macro should be the only place in the source
80 * tree where these functions are referenced.
29581 */
296struct audit_fstat {
297 u_int64_t af_filesz;
298 u_int64_t af_currsz;
299};
300typedef struct audit_fstat au_fstat_t;
82#ifdef AUDIT
83struct ipc_perm;
84struct sockaddr;
85union auditon_udata;
86void audit_arg_addr(void * addr);
87void audit_arg_exit(int status, int retval);
88void audit_arg_len(int len);
89void audit_arg_atfd1(int atfd);
90void audit_arg_atfd2(int atfd);
91void audit_arg_fd(int fd);
92void audit_arg_fflags(int fflags);
93void audit_arg_gid(gid_t gid);
94void audit_arg_uid(uid_t uid);
95void audit_arg_egid(gid_t egid);
96void audit_arg_euid(uid_t euid);
97void audit_arg_rgid(gid_t rgid);
98void audit_arg_ruid(uid_t ruid);
99void audit_arg_sgid(gid_t sgid);
100void audit_arg_suid(uid_t suid);
101void audit_arg_groupset(gid_t *gidset, int gidset_size);
102void audit_arg_login(char *login);
103void audit_arg_ctlname(int *name, int namelen);
104void audit_arg_mask(int mask);
105void audit_arg_mode(mode_t mode);
106void audit_arg_dev(int dev);
107void audit_arg_value(long value);
108void audit_arg_owner(uid_t uid, gid_t gid);
109void audit_arg_pid(pid_t pid);
110void audit_arg_process(struct proc *p);
111void audit_arg_signum(u_int signum);
112void audit_arg_socket(int sodomain, int sotype, int soprotocol);
113void audit_arg_sockaddr(struct thread *td, int dirfd, struct sockaddr *sa);
114void audit_arg_auid(uid_t auid);
115void audit_arg_auditinfo(struct auditinfo *au_info);
116void audit_arg_auditinfo_addr(struct auditinfo_addr *au_info);
117void audit_arg_upath1(struct thread *td, int dirfd, char *upath);
118void audit_arg_upath1_canon(char *upath);
119void audit_arg_upath2(struct thread *td, int dirfd, char *upath);
120void audit_arg_upath2_canon(char *upath);
121void audit_arg_upath1_vp(struct thread *td, struct vnode *rdir,
122 struct vnode *cdir, char *upath);
123void audit_arg_upath2_vp(struct thread *td, struct vnode *rdir,
124 struct vnode *cdir, char *upath);
125void audit_arg_vnode1(struct vnode *vp);
126void audit_arg_vnode2(struct vnode *vp);
127void audit_arg_text(const char *text);
128void audit_arg_cmd(int cmd);
129void audit_arg_svipc_cmd(int cmd);
130void audit_arg_svipc_perm(struct ipc_perm *perm);
131void audit_arg_svipc_id(int id);
132void audit_arg_svipc_addr(void *addr);
133void audit_arg_svipc_which(int which);
134void audit_arg_posix_ipc_perm(uid_t uid, gid_t gid, mode_t mode);
135void audit_arg_auditon(union auditon_udata *udata);
136void audit_arg_file(struct proc *p, struct file *fp);
137void audit_arg_argv(char *argv, int argc, int length);
138void audit_arg_envv(char *envv, int envc, int length);
139void audit_arg_rights(cap_rights_t *rightsp);
140void audit_arg_fcntl_rights(uint32_t fcntlrights);
141void audit_sysclose(struct thread *td, int fd, struct file *fp);
142void audit_cred_copy(struct ucred *src, struct ucred *dest);
143void audit_cred_destroy(struct ucred *cred);
144void audit_cred_init(struct ucred *cred);
145void audit_cred_kproc0(struct ucred *cred);
146void audit_cred_proc1(struct ucred *cred);
147void audit_proc_coredump(struct thread *td, char *path, int errcode);
148void audit_thread_alloc(struct thread *td);
149void audit_thread_free(struct thread *td);
301150
302151/*
303 * Audit to event class mapping.
152 * Define macros to wrap the audit_arg_* calls by checking the global
153 * audit_syscalls_enabled flag before performing the actual call.
304154 */
305struct au_evclass_map {
306 au_event_t ec_number;
307 au_class_t ec_class;
308};
309typedef struct au_evclass_map au_evclass_map_t;
155#define AUDITING_TD(td) (__predict_false((td)->td_pflags & TDP_AUDITREC))
156
157#define AUDIT_ARG_ADDR(addr) do { \
158 if (AUDITING_TD(curthread)) \
159 audit_arg_addr((addr)); \
160} while (0)
161
162#define AUDIT_ARG_ARGV(argv, argc, length) do { \
163 if (AUDITING_TD(curthread)) \
164 audit_arg_argv((argv), (argc), (length)); \
165} while (0)
166
167#define AUDIT_ARG_ATFD1(atfd) do { \
168 if (AUDITING_TD(curthread)) \
169 audit_arg_atfd1((atfd)); \
170} while (0)
171
172#define AUDIT_ARG_ATFD2(atfd) do { \
173 if (AUDITING_TD(curthread)) \
174 audit_arg_atfd2((atfd)); \
175} while (0)
176
177#define AUDIT_ARG_AUDITON(udata) do { \
178 if (AUDITING_TD(curthread)) \
179 audit_arg_auditon((udata)); \
180} while (0)
181
182#define AUDIT_ARG_CMD(cmd) do { \
183 if (AUDITING_TD(curthread)) \
184 audit_arg_cmd((cmd)); \
185} while (0)
186
187#define AUDIT_ARG_DEV(dev) do { \
188 if (AUDITING_TD(curthread)) \
189 audit_arg_dev((dev)); \
190} while (0)
191
192#define AUDIT_ARG_EGID(egid) do { \
193 if (AUDITING_TD(curthread)) \
194 audit_arg_egid((egid)); \
195} while (0)
196
197#define AUDIT_ARG_ENVV(envv, envc, length) do { \
198 if (AUDITING_TD(curthread)) \
199 audit_arg_envv((envv), (envc), (length)); \
200} while (0)
201
202#define AUDIT_ARG_EXIT(status, retval) do { \
203 if (AUDITING_TD(curthread)) \
204 audit_arg_exit((status), (retval)); \
205} while (0)
206
207#define AUDIT_ARG_EUID(euid) do { \
208 if (AUDITING_TD(curthread)) \
209 audit_arg_euid((euid)); \
210} while (0)
211
212#define AUDIT_ARG_FD(fd) do { \
213 if (AUDITING_TD(curthread)) \
214 audit_arg_fd((fd)); \
215} while (0)
216
217#define AUDIT_ARG_FILE(p, fp) do { \
218 if (AUDITING_TD(curthread)) \
219 audit_arg_file((p), (fp)); \
220} while (0)
221
222#define AUDIT_ARG_FFLAGS(fflags) do { \
223 if (AUDITING_TD(curthread)) \
224 audit_arg_fflags((fflags)); \
225} while (0)
226
227#define AUDIT_ARG_GID(gid) do { \
228 if (AUDITING_TD(curthread)) \
229 audit_arg_gid((gid)); \
230} while (0)
231
232#define AUDIT_ARG_GROUPSET(gidset, gidset_size) do { \
233 if (AUDITING_TD(curthread)) \
234 audit_arg_groupset((gidset), (gidset_size)); \
235} while (0)
236
237#define AUDIT_ARG_LOGIN(login) do { \
238 if (AUDITING_TD(curthread)) \
239 audit_arg_login((login)); \
240} while (0)
241
242#define AUDIT_ARG_MODE(mode) do { \
243 if (AUDITING_TD(curthread)) \
244 audit_arg_mode((mode)); \
245} while (0)
246
247#define AUDIT_ARG_OWNER(uid, gid) do { \
248 if (AUDITING_TD(curthread)) \
249 audit_arg_owner((uid), (gid)); \
250} while (0)
251
252#define AUDIT_ARG_PID(pid) do { \
253 if (AUDITING_TD(curthread)) \
254 audit_arg_pid((pid)); \
255} while (0)
256
257#define AUDIT_ARG_POSIX_IPC_PERM(uid, gid, mode) do { \
258 if (AUDITING_TD(curthread)) \
259 audit_arg_posix_ipc_perm((uid), (gid), (mod)); \
260} while (0)
261
262#define AUDIT_ARG_PROCESS(p) do { \
263 if (AUDITING_TD(curthread)) \
264 audit_arg_process((p)); \
265} while (0)
266
267#define AUDIT_ARG_RGID(rgid) do { \
268 if (AUDITING_TD(curthread)) \
269 audit_arg_rgid((rgid)); \
270} while (0)
271
272#define AUDIT_ARG_RIGHTS(rights) do { \
273 if (AUDITING_TD(curthread)) \
274 audit_arg_rights((rights)); \
275} while (0)
276
277#define AUDIT_ARG_FCNTL_RIGHTS(fcntlrights) do { \
278 if (AUDITING_TD(curthread)) \
279 audit_arg_fcntl_rights((fcntlrights)); \
280} while (0)
281
282#define AUDIT_ARG_RUID(ruid) do { \
283 if (AUDITING_TD(curthread)) \
284 audit_arg_ruid((ruid)); \
285} while (0)
286
287#define AUDIT_ARG_SIGNUM(signum) do { \
288 if (AUDITING_TD(curthread)) \
289 audit_arg_signum((signum)); \
290} while (0)
291
292#define AUDIT_ARG_SGID(sgid) do { \
293 if (AUDITING_TD(curthread)) \
294 audit_arg_sgid((sgid)); \
295} while (0)
296
297#define AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol) do { \
298 if (AUDITING_TD(curthread)) \
299 audit_arg_socket((sodomain), (sotype), (soprotocol)); \
300} while (0)
301
302#define AUDIT_ARG_SOCKADDR(td, dirfd, sa) do { \
303 if (AUDITING_TD(curthread)) \
304 audit_arg_sockaddr((td), (dirfd), (sa)); \
305} while (0)
306
307#define AUDIT_ARG_SUID(suid) do { \
308 if (AUDITING_TD(curthread)) \
309 audit_arg_suid((suid)); \
310} while (0)
311
312#define AUDIT_ARG_SVIPC_CMD(cmd) do { \
313 if (AUDITING_TD(curthread)) \
314 audit_arg_svipc_cmd((cmd)); \
315} while (0)
316
317#define AUDIT_ARG_SVIPC_PERM(perm) do { \
318 if (AUDITING_TD(curthread)) \
319 audit_arg_svipc_perm((perm)); \
320} while (0)
321
322#define AUDIT_ARG_SVIPC_ID(id) do { \
323 if (AUDITING_TD(curthread)) \
324 audit_arg_svipc_id((id)); \
325} while (0)
326
327#define AUDIT_ARG_SVIPC_ADDR(addr) do { \
328 if (AUDITING_TD(curthread)) \
329 audit_arg_svipc_addr((addr)); \
330} while (0)
331
332#define AUDIT_ARG_SVIPC_WHICH(which) do { \
333 if (AUDITING_TD(curthread)) \
334 audit_arg_svipc_which((which)); \
335} while (0)
336
337#define AUDIT_ARG_TEXT(text) do { \
338 if (AUDITING_TD(curthread)) \
339 audit_arg_text((text)); \
340} while (0)
341
342#define AUDIT_ARG_UID(uid) do { \
343 if (AUDITING_TD(curthread)) \
344 audit_arg_uid((uid)); \
345} while (0)
346
347#define AUDIT_ARG_UPATH1(td, dirfd, upath) do { \
348 if (AUDITING_TD(curthread)) \
349 audit_arg_upath1((td), (dirfd), (upath)); \
350} while (0)
351
352#define AUDIT_ARG_UPATH1_CANON(upath) do { \
353 if (AUDITING_TD(curthread)) \
354 audit_arg_upath1_canon((upath)); \
355} while (0)
356
357#define AUDIT_ARG_UPATH2(td, dirfd, upath) do { \
358 if (AUDITING_TD(curthread)) \
359 audit_arg_upath2((td), (dirfd), (upath)); \
360} while (0)
361
362#define AUDIT_ARG_UPATH2_CANON(upath) do { \
363 if (AUDITING_TD(curthread)) \
364 audit_arg_upath2_canon((upath)); \
365} while (0)
366
367#define AUDIT_ARG_UPATH1_VP(td, rdir, cdir, upath) do { \
368 if (AUDITING_TD(curthread)) \
369 audit_arg_upath1_vp((td), (rdir), (cdir), (upath)); \
370} while (0)
371
372#define AUDIT_ARG_UPATH2_VP(td, rdir, cdir, upath) do { \
373 if (AUDITING_TD(curthread)) \
374 audit_arg_upath2_vp((td), (rdir), (cdir), (upath)); \
375} while (0)
376
377#define AUDIT_ARG_VALUE(value) do { \
378 if (AUDITING_TD(curthread)) \
379 audit_arg_value((value)); \
380} while (0)
381
382#define AUDIT_ARG_VNODE1(vp) do { \
383 if (AUDITING_TD(curthread)) \
384 audit_arg_vnode1((vp)); \
385} while (0)
386
387#define AUDIT_ARG_VNODE2(vp) do { \
388 if (AUDITING_TD(curthread)) \
389 audit_arg_vnode2((vp)); \
390} while (0)
391
392#define AUDIT_SYSCALL_ENABLED() audit_syscalls_enabled
393
394#define AUDIT_SYSCALL_ENTER(code, td) ({ \
395 bool _audit_entered = false; \
396 if (audit_syscalls_enabled) { \
397 audit_syscall_enter(code, td); \
398 _audit_entered = true; \
399 } \
400 _audit_entered; \
401})
310402
311403/*
312 * Event-to-name mapping.
404 * Wrap the audit_syscall_exit() function so that it is called only when
405 * we have a audit record on the thread. Audit records can persist after
406 * auditing is disabled, so we don't just check audit_syscalls_enabled here.
313407 */
314#define EVNAMEMAP_NAME_SIZE 64
315struct au_evname_map {
316 au_event_t en_number;
317 char en_name[EVNAMEMAP_NAME_SIZE];
318};
319typedef struct au_evname_map au_evname_map_t;
408#define AUDIT_SYSCALL_EXIT(error, td) do { \
409 if (AUDITING_TD(td)) \
410 audit_syscall_exit(error, td); \
411} while (0)
320412
321413/*
322 * Audit system calls.
414 * A Macro to wrap the audit_sysclose() function.
323415 */
324#if !defined(_KERNEL) && !defined(KERNEL)
325int audit(const void *, int);
326int auditon(int, void *, int);
327int auditctl(const char *);
328int getauid(au_id_t *);
329int setauid(const au_id_t *);
330int getaudit(struct auditinfo *);
331int setaudit(const struct auditinfo *);
332int getaudit_addr(struct auditinfo_addr *, int);
333int setaudit_addr(const struct auditinfo_addr *, int);
334
335#ifdef __APPLE_API_PRIVATE
336#include <mach/port.h>
337mach_port_name_t audit_session_self(void);
338au_asid_t audit_session_join(mach_port_name_t port);
339#endif /* __APPLE_API_PRIVATE */
340
341#endif /* defined(_KERNEL) || defined(KERNEL) */
342
343__END_DECLS
344
345#endif /* !_BSM_AUDIT_H */
\ No newline at end of file
416#define AUDIT_SYSCLOSE(td, fd) do { \
417 if (AUDITING_TD(td)) \
418 audit_sysclose(td, fd); \
419} while (0)
420
421#else /* !AUDIT */
422
423#define AUDIT_ARG_ADDR(addr)
424#define AUDIT_ARG_ARGV(argv, argc, length)
425#define AUDIT_ARG_ATFD1(atfd)
426#define AUDIT_ARG_ATFD2(atfd)
427#define AUDIT_ARG_AUDITON(udata)
428#define AUDIT_ARG_CMD(cmd)
429#define AUDIT_ARG_DEV(dev)
430#define AUDIT_ARG_EGID(egid)
431#define AUDIT_ARG_ENVV(envv, envc, length)
432#define AUDIT_ARG_EXIT(status, retval)
433#define AUDIT_ARG_EUID(euid)
434#define AUDIT_ARG_FD(fd)
435#define AUDIT_ARG_FILE(p, fp)
436#define AUDIT_ARG_FFLAGS(fflags)
437#define AUDIT_ARG_GID(gid)
438#define AUDIT_ARG_GROUPSET(gidset, gidset_size)
439#define AUDIT_ARG_LOGIN(login)
440#define AUDIT_ARG_MODE(mode)
441#define AUDIT_ARG_OWNER(uid, gid)
442#define AUDIT_ARG_PID(pid)
443#define AUDIT_ARG_POSIX_IPC_PERM(uid, gid, mode)
444#define AUDIT_ARG_PROCESS(p)
445#define AUDIT_ARG_RGID(rgid)
446#define AUDIT_ARG_RIGHTS(rights)
447#define AUDIT_ARG_FCNTL_RIGHTS(fcntlrights)
448#define AUDIT_ARG_RUID(ruid)
449#define AUDIT_ARG_SIGNUM(signum)
450#define AUDIT_ARG_SGID(sgid)
451#define AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol)
452#define AUDIT_ARG_SOCKADDR(td, dirfd, sa)
453#define AUDIT_ARG_SUID(suid)
454#define AUDIT_ARG_SVIPC_CMD(cmd)
455#define AUDIT_ARG_SVIPC_PERM(perm)
456#define AUDIT_ARG_SVIPC_ID(id)
457#define AUDIT_ARG_SVIPC_ADDR(addr)
458#define AUDIT_ARG_SVIPC_WHICH(which)
459#define AUDIT_ARG_TEXT(text)
460#define AUDIT_ARG_UID(uid)
461#define AUDIT_ARG_UPATH1(td, dirfd, upath)
462#define AUDIT_ARG_UPATH1_CANON(upath)
463#define AUDIT_ARG_UPATH2(td, dirfd, upath)
464#define AUDIT_ARG_UPATH2_CANON(upath)
465#define AUDIT_ARG_UPATH1_VP(td, rdir, cdir, upath)
466#define AUDIT_ARG_UPATH2_VP(td, rdir, cdir, upath)
467#define AUDIT_ARG_VALUE(value)
468#define AUDIT_ARG_VNODE1(vp)
469#define AUDIT_ARG_VNODE2(vp)
470
471#define AUDITING_TD(td) 0
472
473#define AUDIT_SYSCALL_ENABLED() 0
474#define AUDIT_SYSCALL_ENTER(code, td) 0
475#define AUDIT_SYSCALL_EXIT(error, td)
476
477#define AUDIT_SYSCLOSE(p, fd)
478
479#endif /* AUDIT */
480
481#endif /* !_SECURITY_AUDIT_KERNEL_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/security/mac_grantbylabel/mac_grantbylabel.h created+63
......@@ -0,0 +1,63 @@
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2018-2023, Juniper Networks, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _SECURITY_MAC_GRANTBYLABEL_H
30#define _SECURITY_MAC_GRANTBYLABEL_H
31
32#include <security/mac_veriexec/mac_veriexec.h>
33
34#define MAC_GRANTBYLABEL_NAME "mac_grantbylabel"
35
36/* the bits we use to represent tokens */
37#define GBL_EMPTY (1<<0)
38#define GBL_BIND (1<<1)
39#define GBL_IPC (1<<2)
40#define GBL_NET (1<<3)
41#define GBL_PROC (1<<4)
42#define GBL_RTSOCK (1<<5)
43#define GBL_SYSCTL (1<<6)
44#define GBL_VACCESS (1<<7)
45#define GBL_VERIEXEC (1<<8)
46#define GBL_KMEM (1<<9)
47#define GBL_MAX 9
48
49/* this should suffice for now */
50typedef uint32_t gbl_label_t;
51
52#define MAC_GRANTBYLABEL_FETCH_GBL 1
53#define MAC_GRANTBYLABEL_FETCH_PID_GBL 2
54
55struct mac_grantbylabel_fetch_gbl_args {
56 union {
57 int fd;
58 pid_t pid;
59 } u;
60 gbl_label_t gbl;
61};
62
63#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/setjmp.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)setjmp.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SETJMP_H_
lib/libc/include/generic-freebsd/signal.h+14-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.3 (Berkeley) 3/30/94
3230 */
3331
3432#ifndef _SIGNAL_H_
......@@ -42,6 +40,10 @@
4240#include <sys/_ucontext.h>
4341#endif
4442
43#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE
44#define SIG2STR_MAX 32 /* size of buffer required for sig2str() */
45#endif
46
4547__NULLABILITY_PRAGMA_PUSH
4648
4749#if __BSD_VISIBLE
......@@ -70,6 +72,10 @@ typedef __pthread_t pthread_t;
7072#endif
7173#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */
7274
75#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
76#include <ssp/signal.h>
77#endif
78
7379__BEGIN_DECLS
7480int raise(int);
7581
......@@ -117,9 +123,15 @@ int siginterrupt(int, int);
117123#endif
118124
119125#if __POSIX_VISIBLE >= 200809
126void psiginfo(const siginfo_t *, const char *);
120127void psignal(int, const char *);
121128#endif
122129
130#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE
131int sig2str(int, char *);
132int str2sig(const char * __restrict, int * __restrict);
133#endif
134
123135#if __BSD_VISIBLE
124136int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right);
125137int sigblock(int);
lib/libc/include/generic-freebsd/ssp/poll.h created+60
......@@ -0,0 +1,60 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024, Klara, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_POLL_H_
28#define _SSP_POLL_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34__BEGIN_DECLS
35
36__ssp_redirect_raw_impl(int, poll, poll,
37 (struct pollfd fds[], nfds_t nfds, int timeout))
38{
39 if (__ssp_bos(fds) / sizeof(fds[0]) < nfds)
40 __chk_fail();
41
42 return (__ssp_real(poll)(fds, nfds, timeout));
43}
44
45#if __POSIX_VISIBLE >= 202405
46__ssp_redirect_raw_impl(int, ppoll, ppoll,
47 (struct pollfd fds[], nfds_t nfds,
48 const struct timespec *__restrict timeout,
49 const sigset_t *__restrict newsigmask))
50{
51 if (__ssp_bos(fds) / sizeof(fds[0]) < nfds)
52 __chk_fail();
53
54 return (__ssp_real(ppoll)(fds, nfds, timeout, newsigmask));
55}
56#endif /* __POSIX_VISIBLE >= 202405 */
57__END_DECLS
58
59#endif /* __SSP_FORTIFY_LEVEL > 0 */
60#endif /* _SSP_POLL_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/random.h created+42
......@@ -0,0 +1,42 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024, Klara, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_RANDOM_H_
28#define _SSP_RANDOM_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34__BEGIN_DECLS
35
36__ssp_redirect(ssize_t, getrandom, (void *__buf, size_t __len,
37 unsigned int __flags), (__buf, __len, __flags));
38
39__END_DECLS
40
41#endif /* __SSP_FORTIFY_LEVEL > 0 */
42#endif /* _SSP_RANDOM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/signal.h created+52
......@@ -0,0 +1,52 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025, Ricardo Branco <rbranco@suse.de>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_SIGNAL_H_
28#define _SSP_SIGNAL_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34#include <signal.h>
35
36__BEGIN_DECLS
37
38#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE
39__ssp_redirect_raw_impl(int, sig2str, sig2str,
40 (int signum, char *__restrict str))
41{
42 if (__ssp_bos(str) < SIG2STR_MAX)
43 __chk_fail();
44
45 return (__ssp_real(sig2str)(signum, str));
46}
47#endif
48
49__END_DECLS
50
51#endif /* __SSP_FORTIFY_LEVEL > 0 */
52#endif /* _SSP_SIGNAL_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/socket.h created+120
......@@ -0,0 +1,120 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024, Klara, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_SOCKET_H_
28#define _SSP_SOCKET_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34#include <sys/_null.h>
35
36__BEGIN_DECLS
37
38__ssp_inline void
39__ssp_check_msghdr(struct msghdr *hdr)
40{
41 if (__ssp_bos(hdr->msg_name) < hdr->msg_namelen)
42 __chk_fail();
43
44 __ssp_check_iovec(hdr->msg_iov, hdr->msg_iovlen);
45
46 if (__ssp_bos(hdr->msg_control) < hdr->msg_controllen)
47 __chk_fail();
48}
49
50__ssp_redirect_raw_impl(int, getpeername, getpeername,
51 (int fdes, struct sockaddr *__restrict name, socklen_t *__restrict namelen))
52{
53 size_t namesz = __ssp_bos(name);
54
55 if (namesz != (size_t)-1 && namesz < *namelen)
56 __chk_fail();
57
58 return (__ssp_real(getpeername)(fdes, name, namelen));
59}
60
61__ssp_redirect_raw_impl(int, getsockname, getsockname,
62 (int fdes, struct sockaddr *__restrict name,
63 socklen_t *__restrict namelen))
64{
65 size_t namesz = __ssp_bos(name);
66
67 if (namesz != (size_t)-1 && namesz < *namelen)
68 __chk_fail();
69
70 return (__ssp_real(getsockname)(fdes, name, namelen));
71}
72
73__ssp_redirect(ssize_t, recv, (int __sock, void *__buf, size_t __len,
74 int __flags), (__sock, __buf, __len, __flags));
75
76__ssp_redirect_raw_impl(ssize_t, recvfrom, recvfrom,
77 (int s, void *buf, size_t len, int flags,
78 struct sockaddr *__restrict from,
79 socklen_t *__restrict fromlen))
80{
81 if (__ssp_bos(buf) < len)
82 __chk_fail();
83 if (from != NULL && __ssp_bos(from) < *fromlen)
84 __chk_fail();
85
86 return (__ssp_real(recvfrom)(s, buf, len, flags, from, fromlen));
87}
88
89__ssp_redirect_raw_impl(ssize_t, recvmsg, recvmsg,
90 (int s, struct msghdr *hdr, int flags))
91{
92 __ssp_check_msghdr(hdr);
93 return (__ssp_real(recvmsg)(s, hdr, flags));
94}
95
96#if __BSD_VISIBLE
97struct timespec;
98
99__ssp_redirect_raw_impl(ssize_t, recvmmsg, recvmmsg,
100 (int s, struct mmsghdr *__restrict hdrvec, size_t vlen, int flags,
101 const struct timespec *__restrict timeout))
102{
103 const size_t vecsz = __ssp_bos(hdrvec);
104 size_t i;
105
106 if (vecsz != (size_t)-1 && vecsz / sizeof(*hdrvec) < vlen)
107 __chk_fail();
108
109 for (i = 0; i < vlen; i++) {
110 __ssp_check_msghdr(&hdrvec[i].msg_hdr);
111 }
112
113 return (__ssp_real(recvmmsg)(s, hdrvec, vlen, flags, timeout));
114}
115#endif
116
117__END_DECLS
118
119#endif /* __SSP_FORTIFY_LEVEL > 0 */
120#endif /* _SSP_SOCKET_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/ssp.h created+127
......@@ -0,0 +1,127 @@
1/* $NetBSD: ssp.h,v 1.13 2015/09/03 20:43:47 plunky Exp $ */
2
3/*-
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7 * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Christos Zoulas.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _SSP_SSP_H_
35#define _SSP_SSP_H_
36
37#include <sys/cdefs.h>
38
39#if !defined(__cplusplus)
40# if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && \
41 (__OPTIMIZE__ > 0 || defined(__clang__))
42# if _FORTIFY_SOURCE > 1
43# define __SSP_FORTIFY_LEVEL 2
44# else
45# define __SSP_FORTIFY_LEVEL 1
46# endif
47# else
48# define __SSP_FORTIFY_LEVEL 0
49# endif
50#else
51# define __SSP_FORTIFY_LEVEL 0
52#endif
53
54#define __ssp_var(type) __CONCAT(__ssp_ ## type, __COUNTER__)
55
56/* __ssp_real is used by the implementation in libc */
57#if __SSP_FORTIFY_LEVEL == 0
58#define __ssp_real_(fun) fun
59#else
60#define __ssp_real_(fun) __ssp_real_ ## fun
61#endif
62#define __ssp_real(fun) __ssp_real_(fun)
63
64#define __ssp_inline static __inline __attribute__((__always_inline__))
65
66#define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1)
67#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
68
69#define __ssp_check(buf, len, bos) \
70 if (bos(buf) != (size_t)-1 && (size_t)len > bos(buf)) \
71 __chk_fail()
72
73#define __ssp_redirect_raw_impl(rtype, fun, symbol, args) \
74rtype __ssp_real_(fun) args __RENAME(symbol); \
75__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \
76__ssp_inline rtype fun args
77
78#define __ssp_redirect_raw(rtype, fun, symbol, args, call, cond, bos, len) \
79__ssp_redirect_raw_impl(rtype, fun, symbol, args) { \
80 if (cond) \
81 __ssp_check(__buf, len, bos); \
82 return __ssp_real_(fun) call; \
83}
84
85#define __ssp_redirect(rtype, fun, args, call) \
86 __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos, __len)
87#define __ssp_redirect0(rtype, fun, args, call) \
88 __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0, __len)
89
90#include <sys/_types.h>
91#include <machine/_limits.h>
92
93__ssp_inline int
94__ssp_overlap(const void *leftp, const void *rightp, __size_t sz)
95{
96 __uintptr_t left = (__uintptr_t)leftp;
97 __uintptr_t right = (__uintptr_t)rightp;
98
99 if (left <= right)
100 return (__SIZE_T_MAX - sz < left || right < left + sz);
101
102 return (__SIZE_T_MAX - sz < right || left < right + sz);
103}
104
105#include <sys/_iovec.h>
106
107__BEGIN_DECLS
108void __stack_chk_fail(void) __dead2;
109void __chk_fail(void) __dead2;
110__END_DECLS
111
112__ssp_inline void
113__ssp_check_iovec(const struct iovec *iov, int iovcnt)
114{
115 const size_t iovsz = __ssp_bos(iov);
116 int i;
117
118 if (iovsz != (size_t)-1 && iovsz / sizeof(*iov) < (size_t)iovcnt)
119 __chk_fail();
120
121 for (i = 0; i < iovcnt; i++) {
122 if (__ssp_bos(iov[i].iov_base) < iov[i].iov_len)
123 __chk_fail();
124 }
125}
126
127#endif /* _SSP_SSP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/stdio.h created+107
......@@ -0,0 +1,107 @@
1/* $NetBSD: stdio.h,v 1.5 2011/07/17 20:54:34 joerg Exp $ */
2
3/*-
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7 * Copyright (c) 2006 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Christos Zoulas.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _SSP_STDIO_H_
35#define _SSP_STDIO_H_
36
37#include <ssp/ssp.h>
38
39__BEGIN_DECLS
40#if __SSP_FORTIFY_LEVEL > 0
41#if __POSIX_VISIBLE
42__ssp_redirect_raw(char *, ctermid, ctermid, (char *__buf), (__buf),
43 __buf != NULL, __ssp_bos, L_ctermid);
44#if __BSD_VISIBLE
45__ssp_redirect_raw(char *, ctermid_r, ctermid_r, (char *__buf), (__buf),
46 __buf != NULL, __ssp_bos, L_ctermid);
47#endif /* __BSD_VISIBLE */
48#endif /* __POSIX_VISIBLE */
49__ssp_redirect(size_t, fread, (void *__restrict __buf, size_t __len,
50 size_t __nmemb, FILE *__restrict __fp), (__buf, __len, __nmemb, __fp));
51__ssp_redirect(size_t, fread_unlocked, (void *__restrict __buf, size_t __len,
52 size_t __nmemb, FILE *__restrict __fp), (__buf, __len, __nmemb, __fp));
53#if __EXT1_VISIBLE
54__ssp_redirect(char *, gets_s, (char *__buf, rsize_t __len), (__buf, __len));
55#endif /* __EXT1_VISIBLE */
56__ssp_redirect_raw(char *, tmpnam, tmpnam, (char *__buf), (__buf), 1,
57 __ssp_bos, L_tmpnam);
58#endif
59
60int __sprintf_chk(char *__restrict, int, size_t, const char *__restrict, ...)
61 __printflike(4, 5);
62int __vsprintf_chk(char *__restrict, int, size_t, const char *__restrict,
63 __va_list)
64 __printflike(4, 0);
65int __snprintf_chk(char *__restrict, size_t, int, size_t,
66 const char *__restrict, ...)
67 __printflike(5, 6);
68int __vsnprintf_chk(char *__restrict, size_t, int, size_t,
69 const char *__restrict, __va_list)
70 __printflike(5, 0);
71char *__fgets_chk(char *, int, size_t, FILE *);
72__END_DECLS
73
74#if __SSP_FORTIFY_LEVEL > 0
75
76#define sprintf(str, ...) __extension__ ({ \
77 char *_ssp_str = (str); \
78 __builtin___sprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str), \
79 __VA_ARGS__); \
80})
81
82#define vsprintf(str, fmt, ap) __extension__ ({ \
83 char *_ssp_str = (str); \
84 __builtin___vsprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str), fmt, \
85 ap); \
86})
87
88#define snprintf(str, len, ...) __extension__ ({ \
89 char *_ssp_str = (str); \
90 __builtin___snprintf_chk(_ssp_str, len, 0, __ssp_bos(_ssp_str), \
91 __VA_ARGS__); \
92})
93
94#define vsnprintf(str, len, fmt, ap) __extension__ ({ \
95 char *_ssp_str = (str); \
96 __builtin___vsnprintf_chk(_ssp_str, len, 0, __ssp_bos(_ssp_str), \
97 fmt, ap); \
98})
99
100#define fgets(str, len, fp) __extension__ ({ \
101 char *_ssp_str = (str); \
102 __fgets_chk(_ssp_str, len, __ssp_bos(_ssp_str), fp); \
103})
104
105#endif /* __SSP_FORTIFY_LEVEL > 0 */
106
107#endif /* _SSP_STDIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/stdlib.h created+57
......@@ -0,0 +1,57 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024, Klara, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_STDLIB_H_
28#define _SSP_STDLIB_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34#include <limits.h>
35
36__BEGIN_DECLS
37
38__ssp_redirect(void, arc4random_buf, (void *__buf, size_t __len),
39 (__buf, __len));
40
41__ssp_redirect(int, getenv_r,
42 (const char *name, char * _Nonnull __buf, size_t __len),
43 (name, __buf, __len));
44
45__ssp_redirect_raw_impl(char *, realpath, realpath,
46 (const char *__restrict path, char *__restrict buf))
47{
48 if (__ssp_bos(buf) < PATH_MAX)
49 __chk_fail();
50
51 return (__ssp_real(realpath)(path, buf));
52}
53
54__END_DECLS
55
56#endif /* __SSP_FORTIFY_LEVEL > 0 */
57#endif /* _SSP_STDLIB_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/string.h created+141
......@@ -0,0 +1,141 @@
1/* $NetBSD: string.h,v 1.14 2020/09/05 13:37:59 mrg Exp $ */
2
3/*-
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7 * Copyright (c) 2006 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Christos Zoulas.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _SSP_STRING_H_
35#define _SSP_STRING_H_
36
37#include <ssp/ssp.h>
38
39__BEGIN_DECLS
40void *__memcpy_chk(void *, const void *, size_t, size_t);
41void *__memmove_chk(void *, const void *, size_t, size_t);
42void *__memset_chk(void *, int, size_t, size_t);
43char *__stpcpy_chk(char *, const char *, size_t);
44char *__stpncpy_chk(char *, const char *, size_t, size_t);
45char *__strcat_chk(char *, const char *, size_t);
46char *__strcpy_chk(char *, const char *, size_t);
47char *__strncat_chk(char *, const char *, size_t, size_t);
48size_t __strlcat_chk(char *, const char *, size_t, size_t);
49char *__strncpy_chk(char *, const char *, size_t, size_t);
50size_t __strlcpy_chk(char *, const char *, size_t, size_t);
51__END_DECLS
52
53#if __SSP_FORTIFY_LEVEL > 0
54
55#define __ssp_bos_check3_typed_var(fun, dsttype, dsrvar, dst, srctype, srcvar, \
56 src, lenvar, len) __extension__ ({ \
57 srctype srcvar = (src); \
58 dsttype dstvar = (dst); \
59 size_t lenvar = (len); \
60 ((__ssp_bos0(dstvar) != (size_t)-1) ? \
61 __builtin___ ## fun ## _chk(dstvar, srcvar, lenvar, \
62 __ssp_bos0(dstvar)) : \
63 __ ## fun ## _ichk(dstvar, srcvar, lenvar)); \
64})
65
66#define __ssp_bos_check3_typed(fun, dsttype, dst, srctype, src, len) \
67 __ssp_bos_check3_typed_var(fun, dsttype, __ssp_var(dstv), dst, \
68 srctype, __ssp_var(srcv), src, __ssp_var(lenv), len)
69
70#define __ssp_bos_check3(fun, dst, src, len) \
71 __ssp_bos_check3_typed_var(fun, void *, __ssp_var(dstv), dst, \
72 const void *, __ssp_var(srcv), src, __ssp_var(lenv), len)
73
74#define __ssp_bos_check2_var(fun, dstvar, dst, srcvar, src) __extension__ ({ \
75 const void *srcvar = (src); \
76 void *dstvar = (dst); \
77 ((__ssp_bos0(dstvar) != (size_t)-1) ? \
78 __builtin___ ## fun ## _chk(dstvar, srcvar, \
79 __ssp_bos0(dstvar)) : \
80 __ ## fun ## _ichk(dstvar, srcvar)); \
81})
82
83#define __ssp_bos_check2(fun, dst, src) \
84 __ssp_bos_check2_var(fun, __ssp_var(dstv), dst, __ssp_var(srcv), src)
85
86#define __ssp_bos_icheck3_restrict(fun, type1, type2) \
87static __inline type1 __ ## fun ## _ichk(type1 __restrict, type2 __restrict, size_t); \
88static __inline __attribute__((__always_inline__)) type1 \
89__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src, size_t len) { \
90 return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \
91}
92
93#define __ssp_bos_icheck3(fun, type1, type2) \
94static __inline type1 __ ## fun ## _ichk(type1, type2, size_t); \
95static __inline __attribute__((__always_inline__)) type1 \
96__ ## fun ## _ichk(type1 dst, type2 src, size_t len) { \
97 return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \
98}
99
100#define __ssp_bos_icheck2_restrict(fun, type1, type2) \
101static __inline type1 __ ## fun ## _ichk(type1, type2); \
102static __inline __attribute__((__always_inline__)) type1 \
103__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src) { \
104 return __builtin___ ## fun ## _chk(dst, src, __ssp_bos0(dst)); \
105}
106
107__BEGIN_DECLS
108__ssp_bos_icheck3_restrict(memcpy, void *, const void *)
109__ssp_bos_icheck3_restrict(mempcpy, void *, const void *)
110__ssp_bos_icheck3(memmove, void *, const void *)
111__ssp_bos_icheck3(memset, void *, int)
112__ssp_redirect(void *, memset_explicit, (void *__buf, int __ch, size_t __len),
113 (__buf, __ch, __len));
114__ssp_bos_icheck2_restrict(stpcpy, char *, const char *)
115__ssp_bos_icheck3_restrict(stpncpy, char *, const char *)
116__ssp_bos_icheck2_restrict(strcpy, char *, const char *)
117__ssp_bos_icheck2_restrict(strcat, char *, const char *)
118__ssp_redirect0(int, strerror_r, (int __errnum, char *__buf, size_t __len),
119 (__errnum, __buf, __len));
120__ssp_bos_icheck3_restrict(strncpy, char *, const char *)
121__ssp_bos_icheck3_restrict(strncat, char *, const char *)
122__END_DECLS
123
124#define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
125#define mempcpy(dst, src, len) __ssp_bos_check3(mempcpy, dst, src, len)
126#define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len)
127#define memset(dst, val, len) \
128 __ssp_bos_check3_typed(memset, void *, dst, int, val, len)
129#define stpcpy(dst, src) __ssp_bos_check2(stpcpy, dst, src)
130#define stpncpy(dst, src, len) __ssp_bos_check3(stpncpy, dst, src, len)
131#define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src)
132#define strcat(dst, src) __ssp_bos_check2(strcat, dst, src)
133#define strlcpy(dst, src, dstlen) \
134 __strlcpy_chk(dst, src, dstlen, __ssp_bos(dst))
135#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len)
136#define strlcat(dst, src, dstlen) \
137 __strlcat_chk(dst, src, dstlen, __ssp_bos(dst))
138#define strncat(dst, src, len) __ssp_bos_check3(strncat, dst, src, len)
139
140#endif /* __SSP_FORTIFY_LEVEL > 0 */
141#endif /* _SSP_STRING_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/strings.h created+72
......@@ -0,0 +1,72 @@
1/* $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */
2
3/*-
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7 * Copyright (c) 2007 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Christos Zoulas.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _SSP_STRINGS_H_
35#define _SSP_STRINGS_H_
36
37#include <ssp/ssp.h>
38#include <string.h>
39
40#if __SSP_FORTIFY_LEVEL > 0
41
42#define _ssp_bcopy(srcvar, src, dstvar, dst, lenvar, len) __extension__ ({ \
43 const void *srcvar = (src); \
44 void *dstvar = (dst); \
45 size_t lenvar = (len); \
46 ((__ssp_bos0(dstvar) != (size_t)-1) ? \
47 __builtin___memmove_chk(dstvar, srcvar, lenvar, \
48 __ssp_bos0(dstvar)) : \
49 __memmove_ichk(dstvar, srcvar, lenvar)); \
50})
51
52#define bcopy(src, dst, len) \
53 _ssp_bcopy(__ssp_var(srcv), src, __ssp_var(dstv), dst, __ssp_var(lenv), len)
54
55#define _ssp_bzero(dstvar, dst, lenvar, len) __extension__ ({ \
56 void *dstvar = (dst); \
57 size_t lenvar = (len); \
58 ((__ssp_bos0(dstvar) != (size_t)-1) ? \
59 __builtin___memset_chk(dstvar, 0, lenvar, \
60 __ssp_bos0(dstvar)) : \
61 __memset_ichk(dstvar, 0, lenvar)); \
62})
63
64#define bzero(dst, len) _ssp_bzero(__ssp_var(dstv), dst, __ssp_var(lenv), len)
65
66__BEGIN_DECLS
67__ssp_redirect(void, explicit_bzero, (void *__buf, size_t __len),
68 (__buf, __len));
69__END_DECLS
70
71#endif /* __SSP_FORTIFY_LEVEL > 0 */
72#endif /* _SSP_STRINGS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/uio.h created+53
......@@ -0,0 +1,53 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024, Klara, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_UIO_H_
28#define _SSP_UIO_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34__BEGIN_DECLS
35
36__ssp_redirect_raw_impl(ssize_t, readv, readv,
37 (int fd, const struct iovec *iov, int iovcnt))
38{
39 __ssp_check_iovec(iov, iovcnt);
40 return (__ssp_real(readv)(fd, iov, iovcnt));
41}
42
43__ssp_redirect_raw_impl(ssize_t, preadv, preadv,
44 (int fd, const struct iovec *iov, int iovcnt, off_t offset))
45{
46 __ssp_check_iovec(iov, iovcnt);
47 return (__ssp_real(preadv)(fd, iov, iovcnt, offset));
48}
49
50__END_DECLS
51
52#endif /* __SSP_FORTIFY_LEVEL > 0 */
53#endif /* _SSP_UIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/unistd.h created+90
......@@ -0,0 +1,90 @@
1/* $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $ */
2
3/*-
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7 * Copyright (c) 2006 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Christos Zoulas.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _SSP_UNISTD_H_
35#define _SSP_UNISTD_H_
36
37#include <ssp/ssp.h>
38
39#if __SSP_FORTIFY_LEVEL > 0
40__BEGIN_DECLS
41
42#ifndef _FORTIFY_SOURCE_read
43#define _FORTIFY_SOURCE_read read
44#endif
45
46__ssp_inline size_t
47__ssp_gid_bos(const void *ptr)
48{
49 size_t ptrsize = __ssp_bos(ptr);
50
51 if (ptrsize == (size_t)-1)
52 return (ptrsize);
53
54 return (ptrsize / sizeof(gid_t));
55}
56
57__ssp_redirect_raw(int, getgrouplist, getgrouplist,
58 (const char *__name, gid_t __base, gid_t *__buf, int *__lenp),
59 (__name, __base, __buf, __lenp), 1, __ssp_gid_bos, *__lenp);
60
61__ssp_redirect_raw(int, getgroups, getgroups, (int __len, gid_t *__buf),
62 (__len, __buf), 1, __ssp_gid_bos, __len);
63
64__ssp_redirect(int, getloginclass, (char *__buf, size_t __len),
65 (__buf, __len));
66
67__ssp_redirect(ssize_t, _FORTIFY_SOURCE_read, (int __fd, void *__buf,
68 size_t __len), (__fd, __buf, __len));
69__ssp_redirect(ssize_t, pread, (int __fd, void *__buf, size_t __len,
70 off_t __offset), (__fd, __buf, __len, __offset));
71
72__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \
73 char *__restrict __buf, size_t __len), (__path, __buf, __len));
74__ssp_redirect(ssize_t, readlinkat, (int __fd, const char *__restrict __path,
75 char *__restrict __buf, size_t __len), (__fd, __path, __buf, __len));
76
77__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, size_t __len),
78 (__buf, __len), __buf != 0, __ssp_bos, __len);
79
80__ssp_redirect(int, getdomainname, (char *__buf, int __len), (__buf, __len));
81__ssp_redirect(int, getentropy, (void *__buf, size_t __len), (__buf, __len));
82__ssp_redirect(int, gethostname, (char *__buf, size_t __len), (__buf, __len));
83__ssp_redirect(int, getlogin_r, (char *__buf, size_t __len), (__buf, __len));
84__ssp_redirect(int, ttyname_r, (int __fd, char *__buf, size_t __len),
85 (__fd, __buf, __len));
86
87__END_DECLS
88
89#endif /* __SSP_FORTIFY_LEVEL > 0 */
90#endif /* _SSP_UNISTD_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ssp/wchar.h created+229
......@@ -0,0 +1,229 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024, Klara, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27#ifndef _SSP_WCHAR_H_
28#define _SSP_WCHAR_H_
29
30#include <ssp/ssp.h>
31
32#if __SSP_FORTIFY_LEVEL > 0
33
34__ssp_inline int
35__ssp_wchar_overlap(const void *leftp, const void *rightp, size_t len)
36{
37
38 if (len > __SIZE_T_MAX / sizeof(wchar_t))
39 return (1);
40 return (__ssp_overlap(leftp, rightp, len * sizeof(wchar_t)));
41}
42
43/*
44 * __ssp_wbos for w*() calls where the size parameters are in sizeof(wchar_t)
45 * units, so the result needs to be scaled appropriately.
46 */
47__ssp_inline size_t
48__ssp_wbos(void *ptr)
49{
50 const size_t ptrsize = __ssp_bos(ptr);
51
52 if (ptrsize == (size_t)-1)
53 return (ptrsize);
54
55 return (ptrsize / sizeof(wchar_t));
56}
57
58__BEGIN_DECLS
59__ssp_redirect_raw_impl(wchar_t *, wmemcpy, wmemcpy,
60 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
61{
62 const size_t slen = __ssp_wbos(buf);
63
64 if (len > slen)
65 __chk_fail();
66 if (__ssp_wchar_overlap(src, buf, len))
67 __chk_fail();
68
69 return (__ssp_real(wmemcpy)(buf, src, len));
70}
71
72__ssp_redirect_raw_impl(wchar_t *, wmempcpy, wmempcpy,
73 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
74{
75 const size_t slen = __ssp_wbos(buf);
76
77 if (len > slen)
78 __chk_fail();
79 if (__ssp_wchar_overlap(src, buf, len))
80 __chk_fail();
81
82 return (__ssp_real(wmempcpy)(buf, src, len));
83}
84
85__ssp_redirect_raw_impl(wchar_t *, wmemmove, wmemmove,
86 (wchar_t *buf, const wchar_t *src, size_t len))
87{
88 const size_t slen = __ssp_wbos(buf);
89
90 if (len > slen)
91 __chk_fail();
92
93 return (__ssp_real(wmemmove)(buf, src, len));
94}
95
96__ssp_redirect_raw_impl(wchar_t *, wmemset, wmemset,
97 (wchar_t *buf, wchar_t c, size_t len))
98{
99 const size_t slen = __ssp_wbos(buf);
100
101 if (len > slen)
102 __chk_fail();
103 return (__ssp_real(wmemset)(buf, c, len));
104}
105
106__ssp_redirect_raw_impl(wchar_t *, wcpcpy, wcpcpy,
107 (wchar_t *__restrict buf, const wchar_t *__restrict src))
108{
109 const size_t slen = __ssp_wbos(buf);
110 const size_t len = wcslen(src);
111
112 if (len >= slen)
113 __chk_fail();
114 if (__ssp_wchar_overlap(buf, src, len))
115 __chk_fail();
116
117 (void)__ssp_real(wmemcpy)(buf, src, len + 1);
118 return (buf + len);
119}
120
121__ssp_redirect_raw_impl(wchar_t *, wcpncpy, wcpncpy,
122 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
123{
124 const size_t slen = __ssp_wbos(buf);
125
126 if (len > slen)
127 __chk_fail();
128 if (__ssp_wchar_overlap(buf, src, len))
129 __chk_fail();
130
131 return (__ssp_real(wcpncpy)(buf, src, len));
132}
133
134__ssp_redirect_raw_impl(wchar_t *, wcscat, wcscat,
135 (wchar_t *__restrict buf, const wchar_t *__restrict src))
136{
137 size_t slen = __ssp_wbos(buf);
138 wchar_t *cp;
139
140 cp = buf;
141 while (*cp != L'\0') {
142 cp++;
143 if (slen-- == 0)
144 __chk_fail();
145 }
146
147 while (*src != L'\0') {
148 if (slen-- == 0)
149 __chk_fail();
150 *cp++ = *src++;
151 }
152
153 if (slen-- == 0)
154 __chk_fail();
155 *cp = '\0';
156 return (buf);
157}
158
159__ssp_redirect_raw_impl(wchar_t *, wcscpy, wcscpy,
160 (wchar_t *__restrict buf, const wchar_t *__restrict src))
161{
162 const size_t slen = __ssp_wbos(buf);
163 size_t len = wcslen(src) + 1;
164
165 if (len > slen)
166 __chk_fail();
167 if (__ssp_wchar_overlap(buf, src, len))
168 __chk_fail();
169
170 return (__ssp_real(wmemcpy)(buf, src, len));
171}
172
173__ssp_redirect_raw_impl(wchar_t *, wcsncat, wcsncat,
174 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
175{
176 const size_t slen = __ssp_wbos(buf);
177
178 if (len == 0)
179 return (buf);
180 if (len > slen)
181 __chk_fail();
182 if (__ssp_wchar_overlap(buf, src, len))
183 __chk_fail();
184
185 return (__ssp_real(wcsncat)(buf, src, len));
186}
187
188__ssp_redirect_raw_impl(size_t, wcslcat, wcslcat,
189 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
190{
191 const size_t slen = __ssp_wbos(buf);
192
193 if (len > slen)
194 __chk_fail();
195 if (__ssp_wchar_overlap(buf, src, len))
196 __chk_fail();
197
198 return (__ssp_real(wcslcat)(buf, src, len));
199}
200
201__ssp_redirect_raw_impl(wchar_t *, wcsncpy, wcsncpy,
202 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
203{
204 const size_t slen = __ssp_wbos(buf);
205
206 if (len > slen)
207 __chk_fail();
208 if (__ssp_wchar_overlap(buf, src, len))
209 __chk_fail();
210
211 return (__ssp_real(wcsncpy)(buf, src, len));
212}
213
214__ssp_redirect_raw_impl(size_t, wcslcpy, wcslcpy,
215 (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len))
216{
217 const size_t slen = __ssp_wbos(buf);
218
219 if (len > slen)
220 __chk_fail();
221 if (__ssp_wchar_overlap(buf, src, len))
222 __chk_fail();
223
224 return (__ssp_real(wcslcpy)(buf, src, len));
225}
226__END_DECLS
227
228#endif /* __SSP_FORTIFY_LEVEL > 0 */
229#endif /* _SSP_WCHAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/stab.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)stab.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _STAB_H_
lib/libc/include/generic-freebsd/stdarg.h+3-34
......@@ -1,37 +1,6 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2017 Poul-Henning Kamp. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_STDARG_H_
29#define _MACHINE_STDARG_H_
1#ifndef __SYS_STDARG_H__
2#define __SYS_STDARG_H__
303
314#include <sys/_stdarg.h>
325
33#ifndef va_start
34 #error this file needs to be ported to your compiler
35#endif
36
37#endif /* !_MACHINE_STDARG_H_ */
\ No newline at end of file
6#endif /* __SYS_STDARG_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/stdatomic.h+2-1
......@@ -33,7 +33,8 @@
3333#include <sys/cdefs.h>
3434#include <sys/_types.h>
3535
36#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
36#if (__has_extension(c_atomic) || __has_extension(cxx_atomic)) && \
37 defined(__clang__)
3738#define __CLANG_ATOMICS
3839#elif __GNUC_PREREQ__(4, 7)
3940#define __GNUC_ATOMICS
lib/libc/include/generic-freebsd/stdckdint.h+3-3
......@@ -13,7 +13,7 @@
1313
1414#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_add_overflow)
1515#define ckd_add(result, a, b) \
16 (_Bool)__builtin_add_overflow((a), (b), (result))
16 __builtin_add_overflow((a), (b), (result))
1717#else
1818#define ckd_add(result, a, b) \
1919 _Static_assert(0, "checked addition not supported")
......@@ -21,7 +21,7 @@
2121
2222#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_sub_overflow)
2323#define ckd_sub(result, a, b) \
24 (_Bool)__builtin_sub_overflow((a), (b), (result))
24 __builtin_sub_overflow((a), (b), (result))
2525#else
2626#define ckd_sub(result, a, b) \
2727 _Static_assert(0, "checked subtraction not supported")
......@@ -29,7 +29,7 @@
2929
3030#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_mul_overflow)
3131#define ckd_mul(result, a, b) \
32 (_Bool)__builtin_mul_overflow((a), (b), (result))
32 __builtin_mul_overflow((a), (b), (result))
3333#else
3434#define ckd_mul(result, a, b) \
3535 _Static_assert(0, "checked multiplication not supported")
lib/libc/include/generic-freebsd/stddef.h+4-11
......@@ -27,29 +27,20 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)stddef.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _STDDEF_H_
3533#define _STDDEF_H_
3634
37#include <sys/cdefs.h>
3835#include <sys/_null.h>
3936#include <sys/_types.h>
37#include <sys/_visible.h>
4038
4139#ifndef _PTRDIFF_T_DECLARED
4240typedef __ptrdiff_t ptrdiff_t;
4341#define _PTRDIFF_T_DECLARED
4442#endif
4543
46#if __BSD_VISIBLE
47#ifndef _RUNE_T_DECLARED
48typedef __rune_t rune_t;
49#define _RUNE_T_DECLARED
50#endif
51#endif
52
5344#ifndef _SIZE_T_DECLARED
5445typedef __size_t size_t;
5546#define _SIZE_T_DECLARED
......@@ -70,7 +61,9 @@ typedef __max_align_t max_align_t;
7061#endif
7162#endif
7263
73#define offsetof(type, field) __offsetof(type, field)
64#ifndef offsetof
65#define offsetof(type, field) __builtin_offsetof(type, field)
66#endif
7467
7568#if __EXT1_VISIBLE
7669/* ISO/IEC 9899:2011 K.3.3.2 */
lib/libc/include/generic-freebsd/stdio.h+26-21
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)stdio.h 8.5 (Berkeley) 4/29/95
3533 */
3634
3735#ifndef _STDIO_H_
......@@ -50,10 +48,13 @@ typedef __size_t size_t;
5048#define _SIZE_T_DECLARED
5149#endif
5250
51#if __EXT1_VISIBLE
52/* ISO/IEC 9899:2011 K.3.3.2 */
5353#ifndef _RSIZE_T_DEFINED
5454#define _RSIZE_T_DEFINED
5555typedef size_t rsize_t;
5656#endif
57#endif /* __EXT1_VISIBLE */
5758
5859#if __POSIX_VISIBLE >= 200809
5960#ifndef _OFF_T_DECLARED
......@@ -73,7 +74,7 @@ typedef __off64_t off64_t;
7374
7475#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
7576#ifndef _VA_LIST_DECLARED
76typedef __va_list va_list;
77typedef __builtin_va_list va_list;
7778#define _VA_LIST_DECLARED
7879#endif
7980#endif
......@@ -240,6 +241,21 @@ __END_DECLS
240241#define stdout __stdoutp
241242#define stderr __stderrp
242243
244/*
245 * Functions defined in all versions of POSIX 1003.1.
246 */
247#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506)
248#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */
249#endif
250
251#if __POSIX_VISIBLE
252#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
253#endif /* __POSIX_VISIBLE */
254
255#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
256#include <ssp/stdio.h>
257#endif
258
243259__BEGIN_DECLS
244260#ifdef _XLOCALE_H_
245261#include <xlocale/_stdio.h>
......@@ -254,7 +270,7 @@ int ferror(FILE *);
254270int fflush(FILE *);
255271int fgetc(FILE *);
256272int fgetpos(FILE * __restrict, fpos_t * __restrict);
257char *fgets(char * __restrict, int, FILE * __restrict);
273char *(fgets)(char * __restrict, int, FILE * __restrict);
258274FILE *fopen(const char * __restrict, const char * __restrict);
259275int fprintf(FILE * __restrict, const char * __restrict, ...);
260276int fputc(int, FILE *);
......@@ -282,7 +298,7 @@ void rewind(FILE *);
282298int scanf(const char * __restrict, ...);
283299void setbuf(FILE * __restrict, char * __restrict);
284300int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
285int sprintf(char * __restrict, const char * __restrict, ...);
301int (sprintf)(char * __restrict, const char * __restrict, ...);
286302int sscanf(const char * __restrict, const char * __restrict, ...);
287303FILE *tmpfile(void);
288304char *tmpnam(char *);
......@@ -290,13 +306,13 @@ int ungetc(int, FILE *);
290306int vfprintf(FILE * __restrict, const char * __restrict,
291307 __va_list);
292308int vprintf(const char * __restrict, __va_list);
293int vsprintf(char * __restrict, const char * __restrict,
309int (vsprintf)(char * __restrict, const char * __restrict,
294310 __va_list);
295311
296312#if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 199506
297int snprintf(char * __restrict, size_t, const char * __restrict,
313int (snprintf)(char * __restrict, size_t, const char * __restrict,
298314 ...) __printflike(3, 4);
299int vsnprintf(char * __restrict, size_t, const char * __restrict,
315int (vsnprintf)(char * __restrict, size_t, const char * __restrict,
300316 __va_list) __printflike(3, 0);
301317#endif
302318#if __ISO_C_VISIBLE >= 1999
......@@ -307,16 +323,7 @@ int vsscanf(const char * __restrict, const char * __restrict, __va_list)
307323 __scanflike(2, 0);
308324#endif
309325
310/*
311 * Functions defined in all versions of POSIX 1003.1.
312 */
313#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506)
314#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */
315#endif
316
317326#if __POSIX_VISIBLE
318#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
319
320327char *ctermid(char *);
321328FILE *fdopen(int, const char *);
322329int fileno(FILE *);
......@@ -415,6 +422,7 @@ FILE *funopen(const void *,
415422#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
416423#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
417424
425#if __BSD_VISIBLE
418426typedef __ssize_t cookie_read_function_t(void *, char *, size_t);
419427typedef __ssize_t cookie_write_function_t(void *, const char *, size_t);
420428typedef int cookie_seek_function_t(void *, off64_t *, int);
......@@ -426,6 +434,7 @@ typedef struct {
426434 cookie_close_function_t *close;
427435} cookie_io_functions_t;
428436FILE *fopencookie(void *, const char *, cookie_io_functions_t);
437#endif
429438
430439/*
431440 * Portability hacks. See <sys/types.h>.
......@@ -497,10 +506,6 @@ extern int __isthreaded;
497506#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
498507#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
499508
500#if __POSIX_VISIBLE
501#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
502#endif
503
504509#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
505510#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
506511
lib/libc/include/generic-freebsd/stdlib.h+22-21
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
3230 */
3331
3432#ifndef _STDLIB_H_
......@@ -40,13 +38,6 @@
4038
4139__NULLABILITY_PRAGMA_PUSH
4240
43#if __BSD_VISIBLE
44#ifndef _RUNE_T_DECLARED
45typedef __rune_t rune_t;
46#define _RUNE_T_DECLARED
47#endif
48#endif
49
5041#ifndef _SIZE_T_DECLARED
5142typedef __size_t size_t;
5243#define _SIZE_T_DECLARED
......@@ -78,6 +69,10 @@ typedef struct {
7869 */
7970#define RAND_MAX 0x7fffffff
8071
72#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
73#include <ssp/stdlib.h>
74#endif
75
8176__BEGIN_DECLS
8277#ifdef _XLOCALE_H_
8378#include <xlocale/_stdlib.h>
......@@ -86,9 +81,9 @@ extern int __mb_cur_max;
8681extern int ___mb_cur_max(void);
8782#define MB_CUR_MAX ((size_t)___mb_cur_max())
8883
89_Noreturn void abort(void);
84_Noreturn void abort(void) __noexcept;
9085int abs(int) __pure2;
91int atexit(void (* _Nonnull)(void));
86int atexit(void (* _Nonnull)(void)) __noexcept;
9287double atof(const char *);
9388int atoi(const char *);
9489long atol(const char *);
......@@ -100,6 +95,9 @@ div_t div(int, int) __pure2;
10095_Noreturn void exit(int);
10196void free(void *);
10297char *getenv(const char *);
98#if __BSD_VISIBLE
99int getenv_r(const char *, char * _Nonnull, size_t);
100#endif
103101long labs(long) __pure2;
104102ldiv_t ldiv(long, long) __pure2;
105103void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
......@@ -156,7 +154,7 @@ unsigned long long
156154 strtoull(const char * __restrict, char ** __restrict, int);
157155#endif /* __LONG_LONG_SUPPORTED */
158156
159_Noreturn void _Exit(int);
157_Noreturn void _Exit(int) __noexcept;
160158#endif /* __ISO_C_VISIBLE >= 1999 */
161159
162160/*
......@@ -165,9 +163,9 @@ _Noreturn void _Exit(int);
165163#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
166164void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
167165 __alloc_size(2);
168int at_quick_exit(void (*)(void));
166int at_quick_exit(void (*)(void)) __noexcept;
169167_Noreturn void
170 quick_exit(int);
168 quick_exit(int) /* __noexcept -- not ready ABI issues? */;
171169#endif /* __ISO_C_VISIBLE >= 2011 */
172170/*
173171 * Extensions made by POSIX relative to C.
......@@ -339,23 +337,26 @@ __uint64_t
339337 * parameter, and both are different from the ones expected by the historical
340338 * FreeBSD qsort_r() interface.
341339 *
342 * Apply a workaround where we explicitly link against the historical
343 * interface, qsort_r@FBSD_1.0, in case when qsort_r() is called with
344 * the last parameter with a function pointer that exactly matches the
345 * historical FreeBSD qsort_r() comparator signature, so applications
346 * written for the historical interface can continue to work without
347 * modification.
340 * Apply a workaround where we explicitly link against the historical interface,
341 * qsort_r@FBSD_1.0, in case when qsort_r() is called with the last parameter
342 * with a function pointer that exactly matches the historical FreeBSD qsort_r()
343 * comparator signature, so applications written for the historical interface
344 * can continue to work without modification. Toolchains that don't support
345 * symbol versioning don't define __sym_compat, so only provide this symbol in
346 * supported environments.
348347 */
348#ifdef __sym_compat
349349#if defined(__generic) || defined(__cplusplus)
350350void __qsort_r_compat(void *, size_t, size_t, void *,
351351 int (*)(void *, const void *, const void *));
352352__sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0);
353353#endif
354#endif
354355#if defined(__generic) && !defined(__cplusplus)
355356#define qsort_r(base, nel, width, arg4, arg5) \
356357 __generic(arg5, int (*)(void *, const void *, const void *), \
357358 __qsort_r_compat, qsort_r)(base, nel, width, arg4, arg5)
358#elif defined(__cplusplus)
359#elif defined(__cplusplus) && defined(__sym_compat)
359360__END_DECLS
360361extern "C++" {
361362static inline void qsort_r(void *base, size_t nmemb, size_t size,
lib/libc/include/generic-freebsd/string.h+24-17
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)string.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _STRING_H_
......@@ -51,8 +49,12 @@ typedef __size_t size_t;
5149#define _SIZE_T_DECLARED
5250#endif
5351
52#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
53#include <ssp/string.h>
54#endif
55
5456__BEGIN_DECLS
55#if __XSI_VISIBLE >= 600
57#if __XSI_VISIBLE >= 600 || __ISO_C_VISIBLE >= 2023
5658void *memccpy(void * __restrict, const void * __restrict, int, size_t);
5759#endif
5860void *memchr(const void *, int, size_t) __pure;
......@@ -60,23 +62,26 @@ void *memchr(const void *, int, size_t) __pure;
6062void *memrchr(const void *, int, size_t) __pure;
6163#endif
6264int memcmp(const void *, const void *, size_t) __pure;
63void *memcpy(void * __restrict, const void * __restrict, size_t);
65void *(memcpy)(void * __restrict, const void * __restrict, size_t);
6466#if __BSD_VISIBLE
6567void *memmem(const void *, size_t, const void *, size_t) __pure;
6668#endif
67void *memmove(void *, const void *, size_t);
69void *(memmove)(void *, const void *, size_t);
6870#if __BSD_VISIBLE
69void *mempcpy(void * __restrict, const void * __restrict, size_t);
71void *(mempcpy)(void * __restrict, const void * __restrict, size_t);
72#endif
73void *(memset)(void *, int, size_t);
74#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 2023
75void *memset_explicit(void *, int, size_t);
7076#endif
71void *memset(void *, int, size_t);
7277#if __POSIX_VISIBLE >= 200809
73char *stpcpy(char * __restrict, const char * __restrict);
74char *stpncpy(char * __restrict, const char * __restrict, size_t);
78char *(stpcpy)(char * __restrict, const char * __restrict);
79char *(stpncpy)(char * __restrict, const char * __restrict, size_t);
7580#endif
7681#if __BSD_VISIBLE
7782char *strcasestr(const char *, const char *) __pure;
7883#endif
79char *strcat(char * __restrict, const char * __restrict);
84char *(strcat)(char * __restrict, const char * __restrict);
8085char *strchr(const char *, int) __pure;
8186#if __BSD_VISIBLE
8287char *strchrnul(const char*, int) __pure;
......@@ -84,9 +89,9 @@ int strverscmp(const char *, const char *) __pure;
8489#endif
8590int strcmp(const char *, const char *) __pure;
8691int strcoll(const char *, const char *);
87char *strcpy(char * __restrict, const char * __restrict);
92char *(strcpy)(char * __restrict, const char * __restrict);
8893size_t strcspn(const char *, const char *) __pure;
89#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
94#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE || __ISO_C_VISIBLE >= 2023
9095char *strdup(const char *) __malloc_like;
9196#endif
9297char *strerror(int);
......@@ -94,8 +99,8 @@ char *strerror(int);
9499int strerror_r(int, char *, size_t);
95100#endif
96101#if __BSD_VISIBLE
97size_t strlcat(char * __restrict, const char * __restrict, size_t);
98size_t strlcpy(char * __restrict, const char * __restrict, size_t);
102size_t (strlcat)(char * __restrict, const char * __restrict, size_t);
103size_t (strlcpy)(char * __restrict, const char * __restrict, size_t);
99104#endif
100105size_t strlen(const char *) __pure;
101106#if __BSD_VISIBLE
......@@ -107,11 +112,13 @@ typedef __mode_t mode_t;
107112
108113void strmode(mode_t, char *);
109114#endif
110char *strncat(char * __restrict, const char * __restrict, size_t);
115char *(strncat)(char * __restrict, const char * __restrict, size_t);
111116int strncmp(const char *, const char *, size_t) __pure;
112char *strncpy(char * __restrict, const char * __restrict, size_t);
113#if __POSIX_VISIBLE >= 200809
117char *(strncpy)(char * __restrict, const char * __restrict, size_t);
118#if __POSIX_VISIBLE >= 200809 || __ISO_C_VISIBLE >= 2023
114119char *strndup(const char *, size_t) __malloc_like;
120#endif
121#if __POSIX_VISIBLE >= 200809
115122size_t strnlen(const char *, size_t) __pure;
116123#endif
117124#if __BSD_VISIBLE
lib/libc/include/generic-freebsd/stringlist.h+1-1
......@@ -30,7 +30,7 @@
3030
3131#ifndef _STRINGLIST_H
3232#define _STRINGLIST_H
33#include <sys/cdefs.h>
33
3434#include <sys/types.h>
3535
3636/*
lib/libc/include/generic-freebsd/strings.h+6-2
......@@ -37,11 +37,15 @@ typedef __size_t size_t;
3737#define _SIZE_T_DECLARED
3838#endif
3939
40#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
41#include <ssp/strings.h>
42#endif
43
4044__BEGIN_DECLS
4145#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
4246int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
43void bcopy(const void *, void *, size_t); /* LEGACY */
44void bzero(void *, size_t); /* LEGACY */
47void (bcopy)(const void *, void *, size_t); /* LEGACY */
48void (bzero)(void *, size_t); /* LEGACY */
4549#endif
4650#if __BSD_VISIBLE
4751void explicit_bzero(void *, size_t);
lib/libc/include/generic-freebsd/sys/_atomic64e.h+1-1
......@@ -55,7 +55,7 @@ int atomic_fcmpset_64(volatile u_int64_t *, u_int64_t *, u_int64_t);
5555
5656u_int64_t atomic_fetchadd_64(volatile u_int64_t *, u_int64_t);
5757
58u_int64_t atomic_load_64(volatile u_int64_t *);
58u_int64_t atomic_load_64(const volatile u_int64_t *);
5959#define atomic_load_acq_64 atomic_load_64
6060
6161void atomic_readandclear_64(volatile u_int64_t *);
lib/libc/include/generic-freebsd/sys/_atomic_subword.h+20-56
......@@ -176,7 +176,7 @@ atomic_fcmpset_16(__volatile uint16_t *addr, uint16_t *old, uint16_t val)
176176
177177#ifndef atomic_load_acq_8
178178static __inline uint8_t
179atomic_load_acq_8(volatile uint8_t *p)
179atomic_load_acq_8(const volatile uint8_t *p)
180180{
181181 int shift;
182182 uint8_t ret;
......@@ -189,7 +189,7 @@ atomic_load_acq_8(volatile uint8_t *p)
189189
190190#ifndef atomic_load_acq_16
191191static __inline uint16_t
192atomic_load_acq_16(volatile uint16_t *p)
192atomic_load_acq_16(const volatile uint16_t *p)
193193{
194194 int shift;
195195 uint16_t ret;
......@@ -205,67 +205,31 @@ atomic_load_acq_16(volatile uint16_t *p)
205205#undef _ATOMIC_BYTE_SHIFT
206206#undef _ATOMIC_HWORD_SHIFT
207207
208/*
209 * Provide generic testandset_long implementation based on fcmpset long
210 * primitive. It may not be ideal for any given arch, so machine/atomic.h
211 * should define the macro atomic_testandset_long to override with an
212 * MD-specific version.
213 *
214 * (Organizationally, this isn't really subword atomics. But atomic_common is
215 * included too early in machine/atomic.h, so it isn't a good place for derived
216 * primitives like this.)
217 */
218#ifndef atomic_testandset_acq_long
219static __inline int
220atomic_testandset_acq_long(volatile u_long *p, u_int v)
221{
222 u_long bit, old;
223 bool ret;
224
225 bit = (1ul << (v % (sizeof(*p) * NBBY)));
226
227 old = atomic_load_acq_long(p);
228 ret = false;
229 while (!ret && (old & bit) == 0)
230 ret = atomic_fcmpset_acq_long(p, &old, old | bit);
231
232 return (!ret);
233}
234#endif
235
236#ifndef atomic_testandset_long
237static __inline int
238atomic_testandset_long(volatile u_long *p, u_int v)
208#ifndef atomic_set_16
209static __inline void
210atomic_set_16(volatile uint16_t *p, uint16_t bit)
239211{
240 u_long bit, old;
241 bool ret;
242
243 bit = (1ul << (v % (sizeof(*p) * NBBY)));
244
245 old = atomic_load_long(p);
246 ret = false;
247 while (!ret && (old & bit) == 0)
248 ret = atomic_fcmpset_long(p, &old, old | bit);
212 uint16_t v;
249213
250 return (!ret);
214 v = atomic_load_16(p);
215 for (;;) {
216 if (atomic_fcmpset_16(p, &v, v | bit))
217 break;
218 }
251219}
252220#endif
253221
254#ifndef atomic_testandclear_long
255static __inline int
256atomic_testandclear_long(volatile u_long *p, u_int v)
222#ifndef atomic_clear_16
223static __inline void
224atomic_clear_16(volatile uint16_t *p, uint16_t bit)
257225{
258 u_long bit, old;
259 bool ret;
260
261 bit = (1ul << (v % (sizeof(*p) * NBBY)));
226 uint16_t v;
262227
263 old = atomic_load_long(p);
264 ret = false;
265 while (!ret && (old & bit) != 0)
266 ret = atomic_fcmpset_long(p, &old, old & ~bit);
267
268 return (ret);
228 v = atomic_load_16(p);
229 for (;;) {
230 if (atomic_fcmpset_16(p, &v, v & ~bit))
231 break;
232 }
269233}
270234#endif
271235
lib/libc/include/generic-freebsd/sys/_bitset.h+2-2
......@@ -36,7 +36,7 @@
3636 * Macros addressing word and bit within it, tuned to make compiler
3737 * optimize cases when SETSIZE fits into single machine word.
3838 */
39#define _BITSET_BITS (sizeof(long) * 8)
39#define _BITSET_BITS (sizeof(unsigned long) * 8)
4040
4141#define __howmany(x, y) (((x) + ((y) - 1)) / (y))
4242
......@@ -44,7 +44,7 @@
4444
4545#define __BITSET_DEFINE(_t, _s) \
4646struct _t { \
47 long __bits[__bitset_words((_s))]; \
47 unsigned long __bits[__bitset_words((_s))]; \
4848}
4949
5050/*
lib/libc/include/generic-freebsd/sys/_callout.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)callout.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS__CALLOUT_H
lib/libc/include/generic-freebsd/sys/_clock_id.h+5-1
......@@ -74,11 +74,15 @@
7474#define CLOCK_PROCESS_CPUTIME_ID 15
7575#endif /* __POSIX_VISIBLE >= 199309 */
7676
77#ifdef __BSD_VISIBLE
78#define CLOCK_TAI 16
79#endif
80
7781/*
7882 * Linux compatible names.
7983 */
8084#if __BSD_VISIBLE
81#define CLOCK_BOOTTIME CLOCK_UPTIME
85#define CLOCK_BOOTTIME CLOCK_MONOTONIC
8286#define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST
8387#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
8488#endif
lib/libc/include/generic-freebsd/sys/_cpuset.h+2
......@@ -35,6 +35,8 @@
3535#include <sys/_bitset.h>
3636
3737#ifdef _KERNEL
38#include <machine/param.h>
39
3840#define CPU_SETSIZE MAXCPU
3941#endif
4042
lib/libc/include/generic-freebsd/sys/_domainset.h+2
......@@ -32,6 +32,8 @@
3232#include <sys/_bitset.h>
3333
3434#ifdef _KERNEL
35#include <machine/param.h>
36
3537#define DOMAINSET_SETSIZE MAXMEMDOM
3638#endif
3739
lib/libc/include/generic-freebsd/sys/_endian.h+4-2
......@@ -69,8 +69,10 @@
6969
7070/*
7171 * POSIX Issue 8 will require these for endian.h. Define them there and in the
72 * traditional BSD compilation environment. Since issue 8 doesn't yet have an
73 * assigned date, use strictly greater than issue 7's date.
72 * traditional BSD compilation environment. PDP_ENDIAN isn't strictly in Issue
73 * 8, but is allowed as implementations can define any *_ENDIAN symbol. Since
74 * issue 8 doesn't yet have an assigned date, use strictly greater than issue
75 * 7's date.
7476 */
7577#if __BSD_VISIBLE || _POSIX_C_SOURCE > 200809
7678#define LITTLE_ENDIAN _LITTLE_ENDIAN
lib/libc/include/generic-freebsd/sys/_exterr.h created+25
......@@ -0,0 +1,25 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8 * under sponsorship from the FreeBSD Foundation.
9 */
10
11#ifndef _SYS__EXTERR_H_
12#define _SYS__EXTERR_H_
13
14#include <sys/_types.h>
15
16struct kexterr {
17 int error;
18 const char *msg;
19 __uint64_t p1;
20 __uint64_t p2;
21 unsigned cat;
22 unsigned src_line;
23};
24
25#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_iovec.h+24-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)uio.h 8.5 (Berkeley) 2/22/94
3230 */
3331
3432#ifndef _SYS__IOVEC_H_
......@@ -46,4 +44,28 @@ struct iovec {
4644 size_t iov_len; /* Length. */
4745};
4846
47#ifdef _KERNEL
48#define IOVEC_INIT(iovp, base, len) \
49 *(iovp) = (struct iovec){ .iov_base = (base), .iov_len = (len) }
50
51/* String with length including NUL terminator */
52#define IOVEC_INIT_CSTR(iovp, str) do { \
53 void *__str = (str); \
54 IOVEC_INIT(iovp, __str, strlen(__str) + 1); \
55} while(0)
56
57/* Object with size from sizeof() */
58#define IOVEC_INIT_OBJ(iovp, obj) \
59 IOVEC_INIT(iovp, &(obj), sizeof(obj))
60
61#define IOVEC_ADVANCE(iovp, amt) do { \
62 struct iovec *__iovp = (iovp); \
63 size_t __amt = (amt); \
64 KASSERT(__amt <= __iovp->iov_len, ("%s: amount %zu > iov_len \
65 %zu", __func__, __amt, __iovp->iov_len)); \
66 __iovp->iov_len -= __amt; \
67 __iovp->iov_base = (char *)__iovp->iov_base + __amt; \
68} while(0)
69#endif /* _KERNEL */
70
4971#endif /* !_SYS__IOVEC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_lock.h+2-2
......@@ -33,8 +33,8 @@
3333
3434struct lock_object {
3535 const char *lo_name; /* Individual lock name. */
36 u_int lo_flags;
37 u_int lo_data; /* General class specific data. */
36 unsigned int lo_flags;
37 unsigned int lo_data; /* General class specific data. */
3838 struct witness *lo_witness; /* Data for witness. */
3939};
4040
lib/libc/include/generic-freebsd/sys/_maxphys.h created+10
......@@ -0,0 +1,10 @@
1/*-
2 * This file is in the public domain.
3 */
4#ifndef MAXPHYS
5#ifdef __ILP32__
6#define MAXPHYS (128 * 1024)
7#else
8#define MAXPHYS (1024 * 1024)
9#endif
10#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_mutex.h+4-2
......@@ -31,6 +31,8 @@
3131#ifndef _SYS__MUTEX_H_
3232#define _SYS__MUTEX_H_
3333
34#include <sys/_types.h>
35#include <sys/_lock.h>
3436#include <machine/param.h>
3537
3638/*
......@@ -44,7 +46,7 @@
4446 */
4547struct mtx {
4648 struct lock_object lock_object; /* Common lock properties. */
47 volatile uintptr_t mtx_lock; /* Owner and flags. */
49 volatile __uintptr_t mtx_lock; /* Owner and flags. */
4850};
4951
5052/*
......@@ -58,7 +60,7 @@ struct mtx {
5860 */
5961struct mtx_padalign {
6062 struct lock_object lock_object; /* Common lock properties. */
61 volatile uintptr_t mtx_lock; /* Owner and flags. */
63 volatile __uintptr_t mtx_lock; /* Owner and flags. */
6264} __aligned(CACHE_LINE_SIZE);
6365
6466#endif /* !_SYS__MUTEX_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_null.h+1-3
......@@ -31,9 +31,7 @@
3131#if !defined(__cplusplus)
3232#define NULL ((void *)0)
3333#else
34#if __cplusplus >= 201103L
35#define NULL nullptr
36#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
34#if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
3735#define NULL __null
3836#else
3937#if defined(__LP64__)
lib/libc/include/generic-freebsd/sys/_nv.h created+45
......@@ -0,0 +1,45 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2009-2013 The FreeBSD Foundation
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#ifndef __NV_H_
32#define __NV_H_
33
34#ifndef _KERNEL
35#include <sys/nv_namespace.h>
36#endif
37
38#ifndef _NVLIST_T_DECLARED
39#define _NVLIST_T_DECLARED
40struct nvlist;
41
42typedef struct nvlist nvlist_t;
43#endif
44
45#endif /* !__NV_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_param.h created+28
......@@ -0,0 +1,28 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 */
8
9#ifndef _SYS__PARAM_H_
10#define _SYS__PARAM_H_
11
12#define NBBY 8 /* number of bits in a byte */
13#define NBPW sizeof(int) /* number of bytes per word (integer) */
14
15/*
16 * Macros for counting and rounding.
17 */
18#define nitems(x) (sizeof((x)) / sizeof((x)[0]))
19#ifndef howmany
20#define howmany(x, y) (((x)+((y)-1))/(y))
21#endif
22#define rounddown(x, y) (((x)/(y))*(y))
23#define rounddown2(x, y) __align_down(x, y) /* if y is power of two */
24#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
25#define roundup2(x, y) __align_up(x, y) /* if y is powers of two */
26#define powerof2(x) ((((x)-1)&(x))==0)
27
28#endif /* _SYS__PARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_rmlock.h+8-2
......@@ -32,6 +32,14 @@
3232#ifndef _SYS__RMLOCK_H_
3333#define _SYS__RMLOCK_H_
3434
35#include <sys/_cpuset.h>
36#include <sys/_lock.h>
37#include <sys/_mutex.h>
38#include <sys/queue.h>
39#include <sys/_sx.h>
40
41struct thread;
42
3543/*
3644 * Mostly reader/occasional writer lock.
3745 */
......@@ -66,8 +74,6 @@ struct rm_priotracker {
6674 LIST_ENTRY(rm_priotracker) rmp_qentry;
6775};
6876
69#include <sys/_mutex.h>
70
7177struct rmslock_pcpu;
7278
7379struct rmslock {
lib/libc/include/generic-freebsd/sys/_rwlock.h+4-2
......@@ -28,6 +28,8 @@
2828#ifndef _SYS__RWLOCK_H_
2929#define _SYS__RWLOCK_H_
3030
31#include <sys/_types.h>
32#include <sys/_lock.h>
3133#include <machine/param.h>
3234
3335/*
......@@ -41,7 +43,7 @@
4143 */
4244struct rwlock {
4345 struct lock_object lock_object;
44 volatile uintptr_t rw_lock;
46 volatile __uintptr_t rw_lock;
4547};
4648
4749/*
......@@ -55,7 +57,7 @@ struct rwlock {
5557 */
5658struct rwlock_padalign {
5759 struct lock_object lock_object;
58 volatile uintptr_t rw_lock;
60 volatile __uintptr_t rw_lock;
5961} __aligned(CACHE_LINE_SIZE);
6062
6163#endif /* !_SYS__RWLOCK_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_sigaltstack.h created+65
......@@ -0,0 +1,65 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1982, 1986, 1989, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef _SYS__SIGALTSTACK_H_
38#define _SYS__SIGALTSTACK_H_
39
40#include <sys/_types.h>
41
42#if __XSI_VISIBLE
43#if __BSD_VISIBLE
44#define __stack_t sigaltstack
45#endif
46typedef struct __stack_t stack_t;
47
48#define SS_ONSTACK 0x0001 /* take signal on alternate stack */
49#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
50#define MINSIGSTKSZ __MINSIGSTKSZ /* minimum stack size */
51#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
52#endif
53
54/*
55 * Structure used in sigaltstack call. Its definition is always
56 * needed for __ucontext. If __BSD_VISIBLE is defined, the structure
57 * tag is actually sigaltstack.
58 */
59struct __stack_t {
60 void *ss_sp; /* signal stack base */
61 __size_t ss_size; /* signal stack length */
62 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
63};
64
65#endif /* !_SYS__SIGALTSTACK_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_sigset.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)signal.h 8.4 (Berkeley) 5/4/95
3735 */
3836
3937#ifndef _SYS__SIGSET_H_
lib/libc/include/generic-freebsd/sys/_sockaddr_storage.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)socket.h 8.4 (Berkeley) 2/21/94
3230 */
3331
3432#ifndef _SYS__SOCKADDR_STORAGE_H_
lib/libc/include/generic-freebsd/sys/_stdarg.h+3-4
......@@ -31,12 +31,11 @@
3131#ifndef _SYS__STDARG_H_
3232#define _SYS__STDARG_H_
3333
34#include <sys/cdefs.h>
35#include <sys/_types.h>
34#include <sys/_visible.h>
3635
3736#ifndef _VA_LIST_DECLARED
38 #define _VA_LIST_DECLARED
39 typedef __va_list va_list;
37#define _VA_LIST_DECLARED
38typedef __builtin_va_list va_list;
4039#endif
4140
4241#define va_start(ap, last) __builtin_va_start((ap), (last))
lib/libc/include/generic-freebsd/sys/_sx.h+4-1
......@@ -31,12 +31,15 @@
3131#ifndef _SYS__SX_H_
3232#define _SYS__SX_H_
3333
34#include <sys/_types.h>
35#include <sys/_lock.h>
36
3437/*
3538 * Shared/exclusive lock main structure definition.
3639 */
3740struct sx {
3841 struct lock_object lock_object;
39 volatile uintptr_t sx_lock;
42 volatile __uintptr_t sx_lock;
4043};
4144
4245#endif /* !_SYS__SX_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_termios.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)termios.h 8.3 (Berkeley) 3/28/94
3230 */
3331
3432#ifndef _SYS__TERMIOS_H_
lib/libc/include/generic-freebsd/sys/_timespec.h-3
......@@ -27,9 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)time.h 8.5 (Berkeley) 5/4/95
32 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
3330 */
3431
3532#ifndef _SYS__TIMESPEC_H_
lib/libc/include/generic-freebsd/sys/_tls_variant_i.h+11-1
......@@ -37,8 +37,18 @@
3737
3838struct pthread;
3939
40struct dtv_slot {
41 char *dtvs_tls;
42};
43
44struct dtv {
45 uintptr_t dtv_gen;
46 uintptr_t dtv_size;
47 struct dtv_slot dtv_slots[];
48};
49
4050struct tcb {
41 uintptr_t *tcb_dtv; /* required by rtld */
51 struct dtv *tcb_dtv; /* required by rtld */
4252 struct pthread *tcb_thread;
4353};
4454
lib/libc/include/generic-freebsd/sys/_types.h+13-4
......@@ -29,8 +29,6 @@
2929#ifndef _SYS__TYPES_H_
3030#define _SYS__TYPES_H_
3131
32#include <sys/cdefs.h>
33
3432/*
3533 * Basic types upon which most other types are built.
3634 *
......@@ -181,12 +179,23 @@ typedef __uint_least32_t __char32_t;
181179#endif
182180
183181typedef struct {
184 long long __max_align1 __aligned(_Alignof(long long));
182 long long __max_align1
183 __attribute__((__aligned__(__alignof__(long long))));
185184#ifndef _STANDALONE
186 long double __max_align2 __aligned(_Alignof(long double));
185 long double __max_align2
186 __attribute__((__aligned__(__alignof__(long long))));
187187#endif
188188} __max_align_t;
189189
190/* Types for sys/acl.h */
191typedef __uint32_t __acl_tag_t;
192typedef __uint32_t __acl_perm_t;
193typedef __uint16_t __acl_entry_type_t;
194typedef __uint16_t __acl_flag_t;
195typedef __uint32_t __acl_type_t;
196typedef __uint32_t *__acl_permset_t;
197typedef __uint16_t *__acl_flagset_t;
198
190199typedef __uint64_t __dev_t; /* device number */
191200
192201typedef __uint32_t __fixpt_t; /* fixed point number */
lib/libc/include/generic-freebsd/sys/_uexterror.h created+29
......@@ -0,0 +1,29 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8 * under sponsorship from the FreeBSD Foundation.
9 */
10
11#ifndef _SYS__UEXTERROR_H_
12#define _SYS__UEXTERROR_H_
13
14#include <sys/_types.h>
15
16struct uexterror {
17 __uint32_t ver;
18 __uint32_t error;
19 __uint32_t cat;
20 __uint32_t src_line;
21 __uint32_t flags;
22 __uint32_t rsrv0;
23 __uint64_t p1;
24 __uint64_t p2;
25 __uint64_t rsrv1[4];
26 char msg[128];
27};
28
29#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_uio.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)uio.h 8.5 (Berkeley) 2/22/94
3230 */
3331
3432#ifndef _SYS__UIO_H_
lib/libc/include/generic-freebsd/sys/_visible.h created+223
......@@ -0,0 +1,223 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Berkeley Software Design, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#ifndef _SYS__VISIBLE_H_
36#define _SYS__VISIBLE_H_
37
38/*-
39 * The following definitions are an extension of the behavior originally
40 * implemented in <sys/_posix.h>, but with a different level of granularity.
41 * POSIX.1 requires that the macros we test be defined before any standard
42 * header file is included.
43 *
44 * Here's a quick run-down of the versions (and some informal names)
45 * defined(_POSIX_SOURCE) 1003.1-1988
46 * encoded as 198808 below
47 * _POSIX_C_SOURCE == 1 1003.1-1990
48 * encoded as 199009 below
49 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
50 * encoded as 199209 below
51 * _POSIX_C_SOURCE == 199309 1003.1b-1993
52 * (1003.1 Issue 4, Single Unix Spec v1, Unix 93)
53 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
54 * and the omnibus ISO/IEC 9945-1: 1996
55 * (1003.1 Issue 5, Single Unix Spec v2, Unix 95)
56 * _POSIX_C_SOURCE == 200112 1003.1-2001 (1003.1 Issue 6, Unix 03)
57 * with _XOPEN_SOURCE=600
58 * _POSIX_C_SOURCE == 200809 1003.1-2008 (1003.1 Issue 7)
59 * IEEE Std 1003.1-2017 (Rev of 1003.1-2008) is
60 * 1003.1-2008 with two TCs applied and
61 * _XOPEN_SOURCE=700
62 * _POSIX_C_SOURCE == 202405 1003.1-2004 (1003.1 Issue 8), IEEE Std 1003.1-2024
63 * with _XOPEN_SOURCE=800
64 *
65 * In addition, the X/Open Portability Guide, which is now the Single UNIX
66 * Specification, defines a feature-test macro which indicates the version of
67 * that specification, and which subsumes _POSIX_C_SOURCE.
68 *
69 * Our macros begin with two underscores to avoid namespace screwage.
70 */
71
72/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
73#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
74#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
75#define _POSIX_C_SOURCE 199009
76#endif
77
78/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
79#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
80#undef _POSIX_C_SOURCE
81#define _POSIX_C_SOURCE 199209
82#endif
83
84/*
85 * Deal with various X/Open Portability Guides and Single UNIX Spec. We use the
86 * '- 0' construct so software that defines _XOPEN_SOURCE to nothing doesn't
87 * cause errors. X/Open CAE Specification, August 1994, System Interfaces and
88 * Headers, Issue 4, Version 2 section 2.2 states an empty definition means the
89 * same thing as _POSIX_C_SOURCE == 2. This broadly mirrors "System V Interface
90 * Definition, Fourth Edition", but earlier editions suggest some ambiguity.
91 * However, FreeBSD has histoically implemented this as a NOP, so we just
92 * document what it should be for now to not break ports gratuitously.
93 */
94#ifdef _XOPEN_SOURCE
95#if _XOPEN_SOURCE - 0 >= 800
96#define __XSI_VISIBLE 800
97#undef _POSIX_C_SOURCE
98#define _POSIX_C_SOURCE 202405
99#elif _XOPEN_SOURCE - 0 >= 700
100#define __XSI_VISIBLE 700
101#undef _POSIX_C_SOURCE
102#define _POSIX_C_SOURCE 200809
103#elif _XOPEN_SOURCE - 0 >= 600
104#define __XSI_VISIBLE 600
105#undef _POSIX_C_SOURCE
106#define _POSIX_C_SOURCE 200112
107#elif _XOPEN_SOURCE - 0 >= 500
108#define __XSI_VISIBLE 500
109#undef _POSIX_C_SOURCE
110#define _POSIX_C_SOURCE 199506
111#else
112/* #define _POSIX_C_SOURCE 199209 */
113#endif
114#endif
115
116/*
117 * Deal with all versions of POSIX. The ordering relative to the tests above is
118 * important.
119 */
120#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
121#define _POSIX_C_SOURCE 198808
122#endif
123#ifdef _POSIX_C_SOURCE
124#if _POSIX_C_SOURCE >= 202405
125#define __POSIX_VISIBLE 202405
126#define __ISO_C_VISIBLE 2017
127#elif _POSIX_C_SOURCE >= 200809
128#define __POSIX_VISIBLE 200809
129#define __ISO_C_VISIBLE 1999
130#elif _POSIX_C_SOURCE >= 200112
131#define __POSIX_VISIBLE 200112
132#define __ISO_C_VISIBLE 1999
133#elif _POSIX_C_SOURCE >= 199506
134#define __POSIX_VISIBLE 199506
135#define __ISO_C_VISIBLE 1990
136#elif _POSIX_C_SOURCE >= 199309
137#define __POSIX_VISIBLE 199309
138#define __ISO_C_VISIBLE 1990
139#elif _POSIX_C_SOURCE >= 199209
140#define __POSIX_VISIBLE 199209
141#define __ISO_C_VISIBLE 1990
142#elif _POSIX_C_SOURCE >= 199009
143#define __POSIX_VISIBLE 199009
144#define __ISO_C_VISIBLE 1990
145#else
146#define __POSIX_VISIBLE 198808
147#define __ISO_C_VISIBLE 0
148#endif /* _POSIX_C_SOURCE */
149
150/*
151 * When we've explicitly asked for a newer C version, make the C variable
152 * visible by default. Also honor the glibc _ISOC{11,23}_SOURCE macros
153 * extensions. Both glibc and OpenBSD do this, even when a more strict
154 * _POSIX_C_SOURCE has been requested, and it makes good sense (especially for
155 * pre POSIX 2024, since C11 is much nicer than the old C99 base). Continue the
156 * practice with C23, though don't do older standards. Also, GLIBC doesn't have
157 * a _ISOC17_SOURCE, so it's not implemented here. glibc has earlier ISOCxx defines,
158 * but we don't implement those as they are not relevant enough.
159 */
160#if _ISOC23_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
161#undef __ISO_C_VISIBLE
162#define __ISO_C_VISIBLE 2023
163#elif _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
164#undef __ISO_C_VISIBLE
165#define __ISO_C_VISIBLE 2011
166#endif
167#else /* _POSIX_C_SOURCE */
168/*-
169 * Deal with _ANSI_SOURCE:
170 * If it is defined, and no other compilation environment is explicitly
171 * requested, then define our internal feature-test macros to zero. This
172 * makes no difference to the preprocessor (undefined symbols in preprocessing
173 * expressions are defined to have value zero), but makes it more convenient for
174 * a test program to print out the values.
175 *
176 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
177 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
178 * environment (and in fact we will never get here).
179 */
180#if defined(_ANSI_SOURCE) /* Hide almost everything. */
181#define __POSIX_VISIBLE 0
182#define __XSI_VISIBLE 0
183#define __BSD_VISIBLE 0
184#define __ISO_C_VISIBLE 1990
185#define __EXT1_VISIBLE 0
186#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
187#define __POSIX_VISIBLE 0
188#define __XSI_VISIBLE 0
189#define __BSD_VISIBLE 0
190#define __ISO_C_VISIBLE 1999
191#define __EXT1_VISIBLE 0
192#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
193#define __POSIX_VISIBLE 0
194#define __XSI_VISIBLE 0
195#define __BSD_VISIBLE 0
196#define __ISO_C_VISIBLE 2011
197#define __EXT1_VISIBLE 0
198#elif defined(_C23_SOURCE) /* Localism to specify strict C23 env. */
199#define __POSIX_VISIBLE 0
200#define __XSI_VISIBLE 0
201#define __BSD_VISIBLE 0
202#define __ISO_C_VISIBLE 2023
203#define __EXT1_VISIBLE 0
204#else /* Default environment: show everything. */
205#define __POSIX_VISIBLE 202405
206#define __XSI_VISIBLE 800
207#define __BSD_VISIBLE 1
208#define __ISO_C_VISIBLE 2023
209#define __EXT1_VISIBLE 1
210#endif
211#endif /* _POSIX_C_SOURCE */
212
213/* User override __EXT1_VISIBLE */
214#if defined(__STDC_WANT_LIB_EXT1__)
215#undef __EXT1_VISIBLE
216#if __STDC_WANT_LIB_EXT1__
217#define __EXT1_VISIBLE 1
218#else
219#define __EXT1_VISIBLE 0
220#endif
221#endif /* __STDC_WANT_LIB_EXT1__ */
222
223#endif /* !_SYS__VISIBLE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_winsize.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ttycom.h 8.1 (Berkeley) 3/28/94
3230 */
3331
3432#ifndef _SYS__WINSIZE_H_
lib/libc/include/generic-freebsd/sys/acct.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)acct.h 8.4 (Berkeley) 1/9/95
3735 */
3836
3937#ifndef _SYS_ACCT_H_
lib/libc/include/generic-freebsd/sys/acl.h+12-10
......@@ -36,21 +36,23 @@
3636#ifndef _SYS_ACL_H_
3737#define _SYS_ACL_H_
3838
39#include <sys/param.h>
40#include <sys/queue.h>
41#include <vm/uma.h>
39#include <sys/types.h>
40#include <sys/_null.h>
41#ifdef _KERNEL
42#include <sys/malloc.h>
43#endif
4244
4345/*
4446 * POSIX.1e and NFSv4 ACL types and related constants.
4547 */
4648
47typedef uint32_t acl_tag_t;
48typedef uint32_t acl_perm_t;
49typedef uint16_t acl_entry_type_t;
50typedef uint16_t acl_flag_t;
51typedef int acl_type_t;
52typedef int *acl_permset_t;
53typedef uint16_t *acl_flagset_t;
49typedef __acl_tag_t acl_tag_t;
50typedef __acl_perm_t acl_perm_t;
51typedef __acl_entry_type_t acl_entry_type_t;
52typedef __acl_flag_t acl_flag_t;
53typedef __acl_type_t acl_type_t;
54typedef __acl_permset_t acl_permset_t;
55typedef __acl_flagset_t acl_flagset_t;
5456
5557/*
5658 * With 254 entries, "struct acl_t_struct" is exactly one 4kB page big.
lib/libc/include/generic-freebsd/sys/aio.h+1-1
......@@ -97,7 +97,7 @@
9797struct __aiocb_private {
9898 long status;
9999 long error;
100 void *kernelinfo;
100 void *spare;
101101};
102102
103103/*
lib/libc/include/generic-freebsd/sys/asan.h+4
......@@ -53,14 +53,18 @@
5353#define KASAN_KSTACK_FREED 0xFE
5454#define KASAN_EXEC_ARGS_FREED 0xFF
5555
56struct thread;
57
5658void kasan_init(void);
5759void kasan_init_early(vm_offset_t, size_t);
5860void kasan_shadow_map(vm_offset_t, size_t);
5961void kasan_mark(const void *, size_t, size_t, uint8_t);
62void kasan_thread_alloc(struct thread *);
6063#else /* KASAN */
6164#define kasan_init()
6265#define kasan_shadow_map(a, s)
6366#define kasan_mark(p, s, l, c)
67#define kasan_thread_alloc(t)
6468#endif /* !KASAN */
6569
6670#endif /* !_SYS_ASAN_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/atomic_common.h+11-11
......@@ -36,18 +36,18 @@
3636
3737#include <sys/types.h>
3838
39#define __atomic_load_bool_relaxed(p) (*(volatile _Bool *)(p))
39#define __atomic_load_bool_relaxed(p) (*(const volatile _Bool *)(p))
4040#define __atomic_store_bool_relaxed(p, v) \
4141 (*(volatile _Bool *)(p) = (_Bool)(v))
4242
43#define __atomic_load_char_relaxed(p) (*(volatile u_char *)(p))
44#define __atomic_load_short_relaxed(p) (*(volatile u_short *)(p))
45#define __atomic_load_int_relaxed(p) (*(volatile u_int *)(p))
46#define __atomic_load_long_relaxed(p) (*(volatile u_long *)(p))
47#define __atomic_load_8_relaxed(p) (*(volatile uint8_t *)(p))
48#define __atomic_load_16_relaxed(p) (*(volatile uint16_t *)(p))
49#define __atomic_load_32_relaxed(p) (*(volatile uint32_t *)(p))
50#define __atomic_load_64_relaxed(p) (*(volatile uint64_t *)(p))
43#define __atomic_load_char_relaxed(p) (*(const volatile u_char *)(p))
44#define __atomic_load_short_relaxed(p) (*(const volatile u_short *)(p))
45#define __atomic_load_int_relaxed(p) (*(const volatile u_int *)(p))
46#define __atomic_load_long_relaxed(p) (*(const volatile u_long *)(p))
47#define __atomic_load_8_relaxed(p) (*(const volatile uint8_t *)(p))
48#define __atomic_load_16_relaxed(p) (*(const volatile uint16_t *)(p))
49#define __atomic_load_32_relaxed(p) (*(const volatile uint32_t *)(p))
50#define __atomic_load_64_relaxed(p) (*(const volatile uint64_t *)(p))
5151
5252#define __atomic_store_char_relaxed(p, v) \
5353 (*(volatile u_char *)(p) = (u_char)(v))
......@@ -124,7 +124,7 @@
124124 __atomic_store_generic(p, v, int64_t, uint64_t, 64)
125125#endif
126126
127#define atomic_load_ptr(p) (*(volatile __typeof(*p) *)(p))
127#define atomic_load_ptr(p) (*(const volatile __typeof(*p) *)(p))
128128#define atomic_store_ptr(p, v) (*(volatile __typeof(*p) *)(p) = (v))
129129
130130/*
......@@ -133,7 +133,7 @@
133133 * openly resorting to the stronger acquire fence, to be sorted out.
134134 */
135135#define atomic_load_consume_ptr(p) \
136 ((__typeof(*p)) atomic_load_acq_ptr((uintptr_t *)p))
136 ((__typeof(*p)) atomic_load_acq_ptr((const volatile uintptr_t *)p))
137137
138138#define atomic_interrupt_fence() __compiler_membar()
139139
lib/libc/include/generic-freebsd/sys/atomic_san.h+4-5
......@@ -65,10 +65,10 @@
6565 type sp##_atomic_readandclear_##name(volatile type *)
6666
6767#define ATOMIC_SAN_LOAD(sp, name, type) \
68 type sp##_atomic_load_##name(volatile type *)
68 type sp##_atomic_load_##name(const volatile type *)
6969
7070#define ATOMIC_SAN_LOAD_ACQ(sp, name, type) \
71 type sp##_atomic_load_acq_##name(volatile type *)
71 type sp##_atomic_load_acq_##name(const volatile type *)
7272
7373#define ATOMIC_SAN_STORE(sp, name, type) \
7474 void sp##_atomic_store_##name(volatile type *, type)
......@@ -266,11 +266,10 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
266266#define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr)
267267#define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr)
268268#define atomic_load_ptr(x) \
269 ((__typeof(*x))ATOMIC_SAN(load_ptr)( \
270 __DECONST(volatile uintptr_t *, (x))))
269 ((__typeof(*x))ATOMIC_SAN(load_ptr)((const volatile uintptr_t *)(x)))
271270#define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr)
272271#define atomic_load_consume_ptr(x) \
273 ((__typeof(*x))atomic_load_acq_ptr((volatile uintptr_t *)(x)))
272 ((__typeof(*x))atomic_load_acq_ptr((const volatile uintptr_t *)(x)))
274273#define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr)
275274#define atomic_set_ptr ATOMIC_SAN(set_ptr)
276275#define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr)
lib/libc/include/generic-freebsd/sys/bio.h-4
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)buf.h 8.9 (Berkeley) 3/30/95
3735 */
3836
3937#ifndef _SYS_BIO_H_
......@@ -77,7 +75,6 @@
7775#ifdef _KERNEL
7876struct disk;
7977struct bio;
80struct vm_map;
8178
8279typedef void bio_task_t(void *);
8380
......@@ -146,7 +143,6 @@ struct bio_queue_head {
146143 int batched;
147144};
148145
149extern struct vm_map *bio_transient_map;
150146extern int bio_transient_maxcnt;
151147
152148void biodone(struct bio *bp);
lib/libc/include/generic-freebsd/sys/bitcount.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)types.h 8.6 (Berkeley) 2/19/95
3735 */
3836
3937#ifndef _SYS_BITCOUNT_H_
lib/libc/include/generic-freebsd/sys/buf.h+11-6
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)buf.h 8.9 (Berkeley) 3/30/95
3735 */
3836
3937#ifndef _SYS_BUF_H_
......@@ -298,7 +296,7 @@ struct buf {
298296 * Initialize a lock.
299297 */
300298#define BUF_LOCKINIT(bp, wmesg) \
301 lockinit(&(bp)->b_lock, PRIBIO + 4, wmesg, 0, LK_NEW)
299 lockinit(&(bp)->b_lock, PVFS, wmesg, 0, LK_NEW)
302300/*
303301 *
304302 * Get a lock sleeping non-interruptably until it becomes available.
......@@ -313,7 +311,7 @@ struct buf {
313311 */
314312#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \
315313 _lockmgr_args_rw(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \
316 (interlock), (wmesg), (PRIBIO + 4) | (catch), (timo), \
314 (interlock), (wmesg), PVFS | (catch), (timo), \
317315 LOCK_FILE, LOCK_LINE)
318316
319317/*
......@@ -343,6 +341,13 @@ struct buf {
343341 */
344342#define BUF_ISLOCKED(bp) \
345343 lockstatus(&(bp)->b_lock)
344
345/*
346 * Check if a buffer lock is currently held by LK_KERNPROC.
347 */
348#define BUF_DISOWNED(bp) \
349 lockmgr_disowned(&(bp)->b_lock)
350
346351/*
347352 * Free a buffer lock.
348353 */
......@@ -514,7 +519,6 @@ extern int nbuf; /* The number of buffer headers */
514519extern u_long maxswzone; /* Max KVA for swap structures */
515520extern u_long maxbcache; /* Max KVA for buffer cache */
516521extern int maxbcachebuf; /* Max buffer cache block size */
517extern long runningbufspace;
518522extern long hibufspace;
519523extern int dirtybufthresh;
520524extern int bdwriteskip;
......@@ -531,6 +535,7 @@ buf_mapped(struct buf *bp)
531535 return (bp->b_data != unmapped_buf);
532536}
533537
538long runningbufclaim(struct buf *, int);
534539void runningbufwakeup(struct buf *);
535540void waitrunningbufspace(void);
536541caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est);
......@@ -598,7 +603,7 @@ void vfs_unbusy_pages(struct buf *);
598603int vmapbuf(struct buf *, void *, size_t, int);
599604void vunmapbuf(struct buf *);
600605void brelvp(struct buf *);
601void bgetvp(struct vnode *, struct buf *);
606int bgetvp(struct vnode *, struct buf *) __result_use_check;
602607void pbgetbo(struct bufobj *bo, struct buf *bp);
603608void pbgetvp(struct vnode *, struct buf *);
604609void pbrelbo(struct buf *);
lib/libc/include/generic-freebsd/sys/buf_ring.h+35-29
......@@ -51,13 +51,13 @@
5151 *
5252 */
5353struct buf_ring {
54 volatile uint32_t br_prod_head;
55 volatile uint32_t br_prod_tail;
54 uint32_t br_prod_head;
55 uint32_t br_prod_tail;
5656 int br_prod_size;
5757 int br_prod_mask;
5858 uint64_t br_drops;
59 volatile uint32_t br_cons_head __aligned(CACHE_LINE_SIZE);
60 volatile uint32_t br_cons_tail;
59 uint32_t br_cons_head __aligned(CACHE_LINE_SIZE);
60 uint32_t br_cons_tail;
6161 int br_cons_size;
6262 int br_cons_mask;
6363#if defined(DEBUG_BUFRING) && defined(_KERNEL)
......@@ -83,10 +83,12 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
8383 * via drbr_peek(), and then re-added via drbr_putback() and
8484 * trigger a spurious panic.
8585 */
86 for (uint32_t i = br->br_cons_head; i != br->br_prod_head; i++)
86 for (uint32_t i = atomic_load_32(&br->br_cons_head);
87 i != atomic_load_32(&br->br_prod_head); i++)
8788 if (br->br_ring[i & mask] == buf)
8889 panic("buf=%p already enqueue at %d prod=%d cons=%d",
89 buf, i, br->br_prod_tail, br->br_cons_tail);
90 buf, i, atomic_load_32(&br->br_prod_tail),
91 atomic_load_32(&br->br_cons_tail));
9092#endif
9193 critical_enter();
9294 do {
......@@ -105,16 +107,15 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
105107 cons_tail = atomic_load_acq_32(&br->br_cons_tail);
106108
107109 if ((int32_t)(cons_tail + br->br_prod_size - prod_next) < 1) {
108 rmb();
109 if (prod_head == br->br_prod_head &&
110 cons_tail == br->br_cons_tail) {
110 if (prod_head == atomic_load_32(&br->br_prod_head) &&
111 cons_tail == atomic_load_32(&br->br_cons_tail)) {
111112 br->br_drops++;
112113 critical_exit();
113114 return (ENOBUFS);
114115 }
115116 continue;
116117 }
117 } while (!atomic_cmpset_acq_32(&br->br_prod_head, prod_head, prod_next));
118 } while (!atomic_cmpset_32(&br->br_prod_head, prod_head, prod_next));
118119 prod_idx = prod_head & mask;
119120#ifdef DEBUG_BUFRING
120121 if (br->br_ring[prod_idx] != NULL)
......@@ -127,7 +128,7 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
127128 * that preceded us, we need to wait for them
128129 * to complete
129130 */
130 while (br->br_prod_tail != prod_head)
131 while (atomic_load_32(&br->br_prod_tail) != prod_head)
131132 cpu_spinwait();
132133 atomic_store_rel_32(&br->br_prod_tail, prod_next);
133134 critical_exit();
......@@ -161,7 +162,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)
161162 critical_exit();
162163 return (NULL);
163164 }
164 } while (!atomic_cmpset_acq_32(&br->br_cons_head, cons_head, cons_next));
165 } while (!atomic_cmpset_32(&br->br_cons_head, cons_head, cons_next));
165166 cons_idx = cons_head & mask;
166167
167168 buf = br->br_ring[cons_idx];
......@@ -173,7 +174,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)
173174 * that preceded us, we need to wait for them
174175 * to complete
175176 */
176 while (br->br_cons_tail != cons_head)
177 while (atomic_load_32(&br->br_cons_tail) != cons_head)
177178 cpu_spinwait();
178179
179180 atomic_store_rel_32(&br->br_cons_tail, cons_next);
......@@ -195,7 +196,7 @@ buf_ring_dequeue_sc(struct buf_ring *br)
195196 void *buf;
196197
197198 mask = br->br_cons_mask;
198 cons_head = br->br_cons_head;
199 cons_head = atomic_load_32(&br->br_cons_head);
199200 prod_tail = atomic_load_acq_32(&br->br_prod_tail);
200201
201202 cons_next = cons_head + 1;
......@@ -204,7 +205,7 @@ buf_ring_dequeue_sc(struct buf_ring *br)
204205 return (NULL);
205206
206207 cons_idx = cons_head & mask;
207 br->br_cons_head = cons_next;
208 atomic_store_32(&br->br_cons_head, cons_next);
208209 buf = br->br_ring[cons_idx];
209210
210211#ifdef DEBUG_BUFRING
......@@ -213,9 +214,9 @@ buf_ring_dequeue_sc(struct buf_ring *br)
213214 if (!mtx_owned(br->br_lock))
214215 panic("lock not held on single consumer dequeue");
215216#endif
216 if (br->br_cons_tail != cons_head)
217 if (atomic_load_32(&br->br_cons_tail) != cons_head)
217218 panic("inconsistent list cons_tail=%d cons_head=%d",
218 br->br_cons_tail, cons_head);
219 atomic_load_32(&br->br_cons_tail), cons_head);
219220#endif
220221 atomic_store_rel_32(&br->br_cons_tail, cons_next);
221222 return (buf);
......@@ -235,13 +236,13 @@ buf_ring_advance_sc(struct buf_ring *br)
235236
236237 mask = br->br_cons_mask;
237238#endif
238 cons_head = br->br_cons_head;
239 prod_tail = br->br_prod_tail;
239 cons_head = atomic_load_32(&br->br_cons_head);
240 prod_tail = atomic_load_32(&br->br_prod_tail);
240241
241242 cons_next = cons_head + 1;
242243 if (cons_head == prod_tail)
243244 return;
244 br->br_cons_head = cons_next;
245 atomic_store_32(&br->br_cons_head, cons_next);
245246#ifdef DEBUG_BUFRING
246247 br->br_ring[cons_head & mask] = NULL;
247248#endif
......@@ -267,12 +268,13 @@ buf_ring_advance_sc(struct buf_ring *br)
267268static __inline void
268269buf_ring_putback_sc(struct buf_ring *br, void *new)
269270{
270 uint32_t mask;
271 uint32_t cons_idx, mask;
271272
272273 mask = br->br_cons_mask;
273 KASSERT((br->br_cons_head & mask) != (br->br_prod_tail & mask),
274 cons_idx = atomic_load_32(&br->br_cons_head) & mask;
275 KASSERT(cons_idx != (atomic_load_32(&br->br_prod_tail) & mask),
274276 ("Buf-Ring has none in putback")) ;
275 br->br_ring[br->br_cons_head & mask] = new;
277 br->br_ring[cons_idx] = new;
276278}
277279
278280/*
......@@ -291,7 +293,7 @@ buf_ring_peek(struct buf_ring *br)
291293#endif
292294 mask = br->br_cons_mask;
293295 prod_tail = atomic_load_acq_32(&br->br_prod_tail);
294 cons_head = br->br_cons_head;
296 cons_head = atomic_load_32(&br->br_cons_head);
295297
296298 if (cons_head == prod_tail)
297299 return (NULL);
......@@ -312,7 +314,7 @@ buf_ring_peek_clear_sc(struct buf_ring *br)
312314
313315 mask = br->br_cons_mask;
314316 prod_tail = atomic_load_acq_32(&br->br_prod_tail);
315 cons_head = br->br_cons_head;
317 cons_head = atomic_load_32(&br->br_cons_head);
316318
317319 if (cons_head == prod_tail)
318320 return (NULL);
......@@ -332,22 +334,26 @@ static __inline int
332334buf_ring_full(struct buf_ring *br)
333335{
334336
335 return (br->br_prod_head == br->br_cons_tail + br->br_cons_size - 1);
337 return (atomic_load_32(&br->br_prod_head) ==
338 atomic_load_32(&br->br_cons_tail) + br->br_cons_size - 1);
336339}
337340
338341static __inline int
339342buf_ring_empty(struct buf_ring *br)
340343{
341344
342 return (br->br_cons_head == br->br_prod_tail);
345 return (atomic_load_32(&br->br_cons_head) ==
346 atomic_load_32(&br->br_prod_tail));
343347}
344348
345349static __inline int
346350buf_ring_count(struct buf_ring *br)
347351{
352 uint32_t cons_tail, prod_tail;
348353
349 return ((br->br_prod_size + br->br_prod_tail - br->br_cons_tail)
350 & br->br_prod_mask);
354 cons_tail = atomic_load_32(&br->br_cons_tail);
355 prod_tail = atomic_load_32(&br->br_prod_tail);
356 return ((br->br_prod_size + prod_tail - cons_tail) & br->br_prod_mask);
351357}
352358
353359#ifdef _KERNEL
lib/libc/include/generic-freebsd/sys/bufobj.h+2-1
......@@ -33,7 +33,7 @@
3333 * cache.
3434 *
3535 * This used to be vnodes, but we need non-vnode code to be able
36 * to use the buffer cache as well, specifically geom classes like gbde,
36 * to use the buffer cache as well, specifically geom classes like
3737 * raid3 and raid5.
3838 *
3939 * All vnodes will contain a bufobj initially, but down the road we may
......@@ -116,6 +116,7 @@ struct bufobj {
116116#define BO_WWAIT (1 << 1) /* Wait for output to complete */
117117#define BO_DEAD (1 << 2) /* Dead; only with INVARIANTS */
118118#define BO_NOBUFS (1 << 3) /* No bufs allowed */
119#define BO_NONSTERILE (1 << 4) /* Ever called reassignbuf() */
119120
120121#define BO_LOCKPTR(bo) (&(bo)->bo_lock)
121122#define BO_LOCK(bo) rw_wlock(BO_LOCKPTR((bo)))
lib/libc/include/generic-freebsd/sys/bus.h+84-57
......@@ -159,6 +159,7 @@ struct devreq {
159159/* Flags for DEV_RESET */
160160#define DEVF_RESET_DETACH 0x0000001 /* Detach drivers vs suspend
161161 device */
162#define DEVICE_UNIT_ANY (-1)
162163
163164#ifdef _KERNEL
164165
......@@ -276,6 +277,7 @@ enum intr_type {
276277 INTR_EXCL = 256, /* exclusive interrupt */
277278 INTR_MPSAFE = 512, /* this interrupt is SMP safe */
278279 INTR_ENTROPY = 1024, /* this interrupt provides entropy */
280 INTR_SLEEPABLE = 2048, /* this interrupt handler can sleep */
279281 INTR_MD1 = 4096, /* flag reserved for MD use */
280282 INTR_MD2 = 8192, /* flag reserved for MD use */
281283 INTR_MD3 = 16384, /* flag reserved for MD use */
......@@ -305,18 +307,6 @@ enum cpu_sets {
305307 INTR_CPUS
306308};
307309
308typedef int (*devop_t)(void);
309
310/**
311 * @brief This structure is deprecated.
312 *
313 * Use the kobj(9) macro DEFINE_CLASS to
314 * declare classes which implement device drivers.
315 */
316struct driver {
317 KOBJ_CLASS_FIELDS;
318};
319
320310struct resource;
321311
322312/**
......@@ -396,7 +386,7 @@ struct resource *
396386 rman_res_t count, u_int flags);
397387int resource_list_release(struct resource_list *rl,
398388 device_t bus, device_t child,
399 int type, int rid, struct resource *res);
389 struct resource *res);
400390int resource_list_release_active(struct resource_list *rl,
401391 device_t bus, device_t child,
402392 int type);
......@@ -427,12 +417,12 @@ void root_bus_configure(void);
427417
428418struct _cpuset;
429419
430int bus_generic_activate_resource(device_t dev, device_t child, int type,
431 int rid, struct resource *r);
420int bus_generic_activate_resource(device_t dev, device_t child,
421 struct resource *r);
432422device_t
433423 bus_generic_add_child(device_t dev, u_int order, const char *name,
434424 int unit);
435int bus_generic_adjust_resource(device_t bus, device_t child, int type,
425int bus_generic_adjust_resource(device_t bus, device_t child,
436426 struct resource *r, rman_res_t start,
437427 rman_res_t end);
438428struct resource *
......@@ -441,7 +431,8 @@ struct resource *
441431 rman_res_t count, u_int flags);
442432int bus_generic_translate_resource(device_t dev, int type, rman_res_t start,
443433 rman_res_t *newstart);
444int bus_generic_attach(device_t dev);
434int bus_generic_attach(device_t dev)
435 __deprecated1("Use bus_attach_children instead");
445436int bus_generic_bind_intr(device_t dev, device_t child,
446437 struct resource *irq, int cpu);
447438int bus_generic_child_location(device_t dev, device_t child, struct sbuf *sb);
......@@ -452,8 +443,8 @@ int bus_generic_config_intr(device_t, int, enum intr_trigger,
452443int bus_generic_describe_intr(device_t dev, device_t child,
453444 struct resource *irq, void *cookie,
454445 const char *descr);
455int bus_generic_deactivate_resource(device_t dev, device_t child, int type,
456 int rid, struct resource *r);
446int bus_generic_deactivate_resource(device_t dev, device_t child,
447 struct resource *r);
457448int bus_generic_detach(device_t dev);
458449void bus_generic_driver_added(device_t dev, driver_t *driver);
459450int bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op,
......@@ -466,9 +457,7 @@ int bus_generic_get_domain(device_t dev, device_t child, int *domain);
466457ssize_t bus_generic_get_property(device_t dev, device_t child,
467458 const char *propname, void *propvalue,
468459 size_t size, device_property_type_t type);
469struct resource_list *
470 bus_generic_get_resource_list(device_t, device_t);
471int bus_generic_map_resource(device_t dev, device_t child, int type,
460int bus_generic_map_resource(device_t dev, device_t child,
472461 struct resource *r,
473462 struct resource_map_request *args,
474463 struct resource_map *map);
......@@ -477,11 +466,12 @@ int bus_print_child_header(device_t dev, device_t child);
477466int bus_print_child_domain(device_t dev, device_t child);
478467int bus_print_child_footer(device_t dev, device_t child);
479468int bus_generic_print_child(device_t dev, device_t child);
480int bus_generic_probe(device_t dev);
469int bus_generic_probe(device_t dev)
470 __deprecated1("Use bus_identify_children instead");
481471int bus_generic_read_ivar(device_t dev, device_t child, int which,
482472 uintptr_t *result);
483473int bus_generic_release_resource(device_t bus, device_t child,
484 int type, int rid, struct resource *r);
474 struct resource *r);
485475int bus_generic_resume(device_t dev);
486476int bus_generic_resume_child(device_t dev, device_t child);
487477int bus_generic_setup_intr(device_t dev, device_t child,
......@@ -497,24 +487,20 @@ int bus_generic_rl_get_resource (device_t, device_t, int, int, rman_res_t *,
497487 rman_res_t *);
498488int bus_generic_rl_set_resource (device_t, device_t, int, int, rman_res_t,
499489 rman_res_t);
500int bus_generic_rl_release_resource (device_t, device_t, int, int,
501 struct resource *);
490int bus_generic_rl_release_resource (device_t, device_t, struct resource *);
502491struct resource *
503492 bus_generic_rman_alloc_resource(device_t dev, device_t child, int type,
504493 int *rid, rman_res_t start,
505494 rman_res_t end, rman_res_t count,
506495 u_int flags);
507int bus_generic_rman_adjust_resource(device_t dev, device_t child, int type,
496int bus_generic_rman_adjust_resource(device_t dev, device_t child,
508497 struct resource *r, rman_res_t start,
509498 rman_res_t end);
510499int bus_generic_rman_release_resource(device_t dev, device_t child,
511 int type, int rid,
512500 struct resource *r);
513501int bus_generic_rman_activate_resource(device_t dev, device_t child,
514 int type, int rid,
515502 struct resource *r);
516503int bus_generic_rman_deactivate_resource(device_t dev, device_t child,
517 int type, int rid,
518504 struct resource *r);
519505
520506int bus_generic_shutdown(device_t dev);
......@@ -526,7 +512,7 @@ int bus_generic_suspend_intr(device_t dev, device_t child,
526512 struct resource *irq);
527513int bus_generic_resume_intr(device_t dev, device_t child,
528514 struct resource *irq);
529int bus_generic_unmap_resource(device_t dev, device_t child, int type,
515int bus_generic_unmap_resource(device_t dev, device_t child,
530516 struct resource *r,
531517 struct resource_map *map);
532518int bus_generic_write_ivar(device_t dev, device_t child, int which,
......@@ -554,29 +540,26 @@ int bus_alloc_resources(device_t dev, struct resource_spec *rs,
554540void bus_release_resources(device_t dev, const struct resource_spec *rs,
555541 struct resource **res);
556542
557int bus_adjust_resource(device_t child, int type, struct resource *r,
543int bus_adjust_resource(device_t child, struct resource *r,
558544 rman_res_t start, rman_res_t end);
559545int bus_translate_resource(device_t child, int type, rman_res_t start,
560546 rman_res_t *newstart);
561547struct resource *bus_alloc_resource(device_t dev, int type, int *rid,
562548 rman_res_t start, rman_res_t end,
563549 rman_res_t count, u_int flags);
564int bus_activate_resource(device_t dev, int type, int rid,
565 struct resource *r);
566int bus_deactivate_resource(device_t dev, int type, int rid,
567 struct resource *r);
568int bus_map_resource(device_t dev, int type, struct resource *r,
550int bus_activate_resource(device_t dev, struct resource *r);
551int bus_deactivate_resource(device_t dev, struct resource *r);
552int bus_map_resource(device_t dev, struct resource *r,
569553 struct resource_map_request *args,
570554 struct resource_map *map);
571int bus_unmap_resource(device_t dev, int type, struct resource *r,
555int bus_unmap_resource(device_t dev, struct resource *r,
572556 struct resource_map *map);
573557int bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize,
574558 struct _cpuset *cpuset);
575559bus_dma_tag_t bus_get_dma_tag(device_t dev);
576560bus_space_tag_t bus_get_bus_tag(device_t dev);
577561int bus_get_domain(device_t dev, int *domain);
578int bus_release_resource(device_t dev, int type, int rid,
579 struct resource *r);
562int bus_release_resource(device_t dev, struct resource *r);
580563int bus_free_resource(device_t dev, int type, struct resource *r);
581564int bus_setup_intr(device_t dev, struct resource *r, int flags,
582565 driver_filter_t filter, driver_intr_t handler,
......@@ -597,8 +580,12 @@ void bus_delete_resource(device_t dev, int type, int rid);
597580int bus_child_present(device_t child);
598581int bus_child_pnpinfo(device_t child, struct sbuf *sb);
599582int bus_child_location(device_t child, struct sbuf *sb);
583
584void bus_attach_children(device_t dev);
585void bus_delayed_attach_children(device_t bus);
586int bus_detach_children(device_t dev);
600587void bus_enumerate_hinted_children(device_t bus);
601int bus_delayed_attach_children(device_t bus);
588void bus_identify_children(device_t dev);
602589
603590static __inline struct resource *
604591bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
......@@ -613,6 +600,47 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
613600 return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags));
614601}
615602
603/* Compat shims for simpler bus resource API. */
604int bus_adjust_resource_old(device_t child, int type, struct resource *r,
605 rman_res_t start, rman_res_t end);
606int bus_activate_resource_old(device_t dev, int type, int rid,
607 struct resource *r);
608int bus_deactivate_resource_old(device_t dev, int type, int rid,
609 struct resource *r);
610int bus_map_resource_old(device_t dev, int type, struct resource *r,
611 struct resource_map_request *args,
612 struct resource_map *map);
613int bus_unmap_resource_old(device_t dev, int type, struct resource *r,
614 struct resource_map *map);
615int bus_release_resource_old(device_t dev, int type, int rid,
616 struct resource *r);
617
618#define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
619
620#define bus_adjust_resource(...) \
621 _BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource_old, \
622 bus_adjust_resource)(__VA_ARGS__)
623
624#define bus_activate_resource(...) \
625 _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource_old, \
626 INVALID, bus_activate_resource)(__VA_ARGS__)
627
628#define bus_deactivate_resource(...) \
629 _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_deactivate_resource_old, \
630 INVALID, bus_deactivate_resource)(__VA_ARGS__)
631
632#define bus_map_resource(...) \
633 _BUS_API_MACRO(__VA_ARGS__, bus_map_resource_old, \
634 bus_map_resource)(__VA_ARGS__)
635
636#define bus_unmap_resource(...) \
637 _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_unmap_resource_old, \
638 bus_unmap_resource)(__VA_ARGS__)
639
640#define bus_release_resource(...) \
641 _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_release_resource_old, \
642 INVALID, bus_release_resource)(__VA_ARGS__)
643
616644/*
617645 * Access functions for device.
618646 */
......@@ -783,9 +811,7 @@ void bus_data_generation_update(void);
783811#define BUS_LOCATOR_UEFI "UEFI"
784812#define BUS_LOCATOR_OFW "OFW"
785813
786extern int bus_current_pass;
787
788void bus_set_pass(int pass);
814int bus_get_pass(void);
789815
790816/**
791817 * Routines to lock / unlock the newbus lock.
......@@ -824,24 +850,25 @@ struct driver_module_data {
824850 int dmd_pass;
825851};
826852
827#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \
853#define EARLY_DRIVER_MODULE_ORDERED(_name, busname, driver, evh, arg, \
828854 order, pass) \
829855 \
830static struct driver_module_data name##_##busname##_driver_mod = { \
831 evh, arg, \
832 #busname, \
833 (kobj_class_t) &driver, \
834 NULL, \
835 pass \
856static struct driver_module_data _name##_##busname##_driver_mod = { \
857 .dmd_chainevh = evh, \
858 .dmd_chainarg = arg, \
859 .dmd_busname = #busname, \
860 .dmd_driver = (kobj_class_t)&driver, \
861 .dmd_devclass = NULL, \
862 .dmd_pass = pass, \
836863}; \
837864 \
838static moduledata_t name##_##busname##_mod = { \
839 #busname "/" #name, \
840 driver_module_handler, \
841 &name##_##busname##_driver_mod \
865static moduledata_t _name##_##busname##_mod = { \
866 .name = #busname "/" #_name , \
867 .evhand = driver_module_handler, \
868 .priv = &_name##_##busname##_driver_mod, \
842869}; \
843DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \
844 SI_SUB_DRIVERS, order)
870DECLARE_MODULE(_name##_##busname, _name##_##busname##_mod, \
871 SI_SUB_DRIVERS, order)
845872
846873#define EARLY_DRIVER_MODULE(name, busname, driver, evh, arg, pass) \
847874 EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \
lib/libc/include/generic-freebsd/sys/bus_dma.h+2-5
......@@ -161,11 +161,8 @@ void _busdma_dflt_lock(void *arg, bus_dma_lock_op_t op);
161161 * boundary: Boundary that segments cannot cross.
162162 * lowaddr: Low restricted address that cannot appear in a mapping.
163163 * highaddr: High restricted address that cannot appear in a mapping.
164 * filtfunc: An optional function to further test if an address
165 * within the range of lowaddr and highaddr cannot appear
166 * in a mapping.
167 * filtfuncarg: An argument that will be passed to filtfunc in addition
168 * to the address to test.
164 * filtfunc: (deprecated, must be NULL)
165 * filtfuncarg: (deprecated, must be NULL)
169166 * maxsize: Maximum mapping size supported by this tag.
170167 * nsegments: Number of discontinuities allowed in maps.
171168 * maxsegsz: Maximum size of a segment in the map.
lib/libc/include/generic-freebsd/sys/callout.h+7-14
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)callout.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_CALLOUT_H_
......@@ -41,7 +39,7 @@
4139
4240#include <sys/_callout.h>
4341
44#define CALLOUT_LOCAL_ALLOC 0x0001 /* was allocated from callfree */
42#define CALLOUT_TRYLOCK 0x0001 /* try semantic in softclock_call_cc */
4543#define CALLOUT_ACTIVE 0x0002 /* callout is currently active */
4644#define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */
4745#define CALLOUT_MPSAFE 0x0008 /* deprecated */
......@@ -83,18 +81,15 @@
8381 */
8482#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE)
8583#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE)
86#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN, NULL)
84#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN)
8785void callout_init(struct callout *, int);
8886void _callout_init_lock(struct callout *, struct lock_object *, int);
8987#define callout_init_mtx(c, mtx, flags) \
90 _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \
91 NULL, (flags))
88 _callout_init_lock((c), &(mtx)->lock_object, (flags))
9289#define callout_init_rm(c, rm, flags) \
93 _callout_init_lock((c), ((rm) != NULL) ? &(rm)->lock_object : \
94 NULL, (flags))
90 _callout_init_lock((c), &(rm)->lock_object, (flags))
9591#define callout_init_rw(c, rw, flags) \
96 _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \
97 NULL, (flags))
92 _callout_init_lock((c), &(rw)->lock_object, (flags))
9893#define callout_pending(c) ((c)->c_iflags & CALLOUT_PENDING)
9994int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t,
10095 void (*)(void *), void *, int, int);
......@@ -121,11 +116,9 @@ int callout_schedule(struct callout *, int);
121116int callout_schedule_on(struct callout *, int, int);
122117#define callout_schedule_curcpu(c, on_tick) \
123118 callout_schedule_on((c), (on_tick), PCPU_GET(cpuid))
124#define callout_stop(c) _callout_stop_safe(c, 0, NULL)
125int _callout_stop_safe(struct callout *, int, void (*)(void *));
119#define callout_stop(c) _callout_stop_safe(c, 0)
120int _callout_stop_safe(struct callout *, int);
126121void callout_process(sbintime_t now);
127#define callout_async_drain(c, d) \
128 _callout_stop_safe(c, 0, d)
129122void callout_when(sbintime_t sbt, sbintime_t precision, int flags,
130123 sbintime_t *sbt_res, sbintime_t *prec_res);
131124#endif
lib/libc/include/generic-freebsd/sys/caprights.h+48-45
......@@ -58,51 +58,54 @@ typedef struct cap_rights cap_rights_t;
5858#endif
5959
6060#ifdef _KERNEL
61extern cap_rights_t cap_accept_rights;
62extern cap_rights_t cap_bind_rights;
63extern cap_rights_t cap_connect_rights;
64extern cap_rights_t cap_event_rights;
65extern cap_rights_t cap_fchdir_rights;
66extern cap_rights_t cap_fchflags_rights;
67extern cap_rights_t cap_fchmod_rights;
68extern cap_rights_t cap_fchown_rights;
69extern cap_rights_t cap_fcntl_rights;
70extern cap_rights_t cap_fexecve_rights;
71extern cap_rights_t cap_flock_rights;
72extern cap_rights_t cap_fpathconf_rights;
73extern cap_rights_t cap_fstat_rights;
74extern cap_rights_t cap_fstatfs_rights;
75extern cap_rights_t cap_fsync_rights;
76extern cap_rights_t cap_ftruncate_rights;
77extern cap_rights_t cap_futimes_rights;
78extern cap_rights_t cap_getpeername_rights;
79extern cap_rights_t cap_getsockopt_rights;
80extern cap_rights_t cap_getsockname_rights;
81extern cap_rights_t cap_ioctl_rights;
82extern cap_rights_t cap_linkat_source_rights;
83extern cap_rights_t cap_linkat_target_rights;
84extern cap_rights_t cap_listen_rights;
85extern cap_rights_t cap_mkdirat_rights;
86extern cap_rights_t cap_mkfifoat_rights;
87extern cap_rights_t cap_mknodat_rights;
88extern cap_rights_t cap_mmap_rights;
89extern cap_rights_t cap_no_rights;
90extern cap_rights_t cap_pdgetpid_rights;
91extern cap_rights_t cap_pdkill_rights;
92extern cap_rights_t cap_pread_rights;
93extern cap_rights_t cap_pwrite_rights;
94extern cap_rights_t cap_read_rights;
95extern cap_rights_t cap_recv_rights;
96extern cap_rights_t cap_renameat_source_rights;
97extern cap_rights_t cap_renameat_target_rights;
98extern cap_rights_t cap_seek_rights;
99extern cap_rights_t cap_send_rights;
100extern cap_rights_t cap_send_connect_rights;
101extern cap_rights_t cap_setsockopt_rights;
102extern cap_rights_t cap_shutdown_rights;
103extern cap_rights_t cap_symlinkat_rights;
104extern cap_rights_t cap_unlinkat_rights;
105extern cap_rights_t cap_write_rights;
61extern const cap_rights_t cap_accept_rights;
62extern const cap_rights_t cap_bind_rights;
63extern const cap_rights_t cap_connect_rights;
64extern const cap_rights_t cap_event_rights;
65extern const cap_rights_t cap_fchdir_rights;
66extern const cap_rights_t cap_fchflags_rights;
67extern const cap_rights_t cap_fchmod_rights;
68extern const cap_rights_t cap_fchown_rights;
69extern const cap_rights_t cap_fchroot_rights;
70extern const cap_rights_t cap_fcntl_rights;
71extern const cap_rights_t cap_fexecve_rights;
72extern const cap_rights_t cap_flock_rights;
73extern const cap_rights_t cap_fpathconf_rights;
74extern const cap_rights_t cap_fstat_rights;
75extern const cap_rights_t cap_fstatfs_rights;
76extern const cap_rights_t cap_fsync_rights;
77extern const cap_rights_t cap_ftruncate_rights;
78extern const cap_rights_t cap_futimes_rights;
79extern const cap_rights_t cap_getpeername_rights;
80extern const cap_rights_t cap_getsockopt_rights;
81extern const cap_rights_t cap_getsockname_rights;
82extern const cap_rights_t cap_inotify_add_rights;
83extern const cap_rights_t cap_inotify_rm_rights;
84extern const cap_rights_t cap_ioctl_rights;
85extern const cap_rights_t cap_linkat_source_rights;
86extern const cap_rights_t cap_linkat_target_rights;
87extern const cap_rights_t cap_listen_rights;
88extern const cap_rights_t cap_mkdirat_rights;
89extern const cap_rights_t cap_mkfifoat_rights;
90extern const cap_rights_t cap_mknodat_rights;
91extern const cap_rights_t cap_mmap_rights;
92extern const cap_rights_t cap_no_rights;
93extern const cap_rights_t cap_pdgetpid_rights;
94extern const cap_rights_t cap_pdkill_rights;
95extern const cap_rights_t cap_pread_rights;
96extern const cap_rights_t cap_pwrite_rights;
97extern const cap_rights_t cap_read_rights;
98extern const cap_rights_t cap_recv_rights;
99extern const cap_rights_t cap_renameat_source_rights;
100extern const cap_rights_t cap_renameat_target_rights;
101extern const cap_rights_t cap_seek_rights;
102extern const cap_rights_t cap_send_rights;
103extern const cap_rights_t cap_send_connect_rights;
104extern const cap_rights_t cap_setsockopt_rights;
105extern const cap_rights_t cap_shutdown_rights;
106extern const cap_rights_t cap_symlinkat_rights;
107extern const cap_rights_t cap_unlinkat_rights;
108extern const cap_rights_t cap_write_rights;
106109#endif
107110
108111#endif /* !_SYS_CAPRIGHTS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/capsicum.h+28-6
......@@ -39,7 +39,6 @@
3939#ifndef _SYS_CAPSICUM_H_
4040#define _SYS_CAPSICUM_H_
4141
42#include <sys/cdefs.h>
4342#include <sys/param.h>
4443
4544#include <sys/caprights.h>
......@@ -202,6 +201,9 @@
202201/* Allows for renameat(2) (target directory descriptor). */
203202#define CAP_RENAMEAT_TARGET (CAP_LOOKUP | 0x0000040000000000ULL)
204203
204/* Allows for fchroot(2). */
205#define CAP_FCHROOT CAPRIGHT(0, 0x0000080000000000ULL)
206
205207#define CAP_SOCK_CLIENT \
206208 (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
207209 CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
......@@ -211,11 +213,9 @@
211213 CAP_SETSOCKOPT | CAP_SHUTDOWN)
212214
213215/* All used bits for index 0. */
214#define CAP_ALL0 CAPRIGHT(0, 0x000007FFFFFFFFFFULL)
216#define CAP_ALL0 CAPRIGHT(0, 0x00000FFFFFFFFFFFULL)
215217
216218/* Available bits for index 0. */
217#define CAP_UNUSED0_44 CAPRIGHT(0, 0x0000080000000000ULL)
218/* ... */
219219#define CAP_UNUSED0_57 CAPRIGHT(0, 0x0100000000000000ULL)
220220
221221/* INDEX 1 */
......@@ -279,11 +279,15 @@
279279
280280#define CAP_KQUEUE (CAP_KQUEUE_EVENT | CAP_KQUEUE_CHANGE)
281281
282/* Allows operations on inotify descriptors. */
283#define CAP_INOTIFY_ADD CAPRIGHT(1, 0x0000000000200000ULL)
284#define CAP_INOTIFY_RM CAPRIGHT(1, 0x0000000000400000ULL)
285
282286/* All used bits for index 1. */
283#define CAP_ALL1 CAPRIGHT(1, 0x00000000001FFFFFULL)
287#define CAP_ALL1 CAPRIGHT(1, 0x00000000007FFFFFULL)
284288
285289/* Available bits for index 1. */
286#define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000200000ULL)
290#define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000800000ULL)
287291/* ... */
288292#define CAP_UNUSED1_57 CAPRIGHT(1, 0x0100000000000000ULL)
289293
......@@ -371,6 +375,24 @@ _Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00,
371375 _r; \
372376})
373377
378#define _CAP_RIGHTS_WORD_INITIALIZER(i, r) \
379 (CAPIDXBIT(r) == (i) + 1 ? (r) : 0ULL)
380
381/*
382 * Define a set of up to two rights at compile time.
383 */
384#define CAP_RIGHTS_INITIALIZER2(r1, r2) ((struct cap_rights){ \
385 .cr_rights = { \
386 [0] = ((uint64_t)CAP_RIGHTS_VERSION << 62) | \
387 _CAP_RIGHTS_WORD_INITIALIZER(0, r1) | \
388 _CAP_RIGHTS_WORD_INITIALIZER(0, r2), \
389 [1] = _CAP_RIGHTS_WORD_INITIALIZER(1, r1) | \
390 _CAP_RIGHTS_WORD_INITIALIZER(1, r2), \
391 }, \
392})
393#define CAP_RIGHTS_INITIALIZER(r) \
394 CAP_RIGHTS_INITIALIZER2(r, 0ULL)
395
374396/*
375397 * Allow checking caps which are possibly getting modified at the same time.
376398 * The caller is expected to determine whether the result is legitimate via
lib/libc/include/generic-freebsd/sys/cdefs.h+102-387
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
3533 */
3634
3735#ifndef _SYS_CDEFS_H_
......@@ -42,7 +40,10 @@
4240#endif
4341
4442/*
45 * Testing against Clang-specific extensions.
43 * Provide clang-compatible testing macros. All supported versions of gcc (10+)
44 * provide all of these except has_feature and has_extension which are new in
45 * gcc 14. Keep the older ifndefs, though, for non-gcc compilers that may lack
46 * them like tcc and pcc.
4647 */
4748#ifndef __has_attribute
4849#define __has_attribute(x) 0
......@@ -74,61 +75,34 @@
7475 * having a compiler-agnostic source tree.
7576 */
7677
78/*
79 * Macro to test if we're using a specific version of gcc or later.
80 */
7781#if defined(__GNUC__)
78
79#if __GNUC__ >= 3
80#define __GNUCLIKE_ASM 3
81#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
82#define __GNUC_PREREQ__(ma, mi) \
83 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
8284#else
83#define __GNUCLIKE_ASM 2
84#endif
85#define __GNUCLIKE___TYPEOF 1
86#define __GNUCLIKE___SECTION 1
87
88#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
89
90#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
91
92#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
93#define __GNUCLIKE_BUILTIN_VARARGS 1
94#define __GNUCLIKE_BUILTIN_STDARG 1
95#define __GNUCLIKE_BUILTIN_VAALIST 1
85#define __GNUC_PREREQ__(ma, mi) 0
9686#endif
9787
98#define __GNUC_VA_LIST_COMPATIBILITY 1
88#if defined(__GNUC__)
9989
10090/*
10191 * Compiler memory barriers, specific to gcc and clang.
10292 */
10393#define __compiler_membar() __asm __volatile(" " : : : "memory")
10494
105#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
106#define __GNUCLIKE_MATH_BUILTIN_RELOPS
107
108#define __GNUCLIKE_BUILTIN_MEMCPY 1
109
110/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
111#define __CC_SUPPORTS_INLINE 1
11295#define __CC_SUPPORTS___INLINE 1
113#define __CC_SUPPORTS___INLINE__ 1
114
115#define __CC_SUPPORTS___FUNC__ 1
116#define __CC_SUPPORTS_WARNING 1
117
118#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
119
120#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
96#define __CC_SUPPORTS_SYMVER 1
12197
12298#endif /* __GNUC__ */
12399
124100/*
125 * Macro to test if we're using a specific version of gcc or later.
101 * TinyC pretends to be gcc 9.3. This is generally good enough to support
102 * everything FreeBSD... except for the .symver assembler directive.
126103 */
127#if defined(__GNUC__)
128#define __GNUC_PREREQ__(ma, mi) \
129 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
130#else
131#define __GNUC_PREREQ__(ma, mi) 0
104#ifdef __TINYC__
105#undef __CC_SUPPORTS_SYMVER
132106#endif
133107
134108/*
......@@ -150,8 +124,6 @@
150124#define __STRING(x) #x /* stringify without expanding x */
151125#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
152126
153#define __const const /* define reserved names to standard */
154#define __signed signed
155127#define __volatile volatile
156128#if defined(__cplusplus)
157129#define __inline inline /* convert to C++ keyword */
......@@ -165,76 +137,32 @@
165137#define __P(protos) () /* traditional C preprocessor */
166138#define __CONCAT(x,y) x/**/y
167139#define __STRING(x) "x"
168
169140#if !defined(__CC_SUPPORTS___INLINE)
170#define __const /* delete pseudo-ANSI C keywords */
141/* Just delete these in a K&R environment */
171142#define __inline
172#define __signed
173143#define __volatile
174/*
175 * In non-ANSI C environments, new programs will want ANSI-only C keywords
176 * deleted from the program and old programs will want them left alone.
177 * When using a compiler other than gcc, programs using the ANSI C keywords
178 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
179 * When using "gcc -traditional", we assume that this is the intent; if
180 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
181 */
182#ifndef NO_ANSI_KEYWORDS
183#define const /* delete ANSI C keywords */
184#define inline
185#define signed
186#define volatile
187#endif /* !NO_ANSI_KEYWORDS */
188144#endif /* !__CC_SUPPORTS___INLINE */
189145#endif /* !(__STDC__ || __cplusplus) */
190146
191147/*
192 * Compiler-dependent macros to help declare dead (non-returning) and
193 * pure (no side effects) functions, and unused variables. They are
194 * null except for versions of gcc that are known to support the features
195 * properly (old versions of gcc-2 supported the dead and pure features
196 * in a different (wrong) way). If we do not provide an implementation
197 * for a given compiler, let the compile fail if it is told to use
198 * a feature that we cannot live without.
148 * Compiler-dependent macros to help declare dead (non-returning) and pure (no
149 * side effects) functions, and unused variables. These attributes are supported
150 * by all current compilers, even pcc.
199151 */
200152#define __weak_symbol __attribute__((__weak__))
201#if !__GNUC_PREREQ__(2, 5)
202#define __dead2
203#define __pure2
204#define __unused
205#endif
206#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
207#define __dead2 __attribute__((__noreturn__))
208#define __pure2 __attribute__((__const__))
209#define __unused
210/* XXX Find out what to do for __packed, __aligned and __section */
211#endif
212#if __GNUC_PREREQ__(2, 7)
213153#define __dead2 __attribute__((__noreturn__))
214154#define __pure2 __attribute__((__const__))
215155#define __unused __attribute__((__unused__))
216156#define __used __attribute__((__used__))
157#define __deprecated __attribute__((__deprecated__))
158#define __deprecated1(msg) __attribute__((__deprecated__(msg)))
217159#define __packed __attribute__((__packed__))
218160#define __aligned(x) __attribute__((__aligned__(x)))
219161#define __section(x) __attribute__((__section__(x)))
220#endif
221162#define __writeonly __unused
222#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
223163#define __alloc_size(x) __attribute__((__alloc_size__(x)))
224164#define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x)))
225#else
226#define __alloc_size(x)
227#define __alloc_size2(n, x)
228#endif
229#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
230165#define __alloc_align(x) __attribute__((__alloc_align__(x)))
231#else
232#define __alloc_align(x)
233#endif
234
235#if !__GNUC_PREREQ__(2, 95)
236#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
237#endif
238166
239167/*
240168 * Keywords added in C11.
......@@ -258,15 +186,6 @@
258186#define _Alignof(x) __alignof(x)
259187#endif
260188
261#if !defined(__cplusplus) && !__has_extension(c_atomic) && \
262 !__has_extension(cxx_atomic) && !__GNUC_PREREQ__(4, 7)
263/*
264 * No native support for _Atomic(). Place object in structure to prevent
265 * most forms of direct non-atomic access.
266 */
267#define _Atomic(T) struct { T volatile __val; }
268#endif
269
270189#if defined(__cplusplus) && __cplusplus >= 201103L
271190#define _Noreturn [[noreturn]]
272191#else
......@@ -281,12 +200,7 @@
281200#endif
282201
283202#if !__has_extension(c_thread_local)
284/*
285 * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
286 * without actually supporting the thread_local keyword. Don't check for
287 * the presence of C++11 when defining _Thread_local.
288 */
289#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
203#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
290204 __has_extension(cxx_thread_local)
291205#define _Thread_local thread_local
292206#else
......@@ -312,10 +226,10 @@
312226 __has_extension(c_generic_selections)
313227#define __generic(expr, t, yes, no) \
314228 _Generic(expr, t: yes, default: no)
315#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
229#elif !defined(__cplusplus)
316230#define __generic(expr, t, yes, no) \
317 __builtin_choose_expr( \
318 __builtin_types_compatible_p(__typeof((0, (expr))), t), yes, no)
231 __builtin_choose_expr(__builtin_types_compatible_p( \
232 __typeof(((void)0, (expr))), t), yes, no)
319233#endif
320234
321235/*
......@@ -326,59 +240,24 @@
326240 * void bar(int myArray[__min_size(10)]);
327241 */
328242#if !defined(__cplusplus) && \
329 (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
330243 (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
331244#define __min_size(x) static (x)
332245#else
333246#define __min_size(x) (x)
334247#endif
335248
336#if __GNUC_PREREQ__(2, 96)
337249#define __malloc_like __attribute__((__malloc__))
338250#define __pure __attribute__((__pure__))
339#else
340#define __malloc_like
341#define __pure
342#endif
343
344#if __GNUC_PREREQ__(3, 1)
345#define __always_inline __attribute__((__always_inline__))
346#else
347#define __always_inline
348#endif
349251
350#if __GNUC_PREREQ__(3, 1)
252#define __always_inline __inline __attribute__((__always_inline__))
351253#define __noinline __attribute__ ((__noinline__))
352#else
353#define __noinline
354#endif
355
356#if __GNUC_PREREQ__(3, 4)
357254#define __fastcall __attribute__((__fastcall__))
358255#define __result_use_check __attribute__((__warn_unused_result__))
359#else
360#define __fastcall
361#define __result_use_check
362#endif
363
364#if __GNUC_PREREQ__(4, 1)
365256#define __returns_twice __attribute__((__returns_twice__))
366#else
367#define __returns_twice
368#endif
369257
370#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
371258#define __unreachable() __builtin_unreachable()
372#else
373#define __unreachable() ((void)0)
374#endif
375259
376/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
377#if !__GNUC_PREREQ__(2, 7)
378#define __func__ NULL
379#endif
380
381#if (defined(__GNUC__) && __GNUC__ >= 2) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
260#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
382261#define __LONG_LONG_SUPPORTED
383262#endif
384263
......@@ -393,6 +272,55 @@
393272#endif
394273#endif
395274
275/*
276 * noexcept keyword added in C++11.
277 */
278#if defined(__cplusplus) && __cplusplus >= 201103L
279#define __noexcept noexcept
280#define __noexcept_if(__c) noexcept(__c)
281#else
282#define __noexcept
283#define __noexcept_if(__c)
284#endif
285
286/*
287 * nodiscard attribute added in C++17 and C23, but supported by both LLVM and
288 * GCC in earlier language versions, so we use __has_c{,pp}_attribute to test
289 * for it.
290 *
291 * __nodiscard may be used on a function:
292 * __nodiscard int f();
293 *
294 * or on a struct, union or enum:
295 * struct __nodiscard S{};
296 * struct S f();
297 *
298 * or in C++, on an object constructor.
299 */
300
301#if defined(__cplusplus) && defined(__has_cpp_attribute)
302#if __has_cpp_attribute(nodiscard)
303#define __nodiscard [[nodiscard]]
304#endif
305#elif defined(__STDC_VERSION__) && defined(__has_c_attribute)
306#if __has_c_attribute(__nodiscard__)
307#define __nodiscard [[__nodiscard__]]
308#endif
309#endif
310
311#ifndef __nodiscard
312/*
313 * LLVM 16 and earlier don't support [[nodiscard]] in C, but they do support
314 * __warn_unused_result__ with the same semantics, so fall back to that.
315 * We can't do this for GCC because the semantics are different.
316 */
317#ifdef __clang__
318#define __nodiscard __attribute__((__warn_unused_result__))
319#else
320#define __nodiscard
321#endif
322#endif
323
396324/*
397325 * We use `__restrict' as a way to define the `restrict' type qualifier
398326 * without disturbing older software that is unaware of C99 keywords.
......@@ -401,73 +329,27 @@
401329 */
402330#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901
403331#define __restrict restrict
404#elif !__GNUC_PREREQ__(2, 95)
405#define __restrict
406332#endif
407333
408334/*
409 * GNU C version 2.96 adds explicit branch prediction so that
410 * the CPU back-end can hint the processor and also so that
411 * code blocks can be reordered such that the predicted path
412 * sees a more linear flow, thus improving cache behavior, etc.
413 *
414 * The following two macros provide us with a way to utilize this
415 * compiler feature. Use __predict_true() if you expect the expression
416 * to evaluate to true, and __predict_false() if you expect the
417 * expression to evaluate to false.
418 *
419 * A few notes about usage:
420 *
421 * * Generally, __predict_false() error condition checks (unless
422 * you have some _strong_ reason to do otherwise, in which case
423 * document it), and/or __predict_true() `no-error' condition
424 * checks, assuming you want to optimize for the no-error case.
425 *
426 * * Other than that, if you don't know the likelihood of a test
427 * succeeding from empirical or other `hard' evidence, don't
428 * make predictions.
429 *
430 * * These are meant to be used in places that are run `a lot'.
431 * It is wasteful to make predictions in code that is run
432 * seldomly (e.g. at subsystem initialization time) as the
433 * basic block reordering that this affects can often generate
434 * larger code.
335 * All modern compilers have explicit branch prediction so that the CPU back-end
336 * can hint to the processor and also so that code blocks can be reordered such
337 * that the predicted path sees a more linear flow, thus improving cache
338 * behavior, etc. Use sparingly, except in performance critical code where
339 * they make things measurably faster.
435340 */
436#if __GNUC_PREREQ__(2, 96)
437341#define __predict_true(exp) __builtin_expect((exp), 1)
438342#define __predict_false(exp) __builtin_expect((exp), 0)
439#else
440#define __predict_true(exp) (exp)
441#define __predict_false(exp) (exp)
442#endif
443343
444#if __GNUC_PREREQ__(4, 0)
445344#define __null_sentinel __attribute__((__sentinel__))
446345#define __exported __attribute__((__visibility__("default")))
447346#define __hidden __attribute__((__visibility__("hidden")))
448#else
449#define __null_sentinel
450#define __exported
451#define __hidden
452#endif
453347
454348/*
455349 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
456350 * require it.
457351 */
458#if __GNUC_PREREQ__(4, 1)
459352#define __offsetof(type, field) __builtin_offsetof(type, field)
460#else
461#ifndef __cplusplus
462#define __offsetof(type, field) \
463 ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
464#else
465#define __offsetof(type, field) \
466 (__offsetof__ (reinterpret_cast <__size_t> \
467 (&reinterpret_cast <const volatile char &> \
468 (static_cast<type *> (0)->field))))
469#endif
470#endif
471353#define __rangeof(type, start, end) \
472354 (__offsetof(type, end) - __offsetof(type, start))
473355
......@@ -477,29 +359,15 @@
477359 * assign pointer x to a local variable, to check that its type is
478360 * compatible with member m.
479361 */
480#if __GNUC_PREREQ__(3, 1)
481362#define __containerof(x, s, m) ({ \
482363 const volatile __typeof(((s *)0)->m) *__x = (x); \
483364 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
484365})
485#else
486#define __containerof(x, s, m) \
487 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
488#endif
489366
490367/*
491368 * Compiler-dependent macros to declare that functions take printf-like
492 * or scanf-like arguments. They are null except for versions of gcc
493 * that are known to support the features properly (old versions of gcc-2
494 * didn't permit keeping the keywords out of the application namespace).
369 * or scanf-like arguments.
495370 */
496#if !__GNUC_PREREQ__(2, 7)
497#define __printflike(fmtarg, firstvararg)
498#define __scanflike(fmtarg, firstvararg)
499#define __format_arg(fmtarg)
500#define __strfmonlike(fmtarg, firstvararg)
501#define __strftimelike(fmtarg, firstvararg)
502#else
503371#define __printflike(fmtarg, firstvararg) \
504372 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
505373#define __scanflike(fmtarg, firstvararg) \
......@@ -509,18 +377,23 @@
509377 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
510378#define __strftimelike(fmtarg, firstvararg) \
511379 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
512#endif
513380
514/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
515#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
516 defined(__GNUC__)
381/*
382 * Like __printflike, but allows fmtarg to be NULL. FreeBSD invented 'printf0'
383 * for this because older versions of gcc issued warnings for NULL first args.
384 * Clang has always had printf and printf0 as aliases. gcc 11.0 now follows
385 * clang. So now this is an alias for __printflike, or nothing. In the future
386 * _Nullable or _Nonnull will replace this.
387 * XXX Except that doesn't work, so for now revert to printf0 for clang and
388 * the FreeBSD gcc until I can work this out.
389 */
390#if defined(__clang__) || (defined(__GNUC__) && defined (__FreeBSD_cc_version))
517391#define __printf0like(fmtarg, firstvararg) \
518392 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
519393#else
520394#define __printf0like(fmtarg, firstvararg)
521395#endif
522396
523#if defined(__GNUC__)
524397#define __strong_reference(sym,aliassym) \
525398 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
526399#ifdef __STDC__
......@@ -531,10 +404,12 @@
531404 __asm__(".section .gnu.warning." #sym); \
532405 __asm__(".asciz \"" msg "\""); \
533406 __asm__(".previous")
407#ifdef __CC_SUPPORTS_SYMVER
534408#define __sym_compat(sym,impl,verid) \
535409 __asm__(".symver " #impl ", " #sym "@" #verid)
536410#define __sym_default(sym,impl,verid) \
537411 __asm__(".symver " #impl ", " #sym "@@@" #verid)
412#endif
538413#else
539414#define __weak_reference(sym,alias) \
540415 __asm__(".weak alias"); \
......@@ -543,27 +418,18 @@
543418 __asm__(".section .gnu.warning.sym"); \
544419 __asm__(".asciz \"msg\""); \
545420 __asm__(".previous")
421#ifdef __CC_SUPPORTS_SYMVER
546422#define __sym_compat(sym,impl,verid) \
547423 __asm__(".symver impl, sym@verid")
548424#define __sym_default(impl,sym,verid) \
549425 __asm__(".symver impl, sym@@@verid")
426#endif
550427#endif /* __STDC__ */
551#endif /* __GNUC__ */
552428
553429#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))
554430#define __WEAK(sym) __asm__(".weak " __XSTRING(sym))
555431
556#if defined(__GNUC__)
557432#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
558#else
559/*
560 * The following definition might not work well if used in header files,
561 * but it should be better than nothing. If you want a "do nothing"
562 * version, then it should generate some harmless declaration, such as:
563 * #define __IDSTRING(name,string) struct __hack
564 */
565#define __IDSTRING(name,string) static const char name[] __unused = string
566#endif
567433
568434/*
569435 * Embed the rcs id of a source file in the resulting library. Note that in
......@@ -622,164 +488,13 @@
622488#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
623489#endif
624490
625/*-
626 * The following definitions are an extension of the behavior originally
627 * implemented in <sys/_posix.h>, but with a different level of granularity.
628 * POSIX.1 requires that the macros we test be defined before any standard
629 * header file is included.
630 *
631 * Here's a quick run-down of the versions (and some informal names)
632 * defined(_POSIX_SOURCE) 1003.1-1988
633 * encoded as 198808 below
634 * _POSIX_C_SOURCE == 1 1003.1-1990
635 * encoded as 199009 below
636 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
637 * encoded as 199209 below
638 * _POSIX_C_SOURCE == 199309 1003.1b-1993
639 * (1003.1 Issue 4, Single Unix Spec v1, Unix 93)
640 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
641 * and the omnibus ISO/IEC 9945-1: 1996
642 * (1003.1 Issue 5, Single Unix Spec v2, Unix 95)
643 * _POSIX_C_SOURCE == 200112 1003.1-2001 (1003.1 Issue 6, Unix 03)
644 * _POSIX_C_SOURCE == 200809 1003.1-2008 (1003.1 Issue 7)
645 * IEEE Std 1003.1-2017 (Rev of 1003.1-2008) is
646 * 1003.1-2008 with two TCs applied with
647 * _POSIX_C_SOURCE=200809 and _XOPEN_SOURCE=700
648 *
649 * In addition, the X/Open Portability Guide, which is now the Single UNIX
650 * Specification, defines a feature-test macro which indicates the version of
651 * that specification, and which subsumes _POSIX_C_SOURCE.
652 *
653 * Our macros begin with two underscores to avoid namespace screwage.
654 */
655
656/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
657#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
658#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
659#define _POSIX_C_SOURCE 199009
660#endif
661
662/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
663#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
664#undef _POSIX_C_SOURCE
665#define _POSIX_C_SOURCE 199209
666#endif
667
668/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
669#ifdef _XOPEN_SOURCE
670#if _XOPEN_SOURCE - 0 >= 700
671#define __XSI_VISIBLE 700
672#undef _POSIX_C_SOURCE
673#define _POSIX_C_SOURCE 200809
674#elif _XOPEN_SOURCE - 0 >= 600
675#define __XSI_VISIBLE 600
676#undef _POSIX_C_SOURCE
677#define _POSIX_C_SOURCE 200112
678#elif _XOPEN_SOURCE - 0 >= 500
679#define __XSI_VISIBLE 500
680#undef _POSIX_C_SOURCE
681#define _POSIX_C_SOURCE 199506
682#endif
491#if !defined(_STANDALONE) && !defined(_KERNEL)
492#define __RENAME(x) __asm(__STRING(x))
493#else /* _STANDALONE || _KERNEL */
494#define __RENAME(x) no renaming in kernel/standalone environment
683495#endif
684496
685/*
686 * Deal with all versions of POSIX. The ordering relative to the tests above is
687 * important.
688 */
689#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
690#define _POSIX_C_SOURCE 198808
691#endif
692#ifdef _POSIX_C_SOURCE
693#if _POSIX_C_SOURCE >= 200809
694#define __POSIX_VISIBLE 200809
695#define __ISO_C_VISIBLE 1999
696#elif _POSIX_C_SOURCE >= 200112
697#define __POSIX_VISIBLE 200112
698#define __ISO_C_VISIBLE 1999
699#elif _POSIX_C_SOURCE >= 199506
700#define __POSIX_VISIBLE 199506
701#define __ISO_C_VISIBLE 1990
702#elif _POSIX_C_SOURCE >= 199309
703#define __POSIX_VISIBLE 199309
704#define __ISO_C_VISIBLE 1990
705#elif _POSIX_C_SOURCE >= 199209
706#define __POSIX_VISIBLE 199209
707#define __ISO_C_VISIBLE 1990
708#elif _POSIX_C_SOURCE >= 199009
709#define __POSIX_VISIBLE 199009
710#define __ISO_C_VISIBLE 1990
711#else
712#define __POSIX_VISIBLE 198808
713#define __ISO_C_VISIBLE 0
714#endif /* _POSIX_C_SOURCE */
715/*
716 * Both glibc and OpenBSD enable c11 features when _ISOC11_SOURCE is defined, or
717 * when compiling with -stdc=c11. A strict reading of the standard would suggest
718 * doing it only for the former. However, a strict reading also requires C99
719 * mode only, so building with C11 is already undefined. Follow glibc's and
720 * OpenBSD's lead for this non-standard configuration for maximum compatibility.
721 */
722#if _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
723#undef __ISO_C_VISIBLE
724#define __ISO_C_VISIBLE 2011
725#endif
726#else
727/*-
728 * Deal with _ANSI_SOURCE:
729 * If it is defined, and no other compilation environment is explicitly
730 * requested, then define our internal feature-test macros to zero. This
731 * makes no difference to the preprocessor (undefined symbols in preprocessing
732 * expressions are defined to have value zero), but makes it more convenient for
733 * a test program to print out the values.
734 *
735 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
736 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
737 * environment (and in fact we will never get here).
738 */
739#if defined(_ANSI_SOURCE) /* Hide almost everything. */
740#define __POSIX_VISIBLE 0
741#define __XSI_VISIBLE 0
742#define __BSD_VISIBLE 0
743#define __ISO_C_VISIBLE 1990
744#define __EXT1_VISIBLE 0
745#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
746#define __POSIX_VISIBLE 0
747#define __XSI_VISIBLE 0
748#define __BSD_VISIBLE 0
749#define __ISO_C_VISIBLE 1999
750#define __EXT1_VISIBLE 0
751#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
752#define __POSIX_VISIBLE 0
753#define __XSI_VISIBLE 0
754#define __BSD_VISIBLE 0
755#define __ISO_C_VISIBLE 2011
756#define __EXT1_VISIBLE 0
757#else /* Default environment: show everything. */
758#define __POSIX_VISIBLE 200809
759#define __XSI_VISIBLE 700
760#define __BSD_VISIBLE 1
761#define __ISO_C_VISIBLE 2011
762#define __EXT1_VISIBLE 1
763#endif
764#endif
765
766/* User override __EXT1_VISIBLE */
767#if defined(__STDC_WANT_LIB_EXT1__)
768#undef __EXT1_VISIBLE
769#if __STDC_WANT_LIB_EXT1__
770#define __EXT1_VISIBLE 1
771#else
772#define __EXT1_VISIBLE 0
773#endif
774#endif /* __STDC_WANT_LIB_EXT1__ */
775
776/*
777 * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h
778 * translates them to __ARM_ARCH and the modern feature symbols defined by ARM.
779 */
780#if defined(__arm__) && !defined(__ARM_ARCH)
781#include <machine/acle-compat.h>
782#endif
497#include <sys/_visible.h>
783498
784499/*
785500 * Nullability qualifiers: currently only supported by Clang.
lib/libc/include/generic-freebsd/sys/cnv.h+1-7
......@@ -30,6 +30,7 @@
3030#define _CNV_H_
3131
3232#include <sys/cdefs.h>
33#include <sys/_nv.h>
3334
3435#ifndef _KERNEL
3536#include <stdarg.h>
......@@ -39,13 +40,6 @@
3940#include <sys/nv_namespace.h>
4041#endif
4142
42#ifndef _NVLIST_T_DECLARED
43#define _NVLIST_T_DECLARED
44struct nvlist;
45
46typedef struct nvlist nvlist_t;
47#endif
48
4943__BEGIN_DECLS
5044
5145/*
lib/libc/include/generic-freebsd/sys/compressor.h+1
......@@ -42,6 +42,7 @@ struct compressor;
4242bool compressor_avail(int format);
4343struct compressor *compressor_init(compressor_cb_t cb, int format,
4444 size_t maxiosize, int level, void *arg);
45int compressor_format(const struct compressor *stream);
4546void compressor_reset(struct compressor *stream);
4647int compressor_write(struct compressor *stream, void *data,
4748 size_t len);
lib/libc/include/generic-freebsd/sys/conf.h+4-2
......@@ -34,8 +34,6 @@
3434 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3535 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636 * SUCH DAMAGE.
37 *
38 * @(#)conf.h 8.5 (Berkeley) 1/9/95
3937 */
4038
4139#ifndef _SYS_CONF_H_
......@@ -46,6 +44,7 @@
4644#else
4745#include <sys/queue.h>
4846#endif
47#include <sys/_timespec.h>
4948
5049struct snapdata;
5150struct devfs_dirent;
......@@ -160,6 +159,7 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh);
160159#define GID_RT_PRIO 47
161160#define GID_ID_PRIO 48
162161#define GID_DIALER 68
162#define GID_U2F 116
163163#define GID_NOGROUP 65533
164164#define GID_NOBODY 65534
165165
......@@ -278,6 +278,7 @@ void destroy_dev(struct cdev *_dev);
278278int destroy_dev_sched(struct cdev *dev);
279279int destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg);
280280void destroy_dev_drain(struct cdevsw *csw);
281void dev_copyname(struct cdev *dev, char *path, size_t len);
281282struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref);
282283struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref);
283284void dev_relthread(struct cdev *_dev, int _ref);
......@@ -360,6 +361,7 @@ struct dumperinfo {
360361};
361362
362363extern int dumping; /* system is dumping */
364extern bool dumped_core; /* system successfully dumped kernel core */
363365
364366/*
365367 * Save registers for later extraction from a kernel dump.
lib/libc/include/generic-freebsd/sys/cons.h+2-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)cons.h 7.2 (Berkeley) 5/9/91
3735 */
3836
3937#ifndef _MACHINE_CONS_H_
......@@ -96,6 +94,8 @@ struct consdev {
9694
9795#ifdef _KERNEL
9896
97extern int cn_mute;
98
9999extern struct msgbuf consmsgbuf; /* Message buffer for constty. */
100100extern struct tty *constty; /* Temporary virtual console. */
101101
lib/libc/include/generic-freebsd/sys/copyright.h+2-2
......@@ -1,7 +1,7 @@
11/*-
22 * SPDX-License-Identifier: BSD-2-Clause
33 *
4 * Copyright (C) 1992-2023 The FreeBSD Project. All rights reserved.
4 * Copyright (C) 1992-2025 The FreeBSD Project. All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions
......@@ -35,7 +35,7 @@
3535
3636/* FreeBSD */
3737#define COPYRIGHT_FreeBSD \
38 "Copyright (c) 1992-2023 The FreeBSD Project.\n"
38 "Copyright (c) 1992-2025 The FreeBSD Project.\n"
3939
4040/* Foundation */
4141#define TRADEMARK_Foundation \
lib/libc/include/generic-freebsd/sys/counter.h+4-9
......@@ -60,17 +60,12 @@ uint64_t counter_u64_fetch(counter_u64_t);
6060 counter_u64_zero((a)[_i]); \
6161} while (0)
6262
63/*
64 * counter(9) based rate checking.
65 */
66struct counter_rate {
67 counter_u64_t cr_rate; /* Events since last second */
68 volatile int cr_lock; /* Lock to clean the struct */
69 int cr_ticks; /* Ticks on last clean */
70 int cr_over; /* Over limit since cr_ticks? */
71};
63struct counter_rate;
7264
65struct counter_rate *counter_rate_alloc(int flags, int period);
66void counter_rate_free(struct counter_rate *);
7367int64_t counter_ratecheck(struct counter_rate *, int64_t);
68uint64_t counter_rate_get(struct counter_rate *);
7469
7570#define COUNTER_U64_SYSINIT(c) \
7671 SYSINIT(c##_counter_sysinit, SI_SUB_COUNTER, \
lib/libc/include/generic-freebsd/sys/cpuset.h+2
......@@ -61,8 +61,10 @@
6161#define CPU_ANDNOT(d, s1, s2) __BIT_ANDNOT2(CPU_SETSIZE, d, s1, s2)
6262#define CPU_XOR(d, s1, s2) __BIT_XOR2(CPU_SETSIZE, d, s1, s2)
6363#define CPU_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(CPU_SETSIZE, n, p)
64#define CPU_TEST_CLR_ATOMIC(n, p) __BIT_TEST_CLR_ATOMIC(CPU_SETSIZE, n, p)
6465#define CPU_SET_ATOMIC(n, p) __BIT_SET_ATOMIC(CPU_SETSIZE, n, p)
6566#define CPU_SET_ATOMIC_ACQ(n, p) __BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p)
67#define CPU_TEST_SET_ATOMIC(n, p) __BIT_TEST_SET_ATOMIC(CPU_SETSIZE, n, p)
6668#define CPU_AND_ATOMIC(n, p) __BIT_AND_ATOMIC(CPU_SETSIZE, n, p)
6769#define CPU_OR_ATOMIC(d, s) __BIT_OR_ATOMIC(CPU_SETSIZE, d, s)
6870#define CPU_COPY_STORE_REL(f, t) __BIT_COPY_STORE_REL(CPU_SETSIZE, f, t)
lib/libc/include/generic-freebsd/sys/devicestat.h+1
......@@ -125,6 +125,7 @@ typedef enum {
125125 DEVSTAT_TYPE_IF_SCSI = 0x010,
126126 DEVSTAT_TYPE_IF_IDE = 0x020,
127127 DEVSTAT_TYPE_IF_OTHER = 0x030,
128 DEVSTAT_TYPE_IF_NVME = 0x040,
128129 DEVSTAT_TYPE_IF_MASK = 0x0f0,
129130 DEVSTAT_TYPE_PASS = 0x100
130131} devstat_type_flags;
lib/libc/include/generic-freebsd/sys/devmap.h+5-18
......@@ -33,6 +33,7 @@
3333#error "no user-serviceable parts inside"
3434#endif
3535
36#ifdef __HAVE_STATIC_DEVMAP
3637/*
3738 * This structure is used by MD code to describe static mappings of devices
3839 * which are established as part of bringing up the MMU early in the boot.
......@@ -71,27 +72,13 @@ void devmap_register_table(const struct devmap_entry * _table);
7172 * Establish mappings for all the entries in the table. This is called
7273 * automatically from the common platform-specific init function in
7374 * <ARCH>/machdep.c, and also from the custom platform-specific init routines
74 * in older code. If the table pointer is NULL, this will use the table
75 * installed previously by devmap_register_table().
75 * in older code. This function only has an effect when a table was installed
76 * previously by devmap_register_table().
7677 */
77void devmap_bootstrap(vm_offset_t _l1pt,
78 const struct devmap_entry *_table);
79
80/*
81 * Translate between virtual and physical addresses within a region that is
82 * static-mapped by the devmap code. If the given address range isn't
83 * static-mapped, then ptov returns NULL and vtop returns DEVMAP_PADDR_NOTFOUND.
84 * The latter implies that you can't vtop just the last byte of physical address
85 * space. This is not as limiting as it might sound, because even if a device
86 * occupies the end of the physical address space, you're only prevented from
87 * doing vtop for that single byte. If you vtop a size bigger than 1 it works.
88 */
89#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1))
90
91void * devmap_ptov(vm_paddr_t _pa, vm_size_t _sz);
92vm_paddr_t devmap_vtop(void * _va, vm_size_t _sz);
78void devmap_bootstrap(void);
9379
9480/* Print the static mapping table; used for bootverbose output. */
9581void devmap_print_table(void);
82#endif
9683
9784#endif /* !_SYS_DEVMAP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/dirent.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)dirent.h 8.3 (Berkeley) 8/10/94
3230 */
3331
3432#ifndef _SYS_DIRENT_H_
lib/libc/include/generic-freebsd/sys/disk.h+1-1
......@@ -78,7 +78,7 @@ void disk_err(struct bio *bp, const char *what, int blkdone, int nl);
7878 * only if they point at exactly the same physical storage, this is
7979 * the case for multipathing for example,
8080 * - GEOM classes that consumes single providers and provide single
81 * providers, like geli, gbde, should just attach class name to the
81 * providers, like geli, should just attach class name to the
8282 * ident of the underlying provider,
8383 * - ident is an ASCII string (is printable),
8484 * - ident is optional and applications can't relay on its presence.
lib/libc/include/generic-freebsd/sys/disk/bsd.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
3028 */
3129
3230#ifndef _SYS_DISK_BSD_H_
lib/libc/include/generic-freebsd/sys/disk/gpt.h+3
......@@ -259,6 +259,9 @@ CTASSERT(sizeof(struct gpt_ent) == 128);
259259#define GPT_ENT_TYPE_HIFIVE_BBL \
260260 {0x2e54b353,0x1271,0x4842,0x80,0x6f,{0xe4,0x36,0xd6,0xaf,0x69,0x85}}
261261
262#define GPT_ENT_TYPE_U_BOOT_ENV \
263 {0x3de21764,0x95bd,0x54bd,0xa5,0xc3,{0x4a,0xbe,0x78,0x6f,0x38,0xa8}}
264
262265/*
263266 * Boot partition used by GRUB 2.
264267 */
lib/libc/include/generic-freebsd/sys/disk/mbr.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
3028 */
3129
3230#ifndef _SYS_DISK_MBR_H_
lib/libc/include/generic-freebsd/sys/disklabel.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
3230 */
3331
3432#ifndef _SYS_DISKLABEL_H_
lib/libc/include/generic-freebsd/sys/diskmbr.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
3230 */
3331
3432#ifndef _SYS_DISKMBR_H_
lib/libc/include/generic-freebsd/sys/dkstat.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)dkstat.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_DKSTAT_H_
lib/libc/include/generic-freebsd/sys/dnv.h+1-7
......@@ -32,6 +32,7 @@
3232#define _DNV_H_
3333
3434#include <sys/cdefs.h>
35#include <sys/_nv.h>
3536
3637#ifndef _KERNEL
3738#include <stdarg.h>
......@@ -41,13 +42,6 @@
4142#include <sys/nv_namespace.h>
4243#endif
4344
44#ifndef _NVLIST_T_DECLARED
45#define _NVLIST_T_DECLARED
46struct nvlist;
47
48typedef struct nvlist nvlist_t;
49#endif
50
5145__BEGIN_DECLS
5246
5347/*
lib/libc/include/generic-freebsd/sys/domain.h-6
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)domain.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_DOMAIN_H_
......@@ -54,10 +52,6 @@ struct domain {
5452 char *dom_name;
5553 int dom_flags;
5654 int (*dom_probe)(void); /* check for support (optional) */
57 int (*dom_externalize) /* externalize access rights */
58 (struct mbuf *, struct mbuf **, int);
59 void (*dom_dispose) /* dispose of internalized rights */
60 (struct socket *);
6155 struct rib_head *(*dom_rtattach) /* initialize routing table */
6256 (uint32_t);
6357 void (*dom_rtdetach) /* clean up routing table */
lib/libc/include/generic-freebsd/sys/domainset.h+14
......@@ -113,6 +113,20 @@ void domainset_zero(void);
113113 * returned value will not match the key pointer.
114114 */
115115struct domainset *domainset_create(const struct domainset *);
116
117/*
118 * Remove empty domains from a given domainset.
119 * Returns 'false' if the domainset consists entirely of empty domains.
120 */
121bool domainset_empty_vm(struct domainset *domain);
122
123/*
124 * Validate and populate a domainset structure according to the specified
125 * policy and mask.
126 */
127int domainset_populate(struct domainset *domain, const domainset_t *mask, int policy,
128 size_t mask_size);
129
116130#ifdef _SYS_SYSCTL_H_
117131int sysctl_handle_domainset(SYSCTL_HANDLER_ARGS);
118132#endif
lib/libc/include/generic-freebsd/sys/efi.h+52-22
......@@ -35,15 +35,17 @@
3535#define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1)
3636
3737#define EFI_TABLE_SMBIOS \
38 {0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}}
38 {0xeb9d2d31,0x2d88,0x11d3,{0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}}
3939#define EFI_TABLE_SMBIOS3 \
40 {0xf2fd1544,0x9794,0x4a2c,0x99,0x2e,{0xe5,0xbb,0xcf,0x20,0xe3,0x94}}
40 {0xf2fd1544,0x9794,0x4a2c,{0x99,0x2e,0xe5,0xbb,0xcf,0x20,0xe3,0x94}}
4141#define EFI_TABLE_ESRT \
42 {0xb122a263,0x3661,0x4f68,0x99,0x29,{0x78,0xf8,0xb0,0xd6,0x21,0x80}}
42 {0xb122a263,0x3661,0x4f68,{0x99,0x29,0x78,0xf8,0xb0,0xd6,0x21,0x80}}
4343#define EFI_PROPERTIES_TABLE \
44 {0x880aaca3,0x4adc,0x4a04,0x90,0x79,{0xb7,0x47,0x34,0x08,0x25,0xe5}}
44 {0x880aaca3,0x4adc,0x4a04,{0x90,0x79,0xb7,0x47,0x34,0x08,0x25,0xe5}}
45#define EFI_MEMORY_ATTRIBUTES_TABLE \
46 {0xdcfa911d,0x26eb,0x469f,{0xa2,0x20,0x38,0xb7,0xdc,0x46,0x12,0x20}}
4547#define LINUX_EFI_MEMRESERVE_TABLE \
46 {0x888eb0c6,0x8ede,0x4ff5,0xa8,0xf0,{0x9a,0xee,0x5c,0xb9,0x77,0xc2}}
48 {0x888eb0c6,0x8ede,0x4ff5,{0xa8,0xf0,0x9a,0xee,0x5c,0xb9,0x77,0xc2}}
4749
4850enum efi_reset {
4951 EFI_RESET_COLD = 0,
......@@ -54,8 +56,20 @@ enum efi_reset {
5456typedef uint16_t efi_char;
5557typedef unsigned long efi_status;
5658
59/*
60 * This type-puns to a struct uuid, but all the EDK2 headers use this variation,
61 * and we use it in the loader to specify GUIDs. We define it here so that we
62 * can use EDK2 definitions both places.
63 */
64typedef struct efi_guid {
65 uint32_t Data1;
66 uint16_t Data2;
67 uint16_t Data3;
68 uint8_t Data4[8];
69} efi_guid_t; /* Type puns with GUID and EFI_GUID */
70
5771struct efi_cfgtbl {
58 struct uuid ct_uuid;
72 efi_guid_t ct_guid;
5973 void *ct_data;
6074};
6175
......@@ -139,7 +153,7 @@ struct efi_esrt_table {
139153};
140154
141155struct efi_esrt_entry_v1 {
142 struct uuid fw_class;
156 efi_guid_t fw_class;
143157 uint32_t fw_type;
144158 uint32_t fw_version;
145159 uint32_t lowest_supported_fw_version;
......@@ -154,6 +168,22 @@ struct efi_prop_table {
154168 uint64_t memory_protection_attribute;
155169};
156170
171struct efi_memory_descriptor {
172 uint32_t type;
173 caddr_t phy_addr;
174 caddr_t virt_addr;
175 uint64_t pages;
176 uint64_t attrs;
177};
178
179struct efi_memory_attribute_table {
180 uint32_t version;
181 uint32_t num_ents;
182 uint32_t descriptor_size;
183 uint32_t flags;
184 struct efi_memory_descriptor tables[];
185};
186
157187#ifdef _KERNEL
158188
159189#ifdef EFIABI_ATTR
......@@ -169,11 +199,11 @@ struct efi_rt {
169199 efi_status (*rt_setvirtual)(u_long, u_long, uint32_t,
170200 struct efi_md *) EFIABI_ATTR;
171201 efi_status (*rt_cvtptr)(u_long, void **) EFIABI_ATTR;
172 efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *,
202 efi_status (*rt_getvar)(efi_char *, efi_guid_t *, uint32_t *,
173203 u_long *, void *) EFIABI_ATTR;
174 efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *)
204 efi_status (*rt_scanvar)(u_long *, efi_char *, efi_guid_t *)
175205 EFIABI_ATTR;
176 efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t,
206 efi_status (*rt_setvar)(efi_char *, efi_guid_t *, uint32_t,
177207 u_long, void *) EFIABI_ATTR;
178208 efi_status (*rt_gethicnt)(uint32_t *) EFIABI_ATTR;
179209 efi_status (*rt_reset)(enum efi_reset, efi_status, u_long,
......@@ -246,8 +276,8 @@ struct efi_ops {
246276 * access them.
247277 */
248278 int (*rt_ok)(void);
249 int (*get_table)(struct uuid *, void **);
250 int (*copy_table)(struct uuid *, void **, size_t, size_t *);
279 int (*get_table)(efi_guid_t *, void **);
280 int (*copy_table)(efi_guid_t *, void **, size_t, size_t *);
251281 int (*get_time)(struct efi_tm *);
252282 int (*get_time_capabilities)(struct efi_tmcap *);
253283 int (*reset_system)(enum efi_reset);
......@@ -255,10 +285,10 @@ struct efi_ops {
255285 int (*get_waketime)(uint8_t *enabled, uint8_t *pending,
256286 struct efi_tm *tm);
257287 int (*set_waketime)(uint8_t enable, struct efi_tm *tm);
258 int (*var_get)(uint16_t *, struct uuid *, uint32_t *, size_t *,
288 int (*var_get)(uint16_t *, efi_guid_t *, uint32_t *, size_t *,
259289 void *);
260 int (*var_nextname)(size_t *, uint16_t *, struct uuid *);
261 int (*var_set)(uint16_t *, struct uuid *, uint32_t, size_t, void *);
290 int (*var_nextname)(size_t *, uint16_t *, efi_guid_t *);
291 int (*var_set)(uint16_t *, efi_guid_t *, uint32_t, size_t, void *);
262292};
263293extern const struct efi_ops *active_efi_ops;
264294
......@@ -271,21 +301,21 @@ static inline int efi_rt_ok(void)
271301 return (active_efi_ops->rt_ok());
272302}
273303
274static inline int efi_get_table(struct uuid *uuid, void **ptr)
304static inline int efi_get_table(efi_guid_t *guid, void **ptr)
275305{
276306
277307 if (active_efi_ops->get_table == NULL)
278308 return (ENXIO);
279 return (active_efi_ops->get_table(uuid, ptr));
309 return (active_efi_ops->get_table(guid, ptr));
280310}
281311
282static inline int efi_copy_table(struct uuid *uuid, void **buf,
312static inline int efi_copy_table(efi_guid_t *guid, void **buf,
283313 size_t buf_len, size_t *table_len)
284314{
285315
286316 if (active_efi_ops->copy_table == NULL)
287317 return (ENXIO);
288 return (active_efi_ops->copy_table(uuid, buf, buf_len, table_len));
318 return (active_efi_ops->copy_table(guid, buf, buf_len, table_len));
289319}
290320
291321static inline int efi_get_time(struct efi_tm *tm)
......@@ -335,7 +365,7 @@ static inline int efi_set_waketime(uint8_t enable, struct efi_tm *tm)
335365 return (active_efi_ops->set_waketime(enable, tm));
336366}
337367
338static inline int efi_var_get(uint16_t *name, struct uuid *vendor,
368static inline int efi_var_get(uint16_t *name, efi_guid_t *vendor,
339369 uint32_t *attrib, size_t *datasize, void *data)
340370{
341371
......@@ -345,7 +375,7 @@ static inline int efi_var_get(uint16_t *name, struct uuid *vendor,
345375}
346376
347377static inline int efi_var_nextname(size_t *namesize, uint16_t *name,
348 struct uuid *vendor)
378 efi_guid_t *vendor)
349379{
350380
351381 if (active_efi_ops->var_nextname == NULL)
......@@ -353,7 +383,7 @@ static inline int efi_var_nextname(size_t *namesize, uint16_t *name,
353383 return (active_efi_ops->var_nextname(namesize, name, vendor));
354384}
355385
356static inline int efi_var_set(uint16_t *name, struct uuid *vendor,
386static inline int efi_var_set(uint16_t *name, efi_guid_t *vendor,
357387 uint32_t attrib, size_t datasize, void *data)
358388{
359389
lib/libc/include/generic-freebsd/sys/efi_map.h created+24
......@@ -0,0 +1,24 @@
1/*
2 * Copyright (c) 2014 The FreeBSD Foundation
3 * Copyright (c) 2018 Andrew Turner
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7#ifndef _SYS_EFI_MAP_H_
8#define _SYS_EFI_MAP_H_
9
10#include <sys/efi.h>
11#include <machine/metadata.h>
12
13struct efi_map_header;
14
15typedef void (*efi_map_entry_cb)(struct efi_md *, void *argp);
16
17void efi_map_foreach_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb,
18 void *argp);
19
20void efi_map_add_entries(struct efi_map_header *efihdr);
21void efi_map_exclude_entries(struct efi_map_header *efihdr);
22void efi_map_print_entries(struct efi_map_header *efihdr);
23
24#endif /* !_SYS_EFI_MAP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/efiio.h+52-11
......@@ -30,38 +30,79 @@
3030#include <sys/uuid.h>
3131#include <sys/efi.h>
3232
33struct efi_get_table_ioc
33/*
34 * The EFI world chose not to use the typical uuid_t defines for its global
35 * universal identifiers. But the textual representation is the same, and we can
36 * use the uuid_* routines to parse and print them. However, all EFI interfaces
37 * for this need to be efi_guid_t so we can share code with EDK2, so the *_ioc
38 * structures in this file are converted to _ioctl structure to transition to
39 * this new requirement. This library is little used outside of FreeBSD and they
40 * will be dropped in 16.
41 */
42_Static_assert(sizeof(struct uuid) == sizeof(efi_guid_t),
43 "uuid_t and efi_guid_t are same bytes, but different elements");
44#if __FreeBSD_version < 1600000 && !defined(_KERNEL)
45#define _WANT_EFI_IOC
46#endif
47
48struct efi_get_table_ioctl
3449{
3550 void *buf; /* Pointer to userspace buffer */
36 struct uuid uuid; /* UUID to look up */
51 efi_guid_t guid; /* GUID to look up */
3752 size_t table_len; /* Table size */
3853 size_t buf_len; /* Size of the buffer */
3954};
4055
41struct efi_var_ioc
56struct efi_var_ioctl
4257{
4358 efi_char *name; /* User pointer to name, in wide chars */
4459 size_t namesize; /* Number of wide characters in name */
45 struct uuid vendor; /* Vendor's UUID for variable */
60 efi_guid_t vendor; /* Vendor's GUID for variable */
4661 uint32_t attrib; /* Attributes */
4762 void *data; /* User pointer to the data */
4863 size_t datasize; /* Number of *bytes* in the data */
4964};
5065
51struct efi_waketime_ioc
66struct efi_waketime_ioctl
5267{
5368 struct efi_tm waketime;
5469 uint8_t enabled;
5570 uint8_t pending;
5671};
5772
58#define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioc)
73#define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioctl)
5974#define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm)
6075#define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm)
61#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioc)
62#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioc)
63#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioc)
64#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioc)
65#define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioc)
76#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioctl)
77#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioctl)
78#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioctl)
79#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioctl)
80#define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioctl)
81
82#ifdef _WANT_EFI_IOC
83struct efi_get_table_ioc
84{
85 void *buf; /* Pointer to userspace buffer */
86 struct uuid uuid; /* GUID to look up */
87 size_t table_len; /* Table size */
88 size_t buf_len; /* Size of the buffer */
89};
90
91struct efi_var_ioc
92{
93 efi_char *name; /* User pointer to name, in wide chars */
94 size_t namesize; /* Number of wide characters in name */
95 struct uuid vendor; /* Vendor's GUID for variable */
96 uint32_t attrib; /* Attributes */
97 void *data; /* User pointer to the data */
98 size_t datasize; /* Number of *bytes* in the data */
99};
100
101_Static_assert(sizeof(struct efi_get_table_ioc) == sizeof(struct efi_get_table_ioctl),
102 "Old and new struct table defines must be the same size");
103_Static_assert(sizeof(struct efi_var_ioc) == sizeof(struct efi_var_ioctl),
104 "Old and new struct var defines must be the same size");
105#define efi_waketime_ioc efi_waketime_ioctl
106#endif
66107
67108#endif /* _SYS_EFIIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/elf_common.h+205-17
......@@ -306,6 +306,7 @@ typedef struct {
306306 and MPRC of Peking University */
307307#define EM_AARCH64 183 /* AArch64 (64-bit ARM) */
308308#define EM_RISCV 243 /* RISC-V */
309#define EM_LOONGARCH 258 /* Loongson LoongArch */
309310
310311/* Non-standard or deprecated. */
311312#define EM_486 6 /* Intel i486. */
......@@ -382,6 +383,25 @@ typedef struct {
382383#define EF_RISCV_RVE 0x00000008
383384#define EF_RISCV_TSO 0x00000010
384385
386/*
387 * Loongson LoongArch Specific e_flags
388 *
389 * Definitions from LoongArch ELF psABI v2.01.
390 * Reference: https://github.com/loongson/LoongArch-Documentation
391 * (commit hash 296de4def055c871809068e0816325a4ac04eb12)
392 */
393
394/* LoongArch Base ABI Modifiers */
395#define EF_LOONGARCH_ABI_SOFT_FLOAT 0x00000001
396#define EF_LOONGARCH_ABI_SINGLE_FLOAT 0x00000002
397#define EF_LOONGARCH_ABI_DOUBLE_FLOAT 0x00000003
398#define EF_LOONGARCH_ABI_MODIFIER_MASK 0x00000007
399
400/* LoongArch Object file ABI versions */
401#define EF_LOONGARCH_OBJABI_V0 0x00000000
402#define EF_LOONGARCH_OBJABI_V1 0x00000040
403#define EF_LOONGARCH_OBJABI_MASK 0x000000C0
404
385405#define EF_SPARC_EXT_MASK 0x00ffff00
386406#define EF_SPARC_32PLUS 0x00000100
387407#define EF_SPARC_SUN_US1 0x00000200
......@@ -450,12 +470,12 @@ typedef struct {
450470#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */
451471#define SHT_LOPROC 0x70000000 /* reserved range for processor */
452472#define SHT_X86_64_UNWIND 0x70000001 /* unwind information */
453#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND
473#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND
454474
455475#define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */
456#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking
476#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking
457477 pre-emption map. */
458#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility
478#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility
459479 attributes. */
460480#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */
461481#define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */
......@@ -534,8 +554,8 @@ typedef struct {
534554#define PT_GNU_EH_FRAME 0x6474e550
535555#define PT_GNU_STACK 0x6474e551
536556#define PT_GNU_RELRO 0x6474e552
537#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for kernel dumps
538 (currently arm). */
557#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for arm and amd64 kernel
558 dumps */
539559#define PT_LOSUNW 0x6ffffffa
540560#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
541561#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */
......@@ -770,7 +790,8 @@ typedef struct {
770790#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */
771791#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */
772792#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */
773#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */
793#define DF_1_INITFIRST 0x00000020 /* Initialize DSO first at runtime */
794#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */
774795#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */
775796#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */
776797#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */
......@@ -804,6 +825,7 @@ typedef struct {
804825#define NT_FREEBSD_FCTL_WXNEEDED 0x00000008
805826#define NT_FREEBSD_FCTL_LA48 0x00000010
806827/* was ASG_DISABLE, do not reuse 0x00000020 */
828#define NT_FREEBSD_FCTL_LA57 0x00000040
807829
808830/* Values for n_type. Used in core files. */
809831#define NT_PRSTATUS 1 /* Process status. */
......@@ -820,6 +842,7 @@ typedef struct {
820842#define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */
821843#define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */
822844#define NT_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */
845#define NT_PROCSTAT_KQUEUES 18 /* Procstat kqueues events. */
823846#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
824847#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
825848#define NT_X86_SEGBASES 0x200 /* x86 FS/GS base addresses. */
......@@ -885,7 +908,7 @@ typedef struct {
885908#define STV_ELIMINATE 0x6
886909
887910/* Architecture specific data - st_other */
888#define STO_AARCH64_VARIANT_PCS 0x80
911#define STO_AARCH64_VARIANT_PCS 0x80
889912
890913/* Special symbol table indexes. */
891914#define STN_UNDEF 0 /* Undefined symbol index. */
......@@ -991,8 +1014,11 @@ typedef struct {
9911014#define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */
9921015#define AT_USRSTACKBASE 35 /* Top of user stack */
9931016#define AT_USRSTACKLIM 36 /* Grow limit of user stack */
1017#define AT_CHERI_STATS 37 /* Reserved */
1018#define AT_HWCAP3 38 /* CPU feature flags 3. */
1019#define AT_HWCAP4 39 /* CPU feature flags 4. */
9941020
995#define AT_COUNT 37 /* Count of defined aux entry types. */
1021#define AT_COUNT 40 /* Count of defined aux entry types. */
9961022
9971023/*
9981024 * Relocation types.
......@@ -1058,11 +1084,11 @@ typedef struct {
10581084#define R_AARCH64_COPY 1024 /* Copy data from shared object */
10591085#define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */
10601086#define R_AARCH64_JUMP_SLOT 1026 /* Set GOT entry to code address */
1061#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */
1087#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */
10621088#define R_AARCH64_TLS_DTPREL64 1028
10631089#define R_AARCH64_TLS_DTPMOD64 1029
1064#define R_AARCH64_TLS_TPREL64 1030
1065#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */
1090#define R_AARCH64_TLS_TPREL64 1030
1091#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */
10661092#define R_AARCH64_IRELATIVE 1032
10671093
10681094#define R_ARM_NONE 0 /* No relocation. */
......@@ -1205,8 +1231,8 @@ typedef struct {
12051231#define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */
12061232#define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */
12071233#define R_MIPS_SUB 24
1208#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */
1209#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */
1234#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */
1235#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */
12101236#define R_MIPS_JALR 37
12111237#define R_MIPS_TLS_GD 42
12121238#define R_MIPS_COPY 126
......@@ -1326,7 +1352,6 @@ typedef struct {
13261352 * RISC-V relocation types.
13271353 */
13281354
1329/* Relocation types used by the dynamic linker. */
13301355#define R_RISCV_NONE 0
13311356#define R_RISCV_32 1
13321357#define R_RISCV_64 2
......@@ -1339,8 +1364,7 @@ typedef struct {
13391364#define R_RISCV_TLS_DTPREL64 9
13401365#define R_RISCV_TLS_TPREL32 10
13411366#define R_RISCV_TLS_TPREL64 11
1342
1343/* Relocation types not used by the dynamic linker. */
1367#define R_RISCV_TLSDESC 12
13441368#define R_RISCV_BRANCH 16
13451369#define R_RISCV_JAL 17
13461370#define R_RISCV_CALL 18
......@@ -1366,10 +1390,10 @@ typedef struct {
13661390#define R_RISCV_SUB16 38
13671391#define R_RISCV_SUB32 39
13681392#define R_RISCV_SUB64 40
1393#define R_RISCV_GOT32_PCREL 41
13691394#define R_RISCV_ALIGN 43
13701395#define R_RISCV_RVC_BRANCH 44
13711396#define R_RISCV_RVC_JUMP 45
1372#define R_RISCV_RVC_LUI 46
13731397#define R_RISCV_RELAX 51
13741398#define R_RISCV_SUB6 52
13751399#define R_RISCV_SET6 53
......@@ -1378,6 +1402,170 @@ typedef struct {
13781402#define R_RISCV_SET32 56
13791403#define R_RISCV_32_PCREL 57
13801404#define R_RISCV_IRELATIVE 58
1405#define R_RISCV_PLT32 59
1406#define R_RISCV_SET_ULEB128 60
1407#define R_RISCV_SUB_ULEB128 61
1408#define R_RISCV_TLSDESC_HI20 62
1409#define R_RISCV_TLSDESC_LOAD_LO12 63
1410#define R_RISCV_TLSDESC_ADD_LO12 64
1411#define R_RISCV_TLSDESC_CALL 65
1412#define R_RISCV_VENDOR 191
1413
1414/*
1415 * Loongson LoongArch relocation types.
1416 *
1417 * LoongArch ELF psABI: https://github.com/loongson/LoongArch-Documentation
1418 * (commit hash 9b3bd9f4a497115913c22f1a2a47863798fbc02a)
1419 */
1420
1421/* Relocation types used by the dynamic linker */
1422#define R_LARCH_NONE 0
1423#define R_LARCH_32 1
1424#define R_LARCH_64 2
1425#define R_LARCH_RELATIVE 3
1426#define R_LARCH_COPY 4
1427#define R_LARCH_JUMP_SLOT 5
1428#define R_LARCH_TLS_DTPMOD32 6
1429#define R_LARCH_TLS_DTPMOD64 7
1430#define R_LARCH_TLS_DTPREL32 8
1431#define R_LARCH_TLS_DTPREL64 9
1432#define R_LARCH_TLS_TPREL32 10
1433#define R_LARCH_TLS_TPREL64 11
1434#define R_LARCH_IRELATIVE 12
1435#define R_LARCH_MARK_LA 20
1436#define R_LARCH_MARK_PCREL 21
1437#define R_LARCH_SOP_PUSH_PCREL 22
1438#define R_LARCH_SOP_PUSH_ABSOLUTE 23
1439#define R_LARCH_SOP_PUSH_DUP 24
1440#define R_LARCH_SOP_PUSH_GPREL 25
1441#define R_LARCH_SOP_PUSH_TLS_TPREL 26
1442#define R_LARCH_SOP_PUSH_TLS_GOT 27
1443#define R_LARCH_SOP_PUSH_TLS_GD 28
1444#define R_LARCH_SOP_PUSH_PLT_PCREL 29
1445#define R_LARCH_SOP_ASSERT 30
1446#define R_LARCH_SOP_NOT 31
1447#define R_LARCH_SOP_SUB 32
1448#define R_LARCH_SOP_SL 33
1449#define R_LARCH_SOP_SR 34
1450#define R_LARCH_SOP_ADD 35
1451#define R_LARCH_SOP_AND 36
1452#define R_LARCH_SOP_IF_ELSE 37
1453#define R_LARCH_SOP_POP_32_S_10_5 38
1454#define R_LARCH_SOP_POP_32_U_10_12 39
1455#define R_LARCH_SOP_POP_32_S_10_12 40
1456#define R_LARCH_SOP_POP_32_S_10_16 41
1457#define R_LARCH_SOP_POP_32_S_10_16_S2 42
1458#define R_LARCH_SOP_POP_32_S_5_20 43
1459#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2 44
1460#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2 45
1461#define R_LARCH_SOP_POP_32_U 46
1462#define R_LARCH_ADD8 47
1463#define R_LARCH_ADD16 48
1464#define R_LARCH_ADD24 49
1465#define R_LARCH_ADD32 50
1466#define R_LARCH_ADD64 51
1467#define R_LARCH_SUB8 52
1468#define R_LARCH_SUB16 53
1469#define R_LARCH_SUB24 54
1470#define R_LARCH_SUB32 55
1471#define R_LARCH_SUB64 56
1472#define R_LARCH_GNU_VTINHERIT 57
1473#define R_LARCH_GNU_VTENTRY 58
1474
1475/*
1476 * Relocs whose processing do not require a stack machine.
1477 *
1478 * Spec addition: https://github.com/loongson/LoongArch-Documentation/pull/57
1479 */
1480#define R_LARCH_B16 64
1481#define R_LARCH_B21 65
1482#define R_LARCH_B26 66
1483#define R_LARCH_ABS_HI20 67
1484#define R_LARCH_ABS_LO12 68
1485#define R_LARCH_ABS64_LO20 69
1486#define R_LARCH_ABS64_HI12 70
1487#define R_LARCH_PCALA_HI20 71
1488#define R_LARCH_PCALA_LO12 72
1489#define R_LARCH_PCALA64_LO20 73
1490#define R_LARCH_PCALA64_HI12 74
1491#define R_LARCH_GOT_PC_HI20 75
1492#define R_LARCH_GOT_PC_LO12 76
1493#define R_LARCH_GOT64_PC_LO20 77
1494#define R_LARCH_GOT64_PC_HI12 78
1495#define R_LARCH_GOT_HI20 79
1496#define R_LARCH_GOT_LO12 80
1497#define R_LARCH_GOT64_LO20 81
1498#define R_LARCH_GOT64_HI12 82
1499#define R_LARCH_TLS_LE_HI20 83
1500#define R_LARCH_TLS_LE_LO12 84
1501#define R_LARCH_TLS_LE64_LO20 85
1502#define R_LARCH_TLS_LE64_HI12 86
1503#define R_LARCH_TLS_IE_PC_HI20 87
1504#define R_LARCH_TLS_IE_PC_LO12 88
1505#define R_LARCH_TLS_IE64_PC_LO20 89
1506#define R_LARCH_TLS_IE64_PC_HI12 90
1507#define R_LARCH_TLS_IE_HI20 91
1508#define R_LARCH_TLS_IE_LO12 92
1509#define R_LARCH_TLS_IE64_LO20 93
1510#define R_LARCH_TLS_IE64_HI12 94
1511#define R_LARCH_TLS_LD_PC_HI20 95
1512#define R_LARCH_TLS_LD_HI20 96
1513#define R_LARCH_TLS_GD_PC_HI20 97
1514#define R_LARCH_TLS_GD_HI20 98
1515#define R_LARCH_32_PCREL 99
1516#define R_LARCH_RELAX 100
1517
1518/*
1519 * Relocs added in ELF for the LoongArch™ Architecture v20230519, part of the
1520 * v2.10 LoongArch ABI specs.
1521 *
1522 * Spec addition: https://github.com/loongson/la-abi-specs/pull/1
1523 *
1524 * Note that the 101 and 104 relocation numbers are defined as R_LARCH_DELETE
1525 * and R_LARCH_CFA respectively in psABI 2.10. But they are marked as reserved
1526 * in psABI v2.20 because they were proved not necessary to be exposed outside
1527 * of the linker.
1528 */
1529#define R_LARCH_ALIGN 102
1530#define R_LARCH_PCREL20_S2 103
1531#define R_LARCH_ADD6 105
1532#define R_LARCH_SUB6 106
1533#define R_LARCH_ADD_ULEB128 107
1534#define R_LARCH_SUB_ULEB128 108
1535#define R_LARCH_64_PCREL 109
1536
1537/*
1538 * Relocs added in ELF for the LoongArch™ Architecture v20231102, part of the
1539 * v2.20 LoongArch ABI specs.
1540 *
1541 * Spec addition: https://github.com/loongson/la-abi-specs/pull/4
1542 */
1543#define R_LARCH_CALL36 110
1544
1545/*
1546 * Relocs added in ELF for the LoongArch™ Architecture v20231219, part of the
1547 * v2.30 LoongArch ABI specs.
1548 *
1549 * Spec addition: https://github.com/loongson/la-abi-specs/pull/5
1550 */
1551#define R_LARCH_TLS_DESC32 13
1552#define R_LARCH_TLS_DESC64 14
1553#define R_LARCH_TLS_DESC_PC_HI20 111
1554#define R_LARCH_TLS_DESC_PC_LO12 112
1555#define R_LARCH_TLS_DESC64_PC_LO20 113
1556#define R_LARCH_TLS_DESC64_PC_HI12 114
1557#define R_LARCH_TLS_DESC_HI20 115
1558#define R_LARCH_TLS_DESC_LO12 116
1559#define R_LARCH_TLS_DESC64_LO20 117
1560#define R_LARCH_TLS_DESC64_HI12 118
1561#define R_LARCH_TLS_DESC_LD 119
1562#define R_LARCH_TLS_DESC_CALL 120
1563#define R_LARCH_TLS_LE_HI20_R 121
1564#define R_LARCH_TLS_LE_ADD_R 122
1565#define R_LARCH_TLS_LE_LO12_R 123
1566#define R_LARCH_TLS_LD_PCREL20_S2 124
1567#define R_LARCH_TLS_GD_PCREL20_S2 125
1568#define R_LARCH_TLS_DESC_PCREL20_S2 126
13811569
13821570#define R_SPARC_NONE 0
13831571#define R_SPARC_8 1
lib/libc/include/generic-freebsd/sys/endian.h+3-1
......@@ -56,7 +56,9 @@ typedef __uint64_t uint64_t;
5656/*
5757 * Note: While tempting to try to avoid namespace pollution from this file,
5858 * several software packages assume these marcos are defined, even when it
59 * defines _POSIX_C_SOURCE to request an unpolluted namespace.
59 * defines _POSIX_C_SOURCE to request an unpolluted namespace. <sys/endian.h>
60 * is not defined by any version of POSIX.1, so we don't have to be
61 * careful. No POSIX.1 defined header file includes <sys/endian.h> on FreeBSD.
6062 */
6163
6264/*
lib/libc/include/generic-freebsd/sys/errno.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)errno.h 8.5 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_ERRNO_H_
lib/libc/include/generic-freebsd/sys/event.h+19-3
......@@ -45,7 +45,9 @@
4545#define EVFILT_USER (-11) /* User events */
4646#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */
4747#define EVFILT_EMPTY (-13) /* empty send socket buf */
48#define EVFILT_SYSCOUNT 13
48#define EVFILT_JAIL (-14) /* attached to struct prison */
49#define EVFILT_JAILDESC (-15) /* attached to jail descriptors */
50#define EVFILT_SYSCOUNT 15
4951
5052#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
5153#define EV_SET(kevp_, a, b, c, d, e, f) do { \
......@@ -101,7 +103,7 @@ struct freebsd11_kevent {
101103};
102104#endif
103105
104#if defined(_WANT_KEVENT32) || (defined(_KERNEL) && defined(__LP64__))
106#if defined(_WANT_KEVENT32) || defined(_KERNEL)
105107struct kevent32 {
106108 __uint32_t ident; /* identifier for this event */
107109 short filter; /* filter for event */
......@@ -205,10 +207,18 @@ struct freebsd11_kevent32 {
205207#define NOTE_PDATAMASK 0x000fffff /* mask for pid */
206208
207209/* additional flags for EVFILT_PROC */
208#define NOTE_TRACK 0x00000001 /* follow across forks */
210#define NOTE_TRACK 0x00000001 /* follow across fork/create */
209211#define NOTE_TRACKERR 0x00000002 /* could not track child */
210212#define NOTE_CHILD 0x00000004 /* am a child process */
211213
214/* data/hint flags for EVFILT_JAIL and EVFILT_JAILDESC */
215#define NOTE_JAIL_CHILD 0x80000000 /* child jail was created */
216#define NOTE_JAIL_SET 0x40000000 /* jail was modified */
217#define NOTE_JAIL_ATTACH 0x20000000 /* jail was attached to */
218#define NOTE_JAIL_REMOVE 0x10000000 /* jail was removed */
219#define NOTE_JAIL_MULTI 0x08000000 /* multiple child or attach */
220#define NOTE_JAIL_CTRLMASK 0xf0000000 /* mask for hint bits */
221
212222/* additional flags for EVFILT_TIMER */
213223#define NOTE_SECONDS 0x00000001 /* data is seconds */
214224#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */
......@@ -262,12 +272,17 @@ struct knlist {
262272#define EVENT_REGISTER 1
263273#define EVENT_PROCESS 2
264274
275struct kinfo_knote;
276struct proc;
277
265278struct filterops {
266279 int f_isfd; /* true if ident == filedescriptor */
267280 int (*f_attach)(struct knote *kn);
268281 void (*f_detach)(struct knote *kn);
269282 int (*f_event)(struct knote *kn, long hint);
270283 void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type);
284 int (*f_userdump)(struct proc *p, struct knote *kn,
285 struct kinfo_knote *kin);
271286};
272287
273288/*
......@@ -304,6 +319,7 @@ struct knote {
304319 struct proc *p_proc; /* proc pointer */
305320 struct kaiocb *p_aio; /* AIO job pointer */
306321 struct aioliojob *p_lio; /* LIO job pointer */
322 struct prison *p_prison; /* prison pointer */
307323 void *p_v; /* generic other pointer */
308324 } kn_ptr;
309325 const struct filterops *kn_fop;
lib/libc/include/generic-freebsd/sys/eventhandler.h+5
......@@ -326,4 +326,9 @@ struct ifaddr;
326326typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int);
327327EVENTHANDLER_DECLARE(rt_addrmsg, rt_addrmsg_fn);
328328
329/* Kernel environment variable change event */
330typedef void (*env_change_fn)(void *, const char *);
331EVENTHANDLER_DECLARE(setenv, env_change_fn);
332EVENTHANDLER_DECLARE(unsetenv, env_change_fn);
333
329334#endif /* _SYS_EVENTHANDLER_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/exec.h-22
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)exec.h 8.3 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_EXEC_H_
......@@ -59,16 +57,6 @@ struct ps_strings {
5957 unsigned int ps_nenvstr; /* the number of environment strings */
6058};
6159
62/* Coredump output parameters. */
63struct coredump_params {
64 off_t offset;
65 struct ucred *active_cred;
66 struct ucred *file_cred;
67 struct thread *td;
68 struct vnode *vp;
69 struct compressor *comp;
70};
71
7260struct image_params;
7361
7462struct execsw {
......@@ -107,16 +95,6 @@ int exec_unregister(const struct execsw *);
10795
10896enum uio_seg;
10997
110#define CORE_BUF_SIZE (16 * 1024)
111
112int core_write(struct coredump_params *, const void *, size_t, off_t,
113 enum uio_seg, size_t *);
114int core_output(char *, size_t, off_t, struct coredump_params *, void *);
115int sbuf_drain_core_output(void *, const char *, int);
116
117extern int coredump_pack_fileinfo;
118extern int coredump_pack_vmmapinfo;
119
12098/*
12199 * note: name##_mod cannot be const storage because the
122100 * linker_file_sysinit() function modifies _file in the
lib/libc/include/generic-freebsd/sys/exterr_cat.h created+25
......@@ -0,0 +1,25 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8 * under sponsorship from the FreeBSD Foundation.
9 */
10
11#ifndef _SYS_EXTERR_CAT_H_
12#define _SYS_EXTERR_CAT_H_
13
14#define EXTERR_CAT_MMAP 1
15#define EXTERR_CAT_FILEDESC 2
16#define EXTERR_KTRACE 3 /* To allow inclusion of this
17 file into kern_ktrace.c */
18#define EXTERR_CAT_FUSE 4
19#define EXTERR_CAT_INOTIFY 5
20#define EXTERR_CAT_GENIO 6
21#define EXTERR_CAT_BRIDGE 7
22#define EXTERR_CAT_SWAP 8
23#define EXTERR_CAT_VFSSYSCALL 9
24
25#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/exterrvar.h created+67
......@@ -0,0 +1,67 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8 * under sponsorship from the FreeBSD Foundation.
9 */
10
11#ifndef _SYS_EXTERRVAR_H_
12#define _SYS_EXTERRVAR_H_
13
14#include <sys/_exterr.h>
15#include <sys/_uexterror.h>
16#include <sys/exterr_cat.h>
17
18#define UEXTERROR_MAXLEN 256
19
20#define UEXTERROR_VER 0x10010002
21
22#define EXTERRCTL_ENABLE 1
23#define EXTERRCTL_DISABLE 2
24#define EXTERRCTL_UD 3
25
26#define EXTERRCTLF_FORCE 0x00000001
27
28#ifdef _KERNEL
29
30#ifndef EXTERR_CATEGORY
31#error "Specify error category before including sys/exterrvar.h"
32#endif
33
34#ifdef EXTERR_STRINGS
35#define SET_ERROR_MSG(mmsg) (mmsg)
36#else
37#define SET_ERROR_MSG(mmsg) NULL
38#endif
39
40#define _SET_ERROR2(eerror, mmsg, pp1, pp2) \
41 exterr_set(eerror, EXTERR_CATEGORY, SET_ERROR_MSG(mmsg), \
42 (uintptr_t)(pp1), (uintptr_t)(pp2), __LINE__)
43#define _SET_ERROR0(eerror, mmsg) _SET_ERROR2(eerror, mmsg, 0, 0)
44#define _SET_ERROR1(eerror, mmsg, pp1) _SET_ERROR2(eerror, mmsg, pp1, 0)
45
46#define _EXTERROR_MACRO(eerror, mmsg, _1, _2, NAME, ...) \
47 NAME
48#define EXTERROR(...) \
49 _EXTERROR_MACRO(__VA_ARGS__, _SET_ERROR2, _SET_ERROR1, \
50 _SET_ERROR0)(__VA_ARGS__)
51
52int exterr_set(int eerror, int category, const char *mmsg, uintptr_t pp1,
53 uintptr_t pp2, int line);
54int exterr_to_ue(struct thread *td, struct uexterror *ue);
55void ktrexterr(struct thread *td);
56
57#else /* _KERNEL */
58
59#include <sys/types.h>
60
61__BEGIN_DECLS
62int exterrctl(u_int op, u_int flags, void *ptr);
63__END_DECLS
64
65#endif /* _KERNEL */
66
67#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/fbio.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * @(#)fbio.h 8.2 (Berkeley) 10/30/93
3634 */
3735
3836#ifndef _SYS_FBIO_H_
lib/libc/include/generic-freebsd/sys/fcntl.h+31-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_FCNTL_H_
......@@ -142,8 +140,24 @@ typedef __pid_t pid_t;
142140#define O_DSYNC 0x01000000 /* POSIX data sync */
143141#if __BSD_VISIBLE
144142#define O_EMPTY_PATH 0x02000000
143#define O_NAMEDATTR 0x04000000 /* NFSv4 named attributes */
144#define O_XATTR O_NAMEDATTR /* Solaris compatibility */
145#endif
146
147#if __POSIX_VISIBLE >= 202405
148#define O_CLOFORK 0x08000000
145149#endif
146150
151/*
152 * !!! DANGER !!!
153 *
154 * There are very few bits left for O_* flags. Every bit we consume for
155 * local features is one bit we can't use for future source compatibility
156 * with other operating systems.
157 *
158 * All additions should be coordinated with srcmgr@.
159 */
160
147161/*
148162 * XXX missing O_RSYNC.
149163 */
......@@ -270,6 +284,16 @@ typedef __pid_t pid_t;
270284#define F_GET_SEALS 20
271285#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */
272286#define F_KINFO 22 /* Return kinfo_file for this fd */
287#endif /* __BSD_VISIBLE */
288
289#if __POSIX_VISIBLE >= 202405
290#define F_DUPFD_CLOFORK 23 /* Like F_DUPFD, but FD_CLOFORK is set */
291#endif
292
293#if __BSD_VISIBLE
294#define F_DUP3FD 24 /* Used with dup3() */
295
296#define F_DUP3FD_SHIFT 16 /* Shift used for F_DUP3FD */
273297
274298/* Seals (F_ADD_SEALS, F_GET_SEALS). */
275299#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */
......@@ -280,6 +304,11 @@ typedef __pid_t pid_t;
280304
281305/* file descriptor flags (F_GETFD, F_SETFD) */
282306#define FD_CLOEXEC 1 /* close-on-exec flag */
307#define FD_RESOLVE_BENEATH 2 /* all lookups relative to fd have
308 O_RESOLVE_BENEATH semantics */
309#if __POSIX_VISIBLE >= 202405
310#define FD_CLOFORK 4 /* close-on-fork flag */
311#endif
283312
284313/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
285314#define F_RDLCK 1 /* shared or read lock */
lib/libc/include/generic-freebsd/sys/file.h+34-26
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)file.h 8.3 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_FILE_H_
......@@ -39,13 +37,16 @@
3937#include <sys/fcntl.h>
4038#include <sys/unistd.h>
4139#else
42#include <sys/queue.h>
43#include <sys/refcount.h>
40#include <sys/errno.h>
4441#include <sys/_lock.h>
4542#include <sys/_mutex.h>
43#include <sys/_null.h>
44#include <sys/queue.h>
45#include <sys/refcount.h>
4646#include <vm/vm.h>
4747
4848struct filedesc;
49struct proc;
4950struct stat;
5051struct thread;
5152struct uio;
......@@ -70,6 +71,8 @@ struct nameidata;
7071#define DTYPE_PROCDESC 12 /* process descriptor */
7172#define DTYPE_EVENTFD 13 /* eventfd */
7273#define DTYPE_TIMERFD 14 /* timerfd */
74#define DTYPE_INOTIFY 15 /* inotify descriptor */
75#define DTYPE_JAILDESC 16 /* jail descriptor */
7376
7477#ifdef _KERNEL
7578
......@@ -85,6 +88,8 @@ struct ucred;
8588#define FOF_NEXTOFF_W 0x08 /* Also update f_nextoff[UIO_WRITE] */
8689#define FOF_NOUPDATE 0x10 /* Do not update f_offset */
8790off_t foffset_lock(struct file *fp, int flags);
91void foffset_lock_pair(struct file *fp1, off_t *off1p, struct file *fp2,
92 off_t *off2p, int flags);
8893void foffset_lock_uio(struct file *fp, struct uio *uio, int flags);
8994void foffset_unlock(struct file *fp, off_t val, int flags);
9095void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags);
......@@ -156,7 +161,7 @@ struct fileops {
156161 fo_fallocate_t *fo_fallocate;
157162 fo_fspacectl_t *fo_fspacectl;
158163 fo_cmp_t *fo_cmp;
159 fo_spare_t *fo_spares[7]; /* Spare slots */
164 fo_spare_t *fo_spares[8]; /* Spare slots */
160165 fo_flags_t fo_flags; /* DFLAG_* below */
161166};
162167
......@@ -188,11 +193,11 @@ struct file {
188193 volatile u_int f_flag; /* see fcntl.h */
189194 volatile u_int f_count; /* reference count */
190195 void *f_data; /* file descriptor specific data */
191 struct fileops *f_ops; /* File operations */
196 const struct fileops *f_ops; /* File operations */
192197 struct vnode *f_vnode; /* NULL or applicable vnode */
193198 struct ucred *f_cred; /* associated credentials. */
194199 short f_type; /* descriptor type */
195 short f_vnread_flags; /* (f) Sleep lock for f_offset */
200 short f_vflags; /* (f) Sleep lock flags for members */
196201 /*
197202 * DTYPE_VNODE specific fields.
198203 */
......@@ -215,8 +220,8 @@ struct file {
215220#define f_cdevpriv f_vnun.fvn_cdevpriv
216221#define f_advice f_vnun.fvn_advice
217222
218#define FOFFSET_LOCKED 0x1
219#define FOFFSET_LOCK_WAITING 0x2
223#define FILE_V_FOFFSET_LOCKED 0x0001
224#define FILE_V_FOFFSET_LOCK_WAITING 0x0002
220225#endif /* __BSD_VISIBLE */
221226
222227#endif /* _KERNEL || _WANT_FILE */
......@@ -248,24 +253,27 @@ struct xfile {
248253
249254#ifdef _KERNEL
250255
251extern struct fileops vnops;
252extern struct fileops badfileops;
253extern struct fileops path_fileops;
254extern struct fileops socketops;
256extern const struct fileops vnops;
257extern const struct fileops badfileops;
258extern const struct fileops path_fileops;
259extern const struct fileops socketops;
255260extern int maxfiles; /* kernel limit on number of open files */
256261extern int maxfilesperproc; /* per process limit on number of open files */
257262
258int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp);
259int fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp,
263int fget(struct thread *td, int fd, const cap_rights_t *rightsp,
264 struct file **fpp);
265int fget_mmap(struct thread *td, int fd, const cap_rights_t *rightsp,
260266 vm_prot_t *maxprotp, struct file **fpp);
261int fget_read(struct thread *td, int fd, cap_rights_t *rightsp,
267int fget_read(struct thread *td, int fd, const cap_rights_t *rightsp,
262268 struct file **fpp);
263int fget_write(struct thread *td, int fd, cap_rights_t *rightsp,
269int fget_write(struct thread *td, int fd, const cap_rights_t *rightsp,
264270 struct file **fpp);
265int fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp,
271int fget_fcntl(struct thread *td, int fd, const cap_rights_t *rightsp,
266272 int needfcntl, struct file **fpp);
267273int _fdrop(struct file *fp, struct thread *td);
268274int fget_remote(struct thread *td, struct proc *p, int fd, struct file **fpp);
275int fget_remote_foreach(struct thread *td, struct proc *p,
276 int (*fn)(struct proc *, int, struct file *, void *), void *arg);
269277
270278fo_rdwr_t invfo_rdwr;
271279fo_truncate_t invfo_truncate;
......@@ -283,19 +291,19 @@ fo_kqfilter_t vn_kqfilter_opath;
283291int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif);
284292int file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td);
285293
286void finit(struct file *, u_int, short, void *, struct fileops *);
287void finit_vnode(struct file *, u_int, void *, struct fileops *);
288int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp,
294void finit(struct file *, u_int, short, void *, const struct fileops *);
295void finit_vnode(struct file *, u_int, void *, const struct fileops *);
296int fgetvp(struct thread *td, int fd, const cap_rights_t *rightsp,
289297 struct vnode **vpp);
290int fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp,
298int fgetvp_exec(struct thread *td, int fd, const cap_rights_t *rightsp,
291299 struct vnode **vpp);
292int fgetvp_rights(struct thread *td, int fd, cap_rights_t *needrightsp,
300int fgetvp_rights(struct thread *td, int fd, const cap_rights_t *needrightsp,
293301 struct filecaps *havecaps, struct vnode **vpp);
294int fgetvp_read(struct thread *td, int fd, cap_rights_t *rightsp,
302int fgetvp_read(struct thread *td, int fd, const cap_rights_t *rightsp,
295303 struct vnode **vpp);
296int fgetvp_write(struct thread *td, int fd, cap_rights_t *rightsp,
304int fgetvp_write(struct thread *td, int fd, const cap_rights_t *rightsp,
297305 struct vnode **vpp);
298int fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, bool *fsearch);
306int fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, int *flagsp);
299307int fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp);
300308
301309static __inline __result_use_check bool
lib/libc/include/generic-freebsd/sys/filedesc.h+17-12
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_FILEDESC_H_
......@@ -150,6 +148,8 @@ struct filedesc_to_leader {
150148 * Per-process open flags.
151149 */
152150#define UF_EXCLOSE 0x01 /* auto-close on exec */
151#define UF_RESOLVE_BENEATH 0x02 /* lookups must be beneath this dir */
152#define UF_FOCLOSE 0x04 /* auto-close on fork */
153153
154154#ifdef _KERNEL
155155
......@@ -222,6 +222,7 @@ enum {
222222
223223/* Flags for kern_dup(). */
224224#define FDDUP_FLAG_CLOEXEC 0x1 /* Atomically set UF_EXCLOSE. */
225#define FDDUP_FLAG_CLOFORK 0x2 /* Atomically set UF_FOCLOSE. */
225226
226227/* For backward compatibility. */
227228#define falloc(td, resultfp, resultfd, flags) \
......@@ -277,22 +278,26 @@ struct filedesc_to_leader *
277278struct filedesc_to_leader *
278279 filedesc_to_leader_share(struct filedesc_to_leader *fdtol,
279280 struct filedesc *fdp);
280int getvnode(struct thread *td, int fd, cap_rights_t *rightsp,
281 struct file **fpp);
282int getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp,
281int getvnode(struct thread *td, int fd, const cap_rights_t *rightsp,
283282 struct file **fpp);
283int getvnode_path(struct thread *td, int fd, const cap_rights_t *rightsp,
284 uint8_t *flagsp, struct file **fpp);
284285void mountcheckdirs(struct vnode *olddp, struct vnode *newdp);
285286
286int fget_cap_noref(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
287 struct file **fpp, struct filecaps *havecapsp);
288int fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
289 struct file **fpp, struct filecaps *havecapsp);
287int fget_cap_noref(struct filedesc *fdp, int fd,
288 const cap_rights_t *needrightsp, struct file **fpp,
289 struct filecaps *havecapsp);
290int fget_cap(struct thread *td, int fd, const cap_rights_t *needrightsp,
291 uint8_t *flagsp, struct file **fpp, struct filecaps *havecapsp);
290292/* Return a referenced file from an unlocked descriptor. */
291int fget_unlocked(struct thread *td, int fd, cap_rights_t *needrightsp,
293int fget_unlocked(struct thread *td, int fd,
294 const cap_rights_t *needrightsp, struct file **fpp);
295int fget_unlocked_flags(struct thread *td, int fd,
296 const cap_rights_t *needrightsp, uint8_t *flagsp,
292297 struct file **fpp);
293298/* Return a file pointer without a ref. FILEDESC_IS_ONLY_USER must be true. */
294int fget_only_user(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
295 struct file **fpp);
299int fget_only_user(struct filedesc *fdp, int fd,
300 const cap_rights_t *needrightsp, struct file **fpp);
296301#define fput_only_user(fdp, fp) ({ \
297302 MPASS(FILEDESC_IS_ONLY_USER(fdp)); \
298303 MPASS(refcount_load(&fp->f_count) > 0); \
lib/libc/include/generic-freebsd/sys/filio.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)filio.h 8.1 (Berkeley) 3/28/94
3735 */
3836
3937#ifndef _SYS_FILIO_H_
lib/libc/include/generic-freebsd/sys/gmon.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)gmon.h 8.2 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _SYS_GMON_H_
lib/libc/include/generic-freebsd/sys/hwt.h created+129
......@@ -0,0 +1,129 @@
1/*-
2 * Copyright (c) 2023-2025 Ruslan Bukin <br@bsdpad.com>
3 *
4 * This work was supported by Innovate UK project 105694, "Digital Security
5 * by Design (DSbD) Technology Platform Prototype".
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29/* User-visible header. */
30
31#include <sys/param.h>
32#include <sys/cpuset.h>
33#include <sys/types.h>
34#include <sys/hwt_record.h>
35
36#ifndef _SYS_HWT_H_
37#define _SYS_HWT_H_
38
39#define HWT_MAGIC 0x42
40#define HWT_IOC_ALLOC _IOW(HWT_MAGIC, 0x00, struct hwt_alloc)
41#define HWT_IOC_START _IOW(HWT_MAGIC, 0x01, struct hwt_start)
42#define HWT_IOC_STOP _IOW(HWT_MAGIC, 0x02, struct hwt_stop)
43#define HWT_IOC_RECORD_GET _IOW(HWT_MAGIC, 0x03, struct hwt_record_get)
44#define HWT_IOC_BUFPTR_GET _IOW(HWT_MAGIC, 0x04, struct hwt_bufptr_get)
45#define HWT_IOC_SET_CONFIG _IOW(HWT_MAGIC, 0x05, struct hwt_set_config)
46#define HWT_IOC_WAKEUP _IOW(HWT_MAGIC, 0x06, struct hwt_wakeup)
47#define HWT_IOC_SVC_BUF _IOW(HWT_MAGIC, 0x07, struct hwt_svc_buf)
48
49#define HWT_BACKEND_MAXNAMELEN 256
50
51#define HWT_MODE_THREAD 1
52#define HWT_MODE_CPU 2
53
54struct hwt_alloc {
55 size_t bufsize;
56 int mode;
57 pid_t pid; /* thread mode */
58 cpuset_t *cpu_map; /* cpu mode only */
59 size_t cpusetsize;
60 const char *backend_name;
61 int *ident;
62 int kqueue_fd;
63} __aligned(16);
64
65struct hwt_start {
66 int reserved;
67} __aligned(16);
68
69struct hwt_stop {
70 int reserved;
71} __aligned(16);
72
73struct hwt_wakeup {
74 int reserved;
75} __aligned(16);
76
77struct hwt_record_user_entry {
78 enum hwt_record_type record_type;
79 union {
80 /*
81 * Used for MMAP, EXECUTABLE, INTERP,
82 * and KERNEL records.
83 */
84 struct {
85 char fullpath[MAXPATHLEN];
86 uintptr_t addr;
87 uintptr_t baseaddr;
88 };
89 /* Used for BUFFER records. */
90 struct {
91 int buf_id;
92 int curpage;
93 vm_offset_t offset;
94 };
95 /* Used for THREAD_* records. */
96 int thread_id;
97 };
98} __aligned(16);
99
100struct hwt_record_get {
101 struct hwt_record_user_entry *records;
102 int *nentries;
103 int wait;
104} __aligned(16);
105
106struct hwt_bufptr_get {
107 int *ident;
108 vm_offset_t *offset;
109 uint64_t *data;
110} __aligned(16);
111
112struct hwt_set_config {
113 /* Configuration of ctx. */
114 int pause_on_mmap;
115
116 /* The following passed to backend as is. */
117 void *config;
118 size_t config_size;
119 int config_version;
120} __aligned(16);
121
122struct hwt_svc_buf {
123 /* The following passed to backend as is. */
124 void *data;
125 size_t data_size;
126 int data_version;
127} __aligned(16);
128
129#endif /* !_SYS_HWT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/hwt_record.h created+70
......@@ -0,0 +1,70 @@
1/*-
2 * Copyright (c) 2023-2025 Ruslan Bukin <br@bsdpad.com>
3 *
4 * This work was supported by Innovate UK project 105694, "Digital Security
5 * by Design (DSbD) Technology Platform Prototype".
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29/* User-visible header. */
30
31#ifndef _SYS_HWT_RECORD_H_
32#define _SYS_HWT_RECORD_H_
33
34enum hwt_record_type {
35 HWT_RECORD_MMAP,
36 HWT_RECORD_MUNMAP,
37 HWT_RECORD_EXECUTABLE,
38 HWT_RECORD_KERNEL,
39 HWT_RECORD_THREAD_CREATE,
40 HWT_RECORD_THREAD_SET_NAME,
41 HWT_RECORD_BUFFER
42};
43
44#ifdef _KERNEL
45struct hwt_record_entry {
46 TAILQ_ENTRY(hwt_record_entry) next;
47 enum hwt_record_type record_type;
48 union {
49 /*
50 * Used for MMAP, EXECUTABLE, INTERP,
51 * and KERNEL records.
52 */
53 struct {
54 char *fullpath;
55 uintptr_t addr;
56 uintptr_t baseaddr;
57 };
58 /* Used for BUFFER records. */
59 struct {
60 int buf_id;
61 int curpage;
62 vm_offset_t offset;
63 };
64 /* Used for THREAD_* records. */
65 int thread_id;
66 };
67};
68#endif
69
70#endif /* !_SYS_HWT_RECORD_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/imgact.h+1-2
......@@ -119,8 +119,7 @@ int exec_map_stack(struct image_params *);
119119int exec_new_vmspace(struct image_params *, struct sysentvec *);
120120void exec_setregs(struct thread *, struct image_params *, uintptr_t);
121121int exec_shell_imgact(struct image_params *);
122int exec_copyin_args(struct image_args *, const char *, enum uio_seg,
123 char **, char **);
122int exec_copyin_args(struct image_args *, const char *, char **, char **);
124123int pre_execve(struct thread *td, struct vmspace **oldvmspace);
125124void post_execve(struct thread *td, int error, struct vmspace *oldvmspace);
126125#endif
lib/libc/include/generic-freebsd/sys/imgact_aout.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)exec.h 8.1 (Berkeley) 6/11/93
3230 */
3331
3432#ifndef _IMGACT_AOUT_H_
lib/libc/include/generic-freebsd/sys/imgact_elf.h+7-6
......@@ -45,6 +45,7 @@
4545 {(pos)->a_type = (id); (pos)->a_un.a_ptr = (ptr); (pos)++;}
4646#endif
4747
48struct coredump_writer;
4849struct image_params;
4950struct thread;
5051struct vnode;
......@@ -86,8 +87,8 @@ typedef struct {
8687 const char *interp_newpath;
8788 int flags;
8889 Elf_Brandnote *brand_note;
89 bool (*header_supported)(struct image_params *,
90 int32_t *, uint32_t *);
90 bool (*header_supported)(const struct image_params *,
91 const int32_t *, const uint32_t *);
9192 /* High 8 bits of flags is private to the ABI */
9293#define BI_CAN_EXEC_DYN 0x0001
9394#define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */
......@@ -114,7 +115,7 @@ bool __elfN(brand_inuse)(Elf_Brandinfo *entry);
114115int __elfN(insert_brand_entry)(Elf_Brandinfo *entry);
115116int __elfN(remove_brand_entry)(Elf_Brandinfo *entry);
116117int __elfN(freebsd_fixup)(uintptr_t *, struct image_params *);
117int __elfN(coredump)(struct thread *, struct vnode *, off_t, int);
118int __elfN(coredump)(struct thread *, struct coredump_writer *, off_t, int);
118119size_t __elfN(populate_note)(int, void *, void *, size_t, void **);
119120int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t);
120121void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int);
......@@ -123,9 +124,9 @@ void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
123124void __elfN(size_segments)(struct thread *, struct sseg_closure *, int);
124125size_t __elfN(register_note)(struct thread *, struct note_info_list *,
125126 int, outfunc_t, void *);
126bool __elfN(parse_notes)(struct image_params *, Elf_Note *, const char *,
127 const Elf_Phdr *, bool (*)(const Elf_Note *, void *, bool *),
128 void *);
127bool __elfN(parse_notes)(const struct image_params *, const Elf_Note *,
128 const char *, const Elf_Phdr *,
129 bool (*)(const Elf_Note *, void *, bool *), void *);
129130
130131/* Machine specific function to dump per-thread information. */
131132void __elfN(dump_thread)(struct thread *, void *, size_t *);
lib/libc/include/generic-freebsd/sys/inotify.h created+158
......@@ -0,0 +1,158 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 Klara, Inc.
5 */
6
7#ifndef _INOTIFY_H_
8#define _INOTIFY_H_
9
10#include <sys/_types.h>
11
12/* Flags for inotify_init1(). */
13#define IN_NONBLOCK 0x00000004 /* O_NONBLOCK */
14#define IN_CLOEXEC 0x00100000 /* O_CLOEXEC */
15
16struct inotify_event {
17 int wd;
18 __uint32_t mask;
19 __uint32_t cookie;
20 __uint32_t len;
21 char name[0];
22};
23
24/* Events, set in the mask field. */
25#define IN_ACCESS 0x00000001
26#define IN_MODIFY 0x00000002
27#define IN_ATTRIB 0x00000004
28#define IN_CLOSE_WRITE 0x00000008
29#define IN_CLOSE_NOWRITE 0x00000010
30#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
31#define IN_OPEN 0x00000020
32#define IN_MOVED_FROM 0x00000040
33#define IN_MOVED_TO 0x00000080
34#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
35#define IN_CREATE 0x00000100
36#define IN_DELETE 0x00000200
37#define IN_DELETE_SELF 0x00000400
38#define IN_MOVE_SELF 0x00000800
39#define IN_ALL_EVENTS 0x00000fff
40
41/* Events report only for entries in a watched dir, not the dir itself. */
42#define _IN_DIR_EVENTS (IN_CLOSE_WRITE | IN_DELETE | IN_MODIFY | \
43 IN_MOVED_FROM | IN_MOVED_TO)
44
45#ifdef _KERNEL
46/*
47 * An unlink that's done as part of a rename only records IN_DELETE if the
48 * unlinked vnode itself is watched, and not when the containing directory is
49 * watched.
50 */
51#define _IN_MOVE_DELETE 0x40000000
52/*
53 * Inode link count changes only trigger IN_ATTRIB events if the inode itself is
54 * watched, and not when the containing directory is watched.
55 */
56#define _IN_ATTRIB_LINKCOUNT 0x80000000
57#endif
58
59/* Flags, set in the mask field. */
60#define IN_ONLYDIR 0x01000000
61#define IN_DONT_FOLLOW 0x02000000
62#define IN_EXCL_UNLINK 0x04000000
63#define IN_MASK_CREATE 0x10000000
64#define IN_MASK_ADD 0x20000000
65#define IN_ONESHOT 0x80000000
66#define _IN_ALL_FLAGS (IN_ONLYDIR | IN_DONT_FOLLOW | \
67 IN_EXCL_UNLINK | IN_MASK_CREATE | \
68 IN_MASK_ADD | IN_ONESHOT)
69
70/* Flags returned by the kernel. */
71#define IN_UNMOUNT 0x00002000
72#define IN_Q_OVERFLOW 0x00004000
73#define IN_IGNORED 0x00008000
74#define IN_ISDIR 0x40000000
75#define _IN_ALL_RETFLAGS (IN_Q_OVERFLOW | IN_UNMOUNT | IN_IGNORED | \
76 IN_ISDIR)
77
78#define _IN_ALIGN _Alignof(struct inotify_event)
79#define _IN_NAMESIZE(namelen) \
80 ((namelen) == 0 ? 0 : __align_up((namelen) + 1, _IN_ALIGN))
81
82#ifdef _KERNEL
83struct componentname;
84struct file;
85struct inotify_softc;
86struct thread;
87struct vnode;
88
89int inotify_create_file(struct thread *, struct file *, int, int *);
90void inotify_log(struct vnode *, const char *, size_t, int, __uint32_t);
91
92int kern_inotify_rm_watch(int, uint32_t, struct thread *);
93int kern_inotify_add_watch(int, int, const char *, uint32_t,
94 struct thread *);
95
96void vn_inotify(struct vnode *, struct vnode *, struct componentname *, int,
97 uint32_t);
98int vn_inotify_add_watch(struct vnode *, struct inotify_softc *,
99 __uint32_t, __uint32_t *, struct thread *);
100void vn_inotify_revoke(struct vnode *);
101
102/* Log an inotify event. */
103#define INOTIFY(vp, ev) do { \
104 if (__predict_false((vn_irflag_read(vp) & (VIRF_INOTIFY | \
105 VIRF_INOTIFY_PARENT)) != 0)) \
106 VOP_INOTIFY((vp), NULL, NULL, (ev), 0); \
107} while (0)
108
109/* Log an inotify event using a specific name for the vnode. */
110#define INOTIFY_NAME_LOCK(vp, dvp, cnp, ev, lock) do { \
111 if (__predict_false((vn_irflag_read(vp) & VIRF_INOTIFY) != 0 || \
112 (vn_irflag_read(dvp) & VIRF_INOTIFY) != 0)) { \
113 if (lock) \
114 vn_lock((vp), LK_SHARED | LK_RETRY); \
115 VOP_INOTIFY((vp), (dvp), (cnp), (ev), 0); \
116 if (lock) \
117 VOP_UNLOCK(vp); \
118 } \
119} while (0)
120#define INOTIFY_NAME(vp, dvp, cnp, ev) \
121 INOTIFY_NAME_LOCK((vp), (dvp), (cnp), (ev), false)
122
123extern __uint32_t inotify_rename_cookie;
124
125#define INOTIFY_MOVE(vp, fdvp, fcnp, tvp, tdvp, tcnp) do { \
126 if (__predict_false((vn_irflag_read(fdvp) & VIRF_INOTIFY) != 0 || \
127 (vn_irflag_read(tdvp) & VIRF_INOTIFY) != 0 || \
128 (vn_irflag_read(vp) & VIRF_INOTIFY) != 0)) { \
129 __uint32_t cookie; \
130 \
131 cookie = atomic_fetchadd_32(&inotify_rename_cookie, 1); \
132 VOP_INOTIFY((vp), (fdvp), (fcnp), IN_MOVED_FROM, cookie); \
133 VOP_INOTIFY((vp), (tdvp), (tcnp), IN_MOVED_TO, cookie); \
134 } \
135 if ((tvp) != NULL) \
136 INOTIFY_NAME_LOCK((tvp), (tdvp), (tcnp), \
137 _IN_MOVE_DELETE, true); \
138} while (0)
139
140#define INOTIFY_REVOKE(vp) do { \
141 if (__predict_false((vn_irflag_read(vp) & VIRF_INOTIFY) != 0)) \
142 vn_inotify_revoke((vp)); \
143} while (0)
144
145#else
146#include <sys/cdefs.h>
147
148__BEGIN_DECLS
149int inotify_init(void);
150int inotify_init1(int flags);
151int inotify_add_watch(int fd, const char *pathname, __uint32_t mask);
152int inotify_add_watch_at(int fd, int dfd, const char *pathname,
153 __uint32_t mask);
154int inotify_rm_watch(int fd, int wd);
155__END_DECLS
156#endif /* !_KERNEL */
157
158#endif /* !_INOTIFY_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/interrupt.h+4-3
......@@ -121,7 +121,7 @@ struct intr_event {
121121 int ie_count; /* Loop counter. */
122122 int ie_warncnt; /* Rate-check interrupt storm warns. */
123123 struct timeval ie_warntm;
124 int ie_irq; /* Physical irq number if !SOFT. */
124 u_int ie_irq; /* Physical irq number if !SOFT. */
125125 int ie_cpu; /* CPU this event is bound to. */
126126 volatile int ie_phase; /* Switched to establish a barrier. */
127127 volatile int ie_active[2]; /* Filters in ISR context. */
......@@ -129,6 +129,7 @@ struct intr_event {
129129
130130/* Interrupt event flags kept in ie_flags. */
131131#define IE_SOFT 0x000001 /* Software interrupt. */
132#define IE_SLEEPABLE 0x000002 /* Sleepable ithread */
132133#define IE_ADDING_THREAD 0x000004 /* Currently building an ithread. */
133134
134135/* Flags to pass to swi_sched. */
......@@ -175,7 +176,7 @@ struct _cpuset;
175176int intr_event_bind_ithread_cpuset(struct intr_event *ie,
176177 struct _cpuset *mask);
177178int intr_event_create(struct intr_event **event, void *source,
178 int flags, int irq, void (*pre_ithread)(void *),
179 int flags, u_int irq, void (*pre_ithread)(void *),
179180 void (*post_ithread)(void *), void (*post_filter)(void *),
180181 int (*assign_cpu)(void *, int), const char *fmt, ...)
181182 __printflike(9, 10);
......@@ -188,7 +189,7 @@ int intr_event_suspend_handler(void *cookie);
188189int intr_event_resume_handler(void *cookie);
189190int intr_getaffinity(int irq, int mode, void *mask);
190191void *intr_handler_source(void *cookie);
191int intr_setaffinity(int irq, int mode, void *mask);
192int intr_setaffinity(int irq, int mode, const void *mask);
192193void _intr_drain(int irq); /* LinuxKPI only. */
193194int swi_add(struct intr_event **eventp, const char *name,
194195 driver_intr_t handler, void *arg, int pri, enum intr_type flags,
lib/libc/include/generic-freebsd/sys/intr.h+11-3
......@@ -33,10 +33,12 @@
3333#error Need INTRNG for this file
3434#endif
3535
36#include <sys/systm.h>
36#include <machine/intr.h>
3737
3838#define INTR_IRQ_INVALID 0xFFFFFFFF
3939
40#ifndef LOCORE
41
4042enum intr_map_data_type {
4143 INTR_MAP_DATA_ACPI = 0,
4244 INTR_MAP_DATA_FDT,
......@@ -110,12 +112,13 @@ u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask);
110112
111113struct intr_pic *intr_pic_register(device_t, intptr_t);
112114int intr_pic_deregister(device_t, intptr_t);
113int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *);
115int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *,
116 uint32_t);
114117int intr_pic_add_handler(device_t, struct intr_pic *,
115118 intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t);
116119bool intr_is_per_cpu(struct resource *);
117120
118extern device_t intr_irq_root_dev;
121device_t intr_irq_root_device(uint32_t);
119122
120123/* Intr interface for BUS. */
121124
......@@ -163,4 +166,9 @@ void intr_ipi_send(cpuset_t cpus, u_int ipi);
163166void intr_ipi_dispatch(u_int ipi);
164167#endif
165168
169/* Main interrupt handler called from asm on most archs except riscv. */
170void intr_irq_handler(struct trapframe *tf, uint32_t rootnum);
171
172#endif /* !LOCORE */
173
166174#endif /* _SYS_INTR_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ioccom.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ioccom.h 8.3 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_IOCCOM_H_
lib/libc/include/generic-freebsd/sys/ioctl.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)ioctl.h 8.6 (Berkeley) 3/28/94
3735 */
3836
3937#ifndef _SYS_IOCTL_H_
lib/libc/include/generic-freebsd/sys/ioctl_compat.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)ioctl_compat.h 8.4 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_IOCTL_COMPAT_H_
lib/libc/include/generic-freebsd/sys/ipc.h-2
......@@ -37,8 +37,6 @@
3737 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3838 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3939 * SUCH DAMAGE.
40 *
41 * @(#)ipc.h 8.4 (Berkeley) 2/19/95
4240 */
4341
4442/*
lib/libc/include/generic-freebsd/sys/jail.h+61-23
......@@ -99,8 +99,12 @@ enum prison_state {
9999#define JAIL_UPDATE 0x02 /* Update parameters of existing jail */
100100#define JAIL_ATTACH 0x04 /* Attach to jail upon creation */
101101#define JAIL_DYING 0x08 /* Allow getting a dying jail */
102#define JAIL_SET_MASK 0x0f
103#define JAIL_GET_MASK 0x08
102#define JAIL_USE_DESC 0x10 /* Get/set jail in descriptor */
103#define JAIL_AT_DESC 0x20 /* Find/add jail under descriptor */
104#define JAIL_GET_DESC 0x40 /* Return a new jail descriptor */
105#define JAIL_OWN_DESC 0x80 /* Return a new owning jail descriptor */
106#define JAIL_SET_MASK 0xff /* JAIL_DYING is deprecated/ignored here */
107#define JAIL_GET_MASK 0xf8
104108
105109#define JAIL_SYS_DISABLE 0
106110#define JAIL_SYS_NEW 1
......@@ -115,7 +119,9 @@ int jail(struct jail *);
115119int jail_set(struct iovec *, unsigned int, int);
116120int jail_get(struct iovec *, unsigned int, int);
117121int jail_attach(int);
122int jail_attach_jd(int);
118123int jail_remove(int);
124int jail_remove_jd(int);
119125__END_DECLS
120126
121127#else /* _KERNEL */
......@@ -141,6 +147,11 @@ MALLOC_DECLARE(M_PRISON);
141147#define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000"
142148#define OSRELEASELEN 32
143149
150#define JAIL_META_PRIVATE "meta"
151#define JAIL_META_SHARED "env"
152
153struct jaildesc;
154struct knlist;
144155struct racct;
145156struct prison_racct;
146157
......@@ -186,7 +197,9 @@ struct prison {
186197 struct vnode *pr_root; /* (c) vnode to rdir */
187198 struct prison_ip *pr_addrs[PR_FAMILY_MAX]; /* (p,n) IPs of jail */
188199 struct prison_racct *pr_prison_racct; /* (c) racct jail proxy */
189 void *pr_sparep[3];
200 struct knlist *pr_klist; /* (m) attached knotes */
201 LIST_HEAD(, jaildesc) pr_descs; /* (a) attached descriptors */
202 void *pr_sparep;
190203 int pr_childcount; /* (a) number of child jails */
191204 int pr_childmax; /* (p) maximum child jails */
192205 unsigned pr_allow; /* (p) PR_ALLOW_* flags */
......@@ -253,13 +266,29 @@ struct prison_racct {
253266#define PR_ALLOW_RESERVED_PORTS 0x00008000
254267#define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */
255268#define PR_ALLOW_NFSD 0x00020000
256#define PR_ALLOW_ALL_STATIC 0x000387ff
269#define PR_ALLOW_EXTATTR 0x00040000
270#define PR_ALLOW_ADJTIME 0x00080000
271#define PR_ALLOW_SETTIME 0x00100000
272#define PR_ALLOW_ROUTING 0x00200000
273#define PR_ALLOW_UNPRIV_PARENT_TAMPER 0x00400000
274#define PR_ALLOW_SETAUDIT 0x00800000
275
276/*
277 * PR_ALLOW_PRISON0 are the allow flags that we apply by default to prison0,
278 * while PR_ALLOW_ALL_STATIC are all of the allow bits that we have allocated at
279 * build time. PR_ALLOW_ALL_STATIC should contain any bit above that we expect
280 * to be used on the system, while PR_ALLOW_PRISON0 will be some subset of that.
281 */
282#define PR_ALLOW_ALL_STATIC 0x00ff87ff
283#define PR_ALLOW_PRISON0 \
284 (PR_ALLOW_ALL_STATIC & ~(PR_ALLOW_UNPRIV_PARENT_TAMPER))
257285
258286/*
259287 * PR_ALLOW_DIFFERENCES determines which flags are able to be
260288 * different between the parent and child jail upon creation.
261289 */
262#define PR_ALLOW_DIFFERENCES (PR_ALLOW_UNPRIV_DEBUG)
290#define PR_ALLOW_DIFFERENCES \
291 (PR_ALLOW_UNPRIV_DEBUG | PR_ALLOW_UNPRIV_PARENT_TAMPER)
263292
264293/*
265294 * OSD methods
......@@ -373,37 +402,45 @@ extern struct sx allprison_lock;
373402/*
374403 * Sysctls to describe jail parameters.
375404 */
405SYSCTL_DECL(_security_jail);
376406SYSCTL_DECL(_security_jail_param);
377407
408#define SYSCTL_JAIL_PARAM_DECL(name) \
409 SYSCTL_DECL(_security_jail_param_##name)
378410#define SYSCTL_JAIL_PARAM(module, param, type, fmt, descr) \
379 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
380 (type) | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_param, fmt, descr)
411 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
412 (type) | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_param, fmt, descr)
381413#define SYSCTL_JAIL_PARAM_STRING(module, param, access, len, descr) \
382 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
383 CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), NULL, len, \
384 sysctl_jail_param, "A", descr)
385#define SYSCTL_JAIL_PARAM_STRUCT(module, param, access, len, fmt, descr)\
386 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
387 CTLTYPE_STRUCT | CTLFLAG_MPSAFE | (access), NULL, len, \
388 sysctl_jail_param, fmt, descr)
414 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
415 CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), NULL, len, \
416 sysctl_jail_param, "A", descr)
417#define SYSCTL_JAIL_PARAM_STRUCT(module, param, access, len, fmt, descr) \
418 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
419 CTLTYPE_STRUCT | CTLFLAG_MPSAFE | (access), NULL, len, \
420 sysctl_jail_param, fmt, descr)
389421#define SYSCTL_JAIL_PARAM_NODE(module, descr) \
390 SYSCTL_NODE(_security_jail_param, OID_AUTO, module, CTLFLAG_MPSAFE, \
391 0, descr)
422 SYSCTL_NODE(_security_jail_param, OID_AUTO, module, CTLFLAG_MPSAFE, \
423 0, descr)
392424#define SYSCTL_JAIL_PARAM_SUBNODE(parent, module, descr) \
393 SYSCTL_NODE(_security_jail_param_##parent, OID_AUTO, module, \
394 CTLFLAG_MPSAFE, 0, descr)
425 SYSCTL_NODE(_security_jail_param_##parent, OID_AUTO, module, \
426 CTLFLAG_MPSAFE, 0, descr)
395427#define SYSCTL_JAIL_PARAM_SYS_NODE(module, access, descr) \
396 SYSCTL_JAIL_PARAM_NODE(module, descr); \
397 SYSCTL_JAIL_PARAM(_##module, , CTLTYPE_INT | (access), "E,jailsys", \
398 descr)
428 SYSCTL_JAIL_PARAM_NODE(module, descr); \
429 SYSCTL_JAIL_PARAM(_##module, , CTLTYPE_INT | (access), "E,jailsys", \
430 descr)
431#define SYSCTL_JAIL_PARAM_SYS_SUBNODE(parent, module, access, descr) \
432 SYSCTL_JAIL_PARAM_SUBNODE(parent, module, descr); \
433 SYSCTL_JAIL_PARAM(_##parent##_##module, , CTLTYPE_INT | (access), \
434 "E,jailsys", descr)
399435
400436/*
401437 * Kernel support functions for jail().
402438 */
403struct ucred;
439struct knote;
404440struct mount;
405441struct sockaddr;
406442struct statfs;
443struct ucred;
407444struct vfsconf;
408445
409446/*
......@@ -421,7 +458,7 @@ void prison0_init(void);
421458bool prison_allow(struct ucred *, unsigned);
422459int prison_check(struct ucred *cred1, struct ucred *cred2);
423460bool prison_check_nfsd(struct ucred *cred);
424bool prison_owns_vnet(struct ucred *);
461bool prison_owns_vnet(struct prison *pr);
425462int prison_canseemount(struct ucred *cred, struct mount *mp);
426463void prison_enforce_statfs(struct ucred *cred, struct mount *mp,
427464 struct statfs *sp);
......@@ -438,6 +475,7 @@ void prison_proc_free(struct prison *);
438475void prison_proc_link(struct prison *, struct proc *);
439476void prison_proc_unlink(struct prison *, struct proc *);
440477void prison_proc_iterate(struct prison *, void (*)(struct proc *, void *), void *);
478void prison_remove(struct prison *);
441479void prison_set_allow(struct ucred *cred, unsigned flag, int enable);
442480bool prison_ischild(struct prison *, struct prison *);
443481bool prison_isalive(const struct prison *);
lib/libc/include/generic-freebsd/sys/jaildesc.h created+87
......@@ -0,0 +1,87 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 James Gritton.
5 * All rights reserved.
6 *
7 * This software was developed at the University of Cambridge Computer
8 * Laboratory with support from a grant from Google, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _SYS_JAILDESC_H_
33#define _SYS_JAILDESC_H_
34
35#ifdef _KERNEL
36
37#include <sys/queue.h>
38#include <sys/selinfo.h>
39#include <sys/_lock.h>
40#include <sys/_mutex.h>
41#include <sys/_types.h>
42
43struct prison;
44
45/*-
46 * struct jaildesc describes a jail descriptor, which points to a struct
47 * prison. struct prison in turn has a linked list of struct jaildesc.
48 *
49 * Locking key:
50 * (c) set on creation, remains unchanged
51 * (d) jd_lock
52 * (p) jd_prison->pr_mtx
53 */
54struct jaildesc {
55 LIST_ENTRY(jaildesc) jd_list; /* (d,p) this prison's descs */
56 struct prison *jd_prison; /* (d) the prison */
57 struct mtx jd_lock;
58 struct selinfo jd_selinfo; /* (d) event notification */
59 unsigned jd_flags; /* (d) JDF_* flags */
60};
61
62/*
63 * Locking macros for the jaildesc.
64 */
65#define JAILDESC_LOCK_DESTROY(jd) mtx_destroy(&(jd)->jd_lock)
66#define JAILDESC_LOCK_INIT(jd) mtx_init(&(jd)->jd_lock, "jaildesc", \
67 NULL, MTX_DEF)
68#define JAILDESC_LOCK(jd) mtx_lock(&(jd)->jd_lock)
69#define JAILDESC_UNLOCK(jd) mtx_unlock(&(jd)->jd_lock)
70
71/*
72 * Flags for the jd_flags field
73 */
74#define JDF_SELECTED 0x00000001 /* issue selwakeup() */
75#define JDF_REMOVED 0x00000002 /* jail was removed */
76#define JDF_OWNING 0x00000004 /* closing descriptor removes jail */
77
78int jaildesc_find(struct thread *td, int fd, struct prison **prp,
79 struct ucred **ucredp);
80int jaildesc_alloc(struct thread *td, struct file **fpp, int *fdp, int owning);
81void jaildesc_set_prison(struct file *jd, struct prison *pr);
82void jaildesc_prison_cleanup(struct prison *pr);
83void jaildesc_knote(struct prison *pr, long hint);
84
85#endif /* _KERNEL */
86
87#endif /* !_SYS_JAILDESC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/kassert.h+27-2
......@@ -31,12 +31,37 @@
3131#ifndef _SYS_KASSERT_H_
3232#define _SYS_KASSERT_H_
3333
34#include <sys/_types.h>
3435#include <sys/cdefs.h>
3536
3637#ifdef _KERNEL
3738extern const char *panicstr; /* panic message */
38extern bool panicked;
39#define KERNEL_PANICKED() __predict_false(panicked)
39#define KERNEL_PANICKED() __predict_false(panicstr != NULL)
40
41/*
42 * Trap accesses going through a pointer.
43 *
44 * Sample usage: you have a struct with numerous fields and by API contract
45 * only some of them get populated, even if the implementation temporary writes
46 * to them. You can use DEBUG_POISON_POINTER so that the consumer which should
47 * no be looking at the field gets caught.
48 *
49 * DEBUG_POISON_POINTER(obj->ptr);
50 * ....
51 * if (obj->ptr->field) // traps
52 */
53#ifdef INVARIANTS
54
55extern void *poisoned_buf;
56#define DEBUG_POISON_POINTER_VALUE poisoned_buf
57
58#define DEBUG_POISON_POINTER(x) ({ \
59 x = (DEBUG_POISON_POINTER_VALUE); \
60})
61
62#else
63#define DEBUG_POISON_POINTER(x)
64#endif
4065
4166#ifdef INVARIANTS /* The option is always available */
4267#define VNASSERT(exp, vp, msg) do { \
lib/libc/include/generic-freebsd/sys/kernel.h+66-67
......@@ -39,8 +39,6 @@
3939 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4040 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4141 * SUCH DAMAGE.
42 *
43 * @(#)kernel.h 8.3 (Berkeley) 1/21/94
4442 */
4543
4644#ifndef _SYS_KERNEL_H_
......@@ -67,7 +65,16 @@ extern int psratio; /* ratio: prof / stat */
6765extern int stathz; /* statistics clock's frequency */
6866extern int profhz; /* profiling clock's frequency */
6967extern int profprocs; /* number of process's profiling */
68
69/*
70 * The ticks and ticksl symbols overlap, giving a 64-bit tick counter on 64-bit
71 * platforms while still maintaining compatibility with the legacy 32-bit
72 * counter. Either value can be used, but rollover must be handled; at 1000Hz,
73 * ticks (and ticksl on 32-bit platforms) roll over roughly every 25 days. On
74 * 64-bit platforms, ticksl will not roll over in the foreseeable future.
75 */
7076extern volatile int ticks;
77extern volatile long ticksl;
7178
7279#endif /* _KERNEL */
7380
......@@ -86,16 +93,15 @@ extern volatile int ticks;
8693 * The SI_SUB_LAST value must have the highest lexical value.
8794 */
8895enum sysinit_sub_id {
89 SI_SUB_DUMMY = 0x0000000, /* not executed; for linker*/
90 SI_SUB_DONE = 0x0000001, /* processed*/
96 SI_SUB_DUMMY = 0x0000000, /* not executed; for linker */
9197 SI_SUB_TUNABLES = 0x0700000, /* establish tunable values */
92 SI_SUB_COPYRIGHT = 0x0800001, /* first use of console*/
98 SI_SUB_COPYRIGHT = 0x0800001, /* first use of console */
9399 SI_SUB_VM = 0x1000000, /* virtual memory system init */
94100 SI_SUB_COUNTER = 0x1100000, /* counter(9) is initialized */
95 SI_SUB_KMEM = 0x1800000, /* kernel memory*/
101 SI_SUB_KMEM = 0x1800000, /* kernel memory */
96102 SI_SUB_HYPERVISOR = 0x1A40000, /*
97103 * Hypervisor detection and
98 * virtualization support
104 * virtualization support
99105 * setup.
100106 */
101107 SI_SUB_WITNESS = 0x1A80000, /* witness initialization */
......@@ -105,7 +111,7 @@ enum sysinit_sub_id {
105111 SI_SUB_VNET_PRELINK = 0x1E00000, /* vnet init before modules */
106112 SI_SUB_KLD = 0x2000000, /* KLD and module setup */
107113 SI_SUB_KHELP = 0x2080000, /* khelp modules */
108 SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/
114 SI_SUB_CPU = 0x2100000, /* CPU resource(s) */
109115 SI_SUB_RACCT = 0x2110000, /* resource accounting */
110116 SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */
111117 SI_SUB_RANDOM = 0x2160000, /* random number generator */
......@@ -113,21 +119,21 @@ enum sysinit_sub_id {
113119 SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */
114120 SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */
115121 SI_SUB_VNET = 0x21E0000, /* vnet 0 */
116 SI_SUB_INTRINSIC = 0x2200000, /* proc 0*/
117 SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits*/
122 SI_SUB_INTRINSIC = 0x2200000, /* proc 0 */
123 SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits */
118124 SI_SUB_DDB_SERVICES = 0x2380000, /* capture, scripting, etc. */
119 SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue*/
125 SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue */
120126 SI_SUB_KTRACE = 0x2480000, /* ktrace */
121127 SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */
122128 SI_SUB_AUDIT = 0x24C0000, /* audit */
123 SI_SUB_CREATE_INIT = 0x2500000, /* create init process*/
129 SI_SUB_CREATE_INIT = 0x2500000, /* create init process */
124130 SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */
125131 SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */
126132 SI_SUB_INTR = 0x2800000, /* interrupt threads */
127133 SI_SUB_TASKQ = 0x2880000, /* task queues */
128134 SI_SUB_EPOCH = 0x2888000, /* epoch subsystem */
129135#ifdef EARLY_AP_STARTUP
130 SI_SUB_SMP = 0x2900000, /* start the APs*/
136 SI_SUB_SMP = 0x2900000, /* start the APs */
131137#endif
132138 SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */
133139 SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */
......@@ -138,40 +144,40 @@ enum sysinit_sub_id {
138144 SI_SUB_DTRACE_ANON = 0x308C000, /* DTrace anon enabling */
139145 SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */
140146 SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */
141 SI_SUB_VFS = 0x4000000, /* virtual filesystem*/
142 SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks*/
143 SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory*/
144 SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores*/
145 SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues*/
147 SI_SUB_VFS = 0x4000000, /* virtual filesystem */
148 SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks */
149 SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory */
150 SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores */
151 SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues */
146152 SI_SUB_P1003_1B = 0x6E00000, /* P1003.1B realtime */
147 SI_SUB_PSEUDO = 0x7000000, /* pseudo devices*/
153 SI_SUB_PSEUDO = 0x7000000, /* pseudo devices */
148154 SI_SUB_EXEC = 0x7400000, /* execve() handlers */
149155 SI_SUB_PROTO_BEGIN = 0x8000000, /* VNET initialization */
150156 SI_SUB_PROTO_PFIL = 0x8100000, /* Initialize pfil before FWs */
151 SI_SUB_PROTO_IF = 0x8400000, /* interfaces*/
157 SI_SUB_PROTO_IF = 0x8400000, /* interfaces */
152158 SI_SUB_PROTO_DOMAININIT = 0x8600000, /* domain registration system */
153159 SI_SUB_PROTO_MC = 0x8700000, /* Multicast */
154 SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?)*/
160 SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?) */
155161 SI_SUB_PROTO_FIREWALL = 0x8806000, /* Firewalls */
156162 SI_SUB_PROTO_IFATTACHDOMAIN = 0x8808000,/* domain dependent data init */
157163 SI_SUB_PROTO_END = 0x8ffffff, /* VNET helper functions */
158 SI_SUB_KPROF = 0x9000000, /* kernel profiling*/
159 SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events*/
164 SI_SUB_KPROF = 0x9000000, /* kernel profiling */
165 SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events */
160166 SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */
161167 SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */
162 SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup*/
168 SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup */
163169 SI_SUB_SYSCALLS = 0xd800000, /* register system calls */
164170 SI_SUB_VNET_DONE = 0xdc00000, /* vnet registration complete */
165 SI_SUB_KTHREAD_INIT = 0xe000000, /* init process*/
166 SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon*/
167 SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon*/
168 SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon*/
169 SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon*/
170 SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/
171 SI_SUB_KTHREAD_INIT = 0xe000000, /* init process */
172 SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon */
173 SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon */
174 SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon */
175 SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon */
176 SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs */
171177#ifndef EARLY_AP_STARTUP
172 SI_SUB_SMP = 0xf000000, /* start the APs*/
173#endif
174 SI_SUB_RACCTD = 0xf100000, /* start racctd*/
178 SI_SUB_SMP = 0xf000000, /* start the APs */
179#endif
180 SI_SUB_RACCTD = 0xf100000, /* start racctd */
175181 SI_SUB_LAST = 0xfffffff /* final initialization */
176182};
177183
......@@ -179,16 +185,16 @@ enum sysinit_sub_id {
179185 * Some enumerated orders; "ANY" sorts last.
180186 */
181187enum sysinit_elem_order {
182 SI_ORDER_FIRST = 0x0000000, /* first*/
183 SI_ORDER_SECOND = 0x0000001, /* second*/
184 SI_ORDER_THIRD = 0x0000002, /* third*/
185 SI_ORDER_FOURTH = 0x0000003, /* fourth*/
186 SI_ORDER_FIFTH = 0x0000004, /* fifth*/
187 SI_ORDER_SIXTH = 0x0000005, /* sixth*/
188 SI_ORDER_SEVENTH = 0x0000006, /* seventh*/
189 SI_ORDER_EIGHTH = 0x0000007, /* eighth*/
188 SI_ORDER_FIRST = 0x0000000, /* first */
189 SI_ORDER_SECOND = 0x0000001, /* second */
190 SI_ORDER_THIRD = 0x0000002, /* third */
191 SI_ORDER_FOURTH = 0x0000003, /* fourth */
192 SI_ORDER_FIFTH = 0x0000004, /* fifth */
193 SI_ORDER_SIXTH = 0x0000005, /* sixth */
194 SI_ORDER_SEVENTH = 0x0000006, /* seventh */
195 SI_ORDER_EIGHTH = 0x0000007, /* eighth */
190196 SI_ORDER_MIDDLE = 0x1000000, /* somewhere in the middle */
191 SI_ORDER_ANY = 0xfffffff /* last*/
197 SI_ORDER_ANY = 0xfffffff /* last */
192198};
193199
194200/*
......@@ -218,10 +224,10 @@ typedef void (*sysinit_nfunc_t)(void *);
218224typedef void (*sysinit_cfunc_t)(const void *);
219225
220226struct sysinit {
221 enum sysinit_sub_id subsystem; /* subsystem identifier*/
222 enum sysinit_elem_order order; /* init order within subsystem*/
227 enum sysinit_sub_id subsystem; /* subsystem identifier */
228 enum sysinit_elem_order order; /* init order within subsystem */
223229 STAILQ_ENTRY(sysinit) next; /* singly-linked list */
224 sysinit_cfunc_t func; /* function */
230 sysinit_cfunc_t func; /* function */
225231 const void *udata; /* multiplexer/argument */
226232};
227233
......@@ -240,18 +246,11 @@ struct sysinit {
240246#ifdef TSLOG
241247struct sysinit_tslog {
242248 sysinit_cfunc_t func;
243 const void * data;
244 const char * name;
249 const void *data;
250 const char *name;
245251};
246static inline void
247sysinit_tslog_shim(const void * data)
248{
249 const struct sysinit_tslog * x = data;
250
251 TSRAW(curthread, TS_ENTER, "SYSINIT", x->name);
252 (x->func)(x->data);
253 TSRAW(curthread, TS_EXIT, "SYSINIT", x->name);
254}
252void sysinit_tslog_shim(const void *);
253
255254#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \
256255 static struct sysinit_tslog uniquifier ## _sys_init_tslog = { \
257256 func, \
......@@ -265,7 +264,7 @@ sysinit_tslog_shim(const void * data)
265264 sysinit_tslog_shim, \
266265 &uniquifier ## _sys_init_tslog \
267266 }; \
268 DATA_WSET(sysinit_set,uniquifier ## _sys_init)
267 DATA_WSET(sysinit_set, uniquifier ## _sys_init)
269268#else
270269#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \
271270 static struct sysinit uniquifier ## _sys_init = { \
......@@ -275,7 +274,7 @@ sysinit_tslog_shim(const void * data)
275274 func, \
276275 (ident) \
277276 }; \
278 DATA_WSET(sysinit_set,uniquifier ## _sys_init)
277 DATA_WSET(sysinit_set, uniquifier ## _sys_init)
279278#endif
280279
281280#define SYSINIT(uniquifier, subsystem, order, func, ident) \
......@@ -293,7 +292,7 @@ sysinit_tslog_shim(const void * data)
293292 func, \
294293 (ident) \
295294 }; \
296 DATA_WSET(sysuninit_set,uniquifier ## _sys_uninit)
295 DATA_WSET(sysuninit_set, uniquifier ## _sys_uninit)
297296
298297#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
299298 C_SYSUNINIT(uniquifier, subsystem, order, \
......@@ -316,7 +315,7 @@ void sysinit_add(struct sysinit **set, struct sysinit **set_end);
316315 * int
317316 * please avoid using for new tunables!
318317 */
319extern void tunable_int_init(void *);
318extern void tunable_int_init(const void *);
320319struct tunable_int {
321320 const char *path;
322321 int *var;
......@@ -335,7 +334,7 @@ struct tunable_int {
335334/*
336335 * long
337336 */
338extern void tunable_long_init(void *);
337extern void tunable_long_init(const void *);
339338struct tunable_long {
340339 const char *path;
341340 long *var;
......@@ -354,7 +353,7 @@ struct tunable_long {
354353/*
355354 * unsigned long
356355 */
357extern void tunable_ulong_init(void *);
356extern void tunable_ulong_init(const void *);
358357struct tunable_ulong {
359358 const char *path;
360359 unsigned long *var;
......@@ -373,7 +372,7 @@ struct tunable_ulong {
373372/*
374373 * int64_t
375374 */
376extern void tunable_int64_init(void *);
375extern void tunable_int64_init(const void *);
377376struct tunable_int64 {
378377 const char *path;
379378 int64_t *var;
......@@ -392,7 +391,7 @@ struct tunable_int64 {
392391/*
393392 * uint64_t
394393 */
395extern void tunable_uint64_init(void *);
394extern void tunable_uint64_init(const void *);
396395struct tunable_uint64 {
397396 const char *path;
398397 uint64_t *var;
......@@ -411,7 +410,7 @@ struct tunable_uint64 {
411410/*
412411 * quad
413412 */
414extern void tunable_quad_init(void *);
413extern void tunable_quad_init(const void *);
415414struct tunable_quad {
416415 const char *path;
417416 quad_t *var;
......@@ -430,7 +429,7 @@ struct tunable_quad {
430429/*
431430 * bool
432431 */
433extern void tunable_bool_init(void *);
432extern void tunable_bool_init(const void *);
434433struct tunable_bool {
435434 const char *path;
436435 bool *var;
......@@ -446,7 +445,7 @@ struct tunable_bool {
446445
447446#define TUNABLE_BOOL_FETCH(path, var) getenv_bool((path), (var))
448447
449extern void tunable_str_init(void *);
448extern void tunable_str_init(const void *);
450449struct tunable_str {
451450 const char *path;
452451 char *var;
lib/libc/include/generic-freebsd/sys/kerneldump.h+1
......@@ -161,6 +161,7 @@ void dumpsys_pb_progress(size_t);
161161extern int do_minidump;
162162
163163int livedump_start(int, int, uint8_t);
164int livedump_start_vnode(struct vnode *, int, uint8_t);
164165
165166/* Live minidump events */
166167typedef void (*livedump_start_fn)(void *arg, int *errorp);
lib/libc/include/generic-freebsd/sys/ktls.h+42-7
......@@ -28,8 +28,11 @@
2828#define _SYS_KTLS_H_
2929
3030#ifdef _KERNEL
31#include <sys/_null.h>
3132#include <sys/refcount.h>
3233#include <sys/_task.h>
34
35#include <machine/param.h>
3336#endif
3437
3538struct tls_record_layer {
......@@ -142,6 +145,28 @@ struct tls_get_record {
142145 uint16_t tls_length;
143146};
144147
148#define XKTLS_SESSION_IV_BUF_LEN 32
149struct xktls_session_onedir {
150 uint64_t gen;
151 uint64_t rsrv1[8];
152 uint32_t rsrv2[8];
153 uint8_t iv[XKTLS_SESSION_IV_BUF_LEN];
154 int cipher_algorithm;
155 int auth_algorithm;
156 uint16_t cipher_key_len;
157 uint16_t iv_len;
158 uint16_t auth_key_len;
159 uint16_t max_frame_len;
160 uint8_t tls_vmajor;
161 uint8_t tls_vminor;
162 uint8_t tls_hlen;
163 uint8_t tls_tlen;
164 uint8_t tls_bs;
165 uint8_t flags;
166 uint16_t drv_st_len;
167 char ifnet[16]; /* IFNAMSIZ */
168};
169
145170#ifdef _KERNEL
146171
147172struct tls_session_params {
......@@ -174,6 +199,7 @@ struct m_snd_tag;
174199struct mbuf;
175200struct sockbuf;
176201struct socket;
202struct sockopt;
177203
178204struct ktls_session {
179205 struct ktls_ocf_session *ocf_session;
......@@ -202,6 +228,8 @@ struct ktls_session {
202228
203229 /* Used to destroy any kTLS session */
204230 struct task destroy_task;
231
232 uint64_t gen;
205233} __aligned(CACHE_LINE_SIZE);
206234
207235extern unsigned int ktls_ifnet_max_rexmit_pct;
......@@ -213,27 +241,29 @@ typedef enum {
213241} ktls_mbuf_crypto_st_t;
214242
215243void ktls_check_rx(struct sockbuf *sb);
216ktls_mbuf_crypto_st_t ktls_mbuf_crypto_state(struct mbuf *mb, int offset, int len);
244void ktls_cleanup_tls_enable(struct tls_enable *tls);
245int ktls_copyin_tls_enable(struct sockopt *sopt, struct tls_enable *tls);
217246void ktls_disable_ifnet(void *arg);
218247int ktls_enable_rx(struct socket *so, struct tls_enable *en);
219248int ktls_enable_tx(struct socket *so, struct tls_enable *en);
249void ktls_enqueue(struct mbuf *m, struct socket *so, int page_count);
250void ktls_enqueue_to_free(struct mbuf *m);
220251void ktls_destroy(struct ktls_session *tls);
221252void ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,
222253 uint8_t record_type);
223bool ktls_permit_empty_frames(struct ktls_session *tls);
224void ktls_seq(struct sockbuf *sb, struct mbuf *m);
225void ktls_enqueue(struct mbuf *m, struct socket *so, int page_count);
226void ktls_enqueue_to_free(struct mbuf *m);
227254int ktls_get_rx_mode(struct socket *so, int *modep);
228int ktls_set_tx_mode(struct socket *so, int mode);
229255int ktls_get_tx_mode(struct socket *so, int *modep);
230256int ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq);
231257void ktls_input_ifp_mismatch(struct sockbuf *sb, struct ifnet *ifp);
232int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls);
258ktls_mbuf_crypto_st_t ktls_mbuf_crypto_state(struct mbuf *mb, int offset, int len);
233259#ifdef RATELIMIT
234260int ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate);
235261#endif
262int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls);
236263bool ktls_pending_rx_info(struct sockbuf *sb, uint64_t *seqnop, size_t *residp);
264bool ktls_permit_empty_frames(struct ktls_session *tls);
265void ktls_seq(struct sockbuf *sb, struct mbuf *m);
266int ktls_set_tx_mode(struct socket *so, int mode);
237267
238268static inline struct ktls_session *
239269ktls_hold(struct ktls_session *tls)
......@@ -252,5 +282,10 @@ ktls_free(struct ktls_session *tls)
252282 ktls_destroy(tls);
253283}
254284
285void ktls_session_to_xktls_onedir(const struct ktls_session *ks,
286 bool export_keys, struct xktls_session_onedir *xktls_od);
287void ktls_session_copy_keys(const struct ktls_session *ktls,
288 uint8_t *data, size_t *sz);
289
255290#endif /* !_KERNEL */
256291#endif /* !_SYS_KTLS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ktrace.h+27-5
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ktrace.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_KTRACE_H_
......@@ -38,6 +36,7 @@
3836#include <sys/caprights.h>
3937#include <sys/signal.h>
4038#include <sys/socket.h>
39#include <sys/_uexterror.h>
4140#include <sys/_uio.h>
4241
4342/*
......@@ -89,10 +88,9 @@ struct ktr_header {
8988 * is the public interface.
9089 */
9190#define KTRCHECK(td, type) ((td)->td_proc->p_traceflag & (1 << type))
92#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type))))
93#define KTRCHECKDRAIN(td) (!(STAILQ_EMPTY(&(td)->td_proc->p_ktr)))
91#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type))))
9492#define KTRUSERRET(td) do { \
95 if (__predict_false(KTRCHECKDRAIN(td))) \
93 if (__predict_false(!STAILQ_EMPTY_ATOMIC(&(td)->td_proc->p_ktr))) \
9694 ktruserret(td); \
9795} while (0)
9896
......@@ -265,6 +263,24 @@ struct ktr_struct_array {
265263 */
266264};
267265
266/*
267 * KTR_ARGS - arguments of execve()
268 */
269#define KTR_ARGS 16
270
271/*
272 * KTR_ENVS - environment variables of execve()
273 */
274#define KTR_ENVS 17
275
276/*
277 * KTR_EXTERR - extended error reported
278 */
279#define KTR_EXTERR 18
280struct ktr_exterr {
281 struct uexterror ue;
282};
283
268284/*
269285 * KTR_DROP - If this bit is set in ktr_type, then at least one event
270286 * between the previous record and this record was dropped.
......@@ -297,6 +313,9 @@ struct ktr_struct_array {
297313#define KTRFAC_FAULT (1<<KTR_FAULT)
298314#define KTRFAC_FAULTEND (1<<KTR_FAULTEND)
299315#define KTRFAC_STRUCT_ARRAY (1<<KTR_STRUCT_ARRAY)
316#define KTRFAC_ARGS (1<<KTR_ARGS)
317#define KTRFAC_ENVS (1<<KTR_ENVS)
318#define KTRFAC_EXTERR (1<<KTR_EXTERR)
300319
301320/*
302321 * trace flags (also in p_traceflags)
......@@ -337,6 +356,7 @@ void ktrstruct(const char *, const void *, size_t);
337356void ktrstruct_error(const char *, const void *, size_t, int);
338357void ktrstructarray(const char *, enum uio_seg, const void *, int, size_t);
339358void ktrcapfail(enum ktr_cap_violation, const void *);
359void ktrdata(int, const void *, size_t);
340360#define ktrcaprights(s) \
341361 ktrstruct("caprights", (s), sizeof(cap_rights_t))
342362#define ktritimerval(s) \
......@@ -351,6 +371,8 @@ void ktrcapfail(enum ktr_cap_violation, const void *);
351371 ktrstruct("cpuset_t", (s), l)
352372#define ktrsplice(s) \
353373 ktrstruct("splice", (s), sizeof(struct splice))
374#define ktrthrparam(s) \
375 ktrstruct("thrparam", (s), sizeof(struct thr_param))
354376extern u_int ktr_geniosize;
355377#ifdef KTRACE
356378extern int ktr_filesize_limit_signal;
lib/libc/include/generic-freebsd/sys/libkern.h+50-3
......@@ -27,18 +27,16 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)libkern.h 8.1 (Berkeley) 6/10/93
3230 */
3331
3432#ifndef _SYS_LIBKERN_H_
3533#define _SYS_LIBKERN_H_
3634
37#include <sys/cdefs.h>
3835#include <sys/types.h>
3936#ifdef _KERNEL
4037#include <sys/systm.h>
4138#endif
39#include <sys/kassert.h>
4240
4341#ifndef LIBKERN_INLINE
4442#define LIBKERN_INLINE static __inline
......@@ -189,6 +187,49 @@ flsll(long long mask)
189187 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
190188}
191189
190static __inline __pure2 int
191ilog2_int(int n)
192{
193
194 KASSERT(n != 0, ("ilog argument must be nonzero"));
195 return (8 * sizeof(n) - 1 - __builtin_clz((u_int)n));
196}
197
198static __inline __pure2 int
199ilog2_long(long n)
200{
201
202 KASSERT(n != 0, ("ilog argument must be nonzero"));
203 return (8 * sizeof(n) - 1 - __builtin_clzl((u_long)n));
204}
205
206static __inline __pure2 int
207ilog2_long_long(long long n)
208{
209
210 KASSERT(n != 0, ("ilog argument must be nonzero"));
211 return (8 * sizeof(n) - 1 -
212 __builtin_clzll((unsigned long long)n));
213}
214
215#define ilog2_var(n) \
216 _Generic((n), \
217 default: ilog2_int, \
218 long: ilog2_long, \
219 unsigned long: ilog2_long, \
220 long long: ilog2_long_long, \
221 unsigned long long: ilog2_long_long \
222 )(n)
223
224#define ilog2_const(n) \
225 (8 * (int)sizeof(unsigned long long) - 1 - \
226 __builtin_clzll(n))
227
228#define ilog2(n) (__builtin_constant_p(n) ? ilog2_const(n) : ilog2_var(n))
229#define rounddown_pow_of_two(n) ((__typeof(n))1 << ilog2(n))
230#define order_base_2(n) ilog2(2*(n)-1)
231#define roundup_pow_of_two(n) ((__typeof(n))1 << order_base_2(n))
232
192233#define bitcount64(x) __bitcount64((uint64_t)(x))
193234#define bitcount32(x) __bitcount32((uint32_t)(x))
194235#define bitcount16(x) __bitcount16((uint16_t)(x))
......@@ -293,4 +334,10 @@ signed_extend32(uint32_t bitmap, int lsb, int width)
293334#define FNM_IGNORECASE FNM_CASEFOLD
294335#define FNM_FILE_NAME FNM_PATHNAME
295336
337#if !defined(_KERNEL) && __has_include(<ssp/ssp.h>)
338#include <ssp/ssp.h> /* __ssp_real */
339#else
340#define __ssp_real(fun) fun
341#endif
342
296343#endif /* !_SYS_LIBKERN_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/link_elf.h+3-1
......@@ -93,10 +93,12 @@ struct dl_phdr_info
9393__BEGIN_DECLS
9494
9595typedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *);
96extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
96int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
9797int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
9898int _rtld_get_stack_prot(void);
9999int _rtld_is_dlopened(void *);
100const char *rtld_get_var(const char *name);
101int rtld_set_var(const char *name, const char *val);
100102
101103#ifdef __ARM_EABI__
102104void * dl_unwind_find_exidx(const void *, int *);
lib/libc/include/generic-freebsd/sys/linker.h+25-2
......@@ -29,6 +29,8 @@
2929#ifndef _SYS_LINKER_H_
3030#define _SYS_LINKER_H_
3131
32#include <sys/param.h>
33
3234#ifdef _KERNEL
3335
3436#include <machine/elf.h>
......@@ -130,6 +132,12 @@ typedef int linker_predicate_t(linker_file_t, void *);
130132 */
131133extern linker_file_t linker_kernel_file;
132134
135/*
136 * Special symbol which will be replaced by a reference to the linker_file_t
137 * of the module it is used in.
138 */
139extern linker_file_t __this_linker_file;
140
133141/*
134142 * Obtain a reference to a module, loading it if required.
135143 */
......@@ -212,6 +220,14 @@ void linker_kldload_unbusy(int flags);
212220
213221#endif /* _KERNEL */
214222
223/*
224 * ELF file types
225 */
226#define KERNTYPE_MB "elf multiboot kernel"
227#define KERNTYPE "elf kernel"
228#define MODTYPE_OBJ "elf obj module"
229#define MODTYPE "elf module"
230
215231/*
216232 * Module information subtypes
217233 */
......@@ -264,7 +280,10 @@ void linker_kldload_unbusy(int flags);
264280 * Module lookup
265281 */
266282extern vm_offset_t preload_addr_relocate;
267extern caddr_t preload_metadata;
283extern caddr_t preload_metadata, preload_kmdp;
284extern const char preload_modtype[];
285extern const char preload_kerntype[];
286extern const char preload_modtype_obj[];
268287
269288extern void * preload_fetch_addr(caddr_t _mod);
270289extern size_t preload_fetch_size(caddr_t _mod);
......@@ -272,6 +291,7 @@ extern caddr_t preload_search_by_name(const char *_name);
272291extern caddr_t preload_search_by_type(const char *_type);
273292extern caddr_t preload_search_next_name(caddr_t _base);
274293extern caddr_t preload_search_info(caddr_t _mod, int _inf);
294extern void preload_initkmdp(bool _fatal);
275295extern void preload_delete_name(const char *_name);
276296extern void preload_bootstrap_relocate(vm_offset_t _offset);
277297extern void preload_dump(void);
......@@ -304,7 +324,7 @@ int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel,
304324Elf_Addr elf_relocaddr(linker_file_t _lf, Elf_Addr addr);
305325const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Size _symidx);
306326const char *elf_get_symname(linker_file_t _lf, Elf_Size _symidx);
307void link_elf_ireloc(caddr_t kmdp);
327void link_elf_ireloc(void);
308328
309329#if defined(__aarch64__) || defined(__amd64__)
310330int elf_reloc_late(linker_file_t _lf, Elf_Addr base, const void *_rel,
......@@ -325,6 +345,9 @@ typedef struct linker_ctf {
325345} linker_ctf_t;
326346
327347int linker_ctf_get(linker_file_t, linker_ctf_t *);
348int linker_ctf_lookup_sym_ddb(const char *symname, c_linker_sym_t *sym,
349 linker_ctf_t *lc);
350int linker_ctf_lookup_typename_ddb(linker_ctf_t *lc, const char *typename);
328351
329352int elf_cpu_load_file(linker_file_t);
330353int elf_cpu_unload_file(linker_file_t);
lib/libc/include/generic-freebsd/sys/lock.h+1
......@@ -66,6 +66,7 @@ struct lock_class {
6666 int (*lc_owner)(const struct lock_object *lock,
6767 struct thread **owner);
6868 uintptr_t (*lc_unlock)(struct lock_object *lock);
69 int (*lc_trylock)(struct lock_object *lock, uintptr_t how);
6970};
7071
7172#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */
lib/libc/include/generic-freebsd/sys/lockf.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)lockf.h 8.1 (Berkeley) 6/11/93
3533 */
3634
3735#ifndef _SYS_LOCKF_H_
lib/libc/include/generic-freebsd/sys/lockmgr.h+4
......@@ -130,6 +130,10 @@ _lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk,
130130 LOCK_FILE, LOCK_LINE)
131131#define lockmgr_disown(lk) \
132132 _lockmgr_disown((lk), LOCK_FILE, LOCK_LINE)
133#define lockmgr_disowned_v(v) \
134 (LK_HOLDER((v)) == LK_KERNPROC)
135#define lockmgr_disowned(lk) \
136 lockmgr_disowned_v(lockmgr_read_value((lk)))
133137#define lockmgr_recursed_v(v) \
134138 (v & LK_WRITER_RECURSED)
135139#define lockmgr_recursed(lk) \
lib/libc/include/generic-freebsd/sys/mac.h+14
......@@ -47,6 +47,13 @@
4747#ifndef _SYS_MAC_H_
4848#define _SYS_MAC_H_
4949
50#include <sys/_types.h>
51
52#ifndef _SIZE_T_DECLARED
53typedef __size_t size_t;
54#define _SIZE_T_DECLARED
55#endif
56
5057#ifndef _POSIX_MAC
5158#define _POSIX_MAC
5259#endif
......@@ -72,6 +79,13 @@ typedef struct mac *mac_t;
7279
7380#ifndef _KERNEL
7481
82#include <sys/cdefs.h> /* For __BEGIN_DECLS and __END_DECLS. */
83
84#ifndef _PID_T_DECLARED
85typedef __pid_t pid_t; /* process id */
86#define _PID_T_DECLARED
87#endif
88
7589/*
7690 * Location of the userland MAC framework configuration file. mac.conf
7791 * set defaults for MAC-aware applications.
lib/libc/include/generic-freebsd/sys/malloc.h+7-4
......@@ -29,8 +29,6 @@
2929 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3030 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3131 * SUCH DAMAGE.
32 *
33 * @(#)malloc.h 8.5 (Berkeley) 5/3/95
3432 */
3533
3634#ifndef _SYS_MALLOC_H_
......@@ -62,8 +60,9 @@
6260#define M_BESTFIT 0x2000 /* only for vmem, low fragmentation */
6361#define M_EXEC 0x4000 /* allocate executable space */
6462#define M_NEXTFIT 0x8000 /* only for vmem, follow cursor */
63#define M_NEVERFREED 0x10000 /* chunk will never get freed */
6564
66#define M_VERSION 2020110501
65#define M_VERSION 2024073001
6766
6867/*
6968 * Two malloc type structures are present: malloc_type, which is used by a
......@@ -159,6 +158,9 @@ struct malloc_type_header {
159158
160159MALLOC_DECLARE(M_CACHE);
161160MALLOC_DECLARE(M_DEVBUF);
161MALLOC_DECLARE(M_PARGS);
162MALLOC_DECLARE(M_SESSION);
163MALLOC_DECLARE(M_SUBPROC);
162164MALLOC_DECLARE(M_TEMP);
163165
164166/*
......@@ -176,7 +178,8 @@ extern struct mtx malloc_mtx;
176178 */
177179typedef void malloc_type_list_func_t(struct malloc_type *, void *);
178180
179void contigfree(void *addr, unsigned long size, struct malloc_type *type);
181/* contigfree(9) is deprecated. */
182void contigfree(void *addr, unsigned long, struct malloc_type *type);
180183void *contigmalloc(unsigned long size, struct malloc_type *type, int flags,
181184 vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
182185 vm_paddr_t boundary) __malloc_like __result_use_check
lib/libc/include/generic-freebsd/sys/mbuf.h+161-28
......@@ -28,8 +28,6 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
3331 */
3432
3533#ifndef _SYS_MBUF_H_
......@@ -596,6 +594,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
596594#define EXT_PACKET 6 /* mbuf+cluster from packet zone */
597595#define EXT_MBUF 7 /* external mbuf reference */
598596#define EXT_RXRING 8 /* data in NIC receive ring */
597#define EXT_CTL 9 /* buffer from a ctl(4) backend */
599598
600599#define EXT_VENDOR1 224 /* for vendor-internal use */
601600#define EXT_VENDOR2 225 /* for vendor-internal use */
......@@ -642,16 +641,15 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
642641
643642/*
644643 * Flags indicating checksum, segmentation and other offload work to be
645 * done, or already done, by hardware or lower layers. It is split into
646 * separate inbound and outbound flags.
644 * done, or already done, by hardware or lower layers.
647645 *
648 * Outbound flags that are set by upper protocol layers requesting lower
646 * Flags that are set by upper protocol layers requesting lower
649647 * layers, or ideally the hardware, to perform these offloading tasks.
650 * For outbound packets this field and its flags can be directly tested
651 * against ifnet if_hwassist. Note that the outbound and the inbound flags do
652 * not collide right now but they could be allowed to (as long as the flags are
653 * scrubbed appropriately when the direction of an mbuf changes). CSUM_BITS
654 * would also have to split into CSUM_BITS_TX and CSUM_BITS_RX.
648 * Before passing packets to a network interface this field and its flags can
649 * be directly tested against ifnet if_hwassist. Note that the flags
650 * CSUM_IP_SCTP, CSUM_IP_TCP, and CSUM_IP_UDP can appear on input processing
651 * of SCTP, TCP, and UDP. In such a case the checksum will not be computed or
652 * validated by SCTP, TCP, or TCP, since the packet has not been on the wire.
655653 *
656654 * CSUM_INNER_<x> is the same as CSUM_<x> but it applies to the inner frame.
657655 * The CSUM_ENCAP_<x> bits identify the outer encapsulation.
......@@ -680,7 +678,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
680678#define CSUM_ENCAP_VXLAN 0x00040000 /* VXLAN outer encapsulation */
681679#define CSUM_ENCAP_RSVD1 0x00080000
682680
683/* Inbound checksum support where the checksum was verified by hardware. */
681/* Flags used to indicate that the checksum was verified by hardware. */
684682#define CSUM_INNER_L3_CALC 0x00100000
685683#define CSUM_INNER_L3_VALID 0x00200000
686684#define CSUM_INNER_L4_CALC 0x00400000
......@@ -809,12 +807,12 @@ void mb_dupcl(struct mbuf *, struct mbuf *);
809807void mb_free_ext(struct mbuf *);
810808void mb_free_extpg(struct mbuf *);
811809void mb_free_mext_pgs(struct mbuf *);
812struct mbuf *mb_alloc_ext_pgs(int, m_ext_free_t);
810struct mbuf *mb_alloc_ext_pgs(int, m_ext_free_t, int);
813811struct mbuf *mb_alloc_ext_plus_pages(int, int);
814812struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int,
815813 struct mbuf **);
816814int mb_unmapped_compress(struct mbuf *m);
817struct mbuf *mb_unmapped_to_ext(struct mbuf *m);
815int mb_unmapped_to_ext(struct mbuf *m, struct mbuf **mres);
818816void mb_free_notready(struct mbuf *m, int count);
819817void m_adj(struct mbuf *, int);
820818void m_adj_decap(struct mbuf *, int);
......@@ -886,9 +884,11 @@ m_gettype(int size)
886884 case MCLBYTES:
887885 type = EXT_CLUSTER;
888886 break;
887#if MJUMPAGESIZE != MCLBYTES
889888 case MJUMPAGESIZE:
890889 type = EXT_JUMBOP;
891890 break;
891#endif
892892 case MJUM9BYTES:
893893 type = EXT_JUMBO9;
894894 break;
......@@ -934,9 +934,11 @@ m_getzone(int size)
934934 case MCLBYTES:
935935 zone = zone_clust;
936936 break;
937#if MJUMPAGESIZE != MCLBYTES
937938 case MJUMPAGESIZE:
938939 zone = zone_jumbop;
939940 break;
941#endif
940942 case MJUM9BYTES:
941943 zone = zone_jumbo9;
942944 break;
......@@ -1056,9 +1058,11 @@ m_cljset(struct mbuf *m, void *cl, int type)
10561058 case EXT_CLUSTER:
10571059 size = MCLBYTES;
10581060 break;
1061#if MJUMPAGESIZE != MCLBYTES
10591062 case EXT_JUMBOP:
10601063 size = MJUMPAGESIZE;
10611064 break;
1065#endif
10621066 case EXT_JUMBO9:
10631067 size = MJUM9BYTES;
10641068 break;
......@@ -1110,7 +1114,7 @@ static inline u_int
11101114m_extrefcnt(struct mbuf *m)
11111115{
11121116
1113 KASSERT(m->m_flags & M_EXT, ("%s: M_EXT missing", __func__));
1117 KASSERT(m->m_flags & M_EXT, ("%s: M_EXT missing for %p", __func__, m));
11141118
11151119 return ((m->m_ext.ext_flags & EXT_FLAG_EMBREF) ? m->m_ext.ext_count :
11161120 *m->m_ext.ext_cnt);
......@@ -1142,13 +1146,13 @@ m_extrefcnt(struct mbuf *m)
11421146/* Check if the supplied mbuf has a packet header, or else panic. */
11431147#define M_ASSERTPKTHDR(m) \
11441148 KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \
1145 ("%s: no mbuf packet header!", __func__))
1149 ("%s: no mbuf %p packet header!", __func__, (m)))
11461150
11471151/* Check if the supplied mbuf has no send tag, or else panic. */
11481152#define M_ASSERT_NO_SND_TAG(m) \
11491153 KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR && \
11501154 ((m)->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0, \
1151 ("%s: receive mbuf has send tag!", __func__))
1155 ("%s: receive mbuf %p has send tag!", __func__, (m)))
11521156
11531157/* Check if mbuf is multipage. */
11541158#define M_ASSERTEXTPG(m) \
......@@ -1162,7 +1166,7 @@ m_extrefcnt(struct mbuf *m)
11621166 */
11631167#define M_ASSERTVALID(m) \
11641168 KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \
1165 ("%s: attempted use of a free mbuf!", __func__))
1169 ("%s: attempted use of a free mbuf %p!", __func__, (m)))
11661170
11671171/* Check whether any mbuf in the chain is unmapped. */
11681172#ifdef INVARIANTS
......@@ -1207,12 +1211,9 @@ m_extrefcnt(struct mbuf *m)
12071211static __inline void
12081212m_align(struct mbuf *m, int len)
12091213{
1210#ifdef INVARIANTS
1211 const char *msg = "%s: not a virgin mbuf";
1212#endif
12131214 int adjust;
1214
1215 KASSERT(m->m_data == M_START(m), (msg, __func__));
1215 KASSERT(m->m_data == M_START(m),
1216 ("%s: not a virgin mbuf %p", __func__, m));
12161217
12171218 adjust = M_SIZE(m) - len;
12181219 m->m_data += adjust &~ (sizeof(long)-1);
......@@ -1387,6 +1388,9 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */
13871388#define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */
13881389#define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */
13891390#define PACKET_TAG_PF_REASSEMBLED 31
1391#define PACKET_TAG_IPSEC_ACCEL_OUT 32 /* IPSEC accel out */
1392#define PACKET_TAG_IPSEC_ACCEL_IN 33 /* IPSEC accel in */
1393#define PACKET_TAG_OVPN 34 /* if_ovpn */
13901394
13911395/* Specific cookies and tags. */
13921396
......@@ -1530,14 +1534,16 @@ m_free(struct mbuf *m)
15301534static __inline int
15311535rt_m_getfib(struct mbuf *m)
15321536{
1533 KASSERT(m->m_flags & M_PKTHDR , ("Attempt to get FIB from non header mbuf."));
1537 KASSERT(m->m_flags & M_PKTHDR,
1538 ("%s: Attempt to get FIB from non header mbuf %p", __func__, m));
15341539 return (m->m_pkthdr.fibnum);
15351540}
15361541
15371542#define M_GETFIB(_m) rt_m_getfib(_m)
15381543
15391544#define M_SETFIB(_m, _fib) do { \
1540 KASSERT((_m)->m_flags & M_PKTHDR, ("Attempt to set FIB on non header mbuf.")); \
1545 KASSERT((_m)->m_flags & M_PKTHDR, \
1546 ("%s: Attempt to set FIB on non header mbuf %p", __func__, (_m))); \
15411547 ((_m)->m_pkthdr.fibnum) = (_fib); \
15421548} while (0)
15431549
......@@ -1559,6 +1565,10 @@ uint32_t m_infiniband_tcpip_hash(const uint32_t, const struct mbuf *, uint32_t);
15591565 #define M_PROFILE(m)
15601566#endif
15611567
1568/*
1569 * Structure describing a packet queue: mbufs linked by m_stailqpkt.
1570 * Does accounting of number of packets and has a cap.
1571 */
15621572struct mbufq {
15631573 STAILQ_HEAD(, mbuf) mq_head;
15641574 int mq_len;
......@@ -1676,14 +1686,137 @@ mbufq_concat(struct mbufq *mq_dst, struct mbufq *mq_src)
16761686 mq_src->mq_len = 0;
16771687}
16781688
1689/*
1690 * Structure describing a chain of mbufs linked by m_stailq, also tracking
1691 * the pointer to the last. Also does accounting of data length and memory
1692 * usage.
1693 * To be used as an argument to mbuf chain allocation and manipulation KPIs,
1694 * and can be allocated on the stack of a caller. Kernel facilities may use
1695 * it internally as a most simple implementation of a stream data buffer.
1696 */
1697struct mchain {
1698 STAILQ_HEAD(, mbuf) mc_q;
1699 u_int mc_len;
1700 u_int mc_mlen;
1701};
1702
1703#define MCHAIN_INITIALIZER(mc) \
1704 (struct mchain){ .mc_q = STAILQ_HEAD_INITIALIZER((mc)->mc_q) }
1705
1706static inline struct mbuf *
1707mc_first(struct mchain *mc)
1708{
1709 return (STAILQ_FIRST(&mc->mc_q));
1710}
1711
1712static inline struct mbuf *
1713mc_last(struct mchain *mc)
1714{
1715 return (STAILQ_LAST(&mc->mc_q, mbuf, m_stailq));
1716}
1717
1718static inline bool
1719mc_empty(struct mchain *mc)
1720{
1721 return (STAILQ_EMPTY(&mc->mc_q));
1722}
1723
1724/* Account addition of m to mc. */
1725static inline void
1726mc_inc(struct mchain *mc, struct mbuf *m)
1727{
1728 mc->mc_len += m->m_len;
1729 mc->mc_mlen += MSIZE;
1730 if (m->m_flags & M_EXT)
1731 mc->mc_mlen += m->m_ext.ext_size;
1732}
1733
1734/* Account removal of m from mc. */
1735static inline void
1736mc_dec(struct mchain *mc, struct mbuf *m)
1737{
1738 MPASS(mc->mc_len >= m->m_len);
1739 mc->mc_len -= m->m_len;
1740 MPASS(mc->mc_mlen >= MSIZE);
1741 mc->mc_mlen -= MSIZE;
1742 if (m->m_flags & M_EXT) {
1743 MPASS(mc->mc_mlen >= m->m_ext.ext_size);
1744 mc->mc_mlen -= m->m_ext.ext_size;
1745 }
1746}
1747
1748/*
1749 * Get mchain from a classic mbuf chain linked by m_next. Two hacks here:
1750 * we use the fact that m_next is alias to m_stailq, we use internal queue(3)
1751 * fields.
1752 */
1753static inline void
1754mc_init_m(struct mchain *mc, struct mbuf *m)
1755{
1756 struct mbuf *last;
1757
1758 STAILQ_FIRST(&mc->mc_q) = m;
1759 mc->mc_len = mc->mc_mlen = 0;
1760 STAILQ_FOREACH(m, &mc->mc_q, m_stailq) {
1761 mc_inc(mc, m);
1762 last = m;
1763 }
1764 mc->mc_q.stqh_last = &STAILQ_NEXT(last, m_stailq);
1765}
1766
1767static inline void
1768mc_freem(struct mchain *mc)
1769{
1770 if (!mc_empty(mc))
1771 m_freem(mc_first(mc));
1772}
1773
1774static inline void
1775mc_prepend(struct mchain *mc, struct mbuf *m)
1776{
1777 STAILQ_INSERT_HEAD(&mc->mc_q, m, m_stailq);
1778 mc_inc(mc, m);
1779}
1780
1781static inline void
1782mc_append(struct mchain *mc, struct mbuf *m)
1783{
1784 STAILQ_INSERT_TAIL(&mc->mc_q, m, m_stailq);
1785 mc_inc(mc, m);
1786}
1787
1788static inline void
1789mc_concat(struct mchain *head, struct mchain *tail)
1790{
1791 STAILQ_CONCAT(&head->mc_q, &tail->mc_q);
1792 head->mc_len += tail->mc_len;
1793 head->mc_mlen += tail->mc_mlen;
1794 tail->mc_len = tail->mc_mlen = 0;
1795}
1796
1797/*
1798 * Note: STAILQ_REMOVE() is expensive. mc_remove_after() needs to be provided
1799 * as long as there consumers that would benefit from it.
1800 */
1801static inline void
1802mc_remove(struct mchain *mc, struct mbuf *m)
1803{
1804 STAILQ_REMOVE(&mc->mc_q, m, mbuf, m_stailq);
1805 mc_dec(mc, m);
1806}
1807
1808int mc_get(struct mchain *, u_int, int, short, int);
1809int mc_split(struct mchain *, struct mchain *, u_int, int);
1810int mc_uiotomc(struct mchain *, struct uio *, u_int, u_int, int, int);
1811
16791812#ifdef _SYS_TIMESPEC_H_
16801813static inline void
16811814mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts)
16821815{
16831816
1684 KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m));
1817 M_ASSERTPKTHDR(m);
16851818 KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0,
1686 ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m));
1819 ("%s: mbuf %p no M_TSTMP or M_TSTMP_LRO", __func__, m));
16871820 ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
16881821 ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000;
16891822}
......@@ -1693,9 +1826,9 @@ static inline void
16931826mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv)
16941827{
16951828
1696 KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m));
1829 M_ASSERTPKTHDR(m);
16971830 KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0,
1698 ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m));
1831 ("%s: mbuf %p no M_TSTMP or M_TSTMP_LRO", __func__, m));
16991832 tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
17001833 tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000;
17011834}
lib/libc/include/generic-freebsd/sys/md4.h+44-4
......@@ -25,8 +25,8 @@
2525 documentation and/or software.
2626 */
2727
28#ifndef _MD4_H_
29#define _MD4_H_
28#ifndef _SYS_MD4_H_
29#define _SYS_MD4_H_
3030/* MD4 context. */
3131typedef struct MD4Context {
3232 u_int32_t state[4]; /* state (ABCD) */
......@@ -36,6 +36,43 @@ typedef struct MD4Context {
3636
3737#include <sys/cdefs.h>
3838
39#ifndef _KERNEL
40
41/* Ensure libmd symbols do not clash with libcrypto */
42
43#ifndef MD4Init
44#define MD4Init _libmd_MD4Init
45#endif
46#ifndef MD4Update
47#define MD4Update _libmd_MD4Update
48#endif
49#ifndef MD4Pad
50#define MD4Pad _libmd_MD4Pad
51#endif
52#ifndef MD4Final
53#define MD4Final _libmd_MD4Final
54#endif
55#ifndef MD4End
56#define MD4End _libmd_MD4End
57#endif
58#ifndef MD4Fd
59#define MD4Fd _libmd_MD4Fd
60#endif
61#ifndef MD4FdChunk
62#define MD4FdChunk _libmd_MD4FdChunk
63#endif
64#ifndef MD4File
65#define MD4File _libmd_MD4File
66#endif
67#ifndef MD4FileChunk
68#define MD4FileChunk _libmd_MD4FileChunk
69#endif
70#ifndef MD4Data
71#define MD4Data _libmd_MD4Data
72#endif
73
74#endif
75
3976__BEGIN_DECLS
4077void MD4Init(MD4_CTX *);
4178void MD4Update(MD4_CTX *, const unsigned char *, unsigned int);
......@@ -43,9 +80,12 @@ void MD4Pad(MD4_CTX *);
4380void MD4Final(unsigned char [__min_size(16)], MD4_CTX *);
4481#ifndef _KERNEL
4582char * MD4End(MD4_CTX *, char *);
83char * MD4Fd(int, char *);
84char * MD4FdChunk(int, char *, off_t, off_t);
4685char * MD4File(const char *, char *);
47char * MD4Data(const unsigned char *, unsigned int, char *);
86char * MD4FileChunk(const char *, char *, off_t, off_t);
87char * MD4Data(const void *, unsigned int, char *);
4888#endif
4989__END_DECLS
5090
51#endif /* _MD4_H_ */
\ No newline at end of file
91#endif /* _SYS_MD4_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/md5.h+42
......@@ -29,6 +29,8 @@ documentation and/or software.
2929#ifndef _SYS_MD5_H_
3030#define _SYS_MD5_H_
3131
32#include <sys/types.h>
33
3234#define MD5_BLOCK_LENGTH 64
3335#define MD5_DIGEST_LENGTH 16
3436#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
......@@ -40,6 +42,46 @@ typedef struct MD5Context {
4042 unsigned char buffer[64]; /* input buffer */
4143} MD5_CTX;
4244
45#ifndef _KERNEL
46
47/* Ensure libmd symbols do not clash with libcrypto */
48
49#ifndef MD5Init
50#define MD5Init _libmd_MD5Init
51#endif
52#ifndef MD5Update
53#define MD5Update _libmd_MD5Update
54#endif
55#ifndef MD5Pad
56#define MD5Pad _libmd_MD5Pad
57#endif
58#ifndef MD5Final
59#define MD5Final _libmd_MD5Final
60#endif
61#ifndef MD5Transform
62#define MD5Transform _libmd_MD5Transform
63#endif
64#ifndef MD5End
65#define MD5End _libmd_MD5End
66#endif
67#ifndef MD5Fd
68#define MD5Fd _libmd_MD5Fd
69#endif
70#ifndef MD5FdChunk
71#define MD5FdChunk _libmd_MD5FdChunk
72#endif
73#ifndef MD5File
74#define MD5File _libmd_MD5File
75#endif
76#ifndef MD5FileChunk
77#define MD5FileChunk _libmd_MD5FileChunk
78#endif
79#ifndef MD5Data
80#define MD5Data _libmd_MD5Data
81#endif
82
83#endif
84
4385#include <sys/cdefs.h>
4486
4587__BEGIN_DECLS
lib/libc/include/generic-freebsd/sys/mdioctl.h-4
......@@ -34,10 +34,6 @@
3434 * SUCH DAMAGE.
3535 *
3636 * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$
37 *
38 * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93
39 *
40 * From: src/sys/sys/vnioctl.h,v 1.4
4137 */
4238
4339#ifndef _SYS_MDIOCTL_H_
lib/libc/include/generic-freebsd/sys/memdesc.h+36
......@@ -163,4 +163,40 @@ void memdesc_copyback(struct memdesc *mem, int off, int size,
163163 const void *src);
164164void memdesc_copydata(struct memdesc *mem, int off, int size, void *dst);
165165
166/*
167 * This routine constructs a chain of M_EXT mbufs backed by a data
168 * buffer described by a memory descriptor. Some buffers may require
169 * multiple mbufs. For memory descriptors using unmapped storage
170 * (e.g. memdesc_vmpages), M_EXTPG mbufs are used.
171 *
172 * Since memory descriptors are not an actual buffer, just a
173 * description of the buffer, the caller is required to supply a
174 * couple of helper routines to manage allocation of the raw mbufs and
175 * associate them with a reference to the underlying buffer.
176 *
177 * The memdesc_alloc_ext_mbuf_t callback is passed the callback
178 * argument as its first argument, the how flag as its second
179 * argument, and the pointer and length of a KVA buffer. This
180 * callback should allocate an mbuf for the KVA buffer, either by
181 * making a copy of the data or using m_extaddref().
182 *
183 * The memdesc_alloc_extpg_mbuf_t callback is passed the callback
184 * argument as its first argument and the how flag as its second
185 * argument. It should return an empty mbuf allocated by
186 * mb_alloc_ext_pgs.
187 *
188 * If either of the callbacks returns NULL, any partially allocated
189 * chain is freed and this routine returns NULL.
190 *
191 * If can_truncate is true, then this function might return a short
192 * chain to avoid gratuitously splitting up a page.
193 */
194typedef struct mbuf *memdesc_alloc_ext_mbuf_t(void *, int, void *, size_t);
195typedef struct mbuf *memdesc_alloc_extpg_mbuf_t(void *, int);
196
197struct mbuf *memdesc_alloc_ext_mbufs(struct memdesc *mem,
198 memdesc_alloc_ext_mbuf_t *ext_alloc,
199 memdesc_alloc_extpg_mbuf_t *extpg_alloc, void *cb_arg, int how,
200 size_t offset, size_t len, size_t *actual_len, bool can_truncate);
201
166202#endif /* _SYS_MEMDESC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/mman.h+18-16
......@@ -27,12 +27,10 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)mman.h 8.2 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_MMAN_H_
35#define _SYS_MMAN_H_
33#define _SYS_MMAN_H_
3634
3735#include <sys/cdefs.h>
3836#include <sys/_types.h>
......@@ -41,10 +39,10 @@
4139/*
4240 * Inheritance for minherit()
4341 */
44#define INHERIT_SHARE 0
45#define INHERIT_COPY 1
46#define INHERIT_NONE 2
47#define INHERIT_ZERO 3
42#define INHERIT_SHARE 0
43#define INHERIT_COPY 1
44#define INHERIT_NONE 2
45#define INHERIT_ZERO 3
4846#endif
4947
5048/*
......@@ -55,6 +53,8 @@
5553#define PROT_WRITE 0x02 /* pages can be written */
5654#define PROT_EXEC 0x04 /* pages can be executed */
5755#if __BSD_VISIBLE
56#define PROT_CHERI0 0x08
57#define PROT_CHERI1 0x10
5858#define _PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
5959#define PROT_EXTRACT(prot) ((prot) & _PROT_ALL)
6060
......@@ -120,9 +120,9 @@
120120 * Flags provided to shm_rename
121121 */
122122/* Don't overwrite dest, if it exists */
123#define SHM_RENAME_NOREPLACE (1 << 0)
123#define SHM_RENAME_NOREPLACE (1 << 0)
124124/* Atomically swap src and dest */
125#define SHM_RENAME_EXCHANGE (1 << 1)
125#define SHM_RENAME_EXCHANGE (1 << 1)
126126
127127#endif /* __BSD_VISIBLE */
128128
......@@ -130,21 +130,21 @@
130130/*
131131 * Process memory locking
132132 */
133#define MCL_CURRENT 0x0001 /* Lock only current memory */
134#define MCL_FUTURE 0x0002 /* Lock all future memory as well */
133#define MCL_CURRENT 0x0001 /* Lock only current memory */
134#define MCL_FUTURE 0x0002 /* Lock all future memory as well */
135135#endif
136136
137137/*
138138 * Error return from mmap()
139139 */
140#define MAP_FAILED ((void *)-1)
140#define MAP_FAILED ((void *)-1)
141141
142142/*
143143 * msync() flags
144144 */
145145#define MS_SYNC 0x0000 /* msync synchronously */
146#define MS_ASYNC 0x0001 /* return immediately */
147#define MS_INVALIDATE 0x0002 /* invalidate all cached data */
146#define MS_ASYNC 0x0001 /* return immediately */
147#define MS_INVALIDATE 0x0002 /* invalidate all cached data */
148148
149149/*
150150 * Advice to madvise
......@@ -177,7 +177,9 @@
177177#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
178178#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */
179179#define MINCORE_SUPER 0x60 /* Page is a "super" page */
180#define MINCORE_PSIND(i) (((i) << 5) & MINCORE_SUPER) /* Page size */
180#define MINCORE_PSIND_SHIFT 5
181#define MINCORE_PSIND(i) (((i) << MINCORE_PSIND_SHIFT) & MINCORE_SUPER)
182 /* Page size */
181183
182184/*
183185 * Anonymous object constant for shm_open().
......@@ -312,7 +314,7 @@ bool shm_largepage(struct shmfd *shmfd);
312314void shm_remove_prison(struct prison *pr);
313315int shm_get_path(struct vm_object *obj, char *path, size_t sz);
314316
315extern struct fileops shm_ops;
317extern const struct fileops shm_ops;
316318
317319#define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31)
318320
lib/libc/include/generic-freebsd/sys/mount.h+12-4
......@@ -27,22 +27,24 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)mount.h 8.21 (Berkeley) 5/20/95
3230 */
3331
3432#ifndef _SYS_MOUNT_H_
3533#define _SYS_MOUNT_H_
3634
35#include <sys/types.h>
3736#include <sys/ucred.h>
3837#include <sys/queue.h>
3938#ifdef _KERNEL
40#include <sys/types.h>
4139#include <sys/lock.h>
4240#include <sys/lockmgr.h>
4341#include <sys/tslog.h>
4442#include <sys/_mutex.h>
4543#include <sys/_sx.h>
44#elif defined(_WANT_MOUNT)
45#include <sys/_lock.h>
46#include <sys/_lockmgr.h>
47#include <sys/_mutex.h>
4648#endif
4749
4850/*
......@@ -265,6 +267,7 @@ struct mount {
265267 int mnt_lazyvnodelistsize; /* (l) # of lazy vnodes */
266268 int mnt_upper_pending; /* (i) # of pending ops on mnt_uppers */
267269 struct lock mnt_explock; /* vfs_export walkers lock */
270 struct lock mnt_renamelock; /* renames and O_RESOLVE_BENEATH */
268271 TAILQ_HEAD(, mount_upper_node) mnt_uppers; /* (i) upper mounts over us */
269272 TAILQ_HEAD(, mount_upper_node) mnt_notify; /* (i) upper mounts for notification */
270273 STAILQ_ENTRY(mount) mnt_taskqueue_link; /* (d) our place in deferred unmount list */
......@@ -367,6 +370,7 @@ struct mntoptnames {
367370 { MNT_RELOAD, "reload" }, \
368371 { MNT_FORCE, "force" }, \
369372 { MNT_SNAPSHOT, "snapshot" }, \
373 { MNT_NAMEDATTR, "named attributes" }, \
370374 { 0, NULL }
371375#endif
372376
......@@ -392,6 +396,7 @@ struct mntoptnames {
392396#define MNT_SUJ 0x0000000100000000ULL /* using journaled soft updates */
393397#define MNT_AUTOMOUNTED 0x0000000200000000ULL /* mounted by automountd(8) */
394398#define MNT_UNTRUSTED 0x0000000800000000ULL /* filesys metadata untrusted */
399#define MNT_NAMEDATTR 0x0000020000000000ULL /* named attributes enabled */
395400
396401/*
397402 * NFS export related mount flags.
......@@ -431,7 +436,7 @@ struct mntoptnames {
431436 MNT_IGNORE | MNT_EXPUBLIC | MNT_NOSYMFOLLOW | \
432437 MNT_GJOURNAL | MNT_MULTILABEL | MNT_ACLS | \
433438 MNT_NFS4ACLS | MNT_AUTOMOUNTED | MNT_VERIFIED | \
434 MNT_UNTRUSTED)
439 MNT_UNTRUSTED | MNT_NAMEDATTR)
435440
436441/* Mask of flags that can be updated. */
437442#define MNT_UPDATEMASK (MNT_NOSUID | MNT_NOEXEC | \
......@@ -687,6 +692,8 @@ struct ovfsconf {
687692#define VFCF_SBDRY 0x01000000 /* Stop at Boundary: defer stop requests
688693 to kernel->user (AST) transition */
689694#define VFCF_FILEMOUNT 0x02000000 /* allow mounting files */
695#define VFCF_FILEREVINC 0x04000000 /* va_filerev is incr. by one */
696#define VFCF_FILEREVCT 0x08000000 /* va_filerev is set to ctime */
690697
691698typedef uint32_t fsctlop_t;
692699
......@@ -1000,6 +1007,7 @@ struct mntarg *mount_argsu(struct mntarg *ma, const char *name, const void *val,
10001007void statfs_scale_blocks(struct statfs *sf, long max_size);
10011008struct vfsconf *vfs_byname(const char *);
10021009struct vfsconf *vfs_byname_kld(const char *, struct thread *td, int *);
1010void vfs_unref_vfsconf(struct vfsconf *vfsp);
10031011void vfs_mount_destroy(struct mount *);
10041012void vfs_event_signal(fsid_t *, u_int32_t, intptr_t);
10051013void vfs_freeopts(struct vfsoptlist *opts);
lib/libc/include/generic-freebsd/sys/msg.h-3
......@@ -162,9 +162,6 @@ int msgctl(int, int, struct msqid_ds *);
162162int msgget(key_t, int);
163163ssize_t msgrcv(int, void *, size_t, long, int);
164164int msgsnd(int, const void *, size_t, int);
165#if __BSD_VISIBLE
166int msgsys(int, ...);
167#endif
168165__END_DECLS
169166#endif /* !_KERNEL */
170167
lib/libc/include/generic-freebsd/sys/msgbuf.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_MSGBUF_H_
lib/libc/include/generic-freebsd/sys/mtio.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)mtio.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_MTIO_H_
lib/libc/include/generic-freebsd/sys/mutex.h+1-1
......@@ -91,7 +91,7 @@
9191void _mtx_init(volatile uintptr_t *c, const char *name, const char *type,
9292 int opts);
9393void _mtx_destroy(volatile uintptr_t *c);
94void mtx_sysinit(void *arg);
94void mtx_sysinit(const void *arg);
9595int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF);
9696int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file,
9797 int line);
lib/libc/include/generic-freebsd/sys/namei.h+26-8
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)namei.h 8.5 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_NAMEI_H_
......@@ -40,6 +38,8 @@
4038#include <sys/_seqc.h>
4139#include <sys/_uio.h>
4240
41#include <vm/uma.h>
42
4343enum nameiop { LOOKUP, CREATE, DELETE, RENAME };
4444
4545struct componentname {
......@@ -70,7 +70,7 @@ struct nameidata {
7070 */
7171 const char *ni_dirp; /* pathname pointer */
7272 enum uio_seg ni_segflg; /* location of pathname */
73 cap_rights_t *ni_rightsneeded; /* rights required to look up vnode */
73 const cap_rights_t *ni_rightsneeded; /* rights needed to look up vnode */
7474 /*
7575 * Arguments to lookup.
7676 */
......@@ -108,7 +108,12 @@ struct nameidata {
108108 * through the VOP interface.
109109 */
110110 struct componentname ni_cnd;
111
112 /* Serving RBENEATH. */
111113 struct nameicap_tracker_head ni_cap_tracker;
114 struct vnode *ni_rbeneath_dpp;
115 struct mount *ni_nctrack_mnt;
116
112117 /*
113118 * Private helper data for UFS, must be at the end. See
114119 * NDINIT_PREFILL().
......@@ -152,6 +157,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
152157#define LOCKSHARED 0x0100 /* Shared lock leaf */
153158#define NOFOLLOW 0x0000 /* do not follow symbolic links (pseudo) */
154159#define RBENEATH 0x100000000ULL /* No escape, even tmp, from start dir */
160#define NAMEILOOKUP 0x200000000ULL /* cnp is embedded in nameidata */
155161#define MODMASK 0xf000001ffULL /* mask of operational modifiers */
156162
157163/*
......@@ -159,7 +165,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
159165 */
160166#define RDONLY 0x00000200 /* lookup with read-only semantics */
161167#define ISRESTARTED 0x00000400 /* restarted namei */
162/* UNUSED 0x00000800 */
168#define IGNOREWHITEOUT 0x00000800 /* ignore whiteouts, e.g. when checking if a dir is empty */
163169#define ISWHITEOUT 0x00001000 /* found whiteout */
164170#define DOWHITEOUT 0x00002000 /* do whiteouts */
165171#define WILLBEDIR 0x00004000 /* new files will be dirs; allow trailing / */
......@@ -172,14 +178,15 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
172178#define OPENREAD 0x00200000 /* open for reading */
173179#define OPENWRITE 0x00400000 /* open for writing */
174180#define WANTIOCTLCAPS 0x00800000 /* leave ioctl caps for the caller */
175/* UNUSED 0x01000000 */
181#define OPENNAMED 0x01000000 /* opening a named attribute (dir) */
176182#define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */
177183#define MAKEENTRY 0x04000000 /* entry is to be added to name cache */
178184#define ISSYMLINK 0x08000000 /* symlink needs interpretation */
179185#define ISLASTCN 0x10000000 /* this is last component of pathname */
180186#define ISDOTDOT 0x20000000 /* current component name is .. */
181187#define TRAILINGSLASH 0x40000000 /* path ended in a slash */
182#define PARAMASK 0x7ffffe00 /* mask of parameter descriptors */
188#define CREATENAMED 0x80000000 /* create a named attribute dir */
189#define PARAMASK 0xfffffe00 /* mask of parameter descriptors */
183190
184191/*
185192 * Flags which must not be passed in by callers.
......@@ -194,6 +201,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
194201#define NIRES_ABS 0x00000001 /* Path was absolute */
195202#define NIRES_STRICTREL 0x00000002 /* Restricted lookup result */
196203#define NIRES_EMPTYPATH 0x00000004 /* EMPTYPATH used */
204#define NIRES_BENEATH 0x00000008 /* O_RESOLVE_BENEATH is to be inherited */
197205
198206/*
199207 * Flags in ni_lcf, valid for the duration of the namei call.
......@@ -232,6 +240,10 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
232240 panic("namei data not inited"); \
233241 if (((arg)->ni_debugflags & NAMEI_DBG_HADSTARTDIR) != 0) \
234242 panic("NDREINIT on namei data with NAMEI_DBG_HADSTARTDIR"); \
243 if ((arg)->ni_nctrack_mnt != NULL) \
244 panic("NDREINIT on namei data with leaked ni_nctrack_mnt"); \
245 if (!TAILQ_EMPTY(&(arg)->ni_cap_tracker)) \
246 panic("NDREINIT on namei data with leaked ni_cap_tracker"); \
235247 (arg)->ni_debugflags = NAMEI_DBG_INITED; \
236248}
237249#else
......@@ -243,12 +255,12 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
243255#define NDINIT_ALL(ndp, op, flags, segflg, namep, dirfd, startdir, rightsp) \
244256do { \
245257 struct nameidata *_ndp = (ndp); \
246 cap_rights_t *_rightsp = (rightsp); \
258 const cap_rights_t *_rightsp = (rightsp); \
247259 MPASS(_rightsp != NULL); \
248260 NDINIT_PREFILL(_ndp); \
249261 NDINIT_DBG(_ndp); \
250262 _ndp->ni_cnd.cn_nameiop = op; \
251 _ndp->ni_cnd.cn_flags = flags; \
263 _ndp->ni_cnd.cn_flags = (flags) | NAMEILOOKUP; \
252264 _ndp->ni_segflg = segflg; \
253265 _ndp->ni_dirp = namep; \
254266 _ndp->ni_dirfd = dirfd; \
......@@ -256,6 +268,9 @@ do { \
256268 _ndp->ni_resflags = 0; \
257269 filecaps_init(&_ndp->ni_filecaps); \
258270 _ndp->ni_rightsneeded = _rightsp; \
271 _ndp->ni_rbeneath_dpp = NULL; \
272 _ndp->ni_nctrack_mnt = NULL; \
273 TAILQ_INIT(&_ndp->ni_cap_tracker); \
259274} while (0)
260275
261276#define NDREINIT(ndp) do { \
......@@ -264,6 +279,7 @@ do { \
264279 filecaps_free(&_ndp->ni_filecaps); \
265280 _ndp->ni_resflags = 0; \
266281 _ndp->ni_startdir = NULL; \
282 _ndp->ni_cnd.cn_flags &= ~NAMEI_INTERNAL_FLAGS; \
267283} while (0)
268284
269285#define NDPREINIT(ndp) do { \
......@@ -285,6 +301,8 @@ do { \
285301
286302int namei(struct nameidata *ndp);
287303int vfs_lookup(struct nameidata *ndp);
304bool vfs_lookup_isroot(struct nameidata *ndp, struct vnode *dvp);
305struct nameidata *vfs_lookup_nameidata(struct componentname *cnp);
288306int vfs_relookup(struct vnode *dvp, struct vnode **vpp,
289307 struct componentname *cnp, bool refstart);
290308
lib/libc/include/generic-freebsd/sys/nlist_aout.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)nlist.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_NLIST_AOUT_H_
lib/libc/include/generic-freebsd/sys/nv.h+1-7
......@@ -34,6 +34,7 @@
3434#define _NV_H_
3535
3636#include <sys/cdefs.h>
37#include <sys/_nv.h>
3738
3839#ifndef _KERNEL
3940#include <stdarg.h>
......@@ -43,13 +44,6 @@
4344#include <sys/nv_namespace.h>
4445#endif
4546
46#ifndef _NVLIST_T_DECLARED
47#define _NVLIST_T_DECLARED
48struct nvlist;
49
50typedef struct nvlist nvlist_t;
51#endif
52
5347#define NV_NAME_MAX 2048
5448
5549#define NV_TYPE_NONE 0
lib/libc/include/generic-freebsd/sys/nvpair.h+3
......@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: CDDL-1.0
12/*
23 * CDDL HEADER START
34 *
......@@ -266,6 +267,8 @@ _SYS_NVPAIR_H int nvlist_lookup_double(const nvlist_t *, const char *,
266267 double *);
267268#endif
268269
270_SYS_NVPAIR_H int nvlist_snprintf(char *, size_t, nvlist_t *, int);
271
269272_SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);
270273_SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *,
271274 nvpair_t **, int *, const char **);
lib/libc/include/generic-freebsd/sys/osd.h+6-1
......@@ -55,7 +55,7 @@ typedef void (*osd_destructor_t)(void *value);
5555typedef int (*osd_method_t)(void *obj, void *data);
5656
5757int osd_register(u_int type, osd_destructor_t destructor,
58 osd_method_t *methods);
58 const osd_method_t *methods);
5959void osd_deregister(u_int type, u_int slot);
6060
6161int osd_set(u_int type, struct osd *osd, u_int slot, void *value);
......@@ -64,6 +64,7 @@ int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv,
6464 void *value);
6565void osd_free_reserved(void **rsv);
6666void *osd_get(u_int type, struct osd *osd, u_int slot);
67void *osd_get_unlocked(u_int type, struct osd *osd, u_int slot);
6768void osd_del(u_int type, struct osd *osd, u_int slot);
6869int osd_call(u_int type, u_int method, void *obj, void *data);
6970
......@@ -79,6 +80,8 @@ void osd_exit(u_int type, struct osd *osd);
7980 osd_set_reserved(OSD_THREAD, &(td)->td_osd, (slot), (rsv), (value))
8081#define osd_thread_get(td, slot) \
8182 osd_get(OSD_THREAD, &(td)->td_osd, (slot))
83#define osd_thread_get_unlocked(td, slot) \
84 osd_get_unlocked(OSD_THREAD, &(td)->td_osd, (slot))
8285#define osd_thread_del(td, slot) do { \
8386 KASSERT((td) == curthread, ("Not curthread.")); \
8487 osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \
......@@ -98,6 +101,8 @@ void osd_exit(u_int type, struct osd *osd);
98101 osd_set_reserved(OSD_JAIL, &(pr)->pr_osd, (slot), (rsv), (value))
99102#define osd_jail_get(pr, slot) \
100103 osd_get(OSD_JAIL, &(pr)->pr_osd, (slot))
104#define osd_jail_get_unlocked(pr, slot) \
105 osd_get_unlocked(OSD_JAIL, &(pr)->pr_osd, (slot))
101106#define osd_jail_del(pr, slot) \
102107 osd_del(OSD_JAIL, &(pr)->pr_osd, (slot))
103108#define osd_jail_call(pr, method, data) \
lib/libc/include/generic-freebsd/sys/param.h+18-26
......@@ -32,14 +32,13 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)param.h 8.3 (Berkeley) 4/4/95
3735 */
3836
3937#ifndef _SYS_PARAM_H_
4038#define _SYS_PARAM_H_
4139
4240#include <sys/_null.h>
41#include <sys/_param.h>
4342
4443#define BSD 199506 /* System version (year & month). */
4544#define BSD4_3 1
......@@ -107,6 +106,8 @@
107106#define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070
108107#define P_OSREL_TIDPID 1400079
109108#define P_OSREL_ARM64_SPSR 1400084
109#define P_OSREL_TLSBASE 1500044
110#define P_OSREL_EXTERRCTL 1500045
110111
111112#define P_OSREL_MAJOR(x) ((x) / 100000)
112113#endif
......@@ -151,17 +152,16 @@
151152#endif
152153#endif
153154
154#ifndef _KERNEL
155#ifndef LOCORE
155#if !defined(_KERNEL) && !defined(_STANDALONE) && !defined(LOCORE)
156156/* Signals. */
157157#include <sys/signal.h>
158158#endif
159#endif
160159
161160/* Machine type dependent parameters. */
162161#include <machine/param.h>
163162#ifndef _KERNEL
164163#include <sys/limits.h>
164#include <sys/_maxphys.h>
165165#endif
166166
167167#ifndef DEV_BSHIFT
......@@ -175,13 +175,6 @@
175175#ifndef DFLTPHYS
176176#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */
177177#endif
178#ifndef MAXPHYS /* max raw I/O transfer size */
179#ifdef __ILP32__
180#define MAXPHYS (128 * 1024)
181#else
182#define MAXPHYS (1024 * 1024)
183#endif
184#endif
185178#ifndef MAXDUMPPGS
186179#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
187180#endif
......@@ -209,6 +202,17 @@
209202#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */
210203#define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */
211204
205/*
206 * Mach derived conversion macros
207 */
208#define round_page(x) roundup2(x, PAGE_SIZE)
209#define trunc_page(x) rounddown2(x, PAGE_SIZE)
210
211#define atop(x) ((x) >> PAGE_SHIFT)
212#define ptoa(x) ((x) << PAGE_SHIFT)
213
214#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
215
212216/*
213217 * Some macros for units conversion
214218 */
......@@ -249,9 +253,6 @@
249253
250254#define NZERO 0 /* default "nice" */
251255
252#define NBBY 8 /* number of bits in a byte */
253#define NBPW sizeof(int) /* number of bytes per word (integer) */
254
255256#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
256257
257258#define NODEV (dev_t)(-1) /* non-existent device */
......@@ -315,16 +316,7 @@
315316#define isclr(a,i) \
316317 ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
317318
318/* Macros for counting and rounding. */
319#ifndef howmany
320#define howmany(x, y) (((x)+((y)-1))/(y))
321#endif
322#define nitems(x) (sizeof((x)) / sizeof((x)[0]))
323#define rounddown(x, y) (((x)/(y))*(y))
324#define rounddown2(x, y) __align_down(x, y) /* if y is power of two */
325#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
326#define roundup2(x, y) __align_up(x, y) /* if y is powers of two */
327#define powerof2(x) ((((x)-1)&(x))==0)
319/* Macros for counting and rounding provided by <sys/_param.h>. */
328320
329321/* Macros for min/max. */
330322#define MIN(a,b) (((a)<(b))?(a):(b))
......@@ -387,4 +379,4 @@ __END_DECLS
387379 */
388380#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])
389381
390#endif /* _SYS_PARAM_H_ */
382#endif /* _SYS_PARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/pciio.h+6-3
......@@ -66,10 +66,10 @@ struct pci_conf {
6666 struct pcisel pc_sel; /* domain+bus+slot+function */
6767 u_int8_t pc_hdr; /* PCI header type */
6868 u_int16_t pc_subvendor; /* card vendor ID */
69 u_int16_t pc_subdevice; /* card device ID, assigned by
69 u_int16_t pc_subdevice; /* card device ID, assigned by
7070 card vendor */
7171 u_int16_t pc_vendor; /* chip vendor ID */
72 u_int16_t pc_device; /* chip device ID, assigned by
72 u_int16_t pc_device; /* chip device ID, assigned by
7373 chip vendor */
7474 u_int8_t pc_class; /* chip PCI class */
7575 u_int8_t pc_subclass; /* chip PCI subclass */
......@@ -77,6 +77,9 @@ struct pci_conf {
7777 u_int8_t pc_revid; /* chip revision ID */
7878 char pd_name[PCI_MAXNAMELEN + 1]; /* device name */
7979 u_long pd_unit; /* device unit number */
80 int pd_numa_domain; /* device NUMA domain */
81 size_t pc_reported_len;/* length of PCI data reported */
82 char pc_spare[64]; /* space for future fields */
8083};
8184
8285struct pci_match_conf {
......@@ -165,7 +168,6 @@ struct pci_bar_ioreq {
165168#define PCIIO_BAR_MMAP_RW 0x04
166169#define PCIIO_BAR_MMAP_ACTIVATE 0x08
167170
168#define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io)
169171#define PCIOCREAD _IOWR('p', 2, struct pci_io)
170172#define PCIOCWRITE _IOWR('p', 3, struct pci_io)
171173#define PCIOCATTACHED _IOWR('p', 4, struct pci_io)
......@@ -173,5 +175,6 @@ struct pci_bar_ioreq {
173175#define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io)
174176#define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap)
175177#define PCIOCBARIO _IOWR('p', 9, struct pci_bar_ioreq)
178#define PCIOCGETCONF _IOWR('p', 10, struct pci_conf_io)
176179
177180#endif /* !_SYS_PCIIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/pctrie.h+293-20
......@@ -34,8 +34,45 @@
3434#include <sys/_pctrie.h>
3535#include <sys/_smr.h>
3636
37struct pctrie_iter {
38 struct pctrie *ptree;
39 struct pctrie_node *node;
40 uint64_t index;
41 uint64_t limit;
42};
43
44static __inline void
45pctrie_iter_reset(struct pctrie_iter *it)
46{
47 it->node = NULL;
48}
49
50static __inline bool
51pctrie_iter_is_reset(struct pctrie_iter *it)
52{
53 return (it->node == NULL);
54}
55
56static __inline void
57pctrie_iter_init(struct pctrie_iter *it, struct pctrie *ptree)
58{
59 it->ptree = ptree;
60 it->node = NULL;
61 it->limit = 0;
62}
63
64static __inline void
65pctrie_iter_limit_init(struct pctrie_iter *it, struct pctrie *ptree,
66 uint64_t limit)
67{
68 pctrie_iter_init(it, ptree);
69 it->limit = limit;
70}
71
3772#ifdef _KERNEL
3873
74typedef void (*pctrie_cb_t)(void *ptr, void *arg);
75
3976#define PCTRIE_DEFINE_SMR(name, type, field, allocfn, freefn, smr) \
4077 PCTRIE_DEFINE(name, type, field, allocfn, freefn) \
4178 \
......@@ -46,6 +83,19 @@ name##_PCTRIE_LOOKUP_UNLOCKED(struct pctrie *ptree, uint64_t key) \
4683 return name##_PCTRIE_VAL2PTR(pctrie_lookup_unlocked(ptree, \
4784 key, (smr))); \
4885} \
86 \
87static __inline __unused int \
88name##_PCTRIE_LOOKUP_RANGE_UNLOCKED(struct pctrie *ptree, uint64_t key, \
89 struct type *value[], int count) \
90{ \
91 uint64_t **data = (uint64_t **)value; \
92 \
93 count = pctrie_lookup_range_unlocked(ptree, key, data, count, \
94 (smr)); \
95 for (int i = 0; i < count; i++) \
96 value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \
97 return (count); \
98} \
4999
50100#define PCTRIE_DEFINE(name, type, field, allocfn, freefn) \
51101 \
......@@ -57,13 +107,18 @@ CTASSERT(sizeof(((struct type *)0)->field) == sizeof(uint64_t)); \
57107CTASSERT((__offsetof(struct type, field) & (sizeof(uint32_t) - 1)) == 0); \
58108 \
59109static __inline struct type * \
60name##_PCTRIE_VAL2PTR(uint64_t *val) \
110name##_PCTRIE_NZVAL2PTR(uint64_t *val) \
61111{ \
112 return (struct type *) \
113 ((uintptr_t)val - __offsetof(struct type, field)); \
114} \
62115 \
116static __inline struct type * \
117name##_PCTRIE_VAL2PTR(uint64_t *val) \
118{ \
63119 if (val == NULL) \
64120 return (NULL); \
65 return (struct type *) \
66 ((uintptr_t)val - __offsetof(struct type, field)); \
121 return (name##_PCTRIE_NZVAL2PTR(val)); \
67122} \
68123 \
69124static __inline uint64_t * \
......@@ -73,23 +128,87 @@ name##_PCTRIE_PTR2VAL(struct type *ptr) \
73128 return &ptr->field; \
74129} \
75130 \
76static __inline int \
131static __inline __unused int \
132name##_PCTRIE_INSERT_BASE(struct pctrie *ptree, uint64_t *val, \
133 struct pctrie_node **parent, void *parentp, \
134 uint64_t *found, struct type **found_out) \
135{ \
136 struct pctrie_node *child; \
137 \
138 if (__predict_false(found != NULL)) { \
139 *found_out = name##_PCTRIE_VAL2PTR(found); \
140 return (EEXIST); \
141 } \
142 if (parentp != NULL) { \
143 child = allocfn(ptree); \
144 if (__predict_false(child == NULL)) { \
145 if (found_out != NULL) \
146 *found_out = NULL; \
147 return (ENOMEM); \
148 } \
149 pctrie_insert_node(val, *parent, parentp, child); \
150 *parent = child; \
151 } \
152 return (0); \
153} \
154 \
155static __inline __unused int \
77156name##_PCTRIE_INSERT(struct pctrie *ptree, struct type *ptr) \
78157{ \
158 void *parentp; \
79159 struct pctrie_node *parent; \
160 uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \
161 \
162 parentp = pctrie_insert_lookup_strict(ptree, val, &parent); \
163 return (name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \
164 NULL, NULL)); \
165} \
166 \
167static __inline __unused int \
168name##_PCTRIE_FIND_OR_INSERT(struct pctrie *ptree, struct type *ptr, \
169 struct type **found_out_opt) \
170{ \
80171 void *parentp; \
172 struct pctrie_node *parent; \
81173 uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \
174 uint64_t *found; \
82175 \
83 parentp = pctrie_insert_lookup(ptree, val); \
84 if (parentp == NULL) \
85 return (0); \
86 parent = allocfn(ptree); \
87 if (parent == NULL) \
88 return (ENOMEM); \
89 pctrie_insert_node(parentp, parent, val); \
176 parentp = pctrie_insert_lookup(ptree, val, &parent, &found); \
177 return (name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \
178 found, found_out_opt)); \
179} \
180 \
181static __inline __unused int \
182name##_PCTRIE_INSERT_LOOKUP_LE(struct pctrie *ptree, struct type *ptr, \
183 struct type **found_out) \
184{ \
185 struct pctrie_node *parent; \
186 void *parentp; \
187 uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \
188 uint64_t *found; \
189 int retval; \
190 \
191 parentp = pctrie_insert_lookup(ptree, val, &parent, &found); \
192 retval = name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \
193 found, found_out); \
194 if (retval != 0) \
195 return (retval); \
196 found = pctrie_subtree_lookup_lt(ptree, parent, *val); \
197 *found_out = name##_PCTRIE_VAL2PTR(found); \
90198 return (0); \
91199} \
92200 \
201static __inline __unused int \
202name##_PCTRIE_ITER_INSERT(struct pctrie_iter *it, struct type *ptr) \
203{ \
204 void *parentp; \
205 uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \
206 \
207 parentp = pctrie_iter_insert_lookup(it, val); \
208 return (name##_PCTRIE_INSERT_BASE(it->ptree, val, &it->node, \
209 parentp, NULL, NULL)); \
210} \
211 \
93212static __inline __unused struct type * \
94213name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \
95214{ \
......@@ -97,6 +216,30 @@ name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \
97216 return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \
98217} \
99218 \
219static __inline __unused int \
220name##_PCTRIE_LOOKUP_RANGE(struct pctrie *ptree, uint64_t key, \
221 struct type *value[], int count) \
222{ \
223 uint64_t **data = (uint64_t **)value; \
224 \
225 count = pctrie_lookup_range(ptree, key, data, count); \
226 for (int i = 0; i < count; i++) \
227 value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \
228 return (count); \
229} \
230 \
231static __inline __unused int \
232name##_PCTRIE_ITER_LOOKUP_RANGE(struct pctrie_iter *it, uint64_t key, \
233 struct type *value[], int count) \
234{ \
235 uint64_t **data = (uint64_t **)value; \
236 \
237 count = pctrie_iter_lookup_range(it, key, data, count); \
238 for (int i = 0; i < count; i++) \
239 value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \
240 return (count); \
241} \
242 \
100243static __inline __unused struct type * \
101244name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \
102245{ \
......@@ -122,6 +265,108 @@ name##_PCTRIE_RECLAIM(struct pctrie *ptree) \
122265 freefn(ptree, freenode); \
123266} \
124267 \
268/* \
269 * While reclaiming all internal trie nodes, invoke callback(leaf, arg) \
270 * on every leaf in the trie, in order. \
271 */ \
272static __inline __unused void \
273name##_PCTRIE_RECLAIM_CALLBACK(struct pctrie *ptree, \
274 void (*typed_cb)(struct type *, void *), void *arg) \
275{ \
276 struct pctrie_node *freenode, *node; \
277 pctrie_cb_t callback = (pctrie_cb_t)typed_cb; \
278 \
279 for (freenode = pctrie_reclaim_begin_cb(&node, ptree, \
280 callback, __offsetof(struct type, field), arg); \
281 freenode != NULL; \
282 freenode = pctrie_reclaim_resume_cb(&node, \
283 callback, __offsetof(struct type, field), arg)) \
284 freefn(ptree, freenode); \
285} \
286 \
287static __inline __unused struct type * \
288name##_PCTRIE_ITER_LOOKUP(struct pctrie_iter *it, uint64_t index) \
289{ \
290 return name##_PCTRIE_VAL2PTR(pctrie_iter_lookup(it, index)); \
291} \
292 \
293static __inline __unused struct type * \
294name##_PCTRIE_ITER_STRIDE(struct pctrie_iter *it, int stride) \
295{ \
296 return name##_PCTRIE_VAL2PTR(pctrie_iter_stride(it, stride)); \
297} \
298 \
299static __inline __unused struct type * \
300name##_PCTRIE_ITER_NEXT(struct pctrie_iter *it) \
301{ \
302 return name##_PCTRIE_VAL2PTR(pctrie_iter_next(it)); \
303} \
304 \
305static __inline __unused struct type * \
306name##_PCTRIE_ITER_PREV(struct pctrie_iter *it) \
307{ \
308 return name##_PCTRIE_VAL2PTR(pctrie_iter_prev(it)); \
309} \
310 \
311static __inline __unused struct type * \
312name##_PCTRIE_ITER_VALUE(struct pctrie_iter *it) \
313{ \
314 return name##_PCTRIE_VAL2PTR(pctrie_iter_value(it)); \
315} \
316 \
317static __inline __unused struct type * \
318name##_PCTRIE_ITER_LOOKUP_GE(struct pctrie_iter *it, uint64_t index) \
319{ \
320 return name##_PCTRIE_VAL2PTR(pctrie_iter_lookup_ge(it, index)); \
321} \
322 \
323static __inline __unused struct type * \
324name##_PCTRIE_ITER_JUMP_GE(struct pctrie_iter *it, int64_t jump) \
325{ \
326 return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_ge(it, jump)); \
327} \
328 \
329static __inline __unused struct type * \
330name##_PCTRIE_ITER_STEP_GE(struct pctrie_iter *it) \
331{ \
332 return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_ge(it, 1)); \
333} \
334 \
335static __inline __unused struct type * \
336name##_PCTRIE_ITER_LOOKUP_LE(struct pctrie_iter *it, uint64_t index) \
337{ \
338 return name##_PCTRIE_VAL2PTR(pctrie_iter_lookup_le(it, index)); \
339} \
340 \
341static __inline __unused struct type * \
342name##_PCTRIE_ITER_JUMP_LE(struct pctrie_iter *it, int64_t jump) \
343{ \
344 return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_le(it, jump)); \
345} \
346 \
347static __inline __unused struct type * \
348name##_PCTRIE_ITER_STEP_LE(struct pctrie_iter *it) \
349{ \
350 return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_le(it, 1)); \
351} \
352 \
353static __inline __unused void \
354name##_PCTRIE_REMOVE_BASE(struct pctrie *ptree, \
355 struct pctrie_node *freenode) \
356{ \
357 if (freenode != NULL) \
358 freefn(ptree, freenode); \
359} \
360 \
361static __inline __unused void \
362name##_PCTRIE_ITER_REMOVE(struct pctrie_iter *it) \
363{ \
364 struct pctrie_node *freenode; \
365 \
366 pctrie_iter_remove(it, &freenode); \
367 name##_PCTRIE_REMOVE_BASE(it->ptree, freenode); \
368} \
369 \
125370static __inline __unused struct type * \
126371name##_PCTRIE_REPLACE(struct pctrie *ptree, struct type *ptr) \
127372{ \
......@@ -139,8 +384,7 @@ name##_PCTRIE_REMOVE(struct pctrie *ptree, uint64_t key) \
139384 val = pctrie_remove_lookup(ptree, key, &freenode); \
140385 if (val == NULL) \
141386 panic("%s: key not found", __func__); \
142 if (freenode != NULL) \
143 freefn(ptree, freenode); \
387 name##_PCTRIE_REMOVE_BASE(ptree, freenode); \
144388} \
145389 \
146390static __inline __unused struct type * \
......@@ -150,24 +394,53 @@ name##_PCTRIE_REMOVE_LOOKUP(struct pctrie *ptree, uint64_t key) \
150394 struct pctrie_node *freenode; \
151395 \
152396 val = pctrie_remove_lookup(ptree, key, &freenode); \
153 if (freenode != NULL) \
154 freefn(ptree, freenode); \
397 name##_PCTRIE_REMOVE_BASE(ptree, freenode); \
155398 return name##_PCTRIE_VAL2PTR(val); \
156399}
157400
158void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val);
159void pctrie_insert_node(void *parentp,
160 struct pctrie_node *parent, uint64_t *val);
401struct pctrie_iter;
402void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val,
403 struct pctrie_node **parent_out, uint64_t **found_out);
404void *pctrie_insert_lookup_strict(struct pctrie *ptree, uint64_t *val,
405 struct pctrie_node **parent_out);
406void pctrie_insert_node(uint64_t *val, struct pctrie_node *parent,
407 void *parentp, struct pctrie_node *child);
161408uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key);
162uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key);
163uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key);
164409uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key,
165410 smr_t smr);
411int pctrie_lookup_range(struct pctrie *ptree,
412 uint64_t index, uint64_t *value[], int count);
413int pctrie_lookup_range_unlocked(struct pctrie *ptree,
414 uint64_t index, uint64_t *value[], int count, smr_t smr);
415int pctrie_iter_lookup_range(struct pctrie_iter *it, uint64_t index,
416 uint64_t *value[], int count);
417uint64_t *pctrie_iter_lookup(struct pctrie_iter *it, uint64_t index);
418uint64_t *pctrie_iter_stride(struct pctrie_iter *it, int stride);
419uint64_t *pctrie_iter_next(struct pctrie_iter *it);
420uint64_t *pctrie_iter_prev(struct pctrie_iter *it);
421void *pctrie_iter_insert_lookup(struct pctrie_iter *it,
422 uint64_t *val);
423uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key);
424uint64_t *pctrie_iter_lookup_ge(struct pctrie_iter *it, uint64_t index);
425uint64_t *pctrie_iter_jump_ge(struct pctrie_iter *it, int64_t jump);
426uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key);
427uint64_t *pctrie_subtree_lookup_lt(struct pctrie *ptree,
428 struct pctrie_node *node, uint64_t key);
429uint64_t *pctrie_iter_lookup_le(struct pctrie_iter *it, uint64_t index);
430uint64_t *pctrie_iter_jump_le(struct pctrie_iter *it, int64_t jump);
166431struct pctrie_node *pctrie_reclaim_begin(struct pctrie_node **pnode,
167432 struct pctrie *ptree);
168433struct pctrie_node *pctrie_reclaim_resume(struct pctrie_node **pnode);
434struct pctrie_node *pctrie_reclaim_begin_cb(struct pctrie_node **pnode,
435 struct pctrie *ptree,
436 pctrie_cb_t callback, int keyoff, void *arg);
437struct pctrie_node *pctrie_reclaim_resume_cb(struct pctrie_node **pnode,
438 pctrie_cb_t callback, int keyoff, void *arg);
169439uint64_t *pctrie_remove_lookup(struct pctrie *ptree, uint64_t index,
170440 struct pctrie_node **killnode);
441void pctrie_iter_remove(struct pctrie_iter *it,
442 struct pctrie_node **freenode);
443uint64_t *pctrie_iter_value(struct pctrie_iter *it);
171444uint64_t *pctrie_replace(struct pctrie *ptree, uint64_t *newval);
172445size_t pctrie_node_size(void);
173446int pctrie_zone_init(void *mem, int size, int flags);
lib/libc/include/generic-freebsd/sys/pipe.h+1-1
......@@ -52,7 +52,7 @@
5252 * See sys_pipe.c for info on what these limits mean.
5353 */
5454extern long maxpipekva;
55extern struct fileops pipeops;
55extern const struct fileops pipeops;
5656#endif
5757
5858/*
lib/libc/include/generic-freebsd/sys/pmc.h+1-3
......@@ -81,7 +81,6 @@ extern char pmc_cpuid[PMC_CPUID_LEN];
8181 * Please keep the pmc(3) manual page in sync with this list.
8282 */
8383#define __PMC_CPUS() \
84 __PMC_CPU(AMD_K7, 0x00, "AMD K7") \
8584 __PMC_CPU(AMD_K8, 0x01, "AMD K8") \
8685 __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \
8786 __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \
......@@ -130,7 +129,7 @@ enum pmc_cputype {
130129 __PMC_CPUS()
131130};
132131
133#define PMC_CPU_FIRST PMC_CPU_AMD_K7
132#define PMC_CPU_FIRST PMC_CPU_AMD_K8
134133#define PMC_CPU_LAST PMC_CPU_ARMV8_CORTEX_A76
135134
136135/*
......@@ -138,7 +137,6 @@ enum pmc_cputype {
138137 */
139138#define __PMC_CLASSES() \
140139 __PMC_CLASS(TSC, 0x00, "CPU Timestamp counter") \
141 __PMC_CLASS(K7, 0x01, "AMD K7 performance counters") \
142140 __PMC_CLASS(K8, 0x02, "AMD K8 performance counters") \
143141 __PMC_CLASS(IAF, 0x06, "Intel Core2/Atom, fixed function") \
144142 __PMC_CLASS(IAP, 0x07, "Intel Core...Atom, programmable") \
lib/libc/include/generic-freebsd/sys/poll.h+6-2
......@@ -96,7 +96,7 @@ struct pollfd {
9696
9797#ifndef _KERNEL
9898
99#if __BSD_VISIBLE
99#if __POSIX_VISIBLE >= 202405
100100#include <sys/_types.h>
101101
102102#include <sys/_sigset.h>
......@@ -109,9 +109,13 @@ typedef __sigset_t sigset_t;
109109
110110#endif
111111
112#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
113#include <ssp/poll.h>
114#endif
115
112116__BEGIN_DECLS
113117int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
114#if __BSD_VISIBLE
118#if __POSIX_VISIBLE >= 202405
115119int ppoll(struct pollfd _pfd[], nfds_t _nfds,
116120 const struct timespec *__restrict _timeout,
117121 const sigset_t *__restrict _newsigmask);
lib/libc/include/generic-freebsd/sys/priority.h+29-23
......@@ -64,17 +64,23 @@
6464 */
6565
6666/*
67 * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ)
68 * are insignificant. Ranges are as follows:
67 * Priorities range from 0 to 255. Ranges are as follows:
6968 *
70 * Interrupt threads: 0 - 15
71 * Realtime user threads: 16 - 47
72 * Top half kernel threads: 48 - 87
73 * Time sharing user threads: 88 - 223
69 * Interrupt threads: 0 - 7
70 * Realtime user threads: 8 - 39
71 * Top half kernel threads: 40 - 55
72 * Time sharing user threads: 56 - 223
7473 * Idle user threads: 224 - 255
7574 *
76 * XXX If/When the specific interrupt thread and top half thread ranges
77 * disappear, a larger range can be used for user processes.
75 * Priority levels of rtprio(2)'s RTP_PRIO_FIFO and RTP_PRIO_REALTIME and
76 * POSIX's SCHED_FIFO and SCHED_RR are directly mapped to the internal realtime
77 * range mentioned above by a simple translation. This range's length
78 * consequently cannot be changed without impacts on the scheduling priority
79 * code, and in any case must never be smaller than 32 for POSIX compliance and
80 * rtprio(2) backwards compatibility. Similarly, priority levels of rtprio(2)'s
81 * RTP_PRIO_IDLE are directly mapped to the internal idle range above (and,
82 * soon, those of the to-be-introduced SCHED_IDLE policy as well), so changing
83 * that range is subject to the same caveats and restrictions.
7884 */
7985
8086#define PRI_MIN (0) /* Highest priority. */
......@@ -88,34 +94,34 @@
8894 * decay to lower priorities if they run for full time slices.
8995 */
9096#define PI_REALTIME (PRI_MIN_ITHD + 0)
91#define PI_INTR (PRI_MIN_ITHD + 4)
97#define PI_INTR (PRI_MIN_ITHD + 1)
9298#define PI_AV PI_INTR
9399#define PI_NET PI_INTR
94100#define PI_DISK PI_INTR
95101#define PI_TTY PI_INTR
96102#define PI_DULL PI_INTR
97#define PI_SOFT (PRI_MIN_ITHD + 8)
103#define PI_SOFT (PRI_MIN_ITHD + 2)
98104#define PI_SOFTCLOCK PI_SOFT
99105#define PI_SWI(x) PI_SOFT
100106
101#define PRI_MIN_REALTIME (16)
107#define PRI_MIN_REALTIME (8)
102108#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1)
103109
104#define PRI_MIN_KERN (48)
110#define PRI_MIN_KERN (40)
105111#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1)
106112
107113#define PSWP (PRI_MIN_KERN + 0)
108#define PVM (PRI_MIN_KERN + 4)
109#define PINOD (PRI_MIN_KERN + 8)
110#define PRIBIO (PRI_MIN_KERN + 12)
111#define PVFS (PRI_MIN_KERN + 16)
112#define PZERO (PRI_MIN_KERN + 20)
113#define PSOCK (PRI_MIN_KERN + 24)
114#define PWAIT (PRI_MIN_KERN + 28)
115#define PLOCK (PRI_MIN_KERN + 32)
116#define PPAUSE (PRI_MIN_KERN + 36)
117
118#define PRI_MIN_TIMESHARE (88)
114#define PVM (PRI_MIN_KERN + 1)
115#define PINOD (PRI_MIN_KERN + 2)
116#define PRIBIO (PRI_MIN_KERN + 3)
117#define PVFS (PRI_MIN_KERN + 4)
118#define PZERO (PRI_MIN_KERN + 5)
119#define PSOCK (PRI_MIN_KERN + 6)
120#define PWAIT (PRI_MIN_KERN + 7)
121#define PLOCK (PRI_MIN_KERN + 8)
122#define PPAUSE (PRI_MIN_KERN + 9)
123
124#define PRI_MIN_TIMESHARE (56)
119125#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1)
120126
121127#define PUSER (PRI_MIN_TIMESHARE)
lib/libc/include/generic-freebsd/sys/priv.h+8-1
......@@ -105,7 +105,8 @@
105105#define PRIV_CRED_SETRESGID 58 /* setresgid. */
106106#define PRIV_SEEOTHERGIDS 59 /* Exempt bsd.seeothergids. */
107107#define PRIV_SEEOTHERUIDS 60 /* Exempt bsd.seeotheruids. */
108#define PRIV_SEEJAILPROC 61 /* Exempt from bsd.see_jail_proc. */
108#define PRIV_SEEJAILPROC 61 /* Exempt from bsd.see_jail_proc. */
109#define PRIV_CRED_SETCRED 62 /* setcred. */
109110
110111/*
111112 * Debugging privileges.
......@@ -114,6 +115,7 @@
114115#define PRIV_DEBUG_SUGID 81 /* Exempt debugging setuid proc. */
115116#define PRIV_DEBUG_UNPRIV 82 /* Exempt unprivileged debug limit. */
116117#define PRIV_DEBUG_DENIED 83 /* Exempt P2_NOTRACE. */
118#define PRIV_DEBUG_DIFFJAIL 84 /* Exempt debugging other jails. */
117119
118120/*
119121 * Dtrace privileges.
......@@ -192,6 +194,7 @@
192194#define PRIV_SCHED_CPUSET 206 /* Can manipulate cpusets. */
193195#define PRIV_SCHED_CPUSET_INTR 207 /* Can adjust IRQ to CPU binding. */
194196#define PRIV_SCHED_IDPRIO 208 /* Can set idle time scheduling. */
197#define PRIV_SCHED_DIFFJAIL 209 /* Exempt scheduling other jails. */
195198
196199/*
197200 * POSIX semaphore privileges.
......@@ -203,6 +206,7 @@
203206 */
204207#define PRIV_SIGNAL_DIFFCRED 230 /* Exempt signalling other users. */
205208#define PRIV_SIGNAL_SUGID 231 /* Non-conserv signal setuid proc. */
209#define PRIV_SIGNAL_DIFFJAIL 232 /* Exempt signalling other jails. */
206210
207211/*
208212 * Sysctl privileges.
......@@ -210,6 +214,7 @@
210214#define PRIV_SYSCTL_DEBUG 240 /* Can invoke sysctl.debug. */
211215#define PRIV_SYSCTL_WRITE 241 /* Can write sysctls. */
212216#define PRIV_SYSCTL_WRITEJAIL 242 /* Can write sysctls, jail permitted. */
217#define PRIV_SYSCTL_MEMLOCK 243 /* Large requests are not serialized. */
213218
214219/*
215220 * TTY privileges.
......@@ -404,6 +409,7 @@
404409#define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */
405410#define PRIV_NETINET_BINDANY 506 /* Allow bind to any address. */
406411#define PRIV_NETINET_HASHKEY 507 /* Get and set hash keys for IPv4/6. */
412#define PRIV_NETINET_KTLSKEYS 508 /* Read ktls session keys. */
407413
408414/*
409415 * Placeholders for IPX/SPX privileges, not supported any more.
......@@ -515,6 +521,7 @@
515521 */
516522#define PRIV_KMEM_READ 680 /* Open mem/kmem for reading. */
517523#define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */
524#define PRIV_PROC_MEM_WRITE 682 /* Writes via proc_rwmem */
518525
519526/*
520527 * Kernel debugger privileges.
lib/libc/include/generic-freebsd/sys/proc.h+52-63
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)proc.h 8.15 (Berkeley) 5/19/95
3735 */
3836
3937#ifndef _SYS_PROC_H_
......@@ -44,6 +42,7 @@
4442#ifdef _KERNEL
4543#include <sys/_eventhandler.h>
4644#endif
45#include <sys/_exterr.h>
4746#include <sys/condvar.h>
4847#ifndef _KERNEL
4948#include <sys/filedesc.h>
......@@ -55,7 +54,6 @@
5554#include <sys/osd.h>
5655#include <sys/priority.h>
5756#include <sys/rtprio.h> /* XXX. */
58#include <sys/runq.h>
5957#include <sys/resource.h>
6058#include <sys/sigio.h>
6159#include <sys/signal.h>
......@@ -249,7 +247,7 @@ struct thread {
249247 struct seltd *td_sel; /* Select queue/channel. */
250248 struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */
251249 struct turnstile *td_turnstile; /* (k) Associated turnstile. */
252 struct rl_q_entry *td_rlqe; /* (k) Associated range lock entry. */
250 void *td_pad1; /* Available */
253251 struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */
254252 lwpid_t td_tid; /* (b) Thread ID. */
255253 sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */
......@@ -272,11 +270,12 @@ struct thread {
272270 const char *td_wmesg; /* (t) Reason for sleep. */
273271 volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */
274272 u_char td_tsqueue; /* (t) Turnstile queue blocked on. */
275 u_char td_stopsched; /* (k) Scheduler stopped. */
273 u_char _td_pad0[2]; /* Available. */
276274 int td_locks; /* (k) Debug: count of non-spin locks */
277275 int td_rw_rlocks; /* (k) Count of rwlock read locks. */
278276 int td_sx_slocks; /* (k) Count of sx shared locks. */
279277 int td_lk_slocks; /* (k) Count of lockmgr shared locks. */
278 struct lock_object *td_wantedlock; /* (k) Lock we are contending on */
280279 struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */
281280 const char *td_lockname; /* (t) Name of lock blocked on. */
282281 LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */
......@@ -314,8 +313,8 @@ struct thread {
314313 struct osd td_osd; /* (k) Object specific data. */
315314 struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */
316315 pid_t td_dbg_forked; /* (c) Child pid for debugger. */
317 struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */
318316 u_int td_no_sleeping; /* (k) Sleeping disabled count. */
317 struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */
319318 void *td_su; /* (k) FFS SU private */
320319 sbintime_t td_sleeptimo; /* (t) Sleep timeout. */
321320 int td_rtcgen; /* (s) rtc_generation of abs. sleep */
......@@ -323,6 +322,7 @@ struct thread {
323322 size_t td_vslock_sz; /* (k) amount of vslock-ed space */
324323 struct kcov_info *td_kcov_info; /* (*) Kernel code coverage data */
325324 long td_ucredref; /* (k) references on td_realucred */
325 struct kexterr td_kexterr;
326326#define td_endzero td_sigmask
327327
328328/* Copied during fork1(), thread_create(), or kthread_add(). */
......@@ -342,6 +342,7 @@ struct thread {
342342 void *td_sigblock_ptr; /* (k) uptr for fast sigblock. */
343343 uint32_t td_sigblock_val; /* (k) fast sigblock value read at
344344 td_sigblock_ptr on kern entry */
345 void *td_exterr_ptr;
345346#define td_endcopy td_pcb
346347
347348/*
......@@ -367,7 +368,8 @@ struct thread {
367368 struct callout td_slpcallout; /* (h) Callout for sleep. */
368369 struct trapframe *td_frame; /* (k) */
369370 vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */
370 int td_kstack_pages; /* (a) Size of the kstack. */
371 u_short td_kstack_pages; /* (a) Size of the kstack. */
372 u_short td_kstack_domain; /* (a) Domain backing kstack KVA. */
371373 volatile u_int td_critnest; /* (k*) Critical section nest level. */
372374 struct mdthread td_md; /* (k) Any machine-dependent fields. */
373375 struct kaudit_record *td_ar; /* (k) Active audit record, if any. */
......@@ -430,7 +432,7 @@ do { \
430432
431433#define TD_LOCKS_INC(td) ((td)->td_locks++)
432434#define TD_LOCKS_DEC(td) do { \
433 KASSERT(SCHEDULER_STOPPED_TD(td) || (td)->td_locks > 0, \
435 KASSERT(SCHEDULER_STOPPED() || (td)->td_locks > 0, \
434436 ("Thread %p owns no locks", (td))); \
435437 (td)->td_locks--; \
436438} while (0)
......@@ -452,7 +454,7 @@ do { \
452454#define TDF_SINTR 0x00000008 /* Sleep is interruptible. */
453455#define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */
454456#define TDF_IDLETD 0x00000020 /* This is a per-CPU idle thread. */
455#define TDF_CANSWAP 0x00000040 /* Thread can be swapped. */
457#define TDF_UNUSED11 0x00000040 /* Available */
456458#define TDF_SIGWAIT 0x00000080 /* Ignore ignored signals */
457459#define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */
458460#define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */
......@@ -468,7 +470,7 @@ do { \
468470#define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */
469471#define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */
470472#define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */
471#define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */
473#define TDF_UNUSED12 0x00400000 /* Available */
472474#define TDF_UNUSED6 0x00800000 /* Available */
473475#define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */
474476#define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */
......@@ -493,13 +495,14 @@ enum {
493495 TDA_KQUEUE,
494496 TDA_RACCT,
495497 TDA_MOD1, /* For third party use, before signals are */
496 TAD_MOD2, /* processed .. */
498 TDA_MOD2, /* processed .. */
499 TDA_PSELECT, /* For discarding temporary signal mask */
497500 TDA_SIG,
498501 TDA_KTRACE,
499502 TDA_SUSPEND,
500503 TDA_SIGSUSPEND,
501504 TDA_MOD3, /* .. and after */
502 TAD_MOD4,
505 TDA_MOD4,
503506 TDA_MAX,
504507};
505508#define TDAI(tda) (1U << (tda))
......@@ -560,13 +563,16 @@ enum {
560563#define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */
561564#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */
562565#define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */
563#define TDP_INTCPCALLOUT 0x20000000 /* used by netinet/tcp_timer.c */
566#define TDP_EFIRT 0x20000000 /* In firmware (EFI RT) call */
564567#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */
565568#define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */
566569
567570#define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */
568571#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */
569572#define TDP2_ACCT 0x00000004 /* Doing accounting */
573#define TDP2_SAN_QUIET 0x00000008 /* Disable warnings from K(A|M)SAN */
574#define TDP2_EXTERR 0x00000010 /* Kernel reported ext error */
575#define TDP2_UEXTERR 0x00000020 /* User set ext error reporting ptr */
570576
571577/*
572578 * Reasons that the current thread can not be run yet.
......@@ -574,14 +580,12 @@ enum {
574580 */
575581#define TDI_SUSPENDED 0x0001 /* On suspension queue. */
576582#define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */
577#define TDI_SWAPPED 0x0004 /* Stack not in mem. Bad juju if run. */
578583#define TDI_LOCK 0x0008 /* Stopped on a lock. */
579584#define TDI_IWAIT 0x0010 /* Awaiting interrupt. */
580585
581586#define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING)
582587#define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL)
583588#define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED)
584#define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED)
585589#define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK)
586590#define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT)
587591#ifdef _KERNEL
......@@ -602,7 +606,6 @@ enum {
602606#define KTDSTATE(td) \
603607 (((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \
604608 ((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \
605 ((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \
606609 ((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \
607610 ((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding")
608611
......@@ -618,14 +621,12 @@ enum {
618621} while (0)
619622
620623#define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING)
621#define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED)
622624#define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK)
623625#define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED)
624626#define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT)
625627#define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING)
626628
627629#define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING)
628#define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED)
629630#define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK)
630631#define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED)
631632#define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT)
......@@ -704,7 +705,7 @@ struct proc {
704705 struct vnode *p_textvp; /* (b) Vnode of executable. */
705706 struct vnode *p_textdvp; /* (b) Dir containing textvp. */
706707 char *p_binname; /* (b) Binary hardlink name. */
707 u_int p_lock; /* (c) Proclock (prevent swap) count. */
708 u_int p_lock; /* (c) Prevent exit. */
708709 struct sigiolst p_sigiolst; /* (c) List of sigio sources. */
709710 int p_sigparent; /* (c) Signal to parent on exit. */
710711 int p_sig; /* (n) For core dump/debugger XXX. */
......@@ -714,7 +715,7 @@ struct proc {
714715 int p_suspcount; /* (j) Num threads in suspended mode. */
715716 struct thread *p_xthread; /* (c) Trap thread */
716717 int p_boundary_count;/* (j) Num threads at user boundary */
717 int p_pendingcnt; /* how many signals are pending */
718 int p_pendingcnt; /* (c) how many signals are pending */
718719 struct itimers *p_itimers; /* (c) POSIX interval timers. */
719720 struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */
720721 u_int p_treeflag; /* (e) P_TREE flags */
......@@ -762,7 +763,6 @@ struct proc {
762763 LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/
763764 struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */
764765 struct cv p_pwait; /* (*) wait cv for exit/exec. */
765 uint64_t p_prev_runtime; /* (c) Resource usage accounting. */
766766 struct racct *p_racct; /* (b) Resource accounting. */
767767 int p_throttled; /* (c) Flag for racct pcpu throttling */
768768 /*
......@@ -806,7 +806,7 @@ struct proc {
806806 lock. */
807807#define P_CONTROLT 0x00000002 /* Has a controlling terminal. */
808808#define P_KPROC 0x00000004 /* Kernel process. */
809#define P_UNUSED3 0x00000008 /* --available-- */
809#define P_IDLEPROC 0x00000008 /* Container for system idle threads. */
810810#define P_PPWAIT 0x00000010 /* Parent is waiting for child to
811811 exec/exit. */
812812#define P_PROFIL 0x00000020 /* Has started profiling. */
......@@ -816,8 +816,7 @@ struct proc {
816816 shortcuts) */
817817#define P_SUGID 0x00000100 /* Had set id privileges since last
818818 exec. */
819#define P_SYSTEM 0x00000200 /* System proc: no sigs, stats or
820 swapping. */
819#define P_SYSTEM 0x00000200 /* System proc: no sigs or stats. */
821820#define P_SINGLE_EXIT 0x00000400 /* Threads suspending should exit,
822821 not wait. */
823822#define P_TRACED 0x00000800 /* Debugged process being traced. */
......@@ -841,9 +840,9 @@ struct proc {
841840#define P_TOTAL_STOP 0x02000000 /* Stopped in stop_all_proc. */
842841#define P_INEXEC 0x04000000 /* Process is in execve(). */
843842#define P_STATCHILD 0x08000000 /* Child process stopped or exited. */
844#define P_INMEM 0x10000000 /* Loaded into memory. */
845#define P_SWAPPINGOUT 0x20000000 /* Process is being swapped out. */
846#define P_SWAPPINGIN 0x40000000 /* Process is being swapped in. */
843#define P_INMEM 0x10000000 /* Loaded into memory, always set. */
844#define P_UNUSED1 0x20000000 /* --available-- */
845#define P_UNUSED2 0x40000000 /* --available-- */
847846#define P_PPTRACE 0x80000000 /* PT_TRACEME by vforked child. */
848847
849848#define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE)
......@@ -874,7 +873,7 @@ struct proc {
874873 MAP_STACK */
875874#define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled
876875 after exec */
877#define P2_ITSTOPPED 0x00002000
876#define P2_ITSTOPPED 0x00002000 /* itimers stopped */
878877#define P2_PTRACEREQ 0x00004000 /* Active ptrace req */
879878#define P2_NO_NEW_PRIVS 0x00008000 /* Ignore setuid */
880879#define P2_WXORX_DISABLE 0x00010000 /* WX mappings enabled */
......@@ -882,7 +881,7 @@ struct proc {
882881#define P2_WEXIT 0x00040000 /* exit just started, no
883882 external thread_single() is
884883 permitted */
885#define P2_REAPKILLED 0x00080000
884#define P2_REAPKILLED 0x00080000 /* REAP_KILL pass touched me */
886885#define P2_MEMBAR_PRIVE 0x00100000 /* membar private expedited
887886 registered */
888887#define P2_MEMBAR_PRIVE_SYNCORE 0x00200000 /* membar private expedited
......@@ -890,6 +889,11 @@ struct proc {
890889#define P2_MEMBAR_GLOBE 0x00400000 /* membar global expedited
891890 registered */
892891
892#define P2_LOGSIGEXIT_ENABLE 0x00800000 /* Disable logging on sigexit */
893#define P2_LOGSIGEXIT_CTL 0x01000000 /* Override kern.logsigexit */
894
895#define P2_HWT 0x02000000 /* Process is using HWT. */
896
893897/* Flags protected by proctree_lock, kept in p_treeflags. */
894898#define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */
895899#define P_TREE_FIRST_ORPHAN 0x00000002 /* First element of orphan
......@@ -938,12 +942,6 @@ struct proc {
938942#define SINGLE_BOUNDARY 2
939943#define SINGLE_ALLPROC 3
940944
941#ifdef MALLOC_DECLARE
942MALLOC_DECLARE(M_PARGS);
943MALLOC_DECLARE(M_SESSION);
944MALLOC_DECLARE(M_SUBPROC);
945#endif
946
947945#define FOREACH_PROC_IN_SYSTEM(p) \
948946 LIST_FOREACH((p), &allproc, p_list)
949947#define FOREACH_THREAD_IN_PROC(p, td) \
......@@ -956,7 +954,7 @@ MALLOC_DECLARE(M_SUBPROC);
956954 * in a pid_t, as it is used to represent "no process group".
957955 */
958956#define PID_MAX 99999
959#define NO_PID 100000
957#define NO_PID (PID_MAX + 1)
960958#define THREAD0_TID NO_PID
961959extern pid_t pid_max;
962960
......@@ -992,18 +990,12 @@ extern pid_t pid_max;
992990#define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type))
993991
994992/*
995 * Non-zero p_lock ensures that:
996 * - exit1() is not performed until p_lock reaches zero;
997 * - the process' threads stack are not swapped out if they are currently
998 * not (P_INMEM).
993 * A non-zero p_lock prevents the process from exiting; it will sleep in exit1()
994 * until the count reaches zero.
999995 *
1000996 * PHOLD() asserts that the process (except the current process) is
1001 * not exiting, increments p_lock and swaps threads stacks into memory,
1002 * if needed.
997 * not exiting and increments p_lock.
1003998 * _PHOLD() is same as PHOLD(), it takes the process locked.
1004 * _PHOLD_LITE() also takes the process locked, but comparing with
1005 * _PHOLD(), it only guarantees that exit1() is not executed,
1006 * faultin() is not called.
1007999 */
10081000#define PHOLD(p) do { \
10091001 PROC_LOCK(p); \
......@@ -1015,14 +1007,6 @@ extern pid_t pid_max;
10151007 KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \
10161008 ("PHOLD of exiting process %p", p)); \
10171009 (p)->p_lock++; \
1018 if (((p)->p_flag & P_INMEM) == 0) \
1019 faultin((p)); \
1020} while (0)
1021#define _PHOLD_LITE(p) do { \
1022 PROC_LOCK_ASSERT((p), MA_OWNED); \
1023 KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \
1024 ("PHOLD of exiting process %p", p)); \
1025 (p)->p_lock++; \
10261010} while (0)
10271011#define PROC_ASSERT_HELD(p) do { \
10281012 KASSERT((p)->p_lock > 0, ("process %p not held", p)); \
......@@ -1058,9 +1042,6 @@ extern pid_t pid_max;
10581042 _p->p_cowgen - _td->td_cowgen; \
10591043})
10601044
1061/* Check whether a thread is safe to be swapped out. */
1062#define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP)
1063
10641045/* Control whether or not it is safe for curthread to sleep. */
10651046#define THREAD_NO_SLEEPING() do { \
10661047 curthread->td_no_sleeping++; \
......@@ -1074,6 +1055,16 @@ extern pid_t pid_max;
10741055
10751056#define THREAD_CAN_SLEEP() ((curthread)->td_no_sleeping == 0)
10761057
1058#define THREAD_CONTENDS_ON_LOCK(lo) do { \
1059 MPASS(curthread->td_wantedlock == NULL); \
1060 curthread->td_wantedlock = lo; \
1061} while (0)
1062
1063#define THREAD_CONTENTION_DONE(lo) do { \
1064 MPASS(curthread->td_wantedlock == lo); \
1065 curthread->td_wantedlock = NULL; \
1066} while (0)
1067
10771068#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
10781069#define PIDHASHLOCK(pid) (&pidhashtbl_lock[((pid) & pidhashlock)])
10791070extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
......@@ -1170,7 +1161,6 @@ int cr_cansignal(struct ucred *cred, struct proc *proc, int signum);
11701161int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp,
11711162 struct session *sess);
11721163int enterthispgrp(struct proc *p, struct pgrp *pgrp);
1173void faultin(struct proc *p);
11741164int fork1(struct thread *, struct fork_req *);
11751165void fork_exit(void (*)(void *, struct trapframe *), void *,
11761166 struct trapframe *);
......@@ -1181,7 +1171,6 @@ void kqtimer_proc_continue(struct proc *p);
11811171void kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry,
11821172 int *resident_count, bool *super);
11831173void kern_yield(int);
1184void kick_proc0(void);
11851174void killjobc(void);
11861175int leavepgrp(struct proc *p);
11871176int maybe_preempt(struct thread *td);
......@@ -1195,6 +1184,7 @@ int p_canwait(struct thread *td, struct proc *p);
11951184struct pargs *pargs_alloc(int len);
11961185void pargs_drop(struct pargs *pa);
11971186void pargs_hold(struct pargs *pa);
1187int pgrp_calc_jobc(struct pgrp *pgrp);
11981188void proc_add_orphan(struct proc *child, struct proc *parent);
11991189int proc_get_binpath(struct proc *p, char *binname, char **fullpath,
12001190 char **freepath);
......@@ -1220,7 +1210,7 @@ int securelevel_ge(struct ucred *cr, int level);
12201210int securelevel_gt(struct ucred *cr, int level);
12211211void sess_hold(struct session *);
12221212void sess_release(struct session *);
1223int setrunnable(struct thread *, int);
1213void setrunnable(struct thread *, int);
12241214void setsugid(struct proc *p);
12251215bool should_yield(void);
12261216int sigonstack(size_t sp);
......@@ -1235,6 +1225,7 @@ extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */
12351225void cpu_switch(struct thread *, struct thread *, struct mtx *);
12361226void cpu_sync_core(void);
12371227void cpu_throw(struct thread *, struct thread *) __dead2;
1228void cpu_update_pcb(struct thread *);
12381229bool curproc_sigkilled(void);
12391230void userret(struct thread *, struct trapframe *);
12401231
......@@ -1250,15 +1241,12 @@ int cpu_procctl(struct thread *td, int idtype, id_t id, int com,
12501241void cpu_set_syscall_retval(struct thread *, int);
12511242int cpu_set_upcall(struct thread *, void (*)(void *), void *,
12521243 stack_t *);
1253int cpu_set_user_tls(struct thread *, void *tls_base);
1244int cpu_set_user_tls(struct thread *, void *tls_base, int flags);
12541245void cpu_thread_alloc(struct thread *);
12551246void cpu_thread_clean(struct thread *);
12561247void cpu_thread_exit(struct thread *);
12571248void cpu_thread_free(struct thread *);
1258void cpu_thread_swapin(struct thread *);
1259void cpu_thread_swapout(struct thread *);
12601249struct thread *thread_alloc(int pages);
1261int thread_alloc_stack(struct thread *, int pages);
12621250int thread_check_susp(struct thread *td, bool sleep);
12631251void thread_cow_get_proc(struct thread *newtd, struct proc *p);
12641252void thread_cow_get(struct thread *newtd, struct thread *td);
......@@ -1271,6 +1259,7 @@ void thread_exit(void) __dead2;
12711259void thread_free(struct thread *td);
12721260void thread_link(struct thread *td, struct proc *p);
12731261void thread_reap_barrier(void);
1262int thread_recycle(struct thread *, int pages);
12741263int thread_single(struct proc *p, int how);
12751264void thread_single_end(struct proc *p, int how);
12761265void thread_stash(struct thread *td);
lib/libc/include/generic-freebsd/sys/procctl.h+6
......@@ -65,6 +65,8 @@
6565#define PROC_NO_NEW_PRIVS_STATUS 20 /* query suid/sgid disabled status */
6666#define PROC_WXMAP_CTL 21 /* control W^X */
6767#define PROC_WXMAP_STATUS 22 /* query W^X */
68#define PROC_LOGSIGEXIT_CTL 23 /* en/dis logging on sigexit */
69#define PROC_LOGSIGEXIT_STATUS 24 /* query logging on sigexit */
6870
6971/* Operations for PROC_SPROTECT (passed in integer arg). */
7072#define PPROT_OP(x) ((x) & 0xf)
......@@ -153,6 +155,10 @@ struct procctl_reaper_kill {
153155#define PROC_WX_MAPPINGS_DISALLOW_EXEC 0x0002
154156#define PROC_WXORX_ENFORCE 0x80000000
155157
158#define PROC_LOGSIGEXIT_CTL_NOFORCE 1
159#define PROC_LOGSIGEXIT_CTL_FORCE_ENABLE 2
160#define PROC_LOGSIGEXIT_CTL_FORCE_DISABLE 3
161
156162#ifndef _KERNEL
157163__BEGIN_DECLS
158164int procctl(idtype_t, id_t, int, void *);
lib/libc/include/generic-freebsd/sys/procdesc.h+5-2
......@@ -94,8 +94,10 @@ struct procdesc {
9494 * In-kernel interfaces to process descriptors.
9595 */
9696int procdesc_exit(struct proc *);
97int procdesc_find(struct thread *, int fd, cap_rights_t *, struct proc **);
98int kern_pdgetpid(struct thread *, int fd, cap_rights_t *, pid_t *pidp);
97int procdesc_find(struct thread *, int fd, const cap_rights_t *,
98 struct proc **);
99int kern_pdgetpid(struct thread *, int fd, const cap_rights_t *,
100 pid_t *pidp);
99101void procdesc_new(struct proc *, int);
100102void procdesc_finit(struct procdesc *, struct file *);
101103pid_t procdesc_pid(struct file *);
......@@ -106,6 +108,7 @@ int procdesc_falloc(struct thread *, struct file **, int *, int,
106108
107109#else /* !_KERNEL */
108110
111#include <sys/cdefs.h>
109112#include <sys/_types.h>
110113
111114#ifndef _PID_T_DECLARED
lib/libc/include/generic-freebsd/sys/protosw.h+26-52
......@@ -27,24 +27,11 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)protosw.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_PROTOSW_H_
3533#define _SYS_PROTOSW_H_
36
37#include <sys/queue.h>
38
39/* Forward declare these structures referenced from prototypes below. */
40struct kaiocb;
41struct mbuf;
42struct thread;
43struct sockaddr;
44struct socket;
45struct sockopt;
46
47/*#ifdef _KERNEL*/
34#if defined(_KERNEL) || defined(_WANT_PROTOSW)
4835/*
4936 * Protocol switch table.
5037 *
......@@ -54,16 +41,24 @@ struct sockopt;
5441 * In retrospect, it would be a lot nicer to use an interface
5542 * similar to the vnode VOP interface.
5643 */
44struct socket;
45struct sockopt;
46struct thread;
47struct sockaddr;
5748struct ifnet;
49struct mbuf;
5850struct stat;
5951struct ucred;
6052struct uio;
53struct kaiocb;
54struct knote;
55enum shutdown_how;
6156
6257/* USE THESE FOR YOUR PROTOTYPES ! */
6358typedef int pr_ctloutput_t(struct socket *, struct sockopt *);
6459typedef int pr_setsbopt_t(struct socket *, struct sockopt *);
6560typedef void pr_abort_t(struct socket *);
66typedef int pr_accept_t(struct socket *, struct sockaddr **);
61typedef int pr_accept_t(struct socket *, struct sockaddr *);
6762typedef int pr_attach_t(struct socket *, int, struct thread *);
6863typedef int pr_bind_t(struct socket *, struct sockaddr *, struct thread *);
6964typedef int pr_connect_t(struct socket *, struct sockaddr *,
......@@ -74,7 +69,7 @@ typedef int pr_control_t(struct socket *, unsigned long, void *,
7469typedef void pr_detach_t(struct socket *);
7570typedef int pr_disconnect_t(struct socket *);
7671typedef int pr_listen_t(struct socket *, int, struct thread *);
77typedef int pr_peeraddr_t(struct socket *, struct sockaddr **);
72typedef int pr_peeraddr_t(struct socket *, struct sockaddr *);
7873typedef int pr_rcvd_t(struct socket *, int);
7974typedef int pr_rcvoob_t(struct socket *, struct mbuf *, int);
8075typedef enum {
......@@ -86,17 +81,17 @@ typedef enum {
8681} pr_send_flags_t;
8782typedef int pr_send_t(struct socket *, int, struct mbuf *,
8883 struct sockaddr *, struct mbuf *, struct thread *);
84typedef int pr_sendfile_wait_t(struct socket *, off_t, int *);
8985typedef int pr_ready_t(struct socket *, struct mbuf *, int);
9086typedef int pr_sense_t(struct socket *, struct stat *);
91typedef int pr_shutdown_t(struct socket *);
92typedef int pr_flush_t(struct socket *, int);
93typedef int pr_sockaddr_t(struct socket *, struct sockaddr **);
87typedef int pr_shutdown_t(struct socket *, enum shutdown_how);
88typedef int pr_sockaddr_t(struct socket *, struct sockaddr *);
9489typedef int pr_sosend_t(struct socket *, struct sockaddr *, struct uio *,
9590 struct mbuf *, struct mbuf *, int, struct thread *);
9691typedef int pr_soreceive_t(struct socket *, struct sockaddr **,
9792 struct uio *, struct mbuf **, struct mbuf **, int *);
98typedef int pr_sopoll_t(struct socket *, int, struct ucred *,
99 struct thread *);
93typedef int pr_sopoll_t(struct socket *, int, struct thread *);
94typedef int pr_kqfilter_t(struct socket *, struct knote *);
10095typedef void pr_sosetlabel_t(struct socket *);
10196typedef void pr_close_t(struct socket *);
10297typedef int pr_bindat_t(int, struct socket *, struct sockaddr *,
......@@ -104,6 +99,8 @@ typedef int pr_bindat_t(int, struct socket *, struct sockaddr *,
10499typedef int pr_connectat_t(int, struct socket *, struct sockaddr *,
105100 struct thread *);
106101typedef int pr_aio_queue_t(struct socket *, struct kaiocb *);
102typedef int pr_chmod_t(struct socket *, __mode_t, struct ucred *,
103 struct thread *);
107104
108105struct protosw {
109106 short pr_type; /* socket type used for */
......@@ -113,9 +110,9 @@ struct protosw {
113110 struct domain *pr_domain; /* domain protocol a member of */
114111
115112 pr_soreceive_t *pr_soreceive; /* recv(2) */
116 pr_rcvd_t *pr_rcvd; /* soreceive_generic() if PR_WANTRCVD */
117113 pr_sosend_t *pr_sosend; /* send(2) */
118114 pr_send_t *pr_send; /* send(2) via sosend_generic() */
115 pr_sendfile_wait_t *pr_sendfile_wait; /* sendfile helper */
119116 pr_ready_t *pr_ready; /* sendfile/ktls readyness */
120117 pr_sopoll_t *pr_sopoll; /* poll(2) */
121118/* Cache line #2 */
......@@ -125,7 +122,7 @@ struct protosw {
125122 pr_disconnect_t *pr_disconnect; /* sodisconnect() */
126123 pr_close_t *pr_close; /* close(2) */
127124 pr_shutdown_t *pr_shutdown; /* shutdown(2) */
128 pr_abort_t *pr_abort; /* abrupt tear down: soabort() */
125 pr_rcvd_t *pr_rcvd; /* soreceive_generic() if PR_WANTRCVD */
129126 pr_aio_queue_t *pr_aio_queue; /* aio(9) */
130127/* Cache line #3 */
131128 pr_bind_t *pr_bind; /* bind(2) */
......@@ -137,15 +134,18 @@ struct protosw {
137134 pr_control_t *pr_control; /* ioctl(2) */
138135 pr_rcvoob_t *pr_rcvoob; /* soreceive_rcvoob() */
139136/* Cache line #4 */
137 pr_abort_t *pr_abort; /* abrupt tear down: soabort() */
140138 pr_ctloutput_t *pr_ctloutput; /* control output (from above) */
141139 pr_peeraddr_t *pr_peeraddr; /* getpeername(2) */
142140 pr_sockaddr_t *pr_sockaddr; /* getsockname(2) */
143141 pr_sense_t *pr_sense; /* stat(2) */
144 pr_flush_t *pr_flush; /* XXXGL: merge with pr_shutdown_t! */
145142 pr_sosetlabel_t *pr_sosetlabel; /* MAC, XXXGL: remove */
146143 pr_setsbopt_t *pr_setsbopt; /* Socket buffer ioctls */
144 pr_chmod_t *pr_chmod; /* fchmod(2) */
145 pr_kqfilter_t *pr_kqfilter; /* kevent(2) */
147146};
148/*#endif*/
147#endif /* defined(_KERNEL) || defined(_WANT_PROTOSW) */
148#ifdef _KERNEL
149149
150150/*
151151 * Values for pr_flags.
......@@ -162,37 +162,12 @@ struct protosw {
162162#define PR_ADDR 0x02 /* addresses given with messages */
163163#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
164164#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
165#define PR_RIGHTS 0x10 /* passes capabilities */
165/* was PR_RIGHTS 0x10 passes capabilities */
166166#define PR_IMPLOPCL 0x20 /* implied open/close */
167167/* was PR_LASTHDR 0x40 enforce ipsec policy; last header */
168168#define PR_CAPATTACH 0x80 /* socket can attach in cap mode */
169169#define PR_SOCKBUF 0x100 /* private implementation of buffers */
170170
171/*
172 * The arguments to ctloutput are:
173 * (*protosw[].pr_ctloutput)(req, so, level, optname, optval, p);
174 * req is one of the actions listed below, so is a (struct socket *),
175 * level is an indication of which protocol layer the option is intended.
176 * optname is a protocol dependent socket option request,
177 * optval is a pointer to a mbuf-chain pointer, for value-return results.
178 * The protocol is responsible for disposal of the mbuf chain *optval
179 * if supplied,
180 * the caller is responsible for any space held by *optval, when returned.
181 * A non-zero return from ctloutput gives an
182 * UNIX error number which should be passed to higher level software.
183 */
184#define PRCO_GETOPT 0
185#define PRCO_SETOPT 1
186
187#define PRCO_NCMDS 2
188
189#ifdef PRCOREQUESTS
190char *prcorequests[] = {
191 "GETOPT", "SETOPT",
192};
193#endif
194
195#ifdef _KERNEL
196171struct domain *pffinddomain(int family);
197172struct protosw *pffindproto(int family, int type, int proto);
198173int protosw_register(struct domain *, struct protosw *);
......@@ -202,5 +177,4 @@ int protosw_unregister(struct protosw *);
202177extern struct domain inetdomain;
203178extern struct domain inet6domain;
204179#endif
205
206180#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ptrace.h+9-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ptrace.h 8.2 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _SYS_PTRACE_H_
......@@ -89,8 +87,16 @@
8987#define PT_SC_REMOTE 44 /* Execute a syscall */
9088
9189#define PT_FIRSTMACH 64 /* for machine-specific requests */
90#define PT_LASTMACH 127
9291#include <machine/ptrace.h> /* machine-specific requests, if any */
9392
93#ifdef _KERNEL
94/* Space for ptrace commands not exposed directly to userspace. */
95#define PTINTERNAL_FIRST 128
96#define PTINTERNAL_LAST 191
97#define PTLINUX_GET_SC_ARGS (PTINTERNAL_FIRST + 0)
98#endif
99
94100/* Events used with PT_GET_EVENT_MASK and PT_SET_EVENT_MASK */
95101#define PTRACE_EXEC 0x0001
96102#define PTRACE_SCE 0x0002
......@@ -152,7 +158,7 @@ struct ptrace_lwpinfo32 {
152158 int pl_flags; /* LWP flags. */
153159 sigset_t pl_sigmask; /* LWP signal mask */
154160 sigset_t pl_siglist; /* LWP pending signal */
155 struct siginfo32 pl_siginfo; /* siginfo for signal */
161 struct __siginfo32 pl_siginfo; /* siginfo for signal */
156162 char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */
157163 pid_t pl_child_pid; /* New child pid */
158164 u_int pl_syscall_code;
lib/libc/include/generic-freebsd/sys/qmath.h+12-9
......@@ -1,5 +1,5 @@
11/*-
2 * Copyright (c) 2018 Netflix, Inc.
2 * Copyright (c) 2018-2024 Netflix, Inc.
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
......@@ -378,15 +378,18 @@ typedef u64q_t umaxq_t;
378378#define Q_QMINQ(a, b) (Q_LT(a, b) ? (a) : (b))
379379
380380/*
381 * Test if 'a' can be represented by 'b' with full accuracy (T) or not (F).
382 * The type casting has to be done to a's type so that any truncation caused by
383 * the casts will not affect the logic.
381 * Test if 'a' can be represented by 'b' with full accuracy (0) or not
382 * (EOVERFLOW). If 'b' has fewer integer and/or fractional bits than 'a',
383 * the integer and fractional values stored in 'a' must fit in the available
384 * number of integer and fractional bits in 'b'.
384385 */
385#define Q_QCANREPQ(a, b) \
386 ((((Q_LTZ(a) && Q_SIGNED(b)) || !Q_LTZ(a)) && \
387 Q_GIABSVAL(a) <= Q_TC(a, Q_IMAXVAL(b)) && \
388 Q_GFABSVAL(a) <= Q_TC(a, Q_FMAXVAL(b))) ? \
389 0 : EOVERFLOW)
386#define Q_QCANREPQ(a, b) (( \
387 (!Q_LTZ(a) || Q_SIGNED(b)) \
388 && ( Q_NIBITS(a) <= Q_NIBITS(b) \
389 || 0 == (Q_GIABSVAL(a) & (~Q_TC(a, 0) << Q_NIBITS(b)))) \
390 && ( Q_NFBITS(a) <= Q_NFBITS(b) \
391 || 0 == (Q_GFABSVAL(a) & ~(~Q_TC(a, 0) << (Q_NFBITS(a) - Q_NFBITS(b))))) \
392 ) ? 0 : EOVERFLOW)
390393
391394/* Test if raw integer value 'i' can be represented by 'q' (T) or not (F). */
392395#define Q_QCANREPI(q, i) \
lib/libc/include/generic-freebsd/sys/queue.h+393-218
......@@ -27,12 +27,10 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)queue.h 8.5 (Berkeley) 8/20/94
3230 */
3331
3432#ifndef _SYS_QUEUE_H_
35#define _SYS_QUEUE_H_
33#define _SYS_QUEUE_H_
3634
3735#include <sys/cdefs.h>
3836
......@@ -113,15 +111,15 @@
113111 * _REMOVE_HEAD + + + +
114112 * _REMOVE s + s +
115113 * _REPLACE - + - +
114 * _SPLIT_AFTER + + + +
116115 * _SWAP + + + +
117116 *
118117 */
119118#ifdef QUEUE_MACRO_DEBUG
120#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH
121#define QUEUE_MACRO_DEBUG_TRACE
122#define QUEUE_MACRO_DEBUG_TRASH
119#warn Use QUEUE_MACRO_DEBUG_xxx instead (TRACE, TRASH and/or ASSERTIONS)
120#define QUEUE_MACRO_DEBUG_TRACE
121#define QUEUE_MACRO_DEBUG_TRASH
123122#endif
124
125123#ifdef QUEUE_MACRO_DEBUG_TRACE
126124/* Store the last 2 places the queue element or head was altered */
127125struct qm_trace {
......@@ -131,17 +129,17 @@ struct qm_trace {
131129 const char *prevfile;
132130};
133131
134#define TRACEBUF struct qm_trace trace;
135#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
132#define TRACEBUF struct qm_trace trace;
133#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
136134
137#define QMD_TRACE_HEAD(head) do { \
135#define QMD_TRACE_HEAD(head) do { \
138136 (head)->trace.prevline = (head)->trace.lastline; \
139137 (head)->trace.prevfile = (head)->trace.lastfile; \
140138 (head)->trace.lastline = __LINE__; \
141139 (head)->trace.lastfile = __FILE__; \
142140} while (0)
143141
144#define QMD_TRACE_ELEM(elem) do { \
142#define QMD_TRACE_ELEM(elem) do { \
145143 (elem)->trace.prevline = (elem)->trace.lastline; \
146144 (elem)->trace.prevfile = (elem)->trace.lastfile; \
147145 (elem)->trace.lastline = __LINE__; \
......@@ -149,53 +147,110 @@ struct qm_trace {
149147} while (0)
150148
151149#else /* !QUEUE_MACRO_DEBUG_TRACE */
152#define QMD_TRACE_ELEM(elem)
153#define QMD_TRACE_HEAD(head)
154#define TRACEBUF
155#define TRACEBUF_INITIALIZER
150#define QMD_TRACE_ELEM(elem)
151#define QMD_TRACE_HEAD(head)
152#define TRACEBUF
153#define TRACEBUF_INITIALIZER
156154#endif /* QUEUE_MACRO_DEBUG_TRACE */
157155
158156#ifdef QUEUE_MACRO_DEBUG_TRASH
159#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
160#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
161#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)
157#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
158#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
159#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)
162160#else /* !QUEUE_MACRO_DEBUG_TRASH */
163#define QMD_SAVELINK(name, link)
164#define TRASHIT(x)
165#define QMD_IS_TRASHED(x) 0
161#define QMD_SAVELINK(name, link)
162#define TRASHIT(x)
163#define QMD_IS_TRASHED(x) 0
166164#endif /* QUEUE_MACRO_DEBUG_TRASH */
167165
166#if defined(QUEUE_MACRO_DEBUG_ASSERTIONS) && \
167 defined(QUEUE_MACRO_NO_DEBUG_ASSERTIONS)
168#error Both QUEUE_MACRO_DEBUG_ASSERTIONS and QUEUE_MACRO_NO_DEBUG_ASSERTIONS defined
169#endif
170
171/*
172 * Automatically define QUEUE_MACRO_DEBUG_ASSERTIONS when compiling the kernel
173 * with INVARIANTS, if not already defined and not prevented by presence of
174 * QUEUE_MACRO_NO_DEBUG_ASSERTIONS.
175 */
176#if !defined(QUEUE_MACRO_DEBUG_ASSERTIONS) && \
177 !defined(QUEUE_MACRO_NO_DEBUG_ASSERTIONS) && \
178 (defined(_KERNEL) && defined(INVARIANTS))
179#define QUEUE_MACRO_DEBUG_ASSERTIONS
180#endif
181
182/*
183 * If queue assertions are enabled, provide default definitions for QMD_PANIC()
184 * and QMD_ASSERT() if undefined.
185 */
186#ifdef QUEUE_MACRO_DEBUG_ASSERTIONS
187#ifndef QMD_PANIC
188#if defined(_KERNEL) || defined(_STANDALONE)
189/*
190 * On _STANDALONE, either <stand.h> or the headers using <sys/queue.h> provide
191 * a declaration or macro for panic().
192 */
193#ifdef _KERNEL
194#include <sys/kassert.h>
195#endif
196#define QMD_PANIC(fmt, ...) do { \
197 panic(fmt, ##__VA_ARGS__); \
198} while (0)
199#else /* !(_KERNEL || _STANDALONE) */
200#include <stdio.h>
201#include <stdlib.h>
202#define QMD_PANIC(fmt, ...) do { \
203 fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
204 abort(); \
205} while (0)
206#endif /* _KERNEL || _STANDALONE */
207#endif /* !QMD_PANIC */
208
209#ifndef QMD_ASSERT
210#define QMD_ASSERT(expression, fmt, ...) do { \
211 if (__predict_false(!(expression))) \
212 QMD_PANIC("%s:%u: %s: " fmt, \
213 __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
214} while (0)
215#endif /* !QMD_ASSERT */
216#else /* !QUEUE_MACRO_DEBUG_ASSERTIONS */
217#undef QMD_ASSERT
218#define QMD_ASSERT(test, fmt, ...) do {} while (0)
219#endif /* QUEUE_MACRO_DEBUG_ASSERTIONS */
220
221
168222#ifdef __cplusplus
169223/*
170224 * In C++ there can be structure lists and class lists:
171225 */
172#define QUEUE_TYPEOF(type) type
226#define QUEUE_TYPEOF(type) type
173227#else
174#define QUEUE_TYPEOF(type) struct type
228#define QUEUE_TYPEOF(type) struct type
175229#endif
176230
177231/*
178232 * Singly-linked List declarations.
179233 */
180#define SLIST_HEAD(name, type) \
234
235#define SLIST_HEAD(name, type) \
181236struct name { \
182237 struct type *slh_first; /* first element */ \
183238}
184239
185#define SLIST_CLASS_HEAD(name, type) \
240#define SLIST_CLASS_HEAD(name, type) \
186241struct name { \
187242 class type *slh_first; /* first element */ \
188243}
189244
190#define SLIST_HEAD_INITIALIZER(head) \
245#define SLIST_HEAD_INITIALIZER(head) \
191246 { NULL }
192247
193#define SLIST_ENTRY(type) \
248#define SLIST_ENTRY(type) \
194249struct { \
195250 struct type *sle_next; /* next element */ \
196251}
197252
198#define SLIST_CLASS_ENTRY(type) \
253#define SLIST_CLASS_ENTRY(type) \
199254struct { \
200255 class type *sle_next; /* next element */ \
201256}
......@@ -203,137 +258,151 @@ struct { \
203258/*
204259 * Singly-linked List functions.
205260 */
206#if (defined(_KERNEL) && defined(INVARIANTS))
207#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) do { \
208 if (*(prevp) != (elm)) \
209 panic("Bad prevptr *(%p) == %p != %p", \
210 (prevp), *(prevp), (elm)); \
211} while (0)
212#else
213#define QMD_SLIST_CHECK_PREVPTR(prevp, elm)
214#endif
261
262#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) \
263 QMD_ASSERT(*(prevp) == (elm), \
264 "Bad prevptr *(%p) == %p != %p", \
265 (prevp), *(prevp), (elm))
266
267#define SLIST_ASSERT_EMPTY(head) \
268 QMD_ASSERT(SLIST_EMPTY((head)), \
269 "slist %p is not empty", (head))
270
271#define SLIST_ASSERT_NONEMPTY(head) \
272 QMD_ASSERT(!SLIST_EMPTY((head)), \
273 "slist %p is empty", (head))
215274
216275#define SLIST_CONCAT(head1, head2, type, field) do { \
217 QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \
218 if (curelm == NULL) { \
276 QUEUE_TYPEOF(type) *_Curelm = SLIST_FIRST(head1); \
277 if (_Curelm == NULL) { \
219278 if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \
220279 SLIST_INIT(head2); \
221280 } else if (SLIST_FIRST(head2) != NULL) { \
222 while (SLIST_NEXT(curelm, field) != NULL) \
223 curelm = SLIST_NEXT(curelm, field); \
224 SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \
281 while (SLIST_NEXT(_Curelm, field) != NULL) \
282 _Curelm = SLIST_NEXT(_Curelm, field); \
283 SLIST_NEXT(_Curelm, field) = SLIST_FIRST(head2); \
225284 SLIST_INIT(head2); \
226285 } \
227286} while (0)
228287
229#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
288#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
230289
231#define SLIST_FIRST(head) ((head)->slh_first)
290#define SLIST_EMPTY_ATOMIC(head) \
291 (atomic_load_ptr(&(head)->slh_first) == NULL)
232292
233#define SLIST_FOREACH(var, head, field) \
293#define SLIST_FIRST(head) ((head)->slh_first)
294
295#define SLIST_FOREACH(var, head, field) \
234296 for ((var) = SLIST_FIRST((head)); \
235297 (var); \
236298 (var) = SLIST_NEXT((var), field))
237299
238#define SLIST_FOREACH_FROM(var, head, field) \
300#define SLIST_FOREACH_FROM(var, head, field) \
239301 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
240302 (var); \
241303 (var) = SLIST_NEXT((var), field))
242304
243#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
305#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
244306 for ((var) = SLIST_FIRST((head)); \
245307 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
246308 (var) = (tvar))
247309
248#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
310#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
249311 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
250312 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
251313 (var) = (tvar))
252314
253#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
315#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
254316 for ((varp) = &SLIST_FIRST((head)); \
255317 ((var) = *(varp)) != NULL; \
256318 (varp) = &SLIST_NEXT((var), field))
257319
258#define SLIST_INIT(head) do { \
320#define SLIST_INIT(head) do { \
259321 SLIST_FIRST((head)) = NULL; \
260322} while (0)
261323
262#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
324#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
263325 SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
264326 SLIST_NEXT((slistelm), field) = (elm); \
265327} while (0)
266328
267#define SLIST_INSERT_HEAD(head, elm, field) do { \
329#define SLIST_INSERT_HEAD(head, elm, field) do { \
268330 SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
269331 SLIST_FIRST((head)) = (elm); \
270332} while (0)
271333
272#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
334#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
273335
274#define SLIST_REMOVE(head, elm, type, field) do { \
336#define SLIST_REMOVE(head, elm, type, field) do { \
275337 if (SLIST_FIRST((head)) == (elm)) { \
276338 SLIST_REMOVE_HEAD((head), field); \
277339 } \
278340 else { \
279 QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \
280 while (SLIST_NEXT(curelm, field) != (elm)) \
281 curelm = SLIST_NEXT(curelm, field); \
282 SLIST_REMOVE_AFTER(curelm, field); \
341 QUEUE_TYPEOF(type) *_Curelm = SLIST_FIRST(head); \
342 while (SLIST_NEXT(_Curelm, field) != (elm)) \
343 _Curelm = SLIST_NEXT(_Curelm, field); \
344 SLIST_REMOVE_AFTER(_Curelm, field); \
283345 } \
284346} while (0)
285347
286348#define SLIST_REMOVE_AFTER(elm, field) do { \
287 QMD_SAVELINK(oldnext, SLIST_NEXT(elm, field)->field.sle_next); \
349 QMD_SAVELINK(_Oldnext, SLIST_NEXT(elm, field)->field.sle_next); \
288350 SLIST_NEXT(elm, field) = \
289351 SLIST_NEXT(SLIST_NEXT(elm, field), field); \
290 TRASHIT(*oldnext); \
352 TRASHIT(*_Oldnext); \
291353} while (0)
292354
293#define SLIST_REMOVE_HEAD(head, field) do { \
294 QMD_SAVELINK(oldnext, SLIST_FIRST(head)->field.sle_next); \
355#define SLIST_REMOVE_HEAD(head, field) do { \
356 QMD_SAVELINK(_Oldnext, SLIST_FIRST(head)->field.sle_next); \
295357 SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
296 TRASHIT(*oldnext); \
358 TRASHIT(*_Oldnext); \
297359} while (0)
298360
299#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \
361#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \
300362 QMD_SLIST_CHECK_PREVPTR(prevp, elm); \
301363 *(prevp) = SLIST_NEXT(elm, field); \
302364 TRASHIT((elm)->field.sle_next); \
303365} while (0)
304366
367#define SLIST_SPLIT_AFTER(head, elm, rest, field) do { \
368 SLIST_ASSERT_NONEMPTY((head)); \
369 SLIST_FIRST((rest)) = SLIST_NEXT((elm), field); \
370 SLIST_NEXT((elm), field) = NULL; \
371} while (0)
372
305373#define SLIST_SWAP(head1, head2, type) do { \
306 QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \
374 QUEUE_TYPEOF(type) *_Swap_first = SLIST_FIRST(head1); \
307375 SLIST_FIRST(head1) = SLIST_FIRST(head2); \
308 SLIST_FIRST(head2) = swap_first; \
376 SLIST_FIRST(head2) = _Swap_first; \
309377} while (0)
310378
311#define SLIST_END(head) NULL
379#define SLIST_END(head) NULL
312380
313381/*
314382 * Singly-linked Tail queue declarations.
315383 */
316#define STAILQ_HEAD(name, type) \
384
385#define STAILQ_HEAD(name, type) \
317386struct name { \
318387 struct type *stqh_first;/* first element */ \
319388 struct type **stqh_last;/* addr of last next element */ \
320389}
321390
322#define STAILQ_CLASS_HEAD(name, type) \
391#define STAILQ_CLASS_HEAD(name, type) \
323392struct name { \
324393 class type *stqh_first; /* first element */ \
325394 class type **stqh_last; /* addr of last next element */ \
326395}
327396
328#define STAILQ_HEAD_INITIALIZER(head) \
397#define STAILQ_HEAD_INITIALIZER(head) \
329398 { NULL, &(head).stqh_first }
330399
331#define STAILQ_ENTRY(type) \
400#define STAILQ_ENTRY(type) \
332401struct { \
333402 struct type *stqe_next; /* next element */ \
334403}
335404
336#define STAILQ_CLASS_ENTRY(type) \
405#define STAILQ_CLASS_ENTRY(type) \
337406struct { \
338407 class type *stqe_next; /* next element */ \
339408}
......@@ -341,7 +410,38 @@ struct { \
341410/*
342411 * Singly-linked Tail queue functions.
343412 */
344#define STAILQ_CONCAT(head1, head2) do { \
413
414/*
415 * QMD_STAILQ_CHECK_EMPTY(STAILQ_HEAD *head)
416 *
417 * Validates that the stailq head's pointer to the last element's next pointer
418 * actually points to the head's first element pointer field.
419 */
420#define QMD_STAILQ_CHECK_EMPTY(head) \
421 QMD_ASSERT((head)->stqh_last == &(head)->stqh_first, \
422 "Empty stailq %p->stqh_last is %p, " \
423 "not head's first field address", \
424 (head), (head)->stqh_last)
425
426/*
427 * QMD_STAILQ_CHECK_TAIL(STAILQ_HEAD *head)
428 *
429 * Validates that the stailq's last element's next pointer is NULL.
430 */
431#define QMD_STAILQ_CHECK_TAIL(head) \
432 QMD_ASSERT(*(head)->stqh_last == NULL, \
433 "Stailq %p last element's next pointer is " \
434 "%p, not NULL", (head), *(head)->stqh_last)
435
436#define STAILQ_ASSERT_EMPTY(head) \
437 QMD_ASSERT(STAILQ_EMPTY((head)), \
438 "stailq %p is not empty", (head))
439
440#define STAILQ_ASSERT_NONEMPTY(head) \
441 QMD_ASSERT(!STAILQ_EMPTY((head)), \
442 "stailq %p is empty", (head))
443
444#define STAILQ_CONCAT(head1, head2) do { \
345445 if (!STAILQ_EMPTY((head2))) { \
346446 *(head1)->stqh_last = (head2)->stqh_first; \
347447 (head1)->stqh_last = (head2)->stqh_last; \
......@@ -349,72 +449,80 @@ struct { \
349449 } \
350450} while (0)
351451
352#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
452#define STAILQ_EMPTY(head) ({ \
453 if (STAILQ_FIRST(head) == NULL) \
454 QMD_STAILQ_CHECK_EMPTY(head); \
455 STAILQ_FIRST(head) == NULL; \
456})
457
458#define STAILQ_EMPTY_ATOMIC(head) \
459 (atomic_load_ptr(&(head)->stqh_first) == NULL)
353460
354#define STAILQ_FIRST(head) ((head)->stqh_first)
461#define STAILQ_FIRST(head) ((head)->stqh_first)
355462
356#define STAILQ_FOREACH(var, head, field) \
463#define STAILQ_FOREACH(var, head, field) \
357464 for((var) = STAILQ_FIRST((head)); \
358465 (var); \
359466 (var) = STAILQ_NEXT((var), field))
360467
361#define STAILQ_FOREACH_FROM(var, head, field) \
468#define STAILQ_FOREACH_FROM(var, head, field) \
362469 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
363470 (var); \
364471 (var) = STAILQ_NEXT((var), field))
365472
366#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
473#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
367474 for ((var) = STAILQ_FIRST((head)); \
368475 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
369476 (var) = (tvar))
370477
371#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
478#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
372479 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
373480 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
374481 (var) = (tvar))
375482
376#define STAILQ_INIT(head) do { \
483#define STAILQ_INIT(head) do { \
377484 STAILQ_FIRST((head)) = NULL; \
378485 (head)->stqh_last = &STAILQ_FIRST((head)); \
379486} while (0)
380487
381#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
488#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
382489 if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
383490 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
384491 STAILQ_NEXT((tqelm), field) = (elm); \
385492} while (0)
386493
387#define STAILQ_INSERT_HEAD(head, elm, field) do { \
494#define STAILQ_INSERT_HEAD(head, elm, field) do { \
388495 if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
389496 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
390497 STAILQ_FIRST((head)) = (elm); \
391498} while (0)
392499
393#define STAILQ_INSERT_TAIL(head, elm, field) do { \
500#define STAILQ_INSERT_TAIL(head, elm, field) do { \
501 QMD_STAILQ_CHECK_TAIL(head); \
394502 STAILQ_NEXT((elm), field) = NULL; \
395503 *(head)->stqh_last = (elm); \
396504 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
397505} while (0)
398506
399#define STAILQ_LAST(head, type, field) \
507#define STAILQ_LAST(head, type, field) \
400508 (STAILQ_EMPTY((head)) ? NULL : \
401509 __containerof((head)->stqh_last, \
402510 QUEUE_TYPEOF(type), field.stqe_next))
403511
404#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
512#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
405513
406#define STAILQ_REMOVE(head, elm, type, field) do { \
407 QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
514#define STAILQ_REMOVE(head, elm, type, field) do { \
515 QMD_SAVELINK(_Oldnext, (elm)->field.stqe_next); \
408516 if (STAILQ_FIRST((head)) == (elm)) { \
409517 STAILQ_REMOVE_HEAD((head), field); \
410518 } \
411519 else { \
412 QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \
413 while (STAILQ_NEXT(curelm, field) != (elm)) \
414 curelm = STAILQ_NEXT(curelm, field); \
415 STAILQ_REMOVE_AFTER(head, curelm, field); \
520 QUEUE_TYPEOF(type) *_Curelm = STAILQ_FIRST(head); \
521 while (STAILQ_NEXT(_Curelm, field) != (elm)) \
522 _Curelm = STAILQ_NEXT(_Curelm, field); \
523 STAILQ_REMOVE_AFTER(head, _Curelm, field); \
416524 } \
417 TRASHIT(*oldnext); \
525 TRASHIT(*_Oldnext); \
418526} while (0)
419527
420528#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
......@@ -423,51 +531,81 @@ struct { \
423531 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
424532} while (0)
425533
426#define STAILQ_REMOVE_HEAD(head, field) do { \
534#define STAILQ_REMOVE_HEAD(head, field) do { \
427535 if ((STAILQ_FIRST((head)) = \
428536 STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
429537 (head)->stqh_last = &STAILQ_FIRST((head)); \
430538} while (0)
431539
540#define STAILQ_SPLIT_AFTER(head, elm, rest, field) do { \
541 STAILQ_ASSERT_NONEMPTY((head)); \
542 QMD_STAILQ_CHECK_TAIL((head)); \
543 if (STAILQ_NEXT((elm), field) == NULL) \
544 /* 'elm' is the last element in 'head'. */ \
545 STAILQ_INIT((rest)); \
546 else { \
547 STAILQ_FIRST((rest)) = STAILQ_NEXT((elm), field); \
548 (rest)->stqh_last = (head)->stqh_last; \
549 STAILQ_NEXT((elm), field) = NULL; \
550 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
551 } \
552} while (0)
553
432554#define STAILQ_SWAP(head1, head2, type) do { \
433 QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \
434 QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \
555 QUEUE_TYPEOF(type) *_Swap_first = STAILQ_FIRST(head1); \
556 QUEUE_TYPEOF(type) **_Swap_last = (head1)->stqh_last; \
435557 STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
436558 (head1)->stqh_last = (head2)->stqh_last; \
437 STAILQ_FIRST(head2) = swap_first; \
438 (head2)->stqh_last = swap_last; \
439 if (STAILQ_EMPTY(head1)) \
559 STAILQ_FIRST(head2) = _Swap_first; \
560 (head2)->stqh_last = _Swap_last; \
561 if (STAILQ_FIRST(head1) == NULL) \
440562 (head1)->stqh_last = &STAILQ_FIRST(head1); \
441 if (STAILQ_EMPTY(head2)) \
563 if (STAILQ_FIRST(head2) == NULL) \
442564 (head2)->stqh_last = &STAILQ_FIRST(head2); \
443565} while (0)
444566
445#define STAILQ_END(head) NULL
567#define STAILQ_REVERSE(head, type, field) do { \
568 if (STAILQ_EMPTY(head)) \
569 break; \
570 QUEUE_TYPEOF(type) *_Var, *_Varp, *_Varn; \
571 for (_Var = STAILQ_FIRST(head), _Varp = NULL; \
572 _Var != NULL;) { \
573 _Varn = STAILQ_NEXT(_Var, field); \
574 STAILQ_NEXT(_Var, field) = _Varp; \
575 _Varp = _Var; \
576 _Var = _Varn; \
577 } \
578 (head)->stqh_last = &STAILQ_NEXT(STAILQ_FIRST(head), field); \
579 (head)->stqh_first = _Varp; \
580} while (0)
581
582#define STAILQ_END(head) NULL
446583
447584
448585/*
449586 * List declarations.
450587 */
451#define LIST_HEAD(name, type) \
588
589#define LIST_HEAD(name, type) \
452590struct name { \
453591 struct type *lh_first; /* first element */ \
454592}
455593
456#define LIST_CLASS_HEAD(name, type) \
594#define LIST_CLASS_HEAD(name, type) \
457595struct name { \
458596 class type *lh_first; /* first element */ \
459597}
460598
461#define LIST_HEAD_INITIALIZER(head) \
599#define LIST_HEAD_INITIALIZER(head) \
462600 { NULL }
463601
464#define LIST_ENTRY(type) \
602#define LIST_ENTRY(type) \
465603struct { \
466604 struct type *le_next; /* next element */ \
467605 struct type **le_prev; /* address of previous next element */ \
468606}
469607
470#define LIST_CLASS_ENTRY(type) \
608#define LIST_CLASS_ENTRY(type) \
471609struct { \
472610 class type *le_next; /* next element */ \
473611 class type **le_prev; /* address of previous next element */ \
......@@ -477,19 +615,18 @@ struct { \
477615 * List functions.
478616 */
479617
480#if (defined(_KERNEL) && defined(INVARIANTS))
481618/*
482619 * QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME)
483620 *
484621 * If the list is non-empty, validates that the first element of the list
485622 * points back at 'head.'
486623 */
487#define QMD_LIST_CHECK_HEAD(head, field) do { \
488 if (LIST_FIRST((head)) != NULL && \
489 LIST_FIRST((head))->field.le_prev != \
490 &LIST_FIRST((head))) \
491 panic("Bad list head %p first->prev != head", (head)); \
492} while (0)
624#define QMD_LIST_CHECK_HEAD(head, field) \
625 QMD_ASSERT(LIST_FIRST((head)) == NULL || \
626 LIST_FIRST((head))->field.le_prev == \
627 &LIST_FIRST((head)), \
628 "Bad list head %p first->prev != head", \
629 (head))
493630
494631/*
495632 * QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME)
......@@ -497,74 +634,78 @@ struct { \
497634 * If an element follows 'elm' in the list, validates that the next element
498635 * points back at 'elm.'
499636 */
500#define QMD_LIST_CHECK_NEXT(elm, field) do { \
501 if (LIST_NEXT((elm), field) != NULL && \
502 LIST_NEXT((elm), field)->field.le_prev != \
503 &((elm)->field.le_next)) \
504 panic("Bad link elm %p next->prev != elm", (elm)); \
505} while (0)
637#define QMD_LIST_CHECK_NEXT(elm, field) \
638 QMD_ASSERT(LIST_NEXT((elm), field) == NULL || \
639 LIST_NEXT((elm), field)->field.le_prev == \
640 &((elm)->field.le_next), \
641 "Bad link elm %p next->prev != elm", (elm))
506642
507643/*
508644 * QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME)
509645 *
510646 * Validates that the previous element (or head of the list) points to 'elm.'
511647 */
512#define QMD_LIST_CHECK_PREV(elm, field) do { \
513 if (*(elm)->field.le_prev != (elm)) \
514 panic("Bad link elm %p prev->next != elm", (elm)); \
515} while (0)
516#else
517#define QMD_LIST_CHECK_HEAD(head, field)
518#define QMD_LIST_CHECK_NEXT(elm, field)
519#define QMD_LIST_CHECK_PREV(elm, field)
520#endif /* (_KERNEL && INVARIANTS) */
648#define QMD_LIST_CHECK_PREV(elm, field) \
649 QMD_ASSERT(*(elm)->field.le_prev == (elm), \
650 "Bad link elm %p prev->next != elm", (elm))
651
652#define LIST_ASSERT_EMPTY(head) \
653 QMD_ASSERT(LIST_EMPTY((head)), \
654 "list %p is not empty", (head))
655
656#define LIST_ASSERT_NONEMPTY(head) \
657 QMD_ASSERT(!LIST_EMPTY((head)), \
658 "list %p is empty", (head))
521659
522660#define LIST_CONCAT(head1, head2, type, field) do { \
523 QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \
524 if (curelm == NULL) { \
661 QUEUE_TYPEOF(type) *_Curelm = LIST_FIRST(head1); \
662 if (_Curelm == NULL) { \
525663 if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \
526664 LIST_FIRST(head2)->field.le_prev = \
527665 &LIST_FIRST((head1)); \
528666 LIST_INIT(head2); \
529667 } \
530668 } else if (LIST_FIRST(head2) != NULL) { \
531 while (LIST_NEXT(curelm, field) != NULL) \
532 curelm = LIST_NEXT(curelm, field); \
533 LIST_NEXT(curelm, field) = LIST_FIRST(head2); \
534 LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field);\
669 while (LIST_NEXT(_Curelm, field) != NULL) \
670 _Curelm = LIST_NEXT(_Curelm, field); \
671 LIST_NEXT(_Curelm, field) = LIST_FIRST(head2); \
672 LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(_Curelm, field);\
535673 LIST_INIT(head2); \
536674 } \
537675} while (0)
538676
539#define LIST_EMPTY(head) ((head)->lh_first == NULL)
677#define LIST_EMPTY(head) ((head)->lh_first == NULL)
678
679#define LIST_EMPTY_ATOMIC(head) \
680 (atomic_load_ptr(&(head)->lh_first) == NULL)
540681
541#define LIST_FIRST(head) ((head)->lh_first)
682#define LIST_FIRST(head) ((head)->lh_first)
542683
543#define LIST_FOREACH(var, head, field) \
684#define LIST_FOREACH(var, head, field) \
544685 for ((var) = LIST_FIRST((head)); \
545686 (var); \
546687 (var) = LIST_NEXT((var), field))
547688
548#define LIST_FOREACH_FROM(var, head, field) \
689#define LIST_FOREACH_FROM(var, head, field) \
549690 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
550691 (var); \
551692 (var) = LIST_NEXT((var), field))
552693
553#define LIST_FOREACH_SAFE(var, head, field, tvar) \
694#define LIST_FOREACH_SAFE(var, head, field, tvar) \
554695 for ((var) = LIST_FIRST((head)); \
555696 (var) && ((tvar) = LIST_NEXT((var), field), 1); \
556697 (var) = (tvar))
557698
558#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
699#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
559700 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
560701 (var) && ((tvar) = LIST_NEXT((var), field), 1); \
561702 (var) = (tvar))
562703
563#define LIST_INIT(head) do { \
704#define LIST_INIT(head) do { \
564705 LIST_FIRST((head)) = NULL; \
565706} while (0)
566707
567#define LIST_INSERT_AFTER(listelm, elm, field) do { \
708#define LIST_INSERT_AFTER(listelm, elm, field) do { \
568709 QMD_LIST_CHECK_NEXT(listelm, field); \
569710 if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
570711 LIST_NEXT((listelm), field)->field.le_prev = \
......@@ -573,7 +714,7 @@ struct { \
573714 (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
574715} while (0)
575716
576#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
717#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
577718 QMD_LIST_CHECK_PREV(listelm, field); \
578719 (elm)->field.le_prev = (listelm)->field.le_prev; \
579720 LIST_NEXT((elm), field) = (listelm); \
......@@ -581,7 +722,7 @@ struct { \
581722 (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
582723} while (0)
583724
584#define LIST_INSERT_HEAD(head, elm, field) do { \
725#define LIST_INSERT_HEAD(head, elm, field) do { \
585726 QMD_LIST_CHECK_HEAD((head), field); \
586727 if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
587728 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
......@@ -589,9 +730,9 @@ struct { \
589730 (elm)->field.le_prev = &LIST_FIRST((head)); \
590731} while (0)
591732
592#define LIST_NEXT(elm, field) ((elm)->field.le_next)
733#define LIST_NEXT(elm, field) ((elm)->field.le_next)
593734
594#define LIST_PREV(elm, head, type, field) \
735#define LIST_PREV(elm, head, type, field) \
595736 ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
596737 __containerof((elm)->field.le_prev, \
597738 QUEUE_TYPEOF(type), field.le_next))
......@@ -599,22 +740,22 @@ struct { \
599740#define LIST_REMOVE_HEAD(head, field) \
600741 LIST_REMOVE(LIST_FIRST(head), field)
601742
602#define LIST_REMOVE(elm, field) do { \
603 QMD_SAVELINK(oldnext, (elm)->field.le_next); \
604 QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
743#define LIST_REMOVE(elm, field) do { \
744 QMD_SAVELINK(_Oldnext, (elm)->field.le_next); \
745 QMD_SAVELINK(_Oldprev, (elm)->field.le_prev); \
605746 QMD_LIST_CHECK_NEXT(elm, field); \
606747 QMD_LIST_CHECK_PREV(elm, field); \
607748 if (LIST_NEXT((elm), field) != NULL) \
608749 LIST_NEXT((elm), field)->field.le_prev = \
609750 (elm)->field.le_prev; \
610751 *(elm)->field.le_prev = LIST_NEXT((elm), field); \
611 TRASHIT(*oldnext); \
612 TRASHIT(*oldprev); \
752 TRASHIT(*_Oldnext); \
753 TRASHIT(*_Oldprev); \
613754} while (0)
614755
615756#define LIST_REPLACE(elm, elm2, field) do { \
616 QMD_SAVELINK(oldnext, (elm)->field.le_next); \
617 QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
757 QMD_SAVELINK(_Oldnext, (elm)->field.le_next); \
758 QMD_SAVELINK(_Oldprev, (elm)->field.le_prev); \
618759 QMD_LIST_CHECK_NEXT(elm, field); \
619760 QMD_LIST_CHECK_PREV(elm, field); \
620761 LIST_NEXT((elm2), field) = LIST_NEXT((elm), field); \
......@@ -623,8 +764,21 @@ struct { \
623764 &(elm2)->field.le_next; \
624765 (elm2)->field.le_prev = (elm)->field.le_prev; \
625766 *(elm2)->field.le_prev = (elm2); \
626 TRASHIT(*oldnext); \
627 TRASHIT(*oldprev); \
767 TRASHIT(*_Oldnext); \
768 TRASHIT(*_Oldprev); \
769} while (0)
770
771#define LIST_SPLIT_AFTER(head, elm, rest, field) do { \
772 LIST_ASSERT_NONEMPTY((head)); \
773 if (LIST_NEXT((elm), field) == NULL) \
774 /* 'elm' is the last element in 'head'. */ \
775 LIST_INIT((rest)); \
776 else { \
777 LIST_FIRST((rest)) = LIST_NEXT((elm), field); \
778 LIST_NEXT((elm), field)->field.le_prev = \
779 &LIST_FIRST((rest)); \
780 LIST_NEXT((elm), field) = NULL; \
781 } \
628782} while (0)
629783
630784#define LIST_SWAP(head1, head2, type, field) do { \
......@@ -637,36 +791,37 @@ struct { \
637791 swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
638792} while (0)
639793
640#define LIST_END(head) NULL
794#define LIST_END(head) NULL
641795
642796/*
643797 * Tail queue declarations.
644798 */
645#define TAILQ_HEAD(name, type) \
799
800#define TAILQ_HEAD(name, type) \
646801struct name { \
647802 struct type *tqh_first; /* first element */ \
648803 struct type **tqh_last; /* addr of last next element */ \
649804 TRACEBUF \
650805}
651806
652#define TAILQ_CLASS_HEAD(name, type) \
807#define TAILQ_CLASS_HEAD(name, type) \
653808struct name { \
654809 class type *tqh_first; /* first element */ \
655810 class type **tqh_last; /* addr of last next element */ \
656811 TRACEBUF \
657812}
658813
659#define TAILQ_HEAD_INITIALIZER(head) \
814#define TAILQ_HEAD_INITIALIZER(head) \
660815 { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
661816
662#define TAILQ_ENTRY(type) \
817#define TAILQ_ENTRY(type) \
663818struct { \
664819 struct type *tqe_next; /* next element */ \
665820 struct type **tqe_prev; /* address of previous next element */ \
666821 TRACEBUF \
667822}
668823
669#define TAILQ_CLASS_ENTRY(type) \
824#define TAILQ_CLASS_ENTRY(type) \
670825struct { \
671826 class type *tqe_next; /* next element */ \
672827 class type **tqe_prev; /* address of previous next element */ \
......@@ -676,29 +831,29 @@ struct { \
676831/*
677832 * Tail queue functions.
678833 */
679#if (defined(_KERNEL) && defined(INVARIANTS))
834
680835/*
681836 * QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
682837 *
683838 * If the tailq is non-empty, validates that the first element of the tailq
684839 * points back at 'head.'
685840 */
686#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
687 if (!TAILQ_EMPTY(head) && \
688 TAILQ_FIRST((head))->field.tqe_prev != \
689 &TAILQ_FIRST((head))) \
690 panic("Bad tailq head %p first->prev != head", (head)); \
691} while (0)
841#define QMD_TAILQ_CHECK_HEAD(head, field) \
842 QMD_ASSERT(TAILQ_EMPTY(head) || \
843 TAILQ_FIRST((head))->field.tqe_prev == \
844 &TAILQ_FIRST((head)), \
845 "Bad tailq head %p first->prev != head", \
846 (head))
692847
693848/*
694849 * QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
695850 *
696851 * Validates that the tail of the tailq is a pointer to pointer to NULL.
697852 */
698#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
699 if (*(head)->tqh_last != NULL) \
700 panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
701} while (0)
853#define QMD_TAILQ_CHECK_TAIL(head, field) \
854 QMD_ASSERT(*(head)->tqh_last == NULL, \
855 "Bad tailq NEXT(%p->tqh_last) != NULL", \
856 (head))
702857
703858/*
704859 * QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME)
......@@ -706,30 +861,30 @@ struct { \
706861 * If an element follows 'elm' in the tailq, validates that the next element
707862 * points back at 'elm.'
708863 */
709#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
710 if (TAILQ_NEXT((elm), field) != NULL && \
711 TAILQ_NEXT((elm), field)->field.tqe_prev != \
712 &((elm)->field.tqe_next)) \
713 panic("Bad link elm %p next->prev != elm", (elm)); \
714} while (0)
864#define QMD_TAILQ_CHECK_NEXT(elm, field) \
865 QMD_ASSERT(TAILQ_NEXT((elm), field) == NULL || \
866 TAILQ_NEXT((elm), field)->field.tqe_prev == \
867 &((elm)->field.tqe_next), \
868 "Bad link elm %p next->prev != elm", (elm))
715869
716870/*
717871 * QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME)
718872 *
719873 * Validates that the previous element (or head of the tailq) points to 'elm.'
720874 */
721#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
722 if (*(elm)->field.tqe_prev != (elm)) \
723 panic("Bad link elm %p prev->next != elm", (elm)); \
724} while (0)
725#else
726#define QMD_TAILQ_CHECK_HEAD(head, field)
727#define QMD_TAILQ_CHECK_TAIL(head, headname)
728#define QMD_TAILQ_CHECK_NEXT(elm, field)
729#define QMD_TAILQ_CHECK_PREV(elm, field)
730#endif /* (_KERNEL && INVARIANTS) */
875#define QMD_TAILQ_CHECK_PREV(elm, field) \
876 QMD_ASSERT(*(elm)->field.tqe_prev == (elm), \
877 "Bad link elm %p prev->next != elm", (elm))
731878
732#define TAILQ_CONCAT(head1, head2, field) do { \
879#define TAILQ_ASSERT_EMPTY(head) \
880 QMD_ASSERT(TAILQ_EMPTY((head)), \
881 "tailq %p is not empty", (head))
882
883#define TAILQ_ASSERT_NONEMPTY(head) \
884 QMD_ASSERT(!TAILQ_EMPTY((head)), \
885 "tailq %p is empty", (head))
886
887#define TAILQ_CONCAT(head1, head2, field) do { \
733888 if (!TAILQ_EMPTY(head2)) { \
734889 *(head1)->tqh_last = (head2)->tqh_first; \
735890 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
......@@ -740,57 +895,60 @@ struct { \
740895 } \
741896} while (0)
742897
743#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
898#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
899
900#define TAILQ_EMPTY_ATOMIC(head) \
901 (atomic_load_ptr(&(head)->tqh_first) == NULL)
744902
745#define TAILQ_FIRST(head) ((head)->tqh_first)
903#define TAILQ_FIRST(head) ((head)->tqh_first)
746904
747#define TAILQ_FOREACH(var, head, field) \
905#define TAILQ_FOREACH(var, head, field) \
748906 for ((var) = TAILQ_FIRST((head)); \
749907 (var); \
750908 (var) = TAILQ_NEXT((var), field))
751909
752#define TAILQ_FOREACH_FROM(var, head, field) \
910#define TAILQ_FOREACH_FROM(var, head, field) \
753911 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
754912 (var); \
755913 (var) = TAILQ_NEXT((var), field))
756914
757#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
915#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
758916 for ((var) = TAILQ_FIRST((head)); \
759917 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
760918 (var) = (tvar))
761919
762#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
920#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
763921 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
764922 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
765923 (var) = (tvar))
766924
767#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
925#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
768926 for ((var) = TAILQ_LAST((head), headname); \
769927 (var); \
770928 (var) = TAILQ_PREV((var), headname, field))
771929
772#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
930#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
773931 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
774932 (var); \
775933 (var) = TAILQ_PREV((var), headname, field))
776934
777#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
935#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
778936 for ((var) = TAILQ_LAST((head), headname); \
779937 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
780938 (var) = (tvar))
781939
782#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar)\
940#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar)\
783941 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
784942 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
785943 (var) = (tvar))
786944
787#define TAILQ_INIT(head) do { \
945#define TAILQ_INIT(head) do { \
788946 TAILQ_FIRST((head)) = NULL; \
789947 (head)->tqh_last = &TAILQ_FIRST((head)); \
790948 QMD_TRACE_HEAD(head); \
791949} while (0)
792950
793#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
951#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
794952 QMD_TAILQ_CHECK_NEXT(listelm, field); \
795953 if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
796954 TAILQ_NEXT((elm), field)->field.tqe_prev = \
......@@ -805,7 +963,7 @@ struct { \
805963 QMD_TRACE_ELEM(&(listelm)->field); \
806964} while (0)
807965
808#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
966#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
809967 QMD_TAILQ_CHECK_PREV(listelm, field); \
810968 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
811969 TAILQ_NEXT((elm), field) = (listelm); \
......@@ -815,7 +973,7 @@ struct { \
815973 QMD_TRACE_ELEM(&(listelm)->field); \
816974} while (0)
817975
818#define TAILQ_INSERT_HEAD(head, elm, field) do { \
976#define TAILQ_INSERT_HEAD(head, elm, field) do { \
819977 QMD_TAILQ_CHECK_HEAD(head, field); \
820978 if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
821979 TAILQ_FIRST((head))->field.tqe_prev = \
......@@ -828,7 +986,7 @@ struct { \
828986 QMD_TRACE_ELEM(&(elm)->field); \
829987} while (0)
830988
831#define TAILQ_INSERT_TAIL(head, elm, field) do { \
989#define TAILQ_INSERT_TAIL(head, elm, field) do { \
832990 QMD_TAILQ_CHECK_TAIL(head, field); \
833991 TAILQ_NEXT((elm), field) = NULL; \
834992 (elm)->field.tqe_prev = (head)->tqh_last; \
......@@ -838,7 +996,7 @@ struct { \
838996 QMD_TRACE_ELEM(&(elm)->field); \
839997} while (0)
840998
841#define TAILQ_LAST(head, headname) \
999#define TAILQ_LAST(head, headname) \
8421000 (*(((struct headname *)((head)->tqh_last))->tqh_last))
8431001
8441002/*
......@@ -848,24 +1006,24 @@ struct { \
8481006 * the previous element. FAST is very useful for instances when
8491007 * you may want to prefetch the last data element.
8501008 */
851#define TAILQ_LAST_FAST(head, type, field) \
1009#define TAILQ_LAST_FAST(head, type, field) \
8521010 (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next))
8531011
854#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
1012#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
8551013
856#define TAILQ_PREV(elm, headname, field) \
1014#define TAILQ_PREV(elm, headname, field) \
8571015 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
8581016
859#define TAILQ_PREV_FAST(elm, head, type, field) \
1017#define TAILQ_PREV_FAST(elm, head, type, field) \
8601018 ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \
8611019 __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next))
8621020
8631021#define TAILQ_REMOVE_HEAD(head, field) \
8641022 TAILQ_REMOVE(head, TAILQ_FIRST(head), field)
8651023
866#define TAILQ_REMOVE(head, elm, field) do { \
867 QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
868 QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
1024#define TAILQ_REMOVE(head, elm, field) do { \
1025 QMD_SAVELINK(_Oldnext, (elm)->field.tqe_next); \
1026 QMD_SAVELINK(_Oldprev, (elm)->field.tqe_prev); \
8691027 QMD_TAILQ_CHECK_NEXT(elm, field); \
8701028 QMD_TAILQ_CHECK_PREV(elm, field); \
8711029 if ((TAILQ_NEXT((elm), field)) != NULL) \
......@@ -876,14 +1034,14 @@ struct { \
8761034 QMD_TRACE_HEAD(head); \
8771035 } \
8781036 *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
879 TRASHIT(*oldnext); \
880 TRASHIT(*oldprev); \
1037 TRASHIT(*_Oldnext); \
1038 TRASHIT(*_Oldprev); \
8811039 QMD_TRACE_ELEM(&(elm)->field); \
8821040} while (0)
8831041
8841042#define TAILQ_REPLACE(head, elm, elm2, field) do { \
885 QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
886 QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
1043 QMD_SAVELINK(_Oldnext, (elm)->field.tqe_next); \
1044 QMD_SAVELINK(_Oldprev, (elm)->field.tqe_prev); \
8871045 QMD_TAILQ_CHECK_NEXT(elm, field); \
8881046 QMD_TAILQ_CHECK_PREV(elm, field); \
8891047 TAILQ_NEXT((elm2), field) = TAILQ_NEXT((elm), field); \
......@@ -894,11 +1052,28 @@ struct { \
8941052 (head)->tqh_last = &(elm2)->field.tqe_next; \
8951053 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
8961054 *(elm2)->field.tqe_prev = (elm2); \
897 TRASHIT(*oldnext); \
898 TRASHIT(*oldprev); \
1055 TRASHIT(*_Oldnext); \
1056 TRASHIT(*_Oldprev); \
8991057 QMD_TRACE_ELEM(&(elm)->field); \
9001058} while (0)
9011059
1060#define TAILQ_SPLIT_AFTER(head, elm, rest, field) do { \
1061 TAILQ_ASSERT_NONEMPTY((head)); \
1062 QMD_TAILQ_CHECK_TAIL((head), field); \
1063 if (TAILQ_NEXT((elm), field) == NULL) \
1064 /* 'elm' is the last element in 'head'. */ \
1065 TAILQ_INIT((rest)); \
1066 else { \
1067 TAILQ_FIRST((rest)) = TAILQ_NEXT((elm), field); \
1068 (rest)->tqh_last = (head)->tqh_last; \
1069 TAILQ_NEXT((elm), field)->field.tqe_prev = \
1070 &TAILQ_FIRST((rest)); \
1071 \
1072 TAILQ_NEXT((elm), field) = NULL; \
1073 (head)->tqh_last = &TAILQ_NEXT((elm), field); \
1074 } \
1075} while (0)
1076
9021077#define TAILQ_SWAP(head1, head2, type, field) do { \
9031078 QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \
9041079 QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \
......@@ -916,6 +1091,6 @@ struct { \
9161091 (head2)->tqh_last = &(head2)->tqh_first; \
9171092} while (0)
9181093
919#define TAILQ_END(head) NULL
1094#define TAILQ_END(head) NULL
9201095
9211096#endif /* !_SYS_QUEUE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/racct.h+5-2
......@@ -35,7 +35,6 @@
3535#ifndef _RACCT_H_
3636#define _RACCT_H_
3737
38#include <sys/cdefs.h>
3938#include <sys/types.h>
4039#include <sys/queue.h>
4140#include <sys/stdint.h>
......@@ -142,13 +141,17 @@ extern bool racct_enable;
142141
143142/*
144143 * The 'racct' structure defines resource consumption for a particular
145 * subject, such as process or jail.
144 * subject, such as process or jail. It also contains the total
145 * cpu time and real time of the subject, recorded at the most recent
146 * time that RACCT_PCPU was updated.
146147 *
147148 * This structure must be filled with zeroes initially.
148149 */
149150struct racct {
150151 int64_t r_resources[RACCT_MAX + 1];
151152 LIST_HEAD(, rctl_rule_link) r_rule_links;
153 uint64_t r_runtime;
154 struct timeval r_time;
152155};
153156
154157SYSCTL_DECL(_kern_racct);
lib/libc/include/generic-freebsd/sys/random.h+14-9
......@@ -85,24 +85,26 @@ enum random_entropy_source {
8585 RANDOM_FS_ATIME,
8686 RANDOM_UMA, /* Special!! UMA/SLAB Allocator */
8787 RANDOM_CALLOUT,
88 RANDOM_ENVIRONMENTAL_END = RANDOM_CALLOUT,
88 RANDOM_RANDOMDEV,
89 RANDOM_ENVIRONMENTAL_END = RANDOM_RANDOMDEV,
8990 /* Fast hardware random-number sources from here on. */
9091 RANDOM_PURE_START,
91 RANDOM_PURE_OCTEON = RANDOM_PURE_START,
92 RANDOM_PURE_SAFE,
93 RANDOM_PURE_GLXSB,
94 RANDOM_PURE_HIFN,
92 RANDOM_PURE_TPM = RANDOM_PURE_START,
9593 RANDOM_PURE_RDRAND,
94 RANDOM_PURE_RDSEED,
9695 RANDOM_PURE_NEHEMIAH,
9796 RANDOM_PURE_RNDTEST,
9897 RANDOM_PURE_VIRTIO,
9998 RANDOM_PURE_BROADCOM,
10099 RANDOM_PURE_CCP,
101100 RANDOM_PURE_DARN,
102 RANDOM_PURE_TPM,
103101 RANDOM_PURE_VMGENID,
104102 RANDOM_PURE_QUALCOMM,
105103 RANDOM_PURE_ARMV8,
104 RANDOM_PURE_ARM_TRNG,
105 RANDOM_PURE_SAFE,
106 RANDOM_PURE_GLXSB,
107 RANDOM_PURE_HIFN,
106108 ENTROPYSOURCE
107109};
108110_Static_assert(ENTROPYSOURCE <= 32,
......@@ -140,9 +142,6 @@ random_harvest_direct(const void *entropy, u_int size, enum random_entropy_sourc
140142 random_harvest_direct_(entropy, size, origin);
141143}
142144
143void random_harvest_register_source(enum random_entropy_source);
144void random_harvest_deregister_source(enum random_entropy_source);
145
146145#if defined(RANDOM_ENABLE_UMA)
147146#define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c)
148147#else /* !defined(RANDOM_ENABLE_UMA) */
......@@ -155,6 +154,12 @@ void random_harvest_deregister_source(enum random_entropy_source);
155154#define random_harvest_queue_ether(a, b) do {} while (0)
156155#endif /* defined(RANDOM_ENABLE_ETHER) */
157156
157#else /* !_KERNEL */
158
159#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
160#include <ssp/random.h>
161#endif
162
158163#endif /* _KERNEL */
159164
160165#define GRND_NONBLOCK 0x1
lib/libc/include/generic-freebsd/sys/rangelock.h+16-30
......@@ -29,12 +29,14 @@
2929#ifndef _SYS_RANGELOCK_H
3030#define _SYS_RANGELOCK_H
3131
32#include <sys/queue.h>
32#include <sys/types.h>
33#ifndef _KERNEL
34#include <stdbool.h>
35#endif
3336
3437#define RL_LOCK_READ 0x0001
3538#define RL_LOCK_WRITE 0x0002
3639#define RL_LOCK_TYPE_MASK 0x0003
37#define RL_LOCK_GRANTED 0x0004
3840
3941struct rl_q_entry;
4042
......@@ -44,42 +46,26 @@ struct rl_q_entry;
4446 * all existing lock owners are compatible with the request. Two lock
4547 * owners are compatible if their ranges do not overlap, or both
4648 * owners are for read.
47 *
48 * Access to the structure itself is synchronized with the externally
49 * supplied mutex.
50 *
51 * rl_waiters is the queue containing in order (a) granted write lock
52 * requests, (b) granted read lock requests, and (c) in order of arrival,
53 * lock requests which cannot be granted yet.
54 *
55 * rl_currdep is the first lock request that cannot be granted now due
56 * to the preceding requests conflicting with it (i.e., it points to
57 * position (c) in the list above).
5849 */
5950struct rangelock {
60 TAILQ_HEAD(, rl_q_entry) rl_waiters;
61 struct rl_q_entry *rl_currdep;
51 uintptr_t head;
52 bool sleepers;
6253};
6354
6455#ifdef _KERNEL
6556
66struct mtx;
67
6857void rangelock_init(struct rangelock *lock);
6958void rangelock_destroy(struct rangelock *lock);
70void rangelock_unlock(struct rangelock *lock, void *cookie,
71 struct mtx *ilk);
72void *rangelock_unlock_range(struct rangelock *lock, void *cookie,
73 off_t start, off_t end, struct mtx *ilk);
74void *rangelock_rlock(struct rangelock *lock, off_t start, off_t end,
75 struct mtx *ilk);
76void *rangelock_tryrlock(struct rangelock *lock, off_t start, off_t end,
77 struct mtx *ilk);
78void *rangelock_wlock(struct rangelock *lock, off_t start, off_t end,
79 struct mtx *ilk);
80void *rangelock_trywlock(struct rangelock *lock, off_t start, off_t end,
81 struct mtx *ilk);
82void rlqentry_free(struct rl_q_entry *rlqe);
59void rangelock_unlock(struct rangelock *lock, void *cookie);
60void *rangelock_rlock(struct rangelock *lock, vm_ooffset_t start,
61 vm_ooffset_t end);
62void *rangelock_tryrlock(struct rangelock *lock, vm_ooffset_t start,
63 vm_ooffset_t end);
64void *rangelock_wlock(struct rangelock *lock, vm_ooffset_t start,
65 vm_ooffset_t end);
66void *rangelock_trywlock(struct rangelock *lock, vm_ooffset_t start,
67 vm_ooffset_t end);
68void rangelock_may_recurse(struct rangelock *lock);
8369#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
8470void _rangelock_cookie_assert(void *cookie, int what, const char *file,
8571 int line);
lib/libc/include/generic-freebsd/sys/rangeset.h+12-3
......@@ -69,10 +69,19 @@ int rangeset_remove_pred(struct rangeset *rs, uint64_t start,
6969 uint64_t end, rs_pred_t pred);
7070
7171/*
72 * Really returns the pointer to the data with struct rs_el embedded
73 * at the beginning.
72 * Finds the range that contains place, if any.
7473 */
75void *rangeset_lookup(struct rangeset *rs, uint64_t place);
74void *rangeset_containing(struct rangeset *rs, uint64_t place);
75
76/*
77 * Report whether no range begins between start and end.
78 */
79bool rangeset_empty(struct rangeset *rs, uint64_t start, uint64_t end);
80
81/*
82 * Finds the range that begins at place, if any.
83 */
84void *rangeset_beginning(struct rangeset *rs, uint64_t place);
7685
7786/*
7887 * Copies src_rs entries into dst_rs. dst_rs must be empty.
lib/libc/include/generic-freebsd/sys/reboot.h+1-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)reboot.h 8.3 (Berkeley) 12/13/94
3230 */
3331
3432#ifndef _SYS_REBOOT_H_
......@@ -62,6 +60,7 @@
6260#define RB_PAUSE 0x100000 /* pause after each output line during probe */
6361#define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */
6462#define RB_POWERCYCLE 0x400000 /* Power cycle if possible */
63#define RB_MUTEMSGS 0x800000 /* start up with console muted after banner */
6564#define RB_PROBE 0x10000000 /* Probe multiple consoles */
6665#define RB_MULTIPLE 0x20000000 /* use multiple consoles */
6766
lib/libc/include/generic-freebsd/sys/refcount.h+6-7
......@@ -28,15 +28,14 @@
2828#ifndef __SYS_REFCOUNT_H__
2929#define __SYS_REFCOUNT_H__
3030
31#include <machine/atomic.h>
32
33#if defined(_KERNEL) || defined(_STANDALONE)
34#include <sys/systm.h>
35#else
31#include <sys/types.h>
32#include <sys/kassert.h>
33#if !defined(_KERNEL) && !defined(_STANDALONE)
3634#include <stdbool.h>
37#define KASSERT(exp, msg) /* */
3835#endif
3936
37#include <machine/atomic.h>
38
4039#define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0)
4140#define REFCOUNT_SATURATION_VALUE (3U << 30)
4241
......@@ -65,7 +64,7 @@ refcount_init(volatile u_int *count, u_int value)
6564}
6665
6766static __inline u_int
68refcount_load(volatile u_int *count)
67refcount_load(volatile const u_int *count)
6968{
7069 return (atomic_load_int(count));
7170}
lib/libc/include/generic-freebsd/sys/resource.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)resource.h 8.4 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_RESOURCE_H_
lib/libc/include/generic-freebsd/sys/resourcevar.h+4-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_RESOURCEVAR_H_
......@@ -124,6 +122,8 @@ struct uidinfo {
124122 long ui_kqcnt; /* (b) number of kqueues */
125123 long ui_umtxcnt; /* (b) number of shared umtxs */
126124 long ui_pipecnt; /* (b) consumption of pipe buffers */
125 long ui_inotifycnt; /* (b) number of inotify descriptors */
126 long ui_inotifywatchcnt; /* (b) number of inotify watches */
127127 uid_t ui_uid; /* (a) uid */
128128 u_int ui_ref; /* (b) reference count */
129129#ifdef RACCT
......@@ -146,6 +146,8 @@ int chgsbsize(struct uidinfo *uip, u_int *hiwat, u_int to,
146146int chgptscnt(struct uidinfo *uip, int diff, rlim_t maxval);
147147int chgumtxcnt(struct uidinfo *uip, int diff, rlim_t maxval);
148148int chgpipecnt(struct uidinfo *uip, int diff, rlim_t max);
149int chginotifycnt(struct uidinfo *uip, int diff, rlim_t maxval);
150int chginotifywatchcnt(struct uidinfo *uip, int diff, rlim_t maxval);
149151int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
150152 struct rlimit *limp);
151153struct plimit
lib/libc/include/generic-freebsd/sys/rman.h+14-17
......@@ -124,17 +124,18 @@ TAILQ_HEAD(rman_head, rman);
124124int rman_activate_resource(struct resource *r);
125125int rman_adjust_resource(struct resource *r, rman_res_t start, rman_res_t end);
126126int rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);
127bus_space_handle_t rman_get_bushandle(struct resource *);
128bus_space_tag_t rman_get_bustag(struct resource *);
129rman_res_t rman_get_end(struct resource *);
130device_t rman_get_device(struct resource *);
131u_int rman_get_flags(struct resource *);
132void *rman_get_irq_cookie(struct resource *);
133void rman_get_mapping(struct resource *, struct resource_map *);
134int rman_get_rid(struct resource *);
135rman_res_t rman_get_size(struct resource *);
136rman_res_t rman_get_start(struct resource *);
137void *rman_get_virtual(struct resource *);
127bus_space_handle_t rman_get_bushandle(const struct resource *);
128bus_space_tag_t rman_get_bustag(const struct resource *);
129rman_res_t rman_get_end(const struct resource *);
130device_t rman_get_device(const struct resource *);
131u_int rman_get_flags(const struct resource *);
132void *rman_get_irq_cookie(const struct resource *);
133void rman_get_mapping(const struct resource *, struct resource_map *);
134int rman_get_rid(const struct resource *);
135rman_res_t rman_get_size(const struct resource *);
136rman_res_t rman_get_start(const struct resource *);
137int rman_get_type(const struct resource *);
138void *rman_get_virtual(const struct resource *);
138139int rman_deactivate_resource(struct resource *r);
139140int rman_fini(struct rman *rm);
140141int rman_init(struct rman *rm);
......@@ -142,22 +143,18 @@ int rman_init_from_resource(struct rman *rm, struct resource *r);
142143int rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);
143144uint32_t rman_make_alignment_flags(uint32_t size);
144145int rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end);
145int rman_is_region_manager(struct resource *r, struct rman *rm);
146int rman_is_region_manager(const struct resource *r, const struct rman *rm);
146147int rman_release_resource(struct resource *r);
147148struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start,
148149 rman_res_t end, rman_res_t count,
149150 u_int flags, device_t dev);
150struct resource *rman_reserve_resource_bound(struct rman *rm, rman_res_t start,
151 rman_res_t end, rman_res_t count, rman_res_t bound,
152 u_int flags, device_t dev);
153151void rman_set_bushandle(struct resource *_r, bus_space_handle_t _h);
154152void rman_set_bustag(struct resource *_r, bus_space_tag_t _t);
155153void rman_set_device(struct resource *_r, device_t _dev);
156void rman_set_end(struct resource *_r, rman_res_t _end);
157154void rman_set_irq_cookie(struct resource *_r, void *_c);
158155void rman_set_mapping(struct resource *, struct resource_map *);
159156void rman_set_rid(struct resource *_r, int _rid);
160void rman_set_start(struct resource *_r, rman_res_t _start);
157void rman_set_type(struct resource *_r, int _type);
161158void rman_set_virtual(struct resource *_r, void *_v);
162159
163160extern struct rman_head rman_head;
lib/libc/include/generic-freebsd/sys/rmlock.h+1-1
......@@ -52,7 +52,7 @@ void rm_init(struct rmlock *rm, const char *name);
5252void rm_init_flags(struct rmlock *rm, const char *name, int opts);
5353void rm_destroy(struct rmlock *rm);
5454int rm_wowned(const struct rmlock *rm);
55void rm_sysinit(void *arg);
55void rm_sysinit(const void *arg);
5656
5757void _rm_wlock_debug(struct rmlock *rm, const char *file, int line);
5858void _rm_wunlock_debug(struct rmlock *rm, const char *file, int line);
lib/libc/include/generic-freebsd/sys/runq.h+66-17
......@@ -3,6 +3,11 @@
33 *
44 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
55 * All rights reserved.
6 * Copyright (c) 2024 The FreeBSD Foundation
7 *
8 * Portions of this software were developed by Olivier Certner
9 * <olce.freebsd@certner.fr> at Kumacom SARL under sponsorship from the FreeBSD
10 * Foundation.
611 *
712 * Redistribution and use in source and binary forms, with or without
813 * modification, are permitted provided that the following conditions
......@@ -29,7 +34,14 @@
2934#ifndef _RUNQ_H_
3035#define _RUNQ_H_
3136
32#include <machine/runq.h>
37#ifndef _KERNEL
38#error "no user-serviceable parts inside"
39#endif
40
41#include <sys/types.h> /* For bool. */
42#include <sys/_param.h>
43#include <sys/libkern.h>
44#include <sys/queue.h>
3345
3446struct thread;
3547
......@@ -37,20 +49,46 @@ struct thread;
3749 * Run queue parameters.
3850 */
3951
40#define RQ_NQS (64) /* Number of run queues. */
41#define RQ_PPQ (4) /* Priorities per queue. */
52#define RQ_MAX_PRIO (255) /* Maximum priority (minimum is 0). */
53#define RQ_PPQ (1) /* Priorities per queue. */
54
55/*
56 * Deduced from the above parameters and machine ones.
57 */
58#define RQ_NQS (howmany(RQ_MAX_PRIO + 1, RQ_PPQ)) /* Number of run queues. */
59#define RQ_PRI_TO_QUEUE_IDX(pri) ((pri) / RQ_PPQ) /* Priority to queue index. */
60
61typedef unsigned long rqsw_t; /* runq's status words type. */
62#define RQSW_BPW (sizeof(rqsw_t) * NBBY) /* Bits per runq word. */
63#define RQSW_PRI "%#lx" /* printf() directive. */
64
65/* Number of status words to cover RQ_NQS queues. */
66#define RQSW_NB (howmany(RQ_NQS, RQSW_BPW))
67#define RQSW_IDX(idx) ((idx) / RQSW_BPW)
68#define RQSW_BIT_IDX(idx) ((idx) % RQSW_BPW)
69#define RQSW_BIT(idx) (1ul << RQSW_BIT_IDX(idx))
70#define RQSW_BSF(word) __extension__ ({ \
71 int _res = ffsl((long)(word)); /* Assumes two-complement. */ \
72 MPASS(_res > 0); \
73 _res - 1; \
74})
75#define RQSW_TO_QUEUE_IDX(word_idx, bit_idx) \
76 (((word_idx) * RQSW_BPW) + (bit_idx))
77#define RQSW_FIRST_QUEUE_IDX(word_idx, word) \
78 RQSW_TO_QUEUE_IDX(word_idx, RQSW_BSF(word))
79
4280
4381/*
44 * Head of run queues.
82 * The queue for a given index as a list of threads.
4583 */
46TAILQ_HEAD(rqhead, thread);
84TAILQ_HEAD(rq_queue, thread);
4785
4886/*
4987 * Bit array which maintains the status of a run queue. When a queue is
5088 * non-empty the bit corresponding to the queue number will be set.
5189 */
52struct rqbits {
53 rqb_word_t rqb_bits[RQB_LEN];
90struct rq_status {
91 rqsw_t rq_sw[RQSW_NB];
5492};
5593
5694/*
......@@ -58,18 +96,29 @@ struct rqbits {
5896 * are placed, and a structure to maintain the status of each queue.
5997 */
6098struct runq {
61 struct rqbits rq_status;
62 struct rqhead rq_queues[RQ_NQS];
99 struct rq_status rq_status;
100 struct rq_queue rq_queues[RQ_NQS];
63101};
64102
65void runq_add(struct runq *, struct thread *, int);
66void runq_add_pri(struct runq *, struct thread *, u_char, int);
67int runq_check(struct runq *);
68struct thread *runq_choose(struct runq *);
69struct thread *runq_choose_from(struct runq *, u_char);
70struct thread *runq_choose_fuzz(struct runq *, int);
71103void runq_init(struct runq *);
72void runq_remove(struct runq *, struct thread *);
73void runq_remove_idx(struct runq *, struct thread *, u_char *);
104bool runq_is_queue_empty(struct runq *, int _idx);
105void runq_add(struct runq *, struct thread *, int _flags);
106void runq_add_idx(struct runq *, struct thread *, int _idx, int _flags);
107bool runq_remove(struct runq *, struct thread *);
108
109/*
110 * Implementation helpers for common and scheduler-specific runq_choose*()
111 * functions.
112 */
113typedef bool runq_pred_t(int _idx, struct rq_queue *, void *_data);
114int runq_findq(struct runq *const rq, const int lvl_min,
115 const int lvl_max,
116 runq_pred_t *const pred, void *const pred_data);
117struct thread *runq_first_thread_range(struct runq *const rq,
118 const int lvl_min, const int lvl_max);
119
120bool runq_not_empty(struct runq *);
121struct thread *runq_choose(struct runq *);
122struct thread *runq_choose_fuzz(struct runq *, int _fuzz);
74123
75124#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/rwlock.h+1-1
......@@ -128,7 +128,7 @@
128128 */
129129void _rw_init_flags(volatile uintptr_t *c, const char *name, int opts);
130130void _rw_destroy(volatile uintptr_t *c);
131void rw_sysinit(void *arg);
131void rw_sysinit(const void *arg);
132132int _rw_wowned(const volatile uintptr_t *c);
133133void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line);
134134int __rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF);
lib/libc/include/generic-freebsd/sys/sched.h+11-2
......@@ -63,6 +63,15 @@
6363#define _SCHED_H_
6464
6565#ifdef _KERNEL
66
67#include <sys/types.h>
68#ifdef SCHED_STATS
69#include <sys/pcpu.h>
70#endif
71
72struct proc;
73struct thread;
74
6675/*
6776 * General scheduling info.
6877 *
......@@ -74,7 +83,7 @@
7483 */
7584int sched_load(void);
7685int sched_rr_interval(void);
77int sched_runnable(void);
86bool sched_runnable(void);
7887
7988/*
8089 * Proc related scheduling hooks.
......@@ -214,7 +223,7 @@ SYSINIT(name, SI_SUB_LAST, SI_ORDER_MIDDLE, name ## _add_proc, NULL);
214223 SCHED_STAT_DEFINE_VAR(name, &DPCPU_NAME(name), descr)
215224/*
216225 * Sched stats are always incremented in critical sections so no atomic
217 * is necesssary to increment them.
226 * is necessary to increment them.
218227 */
219228#define SCHED_STAT_INC(var) DPCPU_GET(var)++;
220229#else
lib/libc/include/generic-freebsd/sys/sdt.h+94-75
......@@ -77,8 +77,8 @@
7777
7878#else /* _KERNEL */
7979
80#include <sys/cdefs.h>
8180#include <sys/linker_set.h>
81#include <machine/sdt_machdep.h>
8282
8383extern volatile bool sdt_probes_enabled;
8484
......@@ -102,8 +102,6 @@ extern volatile bool sdt_probes_enabled;
102102#define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
103103#define SDT_PROBE_DEFINE6(prov, mod, func, name, arg0, arg1, arg2, \
104104 arg3, arg4, arg5)
105#define SDT_PROBE_DEFINE7(prov, mod, func, name, arg0, arg1, arg2, \
106 arg3, arg4, arg5, arg6)
107105
108106#define SDT_PROBE0(prov, mod, func, name)
109107#define SDT_PROBE1(prov, mod, func, name, arg0)
......@@ -112,8 +110,9 @@ extern volatile bool sdt_probes_enabled;
112110#define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3)
113111#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
114112#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5)
115#define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \
116 arg6)
113
114#define MIB_SDT_PROBE1(...)
115#define MIB_SDT_PROBE2(...)
117116
118117#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name)
119118#define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0)
......@@ -127,9 +126,6 @@ extern volatile bool sdt_probes_enabled;
127126 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4)
128127#define SDT_PROBE_DEFINE6_XLATE(prov, mod, func, name, arg0, xarg0, \
129128 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5)
130#define SDT_PROBE_DEFINE7_XLATE(prov, mod, func, name, arg0, xarg0, \
131 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5, arg6, \
132 xarg6)
133129
134130#define DTRACE_PROBE(name)
135131#define DTRACE_PROBE1(name, type0, arg0)
......@@ -141,6 +137,18 @@ extern volatile bool sdt_probes_enabled;
141137
142138#else
143139
140void sdt_probe(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
141 uintptr_t);
142void sdt_probe6(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
143 uintptr_t, uintptr_t);
144
145#define _SDT_TRACEPOINT_SET sdt_tracepoint_set
146#define _SDT_TRACEPOINT_SECTION "set_sdt_tracepoint_set"
147
148bool sdt_tracepoint_valid(uintptr_t patchpoint, uintptr_t target);
149void sdt_tracepoint_patch(uintptr_t patchpoint, uintptr_t target);
150void sdt_tracepoint_restore(uintptr_t patchpoint);
151
144152#define __sdt_used
145153
146154SET_DECLARE(sdt_providers_set, struct sdt_provider);
......@@ -153,39 +161,81 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
153161 sdt_provider_##prov
154162
155163#define SDT_PROVIDER_DEFINE(_prov) \
156 struct sdt_provider _SDT_PROVIDER_NAME(_prov)[1] = { \
157 [0] = { .name = #_prov }, \
164 struct sdt_provider _SDT_PROVIDER_NAME(_prov) = { \
165 .name = #_prov, \
158166 }; \
159167 DATA_SET(sdt_providers_set, _SDT_PROVIDER_NAME(_prov))
160168
161169#define SDT_PROVIDER_DECLARE(prov) \
162 extern struct sdt_provider _SDT_PROVIDER_NAME(prov)[1]
170 extern struct sdt_provider _SDT_PROVIDER_NAME(prov)
163171
164172#define SDT_PROBE_DEFINE(_prov, _mod, _func, _name) \
165 struct sdt_probe _SDT_PROBE_NAME(_prov, _mod, _func, _name)[1] = { \
166 [0] = { \
167 .version = sizeof(struct sdt_probe), \
168 .prov = _SDT_PROVIDER_NAME(_prov), \
169 .mod = #_mod, \
170 .func = #_func, \
171 .name = #_name, \
172 }, \
173 struct sdt_probe _SDT_PROBE_NAME(_prov, _mod, _func, _name) = { \
174 .version = sizeof(struct sdt_probe), \
175 .prov = &_SDT_PROVIDER_NAME(_prov), \
176 .mod = #_mod, \
177 .func = #_func, \
178 .name = #_name, \
173179 }; \
174180 DATA_SET(sdt_probes_set, _SDT_PROBE_NAME(_prov, _mod, _func, _name))
175181
176182#define SDT_PROBE_DECLARE(prov, mod, func, name) \
177 extern struct sdt_probe _SDT_PROBE_NAME(prov, mod, func, name)[1]
183 extern struct sdt_probe _SDT_PROBE_NAME(prov, mod, func, name)
178184
179185#define SDT_PROBES_ENABLED() __predict_false(sdt_probes_enabled)
180186
181#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \
182 if (SDT_PROBES_ENABLED()) { \
183 if (__predict_false(_SDT_PROBE_NAME(prov, mod, func, name)->id)) \
184 (*sdt_probe_func)(_SDT_PROBE_NAME(prov, mod, func, name)->id, \
185 (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \
186 (uintptr_t) arg3, (uintptr_t) arg4); \
187 } \
187#ifdef _ILP32
188#define _SDT_ASM_WORD ".long"
189#else
190#define _SDT_ASM_WORD ".quad"
191#endif
192
193#ifndef _SDT_ASM_PROBE_CONSTRAINT
194#define _SDT_ASM_PROBE_CONSTRAINT "i"
195#endif
196#ifndef _SDT_ASM_PROBE_OPERAND
197#define _SDT_ASM_PROBE_OPERAND "c"
198#endif
199
200/*
201 * The asm below generates records corresponding to the structure's layout, so
202 * the two must be kept in sync.
203 */
204struct sdt_tracepoint {
205 struct sdt_probe *probe;
206 uintptr_t patchpoint;
207 uintptr_t target;
208 STAILQ_ENTRY(sdt_tracepoint) tracepoint_entry;
209};
210
211#define __SDT_PROBE(prov, mod, func, name, uniq, f, ...) do { \
212 __WEAK(__CONCAT(__start_set_, _SDT_TRACEPOINT_SET)); \
213 __WEAK(__CONCAT(__stop_set_, _SDT_TRACEPOINT_SET)); \
214 asm goto( \
215 "0:\n" \
216 _SDT_ASM_PATCH_INSTR "\n" \
217 ".pushsection " _SDT_TRACEPOINT_SECTION ", \"aw\"\n" \
218 _SDT_ASM_WORD " %" _SDT_ASM_PROBE_OPERAND "0\n" \
219 _SDT_ASM_WORD " 0b\n" \
220 _SDT_ASM_WORD " %l1\n" \
221 _SDT_ASM_WORD " 0\n" \
222 ".popsection\n" \
223 : \
224 : _SDT_ASM_PROBE_CONSTRAINT (&_SDT_PROBE_NAME(prov, mod, \
225 func, name)) \
226 : \
227 : __sdt_probe##uniq); \
228 if (0) { \
229__sdt_probe##uniq:; \
230 f(_SDT_PROBE_NAME(prov, mod, func, name).id, __VA_ARGS__); \
231 } \
188232} while (0)
233#define _SDT_PROBE(prov, mod, func, name, uniq, f, ...) \
234 __SDT_PROBE(prov, mod, func, name, uniq, f, __VA_ARGS__)
235#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
236 _SDT_PROBE(prov, mod, func, name, __COUNTER__, sdt_probe, \
237 (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
238 (uintptr_t)arg3, (uintptr_t)arg4)
189239
190240#define SDT_PROBE_ARGTYPE(_prov, _mod, _func, _name, _num, _type, _xtype) \
191241 static struct sdt_argtype \
......@@ -194,7 +244,7 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
194244 .ndx = _num, \
195245 .type = _type, \
196246 .xtype = _xtype, \
197 .probe = _SDT_PROBE_NAME(_prov, _mod, _func, _name), \
247 .probe = &_SDT_PROBE_NAME(_prov, _mod, _func, _name), \
198248 }, \
199249 }; \
200250 DATA_SET(sdt_argtypes_set, \
......@@ -243,17 +293,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
243293 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, NULL); \
244294 SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, NULL)
245295
246#define SDT_PROBE_DEFINE7(prov, mod, func, name, arg0, arg1, arg2, arg3,\
247 arg4, arg5, arg6) \
248 SDT_PROBE_DEFINE(prov, mod, func, name); \
249 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0, NULL); \
250 SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1, NULL); \
251 SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2, NULL); \
252 SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3, NULL); \
253 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, NULL); \
254 SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, NULL); \
255 SDT_PROBE_ARGTYPE(prov, mod, func, name, 6, arg6, NULL)
256
257296#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) \
258297 SDT_PROBE_DEFINE(prov, mod, func, name)
259298
......@@ -301,18 +340,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
301340 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, xarg4); \
302341 SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, xarg5)
303342
304#define SDT_PROBE_DEFINE7_XLATE(prov, mod, func, name, arg0, xarg0, \
305 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5, arg6, \
306 xarg6) \
307 SDT_PROBE_DEFINE(prov, mod, func, name); \
308 SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0, xarg0); \
309 SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1, xarg1); \
310 SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2, xarg2); \
311 SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3, xarg3); \
312 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, xarg4); \
313 SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, xarg5); \
314 SDT_PROBE_ARGTYPE(prov, mod, func, name, 6, arg6, xarg6)
315
316343#define SDT_PROBE0(prov, mod, func, name) \
317344 SDT_PROBE(prov, mod, func, name, 0, 0, 0, 0, 0)
318345#define SDT_PROBE1(prov, mod, func, name, arg0) \
......@@ -325,27 +352,18 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
325352 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, 0)
326353#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
327354 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
328#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \
329 do { \
330 if (_SDT_PROBE_NAME(prov, mod, func, name)->id) \
331 (*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \
332 uintptr_t, uintptr_t, uintptr_t))sdt_probe_func)( \
333 _SDT_PROBE_NAME(prov, mod, func, name)->id, \
334 (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
335 (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5);\
336 } while (0)
337#define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \
338 arg6) \
339 do { \
340 if (_SDT_PROBE_NAME(prov, mod, func, name)->id) \
341 (*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \
342 uintptr_t, uintptr_t, uintptr_t, uintptr_t)) \
343 sdt_probe_func)( \
344 _SDT_PROBE_NAME(prov, mod, func, name)->id, \
345 (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
346 (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5, \
347 (uintptr_t)arg6); \
348 } while (0)
355#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \
356 _SDT_PROBE(prov, mod, func, name, __COUNTER__, sdt_probe6, \
357 (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
358 (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5)
359
360#ifdef KDTRACE_MIB_SDT
361#define MIB_SDT_PROBE1(...) SDT_PROBE1(mib, __VA_ARGS__)
362#define MIB_SDT_PROBE2(...) SDT_PROBE2(mib, __VA_ARGS__)
363#else
364#define MIB_SDT_PROBE1(...)
365#define MIB_SDT_PROBE2(...)
366#endif
349367
350368#define DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \
351369 static SDT_PROBE_DEFINE(sdt, , , name); \
......@@ -399,12 +417,12 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
399417 * way to avoid having to rely on CDDL code.
400418 */
401419typedef void (*sdt_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1,
402 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
420 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5);
403421
404422/*
405423 * The 'sdt' provider will set it to dtrace_probe when it loads.
406424 */
407extern sdt_probe_func_t sdt_probe_func;
425extern sdt_probe_func_t sdt_probe_func;
408426
409427struct sdt_probe;
410428struct sdt_provider;
......@@ -425,6 +443,7 @@ struct sdt_probe {
425443 TAILQ_ENTRY(sdt_probe)
426444 probe_entry; /* SDT probe list entry. */
427445 TAILQ_HEAD(, sdt_argtype) argtype_list;
446 STAILQ_HEAD(, sdt_tracepoint) tracepoint_list;
428447 const char *mod;
429448 const char *func;
430449 const char *name;
......@@ -442,7 +461,7 @@ struct sdt_provider {
442461};
443462
444463void sdt_probe_stub(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
445 uintptr_t);
464 uintptr_t, uintptr_t);
446465
447466SDT_PROVIDER_DECLARE(sdt);
448467
lib/libc/include/generic-freebsd/sys/select.h+29-3
......@@ -49,6 +49,12 @@ typedef __fd_mask fd_mask;
4949typedef __sigset_t sigset_t;
5050#endif
5151
52#if !defined(_KERNEL) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
53#include <ssp/ssp.h>
54#else
55#define __SSP_FORTIFY_LEVEL 0
56#endif
57
5258/*
5359 * Select uses bit masks of file descriptors in longs. These macros
5460 * manipulate such bit fields (the filesystem macros use chars).
......@@ -75,13 +81,33 @@ typedef struct fd_set {
7581#define fds_bits __fds_bits
7682#endif
7783
84#define __fdset_idx_(p, n) ((n) / _NFDBITS)
85#if __SSP_FORTIFY_LEVEL == 0
86#define __fdset_idx(p, n) __fdset_idx_(p, n)
87#else
88__ssp_inline unsigned long
89__fdset_idx(const fd_set *p, unsigned long idx)
90{
91 __size_t psz = __ssp_bos0(p);
92 unsigned long sidx = __fdset_idx_(p, idx);
93
94 if (idx >= FD_SETSIZE)
95 __chk_fail();
96 if (psz / sizeof(__fd_mask) < (sidx + 1))
97 __chk_fail();
98
99 return (sidx);
100}
101#endif
102
78103#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
79#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
104#define FD_CLR(n, p) ((p)->__fds_bits[__fdset_idx(p, n)] &= ~__fdset_mask(n))
80105#if __BSD_VISIBLE
81106#define FD_COPY(f, t) (void)(*(t) = *(f))
82107#endif
83#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)
84#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
108#define FD_ISSET(n, p) \
109 (((p)->__fds_bits[__fdset_idx(p, n)] & __fdset_mask(n)) != 0)
110#define FD_SET(n, p) ((p)->__fds_bits[__fdset_idx(p, n)] |= __fdset_mask(n))
85111#define FD_ZERO(p) do { \
86112 fd_set *_p; \
87113 __size_t _n; \
lib/libc/include/generic-freebsd/sys/selinfo.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)select.h 8.2 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _SYS_SELINFO_H_
lib/libc/include/generic-freebsd/sys/sem.h-3
......@@ -148,9 +148,6 @@ int kern_get_sema(struct thread *td, struct semid_kernel **res,
148148#else /* !_KERNEL */
149149
150150__BEGIN_DECLS
151#if __BSD_VISIBLE
152int semsys(int, ...);
153#endif
154151int semctl(int, int, int, ...);
155152int semget(key_t, int, int);
156153int semop(int, struct sembuf *, size_t);
lib/libc/include/generic-freebsd/sys/seqc.h+2-2
......@@ -78,14 +78,14 @@ static __inline seqc_t
7878seqc_read_any(const seqc_t *seqcp)
7979{
8080
81 return (atomic_load_acq_int(__DECONST(seqc_t *, seqcp)));
81 return (atomic_load_acq_int(seqcp));
8282}
8383
8484static __inline seqc_t
8585seqc_read_notmodify(const seqc_t *seqcp)
8686{
8787
88 return (atomic_load_acq_int(__DECONST(seqc_t *, seqcp)) & ~SEQC_MOD);
88 return (atomic_load_acq_int(seqcp) & ~SEQC_MOD);
8989}
9090
9191static __inline seqc_t
lib/libc/include/generic-freebsd/sys/sglist.h+1
......@@ -55,6 +55,7 @@ struct sglist {
5555
5656struct bio;
5757struct mbuf;
58struct thread;
5859struct uio;
5960
6061static __inline void
lib/libc/include/generic-freebsd/sys/shm.h+1-4
......@@ -51,7 +51,7 @@
5151
5252#define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
5353#define SHM_RND 020000 /* Round attach address to SHMLBA */
54#define SHM_REMAP 030000 /* Unmap before mapping */
54#define SHM_REMAP 040000 /* Unmap before mapping */
5555#define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */
5656
5757/* "official" access mode definitions; somewhat braindead since you have
......@@ -173,9 +173,6 @@ typedef __size_t size_t;
173173#endif
174174
175175__BEGIN_DECLS
176#if __BSD_VISIBLE
177int shmsys(int, ...);
178#endif
179176void *shmat(int, const void *, int);
180177int shmget(key_t, size_t, int);
181178int shmctl(int, int, struct shmid_ds *);
lib/libc/include/generic-freebsd/sys/sigio.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_SIGIO_H_
lib/libc/include/generic-freebsd/sys/signal.h+3-27
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)signal.h 8.4 (Berkeley) 5/4/95
3735 */
3836
3937#ifndef _SYS_SIGNAL_H_
......@@ -42,6 +40,7 @@
4240#include <sys/cdefs.h>
4341#include <sys/_types.h>
4442#include <sys/_sigset.h>
43#include <sys/_sigaltstack.h>
4544#include <sys/_sigval.h>
4645
4746#include <machine/_limits.h> /* __MINSIGSTKSZ */
......@@ -255,7 +254,7 @@ typedef struct __siginfo {
255254#define si_syscall _reason._capsicum._syscall
256255
257256#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__))
258struct siginfo32 {
257struct __siginfo32 {
259258 int si_signo; /* signal number */
260259 int si_errno; /* errno association */
261260 int si_code; /* signal code */
......@@ -373,7 +372,7 @@ struct sigaction {
373372#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
374373#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */
375374
376#if __XSI_VISIBLE
375#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
377376#define SA_ONSTACK 0x0001 /* take signal on signal stack */
378377#define SA_RESTART 0x0002 /* restart system call on signal return */
379378#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
......@@ -408,29 +407,6 @@ typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
408407typedef void __siginfohandler_t(int, struct __siginfo *, void *);
409408#endif
410409
411#if __XSI_VISIBLE
412#if __BSD_VISIBLE
413#define __stack_t sigaltstack
414#endif
415typedef struct __stack_t stack_t;
416
417#define SS_ONSTACK 0x0001 /* take signal on alternate stack */
418#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
419#define MINSIGSTKSZ __MINSIGSTKSZ /* minimum stack size */
420#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
421#endif
422
423/*
424 * Structure used in sigaltstack call. Its definition is always
425 * needed for __ucontext. If __BSD_VISIBLE is defined, the structure
426 * tag is actually sigaltstack.
427 */
428struct __stack_t {
429 void *ss_sp; /* signal stack base */
430 __size_t ss_size; /* signal stack length */
431 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
432};
433
434410#if __BSD_VISIBLE
435411/*
436412 * 4.3 compatibility:
lib/libc/include/generic-freebsd/sys/signalvar.h+2-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)signalvar.h 8.6 (Berkeley) 2/19/95
3230 */
3331
3432#ifndef _SYS_SIGNALVAR_H_
......@@ -272,6 +270,7 @@ int __sys_sigfastblock(int cmd, void *ptr);
272270
273271#ifdef _KERNEL
274272extern bool sigfastblock_fetch_always;
273extern bool pt_attach_transparent;
275274
276275/* Return nonzero if process p has an unmasked pending signal. */
277276#define SIGPENDING(td) \
......@@ -404,6 +403,7 @@ int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **);
404403void sigfastblock_clear(struct thread *td);
405404void sigfastblock_fetch(struct thread *td);
406405int sig_intr(void);
406bool sig_do_core(int);
407407void siginit(struct proc *p);
408408void signotify(struct thread *td);
409409void sigqueue_delete(struct sigqueue *queue, int sig);
lib/libc/include/generic-freebsd/sys/sleepqueue.h+4-4
......@@ -86,21 +86,21 @@ struct thread;
8686#define SLEEPQ_DROP 0x400 /* Return without lock held. */
8787
8888void init_sleepqueues(void);
89int sleepq_abort(struct thread *td, int intrval);
89void sleepq_abort(struct thread *td, int intrval);
9090void sleepq_add(const void *wchan, struct lock_object *lock,
9191 const char *wmesg, int flags, int queue);
9292struct sleepqueue *sleepq_alloc(void);
93int sleepq_broadcast(const void *wchan, int flags, int pri, int queue);
93void sleepq_broadcast(const void *wchan, int flags, int pri, int queue);
9494void sleepq_chains_remove_matching(bool (*matches)(struct thread *));
9595void sleepq_free(struct sleepqueue *sq);
9696void sleepq_lock(const void *wchan);
9797struct sleepqueue *sleepq_lookup(const void *wchan);
9898void sleepq_release(const void *wchan);
9999void sleepq_remove(struct thread *td, const void *wchan);
100int sleepq_remove_matching(struct sleepqueue *sq, int queue,
100void sleepq_remove_matching(struct sleepqueue *sq, int queue,
101101 bool (*matches)(struct thread *), int pri);
102102void sleepq_remove_nested(struct thread *td);
103int sleepq_signal(const void *wchan, int flags, int pri, int queue);
103void sleepq_signal(const void *wchan, int flags, int pri, int queue);
104104void sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt,
105105 sbintime_t pr, int flags);
106106#define sleepq_set_timeout(wchan, timo) \
lib/libc/include/generic-freebsd/sys/smr_types.h+4-2
......@@ -60,7 +60,8 @@ struct { \
6060 */
6161#define smr_entered_load(p, smr) ({ \
6262 SMR_ASSERT(SMR_ENTERED((smr)), "smr_entered_load"); \
63 (__typeof((p)->__ptr))atomic_load_acq_ptr((uintptr_t *)&(p)->__ptr); \
63 (__typeof((p)->__ptr))atomic_load_acq_ptr( \
64 (const uintptr_t *)&(p)->__ptr); \
6465})
6566
6667/*
......@@ -70,7 +71,8 @@ struct { \
7071 */
7172#define smr_serialized_load(p, ex) ({ \
7273 SMR_ASSERT(ex, "smr_serialized_load"); \
73 (__typeof((p)->__ptr))atomic_load_ptr(&(p)->__ptr); \
74 (__typeof((p)->__ptr))atomic_load_ptr( \
75 (const uintptr_t *)&(p)->__ptr); \
7476})
7577
7678/*
lib/libc/include/generic-freebsd/sys/sndstat.h+2
......@@ -94,12 +94,14 @@ struct sndstioc_nv_arg {
9494#define SNDST_DSPS_SOUND4_CHAN_LEFTVOL "left_volume"
9595#define SNDST_DSPS_SOUND4_CHAN_RIGHTVOL "right_volume"
9696#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT "hwbuf_format"
97#define SNDST_DSPS_SOUND4_CHAN_HWBUF_RATE "hwbuf_rate"
9798#define SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE "hwbuf_size"
9899#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ "hwbuf_blksz"
99100#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT "hwbuf_blkcnt"
100101#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE "hwbuf_free"
101102#define SNDST_DSPS_SOUND4_CHAN_HWBUF_READY "hwbuf_ready"
102103#define SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT "swbuf_format"
104#define SNDST_DSPS_SOUND4_CHAN_SWBUF_RATE "swbuf_rate"
103105#define SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE "swbuf_size"
104106#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ "swbuf_blksz"
105107#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT "swbuf_blkcnt"
lib/libc/include/generic-freebsd/sys/sockbuf.h+21-10
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
3230 */
3331#ifndef _SYS_SOCKBUF_H_
3432#define _SYS_SOCKBUF_H_
......@@ -42,13 +40,13 @@
4240#define SB_SEL 0x08 /* someone is selecting */
4341#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
4442#define SB_UPCALL 0x20 /* someone wants an upcall */
45#define SB_NOINTR 0x40 /* operations not interruptible */
43#define SB_AUTOLOWAT 0x40 /* sendfile(2) may autotune sb_lowat */
4644#define SB_AIO 0x80 /* AIO operations queued */
4745#define SB_KNOTE 0x100 /* kernel note attached */
4846#define SB_NOCOALESCE 0x200 /* don't coalesce new data into existing mbufs */
4947#define SB_IN_TOE 0x400 /* socket buffer is in the middle of an operation */
5048#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */
51#define SB_STOP 0x1000 /* backpressure indicator */
49/* was SB_STOP 0x1000 */
5250#define SB_AIO_RUNNING 0x2000 /* AIO operation running */
5351#define SB_SPLICED 0x4000 /* socket buffer is spliced;
5452 previously used for SB_TLS_IFNET */
......@@ -64,7 +62,7 @@
6462#include <sys/_sx.h>
6563#include <sys/_task.h>
6664
67#define SB_MAX (2*1024*1024) /* default for max chars in sockbuf */
65#define SB_MAX (8*1024*1024) /* default for max chars in sockbuf */
6866
6967struct ktls_session;
7068struct mbuf;
......@@ -134,6 +132,18 @@ struct sockbuf {
134132 /* TLS state, locked by sockbuf and sock I/O mutexes. */
135133 struct ktls_session *sb_tls_info;
136134 };
135 /*
136 * PF_UNIX/SOCK_STREAM and PF_UNIX/SOCK_SEQPACKET
137 * A simple stream buffer with not ready data pointer.
138 */
139 struct {
140 STAILQ_HEAD(, mbuf) uxst_mbq;
141 struct mbuf *uxst_fnrdy;
142 struct socket *uxst_peer;
143 u_int uxst_flags;
144#define UXST_PEER_AIO 0x1
145#define UXST_PEER_SEL 0x2
146 };
137147 /*
138148 * PF_UNIX/SOCK_DGRAM
139149 *
......@@ -167,6 +177,12 @@ struct sockbuf {
167177 u_int uxdg_ctl;
168178 u_int uxdg_mbcnt;
169179 };
180 /*
181 * Netlink socket.
182 */
183 struct {
184 TAILQ_HEAD(, nl_buf) nl_queue;
185 };
170186 };
171187};
172188
......@@ -194,8 +210,6 @@ typedef enum { SO_RCV, SO_SND } sb_which;
194210 * Socket buffer private mbuf(9) flags.
195211 */
196212#define M_NOTREADY M_PROTO1 /* m_data not populated yet */
197#define M_BLOCKED M_PROTO2 /* M_NOTREADY in front of m */
198#define M_NOTAVAIL (M_NOTREADY | M_BLOCKED)
199213
200214void sbappend(struct sockbuf *sb, struct mbuf *m, int flags);
201215void sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags);
......@@ -287,9 +301,6 @@ sbspace(struct sockbuf *sb)
287301 SOCKBUF_LOCK_ASSERT(sb);
288302#endif
289303
290 if (sb->sb_flags & SB_STOP)
291 return(0);
292
293304 bleft = sb->sb_hiwat - sb->sb_ccc;
294305 mleft = sb->sb_mbmax - sb->sb_mbcnt;
295306
lib/libc/include/generic-freebsd/sys/socket.h+23-40
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)socket.h 8.4 (Berkeley) 2/21/94
3230 */
3331
3432#ifndef _SYS_SOCKET_H_
......@@ -113,10 +111,11 @@ typedef __uintptr_t uintptr_t;
113111 */
114112#define SOCK_CLOEXEC 0x10000000
115113#define SOCK_NONBLOCK 0x20000000
114#define SOCK_CLOFORK 0x40000000
116115#ifdef _KERNEL
117116/*
118117 * Flags for accept1(), kern_accept4() and solisten_dequeue, in addition
119 * to SOCK_CLOEXEC and SOCK_NONBLOCK.
118 * to SOCK_CLOEXEC, SOCK_CLOFORK and SOCK_NONBLOCK.
120119 */
121120#define ACCEPT4_INHERIT 0x1
122121#define ACCEPT4_COMPAT 0x2
......@@ -166,17 +165,18 @@ typedef __uintptr_t uintptr_t;
166165#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */
167166#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */
168167#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */
169#define SO_SETFIB 0x1014 /* use this FIB to route */
168#define SO_FIB 0x1014 /* get or set socket FIB */
169#define SO_SETFIB SO_FIB /* backward compat alias */
170170#define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */
171171#define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */
172172#define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */
173173#define SO_TS_CLOCK 0x1017 /* clock type used for SO_TIMESTAMP */
174174#define SO_MAX_PACING_RATE 0x1018 /* socket's max TX pacing rate (Linux name) */
175175#define SO_DOMAIN 0x1019 /* get socket domain */
176#define SO_SPLICE 0x1023 /* splice data to other socket */
176177#endif
177178
178179#if __BSD_VISIBLE
179#define SO_SPLICE 0x1023 /* splice data to other socket */
180180#define SO_TS_REALTIME_MICRO 0 /* microsecond resolution, realtime */
181181#define SO_TS_BINTIME 1 /* sub-nanosecond resolution, realtime */
182182#define SO_TS_REALTIME 2 /* nanosecond resolution, realtime */
......@@ -270,7 +270,8 @@ struct accept_filter_arg {
270270#define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */
271271#define AF_HYPERV 43 /* HyperV sockets */
272272#define AF_DIVERT 44 /* divert(4) */
273#define AF_MAX 44
273#define AF_IPFWLOG 46
274#define AF_MAX 46
274275/*
275276 * When allocating a new AF_ constant, please only allocate
276277 * even numbered constants for FreeBSD until 134 as odd numbered AF_
......@@ -396,6 +397,7 @@ struct sockproto {
396397#define PF_INET_SDP AF_INET_SDP
397398#define PF_INET6_SDP AF_INET6_SDP
398399#define PF_DIVERT AF_DIVERT
400#define PF_IPFWLOG AF_IPFWLOG
399401
400402#define PF_MAX AF_MAX
401403
......@@ -477,6 +479,9 @@ struct msghdr {
477479#define MSG_MORETOCOME 0x00100000 /* additional data pending */
478480#define MSG_TLSAPPDATA 0x00200000 /* do not soreceive() alert rec. (TLS) */
479481#endif
482#if __BSD_VISIBLE
483#define MSG_CMSG_CLOFORK 0x00400000 /* make received fds close-on-fork */
484#endif
480485
481486/*
482487 * Header for ancillary data objects in msg_control buffer.
......@@ -631,17 +636,14 @@ struct omsghdr {
631636/*
632637 * howto arguments for shutdown(2), specified by Posix.1g.
633638 */
634#define SHUT_RD 0 /* shut down the reading side */
635#define SHUT_WR 1 /* shut down the writing side */
636#define SHUT_RDWR 2 /* shut down both sides */
637
638#if __BSD_VISIBLE
639/* for SCTP */
640/* we cheat and use the SHUT_XX defines for these */
641#define PRU_FLUSH_RD SHUT_RD
642#define PRU_FLUSH_WR SHUT_WR
643#define PRU_FLUSH_RDWR SHUT_RDWR
644#endif
639enum shutdown_how {
640 SHUT_RD = 0, /* shut down the reading side */
641#define SHUT_RD SHUT_RD
642 SHUT_WR, /* shut down the writing side */
643#define SHUT_WR SHUT_WR
644 SHUT_RDWR /* shut down both sides */
645#define SHUT_RDWR SHUT_RDWR
646};
645647
646648#if __BSD_VISIBLE
647649/*
......@@ -689,6 +691,10 @@ struct splice {
689691
690692#ifndef _KERNEL
691693
694#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
695#include <ssp/socket.h>
696#endif
697
692698#include <sys/cdefs.h>
693699
694700__BEGIN_DECLS
......@@ -733,33 +739,10 @@ __END_DECLS
733739#ifdef _KERNEL
734740struct socket;
735741
736struct inpcb *so_sotoinpcb(struct socket *so);
737struct sockbuf *so_sockbuf_snd(struct socket *);
738struct sockbuf *so_sockbuf_rcv(struct socket *);
739
740int so_state_get(const struct socket *);
741void so_state_set(struct socket *, int);
742
743742int so_options_get(const struct socket *);
744743void so_options_set(struct socket *, int);
745744
746745int so_error_get(const struct socket *);
747746void so_error_set(struct socket *, int);
748
749int so_linger_get(const struct socket *);
750void so_linger_set(struct socket *, int);
751
752struct protosw *so_protosw_get(const struct socket *);
753void so_protosw_set(struct socket *, struct protosw *);
754
755void so_sorwakeup_locked(struct socket *so);
756void so_sowwakeup_locked(struct socket *so);
757
758void so_sorwakeup(struct socket *so);
759void so_sowwakeup(struct socket *so);
760
761void so_lock(struct socket *so);
762void so_unlock(struct socket *so);
763
764747#endif /* _KERNEL */
765748#endif /* !_SYS_SOCKET_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/socketvar.h+22-17
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
3230 */
3331
3432#ifndef _SYS_SOCKETVAR_H_
......@@ -82,6 +80,7 @@ struct so_splice {
8280 struct mtx mtx;
8381 unsigned int wq_index;
8482 enum so_splice_state {
83 SPLICE_INIT, /* embryonic state, don't queue work yet */
8584 SPLICE_IDLE, /* waiting for work to arrive */
8685 SPLICE_QUEUED, /* a wakeup has queued some work */
8786 SPLICE_RUNNING, /* currently transferring data */
......@@ -239,7 +238,7 @@ struct socket {
239238#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
240239#define SS_NBIO 0x0100 /* non-blocking ops */
241240#define SS_ASYNC 0x0200 /* async i/o notify */
242#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
241/* was SS_ISCONFIRMING 0x0400 */
243242#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
244243
245244#ifdef _KERNEL
......@@ -343,16 +342,14 @@ soeventmtx(struct socket *so, const sb_which which)
343342 soiolock((so), &(so)->so_snd_sx, (flags))
344343#define SOCK_IO_SEND_UNLOCK(so) \
345344 soiounlock(&(so)->so_snd_sx)
346#define SOCK_IO_SEND_OWNED(so) sx_xlocked(&(so)->so_snd_sx)
347345#define SOCK_IO_SEND_ASSERT_LOCKED(so) \
348 sx_assert(&(so)->so_snd_sx, SA_XLOCKED)
346 sx_assert(&(so)->so_snd_sx, SA_LOCKED)
349347#define SOCK_IO_RECV_LOCK(so, flags) \
350348 soiolock((so), &(so)->so_rcv_sx, (flags))
351349#define SOCK_IO_RECV_UNLOCK(so) \
352350 soiounlock(&(so)->so_rcv_sx)
353#define SOCK_IO_RECV_OWNED(so) sx_xlocked(&(so)->so_rcv_sx)
354351#define SOCK_IO_RECV_ASSERT_LOCKED(so) \
355 sx_assert(&(so)->so_rcv_sx, SA_XLOCKED)
352 sx_assert(&(so)->so_rcv_sx, SA_LOCKED)
356353
357354/* do we have to send all at once on a socket? */
358355#define sosendallatonce(so) \
......@@ -459,7 +456,8 @@ MALLOC_DECLARE(M_SONAME);
459456#define HHOOK_FILT_SOREAD 4
460457#define HHOOK_FILT_SOWRITE 5
461458#define HHOOK_SOCKET_CLOSE 6
462#define HHOOK_SOCKET_LAST HHOOK_SOCKET_CLOSE
459#define HHOOK_SOCKET_NEWCONN 7
460#define HHOOK_SOCKET_LAST HHOOK_SOCKET_NEWCONN
463461
464462struct socket_hhook_data {
465463 struct socket *so;
......@@ -479,6 +477,7 @@ struct mbuf;
479477struct sockaddr;
480478struct ucred;
481479struct uio;
480enum shutdown_how;
482481
483482/* Return values for socket upcalls. */
484483#define SU_OK 0
......@@ -489,12 +488,14 @@ struct uio;
489488 */
490489int getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr,
491490 size_t len);
492int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
491int getsock_cap(struct thread *td, int fd, const cap_rights_t *rightsp,
493492 struct file **fpp, struct filecaps *havecaps);
494int getsock(struct thread *td, int fd, cap_rights_t *rightsp,
493int getsock(struct thread *td, int fd, const cap_rights_t *rightsp,
495494 struct file **fpp);
496495void soabort(struct socket *so);
497int soaccept(struct socket *so, struct sockaddr **nam);
496int soaccept(struct socket *so, struct sockaddr *sa);
497int sopeeraddr(struct socket *so, struct sockaddr *sa);
498int sosockaddr(struct socket *so, struct sockaddr *sa);
498499void soaio_enqueue(struct task *task);
499500void soaio_rcv(void *context, int pending);
500501void soaio_snd(void *context, int pending);
......@@ -525,10 +526,9 @@ struct socket *
525526 sonewconn(struct socket *head, int connstatus);
526527struct socket *
527528 sopeeloff(struct socket *);
528int sopoll(struct socket *so, int events, struct ucred *active_cred,
529 struct thread *td);
530int sopoll_generic(struct socket *so, int events,
531 struct ucred *active_cred, struct thread *td);
529int sopoll_generic(struct socket *so, int events, struct thread *td);
530int sokqfilter_generic(struct socket *so, struct knote *kn);
531int soaio_queue_generic(struct socket *so, struct kaiocb *job);
532532int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
533533 struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
534534int soreceive_stream(struct socket *so, struct sockaddr **paddr,
......@@ -555,7 +555,9 @@ int sosend_dgram(struct socket *so, struct sockaddr *addr,
555555int sosend_generic(struct socket *so, struct sockaddr *addr,
556556 struct uio *uio, struct mbuf *top, struct mbuf *control,
557557 int flags, struct thread *td);
558int soshutdown(struct socket *so, int how);
558int sendfile_wait_generic(struct socket *so, off_t need, int *space);
559int sosetfib(struct socket *so, int fibnum);
560int soshutdown(struct socket *so, enum shutdown_how);
559561void soupcall_clear(struct socket *, sb_which);
560562void soupcall_set(struct socket *, sb_which, so_upcall_t, void *);
561563void solisten_upcall_set(struct socket *, so_upcall_t, void *);
......@@ -596,6 +598,8 @@ SYSCTL_DECL(_net_inet_accf);
596598int accept_filt_generic_mod_event(module_t mod, int event, void *data);
597599#endif
598600
601int pr_listen_notsupp(struct socket *so, int backlog, struct thread *td);
602
599603#endif /* _KERNEL */
600604
601605/*
......@@ -615,7 +619,8 @@ struct xsocket {
615619 uint32_t so_qlimit;
616620 pid_t so_pgid;
617621 uid_t so_uid;
618 int32_t so_spare32[8];
622 int32_t so_fibnum;
623 int32_t so_spare32[7];
619624 int16_t so_type;
620625 int16_t so_options;
621626 int16_t so_linger;
lib/libc/include/generic-freebsd/sys/sockio.h+4-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)sockio.h 8.1 (Berkeley) 3/28/94
3230 */
3331
3432#ifndef _SYS_SOCKIO_H_
......@@ -149,4 +147,8 @@
149147#define SIOCSIFCAPNV _IOW('i', 155, struct ifreq) /* set IF features */
150148#define SIOCGIFCAPNV _IOWR('i', 156, struct ifreq) /* get IF features */
151149
150#define SIOCGUMBINFO _IOWR('i', 157, struct ifreq) /* get MBIM info */
151#define SIOCSUMBPARAM _IOW('i', 158, struct ifreq) /* set MBIM param */
152#define SIOCGUMBPARAM _IOWR('i', 159, struct ifreq) /* get MBIM param */
153
152154#endif /* !_SYS_SOCKIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/sockopt.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
3230 */
3331#ifndef _SYS_SOCKOPT_H_
3432#define _SYS_SOCKOPT_H_
lib/libc/include/generic-freebsd/sys/soundcard.h+11-2
......@@ -184,6 +184,8 @@ struct snd_size {
184184#define AFMT_S24_BE 0x00020000 /* Big endian signed 24-bit */
185185#define AFMT_U24_LE 0x00040000 /* Little endian unsigned 24-bit */
186186#define AFMT_U24_BE 0x00080000 /* Big endian unsigned 24-bit */
187#define AFMT_F32_LE 0x10000000 /* Little endian 32-bit floating point */
188#define AFMT_F32_BE 0x20000000 /* Big endian 32-bit floating point */
187189
188190/* Machine dependent AFMT_* definitions. */
189191#if BYTE_ORDER == LITTLE_ENDIAN
......@@ -199,6 +201,8 @@ struct snd_size {
199201#define AFMT_U16_OE AFMT_U16_BE
200202#define AFMT_U24_OE AFMT_U24_BE
201203#define AFMT_U32_OE AFMT_U32_BE
204#define AFMT_F32_NE AFMT_F32_LE
205#define AFMT_F32_OE AFMT_F32_BE
202206#else
203207#define AFMT_S16_OE AFMT_S16_LE
204208#define AFMT_S24_OE AFMT_S24_LE
......@@ -212,8 +216,12 @@ struct snd_size {
212216#define AFMT_U16_NE AFMT_U16_BE
213217#define AFMT_U24_NE AFMT_U24_BE
214218#define AFMT_U32_NE AFMT_U32_BE
219#define AFMT_F32_NE AFMT_F32_BE
220#define AFMT_F32_OE AFMT_F32_LE
215221#endif
216222
223#define AFMT_FLOAT AFMT_F32_NE /* compatibility alias */
224
217225#define AFMT_STEREO 0x10000000 /* can do/want stereo */
218226
219227/*
......@@ -1400,8 +1408,9 @@ void seqbuf_dump(void); /* This function must be provided by programs */
14001408 int i, l=(len); if (l>6)l=6;\
14011409 _SEQ_NEEDBUF(8);\
14021410 _seqbuf[_seqbufptr] = EV_SYSEX;\
1403 for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\
1404 for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\
1411 _seqbuf[_seqbufptr+1] = (dev);\
1412 for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+2] = (buf)[i];\
1413 for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+2] = 0xff;\
14051414 _SEQ_ADVBUF(8);}
14061415
14071416#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
lib/libc/include/generic-freebsd/sys/specialfd.h+5
......@@ -30,6 +30,7 @@
3030
3131enum specialfd_type {
3232 SPECIALFD_EVENTFD = 1,
33 SPECIALFD_INOTIFY = 2,
3334};
3435
3536struct specialfd_eventfd {
......@@ -37,4 +38,8 @@ struct specialfd_eventfd {
3738 int flags;
3839};
3940
41struct specialfd_inotify {
42 int flags;
43};
44
4045#endif /* !_SYS_SPECIALFD_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/stat.h+6-4
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)stat.h 8.12 (Berkeley) 6/16/95
3735 */
3836
3937#ifndef _SYS_STAT_H_
......@@ -161,7 +159,7 @@ struct stat {
161159 ino_t st_ino; /* inode's number */
162160 nlink_t st_nlink; /* number of hard links */
163161 mode_t st_mode; /* inode protection mode */
164 __int16_t st_padding0;
162 __int16_t st_bsdflags; /* misc system flags */
165163 uid_t st_uid; /* user ID of the file's owner */
166164 gid_t st_gid; /* group ID of the file's group */
167165 __int32_t st_padding1;
......@@ -187,7 +185,8 @@ struct stat {
187185 blksize_t st_blksize; /* optimal blocksize for I/O */
188186 fflags_t st_flags; /* user defined flags for file */
189187 __uint64_t st_gen; /* file generation number */
190 __uint64_t st_spare[10];
188 __uint64_t st_filerev; /* file revision, incr on changes */
189 __uint64_t st_spare[9];
191190};
192191
193192#ifdef _KERNEL
......@@ -341,6 +340,9 @@ struct nstat {
341340#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
342341#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
343342
343/* st_bsdflags */
344#define SFBSD_NAMEDATTR 0x0001 /* file is named attribute or dir */
345
344346#ifdef _KERNEL
345347/*
346348 * Shorthand abbreviations of above.
lib/libc/include/generic-freebsd/sys/stdarg.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __SYS_STDARG_H__
2#define __SYS_STDARG_H__
3
4#include <sys/_stdarg.h>
5
6#endif /* __SYS_STDARG_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/stdatomic.h+2-1
......@@ -33,7 +33,8 @@
3333#include <sys/cdefs.h>
3434#include <sys/_types.h>
3535
36#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
36#if (__has_extension(c_atomic) || __has_extension(cxx_atomic)) && \
37 defined(__clang__)
3738#define __CLANG_ATOMICS
3839#elif __GNUC_PREREQ__(4, 7)
3940#define __GNUC_ATOMICS
lib/libc/include/generic-freebsd/sys/sx.h+7-7
......@@ -99,7 +99,7 @@
9999 * Function prototipes. Routines that start with an underscore are not part
100100 * of the public interface and are wrappered with a macro.
101101 */
102void sx_sysinit(void *arg);
102void sx_sysinit(const void *arg);
103103#define sx_init(sx, desc) sx_init_flags((sx), (desc), 0)
104104void sx_init_flags(struct sx *sx, const char *description, int opts);
105105void sx_destroy(struct sx *sx);
......@@ -301,12 +301,12 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line)
301301
302302#ifdef _STANDALONE
303303/* since we have no threads in the boot loader, trivially implement no-op version */
304#define sx_xlock(s) (1)
305#define sx_try_xlock(s) (1)
306#define sx_xunlock(s) (1)
307#define SX_DUPOK 0
308#define SX_NEW 0
309#define SX_NOWITNESS 0
304#define sx_xlock(s) do {} while (0)
305#define sx_try_xlock(s) (1)
306#define sx_xunlock(s) do {} while (0)
307#define SX_DUPOK 0
308#define SX_NEW 0
309#define SX_NOWITNESS 0
310310
311311static __inline void
312312sx_init_flags(struct sx *sx, const char *description, int opts)
lib/libc/include/generic-freebsd/sys/syscall.h+18-7
......@@ -4,8 +4,10 @@
44 * DO NOT EDIT-- this file is automatically @generated.
55 */
66
7#define SYS_exit SYS__exit
8
79#define SYS_syscall 0
8#define SYS_exit 1
10#define SYS__exit 1
911#define SYS_fork 2
1012#define SYS_read 3
1113#define SYS_write 4
......@@ -73,8 +75,8 @@
7375#define SYS_vfork 66
7476 /* 67 is obsolete vread */
7577 /* 68 is obsolete vwrite */
76#define SYS_sbrk 69
77#define SYS_sstk 70
78 /* 69 is obsolete sbrk */
79 /* 70 is obsolete sstk */
7880 /* 71 is old mmap */
7981#define SYS_freebsd11_vadvise 72
8082#define SYS_munmap 73
......@@ -83,8 +85,8 @@
8385 /* 76 is obsolete vhangup */
8486 /* 77 is obsolete vlimit */
8587#define SYS_mincore 78
86#define SYS_getgroups 79
87#define SYS_setgroups 80
88#define SYS_freebsd14_getgroups 79
89#define SYS_freebsd14_setgroups 80
8890#define SYS_getpgrp 81
8991#define SYS_setpgid 82
9092#define SYS_setitimer 83
......@@ -442,7 +444,7 @@
442444#define SYS_symlinkat 502
443445#define SYS_unlinkat 503
444446#define SYS_posix_openpt 504
445#define SYS_gssd_syscall 505
447 /* 505 is obsolete kgssapi */
446448#define SYS_jail_get 506
447449#define SYS_jail_set 507
448450#define SYS_jail_remove 508
......@@ -526,4 +528,13 @@
526528#define SYS_timerfd_settime 587
527529#define SYS_kcmp 588
528530#define SYS_getrlimitusage 589
529#define SYS_MAXSYSCALL 590
\ No newline at end of file
531#define SYS_fchroot 590
532#define SYS_setcred 591
533#define SYS_exterrctl 592
534#define SYS_inotify_add_watch_at 593
535#define SYS_inotify_rm_watch 594
536#define SYS_getgroups 595
537#define SYS_setgroups 596
538#define SYS_jail_attach_jd 597
539#define SYS_jail_remove_jd 598
540#define SYS_MAXSYSCALL 599
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/syscallsubr.h+28-15
......@@ -28,13 +28,14 @@
2828#ifndef _SYS_SYSCALLSUBR_H_
2929#define _SYS_SYSCALLSUBR_H_
3030
31#include <sys/signal.h>
32#include <sys/socket.h>
33#include <sys/mac.h>
34#include <sys/mount.h>
31#include <sys/types.h>
3532#include <sys/_cpuset.h>
3633#include <sys/_domainset.h>
3734#include <sys/_uio.h>
35#include <sys/mac.h>
36#include <sys/mount.h>
37#include <sys/signal.h>
38#include <sys/socket.h>
3839
3940struct __wrusage;
4041struct cpuset_copy_cb;
......@@ -49,6 +50,7 @@ struct kevent_copyops;
4950struct kld_file_stat;
5051struct ksiginfo;
5152struct mbuf;
53struct mq_attr;
5254struct msghdr;
5355struct msqid_ds;
5456struct pollfd;
......@@ -58,6 +60,7 @@ struct rusage;
5860struct sched_param;
5961struct sembuf;
6062union semun;
63struct shmfd;
6164struct sockaddr;
6265struct spacectl_range;
6366struct stat;
......@@ -84,10 +87,10 @@ int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,
8487 size_t buflen, size_t path_max);
8588int kern_abort2(struct thread *td, const char *why, int nargs,
8689 void **uargs);
87int kern_accept(struct thread *td, int s, struct sockaddr **name,
88 socklen_t *namelen, struct file **fp);
89int kern_accept4(struct thread *td, int s, struct sockaddr **name,
90 socklen_t *namelen, int flags, struct file **fp);
90int kern_accept(struct thread *td, int s, struct sockaddr *sa,
91 struct file **fp);
92int kern_accept4(struct thread *td, int s, struct sockaddr *sa,
93 int flags, struct file **fp);
9194int kern_accessat(struct thread *td, int fd, const char *path,
9295 enum uio_seg pathseg, int flags, int mode);
9396int kern_adjtime(struct thread *td, struct timeval *delta,
......@@ -164,7 +167,7 @@ int kern_fchmodat(struct thread *td, int fd, const char *path,
164167int kern_fchownat(struct thread *td, int fd, const char *path,
165168 enum uio_seg pathseg, int uid, int gid, int flag);
166169int kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg);
167int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg);
170int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, intptr_t arg);
168171int kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags);
169172int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);
170173int kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf);
......@@ -187,13 +190,11 @@ int kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
187190 size_t *countp, enum uio_seg bufseg, int mode);
188191int kern_getitimer(struct thread *, u_int, struct itimerval *);
189192int kern_getppid(struct thread *);
190int kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
191 socklen_t *alen);
193int kern_getpeername(struct thread *td, int fd, struct sockaddr *sa);
192194int kern_getpriority(struct thread *td, int which, int who);
193195int kern_getrusage(struct thread *td, int who, struct rusage *rup);
194196int kern_getsid(struct thread *td, pid_t pid);
195int kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
196 socklen_t *alen);
197int kern_getsockname(struct thread *td, int fd, struct sockaddr *sa);
197198int kern_getsockopt(struct thread *td, int s, int level, int name,
198199 void *optval, enum uio_seg valseg, socklen_t *valsize);
199200int kern_ioctl(struct thread *td, int fd, u_long com, caddr_t data);
......@@ -214,6 +215,15 @@ int kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps);
214215int kern_kldload(struct thread *td, const char *file, int *fileid);
215216int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat);
216217int kern_kldunload(struct thread *td, int fileid, int flags);
218int kern_kmq_notify(struct thread *, int, struct sigevent *);
219int kern_kmq_open(struct thread *, const char *, int, mode_t,
220 const struct mq_attr *);
221int kern_kmq_setattr(struct thread *, int, const struct mq_attr *,
222 struct mq_attr *);
223int kern_kmq_timedreceive(struct thread *, int, char *,
224 size_t, unsigned int *, const struct timespec *);
225int kern_kmq_timedsend(struct thread *td, int, const char *,
226 size_t, unsigned int, const struct timespec *);
217227int kern_linkat(struct thread *td, int fd1, int fd2, const char *path1,
218228 const char *path2, enum uio_seg segflg, int flag);
219229int kern_listen(struct thread *td, int s, int backlog);
......@@ -248,6 +258,7 @@ int kern_munlock(struct thread *td, uintptr_t addr, size_t size);
248258int kern_munmap(struct thread *td, uintptr_t addr, size_t size);
249259int kern_nanosleep(struct thread *td, struct timespec *rqt,
250260 struct timespec *rmt);
261int kern_nosys(struct thread *td, int dummy);
251262int kern_ntp_adjtime(struct thread *td, struct timex *ntv, int *retvalp);
252263int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
253264 long *ploff);
......@@ -312,7 +323,9 @@ int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
312323 fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits);
313324int kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
314325 struct mbuf *control, enum uio_seg segflg);
315int kern_setgroups(struct thread *td, u_int ngrp, gid_t *groups);
326int kern_setcred(struct thread *const td, const u_int flags,
327 struct setcred *const wcred, gid_t *preallocated_groups);
328int kern_setgroups(struct thread *td, int *ngrpp, gid_t *groups);
316329int kern_setitimer(struct thread *, u_int, struct itimerval *,
317330 struct itimerval *);
318331int kern_setpriority(struct thread *td, int which, int who, int prio);
......@@ -325,7 +338,7 @@ int kern_shm_open(struct thread *td, const char *userpath, int flags,
325338 mode_t mode, struct filecaps *fcaps);
326339int kern_shm_open2(struct thread *td, const char *path, int flags,
327340 mode_t mode, int shmflags, struct filecaps *fcaps,
328 const char *name);
341 const char *name, struct shmfd *shmfd);
329342int kern_shmat(struct thread *td, int shmid, const void *shmaddr,
330343 int shmflg);
331344int kern_shmctl(struct thread *td, int shmid, int cmd, void *buf,
lib/libc/include/generic-freebsd/sys/sysctl.h+26-6
......@@ -30,14 +30,13 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
3533 */
3634
3735#ifndef _SYS_SYSCTL_H_
3836#define _SYS_SYSCTL_H_
3937
4038#ifdef _KERNEL
39#include <sys/cdefs.h>
4140#include <sys/queue.h>
4241#include <sys/tree.h>
4342#endif
......@@ -866,7 +865,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
866865/* OID expressing a sbintime_t as microseconds */
867866#define SYSCTL_SBINTIME_USEC(parent, nbr, name, access, ptr, descr) \
868867 SYSCTL_OID(parent, nbr, name, \
869 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
868 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
870869 (ptr), 0, sysctl_usec_to_sbintime, "Q", descr); \
871870 CTASSERT(((access) & CTLTYPE) == 0 || \
872871 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)
......@@ -876,7 +875,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
876875 CTASSERT(((access) & CTLTYPE) == 0 || \
877876 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
878877 sysctl_add_oid(ctx, parent, nbr, name, \
879 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
878 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
880879 __ptr, 0, sysctl_usec_to_sbintime, "Q", __DESCR(descr), \
881880 NULL); \
882881})
......@@ -884,7 +883,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
884883/* OID expressing a sbintime_t as milliseconds */
885884#define SYSCTL_SBINTIME_MSEC(parent, nbr, name, access, ptr, descr) \
886885 SYSCTL_OID(parent, nbr, name, \
887 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
886 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
888887 (ptr), 0, sysctl_msec_to_sbintime, "Q", descr); \
889888 CTASSERT(((access) & CTLTYPE) == 0 || \
890889 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)
......@@ -894,7 +893,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
894893 CTASSERT(((access) & CTLTYPE) == 0 || \
895894 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
896895 sysctl_add_oid(ctx, parent, nbr, name, \
897 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
896 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
898897 __ptr, 0, sysctl_msec_to_sbintime, "Q", __DESCR(descr), \
899898 NULL); \
900899})
......@@ -934,6 +933,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
934933 CTLFLAG_RD | CTLFLAG_CAPRD | CTLTYPE_INT | CTLFLAG_MPSAFE, \
935934 NULL, 1, sysctl_handle_int, "I", desc, "feature");
936935
936/*
937 * Adding new leaves to the 'debug.sizeof' MIB tree for ad-hoc reasons is
938 * discouraged, and in particular for reporting to developers the size of some
939 * kernel structures, which can be obtained by the following alternative means:
940 * 1. In GDB, load a full kernel image and use 'print(sizeof(struct XXX))'.
941 * Alternatively, use 'ptype/o struct XXX' to additionally get the offsets
942 * and size of all structure's fields.
943 * 2. If the structure is allocated from UMA, then 'vmstat -z' reports its size
944 * (the mapping between structure types and zones is usually
945 * straightforward).
946 */
947/* Generates a read-only sysctl reporting the size of an object/structure. */
948#define SYSCTL_SIZEOF(name, expr) \
949 SYSCTL_INT(_debug_sizeof, OID_AUTO, name, CTLFLAG_RD, \
950 SYSCTL_NULL_INT_PTR, sizeof(expr), \
951 "sizeof(" __STRING(expr) ")");
952/* Same, specialized for structures. */
953#define SYSCTL_SIZEOF_STRUCT(struct_name) \
954 SYSCTL_SIZEOF(struct_name, struct struct_name)
955
937956#endif /* _KERNEL */
938957
939958/*
......@@ -1043,6 +1062,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
10431062#define KERN_PROC_SIGFASTBLK 44 /* address of fastsigblk magic word */
10441063#define KERN_PROC_VM_LAYOUT 45 /* virtual address space layout info */
10451064#define KERN_PROC_RLIMIT_USAGE 46 /* array of rlim_t */
1065#define KERN_PROC_KQUEUE 47 /* array of struct kinfo_knote */
10461066
10471067/*
10481068 * KERN_IPC identifiers
lib/libc/include/generic-freebsd/sys/sysent.h+15-7
......@@ -79,11 +79,10 @@ struct sysent { /* system call table */
7979 */
8080#define SYF_CAPENABLED 0x00000001
8181
82#define SY_THR_FLAGMASK 0x7
83#define SY_THR_STATIC 0x1
84#define SY_THR_DRAINING 0x2
85#define SY_THR_ABSENT 0x4
86#define SY_THR_INCR 0x8
82#define SY_THR_STATIC 0x01
83#define SY_THR_DRAINING 0x02
84#define SY_THR_ABSENT 0x04
85#define SY_THR_INCR 0x08
8786
8887#ifdef KLD_MODULE
8988#define SY_THR_STATIC_KLD 0
......@@ -91,6 +90,7 @@ struct sysent { /* system call table */
9190#define SY_THR_STATIC_KLD SY_THR_STATIC
9291#endif
9392
93struct coredump_writer;
9494struct image_params;
9595struct proc;
9696struct __sigset;
......@@ -109,7 +109,8 @@ struct sysentvec {
109109 int *sv_szsigcode; /* size of sigtramp code */
110110 int sv_sigcodeoff;
111111 char *sv_name; /* name of binary type */
112 int (*sv_coredump)(struct thread *, struct vnode *, off_t, int);
112 int (*sv_coredump)(struct thread *, struct coredump_writer *,
113 off_t, int);
113114 /* function to dump core, or NULL */
114115 int sv_elf_core_osabi;
115116 const char *sv_elf_core_abi_vendor;
......@@ -145,10 +146,13 @@ struct sysentvec {
145146 int (*sv_trap)(struct thread *);
146147 u_long *sv_hwcap; /* Value passed in AT_HWCAP. */
147148 u_long *sv_hwcap2; /* Value passed in AT_HWCAP2. */
149 u_long *sv_hwcap3; /* Value passed in AT_HWCAP3. */
150 u_long *sv_hwcap4; /* Value passed in AT_HWCAP4. */
148151 const char *(*sv_machine_arch)(struct proc *);
149152 vm_offset_t sv_fxrng_gen_offset;
150153 void (*sv_onexec_old)(struct thread *td);
151154 int (*sv_onexec)(struct proc *, struct image_params *);
155 void (*sv_protect)(struct image_params *, int);
152156 void (*sv_onexit)(struct proc *);
153157 void (*sv_ontdexit)(struct thread *td);
154158 int (*sv_setid_allowed)(struct thread *td,
......@@ -161,7 +165,7 @@ struct sysentvec {
161165
162166#define SV_ILP32 0x000100 /* 32-bit executable. */
163167#define SV_LP64 0x000200 /* 64-bit executable. */
164#define SV_IA32 0x004000 /* Intel 32-bit executable. */
168#define SV_RESERVED0 0x004000 /* Formerly SV_IA32 */
165169#define SV_AOUT 0x008000 /* a.out executable. */
166170#define SV_SHP 0x010000 /* Shared page. */
167171#define SV_SIGSYS 0x020000 /* SIGSYS for non-existing syscall */
......@@ -187,6 +191,10 @@ struct sysentvec {
187191#define SVC_NOCOMPRESS 0x00000002 /* disable compression. */
188192#define SVC_ALL 0x00000004 /* dump everything */
189193
194/* sv_protect flags */
195#define SVP_IMAGE 0x00000001
196#define SVP_INTERP 0x00000002
197
190198#ifdef _KERNEL
191199extern struct sysentvec aout_sysvec;
192200extern struct sysent sysent[];
lib/libc/include/generic-freebsd/sys/syslimits.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)syslimits.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_SYSLIMITS_H_
lib/libc/include/generic-freebsd/sys/syslog.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)syslog.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_SYSLOG_H_
lib/libc/include/generic-freebsd/sys/sysproto.h+99-54
......@@ -7,8 +7,8 @@
77#ifndef _SYS_SYSPROTO_H_
88#define _SYS_SYSPROTO_H_
99
10#include <sys/types.h>
1011#include <sys/signal.h>
11#include <sys/acl.h>
1212#include <sys/cpuset.h>
1313#include <sys/domainset.h>
1414#include <sys/_ffcounter.h>
......@@ -33,7 +33,7 @@ struct thread;
3333#define PADR_(t) 0
3434#endif
3535
36struct exit_args {
36struct _exit_args {
3737 char rval_l_[PADL_(int)]; int rval; char rval_r_[PADR_(int)];
3838};
3939struct fork_args {
......@@ -254,12 +254,6 @@ struct msync_args {
254254struct vfork_args {
255255 syscallarg_t dummy;
256256};
257struct sbrk_args {
258 char incr_l_[PADL_(int)]; int incr; char incr_r_[PADR_(int)];
259};
260struct sstk_args {
261 char incr_l_[PADL_(int)]; int incr; char incr_r_[PADR_(int)];
262};
263257struct munmap_args {
264258 char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
265259 char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
......@@ -279,14 +273,6 @@ struct mincore_args {
279273 char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
280274 char vec_l_[PADL_(char *)]; char * vec; char vec_r_[PADR_(char *)];
281275};
282struct getgroups_args {
283 char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)];
284 char gidset_l_[PADL_(gid_t *)]; gid_t * gidset; char gidset_r_[PADR_(gid_t *)];
285};
286struct setgroups_args {
287 char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)];
288 char gidset_l_[PADL_(const gid_t *)]; const gid_t * gidset; char gidset_r_[PADR_(const gid_t *)];
289};
290276struct getpgrp_args {
291277 syscallarg_t dummy;
292278};
......@@ -319,7 +305,7 @@ struct dup2_args {
319305struct fcntl_args {
320306 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
321307 char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
322 char arg_l_[PADL_(long)]; long arg; char arg_r_[PADR_(long)];
308 char arg_l_[PADL_(intptr_t)]; intptr_t arg; char arg_r_[PADR_(intptr_t)];
323309};
324310struct select_args {
325311 char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];
......@@ -383,12 +369,12 @@ struct getsockopt_args {
383369};
384370struct readv_args {
385371 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
386 char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
372 char iovp_l_[PADL_(const struct iovec *)]; const struct iovec * iovp; char iovp_r_[PADR_(const struct iovec *)];
387373 char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];
388374};
389375struct writev_args {
390376 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
391 char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
377 char iovp_l_[PADL_(const struct iovec *)]; const struct iovec * iovp; char iovp_r_[PADR_(const struct iovec *)];
392378 char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];
393379};
394380struct settimeofday_args {
......@@ -552,7 +538,7 @@ struct setrlimit_args {
552538 char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];
553539};
554540struct __sysctl_args {
555 char name_l_[PADL_(int *)]; int * name; char name_r_[PADR_(int *)];
541 char name_l_[PADL_(const int *)]; const int * name; char name_r_[PADR_(const int *)];
556542 char namelen_l_[PADL_(u_int)]; u_int namelen; char namelen_r_[PADR_(u_int)];
557543 char old_l_[PADL_(void *)]; void * old; char old_r_[PADR_(void *)];
558544 char oldlenp_l_[PADL_(size_t *)]; size_t * oldlenp; char oldlenp_r_[PADR_(size_t *)];
......@@ -783,7 +769,7 @@ struct aio_return_args {
783769 char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
784770};
785771struct aio_suspend_args {
786 char aiocbp_l_[PADL_(struct aiocb * const *)]; struct aiocb * const * aiocbp; char aiocbp_r_[PADR_(struct aiocb * const *)];
772 char aiocbp_l_[PADL_(const struct aiocb * const *)]; const struct aiocb * const * aiocbp; char aiocbp_r_[PADR_(const struct aiocb * const *)];
787773 char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)];
788774 char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)];
789775};
......@@ -868,49 +854,49 @@ struct sigpending_args {
868854};
869855struct sigtimedwait_args {
870856 char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];
871 char info_l_[PADL_(struct siginfo *)]; struct siginfo * info; char info_r_[PADR_(struct siginfo *)];
857 char info_l_[PADL_(struct __siginfo *)]; struct __siginfo * info; char info_r_[PADR_(struct __siginfo *)];
872858 char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)];
873859};
874860struct sigwaitinfo_args {
875861 char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];
876 char info_l_[PADL_(struct siginfo *)]; struct siginfo * info; char info_r_[PADR_(struct siginfo *)];
862 char info_l_[PADL_(struct __siginfo *)]; struct __siginfo * info; char info_r_[PADR_(struct __siginfo *)];
877863};
878864struct __acl_get_file_args {
879865 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
880 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
866 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
881867 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
882868};
883869struct __acl_set_file_args {
884870 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
885 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
871 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
886872 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
887873};
888874struct __acl_get_fd_args {
889875 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];
890 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
876 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
891877 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
892878};
893879struct __acl_set_fd_args {
894880 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];
895 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
881 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
896882 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
897883};
898884struct __acl_delete_file_args {
899885 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
900 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
886 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
901887};
902888struct __acl_delete_fd_args {
903889 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];
904 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
890 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
905891};
906892struct __acl_aclcheck_file_args {
907893 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
908 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
894 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
909895 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
910896};
911897struct __acl_aclcheck_fd_args {
912898 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];
913 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
899 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
914900 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
915901};
916902struct extattrctl_args {
......@@ -1136,21 +1122,21 @@ struct swapcontext_args {
11361122};
11371123struct __acl_get_link_args {
11381124 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1139 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
1125 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
11401126 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
11411127};
11421128struct __acl_set_link_args {
11431129 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1144 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
1130 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
11451131 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
11461132};
11471133struct __acl_delete_link_args {
11481134 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1149 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
1135 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
11501136};
11511137struct __acl_aclcheck_link_args {
11521138 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1153 char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)];
1139 char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)];
11541140 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
11551141};
11561142struct sigwait_args {
......@@ -1482,9 +1468,6 @@ struct unlinkat_args {
14821468struct posix_openpt_args {
14831469 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
14841470};
1485struct gssd_syscall_args {
1486 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1487};
14881471struct jail_get_args {
14891472 char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
14901473 char iovcnt_l_[PADL_(unsigned int)]; unsigned int iovcnt; char iovcnt_r_[PADR_(unsigned int)];
......@@ -1603,7 +1586,7 @@ struct wait6_args {
16031586 char status_l_[PADL_(int *)]; int * status; char status_r_[PADR_(int *)];
16041587 char options_l_[PADL_(int)]; int options; char options_r_[PADR_(int)];
16051588 char wrusage_l_[PADL_(struct __wrusage *)]; struct __wrusage * wrusage; char wrusage_r_[PADR_(struct __wrusage *)];
1606 char info_l_[PADL_(struct siginfo *)]; struct siginfo * info; char info_r_[PADR_(struct siginfo *)];
1589 char info_l_[PADL_(struct __siginfo *)]; struct __siginfo * info; char info_r_[PADR_(struct __siginfo *)];
16071590};
16081591struct cap_rights_limit_args {
16091592 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
......@@ -1811,7 +1794,7 @@ struct shm_rename_args {
18111794};
18121795struct sigfastblock_args {
18131796 char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
1814 char ptr_l_[PADL_(uint32_t *)]; uint32_t * ptr; char ptr_r_[PADR_(uint32_t *)];
1797 char ptr_l_[PADL_(void *)]; void * ptr; char ptr_r_[PADR_(void *)];
18151798};
18161799struct __realpathat_args {
18171800 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
......@@ -1826,8 +1809,7 @@ struct close_range_args {
18261809 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
18271810};
18281811struct rpctls_syscall_args {
1829 char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];
1830 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1812 char socookie_l_[PADL_(uint64_t)]; uint64_t socookie; char socookie_r_[PADR_(uint64_t)];
18311813};
18321814struct __specialfd_args {
18331815 char type_l_[PADL_(int)]; int type; char type_r_[PADR_(int)];
......@@ -1888,7 +1870,44 @@ struct getrlimitusage_args {
18881870 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
18891871 char res_l_[PADL_(rlim_t *)]; rlim_t * res; char res_r_[PADR_(rlim_t *)];
18901872};
1891int sys_exit(struct thread *, struct exit_args *);
1873struct fchroot_args {
1874 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
1875};
1876struct setcred_args {
1877 char flags_l_[PADL_(u_int)]; u_int flags; char flags_r_[PADR_(u_int)];
1878 char wcred_l_[PADL_(const struct setcred *)]; const struct setcred * wcred; char wcred_r_[PADR_(const struct setcred *)];
1879 char size_l_[PADL_(size_t)]; size_t size; char size_r_[PADR_(size_t)];
1880};
1881struct exterrctl_args {
1882 char op_l_[PADL_(u_int)]; u_int op; char op_r_[PADR_(u_int)];
1883 char flags_l_[PADL_(u_int)]; u_int flags; char flags_r_[PADR_(u_int)];
1884 char ptr_l_[PADL_(void *)]; void * ptr; char ptr_r_[PADR_(void *)];
1885};
1886struct inotify_add_watch_at_args {
1887 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
1888 char dfd_l_[PADL_(int)]; int dfd; char dfd_r_[PADR_(int)];
1889 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1890 char mask_l_[PADL_(uint32_t)]; uint32_t mask; char mask_r_[PADR_(uint32_t)];
1891};
1892struct inotify_rm_watch_args {
1893 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
1894 char wd_l_[PADL_(int)]; int wd; char wd_r_[PADR_(int)];
1895};
1896struct getgroups_args {
1897 char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)];
1898 char gidset_l_[PADL_(gid_t *)]; gid_t * gidset; char gidset_r_[PADR_(gid_t *)];
1899};
1900struct setgroups_args {
1901 char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)];
1902 char gidset_l_[PADL_(const gid_t *)]; const gid_t * gidset; char gidset_r_[PADR_(const gid_t *)];
1903};
1904struct jail_attach_jd_args {
1905 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
1906};
1907struct jail_remove_jd_args {
1908 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
1909};
1910int sys__exit(struct thread *, struct _exit_args *);
18921911int sys_fork(struct thread *, struct fork_args *);
18931912int sys_read(struct thread *, struct read_args *);
18941913int sys_write(struct thread *, struct write_args *);
......@@ -1940,14 +1959,10 @@ int sys_umask(struct thread *, struct umask_args *);
19401959int sys_chroot(struct thread *, struct chroot_args *);
19411960int sys_msync(struct thread *, struct msync_args *);
19421961int sys_vfork(struct thread *, struct vfork_args *);
1943int sys_sbrk(struct thread *, struct sbrk_args *);
1944int sys_sstk(struct thread *, struct sstk_args *);
19451962int sys_munmap(struct thread *, struct munmap_args *);
19461963int sys_mprotect(struct thread *, struct mprotect_args *);
19471964int sys_madvise(struct thread *, struct madvise_args *);
19481965int sys_mincore(struct thread *, struct mincore_args *);
1949int sys_getgroups(struct thread *, struct getgroups_args *);
1950int sys_setgroups(struct thread *, struct setgroups_args *);
19511966int sys_getpgrp(struct thread *, struct getpgrp_args *);
19521967int sys_setpgid(struct thread *, struct setpgid_args *);
19531968int sys_setitimer(struct thread *, struct setitimer_args *);
......@@ -2210,7 +2225,6 @@ int sys_renameat(struct thread *, struct renameat_args *);
22102225int sys_symlinkat(struct thread *, struct symlinkat_args *);
22112226int sys_unlinkat(struct thread *, struct unlinkat_args *);
22122227int sys_posix_openpt(struct thread *, struct posix_openpt_args *);
2213int sys_gssd_syscall(struct thread *, struct gssd_syscall_args *);
22142228int sys_jail_get(struct thread *, struct jail_get_args *);
22152229int sys_jail_set(struct thread *, struct jail_set_args *);
22162230int sys_jail_remove(struct thread *, struct jail_remove_args *);
......@@ -2290,6 +2304,15 @@ int sys_timerfd_gettime(struct thread *, struct timerfd_gettime_args *);
22902304int sys_timerfd_settime(struct thread *, struct timerfd_settime_args *);
22912305int sys_kcmp(struct thread *, struct kcmp_args *);
22922306int sys_getrlimitusage(struct thread *, struct getrlimitusage_args *);
2307int sys_fchroot(struct thread *, struct fchroot_args *);
2308int sys_setcred(struct thread *, struct setcred_args *);
2309int sys_exterrctl(struct thread *, struct exterrctl_args *);
2310int sys_inotify_add_watch_at(struct thread *, struct inotify_add_watch_at_args *);
2311int sys_inotify_rm_watch(struct thread *, struct inotify_rm_watch_args *);
2312int sys_getgroups(struct thread *, struct getgroups_args *);
2313int sys_setgroups(struct thread *, struct setgroups_args *);
2314int sys_jail_attach_jd(struct thread *, struct jail_attach_jd_args *);
2315int sys_jail_remove_jd(struct thread *, struct jail_remove_jd_args *);
22932316
22942317#ifdef COMPAT_43
22952318
......@@ -2781,7 +2804,23 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
27812804
27822805#endif /* COMPAT_FREEBSD13 */
27832806
2784#define SYS_AUE_exit AUE_EXIT
2807
2808#ifdef COMPAT_FREEBSD14
2809
2810struct freebsd14_getgroups_args {
2811 char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)];
2812 char gidset_l_[PADL_(gid_t *)]; gid_t * gidset; char gidset_r_[PADR_(gid_t *)];
2813};
2814struct freebsd14_setgroups_args {
2815 char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)];
2816 char gidset_l_[PADL_(const gid_t *)]; const gid_t * gidset; char gidset_r_[PADR_(const gid_t *)];
2817};
2818int freebsd14_getgroups(struct thread *, struct freebsd14_getgroups_args *);
2819int freebsd14_setgroups(struct thread *, struct freebsd14_setgroups_args *);
2820
2821#endif /* COMPAT_FREEBSD14 */
2822
2823#define SYS_AUE__exit AUE_EXIT
27852824#define SYS_AUE_fork AUE_FORK
27862825#define SYS_AUE_read AUE_READ
27872826#define SYS_AUE_write AUE_WRITE
......@@ -2846,16 +2885,14 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
28462885#define SYS_AUE_ogetpagesize AUE_NULL
28472886#define SYS_AUE_msync AUE_MSYNC
28482887#define SYS_AUE_vfork AUE_VFORK
2849#define SYS_AUE_sbrk AUE_SBRK
2850#define SYS_AUE_sstk AUE_SSTK
28512888#define SYS_AUE_ommap AUE_MMAP
28522889#define SYS_AUE_freebsd11_vadvise AUE_O_VADVISE
28532890#define SYS_AUE_munmap AUE_MUNMAP
28542891#define SYS_AUE_mprotect AUE_MPROTECT
28552892#define SYS_AUE_madvise AUE_MADVISE
28562893#define SYS_AUE_mincore AUE_MINCORE
2857#define SYS_AUE_getgroups AUE_GETGROUPS
2858#define SYS_AUE_setgroups AUE_SETGROUPS
2894#define SYS_AUE_freebsd14_getgroups AUE_GETGROUPS
2895#define SYS_AUE_freebsd14_setgroups AUE_SETGROUPS
28592896#define SYS_AUE_getpgrp AUE_GETPGRP
28602897#define SYS_AUE_setpgid AUE_SETPGRP
28612898#define SYS_AUE_setitimer AUE_SETITIMER
......@@ -3185,7 +3222,6 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
31853222#define SYS_AUE_symlinkat AUE_SYMLINKAT
31863223#define SYS_AUE_unlinkat AUE_UNLINKAT
31873224#define SYS_AUE_posix_openpt AUE_POSIX_OPENPT
3188#define SYS_AUE_gssd_syscall AUE_NULL
31893225#define SYS_AUE_jail_get AUE_JAIL_GET
31903226#define SYS_AUE_jail_set AUE_JAIL_SET
31913227#define SYS_AUE_jail_remove AUE_JAIL_REMOVE
......@@ -3266,6 +3302,15 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
32663302#define SYS_AUE_timerfd_settime AUE_TIMERFD
32673303#define SYS_AUE_kcmp AUE_NULL
32683304#define SYS_AUE_getrlimitusage AUE_NULL
3305#define SYS_AUE_fchroot AUE_NULL
3306#define SYS_AUE_setcred AUE_SETCRED
3307#define SYS_AUE_exterrctl AUE_NULL
3308#define SYS_AUE_inotify_add_watch_at AUE_INOTIFY
3309#define SYS_AUE_inotify_rm_watch AUE_INOTIFY
3310#define SYS_AUE_getgroups AUE_GETGROUPS
3311#define SYS_AUE_setgroups AUE_SETGROUPS
3312#define SYS_AUE_jail_attach_jd AUE_JAIL_ATTACH
3313#define SYS_AUE_jail_remove_jd AUE_JAIL_REMOVE
32693314
32703315#undef PAD_
32713316#undef PADL_
lib/libc/include/generic-freebsd/sys/systm.h+54-32
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)systm.h 8.7 (Berkeley) 3/29/95
3735 */
3836
3937#ifndef _SYS_SYSTM_H_
......@@ -81,7 +79,7 @@ extern u_long maxphys; /* max raw I/O transfer size */
8179 */
8280enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
8381 VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_BHYVE, VM_GUEST_VBOX,
84 VM_GUEST_PARALLELS, VM_GUEST_NVMM, VM_LAST };
82 VM_GUEST_PARALLELS, VM_GUEST_NVMM, VM_GUEST_LAST };
8583
8684#endif /* KERNEL */
8785
......@@ -101,17 +99,15 @@ struct ucred;
10199#include <sys/pcpu.h> /* curthread */
102100#include <sys/kpilite.h>
103101
102extern bool scheduler_stopped;
103
104104/*
105105 * If we have already panic'd and this is the thread that called
106106 * panic(), then don't block on any mutexes but silently succeed.
107107 * Otherwise, the kernel will deadlock since the scheduler isn't
108108 * going to run the thread that holds any lock we need.
109109 */
110#define SCHEDULER_STOPPED_TD(td) ({ \
111 MPASS((td) == curthread); \
112 __predict_false((td)->td_stopsched); \
113})
114#define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread)
110#define SCHEDULER_STOPPED() __predict_false(scheduler_stopped)
115111
116112extern const int osreldate;
117113
......@@ -212,6 +208,16 @@ critical_exit(void)
212208#ifdef EARLY_PRINTF
213209typedef void early_putc_t(int ch);
214210extern early_putc_t *early_putc;
211#define CHECK_EARLY_PRINTF(x) \
212 __CONCAT(early_printf_, EARLY_PRINTF) == __CONCAT(early_printf_, x)
213#define early_printf_1 1
214#define early_printf_mvebu 2
215#define early_printf_ns8250 3
216#define early_printf_pl011 4
217#define early_printf_snps 5
218#define early_printf_sbi 6
219#else
220#define CHECK_EARLY_PRINTF(x) 0
215221#endif
216222int kvprintf(char const *, void (*)(int, void*), void *, int,
217223 __va_list) __printflike(1, 0);
......@@ -296,17 +302,18 @@ void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n);
296302 ((__r >= __len) ? ENAMETOOLONG : 0); \
297303})
298304
299int copyinstr(const void * __restrict udaddr,
300 void * _Nonnull __restrict kaddr, size_t len,
301 size_t * __restrict lencopied);
302int copyin(const void * __restrict udaddr,
303 void * _Nonnull __restrict kaddr, size_t len);
304int copyin_nofault(const void * __restrict udaddr,
305 void * _Nonnull __restrict kaddr, size_t len);
306int copyout(const void * _Nonnull __restrict kaddr,
307 void * __restrict udaddr, size_t len);
308int copyout_nofault(const void * _Nonnull __restrict kaddr,
309 void * __restrict udaddr, size_t len);
305int __result_use_check copyinstr(const void * __restrict udaddr,
306 void * _Nonnull __restrict kaddr, size_t len,
307 size_t * __restrict lencopied);
308int __result_use_check copyin(const void * __restrict udaddr,
309 void * _Nonnull __restrict kaddr, size_t len);
310int __result_use_check copyin_nofault(const void * __restrict udaddr,
311 void * _Nonnull __restrict kaddr, size_t len);
312__nodiscard int copyout(const void * _Nonnull __restrict kaddr,
313 void * __restrict udaddr, size_t len);
314__nodiscard int copyout_nofault(
315 const void * _Nonnull __restrict kaddr, void * __restrict udaddr,
316 size_t len);
310317
311318#ifdef SAN_NEEDS_INTERCEPTORS
312319int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t);
......@@ -324,14 +331,14 @@ long fuword(volatile const void *base);
324331int fuword16(volatile const void *base);
325332int32_t fuword32(volatile const void *base);
326333int64_t fuword64(volatile const void *base);
327int fueword(volatile const void *base, long *val);
328int fueword32(volatile const void *base, int32_t *val);
329int fueword64(volatile const void *base, int64_t *val);
330int subyte(volatile void *base, int byte);
331int suword(volatile void *base, long word);
332int suword16(volatile void *base, int word);
333int suword32(volatile void *base, int32_t word);
334int suword64(volatile void *base, int64_t word);
334int __result_use_check fueword(volatile const void *base, long *val);
335int __result_use_check fueword32(volatile const void *base, int32_t *val);
336int __result_use_check fueword64(volatile const void *base, int64_t *val);
337__nodiscard int subyte(volatile void *base, int byte);
338__nodiscard int suword(volatile void *base, long word);
339__nodiscard int suword16(volatile void *base, int word);
340__nodiscard int suword32(volatile void *base, int32_t word);
341__nodiscard int suword64(volatile void *base, int64_t word);
335342uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);
336343u_long casuword(volatile u_long *p, u_long oldval, u_long newval);
337344int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,
......@@ -559,17 +566,32 @@ void counted_warning(unsigned *counter, const char *msg);
559566/*
560567 * APIs to manage deprecation and obsolescence.
561568 */
562void _gone_in(int major, const char *msg);
563void _gone_in_dev(device_t dev, int major, const char *msg);
569void _gone_in(int major, const char *msg, ...) __printflike(2, 3);
570void _gone_in_dev(device_t dev, int major, const char *msg, ...)
571 __printflike(3, 4);
564572#ifdef NO_OBSOLETE_CODE
565573#define __gone_ok(m, msg) \
566574 _Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)), \
567 "Obsolete code: " msg);
575 "Obsolete code: " msg)
568576#else
569577#define __gone_ok(m, msg)
570578#endif
571#define gone_in(major, msg) __gone_ok(major, msg) _gone_in(major, msg)
572#define gone_in_dev(dev, major, msg) __gone_ok(major, msg) _gone_in_dev(dev, major, msg)
579#define gone_in(major, msg, ...) do { \
580 static bool __read_mostly __gone_in_ ## __LINE__ = true; \
581 __gone_ok(major, msg); \
582 if (__predict_false(__gone_in_ ## __LINE__)) { \
583 __gone_in_ ## __LINE__ = false; \
584 _gone_in(major, msg __VA_OPT__(,) __VA_ARGS__); \
585 } \
586} while (0)
587#define gone_in_dev(dev, major, msg, ...) do { \
588 static bool __read_mostly __gone_in_ ## __LINE__ = true; \
589 __gone_ok(major, msg); \
590 if (__predict_false(__gone_in_ ## __LINE__)) { \
591 __gone_in_ ## __LINE__ = false; \
592 _gone_in_dev(dev, major, msg __VA_OPT__(,) __VA_ARGS__);\
593 } \
594} while (0)
573595
574596#ifdef INVARIANTS
575597#define __diagused
lib/libc/include/generic-freebsd/sys/taskqueue.h+6
......@@ -215,4 +215,10 @@ struct taskqueue *taskqueue_create_fast(const char *name, int mflags,
215215 taskqueue_enqueue_fn enqueue,
216216 void *context);
217217
218/*
219 * This queue is used to process asynchronous device events such as
220 * hot plug insertion and removal of devices.
221 */
222TASKQUEUE_DECLARE(bus);
223
218224#endif /* !_SYS_TASKQUEUE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/thr.h+1
......@@ -43,6 +43,7 @@ typedef __size_t size_t;
4343#define THR_SUSPENDED 0x0001
4444/* Create the system scope thread. */
4545#define THR_SYSTEM_SCOPE 0x0002
46#define THR_C_RUNTIME 0x0004
4647
4748struct thr_param {
4849 void (*start_func)(void *); /* thread entry function. */
lib/libc/include/generic-freebsd/sys/time.h+2-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)time.h 8.5 (Berkeley) 5/4/95
3230 */
3331
3432#ifndef _SYS_TIME_H_
......@@ -613,7 +611,9 @@ int tvtohz(struct timeval *tv);
613611#include <time.h>
614612
615613#include <sys/cdefs.h>
614#ifndef _STANDALONE
616615#include <sys/select.h>
616#endif
617617
618618__BEGIN_DECLS
619619int setitimer(int, const struct itimerval *, struct itimerval *);
lib/libc/include/generic-freebsd/sys/timeb.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)timeb.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_TIMEB_H_
lib/libc/include/generic-freebsd/sys/timeffc.h+3-1
......@@ -89,7 +89,7 @@ extern int sysclock_active;
8989 * of the kernel tick timer (1/hz [s]).
9090 * FFCLOCK_LERP: Linear interpolation of ffclock time to guarantee
9191 * monotonic time.
92 * FFCLOCK_LEAPSEC: Include leap seconds.
92 * {FB|FF}CLOCK_LEAPSEC: Include leap seconds.
9393 * {FB|FF}CLOCK_UPTIME: Time stamp should be relative to system boot, not epoch.
9494 */
9595#define FFCLOCK_FAST 0x00000001
......@@ -100,6 +100,7 @@ extern int sysclock_active;
100100
101101#define FBCLOCK_FAST 0x00010000 /* Currently unused. */
102102#define FBCLOCK_UPTIME 0x00020000
103#define FBCLOCK_LEAPSEC 0x00040000
103104#define FBCLOCK_MASK 0xffff0000
104105
105106/*
......@@ -111,6 +112,7 @@ struct fbclock_info {
111112 struct bintime error;
112113 struct bintime tick_time;
113114 uint64_t th_scale;
115 long th_tai_offset;
114116 int status;
115117};
116118
lib/libc/include/generic-freebsd/sys/times.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)times.h 8.4 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _SYS_TIMES_H_
lib/libc/include/generic-freebsd/sys/timespec.h-3
......@@ -27,9 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)time.h 8.5 (Berkeley) 5/4/95
32 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
3330 */
3431
3532#ifndef _SYS_TIMESPEC_H_
lib/libc/include/generic-freebsd/sys/timetc.h+2-2
......@@ -49,7 +49,7 @@ struct timecounter {
4949 * This function is optional. It will be called whenever the
5050 * timecounter is rewound, and is intended to check for PPS
5151 * events. Normal hardware does not need it but timecounters
52 * which latch PPS in hardware (like sys/pci/xrpu.c) do.
52 * which latch PPS in hardware do.
5353 */
5454 u_int tc_counter_mask;
5555 /* This mask should mask off any unimplemented bits. */
......@@ -87,7 +87,7 @@ extern int tc_min_ticktock_freq; /*
8787u_int64_t tc_getfrequency(void);
8888void tc_init(struct timecounter *tc);
8989void tc_setclock(struct timespec *ts);
90void tc_ticktock(int cnt);
90void tc_ticktock(long cnt);
9191void cpu_tick_calibration(void);
9292
9393#ifdef SYSCTL_DECL
lib/libc/include/generic-freebsd/sys/timex.h+1-1
......@@ -154,7 +154,7 @@ struct timex {
154154#ifdef __FreeBSD__
155155
156156#ifdef _KERNEL
157void ntp_update_second(int64_t *adjustment, time_t *newsec);
157void ntp_update_second(int64_t *adjustment, time_t *newsec, long *tai_off);
158158#else /* !_KERNEL */
159159#include <sys/cdefs.h>
160160
lib/libc/include/generic-freebsd/sys/ttycom.h+2-4
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)ttycom.h 8.1 (Berkeley) 3/28/94
3735 */
3836
3937#ifndef _SYS_TTYCOM_H_
......@@ -71,8 +69,8 @@
7169 /* 89-91 conflicts: tun and tap */
7270#define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* enable/get timestamp
7371 * of last input event */
74#define TIOCMGDTRWAIT _IOR('t', 90, int) /* modem: get wait on close */
75#define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */
72/* TIOCMGDTRWAIT _IOR('t', 90, int) * was modem: get wait on close */
73/* TIOCMSDTRWAIT _IOW('t', 91, int) * was modem: set wait on close */
7674 /* 92-93 tun and tap */
7775 /* 94-97 conflicts: tun and tap */
7876#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
lib/libc/include/generic-freebsd/sys/ttydefaults.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
3735 */
3836
3937/*
lib/libc/include/generic-freebsd/sys/types.h+4-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)types.h 8.6 (Berkeley) 2/19/95
3735 */
3836
3937#ifndef _SYS_TYPES_H_
......@@ -299,9 +297,11 @@ typedef struct vm_page *vm_page_t;
299297#if defined(_KERNEL) || defined(_STANDALONE)
300298#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
301299#define __bool_true_false_are_defined 1
300#if __STDC_VERSION__ < 202311L
302301#define false 0
303302#define true 1
304303typedef _Bool bool;
304#endif /* __STDC_VERSION__ < 202311L */
305305#endif /* !__bool_true_false_are_defined && !__cplusplus */
306306#endif /* KERNEL || _STANDALONE */
307307
......@@ -313,7 +313,9 @@ typedef _Bool bool;
313313
314314#if __BSD_VISIBLE
315315
316#ifndef _STANDALONE
316317#include <sys/select.h>
318#endif
317319
318320/*
319321 * The major and minor numbers are encoded in dev_t as MMMmmmMm (where
lib/libc/include/generic-freebsd/sys/ucoredump.h created+99
......@@ -0,0 +1,99 @@
1/*
2 *
3 * Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
4 * Copyright (c) 2025 Kyle Evans <kevans@FreeBSD.org>
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 */
9
10#ifndef _SYS_UCOREDUMP_H_
11#define _SYS_UCOREDUMP_H_
12
13#ifdef _KERNEL
14
15#include <sys/_uio.h>
16#include <sys/blockcount.h>
17#include <sys/queue.h>
18
19/* Coredump output parameters. */
20struct coredump_params;
21struct coredump_writer;
22struct thread;
23struct ucred;
24
25typedef int coredump_init_fn(const struct coredump_writer *,
26 const struct coredump_params *);
27typedef int coredump_write_fn(const struct coredump_writer *, const void *, size_t,
28 off_t, enum uio_seg, struct ucred *, size_t *, struct thread *);
29typedef int coredump_extend_fn(const struct coredump_writer *, off_t,
30 struct ucred *);
31
32struct coredump_vnode_ctx {
33 struct vnode *vp;
34 struct ucred *fcred;
35};
36
37coredump_write_fn core_vn_write;
38coredump_extend_fn core_vn_extend;
39
40struct coredump_writer {
41 void *ctx;
42 coredump_init_fn *init_fn;
43 coredump_write_fn *write_fn;
44 coredump_extend_fn *extend_fn;
45};
46
47struct coredump_params {
48 off_t offset;
49 struct ucred *active_cred;
50 struct thread *td;
51 const struct coredump_writer *cdw;
52 struct compressor *comp;
53};
54
55#define CORE_BUF_SIZE (16 * 1024)
56
57int core_write(struct coredump_params *, const void *, size_t, off_t,
58 enum uio_seg, size_t *);
59int core_output(char *, size_t, off_t, struct coredump_params *, void *);
60int sbuf_drain_core_output(void *, const char *, int);
61
62extern int coredump_pack_fileinfo;
63extern int coredump_pack_vmmapinfo;
64
65extern int compress_user_cores;
66extern int compress_user_cores_level;
67
68typedef int coredumper_probe_fn(struct thread *);
69
70/*
71 * Some arbitrary values for coredumper probes to return. The highest priority
72 * we can find wins. It's somewhat expected that a coredumper may want to bid
73 * differently based on the process in question. Note that probe functions will
74 * be called with the proc lock held, so they must not sleep.
75 */
76#define COREDUMPER_NOMATCH (-1) /* Decline to touch it */
77#define COREDUMPER_GENERIC (0) /* I handle coredumps */
78#define COREDUMPER_SPECIAL (50) /* Special handler */
79#define COREDUMPER_HIGH_PRIORITY (100) /* High-priority handler */
80
81/*
82 * The handle functions will be called with the proc lock held, and should
83 * return with the proc lock dropped.
84 */
85typedef int coredumper_handle_fn(struct thread *, off_t);
86
87struct coredumper {
88 SLIST_ENTRY(coredumper) cd_entry;
89 const char *cd_name;
90 coredumper_probe_fn *cd_probe;
91 coredumper_handle_fn *cd_handle;
92 blockcount_t cd_refcount;
93};
94
95void coredumper_register(struct coredumper *);
96void coredumper_unregister(struct coredumper *);
97
98#endif /* _KERNEL */
99#endif /* _SYS_UCOREDUMP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ucred.h+136-25
......@@ -27,22 +27,36 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ucred.h 8.4 (Berkeley) 1/9/95
3230 */
3331
3432#ifndef _SYS_UCRED_H_
3533#define _SYS_UCRED_H_
3634
35#include <sys/types.h>
3736#if defined(_KERNEL) || defined(_WANT_UCRED)
3837#include <sys/_lock.h>
3938#include <sys/_mutex.h>
4039#endif
4140#include <bsm/audit.h>
4241
43struct loginclass;
42#if defined(_KERNEL) || defined(_WANT_UCRED)
43/*
44 * Flags for cr_flags.
45 */
46#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */
47#define CRED_FLAG_GROUPSET 0x00000002 /* Groups have been set. */
4448
45#define XU_NGROUPS 16
49/*
50 * Number of groups inlined in 'struct ucred'. It must stay reasonably low as
51 * it is also used by some functions to allocate an array of this size on the
52 * stack.
53 */
54#define CRED_SMALLGROUPS_NB 16
55
56struct label;
57struct loginclass;
58struct prison;
59struct uidinfo;
4660
4761/*
4862 * Credentials.
......@@ -57,39 +71,37 @@ struct loginclass;
5771 *
5872 * See "Credential management" comment in kern_prot.c for more information.
5973 */
60#if defined(_KERNEL) || defined(_WANT_UCRED)
6174struct ucred {
6275 struct mtx cr_mtx;
6376 long cr_ref; /* (c) reference count */
6477 u_int cr_users; /* (c) proc + thread using this cred */
6578 u_int cr_flags; /* credential flags */
6679 struct auditinfo_addr cr_audit; /* Audit properties. */
80 int cr_ngroups; /* number of supplementary groups */
6781#define cr_startcopy cr_uid
6882 uid_t cr_uid; /* effective user id */
6983 uid_t cr_ruid; /* real user id */
7084 uid_t cr_svuid; /* saved user id */
71 int cr_ngroups; /* number of groups */
85 gid_t cr_gid; /* effective group id */
7286 gid_t cr_rgid; /* real group id */
7387 gid_t cr_svgid; /* saved group id */
7488 struct uidinfo *cr_uidinfo; /* per euid resource consumption */
7589 struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
7690 struct prison *cr_prison; /* jail(2) */
7791 struct loginclass *cr_loginclass; /* login class */
78 void *cr_pspare2[2]; /* general use 2 */
92 void *cr_pspare2[2]; /* general use 2 */
7993#define cr_endcopy cr_label
8094 struct label *cr_label; /* MAC label */
8195 gid_t *cr_groups; /* groups */
8296 int cr_agroups; /* Available groups */
83 gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */
97 /* storage for small groups */
98 gid_t cr_smallgroups[CRED_SMALLGROUPS_NB];
8499};
85100#define NOCRED ((struct ucred *)0) /* no credential available */
86101#define FSCRED ((struct ucred *)-1) /* filesystem credential */
87102#endif /* _KERNEL || _WANT_UCRED */
88103
89/*
90 * Flags for cr_flags.
91 */
92#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */
104#define XU_NGROUPS 16
93105
94106/*
95107 * This is the external representation of struct ucred.
......@@ -97,8 +109,26 @@ struct ucred {
97109struct xucred {
98110 u_int cr_version; /* structure layout version */
99111 uid_t cr_uid; /* effective user id */
100 short cr_ngroups; /* number of groups */
101 gid_t cr_groups[XU_NGROUPS]; /* groups */
112 short cr_ngroups; /* number of groups (incl. cr_gid). */
113 union {
114 /*
115 * The effective GID has been the first element of cr_groups[]
116 * for historical reasons. It should be accessed using the
117 * 'cr_gid' identifier. Supplementary groups should be accessed
118 * using cr_sgroups[]. Note that 'cr_ngroups' currently
119 * includes the effective GID.
120 *
121 * XXXOC: On the next API change (requires versioning), please
122 * replace this union with a true unaliased field 'cr_gid' and
123 * make sure that cr_groups[]/'cr_ngroups' only account for
124 * supplementary groups.
125 */
126 struct {
127 gid_t cr_gid; /* effective group id */
128 gid_t cr_sgroups[XU_NGROUPS - 1];
129 };
130 gid_t cr_groups[XU_NGROUPS]; /* groups */
131 };
102132 union {
103133 void *_cr_unused1; /* compatibility with old ucred */
104134 pid_t cr_pid;
......@@ -106,17 +136,77 @@ struct xucred {
106136};
107137#define XUCRED_VERSION 0
108138
109/* This can be used for both ucred and xucred structures. */
110#define cr_gid cr_groups[0]
139struct mac;
140/*
141 * Structure to pass as an argument to the setcred() system call.
142 */
143struct setcred {
144 uid_t sc_uid; /* effective user id */
145 uid_t sc_ruid; /* real user id */
146 uid_t sc_svuid; /* saved user id */
147 gid_t sc_gid; /* effective group id */
148 gid_t sc_rgid; /* real group id */
149 gid_t sc_svgid; /* saved group id */
150 u_int sc_pad; /* see 32-bit compat structure */
151 u_int sc_supp_groups_nb; /* number of supplementary groups */
152 gid_t *sc_supp_groups; /* supplementary groups */
153 struct mac *sc_label; /* MAC label */
154};
155/*
156 * Initializer for 'struct setcred' variables.
157 */
158#define SETCRED_INITIALIZER { -1, -1, -1, -1, -1, -1, 0, 0, NULL, NULL }
159
160/*
161 * Flags to setcred().
162 */
163#define SETCREDF_UID (1u << 0)
164#define SETCREDF_RUID (1u << 1)
165#define SETCREDF_SVUID (1u << 2)
166#define SETCREDF_GID (1u << 3)
167#define SETCREDF_RGID (1u << 4)
168#define SETCREDF_SVGID (1u << 5)
169#define SETCREDF_SUPP_GROUPS (1u << 6)
170#define SETCREDF_MAC_LABEL (1u << 7)
111171
112172#ifdef _KERNEL
113struct proc;
173/*
174 * Masks of the currently valid flags to setcred().
175 *
176 * Please consider reserving some of the high bits in the 'flags' argument for
177 * versioning when almost all of them are in use.
178 */
179#define SETCREDF_MASK (SETCREDF_UID | SETCREDF_RUID | SETCREDF_SVUID | \
180 SETCREDF_GID | SETCREDF_RGID | SETCREDF_SVGID | SETCREDF_SUPP_GROUPS | \
181 SETCREDF_MAC_LABEL)
182
183struct setcred32 {
184#define setcred32_copy_start sc_uid
185 uid_t sc_uid;
186 uid_t sc_ruid;
187 uid_t sc_svuid;
188 gid_t sc_gid;
189 gid_t sc_rgid;
190 gid_t sc_svgid;
191 u_int sc_pad;
192 u_int sc_supp_groups_nb;
193#define setcred32_copy_end sc_supp_groups
194 uint32_t sc_supp_groups; /* gid_t [*] */
195 uint32_t sc_label; /* struct mac32 [*] */
196};
197
114198struct thread;
115199
200/* Common native and 32-bit compatibility entry point. */
201int user_setcred(struct thread *td, const u_int flags,
202 const void *const uwcred, const size_t size, bool is_32bit);
203
204struct proc;
205
116206struct credbatch {
117207 struct ucred *cred;
118 int users;
119 int ref;
208 u_int users;
209 long ref;
120210};
121211
122212static inline void
......@@ -146,9 +236,9 @@ void crcopy(struct ucred *dest, struct ucred *src);
146236struct ucred *crcopysafe(struct proc *p, struct ucred *cr);
147237struct ucred *crdup(struct ucred *cr);
148238void crextend(struct ucred *cr, int n);
149void proc_set_cred_init(struct proc *p, struct ucred *cr);
150void proc_set_cred(struct proc *p, struct ucred *cr);
151void proc_unset_cred(struct proc *p);
239void proc_set_cred(struct proc *p, struct ucred *newcred);
240bool proc_set_cred_enforce_proc_lim(struct proc *p, struct ucred *newcred);
241void proc_unset_cred(struct proc *p, bool decrement_proc_count);
152242void crfree(struct ucred *cr);
153243struct ucred *crcowsync(void);
154244struct ucred *crget(void);
......@@ -157,9 +247,30 @@ struct ucred *crcowget(struct ucred *cr);
157247void crcowfree(struct thread *td);
158248void cru2x(struct ucred *cr, struct xucred *xcr);
159249void cru2xt(struct thread *td, struct xucred *xcr);
160void crsetgroups(struct ucred *cr, int n, gid_t *groups);
161bool groupmember(gid_t gid, struct ucred *cred);
162bool realgroupmember(gid_t gid, struct ucred *cred);
250void crsetgroups(struct ucred *cr, int ngrp, const gid_t *groups);
251void crsetgroups_and_egid(struct ucred *cr, int ngrp, const gid_t *groups,
252 const gid_t default_egid);
253bool cr_xids_subset(struct ucred *active_cred, struct ucred *obj_cred);
254
255/*
256 * Returns whether gid designates a primary group in cred.
257 */
258static inline bool
259group_is_primary(const gid_t gid, const struct ucred *const cred)
260{
261 return (gid == cred->cr_groups[0] || gid == cred->cr_rgid ||
262 gid == cred->cr_svgid);
263}
264bool group_is_supplementary(const gid_t gid, const struct ucred *const cred);
265bool groupmember(gid_t gid, const struct ucred *cred);
266bool realgroupmember(gid_t gid, const struct ucred *cred);
267
268#else /* !_KERNEL */
269
270__BEGIN_DECLS
271int setcred(u_int flags, const struct setcred *wcred, size_t size);
272__END_DECLS
273
163274#endif /* _KERNEL */
164275
165276#endif /* !_SYS_UCRED_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/uio.h+6-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)uio.h 8.5 (Berkeley) 2/22/94
3230 */
3331
3432#ifndef _SYS_UIO_H_
......@@ -86,12 +84,14 @@ int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov,
8684int copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop);
8785int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz);
8886int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz);
87void exterr_copyout(struct thread *td);
8988int physcopyin(void *src, vm_paddr_t dst, size_t len);
9089int physcopyout(vm_paddr_t src, void *dst, size_t len);
9190int physcopyin_vlist(struct bus_dma_segment *src, off_t offset,
9291 vm_paddr_t dst, size_t len);
9392int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst,
9493 off_t offset, size_t len);
94void uioadvance(struct uio *, size_t);
9595int uiomove(void *cp, int n, struct uio *uio);
9696int uiomove_frombuf(void *buf, int buflen, struct uio *uio);
9797int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,
......@@ -101,6 +101,10 @@ int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio);
101101
102102#else /* !_KERNEL */
103103
104#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
105#include <ssp/uio.h>
106#endif
107
104108__BEGIN_DECLS
105109ssize_t readv(int, const struct iovec *, int);
106110ssize_t writev(int, const struct iovec *, int);
lib/libc/include/generic-freebsd/sys/umtx.h+1
......@@ -135,6 +135,7 @@ struct umtx_robust_lists_params {
135135__BEGIN_DECLS
136136
137137int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2);
138int _umtx_op_err(void *obj, int op, u_long val, void *uaddr, void *uaddr2);
138139
139140__END_DECLS
140141
lib/libc/include/generic-freebsd/sys/umtxvar.h+1
......@@ -206,6 +206,7 @@ int umtx_key_get(const void *, int, int, struct umtx_key *);
206206void umtx_key_release(struct umtx_key *);
207207struct umtx_q *umtxq_alloc(void);
208208void umtxq_busy(struct umtx_key *);
209void umtxq_busy_unlocked(struct umtx_key *);
209210int umtxq_count(struct umtx_key *);
210211void umtxq_free(struct umtx_q *);
211212struct umtxq_chain *umtxq_getchain(struct umtx_key *);
lib/libc/include/generic-freebsd/sys/un.h-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)un.h 8.3 (Berkeley) 2/19/95
3230 */
3331
3432#ifndef _SYS_UN_H_
......@@ -67,7 +65,6 @@ struct sockaddr_un {
6765#define LOCAL_PEERCRED 1 /* retrieve peer credentials */
6866#define LOCAL_CREDS 2 /* pass credentials to receiver */
6967#define LOCAL_CREDS_PERSISTENT 3 /* pass credentials to receiver */
70#define LOCAL_CONNWAIT 4 /* connects block until accepted */
7168
7269/* Start of reserved space for third-party socket options. */
7370#define LOCAL_VENDOR SO_VENDOR
lib/libc/include/generic-freebsd/sys/unistd.h+17-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)unistd.h 8.2 (Berkeley) 1/7/94
3230 */
3331
3432#ifndef _SYS_UNISTD_H_
......@@ -95,7 +93,7 @@
9593#endif
9694
9795/* Define the POSIX.1 version we target for compliance. */
98#define _POSIX_VERSION 200112L
96#define _POSIX_VERSION 200809L
9997
10098/* access function */
10199#define F_OK 0 /* test for existence of file */
......@@ -156,6 +154,12 @@
156154#define _PC_MAC_PRESENT 63
157155#define _PC_ACL_NFS4 64
158156#define _PC_DEALLOC_PRESENT 65
157#define _PC_NAMEDATTR_ENABLED 66
158#define _PC_HAS_NAMEDATTR 67
159#define _PC_XATTR_ENABLED _PC_NAMEDATTR_ENABLED /* Solaris Compatible */
160#define _PC_XATTR_EXISTS _PC_HAS_NAMEDATTR /* Solaris Compatible */
161#define _PC_HAS_HIDDENSYSTEM 68
162#define _PC_CLONE_BLKSIZE 69
159163#endif
160164
161165/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
......@@ -210,6 +214,16 @@
210214 * close_range() options.
211215 */
212216#define CLOSE_RANGE_CLOEXEC (1<<2)
217#define CLOSE_RANGE_CLOFORK (1<<3)
218
219/*
220 * copy_file_range flags visible to user space.
221 * High order 8 bits reserved for kernel flags.
222 * Allocate from bit 23 down, to try and avoid conflicts with
223 * future Linux flags.
224 */
225#define COPY_FILE_RANGE_CLONE 0x00800000 /* Require cloning. */
226#define COPY_FILE_RANGE_USERFLAGS (COPY_FILE_RANGE_CLONE)
213227
214228#endif /* __BSD_VISIBLE */
215229
lib/libc/include/generic-freebsd/sys/unpcb.h+1-4
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)unpcb.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_UNPCB_H_
......@@ -95,6 +93,7 @@ struct unpcb {
9593 u_int unp_msgcount; /* (g) references from message queue */
9694 u_int unp_gcrefs; /* (g) garbage collector refcount */
9795 ino_t unp_ino; /* (g) fake inode number */
96 mode_t unp_mode; /* (g) initial pre-bind() mode */
9897 LIST_ENTRY(unpcb) unp_dead; /* (g) link in dead list */
9998} __aligned(CACHE_LINE_SIZE);
10099
......@@ -109,8 +108,6 @@ struct unpcb {
109108#define UNP_HAVEPC 0x001
110109#define UNP_WANTCRED_ALWAYS 0x002 /* credentials wanted always */
111110#define UNP_WANTCRED_ONESHOT 0x004 /* credentials wanted once */
112#define UNP_CONNWAIT 0x008 /* connect blocks until accepted */
113
114111#define UNP_WANTCRED_MASK (UNP_WANTCRED_ONESHOT | UNP_WANTCRED_ALWAYS)
115112
116113/*
lib/libc/include/generic-freebsd/sys/user.h+48-7
......@@ -29,8 +29,6 @@
2929 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3030 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3131 * SUCH DAMAGE.
32 *
33 * @(#)user.h 8.2 (Berkeley) 9/23/93
3432 */
3533
3634#ifndef _SYS_USER_H_
......@@ -40,6 +38,7 @@
4038#ifndef _KERNEL
4139/* stuff that *used* to be included by user.h, or is now needed */
4240#include <sys/errno.h>
41#include <sys/event.h>
4342#include <sys/time.h>
4443#include <sys/resource.h>
4544#include <sys/ucred.h>
......@@ -87,7 +86,7 @@
8786 */
8887#define KI_NSPARE_INT 2
8988#define KI_NSPARE_LONG 12
90#define KI_NSPARE_PTR 5
89#define KI_NSPARE_PTR 4
9190
9291#ifndef _KERNEL
9392#ifndef KINFO_PROC_SIZE
......@@ -213,6 +212,7 @@ struct kinfo_proc {
213212 * That way the spare room from both arrays will remain contiguous.
214213 */
215214 struct pwddesc *ki_pd; /* pointer to process paths info */
215 void *ki_uerrmsg; /* address of the ext err msg place */
216216 void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */
217217 long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */
218218 long ki_sflag; /* PS_* flags */
......@@ -227,7 +227,7 @@ void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
227227 * Legacy PS_ flag. This moved to p_flag but is maintained for
228228 * compatibility.
229229 */
230#define PS_INMEM 0x00001 /* Loaded into memory. */
230#define PS_INMEM 0x00001 /* Loaded into memory, always true. */
231231
232232/* ki_sessflag values */
233233#define KI_CTTY 0x00000001 /* controlling tty vnode active */
......@@ -265,6 +265,8 @@ struct user {
265265#define KF_TYPE_DEV 12
266266#define KF_TYPE_EVENTFD 13
267267#define KF_TYPE_TIMERFD 14
268#define KF_TYPE_INOTIFY 15
269#define KF_TYPE_JAILDESC 16
268270#define KF_TYPE_UNKNOWN 255
269271
270272#define KF_VTYPE_VNON 0
......@@ -373,7 +375,7 @@ struct kinfo_file {
373375 struct sockaddr_storage kf_sa_peer;
374376 /* Address of so_pcb. */
375377 uint64_t kf_sock_pcb;
376 /* Address of inp_ppcb. */
378 /* Obsolete! May be reused as a spare. */
377379 uint64_t kf_sock_inpcb;
378380 /* Address of unp_conn. */
379381 uint64_t kf_sock_unpconn;
......@@ -451,11 +453,18 @@ struct kinfo_file {
451453 uint32_t kf_timerfd_flags;
452454 uint64_t kf_timerfd_addr;
453455 } kf_timerfd;
456 struct {
457 int32_t kf_jid;
458 } kf_jail;
454459 struct {
455460 uint64_t kf_kqueue_addr;
456461 int32_t kf_kqueue_count;
457462 int32_t kf_kqueue_state;
458463 } kf_kqueue;
464 struct {
465 uint64_t kf_inotify_npending;
466 uint64_t kf_inotify_nbpending;
467 } kf_inotify;
459468 } kf_un;
460469 };
461470 uint16_t kf_status; /* Status flags. */
......@@ -608,7 +617,8 @@ struct kinfo_vmobject {
608617 } kvo_type_spec; /* Type-specific union */
609618 uint64_t kvo_me; /* Uniq handle for anon obj */
610619 uint64_t kvo_laundry; /* Number of laundry pages. */
611 uint64_t _kvo_qspare[5];
620 uint64_t kvo_wired; /* Number of wired pages. */
621 uint64_t _kvo_qspare[4];
612622 uint32_t kvo_swapped; /* Number of swapped pages */
613623 uint32_t kvo_flags;
614624 uint32_t _kvo_ispare[6];
......@@ -625,7 +635,7 @@ struct kinfo_vmobject {
625635#define KKST_MAXLEN 1024
626636
627637#define KKST_STATE_STACKOK 0 /* Stack is valid. */
628#define KKST_STATE_SWAPPED 1 /* Stack swapped out. */
638#define KKST_STATE_SWAPPED 1 /* Stack swapped out, obsolete. */
629639#define KKST_STATE_RUNNING 2 /* Stack ephemeral. */
630640
631641#if defined(__amd64__) || defined(__i386__)
......@@ -667,6 +677,35 @@ struct kinfo_vm_layout {
667677 uintptr_t kvm_spare[12];
668678};
669679
680#define KNOTE_STATUS_ACTIVE 0x00000001
681#define KNOTE_STATUS_QUEUED 0x00000002
682#define KNOTE_STATUS_DISABLED 0x00000004
683#define KNOTE_STATUS_DETACHED 0x00000008
684#define KNOTE_STATUS_KQUEUE 0x00000010
685
686#define KNOTE_EXTDATA_NONE 0
687#define KNOTE_EXTDATA_VNODE 1
688#define KNOTE_EXTDATA_PIPE 2
689
690struct kinfo_knote {
691 int knt_kq_fd;
692 struct kevent knt_event;
693 int knt_status;
694 int knt_extdata;
695 uint64_t knt_spare0[4];
696 union {
697 struct {
698 int knt_vnode_type;
699 uint64_t knt_vnode_fsid;
700 uint64_t knt_vnode_fileid;
701 char knt_vnode_fullpath[PATH_MAX];
702 } knt_vnode;
703 struct {
704 ino_t knt_pipe_ino;
705 } knt_pipe;
706 };
707};
708
670709#ifdef _KERNEL
671710/* Flags for kern_proc_out function. */
672711#define KERN_PROC_NOTHREADS 0x1
......@@ -694,6 +733,8 @@ int kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen);
694733int kern_proc_out(struct proc *p, struct sbuf *sb, int flags);
695734int kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen,
696735 int flags);
736int kern_proc_kqueues_out(struct proc *p, struct sbuf *s, size_t maxlen,
737 bool compat32);
697738
698739int vntype_to_kinfo(int vtype);
699740void pack_kinfo(struct kinfo_file *kif);
lib/libc/include/generic-freebsd/sys/utsname.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)utsname.h 8.1 (Berkeley) 1/4/94
3533 */
3634
3735#ifndef _SYS_UTSNAME_H
lib/libc/include/generic-freebsd/sys/vmmeter.h+8-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94
3230 */
3331
3432#ifndef _SYS_VMMETER_H_
......@@ -122,6 +120,7 @@ struct vmmeter {
122120 counter_u64_t v_rforkpages; /* (p) pages affected by rfork() */
123121 counter_u64_t v_kthreadpages; /* (p) ... and by kernel fork() */
124122 counter_u64_t v_wire_count; /* (p) pages wired down */
123 counter_u64_t v_nofree_count; /* (p) permanently allocated pages */
125124#define VM_METER_NCOUNTERS \
126125 (offsetof(struct vmmeter, v_page_size) / sizeof(counter_u64_t))
127126 /*
......@@ -176,6 +175,13 @@ vm_wire_count(void)
176175 return (VM_CNT_FETCH(v_wire_count));
177176}
178177
178static inline u_int
179vm_nofree_count(void)
180{
181
182 return (VM_CNT_FETCH(v_nofree_count));
183}
184
179185/*
180186 * Return TRUE if we are under our severe low-free-pages threshold
181187 *
lib/libc/include/generic-freebsd/sys/vnode.h+83-25
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)vnode.h 8.7 (Berkeley) 2/4/94
3230 */
3331
3432#ifndef _SYS_VNODE_H_
......@@ -69,6 +67,11 @@ __enum_uint8_decl(vtype) {
6967 VLASTTYPE = VMARKER,
7068};
7169
70/*
71 * We frequently need to test is something is a device node.
72 */
73#define VTYPE_ISDEV(vtype) ((vtype) == VCHR || (vtype) == VBLK)
74
7275__enum_uint8_decl(vstate) {
7376 VSTATE_UNINITIALIZED,
7477 VSTATE_CONSTRUCTED,
......@@ -88,11 +91,13 @@ enum vgetstate {
8891 * it from v_data. If non-null, this area is freed in getnewvnode().
8992 */
9093
91struct namecache;
9294struct cache_fpl;
95struct inotify_watch;
96struct namecache;
9397
9498struct vpollinfo {
9599 struct mtx vpi_lock; /* lock to protect below */
100 TAILQ_HEAD(, inotify_watch) vpi_inotify; /* list of inotify watchers */
96101 struct selinfo vpi_selinfo; /* identity of poller(s) */
97102 short vpi_events; /* what they are looking for */
98103 short vpi_revents; /* what has happened */
......@@ -134,7 +139,7 @@ struct vnode {
134139 seqc_t v_seqc; /* i modification count */
135140 uint32_t v_nchash; /* u namecache hash */
136141 u_int v_hash;
137 struct vop_vector *v_op; /* u vnode operations vector */
142 const struct vop_vector *v_op; /* u vnode operations vector */
138143 void *v_data; /* u private data for fs */
139144
140145 /*
......@@ -199,6 +204,8 @@ struct vnode {
199204 int v_seqc_users; /* i modifications pending */
200205};
201206
207#define VN_ISDEV(vp) VTYPE_ISDEV((vp)->v_type)
208
202209#ifndef DEBUG_LOCKS
203210#ifdef _LP64
204211/*
......@@ -248,6 +255,11 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");
248255#define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */
249256#define VIRF_TEXT_REF 0x0008 /* Executable mappings ref the vnode */
250257#define VIRF_CROSSMP 0x0010 /* Cross-mp vnode, no locking */
258#define VIRF_NAMEDDIR 0x0020 /* Named attribute directory */
259#define VIRF_NAMEDATTR 0x0040 /* Named attribute */
260#define VIRF_INOTIFY 0x0080 /* This vnode is being watched */
261#define VIRF_INOTIFY_PARENT 0x0100 /* A parent of this vnode may be being
262 watched */
251263
252264#define VI_UNUSED0 0x0001 /* unused */
253265#define VI_MOUNT 0x0002 /* Mount in progress */
......@@ -283,7 +295,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");
283295struct vattr {
284296 __enum_uint8(vtype) va_type; /* vnode type (for create) */
285297 u_short va_mode; /* files access mode and type */
286 u_short va_padding0;
298 uint16_t va_bsdflags; /* same as st_bsdflags from stat(2) */
287299 uid_t va_uid; /* owner user id */
288300 gid_t va_gid; /* owner group id */
289301 nlink_t va_nlink; /* number of references to file */
......@@ -304,6 +316,8 @@ struct vattr {
304316 long va_spare; /* remain quad aligned */
305317};
306318
319#define VATTR_ISDEV(vap) VTYPE_ISDEV((vap)->va_type)
320
307321/*
308322 * Flags for va_vaflags.
309323 */
......@@ -533,7 +547,7 @@ extern struct vnodeop_desc *vnodeop_descs[];
533547#define VOPARG_OFFSETTO(s_type, s_offset, struct_p) \
534548 ((s_type)(((char*)(struct_p)) + (s_offset)))
535549
536#ifdef DEBUG_VFS_LOCKS
550#ifdef INVARIANTS
537551/*
538552 * Support code to aid in debugging VFS locking problems. Not totally
539553 * reliable since if the thread sleeps between changing the lock
......@@ -567,7 +581,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str);
567581 VNPASS(!seqc_in_modify(_vp->v_seqc), _vp); \
568582} while (0)
569583
570#else /* !DEBUG_VFS_LOCKS */
584#else /* !INVARIANTS */
571585
572586#define ASSERT_VI_LOCKED(vp, str) ((void)0)
573587#define ASSERT_VI_UNLOCKED(vp, str) ((void)0)
......@@ -578,7 +592,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str);
578592#define ASSERT_VOP_IN_SEQC(vp) ((void)0)
579593#define ASSERT_VOP_NOT_IN_SEQC(vp) ((void)0)
580594
581#endif /* DEBUG_VFS_LOCKS */
595#endif /* INVARIANTS */
582596
583597/*
584598 * This call works for vnodes in the kernel.
......@@ -667,6 +681,7 @@ char *cache_symlink_alloc(size_t size, int flags);
667681void cache_symlink_free(char *string, size_t size);
668682int cache_symlink_resolve(struct cache_fpl *fpl, const char *string,
669683 size_t len);
684void cache_vop_inotify(struct vnode *vp, int event, uint32_t cookie);
670685void cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,
671686 struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp);
672687void cache_vop_rmdir(struct vnode *dvp, struct vnode *vp);
......@@ -708,6 +723,7 @@ int speedup_syncer(void);
708723int vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen);
709724int vn_getcwd(char *buf, char **retbuf, size_t *buflen);
710725int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf);
726int vn_fullpath_jail(struct vnode *vp, char **retbuf, char **freebuf);
711727int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf);
712728int vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp,
713729 const char *hdrl_name, size_t hrdl_name_length, char **retbuf,
......@@ -836,18 +852,15 @@ void vn_seqc_write_end(struct vnode *vp);
836852#define vn_seqc_consistent(vp, seq) seqc_consistent(&(vp)->v_seqc, seq)
837853
838854#define vn_rangelock_unlock(vp, cookie) \
839 rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp))
840#define vn_rangelock_unlock_range(vp, cookie, start, end) \
841 rangelock_unlock_range(&(vp)->v_rl, (cookie), (start), (end), \
842 VI_MTX(vp))
855 rangelock_unlock(&(vp)->v_rl, (cookie))
843856#define vn_rangelock_rlock(vp, start, end) \
844 rangelock_rlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
857 rangelock_rlock(&(vp)->v_rl, (start), (end))
845858#define vn_rangelock_tryrlock(vp, start, end) \
846 rangelock_tryrlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
859 rangelock_tryrlock(&(vp)->v_rl, (start), (end))
847860#define vn_rangelock_wlock(vp, start, end) \
848 rangelock_wlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
861 rangelock_wlock(&(vp)->v_rl, (start), (end))
849862#define vn_rangelock_trywlock(vp, start, end) \
850 rangelock_trywlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
863 rangelock_trywlock(&(vp)->v_rl, (start), (end))
851864
852865#define vn_irflag_read(vp) atomic_load_short(&(vp)->v_irflag)
853866void vn_irflag_set_locked(struct vnode *vp, short toset);
......@@ -872,8 +885,10 @@ int vop_stdfsync(struct vop_fsync_args *);
872885int vop_stdgetwritemount(struct vop_getwritemount_args *);
873886int vop_stdgetpages(struct vop_getpages_args *);
874887int vop_stdinactive(struct vop_inactive_args *);
875int vop_stdioctl(struct vop_ioctl_args *);
876888int vop_stdneed_inactive(struct vop_need_inactive_args *);
889int vop_stdinotify(struct vop_inotify_args *);
890int vop_stdinotify_add_watch(struct vop_inotify_add_watch_args *);
891int vop_stdioctl(struct vop_ioctl_args *);
877892int vop_stdkqfilter(struct vop_kqfilter_args *);
878893int vop_stdlock(struct vop_lock1_args *);
879894int vop_stdunlock(struct vop_unlock_args *);
......@@ -913,9 +928,12 @@ int dead_read(struct vop_read_args *ap);
913928int dead_write(struct vop_write_args *ap);
914929
915930/* These are called from within the actual VOPS. */
931void vop_allocate_post(void *a, int rc);
932void vop_copy_file_range_post(void *ap, int rc);
916933void vop_close_post(void *a, int rc);
917934void vop_create_pre(void *a);
918935void vop_create_post(void *a, int rc);
936void vop_deallocate_post(void *a, int rc);
919937void vop_whiteout_pre(void *a);
920938void vop_whiteout_post(void *a, int rc);
921939void vop_deleteextattr_pre(void *a);
......@@ -931,7 +949,6 @@ void vop_mknod_post(void *a, int rc);
931949void vop_open_post(void *a, int rc);
932950void vop_read_post(void *a, int rc);
933951void vop_read_pgcache_post(void *ap, int rc);
934void vop_readdir_post(void *a, int rc);
935952void vop_reclaim_post(void *a, int rc);
936953void vop_remove_pre(void *a);
937954void vop_remove_post(void *a, int rc);
......@@ -949,7 +966,7 @@ void vop_symlink_pre(void *a);
949966void vop_symlink_post(void *a, int rc);
950967int vop_sigdefer(struct vop_vector *vop, struct vop_generic_args *a);
951968
952#ifdef DEBUG_VFS_LOCKS
969#ifdef INVARIANTS
953970void vop_fdatasync_debugpre(void *a);
954971void vop_fdatasync_debugpost(void *a, int rc);
955972void vop_fplookup_vexec_debugpre(void *a);
......@@ -991,9 +1008,10 @@ void vop_rename_fail(struct vop_rename_args *ap);
9911008 AUDIT_ARG_VNODE1(ap->a_vp); \
9921009 _error = mac_vnode_check_stat(_ap->a_active_cred, _ap->a_file_cred, _ap->a_vp);\
9931010 if (__predict_true(_error == 0)) { \
994 ap->a_sb->st_padding0 = 0; \
9951011 ap->a_sb->st_padding1 = 0; \
9961012 bzero(_ap->a_sb->st_spare, sizeof(_ap->a_sb->st_spare)); \
1013 ap->a_sb->st_filerev = 0; \
1014 ap->a_sb->st_bsdflags = 0; \
9971015 } \
9981016 _error; \
9991017})
......@@ -1006,7 +1024,36 @@ void vop_rename_fail(struct vop_rename_args *ap);
10061024 _error; \
10071025})
10081026
1009#define VOP_WRITE_PRE(ap) \
1027#ifdef INVARIANTS
1028#define vop_readdir_pre_assert(ap) \
1029 ssize_t nresid, oresid; \
1030 \
1031 oresid = (ap)->a_uio->uio_resid;
1032
1033#define vop_readdir_post_assert(ap, ret) \
1034 nresid = (ap)->a_uio->uio_resid; \
1035 if ((ret) == 0 && (ap)->a_eofflag != NULL) { \
1036 VNASSERT(oresid == 0 || nresid != oresid || \
1037 *(ap)->a_eofflag == 1, \
1038 (ap)->a_vp, ("VOP_READDIR: eofflag not set")); \
1039 }
1040#else
1041#define vop_readdir_pre_assert(ap)
1042#define vop_readdir_post_assert(ap, ret)
1043#endif
1044
1045#define vop_readdir_pre(ap) do { \
1046 vop_readdir_pre_assert(ap)
1047
1048#define vop_readdir_post(ap, ret) \
1049 vop_readdir_post_assert(ap, ret); \
1050 if ((ret) == 0) { \
1051 VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_READ); \
1052 INOTIFY((ap)->a_vp, IN_ACCESS); \
1053 } \
1054} while (0)
1055
1056#define vop_write_pre(ap) \
10101057 struct vattr va; \
10111058 int error; \
10121059 off_t osize, ooffset, noffset; \
......@@ -1020,11 +1067,14 @@ void vop_rename_fail(struct vop_rename_args *ap);
10201067 osize = (off_t)va.va_size; \
10211068 }
10221069
1023#define VOP_WRITE_POST(ap, ret) \
1070#define vop_write_post(ap, ret) \
10241071 noffset = (ap)->a_uio->uio_offset; \
1025 if (noffset > ooffset && !VN_KNLIST_EMPTY((ap)->a_vp)) { \
1026 VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE \
1027 | (noffset > osize ? NOTE_EXTEND : 0)); \
1072 if (noffset > ooffset) { \
1073 if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \
1074 VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \
1075 (noffset > osize ? NOTE_EXTEND : 0)); \
1076 } \
1077 INOTIFY((ap)->a_vp, IN_MODIFY); \
10281078 }
10291079
10301080#define VOP_LOCK(vp, flags) VOP_LOCK1(vp, flags, __FILE__, __LINE__)
......@@ -1084,7 +1134,14 @@ vrefcnt(struct vnode *vp)
10841134 vref(vp); \
10851135} while (0)
10861136
1137/*
1138 * The caller doesn't know the file size and vnode_create_vobject() should
1139 * determine the size on its own.
1140 */
1141#define VNODE_NO_SIZE ((off_t)-1)
1142
10871143int vnode_create_vobject(struct vnode *vp, off_t size, struct thread *td);
1144int vnode_create_disk_vobject(struct vnode *vp, off_t size, struct thread *td);
10881145void vnode_destroy_vobject(struct vnode *vp);
10891146
10901147extern struct vop_vector fifo_specops;
......@@ -1190,6 +1247,7 @@ vn_get_state(struct vnode *vp)
11901247#define vfs_smr_exit() smr_exit(VFS_SMR())
11911248#define vfs_smr_synchronize() smr_synchronize(VFS_SMR())
11921249#define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR())
1250#define VFS_SMR_ENTERED() SMR_ENTERED(VFS_SMR())
11931251#define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR())
11941252#define VFS_SMR_ASSERT_NOT_ENTERED() SMR_ASSERT_NOT_ENTERED(VFS_SMR())
11951253#define VFS_SMR_ZONE_SET(zone) uma_zone_set_smr((zone), VFS_SMR())
lib/libc/include/generic-freebsd/sys/wait.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)wait.h 8.2 (Berkeley) 7/10/94
3230 */
3331
3432#ifndef _SYS_WAIT_H_
lib/libc/include/generic-freebsd/sys/watchdog.h+19-6
......@@ -32,15 +32,16 @@
3232#define _SYS_WATCHDOG_H
3333
3434#include <sys/ioccom.h>
35#include <sys/_types.h>
3536
3637#define _PATH_WATCHDOG "fido"
3738
38#define WDIOCPATPAT _IOW('W', 42, u_int) /* pat the watchdog */
39#define WDIOC_SETTIMEOUT _IOW('W', 43, int) /* set/reset the timer */
40#define WDIOC_GETTIMEOUT _IOR('W', 44, int) /* get total timeout */
41#define WDIOC_GETTIMELEFT _IOR('W', 45, int) /* get time left */
42#define WDIOC_GETPRETIMEOUT _IOR('W', 46, int) /* get the pre-timeout */
43#define WDIOC_SETPRETIMEOUT _IOW('W', 47, int) /* set the pre-timeout */
39#define WDIOC_PATPAT _IOW('W', 52, sbintime_t) /* pat the watchdog */
40#define WDIOC_SETTIMEOUT _IOW('W', 53, sbintime_t) /* set/reset the timer */
41#define WDIOC_GETTIMEOUT _IOR('W', 54, sbintime_t) /* get total timeout */
42#define WDIOC_GETTIMELEFT _IOR('W', 55, sbintime_t) /* get time left */
43#define WDIOC_GETPRETIMEOUT _IOR('W', 56, sbintime_t) /* get the pre-timeout */
44#define WDIOC_SETPRETIMEOUT _IOW('W', 57, sbintime_t) /* set the pre-timeout */
4445/* set the action when a pre-timeout occurs see: WD_SOFT_* */
4546#define WDIOC_SETPRETIMEOUTACT _IOW('W', 48, int)
4647
......@@ -48,6 +49,8 @@
4849#define WDIOC_SETSOFT _IOW('W', 49, int)
4950#define WDIOC_SETSOFTTIMEOUTACT _IOW('W', 50, int)
5051
52#define WDIOC_CONTROL _IOW('W', 51, int) /* configure watchdog */
53
5154#define WD_ACTIVE 0x8000000
5255 /*
5356 * Watchdog reset, timeout set to value in WD_INTERVAL field.
......@@ -93,6 +96,11 @@
9396#define WD_TO_64SEC 36
9497#define WD_TO_128SEC 37
9598
99/* Control options for WDIOC_CONTROL */
100#define WD_CTRL_DISABLE 0x00000000
101#define WD_CTRL_ENABLE 0x00000001
102#define WD_CTRL_RESET 0x00000002
103
96104/* action on pre-timeout trigger */
97105#define WD_SOFT_PANIC 0x01 /* panic */
98106#define WD_SOFT_DDB 0x02 /* enter debugger */
......@@ -105,11 +113,16 @@
105113#include <sys/_eventhandler.h>
106114
107115typedef void (*watchdog_fn)(void *, u_int, int *);
116typedef void (*watchdog_sbt_fn)(void *, sbintime_t, sbintime_t *, int *);
108117
109118EVENTHANDLER_DECLARE(watchdog_list, watchdog_fn);
119EVENTHANDLER_DECLARE(watchdog_sbt_list, watchdog_sbt_fn);
110120
111121u_int wdog_kern_last_timeout(void);
112122int wdog_kern_pat(u_int utim);
123sbintime_t wdog_kern_last_timeout_sbt(void);
124int wdog_kern_pat_sbt(sbintime_t utim);
125int wdog_control(int ctrl);
113126
114127/*
115128 * The following function pointer is used to attach a software watchdog
lib/libc/include/generic-freebsd/sysexits.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)sysexits.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYSEXITS_H_
lib/libc/include/generic-freebsd/syslog.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)syslog.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _SYS_SYSLOG_H_
lib/libc/include/generic-freebsd/tar.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)tar.h 8.2 (Berkeley) 1/4/94
3533 */
3634
3735#ifndef _TAR_H
lib/libc/include/generic-freebsd/teken/teken.h deleted-220
......@@ -1,220 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _TEKEN_H_
30#define _TEKEN_H_
31
32#include <sys/types.h>
33
34/*
35 * libteken: terminal emulation library.
36 *
37 * This library converts an UTF-8 stream of bytes to terminal drawing
38 * commands.
39 */
40
41typedef uint32_t teken_char_t;
42typedef unsigned short teken_unit_t;
43typedef unsigned char teken_format_t;
44#define TF_BOLD 0x01 /* Bold character. */
45#define TF_UNDERLINE 0x02 /* Underline character. */
46#define TF_BLINK 0x04 /* Blinking character. */
47#define TF_REVERSE 0x08 /* Reverse rendered character. */
48#define TF_CJK_RIGHT 0x10 /* Right-hand side of CJK character. */
49#define TF_IMAGE 0x20 /* This character space has image. */
50typedef unsigned char teken_color_t;
51#define TC_BLACK 0
52#define TC_RED 1
53#define TC_GREEN 2
54#define TC_YELLOW 3
55#define TC_BLUE 4
56#define TC_MAGENTA 5
57#define TC_CYAN 6
58#define TC_WHITE 7
59#define TC_NCOLORS 8
60#define TC_LIGHT 8 /* ORed with the others. */
61
62typedef struct {
63 teken_unit_t tp_row;
64 teken_unit_t tp_col;
65} teken_pos_t;
66typedef struct {
67 teken_pos_t tr_begin;
68 teken_pos_t tr_end;
69} teken_rect_t;
70typedef struct {
71 teken_format_t ta_format;
72 teken_color_t ta_fgcolor;
73 teken_color_t ta_bgcolor;
74} teken_attr_t;
75typedef struct {
76 teken_unit_t ts_begin;
77 teken_unit_t ts_end;
78} teken_span_t;
79
80typedef struct __teken teken_t;
81
82typedef void teken_state_t(teken_t *, teken_char_t);
83
84/*
85 * Drawing routines supplied by the user.
86 */
87
88typedef void tf_bell_t(void *);
89typedef void tf_cursor_t(void *, const teken_pos_t *);
90typedef void tf_putchar_t(void *, const teken_pos_t *, teken_char_t,
91 const teken_attr_t *);
92typedef void tf_fill_t(void *, const teken_rect_t *, teken_char_t,
93 const teken_attr_t *);
94typedef void tf_copy_t(void *, const teken_rect_t *, const teken_pos_t *);
95typedef void tf_pre_input_t(void *);
96typedef void tf_post_input_t(void *);
97typedef void tf_param_t(void *, int, unsigned int);
98#define TP_SHOWCURSOR 0
99#define TP_KEYPADAPP 1
100#define TP_AUTOREPEAT 2
101#define TP_SWITCHVT 3
102#define TP_132COLS 4
103#define TP_SETBELLPD 5
104#define TP_SETBELLPD_PITCH(pd) ((pd) >> 16)
105#define TP_SETBELLPD_DURATION(pd) ((pd) & 0xffff)
106#define TP_MOUSE 6
107#define TP_SETBORDER 7
108#define TP_SETLOCALCURSOR 8
109#define TP_SETGLOBALCURSOR 9
110typedef void tf_respond_t(void *, const void *, size_t);
111
112typedef struct {
113 tf_bell_t *tf_bell;
114 tf_cursor_t *tf_cursor;
115 tf_putchar_t *tf_putchar;
116 tf_fill_t *tf_fill;
117 tf_copy_t *tf_copy;
118 tf_pre_input_t *tf_pre_input;
119 tf_post_input_t *tf_post_input;
120 tf_param_t *tf_param;
121 tf_respond_t *tf_respond;
122} teken_funcs_t;
123
124typedef teken_char_t teken_scs_t(const teken_t *, teken_char_t);
125
126/*
127 * Terminal state.
128 */
129
130struct __teken {
131 const teken_funcs_t *t_funcs;
132 void *t_softc;
133
134 teken_state_t *t_nextstate;
135 unsigned int t_stateflags;
136
137#define T_NUMSIZE 8
138 unsigned int t_nums[T_NUMSIZE];
139 unsigned int t_curnum;
140
141 teken_pos_t t_cursor;
142 teken_attr_t t_curattr;
143 teken_pos_t t_saved_cursor;
144 teken_attr_t t_saved_curattr;
145
146 teken_attr_t t_defattr;
147 teken_pos_t t_winsize;
148
149 /* For DECSTBM. */
150 teken_span_t t_scrollreg;
151 /* For DECOM. */
152 teken_span_t t_originreg;
153
154#define T_NUMCOL 160
155 unsigned int t_tabstops[T_NUMCOL / (sizeof(unsigned int) * 8)];
156
157 unsigned int t_utf8_left;
158 teken_char_t t_utf8_partial;
159 teken_char_t t_last;
160
161 unsigned int t_curscs;
162 teken_scs_t *t_saved_curscs;
163 teken_scs_t *t_scs[2];
164};
165
166/* Initialize teken structure. */
167void teken_init(teken_t *, const teken_funcs_t *, void *);
168
169/* Deliver character input. */
170void teken_input(teken_t *, const void *, size_t);
171
172/* Get/set teken attributes. */
173const teken_pos_t *teken_get_cursor(const teken_t *);
174const teken_attr_t *teken_get_curattr(const teken_t *);
175const teken_attr_t *teken_get_defattr(const teken_t *);
176void teken_get_defattr_cons25(const teken_t *, int *, int *);
177const teken_pos_t *teken_get_winsize(const teken_t *);
178void teken_set_cursor(teken_t *, const teken_pos_t *);
179void teken_set_curattr(teken_t *, const teken_attr_t *);
180void teken_set_defattr(teken_t *, const teken_attr_t *);
181void teken_set_winsize(teken_t *, const teken_pos_t *);
182void teken_set_winsize_noreset(teken_t *, const teken_pos_t *);
183
184/* Key input escape sequences. */
185#define TKEY_UP 0x00
186#define TKEY_DOWN 0x01
187#define TKEY_LEFT 0x02
188#define TKEY_RIGHT 0x03
189
190#define TKEY_HOME 0x04
191#define TKEY_END 0x05
192#define TKEY_INSERT 0x06
193#define TKEY_DELETE 0x07
194#define TKEY_PAGE_UP 0x08
195#define TKEY_PAGE_DOWN 0x09
196
197#define TKEY_F1 0x0a
198#define TKEY_F2 0x0b
199#define TKEY_F3 0x0c
200#define TKEY_F4 0x0d
201#define TKEY_F5 0x0e
202#define TKEY_F6 0x0f
203#define TKEY_F7 0x10
204#define TKEY_F8 0x11
205#define TKEY_F9 0x12
206#define TKEY_F10 0x13
207#define TKEY_F11 0x14
208#define TKEY_F12 0x15
209const char *teken_get_sequence(const teken_t *, unsigned int);
210
211/* Legacy features. */
212void teken_set_8bit(teken_t *);
213void teken_set_cons25(teken_t *);
214void teken_set_cons25keys(teken_t *);
215
216/* Color conversion. */
217teken_color_t teken_256to16(teken_color_t);
218teken_color_t teken_256to8(teken_color_t);
219
220#endif /* !_TEKEN_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/termios.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)termios.h 8.3 (Berkeley) 3/28/94
3230 */
3331
3432#ifndef _TERMIOS_H_
lib/libc/include/generic-freebsd/time.h+6-3
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
3735 */
3836
3937/*
......@@ -157,6 +155,8 @@ int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
157155#if __POSIX_VISIBLE >= 199506
158156char *asctime_r(const struct tm *, char *);
159157char *ctime_r(const time_t *, char *);
158#endif
159#if __POSIX_VISIBLE >= 199506 || __ISO_C_VISIBLE >= 2023
160160struct tm *gmtime_r(const time_t *, struct tm *);
161161struct tm *localtime_r(const time_t *, struct tm *);
162162#endif
......@@ -164,15 +164,18 @@ struct tm *localtime_r(const time_t *, struct tm *);
164164#if __XSI_VISIBLE
165165char *strptime(const char * __restrict, const char * __restrict,
166166 struct tm * __restrict);
167extern long timezone;
168extern int daylight;
167169#endif
168170
169171#if __BSD_VISIBLE
170char *timezone(int, int); /* XXX XSI conflict */
171172time_t timelocal(struct tm * const);
172173time_t timegm(struct tm * const);
173174int timer_oshandle_np(timer_t timerid);
174175time_t time2posix(time_t t);
175176time_t posix2time(time_t t);
177struct tm *offtime(const time_t *, long);
178struct tm *offtime_r(const time_t *__restrict, long, struct tm *__restrict);
176179#endif /* __BSD_VISIBLE */
177180
178181#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
lib/libc/include/generic-freebsd/timeconv.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
3735 */
3836
3937/*
lib/libc/include/generic-freebsd/ttyent.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ttyent.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _TTYENT_H_
lib/libc/include/generic-freebsd/ufs/ffs/ffs_extern.h+2-3
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95
3230 */
3331
3432#ifndef _UFS_FFS_EXTERN_H
......@@ -84,7 +82,8 @@ int ffs_inotovp(struct mount *, ino_t, uint64_t, int, struct vnode **,
8482 int);
8583int ffs_isblock(struct fs *, uint8_t *, ufs1_daddr_t);
8684int ffs_isfreeblock(struct fs *, uint8_t *, ufs1_daddr_t);
87void ffs_oldfscompat_write(struct fs *, struct ufsmount *);
85void ffs_oldfscompat_write(struct fs *);
86bool ffs_oldfscompat_inode_read(struct fs *, union dinodep, time_t);
8887int ffs_own_mount(const struct mount *mp);
8988int ffs_sbsearch(void *, struct fs **, int, struct malloc_type *,
9089 int (*)(void *, off_t, void **, int));
lib/libc/include/generic-freebsd/ufs/ffs/fs.h+3-4
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)fs.h 8.13 (Berkeley) 3/21/95
3230 */
3331
3432#ifndef _UFS_FFS_FS_H_
......@@ -413,7 +411,8 @@ struct fs {
413411 int64_t fs_unrefs; /* number of unreferenced inodes */
414412 int64_t fs_providersize; /* size of underlying GEOM provider */
415413 int64_t fs_metaspace; /* size of area reserved for metadata */
416 int64_t fs_sparecon64[13]; /* old rotation block list head */
414 uint64_t fs_save_maxfilesize; /* save old UFS1 maxfilesize */
415 int64_t fs_sparecon64[12]; /* old rotation block list head */
417416 int64_t fs_sblockactualloc; /* byte offset of this superblock */
418417 int64_t fs_sblockloc; /* byte offset of standard superblock */
419418 struct csum_total fs_cstotal; /* (u) cylinder summary information */
......@@ -426,7 +425,7 @@ struct fs {
426425 uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
427426 uint32_t fs_avgfilesize; /* expected average file size */
428427 uint32_t fs_avgfpdir; /* expected # of files per directory */
429 int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */
428 uint32_t fs_available_spare; /* old scratch space */
430429 ufs_time_t fs_mtime; /* Last mount or fsck time. */
431430 int32_t fs_sujfree; /* SUJ free list */
432431 int32_t fs_sparecon32[21]; /* reserved for future constants */
lib/libc/include/generic-freebsd/ufs/ffs/softdep.h-2
......@@ -36,8 +36,6 @@
3636 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3737 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3838 * SUCH DAMAGE.
39 *
40 * @(#)softdep.h 9.7 (McKusick) 6/21/00
4139 */
4240
4341#include <sys/queue.h>
lib/libc/include/generic-freebsd/ufs/ufs/dinode.h+20-8
......@@ -62,8 +62,6 @@
6262 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6363 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6464 * SUCH DAMAGE.
65 *
66 * @(#)dinode.h 8.3 (Berkeley) 1/21/94
6765 */
6866
6967#ifndef _UFS_UFS_DINODE_H_
......@@ -113,12 +111,13 @@ typedef int64_t ufs_time_t;
113111#define IFWHT 0160000 /* Whiteout. */
114112
115113/*
116 * A dinode contains all the meta-data associated with a UFS2 file.
117 * This structure defines the on-disk format of a dinode. Since
114 * Each UFS filesystem version defines the on-disk format of its dinode.
115 *
116 * A UFS2 dinode contains all the meta-data associated with a UFS2 file.
117 * This structure defines the on-disk format of a UFS2 dinode. Since
118118 * this structure describes an on-disk structure, all its fields
119119 * are defined by types with precise widths.
120120 */
121
122121#define UFS_NXADDR 2 /* External addresses in inode. */
123122#define UFS_NDADDR 12 /* Direct addresses in inode. */
124123#define UFS_NIADDR 3 /* Indirect addresses in inode. */
......@@ -186,11 +185,11 @@ struct ufs1_dinode {
186185 uint32_t di_dirdepth; /* 4: IFDIR: depth from root dir */
187186 };
188187 uint64_t di_size; /* 8: File byte count. */
189 int32_t di_atime; /* 16: Last access time. */
188 uint32_t di_atime; /* 16: Last access time. */
190189 int32_t di_atimensec; /* 20: Last access time. */
191 int32_t di_mtime; /* 24: Last modified time. */
190 uint32_t di_mtime; /* 24: Last modified time. */
192191 int32_t di_mtimensec; /* 28: Last modified time. */
193 int32_t di_ctime; /* 32: Last inode change time. */
192 uint32_t di_ctime; /* 32: Last inode change time. */
194193 int32_t di_ctimensec; /* 36: Last inode change time. */
195194 union {
196195 struct {
......@@ -212,4 +211,17 @@ struct ufs1_dinode {
212211
213212#define UFS_LINK_MAX 65500 /* leave a few spare for special values */
214213
214/*
215 * These structures hold or reference an on-disk dinode.
216 */
217union dinode {
218 struct ufs1_dinode dp1;
219 struct ufs2_dinode dp2;
220};
221
222union dinodep {
223 struct ufs1_dinode *dp1;
224 struct ufs2_dinode *dp2;
225};
226
215227#endif /* _UFS_UFS_DINODE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/ufs/ufs/dir.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)dir.h 8.2 (Berkeley) 1/21/94
3735 */
3836
3937#ifndef _UFS_UFS_DIR_H_
lib/libc/include/generic-freebsd/ufs/ufs/inode.h+3-8
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)inode.h 8.9 (Berkeley) 5/14/95
3735 */
3836
3937#ifndef _UFS_UFS_INODE_H_
......@@ -90,10 +88,7 @@ struct inode {
9088 /*
9189 * The real copy of the on-disk inode.
9290 */
93 union {
94 struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */
95 struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */
96 } dinode_u;
91 union dinodep i_dp; /* On-disk dinode */
9792
9893 ino_t i_number; /* The identity of the inode. */
9994 uint32_t i_flag; /* flags, see below */
......@@ -206,8 +201,8 @@ struct inode {
206201
207202#define i_dirhash i_un.dirhash
208203#define i_snapblklist i_un.snapblklist
209#define i_din1 dinode_u.din1
210#define i_din2 dinode_u.din2
204#define i_din1 i_dp.dp1
205#define i_din2 i_dp.dp2
211206
212207#define ITOUMP(ip) ((ip)->i_ump)
213208#define ITODEV(ip) (ITOUMP(ip)->um_dev)
lib/libc/include/generic-freebsd/ufs/ufs/quota.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * @(#)quota.h 8.3 (Berkeley) 8/19/94
3533 */
3634
3735#ifndef _UFS_UFS_QUOTA_H_
lib/libc/include/generic-freebsd/ufs/ufs/ufs_extern.h+5-7
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95
3230 */
3331
3432#ifndef _UFS_UFS_EXTERN_H_
......@@ -61,15 +59,15 @@ int ufs_bmap_seekdata(struct vnode *, off_t *);
6159int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *);
6260void ufs_dirbad(struct inode *, doff_t, char *);
6361int ufs_dirbadentry(struct vnode *, struct direct *, int);
64int ufs_dirempty(struct inode *, ino_t, struct ucred *);
62int ufs_dirempty(struct inode *, ino_t, struct ucred *, int);
6563int ufs_extread(struct vop_read_args *);
6664int ufs_extwrite(struct vop_write_args *);
6765void ufs_makedirentry(struct inode *, struct componentname *,
6866 struct direct *);
6967int ufs_direnter(struct vnode *, struct vnode *, struct direct *,
7068 struct componentname *, struct buf *);
71int ufs_dirremove(struct vnode *, struct inode *, int, int);
72int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, int);
69int ufs_dirremove(struct vnode *, struct inode *, int, bool);
70int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, u_int);
7371int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *,
7472 ino_t *);
7573int ufs_getlbns(struct vnode *, ufs2_daddr_t, struct indir *, int *);
......@@ -95,9 +93,9 @@ int softdep_setup_directory_add(struct buf *, struct inode *, off_t,
9593 ino_t, struct buf *, int);
9694void softdep_change_directoryentry_offset(struct buf *, struct inode *,
9795 caddr_t, caddr_t, caddr_t, int);
98void softdep_setup_remove(struct buf *,struct inode *, struct inode *, int);
96void softdep_setup_remove(struct buf *,struct inode *, struct inode *, bool);
9997void softdep_setup_directory_change(struct buf *, struct inode *,
100 struct inode *, ino_t, int);
98 struct inode *, ino_t, u_int);
10199void softdep_change_linkcnt(struct inode *);
102100int softdep_slowdown(struct vnode *);
103101void softdep_setup_create(struct inode *, struct inode *);
lib/libc/include/generic-freebsd/ufs/ufs/ufsmount.h-4
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95
3230 */
3331
3432#ifndef _UFS_UFS_UFSMOUNT_H_
......@@ -99,8 +97,6 @@ struct ufsmount {
9997 uint64_t um_maxsymlinklen; /* (c) max size of short
10098 symlink */
10199 struct mtx um_lock; /* (c) Protects ufsmount & fs */
102 struct sx um_checkpath_lock; /* (c) Protects ufs_checkpath()
103 result */
104100 struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */
105101 struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */
106102 struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */
lib/libc/include/generic-freebsd/unistd.h+10-3
......@@ -27,19 +27,20 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
3230 */
3331
3432#ifndef _UNISTD_H_
3533#define _UNISTD_H_
3634
37#include <sys/cdefs.h>
3835#include <sys/types.h> /* XXX adds too much pollution. */
3936#include <sys/unistd.h>
4037#include <sys/_null.h>
4138#include <sys/_types.h>
4239
40#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
41#include <ssp/unistd.h>
42#endif
43
4344#ifndef _GID_T_DECLARED
4445typedef __gid_t gid_t;
4546#define _GID_T_DECLARED
......@@ -291,6 +292,11 @@ typedef __useconds_t useconds_t;
291292#define _SC_NPROCESSORS_CONF 57
292293#define _SC_NPROCESSORS_ONLN 58
293294#define _SC_CPUSET_SIZE 122
295#define _SC_UEXTERR_MAXLEN 123 /* user */
296#endif
297
298#if __POSIX_VISIBLE >= 202405
299#define _SC_NSIG 124
294300#endif
295301
296302/* Extensions found in Solaris and Linux. */
......@@ -506,6 +512,7 @@ int exect(const char *, char * const *, char * const *);
506512int execvP(const char *, const char *, char * const *);
507513int execvpe(const char *, char * const *, char * const *);
508514int feature_present(const char *);
515int fchroot(int);
509516char *fflagstostr(u_long);
510517int getdomainname(char *, int);
511518int getentropy(void *, size_t);
lib/libc/include/generic-freebsd/utime.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)utime.h 8.1 (Berkeley) 6/2/93
3230 */
3331
3432#ifndef _UTIME_H_
lib/libc/include/generic-freebsd/vm/_vm_radix.h+3-6
......@@ -31,16 +31,13 @@
3131#ifndef __VM_RADIX_H_
3232#define __VM_RADIX_H_
3333
34/*
35 * Radix tree node.
36 */
37struct vm_radix_node;
34#include <sys/_pctrie.h>
3835
3936/*
40 * Radix tree root.
37 * Radix tree
4138 */
4239struct vm_radix {
43 struct vm_radix_node *rt_root;
40 struct pctrie rt_trie;
4441};
4542
4643#endif /* !__VM_RADIX_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/vm/pmap.h+8-10
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)pmap.h 8.1 (Berkeley) 6/11/93
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -83,8 +81,8 @@ typedef struct pmap_statistics *pmap_statistics_t;
8381 * Each machine-dependent implementation is required to provide:
8482 *
8583 * vm_memattr_t pmap_page_get_memattr(vm_page_t);
86 * boolean_t pmap_page_is_mapped(vm_page_t);
87 * boolean_t pmap_page_is_write_mapped(vm_page_t);
84 * bool pmap_page_is_mapped(vm_page_t);
85 * bool pmap_page_is_write_mapped(vm_page_t);
8886 * void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
8987 */
9088#include <machine/pmap.h>
......@@ -138,17 +136,17 @@ void pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m,
138136vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va);
139137vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va,
140138 vm_prot_t prot);
141void pmap_growkernel(vm_offset_t);
139int pmap_growkernel(vm_offset_t);
142140void pmap_init(void);
143boolean_t pmap_is_modified(vm_page_t m);
144boolean_t pmap_is_prefaultable(pmap_t pmap, vm_offset_t va);
145boolean_t pmap_is_referenced(vm_page_t m);
146boolean_t pmap_is_valid_memattr(pmap_t, vm_memattr_t);
141bool pmap_is_modified(vm_page_t m);
142bool pmap_is_prefaultable(pmap_t pmap, vm_offset_t va);
143bool pmap_is_referenced(vm_page_t m);
144bool pmap_is_valid_memattr(pmap_t, vm_memattr_t);
147145vm_offset_t pmap_map(vm_offset_t *, vm_paddr_t, vm_paddr_t, int);
148146int pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *pap);
149147void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr,
150148 vm_object_t object, vm_pindex_t pindex, vm_size_t size);
151boolean_t pmap_page_exists_quick(pmap_t pmap, vm_page_t m);
149bool pmap_page_exists_quick(pmap_t pmap, vm_page_t m);
152150void pmap_page_init(vm_page_t m);
153151int pmap_page_wired_mappings(vm_page_t m);
154152int pmap_pinit(pmap_t);
lib/libc/include/generic-freebsd/vm/swap_pager.h+4-3
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)swap_pager.h 7.1 (Berkeley) 12/5/90
3735 */
3836
3937#ifndef _VM_SWAP_PAGER_H_
......@@ -70,13 +68,16 @@ struct swdevt {
7068
7169#ifdef _KERNEL
7270
71extern bool swap_pager_almost_full;
7372extern int swap_pager_avail;
7473extern int nsw_cluster_max;
7574
7675struct xswdev;
7776int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len);
7877void swap_pager_copy(vm_object_t, vm_object_t, vm_pindex_t, int);
79vm_pindex_t swap_pager_find_least(vm_object_t object, vm_pindex_t pindex);
78bool swap_pager_scan_all_shadowed(vm_object_t object);
79vm_pindex_t swap_pager_seek_data(vm_object_t object, vm_pindex_t pindex);
80vm_pindex_t swap_pager_seek_hole(vm_object_t object, vm_pindex_t pindex);
8081void swap_pager_freespace(vm_object_t object, vm_pindex_t start,
8182 vm_size_t size, vm_size_t *freed);
8283void swap_pager_swap_init(void);
lib/libc/include/generic-freebsd/vm/uma.h+1
......@@ -252,6 +252,7 @@ uma_zone_t uma_zcache_create(const char *name, int size, uma_ctor ctor,
252252#define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */
253253#define UMA_ZONE_NOBUCKET 0x0400 /* Do not use buckets. */
254254#define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets. */
255#define UMA_ZONE_NOTRIM 0x1000 /* Don't trim this zone */
255256#define UMA_ZONE_CACHESPREAD 0x2000 /*
256257 * Spread memory start locations across
257258 * all possible cache lines. May
lib/libc/include/generic-freebsd/vm/vm.h+7-5
......@@ -28,10 +28,6 @@
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
3030 *
31 * @(#)vm.h 8.2 (Berkeley) 12/13/93
32 * @(#)vm_prot.h 8.1 (Berkeley) 6/11/93
33 * @(#)vm_inherit.h 8.1 (Berkeley) 6/11/93
34 *
3531 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3632 * All rights reserved.
3733 *
......@@ -80,6 +76,7 @@ typedef u_char vm_prot_t; /* protection codes */
8076#define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */
8177#define VM_PROT_PRIV_FLAG ((vm_prot_t) 0x10)
8278#define VM_PROT_FAULT_LOOKUP VM_PROT_PRIV_FLAG
79#define VM_PROT_NO_PROMOTE VM_PROT_PRIV_FLAG
8380#define VM_PROT_QUICK_NOFAULT VM_PROT_PRIV_FLAG /* same to save bits */
8481
8582#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
......@@ -158,6 +155,12 @@ struct kva_md_info {
158155#define SWAP_RESERVE_RLIMIT_ON (1 << 1)
159156#define SWAP_RESERVE_ALLOW_NONWIRED (1 << 2)
160157
158#ifdef NUMA
159#define __numa_used
160#else
161#define __numa_used __unused
162#endif
163
161164#ifdef _KERNEL
162165struct ucred;
163166
......@@ -167,7 +170,6 @@ bool swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred);
167170void swap_reserve_force(vm_ooffset_t incr);
168171void swap_release(vm_ooffset_t decr);
169172void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);
170void swapper(void);
171173
172174extern struct kva_md_info kmi;
173175#define VA_IS_CLEANMAP(va) \
lib/libc/include/generic-freebsd/vm/vm_domainset.h+13-5
......@@ -28,25 +28,33 @@
2828#ifndef __VM_DOMAINSET_H__
2929#define __VM_DOMAINSET_H__
3030
31struct pctrie_iter;
32
3133struct vm_domainset_iter {
3234 struct domainset *di_domain;
3335 unsigned int *di_iter;
36 /* Initialized from 'di_domain', initial value after reset. */
37 domainset_t di_valid_mask;
38 /* Domains to browse in the current phase. */
39 domainset_t di_remain_mask;
40 /* Domains skipped in phase 1 because under 'v_free_min'. */
41 domainset_t di_min_mask;
3442 vm_pindex_t di_offset;
3543 int di_flags;
3644 uint16_t di_policy;
37 domainid_t di_n;
3845 bool di_minskip;
3946};
4047
4148int vm_domainset_iter_page(struct vm_domainset_iter *, struct vm_object *,
42 int *);
43void vm_domainset_iter_page_init(struct vm_domainset_iter *,
49 int *, struct pctrie_iter *);
50int vm_domainset_iter_page_init(struct vm_domainset_iter *,
4451 struct vm_object *, vm_pindex_t, int *, int *);
4552int vm_domainset_iter_policy(struct vm_domainset_iter *, int *);
46void vm_domainset_iter_policy_init(struct vm_domainset_iter *,
53int vm_domainset_iter_policy_init(struct vm_domainset_iter *,
4754 struct domainset *, int *, int *);
48void vm_domainset_iter_policy_ref_init(struct vm_domainset_iter *,
55int vm_domainset_iter_policy_ref_init(struct vm_domainset_iter *,
4956 struct domainset_ref *, int *, int *);
57void vm_domainset_iter_ignore(struct vm_domainset_iter *, int);
5058
5159int vm_wait_doms(const domainset_t *, int mflags);
5260
lib/libc/include/generic-freebsd/vm/vm_extern.h+4-6
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94
3230 */
3331
3432#ifndef _VM_EXTERN_H_
......@@ -85,14 +83,16 @@ void kmem_init(vm_offset_t, vm_offset_t);
8583void kmem_init_zero_region(void);
8684void kmeminit(void);
8785
88int kernacc(void *, int, int);
89int useracc(void *, int, int);
86bool kernacc(void *, int, int);
87bool useracc(void *, int, int);
9088int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
9189 int fault_flags, vm_page_t *m_hold);
9290void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,
9391 vm_ooffset_t *);
9492int vm_fault_disable_pagefaults(void);
9593void vm_fault_enable_pagefaults(int save);
94int vm_fault_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
95 vm_prot_t prot, vm_page_t *ma, int max_count, int *ppages_count);
9696int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
9797 vm_prot_t prot, vm_page_t *ma, int max_count);
9898int vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
......@@ -129,8 +129,6 @@ struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset);
129129void vm_imgact_unmap_page(struct sf_buf *sf);
130130void vm_thread_dispose(struct thread *td);
131131int vm_thread_new(struct thread *td, int pages);
132void vm_thread_stack_back(struct domainset *ds, vm_offset_t kaddr,
133 vm_page_t ma[], int npages, int req_class);
134132u_int vm_active_count(void);
135133u_int vm_inactive_count(void);
136134u_int vm_laundry_count(void);
lib/libc/include/generic-freebsd/vm/vm_kern.h-5
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)vm_kern.h 8.1 (Berkeley) 6/11/93
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -71,13 +69,10 @@ extern struct vm_map exec_map_store;
7169extern struct vm_map pipe_map_store;
7270#define pipe_map (&pipe_map_store)
7371extern struct vmem *kernel_arena;
74extern struct vmem *kmem_arena;
7572extern struct vmem *buffer_arena;
7673extern struct vmem *transient_arena;
7774extern struct vmem *memguard_arena;
7875extern u_long vm_kmem_size;
7976extern u_int exec_map_entries;
8077extern u_int exec_map_entry_size;
81extern vm_object_t kstack_object;
82
8378#endif /* _VM_VM_KERN_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/vm/vm_map.h+37-28
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * @(#)vm_map.h 8.9 (Berkeley) 5/17/95
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -77,7 +75,6 @@
7775 * vm_map_entry_t an entry in an address map.
7876 */
7977
80typedef u_char vm_flags_t;
8178typedef u_int vm_eflags_t;
8279
8380/*
......@@ -96,9 +93,9 @@ union vm_map_object {
9693 * and user-exported inheritance and protection information.
9794 * Also included is control information for virtual copy operations.
9895 *
99 * For stack gap map entries (MAP_ENTRY_GUARD | MAP_ENTRY_GROWS_DOWN
100 * or UP), the next_read member is reused as the stack_guard_page
101 * storage, and offset is the stack protection.
96 * For stack gap map entries (MAP_ENTRY_GUARD | MAP_ENTRY_STACK_GAP),
97 * the next_read member is reused as the stack_guard_page storage, and
98 * offset is the stack protection.
10299 */
103100struct vm_map_entry {
104101 struct vm_map_entry *left; /* left child or previous entry */
......@@ -141,14 +138,14 @@ struct vm_map_entry {
141138 a core */
142139#define MAP_ENTRY_VN_EXEC 0x00000800 /* text vnode mapping */
143140#define MAP_ENTRY_GROWS_DOWN 0x00001000 /* top-down stacks */
144#define MAP_ENTRY_GROWS_UP 0x00002000 /* bottom-up stacks */
141#define MAP_ENTRY_UNUSED0 0x00002000
145142
146143#define MAP_ENTRY_WIRE_SKIPPED 0x00004000
147144#define MAP_ENTRY_WRITECNT 0x00008000 /* tracked writeable
148145 mapping */
149146#define MAP_ENTRY_GUARD 0x00010000
150#define MAP_ENTRY_STACK_GAP_DN 0x00020000
151#define MAP_ENTRY_STACK_GAP_UP 0x00040000
147#define MAP_ENTRY_STACK_GAP 0x00020000
148#define MAP_ENTRY_UNUSED1 0x00040000
152149#define MAP_ENTRY_HEADER 0x00080000
153150
154151#define MAP_ENTRY_SPLIT_BOUNDARY_MASK 0x00300000
......@@ -205,14 +202,14 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry)
205202 */
206203struct vm_map {
207204 struct vm_map_entry header; /* List of entries */
208 struct sx lock; /* Lock for map data */
209 struct mtx system_mtx;
205 union {
206 struct sx lock; /* Lock for map data */
207 struct mtx system_mtx;
208 };
210209 int nentries; /* Number of entries */
211210 vm_size_t size; /* virtual size */
212211 u_int timestamp; /* Version number */
213 u_char needs_wakeup;
214 u_char system_map; /* (c) Am I a system map? */
215 vm_flags_t flags; /* flags for this vm_map */
212 u_int flags; /* flags for this vm_map */
216213 vm_map_entry_t root; /* Root of a binary search tree */
217214 pmap_t pmap; /* (c) Physical map */
218215 vm_offset_t anon_loc;
......@@ -223,16 +220,21 @@ struct vm_map {
223220};
224221
225222/*
226 * vm_flags_t values
223 * vm_map flags values
227224 */
228#define MAP_WIREFUTURE 0x01 /* wire all future pages */
229#define MAP_BUSY_WAKEUP 0x02 /* thread(s) waiting on busy state */
230#define MAP_IS_SUB_MAP 0x04 /* has parent */
231#define MAP_ASLR 0x08 /* enabled ASLR */
232#define MAP_ASLR_IGNSTART 0x10 /* ASLR ignores data segment */
233#define MAP_REPLENISH 0x20 /* kmapent zone needs to be refilled */
234#define MAP_WXORX 0x40 /* enforce W^X */
235#define MAP_ASLR_STACK 0x80 /* stack location is randomized */
225#define MAP_WIREFUTURE 0x00000001 /* wire all future pages */
226#define MAP_BUSY_WAKEUP 0x00000002 /* thread(s) waiting on busy
227 state */
228#define MAP_IS_SUB_MAP 0x00000004 /* has parent */
229#define MAP_ASLR 0x00000008 /* enabled ASLR */
230#define MAP_ASLR_IGNSTART 0x00000010 /* ASLR ignores data segment */
231#define MAP_REPLENISH 0x00000020 /* kmapent zone needs to be
232 refilled */
233#define MAP_WXORX 0x00000040 /* enforce W^X */
234#define MAP_ASLR_STACK 0x00000080 /* stack location is
235 randomized */
236#define MAP_NEEDS_WAKEUP 0x40000000
237#define MAP_SYSTEM_MAP 0x80000000
236238
237239#ifdef _KERNEL
238240#if defined(KLD_MODULE) && !defined(KLD_TIED)
......@@ -263,7 +265,7 @@ vm_map_pmap(vm_map_t map)
263265}
264266
265267static __inline void
266vm_map_modflags(vm_map_t map, vm_flags_t set, vm_flags_t clear)
268vm_map_modflags(vm_map_t map, u_int set, u_int clear)
267269{
268270 map->flags = (map->flags | set) & ~clear;
269271}
......@@ -278,6 +280,12 @@ vm_map_range_valid(vm_map_t map, vm_offset_t start, vm_offset_t end)
278280 return (true);
279281}
280282
283static inline bool
284vm_map_is_system(vm_map_t map)
285{
286 return ((map->flags & MAP_SYSTEM_MAP) != 0);
287}
288
281289#endif /* KLD_MODULE */
282290#endif /* _KERNEL */
283291
......@@ -378,12 +386,12 @@ long vmspace_resident_count(struct vmspace *vmspace);
378386#define MAP_PREFAULT_MADVISE 0x00000200 /* from (user) madvise request */
379387#define MAP_WRITECOUNT 0x00000400
380388#define MAP_REMAP 0x00000800
381#define MAP_STACK_GROWS_DOWN 0x00001000
382#define MAP_STACK_GROWS_UP 0x00002000
389#define MAP_STACK_AREA 0x00001000
390#define MAP_COW_UNUSED0 0x00002000
383391#define MAP_ACC_CHARGED 0x00004000
384392#define MAP_ACC_NO_CHARGE 0x00008000
385#define MAP_CREATE_STACK_GAP_UP 0x00010000
386#define MAP_CREATE_STACK_GAP_DN 0x00020000
393#define MAP_COW_UNUSED1 0x00010000
394#define MAP_CREATE_STACK_GAP 0x00020000
387395#define MAP_VN_EXEC 0x00040000
388396#define MAP_SPLIT_BOUNDARY_MASK 0x00180000
389397#define MAP_NO_HINT 0x00200000
......@@ -486,6 +494,7 @@ int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t,
486494vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t);
487495int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t);
488496void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t);
497void vm_map_init_system(vm_map_t, pmap_t, vm_offset_t, vm_offset_t);
489498int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int);
490499int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
491500 vm_pindex_t *, vm_prot_t *, boolean_t *);
lib/libc/include/generic-freebsd/vm/vm_object.h+2-4
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)vm_object.h 8.3 (Berkeley) 1/12/94
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -100,7 +98,6 @@ struct vm_object {
10098 TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
10199 LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
102100 LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
103 struct pglist memq; /* list of resident pages */
104101 struct vm_radix rtree; /* root of the resident page radix trie*/
105102 vm_pindex_t size; /* Object size */
106103 struct domainset_ref domain; /* NUMA policy. */
......@@ -206,7 +203,6 @@ struct vm_object {
206203#define OBJ_PAGERPRIV2 0x00008000 /* Pager private */
207204#define OBJ_SYSVSHM 0x00010000 /* SysV SHM */
208205#define OBJ_POSIXSHM 0x00020000 /* Posix SHM */
209#define OBJ_CDEVH 0x00040000 /* OBJT_DEVICE handle is cdev */
210206
211207/*
212208 * Helpers to perform conversion between vm_object page indexes and offsets.
......@@ -379,6 +375,8 @@ void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start,
379375void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
380376 vm_pindex_t end, int options);
381377boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t);
378void vm_object_prepare_buf_pages(vm_object_t object, vm_page_t *ma_dst,
379 int count, int *rbehind, int *rahead, vm_page_t *ma_src);
382380void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);
383381void vm_object_reference (vm_object_t);
384382void vm_object_reference_locked(vm_object_t);
lib/libc/include/generic-freebsd/vm/vm_page.h+67-112
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -80,10 +78,6 @@
8078 * A radix tree used to quickly
8179 * perform object/offset lookups
8280 *
83 * A list of all pages for a given object,
84 * so they can be quickly deactivated at
85 * time of deallocation.
86 *
8781 * An ordered list of pages due for pageout.
8882 *
8983 * In addition, the structure contains the object
......@@ -235,7 +229,6 @@ struct vm_page {
235229 void *zone;
236230 } uma;
237231 } plinks;
238 TAILQ_ENTRY(vm_page) listq; /* pages in same object (O) */
239232 vm_object_t object; /* which object am I in (O) */
240233 vm_pindex_t pindex; /* offset into object (O,P) */
241234 vm_paddr_t phys_addr; /* physical address of page (C) */
......@@ -343,50 +336,6 @@ SLIST_HEAD(spglist, vm_page);
343336extern vm_page_t bogus_page;
344337#endif /* _KERNEL */
345338
346extern struct mtx_padalign pa_lock[];
347
348#if defined(__arm__)
349#define PDRSHIFT PDR_SHIFT
350#elif !defined(PDRSHIFT)
351#define PDRSHIFT 21
352#endif
353
354#define pa_index(pa) ((pa) >> PDRSHIFT)
355#define PA_LOCKPTR(pa) ((struct mtx *)(&pa_lock[pa_index(pa) % PA_LOCK_COUNT]))
356#define PA_LOCKOBJPTR(pa) ((struct lock_object *)PA_LOCKPTR((pa)))
357#define PA_LOCK(pa) mtx_lock(PA_LOCKPTR(pa))
358#define PA_TRYLOCK(pa) mtx_trylock(PA_LOCKPTR(pa))
359#define PA_UNLOCK(pa) mtx_unlock(PA_LOCKPTR(pa))
360#define PA_UNLOCK_COND(pa) \
361 do { \
362 if ((pa) != 0) { \
363 PA_UNLOCK((pa)); \
364 (pa) = 0; \
365 } \
366 } while (0)
367
368#define PA_LOCK_ASSERT(pa, a) mtx_assert(PA_LOCKPTR(pa), (a))
369
370#if defined(KLD_MODULE) && !defined(KLD_TIED)
371#define vm_page_lock(m) vm_page_lock_KBI((m), LOCK_FILE, LOCK_LINE)
372#define vm_page_unlock(m) vm_page_unlock_KBI((m), LOCK_FILE, LOCK_LINE)
373#define vm_page_trylock(m) vm_page_trylock_KBI((m), LOCK_FILE, LOCK_LINE)
374#else /* !KLD_MODULE */
375#define vm_page_lockptr(m) (PA_LOCKPTR(VM_PAGE_TO_PHYS((m))))
376#define vm_page_lock(m) mtx_lock(vm_page_lockptr((m)))
377#define vm_page_unlock(m) mtx_unlock(vm_page_lockptr((m)))
378#define vm_page_trylock(m) mtx_trylock(vm_page_lockptr((m)))
379#endif
380#if defined(INVARIANTS)
381#define vm_page_assert_locked(m) \
382 vm_page_assert_locked_KBI((m), __FILE__, __LINE__)
383#define vm_page_lock_assert(m, a) \
384 vm_page_lock_assert_KBI((m), (a), __FILE__, __LINE__)
385#else
386#define vm_page_assert_locked(m)
387#define vm_page_lock_assert(m, a)
388#endif
389
390339/*
391340 * The vm_page's aflags are updated using atomic operations. To set or clear
392341 * these flags, the functions vm_page_aflag_set() and vm_page_aflag_clear()
......@@ -459,6 +408,7 @@ extern struct mtx_padalign pa_lock[];
459408#define PG_ZERO 0x04 /* page is zeroed */
460409#define PG_MARKER 0x08 /* special queue marker page */
461410#define PG_NODUMP 0x10 /* don't include this page in a dump */
411#define PG_NOFREE 0x20 /* page should never be freed. */
462412
463413/*
464414 * Misc constants.
......@@ -472,6 +422,7 @@ extern struct mtx_padalign pa_lock[];
472422
473423#include <sys/kassert.h>
474424#include <machine/atomic.h>
425struct pctrie_iter;
475426
476427/*
477428 * Each pageable resident page falls into one of five lists:
......@@ -511,13 +462,15 @@ extern long first_page; /* first physical page number */
511462vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
512463
513464/*
514 * Page allocation parameters for vm_page for the functions
515 * vm_page_alloc(), vm_page_grab(), vm_page_alloc_contig() and
516 * vm_page_alloc_freelist(). Some functions support only a subset
517 * of the flags, and ignore others, see the flags legend.
465 * vm_page allocation arguments for the functions vm_page_alloc(),
466 * vm_page_alloc_contig(), vm_page_alloc_noobj(), vm_page_grab(), and
467 * vm_page_grab_pages(). Each function supports only a subset of the flags.
468 * See the flags legend.
518469 *
519 * The meaning of VM_ALLOC_ZERO differs slightly between the vm_page_alloc*()
520 * and the vm_page_grab*() functions. See these functions for details.
470 * The meaning of VM_ALLOC_ZERO varies: vm_page_alloc_noobj(), vm_page_grab(),
471 * and vm_page_grab_pages() guarantee that the returned pages are zeroed; in
472 * contrast vm_page_alloc() and vm_page_alloc_contig() do not, leaving it to
473 * the caller to test the page's flags for PG_ZERO.
521474 *
522475 * Bits 0 - 1 define class.
523476 * Bits 2 - 15 dedicated for flags.
......@@ -525,7 +478,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
525478 * (a) - vm_page_alloc() supports the flag.
526479 * (c) - vm_page_alloc_contig() supports the flag.
527480 * (g) - vm_page_grab() supports the flag.
528 * (n) - vm_page_alloc_noobj() and vm_page_alloc_freelist() support the flag.
481 * (n) - vm_page_alloc_noobj() supports the flag.
529482 * (p) - vm_page_grab_pages() supports the flag.
530483 * Bits above 15 define the count of additional pages that the caller
531484 * intends to allocate.
......@@ -534,26 +487,26 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
534487#define VM_ALLOC_INTERRUPT 1
535488#define VM_ALLOC_SYSTEM 2
536489#define VM_ALLOC_CLASS_MASK 3
537#define VM_ALLOC_WAITOK 0x0008 /* (acn) Sleep and retry */
538#define VM_ALLOC_WAITFAIL 0x0010 /* (acn) Sleep and return error */
490#define VM_ALLOC_WAITOK 0x0008 /* (gnp) Sleep and retry */
491#define VM_ALLOC_WAITFAIL 0x0010 /* (acgnp) Sleep and return error */
539492#define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */
540493#define VM_ALLOC_ZERO 0x0040 /* (acgnp) Allocate a zeroed page */
541494#define VM_ALLOC_NORECLAIM 0x0080 /* (c) Do not reclaim after failure */
542#define VM_ALLOC_AVAIL0 0x0100
495#define VM_ALLOC_NOFREE 0x0100 /* (agnp) Page will never be freed */
543496#define VM_ALLOC_NOBUSY 0x0200 /* (acgp) Do not excl busy the page */
544#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Don't create a page */
497#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Do not allocate a page */
545498#define VM_ALLOC_AVAIL1 0x0800
546#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy flag */
547#define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */
499#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy state */
500#define VM_ALLOC_NODUMP 0x2000 /* (acgnp) Do not include in dump */
548501#define VM_ALLOC_SBUSY 0x4000 /* (acgp) Shared busy the page */
549502#define VM_ALLOC_NOWAIT 0x8000 /* (acgnp) Do not sleep */
550503#define VM_ALLOC_COUNT_MAX 0xffff
551504#define VM_ALLOC_COUNT_SHIFT 16
552505#define VM_ALLOC_COUNT_MASK (VM_ALLOC_COUNT(VM_ALLOC_COUNT_MAX))
553#define VM_ALLOC_COUNT(count) ({ \
554 KASSERT((count) <= VM_ALLOC_COUNT_MAX, \
555 ("%s: invalid VM_ALLOC_COUNT value", __func__)); \
556 (count) << VM_ALLOC_COUNT_SHIFT; \
506#define VM_ALLOC_COUNT(count) ({ /* (acgn) Additional pages */ \
507 KASSERT((count) <= VM_ALLOC_COUNT_MAX, \
508 ("%s: invalid VM_ALLOC_COUNT value", __func__)); \
509 (count) << VM_ALLOC_COUNT_SHIFT; \
557510})
558511
559512#ifdef M_NOWAIT
......@@ -577,6 +530,8 @@ malloc2vm_flags(int malloc_flags)
577530 pflags |= VM_ALLOC_WAITOK;
578531 if ((malloc_flags & M_NORECLAIM))
579532 pflags |= VM_ALLOC_NORECLAIM;
533 if ((malloc_flags & M_NEVERFREED))
534 pflags |= VM_ALLOC_NOFREE;
580535 return (pflags);
581536}
582537#endif
......@@ -593,22 +548,9 @@ malloc2vm_flags(int malloc_flags)
593548#define PS_ALL_VALID 0x2
594549#define PS_NONE_BUSY 0x4
595550
596bool vm_page_busy_acquire(vm_page_t m, int allocflags);
597void vm_page_busy_downgrade(vm_page_t m);
598int vm_page_busy_tryupgrade(vm_page_t m);
599bool vm_page_busy_sleep(vm_page_t m, const char *msg, int allocflags);
600void vm_page_busy_sleep_unlocked(vm_object_t obj, vm_page_t m,
601 vm_pindex_t pindex, const char *wmesg, int allocflags);
602void vm_page_free(vm_page_t m);
603void vm_page_free_zero(vm_page_t m);
604
605551void vm_page_activate (vm_page_t);
606552void vm_page_advise(vm_page_t m, int advice);
607553vm_page_t vm_page_alloc(vm_object_t, vm_pindex_t, int);
608vm_page_t vm_page_alloc_domain(vm_object_t, vm_pindex_t, int, int);
609vm_page_t vm_page_alloc_after(vm_object_t, vm_pindex_t, int, vm_page_t);
610vm_page_t vm_page_alloc_domain_after(vm_object_t, vm_pindex_t, int, int,
611 vm_page_t);
612554vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
613555 u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment,
614556 vm_paddr_t boundary, vm_memattr_t memattr);
......@@ -616,8 +558,10 @@ vm_page_t vm_page_alloc_contig_domain(vm_object_t object,
616558 vm_pindex_t pindex, int domain, int req, u_long npages, vm_paddr_t low,
617559 vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
618560 vm_memattr_t memattr);
619vm_page_t vm_page_alloc_freelist(int, int);
620vm_page_t vm_page_alloc_freelist_domain(int, int, int);
561vm_page_t vm_page_alloc_domain_iter(vm_object_t object, vm_pindex_t pindex,
562 int domain, int req, struct pctrie_iter *pages);
563vm_page_t vm_page_alloc_iter(vm_object_t object, vm_pindex_t pindex, int req,
564 struct pctrie_iter *pages);
621565vm_page_t vm_page_alloc_noobj(int);
622566vm_page_t vm_page_alloc_noobj_domain(int, int);
623567vm_page_t vm_page_alloc_noobj_contig(int req, u_long npages, vm_paddr_t low,
......@@ -628,7 +572,26 @@ vm_page_t vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages,
628572 vm_memattr_t memattr);
629573void vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set);
630574bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose);
575bool vm_page_busy_acquire(vm_page_t m, int allocflags);
576void vm_page_busy_downgrade(vm_page_t m);
577int vm_page_busy_tryupgrade(vm_page_t m);
578bool vm_page_busy_sleep(vm_page_t m, const char *msg, int allocflags);
579void vm_page_busy_sleep_unlocked(vm_object_t obj, vm_page_t m,
580 vm_pindex_t pindex, const char *wmesg, int allocflags);
581void vm_page_deactivate(vm_page_t m);
582void vm_page_deactivate_noreuse(vm_page_t m);
583void vm_page_dequeue(vm_page_t m);
584void vm_page_dequeue_deferred(vm_page_t m);
585void vm_page_free(vm_page_t m);
586void vm_page_free_invalid(vm_page_t m);
587int vm_page_free_pages_toq(struct spglist *free, bool update_wire_count);
588void vm_page_free_zero(vm_page_t m);
589vm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr);
590int vm_page_grab_zero_partial(vm_object_t object, vm_pindex_t pindex, int base,
591 int end);
631592vm_page_t vm_page_grab(vm_object_t, vm_pindex_t, int);
593vm_page_t vm_page_grab_iter(vm_object_t object, vm_pindex_t pindex,
594 int allocflags, struct pctrie_iter *pages);
632595vm_page_t vm_page_grab_unlocked(vm_object_t, vm_pindex_t, int);
633596int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
634597 vm_page_t *ma, int count);
......@@ -636,37 +599,38 @@ int vm_page_grab_pages_unlocked(vm_object_t object, vm_pindex_t pindex,
636599 int allocflags, vm_page_t *ma, int count);
637600int vm_page_grab_valid(vm_page_t *mp, vm_object_t object, vm_pindex_t pindex,
638601 int allocflags);
602int vm_page_grab_valid_iter(vm_page_t *mp, vm_object_t object,
603 vm_pindex_t pindex, int allocflags, struct pctrie_iter *pages);
639604int vm_page_grab_valid_unlocked(vm_page_t *mp, vm_object_t object,
640605 vm_pindex_t pindex, int allocflags);
641void vm_page_deactivate(vm_page_t);
642void vm_page_deactivate_noreuse(vm_page_t);
643void vm_page_dequeue(vm_page_t m);
644void vm_page_dequeue_deferred(vm_page_t m);
645vm_page_t vm_page_find_least(vm_object_t, vm_pindex_t);
646void vm_page_free_invalid(vm_page_t);
647vm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr);
648606void vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr);
649607void vm_page_init_marker(vm_page_t marker, int queue, uint16_t aflags);
650void vm_page_init_page(vm_page_t m, vm_paddr_t pa, int segind);
608void vm_page_init_page(vm_page_t m, vm_paddr_t pa, int segind, int pool);
651609int vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
652610void vm_page_invalid(vm_page_t m);
611void vm_page_iter_free(struct pctrie_iter *pages, vm_page_t m);
612void vm_page_iter_init(struct pctrie_iter *, vm_object_t);
613int vm_page_iter_insert(vm_page_t m, vm_object_t, vm_pindex_t,
614 struct pctrie_iter *);
615void vm_page_iter_limit_init(struct pctrie_iter *, vm_object_t, vm_pindex_t);
616bool vm_page_iter_remove(struct pctrie_iter *pages, vm_page_t m);
617bool vm_page_iter_rename(struct pctrie_iter *old_pages, vm_page_t m,
618 vm_object_t new_object, vm_pindex_t new_pindex);
653619void vm_page_launder(vm_page_t m);
654620vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t);
655621vm_page_t vm_page_lookup_unlocked(vm_object_t, vm_pindex_t);
656vm_page_t vm_page_next(vm_page_t m);
657622void vm_page_pqbatch_drain(void);
658623void vm_page_pqbatch_submit(vm_page_t m, uint8_t queue);
659624bool vm_page_pqstate_commit(vm_page_t m, vm_page_astate_t *old,
660625 vm_page_astate_t new);
661vm_page_t vm_page_prev(vm_page_t m);
662bool vm_page_ps_test(vm_page_t m, int flags, vm_page_t skip_m);
626bool vm_page_ps_test(vm_page_t m, int psind, int flags, vm_page_t skip_m);
663627void vm_page_putfake(vm_page_t m);
664628void vm_page_readahead_finish(vm_page_t m);
665bool vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low,
629int vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low,
666630 vm_paddr_t high, u_long alignment, vm_paddr_t boundary);
667bool vm_page_reclaim_contig_domain(int domain, int req, u_long npages,
631int vm_page_reclaim_contig_domain(int domain, int req, u_long npages,
668632 vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary);
669bool vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
633int vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
670634 vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
671635 int desired_runs);
672636void vm_page_reference(vm_page_t m);
......@@ -677,7 +641,6 @@ void vm_page_release_locked(vm_page_t m, int flags);
677641vm_page_t vm_page_relookup(vm_object_t, vm_pindex_t);
678642bool vm_page_remove(vm_page_t);
679643bool vm_page_remove_xbusy(vm_page_t);
680int vm_page_rename(vm_page_t, vm_object_t, vm_pindex_t);
681644void vm_page_replace(vm_page_t mnew, vm_object_t object,
682645 vm_pindex_t pindex, vm_page_t mold);
683646int vm_page_sbusied(vm_page_t m);
......@@ -706,16 +669,8 @@ int vm_page_is_valid(vm_page_t, int, int);
706669void vm_page_test_dirty(vm_page_t);
707670vm_page_bits_t vm_page_bits(int base, int size);
708671void vm_page_zero_invalid(vm_page_t m, boolean_t setvalid);
709int vm_page_free_pages_toq(struct spglist *free, bool update_wire_count);
710672
711673void vm_page_dirty_KBI(vm_page_t m);
712void vm_page_lock_KBI(vm_page_t m, const char *file, int line);
713void vm_page_unlock_KBI(vm_page_t m, const char *file, int line);
714int vm_page_trylock_KBI(vm_page_t m, const char *file, int line);
715#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
716void vm_page_assert_locked_KBI(vm_page_t m, const char *file, int line);
717void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line);
718#endif
719674
720675#define vm_page_busy_fetch(m) atomic_load_int(&(m)->busy_lock)
721676
......@@ -732,9 +687,9 @@ void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line);
732687#define vm_page_assert_unbusied(m) \
733688 KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) != \
734689 VPB_CURTHREAD_EXCLUSIVE, \
735 ("vm_page_assert_xbusied: page %p busy_lock %#x owned" \
736 " by me @ %s:%d", \
737 (m), (m)->busy_lock, __FILE__, __LINE__)); \
690 ("vm_page_assert_unbusied: page %p busy_lock %#x owned" \
691 " by me (%p) @ %s:%d", \
692 (m), (m)->busy_lock, curthread, __FILE__, __LINE__)); \
738693
739694#define vm_page_assert_xbusied_unchecked(m) do { \
740695 KASSERT(vm_page_xbusied(m), \
......@@ -746,8 +701,8 @@ void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line);
746701 KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) == \
747702 VPB_CURTHREAD_EXCLUSIVE, \
748703 ("vm_page_assert_xbusied: page %p busy_lock %#x not owned" \
749 " by me @ %s:%d", \
750 (m), (m)->busy_lock, __FILE__, __LINE__)); \
704 " by me (%p) @ %s:%d", \
705 (m), (m)->busy_lock, curthread, __FILE__, __LINE__)); \
751706} while (0)
752707
753708#define vm_page_busied(m) \
......@@ -1018,7 +973,7 @@ vm_page_none_valid(vm_page_t m)
1018973}
1019974
1020975static inline int
1021vm_page_domain(vm_page_t m)
976vm_page_domain(vm_page_t m __numa_used)
1022977{
1023978#ifdef NUMA
1024979 int domn, segind;
lib/libc/include/generic-freebsd/vm/vm_pageout.h+1-6
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)vm_pageout.h 8.2 (Berkeley) 1/12/94
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -102,11 +100,8 @@ void vm_wait_domain(int domain);
102100void vm_wait_min(void);
103101void vm_wait_severe(void);
104102
105int vm_pageout_flush(vm_page_t *, int, int, int, int *, boolean_t *);
103int vm_pageout_flush(vm_page_t *mc, int count, int flags, bool *eio);
106104void vm_pageout_oom(int shortage);
107105
108void vm_swapout_run(void);
109void vm_swapout_run_idle(void);
110
111106#endif /* _KERNEL */
112107#endif /* _VM_VM_PAGEOUT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/vm/vm_pagequeue.h+14-7
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -245,23 +243,26 @@ struct vm_domain {
245243 } vmd_pgcache[VM_NFREEPOOL];
246244 struct vmem *vmd_kernel_arena; /* (c) per-domain kva R/W arena. */
247245 struct vmem *vmd_kernel_rwx_arena; /* (c) per-domain kva R/W/X arena. */
246 struct vmem *vmd_kernel_nofree_arena; /* (c) per-domain kva NOFREE arena. */
248247 u_int vmd_domain; /* (c) Domain number. */
249248 u_int vmd_page_count; /* (c) Total page count. */
250249 long vmd_segs; /* (c) bitmask of the segments */
250 struct pglist vmd_nofreeq; /* (f) NOFREE page bump allocator. */
251251 u_int __aligned(CACHE_LINE_SIZE) vmd_free_count; /* (a,f) free page count */
252252 u_int vmd_pageout_deficit; /* (a) Estimated number of pages deficit */
253253 uint8_t vmd_pad[CACHE_LINE_SIZE - (sizeof(u_int) * 2)];
254254
255255 /* Paging control variables, used within single threaded page daemon. */
256256 struct pidctrl vmd_pid; /* Pageout controller. */
257 boolean_t vmd_oom;
258 u_int vmd_inactive_threads;
257 bool vmd_oom; /* An OOM kill was requested. */
258 bool vmd_helper_threads_enabled;/* Use multiple threads to scan. */
259 u_int vmd_inactive_threads; /* Number of extra helper threads. */
259260 u_int vmd_inactive_shortage; /* Per-thread shortage. */
260261 blockcount_t vmd_inactive_running; /* Number of inactive threads. */
261262 blockcount_t vmd_inactive_starting; /* Number of threads started. */
262 volatile u_int vmd_addl_shortage; /* Shortage accumulator. */
263 volatile u_int vmd_inactive_freed; /* Successful inactive frees. */
264 volatile u_int vmd_inactive_us; /* Microseconds for above. */
263 u_int vmd_addl_shortage; /* (a) Shortage accumulator. */
264 u_int vmd_inactive_freed; /* (a) Successful inactive frees. */
265 u_int vmd_inactive_us; /* (a) Microseconds for above. */
265266 u_int vmd_inactive_pps; /* Exponential decay frees/second. */
266267 int vmd_oom_seq;
267268 int vmd_last_active_scan;
......@@ -356,6 +357,12 @@ vm_batchqueue_init(struct vm_batchqueue *bq)
356357 bq->bq_cnt = 0;
357358}
358359
360static inline bool
361vm_batchqueue_empty(const struct vm_batchqueue *bq)
362{
363 return (bq->bq_cnt == 0);
364}
365
359366static inline int
360367vm_batchqueue_insert(struct vm_batchqueue *bq, vm_page_t m)
361368{
lib/libc/include/generic-freebsd/vm/vm_pager.h+4-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)vm_pager.h 8.4 (Berkeley) 1/12/94
3735 */
3836
3937/*
......@@ -295,6 +293,7 @@ struct cdev_pager_ops {
295293 int (*cdev_pg_ctor)(void *handle, vm_ooffset_t size, vm_prot_t prot,
296294 vm_ooffset_t foff, struct ucred *cred, u_short *color);
297295 void (*cdev_pg_dtor)(void *handle);
296 void (*cdev_pg_path)(void *handle, char *path, size_t len);
298297};
299298
300299vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp,
......@@ -302,6 +301,9 @@ vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp,
302301 vm_ooffset_t foff, struct ucred *cred);
303302vm_object_t cdev_pager_lookup(void *handle);
304303void cdev_pager_free_page(vm_object_t object, vm_page_t m);
304void cdev_mgtdev_pager_free_page(struct pctrie_iter *pages, vm_page_t m);
305void cdev_mgtdev_pager_free_pages(vm_object_t object);
306void cdev_pager_get_path(vm_object_t object, char *path, size_t sz);
305307
306308struct phys_pager_ops {
307309 int (*phys_pg_getpages)(vm_object_t vm_obj, vm_page_t *m, int count,
lib/libc/include/generic-freebsd/vm/vm_param.h-10
......@@ -31,8 +31,6 @@
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
3333 *
34 * from: @(#)vm_param.h 8.1 (Berkeley) 6/11/93
35 *
3634 *
3735 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3836 * All rights reserved.
......@@ -114,14 +112,6 @@ struct xswdev {
114112#define KERN_OUT_OF_BOUNDS 9
115113#define KERN_RESTART 10
116114
117#ifndef PA_LOCK_COUNT
118#ifdef SMP
119#define PA_LOCK_COUNT 32
120#else
121#define PA_LOCK_COUNT 1
122#endif /* !SMP */
123#endif /* !PA_LOCK_COUNT */
124
125115#ifndef KSTACK_MAX_PAGES
126116#define KSTACK_MAX_PAGES 32
127117#endif
lib/libc/include/generic-freebsd/vm/vm_phys.h+6-7
......@@ -61,25 +61,24 @@ extern int *mem_locality;
6161void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end);
6262vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low,
6363 vm_paddr_t high, u_long alignment, vm_paddr_t boundary);
64vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool,
65 int order);
6664int vm_phys_alloc_npages(int domain, int pool, int npages, vm_page_t ma[]);
6765vm_page_t vm_phys_alloc_pages(int domain, int pool, int order);
6866int vm_phys_domain_match(int prefer, vm_paddr_t low, vm_paddr_t high);
69void vm_phys_enqueue_contig(vm_page_t m, u_long npages);
67void vm_phys_enqueue_contig(vm_page_t m, int pool, u_long npages);
7068int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end,
7169 vm_memattr_t memattr);
7270void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end);
7371vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa);
7472int vm_phys_find_range(vm_page_t bounds[], int segind, int domain,
7573 u_long npages, vm_paddr_t low, vm_paddr_t high);
76void vm_phys_free_contig(vm_page_t m, u_long npages);
77void vm_phys_free_pages(vm_page_t m, int order);
74void vm_phys_free_contig(vm_page_t m, int pool, u_long npages);
75void vm_phys_free_pages(vm_page_t m, int pool, int order);
7876void vm_phys_init(void);
7977vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa);
78vm_page_t vm_phys_seg_paddr_to_vm_page(struct vm_phys_seg *seg, vm_paddr_t pa);
8079void vm_phys_register_domains(int ndomains, struct mem_affinity *affinity,
8180 int *locality);
82bool vm_phys_unfree_page(vm_page_t m);
81bool vm_phys_unfree_page(vm_paddr_t pa);
8382int vm_phys_mem_affinity(int f, int t);
8483void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end);
8584vm_paddr_t vm_phys_early_alloc(int domain, size_t alloc_size);
......@@ -89,7 +88,7 @@ vm_paddr_t vm_phys_avail_size(int i);
8988bool vm_phys_is_dumpable(vm_paddr_t pa);
9089
9190static inline int
92vm_phys_domain(vm_paddr_t pa)
91vm_phys_domain(vm_paddr_t pa __numa_used)
9392{
9493#ifdef NUMA
9594 int i;
lib/libc/include/generic-freebsd/vm/vm_radix.h+309-18
......@@ -34,36 +34,327 @@
3434#include <vm/_vm_radix.h>
3535
3636#ifdef _KERNEL
37#include <sys/pctrie.h>
38#include <vm/vm_page.h>
39#include <vm/vm.h>
3740
38int vm_radix_insert(struct vm_radix *rtree, vm_page_t page);
3941void vm_radix_wait(void);
40vm_page_t vm_radix_lookup(struct vm_radix *rtree, vm_pindex_t index);
41vm_page_t vm_radix_lookup_ge(struct vm_radix *rtree, vm_pindex_t index);
42vm_page_t vm_radix_lookup_le(struct vm_radix *rtree, vm_pindex_t index);
43vm_page_t vm_radix_lookup_unlocked(struct vm_radix *rtree, vm_pindex_t index);
44void vm_radix_reclaim_allnodes(struct vm_radix *rtree);
45vm_page_t vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index);
46vm_page_t vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage);
4742void vm_radix_zinit(void);
48
49/*
50 * Each search path in the trie terminates at a leaf, which is a pointer to a
51 * page marked with a set 1-bit. A leaf may be associated with a null pointer
52 * to indicate no page there.
53 */
54#define VM_RADIX_ISLEAF 0x1
55#define VM_RADIX_NULL (struct vm_radix_node *)VM_RADIX_ISLEAF
43void *vm_radix_node_alloc(struct pctrie *ptree);
44void vm_radix_node_free(struct pctrie *ptree, void *node);
45extern smr_t vm_radix_smr;
5646
5747static __inline void
5848vm_radix_init(struct vm_radix *rtree)
5949{
60 rtree->rt_root = VM_RADIX_NULL;
50 pctrie_init(&rtree->rt_trie);
6151}
6252
6353static __inline bool
6454vm_radix_is_empty(struct vm_radix *rtree)
6555{
66 return (rtree->rt_root == VM_RADIX_NULL);
56 return (pctrie_is_empty(&rtree->rt_trie));
57}
58
59PCTRIE_DEFINE_SMR(VM_RADIX, vm_page, pindex, vm_radix_node_alloc,
60 vm_radix_node_free, vm_radix_smr);
61
62/*
63 * Inserts the key-value pair into the trie, starting search from root.
64 * Panics if the key already exists.
65 */
66static __inline int
67vm_radix_insert(struct vm_radix *rtree, vm_page_t page)
68{
69 return (VM_RADIX_PCTRIE_INSERT(&rtree->rt_trie, page));
70}
71
72/*
73 * Inserts the key-value pair into the trie, starting search from iterator.
74 * Panics if the key already exists.
75 */
76static __inline int
77vm_radix_iter_insert(struct pctrie_iter *pages, vm_page_t page)
78{
79 return (VM_RADIX_PCTRIE_ITER_INSERT(pages, page));
80}
81
82/*
83 * Returns the value stored at the index assuming there is an external lock.
84 *
85 * If the index is not present, NULL is returned.
86 */
87static __inline vm_page_t
88vm_radix_lookup(struct vm_radix *rtree, vm_pindex_t index)
89{
90 return (VM_RADIX_PCTRIE_LOOKUP(&rtree->rt_trie, index));
91}
92
93/*
94 * Returns the value stored at the index without requiring an external lock.
95 *
96 * If the index is not present, NULL is returned.
97 */
98static __inline vm_page_t
99vm_radix_lookup_unlocked(struct vm_radix *rtree, vm_pindex_t index)
100{
101 return (VM_RADIX_PCTRIE_LOOKUP_UNLOCKED(&rtree->rt_trie, index));
102}
103
104/*
105 * Returns the number of contiguous, non-NULL pages read into the ma[]
106 * array, without requiring an external lock.
107 */
108static __inline int
109vm_radix_lookup_range_unlocked(struct vm_radix *rtree, vm_pindex_t index,
110 vm_page_t ma[], int count)
111{
112 return (VM_RADIX_PCTRIE_LOOKUP_RANGE_UNLOCKED(&rtree->rt_trie, index,
113 ma, count));
114}
115
116/*
117 * Returns the number of contiguous, non-NULL pages read into the ma[]
118 * array, without requiring an external lock.
119 */
120static __inline int
121vm_radix_iter_lookup_range(struct pctrie_iter *pages, vm_pindex_t index,
122 vm_page_t ma[], int count)
123{
124 return (VM_RADIX_PCTRIE_ITER_LOOKUP_RANGE(pages, index, ma, count));
125}
126
127/*
128 * Initialize an iterator for vm_radix.
129 */
130static __inline void
131vm_radix_iter_init(struct pctrie_iter *pages, struct vm_radix *rtree)
132{
133 pctrie_iter_init(pages, &rtree->rt_trie);
134}
135
136/*
137 * Initialize an iterator for vm_radix.
138 */
139static __inline void
140vm_radix_iter_limit_init(struct pctrie_iter *pages, struct vm_radix *rtree,
141 vm_pindex_t limit)
142{
143 pctrie_iter_limit_init(pages, &rtree->rt_trie, limit);
144}
145
146/*
147 * Returns the value stored at the index.
148 * Requires that access be externally synchronized by a lock.
149 *
150 * If the index is not present, NULL is returned.
151 */
152static __inline vm_page_t
153vm_radix_iter_lookup(struct pctrie_iter *pages, vm_pindex_t index)
154{
155 return (VM_RADIX_PCTRIE_ITER_LOOKUP(pages, index));
156}
157
158/*
159 * Returns the value stored 'stride' steps beyond the current position.
160 * Requires that access be externally synchronized by a lock.
161 *
162 * If the index is not present, NULL is returned.
163 */
164static __inline vm_page_t
165vm_radix_iter_stride(struct pctrie_iter *pages, int stride)
166{
167 return (VM_RADIX_PCTRIE_ITER_STRIDE(pages, stride));
168}
169
170/*
171 * Returns the page with the least pindex that is greater than or equal to the
172 * specified pindex, or NULL if there are no such pages.
173 *
174 * Requires that access be externally synchronized by a lock.
175 */
176static __inline vm_page_t
177vm_radix_lookup_ge(struct vm_radix *rtree, vm_pindex_t index)
178{
179 return (VM_RADIX_PCTRIE_LOOKUP_GE(&rtree->rt_trie, index));
180}
181
182/*
183 * Returns the page with the greatest pindex that is less than or equal to the
184 * specified pindex, or NULL if there are no such pages.
185 *
186 * Requires that access be externally synchronized by a lock.
187 */
188static __inline vm_page_t
189vm_radix_lookup_le(struct vm_radix *rtree, vm_pindex_t index)
190{
191 return (VM_RADIX_PCTRIE_LOOKUP_LE(&rtree->rt_trie, index));
192}
193
194/*
195 * Remove the specified index from the trie, and return the value stored at
196 * that index. If the index is not present, return NULL.
197 */
198static __inline vm_page_t
199vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index)
200{
201 return (VM_RADIX_PCTRIE_REMOVE_LOOKUP(&rtree->rt_trie, index));
202}
203
204/*
205 * Remove the current page from the trie.
206 */
207static __inline void
208vm_radix_iter_remove(struct pctrie_iter *pages)
209{
210 VM_RADIX_PCTRIE_ITER_REMOVE(pages);
211}
212
213/*
214 * Reclaim all the interior nodes of the trie, and invoke the callback
215 * on all the pages, in order.
216 */
217static __inline void
218vm_radix_reclaim_callback(struct vm_radix *rtree,
219 void (*page_cb)(vm_page_t, void *), void *arg)
220{
221 VM_RADIX_PCTRIE_RECLAIM_CALLBACK(&rtree->rt_trie, page_cb, arg);
222}
223
224/*
225 * Initialize an iterator pointing to the page with the least pindex that is
226 * greater than or equal to the specified pindex, or NULL if there are no such
227 * pages. Return the page.
228 *
229 * Requires that access be externally synchronized by a lock.
230 */
231static __inline vm_page_t
232vm_radix_iter_lookup_ge(struct pctrie_iter *pages, vm_pindex_t index)
233{
234 return (VM_RADIX_PCTRIE_ITER_LOOKUP_GE(pages, index));
235}
236
237/*
238 * Update the iterator to point to the page with the least pindex that is 'jump'
239 * or more greater than or equal to the current pindex, or NULL if there are no
240 * such pages. Return the page.
241 *
242 * Requires that access be externally synchronized by a lock.
243 */
244static __inline vm_page_t
245vm_radix_iter_jump(struct pctrie_iter *pages, vm_pindex_t jump)
246{
247 return (VM_RADIX_PCTRIE_ITER_JUMP_GE(pages, jump));
248}
249
250/*
251 * Update the iterator to point to the page with the least pindex that is one or
252 * more greater than the current pindex, or NULL if there are no such pages.
253 * Return the page.
254 *
255 * Requires that access be externally synchronized by a lock.
256 */
257static __inline vm_page_t
258vm_radix_iter_step(struct pctrie_iter *pages)
259{
260 return (VM_RADIX_PCTRIE_ITER_STEP_GE(pages));
261}
262
263/*
264 * Iterate over each non-NULL page from page 'start' to the end of the object.
265 */
266#define VM_RADIX_FOREACH_FROM(m, pages, start) \
267 for (m = vm_radix_iter_lookup_ge(pages, start); m != NULL; \
268 m = vm_radix_iter_step(pages))
269
270/*
271 * Iterate over each non-NULL page from the beginning to the end of the object.
272 */
273#define VM_RADIX_FOREACH(m, pages) VM_RADIX_FOREACH_FROM(m, pages, 0)
274
275/*
276 * Initialize an iterator pointing to the page with the greatest pindex that is
277 * less than or equal to the specified pindex, or NULL if there are no such
278 * pages. Return the page.
279 *
280 * Requires that access be externally synchronized by a lock.
281 */
282static __inline vm_page_t
283vm_radix_iter_lookup_le(struct pctrie_iter *pages, vm_pindex_t index)
284{
285 return (VM_RADIX_PCTRIE_ITER_LOOKUP_LE(pages, index));
286}
287
288/*
289 * Initialize an iterator pointing to the page with the greatest pindex that is
290 * less than to the specified pindex, or NULL if there are no such
291 * pages. Return the page.
292 *
293 * Requires that access be externally synchronized by a lock.
294 */
295static __inline vm_page_t
296vm_radix_iter_lookup_lt(struct pctrie_iter *pages, vm_pindex_t index)
297{
298 return (index == 0 ? NULL : vm_radix_iter_lookup_le(pages, index - 1));
299}
300
301/*
302 * Update the iterator to point to the page with the pindex that is one greater
303 * than the current pindex, or NULL if there is no such page. Return the page.
304 *
305 * Requires that access be externally synchronized by a lock.
306 */
307static __inline vm_page_t
308vm_radix_iter_next(struct pctrie_iter *pages)
309{
310 return (VM_RADIX_PCTRIE_ITER_NEXT(pages));
311}
312
313/*
314 * Iterate over consecutive non-NULL pages from position 'start' to first NULL
315 * page.
316 */
317#define VM_RADIX_FORALL_FROM(m, pages, start) \
318 for (m = vm_radix_iter_lookup(pages, start); m != NULL; \
319 m = vm_radix_iter_next(pages))
320
321/*
322 * Iterate over consecutive non-NULL pages from the beginning to first NULL
323 * page.
324 */
325#define VM_RADIX_FORALL(m, pages) VM_RADIX_FORALL_FROM(m, pages, 0)
326
327/*
328 * Update the iterator to point to the page with the pindex that is one less
329 * than the current pindex, or NULL if there is no such page. Return the page.
330 *
331 * Requires that access be externally synchronized by a lock.
332 */
333static __inline vm_page_t
334vm_radix_iter_prev(struct pctrie_iter *pages)
335{
336 return (VM_RADIX_PCTRIE_ITER_PREV(pages));
337}
338
339/*
340 * Return the current page.
341 *
342 * Requires that access be externally synchronized by a lock.
343 */
344static __inline vm_page_t
345vm_radix_iter_page(struct pctrie_iter *pages)
346{
347 return (VM_RADIX_PCTRIE_ITER_VALUE(pages));
348}
349
350/*
351 * Replace an existing page in the trie with another one.
352 * Panics if there is not an old page in the trie at the new page's index.
353 */
354static __inline vm_page_t
355vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage)
356{
357 return (VM_RADIX_PCTRIE_REPLACE(&rtree->rt_trie, newpage));
67358}
68359
69360#endif /* _KERNEL */
lib/libc/include/generic-freebsd/vm/vm_reserv.h+5-4
......@@ -46,15 +46,16 @@
4646 * The following functions are only to be used by the virtual memory system.
4747 */
4848vm_page_t vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex,
49 int domain, int req, vm_page_t mpred, u_long npages,
50 vm_paddr_t low, vm_paddr_t high, u_long alignment,
51 vm_paddr_t boundary);
49 int domain, int req, u_long npages, vm_paddr_t low,
50 vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
51 struct pctrie_iter *pages);
5252vm_page_t vm_reserv_alloc_page(vm_object_t object, vm_pindex_t pindex,
53 int domain, int req, vm_page_t mpred);
53 int domain, int req, struct pctrie_iter *pages);
5454void vm_reserv_break_all(vm_object_t object);
5555boolean_t vm_reserv_free_page(vm_page_t m);
5656void vm_reserv_init(void);
5757bool vm_reserv_is_page_free(vm_page_t m);
58bool vm_reserv_is_populated(vm_page_t m, int npages);
5859int vm_reserv_level(vm_page_t m);
5960int vm_reserv_level_iffullpop(vm_page_t m);
6061vm_page_t vm_reserv_reclaim_contig(int domain, u_long npages,
lib/libc/include/generic-freebsd/vm/vnode_pager.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * @(#)vnode_pager.h 8.1 (Berkeley) 6/11/93
3735 */
3836
3937#ifndef _VNODE_PAGER_
lib/libc/include/generic-freebsd/wchar.h+9-2
......@@ -78,7 +78,7 @@ typedef __size_t size_t;
7878
7979#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
8080#ifndef _VA_LIST_DECLARED
81typedef __va_list va_list;
81typedef __builtin_va_list va_list;
8282#define _VA_LIST_DECLARED
8383#endif
8484#endif
......@@ -108,6 +108,14 @@ typedef struct __sFILE FILE;
108108#endif
109109struct tm;
110110
111__BEGIN_DECLS
112size_t wcslen(const wchar_t *) __pure;
113__END_DECLS
114
115#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
116#include <ssp/wchar.h>
117#endif
118
111119__BEGIN_DECLS
112120wint_t btowc(int);
113121wint_t fgetwc(FILE *);
......@@ -146,7 +154,6 @@ wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict);
146154size_t wcscspn(const wchar_t *, const wchar_t *) __pure;
147155size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict,
148156 const struct tm * __restrict);
149size_t wcslen(const wchar_t *) __pure;
150157wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict,
151158 size_t);
152159int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure;
lib/libc/include/generic-freebsd/x86/_align.h-2
......@@ -35,8 +35,6 @@
3535 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3636 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3737 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
4038 */
4139
4240#ifndef _X86_INCLUDE__ALIGN_H_
lib/libc/include/generic-freebsd/x86/_limits.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
3230 */
3331
3432#ifndef _MACHINE__LIMITS_H_
lib/libc/include/generic-freebsd/x86/_types.h-3
......@@ -32,9 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
3835 */
3936
4037#ifndef _MACHINE__TYPES_H_
lib/libc/include/generic-freebsd/x86/acpica_machdep.h+2
......@@ -84,6 +84,8 @@ void madt_parse_interrupt_values(void *entry,
8484extern int madt_found_sci_override;
8585extern int (*apei_nmi)(void);
8686
87void acpi_set_root(vm_paddr_t addr);
88
8789#endif /* _KERNEL */
8890
8991#endif /* __ACPICA_MACHDEP_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/apicreg.h+2
......@@ -296,6 +296,8 @@ typedef struct IOAPIC ioapic_t;
296296/* constants relating to APIC ID registers */
297297#define APIC_ID_MASK 0xff000000
298298#define APIC_ID_SHIFT 24
299#define APIC_EXT_ID_MASK 0x00fe0000
300#define APIC_EXT_ID_SHIFT 17
299301#define APIC_ID_CLUSTER 0xf0
300302#define APIC_ID_CLUSTER_ID 0x0f
301303#define APIC_MAX_CLUSTER 0xe
lib/libc/include/generic-freebsd/x86/apicvar.h+16-14
......@@ -196,19 +196,21 @@ extern int *apic_cpuids;
196196/* Allow to replace the lapic_ipi_vectored implementation. */
197197extern void (*ipi_vectored)(u_int, int);
198198
199typedef struct ioapic *ioapic_drv_t;
200
199201void apic_register_enumerator(struct apic_enumerator *enumerator);
200void *ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase);
201int ioapic_disable_pin(void *cookie, u_int pin);
202int ioapic_get_vector(void *cookie, u_int pin);
203void ioapic_register(void *cookie);
204int ioapic_remap_vector(void *cookie, u_int pin, int vector);
205int ioapic_set_bus(void *cookie, u_int pin, int bus_type);
206int ioapic_set_extint(void *cookie, u_int pin);
207int ioapic_set_nmi(void *cookie, u_int pin);
208int ioapic_set_polarity(void *cookie, u_int pin, enum intr_polarity pol);
209int ioapic_set_triggermode(void *cookie, u_int pin,
202ioapic_drv_t ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase);
203int ioapic_disable_pin(ioapic_drv_t cookie, u_int pin);
204int ioapic_get_vector(ioapic_drv_t cookie, u_int pin);
205void ioapic_register(ioapic_drv_t cookie);
206int ioapic_remap_vector(ioapic_drv_t cookie, u_int pin, int vector);
207int ioapic_set_bus(ioapic_drv_t cookie, u_int pin, int bus_type);
208int ioapic_set_extint(ioapic_drv_t cookie, u_int pin);
209int ioapic_set_nmi(ioapic_drv_t cookie, u_int pin);
210int ioapic_set_polarity(ioapic_drv_t cookie, u_int pin, enum intr_polarity pol);
211int ioapic_set_triggermode(ioapic_drv_t cookie, u_int pin,
210212 enum intr_trigger trigger);
211int ioapic_set_smi(void *cookie, u_int pin);
213int ioapic_set_smi(ioapic_drv_t cookie, u_int pin);
212214
213215void lapic_create(u_int apic_id, int boot_cpu);
214216void lapic_init(vm_paddr_t addr);
......@@ -229,9 +231,9 @@ void apic_enable_vector(u_int apic_id, u_int vector);
229231void apic_disable_vector(u_int apic_id, u_int vector);
230232void apic_free_vector(u_int apic_id, u_int vector, u_int irq);
231233void lapic_calibrate_timer(void);
232int lapic_enable_pmc(void);
233void lapic_disable_pmc(void);
234void lapic_reenable_pmc(void);
234int lapic_enable_pcint(void);
235void lapic_disable_pcint(void);
236void lapic_reenable_pcint(void);
235237void lapic_enable_cmc(void);
236238int lapic_enable_mca_elvt(void);
237239void lapic_ipi_raw(register_t icrlo, u_int dest);
lib/libc/include/generic-freebsd/x86/bus.h+1-1
......@@ -1,5 +1,5 @@
11/*-
2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-ClauseE
2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause
33 *
44 * Copyright (c) KATO Takenori, 1999.
55 *
lib/libc/include/generic-freebsd/x86/bus_dma.h+1-1
......@@ -88,7 +88,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
8888
8989/*
9090 * Free a piece of memory and it's allociated dmamap, that was allocated
91 * via bus_dmamem_alloc. Make the same choice for free/contigfree.
91 * via bus_dmamem_alloc.
9292 */
9393static inline void
9494bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
lib/libc/include/generic-freebsd/x86/busdma_impl.h+3-10
......@@ -33,28 +33,23 @@
3333
3434struct bus_dma_tag_common {
3535 struct bus_dma_impl *impl;
36 struct bus_dma_tag_common *parent;
3736 bus_size_t alignment;
3837 bus_addr_t boundary;
3938 bus_addr_t lowaddr;
4039 bus_addr_t highaddr;
41 bus_dma_filter_t *filter;
42 void *filterarg;
4340 bus_size_t maxsize;
4441 u_int nsegments;
4542 bus_size_t maxsegsz;
4643 int flags;
4744 bus_dma_lock_t *lockfunc;
4845 void *lockfuncarg;
49 int ref_count;
5046 int domain;
5147};
5248
5349struct bus_dma_impl {
5450 int (*tag_create)(bus_dma_tag_t parent,
5551 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
56 bus_addr_t highaddr, bus_dma_filter_t *filter,
57 void *filterarg, bus_size_t maxsize, int nsegments,
52 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
5853 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
5954 void *lockfuncarg, bus_dma_tag_t *dmat);
6055 int (*tag_destroy)(bus_dma_tag_t dmat);
......@@ -87,13 +82,11 @@ struct bus_dma_impl {
8782#endif
8883};
8984
90int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr);
9185int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
9286 bus_size_t alignment,
9387 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
94 bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,
95 int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
96 void *lockfuncarg, size_t sz, void **dmat);
88 bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags,
89 bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat);
9790
9891extern struct bus_dma_impl bus_dma_bounce_impl;
9992
lib/libc/include/generic-freebsd/x86/dump.h+8
......@@ -38,7 +38,11 @@
3838
3939/* 20 phys_avail entry pairs correspond to 10 pa's */
4040#define DUMPSYS_MD_PA_NPAIRS 10
41#ifdef __amd64__
42#define DUMPSYS_NUM_AUX_HDRS 1
43#else
4144#define DUMPSYS_NUM_AUX_HDRS 0
45#endif
4246
4347/* How often to check the dump progress bar? */
4448#define DUMPSYS_PB_CHECK_BITS 24 /* Every 16MB */
......@@ -71,12 +75,16 @@ dumpsys_unmap_chunk(vm_paddr_t pa, size_t s, void *va)
7175 dumpsys_gen_unmap_chunk(pa, s, va);
7276}
7377
78#ifdef __amd64__
79int dumpsys_write_aux_headers(struct dumperinfo *di);
80#else
7481static inline int
7582dumpsys_write_aux_headers(struct dumperinfo *di)
7683{
7784
7885 return (dumpsys_gen_write_aux_headers(di));
7986}
87#endif
8088
8189static inline int
8290dumpsys(struct dumperinfo *di)
lib/libc/include/generic-freebsd/x86/endian.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)endian.h 7.8 (Berkeley) 4/3/91
3230 */
3331
3432#ifndef _MACHINE_ENDIAN_H_
lib/libc/include/generic-freebsd/x86/float.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3230 */
3331
3432#ifndef _MACHINE_FLOAT_H_
lib/libc/include/generic-freebsd/x86/fpu.h+7-2
......@@ -28,8 +28,6 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
3331 */
3432
3533/*
......@@ -220,6 +218,13 @@ struct savefpu_ymm {
220218 */
221219#define fpu_enable() clts()
222220#define fpu_disable() load_cr0(rcr0() | CR0_TS)
221
222bool xsave_extfeature_supported(uint64_t feature, bool supervisor);
223bool xsave_extension_supported(uint64_t extension);
224size_t xsave_area_hdr_offset(void);
225size_t xsave_area_offset(uint64_t xstate_bv, uint64_t feature, bool compact,
226 bool supervisor);
227size_t xsave_area_size(uint64_t xstate_bv, bool compact, bool supervisor);
223228#endif
224229
225230#endif /* !_X86_FPU_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/frame.h+1-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)frame.h 5.2 (Berkeley) 1/18/91
3634 */
3735
3836#ifndef _MACHINE_FRAME_H_
......@@ -154,6 +152,7 @@ struct trapframe {
154152#define TF_HASSEGS 0x1
155153#define TF_HASBASES 0x2
156154#define TF_HASFPXSTATE 0x4
155#define TF_RESERV0 0x8 /* no tlsbase in the trapframe */
157156#endif /* __amd64__ */
158157
159158#endif /* _MACHINE_FRAME_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/init.h+2-2
......@@ -35,10 +35,10 @@
3535 * hypervisor environment.
3636 */
3737struct init_ops {
38 caddr_t (*parse_preload_data)(u_int64_t);
38 void (*parse_preload_data)(u_int64_t);
3939 void (*early_clock_source_init)(void);
4040 void (*early_delay)(int);
41 void (*parse_memmap)(caddr_t, vm_paddr_t *, int *);
41 void (*parse_memmap)(vm_paddr_t *, int *);
4242};
4343
4444extern struct init_ops init_ops;
lib/libc/include/generic-freebsd/x86/intr_machdep.h+5-8
......@@ -62,8 +62,6 @@ extern u_int num_msi_irqs;
6262 */
6363#define MSI_INTEL_ADDR_BASE 0xfee00000
6464
65#ifndef LOCORE
66
6765typedef void inthand_t(void);
6866
6967#define IDTVEC(name) __CONCAT(X,name)
......@@ -138,12 +136,12 @@ void elcr_write_trigger(u_int irq, enum intr_trigger trigger);
138136#ifdef SMP
139137void intr_add_cpu(u_int cpu);
140138#endif
141int intr_add_handler(const char *name, int vector, driver_filter_t filter,
142 driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep,
143 int domain);
144int intr_config_intr(int vector, enum intr_trigger trig,
139int intr_add_handler(struct intsrc *isrc, const char *name,
140 driver_filter_t filter, driver_intr_t handler, void *arg,
141 enum intr_type flags, void **cookiep, int domain);
142int intr_config_intr(struct intsrc *isrc, enum intr_trigger trig,
145143 enum intr_polarity pol);
146int intr_describe(u_int vector, void *ih, const char *descr);
144int intr_describe(struct intsrc *isrc, void *ih, const char *descr);
147145void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
148146u_int intr_next_cpu(int domain);
149147struct intsrc *intr_lookup_source(int vector);
......@@ -165,6 +163,5 @@ int msix_release(int irq);
165163void xen_intr_alloc_irqs(void);
166164#endif
167165
168#endif /* !LOCORE */
169166#endif /* _KERNEL */
170167#endif /* !__X86_INTR_MACHDEP_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/legacyvar.h+7-3
......@@ -58,10 +58,14 @@ int legacy_pcib_write_ivar(device_t dev, device_t child, int which,
5858struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child,
5959 int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
6060 u_int flags);
61int legacy_pcib_adjust_resource(device_t dev, device_t child, int type,
61int legacy_pcib_adjust_resource(device_t dev, device_t child,
6262 struct resource *r, rman_res_t start, rman_res_t end);
63int legacy_pcib_release_resource(device_t dev, device_t child, int type,
64 int rid, struct resource *r);
63int legacy_pcib_release_resource(device_t dev, device_t child,
64 struct resource *r);
65int legacy_pcib_activate_resource(device_t dev, device_t child,
66 struct resource *r);
67int legacy_pcib_deactivate_resource(device_t dev, device_t child,
68 struct resource *r);
6569int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count,
6670 int maxcount, int *irqs);
6771int legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq);
lib/libc/include/generic-freebsd/x86/mca.h+25
......@@ -44,6 +44,31 @@ struct mca_record {
4444 int mr_cpu;
4545};
4646
47enum mca_stat_types {
48 MCA_T_NONE = 0,
49 MCA_T_UNCLASSIFIED,
50 MCA_T_UCODE_ROM_PARITY,
51 MCA_T_EXTERNAL,
52 MCA_T_FRC,
53 MCA_T_INTERNAL_PARITY,
54 MCA_T_SMM_HANDLER,
55 MCA_T_INTERNAL_TIMER,
56 MCA_T_GENERIC_IO,
57 MCA_T_INTERNAL,
58 MCA_T_MEMORY,
59 MCA_T_TLB,
60 MCA_T_MEMCONTROLLER_GEN,
61 MCA_T_MEMCONTROLLER_RD,
62 MCA_T_MEMCONTROLLER_WR,
63 MCA_T_MEMCONTROLLER_AC,
64 MCA_T_MEMCONTROLLER_MS,
65 MCA_T_MEMCONTROLLER_OTHER,
66 MCA_T_CACHE,
67 MCA_T_BUS,
68 MCA_T_UNKNOWN,
69 MCA_T_COUNT /* Must stay last */
70};
71
4772#ifdef _KERNEL
4873
4974void cmc_intr(void);
lib/libc/include/generic-freebsd/x86/metadata.h+9-3
......@@ -34,11 +34,17 @@
3434#define MODINFOMD_EFI_FB 0x1005
3535#define MODINFOMD_MODULEP 0x1006
3636#define MODINFOMD_VBE_FB 0x1007
37#define MODINFOMD_EFI_ARCH 0x1008
3738
39/*
40 * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though
41 * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table
42 * starting at a 16-byte alignment.
43 */
3844struct efi_map_header {
39 uint64_t memory_size;
40 uint64_t descriptor_size;
41 uint32_t descriptor_version;
45 uint64_t memory_size; /* Numnber of bytes that follow */
46 uint64_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
47 uint32_t descriptor_version; /* Currently '1' */
4248};
4349
4450struct efi_fb {
lib/libc/include/generic-freebsd/x86/mptable.h-4
......@@ -188,16 +188,12 @@ typedef struct CBASMENTRY {
188188
189189#ifdef _KERNEL
190190struct mptable_hostb_softc {
191#ifdef NEW_PCIB
192191 struct pcib_host_resources sc_host_res;
193192 int sc_decodes_vga_io;
194193 int sc_decodes_isa_io;
195#endif
196194};
197195
198#ifdef NEW_PCIB
199196void mptable_pci_host_res_init(device_t pcib);
200#endif
201197int mptable_pci_probe_table(int bus);
202198int mptable_pci_route_interrupt(device_t pcib, device_t dev, int pin);
203199#endif
lib/libc/include/generic-freebsd/x86/pci_cfgreg.h+2-5
......@@ -58,15 +58,12 @@ extern int cfgmech;
5858rman_res_t hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count);
5959int pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus);
6060int pci_cfgregopen(void);
61u_int32_t pci_cfgregread_domain(int domain, int bus, int slot, int func, int reg, int bytes);
62void pci_cfgregwrite_domain(int domain, int bus, int slot, int func, int reg, u_int32_t data, int bytes);
61u_int32_t pci_cfgregread(int domain, int bus, int slot, int func, int reg, int bytes);
62void pci_cfgregwrite(int domain, int bus, int slot, int func, int reg, u_int32_t data, int bytes);
6363#ifdef __HAVE_PIR
6464void pci_pir_open(void);
6565int pci_pir_probe(int bus, int require_parse);
6666int pci_pir_route_interrupt(int bus, int device, int func, int pin);
6767#endif
6868
69#define pci_cfgregread pci_cfgregread_domain
70#define pci_cfgregwrite pci_cfgregwrite_domain
71
7269#endif /* !__X86_PCI_CFGREG_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/psl.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)psl.h 5.2 (Berkeley) 1/18/91
3533 */
3634
3735#ifndef _MACHINE_PSL_H_
lib/libc/include/generic-freebsd/x86/ptrace.h+2-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)ptrace.h 8.1 (Berkeley) 6/11/93
3230 */
3331
3432#ifndef _MACHINE_PTRACE_H_
......@@ -56,6 +54,8 @@
5654#define PT_SETFSBASE (PT_FIRSTMACH + 8)
5755#define PT_GETGSBASE (PT_FIRSTMACH + 9)
5856#define PT_SETGSBASE (PT_FIRSTMACH + 10)
57#define PT_GETTLSBASE (PT_FIRSTMACH + 11)
58#define PT_SETTLSBASE (PT_FIRSTMACH + 12)
5959
6060/* Argument structure for PT_GETXSTATE_INFO. */
6161struct ptrace_xstate_info {
lib/libc/include/generic-freebsd/x86/reg.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)reg.h 5.5 (Berkeley) 1/18/91
3634 */
3735
3836#ifndef _MACHINE_REG_H_
lib/libc/include/generic-freebsd/x86/segments.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
3634 */
3735
3836#ifndef _X86_SEGMENTS_H_
lib/libc/include/generic-freebsd/x86/signal.h-2
......@@ -28,8 +28,6 @@
2828 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2929 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3030 * SUCH DAMAGE.
31 *
32 * @(#)signal.h 8.1 (Berkeley) 6/11/93
3331 */
3432
3533#ifndef _X86_SIGNAL_H
lib/libc/include/generic-freebsd/x86/specialreg.h+20-5
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)specialreg.h 7.1 (Berkeley) 5/9/91
3230 */
3331
3432#ifndef _MACHINE_SPECIALREG_H_
......@@ -125,6 +123,7 @@
125123#define XFEATURE_ENABLED_OPMASK 0x00000020
126124#define XFEATURE_ENABLED_ZMM_HI256 0x00000040
127125#define XFEATURE_ENABLED_HI16_ZMM 0x00000080
126#define XFEATURE_ENABLED_PT 0x00000100
128127#define XFEATURE_ENABLED_PKRU 0x00000200
129128#define XFEATURE_ENABLED_TILECONFIG 0x00020000
130129#define XFEATURE_ENABLED_TILEDATA 0x00040000
......@@ -215,6 +214,7 @@
215214#define CPUPT_MTC (1 << 3) /* MTC Supported */
216215#define CPUPT_PRW (1 << 4) /* PTWRITE Supported */
217216#define CPUPT_PWR (1 << 5) /* Power Event Trace Supported */
217#define CPUPT_DIS_TNT (1 << 8) /* TNT disable supported */
218218
219219/* Leaf 0 ecx. */
220220#define CPUPT_TOPA (1 << 0) /* ToPA Output Supported */
......@@ -388,6 +388,14 @@
388388#define CPUID_EXTSTATE_XINUSE 0x00000004
389389#define CPUID_EXTSTATE_XSAVES 0x00000008
390390
391/*
392 * CPUID instruction 0xd Processor Extended State Enumeration
393 * Sub-leaf > 1 ecx info
394 */
395#define CPUID_EXTSTATE_SUPERVISOR 0x00000001
396#define CPUID_EXTSTATE_ALIGNED 0x00000002
397#define CPUID_EXTSTATE_XFD_SUPPORTED 0x00000004
398
391399/*
392400 * AMD extended function 8000_0007h ebx info
393401 */
......@@ -648,6 +656,12 @@
648656#define MSR_PAT 0x277
649657#define MSR_MC0_CTL2 0x280
650658#define MSR_MTRRdefType 0x2ff
659#define MSR_IA_GLOBAL_STATUS 0x38E
660#define MSR_IA_GLOBAL_CTRL 0x38F
661#define MSR_IA_GLOBAL_OVF_CTRL 0x390
662#define MSR_IA_GLOBAL_STATUS_RESET 0x390
663#define MSR_IA_GLOBAL_STATUS_SET 0x391
664#define GLOBAL_STATUS_FLAG_TRACETOPAPMI (1ULL << 55)
651665#define MSR_MC0_CTL 0x400
652666#define MSR_MC0_STATUS 0x401
653667#define MSR_MC0_ADDR 0x402
......@@ -775,6 +789,7 @@
775789#define RTIT_CTL_ADDR2_CFG_M (0xfULL << RTIT_CTL_ADDR2_CFG_S)
776790#define RTIT_CTL_ADDR3_CFG_S 44
777791#define RTIT_CTL_ADDR3_CFG_M (0xfULL << RTIT_CTL_ADDR3_CFG_S)
792#define RTIT_CTL_DIS_TNT (1ULL << 55)
778793#define MSR_IA32_RTIT_STATUS 0x571 /* Tracing Status Register (R/W) */
779794#define RTIT_STATUS_FILTEREN (1 << 0)
780795#define RTIT_STATUS_CONTEXTEN (1 << 1)
......@@ -991,7 +1006,7 @@
9911006
9921007#define CCR4 0xe8
9931008#define CCR4_IOMASK 0x07
994#define CCR4_MEM 0x08 /* Enables momory bypassing */
1009#define CCR4_MEM 0x08 /* Enables memory bypassing */
9951010#define CCR4_DTE 0x10 /* Enables directory table entry cache */
9961011#define CCR4_FASTFPE 0x20 /* Fast FPU exception */
9971012#define CCR4_CPUID 0x80 /* Enables CPUID instruction */
......@@ -1011,7 +1026,7 @@
10111026#define PCR0_RSTK 0x01 /* Enables return stack */
10121027#define PCR0_BTB 0x02 /* Enables branch target buffer */
10131028#define PCR0_LOOP 0x04 /* Enables loop */
1014#define PCR0_AIS 0x08 /* Enables all instrcutions stalled to
1029#define PCR0_AIS 0x08 /* Enables all instructions stalled to
10151030 serialize pipe. */
10161031#define PCR0_MLR 0x10 /* Enables reordering of misaligned loads */
10171032#define PCR0_BTBRT 0x40 /* Enables BTB test register. */
......@@ -1165,7 +1180,7 @@
11651180
11661181/*
11671182 * The region control registers specify the attributes associated with
1168 * the ARRx addres regions.
1183 * the ARRx address regions.
11691184 */
11701185#define RCR0 0xdc
11711186#define RCR1 0xdd
lib/libc/include/generic-freebsd/x86/sysarch.h+4
......@@ -61,6 +61,9 @@
6161#define AMD64_GET_XFPUSTATE 132
6262#define AMD64_SET_PKRU 133
6363#define AMD64_CLEAR_PKRU 134
64#define AMD64_GET_TLSBASE 135
65#define AMD64_SET_TLSBASE 136
66#define AMD64_DISABLE_TLSBASE 137
6467
6568/* Flags for AMD64_SET_PKRU */
6669#define AMD64_PKRU_EXCL 0x0001
......@@ -140,6 +143,7 @@ int amd64_get_fsbase(void **);
140143int amd64_get_gsbase(void **);
141144int amd64_set_fsbase(void *);
142145int amd64_set_gsbase(void *);
146int amd64_set_tlsbase(void *);
143147int x86_pkru_get_perm(unsigned int keyidx, int *access, int *modify);
144148int x86_pkru_set_perm(unsigned int keyidx, int access, int modify);
145149int x86_pkru_protect_range(void *addr, unsigned long len, unsigned int keyidx,
lib/libc/include/generic-freebsd/x86/tls.h+12-2
......@@ -36,13 +36,23 @@
3636
3737struct pthread;
3838
39struct dtv_slot {
40 char *dtvs_tls;
41};
42
43struct dtv {
44 uintptr_t dtv_gen;
45 uintptr_t dtv_size;
46 struct dtv_slot dtv_slots[];
47};
48
3949/*
4050 * Variant II tcb, first two members are required by rtld,
4151 * %fs (amd64) / %gs (i386) points to the structure.
4252 */
4353struct tcb {
4454 struct tcb *tcb_self; /* required by rtld */
45 uintptr_t *tcb_dtv; /* required by rtld */
55 struct dtv *tcb_dtv; /* required by rtld */
4656 struct pthread *tcb_thread;
4757};
4858
......@@ -59,7 +69,7 @@ static __inline void
5969_tcb_set(struct tcb *tcb)
6070{
6171#ifdef __amd64__
62 amd64_set_fsbase(tcb);
72 amd64_set_tlsbase(tcb);
6373#else
6474 i386_set_gsbase(tcb);
6575#endif
lib/libc/include/generic-freebsd/x86/trap.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)trap.h 5.4 (Berkeley) 5/9/91
3533 */
3634
3735#ifndef _MACHINE_TRAP_H_
lib/libc/include/generic-freebsd/x86/ucode.h+14-1
......@@ -31,6 +31,12 @@
3131#ifndef _MACHINE_UCODE_H_
3232#define _MACHINE_UCODE_H_
3333
34#ifdef _KERNEL
35#include <sys/types.h>
36#else
37#include <stdbool.h>
38#endif
39
3440struct ucode_intel_header {
3541 uint32_t header_version;
3642 int32_t update_revision;
......@@ -56,7 +62,14 @@ struct ucode_intel_extsig_table {
5662 } entries[0];
5763};
5864
59int ucode_intel_load(void *data, bool unsafe,
65typedef enum { SAFE, UNSAFE, EARLY } ucode_load_how;
66
67const void *ucode_amd_find(const char *path, uint32_t signature,
68 uint32_t *revision, const uint8_t *fw_data, size_t fw_size,
69 size_t *selected_sizep);
70int ucode_intel_load(const void *data, ucode_load_how unsafe,
71 uint64_t *nrevp, uint64_t *orevp);
72int ucode_amd_load(const void *data, ucode_load_how how,
6073 uint64_t *nrevp, uint64_t *orevp);
6174size_t ucode_load_bsp(uintptr_t free);
6275void ucode_load_ap(int cpu);
lib/libc/include/generic-freebsd/x86/ucontext.h+6-2
......@@ -99,7 +99,9 @@ typedef struct __mcontext {
9999#define _MC_HASSEGS 0x1
100100#define _MC_HASBASES 0x2
101101#define _MC_HASFPXSTATE 0x4
102#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE)
102#define _MC_HASTLSBASE 0x8
103#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE | \
104 _MC_HASTLSBASE)
103105
104106typedef struct __mcontext {
105107 /*
......@@ -158,7 +160,9 @@ typedef struct __mcontext {
158160 __register_t mc_xfpustate;
159161 __register_t mc_xfpustate_len;
160162
161 long mc_spare[4];
163 __register_t mc_tlsbase;
164
165 long mc_spare[3];
162166} mcontext_t;
163167#endif /* __amd64__ */
164168
lib/libc/include/generic-freebsd/x86/vmware.h+6-2
......@@ -31,19 +31,23 @@
3131#define VMW_HVPORT 0x5658
3232
3333#define VMW_HVCMD_GETVERSION 10
34#define VMW_HVCMD_GUESTRPC 30
3435#define VMW_HVCMD_GETHZ 45
3536#define VMW_HVCMD_GETVCPU_INFO 68
3637
38#define VMW_HVCMD_DEFAULT_PARAM UINT_MAX
39
3740#define VMW_VCPUINFO_LEGACY_X2APIC (1 << 3)
3841#define VMW_VCPUINFO_VCPU_RESERVED (1 << 31)
3942
4043static __inline void
41vmware_hvcall(u_int cmd, u_int *p)
44vmware_hvcall(int chan, u_int cmd, u_int param, u_int *p)
4245{
4346
4447 __asm __volatile("inl %w3, %0"
4548 : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
46 : "0" (VMW_HVMAGIC), "1" (UINT_MAX), "2" (cmd), "3" (VMW_HVPORT)
49 : "0" (VMW_HVMAGIC), "1" (param), "2" (cmd),
50 "3" (VMW_HVPORT | (chan << 16))
4751 : "memory");
4852}
4953
lib/libc/include/generic-freebsd/x86/vmware_guestrpc.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2015-2024, Juniper Networks, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _X86_VMWARE_GUESTRPC_H_
29#define _X86_VMWARE_GUESTRPC_H_
30
31struct sbuf;
32
33int vmware_guestrpc_cmd(struct sbuf *sbufp);
34int vmware_guestrpc_set_guestinfo(const char *keyword, const char *val);
35int vmware_guestrpc_get_guestinfo(const char *keyword, struct sbuf *sbufp);
36
37#endif /* _X86_VMWARE_GUESTRPC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/x86_ieeefp.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
3735 */
3836
3937#ifndef _X86_X86_IEEEFP_H_
lib/libc/include/generic-freebsd/x86/x86_var.h+5-1
......@@ -50,6 +50,7 @@ extern u_int cpu_clflush_line_size;
5050extern u_int cpu_stdext_feature;
5151extern u_int cpu_stdext_feature2;
5252extern u_int cpu_stdext_feature3;
53extern u_int cpu_stdext_feature4;
5354extern uint64_t cpu_ia32_arch_caps;
5455extern u_int cpu_high;
5556extern u_int cpu_id;
......@@ -62,6 +63,7 @@ extern char cpu_vendor[];
6263extern char cpu_model[];
6364extern u_int cpu_vendor_id;
6465extern u_int cpu_mon_mwait_flags;
66extern u_int cpu_mon_mwait_edx;
6567extern u_int cpu_mon_min_size;
6668extern u_int cpu_mon_max_size;
6769extern u_int cpu_maxphyaddr;
......@@ -147,7 +149,9 @@ void zenbleed_sanitize_enable(void);
147149void zenbleed_check_and_apply(bool all_cpus);
148150void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame);
149151void nmi_call_kdb_smp(u_int type, struct trapframe *frame);
150void nmi_handle_intr(u_int type, struct trapframe *frame);
152void nmi_register_handler(int (*handler)(struct trapframe *));
153void nmi_remove_handler(int (*handler)(struct trapframe *));
154void nmi_handle_intr(struct trapframe *frame);
151155void pagecopy(void *from, void *to);
152156void printcpuinfo(void);
153157int pti_get_default(void);
lib/libc/include/powerpc-freebsd-eabihf/machine/sigframe.h deleted-39
......@@ -1,39 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1999 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer
12 * in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef _MACHINE_SIGFRAME_H_
32#define _MACHINE_SIGFRAME_H_ 1
33
34struct sigframe {
35 ucontext_t sf_uc;
36 siginfo_t sf_si;
37};
38
39#endif /* _MACHINE_SIGFRAME_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/dev/powermac_nvram/powermac_nvramvar.h created+82
......@@ -0,0 +1,82 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2006 Maxim Sobolev <sobomax@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_
30#define _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_
31
32#define NVRAM_SIZE 0x2000
33
34#define CORE99_SIGNATURE 0x5a
35
36#define SM_FLASH_CMD_ERASE_CONFIRM 0xd0
37#define SM_FLASH_CMD_ERASE_SETUP 0x20
38#define SM_FLASH_CMD_RESET 0xff
39#define SM_FLASH_CMD_WRITE_SETUP 0x40
40#define SM_FLASH_CMD_CLEAR_STATUS 0x50
41#define SM_FLASH_CMD_READ_STATUS 0x70
42
43#define SM_FLASH_STATUS_DONE 0x80
44#define SM_FLASH_STATUS_ERR 0x38
45
46#ifdef _KERNEL
47
48struct powermac_nvram_softc {
49 device_t sc_dev;
50 struct sx sc_lock;
51 phandle_t sc_node;
52 void * sc_bank;
53 void * sc_bank0;
54 void * sc_bank1;
55 uint8_t sc_data[NVRAM_SIZE];
56
57 struct cdev * sc_cdev;
58 int sc_type;
59#define FLASH_TYPE_SM 0
60#define FLASH_TYPE_AMD 1
61 int sc_isopen;
62 int sc_rpos;
63 int sc_wpos;
64};
65
66#endif /* _KERNEL */
67
68struct chrp_header {
69 uint8_t signature;
70 uint8_t chrp_checksum;
71 uint16_t length;
72 char name[12];
73};
74
75struct core99_header {
76 struct chrp_header chrp_header;
77 uint32_t adler_checksum;
78 uint32_t generation;
79 uint32_t reserved[2];
80};
81
82#endif /* _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/fenv.h created+305
......@@ -0,0 +1,305 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/_types.h>
33#include <machine/endian.h>
34
35#ifndef __fenv_static
36#define __fenv_static static
37#endif
38
39typedef __uint32_t fenv_t;
40typedef __uint32_t fexcept_t;
41
42/* Exception flags */
43#ifdef __SPE__
44#define FE_OVERFLOW 0x00000100
45#define FE_UNDERFLOW 0x00000200
46#define FE_DIVBYZERO 0x00000400
47#define FE_INVALID 0x00000800
48#define FE_INEXACT 0x00001000
49
50#define FE_ALL_INVALID FE_INVALID
51
52#define _FPUSW_SHIFT 6
53#else
54#define FE_INEXACT 0x02000000
55#define FE_DIVBYZERO 0x04000000
56#define FE_UNDERFLOW 0x08000000
57#define FE_OVERFLOW 0x10000000
58#define FE_INVALID 0x20000000 /* all types of invalid FP ops */
59
60/*
61 * The PowerPC architecture has extra invalid flags that indicate the
62 * specific type of invalid operation occurred. These flags may be
63 * tested, set, and cleared---but not masked---separately. All of
64 * these bits are cleared when FE_INVALID is cleared, but only
65 * FE_VXSOFT is set when FE_INVALID is explicitly set in software.
66 */
67#define FE_VXCVI 0x00000100 /* invalid integer convert */
68#define FE_VXSQRT 0x00000200 /* square root of a negative */
69#define FE_VXSOFT 0x00000400 /* software-requested exception */
70#define FE_VXVC 0x00080000 /* ordered comparison involving NaN */
71#define FE_VXIMZ 0x00100000 /* inf * 0 */
72#define FE_VXZDZ 0x00200000 /* 0 / 0 */
73#define FE_VXIDI 0x00400000 /* inf / inf */
74#define FE_VXISI 0x00800000 /* inf - inf */
75#define FE_VXSNAN 0x01000000 /* operation on a signalling NaN */
76#define FE_ALL_INVALID (FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \
77 FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \
78 FE_VXSNAN | FE_INVALID)
79
80#define _FPUSW_SHIFT 22
81#endif
82#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
83 FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
84
85/* Rounding modes */
86#define FE_TONEAREST 0x0000
87#define FE_TOWARDZERO 0x0001
88#define FE_UPWARD 0x0002
89#define FE_DOWNWARD 0x0003
90#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
91 FE_UPWARD | FE_TOWARDZERO)
92
93__BEGIN_DECLS
94
95/* Default floating-point environment */
96extern const fenv_t __fe_dfl_env;
97#define FE_DFL_ENV (&__fe_dfl_env)
98
99/* We need to be able to map status flag positions to mask flag positions */
100#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
101 FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)
102
103#ifndef _SOFT_FLOAT
104#ifdef __SPE__
105#define __mffs(__env) \
106 __asm __volatile("mfspr %0, 512" : "=r" ((__env)->__bits.__reg))
107#define __mtfsf(__env) \
108 __asm __volatile("mtspr 512,%0;isync" :: "r" ((__env).__bits.__reg))
109#else
110#define __mffs(__env) \
111 __asm __volatile("mffs %0" : "=f" ((__env)->__d))
112#define __mtfsf(__env) \
113 __asm __volatile("mtfsf 255,%0" :: "f" ((__env).__d))
114#endif
115#else
116#define __mffs(__env)
117#define __mtfsf(__env)
118#endif
119
120union __fpscr {
121 double __d;
122 struct {
123#if _BYTE_ORDER == _LITTLE_ENDIAN
124 fenv_t __reg;
125 __uint32_t __junk;
126#else
127 __uint32_t __junk;
128 fenv_t __reg;
129#endif
130 } __bits;
131};
132
133__fenv_static inline int
134feclearexcept(int __excepts)
135{
136 union __fpscr __r;
137
138 if (__excepts & FE_INVALID)
139 __excepts |= FE_ALL_INVALID;
140 __mffs(&__r);
141 __r.__bits.__reg &= ~__excepts;
142 __mtfsf(__r);
143 return (0);
144}
145
146__fenv_static inline int
147fegetexceptflag(fexcept_t *__flagp, int __excepts)
148{
149 union __fpscr __r;
150
151 __mffs(&__r);
152 *__flagp = __r.__bits.__reg & __excepts;
153 return (0);
154}
155
156__fenv_static inline int
157fesetexceptflag(const fexcept_t *__flagp, int __excepts)
158{
159 union __fpscr __r;
160
161 if (__excepts & FE_INVALID)
162 __excepts |= FE_ALL_INVALID;
163 __mffs(&__r);
164 __r.__bits.__reg &= ~__excepts;
165 __r.__bits.__reg |= *__flagp & __excepts;
166 __mtfsf(__r);
167 return (0);
168}
169
170#ifdef __SPE__
171extern int feraiseexcept(int __excepts);
172#else
173__fenv_static inline int
174feraiseexcept(int __excepts)
175{
176 union __fpscr __r;
177
178 if (__excepts & FE_INVALID)
179 __excepts |= FE_VXSOFT;
180 __mffs(&__r);
181 __r.__bits.__reg |= __excepts;
182 __mtfsf(__r);
183 return (0);
184}
185#endif
186
187__fenv_static inline int
188fetestexcept(int __excepts)
189{
190 union __fpscr __r;
191
192 __mffs(&__r);
193 return (__r.__bits.__reg & __excepts);
194}
195
196__fenv_static inline int
197fegetround(void)
198{
199 union __fpscr __r;
200
201 __mffs(&__r);
202 return (__r.__bits.__reg & _ROUND_MASK);
203}
204
205__fenv_static inline int
206fesetround(int __round)
207{
208 union __fpscr __r;
209
210 if (__round & ~_ROUND_MASK)
211 return (-1);
212 __mffs(&__r);
213 __r.__bits.__reg &= ~_ROUND_MASK;
214 __r.__bits.__reg |= __round;
215 __mtfsf(__r);
216 return (0);
217}
218
219__fenv_static inline int
220fegetenv(fenv_t *__envp)
221{
222 union __fpscr __r;
223
224 __mffs(&__r);
225 *__envp = __r.__bits.__reg;
226 return (0);
227}
228
229__fenv_static inline int
230feholdexcept(fenv_t *__envp)
231{
232 union __fpscr __r;
233
234 __mffs(&__r);
235 *__envp = __r.__bits.__reg;
236 __r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
237 __mtfsf(__r);
238 return (0);
239}
240
241__fenv_static inline int
242fesetenv(const fenv_t *__envp)
243{
244 union __fpscr __r;
245
246 __r.__bits.__reg = *__envp;
247 __mtfsf(__r);
248 return (0);
249}
250
251__fenv_static inline int
252feupdateenv(const fenv_t *__envp)
253{
254 union __fpscr __r;
255
256 __mffs(&__r);
257 __r.__bits.__reg &= FE_ALL_EXCEPT;
258 __r.__bits.__reg |= *__envp;
259 __mtfsf(__r);
260 return (0);
261}
262
263#if __BSD_VISIBLE
264
265__fenv_static inline int
266feenableexcept(int __mask)
267{
268 union __fpscr __r;
269 fenv_t __oldmask;
270
271 __mffs(&__r);
272 __oldmask = __r.__bits.__reg;
273 __r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT;
274 __mtfsf(__r);
275 return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
276}
277
278__fenv_static inline int
279fedisableexcept(int __mask)
280{
281 union __fpscr __r;
282 fenv_t __oldmask;
283
284 __mffs(&__r);
285 __oldmask = __r.__bits.__reg;
286 __r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT);
287 __mtfsf(__r);
288 return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
289}
290
291/* We currently provide no external definition of fegetexcept(). */
292static inline int
293fegetexcept(void)
294{
295 union __fpscr __r;
296
297 __mffs(&__r);
298 return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT);
299}
300
301#endif /* __BSD_VISIBLE */
302
303__END_DECLS
304
305#endif /* !_FENV_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/float.h created+98
......@@ -0,0 +1,98 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1989 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11
31 */
32
33#ifndef _MACHINE_FLOAT_H_
34#define _MACHINE_FLOAT_H_ 1
35
36#include <sys/cdefs.h>
37
38#ifndef _SOFT_FLOAT
39__BEGIN_DECLS
40extern int __flt_rounds(void);
41__END_DECLS
42#define FLT_ROUNDS __flt_rounds()
43#else
44#define FLT_ROUNDS (-1)
45#endif
46
47#define FLT_RADIX 2 /* b */
48#if __ISO_C_VISIBLE >= 1999
49#define FLT_EVAL_METHOD 0
50#define DECIMAL_DIG 17 /* max precision in decimal digits */
51#endif
52
53#define FLT_MANT_DIG 24 /* p */
54#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
55#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
56#define FLT_MIN_EXP (-125) /* emin */
57#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
58#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
59#define FLT_MAX_EXP 128 /* emax */
60#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
61#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
62#if __ISO_C_VISIBLE >= 2011
63#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */
64#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */
65#define FLT_HAS_SUBNORM 1
66#endif /* __ISO_C_VISIBLE >= 2011 */
67
68#define DBL_MANT_DIG 53
69#define DBL_EPSILON 2.2204460492503131E-16
70#define DBL_DIG 15
71#define DBL_MIN_EXP (-1021)
72#define DBL_MIN 2.2250738585072014E-308
73#define DBL_MIN_10_EXP (-307)
74#define DBL_MAX_EXP 1024
75#define DBL_MAX 1.7976931348623157E+308
76#define DBL_MAX_10_EXP 308
77#if __ISO_C_VISIBLE >= 2011
78#define DBL_TRUE_MIN 4.9406564584124654E-324
79#define DBL_DECIMAL_DIG 17
80#define DBL_HAS_SUBNORM 1
81#endif /* __ISO_C_VISIBLE >= 2011 */
82
83#define LDBL_MANT_DIG DBL_MANT_DIG
84#define LDBL_EPSILON ((long double)DBL_EPSILON)
85#define LDBL_DIG DBL_DIG
86#define LDBL_MIN_EXP DBL_MIN_EXP
87#define LDBL_MIN ((long double)DBL_MIN)
88#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
89#define LDBL_MAX_EXP DBL_MAX_EXP
90#define LDBL_MAX ((long double)DBL_MAX)
91#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
92#if __ISO_C_VISIBLE >= 2011
93#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN)
94#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
95#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
96#endif /* __ISO_C_VISIBLE >= 2011 */
97
98#endif /* _MACHINE_FLOAT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/floatingpoint.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _FLOATINGPOINT_H_
33#define _FLOATINGPOINT_H_
34
35#include <machine/ieeefp.h>
36
37#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/_align.h created+51
......@@ -0,0 +1,51 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#ifndef _POWERPC_INCLUDE__ALIGN_H_
41#define _POWERPC_INCLUDE__ALIGN_H_
42
43/*
44 * Round p (pointer or byte index) up to a correctly-aligned value
45 * for all data types (int, long, ...). The result is unsigned int
46 * and must be cast to any desired pointer type.
47 */
48#define _ALIGNBYTES (sizeof(register_t) - 1)
49#define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
50
51#endif /* !_POWERPC_INCLUDE__ALIGN_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/_bus.h created+30
......@@ -0,0 +1,30 @@
1/*-
2 * Copyright (c) 2005 The FreeBSD Foundation.
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 *
6 * Derived in part from NetBSD's bus.h files by (alphabetically):
7 * Christopher G. Demetriou
8 * Charles M. Hannum
9 * Jason Thorpe
10 * The NetBSD Foundation.
11 */
12
13#ifndef POWERPC_INCLUDE__BUS_H
14#define POWERPC_INCLUDE__BUS_H
15
16#include <vm/vm_param.h>
17
18/*
19 * Bus address and size types
20 */
21typedef vm_paddr_t bus_addr_t;
22typedef vm_size_t bus_size_t;
23
24/*
25 * Access methods for bus resources and address space.
26 */
27typedef struct bus_space *bus_space_tag_t;
28typedef vm_offset_t bus_space_handle_t;
29
30#endif /* POWERPC_INCLUDE__BUS_H */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/_inttypes.h created+222
......@@ -0,0 +1,222 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $
32 */
33
34#ifndef _MACHINE_INTTYPES_H_
35#define _MACHINE_INTTYPES_H_
36
37/*
38 * Macros for format specifiers.
39 */
40
41#ifdef __LP64__
42#define __PRI64 "l"
43#define __PRIptr "l"
44#else
45#define __PRI64 "ll"
46#define __PRIptr
47#endif
48
49/* fprintf(3) macros for signed integers. */
50
51#define PRId8 "d" /* int8_t */
52#define PRId16 "d" /* int16_t */
53#define PRId32 "d" /* int32_t */
54#define PRId64 __PRI64"d" /* int64_t */
55#define PRIdLEAST8 "d" /* int_least8_t */
56#define PRIdLEAST16 "d" /* int_least16_t */
57#define PRIdLEAST32 "d" /* int_least32_t */
58#define PRIdLEAST64 __PRI64"d" /* int_least64_t */
59#define PRIdFAST8 "d" /* int_fast8_t */
60#define PRIdFAST16 "d" /* int_fast16_t */
61#define PRIdFAST32 "d" /* int_fast32_t */
62#define PRIdFAST64 __PRI64"d" /* int_fast64_t */
63#define PRIdMAX "jd" /* intmax_t */
64#define PRIdPTR __PRIptr"d" /* intptr_t */
65
66#define PRIi8 "i" /* int8_t */
67#define PRIi16 "i" /* int16_t */
68#define PRIi32 "i" /* int32_t */
69#define PRIi64 __PRI64"i" /* int64_t */
70#define PRIiLEAST8 "i" /* int_least8_t */
71#define PRIiLEAST16 "i" /* int_least16_t */
72#define PRIiLEAST32 "i" /* int_least32_t */
73#define PRIiLEAST64 __PRI64"i" /* int_least64_t */
74#define PRIiFAST8 "i" /* int_fast8_t */
75#define PRIiFAST16 "i" /* int_fast16_t */
76#define PRIiFAST32 "i" /* int_fast32_t */
77#define PRIiFAST64 __PRI64"i" /* int_fast64_t */
78#define PRIiMAX "ji" /* intmax_t */
79#define PRIiPTR __PRIptr"i" /* intptr_t */
80
81/* fprintf(3) macros for unsigned integers. */
82
83#define PRIo8 "o" /* uint8_t */
84#define PRIo16 "o" /* uint16_t */
85#define PRIo32 "o" /* uint32_t */
86#define PRIo64 __PRI64"o" /* uint64_t */
87#define PRIoLEAST8 "o" /* uint_least8_t */
88#define PRIoLEAST16 "o" /* uint_least16_t */
89#define PRIoLEAST32 "o" /* uint_least32_t */
90#define PRIoLEAST64 __PRI64"o" /* uint_least64_t */
91#define PRIoFAST8 "o" /* uint_fast8_t */
92#define PRIoFAST16 "o" /* uint_fast16_t */
93#define PRIoFAST32 "o" /* uint_fast32_t */
94#define PRIoFAST64 __PRI64"o" /* uint_fast64_t */
95#define PRIoMAX "jo" /* uintmax_t */
96#define PRIoPTR __PRIptr"o" /* uintptr_t */
97
98#define PRIu8 "u" /* uint8_t */
99#define PRIu16 "u" /* uint16_t */
100#define PRIu32 "u" /* uint32_t */
101#define PRIu64 __PRI64"u" /* uint64_t */
102#define PRIuLEAST8 "u" /* uint_least8_t */
103#define PRIuLEAST16 "u" /* uint_least16_t */
104#define PRIuLEAST32 "u" /* uint_least32_t */
105#define PRIuLEAST64 __PRI64"u" /* uint_least64_t */
106#define PRIuFAST8 "u" /* uint_fast8_t */
107#define PRIuFAST16 "u" /* uint_fast16_t */
108#define PRIuFAST32 "u" /* uint_fast32_t */
109#define PRIuFAST64 __PRI64"u" /* uint_fast64_t */
110#define PRIuMAX "ju" /* uintmax_t */
111#define PRIuPTR __PRIptr"u" /* uintptr_t */
112
113#define PRIx8 "x" /* uint8_t */
114#define PRIx16 "x" /* uint16_t */
115#define PRIx32 "x" /* uint32_t */
116#define PRIx64 __PRI64"x" /* uint64_t */
117#define PRIxLEAST8 "x" /* uint_least8_t */
118#define PRIxLEAST16 "x" /* uint_least16_t */
119#define PRIxLEAST32 "x" /* uint_least32_t */
120#define PRIxLEAST64 __PRI64"x" /* uint_least64_t */
121#define PRIxFAST8 "x" /* uint_fast8_t */
122#define PRIxFAST16 "x" /* uint_fast16_t */
123#define PRIxFAST32 "x" /* uint_fast32_t */
124#define PRIxFAST64 __PRI64"x" /* uint_fast64_t */
125#define PRIxMAX "jx" /* uintmax_t */
126#define PRIxPTR __PRIptr"x" /* uintptr_t */
127
128#define PRIX8 "X" /* uint8_t */
129#define PRIX16 "X" /* uint16_t */
130#define PRIX32 "X" /* uint32_t */
131#define PRIX64 __PRI64"X" /* uint64_t */
132#define PRIXLEAST8 "X" /* uint_least8_t */
133#define PRIXLEAST16 "X" /* uint_least16_t */
134#define PRIXLEAST32 "X" /* uint_least32_t */
135#define PRIXLEAST64 __PRI64"X" /* uint_least64_t */
136#define PRIXFAST8 "X" /* uint_fast8_t */
137#define PRIXFAST16 "X" /* uint_fast16_t */
138#define PRIXFAST32 "X" /* uint_fast32_t */
139#define PRIXFAST64 __PRI64"X" /* uint_fast64_t */
140#define PRIXMAX "jX" /* uintmax_t */
141#define PRIXPTR __PRIptr"X" /* uintptr_t */
142
143/* fscanf(3) macros for signed integers. */
144
145#define SCNd8 "hhd" /* int8_t */
146#define SCNd16 "hd" /* int16_t */
147#define SCNd32 "d" /* int32_t */
148#define SCNd64 __PRI64"d" /* int64_t */
149#define SCNdLEAST8 "hhd" /* int_least8_t */
150#define SCNdLEAST16 "hd" /* int_least16_t */
151#define SCNdLEAST32 "d" /* int_least32_t */
152#define SCNdLEAST64 __PRI64"d" /* int_least64_t */
153#define SCNdFAST8 "d" /* int_fast8_t */
154#define SCNdFAST16 "d" /* int_fast16_t */
155#define SCNdFAST32 "d" /* int_fast32_t */
156#define SCNdFAST64 __PRI64"d" /* int_fast64_t */
157#define SCNdMAX "jd" /* intmax_t */
158#define SCNdPTR __PRIptr"d" /* intptr_t */
159
160#define SCNi8 "hhi" /* int8_t */
161#define SCNi16 "hi" /* int16_t */
162#define SCNi32 "i" /* int32_t */
163#define SCNi64 __PRI64"i" /* int64_t */
164#define SCNiLEAST8 "hhi" /* int_least8_t */
165#define SCNiLEAST16 "hi" /* int_least16_t */
166#define SCNiLEAST32 "i" /* int_least32_t */
167#define SCNiLEAST64 __PRI64"i" /* int_least64_t */
168#define SCNiFAST8 "i" /* int_fast8_t */
169#define SCNiFAST16 "i" /* int_fast16_t */
170#define SCNiFAST32 "i" /* int_fast32_t */
171#define SCNiFAST64 __PRI64"i" /* int_fast64_t */
172#define SCNiMAX "ji" /* intmax_t */
173#define SCNiPTR __PRIptr"i" /* intptr_t */
174
175/* fscanf(3) macros for unsigned integers. */
176
177#define SCNo8 "hho" /* uint8_t */
178#define SCNo16 "ho" /* uint16_t */
179#define SCNo32 "o" /* uint32_t */
180#define SCNo64 __PRI64"o" /* uint64_t */
181#define SCNoLEAST8 "hho" /* uint_least8_t */
182#define SCNoLEAST16 "ho" /* uint_least16_t */
183#define SCNoLEAST32 "o" /* uint_least32_t */
184#define SCNoLEAST64 __PRI64"o" /* uint_least64_t */
185#define SCNoFAST8 "o" /* uint_fast8_t */
186#define SCNoFAST16 "o" /* uint_fast16_t */
187#define SCNoFAST32 "o" /* uint_fast32_t */
188#define SCNoFAST64 __PRI64"o" /* uint_fast64_t */
189#define SCNoMAX "jo" /* uintmax_t */
190#define SCNoPTR __PRIptr"o" /* uintptr_t */
191
192#define SCNu8 "hhu" /* uint8_t */
193#define SCNu16 "hu" /* uint16_t */
194#define SCNu32 "u" /* uint32_t */
195#define SCNu64 __PRI64"u" /* uint64_t */
196#define SCNuLEAST8 "hhu" /* uint_least8_t */
197#define SCNuLEAST16 "hu" /* uint_least16_t */
198#define SCNuLEAST32 "u" /* uint_least32_t */
199#define SCNuLEAST64 __PRI64"u" /* uint_least64_t */
200#define SCNuFAST8 "u" /* uint_fast8_t */
201#define SCNuFAST16 "u" /* uint_fast16_t */
202#define SCNuFAST32 "u" /* uint_fast32_t */
203#define SCNuFAST64 __PRI64"u" /* uint_fast64_t */
204#define SCNuMAX "ju" /* uintmax_t */
205#define SCNuPTR __PRIptr"u" /* uintptr_t */
206
207#define SCNx8 "hhx" /* uint8_t */
208#define SCNx16 "hx" /* uint16_t */
209#define SCNx32 "x" /* uint32_t */
210#define SCNx64 __PRI64"x" /* uint64_t */
211#define SCNxLEAST8 "hhx" /* uint_least8_t */
212#define SCNxLEAST16 "hx" /* uint_least16_t */
213#define SCNxLEAST32 "x" /* uint_least32_t */
214#define SCNxLEAST64 __PRI64"x" /* uint_least64_t */
215#define SCNxFAST8 "x" /* uint_fast8_t */
216#define SCNxFAST16 "x" /* uint_fast16_t */
217#define SCNxFAST32 "x" /* uint_fast32_t */
218#define SCNxFAST64 __PRI64"x" /* uint_fast64_t */
219#define SCNxMAX "jx" /* uintmax_t */
220#define SCNxPTR __PRIptr"x" /* uintptr_t */
221
222#endif /* !_MACHINE_INTTYPES_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/_limits.h created+96
......@@ -0,0 +1,96 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE__LIMITS_H_
33#define _MACHINE__LIMITS_H_
34
35/*
36 * According to ANSI (section 2.2.4.2), the values below must be usable by
37 * #if preprocessing directives. Additionally, the expression must have the
38 * same type as would an expression that is an object of the corresponding
39 * type converted according to the integral promotions. The subtraction for
40 * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
41 * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
42 */
43
44#define __CHAR_BIT 8 /* number of bits in a char */
45
46#define __SCHAR_MAX 0x7f /* max value for a signed char */
47#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
48
49#define __UCHAR_MAX 0xff /* max value for an unsigned char */
50
51#define __USHRT_MAX 0xffff /* max value for an unsigned short */
52#define __SHRT_MAX 0x7fff /* max value for a short */
53#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
54
55#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
56#define __INT_MAX 0x7fffffff /* max value for an int */
57#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
58
59#ifdef __LP64__
60#define __ULONG_MAX 0xffffffffffffffff
61#define __LONG_MAX 0x7fffffffffffffff
62#define __LONG_MIN (-0x7fffffffffffffff - 1)
63#define __LONG_BIT 64
64#else
65#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
66#define __LONG_MAX 0x7fffffffL /* max value for a long */
67#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
68#define __LONG_BIT 32
69#endif
70
71#define __ULLONG_MAX 0xffffffffffffffffULL
72#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
73#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
74
75#ifdef __LP64__
76#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */
77#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */
78#else
79#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */
80#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */
81#endif
82
83#define __OFF_MAX __LLONG_MAX /* max value for an off_t */
84#define __OFF_MIN __LLONG_MIN /* min value for an off_t */
85
86/* Quads and long longs are the same size. Ensure they stay in sync. */
87#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
88#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
89#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
90
91#define __WORD_BIT 32
92
93/* Minimum signal stack size. */
94#define __MINSIGSTKSZ (512 * 4)
95
96#endif /* !_MACHINE__LIMITS_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/_stdint.h created+200
......@@ -0,0 +1,200 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
5 * Copyright (c) 2001 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Klaus Klein.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifndef _MACHINE__STDINT_H_
41#define _MACHINE__STDINT_H_
42
43#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
44
45#define INT8_C(c) (c)
46#define INT16_C(c) (c)
47#define INT32_C(c) (c)
48
49#define UINT8_C(c) (c)
50#define UINT16_C(c) (c)
51#define UINT32_C(c) (c ## U)
52
53#ifdef __LP64__
54#define INT64_C(c) (c ## L)
55#define UINT64_C(c) (c ## UL)
56#else
57#define INT64_C(c) (c ## LL)
58#define UINT64_C(c) (c ## ULL)
59#endif
60
61#define INTMAX_C(c) INT64_C(c)
62#define UINTMAX_C(c) UINT64_C(c)
63
64#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
65
66#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
67
68#ifndef __INT64_C
69#ifdef __LP64__
70#define __INT64_C(c) (c ## L)
71#define __UINT64_C(c) (c ## UL)
72#else
73#define __INT64_C(c) (c ## LL)
74#define __UINT64_C(c) (c ## ULL)
75#endif
76#endif
77
78/*
79 * ISO/IEC 9899:1999
80 * 7.18.2.1 Limits of exact-width integer types
81 */
82/* Minimum values of exact-width signed integer types. */
83#define INT8_MIN (-0x7f-1)
84#define INT16_MIN (-0x7fff-1)
85#define INT32_MIN (-0x7fffffff-1)
86#define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1)
87
88/* Maximum values of exact-width signed integer types. */
89#define INT8_MAX 0x7f
90#define INT16_MAX 0x7fff
91#define INT32_MAX 0x7fffffff
92#define INT64_MAX __INT64_C(0x7fffffffffffffff)
93
94/* Maximum values of exact-width unsigned integer types. */
95#define UINT8_MAX 0xff
96#define UINT16_MAX 0xffff
97#define UINT32_MAX 0xffffffff
98#define UINT64_MAX __UINT64_C(0xffffffffffffffff)
99
100/*
101 * ISO/IEC 9899:1999
102 * 7.18.2.2 Limits of minimum-width integer types
103 */
104/* Minimum values of minimum-width signed integer types. */
105#define INT_LEAST8_MIN INT8_MIN
106#define INT_LEAST16_MIN INT16_MIN
107#define INT_LEAST32_MIN INT32_MIN
108#define INT_LEAST64_MIN INT64_MIN
109
110/* Maximum values of minimum-width signed integer types. */
111#define INT_LEAST8_MAX INT8_MAX
112#define INT_LEAST16_MAX INT16_MAX
113#define INT_LEAST32_MAX INT32_MAX
114#define INT_LEAST64_MAX INT64_MAX
115
116/* Maximum values of minimum-width unsigned integer types. */
117#define UINT_LEAST8_MAX UINT8_MAX
118#define UINT_LEAST16_MAX UINT16_MAX
119#define UINT_LEAST32_MAX UINT32_MAX
120#define UINT_LEAST64_MAX UINT64_MAX
121
122/*
123 * ISO/IEC 9899:1999
124 * 7.18.2.3 Limits of fastest minimum-width integer types
125 */
126/* Minimum values of fastest minimum-width signed integer types. */
127#define INT_FAST8_MIN INT32_MIN
128#define INT_FAST16_MIN INT32_MIN
129#define INT_FAST32_MIN INT32_MIN
130#define INT_FAST64_MIN INT64_MIN
131
132/* Maximum values of fastest minimum-width signed integer types. */
133#define INT_FAST8_MAX INT32_MAX
134#define INT_FAST16_MAX INT32_MAX
135#define INT_FAST32_MAX INT32_MAX
136#define INT_FAST64_MAX INT64_MAX
137
138/* Maximum values of fastest minimum-width unsigned integer types. */
139#define UINT_FAST8_MAX UINT32_MAX
140#define UINT_FAST16_MAX UINT32_MAX
141#define UINT_FAST32_MAX UINT32_MAX
142#define UINT_FAST64_MAX UINT64_MAX
143
144/*
145 * ISO/IEC 9899:1999
146 * 7.18.2.4 Limits of integer types capable of holding object pointers
147 */
148#ifdef __LP64__
149#define INTPTR_MIN INT64_MIN
150#define INTPTR_MAX INT64_MAX
151#define UINTPTR_MAX UINT64_MAX
152#else
153#define INTPTR_MIN INT32_MIN
154#define INTPTR_MAX INT32_MAX
155#define UINTPTR_MAX UINT32_MAX
156#endif
157
158/*
159 * ISO/IEC 9899:1999
160 * 7.18.2.5 Limits of greatest-width integer types
161 */
162#define INTMAX_MIN INT64_MIN
163#define INTMAX_MAX INT64_MAX
164#define UINTMAX_MAX UINT64_MAX
165
166/*
167 * ISO/IEC 9899:1999
168 * 7.18.3 Limits of other integer types
169 */
170#ifdef __LP64__
171/* Limits of ptrdiff_t. */
172#define PTRDIFF_MIN INT64_MIN
173#define PTRDIFF_MAX INT64_MAX
174
175/* Limits of sig_atomic_t. */
176#define SIG_ATOMIC_MIN INT64_MIN
177#define SIG_ATOMIC_MAX INT64_MAX
178
179/* Limit of size_t. */
180#define SIZE_MAX UINT64_MAX
181#else
182/* Limits of ptrdiff_t. */
183#define PTRDIFF_MIN INT32_MIN
184#define PTRDIFF_MAX INT32_MAX
185
186/* Limits of sig_atomic_t. */
187#define SIG_ATOMIC_MIN INT32_MIN
188#define SIG_ATOMIC_MAX INT32_MAX
189
190/* Limit of size_t. */
191#define SIZE_MAX UINT32_MAX
192#endif
193
194/* Limits of wint_t. */
195#define WINT_MIN INT32_MIN
196#define WINT_MAX INT32_MAX
197
198#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
199
200#endif /* !_MACHINE__STDINT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/_types.h created+89
......@@ -0,0 +1,89 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef _MACHINE__TYPES_H_
38#define _MACHINE__TYPES_H_
39
40#ifndef _SYS__TYPES_H_
41#error do not include this header, use sys/_types.h
42#endif
43
44/*
45 * Standard type definitions.
46 */
47typedef __uint32_t __clock_t; /* clock()... */
48#ifndef _STANDALONE
49typedef double __double_t;
50typedef float __float_t;
51#endif
52#ifdef __LP64__
53typedef __int64_t __critical_t;
54#else
55typedef __int32_t __critical_t;
56#endif
57typedef __int32_t __int_fast8_t;
58typedef __int32_t __int_fast16_t;
59typedef __int32_t __int_fast32_t;
60typedef __int64_t __int_fast64_t;
61#ifdef __LP64__
62typedef __int64_t __register_t;
63typedef __int64_t __segsz_t; /* segment size (in pages) */
64#else
65typedef __int32_t __register_t;
66typedef __int32_t __segsz_t; /* segment size (in pages) */
67#endif
68typedef __int64_t __time_t; /* time()... */
69typedef __uint32_t __uint_fast8_t;
70typedef __uint32_t __uint_fast16_t;
71typedef __uint32_t __uint_fast32_t;
72typedef __uint64_t __uint_fast64_t;
73#ifdef __LP64__
74typedef __uint64_t __u_register_t;
75typedef __uint64_t __vm_paddr_t;
76#else
77typedef __uint32_t __u_register_t;
78#ifdef BOOKE
79typedef __uint64_t __vm_paddr_t;
80#else
81typedef __uint32_t __vm_paddr_t;
82#endif
83#endif
84typedef int ___wchar_t;
85
86#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
87#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */
88
89#endif /* !_MACHINE__TYPES_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/altivec.h created+41
......@@ -0,0 +1,41 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Nathan Whitehorn
5 * All rights reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_ALTIVEC_H_
30#define _MACHINE_ALTIVEC_H_
31
32#define ALTIVEC_VSCR_NJ 0x00010000 /* Enable non-Java mode */
33#define ALTIVEC_VSCR_SAT 0x00000001 /* Saturation status bit */
34
35void enable_vec(struct thread *);
36void save_vec(struct thread *);
37void save_vec_nodrop(struct thread *);
38void enable_vec_kern(void);
39void disable_vec(struct thread *td);
40
41#endif /* _MACHINE_ALTIVEC_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/asm.h created+267
......@@ -0,0 +1,267 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: asm.h,v 1.6.18.1 2000/07/25 08:37:14 kleink Exp $
34 */
35
36#ifndef _MACHINE_ASM_H_
37#define _MACHINE_ASM_H_
38
39#include <sys/cdefs.h>
40
41#if defined(PIC) && !defined(__powerpc64__)
42#define PIC_PROLOGUE XXX
43#define PIC_EPILOGUE XXX
44#define PIC_PLT(x) x@plt
45#ifdef __STDC__
46#define PIC_GOT(x) XXX
47#else /* not __STDC__ */
48#define PIC_GOT(x) XXX
49#endif /* __STDC__ */
50#else
51#define PIC_PROLOGUE
52#define PIC_EPILOGUE
53#define PIC_PLT(x) x
54#define PIC_GOT(x) x
55#endif
56
57#define CNAME(csym) csym
58#define ASMNAME(asmsym) asmsym
59#ifdef __powerpc64__
60#define HIDENAME(asmsym) __CONCAT(_,asmsym)
61#else
62#define HIDENAME(asmsym) __CONCAT(.,asmsym)
63#endif
64
65#if !defined(_CALL_ELF) || _CALL_ELF == 1
66#ifdef _KERNEL
67/* ELFv1 kernel uses global dot symbols */
68#define DOT_LABEL(name) __CONCAT(.,name)
69#define TYPE_ENTRY(name) .size name,24; \
70 .type DOT_LABEL(name),@function; \
71 .globl DOT_LABEL(name);
72#define END_SIZE(name) .size DOT_LABEL(name),.-DOT_LABEL(name);
73#else /* !_KERNEL */
74/* ELFv1 user code uses local function entry points */
75#define DOT_LABEL(name) __CONCAT(.L.,name)
76#define TYPE_ENTRY(name) .type name,@function;
77#define END_SIZE(name) .size name,.-DOT_LABEL(name);
78#endif /* _KERNEL */
79#else
80/* ELFv2 doesn't have any of this complication */
81#define DOT_LABEL(name) name
82#define TYPE_ENTRY(name) .type name,@function;
83#define END_SIZE(name) .size name,.-DOT_LABEL(name);
84#endif
85
86#define _GLOBAL(name) \
87 .data; \
88 .p2align 2; \
89 .globl name; \
90 name:
91
92#ifdef __powerpc64__
93#define TOC_NAME_FOR_REF(name) __CONCAT(.L,name)
94#define TOC_REF(name) TOC_NAME_FOR_REF(name)@toc
95#define TOC_ENTRY(name) \
96 .section ".toc","aw"; \
97 TOC_NAME_FOR_REF(name): \
98 .tc name[TC],name
99#endif
100
101#ifdef __powerpc64__
102
103#if !defined(_CALL_ELF) || _CALL_ELF == 1
104#define _ENTRY(name) \
105 .section ".text"; \
106 .p2align 2; \
107 .globl name; \
108 .section ".opd","aw"; \
109 .p2align 3; \
110name: \
111 .quad DOT_LABEL(name),.TOC.@tocbase,0; \
112 .previous; \
113 .p2align 4; \
114 TYPE_ENTRY(name) \
115DOT_LABEL(name): \
116 .cfi_startproc
117#define _NAKED_ENTRY(name) _ENTRY(name)
118#else
119#define _ENTRY(name) \
120 .text; \
121 .p2align 4; \
122 .globl name; \
123 .type name,@function; \
124name: \
125 .cfi_startproc; \
126 addis %r2, %r12, (.TOC.-name)@ha; \
127 addi %r2, %r2, (.TOC.-name)@l; \
128 .localentry name, .-name;
129
130/* "Naked" function entry. No TOC prologue for ELFv2. */
131#define _NAKED_ENTRY(name) \
132 .text; \
133 .p2align 4; \
134 .globl name; \
135 .type name,@function; \
136name: \
137 .cfi_startproc; \
138 .localentry name, .-name;
139#endif
140
141#define _END(name) \
142 .cfi_endproc; \
143 .long 0; \
144 .byte 0,0,0,0,0,0,0,0; \
145 END_SIZE(name)
146
147#define LOAD_ADDR(reg, var) \
148 lis reg, var@highest; \
149 ori reg, reg, var@higher; \
150 rldicr reg, reg, 32, 31; \
151 oris reg, reg, var@h; \
152 ori reg, reg, var@l;
153#else /* !__powerpc64__ */
154#define _ENTRY(name) \
155 .text; \
156 .p2align 4; \
157 .globl name; \
158 .type name,@function; \
159name: \
160 .cfi_startproc
161#define _END(name) \
162 .cfi_endproc; \
163 .size name, . - name
164
165#define _NAKED_ENTRY(name) _ENTRY(name)
166
167#define LOAD_ADDR(reg, var) \
168 lis reg, var@ha; \
169 ori reg, reg, var@l;
170#endif /* __powerpc64__ */
171
172#if defined(PROF) || (defined(_KERNEL) && defined(GPROF))
173# ifdef __powerpc64__
174# define _PROF_PROLOGUE mflr 0; \
175 std 3,48(1); \
176 std 4,56(1); \
177 std 5,64(1); \
178 std 0,16(1); \
179 stdu 1,-112(1); \
180 bl _mcount; \
181 nop; \
182 ld 0,112+16(1); \
183 ld 3,112+48(1); \
184 ld 4,112+56(1); \
185 ld 5,112+64(1); \
186 mtlr 0; \
187 addi 1,1,112
188# else
189# define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount
190# endif
191#else
192# define _PROF_PROLOGUE
193#endif
194
195#define ASEND(y) _END(ASMNAME(y))
196#define ASENTRY(y) _ENTRY(ASMNAME(y)); _PROF_PROLOGUE
197#define END(y) _END(CNAME(y))
198#define ENTRY(y) _ENTRY(CNAME(y)); _PROF_PROLOGUE
199#define GLOBAL(y) _GLOBAL(CNAME(y))
200
201#define ASENTRY_NOPROF(y) _ENTRY(ASMNAME(y))
202#define ENTRY_NOPROF(y) _ENTRY(CNAME(y))
203
204/* Load NIA without affecting branch prediction */
205#define LOAD_LR_NIA bcl 20, 31, .+4
206
207/*
208 * Magic sequence to return to native endian.
209 * Overwrites r0 and r11.
210 *
211 * The encoding of the instruction "tdi 0, %r0, 0x48" in opposite endian
212 * happens to be "b . + 8". This is useful because we can write a sequence
213 * of instructions that can execute in either endian.
214 *
215 * Use a sequence of handcoded instructions that switches contexts to the
216 * instruction following the sequence, but with the correct PSL_LE bit.
217 *
218 * The same sequence works for both BE and LE because the xori will flip
219 * the bit to the other state, and the code only runs when running in the
220 * wrong endian.
221 *
222 * This sequence is NMI-reentrant.
223 *
224 * Do not change the length of this sequence without looking at the users,
225 * this is used in size-constrained places like the reset vector!
226 */
227#define RETURN_TO_NATIVE_ENDIAN \
228 tdi 0, %r0, 0x48; /* Endian swapped: b . + 8 */\
229 b 1f; /* Will fall through to here if correct */\
230 .long 0xa600607d; /* mfmsr %r11 */\
231 .long 0x00000038; /* li %r0, 0 */\
232 .long 0x6401617d; /* mtmsrd %r0, 1 (L=1 EE,RI bits only) */\
233 .long 0x01006b69; /* xori %r11, %r11, 0x1 (PSL_LE) */\
234 .long 0xa602087c; /* mflr %r0 */\
235 .long 0x05009f42; /* LOAD_LR_NIA */\
236 .long 0xa6037b7d; /* 0: mtsrr1 %r11 */\
237 .long 0xa602687d; /* mflr %r11 */\
238 .long 0x18006b39; /* addi %r11, %r11, (1f - 0b) */\
239 .long 0xa6037a7d; /* mtsrr0 %r11 */\
240 .long 0xa603087c; /* mtlr %r0 */\
241 .long 0x2400004c; /* rfid */\
2421: /* RETURN_TO_NATIVE_ENDIAN */
243
244#define ASMSTR .asciz
245
246#define RCSID(x) .text; .asciz x
247
248#undef __FBSDID
249#if !defined(lint) && !defined(STRIP_FBSDID)
250#define __FBSDID(s) .ident s
251#else
252#define __FBSDID(s) /* nothing */
253#endif /* not lint and not STRIP_FBSDID */
254
255#define WEAK_REFERENCE(sym, alias) \
256 .weak alias; \
257 .equ alias,sym
258
259#ifdef __STDC__
260#define WARN_REFERENCES(_sym,_msg) \
261 .section .gnu.warning. ## _sym ; .ascii _msg ; .text
262#else
263#define WARN_REFERENCES(_sym,_msg) \
264 .section .gnu.warning./**/_sym ; .ascii _msg ; .text
265#endif /* __STDC__ */
266
267#endif /* !_MACHINE_ASM_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/atomic.h created+1183
......@@ -0,0 +1,1183 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Marcel Moolenaar
5 * Copyright (c) 2001 Benno Rice
6 * Copyright (c) 2001 David E. O'Brien
7 * Copyright (c) 1998 Doug Rabson
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_ATOMIC_H_
33#define _MACHINE_ATOMIC_H_
34
35#include <sys/atomic_common.h>
36
37#ifndef __powerpc64__
38#include <sys/_atomic64e.h>
39#endif
40
41/*
42 * The __ATOMIC_REL/ACQ() macros provide memory barriers only in conjunction
43 * with the atomic lXarx/stXcx. sequences below. They are not exposed outside
44 * of this file. See also Appendix B.2 of Book II of the architecture manual.
45 *
46 * Note that not all Book-E processors accept the light-weight sync variant.
47 * In particular, early models of E500 cores are known to wedge. Bank on all
48 * 64-bit capable CPUs to accept lwsync properly and pressimize 32-bit CPUs
49 * to use the heavier-weight sync.
50 */
51
52#ifdef __powerpc64__
53#define mb() __asm __volatile("sync" : : : "memory")
54#define rmb() __asm __volatile("lwsync" : : : "memory")
55#define wmb() __asm __volatile("lwsync" : : : "memory")
56#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory")
57#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory")
58#else
59#define mb() __asm __volatile("sync" : : : "memory")
60#define rmb() __asm __volatile("sync" : : : "memory")
61#define wmb() __asm __volatile("sync" : : : "memory")
62#define __ATOMIC_REL() __asm __volatile("sync" : : : "memory")
63#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory")
64#endif
65
66static __inline void
67powerpc_lwsync(void)
68{
69
70#ifdef __powerpc64__
71 __asm __volatile("lwsync" : : : "memory");
72#else
73 __asm __volatile("sync" : : : "memory");
74#endif
75}
76
77/*
78 * atomic_add(p, v)
79 * { *p += v; }
80 */
81
82#define __atomic_add_int(p, v, t) \
83 __asm __volatile( \
84 "1: lwarx %0, 0, %2\n" \
85 " add %0, %3, %0\n" \
86 " stwcx. %0, 0, %2\n" \
87 " bne- 1b\n" \
88 : "=&r" (t), "=m" (*p) \
89 : "r" (p), "r" (v), "m" (*p) \
90 : "cr0", "memory") \
91 /* __atomic_add_int */
92
93#ifdef __powerpc64__
94#define __atomic_add_long(p, v, t) \
95 __asm __volatile( \
96 "1: ldarx %0, 0, %2\n" \
97 " add %0, %3, %0\n" \
98 " stdcx. %0, 0, %2\n" \
99 " bne- 1b\n" \
100 : "=&r" (t), "=m" (*p) \
101 : "r" (p), "r" (v), "m" (*p) \
102 : "cr0", "memory") \
103 /* __atomic_add_long */
104#else
105#define __atomic_add_long(p, v, t) \
106 __asm __volatile( \
107 "1: lwarx %0, 0, %2\n" \
108 " add %0, %3, %0\n" \
109 " stwcx. %0, 0, %2\n" \
110 " bne- 1b\n" \
111 : "=&r" (t), "=m" (*p) \
112 : "r" (p), "r" (v), "m" (*p) \
113 : "cr0", "memory") \
114 /* __atomic_add_long */
115#endif
116
117#define _ATOMIC_ADD(type) \
118 static __inline void \
119 atomic_add_##type(volatile u_##type *p, u_##type v) { \
120 u_##type t; \
121 __atomic_add_##type(p, v, t); \
122 } \
123 \
124 static __inline void \
125 atomic_add_acq_##type(volatile u_##type *p, u_##type v) { \
126 u_##type t; \
127 __atomic_add_##type(p, v, t); \
128 __ATOMIC_ACQ(); \
129 } \
130 \
131 static __inline void \
132 atomic_add_rel_##type(volatile u_##type *p, u_##type v) { \
133 u_##type t; \
134 __ATOMIC_REL(); \
135 __atomic_add_##type(p, v, t); \
136 } \
137 /* _ATOMIC_ADD */
138
139_ATOMIC_ADD(int)
140_ATOMIC_ADD(long)
141
142#define atomic_add_32 atomic_add_int
143#define atomic_add_acq_32 atomic_add_acq_int
144#define atomic_add_rel_32 atomic_add_rel_int
145
146#ifdef __powerpc64__
147#define atomic_add_64 atomic_add_long
148#define atomic_add_acq_64 atomic_add_acq_long
149#define atomic_add_rel_64 atomic_add_rel_long
150
151#define atomic_add_ptr atomic_add_long
152#define atomic_add_acq_ptr atomic_add_acq_long
153#define atomic_add_rel_ptr atomic_add_rel_long
154#else
155#define atomic_add_ptr atomic_add_int
156#define atomic_add_acq_ptr atomic_add_acq_int
157#define atomic_add_rel_ptr atomic_add_rel_int
158#endif
159#undef _ATOMIC_ADD
160#undef __atomic_add_long
161#undef __atomic_add_int
162
163/*
164 * atomic_clear(p, v)
165 * { *p &= ~v; }
166 */
167
168#define __atomic_clear_int(p, v, t) \
169 __asm __volatile( \
170 "1: lwarx %0, 0, %2\n" \
171 " andc %0, %0, %3\n" \
172 " stwcx. %0, 0, %2\n" \
173 " bne- 1b\n" \
174 : "=&r" (t), "=m" (*p) \
175 : "r" (p), "r" (v), "m" (*p) \
176 : "cr0", "memory") \
177 /* __atomic_clear_int */
178
179#ifdef __powerpc64__
180#define __atomic_clear_long(p, v, t) \
181 __asm __volatile( \
182 "1: ldarx %0, 0, %2\n" \
183 " andc %0, %0, %3\n" \
184 " stdcx. %0, 0, %2\n" \
185 " bne- 1b\n" \
186 : "=&r" (t), "=m" (*p) \
187 : "r" (p), "r" (v), "m" (*p) \
188 : "cr0", "memory") \
189 /* __atomic_clear_long */
190#else
191#define __atomic_clear_long(p, v, t) \
192 __asm __volatile( \
193 "1: lwarx %0, 0, %2\n" \
194 " andc %0, %0, %3\n" \
195 " stwcx. %0, 0, %2\n" \
196 " bne- 1b\n" \
197 : "=&r" (t), "=m" (*p) \
198 : "r" (p), "r" (v), "m" (*p) \
199 : "cr0", "memory") \
200 /* __atomic_clear_long */
201#endif
202
203#define _ATOMIC_CLEAR(type) \
204 static __inline void \
205 atomic_clear_##type(volatile u_##type *p, u_##type v) { \
206 u_##type t; \
207 __atomic_clear_##type(p, v, t); \
208 } \
209 \
210 static __inline void \
211 atomic_clear_acq_##type(volatile u_##type *p, u_##type v) { \
212 u_##type t; \
213 __atomic_clear_##type(p, v, t); \
214 __ATOMIC_ACQ(); \
215 } \
216 \
217 static __inline void \
218 atomic_clear_rel_##type(volatile u_##type *p, u_##type v) { \
219 u_##type t; \
220 __ATOMIC_REL(); \
221 __atomic_clear_##type(p, v, t); \
222 } \
223 /* _ATOMIC_CLEAR */
224
225_ATOMIC_CLEAR(int)
226_ATOMIC_CLEAR(long)
227
228#define atomic_clear_32 atomic_clear_int
229#define atomic_clear_acq_32 atomic_clear_acq_int
230#define atomic_clear_rel_32 atomic_clear_rel_int
231
232#ifdef __powerpc64__
233#define atomic_clear_64 atomic_clear_long
234#define atomic_clear_acq_64 atomic_clear_acq_long
235#define atomic_clear_rel_64 atomic_clear_rel_long
236
237#define atomic_clear_ptr atomic_clear_long
238#define atomic_clear_acq_ptr atomic_clear_acq_long
239#define atomic_clear_rel_ptr atomic_clear_rel_long
240#else
241#define atomic_clear_ptr atomic_clear_int
242#define atomic_clear_acq_ptr atomic_clear_acq_int
243#define atomic_clear_rel_ptr atomic_clear_rel_int
244#endif
245#undef _ATOMIC_CLEAR
246#undef __atomic_clear_long
247#undef __atomic_clear_int
248
249/*
250 * atomic_cmpset(p, o, n)
251 */
252/* TODO -- see below */
253
254/*
255 * atomic_load_acq(p)
256 */
257/* TODO -- see below */
258
259/*
260 * atomic_readandclear(p)
261 */
262/* TODO -- see below */
263
264/*
265 * atomic_set(p, v)
266 * { *p |= v; }
267 */
268
269#define __atomic_set_int(p, v, t) \
270 __asm __volatile( \
271 "1: lwarx %0, 0, %2\n" \
272 " or %0, %3, %0\n" \
273 " stwcx. %0, 0, %2\n" \
274 " bne- 1b\n" \
275 : "=&r" (t), "=m" (*p) \
276 : "r" (p), "r" (v), "m" (*p) \
277 : "cr0", "memory") \
278 /* __atomic_set_int */
279
280#ifdef __powerpc64__
281#define __atomic_set_long(p, v, t) \
282 __asm __volatile( \
283 "1: ldarx %0, 0, %2\n" \
284 " or %0, %3, %0\n" \
285 " stdcx. %0, 0, %2\n" \
286 " bne- 1b\n" \
287 : "=&r" (t), "=m" (*p) \
288 : "r" (p), "r" (v), "m" (*p) \
289 : "cr0", "memory") \
290 /* __atomic_set_long */
291#else
292#define __atomic_set_long(p, v, t) \
293 __asm __volatile( \
294 "1: lwarx %0, 0, %2\n" \
295 " or %0, %3, %0\n" \
296 " stwcx. %0, 0, %2\n" \
297 " bne- 1b\n" \
298 : "=&r" (t), "=m" (*p) \
299 : "r" (p), "r" (v), "m" (*p) \
300 : "cr0", "memory") \
301 /* __atomic_set_long */
302#endif
303
304#define _ATOMIC_SET(type) \
305 static __inline void \
306 atomic_set_##type(volatile u_##type *p, u_##type v) { \
307 u_##type t; \
308 __atomic_set_##type(p, v, t); \
309 } \
310 \
311 static __inline void \
312 atomic_set_acq_##type(volatile u_##type *p, u_##type v) { \
313 u_##type t; \
314 __atomic_set_##type(p, v, t); \
315 __ATOMIC_ACQ(); \
316 } \
317 \
318 static __inline void \
319 atomic_set_rel_##type(volatile u_##type *p, u_##type v) { \
320 u_##type t; \
321 __ATOMIC_REL(); \
322 __atomic_set_##type(p, v, t); \
323 } \
324 /* _ATOMIC_SET */
325
326_ATOMIC_SET(int)
327_ATOMIC_SET(long)
328
329#define atomic_set_32 atomic_set_int
330#define atomic_set_acq_32 atomic_set_acq_int
331#define atomic_set_rel_32 atomic_set_rel_int
332
333#ifdef __powerpc64__
334#define atomic_set_64 atomic_set_long
335#define atomic_set_acq_64 atomic_set_acq_long
336#define atomic_set_rel_64 atomic_set_rel_long
337
338#define atomic_set_ptr atomic_set_long
339#define atomic_set_acq_ptr atomic_set_acq_long
340#define atomic_set_rel_ptr atomic_set_rel_long
341#else
342#define atomic_set_ptr atomic_set_int
343#define atomic_set_acq_ptr atomic_set_acq_int
344#define atomic_set_rel_ptr atomic_set_rel_int
345#endif
346#undef _ATOMIC_SET
347#undef __atomic_set_long
348#undef __atomic_set_int
349
350/*
351 * atomic_subtract(p, v)
352 * { *p -= v; }
353 */
354
355#define __atomic_subtract_int(p, v, t) \
356 __asm __volatile( \
357 "1: lwarx %0, 0, %2\n" \
358 " subf %0, %3, %0\n" \
359 " stwcx. %0, 0, %2\n" \
360 " bne- 1b\n" \
361 : "=&r" (t), "=m" (*p) \
362 : "r" (p), "r" (v), "m" (*p) \
363 : "cr0", "memory") \
364 /* __atomic_subtract_int */
365
366#ifdef __powerpc64__
367#define __atomic_subtract_long(p, v, t) \
368 __asm __volatile( \
369 "1: ldarx %0, 0, %2\n" \
370 " subf %0, %3, %0\n" \
371 " stdcx. %0, 0, %2\n" \
372 " bne- 1b\n" \
373 : "=&r" (t), "=m" (*p) \
374 : "r" (p), "r" (v), "m" (*p) \
375 : "cr0", "memory") \
376 /* __atomic_subtract_long */
377#else
378#define __atomic_subtract_long(p, v, t) \
379 __asm __volatile( \
380 "1: lwarx %0, 0, %2\n" \
381 " subf %0, %3, %0\n" \
382 " stwcx. %0, 0, %2\n" \
383 " bne- 1b\n" \
384 : "=&r" (t), "=m" (*p) \
385 : "r" (p), "r" (v), "m" (*p) \
386 : "cr0", "memory") \
387 /* __atomic_subtract_long */
388#endif
389
390#define _ATOMIC_SUBTRACT(type) \
391 static __inline void \
392 atomic_subtract_##type(volatile u_##type *p, u_##type v) { \
393 u_##type t; \
394 __atomic_subtract_##type(p, v, t); \
395 } \
396 \
397 static __inline void \
398 atomic_subtract_acq_##type(volatile u_##type *p, u_##type v) { \
399 u_##type t; \
400 __atomic_subtract_##type(p, v, t); \
401 __ATOMIC_ACQ(); \
402 } \
403 \
404 static __inline void \
405 atomic_subtract_rel_##type(volatile u_##type *p, u_##type v) { \
406 u_##type t; \
407 __ATOMIC_REL(); \
408 __atomic_subtract_##type(p, v, t); \
409 } \
410 /* _ATOMIC_SUBTRACT */
411
412_ATOMIC_SUBTRACT(int)
413_ATOMIC_SUBTRACT(long)
414
415#define atomic_subtract_32 atomic_subtract_int
416#define atomic_subtract_acq_32 atomic_subtract_acq_int
417#define atomic_subtract_rel_32 atomic_subtract_rel_int
418
419#ifdef __powerpc64__
420#define atomic_subtract_64 atomic_subtract_long
421#define atomic_subtract_acq_64 atomic_subract_acq_long
422#define atomic_subtract_rel_64 atomic_subtract_rel_long
423
424#define atomic_subtract_ptr atomic_subtract_long
425#define atomic_subtract_acq_ptr atomic_subtract_acq_long
426#define atomic_subtract_rel_ptr atomic_subtract_rel_long
427#else
428#define atomic_subtract_ptr atomic_subtract_int
429#define atomic_subtract_acq_ptr atomic_subtract_acq_int
430#define atomic_subtract_rel_ptr atomic_subtract_rel_int
431#endif
432#undef _ATOMIC_SUBTRACT
433#undef __atomic_subtract_long
434#undef __atomic_subtract_int
435
436/*
437 * atomic_store_rel(p, v)
438 */
439/* TODO -- see below */
440
441/*
442 * Old/original implementations that still need revisiting.
443 */
444
445static __inline u_int
446atomic_readandclear_int(volatile u_int *addr)
447{
448 u_int result,temp;
449
450 __asm __volatile (
451 "\tsync\n" /* drain writes */
452 "1:\tlwarx %0, 0, %3\n\t" /* load old value */
453 "li %1, 0\n\t" /* load new value */
454 "stwcx. %1, 0, %3\n\t" /* attempt to store */
455 "bne- 1b\n\t" /* spin if failed */
456 : "=&r"(result), "=&r"(temp), "=m" (*addr)
457 : "r" (addr), "m" (*addr)
458 : "cr0", "memory");
459
460 return (result);
461}
462
463#ifdef __powerpc64__
464static __inline u_long
465atomic_readandclear_long(volatile u_long *addr)
466{
467 u_long result,temp;
468
469 __asm __volatile (
470 "\tsync\n" /* drain writes */
471 "1:\tldarx %0, 0, %3\n\t" /* load old value */
472 "li %1, 0\n\t" /* load new value */
473 "stdcx. %1, 0, %3\n\t" /* attempt to store */
474 "bne- 1b\n\t" /* spin if failed */
475 : "=&r"(result), "=&r"(temp), "=m" (*addr)
476 : "r" (addr), "m" (*addr)
477 : "cr0", "memory");
478
479 return (result);
480}
481#endif
482
483#define atomic_readandclear_32 atomic_readandclear_int
484
485#ifdef __powerpc64__
486#define atomic_readandclear_64 atomic_readandclear_long
487
488#define atomic_readandclear_ptr atomic_readandclear_long
489#else
490static __inline u_long
491atomic_readandclear_long(volatile u_long *addr)
492{
493
494 return ((u_long)atomic_readandclear_int((volatile u_int *)addr));
495}
496
497#define atomic_readandclear_ptr atomic_readandclear_int
498#endif
499
500/*
501 * We assume that a = b will do atomic loads and stores.
502 */
503#define ATOMIC_STORE_LOAD(TYPE) \
504static __inline u_##TYPE \
505atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
506{ \
507 u_##TYPE v; \
508 \
509 v = *p; \
510 powerpc_lwsync(); \
511 return (v); \
512} \
513 \
514static __inline void \
515atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) \
516{ \
517 \
518 powerpc_lwsync(); \
519 *p = v; \
520}
521
522ATOMIC_STORE_LOAD(int)
523
524#define atomic_load_acq_32 atomic_load_acq_int
525#define atomic_store_rel_32 atomic_store_rel_int
526
527#ifdef __powerpc64__
528ATOMIC_STORE_LOAD(long)
529
530#define atomic_load_acq_64 atomic_load_acq_long
531#define atomic_store_rel_64 atomic_store_rel_long
532
533#define atomic_load_acq_ptr atomic_load_acq_long
534#define atomic_store_rel_ptr atomic_store_rel_long
535#else
536static __inline u_long
537atomic_load_acq_long(const volatile u_long *addr)
538{
539
540 return ((u_long)atomic_load_acq_int((const volatile u_int *)addr));
541}
542
543static __inline void
544atomic_store_rel_long(volatile u_long *addr, u_long val)
545{
546
547 atomic_store_rel_int((volatile u_int *)addr, (u_int)val);
548}
549
550#define atomic_load_acq_ptr atomic_load_acq_int
551#define atomic_store_rel_ptr atomic_store_rel_int
552#endif
553#undef ATOMIC_STORE_LOAD
554
555/*
556 * Atomically compare the value stored at *p with cmpval and if the
557 * two values are equal, update the value of *p with newval. Returns
558 * zero if the compare failed, nonzero otherwise.
559 */
560#ifdef ISA_206_ATOMICS
561static __inline int
562atomic_cmpset_char(volatile u_char *p, u_char cmpval, u_char newval)
563{
564 int ret;
565
566 __asm __volatile (
567 "1:\tlbarx %0, 0, %2\n\t" /* load old value */
568 "cmplw %3, %0\n\t" /* compare */
569 "bne- 2f\n\t" /* exit if not equal */
570 "stbcx. %4, 0, %2\n\t" /* attempt to store */
571 "bne- 1b\n\t" /* spin if failed */
572 "li %0, 1\n\t" /* success - retval = 1 */
573 "b 3f\n\t" /* we've succeeded */
574 "2:\n\t"
575 "stbcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
576 "li %0, 0\n\t" /* failure - retval = 0 */
577 "3:\n\t"
578 : "=&r" (ret), "=m" (*p)
579 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
580 : "cr0", "memory");
581
582 return (ret);
583}
584
585static __inline int
586atomic_cmpset_short(volatile u_short *p, u_short cmpval, u_short newval)
587{
588 int ret;
589
590 __asm __volatile (
591 "1:\tlharx %0, 0, %2\n\t" /* load old value */
592 "cmplw %3, %0\n\t" /* compare */
593 "bne- 2f\n\t" /* exit if not equal */
594 "sthcx. %4, 0, %2\n\t" /* attempt to store */
595 "bne- 1b\n\t" /* spin if failed */
596 "li %0, 1\n\t" /* success - retval = 1 */
597 "b 3f\n\t" /* we've succeeded */
598 "2:\n\t"
599 "sthcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
600 "li %0, 0\n\t" /* failure - retval = 0 */
601 "3:\n\t"
602 : "=&r" (ret), "=m" (*p)
603 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
604 : "cr0", "memory");
605
606 return (ret);
607}
608#else
609static __inline int
610atomic_cmpset_masked(uint32_t *p, uint32_t cmpval, uint32_t newval,
611 uint32_t mask)
612{
613 int ret;
614 uint32_t tmp;
615
616 __asm __volatile (
617 "1:\tlwarx %2, 0, %3\n\t" /* load old value */
618 "and %0, %2, %7\n\t"
619 "cmplw %4, %0\n\t" /* compare */
620 "bne- 2f\n\t" /* exit if not equal */
621 "andc %2, %2, %7\n\t"
622 "or %2, %2, %5\n\t"
623 "stwcx. %2, 0, %3\n\t" /* attempt to store */
624 "bne- 1b\n\t" /* spin if failed */
625 "li %0, 1\n\t" /* success - retval = 1 */
626 "b 3f\n\t" /* we've succeeded */
627 "2:\n\t"
628 "stwcx. %2, 0, %3\n\t" /* clear reservation (74xx) */
629 "li %0, 0\n\t" /* failure - retval = 0 */
630 "3:\n\t"
631 : "=&r" (ret), "=m" (*p), "+&r" (tmp)
632 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p),
633 "r" (mask)
634 : "cr0", "memory");
635
636 return (ret);
637}
638
639#define _atomic_cmpset_masked_word(a,o,v,m) atomic_cmpset_masked(a, o, v, m)
640#endif
641
642static __inline int
643atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval)
644{
645 int ret;
646
647 __asm __volatile (
648 "1:\tlwarx %0, 0, %2\n\t" /* load old value */
649 "cmplw %3, %0\n\t" /* compare */
650 "bne- 2f\n\t" /* exit if not equal */
651 "stwcx. %4, 0, %2\n\t" /* attempt to store */
652 "bne- 1b\n\t" /* spin if failed */
653 "li %0, 1\n\t" /* success - retval = 1 */
654 "b 3f\n\t" /* we've succeeded */
655 "2:\n\t"
656 "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
657 "li %0, 0\n\t" /* failure - retval = 0 */
658 "3:\n\t"
659 : "=&r" (ret), "=m" (*p)
660 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
661 : "cr0", "memory");
662
663 return (ret);
664}
665static __inline int
666atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval)
667{
668 int ret;
669
670 __asm __volatile (
671 #ifdef __powerpc64__
672 "1:\tldarx %0, 0, %2\n\t" /* load old value */
673 "cmpld %3, %0\n\t" /* compare */
674 "bne- 2f\n\t" /* exit if not equal */
675 "stdcx. %4, 0, %2\n\t" /* attempt to store */
676 #else
677 "1:\tlwarx %0, 0, %2\n\t" /* load old value */
678 "cmplw %3, %0\n\t" /* compare */
679 "bne- 2f\n\t" /* exit if not equal */
680 "stwcx. %4, 0, %2\n\t" /* attempt to store */
681 #endif
682 "bne- 1b\n\t" /* spin if failed */
683 "li %0, 1\n\t" /* success - retval = 1 */
684 "b 3f\n\t" /* we've succeeded */
685 "2:\n\t"
686 #ifdef __powerpc64__
687 "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
688 #else
689 "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */
690 #endif
691 "li %0, 0\n\t" /* failure - retval = 0 */
692 "3:\n\t"
693 : "=&r" (ret), "=m" (*p)
694 : "r" (p), "r" (cmpval), "r" (newval), "m" (*p)
695 : "cr0", "memory");
696
697 return (ret);
698}
699
700#define ATOMIC_CMPSET_ACQ_REL(type) \
701 static __inline int \
702 atomic_cmpset_acq_##type(volatile u_##type *p, \
703 u_##type cmpval, u_##type newval)\
704 {\
705 u_##type retval; \
706 retval = atomic_cmpset_##type(p, cmpval, newval);\
707 __ATOMIC_ACQ();\
708 return (retval);\
709 }\
710 static __inline int \
711 atomic_cmpset_rel_##type(volatile u_##type *p, \
712 u_##type cmpval, u_##type newval)\
713 {\
714 __ATOMIC_REL();\
715 return (atomic_cmpset_##type(p, cmpval, newval));\
716 }\
717 struct hack
718
719ATOMIC_CMPSET_ACQ_REL(int);
720ATOMIC_CMPSET_ACQ_REL(long);
721
722#ifdef ISA_206_ATOMICS
723#define atomic_cmpset_8 atomic_cmpset_char
724#endif
725#define atomic_cmpset_acq_8 atomic_cmpset_acq_char
726#define atomic_cmpset_rel_8 atomic_cmpset_rel_char
727
728#ifdef ISA_206_ATOMICS
729#define atomic_cmpset_16 atomic_cmpset_short
730#endif
731#define atomic_cmpset_acq_16 atomic_cmpset_acq_short
732#define atomic_cmpset_rel_16 atomic_cmpset_rel_short
733
734#define atomic_cmpset_32 atomic_cmpset_int
735#define atomic_cmpset_acq_32 atomic_cmpset_acq_int
736#define atomic_cmpset_rel_32 atomic_cmpset_rel_int
737
738#ifdef __powerpc64__
739#define atomic_cmpset_64 atomic_cmpset_long
740#define atomic_cmpset_acq_64 atomic_cmpset_acq_long
741#define atomic_cmpset_rel_64 atomic_cmpset_rel_long
742
743#define atomic_cmpset_ptr atomic_cmpset_long
744#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long
745#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long
746#else
747#define atomic_cmpset_ptr atomic_cmpset_int
748#define atomic_cmpset_acq_ptr atomic_cmpset_acq_int
749#define atomic_cmpset_rel_ptr atomic_cmpset_rel_int
750#endif
751
752/*
753 * Atomically compare the value stored at *p with *cmpval and if the
754 * two values are equal, update the value of *p with newval. Returns
755 * zero if the compare failed and sets *cmpval to the read value from *p,
756 * nonzero otherwise.
757 */
758#ifdef ISA_206_ATOMICS
759static __inline int
760atomic_fcmpset_char(volatile u_char *p, u_char *cmpval, u_char newval)
761{
762 int ret;
763
764 __asm __volatile (
765 "lbarx %0, 0, %3\n\t" /* load old value */
766 "cmplw %4, %0\n\t" /* compare */
767 "bne- 1f\n\t" /* exit if not equal */
768 "stbcx. %5, 0, %3\n\t" /* attempt to store */
769 "bne- 1f\n\t" /* exit if failed */
770 "li %0, 1\n\t" /* success - retval = 1 */
771 "b 2f\n\t" /* we've succeeded */
772 "1:\n\t"
773 "stbcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
774 "stbx %0, 0, %7\n\t"
775 "li %0, 0\n\t" /* failure - retval = 0 */
776 "2:\n\t"
777 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
778 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
779 : "cr0", "memory");
780
781 return (ret);
782}
783
784static __inline int
785atomic_fcmpset_short(volatile u_short *p, u_short *cmpval, u_short newval)
786{
787 int ret;
788
789 __asm __volatile (
790 "lharx %0, 0, %3\n\t" /* load old value */
791 "cmplw %4, %0\n\t" /* compare */
792 "bne- 1f\n\t" /* exit if not equal */
793 "sthcx. %5, 0, %3\n\t" /* attempt to store */
794 "bne- 1f\n\t" /* exit if failed */
795 "li %0, 1\n\t" /* success - retval = 1 */
796 "b 2f\n\t" /* we've succeeded */
797 "1:\n\t"
798 "sthcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
799 "sthx %0, 0, %7\n\t"
800 "li %0, 0\n\t" /* failure - retval = 0 */
801 "2:\n\t"
802 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
803 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
804 : "cr0", "memory");
805
806 return (ret);
807}
808#endif /* ISA_206_ATOMICS */
809
810static __inline int
811atomic_fcmpset_int(volatile u_int *p, u_int *cmpval, u_int newval)
812{
813 int ret;
814
815 __asm __volatile (
816 "lwarx %0, 0, %3\n\t" /* load old value */
817 "cmplw %4, %0\n\t" /* compare */
818 "bne- 1f\n\t" /* exit if not equal */
819 "stwcx. %5, 0, %3\n\t" /* attempt to store */
820 "bne- 1f\n\t" /* exit if failed */
821 "li %0, 1\n\t" /* success - retval = 1 */
822 "b 2f\n\t" /* we've succeeded */
823 "1:\n\t"
824 "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
825 "stwx %0, 0, %7\n\t"
826 "li %0, 0\n\t" /* failure - retval = 0 */
827 "2:\n\t"
828 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
829 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
830 : "cr0", "memory");
831
832 return (ret);
833}
834static __inline int
835atomic_fcmpset_long(volatile u_long *p, u_long *cmpval, u_long newval)
836{
837 int ret;
838
839 __asm __volatile (
840 #ifdef __powerpc64__
841 "ldarx %0, 0, %3\n\t" /* load old value */
842 "cmpld %4, %0\n\t" /* compare */
843 "bne- 1f\n\t" /* exit if not equal */
844 "stdcx. %5, 0, %3\n\t" /* attempt to store */
845 #else
846 "lwarx %0, 0, %3\n\t" /* load old value */
847 "cmplw %4, %0\n\t" /* compare */
848 "bne- 1f\n\t" /* exit if not equal */
849 "stwcx. %5, 0, %3\n\t" /* attempt to store */
850 #endif
851 "bne- 1f\n\t" /* exit if failed */
852 "li %0, 1\n\t" /* success - retval = 1 */
853 "b 2f\n\t" /* we've succeeded */
854 "1:\n\t"
855 #ifdef __powerpc64__
856 "stdcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
857 "stdx %0, 0, %7\n\t"
858 #else
859 "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
860 "stwx %0, 0, %7\n\t"
861 #endif
862 "li %0, 0\n\t" /* failure - retval = 0 */
863 "2:\n\t"
864 : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
865 : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
866 : "cr0", "memory");
867
868 return (ret);
869}
870
871#define ATOMIC_FCMPSET_ACQ_REL(type) \
872 static __inline int \
873 atomic_fcmpset_acq_##type(volatile u_##type *p, \
874 u_##type *cmpval, u_##type newval)\
875 {\
876 u_##type retval; \
877 retval = atomic_fcmpset_##type(p, cmpval, newval);\
878 __ATOMIC_ACQ();\
879 return (retval);\
880 }\
881 static __inline int \
882 atomic_fcmpset_rel_##type(volatile u_##type *p, \
883 u_##type *cmpval, u_##type newval)\
884 {\
885 __ATOMIC_REL();\
886 return (atomic_fcmpset_##type(p, cmpval, newval));\
887 }\
888 struct hack
889
890ATOMIC_FCMPSET_ACQ_REL(int);
891ATOMIC_FCMPSET_ACQ_REL(long);
892
893#ifdef ISA_206_ATOMICS
894#define atomic_fcmpset_8 atomic_fcmpset_char
895#endif
896#define atomic_fcmpset_acq_8 atomic_fcmpset_acq_char
897#define atomic_fcmpset_rel_8 atomic_fcmpset_rel_char
898
899#ifdef ISA_206_ATOMICS
900#define atomic_fcmpset_16 atomic_fcmpset_short
901#endif
902#define atomic_fcmpset_acq_16 atomic_fcmpset_acq_short
903#define atomic_fcmpset_rel_16 atomic_fcmpset_rel_short
904
905#define atomic_fcmpset_32 atomic_fcmpset_int
906#define atomic_fcmpset_acq_32 atomic_fcmpset_acq_int
907#define atomic_fcmpset_rel_32 atomic_fcmpset_rel_int
908
909#ifdef __powerpc64__
910#define atomic_fcmpset_64 atomic_fcmpset_long
911#define atomic_fcmpset_acq_64 atomic_fcmpset_acq_long
912#define atomic_fcmpset_rel_64 atomic_fcmpset_rel_long
913
914#define atomic_fcmpset_ptr atomic_fcmpset_long
915#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long
916#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long
917#else
918#define atomic_fcmpset_ptr atomic_fcmpset_int
919#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_int
920#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_int
921#endif
922
923static __inline u_int
924atomic_fetchadd_int(volatile u_int *p, u_int v)
925{
926 u_int value;
927
928 do {
929 value = *p;
930 } while (!atomic_cmpset_int(p, value, value + v));
931 return (value);
932}
933
934static __inline u_long
935atomic_fetchadd_long(volatile u_long *p, u_long v)
936{
937 u_long value;
938
939 do {
940 value = *p;
941 } while (!atomic_cmpset_long(p, value, value + v));
942 return (value);
943}
944
945static __inline u_int
946atomic_swap_32(volatile u_int *p, u_int v)
947{
948 u_int prev;
949
950 __asm __volatile(
951 "1: lwarx %0,0,%2\n"
952 " stwcx. %3,0,%2\n"
953 " bne- 1b\n"
954 : "=&r" (prev), "+m" (*(volatile u_int *)p)
955 : "r" (p), "r" (v)
956 : "cr0", "memory");
957
958 return (prev);
959}
960
961#ifdef __powerpc64__
962static __inline u_long
963atomic_swap_64(volatile u_long *p, u_long v)
964{
965 u_long prev;
966
967 __asm __volatile(
968 "1: ldarx %0,0,%2\n"
969 " stdcx. %3,0,%2\n"
970 " bne- 1b\n"
971 : "=&r" (prev), "+m" (*(volatile u_long *)p)
972 : "r" (p), "r" (v)
973 : "cr0", "memory");
974
975 return (prev);
976}
977#endif
978
979#define atomic_fetchadd_32 atomic_fetchadd_int
980#define atomic_swap_int atomic_swap_32
981
982#ifdef __powerpc64__
983#define atomic_fetchadd_64 atomic_fetchadd_long
984#define atomic_swap_long atomic_swap_64
985#define atomic_swap_ptr atomic_swap_64
986#else
987#define atomic_swap_long(p,v) atomic_swap_32((volatile u_int *)(p), v)
988#define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v)
989#endif
990
991static __inline int
992atomic_testandset_int(volatile u_int *p, u_int v)
993{
994 u_int m = (1u << (v & 0x1f));
995 u_int res;
996 u_int tmp;
997
998 __asm __volatile(
999 "1: lwarx %0,0,%3\n"
1000 " and %1,%0,%4\n"
1001 " or %0,%0,%4\n"
1002 " stwcx. %0,0,%3\n"
1003 " bne- 1b\n"
1004 : "=&r"(tmp), "=&r"(res), "+m"(*p)
1005 : "r"(p), "r"(m)
1006 : "cr0", "memory");
1007
1008 return (res != 0);
1009}
1010
1011static __inline int
1012atomic_testandclear_int(volatile u_int *p, u_int v)
1013{
1014 u_int m = (1u << (v & 0x1f));
1015 u_int res;
1016 u_int tmp;
1017
1018 __asm __volatile(
1019 "1: lwarx %0,0,%3\n"
1020 " and %1,%0,%4\n"
1021 " andc %0,%0,%4\n"
1022 " stwcx. %0,0,%3\n"
1023 " bne- 1b\n"
1024 : "=&r"(tmp), "=&r"(res), "+m"(*p)
1025 : "r"(p), "r"(m)
1026 : "cr0", "memory");
1027
1028 return (res != 0);
1029}
1030
1031#ifdef __powerpc64__
1032static __inline int
1033atomic_testandset_long(volatile u_long *p, u_int v)
1034{
1035 u_long m = (1ul << (v & 0x3f));
1036 u_long res;
1037 u_long tmp;
1038
1039 __asm __volatile(
1040 "1: ldarx %0,0,%3\n"
1041 " and %1,%0,%4\n"
1042 " or %0,%0,%4\n"
1043 " stdcx. %0,0,%3\n"
1044 " bne- 1b\n"
1045 : "=&r"(tmp), "=&r"(res), "+m"(*(volatile u_long *)p)
1046 : "r"(p), "r"(m)
1047 : "cr0", "memory");
1048
1049 return (res != 0);
1050}
1051
1052static __inline int
1053atomic_testandclear_long(volatile u_long *p, u_int v)
1054{
1055 u_long m = (1ul << (v & 0x3f));
1056 u_long res;
1057 u_long tmp;
1058
1059 __asm __volatile(
1060 "1: ldarx %0,0,%3\n"
1061 " and %1,%0,%4\n"
1062 " andc %0,%0,%4\n"
1063 " stdcx. %0,0,%3\n"
1064 " bne- 1b\n"
1065 : "=&r"(tmp), "=&r"(res), "+m"(*p)
1066 : "r"(p), "r"(m)
1067 : "cr0", "memory");
1068
1069 return (res != 0);
1070}
1071#else
1072static __inline int
1073atomic_testandset_long(volatile u_long *p, u_int v)
1074{
1075 return (atomic_testandset_int((volatile u_int *)p, v));
1076}
1077
1078static __inline int
1079atomic_testandclear_long(volatile u_long *p, u_int v)
1080{
1081 return (atomic_testandclear_int((volatile u_int *)p, v));
1082}
1083#endif
1084
1085#define atomic_testandclear_32 atomic_testandclear_int
1086#define atomic_testandset_32 atomic_testandset_int
1087
1088static __inline int
1089atomic_testandset_acq_long(volatile u_long *p, u_int v)
1090{
1091 u_int a = atomic_testandset_long(p, v);
1092 __ATOMIC_ACQ();
1093 return (a);
1094}
1095
1096#ifdef __powerpc64__
1097#define atomic_testandclear_ptr atomic_testandclear_long
1098#define atomic_testandset_ptr atomic_testandset_long
1099#else
1100#define atomic_testandclear_ptr(p,v) \
1101 atomic_testandclear_32((volatile u_int *)(p), v)
1102#define atomic_testandset_ptr(p,v) \
1103 atomic_testandset_32((volatile u_int *)(p), v)
1104#endif
1105
1106static __inline void
1107atomic_thread_fence_acq(void)
1108{
1109
1110 powerpc_lwsync();
1111}
1112
1113static __inline void
1114atomic_thread_fence_rel(void)
1115{
1116
1117 powerpc_lwsync();
1118}
1119
1120static __inline void
1121atomic_thread_fence_acq_rel(void)
1122{
1123
1124 powerpc_lwsync();
1125}
1126
1127static __inline void
1128atomic_thread_fence_seq_cst(void)
1129{
1130
1131 __asm __volatile("sync" : : : "memory");
1132}
1133
1134#ifndef ISA_206_ATOMICS
1135#include <sys/_atomic_subword.h>
1136#define atomic_cmpset_char atomic_cmpset_8
1137#define atomic_cmpset_short atomic_cmpset_16
1138#define atomic_fcmpset_char atomic_fcmpset_8
1139#define atomic_fcmpset_short atomic_fcmpset_16
1140#define atomic_set_short atomic_set_16
1141#define atomic_clear_short atomic_clear_16
1142#else
1143
1144static __inline void
1145atomic_set_short(volatile u_short *p, u_short bit)
1146{
1147 u_short v;
1148
1149 v = atomic_load_short(p);
1150 for (;;) {
1151 if (atomic_fcmpset_16(p, &v, v | bit))
1152 break;
1153 }
1154}
1155
1156static __inline void
1157atomic_clear_short(volatile u_short *p, u_short bit)
1158{
1159 u_short v;
1160
1161 v = atomic_load_short(p);
1162 for (;;) {
1163 if (atomic_fcmpset_16(p, &v, v & ~bit))
1164 break;
1165 }
1166}
1167
1168#define atomic_set_16 atomic_set_short
1169#define atomic_clear_16 atomic_clear_short
1170
1171#endif /* ISA_206_ATOMICS */
1172
1173/* These need sys/_atomic_subword.h on non-ISA-2.06-atomic platforms. */
1174ATOMIC_CMPSET_ACQ_REL(char);
1175ATOMIC_CMPSET_ACQ_REL(short);
1176
1177ATOMIC_FCMPSET_ACQ_REL(char);
1178ATOMIC_FCMPSET_ACQ_REL(short);
1179
1180#undef __ATOMIC_REL
1181#undef __ATOMIC_ACQ
1182
1183#endif /* ! _MACHINE_ATOMIC_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/bat.h created+167
......@@ -0,0 +1,167 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause
3 *
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*-
33 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
34 * Copyright (C) 1995, 1996 TooLs GmbH.
35 * All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by TooLs GmbH.
48 * 4. The name of TooLs GmbH may not be used to endorse or promote products
49 * derived from this software without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
52 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
54 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
56 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
57 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
58 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
59 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
60 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 * $NetBSD: bat.h,v 1.2 1999/12/18 01:36:06 thorpej Exp $
63 */
64
65#ifndef _MACHINE_BAT_H_
66#define _MACHINE_BAT_H_
67
68#ifndef LOCORE
69struct bat {
70 u_int32_t batu;
71 u_int32_t batl;
72};
73#endif
74
75/* Lower BAT bits (all but PowerPC 601): */
76#define BAT_PBS 0xfffe0000 /* physical block start */
77#define BAT_W 0x00000040 /* 1 = write-through, 0 = write-back */
78#define BAT_I 0x00000020 /* cache inhibit */
79#define BAT_M 0x00000010 /* memory coherency enable */
80#define BAT_G 0x00000008 /* guarded region */
81
82#define BAT_PP_NONE 0x00000000 /* no access permission */
83#define BAT_PP_RO_S 0x00000001 /* read-only (soft) */
84#define BAT_PP_RW 0x00000002 /* read/write */
85#define BAT_PP_RO 0x00000003 /* read-only */
86
87/* Upper BAT bits (all but PowerPC 601): */
88#define BAT_EBS 0xfffe0000 /* effective block start */
89#define BAT_BL 0x00001ffc /* block length */
90#define BAT_Vs 0x00000002 /* valid in supervisor mode */
91#define BAT_Vu 0x00000001 /* valid in user mode */
92
93#define BAT_V (BAT_Vs|BAT_Vu)
94
95/* Block Length encoding (all but PowerPC 601): */
96#define BAT_BL_128K 0x00000000
97#define BAT_BL_256K 0x00000004
98#define BAT_BL_512K 0x0000000c
99#define BAT_BL_1M 0x0000001c
100#define BAT_BL_2M 0x0000003c
101#define BAT_BL_4M 0x0000007c
102#define BAT_BL_8M 0x000000fc
103#define BAT_BL_16M 0x000001fc
104#define BAT_BL_32M 0x000003fc
105#define BAT_BL_64M 0x000007fc
106#define BAT_BL_128M 0x00000ffc
107#define BAT_BL_256M 0x00001ffc
108
109#define BATU(va, len, v) \
110 (((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V))
111
112#define BATL(pa, wimg, pp) \
113 (((pa) & BAT_PBS) | (wimg) | (pp))
114
115/* Lower BAT bits (PowerPC 601): */
116#define BAT601_PBN 0xfffe0000 /* physical block number */
117#define BAT601_V 0x00000040 /* valid */
118#define BAT601_BSM 0x0000003f /* block size mask */
119
120/* Upper BAT bits (PowerPC 601): */
121#define BAT601_BLPI 0xfffe0000 /* block logical page index */
122#define BAT601_W 0x00000040 /* 1 = write-through, 0 = write-back */
123#define BAT601_I 0x00000020 /* cache inhibit */
124#define BAT601_M 0x00000010 /* memory coherency enable */
125#define BAT601_Ks 0x00000008 /* key-supervisor */
126#define BAT601_Ku 0x00000004 /* key-user */
127
128/*
129 * Permission bits on the PowerPC 601 are modified by the appropriate
130 * Key bit:
131 *
132 * Key PP Access
133 * 0 NONE read/write
134 * 0 RO_S read/write
135 * 0 RW read/write
136 * 0 RO read-only
137 *
138 * 1 NONE none
139 * 1 RO_S read-only
140 * 1 RW read/write
141 * 1 RO read-only
142 */
143#define BAT601_PP_NONE 0x00000000 /* no access permission */
144#define BAT601_PP_RO_S 0x00000001 /* read-only (soft) */
145#define BAT601_PP_RW 0x00000002 /* read/write */
146#define BAT601_PP_RO 0x00000003 /* read-only */
147
148/* Block Size Mask encoding (PowerPC 601): */
149#define BAT601_BSM_128K 0x00000000
150#define BAT601_BSM_256K 0x00000001
151#define BAT601_BSM_512K 0x00000003
152#define BAT601_BSM_1M 0x00000007
153#define BAT601_BSM_2M 0x0000000f
154#define BAT601_BSM_4M 0x0000001f
155#define BAT601_BSM_8M 0x0000003f
156
157#define BATU601(va, wim, key, pp) \
158 (((va) & BAT601_BLPI) | (wim) | (key) | (pp))
159
160#define BATL601(pa, size, v) \
161 (((pa) & BAT601_PBN) | (v) | (size))
162
163#if defined(_KERNEL) && !defined(LOCORE)
164extern struct bat battable[16];
165#endif
166
167#endif /* _MACHINE_BAT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/bus.h created+493
......@@ -0,0 +1,493 @@
1/* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */
2
3/*-
4 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause
5 *
6 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
7 * All rights reserved.
8 *
9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
11 * NASA Ames Research Center.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*-
36 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
37 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by Christopher G. Demetriou
50 * for the NetBSD Project.
51 * 4. The name of the author may not be used to endorse or promote products
52 * derived from this software without specific prior written permission
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
55 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
56 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
58 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
63 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 */
65
66#ifndef _MACHINE_BUS_H_
67#define _MACHINE_BUS_H_
68
69#include <machine/_bus.h>
70
71#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
72
73#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL
74#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL
75#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL
76#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL
77
78#ifdef __powerpc64__
79#define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL
80#define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL
81#else
82#ifdef BOOKE
83#define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL
84#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL
85#else
86#define BUS_SPACE_MAXADDR 0xFFFFFFFFUL
87#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL
88#endif
89#endif
90
91#define BUS_SPACE_MAP_CACHEABLE 0x01
92#define BUS_SPACE_MAP_LINEAR 0x02
93#define BUS_SPACE_MAP_PREFETCHABLE 0x04
94
95#define BUS_SPACE_UNRESTRICTED (~0)
96
97#define BUS_SPACE_BARRIER_READ 0x01
98#define BUS_SPACE_BARRIER_WRITE 0x02
99
100struct bus_space_access;
101
102struct bus_space {
103 /* mapping/unmapping */
104 int (*bs_map)(bus_addr_t, bus_size_t, int,
105 bus_space_handle_t *);
106 void (*bs_unmap)(bus_space_handle_t, bus_size_t);
107 int (*bs_subregion)(bus_space_handle_t, bus_size_t,
108 bus_size_t, bus_space_handle_t *);
109
110 /* allocation/deallocation */
111 int (*bs_alloc)(bus_addr_t, bus_addr_t, bus_size_t,
112 bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
113 void (*bs_free)(bus_space_handle_t, bus_size_t);
114
115 void (*bs_barrier)(bus_space_handle_t, bus_size_t,
116 bus_size_t, int);
117
118 /* Read single. */
119 uint8_t (*bs_r_1)(bus_space_handle_t, bus_size_t);
120 uint16_t (*bs_r_2)(bus_space_handle_t, bus_size_t);
121 uint32_t (*bs_r_4)(bus_space_handle_t, bus_size_t);
122 uint64_t (*bs_r_8)(bus_space_handle_t, bus_size_t);
123
124 uint16_t (*bs_r_s_2)(bus_space_handle_t, bus_size_t);
125 uint32_t (*bs_r_s_4)(bus_space_handle_t, bus_size_t);
126 uint64_t (*bs_r_s_8)(bus_space_handle_t, bus_size_t);
127
128 /* read multiple */
129 void (*bs_rm_1)(bus_space_handle_t, bus_size_t, uint8_t *,
130 bus_size_t);
131 void (*bs_rm_2)(bus_space_handle_t, bus_size_t, uint16_t *,
132 bus_size_t);
133 void (*bs_rm_4)(bus_space_handle_t, bus_size_t, uint32_t *,
134 bus_size_t);
135 void (*bs_rm_8)(bus_space_handle_t, bus_size_t, uint64_t *,
136 bus_size_t);
137
138 void (*bs_rm_s_2)(bus_space_handle_t, bus_size_t, uint16_t *,
139 bus_size_t);
140 void (*bs_rm_s_4)(bus_space_handle_t, bus_size_t, uint32_t *,
141 bus_size_t);
142 void (*bs_rm_s_8)(bus_space_handle_t, bus_size_t, uint64_t *,
143 bus_size_t);
144
145 /* read region */
146 void (*bs_rr_1)(bus_space_handle_t, bus_size_t, uint8_t *,
147 bus_size_t);
148 void (*bs_rr_2)(bus_space_handle_t, bus_size_t, uint16_t *,
149 bus_size_t);
150 void (*bs_rr_4)(bus_space_handle_t, bus_size_t, uint32_t *,
151 bus_size_t);
152 void (*bs_rr_8)(bus_space_handle_t, bus_size_t, uint64_t *,
153 bus_size_t);
154
155 void (*bs_rr_s_2)(bus_space_handle_t, bus_size_t, uint16_t *,
156 bus_size_t);
157 void (*bs_rr_s_4)(bus_space_handle_t, bus_size_t, uint32_t *,
158 bus_size_t);
159 void (*bs_rr_s_8)(bus_space_handle_t, bus_size_t, uint64_t *,
160 bus_size_t);
161
162 /* write */
163 void (*bs_w_1)(bus_space_handle_t, bus_size_t, uint8_t);
164 void (*bs_w_2)(bus_space_handle_t, bus_size_t, uint16_t);
165 void (*bs_w_4)(bus_space_handle_t, bus_size_t, uint32_t);
166 void (*bs_w_8)(bus_space_handle_t, bus_size_t, uint64_t);
167
168 void (*bs_w_s_2)(bus_space_handle_t, bus_size_t, uint16_t);
169 void (*bs_w_s_4)(bus_space_handle_t, bus_size_t, uint32_t);
170 void (*bs_w_s_8)(bus_space_handle_t, bus_size_t, uint64_t);
171
172 /* write multiple */
173 void (*bs_wm_1)(bus_space_handle_t, bus_size_t,
174 const uint8_t *, bus_size_t);
175 void (*bs_wm_2)(bus_space_handle_t, bus_size_t,
176 const uint16_t *, bus_size_t);
177 void (*bs_wm_4)(bus_space_handle_t, bus_size_t,
178 const uint32_t *, bus_size_t);
179 void (*bs_wm_8)(bus_space_handle_t, bus_size_t,
180 const uint64_t *, bus_size_t);
181
182 void (*bs_wm_s_2)(bus_space_handle_t, bus_size_t,
183 const uint16_t *, bus_size_t);
184 void (*bs_wm_s_4)(bus_space_handle_t, bus_size_t,
185 const uint32_t *, bus_size_t);
186 void (*bs_wm_s_8)(bus_space_handle_t, bus_size_t,
187 const uint64_t *, bus_size_t);
188
189 /* write region */
190 void (*bs_wr_1)(bus_space_handle_t, bus_size_t,
191 const uint8_t *, bus_size_t);
192 void (*bs_wr_2)(bus_space_handle_t, bus_size_t,
193 const uint16_t *, bus_size_t);
194 void (*bs_wr_4)(bus_space_handle_t, bus_size_t,
195 const uint32_t *, bus_size_t);
196 void (*bs_wr_8)(bus_space_handle_t, bus_size_t,
197 const uint64_t *, bus_size_t);
198
199 void (*bs_wr_s_2)(bus_space_handle_t, bus_size_t,
200 const uint16_t *, bus_size_t);
201 void (*bs_wr_s_4)(bus_space_handle_t, bus_size_t,
202 const uint32_t *, bus_size_t);
203 void (*bs_wr_s_8)(bus_space_handle_t, bus_size_t,
204 const uint64_t *, bus_size_t);
205
206 /* set multiple */
207 void (*bs_sm_1)(bus_space_handle_t, bus_size_t, uint8_t,
208 bus_size_t);
209 void (*bs_sm_2)(bus_space_handle_t, bus_size_t, uint16_t,
210 bus_size_t);
211 void (*bs_sm_4)(bus_space_handle_t, bus_size_t, uint32_t,
212 bus_size_t);
213 void (*bs_sm_8)(bus_space_handle_t, bus_size_t, uint64_t,
214 bus_size_t);
215
216 void (*bs_sm_s_2)(bus_space_handle_t, bus_size_t, uint16_t,
217 bus_size_t);
218 void (*bs_sm_s_4)(bus_space_handle_t, bus_size_t, uint32_t,
219 bus_size_t);
220 void (*bs_sm_s_8)(bus_space_handle_t, bus_size_t, uint64_t,
221 bus_size_t);
222
223 /* set region */
224 void (*bs_sr_1)(bus_space_handle_t, bus_size_t, uint8_t,
225 bus_size_t);
226 void (*bs_sr_2)(bus_space_handle_t, bus_size_t, uint16_t,
227 bus_size_t);
228 void (*bs_sr_4)(bus_space_handle_t, bus_size_t, uint32_t,
229 bus_size_t);
230 void (*bs_sr_8)(bus_space_handle_t, bus_size_t, uint64_t,
231 bus_size_t);
232
233 void (*bs_sr_s_2)(bus_space_handle_t, bus_size_t, uint16_t,
234 bus_size_t);
235 void (*bs_sr_s_4)(bus_space_handle_t, bus_size_t, uint32_t,
236 bus_size_t);
237 void (*bs_sr_s_8)(bus_space_handle_t, bus_size_t, uint64_t,
238 bus_size_t);
239
240 /* copy region */
241 void (*bs_cr_1)(bus_space_handle_t, bus_size_t,
242 bus_space_handle_t, bus_size_t, bus_size_t);
243 void (*bs_cr_2)(bus_space_handle_t, bus_size_t,
244 bus_space_handle_t, bus_size_t, bus_size_t);
245 void (*bs_cr_4)(bus_space_handle_t, bus_size_t,
246 bus_space_handle_t, bus_size_t, bus_size_t);
247 void (*bs_cr_8)(bus_space_handle_t, bus_size_t,
248 bus_space_handle_t, bus_size_t, bus_size_t);
249
250 void (*bs_cr_s_2)(bus_space_handle_t, bus_size_t,
251 bus_space_handle_t, bus_size_t, bus_size_t);
252 void (*bs_cr_s_4)(bus_space_handle_t, bus_size_t,
253 bus_space_handle_t, bus_size_t, bus_size_t);
254 void (*bs_cr_s_8)(bus_space_handle_t, bus_size_t,
255 bus_space_handle_t, bus_size_t, bus_size_t);
256};
257
258extern struct bus_space bs_be_tag;
259extern struct bus_space bs_le_tag;
260
261#define __bs_c(a,b) __CONCAT(a,b)
262#define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size)
263
264#define __bs_rs(sz, t, h, o) \
265 (*(t)->__bs_opname(r,sz))(h, o)
266#define __bs_ws(sz, t, h, o, v) \
267 (*(t)->__bs_opname(w,sz))(h, o, v)
268#define __bs_nonsingle(type, sz, t, h, o, a, c) \
269 (*(t)->__bs_opname(type,sz))(h, o, a, c)
270#define __bs_set(type, sz, t, h, o, v, c) \
271 (*(t)->__bs_opname(type,sz))(h, o, v, c)
272#define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \
273 (*(t)->__bs_opname(c,sz))(h1, o1, h2, o2, cnt)
274
275/*
276 * Mapping and unmapping operations.
277 */
278#define bus_space_map(t, a, s, c, hp) (*(t)->bs_map)(a, s, c, hp)
279#define bus_space_unmap(t, h, s) (*(t)->bs_unmap)(h, s)
280#define bus_space_subregion(t, h, o, s, hp) (*(t)->bs_subregion)(h, o, s, hp)
281
282/*
283 * Allocation and deallocation operations.
284 */
285#define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \
286 (*(t)->bs_alloc)(rs, re, s, a, b, c, ap, hp)
287#define bus_space_free(t, h, s) \
288 (*(t)->bs_free)(h, s)
289
290/*
291 * Bus barrier operations.
292 */
293#define bus_space_barrier(t, h, o, l, f) (*(t)->bs_barrier)(h, o, l, f)
294
295/*
296 * Bus read (single) operations.
297 */
298#define bus_space_read_1(t, h, o) __bs_rs(1,t,h,o)
299#define bus_space_read_2(t, h, o) __bs_rs(2,t,h,o)
300#define bus_space_read_4(t, h, o) __bs_rs(4,t,h,o)
301#define bus_space_read_8(t, h, o) __bs_rs(8,t,h,o)
302
303#define bus_space_read_stream_1 bus_space_read_1
304#define bus_space_read_stream_2(t, h, o) __bs_rs(s_2,t,h,o)
305#define bus_space_read_stream_4(t, h, o) __bs_rs(s_4,t,h,o)
306#define bus_space_read_stream_8(t, h, o) __bs_rs(s_8,t,h,o)
307
308/*
309 * Bus read multiple operations.
310 */
311#define bus_space_read_multi_1(t, h, o, a, c) \
312 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
313#define bus_space_read_multi_2(t, h, o, a, c) \
314 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
315#define bus_space_read_multi_4(t, h, o, a, c) \
316 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
317#define bus_space_read_multi_8(t, h, o, a, c) \
318 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
319
320#define bus_space_read_multi_stream_1 bus_space_read_multi_1
321#define bus_space_read_multi_stream_2(t, h, o, a, c) \
322 __bs_nonsingle(rm,s_2,(t),(h),(o),(a),(c))
323#define bus_space_read_multi_stream_4(t, h, o, a, c) \
324 __bs_nonsingle(rm,s_4,(t),(h),(o),(a),(c))
325#define bus_space_read_multi_stream_8(t, h, o, a, c) \
326 __bs_nonsingle(rm,s_8,(t),(h),(o),(a),(c))
327
328/*
329 * Bus read region operations.
330 */
331#define bus_space_read_region_1(t, h, o, a, c) \
332 __bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
333#define bus_space_read_region_2(t, h, o, a, c) \
334 __bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
335#define bus_space_read_region_4(t, h, o, a, c) \
336 __bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
337#define bus_space_read_region_8(t, h, o, a, c) \
338 __bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
339
340#define bus_space_read_region_stream_1 bus_space_read_region_1
341#define bus_space_read_region_stream_2(t, h, o, a, c) \
342 __bs_nonsingle(rr,s_2,(t),(h),(o),(a),(c))
343#define bus_space_read_region_stream_4(t, h, o, a, c) \
344 __bs_nonsingle(rr,s_4,(t),(h),(o),(a),(c))
345#define bus_space_read_region_stream_8(t, h, o, a, c) \
346 __bs_nonsingle(rr,s_8,(t),(h),(o),(a),(c))
347
348/*
349 * Bus write (single) operations.
350 */
351#define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v))
352#define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v))
353#define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v))
354#define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v))
355
356#define bus_space_write_stream_1 bus_space_write_1
357#define bus_space_write_stream_2(t, h, o, v) __bs_ws(s_2,(t),(h),(o),(v))
358#define bus_space_write_stream_4(t, h, o, v) __bs_ws(s_4,(t),(h),(o),(v))
359#define bus_space_write_stream_8(t, h, o, v) __bs_ws(s_8,(t),(h),(o),(v))
360
361/*
362 * Bus write multiple operations.
363 */
364#define bus_space_write_multi_1(t, h, o, a, c) \
365 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
366#define bus_space_write_multi_2(t, h, o, a, c) \
367 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
368#define bus_space_write_multi_4(t, h, o, a, c) \
369 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
370#define bus_space_write_multi_8(t, h, o, a, c) \
371 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
372
373#define bus_space_write_multi_stream_1 bus_space_write_multi_1
374#define bus_space_write_multi_stream_2(t, h, o, a, c) \
375 __bs_nonsingle(wm,s_2,(t),(h),(o),(a),(c))
376#define bus_space_write_multi_stream_4(t, h, o, a, c) \
377 __bs_nonsingle(wm,s_4,(t),(h),(o),(a),(c))
378#define bus_space_write_multi_stream_8(t, h, o, a, c) \
379 __bs_nonsingle(wm,s_8,(t),(h),(o),(a),(c))
380
381/*
382 * Bus write region operations.
383 */
384#define bus_space_write_region_1(t, h, o, a, c) \
385 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
386#define bus_space_write_region_2(t, h, o, a, c) \
387 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
388#define bus_space_write_region_4(t, h, o, a, c) \
389 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
390#define bus_space_write_region_8(t, h, o, a, c) \
391 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
392
393#define bus_space_write_region_stream_1 bus_space_write_region_1
394#define bus_space_write_region_stream_2(t, h, o, a, c) \
395 __bs_nonsingle(wr,s_2,(t),(h),(o),(a),(c))
396#define bus_space_write_region_stream_4(t, h, o, a, c) \
397 __bs_nonsingle(wr,s_4,(t),(h),(o),(a),(c))
398#define bus_space_write_region_stream_8(t, h, o, a, c) \
399 __bs_nonsingle(wr,s_8,(t),(h),(o),(a),(c))
400
401/*
402 * Set multiple operations.
403 */
404#define bus_space_set_multi_1(t, h, o, v, c) \
405 __bs_set(sm,1,(t),(h),(o),(v),(c))
406#define bus_space_set_multi_2(t, h, o, v, c) \
407 __bs_set(sm,2,(t),(h),(o),(v),(c))
408#define bus_space_set_multi_4(t, h, o, v, c) \
409 __bs_set(sm,4,(t),(h),(o),(v),(c))
410#define bus_space_set_multi_8(t, h, o, v, c) \
411 __bs_set(sm,8,(t),(h),(o),(v),(c))
412
413#define bus_space_set_multi_stream_1 bus_space_set_multi_1
414#define bus_space_set_multi_stream_2(t, h, o, v, c) \
415 __bs_set(sm,s_2,(t),(h),(o),(v),(c))
416#define bus_space_set_multi_stream_4(t, h, o, v, c) \
417 __bs_set(sm,s_4,(t),(h),(o),(v),(c))
418#define bus_space_set_multi_stream_8(t, h, o, v, c) \
419 __bs_set(sm,s_8,(t),(h),(o),(v),(c))
420
421/*
422 * Set region operations.
423 */
424#define bus_space_set_region_1(t, h, o, v, c) \
425 __bs_set(sr,1,(t),(h),(o),(v),(c))
426#define bus_space_set_region_2(t, h, o, v, c) \
427 __bs_set(sr,2,(t),(h),(o),(v),(c))
428#define bus_space_set_region_4(t, h, o, v, c) \
429 __bs_set(sr,4,(t),(h),(o),(v),(c))
430#define bus_space_set_region_8(t, h, o, v, c) \
431 __bs_set(sr,8,(t),(h),(o),(v),(c))
432
433#define bus_space_set_region_stream_1 bus_space_set_region_1
434#define bus_space_set_region_stream_2(t, h, o, v, c) \
435 __bs_set(sr,s_2,(t),(h),(o),(v),(c))
436#define bus_space_set_region_stream_4(t, h, o, v, c) \
437 __bs_set(sr,s_4,(t),(h),(o),(v),(c))
438#define bus_space_set_region_stream_8(t, h, o, v, c) \
439 __bs_set(sr,s_8,(t),(h),(o),(v),(c))
440
441#if 0
442/*
443 * Copy operations.
444 */
445#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
446 __bs_copy(1, t, h1, o1, h2, o2, c)
447#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
448 __bs_copy(2, t, h1, o1, h2, o2, c)
449#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
450 __bs_copy(4, t, h1, o1, h2, o2, c)
451#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
452 __bs_copy(8, t, h1, o1, h2, o2, c)
453
454#define bus_space_copy_region_stream_1 bus_space_copy_region_1
455#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
456 __bs_copy(s_2, t, h1, o1, h2, o2, c)
457#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
458 __bs_copy(s_4, t, h1, o1, h2, o2, c)
459#define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c) \
460 __bs_copy(s_8, t, h1, o1, h2, o2, c)
461#endif
462
463#define BUS_PEEK_FUNC(width, type) \
464 static inline int \
465 bus_space_peek_##width(bus_space_tag_t tag, \
466 bus_space_handle_t hnd, bus_size_t offset, type *value) \
467 { \
468 type tmp; \
469 tmp = bus_space_read_##width(tag, hnd, offset); \
470 *value = (type)tmp; \
471 return (0); \
472 }
473BUS_PEEK_FUNC(1, uint8_t)
474BUS_PEEK_FUNC(2, uint16_t)
475BUS_PEEK_FUNC(4, uint32_t)
476BUS_PEEK_FUNC(8, uint64_t)
477
478#define BUS_POKE_FUNC(width, type) \
479 static inline int \
480 bus_space_poke_##width(bus_space_tag_t tag, \
481 bus_space_handle_t hnd, bus_size_t offset, type value) \
482 { \
483 bus_space_write_##width(tag, hnd, offset, value); \
484 return (0); \
485 }
486BUS_POKE_FUNC(1, uint8_t)
487BUS_POKE_FUNC(2, uint16_t)
488BUS_POKE_FUNC(4, uint32_t)
489BUS_POKE_FUNC(8, uint64_t)
490
491#include <machine/bus_dma.h>
492
493#endif /* _MACHINE_BUS_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/bus_dma.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 Scott Long
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _POWERPC_BUS_DMA_H_
30#define _POWERPC_BUS_DMA_H_
31
32#include <sys/bus_dma.h>
33#include <sys/bus_dma_internal.h>
34
35int bus_dma_tag_set_iommu(bus_dma_tag_t, device_t iommu, void *cookie);
36
37#endif /* _POWERPC_BUS_DMA_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/clock.h created+18
......@@ -0,0 +1,18 @@
1/*-
2 * Kernel interface to machine-dependent clock driver.
3 * Garrett Wollman, September 1994.
4 * This file is in the public domain.
5 */
6
7#ifndef _MACHINE_CLOCK_H_
8#define _MACHINE_CLOCK_H_
9
10#ifdef _KERNEL
11
12struct trapframe;
13
14void decr_intr(struct trapframe *);
15
16#endif
17
18#endif /* !_MACHINE_CLOCK_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/counter.h created+164
......@@ -0,0 +1,164 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2012, 2013 Konstantin Belousov <kib@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef __MACHINE_COUNTER_H__
30#define __MACHINE_COUNTER_H__
31
32#include <sys/pcpu.h>
33#ifdef INVARIANTS
34#include <sys/proc.h>
35#endif
36
37#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter
38
39#ifdef __powerpc64__
40
41#define counter_enter() do {} while (0)
42#define counter_exit() do {} while (0)
43
44#ifdef IN_SUBR_COUNTER_C
45static inline uint64_t
46counter_u64_read_one(uint64_t *p, int cpu)
47{
48
49 return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu));
50}
51
52static inline uint64_t
53counter_u64_fetch_inline(uint64_t *p)
54{
55 uint64_t r;
56 int i;
57
58 r = 0;
59 CPU_FOREACH(i)
60 r += counter_u64_read_one((uint64_t *)p, i);
61
62 return (r);
63}
64
65static void
66counter_u64_zero_one_cpu(void *arg)
67{
68
69 *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE *
70 PCPU_GET(cpuid))) = 0;
71}
72
73static inline void
74counter_u64_zero_inline(counter_u64_t c)
75{
76
77 smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu,
78 smp_no_rendezvous_barrier, c);
79}
80#endif
81
82#define counter_u64_add_protected(c, i) counter_u64_add(c, i)
83
84static inline void
85counter_u64_add(counter_u64_t c, int64_t inc)
86{
87 uint64_t ccpu, old;
88
89 __asm __volatile("\n"
90 "1:\n\t"
91 "mfsprg %0, 0\n\t"
92 "ldarx %1, %0, %2\n\t"
93 "add %1, %1, %3\n\t"
94 "stdcx. %1, %0, %2\n\t"
95 "bne- 1b"
96 : "=&b" (ccpu), "=&r" (old)
97 : "r" ((char *)c - (char *)&__pcpu[0]), "r" (inc)
98 : "cr0", "memory");
99}
100
101#else /* !64bit */
102
103#include <sys/systm.h>
104
105#define counter_enter() critical_enter()
106#define counter_exit() critical_exit()
107
108#ifdef IN_SUBR_COUNTER_C
109/* XXXKIB non-atomic 64bit read */
110static inline uint64_t
111counter_u64_read_one(uint64_t *p, int cpu)
112{
113
114 return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu));
115}
116
117static inline uint64_t
118counter_u64_fetch_inline(uint64_t *p)
119{
120 uint64_t r;
121 int i;
122
123 r = 0;
124 for (i = 0; i < mp_ncpus; i++)
125 r += counter_u64_read_one((uint64_t *)p, i);
126
127 return (r);
128}
129
130/* XXXKIB non-atomic 64bit store, might interrupt increment */
131static void
132counter_u64_zero_one_cpu(void *arg)
133{
134
135 *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE *
136 PCPU_GET(cpuid))) = 0;
137}
138
139static inline void
140counter_u64_zero_inline(counter_u64_t c)
141{
142
143 smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu,
144 smp_no_rendezvous_barrier, c);
145}
146#endif
147
148#define counter_u64_add_protected(c, inc) do { \
149 CRITICAL_ASSERT(curthread); \
150 *(uint64_t *)zpcpu_get(c) += (inc); \
151} while (0)
152
153static inline void
154counter_u64_add(counter_u64_t c, int64_t inc)
155{
156
157 counter_enter();
158 counter_u64_add_protected(c, inc);
159 counter_exit();
160}
161
162#endif /* 64bit */
163
164#endif /* ! __MACHINE_COUNTER_H__ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/cpu.h created+157
......@@ -0,0 +1,157 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995-1997 Wolfgang Solfrank.
5 * Copyright (C) 1995-1997 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $
34 */
35
36#ifndef _MACHINE_CPU_H_
37#define _MACHINE_CPU_H_
38
39#include <machine/frame.h>
40#include <machine/pcb.h>
41#include <machine/psl.h>
42
43/*
44 * CPU Feature Attributes
45 *
46 * These are defined in the PowerPC ELF ABI for the AT_HWCAP vector,
47 * and are exported to userland via the machdep.cpu_features
48 * sysctl.
49 */
50
51extern u_long cpu_features;
52extern u_long cpu_features2;
53
54#define PPC_FEATURE_32 0x80000000 /* Always true */
55#define PPC_FEATURE_64 0x40000000 /* Defined on a 64-bit CPU */
56#define PPC_FEATURE_601_INSTR 0x20000000 /* Defined on a 64-bit CPU */
57#define PPC_FEATURE_HAS_ALTIVEC 0x10000000
58#define PPC_FEATURE_HAS_FPU 0x08000000
59#define PPC_FEATURE_HAS_MMU 0x04000000
60#define PPC_FEATURE_UNIFIED_CACHE 0x01000000
61#define PPC_FEATURE_HAS_SPE 0x00800000
62#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000
63#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000
64#define PPC_FEATURE_NO_TB 0x00100000
65#define PPC_FEATURE_POWER4 0x00080000
66#define PPC_FEATURE_POWER5 0x00040000
67#define PPC_FEATURE_POWER5_PLUS 0x00020000
68#define PPC_FEATURE_CELL 0x00010000
69#define PPC_FEATURE_BOOKE 0x00008000
70#define PPC_FEATURE_SMT 0x00004000
71#define PPC_FEATURE_ICACHE_SNOOP 0x00002000
72#define PPC_FEATURE_ARCH_2_05 0x00001000
73#define PPC_FEATURE_HAS_DFP 0x00000400
74#define PPC_FEATURE_POWER6_EXT 0x00000200
75#define PPC_FEATURE_ARCH_2_06 0x00000100
76#define PPC_FEATURE_HAS_VSX 0x00000080
77#define PPC_FEATURE_TRUE_LE 0x00000002
78#define PPC_FEATURE_PPC_LE 0x00000001
79
80#define PPC_FEATURE2_ARCH_2_07 0x80000000
81#define PPC_FEATURE2_HTM 0x40000000
82#define PPC_FEATURE2_DSCR 0x20000000
83#define PPC_FEATURE2_EBB 0x10000000
84#define PPC_FEATURE2_ISEL 0x08000000
85#define PPC_FEATURE2_TAR 0x04000000
86#define PPC_FEATURE2_HAS_VEC_CRYPTO 0x02000000
87#define PPC_FEATURE2_HTM_NOSC 0x01000000
88#define PPC_FEATURE2_ARCH_3_00 0x00800000
89#define PPC_FEATURE2_HAS_IEEE128 0x00400000
90#define PPC_FEATURE2_DARN 0x00200000
91#define PPC_FEATURE2_SCV 0x00100000
92#define PPC_FEATURE2_HTM_NOSUSPEND 0x00080000
93#define PPC_FEATURE2_ARCH_3_1 0x00040000
94#define PPC_FEATURE2_MMA 0x00020000
95
96#define PPC_FEATURE_BITMASK \
97 "\20" \
98 "\040PPC32\037PPC64\036PPC601\035ALTIVEC\034FPU\033MMU\031UNIFIEDCACHE" \
99 "\030SPE\027SPESFP\026DPESFP\025NOTB\024POWER4\023POWER5\022P5PLUS\021CELL"\
100 "\020BOOKE\017SMT\016ISNOOP\015ARCH205\013DFP\011ARCH206\010VSX"\
101 "\002TRUELE\001PPCLE"
102#define PPC_FEATURE2_BITMASK \
103 "\20" \
104 "\040ARCH207\037HTM\036DSCR\034ISEL\033TAR\032VCRYPTO\031HTMNOSC" \
105 "\030ARCH300\027IEEE128\026DARN\025SCV\024HTMNOSUSP"
106
107#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0)
108#define TRAPF_PC(frame) ((frame)->srr0)
109
110/*
111 * CTL_MACHDEP definitions.
112 */
113#define CPU_CACHELINE 1
114
115static __inline u_int64_t
116get_cyclecount(void)
117{
118 u_int32_t _upper, _lower;
119 u_int64_t _time;
120
121 __asm __volatile(
122 "mftb %0\n"
123 "mftbu %1"
124 : "=r" (_lower), "=r" (_upper));
125
126 _time = (u_int64_t)_upper;
127 _time = (_time << 32) + _lower;
128 return (_time);
129}
130
131#define cpu_getstack(td) ((td)->td_frame->fixreg[1])
132#define cpu_spinwait() __asm __volatile("or 27,27,27") /* yield */
133#define cpu_lock_delay() DELAY(1)
134
135extern char btext[];
136extern char etext[];
137
138struct thread;
139
140#ifdef __powerpc64__
141extern void enter_idle_powerx(void);
142extern uint64_t can_wakeup;
143extern register_t lpcr;
144#endif
145
146void cpu_halt(void);
147void cpu_reset(void);
148void flush_disable_caches(void);
149void fork_trampoline(void);
150int cpu_machine_check(struct thread *, struct trapframe *, int *);
151
152
153#ifndef __powerpc64__
154void mpc745x_sleep(void);
155#endif
156
157#endif /* _MACHINE_CPU_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/cpufunc.h created+298
......@@ -0,0 +1,298 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 1998 Doug Rabson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_CPUFUNC_H_
30#define _MACHINE_CPUFUNC_H_
31
32#ifdef _KERNEL
33
34#include <sys/types.h>
35
36#include <machine/psl.h>
37#include <machine/spr.h>
38
39struct thread;
40
41#ifdef KDB
42void breakpoint(void);
43#else
44static __inline void
45breakpoint(void)
46{
47
48 return;
49}
50#endif
51
52/* CPU register mangling inlines */
53
54static __inline void
55mtmsr(register_t value)
56{
57
58 __asm __volatile ("mtmsr %0; isync" :: "r"(value));
59}
60
61#ifdef __powerpc64__
62static __inline void
63mtmsrd(register_t value)
64{
65
66 __asm __volatile ("mtmsrd %0; isync" :: "r"(value));
67}
68#endif
69
70static __inline register_t
71mfmsr(void)
72{
73 register_t value;
74
75 __asm __volatile ("mfmsr %0" : "=r"(value));
76
77 return (value);
78}
79
80#ifndef __powerpc64__
81static __inline void
82mtsrin(vm_offset_t va, register_t value)
83{
84
85 __asm __volatile ("mtsrin %0,%1; isync" :: "r"(value), "r"(va));
86}
87
88static __inline register_t
89mfsrin(vm_offset_t va)
90{
91 register_t value;
92
93 __asm __volatile ("mfsrin %0,%1" : "=r"(value) : "r"(va));
94
95 return (value);
96}
97#endif
98
99static __inline register_t
100mfctrl(void)
101{
102 register_t value;
103
104 __asm __volatile ("mfspr %0,136" : "=r"(value));
105
106 return (value);
107}
108
109static __inline void
110mtdec(register_t value)
111{
112
113 __asm __volatile ("mtdec %0" :: "r"(value));
114}
115
116static __inline register_t
117mfdec(void)
118{
119 register_t value;
120
121 __asm __volatile ("mfdec %0" : "=r"(value));
122
123 return (value);
124}
125
126static __inline uint32_t
127mfpvr(void)
128{
129 uint32_t value;
130
131 __asm __volatile ("mfpvr %0" : "=r"(value));
132
133 return (value);
134}
135
136static __inline u_quad_t
137mftb(void)
138{
139 u_quad_t tb;
140 #ifdef __powerpc64__
141 __asm __volatile ("mftb %0" : "=r"(tb));
142 #else
143 uint32_t *tbup = (uint32_t *)&tb;
144 uint32_t *tblp = tbup + 1;
145
146 do {
147 *tbup = mfspr(TBR_TBU);
148 *tblp = mfspr(TBR_TBL);
149 } while (*tbup != mfspr(TBR_TBU));
150 #endif
151
152 return (tb);
153}
154
155static __inline void
156mttb(u_quad_t time)
157{
158
159 mtspr(TBR_TBWL, 0);
160 mtspr(TBR_TBWU, (uint32_t)(time >> 32));
161 mtspr(TBR_TBWL, (uint32_t)(time & 0xffffffff));
162}
163
164static __inline register_t
165mffs(void)
166{
167 uint64_t value;
168
169 __asm __volatile ("mffs 0; stfd 0,0(%0)"
170 :: "b"(&value));
171
172 return ((register_t)value);
173}
174
175static __inline void
176mtfsf(uint64_t value)
177{
178
179 __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0"
180 :: "b"(&value));
181}
182
183static __inline void
184eieio(void)
185{
186
187 __asm __volatile ("eieio" : : : "memory");
188}
189
190static __inline void
191isync(void)
192{
193
194 __asm __volatile ("isync" : : : "memory");
195}
196
197static __inline void
198powerpc_sync(void)
199{
200
201 __asm __volatile ("sync" : : : "memory");
202}
203
204static __inline int
205cntlzd(uint64_t word)
206{
207 uint64_t result;
208 /* cntlzd %0, %1 */
209 __asm __volatile(".long 0x7c000074 | (%1 << 21) | (%0 << 16)" :
210 "=r"(result) : "r"(word));
211
212 return (int)result;
213}
214
215static __inline int
216cnttzd(uint64_t word)
217{
218 uint64_t result;
219 /* cnttzd %0, %1 */
220 __asm __volatile(".long 0x7c000474 | (%1 << 21) | (%0 << 16)" :
221 "=r"(result) : "r"(word));
222
223 return (int)result;
224}
225
226static __inline void
227ptesync(void)
228{
229 __asm __volatile("ptesync");
230}
231
232static __inline register_t
233intr_disable(void)
234{
235 register_t msr;
236
237 msr = mfmsr();
238 mtmsr(msr & ~PSL_EE);
239 return (msr);
240}
241
242static __inline void
243intr_restore(register_t msr)
244{
245
246 mtmsr(msr);
247}
248
249static __inline struct pcpu *
250get_pcpu(void)
251{
252 struct pcpu *ret;
253
254 __asm __volatile("mfsprg %0, 0" : "=r"(ret));
255
256 return (ret);
257}
258
259/* "NOP" operations to signify priorities to the kernel. */
260static __inline void
261nop_prio_vlow(void)
262{
263 __asm __volatile("or 31,31,31");
264}
265
266static __inline void
267nop_prio_low(void)
268{
269 __asm __volatile("or 1,1,1");
270}
271
272static __inline void
273nop_prio_mlow(void)
274{
275 __asm __volatile("or 6,6,6");
276}
277
278static __inline void
279nop_prio_medium(void)
280{
281 __asm __volatile("or 2,2,2");
282}
283
284static __inline void
285nop_prio_mhigh(void)
286{
287 __asm __volatile("or 5,5,5");
288}
289
290static __inline void
291nop_prio_high(void)
292{
293 __asm __volatile("or 3,3,3");
294}
295
296#endif /* _KERNEL */
297
298#endif /* !_MACHINE_CPUFUNC_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/db_machdep.h created+87
......@@ -0,0 +1,87 @@
1/*-
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 *
26 * $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $
27 * $NetBSD: db_machdep.h,v 1.4.22.1 2000/08/05 11:10:43 wiz Exp $
28 */
29
30/*
31 * Machine-dependent defines for new kernel debugger.
32 */
33#ifndef _POWERPC_DB_MACHDEP_H_
34#define _POWERPC_DB_MACHDEP_H_
35
36#include <vm/vm_param.h>
37#include <machine/elf.h>
38
39#define DB_ELF_SYMBOLS
40#define DB_ELFSIZE __ELF_WORD_SIZE
41
42typedef vm_offset_t db_addr_t; /* address - unsigned */
43typedef intptr_t db_expr_t; /* expression - signed */
44
45#define PC_REGS(regs) ((db_addr_t)kdb_thrctx->pcb_lr)
46
47#define BKPT_INST 0x7C810808 /* breakpoint instruction */
48
49#define BKPT_SIZE (4) /* size of breakpoint inst */
50#define BKPT_SET(inst) (BKPT_INST)
51
52#define db_clear_single_step kdb_cpu_clear_singlestep
53#define db_set_single_step kdb_cpu_set_singlestep
54
55#if 0
56#define SR_SINGLESTEP 0x400
57#define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP)
58#define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP)
59#endif
60
61#define T_BREAKPOINT 0xffff
62#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT)
63
64#define T_WATCHPOINT 0xeeee
65#ifdef T_WATCHPOINT
66#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT)
67#else
68#define IS_WATCHPOINT_TRAP(type, code) 0
69#endif
70
71#define M_RTS 0xfc0007fe
72#define I_RTS 0x4c000020
73#define M_BC 0xfc000000
74#define I_BC 0x40000000
75#define M_B 0xfc000000
76#define I_B 0x50000000
77#define M_RFI 0xfc0007fe
78#define I_RFI 0x4c000064
79
80#define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI)
81#define inst_return(ins) (((ins)&M_RTS) == I_RTS)
82#define inst_call(ins) (((ins)&M_BC ) == I_BC || \
83 ((ins)&M_B ) == I_B )
84#define inst_load(ins) 0
85#define inst_store(ins) 0
86
87#endif /* _POWERPC_DB_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/dbdma.h created+153
......@@ -0,0 +1,153 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Nathan Whitehorn
5 * All rights reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_DBDMA_H_
30#define _MACHINE_DBDMA_H_
31
32#include <sys/param.h>
33#include <machine/bus.h>
34
35/*
36 * Apple's DBDMA (Descriptor-based DMA) interface is a common DMA engine
37 * used by a variety of custom Apple ASICs. It is described in the CHRP
38 * specification and in the book Macintosh Technology in the Common
39 * Hardware Reference Platform, copyright 1995 Apple Computer.
40 */
41
42/* DBDMA Command Values */
43
44enum {
45 DBDMA_OUTPUT_MORE = 0,
46 DBDMA_OUTPUT_LAST = 1,
47 DBDMA_INPUT_MORE = 2,
48 DBDMA_INPUT_LAST = 3,
49
50 DBDMA_STORE_QUAD = 4,
51 DBDMA_LOAD_QUAD = 5,
52 DBDMA_NOP = 6,
53 DBDMA_STOP = 7
54};
55
56/* These codes are for the interrupt, branch, and wait flags */
57
58enum {
59 DBDMA_NEVER = 0,
60 DBDMA_COND_TRUE = 1,
61 DBDMA_COND_FALSE = 2,
62 DBDMA_ALWAYS = 3
63};
64
65/* Channel status bits */
66#define DBDMA_STATUS_RUN (0x01 << 15)
67#define DBDMA_STATUS_PAUSE (0x01 << 14)
68#define DBDMA_STATUS_FLUSH (0x01 << 13)
69#define DBDMA_STATUS_WAKE (0x01 << 12)
70#define DBDMA_STATUS_DEAD (0x01 << 11)
71#define DBDMA_STATUS_ACTIVE (0x01 << 10)
72
73/* Set by hardware if a branch was taken */
74#define DBDMA_STATUS_BRANCH 8
75
76struct dbdma_command;
77typedef struct dbdma_command dbdma_command_t;
78struct dbdma_channel;
79typedef struct dbdma_channel dbdma_channel_t;
80
81int dbdma_allocate_channel(struct resource *dbdma_regs, u_int offset,
82 bus_dma_tag_t parent_dma, int slots, dbdma_channel_t **chan);
83
84int dbdma_resize_channel(dbdma_channel_t *chan, int newslots);
85int dbdma_free_channel(dbdma_channel_t *chan);
86
87void dbdma_run(dbdma_channel_t *chan);
88void dbdma_stop(dbdma_channel_t *chan);
89void dbdma_reset(dbdma_channel_t *chan);
90void dbdma_set_current_cmd(dbdma_channel_t *chan, int slot);
91
92void dbdma_pause(dbdma_channel_t *chan);
93void dbdma_wake(dbdma_channel_t *chan);
94
95/*
96 * DBDMA uses a 16 bit channel control register to describe the current
97 * state of DMA on the channel. The high-order bits (8-15) contain information
98 * on the run state and are listed in the DBDMA_STATUS_* constants above. These
99 * are manipulated with the dbdma_run/stop/reset() routines above.
100 *
101 * The low order bits (0-7) are device dependent status bits. These can be set
102 * and read by both hardware and software. The mask is the set of bits to
103 * modify; if mask is 0x03 and value is 0, the lowest order 2 bits will be
104 * zeroed.
105 */
106
107uint16_t dbdma_get_chan_status(dbdma_channel_t *chan);
108
109uint8_t dbdma_get_device_status(dbdma_channel_t *chan);
110void dbdma_set_device_status(dbdma_channel_t *chan, uint8_t mask,
111 uint8_t value);
112
113/*
114 * Each DBDMA command word has the current channel status register and the
115 * number of residual bytes (requested - actually transferred) written to it
116 * at time of command completion.
117 */
118
119uint16_t dbdma_get_cmd_status(dbdma_channel_t *chan, int slot);
120uint16_t dbdma_get_residuals(dbdma_channel_t *chan, int slot);
121
122void dbdma_clear_cmd_status(dbdma_channel_t *chan, int slot);
123
124/*
125 * The interrupt/branch/wait selector let you specify a set of values
126 * of the device dependent status bits that will cause intterupt/branch/wait
127 * conditions to be taken if the flags for these are set to one of the
128 * DBDMA_COND_* values.
129 *
130 * The condition is considered true if (status & mask) == value.
131 */
132
133void dbdma_set_interrupt_selector(dbdma_channel_t *chan, uint8_t mask,
134 uint8_t value);
135void dbdma_set_branch_selector(dbdma_channel_t *chan, uint8_t mask,
136 uint8_t value);
137void dbdma_set_wait_selector(dbdma_channel_t *chan, uint8_t mask,
138 uint8_t value);
139
140void dbdma_insert_command(dbdma_channel_t *chan, int slot, int command,
141 int stream, bus_addr_t data, size_t count, uint8_t interrupt,
142 uint8_t branch, uint8_t wait, uint32_t branch_slot);
143
144void dbdma_insert_stop(dbdma_channel_t *chan, int slot);
145void dbdma_insert_nop(dbdma_channel_t *chan, int slot);
146void dbdma_insert_branch(dbdma_channel_t *chan, int slot, int to_slot);
147
148void dbdma_sync_commands(dbdma_channel_t *chan, bus_dmasync_op_t op);
149
150void dbdma_save_state(dbdma_channel_t *chan);
151void dbdma_restore_state(dbdma_channel_t *chan);
152
153#endif /* _MACHINE_DBDMA_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/dump.h created+73
......@@ -0,0 +1,73 @@
1/*-
2 * Copyright (c) 2014 EMC Corp.
3 * Author: Conrad Meyer <conrad.meyer@isilon.com>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_DUMP_H_
29#define _MACHINE_DUMP_H_
30
31#define KERNELDUMP_ARCH_VERSION KERNELDUMP_POWERPC_VERSION
32#define EM_VALUE ELF_ARCH /* Defined in powerpc/include/elf.h */
33#define DUMPSYS_MD_PA_NPAIRS (PHYS_AVAIL_SZ + 1)
34#define DUMPSYS_NUM_AUX_HDRS 0
35
36/* How often to check the dump progress bar? */
37#define DUMPSYS_PB_CHECK_BITS 20 /* Every 1MB */
38
39void dumpsys_pa_init(void);
40void dumpsys_unmap_chunk(vm_paddr_t, size_t, void *);
41size_t dumpsys_scan_pmap(struct bitset *);
42void *dumpsys_dump_pmap_init(unsigned blkpgs);
43void *dumpsys_dump_pmap(void *ctx, void *buf, u_long *nbytes);
44
45static inline struct dump_pa *
46dumpsys_pa_next(struct dump_pa *p)
47{
48
49 return (dumpsys_gen_pa_next(p));
50}
51
52static inline void
53dumpsys_wbinv_all(void)
54{
55
56 dumpsys_gen_wbinv_all();
57}
58
59static inline int
60dumpsys_write_aux_headers(struct dumperinfo *di)
61{
62
63 return (dumpsys_gen_write_aux_headers(di));
64}
65
66static inline int
67dumpsys(struct dumperinfo *di)
68{
69
70 return (dumpsys_generic(di));
71}
72
73#endif /* !_MACHINE_DUMP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/efi.h created+12
......@@ -0,0 +1,12 @@
1/*-
2 * This file is in the public domain since it's just boilerplate.
3 */
4
5#ifndef __POWERPC_INCLUDE_EFI_H_
6#define __POWERPC_INCLUDE_EFI_H_
7
8#define EFIABI_ATTR
9
10/* Note: we don't actually support this on powerpc */
11
12#endif /* __POWERPC_INCLUDE_EFI_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/elf.h created+146
......@@ -0,0 +1,146 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * Copyright (c) 1996-1997 John D. Polstra.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_ELF_H_
31#define _MACHINE_ELF_H_ 1
32
33/*
34 * EABI ELF definitions for the PowerPC architecture.
35 * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation"
36 * [ppc-eabi-1995-01.pdf] for details.
37 */
38
39#ifndef __ELF_WORD_SIZE
40#ifdef __powerpc64__
41#define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */
42#else
43#define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */
44#endif
45#endif
46
47#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */
48#include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */
49#include <sys/elf_generic.h>
50
51#if __ELF_WORD_SIZE == 64
52#define ELF_ARCH EM_PPC64
53#define ELF_MACHINE_OK(x) ((x) == EM_PPC64)
54#else
55#define ELF_ARCH EM_PPC
56#define ELF_ARCH32 EM_PPC
57#define ELF_MACHINE_OK(x) ((x) == EM_PPC)
58#endif
59
60/*
61 * Auxiliary vector entries for passing information to the interpreter.
62 *
63 * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t",
64 * but POSIX lays claim to all symbols ending with "_t".
65 */
66
67typedef struct { /* Auxiliary vector entry on initial stack */
68 int a_type; /* Entry type. */
69 union {
70#ifdef __powerpc64__
71 int a_val; /* Integer value */
72#else
73 long a_val; /* Integer value. */
74 void *a_ptr; /* Address. */
75 void (*a_fcn)(void); /* Function pointer (not used). */
76#endif
77 } a_un;
78} Elf32_Auxinfo;
79
80typedef struct { /* Auxiliary vector entry on initial stack */
81 long a_type; /* Entry type. */
82 union {
83 long a_val; /* Integer value. */
84 void *a_ptr; /* Address. */
85 void (*a_fcn)(void); /* Function pointer (not used). */
86 } a_un;
87} Elf64_Auxinfo;
88
89__ElfType(Auxinfo);
90
91/*
92 * Relocation types.
93 */
94
95#define R_PPC_COUNT 37 /* Count of defined relocation types. */
96
97 /* Count of defined relocation types. */
98#define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1)
99
100/* Define "machine" characteristics */
101#if BYTE_ORDER == LITTLE_ENDIAN
102#define ELF_TARG_DATA ELFDATA2LSB
103#else
104#define ELF_TARG_DATA ELFDATA2MSB
105#endif
106#if __ELF_WORD_SIZE == 64
107#define ELF_TARG_CLASS ELFCLASS64
108#define ELF_TARG_MACH EM_PPC64
109#define ELF_TARG_VER 1
110#else
111#define ELF_TARG_CLASS ELFCLASS32
112#define ELF_TARG_MACH EM_PPC
113#define ELF_TARG_VER 1
114#endif
115
116#define ET_DYN_LOAD_ADDR 0x01010000
117
118#define AT_OLD_NULL AT_NULL
119#define AT_OLD_IGNORE AT_IGNORE
120#define AT_OLD_EXECFD AT_EXECFD
121#define AT_OLD_PHDR AT_PHDR
122#define AT_OLD_PHENT AT_PHENT
123#define AT_OLD_PHNUM AT_PHNUM
124#define AT_OLD_PAGESZ AT_PAGESZ
125#define AT_OLD_BASE AT_BASE
126#define AT_OLD_FLAGS AT_FLAGS
127#define AT_OLD_ENTRY AT_ENTRY
128#define AT_OLD_NOTELF AT_NOTELF
129#define AT_OLD_UID AT_UID
130#define AT_OLD_EUID AT_EUID
131#define AT_OLD_EXECPATH 13
132#define AT_OLD_CANARY 14
133#define AT_OLD_CANARYLEN 15
134#define AT_OLD_OSRELDATE 16
135#define AT_OLD_NCPUS 17
136#define AT_OLD_PAGESIZES 18
137#define AT_OLD_PAGESIZESLEN 19
138#define AT_OLD_STACKPROT 21
139#define AT_OLD_TIMEKEEP AT_TIMEKEEP
140#define AT_OLD_EHDRFLAGS AT_EHDRFLAGS
141#define AT_OLD_HWCAP AT_HWCAP
142#define AT_OLD_HWCAP2 AT_HWCAP2
143
144#define AT_OLD_COUNT 27 /* Count of defined aux entry types. */
145
146#endif /* !_MACHINE_ELF_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/endian.h created+38
......@@ -0,0 +1,38 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1987, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_ENDIAN_H_
33#define _MACHINE_ENDIAN_H_
34
35#include <sys/_types.h>
36#include <sys/_endian.h>
37
38#endif /* !_MACHINE_ENDIAN_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/exec.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_EXEC_H_
33#define _MACHINE_EXEC_H_
34
35#define __LDPGSZ 4096
36
37#endif /* !_MACHINE_EXEC_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/float.h created+98
......@@ -0,0 +1,98 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1989 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11
31 */
32
33#ifndef _MACHINE_FLOAT_H_
34#define _MACHINE_FLOAT_H_ 1
35
36#include <sys/cdefs.h>
37
38#ifndef _SOFT_FLOAT
39__BEGIN_DECLS
40extern int __flt_rounds(void);
41__END_DECLS
42#define FLT_ROUNDS __flt_rounds()
43#else
44#define FLT_ROUNDS (-1)
45#endif
46
47#define FLT_RADIX 2 /* b */
48#if __ISO_C_VISIBLE >= 1999
49#define FLT_EVAL_METHOD 0
50#define DECIMAL_DIG 17 /* max precision in decimal digits */
51#endif
52
53#define FLT_MANT_DIG 24 /* p */
54#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
55#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
56#define FLT_MIN_EXP (-125) /* emin */
57#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
58#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
59#define FLT_MAX_EXP 128 /* emax */
60#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
61#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
62#if __ISO_C_VISIBLE >= 2011
63#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */
64#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */
65#define FLT_HAS_SUBNORM 1
66#endif /* __ISO_C_VISIBLE >= 2011 */
67
68#define DBL_MANT_DIG 53
69#define DBL_EPSILON 2.2204460492503131E-16
70#define DBL_DIG 15
71#define DBL_MIN_EXP (-1021)
72#define DBL_MIN 2.2250738585072014E-308
73#define DBL_MIN_10_EXP (-307)
74#define DBL_MAX_EXP 1024
75#define DBL_MAX 1.7976931348623157E+308
76#define DBL_MAX_10_EXP 308
77#if __ISO_C_VISIBLE >= 2011
78#define DBL_TRUE_MIN 4.9406564584124654E-324
79#define DBL_DECIMAL_DIG 17
80#define DBL_HAS_SUBNORM 1
81#endif /* __ISO_C_VISIBLE >= 2011 */
82
83#define LDBL_MANT_DIG DBL_MANT_DIG
84#define LDBL_EPSILON ((long double)DBL_EPSILON)
85#define LDBL_DIG DBL_DIG
86#define LDBL_MIN_EXP DBL_MIN_EXP
87#define LDBL_MIN ((long double)DBL_MIN)
88#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
89#define LDBL_MAX_EXP DBL_MAX_EXP
90#define LDBL_MAX ((long double)DBL_MAX)
91#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
92#if __ISO_C_VISIBLE >= 2011
93#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN)
94#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
95#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
96#endif /* __ISO_C_VISIBLE >= 2011 */
97
98#endif /* _MACHINE_FLOAT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/floatingpoint.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _FLOATINGPOINT_H_
33#define _FLOATINGPOINT_H_
34
35#include <machine/ieeefp.h>
36
37#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/fpu.h created+102
......@@ -0,0 +1,102 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1996 Wolfgang Solfrank.
5 * Copyright (C) 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: fpu.h,v 1.2 1999/12/07 15:14:56 danw Exp $
34 */
35
36#ifndef _MACHINE_FPU_H_
37#define _MACHINE_FPU_H_
38
39#define FPSCR_FX 0x80000000
40#define FPSCR_FEX 0x40000000
41#define FPSCR_VX 0x20000000
42#define FPSCR_OX 0x10000000
43#define FPSCR_UX 0x08000000
44#define FPSCR_ZX 0x04000000
45#define FPSCR_XX 0x02000000
46#define FPSCR_VXSNAN 0x01000000
47#define FPSCR_VXISI 0x00800000
48#define FPSCR_VXIDI 0x00400000
49#define FPSCR_VXZDZ 0x00200000
50#define FPSCR_VXIMZ 0x00100000
51#define FPSCR_VXVC 0x00080000
52#define FPSCR_FR 0x00040000
53#define FPSCR_FI 0x00020000
54#define FPSCR_FPRF 0x0001f000
55#define FPSCR_C 0x00010000
56#define FPSCR_FPCC 0x0000f000
57#define FPSCR_FL 0x00008000
58#define FPSCR_FG 0x00004000
59#define FPSCR_FE 0x00002000
60#define FPSCR_FU 0x00001000
61#define FPSCR_VXSOFT 0x00000400
62#define FPSCR_VXSQRT 0x00000200
63#define FPSCR_VXCVI 0x00000100
64#define FPSCR_VE 0x00000080
65#define FPSCR_OE 0x00000040
66#define FPSCR_UE 0x00000020
67#define FPSCR_ZE 0x00000010
68#define FPSCR_XE 0x00000008
69#define FPSCR_NI 0x00000004
70#define FPSCR_RN 0x00000003
71
72#ifdef _KERNEL
73
74void enable_fpu(struct thread *);
75void save_fpu(struct thread *);
76void save_fpu_nodrop(struct thread *);
77void cleanup_fpscr(void);
78u_int get_fpu_exception(struct thread *);
79void enable_fpu_kern(void);
80void disable_fpu(struct thread *td);
81
82/*
83 * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread().
84 */
85#define FPU_KERN_NORMAL 0x0000
86#define FPU_KERN_NOWAIT 0x0001
87#define FPU_KERN_KTHR 0x0002
88#define FPU_KERN_NOCTX 0x0004
89
90struct fpu_kern_ctx;
91
92struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
93void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
94void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
95 u_int flags);
96int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
97int fpu_kern_thread(u_int flags);
98int is_fpu_kern_thread(u_int flags);
99
100#endif /* _KERNEL */
101
102#endif /* _MACHINE_FPU_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/frame.h created+114
......@@ -0,0 +1,114 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: frame.h,v 1.2 1999/01/10 10:13:15 tsubai Exp $
34 */
35
36#ifndef _MACHINE_FRAME_H_
37#define _MACHINE_FRAME_H_
38
39#include <sys/types.h>
40
41/*
42 * We have to save all registers on every trap, because
43 * 1. user could attach this process every time
44 * 2. we must be able to restore all user registers in case of fork
45 * Actually, we do not save the fp registers on trap, since
46 * these are not used by the kernel. They are saved only when switching
47 * between processes using the FPU.
48 *
49 * Change ordering to cluster together these register_t's. XXX
50 */
51struct trapframe {
52 register_t fixreg[32];
53 register_t lr;
54 register_t cr;
55 register_t xer;
56 register_t ctr;
57 register_t srr0;
58 register_t srr1;
59 register_t exc;
60 register_t dar; /* DAR/DEAR filled in on DSI traps */
61 union {
62 struct {
63 /* dsisr only filled on a DSI trap */
64 register_t dsisr;
65 } aim;
66 struct {
67 register_t esr;
68 register_t dbcr0;
69 } booke;
70 } cpu;
71};
72
73/*
74 * FRAMELEN is the size of the stack region used by the low-level trap
75 * handler. It is the size of its data (trapframe) plus the callframe
76 * header (sizeof(struct callframe) - 3 register widths). It must also
77 * be 16-byte aligned.
78 */
79#define FRAMELEN roundup(sizeof(struct trapframe) + \
80 sizeof(struct callframe) - 3*sizeof(register_t), 16)
81#define trapframe(td) ((td)->td_frame)
82
83/*
84 * Call frame for PowerPC used during fork.
85 */
86#ifdef __powerpc64__
87struct callframe {
88 register_t cf_dummy_fp; /* dummy frame pointer */
89 register_t cf_cr;
90 register_t cf_lr;
91 register_t cf_compiler;
92 register_t cf_linkeditor;
93 register_t cf_toc;
94 register_t cf_func;
95 register_t cf_arg0;
96 register_t cf_arg1;
97 register_t _padding; /* Maintain 16-byte alignment */
98};
99#else
100struct callframe {
101 register_t cf_dummy_fp; /* dummy frame pointer */
102 register_t cf_lr; /* space for link register save */
103 register_t cf_func;
104 register_t cf_arg0;
105 register_t cf_arg1;
106 register_t _padding; /* Maintain 16-byte alignment */
107};
108#endif
109
110/* Definitions for syscalls */
111#define FIRSTARG 3 /* first arg in reg 3 */
112#define NARGREG 8 /* 8 args in regs */
113
114#endif /* _MACHINE_FRAME_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/gdb_machdep.h created+140
......@@ -0,0 +1,140 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2006 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_GDB_MACHDEP_H_
30#define _MACHINE_GDB_MACHDEP_H_
31
32#ifdef BOOKE
33#define PPC_GDB_NREGS0 1
34#define PPC_GDB_NREGS4 (70 + 1)
35#define PPC_GDB_NREGS8 (1 + 32)
36#define PPC_GDB_NREGS16 0
37
38#else
39/*
40 * 0 - 32*GPR(4/8)
41 * 32 - 32*FPR(8)
42 * 64 - PC, PS (4/8)
43 * 66 - CR (4)
44 * 67 - LR, CTR (4/8)
45 * 69 - XER, FPSCR (4)
46 * 71 - 32*VR(16)
47 * 103 - VSCR, VRSAVE (4)
48 */
49
50#define PPC_REGNUM_R0 0
51#define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31)
52#define PPC_REGNUM_FR0 32
53#define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31)
54#define PPC_REGNUM_PC 64
55#define PPC_REGNUM_PS 65
56#define PPC_REGNUM_CR 66
57#define PPC_REGNUM_LR 67
58#define PPC_REGNUM_CTR 68
59#define PPC_REGNUM_XER 69
60#define PPC_REGNUM_FPSCR 70
61#define PPC_REGNUM_VR0 71
62#define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31)
63
64#define PPC_GDB_NREGS0 0
65
66#ifdef __powerpc64__
67#define PPC_GDB_NREGS4 5
68#define PPC_GDB_NREGS8 (64 + 4)
69#else
70#define PPC_GDB_NREGS4 (32 + 7 + 2)
71#define PPC_GDB_NREGS8 32
72#endif
73
74#define PPC_GDB_NREGS16 32
75#endif
76
77#define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \
78 PPC_GDB_NREGS8 + PPC_GDB_NREGS16)
79#define GDB_REG_PC 64
80
81#define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \
82 PPC_GDB_NREGS8 * 16 + \
83 PPC_GDB_NREGS16 * 32)
84
85static __inline size_t
86gdb_cpu_regsz(int regnum)
87{
88
89#ifdef BOOKE
90 if (regnum == 70)
91 return (0);
92 if (regnum == 71 || regnum >= 73)
93 return (8);
94#else
95#ifdef __powerpc64__
96 if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) ||
97 regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR)
98 return (8);
99#else
100 if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31)
101 return (8);
102#endif
103 if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31)
104 return (16);
105#endif
106 return (4);
107}
108
109static __inline int
110gdb_cpu_query(void)
111{
112
113 return (0);
114}
115
116static __inline void *
117gdb_begin_write(void)
118{
119
120 return (NULL);
121}
122
123static __inline void
124gdb_end_write(void *arg __unused)
125{
126
127}
128
129static __inline void
130gdb_cpu_stop_reason(int type __unused, int code __unused)
131{
132
133}
134
135void *gdb_cpu_getreg(int, size_t *);
136void gdb_cpu_setreg(int, void *);
137int gdb_cpu_signal(int, int);
138void gdb_cpu_do_offsets(void);
139
140#endif /* !_MACHINE_GDB_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/hid.h created+223
......@@ -0,0 +1,223 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $NetBSD: hid.h,v 1.2 2001/08/22 21:05:25 matt Exp $
29 */
30
31#ifndef _POWERPC_HID_H_
32#define _POWERPC_HID_H_
33
34/* Hardware Implementation Dependent registers for the PowerPC */
35#define HID0_RADIX 0x0080000000000000 /* Enable Radix page tables (POWER9) */
36
37#define HID0_EMCP 0x80000000 /* Enable machine check pin */
38#define HID0_DBP 0x40000000 /* Disable 60x bus parity generation */
39#define HID0_EBA 0x20000000 /* Enable 60x bus address parity checking */
40#define HID0_EBD 0x10000000 /* Enable 60x bus data parity checking */
41#define HID0_BCLK 0x08000000 /* CLK_OUT clock type selection */
42#define HID0_EICE 0x04000000 /* Enable ICE output */
43#define HID0_ECLK 0x02000000 /* CLK_OUT clock type selection */
44#define HID0_PAR 0x01000000 /* Disable precharge of ARTRY */
45#define HID0_STEN 0x01000000 /* Software table search enable (7450) */
46#define HID0_DEEPNAP 0x01000000 /* Enable deep nap mode (970) */
47#define HID0_HBATEN 0x00800000 /* High BAT enable (74[45][578]) */
48#define HID0_DOZE 0x00800000 /* Enable doze mode */
49#define HID0_NAP 0x00400000 /* Enable nap mode */
50#define HID0_SLEEP 0x00200000 /* Enable sleep mode */
51#define HID0_DPM 0x00100000 /* Enable Dynamic power management */
52#define HID0_RISEG 0x00080000 /* Read I-SEG */
53#define HID0_TG 0x00040000 /* Timebase Granularity (OEA64) */
54#define HID0_BHTCLR 0x00040000 /* Clear branch history table (7450) */
55#define HID0_EIEC 0x00040000 /* Enable internal error checking */
56#define HID0_XAEN 0x00020000 /* Enable eXtended Addressing (7450) */
57#define HID0_NHR 0x00010000 /* Not hard reset */
58#define HID0_ICE 0x00008000 /* Enable i-cache */
59#define HID0_DCE 0x00004000 /* Enable d-cache */
60#define HID0_ILOCK 0x00002000 /* i-cache lock */
61#define HID0_DLOCK 0x00001000 /* d-cache lock */
62#define HID0_ICFI 0x00000800 /* i-cache flush invalidate */
63#define HID0_DCFI 0x00000400 /* d-cache flush invalidate */
64#define HID0_SPD 0x00000200 /* Disable speculative cache access */
65#define HID0_XBSEN 0x00000100 /* Extended BAT block-size enable (7457) */
66#define HID0_IFEM 0x00000100 /* Enable M-bit for I-fetch */
67#define HID0_XBSEN 0x00000100 /* Extended BAT block size enable (7455+)*/
68#define HID0_SGE 0x00000080 /* Enable store gathering */
69#define HID0_DCFA 0x00000040 /* Data cache flush assist */
70#define HID0_BTIC 0x00000020 /* Enable BTIC */
71#define HID0_LRSTK 0x00000010 /* Link register stack enable (7450) */
72#define HID0_ABE 0x00000008 /* Enable address broadcast */
73#define HID0_FOLD 0x00000008 /* Branch folding enable (7450) */
74#define HID0_BHT 0x00000004 /* Enable branch history table */
75#define HID0_NOPTI 0x00000001 /* No-op the dcbt(st) */
76
77#define HID0_AIM_TBEN 0x04000000 /* Time base enable (7450) */
78
79#define HID0_E500_TBEN 0x00004000 /* Time Base and decr. enable */
80#define HID0_E500_SEL_TBCLK 0x00002000 /* Select Time Base clock */
81#define HID0_E500_MAS7UPDEN 0x00000080 /* Enable MAS7 update (e500v2) */
82
83#define HID0_E500MC_L2MMU_MHD 0x40000000 /* L2MMU Multiple Hit Detection */
84
85#define HID0_BITMASK \
86 "\20" \
87 "\040EMCP\037DBP\036EBA\035EBD\034BCLK\033EICE\032ECLK\031PAR" \
88 "\030DOZE\027NAP\026SLEEP\025DPM\024RISEG\023EIEC\022res\021NHR" \
89 "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011IFEM" \
90 "\010SGE\007DCFA\006BTIC\005FBIOB\004ABE\003BHT\002NOPDST\001NOPTI"
91
92#define HID0_7450_BITMASK \
93 "\20" \
94 "\040EMCP\037b1\036b2\035b3\034b4\033TBEN\032b6\031STEN" \
95 "\030HBATEN\027NAP\026SLEEP\025DPM\024b12\023BHTCLR\022XAEN\021NHR" \
96 "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011XBSEN" \
97 "\010SGE\007b25\006BTIC\005LRSTK\004FOLD\003BHT\002NOPDST\001NOPTI"
98
99#define HID0_E500_BITMASK \
100 "\20" \
101 "\040EMCP\037b1\036b2\035b3\034b4\033b5\032b6\031b7" \
102 "\030DOZE\027NAP\026SLEEP\025b11\024b12\023b13\022b14\021b15" \
103 "\020b16\017TBEN\016SEL_TBCLK\015b19\014b20\013b21\012b22\011b23" \
104 "\010EN_MAS7_UPDATE\007DCFA\006b26\005b27\004b28\003b29\002b30\001NOPTI"
105
106#define HID0_970_BITMASK \
107 "\20" \
108 "\040ONEPPC\037SINGLE\036ISYNCSC\035SERGP\031DEEPNAP\030DOZE" \
109 "\027NAP\025DPM\023TG\022HANGDETECT\021NHR\020INORDER" \
110 "\016TBCTRL\015TBEN\012CIABREN\011HDICEEN\001ENATTN"
111
112#define HID0_E500MC_BITMASK \
113 "\20" \
114 "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \
115 "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \
116 "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \
117 "\010EN_MAS7_UPDATE\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI"
118
119#define HID0_E5500_BITMASK \
120 "\20" \
121 "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \
122 "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \
123 "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \
124 "\010b24\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI"
125
126/*
127 * HID0 bit definitions per cpu model
128 *
129 * bit 603 604 750 7400 7410 7450 7457 e500
130 * 0 EMCP EMCP EMCP EMCP EMCP - - EMCP
131 * 1 - ECP DBP - - - - -
132 * 2 EBA EBA EBA EBA EDA - - -
133 * 3 EBD EBD EBD EBD EBD - - -
134 * 4 SBCLK - BCLK BCKL BCLK - - -
135 * 5 EICE - - - - TBEN TBEN -
136 * 6 ECLK - ECLK ECLK ECLK - - -
137 * 7 PAR PAR PAR PAR PAR STEN STEN -
138 * 8 DOZE - DOZE DOZE DOZE - HBATEN DOZE
139 * 9 NAP - NAP NAP NAP NAP NAP NAP
140 * 10 SLEEP - SLEEP SLEEP SLEEP SLEEP SLEEP SLEEP
141 * 11 DPM - DPM DPM DPM DPM DPM -
142 * 12 RISEG - - RISEG - - - -
143 * 13 - - - EIEC EIEC BHTCLR BHTCLR -
144 * 14 - - - - - XAEN XAEN -
145 * 15 - NHR NHR NHR NHR NHR NHR -
146 * 16 ICE ICE ICE ICE ICE ICE ICE -
147 * 17 DCE DCE DCE DCE DCE DCE DCE TBEN
148 * 18 ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK SEL_TBCLK
149 * 19 DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK -
150 * 20 ICFI ICFI ICFI ICFI ICFI ICFI ICFI -
151 * 21 DCFI DCFI DCFI DCFI DCFI DCFI DCFI -
152 * 22 - - SPD SPD SPG SPD SPD -
153 * 23 - - IFEM IFTT IFTT - XBSEN -
154 * 24 - SIE SGE SGE SGE SGE SGE EN_MAS7_UPDATE
155 * 25 - - DCFA DCFA DCFA - - DCFA
156 * 26 - - BTIC BTIC BTIC BTIC BTIC -
157 * 27 FBIOB - - - - LRSTK LRSTK -
158 * 28 - - ABE - - FOLD FOLD -
159 * 29 - BHT BHT BHT BHT BHT BHT -
160 * 30 - - - NOPDST NOPDST NOPDST NOPDST -
161 * 31 NOOPTI - NOOPTI NOPTI NOPTI NOPTI NOPTI NOPTI
162 *
163 * bit e500mc e5500
164 * 0 EMCP EMCP
165 * 1 EN_L2MMU_MHD EN_L2MMU_MHD
166 * 2 - -
167 * 3 - -
168 * 4 - -
169 * 5 - -
170 * 6 - -
171 * 7 - -
172 * 8 - -
173 * 9 - -
174 * 10 - -
175 * 11 - -
176 * 12 - -
177 * 13 - -
178 * 14 - -
179 * 15 - -
180 * 16 - -
181 * 17 - -
182 * 18 - -
183 * 19 - -
184 * 20 - -
185 * 21 - -
186 * 22 - -
187 * 23 - -
188 * 24 EN_MAS7_UPDATE -
189 * 25 DCFA DCFA
190 * 26 - -
191 * 27 CIGLSO CIGLSO
192 * 28 - -
193 * 29 - -
194 * 30 - -
195 * 31 NOPTI NOPTI
196 *
197 * 604: ECP = Enable cache parity checking
198 * 604: SIE = Serial instruction execution disable
199 * 7450: TBEN = Time Base Enable
200 * 7450: STEN = Software table lookup enable
201 * 7450: BHTCLR = Branch history clear
202 * 7450: XAEN = Extended Addressing Enabled
203 * 7450: LRSTK = Link Register Stack Enable
204 * 7450: FOLD = Branch folding enable
205 * 7457: HBATEN = High BAT Enable
206 * 7457: XBSEN = Extended BAT Block Size Enable
207 */
208
209#define HID1_E500_ABE 0x00001000 /* Address broadcast enable */
210#define HID1_E500_ASTME 0x00002000 /* Address bus streaming mode enable */
211#define HID1_E500_RFXE 0x00020000 /* Read fault exception enable */
212
213#define HID0_E500_DEFAULT_SET (HID0_EMCP | HID0_E500_TBEN | \
214 HID0_E500_MAS7UPDEN)
215#define HID1_E500_DEFAULT_SET (HID1_E500_ABE | HID1_E500_ASTME)
216#define HID0_E500MC_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD | \
217 HID0_E500_MAS7UPDEN)
218#define HID0_E5500_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD)
219
220#define HID5_970_DCBZ_SIZE_HI 0x00000080UL /* dcbz does a 32-byte store */
221#define HID4_970_DISABLE_LG_PG 0x00000004ULL /* disables large pages */
222
223#endif /* _POWERPC_HID_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/ieee.h created+141
......@@ -0,0 +1,141 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
10 *
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 * from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp
40 */
41
42#ifndef _MACHINE_IEEE_H_
43#define _MACHINE_IEEE_H_
44
45/*
46 * ieee.h defines the machine-dependent layout of the machine's IEEE
47 * floating point. It does *not* define (yet?) any of the rounding
48 * mode bits, exceptions, and so forth.
49 */
50
51/*
52 * Define the number of bits in each fraction and exponent.
53 *
54 * k k+1
55 * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented
56 *
57 * (-exp_bias+1)
58 * as fractions that look like 0.fffff x 2 . This means that
59 *
60 * -126
61 * the number 0.10000 x 2 , for instance, is the same as the normalized
62 *
63 * -127 -128
64 * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero
65 *
66 * -129
67 * in the fraction; to represent 2 , we need two, and so on. This
68 *
69 * (-exp_bias-fracbits+1)
70 * implies that the smallest denormalized number is 2
71 *
72 * for whichever format we are talking about: for single precision, for
73 *
74 * -126 -149
75 * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and
76 *
77 * -149 == -127 - 23 + 1.
78 */
79#define SNG_EXPBITS 8
80#define SNG_FRACBITS 23
81
82#define DBL_EXPBITS 11
83#define DBL_FRACBITS 52
84
85#ifdef notyet
86#define E80_EXPBITS 15
87#define E80_FRACBITS 64
88#endif
89
90#define EXT_EXPBITS 15
91#define EXT_FRACBITS 112
92
93struct ieee_single {
94 u_int sng_sign:1;
95 u_int sng_exp:8;
96 u_int sng_frac:23;
97};
98
99struct ieee_double {
100 u_int dbl_sign:1;
101 u_int dbl_exp:11;
102 u_int dbl_frach:20;
103 u_int dbl_fracl;
104};
105
106struct ieee_ext {
107 u_int ext_sign:1;
108 u_int ext_exp:15;
109 u_int ext_frach:16;
110 u_int ext_frachm;
111 u_int ext_fraclm;
112 u_int ext_fracl;
113};
114
115/*
116 * Floats whose exponent is in [1..INFNAN) (of whatever type) are
117 * `normal'. Floats whose exponent is INFNAN are either Inf or NaN.
118 * Floats whose exponent is zero are either zero (iff all fraction
119 * bits are zero) or subnormal values.
120 *
121 * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
122 * high fraction; if the bit is set, it is a `quiet NaN'.
123 */
124#define SNG_EXP_INFNAN 255
125#define DBL_EXP_INFNAN 2047
126#define EXT_EXP_INFNAN 32767
127
128#if 0
129#define SNG_QUIETNAN (1 << 22)
130#define DBL_QUIETNAN (1 << 19)
131#define EXT_QUIETNAN (1 << 15)
132#endif
133
134/*
135 * Exponent biases.
136 */
137#define SNG_EXP_BIAS 127
138#define DBL_EXP_BIAS 1023
139#define EXT_EXP_BIAS 16383
140
141#endif
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/ieeefp.h created+42
......@@ -0,0 +1,42 @@
1/* -
2 * Written by J.T. Conklin, Apr 6, 1995
3 * Public domain.
4 * $NetBSD: ieeefp.h,v 1.2 1999/07/07 01:52:26 danw Exp $
5 */
6
7#ifndef _MACHINE_IEEEFP_H_
8#define _MACHINE_IEEEFP_H_
9
10/* Deprecated historical FPU control interface */
11
12typedef int fp_except_t;
13#ifdef __SPE__
14#define FP_X_OFL 0x01 /* overflow exception */
15#define FP_X_UFL 0x02 /* underflow exception */
16#define FP_X_DZ 0x04 /* divide-by-zero exception */
17#define FP_X_INV 0x08 /* invalid operation exception */
18#define FP_X_IMP 0x10 /* imprecise (loss of precision) */
19#else
20#define FP_X_IMP 0x01 /* imprecise (loss of precision) */
21#define FP_X_DZ 0x02 /* divide-by-zero exception */
22#define FP_X_UFL 0x04 /* underflow exception */
23#define FP_X_OFL 0x08 /* overflow exception */
24#define FP_X_INV 0x10 /* invalid operation exception */
25#endif
26
27typedef enum {
28 FP_RN=0, /* round to nearest representable number */
29 FP_RZ=1, /* round to zero (truncate) */
30 FP_RP=2, /* round toward positive infinity */
31 FP_RM=3 /* round toward negative infinity */
32} fp_rnd_t;
33
34__BEGIN_DECLS
35extern fp_rnd_t fpgetround(void);
36extern fp_rnd_t fpsetround(fp_rnd_t);
37extern fp_except_t fpgetmask(void);
38extern fp_except_t fpsetmask(fp_except_t);
39extern fp_except_t fpgetsticky(void);
40__END_DECLS
41
42#endif /* _MACHINE_IEEEFP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/ifunc.h created+58
......@@ -0,0 +1,58 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2019 Brandon Bergren <bdragon@FreeBSD.org>
5 * Copyright (c) 2015-2018 The FreeBSD Foundation. All rights reserved.
6 *
7 * Part of this software was developed by
8 * Konstantin Belousov <kib@FreeBSD.org>
9 * under sponsorship from the FreeBSD Foundation.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef __POWERPC_IFUNC_H
34#define __POWERPC_IFUNC_H
35
36#include <sys/types.h>
37
38#define DEFINE_IFUNC(qual, ret_type, name, args) \
39 static ret_type (*name##_resolver(void))args __used; \
40 qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
41 static ret_type (*name##_resolver(void))args
42
43#define DEFINE_UIFUNC(qual, ret_type, name, args) \
44 static ret_type (*name##_resolver(register_t, register_t, \
45 register_t, register_t, register_t, register_t, register_t, \
46 register_t))args __used; \
47 qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
48 static ret_type (*name##_resolver( \
49 register_t cpu_features, \
50 register_t cpu_features2, \
51 register_t arg3 __unused, \
52 register_t arg4 __unused, \
53 register_t arg5 __unused, \
54 register_t arg6 __unused, \
55 register_t arg7 __unused, \
56 register_t arg8 __unused))args
57
58#endif
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/intr_machdep.h created+64
......@@ -0,0 +1,64 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2002 Benno Rice.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_INTR_MACHDEP_H_
29#define _MACHINE_INTR_MACHDEP_H_
30
31#define INTR_VECTORS 256
32
33#define MAX_PICS 32
34#define MAP_IRQ(node, pin) powerpc_get_irq(node, pin)
35
36/*
37 * Default base address for MSI messages on PowerPC
38 */
39#define MSI_INTEL_ADDR_BASE 0xfee00000
40
41extern device_t root_pic;
42
43struct trapframe;
44
45driver_filter_t powerpc_ipi_handler;
46
47void intrcnt_add(const char *name, u_long **countp);
48
49u_int powerpc_register_pic(device_t, uint32_t, u_int, u_int, u_int);
50u_int powerpc_get_irq(uint32_t, u_int);
51
52void powerpc_dispatch_intr(u_int, struct trapframe *);
53int powerpc_enable_intr(void);
54int powerpc_setup_intr(const char *, u_int, driver_filter_t, driver_intr_t,
55 void *, enum intr_type, void **, int);
56int powerpc_teardown_intr(void *);
57int powerpc_bind_intr(u_int irq, u_char cpu);
58int powerpc_config_intr(int, enum intr_trigger, enum intr_polarity);
59int powerpc_fw_config_intr(int irq, int sense_code);
60
61void powerpc_intr_mask(u_int irq);
62void powerpc_intr_unmask(u_int irq);
63
64#endif /* _MACHINE_INTR_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/kdb.h created+67
......@@ -0,0 +1,67 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2004 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_KDB_H_
30#define _MACHINE_KDB_H_
31
32#include <machine/cpufunc.h>
33#include <machine/frame.h>
34#include <machine/md_var.h>
35#include <machine/psl.h>
36#include <machine/spr.h>
37
38void kdb_cpu_clear_singlestep(void);
39void kdb_cpu_set_singlestep(void);
40
41static __inline void
42kdb_cpu_sync_icache(unsigned char *addr, size_t size)
43{
44
45 __syncicache(addr, size);
46}
47
48static __inline void
49kdb_cpu_trap(int vector, int _)
50{
51}
52
53static __inline int
54kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access)
55{
56
57 return (ENXIO);
58}
59
60static __inline int
61kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size)
62{
63
64 return (0);
65}
66
67#endif /* _MACHINE_KDB_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/machdep.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2011-2012 Semihalf
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _POWERPC_MACHDEP_H_
30#define _POWERPC_MACHDEP_H_
31
32void booke_disable_l2_cache(void);
33void booke_enable_l1_cache(void);
34void booke_enable_l2_cache(void);
35void booke_enable_bpred(void);
36
37#endif /* _POWERPC_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/md_var.h created+71
......@@ -0,0 +1,71 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 1998 Doug Rabson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_MD_VAR_H_
30#define _MACHINE_MD_VAR_H_
31
32/*
33 * Miscellaneous machine-dependent declarations.
34 */
35
36extern char sigcode32[];
37extern int szsigcode32;
38
39#ifdef __powerpc64__
40extern char sigcode64[], sigcode64_elfv2[];
41extern int szsigcode64, szsigcode64_elfv2;
42
43struct dumperinfo;
44struct minidumpstate;
45int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *);
46#endif
47
48extern long Maxmem;
49
50extern vm_offset_t kstack0;
51extern vm_offset_t kstack0_phys;
52
53extern int powerpc_pow_enabled;
54extern int cacheline_size;
55extern int hw_direct_map;
56
57void __syncicache(void *, int);
58
59int mem_valid(vm_offset_t addr, int len);
60
61void decr_init(void);
62void decr_ap_init(void);
63void decr_tc_init(void);
64
65void cpu_feature_setup(void);
66void cpu_setup(u_int);
67
68struct trapframe;
69void powerpc_interrupt(struct trapframe *);
70
71#endif /* !_MACHINE_MD_VAR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/metadata.h created+38
......@@ -0,0 +1,38 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_METADATA_H_
30#define _MACHINE_METADATA_H_
31
32#define MODINFOMD_ENVP 0x1001
33#define MODINFOMD_HOWTO 0x1002
34#define MODINFOMD_KERNEND 0x1003
35#define MODINFOMD_BOOTINFO 0x1004
36#define MODINFOMD_DTBP 0x1005
37
38#endif /* !_MACHINE_METADATA_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/minidump.h created+52
......@@ -0,0 +1,52 @@
1/*-
2 * Copyright (c) 2006 Peter Wemm
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * From i386: FreeBSD: 157909 2006-04-21 04:28:43Z peter
27 */
28
29#ifndef _MACHINE_MINIDUMP_H_
30#define _MACHINE_MINIDUMP_H_ 1
31
32#define MINIDUMP_MAGIC "minidump FreeBSD/powerpc64"
33#define MINIDUMP_VERSION 2
34
35struct minidumphdr {
36 char magic[32];
37 char mmu_name[32];
38 uint32_t version;
39 uint32_t msgbufsize;
40 uint32_t bitmapsize;
41 uint32_t pmapsize;
42 uint64_t kernbase;
43 uint64_t kernend;
44 uint64_t dmapbase;
45 uint64_t dmapend;
46 int hw_direct_map;
47 uint64_t startkernel;
48 uint64_t endkernel;
49 uint32_t dumpavailsize;
50};
51
52#endif /* _MACHINE_MINIDUMP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/mmuvar.h created+224
......@@ -0,0 +1,224 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 Peter Grehan
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_MMUVAR_H_
30#define _MACHINE_MMUVAR_H_
31
32typedef void (*pmap_bootstrap_t)(vm_offset_t, vm_offset_t);
33typedef void (*pmap_cpu_bootstrap_t)(int);
34typedef void (*pmap_kenter_t)(vm_offset_t, vm_paddr_t pa);
35typedef void (*pmap_kenter_attr_t)(vm_offset_t, vm_paddr_t, vm_memattr_t);
36typedef void (*pmap_kremove_t)(vm_offset_t);
37typedef void *(*pmap_mapdev_t)(vm_paddr_t, vm_size_t);
38typedef void *(*pmap_mapdev_attr_t)(vm_paddr_t, vm_size_t, vm_memattr_t);
39typedef void (*pmap_unmapdev_t)(void *, vm_size_t);
40typedef void (*pmap_page_set_memattr_t)(vm_page_t, vm_memattr_t);
41typedef int (*pmap_change_attr_t)(vm_offset_t, vm_size_t, vm_memattr_t);
42typedef int (*pmap_map_user_ptr_t)(pmap_t, volatile const void *,
43 void **, size_t, size_t *);
44typedef int (*pmap_decode_kernel_ptr_t)(vm_offset_t, int *, vm_offset_t *);
45typedef vm_paddr_t (*pmap_kextract_t)(vm_offset_t);
46typedef int (*pmap_dev_direct_mapped_t)(vm_paddr_t, vm_size_t);
47
48typedef void (*pmap_page_array_startup_t)(long);
49typedef void (*pmap_advise_t)(pmap_t, vm_offset_t, vm_offset_t, int);
50typedef void (*pmap_clear_modify_t)(vm_page_t);
51typedef void (*pmap_remove_write_t)(vm_page_t);
52typedef void (*pmap_copy_t)(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t);
53typedef void (*pmap_copy_page_t)(vm_page_t, vm_page_t);
54typedef void (*pmap_copy_pages_t)(vm_page_t *, vm_offset_t,
55 vm_page_t *, vm_offset_t, int);
56typedef int (*pmap_enter_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t,
57 u_int, int8_t);
58typedef void (*pmap_enter_object_t)(pmap_t, vm_offset_t, vm_offset_t,
59 vm_page_t, vm_prot_t);
60typedef void (*pmap_enter_quick_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t);
61typedef vm_paddr_t (*pmap_extract_t)(pmap_t, vm_offset_t);
62typedef vm_page_t (*pmap_extract_and_hold_t)(pmap_t, vm_offset_t, vm_prot_t);
63typedef int (*pmap_growkernel_nopanic_t)(vm_offset_t);
64typedef void (*pmap_init_t)(void);
65typedef bool (*pmap_is_modified_t)(vm_page_t);
66typedef bool (*pmap_is_prefaultable_t)(pmap_t, vm_offset_t);
67typedef bool (*pmap_is_referenced_t)(vm_page_t);
68typedef int (*pmap_ts_referenced_t)(vm_page_t);
69typedef vm_offset_t (*pmap_map_t)(vm_offset_t *, vm_paddr_t, vm_paddr_t, int);
70typedef void (*pmap_object_init_pt_t)(pmap_t, vm_offset_t, vm_object_t,
71 vm_pindex_t, vm_size_t);
72typedef bool (*pmap_page_exists_quick_t)(pmap_t, vm_page_t);
73typedef bool (*pmap_page_is_mapped_t)(vm_page_t);
74typedef void (*pmap_page_init_t)(vm_page_t);
75typedef int (*pmap_page_wired_mappings_t)(vm_page_t);
76typedef void (*pmap_pinit0_t)(pmap_t);
77typedef void (*pmap_protect_t)(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t);
78typedef void (*pmap_qenter_t)(vm_offset_t, vm_page_t *, int);
79typedef void (*pmap_qremove_t)(vm_offset_t, int);
80typedef void (*pmap_release_t)(pmap_t);
81typedef void (*pmap_remove_t)(pmap_t, vm_offset_t, vm_offset_t);
82typedef void (*pmap_remove_all_t)(vm_page_t);
83typedef void (*pmap_remove_pages_t)(pmap_t);
84typedef void (*pmap_unwire_t)(pmap_t, vm_offset_t, vm_offset_t);
85typedef void (*pmap_zero_page_t)(vm_page_t);
86typedef void (*pmap_zero_page_area_t)(vm_page_t, int, int);
87typedef int (*pmap_mincore_t)(pmap_t, vm_offset_t, vm_paddr_t *);
88typedef void (*pmap_activate_t)(struct thread *);
89typedef void (*pmap_deactivate_t)(struct thread *);
90typedef void (*pmap_align_superpage_t)(vm_object_t, vm_ooffset_t,
91 vm_offset_t *, vm_size_t);
92
93typedef void (*pmap_sync_icache_t)(pmap_t, vm_offset_t, vm_size_t);
94typedef void (*pmap_dumpsys_map_chunk_t)(vm_paddr_t, size_t, void **);
95typedef void (*pmap_dumpsys_unmap_chunk_t)(vm_paddr_t, size_t, void *);
96typedef void (*pmap_dumpsys_pa_init_t)(void);
97typedef size_t (*pmap_dumpsys_scan_pmap_t)(struct bitset *dump_bitset);
98typedef void *(*pmap_dumpsys_dump_pmap_init_t)(unsigned);
99typedef void *(*pmap_dumpsys_dump_pmap_t)(void *, void *, u_long *);
100typedef vm_offset_t (*pmap_quick_enter_page_t)(vm_page_t);
101typedef void (*pmap_quick_remove_page_t)(vm_offset_t);
102typedef bool (*pmap_ps_enabled_t)(pmap_t);
103typedef void (*pmap_tlbie_all_t)(void);
104typedef void (*pmap_installer_t)(void);
105
106struct pmap_funcs {
107 pmap_installer_t install;
108 pmap_bootstrap_t bootstrap;
109 pmap_cpu_bootstrap_t cpu_bootstrap;
110 pmap_kenter_t kenter;
111 pmap_kenter_attr_t kenter_attr;
112 pmap_kremove_t kremove;
113 pmap_mapdev_t mapdev;
114 pmap_mapdev_attr_t mapdev_attr;
115 pmap_unmapdev_t unmapdev;
116 pmap_page_set_memattr_t page_set_memattr;
117 pmap_change_attr_t change_attr;
118 pmap_map_user_ptr_t map_user_ptr;
119 pmap_decode_kernel_ptr_t decode_kernel_ptr;
120 pmap_kextract_t kextract;
121 pmap_dev_direct_mapped_t dev_direct_mapped;
122 pmap_advise_t advise;
123 pmap_clear_modify_t clear_modify;
124 pmap_remove_write_t remove_write;
125 pmap_copy_t copy;
126 pmap_copy_page_t copy_page;
127 pmap_copy_pages_t copy_pages;
128 pmap_enter_t enter;
129 pmap_enter_object_t enter_object;
130 pmap_enter_quick_t enter_quick;
131 pmap_extract_t extract;
132 pmap_extract_and_hold_t extract_and_hold;
133 pmap_growkernel_nopanic_t growkernel_nopanic;
134 pmap_init_t init;
135 pmap_is_modified_t is_modified;
136 pmap_is_prefaultable_t is_prefaultable;
137 pmap_is_referenced_t is_referenced;
138 pmap_ts_referenced_t ts_referenced;
139 pmap_page_is_mapped_t page_is_mapped;
140 pmap_ps_enabled_t ps_enabled;
141 pmap_map_t map;
142 pmap_object_init_pt_t object_init_pt;
143 pmap_page_exists_quick_t page_exists_quick;
144 pmap_page_init_t page_init;
145 pmap_page_wired_mappings_t page_wired_mappings;
146 pmap_pinit_t pinit;
147 pmap_pinit0_t pinit0;
148 pmap_protect_t protect;
149 pmap_qenter_t qenter;
150 pmap_qremove_t qremove;
151 pmap_release_t release;
152 pmap_remove_t remove;
153 pmap_remove_all_t remove_all;
154 pmap_remove_pages_t remove_pages;
155 pmap_unwire_t unwire;
156 pmap_zero_page_t zero_page;
157 pmap_zero_page_area_t zero_page_area;
158 pmap_mincore_t mincore;
159 pmap_activate_t activate;
160 pmap_deactivate_t deactivate;
161 pmap_align_superpage_t align_superpage;
162 pmap_sync_icache_t sync_icache;
163 pmap_quick_enter_page_t quick_enter_page;
164 pmap_quick_remove_page_t quick_remove_page;
165 pmap_page_array_startup_t page_array_startup;
166 pmap_dumpsys_map_chunk_t dumpsys_map_chunk;
167 pmap_dumpsys_unmap_chunk_t dumpsys_unmap_chunk;
168 pmap_dumpsys_pa_init_t dumpsys_pa_init;
169 pmap_dumpsys_scan_pmap_t dumpsys_scan_pmap;
170 pmap_dumpsys_dump_pmap_init_t dumpsys_dump_pmap_init;
171 pmap_dumpsys_dump_pmap_t dumpsys_dump_pmap;
172 pmap_tlbie_all_t tlbie_all;
173
174};
175struct mmu_kobj {
176 const char *name;
177 const struct mmu_kobj *base;
178 const struct pmap_funcs *funcs;
179};
180
181typedef struct mmu_kobj *mmu_t;
182
183/* The currently installed pmap object. */
184extern mmu_t mmu_obj;
185
186/*
187 * Resolve a given pmap function.
188 * 'func' is the function name less the 'pmap_' * prefix.
189 */
190#define PMAP_RESOLVE_FUNC(func) \
191 ({ \
192 pmap_##func##_t f; \
193 const struct mmu_kobj *mmu = mmu_obj; \
194 do { \
195 f = mmu->funcs->func; \
196 if (f != NULL) break; \
197 mmu = mmu->base; \
198 } while (mmu != NULL); \
199 f;})
200
201#define MMU_DEF(name, ident, methods) \
202 \
203const struct mmu_kobj name = { \
204 ident, NULL, &methods \
205}; \
206DATA_SET(mmu_set, name)
207
208#define MMU_DEF_INHERIT(name, ident, methods, base1) \
209 \
210const struct mmu_kobj name = { \
211 ident, &base1, &methods, \
212}; \
213DATA_SET(mmu_set, name)
214
215/*
216 * Known MMU names
217 */
218#define MMU_TYPE_BOOKE "mmu_booke" /* Book-E MMU specification */
219#define MMU_TYPE_OEA "mmu_oea" /* 32-bit OEA */
220#define MMU_TYPE_G5 "mmu_g5" /* 64-bit bridge (ibm 970) */
221#define MMU_TYPE_RADIX "mmu_radix" /* 64-bit native ISA 3.0 (POWER9) radix */
222#define MMU_TYPE_8xx "mmu_8xx" /* 8xx quicc TLB */
223
224#endif /* _MACHINE_MMUVAR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/ofw_machdep.h created+57
......@@ -0,0 +1,57 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 by Thomas Moestl <tmm@FreeBSD.org>.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_OFW_MACHDEP_H_
29#define _MACHINE_OFW_MACHDEP_H_
30
31#include <sys/types.h>
32#include <sys/rman.h>
33#include <sys/bus.h>
34#include <dev/ofw/openfirm.h>
35#include <machine/platform.h>
36
37struct mem_region;
38struct numa_mem_region;
39
40typedef uint32_t cell_t;
41
42void OF_getetheraddr(device_t dev, u_char *addr);
43
44void OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *));
45bool OF_bootstrap(void);
46
47void OF_reboot(void);
48
49void ofw_mem_regions(struct mem_region *, int *, struct mem_region *, int *);
50void ofw_numa_mem_regions(struct numa_mem_region *, int *);
51void ofw_quiesce(void); /* Must be called before VM is up! */
52void ofw_save_trap_vec(char *);
53int ofw_pcibus_get_domain(device_t dev, device_t child, int *domain);
54int ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op,
55 size_t setsize, cpuset_t *cpuset);
56
57#endif /* _MACHINE_OFW_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/openpicreg.h created+141
......@@ -0,0 +1,141 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp
29 */
30
31/*
32 * Size of OpenPIC register space
33 */
34#define OPENPIC_SIZE 0x40000
35
36/*
37 * Per Processor Registers [private access] (0x00000 - 0x00fff)
38 */
39
40/* IPI dispatch command reg */
41#define OPENPIC_IPI_DISPATCH(ipi) (0x40 + (ipi) * 0x10)
42
43/* current task priority reg */
44#define OPENPIC_TPR 0x80
45#define OPENPIC_TPR_MASK 0x0000000f
46
47#define OPENPIC_WHOAMI 0x90
48
49/* interrupt acknowledge reg */
50#define OPENPIC_IACK 0xa0
51
52/* end of interrupt reg */
53#define OPENPIC_EOI 0xb0
54
55/*
56 * Global registers (0x01000-0x0ffff)
57 */
58
59/* feature reporting reg 0 */
60#define OPENPIC_FEATURE 0x1000
61#define OPENPIC_FEATURE_VERSION_MASK 0x000000ff
62#define OPENPIC_FEATURE_LAST_CPU_MASK 0x00001f00
63#define OPENPIC_FEATURE_LAST_CPU_SHIFT 8
64#define OPENPIC_FEATURE_LAST_IRQ_MASK 0x07ff0000
65#define OPENPIC_FEATURE_LAST_IRQ_SHIFT 16
66
67/* global config reg 0 */
68#define OPENPIC_CONFIG 0x1020
69#define OPENPIC_CONFIG_RESET 0x80000000
70#define OPENPIC_CONFIG_8259_PASSTHRU_DISABLE 0x20000000
71
72/* interrupt configuration mode (direct or serial) */
73#define OPENPIC_ICR 0x1030
74#define OPENPIC_ICR_SERIAL_MODE (1 << 27)
75#define OPENPIC_ICR_SERIAL_RATIO_MASK (0x7 << 28)
76#define OPENPIC_ICR_SERIAL_RATIO_SHIFT 28
77
78/* vendor ID */
79#define OPENPIC_VENDOR_ID 0x1080
80
81/* processor initialization reg */
82#define OPENPIC_PROC_INIT 0x1090
83
84/* IPI vector/priority reg */
85#define OPENPIC_IPI_VECTOR(ipi) (0x10a0 + (ipi) * 0x10)
86
87/* spurious intr. vector */
88#define OPENPIC_SPURIOUS_VECTOR 0x10e0
89
90/* Timer registers */
91#define OPENPIC_TIMERS 4
92#define OPENPIC_TFREQ 0x10f0
93#define OPENPIC_TCNT(t) (0x1100 + (t) * 0x40)
94#define OPENPIC_TBASE(t) (0x1110 + (t) * 0x40)
95#define OPENPIC_TVEC(t) (0x1120 + (t) * 0x40)
96#define OPENPIC_TDST(t) (0x1130 + (t) * 0x40)
97
98/*
99 * Interrupt Source Configuration Registers (0x10000 - 0x1ffff)
100 */
101
102/* interrupt vector/priority reg */
103#define OPENPIC_SRC_VECTOR_COUNT 64
104#ifndef OPENPIC_SRC_VECTOR
105#define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20)
106#endif
107#define OPENPIC_SENSE_LEVEL 0x00400000
108#define OPENPIC_SENSE_EDGE 0x00000000
109#define OPENPIC_POLARITY_POSITIVE 0x00800000
110#define OPENPIC_POLARITY_NEGATIVE 0x00000000
111#define OPENPIC_IMASK 0x80000000
112#define OPENPIC_ACTIVITY 0x40000000
113#define OPENPIC_PRIORITY_MASK 0x000f0000
114#define OPENPIC_PRIORITY_SHIFT 16
115#define OPENPIC_VECTOR_MASK 0x000000ff
116
117/* interrupt destination cpu */
118#ifndef OPENPIC_IDEST
119#define OPENPIC_IDEST(irq) (0x10010 + (irq) * 0x20)
120#endif
121
122/*
123 * Per Processor Registers [global access] (0x20000 - 0x3ffff)
124 */
125
126#define OPENPIC_PCPU_BASE(cpu) (0x20000 + (cpu) * 0x1000)
127
128#define OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi) \
129 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi))
130
131#define OPENPIC_PCPU_TPR(cpu) \
132 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR)
133
134#define OPENPIC_PCPU_WHOAMI(cpu) \
135 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI)
136
137#define OPENPIC_PCPU_IACK(cpu) \
138 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK)
139
140#define OPENPIC_PCPU_EOI(cpu) \
141 (OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI)
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/openpicvar.h created+90
......@@ -0,0 +1,90 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2002 Benno Rice.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _POWERPC_OPENPICVAR_H_
29#define _POWERPC_OPENPICVAR_H_
30
31#define OPENPIC_DEVSTR "OpenPIC Interrupt Controller"
32
33#define OPENPIC_IRQMAX 256 /* h/w allows more */
34
35#define OPENPIC_QUIRK_SINGLE_BIND 1 /* Bind interrupts to only 1 CPU */
36#define OPENPIC_QUIRK_HIDDEN_IRQS 2 /* May have IRQs beyond FRR[NIRQ] */
37
38/* Names match the macros in openpicreg.h. */
39struct openpic_timer {
40 uint32_t tcnt;
41 uint32_t tbase;
42 uint32_t tvec;
43 uint32_t tdst;
44};
45
46struct openpic_softc {
47 device_t sc_dev;
48 struct resource *sc_memr;
49 struct resource *sc_intr;
50 bus_space_tag_t sc_bt;
51 bus_space_handle_t sc_bh;
52 char *sc_version;
53 int sc_rid;
54 int sc_irq;
55 void *sc_icookie;
56 u_int sc_ncpu;
57 u_int sc_nirq;
58 int sc_psim;
59 u_int sc_quirks;
60
61 /* Saved states. */
62 uint32_t sc_saved_config;
63 uint32_t sc_saved_ipis[4];
64 uint32_t sc_saved_prios[4];
65 struct openpic_timer sc_saved_timers[OPENPIC_TIMERS];
66 uint32_t sc_saved_vectors[OPENPIC_SRC_VECTOR_COUNT];
67
68};
69
70/*
71 * Bus-independent attach i/f
72 */
73int openpic_common_attach(device_t, uint32_t);
74
75/*
76 * PIC interface.
77 */
78void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **);
79void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity);
80void openpic_dispatch(device_t, struct trapframe *);
81void openpic_enable(device_t, u_int, u_int, void **);
82void openpic_eoi(device_t, u_int, void *);
83void openpic_ipi(device_t, u_int);
84void openpic_mask(device_t, u_int, void *);
85void openpic_unmask(device_t, u_int, void *);
86
87int openpic_suspend(device_t dev);
88int openpic_resume(device_t dev);
89
90#endif /* _POWERPC_OPENPICVAR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/param.h created+150
......@@ -0,0 +1,150 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2001 David E. O'Brien
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#ifndef _POWERPC_INCLUDE_PARAM_H_
41#define _POWERPC_INCLUDE_PARAM_H_
42
43/*
44 * Machine dependent constants for PowerPC
45 */
46
47#include <machine/_align.h>
48
49#ifndef MACHINE
50#define MACHINE "powerpc"
51#endif
52#ifndef MACHINE_ARCH
53#ifdef __powerpc64__
54#if defined(__LITTLE_ENDIAN__)
55#define MACHINE_ARCH "powerpc64le"
56#else
57#define MACHINE_ARCH "powerpc64"
58#endif
59#else
60#ifdef __SPE__
61#define MACHINE_ARCH "powerpcspe"
62#else
63#define MACHINE_ARCH "powerpc"
64#endif
65#endif
66#endif
67#define MID_MACHINE MID_POWERPC
68#ifdef __powerpc64__
69#ifndef MACHINE_ARCH32
70#define MACHINE_ARCH32 "powerpc"
71#endif
72#endif
73
74#ifdef SMP
75#ifndef MAXCPU
76#define MAXCPU 256
77#endif
78#else
79#define MAXCPU 1
80#endif
81
82#ifndef MAXMEMDOM
83#define MAXMEMDOM 8
84#endif
85
86#define ALIGNBYTES _ALIGNBYTES
87#define ALIGN(p) _ALIGN(p)
88/*
89 * ALIGNED_POINTER is a boolean macro that checks whether an address
90 * is valid to fetch data elements of type t from on this architecture.
91 * This does not reflect the optimal alignment, just the possibility
92 * (within reasonable limits).
93 */
94#define ALIGNED_POINTER(p, t) ((((uintptr_t)(p)) & (sizeof (t) - 1)) == 0)
95
96/*
97 * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
98 * architecture. It should be used with appropriate caution.
99 */
100#define CACHE_LINE_SHIFT 7
101#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT)
102
103#define PAGE_SHIFT 12
104#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */
105#define PAGE_MASK (PAGE_SIZE - 1)
106#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
107#define NPDEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
108
109#define L1_PAGE_SIZE_SHIFT 39
110#define L1_PAGE_SIZE (1UL<<L1_PAGE_SIZE_SHIFT)
111#define L1_PAGE_MASK (L1_PAGE_SIZE-1)
112
113#define L2_PAGE_SIZE_SHIFT 30
114#define L2_PAGE_SIZE (1UL<<L2_PAGE_SIZE_SHIFT)
115#define L2_PAGE_MASK (L2_PAGE_SIZE-1)
116
117#define L3_PAGE_SIZE_SHIFT 21
118#define L3_PAGE_SIZE (1UL<<L3_PAGE_SIZE_SHIFT)
119#define L3_PAGE_MASK (L3_PAGE_SIZE-1)
120
121#define MAXPAGESIZES 3 /* maximum number of supported page sizes */
122
123#define RELOCATABLE_KERNEL 1 /* kernel may relocate during startup */
124
125#ifndef KSTACK_PAGES
126#ifdef __powerpc64__
127#define KSTACK_PAGES 12 /* includes pcb */
128#else
129#define KSTACK_PAGES 4 /* includes pcb */
130#endif
131#endif
132#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */
133#define USPACE (kstack_pages * PAGE_SIZE) /* total size of pcb */
134
135#define COPYFAULT 0x1
136#define FUSUFAULT 0x2
137
138/*
139 * Mach derived conversion macros
140 */
141#define trunc_2mpage(x) ((unsigned long)(x) & ~L3_PAGE_MASK)
142#define round_2mpage(x) ((((unsigned long)(x)) + L3_PAGE_MASK) & ~L3_PAGE_MASK)
143#define trunc_1gpage(x) ((unsigned long)(x) & ~L2_PAGE_MASK)
144
145#define powerpc_btop(x) ((x) >> PAGE_SHIFT)
146#define powerpc_ptob(x) ((x) << PAGE_SHIFT)
147
148#define btoc(x) ((vm_offset_t)(((x)+PAGE_MASK)>>PAGE_SHIFT))
149
150#endif /* !_POWERPC_INCLUDE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/pcb.h created+129
......@@ -0,0 +1,129 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: pcb.h,v 1.4 2000/06/04 11:57:17 tsubai Exp $
34 */
35
36#ifndef _MACHINE_PCB_H_
37#define _MACHINE_PCB_H_
38
39#include <sys/endian.h>
40
41#include <machine/setjmp.h>
42
43#ifndef _STANDALONE
44struct pcb {
45 register_t pcb_context[20]; /* non-volatile r12-r31 */
46 register_t pcb_cr; /* Condition register */
47 register_t pcb_sp; /* stack pointer */
48 register_t pcb_toc; /* toc pointer */
49 register_t pcb_lr; /* link register */
50 register_t pcb_dscr; /* dscr value */
51 register_t pcb_fscr;
52 register_t pcb_tar;
53 struct pmap *pcb_pm; /* pmap of our vmspace */
54 jmp_buf *pcb_onfault; /* For use during
55 copyin/copyout */
56 int pcb_flags;
57#define PCB_FPU 0x1 /* Process uses FPU */
58#define PCB_FPREGS 0x2 /* Process had FPU registers initialized */
59#define PCB_VEC 0x4 /* Process uses Altivec */
60#define PCB_VSX 0x8 /* Process had VSX initialized */
61#define PCB_CDSCR 0x10 /* Process had Custom DSCR initialized */
62#define PCB_HTM 0x20 /* Process had HTM initialized */
63#define PCB_CFSCR 0x40 /* Process had FSCR updated */
64#define PCB_KERN_FPU 0x80 /* Kernel is using FPU/Vector unit */
65#define PCB_KERN_FPU_NOSAVE 0x100 /* FPU/Vec state not saved for kernel use */
66#define PCB_VECREGS 0x200 /* Process had Altivec registers initialized */
67 struct fpu {
68 union {
69 uint32_t vsr[4];
70 double fpr;
71 } fpr[32];
72 double fpscr; /* FPSCR stored as double for easier access */
73 } pcb_fpu; /* Floating point processor */
74 unsigned int pcb_fpcpu; /* which CPU had our FPU
75 stuff. */
76 struct vec {
77 uint32_t vr[32][4];
78 uint32_t spare[2];
79 uint32_t vrsave;
80 uint32_t vscr; /* aligned at vector element 3 */
81 } pcb_vec __aligned(16); /* Vector processor */
82 unsigned int pcb_veccpu; /* which CPU had our vector
83 stuff. */
84 struct htm {
85 uint64_t tfhar;
86 uint64_t texasr;
87 uint64_t tfiar;
88 } pcb_htm;
89
90 struct ebb {
91 uint64_t ebbhr;
92 uint64_t ebbrr;
93 uint64_t bescr;
94 } pcb_ebb;
95
96 struct lmon {
97 uint64_t lmrr;
98 uint64_t lmser;
99 } pcb_lm;
100
101 union {
102 struct {
103 vm_offset_t usr_segm; /* Base address */
104 register_t usr_vsid; /* USER_SR segment */
105 } aim;
106 struct {
107 register_t dbcr0;
108 } booke;
109 } pcb_cpu;
110 vm_offset_t pcb_lastill; /* Last illegal instruction */
111};
112#endif
113
114#ifdef _KERNEL
115
116struct trapframe;
117
118#ifndef curpcb
119extern struct pcb *curpcb;
120#endif
121
122extern struct pmap *curpm;
123extern struct proc *fpuproc;
124
125void makectx(struct trapframe *, struct pcb *);
126void savectx(struct pcb *) __returns_twice;
127
128#endif
129#endif /* _MACHINE_PCB_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/pcpu.h created+174
......@@ -0,0 +1,174 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org>
5 * Copyright (c) Peter Wemm <peter@netplex.com.au>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_PCPU_H_
31#define _MACHINE_PCPU_H_
32
33#include <machine/cpufunc.h>
34#include <machine/slb.h>
35#include <machine/tlb.h>
36
37struct pmap;
38struct pvo_entry;
39#define CPUSAVE_LEN 9
40
41#define PCPU_MD_COMMON_FIELDS \
42 int pc_inside_intr; \
43 struct pmap *pc_curpmap; /* current pmap */ \
44 struct thread *pc_fputhread; /* current fpu user */ \
45 struct thread *pc_vecthread; /* current vec user */ \
46 struct thread *pc_htmthread; /* current htm user */ \
47 uintptr_t pc_hwref; \
48 int pc_bsp; \
49 volatile int pc_awake; \
50 uint32_t pc_ipimask; \
51 uint32_t pc_flags; /* cpu feature flags */ \
52 register_t pc_tempsave[CPUSAVE_LEN]; \
53 register_t pc_disisave[CPUSAVE_LEN]; \
54 register_t pc_dbsave[CPUSAVE_LEN]; \
55 void *pc_restore; \
56 vm_offset_t pc_qmap_addr;
57
58#define PCPU_MD_AIM32_FIELDS \
59 struct pvo_entry *qmap_pvo; \
60 struct mtx qmap_lock; \
61 char __pad[128];
62
63#define PCPU_MD_AIM64_FIELDS \
64 struct slb slb[64]; \
65 struct slb **userslb; \
66 register_t slbsave[18]; \
67 uint8_t slbstack[1024]; \
68 struct pvo_entry *qmap_pvo; \
69 struct mtx qmap_lock; \
70 uint64_t opal_hmi_flags; \
71 char __pad[1337];
72
73#ifdef __powerpc64__
74#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM64_FIELDS
75#else
76#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM32_FIELDS
77#endif
78
79/* CPU feature flags, can be used for cached flow control. */
80#define PC_FLAG_NOSRS 0x80000000
81
82#define BOOKE_CRITSAVE_LEN (CPUSAVE_LEN + 2)
83#define BOOKE_TLB_MAXNEST 4
84#define BOOKE_TLB_SAVELEN 16
85#define BOOKE_TLBSAVE_LEN (BOOKE_TLB_SAVELEN * BOOKE_TLB_MAXNEST)
86
87#ifdef __powerpc64__
88#define BOOKE_PCPU_PAD 901
89#else
90#define BOOKE_PCPU_PAD 365
91#endif
92#define PCPU_MD_BOOKE_FIELDS \
93 register_t critsave[BOOKE_CRITSAVE_LEN]; \
94 register_t mchksave[CPUSAVE_LEN]; \
95 register_t tlbsave[BOOKE_TLBSAVE_LEN]; \
96 register_t tlb_level; \
97 uintptr_t *tlb_lock; \
98 int tid_next; \
99 char __pad[BOOKE_PCPU_PAD];
100
101/* Definitions for register offsets within the exception tmp save areas */
102#define CPUSAVE_R27 0 /* where r27 gets saved */
103#define CPUSAVE_R28 1 /* where r28 gets saved */
104#define CPUSAVE_R29 2 /* where r29 gets saved */
105#define CPUSAVE_R30 3 /* where r30 gets saved */
106#define CPUSAVE_R31 4 /* where r31 gets saved */
107#define CPUSAVE_AIM_DAR 5 /* where SPR_DAR gets saved */
108#define CPUSAVE_AIM_DSISR 6 /* where SPR_DSISR gets saved */
109#define CPUSAVE_BOOKE_DEAR 5 /* where SPR_DEAR gets saved */
110#define CPUSAVE_BOOKE_ESR 6 /* where SPR_ESR gets saved */
111#define CPUSAVE_SRR0 7 /* where SRR0 gets saved */
112#define CPUSAVE_SRR1 8 /* where SRR1 gets saved */
113#define BOOKE_CRITSAVE_SRR0 9 /* where real SRR0 gets saved (critical) */
114#define BOOKE_CRITSAVE_SRR1 10 /* where real SRR0 gets saved (critical) */
115
116/* Book-E TLBSAVE is more elaborate */
117#define TLBSAVE_BOOKE_LR 0
118#define TLBSAVE_BOOKE_CR 1
119#define TLBSAVE_BOOKE_SRR0 2
120#define TLBSAVE_BOOKE_SRR1 3
121#define TLBSAVE_BOOKE_R20 4
122#define TLBSAVE_BOOKE_R21 5
123#define TLBSAVE_BOOKE_R22 6
124#define TLBSAVE_BOOKE_R23 7
125#define TLBSAVE_BOOKE_R24 8
126#define TLBSAVE_BOOKE_R25 9
127#define TLBSAVE_BOOKE_R26 10
128#define TLBSAVE_BOOKE_R27 11
129#define TLBSAVE_BOOKE_R28 12
130#define TLBSAVE_BOOKE_R29 13
131#define TLBSAVE_BOOKE_R30 14
132#define TLBSAVE_BOOKE_R31 15
133
134#define PCPU_MD_FIELDS \
135 PCPU_MD_COMMON_FIELDS \
136 union { \
137 struct { \
138 PCPU_MD_AIM_FIELDS \
139 } pc_aim; \
140 struct { \
141 PCPU_MD_BOOKE_FIELDS \
142 } pc_booke; \
143 }
144
145#ifdef _KERNEL
146
147#define pcpup (get_pcpu())
148
149static __inline __pure2 struct thread *
150__curthread(void)
151{
152 struct thread *td;
153#ifdef __powerpc64__
154 __asm __volatile("mr %0,13" : "=r"(td));
155#else
156 __asm __volatile("mr %0,2" : "=r"(td));
157#endif
158 return (td);
159}
160#define curthread (__curthread())
161
162#define PCPU_GET(member) (pcpup->pc_ ## member)
163
164/*
165 * XXX The implementation of this operation should be made atomic
166 * with respect to preemption.
167 */
168#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value))
169#define PCPU_PTR(member) (&pcpup->pc_ ## member)
170#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
171
172#endif /* _KERNEL */
173
174#endif /* !_MACHINE_PCPU_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/pio.h created+304
......@@ -0,0 +1,304 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed under OpenBSD by
17 * Per Fogelstrom Opsycon AB for RTMX Inc, North Carolina, USA.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $NetBSD: pio.h,v 1.1 1998/05/15 10:15:54 tsubai Exp $
34 * $OpenBSD: pio.h,v 1.1 1997/10/13 10:53:47 pefo Exp $
35 */
36
37#ifndef _MACHINE_PIO_H_
38#define _MACHINE_PIO_H_
39/*
40 * I/O macros.
41 */
42
43/*
44 * Use sync so that bus space operations cannot sneak out the bottom of
45 * mutex-protected sections (mutex release does not guarantee completion of
46 * accesses to caching-inhibited memory on some systems)
47 */
48#define powerpc_iomb() __asm __volatile("sync" : : : "memory")
49
50static __inline void
51__outb(volatile u_int8_t *a, u_int8_t v)
52{
53 *a = v;
54 powerpc_iomb();
55}
56
57static __inline void
58__outw(volatile u_int16_t *a, u_int16_t v)
59{
60 *a = v;
61 powerpc_iomb();
62}
63
64static __inline void
65__outl(volatile u_int32_t *a, u_int32_t v)
66{
67 *a = v;
68 powerpc_iomb();
69}
70
71static __inline void
72__outll(volatile u_int64_t *a, u_int64_t v)
73{
74 *a = v;
75 powerpc_iomb();
76}
77
78static __inline void
79__outwrb(volatile u_int16_t *a, u_int16_t v)
80{
81 __asm__ volatile("sthbrx %0, 0, %1" :: "r"(v), "r"(a));
82 powerpc_iomb();
83}
84
85static __inline void
86__outlrb(volatile u_int32_t *a, u_int32_t v)
87{
88 __asm__ volatile("stwbrx %0, 0, %1" :: "r"(v), "r"(a));
89 powerpc_iomb();
90}
91
92static __inline u_int8_t
93__inb(volatile u_int8_t *a)
94{
95 u_int8_t _v_;
96
97 _v_ = *a;
98 powerpc_iomb();
99 return _v_;
100}
101
102static __inline u_int16_t
103__inw(volatile u_int16_t *a)
104{
105 u_int16_t _v_;
106
107 _v_ = *a;
108 powerpc_iomb();
109 return _v_;
110}
111
112static __inline u_int32_t
113__inl(volatile u_int32_t *a)
114{
115 u_int32_t _v_;
116
117 _v_ = *a;
118 powerpc_iomb();
119 return _v_;
120}
121
122static __inline u_int64_t
123__inll(volatile u_int64_t *a)
124{
125 u_int64_t _v_;
126
127 _v_ = *a;
128 powerpc_iomb();
129 return _v_;
130}
131
132static __inline u_int16_t
133__inwrb(volatile u_int16_t *a)
134{
135 u_int16_t _v_;
136
137 __asm__ volatile("lhbrx %0, 0, %1" : "=r"(_v_) : "r"(a));
138 powerpc_iomb();
139 return _v_;
140}
141
142static __inline u_int32_t
143__inlrb(volatile u_int32_t *a)
144{
145 u_int32_t _v_;
146
147 __asm__ volatile("lwbrx %0, 0, %1" : "=r"(_v_) : "r"(a));
148 powerpc_iomb();
149 return _v_;
150}
151
152#define outb(a,v) (__outb((volatile u_int8_t *)(a), v))
153#define out8(a,v) outb(a,v)
154#define outw(a,v) (__outw((volatile u_int16_t *)(a), v))
155#define out16(a,v) outw(a,v)
156#define outl(a,v) (__outl((volatile u_int32_t *)(a), v))
157#define out32(a,v) outl(a,v)
158#define outll(a,v) (__outll((volatile u_int64_t *)(a), v))
159#define out64(a,v) outll(a,v)
160#define inb(a) (__inb((volatile u_int8_t *)(a)))
161#define in8(a) inb(a)
162#define inw(a) (__inw((volatile u_int16_t *)(a)))
163#define in16(a) inw(a)
164#define inl(a) (__inl((volatile u_int32_t *)(a)))
165#define in32(a) inl(a)
166#define inll(a) (__inll((volatile u_int64_t *)(a)))
167#define in64(a) inll(a)
168
169#define out8rb(a,v) outb(a,v)
170#define outwrb(a,v) (__outwrb((volatile u_int16_t *)(a), v))
171#define out16rb(a,v) outwrb(a,v)
172#define outlrb(a,v) (__outlrb((volatile u_int32_t *)(a), v))
173#define out32rb(a,v) outlrb(a,v)
174#define in8rb(a) inb(a)
175#define inwrb(a) (__inwrb((volatile u_int16_t *)(a)))
176#define in16rb(a) inwrb(a)
177#define inlrb(a) (__inlrb((volatile u_int32_t *)(a)))
178#define in32rb(a) inlrb(a)
179
180static __inline void
181__outsb(volatile u_int8_t *a, const u_int8_t *s, size_t c)
182{
183 while (c--)
184 *a = *s++;
185 powerpc_iomb();
186}
187
188static __inline void
189__outsw(volatile u_int16_t *a, const u_int16_t *s, size_t c)
190{
191 while (c--)
192 *a = *s++;
193 powerpc_iomb();
194}
195
196static __inline void
197__outsl(volatile u_int32_t *a, const u_int32_t *s, size_t c)
198{
199 while (c--)
200 *a = *s++;
201 powerpc_iomb();
202}
203
204static __inline void
205__outsll(volatile u_int64_t *a, const u_int64_t *s, size_t c)
206{
207 while (c--)
208 *a = *s++;
209 powerpc_iomb();
210}
211
212static __inline void
213__outswrb(volatile u_int16_t *a, const u_int16_t *s, size_t c)
214{
215 while (c--)
216 __asm__ volatile("sthbrx %0, 0, %1" :: "r"(*s++), "r"(a));
217 powerpc_iomb();
218}
219
220static __inline void
221__outslrb(volatile u_int32_t *a, const u_int32_t *s, size_t c)
222{
223 while (c--)
224 __asm__ volatile("stwbrx %0, 0, %1" :: "r"(*s++), "r"(a));
225 powerpc_iomb();
226}
227
228static __inline void
229__insb(volatile u_int8_t *a, u_int8_t *d, size_t c)
230{
231 while (c--)
232 *d++ = *a;
233 powerpc_iomb();
234}
235
236static __inline void
237__insw(volatile u_int16_t *a, u_int16_t *d, size_t c)
238{
239 while (c--)
240 *d++ = *a;
241 powerpc_iomb();
242}
243
244static __inline void
245__insl(volatile u_int32_t *a, u_int32_t *d, size_t c)
246{
247 while (c--)
248 *d++ = *a;
249 powerpc_iomb();
250}
251
252static __inline void
253__insll(volatile u_int64_t *a, u_int64_t *d, size_t c)
254{
255 while (c--)
256 *d++ = *a;
257 powerpc_iomb();
258}
259
260static __inline void
261__inswrb(volatile u_int16_t *a, u_int16_t *d, size_t c)
262{
263 while (c--)
264 __asm__ volatile("lhbrx %0, 0, %1" : "=r"(*d++) : "r"(a));
265 powerpc_iomb();
266}
267
268static __inline void
269__inslrb(volatile u_int32_t *a, u_int32_t *d, size_t c)
270{
271 while (c--)
272 __asm__ volatile("lwbrx %0, 0, %1" : "=r"(*d++) : "r"(a));
273 powerpc_iomb();
274}
275
276#define outsb(a,s,c) (__outsb((volatile u_int8_t *)(a), s, c))
277#define outs8(a,s,c) outsb(a,s,c)
278#define outsw(a,s,c) (__outsw((volatile u_int16_t *)(a), s, c))
279#define outs16(a,s,c) outsw(a,s,c)
280#define outsl(a,s,c) (__outsl((volatile u_int32_t *)(a), s, c))
281#define outs32(a,s,c) outsl(a,s,c)
282#define outsll(a,s,c) (__outsll((volatile u_int64_t *)(a), s, c))
283#define outs64(a,s,c) outsll(a,s,c)
284#define insb(a,d,c) (__insb((volatile u_int8_t *)(a), d, c))
285#define ins8(a,d,c) insb(a,d,c)
286#define insw(a,d,c) (__insw((volatile u_int16_t *)(a), d, c))
287#define ins16(a,d,c) insw(a,d,c)
288#define insl(a,d,c) (__insl((volatile u_int32_t *)(a), d, c))
289#define ins32(a,d,c) insl(a,d,c)
290#define insll(a,d,c) (__insll((volatile u_int64_t *)(a), d, c))
291#define ins64(a,d,c) insll(a,d,c)
292
293#define outs8rb(a,s,c) outsb(a,s,c)
294#define outswrb(a,s,c) (__outswrb((volatile u_int16_t *)(a), s, c))
295#define outs16rb(a,s,c) outswrb(a,s,c)
296#define outslrb(a,s,c) (__outslrb((volatile u_int32_t *)(a), s, c))
297#define outs32rb(a,s,c) outslrb(a,s,c)
298#define ins8rb(a,d,c) insb(a,d,c)
299#define inswrb(a,d,c) (__inswrb((volatile u_int16_t *)(a), d, c))
300#define ins16rb(a,d,c) inswrb(a,d,c)
301#define inslrb(a,d,c) (__inslrb((volatile u_int32_t *)(a), d, c))
302#define ins32rb(a,d,c) inslrb(a,d,c)
303
304#endif /*_MACHINE_PIO_H_*/
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/platform.h created+76
......@@ -0,0 +1,76 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1996 Wolfgang Solfrank.
5 * Copyright (C) 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: powerpc.h,v 1.3 2000/06/01 00:49:59 matt Exp $
34 */
35
36#ifndef _MACHINE_PLATFORM_H_
37#define _MACHINE_PLATFORM_H_
38
39#include <machine/ofw_machdep.h>
40#include <machine/smp.h>
41#include <machine/pcpu.h>
42
43struct mem_region {
44 uint64_t mr_start;
45 uint64_t mr_size;
46};
47
48struct numa_mem_region {
49 uint64_t mr_start;
50 uint64_t mr_size;
51 uint64_t mr_domain;
52};
53
54/* Documentation for these functions is in platform_if.m */
55
56void mem_regions(struct mem_region **, int *, struct mem_region **, int *);
57void numa_mem_regions(struct numa_mem_region **, int *);
58vm_offset_t platform_real_maxaddr(void);
59
60u_long platform_timebase_freq(struct cpuref *);
61
62int platform_smp_first_cpu(struct cpuref *);
63int platform_smp_next_cpu(struct cpuref *);
64int platform_smp_get_bsp(struct cpuref *);
65int platform_smp_start_cpu(struct pcpu *);
66void platform_smp_timebase_sync(u_long tb, int ap);
67void platform_smp_ap_init(void);
68void platform_smp_probe_threads(void);
69int platform_node_numa_domain(phandle_t);
70
71const char *installed_platform(void);
72void platform_probe_and_attach(void);
73
74void platform_sleep(void);
75
76#endif /* _MACHINE_PLATFORM_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/platformvar.h created+89
......@@ -0,0 +1,89 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 Peter Grehan
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_PLATFORMVAR_H_
30#define _MACHINE_PLATFORMVAR_H_
31
32/*
33 * A PowerPC platform implementation is declared with a kernel object and
34 * an associated method table, similar to a device driver.
35 *
36 * e.g.
37 *
38 * static platform_method_t chrp_methods[] = {
39 * PLATFORMMETHOD(platform_probe, chrp_probe),
40 * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions),
41 * ...
42 * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu),
43 * { 0, 0 }
44 * };
45 *
46 * static platform_def_t chrp_platform = {
47 * "chrp",
48 * chrp_methods,
49 * sizeof(chrp_platform_softc), // or 0 if no softc
50 * };
51 *
52 * PLATFORM_DEF(chrp_platform);
53 */
54
55#include <sys/kobj.h>
56
57struct platform_kobj {
58 /*
59 * A platform instance is a kernel object
60 */
61 KOBJ_FIELDS;
62
63 /*
64 * Utility elements that an instance may use
65 */
66 struct mtx platform_mtx; /* available for instance use */
67 void *platform_iptr; /* instance data pointer */
68
69 /*
70 * Opaque data that can be overlaid with an instance-private
71 * structure. Platform code can test that this is large enough at
72 * compile time with a sizeof() test againt it's softc. There
73 * is also a run-time test when the platform kernel object is
74 * registered.
75 */
76#define PLATFORM_OPAQUESZ 64
77 u_int platform_opaque[PLATFORM_OPAQUESZ];
78};
79
80typedef struct platform_kobj *platform_t;
81typedef struct kobj_class platform_def_t;
82#define platform_method_t kobj_method_t
83
84#define PLATFORMMETHOD KOBJMETHOD
85#define PLATFORMMETHOD_END KOBJMETHOD_END
86
87#define PLATFORM_DEF(name) DATA_SET(platform_set, name)
88
89#endif /* _MACHINE_PLATFORMVAR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/pmap.h created+361
......@@ -0,0 +1,361 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-4-Clause
3 *
4 * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com>
5 * All rights reserved.
6 *
7 * Adapted for Freescale's e500 core CPUs.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31/*-
32 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
33 * Copyright (C) 1995, 1996 TooLs GmbH.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by TooLs GmbH.
47 * 4. The name of TooLs GmbH may not be used to endorse or promote products
48 * derived from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
51 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
55 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
56 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
57 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
58 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
59 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 * from: $NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $
62 */
63
64#ifndef _MACHINE_PMAP_H_
65#define _MACHINE_PMAP_H_
66
67#include <sys/queue.h>
68#include <sys/tree.h>
69#include <sys/_cpuset.h>
70#include <sys/_lock.h>
71#include <sys/_mutex.h>
72#include <machine/sr.h>
73#include <machine/pte.h>
74#include <machine/slb.h>
75#include <machine/tlb.h>
76#include <machine/vmparam.h>
77#ifdef __powerpc64__
78#include <vm/_vm_radix.h>
79#endif
80
81/*
82 * The radix page table structure is described by levels 1-4.
83 * See Fig 33. on p. 1002 of Power ISA v3.0B
84 *
85 * Page directories and tables must be size aligned.
86 */
87
88/* Root page directory - 64k -- each entry covers 512GB */
89typedef uint64_t pml1_entry_t;
90/* l2 page directory - 4k -- each entry covers 1GB */
91typedef uint64_t pml2_entry_t;
92/* l3 page directory - 4k -- each entry covers 2MB */
93typedef uint64_t pml3_entry_t;
94/* l4 page directory - 256B/4k -- each entry covers 64k/4k */
95typedef uint64_t pml4_entry_t;
96
97typedef uint64_t pt_entry_t;
98
99struct pmap;
100typedef struct pmap *pmap_t;
101
102#define PMAP_ENTER_QUICK_LOCKED 0x10000000
103
104#if !defined(NPMAPS)
105#define NPMAPS 32768
106#endif /* !defined(NPMAPS) */
107
108struct slbtnode;
109
110struct pvo_entry {
111 LIST_ENTRY(pvo_entry) pvo_vlink; /* Link to common virt page */
112#ifndef __powerpc64__
113 LIST_ENTRY(pvo_entry) pvo_olink; /* Link to overflow entry */
114#endif
115 union {
116 RB_ENTRY(pvo_entry) pvo_plink; /* Link to pmap entries */
117 SLIST_ENTRY(pvo_entry) pvo_dlink; /* Link to delete enty */
118 };
119 struct {
120#ifndef __powerpc64__
121 /* 32-bit fields */
122 pte_t pte;
123#endif
124 /* 64-bit fields */
125 uintptr_t slot;
126 vm_paddr_t pa;
127 vm_prot_t prot;
128 } pvo_pte;
129 pmap_t pvo_pmap; /* Owning pmap */
130 vm_offset_t pvo_vaddr; /* VA of entry */
131 uint64_t pvo_vpn; /* Virtual page number */
132};
133LIST_HEAD(pvo_head, pvo_entry);
134SLIST_HEAD(pvo_dlist, pvo_entry);
135RB_HEAD(pvo_tree, pvo_entry);
136int pvo_vaddr_compare(struct pvo_entry *, struct pvo_entry *);
137RB_PROTOTYPE(pvo_tree, pvo_entry, pvo_plink, pvo_vaddr_compare);
138
139/* Used by 32-bit PMAP */
140#define PVO_PTEGIDX_MASK 0x007UL /* which PTEG slot */
141#define PVO_PTEGIDX_VALID 0x008UL /* slot is valid */
142/* Used by 64-bit PMAP */
143#define PVO_HID 0x008UL /* PVO entry in alternate hash*/
144/* Used by both */
145#define PVO_WIRED 0x010UL /* PVO entry is wired */
146#define PVO_MANAGED 0x020UL /* PVO entry is managed */
147#define PVO_BOOTSTRAP 0x080UL /* PVO entry allocated during
148 bootstrap */
149#define PVO_DEAD 0x100UL /* waiting to be deleted */
150#define PVO_LARGE 0x200UL /* large page */
151#define PVO_VADDR(pvo) ((pvo)->pvo_vaddr & ~ADDR_POFF)
152#define PVO_PTEGIDX_GET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_MASK)
153#define PVO_PTEGIDX_ISSET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_VALID)
154#define PVO_PTEGIDX_CLR(pvo) \
155 ((void)((pvo)->pvo_vaddr &= ~(PVO_PTEGIDX_VALID|PVO_PTEGIDX_MASK)))
156#define PVO_PTEGIDX_SET(pvo, i) \
157 ((void)((pvo)->pvo_vaddr |= (i)|PVO_PTEGIDX_VALID))
158#define PVO_VSID(pvo) ((pvo)->pvo_vpn >> 16)
159
160struct pmap {
161 struct pmap_statistics pm_stats;
162 struct mtx pm_mtx;
163 cpuset_t pm_active;
164 union {
165 struct {
166 #ifdef __powerpc64__
167 struct slbtnode *pm_slb_tree_root;
168 struct slb **pm_slb;
169 int pm_slb_len;
170 #else
171 register_t pm_sr[16];
172 #endif
173
174 struct pmap *pmap_phys;
175 struct pvo_tree pmap_pvo;
176 };
177#ifdef __powerpc64__
178 /* Radix support */
179 struct {
180 pml1_entry_t *pm_pml1; /* KVA of root page directory */
181 struct vm_radix pm_radix; /* spare page table pages */
182 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
183 uint64_t pm_pid; /* PIDR value */
184 int pm_flags;
185 };
186#endif
187 struct {
188 /* TID to identify this pmap entries in TLB */
189 tlbtid_t pm_tid[MAXCPU];
190
191#ifdef __powerpc64__
192 /*
193 * Page table directory,
194 * array of pointers to page directories.
195 */
196 pte_t ****pm_root;
197#else
198 /*
199 * Page table directory,
200 * array of pointers to page tables.
201 */
202 pte_t **pm_pdir;
203
204 /* List of allocated ptbl bufs (ptbl kva regions). */
205 TAILQ_HEAD(, ptbl_buf) pm_ptbl_list;
206#endif
207 };
208 } __aligned(CACHE_LINE_SIZE);
209};
210
211/*
212 * pv_entries are allocated in chunks per-process. This avoids the
213 * need to track per-pmap assignments.
214 */
215#define _NPCPV 126
216#define _NPCM howmany(_NPCPV, 64)
217
218#define PV_CHUNK_HEADER \
219 pmap_t pc_pmap; \
220 TAILQ_ENTRY(pv_chunk) pc_list; \
221 uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ \
222 TAILQ_ENTRY(pv_chunk) pc_lru;
223
224struct pv_entry {
225 pmap_t pv_pmap;
226 vm_offset_t pv_va;
227 TAILQ_ENTRY(pv_entry) pv_link;
228};
229typedef struct pv_entry *pv_entry_t;
230
231struct pv_chunk_header {
232 PV_CHUNK_HEADER
233};
234struct pv_chunk {
235 PV_CHUNK_HEADER
236 uint64_t reserved;
237 struct pv_entry pc_pventry[_NPCPV];
238};
239
240struct md_page {
241 union {
242 struct {
243 volatile int32_t mdpg_attrs;
244 vm_memattr_t mdpg_cache_attrs;
245 struct pvo_head mdpg_pvoh;
246 int pv_gen; /* (p) */
247 };
248 struct {
249 int pv_tracked;
250 };
251 };
252 TAILQ_HEAD(, pv_entry) pv_list; /* (p) */
253};
254
255#ifdef AIM
256#define pmap_page_get_memattr(m) ((m)->md.mdpg_cache_attrs)
257#else
258#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT
259#endif /* AIM */
260
261/*
262 * Return the VSID corresponding to a given virtual address.
263 * If no VSID is currently defined, it will allocate one, and add
264 * it to a free slot if available.
265 *
266 * NB: The PMAP MUST be locked already.
267 */
268uint64_t va_to_vsid(pmap_t pm, vm_offset_t va);
269
270/* Lock-free, non-allocating lookup routines */
271uint64_t kernel_va_to_slbv(vm_offset_t va);
272struct slb *user_va_to_slb_entry(pmap_t pm, vm_offset_t va);
273
274uint64_t allocate_user_vsid(pmap_t pm, uint64_t esid, int large);
275void free_vsid(pmap_t pm, uint64_t esid, int large);
276void slb_insert_user(pmap_t pm, struct slb *slb);
277void slb_insert_kernel(uint64_t slbe, uint64_t slbv);
278
279struct slbtnode *slb_alloc_tree(void);
280void slb_free_tree(pmap_t pm);
281struct slb **slb_alloc_user_cache(void);
282void slb_free_user_cache(struct slb **);
283
284extern struct pmap kernel_pmap_store;
285#define kernel_pmap (&kernel_pmap_store)
286
287#ifdef _KERNEL
288
289#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)
290#define PMAP_LOCK_ASSERT(pmap, type) \
291 mtx_assert(&(pmap)->pm_mtx, (type))
292#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx)
293#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, \
294 (pmap == kernel_pmap) ? "kernelpmap" : \
295 "pmap", NULL, MTX_DEF | MTX_DUPOK)
296#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx)
297#define PMAP_MTX(pmap) (&(pmap)->pm_mtx)
298#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx)
299#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx)
300
301#define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0)
302
303#define pmap_vm_page_alloc_check(m)
304
305void pmap_bootstrap(vm_offset_t, vm_offset_t);
306void pmap_kenter(vm_offset_t va, vm_paddr_t pa);
307void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t);
308void pmap_kremove(vm_offset_t);
309void *pmap_mapdev(vm_paddr_t, vm_size_t);
310void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
311void pmap_unmapdev(void *, vm_size_t);
312void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
313int pmap_change_attr(vm_offset_t, vm_size_t, vm_memattr_t);
314int pmap_map_user_ptr(pmap_t pm, volatile const void *uaddr,
315 void **kaddr, size_t ulen, size_t *klen);
316int pmap_decode_kernel_ptr(vm_offset_t addr, int *is_user,
317 vm_offset_t *decoded_addr);
318void pmap_deactivate(struct thread *);
319vm_paddr_t pmap_kextract(vm_offset_t);
320int pmap_dev_direct_mapped(vm_paddr_t, vm_size_t);
321bool pmap_mmu_install(char *name, int prio);
322void pmap_mmu_init(void);
323const char *pmap_mmu_name(void);
324bool pmap_ps_enabled(pmap_t pmap);
325int pmap_nofault(pmap_t pmap, vm_offset_t va, vm_prot_t flags);
326bool pmap_page_is_mapped(vm_page_t m);
327#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)
328
329void pmap_page_array_startup(long count);
330
331#define vtophys(va) pmap_kextract((vm_offset_t)(va))
332
333extern vm_offset_t virtual_avail;
334extern vm_offset_t virtual_end;
335extern caddr_t crashdumpmap;
336
337extern vm_offset_t msgbuf_phys;
338
339extern int pmap_bootstrapped;
340extern int radix_mmu;
341extern int superpages_enabled;
342
343#ifdef AIM
344void pmap_early_io_map_init(void);
345#endif
346vm_offset_t pmap_early_io_map(vm_paddr_t pa, vm_size_t size);
347void pmap_early_io_unmap(vm_offset_t va, vm_size_t size);
348void pmap_track_page(pmap_t pmap, vm_offset_t va);
349void pmap_page_print_mappings(vm_page_t m);
350void pmap_tlbie_all(void);
351
352static inline int
353pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused)
354{
355
356 return (0);
357}
358
359#endif
360
361#endif /* !_MACHINE_PMAP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/pmc_mdep.h created+95
......@@ -0,0 +1,95 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#ifndef _MACHINE_PMC_MDEP_H_
6#define _MACHINE_PMC_MDEP_H_
7
8#define PMC_MDEP_CLASS_INDEX_POWERPC 1
9
10union pmc_md_op_pmcallocate {
11 uint32_t pm_event;
12 uint64_t __pad[4];
13};
14
15/* Logging */
16#ifdef __powerpc64__
17#define PMCLOG_READADDR PMCLOG_READ64
18#define PMCLOG_EMITADDR PMCLOG_EMIT64
19#else
20#define PMCLOG_READADDR PMCLOG_READ32
21#define PMCLOG_EMITADDR PMCLOG_EMIT32
22#endif
23
24#define mtpmr(reg, val) \
25 __asm __volatile("mtpmr %0,%1" : : "K"(reg), "r"(val))
26#define mfpmr(reg) \
27 ( { register_t val; \
28 __asm __volatile("mfpmr %0,%1" : "=r"(val) : "K"(reg)); \
29 val; } )
30
31#define PMR_PMC0 16
32#define PMR_PMC1 17
33#define PMR_PMC2 18
34#define PMR_PMC3 19
35#define PMR_PMLCa0 144
36#define PMLCax_FC 0x80000000
37#define PMLCax_FCS 0x40000000
38#define PMLCax_FCU 0x20000000
39#define PMLCax_FCM1 0x10000000
40#define PMLCax_FCM0 0x08000000
41#define PMLCax_CE 0x04000000
42#define PMLCax_EVENT(x) ((x) << 16)
43#define PMLCax_FCGS1 0x00000002
44#define PMLCax_FCGS0 0x00000001
45#define PMR_PMLCa1 145
46#define PMR_PMLCa2 146
47#define PMR_PMLCa3 147
48#define PMR_PMLCb0 272
49#define PMLCbx_TRIGONCTL(x) ((x) << 28)
50#define PMLCbx_TRIGOFFCTL(x) ((x) << 24)
51#define PMLCbx_PMCC 0x00800000
52#define PMLCbx_PMP(x) ((x) << 13)
53#define PMLCbx_TREHMUL(x) ((x) << 8)
54#define PMLCbx_TRESHOLD(x) ((x) << 0)
55#define PMR_PMLCb1 273
56#define PMR_PMLCb2 274
57#define PMR_PMLCb3 275
58#define PMR_PMGC0 400
59#define PMGC_FAC 0x80000000
60#define PMGC_PMIE 0x40000000
61#define PMGC_FCECE 0x20000000
62#define PMGC_TBSEL(x) ((x) << 11)
63#define PMGC_TBEE 0x00000100
64#define PMR_UPMC0 0
65#define PMR_UPMC1 1
66#define PMR_UPMC2 2
67#define PMR_UPMC3 3
68#define PMR_UPMLCa0 128
69#define PMR_UPMLCa1 129
70#define PMR_UPMLCa2 130
71#define PMR_UPMLCa3 131
72#define PMR_UPMLCb0 256
73#define PMR_UPMLCb1 257
74#define PMR_UPMLCb2 258
75#define PMR_UPMLCb3 259
76#define PMR_UPMGC0 384
77
78#if _KERNEL
79
80struct pmc_md_powerpc_pmc {
81 uint64_t pm_powerpc_overflowcnt;
82 uint32_t pm_powerpc_evsel;
83};
84
85union pmc_md_pmc {
86 struct pmc_md_powerpc_pmc pm_powerpc;
87};
88
89#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->srr0)
90#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->fixreg[1])
91#define PMC_TRAPFRAME_TO_SP(TF) (0)
92
93#endif
94
95#endif /* !_MACHINE_PMC_MDEP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/proc.h created+61
......@@ -0,0 +1,61 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: proc.h,v 1.2 1997/04/16 22:57:48 thorpej Exp $
34 */
35
36#ifndef _MACHINE_PROC_H_
37#define _MACHINE_PROC_H_
38
39/*
40 * Machine-dependent part of the proc structure
41 */
42struct mdthread {
43 int md_spinlock_count; /* (k) */
44 register_t md_saved_msr; /* (k) */
45};
46
47struct mdproc {
48 /*
49 * Avoid empty structs because they are undefined behavior.
50 */
51 long md_spare;
52};
53
54#ifdef __powerpc64__
55#define KINFO_PROC_SIZE 1088
56#define KINFO_PROC32_SIZE 816
57#else
58#define KINFO_PROC_SIZE 816
59#endif
60
61#endif /* !_MACHINE_PROC_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/profile.h created+234
......@@ -0,0 +1,234 @@
1/*-
2 * SPDX-License-Identifier: MIT-CMU
3 *
4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 *
29 * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp
30 * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29
31 */
32
33#ifndef _MACHINE_PROFILE_H_
34#define _MACHINE_PROFILE_H_
35
36#define _MCOUNT_DECL void __mcount
37
38#define FUNCTION_ALIGNMENT 4
39
40typedef __ptrdiff_t fptrdiff_t;
41
42/*
43 * The mcount trampoline macro, expanded in libc/gmon/mcount.c
44 *
45 * For PowerPC SVR4 ABI profiling, the compiler will insert
46 * a data declaration and code sequence at the start of a routine of the form
47 *
48 * .function_mc: .data
49 * .align 2
50 * .long 0
51 * .text
52 *
53 * function: mflr %r0
54 * addis %r11,%r0, .function_mc@ha
55 * stw %r0,4(%r1)
56 * addi %r0,%r11, .function_mc@l
57 * bl _mcount
58 *
59 * The link register is saved in the LR save word in the caller's
60 * stack frame, r0 is set up to point to the allocated longword,
61 * and control is transferred to _mcount.
62 *
63 * On return from _mcount, the routine should function as it would
64 * with no profiling so _mcount must restore register state to that upon
65 * entry. Any routine called by the _mcount trampoline will save
66 * callee-save registers, so _mcount must make sure it saves volatile
67 * registers that may have state after it returns i.e. parameter registers.
68 *
69 * The FreeBSD libc mcount routine ignores the r0 longword pointer, but
70 * instead requires as parameters the current PC and called PC. The current
71 * PC is obtained from the link register, as a result of "bl _mcount" in
72 * the stub, while the caller's PC is obtained from the LR save word.
73 *
74 * On return from libc mcount, the return is done indirectly with the
75 * ctr register rather than the link register, to allow the link register
76 * to be restored to what it was on entry to the profiled routine.
77 */
78
79#if defined(__powerpc64__)
80
81#if !defined(_CALL_ELF) || _CALL_ELF == 1
82#define MCOUNT_PREAMBLE \
83 " .align 2 \n" \
84 " .globl _mcount \n" \
85 " .section \".opd\",\"aw\" \n" \
86 " .align 3 \n" \
87 "_mcount: \n" \
88 " .quad .L._mcount,.TOC.@tocbase,0\n" \
89 " .previous \n" \
90 " .size _mcount,24 \n" \
91 " .type _mcount,@function \n" \
92 " .align 4 \n" \
93 ".L._mcount: \n"
94#else
95#define MCOUNT_PREAMBLE \
96 " .globl _mcount \n" \
97 " .type _mcount,@function \n" \
98 " .align 4 \n" \
99 "_mcount: \n"
100#endif
101
102#define MCOUNT \
103__asm( MCOUNT_PREAMBLE \
104 " stdu %r1,-(288+128)(%r1) \n" \
105 " std %r3,48(%r1) \n" \
106 " std %r4,56(%r1) \n" \
107 " std %r5,64(%r1) \n" \
108 " std %r6,72(%r1) \n" \
109 " std %r7,80(%r1) \n" \
110 " std %r8,88(%r1) \n" \
111 " std %r9,96(%r1) \n" \
112 " std %r10,104(%r1) \n" \
113 " mflr %r4 \n" \
114 " std %r4,112(%r1) \n" \
115 " ld %r3,0(%r1) \n" \
116 " ld %r3,0(%r3) \n" \
117 " ld %r3,16(%r3) \n" \
118 " bl __mcount \n" \
119 " nop \n" \
120 " ld %r4,112(%r1) \n" \
121 " mtlr %r4 \n" \
122 " ld %r3,48(%r1) \n" \
123 " ld %r4,56(%r1) \n" \
124 " ld %r5,64(%r1) \n" \
125 " ld %r6,72(%r1) \n" \
126 " ld %r7,80(%r1) \n" \
127 " ld %r8,88(%r1) \n" \
128 " ld %r9,96(%r1) \n" \
129 " ld %r10,104(%r1) \n" \
130 " addi %r1,%r1,(288+128) \n" \
131 " blr \n");
132#else
133
134#ifdef PIC
135#define _PLT "@plt"
136#else
137#define _PLT
138#endif
139
140#define MCOUNT \
141__asm( " .globl _mcount \n" \
142 " .type _mcount,@function \n" \
143 " .align 4 \n" \
144 "_mcount: \n" \
145 " stwu %r1,-64(%r1) \n" \
146 " stw %r3,16(%r1) \n" \
147 " stw %r4,20(%r1) \n" \
148 " stw %r5,24(%r1) \n" \
149 " stw %r6,28(%r1) \n" \
150 " stw %r7,32(%r1) \n" \
151 " stw %r8,36(%r1) \n" \
152 " stw %r9,40(%r1) \n" \
153 " stw %r10,44(%r1) \n" \
154 " mflr %r4 \n" \
155 " stw %r4,48(%r1) \n" \
156 " lwz %r3,68(%r1) \n" \
157 " bl __mcount" _PLT " \n" \
158 " lwz %r3,68(%r1) \n" \
159 " mtlr %r3 \n" \
160 " lwz %r4,48(%r1) \n" \
161 " mtctr %r4 \n" \
162 " lwz %r3,16(%r1) \n" \
163 " lwz %r4,20(%r1) \n" \
164 " lwz %r5,24(%r1) \n" \
165 " lwz %r6,28(%r1) \n" \
166 " lwz %r7,32(%r1) \n" \
167 " lwz %r8,36(%r1) \n" \
168 " lwz %r9,40(%r1) \n" \
169 " lwz %r10,44(%r1) \n" \
170 " addi %r1,%r1,64 \n" \
171 " bctr \n" \
172 "_mcount_end: \n" \
173 " .size _mcount,_mcount_end-_mcount");
174#endif
175
176#ifdef _KERNEL
177#define MCOUNT_ENTER(s) s = intr_disable()
178#define MCOUNT_EXIT(s) intr_restore(s)
179#define MCOUNT_DECL(s) register_t s;
180
181#ifndef COMPILING_LINT
182#ifdef AIM
183#include <machine/trap.h>
184#define __PROFILE_VECTOR_BASE EXC_RST
185#define __PROFILE_VECTOR_TOP (EXC_LAST + 0x100)
186#endif /* AIM */
187#if defined(BOOKE)
188extern char interrupt_vector_base[];
189extern char interrupt_vector_top[];
190#define __PROFILE_VECTOR_BASE (uintfptr_t)interrupt_vector_base
191#define __PROFILE_VECTOR_TOP (uintfptr_t)interrupt_vector_top
192#endif /* BOOKE_E500 */
193
194#endif /* !COMPILING_LINT */
195
196#ifndef __PROFILE_VECTOR_BASE
197#define __PROFILE_VECTOR_BASE 0
198#endif
199#ifndef __PROFILE_VECTOR_TOP
200#define __PROFILE_VECTOR_TOP 1
201#endif
202
203static __inline void
204powerpc_profile_interrupt(void)
205{
206}
207
208static __inline void
209powerpc_profile_userspace(void)
210{
211}
212
213#define MCOUNT_FROMPC_USER(pc) \
214 ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? \
215 (uintfptr_t)powerpc_profile_userspace : pc)
216
217#define MCOUNT_FROMPC_INTR(pc) \
218 ((pc >= __PROFILE_VECTOR_BASE && \
219 pc < __PROFILE_VECTOR_TOP) ? \
220 (uintfptr_t)powerpc_profile_interrupt : ~0U)
221
222void __mcount(uintfptr_t frompc, uintfptr_t selfpc);
223
224#else /* !_KERNEL */
225
226#ifdef __powerpc64__
227typedef u_long uintfptr_t;
228#else
229typedef u_int uintfptr_t;
230#endif
231
232#endif /* _KERNEL */
233
234#endif /* !_MACHINE_PROFILE_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/psl.h created+101
......@@ -0,0 +1,101 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: psl.h,v 1.5 2000/11/19 19:52:37 matt Exp $
34 */
35
36#ifndef _MACHINE_PSL_H_
37#define _MACHINE_PSL_H_
38
39/*
40 * Machine State Register (MSR) - All cores
41 */
42#define PSL_VEC 0x02000000UL /* AltiVec/SPE vector unit available */
43#define PSL_VSX 0x00800000UL /* Vector-Scalar unit available */
44#define PSL_EE 0x00008000UL /* external interrupt enable */
45#define PSL_PR 0x00004000UL /* privilege mode (1 == user) */
46#define PSL_FP 0x00002000UL /* floating point enable */
47#define PSL_ME 0x00001000UL /* machine check enable */
48#define PSL_FE0 0x00000800UL /* floating point interrupt mode 0 */
49#define PSL_FE1 0x00000100UL /* floating point interrupt mode 1 */
50#define PSL_PMM 0x00000004UL /* performance monitor mark */
51#define PSL_RI 0x00000002UL /* recoverable interrupt */
52
53/* Machine State Register - Book-E cores */
54#ifdef __powerpc64__
55#define PSL_CM 0x80000000UL /* Computation Mode (64-bit) */
56#endif
57
58#define PSL_GS 0x10000000UL /* Guest state */
59#define PSL_UCLE 0x04000000UL /* User mode cache lock enable */
60#define PSL_WE 0x00040000UL /* Wait state enable */
61#define PSL_CE 0x00020000UL /* Critical interrupt enable */
62#define PSL_UBLE 0x00000400UL /* BTB lock enable - e500 only */
63#define PSL_DWE 0x00000400UL /* Debug Wait Enable - 440 only*/
64#define PSL_DE 0x00000200UL /* Debug interrupt enable */
65#define PSL_IS 0x00000020UL /* Instruction address space */
66#define PSL_DS 0x00000010UL /* Data address space */
67
68/* Machine State Register (MSR) - AIM cores */
69#ifdef __powerpc64__
70#define PSL_SF 0x8000000000000000UL /* 64-bit addressing */
71#define PSL_HV 0x1000000000000000UL /* hyper-privileged mode */
72#endif
73
74#define PSL_POW 0x00040000UL /* power management */
75#define PSL_ILE 0x00010000UL /* interrupt endian mode (1 == le) */
76#define PSL_SE 0x00000400UL /* single-step trace enable */
77#define PSL_BE 0x00000200UL /* branch trace enable */
78#define PSL_IP 0x00000040UL /* interrupt prefix - 601 only */
79#define PSL_IR 0x00000020UL /* instruction address relocation */
80#define PSL_DR 0x00000010UL /* data address relocation */
81#define PSL_LE 0x00000001UL /* endian mode (1 == le) */
82
83/*
84 * Floating-point exception modes:
85 */
86#define PSL_FE_DIS 0 /* none */
87#define PSL_FE_NONREC PSL_FE1 /* imprecise non-recoverable */
88#define PSL_FE_REC PSL_FE0 /* imprecise recoverable */
89#define PSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */
90#define PSL_FE_DFLT PSL_FE_PREC /* default == precise */
91
92#ifndef LOCORE
93extern register_t psl_kernset; /* Default MSR values for kernel */
94extern register_t psl_userset; /* Default MSR values for userland */
95#ifdef __powerpc64__
96extern register_t psl_userset32; /* Default user MSR values for 32-bit */
97#endif
98extern register_t psl_userstatic; /* Bits of SRR1 userland may not set */
99#endif
100
101#endif /* _MACHINE_PSL_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/pte.h created+432
......@@ -0,0 +1,432 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: pte.h,v 1.2 1998/08/31 14:43:40 tsubai Exp $
34 */
35
36#ifndef _MACHINE_PTE_H_
37#define _MACHINE_PTE_H_
38
39#if defined(AIM)
40
41/*
42 * Page Table Entries
43 */
44#ifndef LOCORE
45
46/* 32-bit PTE */
47struct pte {
48 u_int32_t pte_hi;
49 u_int32_t pte_lo;
50};
51
52struct pteg {
53 struct pte pt[8];
54};
55
56/* 64-bit (long) PTE */
57struct lpte {
58 u_int64_t pte_hi;
59 u_int64_t pte_lo;
60};
61
62struct lpteg {
63 struct lpte pt[8];
64};
65
66/* Partition table entry */
67struct pate {
68 u_int64_t pagetab;
69 u_int64_t proctab;
70};
71
72/* Process table entry */
73struct prte {
74 u_int64_t proctab0;
75 u_int64_t proctab1;
76};
77
78typedef struct pte pte_t;
79typedef struct lpte lpte_t;
80#endif /* LOCORE */
81
82/* 32-bit PTE definitions */
83
84/* High word: */
85#define PTE_VALID 0x80000000
86#define PTE_VSID_SHFT 7
87#define PTE_HID 0x00000040
88#define PTE_API 0x0000003f
89/* Low word: */
90#define PTE_RPGN 0xfffff000
91#define PTE_REF 0x00000100
92#define PTE_CHG 0x00000080
93#define PTE_WIMG 0x00000078
94#define PTE_W 0x00000040
95#define PTE_I 0x00000020
96#define PTE_M 0x00000010
97#define PTE_G 0x00000008
98#define PTE_PP 0x00000003
99#define PTE_SO 0x00000000 /* Super. Only (U: XX, S: RW) */
100#define PTE_SW 0x00000001 /* Super. Write-Only (U: RO, S: RW) */
101#define PTE_BW 0x00000002 /* Supervisor (U: RW, S: RW) */
102#define PTE_BR 0x00000003 /* Both Read Only (U: RO, S: RO) */
103#define PTE_RW PTE_BW
104#define PTE_RO PTE_BR
105
106#define PTE_EXEC 0x00000200 /* pseudo bit in attrs; page is exec */
107
108/* 64-bit PTE definitions */
109
110/* High quadword: */
111#define LPTE_VSID_SHIFT 12
112#define LPTE_AVPN_MASK 0xFFFFFFFFFFFFFF80ULL
113#define LPTE_AVA_MASK 0x3FFFFFFFFFFFFF80ULL
114#define LPTE_API 0x0000000000000F80ULL
115#define LPTE_SWBITS 0x0000000000000078ULL
116#define LPTE_WIRED 0x0000000000000010ULL
117#define LPTE_LOCKED 0x0000000000000008ULL
118#define LPTE_BIG 0x0000000000000004ULL /* 4kb/16Mb page */
119#define LPTE_HID 0x0000000000000002ULL
120#define LPTE_VALID 0x0000000000000001ULL
121
122/* Low quadword: */
123#define LP_4K_16M 0x38 /* 4KB base, 16MB actual page size */
124
125#define EXTEND_PTE(x) UINT64_C(x) /* make constants 64-bit */
126#define LPTE_RPGN 0xfffffffffffff000ULL
127#define LPTE_LP_MASK 0x00000000000ff000ULL
128#define LPTE_LP_SHIFT 12
129#define LPTE_LP_4K_16M ((unsigned long long)(LP_4K_16M) << LPTE_LP_SHIFT)
130#define LPTE_REF EXTEND_PTE( PTE_REF )
131#define LPTE_CHG EXTEND_PTE( PTE_CHG )
132#define LPTE_WIMG EXTEND_PTE( PTE_WIMG )
133#define LPTE_W EXTEND_PTE( PTE_W )
134#define LPTE_I EXTEND_PTE( PTE_I )
135#define LPTE_M EXTEND_PTE( PTE_M )
136#define LPTE_G EXTEND_PTE( PTE_G )
137#define LPTE_NOEXEC 0x0000000000000004ULL
138#define LPTE_PP EXTEND_PTE( PTE_PP )
139
140#define LPTE_SO EXTEND_PTE( PTE_SO ) /* Super. Only */
141#define LPTE_SW EXTEND_PTE( PTE_SW ) /* Super. Write-Only */
142#define LPTE_BW EXTEND_PTE( PTE_BW ) /* Supervisor */
143#define LPTE_BR EXTEND_PTE( PTE_BR ) /* Both Read Only */
144#define LPTE_RW LPTE_BW
145#define LPTE_RO LPTE_BR
146
147/* HPT superpage definitions */
148#define HPT_SP_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT)
149#define HPT_SP_SIZE (1 << HPT_SP_SHIFT)
150#define HPT_SP_MASK (HPT_SP_SIZE - 1)
151#define HPT_SP_PAGES (1 << VM_LEVEL_0_ORDER)
152
153/* POWER ISA 3.0 Radix Table Definitions */
154#define RPTE_VALID 0x8000000000000000ULL
155#define RPTE_LEAF 0x4000000000000000ULL /* is a PTE: always 1 */
156#define RPTE_SW0 0x2000000000000000ULL
157#define RPTE_RPN_MASK 0x00FFFFFFFFFFF000ULL
158#define RPTE_RPN_SHIFT 12
159#define RPTE_SW1 0x0000000000000800ULL
160#define RPTE_SW2 0x0000000000000400ULL
161#define RPTE_SW3 0x0000000000000200ULL
162#define RPTE_R 0x0000000000000100ULL
163#define RPTE_C 0x0000000000000080ULL
164
165#define RPTE_MANAGED RPTE_SW1
166#define RPTE_WIRED RPTE_SW2
167#define RPTE_PROMOTED RPTE_SW3
168
169#define RPTE_ATTR_MASK 0x0000000000000030ULL
170#define RPTE_ATTR_MEM 0x0000000000000000ULL /* PTE M */
171#define RPTE_ATTR_SAO 0x0000000000000010ULL /* PTE WIM */
172#define RPTE_ATTR_GUARDEDIO 0x0000000000000020ULL /* PTE IMG */
173#define RPTE_ATTR_UNGUARDEDIO 0x0000000000000030ULL /* PTE IM */
174
175#define RPTE_EAA_MASK 0x000000000000000FULL
176#define RPTE_EAA_P 0x0000000000000008ULL /* Supervisor only */
177#define RPTE_EAA_R 0x0000000000000004ULL /* Read allowed */
178#define RPTE_EAA_W 0x0000000000000002ULL /* Write (+read) */
179#define RPTE_EAA_X 0x0000000000000001ULL /* Execute allowed */
180
181#define RPDE_VALID RPTE_VALID
182#define RPDE_LEAF RPTE_LEAF /* is a PTE: always 0 */
183#define RPDE_NLB_MASK 0x00FFFFFFFFFFFF00ULL
184#define RPDE_NLB_SHIFT 8
185#define RPDE_NLS_MASK 0x000000000000001FULL
186
187#define PG_FRAME (0x000ffffffffff000ul)
188#define PG_PS_FRAME (0x000fffffffe00000ul)
189/*
190 * Extract bits from address
191 */
192#define ADDR_SR_SHFT 28
193#define ADDR_PIDX 0x0ffff000UL
194#define ADDR_PIDX_SHFT 12
195#define ADDR_API_SHFT 22
196#define ADDR_API_SHFT64 16
197#define ADDR_POFF 0x00000fffUL
198
199/*
200 * Bits in DSISR:
201 */
202#define DSISR_DIRECT 0x80000000
203#define DSISR_NOTFOUND 0x40000000
204#define DSISR_PROTECT 0x08000000
205#define DSISR_INVRX 0x04000000
206#define DSISR_STORE 0x02000000
207#define DSISR_DABR 0x00400000
208#define DSISR_SEGMENT 0x00200000
209#define DSISR_EAR 0x00100000
210
211/*
212 * Bits in SRR1 on ISI:
213 */
214#define ISSRR1_NOTFOUND 0x40000000
215#define ISSRR1_DIRECT 0x10000000
216#define ISSRR1_PROTECT 0x08000000
217#define ISSRR1_SEGMENT 0x00200000
218
219#else /* BOOKE */
220
221#include <machine/tlb.h>
222
223/*
224 * Flags for pte_remove() routine.
225 */
226#define PTBL_HOLD 0x00000001 /* do not unhold ptbl pages */
227#define PTBL_UNHOLD 0x00000002 /* unhold and attempt to free ptbl pages */
228
229#define PTBL_HOLD_FLAG(pmap) (((pmap) == kernel_pmap) ? PTBL_HOLD : PTBL_UNHOLD)
230
231/*
232 * Page Table Entry definitions and macros.
233 *
234 * RPN need only be 32-bit because Book-E has 36-bit addresses, and the smallest
235 * page size is 4k (12-bit mask), so RPN can really fit into 24 bits.
236 */
237#ifndef LOCORE
238typedef uint64_t pte_t;
239#endif
240
241/* RPN mask, TLB0 4K pages */
242#define PTE_PA_MASK PAGE_MASK
243
244#if defined(BOOKE_E500)
245
246/* PTE bits assigned to MAS2, MAS3 flags */
247#define PTE_MAS2_SHIFT 19
248#define PTE_W (MAS2_W << PTE_MAS2_SHIFT)
249#define PTE_I (MAS2_I << PTE_MAS2_SHIFT)
250#define PTE_M (MAS2_M << PTE_MAS2_SHIFT)
251#define PTE_G (MAS2_G << PTE_MAS2_SHIFT)
252#define PTE_MAS2_MASK (MAS2_G | MAS2_M | MAS2_I | MAS2_W)
253
254#define PTE_MAS3_SHIFT 2
255#define PTE_UX (MAS3_UX << PTE_MAS3_SHIFT)
256#define PTE_SX (MAS3_SX << PTE_MAS3_SHIFT)
257#define PTE_UW (MAS3_UW << PTE_MAS3_SHIFT)
258#define PTE_SW (MAS3_SW << PTE_MAS3_SHIFT)
259#define PTE_UR (MAS3_UR << PTE_MAS3_SHIFT)
260#define PTE_SR (MAS3_SR << PTE_MAS3_SHIFT)
261#define PTE_MAS3_MASK ((MAS3_UX | MAS3_SX | MAS3_UW \
262 | MAS3_SW | MAS3_UR | MAS3_SR) << PTE_MAS3_SHIFT)
263
264#define PTE_PS_SHIFT 8
265#define PTE_PS_4KB (2 << PTE_PS_SHIFT)
266
267#endif
268
269/* Other PTE flags */
270#define PTE_VALID 0x00000001 /* Valid */
271#define PTE_MODIFIED 0x00001000 /* Modified */
272#define PTE_WIRED 0x00002000 /* Wired */
273#define PTE_MANAGED 0x00000002 /* Managed */
274#define PTE_REFERENCED 0x00040000 /* Referenced */
275
276/*
277 * Page Table Entry definitions and macros.
278 *
279 * We use the hardware page table entry format:
280 *
281 * 63 24 23 19 18 17 14 13 12 11 8 7 6 5 4 3 2 1 0
282 * ---------------------------------------------------------------
283 * ARPN(12:51) WIMGE R U0:U3 SW0 C PSIZE UX SX UW SW UR SR SW1 V
284 * ---------------------------------------------------------------
285 */
286
287/* PTE fields. */
288#define PTE_TSIZE_SHIFT (63-54)
289#define PTE_TSIZE_MASK 0x7
290#define PTE_TSIZE_SHIFT_DIRECT (63-55)
291#define PTE_TSIZE_MASK_DIRECT 0xf
292#define PTE_PS_DIRECT(ps) (ps<<PTE_TSIZE_SHIFT_DIRECT) /* Direct Entry Page Size */
293#define PTE_PS(ps) (ps<<PTE_TSIZE_SHIFT) /* Page Size */
294
295/* Macro argument must of pte_t type. */
296#define PTE_TSIZE(pte) (int)((*pte >> PTE_TSIZE_SHIFT) & PTE_TSIZE_MASK)
297#define PTE_TSIZE_DIRECT(pte) (int)((*pte >> PTE_TSIZE_SHIFT_DIRECT) & PTE_TSIZE_MASK_DIRECT)
298
299/* Macro argument must of pte_t type. */
300#define PTE_ARPN_SHIFT 12
301#define PTE_FLAGS_MASK 0x00ffffff
302#define PTE_RPN_FROM_PA(pa) (((pa) & ~PAGE_MASK) << PTE_ARPN_SHIFT)
303#define PTE_PA(pte) ((vm_paddr_t)(*pte >> PTE_ARPN_SHIFT) & ~PAGE_MASK)
304#define PTE_ISVALID(pte) ((*pte) & PTE_VALID)
305#define PTE_ISWIRED(pte) ((*pte) & PTE_WIRED)
306#define PTE_ISMANAGED(pte) ((*pte) & PTE_MANAGED)
307#define PTE_ISMODIFIED(pte) ((*pte) & PTE_MODIFIED)
308#define PTE_ISREFERENCED(pte) ((*pte) & PTE_REFERENCED)
309
310#endif /* BOOKE */
311
312/* Book-E page table format, broken out for the generic pmap.h. */
313#ifdef __powerpc64__
314
315#include <machine/tlb.h>
316
317/*
318 * The virtual address is:
319 *
320 * 4K page size
321 * +-----+-----------+-------+-------------+-------------+----------------+
322 * | - | pg_root |pdir_l1| dir# | pte# | off in 4K page |
323 * +-----+-----------+-------+-------------+-------------+----------------+
324 * 63 52 51 39 38 30 29 ^ 21 20 ^ 12 11 0
325 * | |
326 * index in 1 page of pointers
327 *
328 * 1st level - Root page table
329 *
330 * pp2d consists of PG_ROOT_NENTRIES entries, each being a pointer to
331 * second level entity, i.e. the page table directory (pdir).
332 */
333#define PG_ROOT_H 51
334#define PG_ROOT_L 39
335#define PG_ROOT_SIZE (1UL << PG_ROOT_L) /* va range mapped by pp2d */
336#define PG_ROOT_SHIFT PG_ROOT_L
337#define PG_ROOT_NUM (PG_ROOT_H - PG_ROOT_L + 1)
338#define PG_ROOT_MASK ((1 << PG_ROOT_NUM) - 1)
339#define PG_ROOT_IDX(va) ((va >> PG_ROOT_SHIFT) & PG_ROOT_MASK)
340#define PG_ROOT_NENTRIES (1 << PG_ROOT_NUM)
341#define PG_ROOT_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry **)) */
342
343/*
344 * 2nd level - page directory directory (pdir l1)
345 *
346 * pdir consists of PDIR_NENTRIES entries, each being a pointer to
347 * second level entity, i.e. the actual page table (ptbl).
348 */
349#define PDIR_L1_H (PG_ROOT_L-1)
350#define PDIR_L1_L 30
351#define PDIR_L1_NUM (PDIR_L1_H-PDIR_L1_L+1)
352#define PDIR_L1_SIZE (1 << PDIR_L1_L) /* va range mapped by pdir */
353#define PDIR_L1_MASK ((1<<PDIR_L1_NUM)-1)
354#define PDIR_L1_SHIFT PDIR_L1_L
355#define PDIR_L1_NENTRIES (1<<PDIR_L1_NUM)
356#define PDIR_L1_IDX(va) (((va) >> PDIR_L1_SHIFT) & PDIR_L1_MASK)
357#define PDIR_L1_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */
358#define PDIR_L1_PAGES ((PDIR_L1_NENTRIES * (1<<PDIR_L1_ENTRY_SHIFT)) / PAGE_SIZE)
359
360/*
361 * 3rd level - page table directory (pdir)
362 *
363 * pdir consists of PDIR_NENTRIES entries, each being a pointer to
364 * second level entity, i.e. the actual page table (ptbl).
365 */
366#define PDIR_H (PDIR_L1_L-1)
367#define PDIR_L 21
368#define PDIR_NUM (PDIR_H-PDIR_L+1)
369#define PDIR_SIZE (1 << PDIR_L) /* va range mapped by pdir */
370#define PDIR_MASK ((1<<PDIR_NUM)-1)
371#define PDIR_SHIFT PDIR_L
372#define PDIR_NENTRIES (1<<PDIR_NUM)
373#define PDIR_IDX(va) (((va) >> PDIR_SHIFT) & PDIR_MASK)
374#define PDIR_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */
375#define PDIR_PAGES ((PDIR_NENTRIES * (1<<PDIR_ENTRY_SHIFT)) / PAGE_SIZE)
376
377/*
378 * 4th level - page table (ptbl)
379 *
380 * Page table covers PTBL_NENTRIES page table entries. Page
381 * table entry (pte) is 64 bit wide and defines mapping
382 * for a single page.
383 */
384#define PTBL_H (PDIR_L-1)
385#define PTBL_L PAGE_SHIFT
386#define PTBL_NUM (PTBL_H-PTBL_L+1)
387#define PTBL_MASK ((1<<PTBL_NUM)-1)
388#define PTBL_SHIFT PTBL_L
389#define PTBL_SIZE PAGE_SIZE /* va range mapped by ptbl entry */
390#define PTBL_NENTRIES (1<<PTBL_NUM)
391#define PTBL_IDX(va) ((va >> PTBL_SHIFT) & PTBL_MASK)
392#define PTBL_ENTRY_SHIFT 3 /* log2 (sizeof (struct pte_entry)) */
393#define PTBL_PAGES ((PTBL_NENTRIES * (1<<PTBL_ENTRY_SHIFT)) / PAGE_SIZE)
394
395#else
396/*
397 * 1st level - page table directory (pdir)
398 *
399 * pdir consists of 1024 entries, each being a pointer to
400 * second level entity, i.e. the actual page table (ptbl).
401 */
402#define PDIR_SHIFT 22
403#define PDIR_SIZE (1 << PDIR_SHIFT) /* va range mapped by pdir */
404#define PDIR_MASK (~(PDIR_SIZE - 1))
405#define PDIR_NENTRIES 1024 /* number of page tables in pdir */
406
407/* Returns pdir entry number for given va */
408#define PDIR_IDX(va) ((va) >> PDIR_SHIFT)
409
410#define PDIR_ENTRY_SHIFT 2 /* entry size is 2^2 = 4 bytes */
411
412/*
413 * 2nd level - page table (ptbl)
414 *
415 * Page table covers 1024 page table entries. Page
416 * table entry (pte) is 32 bit wide and defines mapping
417 * for a single page.
418 */
419#define PTBL_SHIFT PAGE_SHIFT
420#define PTBL_SIZE PAGE_SIZE /* va range mapped by ptbl entry */
421#define PTBL_MASK ((PDIR_SIZE - 1) & ~((1 << PAGE_SHIFT) - 1))
422#define PTBL_NENTRIES 1024 /* number of pages mapped by ptbl */
423
424/* Returns ptbl entry number for given va */
425#define PTBL_IDX(va) (((va) & PTBL_MASK) >> PTBL_SHIFT)
426
427/* Size of ptbl in pages, 1024 entries, each sizeof(struct pte_entry). */
428#define PTBL_PAGES 2
429#define PTBL_ENTRY_SHIFT 3 /* entry size is 2^3 = 8 bytes */
430
431#endif
432#endif /* _MACHINE_PTE_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/ptrace.h created+42
......@@ -0,0 +1,42 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2014 Justin Hibbits
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_PTRACE_H_
33#define _MACHINE_PTRACE_H_
34
35#define __HAVE_PTRACE_MACHDEP
36
37#define PT_GETVRREGS (PT_FIRSTMACH + 0)
38#define PT_SETVRREGS (PT_FIRSTMACH + 1)
39#define PT_GETVSRREGS (PT_FIRSTMACH + 2)
40#define PT_SETVSRREGS (PT_FIRSTMACH + 3)
41
42#endif
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/reg.h created+87
......@@ -0,0 +1,87 @@
1/* $NetBSD: reg.h,v 1.4 2000/06/04 09:30:44 tsubai Exp $ */
2
3#ifndef _POWERPC_REG_H_
4#define _POWERPC_REG_H_
5
6#include <sys/_types.h>
7
8/* Must match struct trapframe */
9struct reg {
10 __register_t fixreg[32];
11 __register_t lr;
12 __register_t cr;
13 __register_t xer;
14 __register_t ctr;
15 __register_t pc;
16};
17
18struct fpreg {
19 double fpreg[32];
20 double fpscr;
21};
22
23/* Must match pcb.pcb_vec */
24struct vmxreg {
25 __uint32_t vr[32][4];
26 __uint32_t pad[2];
27 __uint32_t vrsave;
28 __uint32_t vscr;
29};
30
31struct dbreg {
32 unsigned int junk;
33};
34
35#ifdef __LP64__
36/* Must match struct trapframe */
37struct reg32 {
38 __int32_t fixreg[32];
39 __int32_t lr;
40 __int32_t cr;
41 __int32_t xer;
42 __int32_t ctr;
43 __int32_t pc;
44};
45
46struct fpreg32 {
47 struct fpreg data;
48};
49
50struct vmxreg32 {
51 struct vmxreg data;
52};
53
54struct dbreg32 {
55 struct dbreg data;
56};
57
58#define __HAVE_REG32
59#endif
60
61#ifdef _KERNEL
62/*
63 * XXX these interfaces are MI, so they should be declared in a MI place.
64 */
65int fill_regs(struct thread *, struct reg *);
66int set_regs(struct thread *, struct reg *);
67int fill_fpregs(struct thread *, struct fpreg *);
68int set_fpregs(struct thread *, struct fpreg *);
69int fill_dbregs(struct thread *, struct dbreg *);
70int set_dbregs(struct thread *, struct dbreg *);
71
72#ifdef COMPAT_FREEBSD32
73struct image_params;
74
75int fill_regs32(struct thread *, struct reg32 *);
76int set_regs32(struct thread *, struct reg32 *);
77void ppc32_setregs(struct thread *, struct image_params *, uintptr_t);
78
79#define fill_fpregs32(td, reg) fill_fpregs(td,(struct fpreg *)reg)
80#define set_fpregs32(td, reg) set_fpregs(td,(struct fpreg *)reg)
81#define fill_dbregs32(td, reg) fill_dbregs(td,(struct dbreg *)reg)
82#define set_dbregs32(td, reg) set_dbregs(td,(struct dbreg *)reg)
83#endif
84
85#endif
86
87#endif /* _POWERPC_REG_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/reloc.h created+30
......@@ -0,0 +1,30 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/resource.h created+51
......@@ -0,0 +1,51 @@
1/*-
2 * Copyright 1998 Massachusetts Institute of Technology
3 *
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose and without fee is hereby
6 * granted, provided that both the above copyright notice and this
7 * permission notice appear in all copies, that both the above
8 * copyright notice and this permission notice appear in all
9 * supporting documentation, and that the name of M.I.T. not be used
10 * in advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission. M.I.T. makes
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied
14 * warranty.
15 *
16 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
17 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_RESOURCE_H_
31#define _MACHINE_RESOURCE_H_ 1
32
33/*
34 * Definitions of resource types for Intel Architecture machines
35 * with support for legacy ISA devices and drivers.
36 */
37
38#define SYS_RES_IRQ 1 /* interrupt lines */
39#define SYS_RES_DRQ 2 /* isa dma lines */
40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */
42#define PCI_RES_BUS 5 /* PCI bus numbers */
43
44/*
45 * A powerpc-specific resource flag to request little-endian bus tags
46 * for a resource.
47 */
48
49#define RF_LITTLEENDIAN RF_SPARE1
50
51#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/rtas.h created+59
......@@ -0,0 +1,59 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2011 Nathan Whitehorn
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RTAS_H_
30#define _MACHINE_RTAS_H_
31
32#include <sys/types.h>
33#include <dev/ofw/openfirm.h>
34
35/*
36 * RTAS functions are defined by 32-bit integer tokens. These vary from
37 * system to system, and can be looked up from their standardized names
38 * using rtas_token_lookup(). If RTAS is not available, rtas_token_lookup()
39 * and rtas_call_method() return -1; this can be checked in advance using
40 * rtas_exists(). Otherwise, rtas_call_method() returns one of the RTAS
41 * status codes from the bottom of this file.
42 */
43
44int rtas_exists(void);
45int rtas_call_method(cell_t token, int nargs, int nreturns, ...);
46cell_t rtas_token_lookup(const char *method);
47
48/* RTAS Status Codes: see CHRP or PAPR specification */
49#define RTAS_OK 0
50#define RTAS_HW_ERROR -1
51#define RTAS_BUSY -2
52#define RTAS_PARAM_ERROR -3
53#define RTAS_STATE_CHANGE -7
54#define RTAS_VENDOR_BEGIN 9000
55#define RTAS_EXTENDED_DELAY 9900
56#define RTAS_ISOLATION_ERROR -9000
57#define RTAS_VENDOR_ERROR_BEGIN -9004
58
59#endif /* _MACHINE_RTAS_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/sdt_machdep.h created+12
......@@ -0,0 +1,12 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org>
5 */
6
7#ifndef _SYS_SDT_MACHDEP_H_
8#define _SYS_SDT_MACHDEP_H_
9
10#define _SDT_ASM_PATCH_INSTR "nop"
11
12#endif
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/setjmp.h created+27
......@@ -0,0 +1,27 @@
1/*-
2 * $NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $
3 */
4
5#ifndef _MACHINE_SETJMP_H_
6#define _MACHINE_SETJMP_H_
7
8#include <sys/cdefs.h>
9
10#ifdef _KERNEL
11#define _JBLEN 25 /* Kernel doesn't save FP and Altivec regs */
12#else
13#define _JBLEN 100
14#endif
15
16/*
17 * jmp_buf and sigjmp_buf are encapsulated in different structs to force
18 * compile-time diagnostics for mismatches. The structs are the same
19 * internally to avoid some run-time errors for mismatches.
20 */
21#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE
22typedef struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1];
23#endif
24
25typedef struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1];
26
27#endif /* !_MACHINE_SETJMP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/signal.h created+54
......@@ -0,0 +1,54 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $
34 */
35
36#ifndef _MACHINE_SIGNAL_H_
37#define _MACHINE_SIGNAL_H_
38
39#include <sys/cdefs.h>
40
41typedef int sig_atomic_t;
42
43#if __BSD_VISIBLE
44#include <machine/frame.h>
45
46struct sigcontext {
47 int sc_onstack; /* saved onstack flag */
48 int __sc_mask13; /* saved signal mask (old style) */
49 struct trapframe sc_frame; /* saved registers */
50 struct __sigset sc_mask; /* saved signal mask (new style) */
51};
52#endif
53
54#endif /* !_MACHINE_SIGNAL_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/slb.h created+92
......@@ -0,0 +1,92 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2009 Nathan Whitehorn
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_SLB_H_
29#define _MACHINE_SLB_H_
30
31/*
32 * Bit definitions for segment lookaside buffer entries.
33 *
34 * PowerPC Microprocessor Family: The Programming Environments for 64-bit
35 * Microprocessors, section 7.4.2.1
36 *
37 * Note that these bitmasks are relative to the values for one of the two
38 * values for slbmte, slbmfee, and slbmfev, not the internal SLB
39 * representation.
40 */
41
42#define SLBV_KS 0x0000000000000800UL /* Supervisor-state prot key */
43#define SLBV_KP 0x0000000000000400UL /* User-state prot key */
44#define SLBV_N 0x0000000000000200UL /* No-execute protection */
45#define SLBV_L 0x0000000000000100UL /* Large page selector */
46#define SLBV_CLASS 0x0000000000000080UL /* Class selector */
47#define SLBV_VSID_MASK 0xfffffffffffff000UL /* Virtual segment ID mask */
48#define SLBV_VSID_SHIFT 12
49
50/*
51 * Make a predictable 1:1 map from ESIDs to VSIDs for the kernel. Hash table
52 * coverage is increased by swizzling the ESID and multiplying by a prime
53 * number (0x13bb).
54 */
55#define KERNEL_VSID_BIT 0x0000001000000000UL /* Bit set in all kernel VSIDs */
56#define KERNEL_VSID(esid) ((((((uint64_t)esid << 8) | ((uint64_t)esid >> 28)) \
57 * 0x13bbUL) & (KERNEL_VSID_BIT - 1)) | \
58 KERNEL_VSID_BIT)
59
60#define SLBE_VALID 0x0000000008000000UL /* SLB entry valid */
61#define SLBE_INDEX_MASK 0x0000000000000fffUL /* SLB index mask*/
62#define SLBE_ESID_MASK 0xfffffffff0000000UL /* Effective segment ID mask */
63#define SLBE_ESID_SHIFT 28
64
65/*
66 * SLB page sizes encoding, as present in property ibm,segment-page-sizes
67 * of CPU device tree node.
68 *
69 * See LoPAPR: CPU Node Properties, section C.6.1.4.
70 */
71#define SLB_PGSZ_4K_4K 0
72
73/* Virtual real-mode VSID in LPARs */
74#define VSID_VRMA 0x1ffffff
75
76/*
77 * User segment for copyin/out
78 */
79#define USER_SLB_SLOT 0
80#define USER_SLB_SLBE (((USER_ADDR >> ADDR_SR_SHFT) << SLBE_ESID_SHIFT) | \
81 SLBE_VALID | USER_SLB_SLOT)
82
83struct slb {
84 uint64_t slbv;
85 uint64_t slbe;
86};
87
88struct pmap;
89void handle_kernel_slb_spill(int, register_t, register_t);
90int handle_user_slb_spill(struct pmap *pm, vm_offset_t addr);
91
92#endif /* !_MACHINE_SLB_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/smp.h created+64
......@@ -0,0 +1,64 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2008 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_SMP_H_
30#define _MACHINE_SMP_H_
31
32#ifdef _KERNEL
33
34#define IPI_AST 0
35#define IPI_PREEMPT 1
36#define IPI_RENDEZVOUS 2
37#define IPI_STOP 3
38#define IPI_STOP_HARD 3
39#define IPI_HARDCLOCK 4
40
41#ifndef LOCORE
42
43#include <machine/pcb.h>
44#include <sys/_cpuset.h>
45
46void ipi_all_but_self(int ipi);
47void ipi_cpu(int cpu, u_int ipi);
48void ipi_selected(cpuset_t cpus, int ipi);
49
50struct cpuref {
51 uintptr_t cr_hwref;
52 u_int cr_cpuid;
53 u_int cr_domain;
54};
55
56void pmap_cpu_bootstrap(int);
57void cpudep_ap_early_bootstrap(void);
58uintptr_t cpudep_ap_bootstrap(void);
59void cpudep_ap_setup(void);
60void machdep_ap_bootstrap(void);
61
62#endif /* !LOCORE */
63#endif /* _KERNEL */
64#endif /* !_MACHINE_SMP_H */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/spr.h created+868
......@@ -0,0 +1,868 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $NetBSD: spr.h,v 1.25 2002/08/14 15:38:40 matt Exp $
29 */
30#ifndef _POWERPC_SPR_H_
31#define _POWERPC_SPR_H_
32
33#ifndef _LOCORE
34#define mtspr(reg, val) \
35 __asm __volatile("mtspr %0,%1" : : "K"(reg), "r"(val))
36#define mfspr(reg) \
37 ( { register_t val; \
38 __asm __volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \
39 val; } )
40
41#ifndef __powerpc64__
42
43/* The following routines allow manipulation of the full 64-bit width
44 * of SPRs on 64 bit CPUs in bridge mode */
45
46#define mtspr64(reg,valhi,vallo,scratch) \
47 __asm __volatile(" \
48 mfmsr %0; \
49 insrdi %0,%5,1,0; \
50 mtmsrd %0; \
51 isync; \
52 \
53 sld %1,%1,%4; \
54 or %1,%1,%2; \
55 mtspr %3,%1; \
56 srd %1,%1,%4; \
57 \
58 clrldi %0,%0,1; \
59 mtmsrd %0; \
60 isync;" \
61 : "=r"(scratch), "=r"(valhi) : "r"(vallo), "K"(reg), "r"(32), "r"(1))
62
63#define mfspr64upper(reg,scratch) \
64 ( { register_t val; \
65 __asm __volatile(" \
66 mfmsr %0; \
67 insrdi %0,%4,1,0; \
68 mtmsrd %0; \
69 isync; \
70 \
71 mfspr %1,%2; \
72 srd %1,%1,%3; \
73 \
74 clrldi %0,%0,1; \
75 mtmsrd %0; \
76 isync;" \
77 : "=r"(scratch), "=r"(val) : "K"(reg), "r"(32), "r"(1)); \
78 val; } )
79
80#endif
81
82#endif /* _LOCORE */
83
84/*
85 * Special Purpose Register declarations.
86 *
87 * The first column in the comments indicates which PowerPC
88 * architectures the SPR is valid on - 4 for 4xx series,
89 * 6 for 6xx/7xx series and 8 for 8xx and 8xxx series.
90 */
91
92#define SPR_MQ 0x000 /* .6. 601 MQ register */
93#define SPR_XER 0x001 /* 468 Fixed Point Exception Register */
94#define SPR_DSCR 0x003 /* .6. Data Stream Control Register (Unprivileged) */
95#define SPR_RTCU_R 0x004 /* .6. 601 RTC Upper - Read */
96#define SPR_RTCL_R 0x005 /* .6. 601 RTC Lower - Read */
97#define SPR_LR 0x008 /* 468 Link Register */
98#define SPR_CTR 0x009 /* 468 Count Register */
99#define SPR_DSCRP 0x011 /* Data Stream Control Register (Privileged) */
100#define SPR_DSISR 0x012 /* .68 DSI exception source */
101#define DSISR_DIRECT 0x80000000 /* Direct-store error exception */
102#define DSISR_NOTFOUND 0x40000000 /* Translation not found */
103#define DSISR_PROTECT 0x08000000 /* Memory access not permitted */
104#define DSISR_INVRX 0x04000000 /* Reserve-indexed insn direct-store access */
105#define DSISR_STORE 0x02000000 /* Store operation */
106#define DSISR_DABR 0x00400000 /* DABR match */
107#define DSISR_SEGMENT 0x00200000 /* XXX; not in 6xx PEM */
108#define DSISR_EAR 0x00100000 /* eciwx/ecowx && EAR[E] == 0 */
109#define DSISR_MC_UE_DEFERRED 0x00008000 /* UE deferred error */
110#define DSISR_MC_UE_TABLEWALK 0x00004000 /* UE deferred error during tablewalk */
111#define DSISR_MC_DERAT_MULTIHIT 0x00000800 /* D-ERAT multi-hit */
112#define DSISR_MC_TLB_MULTIHIT 0x00000400 /* TLB multi-hit */
113#define DSISR_MC_TLBIE_ERR 0x00000200 /* TLBIE or TLBIEL programming error */
114#define DSISR_MC_SLB_PARITY 0x00000100 /* SLB parity error */
115#define DSISR_MC_SLB_MULTIHIT 0x00000080 /* SLB Multi-hit detected (D-side) */
116#define DSISR_MC_BAD_REAL_LD 0x00000040 /* Bad real address for load. */
117#define DSISR_MC_BAD_ADDR 0x00000020 /* Bad address for load or store tablewalk */
118#define SPR_DAR 0x013 /* .68 Data Address Register */
119#define SPR_RTCU_W 0x014 /* .6. 601 RTC Upper - Write */
120#define SPR_RTCL_W 0x015 /* .6. 601 RTC Lower - Write */
121#define SPR_DEC 0x016 /* .68 DECrementer register */
122#define SPR_SDR1 0x019 /* .68 Page table base address register */
123#define SPR_SRR0 0x01a /* 468 Save/Restore Register 0 */
124#define SPR_SRR1 0x01b /* 468 Save/Restore Register 1 */
125#define SRR1_ISI_PFAULT 0x40000000 /* ISI page not found */
126#define SRR1_ISI_NOEXECUTE 0x10000000 /* Memory marked no-execute */
127#define SRR1_ISI_PP 0x08000000 /* PP bits forbid access */
128#define SRR1_MCHK_DATA 0x00200000 /* Machine check data in DSISR */
129#define SRR1_MCHK_IFETCH_M 0x081c0000 /* Machine check instr fetch mask */
130#define SRR1_MCHK_IFETCH_SLBMH 0x000c0000 /* SLB multihit */
131#define SPR_CFAR 0x01c /* Come From Address Register */
132#define SPR_AMR 0x01d /* Authority Mask Register */
133
134#define SPR_PID 0x030 /* 4.. Process ID */
135
136#define SPR_DECAR 0x036 /* ..8 Decrementer auto reload */
137#define SPR_IAMR 0x03d /* Instr. Authority Mask Reg */
138
139#define SPR_EIE 0x050 /* ..8 Exception Interrupt ??? */
140#define SPR_EID 0x051 /* ..8 Exception Interrupt ??? */
141#define SPR_NRI 0x052 /* ..8 Exception Interrupt ??? */
142#define SPR_FSCR 0x099 /* Facility Status and Control Register */
143#define FSCR_IC_MASK 0xFF00000000000000ULL /* FSCR[0:7] is Interrupt Cause */
144#define FSCR_IC_FP 0x0000000000000000ULL /* FP unavailable */
145#define FSCR_IC_VSX 0x0100000000000000ULL /* VSX unavailable */
146#define FSCR_IC_DSCR 0x0200000000000000ULL /* Access to the DSCR at SPRs 3 or 17 */
147#define FSCR_IC_PM 0x0300000000000000ULL /* Read or write access of a Performance Monitor SPR in group A */
148#define FSCR_IC_BHRB 0x0400000000000000ULL /* Execution of a BHRB Instruction */
149#define FSCR_IC_HTM 0x0500000000000000ULL /* Access to a Transactional Memory */
150/* Reserved 0x0600000000000000ULL */
151#define FSCR_IC_EBB 0x0700000000000000ULL /* Access to Event-Based Branch */
152#define FSCR_IC_TAR 0x0800000000000000ULL /* Access to Target Address Register */
153#define FSCR_IC_STOP 0x0900000000000000ULL /* Access to the 'stop' instruction in privileged non-hypervisor state */
154#define FSCR_IC_MSG 0x0A00000000000000ULL /* Access to 'msgsndp' or 'msgclrp' instructions */
155#define FSCR_IC_LM 0x0A00000000000000ULL /* Access to load monitored facility */
156#define FSCR_IC_SCV 0x0C00000000000000ULL /* Execution of a 'scv' instruction */
157#define FSCR_SCV 0x0000000000001000 /* scv instruction available */
158#define FSCR_LM 0x0000000000000800 /* Load monitored facilities available */
159#define FSCR_MSGP 0x0000000000000400 /* msgsndp and SPRs available */
160#define FSCR_TAR 0x0000000000000100 /* TAR register available */
161#define FSCR_EBB 0x0000000000000080 /* Event-based branch available */
162#define FSCR_DSCR 0x0000000000000004 /* DSCR available in PR state */
163#define SPR_UAMOR 0x09d /* User Authority Mask Override Register */
164#define SPR_DPDES 0x0b0 /* .6. Directed Privileged Doorbell Exception State Register */
165#define SPR_HFSCR 0xbe /* Hypervisor Facility Status and Control Register */
166#define HFSCR_BHRB 0x0000000000000010 /* BHRB instructions */
167#define HFSCR_PM 0x0000000000000008 /* Performance monitor SPRs */
168#define HFSCR_VECVSX 0x0000000000000002 /* Vector and VSX facilities */
169#define HFSCR_FP 0x0000000000000001 /* Floating Point facility */
170#define SPR_USPRG0 0x100 /* 4.8 User SPR General 0 */
171#define SPR_VRSAVE 0x100 /* .6. AltiVec VRSAVE */
172#define SPR_SPRG0 0x110 /* 468 SPR General 0 */
173#define SPR_SPRG1 0x111 /* 468 SPR General 1 */
174#define SPR_SPRG2 0x112 /* 468 SPR General 2 */
175#define SPR_SPRG3 0x113 /* 468 SPR General 3 */
176#define SPR_SPRG4 0x114 /* 4.8 SPR General 4 */
177#define SPR_SPRG5 0x115 /* 4.8 SPR General 5 */
178#define SPR_SPRG6 0x116 /* 4.8 SPR General 6 */
179#define SPR_SPRG7 0x117 /* 4.8 SPR General 7 */
180#define SPR_SCOMC 0x114 /* ... SCOM Address Register (970) */
181#define SPR_SCOMD 0x115 /* ... SCOM Data Register (970) */
182#define SPR_ASR 0x118 /* ... Address Space Register (PPC64) */
183#define SPR_EAR 0x11a /* .68 External Access Register */
184#define SPR_PVR 0x11f /* 468 Processor Version Register */
185#define MPC601 0x0001
186#define MPC603 0x0003
187#define MPC604 0x0004
188#define MPC602 0x0005
189#define MPC603e 0x0006
190#define MPC603ev 0x0007
191#define MPC750 0x0008
192#define MPC750CL 0x7000 /* Nintendo Wii's Broadway */
193#define MPC604ev 0x0009
194#define MPC7400 0x000c
195#define MPC620 0x0014
196#define IBM403 0x0020
197#define IBM401A1 0x0021
198#define IBM401B2 0x0022
199#define IBM401C2 0x0023
200#define IBM401D2 0x0024
201#define IBM401E2 0x0025
202#define IBM401F2 0x0026
203#define IBM401G2 0x0027
204#define IBMRS64II 0x0033
205#define IBMRS64III 0x0034
206#define IBMPOWER4 0x0035
207#define IBMRS64III_2 0x0036
208#define IBMRS64IV 0x0037
209#define IBMPOWER4PLUS 0x0038
210#define IBM970 0x0039
211#define IBMPOWER5 0x003a
212#define IBMPOWER5PLUS 0x003b
213#define IBM970FX 0x003c
214#define IBMPOWER6 0x003e
215#define IBMPOWER7 0x003f
216#define IBMPOWER3 0x0040
217#define IBMPOWER3PLUS 0x0041
218#define IBM970MP 0x0044
219#define IBM970GX 0x0045
220#define IBMPOWERPCA2 0x0049
221#define IBMPOWER7PLUS 0x004a
222#define IBMPOWER8E 0x004b
223#define IBMPOWER8NVL 0x004c
224#define IBMPOWER8 0x004d
225#define IBMPOWER9 0x004e
226#define MPC860 0x0050
227#define IBMCELLBE 0x0070
228#define IBMPOWER10 0x0080
229#define MPC8240 0x0081
230#define IBMPOWER11 0x0082
231#define PA6T 0x0090
232#define IBM405GP 0x4011
233#define IBM405L 0x4161
234#define IBM750FX 0x7000
235#define MPC745X_P(v) ((v & 0xFFF8) == 0x8000)
236#define MPC7450 0x8000
237#define MPC7455 0x8001
238#define MPC7457 0x8002
239#define MPC7447A 0x8003
240#define MPC7448 0x8004
241#define MPC7410 0x800c
242#define MPC8245 0x8081
243#define FSL_E500v1 0x8020
244#define FSL_E500v2 0x8021
245#define FSL_E500mc 0x8023
246#define FSL_E5500 0x8024
247#define FSL_E6500 0x8040
248#define FSL_E300C1 0x8083
249#define FSL_E300C2 0x8084
250#define FSL_E300C3 0x8085
251#define FSL_E300C4 0x8086
252
253#define LPCR_PECE_WAKESET (LPCR_PECE_EXT | LPCR_PECE_DECR | LPCR_PECE_ME)
254
255#define SPR_DBSR 0x130 /* ..8 Debug Status Register */
256#define DBSR_IDE 0x80000000 /* Imprecise debug event. */
257#define DBSR_UDE 0x40000000 /* Unconditional debug event. */
258#define DBSR_MRR 0x30000000 /* Most recent Reset (mask). */
259#define DBSR_ICMP 0x08000000 /* Instr. complete debug event. */
260#define DBSR_BRT 0x04000000 /* Branch taken debug event. */
261#define DBSR_IRPT 0x02000000 /* Interrupt taken debug event. */
262#define DBSR_TRAP 0x01000000 /* Trap instr. debug event. */
263#define DBSR_IAC1 0x00800000 /* Instr. address compare #1. */
264#define DBSR_IAC2 0x00400000 /* Instr. address compare #2. */
265#define DBSR_IAC3 0x00200000 /* Instr. address compare #3. */
266#define DBSR_IAC4 0x00100000 /* Instr. address compare #4. */
267#define DBSR_DAC1R 0x00080000 /* Data addr. read compare #1. */
268#define DBSR_DAC1W 0x00040000 /* Data addr. write compare #1. */
269#define DBSR_DAC2R 0x00020000 /* Data addr. read compare #2. */
270#define DBSR_DAC2W 0x00010000 /* Data addr. write compare #2. */
271#define DBSR_RET 0x00008000 /* Return debug event. */
272#define SPR_EPCR 0x133
273#define EPCR_EXTGS 0x80000000
274#define EPCR_DTLBGS 0x40000000
275#define EPCR_ITLBGS 0x20000000
276#define EPCR_DSIGS 0x10000000
277#define EPCR_ISIGS 0x08000000
278#define EPCR_DUVGS 0x04000000
279#define EPCR_ICM 0x02000000
280#define EPCR_GICMGS 0x01000000
281#define EPCR_DGTMI 0x00800000
282#define EPCR_DMIUH 0x00400000
283#define EPCR_PMGS 0x00200000
284#define SPR_DBCR0 0x134 /* ..8 Debug Control Register 0 */
285#define SPR_DBCR1 0x135 /* ..8 Debug Control Register 1 */
286#define SPR_DBCR2 0x136 /* ..8 Debug Control Register 2 */
287#define SPR_IAC1 0x138 /* ..8 Instruction Address Compare 1 */
288#define SPR_IAC2 0x139 /* ..8 Instruction Address Compare 2 */
289#define SPR_IAC3 0x13a /* ..8 Instruction Address Compare 3 */
290#define SPR_IAC4 0x13b /* ..8 Instruction Address Compare 4 */
291
292#define SPR_HSRR0 0x13a
293#define SPR_HSRR1 0x13b
294#define SPR_DAC1 0x13c /* ..8 Data Address Compare 1 */
295#define SPR_DAC2 0x13d /* ..8 Data Address Compare 2 */
296#define SPR_DVC1 0x13e /* ..8 Data Value Compare 1 */
297#define SPR_DVC2 0x13f /* ..8 Data Value Compare 2 */
298
299#define SPR_LPCR 0x13e /* .6. Logical Partitioning Control */
300#define LPCR_LPES 0x008 /* Bit 60 */
301#define LPCR_HVICE 0x002 /* Hypervisor Virtualization Interrupt (Arch 3.0) */
302#define LPCR_ILE (1ULL << 25) /* Interrupt Little-Endian (ISA 2.07) */
303#define LPCR_UPRT (1ULL << 22) /* Use Process Table (ISA 3) */
304#define LPCR_HR (1ULL << 20) /* Host Radix mode */
305#define LPCR_PECE_DRBL (1ULL << 16) /* Directed Privileged Doorbell */
306#define LPCR_PECE_HDRBL (1ULL << 15) /* Directed Hypervisor Doorbell */
307#define LPCR_PECE_EXT (1ULL << 14) /* External exceptions */
308#define LPCR_PECE_DECR (1ULL << 13) /* Decrementer exceptions */
309#define LPCR_PECE_ME (1ULL << 12) /* Machine Check and Hypervisor */
310 /* Maintenance exceptions */
311#define SPR_LPID 0x13f /* .6. Logical Partitioning Control */
312#define SPR_HMER 0x150 /* Hypervisor Maintenance Exception Register */
313#define SPR_HMEER 0x151 /* Hypervisor Maintenance Exception Enable Register */
314#define SPR_AMOR 0x15d /* Authority Mask Override Register */
315
316#define SPR_TIR 0x1be /* .6. Thread Identification Register */
317#define SPR_PTCR 0x1d0 /* Partition Table Control Register */
318#define SPR_SPEFSCR 0x200 /* ..8 Signal Processing Engine FSCR. */
319#define SPEFSCR_SOVH 0x80000000
320#define SPEFSCR_OVH 0x40000000
321#define SPEFSCR_FGH 0x20000000
322#define SPEFSCR_FXH 0x10000000
323#define SPEFSCR_FINVH 0x08000000
324#define SPEFSCR_FDBZH 0x04000000
325#define SPEFSCR_FUNFH 0x02000000
326#define SPEFSCR_FOVFH 0x01000000
327#define SPEFSCR_FINXS 0x00200000
328#define SPEFSCR_FINVS 0x00100000
329#define SPEFSCR_FDBZS 0x00080000
330#define SPEFSCR_FUNFS 0x00040000
331#define SPEFSCR_FOVFS 0x00020000
332#define SPEFSCR_SOV 0x00008000
333#define SPEFSCR_OV 0x00004000
334#define SPEFSCR_FG 0x00002000
335#define SPEFSCR_FX 0x00001000
336#define SPEFSCR_FINV 0x00000800
337#define SPEFSCR_FDBZ 0x00000400
338#define SPEFSCR_FUNF 0x00000200
339#define SPEFSCR_FOVF 0x00000100
340#define SPEFSCR_FINXE 0x00000040
341#define SPEFSCR_FINVE 0x00000020
342#define SPEFSCR_FDBZE 0x00000010
343#define SPEFSCR_FUNFE 0x00000008
344#define SPEFSCR_FOVFE 0x00000004
345#define SPEFSCR_FRMC_M 0x00000003
346#define SPEFSCR_DFLT (SPEFSCR_FINVE | SPEFSCR_FDBZE | \
347 SPEFSCR_FUNFE | SPEFSCR_FOVFE)
348#define SPR_IBAT0U 0x210 /* .6. Instruction BAT Reg 0 Upper */
349#define SPR_IBAT0L 0x211 /* .6. Instruction BAT Reg 0 Lower */
350#define SPR_IBAT1U 0x212 /* .6. Instruction BAT Reg 1 Upper */
351#define SPR_IBAT1L 0x213 /* .6. Instruction BAT Reg 1 Lower */
352#define SPR_IBAT2U 0x214 /* .6. Instruction BAT Reg 2 Upper */
353#define SPR_IBAT2L 0x215 /* .6. Instruction BAT Reg 2 Lower */
354#define SPR_IBAT3U 0x216 /* .6. Instruction BAT Reg 3 Upper */
355#define SPR_IBAT3L 0x217 /* .6. Instruction BAT Reg 3 Lower */
356#define SPR_DBAT0U 0x218 /* .6. Data BAT Reg 0 Upper */
357#define SPR_DBAT0L 0x219 /* .6. Data BAT Reg 0 Lower */
358#define SPR_DBAT1U 0x21a /* .6. Data BAT Reg 1 Upper */
359#define SPR_DBAT1L 0x21b /* .6. Data BAT Reg 1 Lower */
360#define SPR_DBAT2U 0x21c /* .6. Data BAT Reg 2 Upper */
361#define SPR_DBAT2L 0x21d /* .6. Data BAT Reg 2 Lower */
362#define SPR_DBAT3U 0x21e /* .6. Data BAT Reg 3 Upper */
363#define SPR_DBAT3L 0x21f /* .6. Data BAT Reg 3 Lower */
364#define SPR_IBAT4U 0x230 /* .6. Instruction BAT Reg 4 Upper */
365#define SPR_DBCR3 0x231 /* ..8 Debug Control Register 3 */
366#define SPR_IBAT4L 0x231 /* .6. Instruction BAT Reg 4 Lower */
367#define SPR_IBAT5U 0x232 /* .6. Instruction BAT Reg 5 Upper */
368#define SPR_IBAT5L 0x233 /* .6. Instruction BAT Reg 5 Lower */
369#define SPR_DBCR4 0x233 /* ..8 Debug Control Register 4 */
370#define SPR_IBAT6U 0x234 /* .6. Instruction BAT Reg 6 Upper */
371#define SPR_DBCR5 0x234 /* ..8 Debug Control Register 5 */
372#define SPR_IBAT6L 0x235 /* .6. Instruction BAT Reg 6 Lower */
373#define SPR_IAC5 0x235 /* ..8 Instruction Address Compare 5 */
374#define SPR_IBAT7U 0x236 /* .6. Instruction BAT Reg 7 Upper */
375#define SPR_IAC6 0x236 /* ..8 Instruction Address Compare 6 */
376#define SPR_IBAT7L 0x237 /* .6. Instruction BAT Reg 7 Lower */
377#define SPR_IAC7 0x237 /* ..8 Instruction Address Compare 7 */
378#define SPR_DBAT4U 0x238 /* .6. Data BAT Reg 4 Upper */
379#define SPR_IAC8 0x238 /* ..8 Instruction Address Compare 8 */
380#define SPR_DBAT4L 0x239 /* .6. Data BAT Reg 4 Lower */
381#define SPR_DBAT5U 0x23a /* .6. Data BAT Reg 5 Upper */
382#define SPR_DBAT5L 0x23b /* .6. Data BAT Reg 5 Lower */
383#define SPR_DBAT6U 0x23c /* .6. Data BAT Reg 6 Upper */
384#define SPR_DBAT6L 0x23d /* .6. Data BAT Reg 6 Lower */
385#define SPR_DBAT7U 0x23e /* .6. Data BAT Reg 7 Upper */
386#define SPR_DBAT7L 0x23f /* .6. Data BAT Reg 7 Lower */
387#define SPR_DBCR6 0x25b /* ..8 Debug Control Register 6 */
388#define SPR_SPRG8 0x25c /* ..8 SPR General 8 */
389
390#define SPR_MMCRA 0x312 /* ... Monitor Mode Control Register A */
391#define SPR_PMC1 0x313 /* ... PMC 1 */
392#define SPR_PMC2 0x314 /* ... PMC 2 */
393#define SPR_PMC3 0x315 /* ... PMC 3 */
394#define SPR_PMC4 0x316 /* ... PMC 4 */
395#define SPR_PMC5 0x317 /* ... PMC 5 */
396#define SPR_PMC6 0x318 /* ... PMC 6 */
397#define SPR_PMC7 0x319 /* ... PMC 7 */
398#define SPR_PMC8 0x31a /* ... PMC 8 */
399
400#define SPR_MMCR0 0x31b /* ... Monitor Mode Control Register 0 */
401#define SPR_MMCR0_FC 0x80000000 /* Freeze counters */
402#define SPR_MMCR0_FCS 0x40000000 /* Freeze counters in supervisor mode */
403#define SPR_MMCR0_FCP 0x20000000 /* Freeze counters in user mode */
404#define SPR_MMCR0_FCM1 0x10000000 /* Freeze counters when mark=1 */
405#define SPR_MMCR0_FCM0 0x08000000 /* Freeze counters when mark=0 */
406#define SPR_MMCR0_PMXE 0x04000000 /* Enable PM interrupt */
407#define SPR_MMCR0_PMAE 0x04000000 /* PM Alert Enable */
408#define SPR_MMCR0_FCECE 0x02000000 /* Freeze counters after event */
409#define SPR_MMCR0_TBSEL_15 0x01800000 /* Count bit 15 of TBL */
410#define SPR_MMCR0_TBSEL_19 0x01000000 /* Count bit 19 of TBL */
411#define SPR_MMCR0_TBSEL_23 0x00800000 /* Count bit 23 of TBL */
412#define SPR_MMCR0_TBSEL_31 0x00000000 /* Count bit 31 of TBL */
413#define SPR_MMCR0_TBEE 0x00400000 /* Time-base event enable */
414#define SPR_MMCR0_THRESHOLD(x) ((x) << 16) /* Threshold value */
415#define SPR_MMCR0_PMC1CE 0x00008000 /* PMC1 condition enable */
416#define SPR_MMCR0_PMCNCE 0x00004000 /* PMCn condition enable */
417#define SPR_MMCR0_TRIGGER 0x00002000 /* Trigger */
418#define SPR_MMCR0_PMAO 0x00000080 /* PM Alert Occurred */
419#define SPR_MMCR0_FCPC 0x00001000 /* Freeze Counters in Problem State Cond. */
420#define SPR_MMCR0_FC56 0x00000010 /* Freeze Counters 5-6 */
421#define SPR_MMCR0_PMC1SEL(x) ((x) << 8) /* PMC1 selector (970) */
422#define SPR_MMCR0_PMC2SEL(x) ((x) << 1) /* PMC2 selector (970) */
423#define SPR_MMCR0_74XX_PMC1SEL(x) (((x) & 0x3f) << 6) /* PMC1 selector */
424#define SPR_MMCR0_74XX_PMC2SEL(x) (((x) & 0x3f) << 0) /* PMC2 selector */
425
426#define SPR_MMCR1 0x31e /* ... Monitor Mode Control Register 1 */
427#define SPR_MMCR1_PMC3SEL(x) (((x) & 0x1f) << 27) /* PMC 3 selector */
428#define SPR_MMCR1_PMC4SEL(x) (((x) & 0x1f) << 22) /* PMC 4 selector */
429#define SPR_MMCR1_PMC5SEL(x) (((x) & 0x1f) << 17) /* PMC 5 selector */
430#define SPR_MMCR1_PMC6SEL(x) (((x) & 0x1f) << 12) /* PMC 6 selector */
431#define SPR_MMCR1_74XX_PMC6SEL(x) (((x) & 0x3f) << 11) /* PMC 6 selector */
432#define SPR_MMCR1_PMC7SEL(x) (((x) & 0x1f) << 7) /* PMC 7 selector */
433#define SPR_MMCR1_PMC8SEL(x) (((x) & 0x1f) << 2) /* PMC 8 selector */
434#define SPR_MMCR1_P8_PMCSEL_ALL 0xffffffff
435#define SPR_MMCR1_P8_PMCNSEL_MASK(n) (0xffUL << ((3-(n))*8))
436#define SPR_MMCR1_P8_PMCNSEL(n, v) ((unsigned long)(v) << ((3-(n))*8))
437
438#define SPR_MMCR2 0x311
439#define SPR_MMCR2_CNBIT(n, bit) ((bit) << (((5 - (n)) * 9) + 10))
440#define SPR_MMCR2_FCNS(n) SPR_MMCR2_CNBIT(n, 0x100ULL)
441#define SPR_MMCR2_FCNP0(n) SPR_MMCR2_CNBIT(n, 0x080ULL)
442#define SPR_MMCR2_FCNP1(n) SPR_MMCR2_CNBIT(n, 0x040ULL)
443#define SPR_MMCR2_FCNM1(n) SPR_MMCR2_CNBIT(n, 0x020ULL)
444#define SPR_MMCR2_FCNM0(n) SPR_MMCR2_CNBIT(n, 0x010ULL)
445#define SPR_MMCR2_FCNWAIT(n) SPR_MMCR2_CNBIT(n, 0x008ULL)
446#define SPR_MMCR2_FCNH(n) SPR_MMCR2_CNBIT(n, 0x004ULL)
447/* Freeze Counter N in Hypervisor/Supervisor/Problem states */
448#define SPR_MMCR2_FCNHSP(n) \
449 (SPR_MMCR2_FCNS(n) | SPR_MMCR2_FCNP0(n) | \
450 SPR_MMCR2_FCNP1(n) | SPR_MMCR2_FCNH(n))
451
452#define SPR_M_TWB 0x31c /* ..8 MMU tablewalk base */
453#define M_TWB_L1TB 0xfffff000 /* level-1 translation base */
454#define M_TWB_L1INDX 0x00000ffc /* level-1 index */
455#define SPR_MD_TWC 0x31d /* ..8 DMMU tablewalk control */
456#define SPR_MD_RPN 0x31e /* ..8 DMMU real (phys) page number */
457#define SPR_MD_TW 0x31f /* ..8 MMU tablewalk scratch */
458#define SPR_BESCRS 0x320 /* .6. Branch Event Status and Control Set Register */
459#define SPR_BESCRSU 0x321 /* .6. Branch Event Status and Control Set Register (upper 32-bit) */
460#define SPR_BESCRR 0x322 /* .6. Branch Event Status and Control Reset Register */
461#define SPR_BESCRRU 0x323 /* .6. Branch Event Status and Control Register (upper 32-bit) */
462#define SPR_EBBHR 0x324 /* .6. Event-based Branch Handler Register */
463#define SPR_EBBRR 0x325 /* .6. Event-based Branch Return Register */
464#define SPR_BESCR 0x326 /* .6. Branch Event Status and Control Register */
465#define SPR_LMRR 0x32d /* .6. Load Monitored Region Register */
466#define SPR_LMSER 0x32e /* .6. Load Monitored Section Enable Register */
467#define SPR_TAR 0x32f /* .6. Branch Target Address Register */
468#define SPR_MI_CAM 0x330 /* ..8 IMMU CAM entry read */
469#define SPR_MI_RAM0 0x331 /* ..8 IMMU RAM entry read reg 0 */
470#define SPR_MI_RAM1 0x332 /* ..8 IMMU RAM entry read reg 1 */
471#define SPR_MD_CAM 0x338 /* ..8 IMMU CAM entry read */
472#define SPR_MD_RAM0 0x339 /* ..8 IMMU RAM entry read reg 0 */
473#define SPR_MD_RAM1 0x33a /* ..8 IMMU RAM entry read reg 1 */
474#define SPR_PSSCR 0x357 /* Processor Stop Status and Control Register (ISA 3.0) */
475#define PSSCR_PLS_S 60
476#define PSSCR_PLS_M (0xf << PSSCR_PLS_S)
477#define PSSCR_SD (1 << 22)
478#define PSSCR_ESL (1 << 21)
479#define PSSCR_EC (1 << 20)
480#define PSSCR_PSLL_S 16
481#define PSSCR_PSLL_M (0xf << PSSCR_PSLL_S)
482#define PSSCR_TR_S 8
483#define PSSCR_TR_M (0x3 << PSSCR_TR_S)
484#define PSSCR_MTL_S 4
485#define PSSCR_MTL_M (0xf << PSSCR_MTL_S)
486#define PSSCR_RL_S 0
487#define PSSCR_RL_M (0xf << PSSCR_RL_S)
488#define SPR_PMCR 0x374 /* Processor Management Control Register */
489#define SPR_UMMCR2 0x3a0 /* .6. User Monitor Mode Control Register 2 */
490#define SPR_UMMCR0 0x3a8 /* .6. User Monitor Mode Control Register 0 */
491#define SPR_USIA 0x3ab /* .6. User Sampled Instruction Address */
492#define SPR_UMMCR1 0x3ac /* .6. User Monitor Mode Control Register 1 */
493#define SPR_MMCR2_74XX 0x3b0 /* .6. Monitor Mode Control Register 2 */
494#define SPR_MMCR2_74XX_THRESHMULT_32 0x80000000 /* Multiply MMCR0 threshold by 32 */
495#define SPR_MMCR2_74XX_THRESHMULT_2 0x00000000 /* Multiply MMCR0 threshold by 2 */
496#define SPR_PMC5_74XX 0x3b1 /* .6. Performance Counter Register 5 */
497#define SPR_PMC6_74XX 0x3b2 /* .6. Performance Counter Register 6 */
498#define SPR_MMCR0_74XX 0x3b8 /* .6. Monitor Mode Control Register 0 */
499#define SPR_PMC1_74XX 0x3b9 /* .6. Performance Counter Register 1 */
500#define SPR_PMC2_74XX 0x3ba /* .6. Performance Counter Register 2 */
501#define SPR_SIA 0x3bb /* .6. Sampled Instruction Address */
502#define SPR_MMCR1_74XX 0x3bc /* .6. Monitor Mode Control Register 2 */
503
504#define SPR_PMC3_74XX 0x3bd /* .6. Performance Counter Register 3 */
505#define SPR_PMC4_74XX 0x3be /* .6. Performance Counter Register 4 */
506#define SPR_DMISS 0x3d0 /* .68 Data TLB Miss Address Register */
507#define SPR_DCMP 0x3d1 /* .68 Data TLB Compare Register */
508#define SPR_HASH1 0x3d2 /* .68 Primary Hash Address Register */
509#define SPR_HASH2 0x3d3 /* .68 Secondary Hash Address Register */
510#define SPR_IMISS 0x3d4 /* .68 Instruction TLB Miss Address Register */
511#define SPR_TLBMISS 0x3d4 /* .6. TLB Miss Address Register */
512#define SPR_DEAR 0x03d /* ..8 Data Exception Address Register */
513#define SPR_ICMP 0x3d5 /* .68 Instruction TLB Compare Register */
514#define SPR_PTEHI 0x3d5 /* .6. Instruction TLB Compare Register */
515#define SPR_RPA 0x3d6 /* .68 Required Physical Address Register */
516#define SPR_PTELO 0x3d6 /* .6. Required Physical Address Register */
517
518#define SPR_TSR 0x150 /* ..8 Timer Status Register */
519#define SPR_TCR 0x154 /* ..8 Timer Control Register */
520
521#define TSR_ENW 0x80000000 /* Enable Next Watchdog */
522#define TSR_WIS 0x40000000 /* Watchdog Interrupt Status */
523#define TSR_WRS_MASK 0x30000000 /* Watchdog Reset Status */
524#define TSR_WRS_NONE 0x00000000 /* No watchdog reset has occurred */
525#define TSR_WRS_CORE 0x10000000 /* Core reset was forced by the watchdog */
526#define TSR_WRS_CHIP 0x20000000 /* Chip reset was forced by the watchdog */
527#define TSR_WRS_SYSTEM 0x30000000 /* System reset was forced by the watchdog */
528#define TSR_PIS 0x08000000 /* PIT Interrupt Status */
529#define TSR_DIS 0x08000000 /* Decrementer Interrupt Status */
530#define TSR_FIS 0x04000000 /* FIT Interrupt Status */
531
532#define TCR_WP_MASK 0xc0000000 /* Watchdog Period mask */
533#define TCR_WP_2_17 0x00000000 /* 2**17 clocks */
534#define TCR_WP_2_21 0x40000000 /* 2**21 clocks */
535#define TCR_WP_2_25 0x80000000 /* 2**25 clocks */
536#define TCR_WP_2_29 0xc0000000 /* 2**29 clocks */
537#define TCR_WRC_MASK 0x30000000 /* Watchdog Reset Control mask */
538#define TCR_WRC_NONE 0x00000000 /* No watchdog reset */
539#define TCR_WRC_CORE 0x10000000 /* Core reset */
540#define TCR_WRC_CHIP 0x20000000 /* Chip reset */
541#define TCR_WRC_SYSTEM 0x30000000 /* System reset */
542#define TCR_WIE 0x08000000 /* Watchdog Interrupt Enable */
543#define TCR_PIE 0x04000000 /* PIT Interrupt Enable */
544#define TCR_DIE 0x04000000 /* Pecrementer Interrupt Enable */
545#define TCR_FP_MASK 0x03000000 /* FIT Period */
546#define TCR_FP_2_9 0x00000000 /* 2**9 clocks */
547#define TCR_FP_2_13 0x01000000 /* 2**13 clocks */
548#define TCR_FP_2_17 0x02000000 /* 2**17 clocks */
549#define TCR_FP_2_21 0x03000000 /* 2**21 clocks */
550#define TCR_FIE 0x00800000 /* FIT Interrupt Enable */
551#define TCR_ARE 0x00400000 /* Auto Reload Enable */
552
553#define SPR_HID0 0x3f0 /* ..8 Hardware Implementation Register 0 */
554#define SPR_HID1 0x3f1 /* ..8 Hardware Implementation Register 1 */
555#define SPR_HID2 0x3f3 /* ..8 Hardware Implementation Register 2 */
556#define SPR_HID4 0x3f4 /* ..8 Hardware Implementation Register 4 */
557#define SPR_HID5 0x3f6 /* ..8 Hardware Implementation Register 5 */
558#define SPR_HID6 0x3f9 /* ..8 Hardware Implementation Register 6 */
559
560#define SPR_CELL_TSRL 0x380 /* ... Cell BE Thread Status Register */
561#define SPR_CELL_TSCR 0x399 /* ... Cell BE Thread Switch Register */
562
563#if defined(AIM)
564#define SPR_PIR 0x3ff /* .6. Processor Identification Register */
565#elif defined(BOOKE)
566#define SPR_PIR 0x11e /* ..8 Processor Identification Register */
567#endif
568
569#define DBCR0_EDM 0x80000000 /* External Debug Mode */
570#define DBCR0_IDM 0x40000000 /* Internal Debug Mode */
571#define DBCR0_RST_MASK 0x30000000 /* ReSeT */
572#define DBCR0_RST_NONE 0x00000000 /* No action */
573#define DBCR0_RST_CORE 0x10000000 /* Core reset */
574#define DBCR0_RST_CHIP 0x20000000 /* Chip reset */
575#define DBCR0_RST_SYSTEM 0x30000000 /* System reset */
576#define DBCR0_IC 0x08000000 /* Instruction Completion debug event */
577#define DBCR0_BT 0x04000000 /* Branch Taken debug event */
578#define DBCR0_EDE 0x02000000 /* Exception Debug Event */
579#define DBCR0_TDE 0x01000000 /* Trap Debug Event */
580#define DBCR0_IA1 0x00800000 /* IAC (Instruction Address Compare) 1 debug event */
581#define DBCR0_IA2 0x00400000 /* IAC 2 debug event */
582#define DBCR0_IA12 0x00200000 /* Instruction Address Range Compare 1-2 */
583#define DBCR0_IA12X 0x00100000 /* IA12 eXclusive */
584#define DBCR0_IA3 0x00080000 /* IAC 3 debug event */
585#define DBCR0_IA4 0x00040000 /* IAC 4 debug event */
586#define DBCR0_IA34 0x00020000 /* Instruction Address Range Compare 3-4 */
587#define DBCR0_IA34X 0x00010000 /* IA34 eXclusive */
588#define DBCR0_IA12T 0x00008000 /* Instruction Address Range Compare 1-2 range Toggle */
589#define DBCR0_IA34T 0x00004000 /* Instruction Address Range Compare 3-4 range Toggle */
590#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */
591
592#define SPR_IABR 0x3f2 /* ..8 Instruction Address Breakpoint Register 0 */
593#define SPR_DABR 0x3f5 /* .6. Data Address Breakpoint Register */
594#define SPR_MSSCR0 0x3f6 /* .6. Memory SubSystem Control Register */
595#define MSSCR0_SHDEN 0x80000000 /* 0: Shared-state enable */
596#define MSSCR0_SHDPEN3 0x40000000 /* 1: ~SHD[01] signal enable in MEI mode */
597#define MSSCR0_L1INTVEN 0x38000000 /* 2-4: L1 data cache ~HIT intervention enable */
598#define MSSCR0_L2INTVEN 0x07000000 /* 5-7: L2 data cache ~HIT intervention enable*/
599#define MSSCR0_DL1HWF 0x00800000 /* 8: L1 data cache hardware flush */
600#define MSSCR0_MBO 0x00400000 /* 9: must be one */
601#define MSSCR0_EMODE 0x00200000 /* 10: MPX bus mode (read-only) */
602#define MSSCR0_ABD 0x00100000 /* 11: address bus driven (read-only) */
603#define MSSCR0_MBZ 0x000fffff /* 12-31: must be zero */
604#define MSSCR0_L2PFE 0x00000003 /* 30-31: L2 prefetch enable */
605#define SPR_MSSSR0 0x3f7 /* .6. Memory Subsystem Status Register (MPC745x) */
606#define MSSSR0_L2TAG 0x00040000 /* 13: L2 tag parity error */
607#define MSSSR0_L2DAT 0x00020000 /* 14: L2 data parity error */
608#define MSSSR0_L3TAG 0x00010000 /* 15: L3 tag parity error */
609#define MSSSR0_L3DAT 0x00008000 /* 16: L3 data parity error */
610#define MSSSR0_APE 0x00004000 /* 17: Address parity error */
611#define MSSSR0_DPE 0x00002000 /* 18: Data parity error */
612#define MSSSR0_TEA 0x00001000 /* 19: Bus transfer error acknowledge */
613#define SPR_LDSTCR 0x3f8 /* .6. Load/Store Control Register */
614#define SPR_L2PM 0x3f8 /* .6. L2 Private Memory Control Register */
615#define SPR_L2CR 0x3f9 /* .6. L2 Control Register */
616#define L2CR_L2E 0x80000000 /* 0: L2 enable */
617#define L2CR_L2PE 0x40000000 /* 1: L2 data parity enable */
618#define L2CR_L2SIZ 0x30000000 /* 2-3: L2 size */
619#define L2SIZ_2M 0x00000000
620#define L2SIZ_256K 0x10000000
621#define L2SIZ_512K 0x20000000
622#define L2SIZ_1M 0x30000000
623#define L2CR_L2CLK 0x0e000000 /* 4-6: L2 clock ratio */
624#define L2CLK_DIS 0x00000000 /* disable L2 clock */
625#define L2CLK_10 0x02000000 /* core clock / 1 */
626#define L2CLK_15 0x04000000 /* / 1.5 */
627#define L2CLK_20 0x08000000 /* / 2 */
628#define L2CLK_25 0x0a000000 /* / 2.5 */
629#define L2CLK_30 0x0c000000 /* / 3 */
630#define L2CR_L2RAM 0x01800000 /* 7-8: L2 RAM type */
631#define L2RAM_FLOWTHRU_BURST 0x00000000
632#define L2RAM_PIPELINE_BURST 0x01000000
633#define L2RAM_PIPELINE_LATE 0x01800000
634#define L2CR_L2DO 0x00400000 /* 9: L2 data-only.
635 Setting this bit disables instruction
636 caching. */
637#define L2CR_L2I 0x00200000 /* 10: L2 global invalidate. */
638#define L2CR_L2IO_7450 0x00010000 /* 11: L2 instruction-only (MPC745x). */
639#define L2CR_L2CTL 0x00100000 /* 11: L2 RAM control (ZZ enable).
640 Enables automatic operation of the
641 L2ZZ (low-power mode) signal. */
642#define L2CR_L2WT 0x00080000 /* 12: L2 write-through. */
643#define L2CR_L2TS 0x00040000 /* 13: L2 test support. */
644#define L2CR_L2OH 0x00030000 /* 14-15: L2 output hold. */
645#define L2CR_L2DO_7450 0x00010000 /* 15: L2 data-only (MPC745x). */
646#define L2CR_L2SL 0x00008000 /* 16: L2 DLL slow. */
647#define L2CR_L2DF 0x00004000 /* 17: L2 differential clock. */
648#define L2CR_L2BYP 0x00002000 /* 18: L2 DLL bypass. */
649#define L2CR_L2FA 0x00001000 /* 19: L2 flush assist (for software flush). */
650#define L2CR_L2HWF 0x00000800 /* 20: L2 hardware flush. */
651#define L2CR_L2IO 0x00000400 /* 21: L2 instruction-only. */
652#define L2CR_L2CLKSTP 0x00000200 /* 22: L2 clock stop. */
653#define L2CR_L2DRO 0x00000100 /* 23: L2DLL rollover checkstop enable. */
654#define L2CR_L2IP 0x00000001 /* 31: L2 global invalidate in */
655 /* progress (read only). */
656#define SPR_L3CR 0x3fa /* .6. L3 Control Register */
657#define L3CR_L3E 0x80000000 /* 0: L3 enable */
658#define L3CR_L3PE 0x40000000 /* 1: L3 data parity enable */
659#define L3CR_L3APE 0x20000000
660#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */
661#define L3CR_L3CLKEN 0x08000000 /* 4: Enables L3_CLK[0:1] */
662#define L3CR_L3CLK 0x03800000
663#define L3CR_L3IO 0x00400000
664#define L3CR_L3CLKEXT 0x00200000
665#define L3CR_L3CKSPEXT 0x00100000
666#define L3CR_L3OH1 0x00080000
667#define L3CR_L3SPO 0x00040000
668#define L3CR_L3CKSP 0x00030000
669#define L3CR_L3PSP 0x0000e000
670#define L3CR_L3REP 0x00001000
671#define L3CR_L3HWF 0x00000800
672#define L3CR_L3I 0x00000400 /* 21: L3 global invalidate */
673#define L3CR_L3RT 0x00000300
674#define L3CR_L3NIRCA 0x00000080
675#define L3CR_L3DO 0x00000040
676#define L3CR_PMEN 0x00000004
677#define L3CR_PMSIZ 0x00000003
678
679#define SPR_THRM1 0x3fc /* .6. Thermal Management Register */
680#define SPR_THRM2 0x3fd /* .6. Thermal Management Register */
681#define SPR_THRM_TIN 0x80000000 /* Thermal interrupt bit (RO) */
682#define SPR_THRM_TIV 0x40000000 /* Thermal interrupt valid (RO) */
683#define SPR_THRM_THRESHOLD(x) ((x) << 23) /* Thermal sensor threshold */
684#define SPR_THRM_TID 0x00000004 /* Thermal interrupt direction */
685#define SPR_THRM_TIE 0x00000002 /* Thermal interrupt enable */
686#define SPR_THRM_VALID 0x00000001 /* Valid bit */
687#define SPR_THRM3 0x3fe /* .6. Thermal Management Register */
688#define SPR_THRM_TIMER(x) ((x) << 1) /* Sampling interval timer */
689#define SPR_THRM_ENABLE 0x00000001 /* TAU Enable */
690#define SPR_FPECR 0x3fe /* .6. Floating-Point Exception Cause Register */
691
692/* Time Base Register declarations */
693#define TBR_TBL 0x10c /* 468 Time Base Lower - read */
694#define TBR_TBU 0x10d /* 468 Time Base Upper - read */
695#define TBR_TBWL 0x11c /* 468 Time Base Lower - supervisor, write */
696#define TBR_TBWU 0x11d /* 468 Time Base Upper - supervisor, write */
697
698/* Performance counter declarations */
699#define PMC_OVERFLOW 0x80000000 /* Counter has overflowed */
700
701/* The first five countable [non-]events are common to many PMC's */
702#define PMCN_NONE 0 /* Count nothing */
703#define PMCN_CYCLES 1 /* Processor cycles */
704#define PMCN_ICOMP 2 /* Instructions completed */
705#define PMCN_TBLTRANS 3 /* TBL bit transitions */
706#define PCMN_IDISPATCH 4 /* Instructions dispatched */
707
708/* Similar things for the 970 PMC direct counters */
709#define PMC970N_NONE 0x8 /* Count nothing */
710#define PMC970N_CYCLES 0xf /* Processor cycles */
711#define PMC970N_ICOMP 0x9 /* Instructions completed */
712
713#if defined(BOOKE)
714
715#define SPR_MCARU 0x239 /* ..8 Machine Check Address register upper bits */
716#define SPR_MCSR 0x23c /* ..8 Machine Check Syndrome register */
717#define MCSR_MCP 0x80000000 /* Machine check input signal to core */
718#define MCSR_L2MMU_MHIT 0x08000000 /* L2 MMU simultaneous hit */
719#define MCSR_NMI 0x00100000 /* Non-maskable interrupt */
720#define MCSR_MAV 0x00080000 /* MCAR address valid */
721#define MCSR_MEA 0x00040000 /* MCAR effective address */
722#define MCSR_IF 0x00010000 /* Instruction fetch error report */
723#define MCSR_LD 0x00008000 /* Load instruction error report */
724#define MCSR_ST 0x00004000 /* Store instruction error report */
725#define MCSR_LDG 0x00002000 /* Guarded load instruction error report */
726#define MCSR_TLBSYNC 0x00000002 /* Simultaneous TLBSYNC detected */
727#define SPR_MCAR 0x23d /* ..8 Machine Check Address register */
728
729#define SPR_ESR 0x003e /* ..8 Exception Syndrome Register */
730#define ESR_PIL 0x08000000 /* Program interrupt - illegal */
731#define ESR_PPR 0x04000000 /* Program interrupt - privileged */
732#define ESR_PTR 0x02000000 /* Program interrupt - trap */
733#define ESR_ST 0x00800000 /* Store operation */
734#define ESR_DLK 0x00200000 /* Data storage, D cache locking */
735#define ESR_ILK 0x00100000 /* Data storage, I cache locking */
736#define ESR_BO 0x00020000 /* Data/instruction storage, byte ordering */
737#define ESR_SPE 0x00000080 /* SPE exception bit */
738
739#define SPR_CSRR0 0x03a /* ..8 58 Critical SRR0 */
740#define SPR_CSRR1 0x03b /* ..8 59 Critical SRR1 */
741#define SPR_MCSRR0 0x23a /* ..8 570 Machine check SRR0 */
742#define SPR_MCSRR1 0x23b /* ..8 571 Machine check SRR1 */
743#define SPR_DSRR0 0x23e /* ..8 574 Debug SRR0<E.ED> */
744#define SPR_DSRR1 0x23f /* ..8 575 Debug SRR1<E.ED> */
745
746#define SPR_MMUCSR0 0x3f4 /* ..8 1012 MMU Control and Status Register 0 */
747#define MMUCSR0_L2TLB0_FI 0x04 /* TLB0 flash invalidate */
748#define MMUCSR0_L2TLB1_FI 0x02 /* TLB1 flash invalidate */
749
750#define SPR_SVR 0x3ff /* ..8 1023 System Version Register */
751#define SVR_MPC8533 0x8034
752#define SVR_MPC8533E 0x803c
753#define SVR_MPC8541 0x8072
754#define SVR_MPC8541E 0x807a
755#define SVR_MPC8548 0x8031
756#define SVR_MPC8548E 0x8039
757#define SVR_MPC8555 0x8071
758#define SVR_MPC8555E 0x8079
759#define SVR_MPC8572 0x80e0
760#define SVR_MPC8572E 0x80e8
761#define SVR_P1011 0x80e5
762#define SVR_P1011E 0x80ed
763#define SVR_P1013 0x80e7
764#define SVR_P1013E 0x80ef
765#define SVR_P1020 0x80e4
766#define SVR_P1020E 0x80ec
767#define SVR_P1022 0x80e6
768#define SVR_P1022E 0x80ee
769#define SVR_P2010 0x80e3
770#define SVR_P2010E 0x80eb
771#define SVR_P2020 0x80e2
772#define SVR_P2020E 0x80ea
773#define SVR_P2041 0x8210
774#define SVR_P2041E 0x8218
775#define SVR_P3041 0x8211
776#define SVR_P3041E 0x8219
777#define SVR_P4040 0x8200
778#define SVR_P4040E 0x8208
779#define SVR_P4080 0x8201
780#define SVR_P4080E 0x8209
781#define SVR_P5010 0x8221
782#define SVR_P5010E 0x8229
783#define SVR_P5020 0x8220
784#define SVR_P5020E 0x8228
785#define SVR_P5021 0x8205
786#define SVR_P5021E 0x820d
787#define SVR_P5040 0x8204
788#define SVR_P5040E 0x820c
789#define SVR_VER(svr) (((svr) >> 16) & 0xffff)
790
791#define SPR_PID0 0x030 /* ..8 Process ID Register 0 */
792#define SPR_PID1 0x279 /* ..8 Process ID Register 1 */
793#define SPR_PID2 0x27a /* ..8 Process ID Register 2 */
794
795#define SPR_TLB0CFG 0x2B0 /* ..8 TLB 0 Config Register */
796#define SPR_TLB1CFG 0x2B1 /* ..8 TLB 1 Config Register */
797#define TLBCFG_ASSOC_MASK 0xff000000 /* Associativity of TLB */
798#define TLBCFG_ASSOC_SHIFT 24
799#define TLBCFG_NENTRY_MASK 0x00000fff /* Number of entries in TLB */
800
801#define SPR_IVPR 0x03f /* ..8 Interrupt Vector Prefix Register */
802#define SPR_IVOR0 0x190 /* ..8 Critical input */
803#define SPR_IVOR1 0x191 /* ..8 Machine check */
804#define SPR_IVOR2 0x192
805#define SPR_IVOR3 0x193
806#define SPR_IVOR4 0x194
807#define SPR_IVOR5 0x195
808#define SPR_IVOR6 0x196
809#define SPR_IVOR7 0x197
810#define SPR_IVOR8 0x198
811#define SPR_IVOR9 0x199
812#define SPR_IVOR10 0x19a
813#define SPR_IVOR11 0x19b
814#define SPR_IVOR12 0x19c
815#define SPR_IVOR13 0x19d
816#define SPR_IVOR14 0x19e
817#define SPR_IVOR15 0x19f
818#define SPR_IVOR32 0x210
819#define SPR_IVOR33 0x211
820#define SPR_IVOR34 0x212
821#define SPR_IVOR35 0x213
822
823#define SPR_MAS0 0x270 /* ..8 MMU Assist Register 0 Book-E/e500 */
824#define SPR_MAS1 0x271 /* ..8 MMU Assist Register 1 Book-E/e500 */
825#define SPR_MAS2 0x272 /* ..8 MMU Assist Register 2 Book-E/e500 */
826#define SPR_MAS3 0x273 /* ..8 MMU Assist Register 3 Book-E/e500 */
827#define SPR_MAS4 0x274 /* ..8 MMU Assist Register 4 Book-E/e500 */
828#define SPR_MAS5 0x275 /* ..8 MMU Assist Register 5 Book-E */
829#define SPR_MAS6 0x276 /* ..8 MMU Assist Register 6 Book-E/e500 */
830#define SPR_MAS7 0x3B0 /* ..8 MMU Assist Register 7 Book-E/e500 */
831#define SPR_MAS8 0x155 /* ..8 MMU Assist Register 8 Book-E/e500 */
832
833#define SPR_L1CFG0 0x203 /* ..8 L1 cache configuration register 0 */
834#define SPR_L1CFG1 0x204 /* ..8 L1 cache configuration register 1 */
835
836#define SPR_CCR1 0x378
837#define CCR1_L2COBE 0x00000040
838
839#define DCR_L2DCDCRAI 0x0000 /* L2 D-Cache DCR Address Pointer */
840#define DCR_L2DCDCRDI 0x0001 /* L2 D-Cache DCR Data Indirect */
841#define DCR_L2CR0 0x00 /* L2 Cache Configuration Register 0 */
842#define L2CR0_AS 0x30000000
843
844#define SPR_L1CSR0 0x3F2 /* ..8 L1 Cache Control and Status Register 0 */
845#define L1CSR0_DCPE 0x00010000 /* Data Cache Parity Enable */
846#define L1CSR0_DCLFR 0x00000100 /* Data Cache Lock Bits Flash Reset */
847#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */
848#define L1CSR0_DCE 0x00000001 /* Data Cache Enable */
849#define SPR_L1CSR1 0x3F3 /* ..8 L1 Cache Control and Status Register 1 */
850#define L1CSR1_ICPE 0x00010000 /* Instruction Cache Parity Enable */
851#define L1CSR1_ICUL 0x00000400 /* Instr Cache Unable to Lock */
852#define L1CSR1_ICLFR 0x00000100 /* Instruction Cache Lock Bits Flash Reset */
853#define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */
854#define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */
855
856#define SPR_L2CFG0 0x207 /* ..8 L2 Configuration Register 0 */
857#define SPR_L2CSR0 0x3F9 /* ..8 L2 Cache Control and Status Register 0 */
858#define L2CSR0_L2E 0x80000000 /* L2 Cache Enable */
859#define L2CSR0_L2PE 0x40000000 /* L2 Cache Parity Enable */
860#define L2CSR0_L2FI 0x00200000 /* L2 Cache Flash Invalidate */
861#define L2CSR0_L2LFC 0x00000400 /* L2 Cache Lock Flags Clear */
862
863#define SPR_BUCSR 0x3F5 /* ..8 Branch Unit Control and Status Register */
864#define BUCSR_BPEN 0x00000001 /* Branch Prediction Enable */
865#define BUCSR_BBFI 0x00000200 /* Branch Buffer Flash Invalidate */
866
867#endif /* BOOKE */
868#endif /* !_POWERPC_SPR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/sr.h created+62
......@@ -0,0 +1,62 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (C) 2002 Benno Rice.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE_SR_H_
29#define _MACHINE_SR_H_
30
31/*
32 * Bit definitions for segment registers.
33 *
34 * PowerPC Microprocessor Family: The Programming Environments for 32-bit
35 * Microprocessors, section 2.3.5
36 */
37
38#define SR_TYPE 0x80000000 /* Type selector */
39#define SR_KS 0x40000000 /* Supervisor-state protection key */
40#define SR_KP 0x20000000 /* User-state protection key */
41#define SR_N 0x10000000 /* No-execute protection */
42#define SR_VSID_MASK 0x00ffffff /* Virtual Segment ID mask */
43
44/* Kernel segment register usage */
45#define USER_SR 12
46#define KERNEL_SR 13
47#define KERNEL2_SR 14
48#define KERNEL3_SR 15
49#define KERNEL_VSIDBITS 0xfffffUL
50#define KERNEL_SEGMENT (0xfffff0 + KERNEL_SR)
51#define KERNEL2_SEGMENT (0xfffff0 + KERNEL2_SR)
52#define EMPTY_SEGMENT 0xfffff0
53#ifdef __powerpc64__
54#define USER_ADDR 0xc00ffffff0000000UL
55#else
56#define USER_ADDR ((uintptr_t)USER_SR << ADDR_SR_SHFT)
57#endif
58#define SEGMENT_LENGTH 0x10000000UL
59#define SEGMENT_INVMASK 0x0fffffffUL
60#define SEGMENT_MASK ~SEGMENT_INVMASK
61
62#endif /* !_MACHINE_SR_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/stack.h created+54
......@@ -0,0 +1,54 @@
1/*-
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26
27#ifndef _MACHINE_STACK_H_
28#define _MACHINE_STACK_H_
29
30extern int trapexit[];
31extern int asttrapexit[];
32extern int end[];
33
34#ifdef _SYS_PROC_H_
35
36#include <machine/pcb.h>
37
38/* Get the current kernel thread stack usage. */
39#define GET_STACK_USAGE(total, used) do { \
40 struct thread *td = curthread; \
41 (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
42 (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
43} while (0)
44
45static __inline bool
46kstack_contains(struct thread *td, vm_offset_t va, size_t len)
47{
48 return (va >= td->td_kstack && va + len >= va &&
49 va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
50 sizeof(struct pcb));
51}
52#endif /* _SYS_PROC_H_ */
53
54#endif /* !_MACHINE_STACK_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/sysarch.h created+43
......@@ -0,0 +1,43 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1993 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _MACHINE_SYSARCH_H_
33#define _MACHINE_SYSARCH_H_
34
35#ifndef _KERNEL
36#include <sys/cdefs.h>
37
38__BEGIN_DECLS
39int sysarch(int, void *);
40__END_DECLS
41#endif
42
43#endif /* !_MACHINE_SYSARCH_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/tlb.h created+181
......@@ -0,0 +1,181 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (C) 2006-2012 Semihalf.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
21 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_TLB_H_
31#define _MACHINE_TLB_H_
32
33#if defined(BOOKE_E500)
34
35/* PowerPC E500 MAS registers */
36#define MAS0_TLBSEL(x) ((x << 28) & 0x10000000)
37#define MAS0_ESEL(x) ((x << 16) & 0x003F0000)
38
39#define MAS0_TLBSEL1 0x10000000
40#define MAS0_TLBSEL0 0x00000000
41#define MAS0_ESEL_TLB1MASK 0x000F0000
42#define MAS0_ESEL_TLB0MASK 0x00030000
43#define MAS0_ESEL_SHIFT 16
44#define MAS0_NV_MASK 0x00000003
45#define MAS0_NV_SHIFT 0
46
47#define MAS1_VALID 0x80000000
48#define MAS1_IPROT 0x40000000
49#define MAS1_TID_MASK 0x00FF0000
50#define MAS1_TID_SHIFT 16
51#define MAS1_TS_MASK 0x00001000
52#define MAS1_TS_SHIFT 12
53#define MAS1_TSIZE_MASK 0x00000F00
54#define MAS1_TSIZE_SHIFT 8
55
56#define TLB_SIZE_4K 1
57#define TLB_SIZE_16K 2
58#define TLB_SIZE_64K 3
59#define TLB_SIZE_256K 4
60#define TLB_SIZE_1M 5
61#define TLB_SIZE_4M 6
62#define TLB_SIZE_16M 7
63#define TLB_SIZE_64M 8
64#define TLB_SIZE_256M 9
65#define TLB_SIZE_1G 10
66#define TLB_SIZE_4G 11
67
68#ifdef __powerpc64__
69#define MAS2_EPN_MASK 0xFFFFFFFFFFFFF000UL
70#else
71#define MAS2_EPN_MASK 0xFFFFF000
72#endif
73#define MAS2_EPN_SHIFT 12
74#define MAS2_X0 0x00000040
75#define MAS2_X1 0x00000020
76#define MAS2_W 0x00000010
77#define MAS2_I 0x00000008
78#define MAS2_M 0x00000004
79#define MAS2_G 0x00000002
80#define MAS2_E 0x00000001
81#define MAS2_WIMGE_MASK 0x0000007F
82
83#define MAS3_RPN 0xFFFFF000
84#define MAS3_RPN_SHIFT 12
85#define MAS3_U0 0x00000200
86#define MAS3_U1 0x00000100
87#define MAS3_U2 0x00000080
88#define MAS3_U3 0x00000040
89#define MAS3_UX 0x00000020
90#define MAS3_SX 0x00000010
91#define MAS3_UW 0x00000008
92#define MAS3_SW 0x00000004
93#define MAS3_UR 0x00000002
94#define MAS3_SR 0x00000001
95
96#define MAS4_TLBSELD1 0x10000000
97#define MAS4_TLBSELD0 0x00000000
98#define MAS4_TIDSELD_MASK 0x00030000
99#define MAS4_TIDSELD_SHIFT 16
100#define MAS4_TSIZED_MASK 0x00000F00
101#define MAS4_TSIZED_SHIFT 8
102#define MAS4_X0D 0x00000040
103#define MAS4_X1D 0x00000020
104#define MAS4_WD 0x00000010
105#define MAS4_ID 0x00000008
106#define MAS4_MD 0x00000004
107#define MAS4_GD 0x00000002
108#define MAS4_ED 0x00000001
109
110#define MAS6_SPID0_MASK 0x00FF0000
111#define MAS6_SPID0_SHIFT 16
112#define MAS6_SAS 0x00000001
113
114#define MAS7_RPN 0x0000000F
115
116#define MAS1_GETTID(mas1) (((mas1) & MAS1_TID_MASK) >> MAS1_TID_SHIFT)
117
118#define MAS2_TLB0_ENTRY_IDX_MASK 0x0007f000
119#define MAS2_TLB0_ENTRY_IDX_SHIFT 12
120
121/*
122 * Maximum number of TLB1 entries used for a permanent mapping of kernel
123 * region (kernel image plus statically allocated data).
124 */
125#define KERNEL_REGION_MAX_TLB_ENTRIES 4
126
127/*
128 * Use MAS2_X0 to mark entries which will be copied
129 * to AP CPUs during SMP bootstrap. As result entries
130 * marked with _TLB_ENTRY_SHARED will be shared by all CPUs.
131 */
132#define _TLB_ENTRY_SHARED (MAS2_X0) /* XXX under SMP? */
133#define _TLB_ENTRY_IO (MAS2_I | MAS2_G)
134#define _TLB_ENTRY_MEM (MAS2_M)
135
136#define TLB1_MAX_ENTRIES 64
137
138#if !defined(LOCORE)
139typedef struct tlb_entry {
140 vm_paddr_t phys;
141 vm_offset_t virt;
142 vm_size_t size;
143 uint32_t mas1;
144#ifdef __powerpc64__
145 uint64_t mas2;
146#else
147 uint32_t mas2;
148#endif
149 uint32_t mas3;
150 uint32_t mas7;
151} tlb_entry_t;
152
153void tlb1_inval_entry(unsigned int);
154void tlb1_init(void);
155#endif /* !LOCORE */
156
157#endif /* BOOKE_E500 */
158
159#define TID_KERNEL 0 /* TLB TID to use for kernel (shared) translations */
160#define TID_KRESERVED 1 /* Number of TIDs reserved for kernel */
161#define TID_URESERVED 0 /* Number of TIDs reserved for user */
162#define TID_MIN (TID_KRESERVED + TID_URESERVED)
163#define TID_MAX 255
164#define TID_NONE -1
165
166#define TLB_UNLOCKED 0
167
168#if !defined(LOCORE)
169
170typedef int tlbtid_t;
171
172struct pmap;
173
174void tlb_lock(uintptr_t *);
175void tlb_unlock(uintptr_t *);
176void tlb1_ap_prep(void);
177int tlb1_set_entry(vm_offset_t, vm_paddr_t, vm_size_t, uint32_t);
178
179#endif /* !LOCORE */
180
181#endif /* _MACHINE_TLB_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/tls.h created+66
......@@ -0,0 +1,66 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright 2004 by Peter Grehan. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_TLS_H_
31#define _MACHINE_TLS_H_
32
33#include <sys/_tls_variant_i.h>
34
35#define TLS_DTV_OFFSET 0x8000
36#define TLS_TCB_ALIGN TLS_TCB_SIZE
37#define TLS_TP_OFFSET 0x7000
38
39static __inline void
40_tcb_set(struct tcb *tcb)
41{
42#ifdef __powerpc64__
43 __asm __volatile("mr 13,%0" ::
44 "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE));
45#else
46 __asm __volatile("mr 2,%0" ::
47 "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE));
48#endif
49}
50
51static __inline struct tcb *
52_tcb_get(void)
53{
54 struct tcb *tcb;
55
56#ifdef __powerpc64__
57 __asm __volatile("addi %0,13,%1" : "=r" (tcb) :
58 "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE)));
59#else
60 __asm __volatile("addi %0,2,%1" : "=r" (tcb) :
61 "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE)));
62#endif
63 return (tcb);
64}
65
66#endif /* !_MACHINE_TLS_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/trap.h created+160
......@@ -0,0 +1,160 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: trap.h,v 1.7 2002/02/22 13:51:40 kleink Exp $
34 */
35
36#ifndef _POWERPC_TRAP_H_
37#define _POWERPC_TRAP_H_
38
39#define EXC_RSVD 0x0000 /* Reserved */
40#define EXC_RST 0x0100 /* Reset; all but IBM4xx */
41#define EXC_MCHK 0x0200 /* Machine Check */
42#define EXC_DSI 0x0300 /* Data Storage Interrupt */
43#define EXC_DSE 0x0380 /* Data Segment Interrupt */
44#define EXC_ISI 0x0400 /* Instruction Storage Interrupt */
45#define EXC_ISE 0x0480 /* Instruction Segment Interrupt */
46#define EXC_EXI 0x0500 /* External Interrupt */
47#define EXC_ALI 0x0600 /* Alignment Interrupt */
48#define EXC_PGM 0x0700 /* Program Interrupt */
49#define EXC_FPU 0x0800 /* Floating-point Unavailable */
50#define EXC_DECR 0x0900 /* Decrementer Interrupt */
51#define EXC_SC 0x0c00 /* System Call */
52#define EXC_TRC 0x0d00 /* Trace */
53#define EXC_FPA 0x0e00 /* Floating-point Assist */
54
55/* The following is only available on the 601: */
56#define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */
57
58/* The following are only available on 970(G5): */
59#define EXC_VECAST_G5 0x1700 /* AltiVec Assist */
60
61/* The following are only available on 7400(G4): */
62#define EXC_VEC 0x0f20 /* AltiVec Unavailable */
63#define EXC_VECAST_G4 0x1600 /* AltiVec Assist */
64
65/* The following are only available on 604/750/7400: */
66#define EXC_PERF 0x0f00 /* Performance Monitoring */
67#define EXC_BPT 0x1300 /* Instruction Breakpoint */
68#define EXC_SMI 0x1400 /* System Managment Interrupt */
69
70/* The following are only available on 750/7400: */
71#define EXC_THRM 0x1700 /* Thermal Management Interrupt */
72
73/* And these are only on the 603: */
74#define EXC_IMISS 0x1000 /* Instruction translation miss */
75#define EXC_DLMISS 0x1100 /* Data load translation miss */
76#define EXC_DSMISS 0x1200 /* Data store translation miss */
77
78/* Power ISA 2.06+: */
79#define EXC_HDSI 0x0e00 /* Hypervisor Data Storage */
80#define EXC_HISI 0x0e20 /* Hypervisor Instruction Storage */
81#define EXC_HEA 0x0e40 /* Hypervisor Emulation Assistance */
82#define EXC_HMI 0x0e60 /* Hypervisor Maintenance */
83#define EXC_VSX 0x0f40 /* VSX Unavailable */
84
85/* Power ISA 2.07+: */
86#define EXC_FAC 0x0f60 /* Facility Unavailable */
87#define EXC_HFAC 0x0f80 /* Hypervisor Facility Unavailable */
88
89/* Power ISA 3.0+: */
90#define EXC_HVI 0x0ea0 /* Hypervisor Virtualization */
91
92/* The following are available on 4xx and 85xx */
93#define EXC_CRIT 0x0100 /* Critical Input Interrupt */
94#define EXC_PIT 0x1000 /* Programmable Interval Timer */
95#define EXC_FIT 0x1010 /* Fixed Interval Timer */
96#define EXC_WDOG 0x1020 /* Watchdog Timer */
97#define EXC_DTMISS 0x1100 /* Data TLB Miss */
98#define EXC_ITMISS 0x1200 /* Instruction TLB Miss */
99#define EXC_APU 0x1300 /* Auxiliary Processing Unit */
100#define EXC_DEBUG 0x2f10 /* Debug trap */
101#define EXC_VECAST_E 0x2f20 /* Altivec Assist (Book-E) */
102#define EXC_SPFPD 0x2f30 /* SPE Floating-point Data */
103#define EXC_SPFPR 0x2f40 /* SPE Floating-point Round */
104
105/* POWER8 */
106#define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */
107
108#define EXC_LAST 0x2f00 /* Last possible exception vector */
109
110#define EXC_AST 0x3000 /* Fake AST vector */
111
112/* Trap was in user mode */
113#define EXC_USER 0x10000
114
115/*
116 * EXC_ALI sets bits in the DSISR and DAR to provide enough
117 * information to recover from the unaligned access without needing to
118 * parse the offending instruction. This includes certain bits of the
119 * opcode, and information about what registers are used. The opcode
120 * indicator values below come from Appendix F of Book III of "The
121 * PowerPC Architecture".
122 */
123
124#define EXC_ALI_OPCODE_INDICATOR(dsisr) ((dsisr >> 10) & 0x7f)
125#define EXC_ALI_LFD 0x09
126#define EXC_ALI_STFD 0x0b
127
128/* Macros to extract register information */
129#define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */
130#define EXC_ALI_RA(dsisr) (dsisr & 0x1f)
131#define EXC_ALI_INST_RST(instr) ((instr >> 21) & 0x1f)
132
133/*
134 * SRR1 bits for program exception traps. These identify what caused
135 * the program exception. See section 6.5.9 of the Power ISA Version
136 * 2.05.
137 */
138
139#define EXC_PGM_FPENABLED (1UL << 20)
140#define EXC_PGM_ILLEGAL (1UL << 19)
141#define EXC_PGM_PRIV (1UL << 18)
142#define EXC_PGM_TRAP (1UL << 17)
143
144/* DTrace trap opcode. */
145#define EXC_DTRACE 0x7ffff808
146
147/* Magic pointer to store TOC base and other info for trap handlers on ppc64 */
148#define TRAP_ENTRY 0x1e8
149#define TRAP_GENTRAP 0x1f0
150#define TRAP_TOCBASE 0x1f8
151
152#ifndef LOCORE
153struct trapframe;
154struct thread;
155extern int (*hmi_handler)(struct trapframe *);
156void trap(struct trapframe *);
157int ppc_instr_emulate(struct trapframe *, struct thread *);
158#endif
159
160#endif /* _POWERPC_TRAP_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/ucontext.h created+93
......@@ -0,0 +1,93 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $
34 */
35
36#ifndef _MACHINE_UCONTEXT_H_
37#define _MACHINE_UCONTEXT_H_
38
39typedef struct __mcontext {
40 int mc_vers;
41 int mc_flags;
42#define _MC_FP_VALID 0x01
43#define _MC_AV_VALID 0x02
44#define _MC_VS_VALID 0x04
45 int mc_onstack; /* saved onstack flag */
46 int mc_len; /* sizeof(__mcontext) */
47 __uint64_t mc_avec[32*2]; /* vector register file */
48 __uint32_t mc_av[2];
49 __register_t mc_frame[42];
50 __uint64_t mc_fpreg[33];
51 __uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */
52} mcontext_t __aligned(16);
53
54#if defined(_KERNEL) && defined(__powerpc64__)
55typedef struct __mcontext32 {
56 int mc_vers;
57 int mc_flags;
58#define _MC_FP_VALID 0x01
59#define _MC_AV_VALID 0x02
60#define _MC_VS_VALID 0x04
61 int mc_onstack; /* saved onstack flag */
62 int mc_len; /* sizeof(__mcontext) */
63 uint64_t mc_avec[32*2]; /* vector register file */
64 uint32_t mc_av[2];
65 uint32_t mc_frame[42];
66 uint64_t mc_fpreg[33];
67 uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */
68} mcontext32_t __aligned(16);
69#endif
70
71/* GPRs and supervisor-level regs */
72#define mc_gpr mc_frame
73#define mc_lr mc_frame[32]
74#define mc_cr mc_frame[33]
75#define mc_xer mc_frame[34]
76#define mc_ctr mc_frame[35]
77#define mc_srr0 mc_frame[36]
78#define mc_srr1 mc_frame[37]
79#define mc_exc mc_frame[38]
80#define mc_dar mc_frame[39]
81#define mc_dsisr mc_frame[40]
82
83/* floating-point state */
84#define mc_fpscr mc_fpreg[32]
85
86/* altivec state */
87#define mc_vscr mc_av[0]
88#define mc_vrsave mc_av[1]
89
90#define _MC_VERSION 0x1
91#define _MC_VERSION_KSE 0xee /* partial ucontext for libpthread */
92
93#endif /* !_MACHINE_UCONTEXT_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/vdso.h created+43
......@@ -0,0 +1,43 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright 2012 Konstantin Belousov <kib@FreeBSD.ORG>.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef _POWERPC_VDSO_H
29#define _POWERPC_VDSO_H
30
31#define VDSO_TIMEHANDS_MD \
32 uint32_t th_res[8];
33
34#define VDSO_TH_ALGO_PPC_TB VDSO_TH_ALGO_1
35
36#ifdef _KERNEL
37#ifdef COMPAT_FREEBSD32
38
39#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD
40
41#endif
42#endif
43#endif
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/vm.h created+45
......@@ -0,0 +1,45 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2009 Alan L. Cox <alc@cs.rice.edu>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_VM_H_
30#define _MACHINE_VM_H_
31
32#include <machine/pte.h>
33
34/* Memory attributes. */
35#define VM_MEMATTR_DEFAULT 0
36#define VM_MEMATTR_UNCACHEABLE 0x01
37#define VM_MEMATTR_CACHEABLE 0x02
38#define VM_MEMATTR_WRITE_COMBINING 0x04
39#define VM_MEMATTR_WRITE_BACK 0x08
40#define VM_MEMATTR_WRITE_THROUGH 0x10
41#define VM_MEMATTR_PREFETCHABLE 0x20
42
43#define VM_MEMATTR_DEVICE VM_MEMATTR_DEFAULT
44
45#endif /* !_MACHINE_VM_H_ */
\ No newline at end of file
lib/libc/include/powerpc64-freebsd-none/machine/vmparam.h created+327
......@@ -0,0 +1,327 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $
34 */
35
36#ifndef _MACHINE_VMPARAM_H_
37#define _MACHINE_VMPARAM_H_
38
39#ifndef LOCORE
40#include <machine/md_var.h>
41#endif
42
43#define USRSTACK SHAREDPAGE
44
45#ifndef MAXTSIZ
46#define MAXTSIZ (1*1024*1024*1024) /* max text size */
47#endif
48
49#ifndef DFLDSIZ
50#define DFLDSIZ (128*1024*1024) /* default data size */
51#endif
52
53#ifndef MAXDSIZ
54#ifdef __powerpc64__
55#define MAXDSIZ (32UL*1024*1024*1024) /* max data size */
56#else
57#define MAXDSIZ (1*1024*1024*1024) /* max data size */
58#endif
59#endif
60
61#ifndef DFLSSIZ
62#define DFLSSIZ (8*1024*1024) /* default stack size */
63#endif
64
65#ifndef MAXSSIZ
66#ifdef __powerpc64__
67#define MAXSSIZ (512*1024*1024) /* max stack size */
68#else
69#define MAXSSIZ (64*1024*1024) /* max stack size */
70#endif
71#endif
72
73#ifdef AIM
74#define VM_MAXUSER_ADDRESS32 0xfffff000
75#else
76#define VM_MAXUSER_ADDRESS32 0x7ffff000
77#endif
78
79/*
80 * Would like to have MAX addresses = 0, but this doesn't (currently) work
81 */
82#ifdef __powerpc64__
83/*
84 * Virtual addresses of things. Derived from the page directory and
85 * page table indexes from pmap.h for precision.
86 *
87 * kernel map should be able to start at 0xc008000000000000 -
88 * but at least the functional simulator doesn't like it
89 *
90 * 0x0000000000000000 - 0x000fffffffffffff user map
91 * 0xc000000000000000 - 0xc007ffffffffffff direct map
92 * 0xc008000000000000 - 0xc00fffffffffffff kernel map
93 *
94 */
95#define VM_MIN_ADDRESS 0x0000000000000000
96#define VM_MAXUSER_ADDRESS 0x000fffffc0000000
97#define VM_MAX_ADDRESS 0xc00fffffffffffff
98#define VM_MIN_KERNEL_ADDRESS 0xc008000000000000
99#define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff
100#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
101#else
102#define VM_MIN_ADDRESS 0
103#define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32
104#define VM_MAX_ADDRESS 0xffffffff
105#endif
106
107#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
108
109#define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
110#define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE
111
112#define KERNBASE 0x00100100 /* start of kernel virtual */
113
114#define UMA_MD_SMALL_ALLOC
115
116#ifdef AIM
117#ifndef __powerpc64__
118#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT)
119#define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1)
120#define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1)
121#endif
122
123/*
124 * Use the direct-mapped BAT registers for UMA small allocs. This
125 * takes pressure off the small amount of available KVA.
126 */
127#define UMA_USE_DMAP
128
129#else /* Book-E */
130
131/* Use the direct map for UMA small allocs on powerpc64. */
132#ifdef __powerpc64__
133#define UMA_USE_DMAP
134#else
135#define VM_MIN_KERNEL_ADDRESS 0xc0000000
136#define VM_MAX_KERNEL_ADDRESS 0xffffefff
137#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
138#endif
139
140#endif /* AIM/E500 */
141
142#if !defined(LOCORE)
143struct pmap_physseg {
144 struct pv_entry *pvent;
145 char *attrs;
146};
147#endif
148
149#ifdef __powerpc64__
150#define VM_PHYSSEG_MAX 63 /* 1? */
151#else
152#define VM_PHYSSEG_MAX 16 /* 1? */
153#endif
154
155#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with
156 * logical memory block size of 64MB.
157 * For more Ram increase the lmb or this value.
158 */
159
160/* XXX This is non-sensical. Phys avail should hold contiguous regions. */
161#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ
162
163/*
164 * The physical address space is densely populated on 32-bit systems,
165 * but may not be on 64-bit ones.
166 */
167#ifdef __powerpc64__
168#define VM_PHYSSEG_SPARSE
169#else
170#define VM_PHYSSEG_DENSE
171#endif
172
173/*
174 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
175 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
176 * the pool from which physical pages for small UMA objects are
177 * allocated.
178 */
179#define VM_NFREEPOOL 2
180#define VM_FREEPOOL_DEFAULT 0
181#define VM_FREEPOOL_DIRECT 1
182
183/*
184 * Create one free page list.
185 */
186#define VM_NFREELIST 1
187#define VM_FREELIST_DEFAULT 0
188
189#ifdef __powerpc64__
190/* The largest allocation size is 16MB. */
191#define VM_NFREEORDER 13
192#else
193/* The largest allocation size is 4MB. */
194#define VM_NFREEORDER 11
195#endif
196
197#ifndef VM_NRESERVLEVEL
198#ifdef __powerpc64__
199/* Enable superpage reservations: 1 level. */
200#define VM_NRESERVLEVEL 1
201#else
202/* Disable superpage reservations. */
203#define VM_NRESERVLEVEL 0
204#endif
205#endif
206
207#ifndef VM_LEVEL_0_ORDER
208/* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */
209#define VM_LEVEL_0_ORDER vm_level_0_order
210#ifndef __ASSEMBLER__
211extern int vm_level_0_order;
212#endif
213#endif
214
215#ifndef VM_LEVEL_0_ORDER_MAX
216#define VM_LEVEL_0_ORDER_MAX 12
217#endif
218
219#ifndef VM_INITIAL_PAGEIN
220#define VM_INITIAL_PAGEIN 16
221#endif
222
223#ifndef SGROWSIZ
224#define SGROWSIZ (128UL*1024) /* amount to grow stack */
225#endif
226
227/*
228 * How many physical pages per kmem arena virtual page.
229 */
230#ifndef VM_KMEM_SIZE_SCALE
231#define VM_KMEM_SIZE_SCALE (3)
232#endif
233
234/*
235 * Optional floor (in bytes) on the size of the kmem arena.
236 */
237#ifndef VM_KMEM_SIZE_MIN
238#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024)
239#endif
240
241/*
242 * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the
243 * usable KVA space.
244 */
245#ifndef VM_KMEM_SIZE_MAX
246#define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \
247 VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5)
248#endif
249
250#ifdef __powerpc64__
251#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */
252#else
253#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
254#endif
255
256/*
257 * On 32-bit OEA, the only purpose for which sf_buf is used is to implement
258 * an opaque pointer required by the machine-independent parts of the kernel.
259 * That pointer references the vm_page that is "mapped" by the sf_buf. The
260 * actual mapping is provided by the direct virtual-to-physical mapping.
261 *
262 * On OEA64 and Book-E, we need to do something a little more complicated. Use
263 * the runtime-detected hw_direct_map to pick between the two cases. Our
264 * friends in vm_machdep.c will do the same to ensure nothing gets confused.
265 */
266#define SFBUF
267#define SFBUF_NOMD
268
269/*
270 * We (usually) have a direct map of all physical memory, so provide
271 * a macro to use to get the kernel VA address for a given PA. Check the
272 * value of PMAP_HAS_PMAP before using.
273 */
274#ifndef LOCORE
275#ifdef __powerpc64__
276#define DMAP_BASE_ADDRESS 0xc000000000000000UL
277#define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS
278#define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL
279#else
280#define DMAP_BASE_ADDRESS 0x00000000UL
281#define DMAP_MAX_ADDRESS 0xbfffffffUL
282#endif
283#endif
284
285#if defined(__powerpc64__) || defined(BOOKE)
286/*
287 * powerpc64 and Book-E will provide their own page array allocators.
288 *
289 * On AIM, this will allocate a single virtual array, with pages from the
290 * correct memory domains.
291 * On Book-E this will let us put the array in TLB1, removing the need for TLB
292 * thrashing.
293 *
294 * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver.
295 */
296#define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS
297#define PMAP_HAS_PAGE_ARRAY 1
298#endif
299
300#if defined(__powerpc64__)
301/*
302 * Need a page dump array for minidump.
303 */
304#define MINIDUMP_PAGE_TRACKING 1
305#define MINIDUMP_STARTUP_PAGE_TRACKING 1
306#else
307/*
308 * No minidump with 32-bit powerpc.
309 */
310#define MINIDUMP_PAGE_TRACKING 0
311#define MINIDUMP_STARTUP_PAGE_TRACKING 0
312#endif
313
314#define PMAP_HAS_DMAP (hw_direct_map)
315#define PHYS_TO_DMAP(x) ({ \
316 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \
317 (x) | DMAP_BASE_ADDRESS; })
318#define DMAP_TO_PHYS(x) ({ \
319 KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \
320 (x) &~ DMAP_BASE_ADDRESS; })
321
322/*
323 * No non-transparent large page support in the pmap.
324 */
325#define PMAP_HAS_LARGEPAGES 0
326
327#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/fenv.h+3-28
......@@ -36,6 +36,7 @@
3636#ifndef _FENV_H_
3737#define _FENV_H_
3838
39#include <sys/cdefs.h>
3940#include <sys/_types.h>
4041
4142#ifndef __fenv_static
......@@ -71,32 +72,13 @@ __BEGIN_DECLS
7172extern const fenv_t __fe_dfl_env;
7273#define FE_DFL_ENV (&__fe_dfl_env)
7374
74#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double)
75#if defined(__riscv_float_abi_single)
76#error single precision floating point ABI not supported
77#else
78#error compiler did not set soft/hard float macros
79#endif
75#ifndef __riscv_float_abi_double
76#error only double hard float ABI supported
8077#endif
8178
82#ifndef __riscv_float_abi_soft
8379#define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr))
8480#define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr))
85#endif
8681
87#ifdef __riscv_float_abi_soft
88int feclearexcept(int __excepts);
89int fegetexceptflag(fexcept_t *__flagp, int __excepts);
90int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
91int feraiseexcept(int __excepts);
92int fetestexcept(int __excepts);
93int fegetround(void);
94int fesetround(int __round);
95int fegetenv(fenv_t *__envp);
96int feholdexcept(fenv_t *__envp);
97int fesetenv(const fenv_t *__envp);
98int feupdateenv(const fenv_t *__envp);
99#else
10082__fenv_static inline int
10183feclearexcept(int __excepts)
10284{
......@@ -212,15 +194,9 @@ feupdateenv(const fenv_t *__envp)
212194
213195 return (0);
214196}
215#endif /* !__riscv_float_abi_soft */
216197
217198#if __BSD_VISIBLE
218199
219#ifdef __riscv_float_abi_soft
220int feenableexcept(int __mask);
221int fedisableexcept(int __mask);
222int fegetexcept(void);
223#else
224200__fenv_static inline int
225201feenableexcept(int __mask __unused)
226202{
......@@ -248,7 +224,6 @@ fegetexcept(void)
248224
249225 return (0);
250226}
251#endif /* !__riscv_float_abi_soft */
252227
253228#endif /* __BSD_VISIBLE */
254229
lib/libc/include/riscv64-freebsd-none/float.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3028 */
3129
3230#ifndef _MACHINE_FLOAT_H_
lib/libc/include/riscv64-freebsd-none/machine/_align.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
3028 */
3129
3230#ifndef _MACHINE__ALIGN_H_
lib/libc/include/riscv64-freebsd-none/machine/_bus.h deleted-43
......@@ -1,43 +0,0 @@
1/*-
2 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions, and the following disclaimer,
9 * without modification, immediately at the beginning of the file.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
19 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _MACHINE__BUS_H_
29#define _MACHINE__BUS_H_
30
31/*
32 * Addresses (in bus space).
33 */
34typedef u_long bus_addr_t;
35typedef u_long bus_size_t;
36
37/*
38 * Access methods for bus space.
39 */
40typedef u_long bus_space_handle_t;
41typedef struct bus_space *bus_space_tag_t;
42
43#endif /* !_MACHINE__BUS_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/_limits.h-2
......@@ -22,8 +22,6 @@
2222 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2323 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2424 * SUCH DAMAGE.
25 *
26 * @(#)limits.h 8.3 (Berkeley) 1/4/94
2725 */
2826
2927#ifndef _MACHINE__LIMITS_H_
lib/libc/include/riscv64-freebsd-none/machine/_types.h-3
......@@ -26,9 +26,6 @@
2626 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2727 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2828 * SUCH DAMAGE.
29 *
30 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
31 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
3229 */
3330
3431#ifndef _MACHINE__TYPES_H_
lib/libc/include/riscv64-freebsd-none/machine/asm.h+5
......@@ -69,4 +69,9 @@
6969 li tmp, SSTATUS_SUM; \
7070 csrc sstatus, tmp
7171
72#define SBI_CALL(ext, func) \
73 li a7, ext; \
74 li a6, func; \
75 ecall
76
7277#endif /* _MACHINE_ASM_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/atomic.h+112-7
......@@ -1,5 +1,5 @@
11/*-
2 * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
2 * Copyright (c) 2015-2024 Ruslan Bukin <br@bsdpad.com>
33 * All rights reserved.
44 *
55 * Portions of this software were developed by SRI International and the
......@@ -105,8 +105,6 @@ atomic_fcmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \
105105
106106ATOMIC_CMPSET_ACQ_REL(8);
107107ATOMIC_FCMPSET_ACQ_REL(8);
108ATOMIC_CMPSET_ACQ_REL(16);
109ATOMIC_FCMPSET_ACQ_REL(16);
110108
111109#define atomic_cmpset_char atomic_cmpset_8
112110#define atomic_cmpset_acq_char atomic_cmpset_acq_8
......@@ -116,11 +114,40 @@ ATOMIC_FCMPSET_ACQ_REL(16);
116114#define atomic_fcmpset_rel_char atomic_fcmpset_rel_8
117115
118116#define atomic_cmpset_short atomic_cmpset_16
119#define atomic_cmpset_acq_short atomic_cmpset_acq_16
120#define atomic_cmpset_rel_short atomic_cmpset_rel_16
121117#define atomic_fcmpset_short atomic_fcmpset_16
118
119ATOMIC_CMPSET_ACQ_REL(16);
120ATOMIC_FCMPSET_ACQ_REL(16);
121
122#define atomic_load_acq_16 atomic_load_acq_16
123static __inline uint16_t
124atomic_load_acq_16(const volatile uint16_t *p)
125{
126 uint16_t ret;
127
128 ret = *p;
129
130 fence();
131
132 return (ret);
133}
134
135static __inline void
136atomic_store_rel_16(volatile uint16_t *p, uint16_t val)
137{
138
139 fence();
140
141 *p = val;
142}
143
144#define atomic_cmpset_acq_short atomic_cmpset_acq_16
122145#define atomic_fcmpset_acq_short atomic_fcmpset_acq_16
146#define atomic_load_acq_short atomic_load_acq_16
147
148#define atomic_cmpset_rel_short atomic_cmpset_rel_16
123149#define atomic_fcmpset_rel_short atomic_fcmpset_rel_16
150#define atomic_store_rel_short atomic_store_rel_16
124151
125152static __inline void
126153atomic_add_32(volatile uint32_t *p, uint32_t val)
......@@ -239,6 +266,34 @@ atomic_readandclear_32(volatile uint32_t *p)
239266 return (ret);
240267}
241268
269static __inline int
270atomic_testandclear_32(volatile uint32_t *p, u_int val)
271{
272 uint32_t mask, old;
273
274 mask = 1u << (val & 31);
275 __asm __volatile("amoand.w %0, %2, %1"
276 : "=&r" (old), "+A" (*p)
277 : "r" (~mask)
278 : "memory");
279
280 return ((old & mask) != 0);
281}
282
283static __inline int
284atomic_testandset_32(volatile uint32_t *p, u_int val)
285{
286 uint32_t mask, old;
287
288 mask = 1u << (val & 31);
289 __asm __volatile("amoor.w %0, %2, %1"
290 : "=&r" (old), "+A" (*p)
291 : "r" (mask)
292 : "memory");
293
294 return ((old & mask) != 0);
295}
296
242297#define atomic_add_int atomic_add_32
243298#define atomic_clear_int atomic_clear_32
244299#define atomic_cmpset_int atomic_cmpset_32
......@@ -257,7 +312,7 @@ ATOMIC_CMPSET_ACQ_REL(32);
257312ATOMIC_FCMPSET_ACQ_REL(32);
258313
259314static __inline uint32_t
260atomic_load_acq_32(volatile uint32_t *p)
315atomic_load_acq_32(const volatile uint32_t *p)
261316{
262317 uint32_t ret;
263318
......@@ -410,6 +465,48 @@ atomic_readandclear_64(volatile uint64_t *p)
410465 return (ret);
411466}
412467
468static __inline int
469atomic_testandclear_64(volatile uint64_t *p, u_int val)
470{
471 uint64_t mask, old;
472
473 mask = 1ul << (val & 63);
474 __asm __volatile("amoand.d %0, %2, %1"
475 : "=&r" (old), "+A" (*p)
476 : "r" (~mask)
477 : "memory");
478
479 return ((old & mask) != 0);
480}
481
482static __inline int
483atomic_testandset_64(volatile uint64_t *p, u_int val)
484{
485 uint64_t mask, old;
486
487 mask = 1ul << (val & 63);
488 __asm __volatile("amoor.d %0, %2, %1"
489 : "=&r" (old), "+A" (*p)
490 : "r" (mask)
491 : "memory");
492
493 return ((old & mask) != 0);
494}
495
496static __inline int
497atomic_testandset_acq_64(volatile uint64_t *p, u_int val)
498{
499 uint64_t mask, old;
500
501 mask = 1ul << (val & 63);
502 __asm __volatile("amoor.d.aq %0, %2, %1"
503 : "=&r" (old), "+A" (*p)
504 : "r" (mask)
505 : "memory");
506
507 return ((old & mask) != 0);
508}
509
413510static __inline uint32_t
414511atomic_swap_32(volatile uint32_t *p, uint32_t val)
415512{
......@@ -447,6 +544,9 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
447544#define atomic_set_long atomic_set_64
448545#define atomic_subtract_long atomic_subtract_64
449546#define atomic_swap_long atomic_swap_64
547#define atomic_testandclear_long atomic_testandclear_64
548#define atomic_testandset_long atomic_testandset_64
549#define atomic_testandset_acq_long atomic_testandset_acq_64
450550
451551#define atomic_add_ptr atomic_add_64
452552#define atomic_clear_ptr atomic_clear_64
......@@ -457,6 +557,8 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
457557#define atomic_set_ptr atomic_set_64
458558#define atomic_subtract_ptr atomic_subtract_64
459559#define atomic_swap_ptr atomic_swap_64
560#define atomic_testandclear_ptr atomic_testandclear_64
561#define atomic_testandset_ptr atomic_testandset_64
460562
461563ATOMIC_ACQ_REL(set, 64)
462564ATOMIC_ACQ_REL(clear, 64)
......@@ -467,7 +569,7 @@ ATOMIC_CMPSET_ACQ_REL(64);
467569ATOMIC_FCMPSET_ACQ_REL(64);
468570
469571static __inline uint64_t
470atomic_load_acq_64(volatile uint64_t *p)
572atomic_load_acq_64(const volatile uint64_t *p)
471573{
472574 uint64_t ret;
473575
......@@ -554,4 +656,7 @@ atomic_thread_fence_seq_cst(void)
554656
555657#include <sys/_atomic_subword.h>
556658
659#define atomic_set_short atomic_set_16
660#define atomic_clear_short atomic_clear_16
661
557662#endif /* _MACHINE_ATOMIC_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/bus_dma.h+1-1
......@@ -49,7 +49,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
4949
5050/*
5151 * Free a piece of memory and it's allociated dmamap, that was allocated
52 * via bus_dmamem_alloc. Make the same choice for free/contigfree.
52 * via bus_dmamem_alloc.
5353 */
5454static inline void
5555bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
lib/libc/include/riscv64-freebsd-none/machine/bus_dma_impl.h+3-10
......@@ -31,27 +31,22 @@
3131
3232struct bus_dma_tag_common {
3333 struct bus_dma_impl *impl;
34 struct bus_dma_tag_common *parent;
3534 bus_size_t alignment;
3635 bus_addr_t boundary;
3736 bus_addr_t lowaddr;
3837 bus_addr_t highaddr;
39 bus_dma_filter_t *filter;
40 void *filterarg;
4138 bus_size_t maxsize;
4239 u_int nsegments;
4340 bus_size_t maxsegsz;
4441 int flags;
4542 bus_dma_lock_t *lockfunc;
4643 void *lockfuncarg;
47 int ref_count;
4844};
4945
5046struct bus_dma_impl {
5147 int (*tag_create)(bus_dma_tag_t parent,
5248 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
53 bus_addr_t highaddr, bus_dma_filter_t *filter,
54 void *filterarg, bus_size_t maxsize, int nsegments,
49 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
5550 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
5651 void *lockfuncarg, bus_dma_tag_t *dmat);
5752 int (*tag_destroy)(bus_dma_tag_t dmat);
......@@ -79,13 +74,11 @@ struct bus_dma_impl {
7974 bus_dmasync_op_t op);
8075};
8176
82int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
8377int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
8478 bus_size_t alignment,
8579 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
86 bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,
87 int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
88 void *lockfuncarg, size_t sz, void **dmat);
80 bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags,
81 bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat);
8982
9083extern struct bus_dma_impl bus_dma_bounce_impl;
9184
lib/libc/include/riscv64-freebsd-none/machine/cbo.h created+33
......@@ -0,0 +1,33 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2025 Ruslan Bukin <br@bsdpad.com>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef _RISCV_CBO_H_
29#define _RISCV_CBO_H_
30
31void cbo_zicbom_setup_cache(int cbom_block_size);
32
33#endif /* _RISCV_CBO_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/cpu.h+8-3
......@@ -35,9 +35,11 @@
3535#ifndef _MACHINE_CPU_H_
3636#define _MACHINE_CPU_H_
3737
38#ifndef LOCORE
3839#include <machine/atomic.h>
3940#include <machine/cpufunc.h>
4041#include <machine/frame.h>
42#endif
4143
4244#define TRAPF_PC(tfp) ((tfp)->tf_sepc)
4345#define TRAPF_USERMODE(tfp) (((tfp)->tf_sstatus & SSTATUS_SPP) == 0)
......@@ -47,8 +49,6 @@
4749#define cpu_spinwait() /* nothing */
4850#define cpu_lock_delay() DELAY(1)
4951
50#ifdef _KERNEL
51
5252/*
5353 * Core manufacturer IDs, as reported by the mvendorid CSR.
5454 */
......@@ -80,6 +80,7 @@
8080
8181/* SiFive marchid values */
8282#define MARCHID_SIFIVE_U7 MARCHID_COMMERCIAL(7)
83#define MARCHID_SIFIVE_P5 MARCHID_COMMERCIAL(8)
8384
8485/*
8586 * MMU virtual-addressing modes. Support for each level implies the previous,
......@@ -89,6 +90,9 @@
8990#define MMU_SV48 0x2 /* 4-level paging */
9091#define MMU_SV57 0x4 /* 5-level paging */
9192
93#ifdef _KERNEL
94#ifndef LOCORE
95
9296extern char btext[];
9397extern char etext[];
9498
......@@ -105,6 +109,7 @@ get_cyclecount(void)
105109 return (rdcycle());
106110}
107111
108#endif
112#endif /* !LOCORE */
113#endif /* _KERNEL */
109114
110115#endif /* !_MACHINE_CPU_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/cpufunc.h+50-7
......@@ -44,6 +44,8 @@ breakpoint(void)
4444
4545#ifdef _KERNEL
4646
47#include <sys/_null.h>
48
4749#include <machine/riscvreg.h>
4850
4951static __inline register_t
......@@ -102,21 +104,62 @@ sfence_vma_page(uintptr_t addr)
102104 __asm __volatile("sfence.vma %0" :: "r" (addr) : "memory");
103105}
104106
107static __inline void
108sfence_vma_asid(uint64_t asid)
109{
110
111 __asm __volatile("sfence.vma x0, %0" :: "r" (asid) : "memory");
112}
113
114static __inline void
115sfence_vma_asid_page(uint64_t asid, uintptr_t addr)
116{
117
118 __asm __volatile("sfence.vma %0, %1" :: "r" (addr), "r" (asid)
119 : "memory");
120}
121
105122#define rdcycle() csr_read64(cycle)
106123#define rdtime() csr_read64(time)
107124#define rdinstret() csr_read64(instret)
108125#define rdhpmcounter(n) csr_read64(hpmcounter##n)
109126
127/* Cache hooks. */
128
110129extern int64_t dcache_line_size;
111extern int64_t icache_line_size;
112130
113#define cpu_dcache_wbinv_range(a, s)
114#define cpu_dcache_inv_range(a, s)
115#define cpu_dcache_wb_range(a, s)
131typedef void (*cache_op_t)(vm_offset_t start, vm_size_t size);
132
133struct riscv_cache_ops {
134 cache_op_t dcache_wbinv_range;
135 cache_op_t dcache_inv_range;
136 cache_op_t dcache_wb_range;
137};
138
139extern struct riscv_cache_ops cache_ops;
140
141static __inline void
142cpu_dcache_wbinv_range(vm_offset_t addr, vm_size_t size)
143{
144 if (cache_ops.dcache_wbinv_range != NULL)
145 cache_ops.dcache_wbinv_range(addr, size);
146}
147
148static __inline void
149cpu_dcache_inv_range(vm_offset_t addr, vm_size_t size)
150{
151 if (cache_ops.dcache_inv_range != NULL)
152 cache_ops.dcache_inv_range(addr, size);
153}
154
155static __inline void
156cpu_dcache_wb_range(vm_offset_t addr, vm_size_t size)
157{
158 if (cache_ops.dcache_wb_range != NULL)
159 cache_ops.dcache_wb_range(addr, size);
160}
116161
117#define cpu_idcache_wbinv_range(a, s)
118#define cpu_icache_sync_range(a, s)
119#define cpu_icache_sync_range_checked(a, s)
162void riscv_cache_install_hooks(struct riscv_cache_ops *, u_int);
120163
121164#define cpufunc_nullop() riscv_nullop()
122165
lib/libc/include/riscv64-freebsd-none/machine/elf.h+2
......@@ -80,7 +80,9 @@ __ElfType(Auxinfo);
8080#define HWCAP_ISA_F HWCAP_ISA_BIT('f')
8181#define HWCAP_ISA_D HWCAP_ISA_BIT('d')
8282#define HWCAP_ISA_C HWCAP_ISA_BIT('c')
83#define HWCAP_ISA_H HWCAP_ISA_BIT('h')
8384#define HWCAP_ISA_G \
8485 (HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F | HWCAP_ISA_D)
86#define HWCAP_ISA_B HWCAP_ISA_BIT('b')
8587
8688#endif /* !_MACHINE_ELF_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/endian.h-2
......@@ -24,8 +24,6 @@
2424 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2525 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2626 * SUCH DAMAGE.
27 *
28 * @(#)endian.h 8.1 (Berkeley) 6/10/93
2927 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
3028 */
3129
lib/libc/include/riscv64-freebsd-none/machine/float.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
3028 */
3129
3230#ifndef _MACHINE_FLOAT_H_
lib/libc/include/riscv64-freebsd-none/machine/fpe.h+11-1
......@@ -1,5 +1,5 @@
11/*-
2 * Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com>
2 * Copyright (c) 2016-2024 Ruslan Bukin <br@bsdpad.com>
33 * All rights reserved.
44 *
55 * This software was developed by SRI International and the University of
......@@ -34,4 +34,14 @@
3434void fpe_state_save(struct thread *td);
3535void fpe_state_clear(void);
3636
37struct fpreg *fpu_save_area_alloc(void);
38void fpu_save_area_free(struct fpreg *fsa);
39void fpu_save_area_reset(struct fpreg *fsa);
40
41void fpe_enable(void);
42void fpe_disable(void);
43
44void fpe_store(struct fpreg *state);
45void fpe_restore(struct fpreg *state);
46
3747#endif /* !_MACHINE_FPE_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/frame.h+14
......@@ -57,6 +57,10 @@ struct trapframe {
5757 uint64_t tf_scause;
5858};
5959
60#ifdef _KERNEL
61#define TF_SIZE (roundup2(sizeof(struct trapframe), STACKALIGNBYTES + 1))
62#endif
63
6064/*
6165 * Signal frame. Pushed onto user stack before calling sigcode.
6266 */
......@@ -65,6 +69,16 @@ struct sigframe {
6569 ucontext_t sf_uc; /* actual saved ucontext */
6670};
6771
72#ifdef _KERNEL
73/*
74 * Kernel frame. Reserved near the top of kernel stacks for saving kernel
75 * state while in userspace.
76 */
77struct kernframe {
78 register_t kf_tp;
79};
80#endif
81
6882#endif /* !LOCORE */
6983
7084/* Definitions for syscalls */
lib/libc/include/riscv64-freebsd-none/machine/ifunc.h created+49
......@@ -0,0 +1,49 @@
1/*-
2 * Copyright (c) 2015-2018 The FreeBSD Foundation
3 * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.org>
4 *
5 * Part of this software was developed by Konstantin Belousov <kib@FreeBSD.org>
6 * under sponsorship from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef __RISCV_IFUNC_H
31#define __RISCV_IFUNC_H
32
33#define DEFINE_IFUNC(qual, ret_type, name, args) \
34 static ret_type (*name##_resolver(void))args __used; \
35 qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
36 static ret_type (*name##_resolver(void))args
37
38#define DEFINE_UIFUNC(qual, ret_type, name, args) \
39 static ret_type (*name##_resolver(unsigned long, unsigned long, \
40 unsigned long, unsigned long, unsigned long, unsigned long, \
41 unsigned long, unsigned long))args __used; \
42 qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
43 static ret_type (*name##_resolver(unsigned long elf_hwcap __unused, \
44 unsigned long _arg2 __unused, unsigned long _arg3 __unused, \
45 unsigned long _arg4 __unused, unsigned long _arg5 __unused, \
46 unsigned long _arg6 __unused, unsigned long _arg7 __unused, \
47 unsigned long _arg8 __unused))args
48
49#endif
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/in_cksum.h-1
......@@ -27,7 +27,6 @@
2727 * SUCH DAMAGE.
2828 *
2929 * from tahoe: in_cksum.c 1.2 86/01/05
30 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
3130 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
3231 */
3332
lib/libc/include/riscv64-freebsd-none/machine/intr.h+5-2
......@@ -39,8 +39,7 @@
3939#define NIRQ 1024
4040#endif
4141
42#include <sys/intr.h>
43
42#ifndef LOCORE
4443enum {
4544 IRQ_SOFTWARE_USER,
4645 IRQ_SOFTWARE_SUPERVISOR,
......@@ -55,5 +54,9 @@ enum {
5554 IRQ_EXTERNAL_HYPERVISOR,
5655 IRQ_EXTERNAL_MACHINE,
5756};
57#endif /* !LOCORE */
58
59#define INTR_ROOT_IRQ 0
60#define INTR_ROOT_COUNT 1
5861
5962#endif /* !_MACHINE_INTR_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/machdep.h-2
......@@ -36,10 +36,8 @@
3636#define _MACHINE_MACHDEP_H_
3737
3838struct riscv_bootparams {
39 vm_offset_t kern_l1pt; /* Kernel L1 base */
4039 vm_offset_t kern_phys; /* Kernel base (physical) addr */
4140 vm_offset_t kern_stack;
42 vm_offset_t dtbp_virt; /* Device tree blob virtual addr */
4341 vm_offset_t dtbp_phys; /* Device tree blob physical addr */
4442 vm_offset_t modulep; /* loader(8) metadata */
4543};
lib/libc/include/riscv64-freebsd-none/machine/md_var.h+2
......@@ -42,8 +42,10 @@ extern register_t mimpid;
4242extern u_int mmu_caps;
4343
4444/* Supervisor-mode extension support */
45extern bool has_hyp;
4546extern bool has_sstc;
4647extern bool has_sscofpmf;
48extern bool has_svpbmt;
4749
4850struct dumperinfo;
4951struct minidumpstate;
lib/libc/include/riscv64-freebsd-none/machine/metadata.h+10-3
......@@ -30,11 +30,18 @@
3030
3131#define MODINFOMD_DTBP 0x1001
3232#define MODINFOMD_EFI_MAP 0x1002
33#define MODINFOMD_EFI_FB 0x1003
34#define MODINFOMD_BOOT_HARTID 0x1004
3335
36/*
37 * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though
38 * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table
39 * starting at a 16-byte alignment.
40 */
3441struct efi_map_header {
35 size_t memory_size;
36 size_t descriptor_size;
37 uint32_t descriptor_version;
42 size_t memory_size; /* Numnber of bytes that follow */
43 size_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
44 uint32_t descriptor_version; /* Currently '1' */
3845};
3946
4047/*
lib/libc/include/riscv64-freebsd-none/machine/param.h-12
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
3028 */
3129
3230#ifndef _MACHINE_PARAM_H_
......@@ -41,8 +39,6 @@
4139#define STACKALIGNBYTES (16 - 1)
4240#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
4341
44#define __PCI_REROUTE_INTERRUPT
45
4642#ifndef MACHINE
4743#define MACHINE "riscv"
4844#endif
......@@ -95,15 +91,7 @@
9591/*
9692 * Mach derived conversion macros
9793 */
98#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK)
99#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK)
100
101#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT)
102#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT)
103
10494#define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
10595#define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
10696
107#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
108
10997#endif /* !_MACHINE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/pcpu.h+2-1
......@@ -46,7 +46,8 @@
4646 struct pmap *pc_curpmap; /* Currently active pmap */ \
4747 uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \
4848 uint32_t pc_hart; /* Hart ID */ \
49 char __pad[56] /* Pad to factor of PAGE_SIZE */
49 uint64_t pc_clock; \
50 char __pad[48] /* Pad to factor of PAGE_SIZE */
5051
5152#ifdef _KERNEL
5253
lib/libc/include/riscv64-freebsd-none/machine/pmap.h+9-1
......@@ -67,6 +67,12 @@ struct md_page {
6767 vm_memattr_t pv_memattr;
6868};
6969
70enum pmap_stage {
71 PM_INVALID,
72 PM_STAGE1,
73 PM_STAGE2,
74};
75
7076struct pmap {
7177 struct mtx pm_mtx;
7278 struct pmap_statistics pm_stats; /* pmap statictics */
......@@ -76,6 +82,7 @@ struct pmap {
7682 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
7783 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */
7884 struct vm_radix pm_root;
85 enum pmap_stage pm_stage;
7986};
8087
8188typedef struct pmap *pmap_t;
......@@ -126,7 +133,7 @@ struct thread;
126133
127134void pmap_activate_boot(pmap_t);
128135void pmap_activate_sw(struct thread *);
129void pmap_bootstrap(vm_offset_t, vm_paddr_t, vm_size_t);
136void pmap_bootstrap(vm_paddr_t, vm_size_t);
130137int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);
131138void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);
132139void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
......@@ -134,6 +141,7 @@ vm_paddr_t pmap_kextract(vm_offset_t va);
134141void pmap_kremove(vm_offset_t);
135142void pmap_kremove_device(vm_offset_t, vm_size_t);
136143void *pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma);
144int pmap_pinit_stage(pmap_t, enum pmap_stage);
137145bool pmap_page_is_mapped(vm_page_t m);
138146bool pmap_ps_enabled(pmap_t);
139147
lib/libc/include/riscv64-freebsd-none/machine/proc.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3028 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
3129 */
3230
lib/libc/include/riscv64-freebsd-none/machine/pte.h+46-3
......@@ -83,6 +83,51 @@ typedef uint64_t pn_t; /* page number */
8383#define PTE_PROMOTE (PTE_V | PTE_RWX | PTE_D | PTE_G | PTE_U | \
8484 PTE_SW_MANAGED | PTE_SW_WIRED)
8585
86/*
87 * Svpbmt Memory Attribute (MA) bits [62:61].
88 *
89 * +------+-------+------------------------------------------------------------+
90 * | Mode | Value | Requested Memory Attributes |
91 * +------+-------+------------------------------------------------------------+
92 * | PMA | 00 | None, inherited from Physical Memory Attributes (firmware) |
93 * | NC | 01 | Non-cacheable, idempotent, weakly-ordered (RVWMO), |
94 * | | | main memory |
95 * | IO | 10 | Non-cacheable, non-idempotent, strongly-ordered, I/O |
96 * | -- | 11 | Reserved |
97 * +------+-------+------------------------------------------------------------+
98 */
99#define PTE_MA_SHIFT 61
100#define PTE_MA_MASK (0x3ul << PTE_MA_SHIFT)
101#define PTE_MA_NONE (0ul)
102#define PTE_MA_NC (1ul << PTE_MA_SHIFT)
103#define PTE_MA_IO (2ul << PTE_MA_SHIFT)
104
105/*
106 * T-HEAD Custom Memory Attribute (MA) bits [63:59].
107 *
108 * bit 59: Trustable (relating to TEE)
109 * bit 60: Shareable (among CPUs, not configurable)
110 * bit 61: Bufferable (writes to device memory)
111 * bit 62: Cacheable
112 * bit 63: Memory Ordering (1 = strongly ordered (device), 0 = default)
113 *
114 * +------+-------+------------------------------------------------------------+
115 * | Mode | Value | Requested Memory Attributes |
116 * +------+-------+------------------------------------------------------------+
117 * | NC | 00110 | Weakly-ordered, non-cacheable, bufferable, shareable, |
118 * | | | non-trustable |
119 * | PMA | 01110 | Weakly-ordered, cacheable, bufferable, shareable, |
120 * | | | non-trustable |
121 * | IO | 10010 | Strongly-ordered, non-cacheable, non-bufferable, |
122 * | | | shareable, non-trustable |
123 * +------+-------+------------------------------------------------------------+
124 */
125#define PTE_THEAD_MA_SHIFT 59
126#define PTE_THEAD_MA_MASK (0x1ful << PTE_THEAD_MA_SHIFT)
127#define PTE_THEAD_MA_NC (0x6ul << PTE_THEAD_MA_SHIFT)
128#define PTE_THEAD_MA_NONE (0xeul << PTE_THEAD_MA_SHIFT)
129#define PTE_THEAD_MA_IO (0x12ul << PTE_THEAD_MA_SHIFT)
130
86131/* Bits 63 - 54 are reserved for future use. */
87132#define PTE_HI_MASK 0xFFC0000000000000ULL
88133
......@@ -92,6 +137,4 @@ typedef uint64_t pn_t; /* page number */
92137#define PTE_PPN3_S 37
93138#define PTE_SIZE 8
94139
95#endif /* !_MACHINE_PTE_H_ */
96
97/* End of pte.h */
\ No newline at end of file
140#endif /* !_MACHINE_PTE_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/resource.h-2
......@@ -40,8 +40,6 @@
4040#define SYS_RES_MEMORY 3 /* i/o memory */
4141#define SYS_RES_IOPORT 4 /* i/o ports */
4242#define SYS_RES_GPIO 5 /* general purpose i/o */
43#ifdef NEW_PCIB
4443#define PCI_RES_BUS 6 /* PCI bus numbers */
45#endif
4644
4745#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/riscvreg.h+44-5
......@@ -1,5 +1,5 @@
11/*-
2 * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>
2 * Copyright (c) 2015-2024 Ruslan Bukin <br@bsdpad.com>
33 * All rights reserved.
44 *
55 * Portions of this software were developed by SRI International and the
......@@ -47,9 +47,15 @@
4747#define SCAUSE_STORE_ACCESS_FAULT 7
4848#define SCAUSE_ECALL_USER 8
4949#define SCAUSE_ECALL_SUPERVISOR 9
50#define SCAUSE_VIRTUAL_SUPERVISOR_ECALL 10
51#define SCAUSE_MACHINE_ECALL 11
5052#define SCAUSE_INST_PAGE_FAULT 12
5153#define SCAUSE_LOAD_PAGE_FAULT 13
5254#define SCAUSE_STORE_PAGE_FAULT 15
55#define SCAUSE_FETCH_GUEST_PAGE_FAULT 20
56#define SCAUSE_LOAD_GUEST_PAGE_FAULT 21
57#define SCAUSE_VIRTUAL_INSTRUCTION 22
58#define SCAUSE_STORE_GUEST_PAGE_FAULT 23
5359
5460#define SSTATUS_UIE (1 << 0)
5561#define SSTATUS_SIE (1 << 1)
......@@ -116,6 +122,17 @@
116122#define MSTATUS_PRV_H 2 /* hypervisor */
117123#define MSTATUS_PRV_M 3 /* machine */
118124
125#define HSTATUS_VSBE (1 << 5)
126#define HSTATUS_GVA (1 << 6)
127#define HSTATUS_SPV (1 << 7)
128#define HSTATUS_SPVP (1 << 8)
129#define HSTATUS_HU (1 << 9)
130#define HSTATUS_VGEIN_S 12
131#define HSTATUS_VGEIN_M (0xf << HSTATUS_VGEIN_S)
132#define HSTATUS_VTVM (1 << 20)
133#define HSTATUS_VTW (1 << 21)
134#define HSTATUS_VTSR (1 << 22)
135
119136#define MIE_USIE (1 << 0)
120137#define MIE_SSIE (1 << 1)
121138#define MIE_HSIE (1 << 2)
......@@ -143,10 +160,31 @@
143160
144161#define MIP_SEIP (1 << 9)
145162
163#define HVIP_VSSIP (1 << 2)
164#define HVIP_VSTIP (1 << 6)
165#define HVIP_VSEIP (1 << 10)
166
167#define HIE_VSSIE (1 << 2)
168#define HIE_VSTIE (1 << 6)
169#define HIE_VSEIE (1 << 10)
170#define HIE_SGEIE (1 << 12)
171
146172/* Note: sip register has no SIP_STIP bit in Spike simulator */
147173#define SIP_SSIP (1 << 1)
148174#define SIP_STIP (1 << 5)
149175
176#define HENVCFG_STCE (1UL << 63)
177#define HENVCFG_PBMTE (1UL << 62)
178#define HENVCFG_CBZE (1UL << 7)
179#define HENVCFG_CBCFE (1UL << 6)
180#define HENVCFG_CBIE_S 4
181#define HENVCFG_CBIE_M (0x3 << HENVCFG_CBIE_S)
182#define HENVCFG_FIOM (1UL << 0)
183
184#define HCOUNTEREN_CY (1UL << 0) /* Cycle */
185#define HCOUNTEREN_TM (1UL << 1) /* Time */
186#define HCOUNTEREN_IR (1UL << 2) /* Instret */
187
150188#define SATP_PPN_S 0
151189#define SATP_PPN_M (0xfffffffffffUL << SATP_PPN_S)
152190#define SATP_ASID_S 44
......@@ -189,13 +227,14 @@
189227 (__builtin_constant_p(val) && ((u_long)(val) < 32))
190228
191229#define csr_swap(csr, val) \
192({ if (CSR_ZIMM(val)) \
230({ u_long ret; \
231 if (CSR_ZIMM(val)) \
193232 __asm __volatile("csrrwi %0, " #csr ", %1" \
194 : "=r" (val) : "i" (val)); \
233 : "=r" (ret) : "i" (val)); \
195234 else \
196235 __asm __volatile("csrrw %0, " #csr ", %1" \
197 : "=r" (val) : "r" (val)); \
198 val; \
236 : "=r" (ret) : "r" (val)); \
237 ret; \
199238})
200239
201240#define csr_write(csr, val) \
lib/libc/include/riscv64-freebsd-none/machine/runq.h deleted-44
......@@ -1,44 +0,0 @@
1/*-
2 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef _MACHINE_RUNQ_H_
28#define _MACHINE_RUNQ_H_
29
30#define RQB_LEN (1) /* Number of priority status words. */
31#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */
32#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */
33
34#define RQB_BIT(pri) (1ul << ((pri) & (RQB_BPW - 1)))
35#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
36
37#define RQB_FFS(word) (ffsl(word) - 1)
38
39/*
40 * Type of run queue status word.
41 */
42typedef unsigned long rqb_word_t;
43
44#endif
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/sbi.h+9
......@@ -49,6 +49,12 @@
4949#define SBI_IMPL_ID_KVM 3
5050#define SBI_IMPL_ID_RUSTSBI 4
5151#define SBI_IMPL_ID_DIOSIX 5
52#define SBI_IMPL_ID_COFFER 6
53#define SBI_IMPL_ID_XEN_PROJECT 7
54#define SBI_IMPL_ID_POLARFIRE_HSS 8
55#define SBI_IMPL_ID_COREBOOT 9
56#define SBI_IMPL_ID_OREBOOT 10
57#define SBI_IMPL_ID_BHYVE 11
5258
5359/* SBI Error Codes */
5460#define SBI_SUCCESS 0
......@@ -117,6 +123,8 @@
117123#define SBI_REMOTE_SFENCE_VMA_ASID 7
118124#define SBI_SHUTDOWN 8
119125
126#ifndef LOCORE
127
120128#define SBI_CALL0(e, f) SBI_CALL5(e, f, 0, 0, 0, 0, 0)
121129#define SBI_CALL1(e, f, p1) SBI_CALL5(e, f, p1, 0, 0, 0, 0)
122130#define SBI_CALL2(e, f, p1, p2) SBI_CALL5(e, f, p1, p2, 0, 0, 0)
......@@ -236,4 +244,5 @@ sbi_console_getchar(void)
236244void sbi_print_version(void);
237245void sbi_init(void);
238246
247#endif /* !LOCORE */
239248#endif /* !_MACHINE_SBI_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/sdt_machdep.h created+12
......@@ -0,0 +1,12 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org>
5 */
6
7#ifndef _SYS_SDT_MACHDEP_H_
8#define _SYS_SDT_MACHDEP_H_
9
10#define _SDT_ASM_PATCH_INSTR ".option push; .option norvc; nop; .option pop"
11
12#endif /* _SYS_SDT_MACHDEP_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/signal.h-2
......@@ -25,8 +25,6 @@
2525 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727 * SUCH DAMAGE.
28 *
29 * @(#)signal.h 8.1 (Berkeley) 6/11/93
3028 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
3129 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
3230 */
lib/libc/include/riscv64-freebsd-none/machine/thead.h created+37
......@@ -0,0 +1,37 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 The FreeBSD Foundation
5 *
6 * This software was developed by Mitchell Horne <mhorne@FreeBSD.org> under
7 * sponsorship from the FreeBSD Foundation.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30#ifndef _RISCV_THEAD_H_
31#define _RISCV_THEAD_H_
32
33extern bool has_errata_thead_pbmt;
34
35void thead_setup_cache(void);
36
37#endif /* _RISCV_THEAD_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/vm.h+7-3
......@@ -28,10 +28,14 @@
2828#define _MACHINE_VM_H_
2929
3030/* Memory attribute configuration. */
31#define VM_MEMATTR_DEVICE 0
31#define VM_MEMATTR_PMA 0
3232#define VM_MEMATTR_UNCACHEABLE 1
33#define VM_MEMATTR_WRITE_BACK 2
33#define VM_MEMATTR_DEVICE 2
3434
35#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
35#define VM_MEMATTR_WRITE_BACK VM_MEMATTR_PMA
36#define VM_MEMATTR_DEFAULT VM_MEMATTR_PMA
37
38#define VM_MEMATTR_LAST VM_MEMATTR_DEVICE
39#define VM_MEMATTR_TOTAL (VM_MEMATTR_LAST + 1)
3640
3741#endif /* !_MACHINE_VM_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/vmm.h created+299
......@@ -0,0 +1,299 @@
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2015 Mihai Carabas <mihai.carabas@gmail.com>
5 * Copyright (c) 2024 Ruslan Bukin <br@bsdpad.com>
6 *
7 * This software was developed by the University of Cambridge Computer
8 * Laboratory (Department of Computer Science and Technology) under Innovate
9 * UK project 105694, "Digital Security by Design (DSbD) Technology Platform
10 * Prototype".
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef _VMM_H_
35#define _VMM_H_
36
37#include <sys/param.h>
38#include <sys/cpuset.h>
39#include <vm/vm.h>
40#include <vm/pmap.h>
41
42#include "pte.h"
43#include "pmap.h"
44
45struct vcpu;
46
47enum vm_suspend_how {
48 VM_SUSPEND_NONE,
49 VM_SUSPEND_RESET,
50 VM_SUSPEND_POWEROFF,
51 VM_SUSPEND_HALT,
52 VM_SUSPEND_DESTROY,
53 VM_SUSPEND_LAST
54};
55
56/*
57 * Identifiers for architecturally defined registers.
58 */
59enum vm_reg_name {
60 VM_REG_GUEST_ZERO = 0,
61 VM_REG_GUEST_RA,
62 VM_REG_GUEST_SP,
63 VM_REG_GUEST_GP,
64 VM_REG_GUEST_TP,
65 VM_REG_GUEST_T0,
66 VM_REG_GUEST_T1,
67 VM_REG_GUEST_T2,
68 VM_REG_GUEST_S0,
69 VM_REG_GUEST_S1,
70 VM_REG_GUEST_A0,
71 VM_REG_GUEST_A1,
72 VM_REG_GUEST_A2,
73 VM_REG_GUEST_A3,
74 VM_REG_GUEST_A4,
75 VM_REG_GUEST_A5,
76 VM_REG_GUEST_A6,
77 VM_REG_GUEST_A7,
78 VM_REG_GUEST_S2,
79 VM_REG_GUEST_S3,
80 VM_REG_GUEST_S4,
81 VM_REG_GUEST_S5,
82 VM_REG_GUEST_S6,
83 VM_REG_GUEST_S7,
84 VM_REG_GUEST_S8,
85 VM_REG_GUEST_S9,
86 VM_REG_GUEST_S10,
87 VM_REG_GUEST_S11,
88 VM_REG_GUEST_T3,
89 VM_REG_GUEST_T4,
90 VM_REG_GUEST_T5,
91 VM_REG_GUEST_T6,
92 VM_REG_GUEST_SEPC,
93 VM_REG_LAST
94};
95
96#define VM_INTINFO_VECTOR(info) ((info) & 0xff)
97#define VM_INTINFO_DEL_ERRCODE 0x800
98#define VM_INTINFO_RSVD 0x7ffff000
99#define VM_INTINFO_VALID 0x80000000
100#define VM_INTINFO_TYPE 0x700
101#define VM_INTINFO_HWINTR (0 << 8)
102#define VM_INTINFO_NMI (2 << 8)
103#define VM_INTINFO_HWEXCEPTION (3 << 8)
104#define VM_INTINFO_SWINTR (4 << 8)
105
106#define VM_MAX_NAMELEN 32
107#define VM_MAX_SUFFIXLEN 15
108
109#ifdef _KERNEL
110
111struct vm;
112struct vm_exception;
113struct vm_exit;
114struct vm_run;
115struct vm_object;
116struct vm_guest_paging;
117struct vm_aplic_descr;
118struct pmap;
119
120struct vm_eventinfo {
121 void *rptr; /* rendezvous cookie */
122 int *sptr; /* suspend cookie */
123 int *iptr; /* reqidle cookie */
124};
125
126int vm_create(const char *name, struct vm **retvm);
127struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid);
128void vm_disable_vcpu_creation(struct vm *vm);
129void vm_slock_vcpus(struct vm *vm);
130void vm_unlock_vcpus(struct vm *vm);
131void vm_destroy(struct vm *vm);
132int vm_reinit(struct vm *vm);
133const char *vm_name(struct vm *vm);
134
135uint16_t vm_get_maxcpus(struct vm *vm);
136void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores,
137 uint16_t *threads, uint16_t *maxcpus);
138int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
139 uint16_t threads, uint16_t maxcpus);
140int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
141int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
142int vm_run(struct vcpu *vcpu);
143int vm_suspend(struct vm *vm, enum vm_suspend_how how);
144void* vm_get_cookie(struct vm *vm);
145int vcpu_vcpuid(struct vcpu *vcpu);
146void *vcpu_get_cookie(struct vcpu *vcpu);
147struct vm *vcpu_vm(struct vcpu *vcpu);
148struct vcpu *vm_vcpu(struct vm *vm, int cpu);
149int vm_get_capability(struct vcpu *vcpu, int type, int *val);
150int vm_set_capability(struct vcpu *vcpu, int type, int val);
151int vm_activate_cpu(struct vcpu *vcpu);
152int vm_suspend_cpu(struct vm *vm, struct vcpu *vcpu);
153int vm_resume_cpu(struct vm *vm, struct vcpu *vcpu);
154int vm_inject_exception(struct vcpu *vcpu, uint64_t scause);
155int vm_attach_aplic(struct vm *vm, struct vm_aplic_descr *descr);
156int vm_assert_irq(struct vm *vm, uint32_t irq);
157int vm_deassert_irq(struct vm *vm, uint32_t irq);
158int vm_raise_msi(struct vm *vm, uint64_t msg, uint64_t addr, int bus, int slot,
159 int func);
160struct vm_exit *vm_exitinfo(struct vcpu *vcpu);
161void vm_exit_suspended(struct vcpu *vcpu, uint64_t pc);
162void vm_exit_debug(struct vcpu *vcpu, uint64_t pc);
163void vm_exit_rendezvous(struct vcpu *vcpu, uint64_t pc);
164void vm_exit_astpending(struct vcpu *vcpu, uint64_t pc);
165
166cpuset_t vm_active_cpus(struct vm *vm);
167cpuset_t vm_debug_cpus(struct vm *vm);
168cpuset_t vm_suspended_cpus(struct vm *vm);
169
170static __inline int
171vcpu_rendezvous_pending(struct vm_eventinfo *info)
172{
173
174 return (*((uintptr_t *)(info->rptr)) != 0);
175}
176
177static __inline int
178vcpu_suspended(struct vm_eventinfo *info)
179{
180
181 return (*info->sptr);
182}
183
184int vcpu_debugged(struct vcpu *vcpu);
185
186enum vcpu_state {
187 VCPU_IDLE,
188 VCPU_FROZEN,
189 VCPU_RUNNING,
190 VCPU_SLEEPING,
191};
192
193int vcpu_set_state(struct vcpu *vcpu, enum vcpu_state state, bool from_idle);
194enum vcpu_state vcpu_get_state(struct vcpu *vcpu, int *hostcpu);
195
196static int __inline
197vcpu_is_running(struct vcpu *vcpu, int *hostcpu)
198{
199 return (vcpu_get_state(vcpu, hostcpu) == VCPU_RUNNING);
200}
201
202#ifdef _SYS_PROC_H_
203static int __inline
204vcpu_should_yield(struct vcpu *vcpu)
205{
206 struct thread *td;
207
208 td = curthread;
209 return (td->td_ast != 0 || td->td_owepreempt != 0);
210}
211#endif
212
213void *vcpu_stats(struct vcpu *vcpu);
214void vcpu_notify_event(struct vcpu *vcpu);
215struct vmspace *vm_vmspace(struct vm *vm);
216struct vm_mem *vm_mem(struct vm *vm);
217
218enum vm_reg_name vm_segment_name(int seg_encoding);
219
220#endif /* _KERNEL */
221
222#define VM_DIR_READ 0
223#define VM_DIR_WRITE 1
224
225#define VM_GP_M_MASK 0x1f
226#define VM_GP_MMU_ENABLED (1 << 5)
227
228struct vm_guest_paging {
229 int flags;
230 int padding;
231};
232
233struct vie {
234 uint8_t access_size:4, sign_extend:1, dir:1, unused:2;
235 enum vm_reg_name reg;
236};
237
238struct vre {
239 uint32_t inst_syndrome;
240 uint8_t dir:1, unused:7;
241 enum vm_reg_name reg;
242};
243
244/*
245 * Identifiers for optional vmm capabilities
246 */
247enum vm_cap_type {
248 VM_CAP_UNRESTRICTED_GUEST,
249 VM_CAP_SSTC,
250 VM_CAP_MAX
251};
252
253enum vm_exitcode {
254 VM_EXITCODE_BOGUS,
255 VM_EXITCODE_ECALL,
256 VM_EXITCODE_HYP,
257 VM_EXITCODE_PAGING,
258 VM_EXITCODE_SUSPENDED,
259 VM_EXITCODE_DEBUG,
260 VM_EXITCODE_INST_EMUL,
261 VM_EXITCODE_WFI,
262 VM_EXITCODE_MAX
263};
264
265struct vm_exit {
266 uint64_t scause;
267 uint64_t sepc;
268 uint64_t stval;
269 uint64_t htval;
270 uint64_t htinst;
271 enum vm_exitcode exitcode;
272 int inst_length;
273 uint64_t pc;
274 union {
275 struct {
276 uint64_t gpa;
277 } paging;
278
279 struct {
280 uint64_t gpa;
281 struct vm_guest_paging paging;
282 struct vie vie;
283 } inst_emul;
284
285 struct {
286 uint64_t args[8];
287 } ecall;
288
289 struct {
290 enum vm_suspend_how how;
291 } suspended;
292
293 struct {
294 uint64_t scause;
295 } hyp;
296 } u;
297};
298
299#endif /* _VMM_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/vmm_dev.h created+265
......@@ -0,0 +1,265 @@
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2015 Mihai Carabas <mihai.carabas@gmail.com>
5 * Copyright (c) 2024 Ruslan Bukin <br@bsdpad.com>
6 *
7 * This software was developed by the University of Cambridge Computer
8 * Laboratory (Department of Computer Science and Technology) under Innovate
9 * UK project 105694, "Digital Security by Design (DSbD) Technology Platform
10 * Prototype".
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef _VMM_DEV_H_
35#define _VMM_DEV_H_
36
37#include <sys/domainset.h>
38
39#include <machine/vmm.h>
40
41struct vm_memmap {
42 vm_paddr_t gpa;
43 int segid; /* memory segment */
44 vm_ooffset_t segoff; /* offset into memory segment */
45 size_t len; /* mmap length */
46 int prot; /* RWX */
47 int flags;
48};
49#define VM_MEMMAP_F_WIRED 0x01
50
51struct vm_munmap {
52 vm_paddr_t gpa;
53 size_t len;
54};
55
56#define VM_MEMSEG_NAME(m) ((m)->name[0] != '\0' ? (m)->name : NULL)
57struct vm_memseg {
58 int segid;
59 size_t len;
60 char name[VM_MAX_SUFFIXLEN + 1];
61 domainset_t *ds_mask;
62 size_t ds_mask_size;
63 int ds_policy;
64};
65
66struct vm_register {
67 int cpuid;
68 int regnum; /* enum vm_reg_name */
69 uint64_t regval;
70};
71
72struct vm_register_set {
73 int cpuid;
74 unsigned int count;
75 const int *regnums; /* enum vm_reg_name */
76 uint64_t *regvals;
77};
78
79struct vm_run {
80 int cpuid;
81 cpuset_t *cpuset; /* CPU set storage */
82 size_t cpusetsize;
83 struct vm_exit *vm_exit;
84};
85
86struct vm_exception {
87 int cpuid;
88 uint64_t scause;
89};
90
91struct vm_msi {
92 uint64_t msg;
93 uint64_t addr;
94 int bus;
95 int slot;
96 int func;
97};
98
99struct vm_capability {
100 int cpuid;
101 enum vm_cap_type captype;
102 int capval;
103 int allcpus;
104};
105
106#define MAX_VM_STATS 64
107struct vm_stats {
108 int cpuid; /* in */
109 int index; /* in */
110 int num_entries; /* out */
111 struct timeval tv;
112 uint64_t statbuf[MAX_VM_STATS];
113};
114struct vm_stat_desc {
115 int index; /* in */
116 char desc[128]; /* out */
117};
118
119struct vm_suspend {
120 enum vm_suspend_how how;
121};
122
123struct vm_gla2gpa {
124 int vcpuid; /* inputs */
125 int prot; /* PROT_READ or PROT_WRITE */
126 uint64_t gla;
127 struct vm_guest_paging paging;
128 int fault; /* outputs */
129 uint64_t gpa;
130};
131
132struct vm_activate_cpu {
133 int vcpuid;
134};
135
136struct vm_cpuset {
137 int which;
138 int cpusetsize;
139 cpuset_t *cpus;
140};
141#define VM_ACTIVE_CPUS 0
142#define VM_SUSPENDED_CPUS 1
143#define VM_DEBUG_CPUS 2
144
145struct vm_aplic_descr {
146 uint64_t mem_start;
147 uint64_t mem_size;
148};
149
150struct vm_irq {
151 uint32_t irq;
152};
153
154struct vm_cpu_topology {
155 uint16_t sockets;
156 uint16_t cores;
157 uint16_t threads;
158 uint16_t maxcpus;
159};
160
161enum {
162 /* general routines */
163 IOCNUM_ABIVERS = 0,
164 IOCNUM_RUN = 1,
165 IOCNUM_SET_CAPABILITY = 2,
166 IOCNUM_GET_CAPABILITY = 3,
167 IOCNUM_SUSPEND = 4,
168 IOCNUM_REINIT = 5,
169
170 /* memory apis */
171 IOCNUM_GET_GPA_PMAP = 12,
172 IOCNUM_GLA2GPA_NOFAULT = 13,
173 IOCNUM_ALLOC_MEMSEG = 14,
174 IOCNUM_GET_MEMSEG = 15,
175 IOCNUM_MMAP_MEMSEG = 16,
176 IOCNUM_MMAP_GETNEXT = 17,
177 IOCNUM_MUNMAP_MEMSEG = 18,
178
179 /* register/state accessors */
180 IOCNUM_SET_REGISTER = 20,
181 IOCNUM_GET_REGISTER = 21,
182 IOCNUM_SET_REGISTER_SET = 24,
183 IOCNUM_GET_REGISTER_SET = 25,
184
185 /* statistics */
186 IOCNUM_VM_STATS = 50,
187 IOCNUM_VM_STAT_DESC = 51,
188
189 /* CPU Topology */
190 IOCNUM_SET_TOPOLOGY = 63,
191 IOCNUM_GET_TOPOLOGY = 64,
192
193 /* interrupt injection */
194 IOCNUM_ASSERT_IRQ = 80,
195 IOCNUM_DEASSERT_IRQ = 81,
196 IOCNUM_RAISE_MSI = 82,
197 IOCNUM_INJECT_EXCEPTION = 83,
198
199 /* vm_cpuset */
200 IOCNUM_ACTIVATE_CPU = 90,
201 IOCNUM_GET_CPUSET = 91,
202 IOCNUM_SUSPEND_CPU = 92,
203 IOCNUM_RESUME_CPU = 93,
204
205 /* vm_attach_aplic */
206 IOCNUM_ATTACH_APLIC = 110,
207};
208
209#define VM_RUN \
210 _IOWR('v', IOCNUM_RUN, struct vm_run)
211#define VM_SUSPEND \
212 _IOW('v', IOCNUM_SUSPEND, struct vm_suspend)
213#define VM_REINIT \
214 _IO('v', IOCNUM_REINIT)
215#define VM_ALLOC_MEMSEG \
216 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg)
217#define VM_GET_MEMSEG \
218 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg)
219#define VM_MMAP_MEMSEG \
220 _IOW('v', IOCNUM_MMAP_MEMSEG, struct vm_memmap)
221#define VM_MMAP_GETNEXT \
222 _IOWR('v', IOCNUM_MMAP_GETNEXT, struct vm_memmap)
223#define VM_MUNMAP_MEMSEG \
224 _IOW('v', IOCNUM_MUNMAP_MEMSEG, struct vm_munmap)
225#define VM_SET_REGISTER \
226 _IOW('v', IOCNUM_SET_REGISTER, struct vm_register)
227#define VM_GET_REGISTER \
228 _IOWR('v', IOCNUM_GET_REGISTER, struct vm_register)
229#define VM_SET_REGISTER_SET \
230 _IOW('v', IOCNUM_SET_REGISTER_SET, struct vm_register_set)
231#define VM_GET_REGISTER_SET \
232 _IOWR('v', IOCNUM_GET_REGISTER_SET, struct vm_register_set)
233#define VM_SET_CAPABILITY \
234 _IOW('v', IOCNUM_SET_CAPABILITY, struct vm_capability)
235#define VM_GET_CAPABILITY \
236 _IOWR('v', IOCNUM_GET_CAPABILITY, struct vm_capability)
237#define VM_STATS \
238 _IOWR('v', IOCNUM_VM_STATS, struct vm_stats)
239#define VM_STAT_DESC \
240 _IOWR('v', IOCNUM_VM_STAT_DESC, struct vm_stat_desc)
241#define VM_ASSERT_IRQ \
242 _IOW('v', IOCNUM_ASSERT_IRQ, struct vm_irq)
243#define VM_DEASSERT_IRQ \
244 _IOW('v', IOCNUM_DEASSERT_IRQ, struct vm_irq)
245#define VM_RAISE_MSI \
246 _IOW('v', IOCNUM_RAISE_MSI, struct vm_msi)
247#define VM_INJECT_EXCEPTION \
248 _IOW('v', IOCNUM_INJECT_EXCEPTION, struct vm_exception)
249#define VM_SET_TOPOLOGY \
250 _IOW('v', IOCNUM_SET_TOPOLOGY, struct vm_cpu_topology)
251#define VM_GET_TOPOLOGY \
252 _IOR('v', IOCNUM_GET_TOPOLOGY, struct vm_cpu_topology)
253#define VM_GLA2GPA_NOFAULT \
254 _IOWR('v', IOCNUM_GLA2GPA_NOFAULT, struct vm_gla2gpa)
255#define VM_ACTIVATE_CPU \
256 _IOW('v', IOCNUM_ACTIVATE_CPU, struct vm_activate_cpu)
257#define VM_GET_CPUS \
258 _IOW('v', IOCNUM_GET_CPUSET, struct vm_cpuset)
259#define VM_SUSPEND_CPU \
260 _IOW('v', IOCNUM_SUSPEND_CPU, struct vm_activate_cpu)
261#define VM_RESUME_CPU \
262 _IOW('v', IOCNUM_RESUME_CPU, struct vm_activate_cpu)
263#define VM_ATTACH_APLIC \
264 _IOW('v', IOCNUM_ATTACH_APLIC, struct vm_aplic_descr)
265#endif
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/vmm_instruction_emul.h created+85
......@@ -0,0 +1,85 @@
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2015 Mihai Carabas <mihai.carabas@gmail.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _VMM_INSTRUCTION_EMUL_H_
30#define _VMM_INSTRUCTION_EMUL_H_
31
32/*
33 * Callback functions to read and write memory regions.
34 */
35typedef int (*mem_region_read_t)(struct vcpu *vcpu, uint64_t gpa,
36 uint64_t *rval, int rsize, void *arg);
37typedef int (*mem_region_write_t)(struct vcpu *vcpu, uint64_t gpa,
38 uint64_t wval, int wsize, void *arg);
39
40/*
41 * Callback functions to read and write registers.
42 */
43typedef int (*reg_read_t)(struct vcpu *vcpu, uint64_t *rval, void *arg);
44typedef int (*reg_write_t)(struct vcpu *vcpu, uint64_t wval, void *arg);
45
46/*
47 * Emulate the decoded 'vie' instruction when it contains a memory operation.
48 *
49 * The callbacks 'mrr' and 'mrw' emulate reads and writes to the memory region
50 * containing 'gpa'. 'mrarg' is an opaque argument that is passed into the
51 * callback functions.
52 *
53 * 'void *vm' should be 'struct vm *' when called from kernel context and
54 * 'struct vmctx *' when called from user context.
55 *
56 */
57int vmm_emulate_instruction(struct vcpu *vcpu, uint64_t gpa, struct vie *vie,
58 struct vm_guest_paging *paging, mem_region_read_t mrr,
59 mem_region_write_t mrw, void *mrarg);
60
61/*
62 * Emulate the decoded 'vre' instruction when it contains a register access.
63 *
64 * The callbacks 'regread' and 'regwrite' emulate reads and writes to the
65 * register from 'vie'. 'regarg' is an opaque argument that is passed into the
66 * callback functions.
67 *
68 * 'void *vm' should be 'struct vm *' when called from kernel context and
69 * 'struct vmctx *' when called from user context.
70 *
71 */
72int vmm_emulate_register(struct vcpu *vcpu, struct vre *vre, reg_read_t regread,
73 reg_write_t regwrite, void *regarg);
74
75#ifdef _KERNEL
76void vm_register_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask,
77 reg_read_t reg_read, reg_write_t reg_write, void *arg);
78void vm_deregister_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask);
79
80void vm_register_inst_handler(struct vm *vm, uint64_t start, uint64_t size,
81 mem_region_read_t mmio_read, mem_region_write_t mmio_write);
82void vm_deregister_inst_handler(struct vm *vm, uint64_t start, uint64_t size);
83#endif
84
85#endif /* _VMM_INSTRUCTION_EMUL_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/vmparam.h+7-7
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
3533 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30
3634 */
3735
......@@ -211,8 +209,6 @@
211209#define PS_STRINGS_SV39 (USRSTACK_SV39 - sizeof(struct ps_strings))
212210#define PS_STRINGS_SV48 (USRSTACK_SV48 - sizeof(struct ps_strings))
213211
214#define VM_EARLY_DTB_ADDRESS (VM_MAX_KERNEL_ADDRESS - (2 * L2_SIZE))
215
216212/*
217213 * How many physical pages per kmem arena virtual page.
218214 */
......@@ -236,19 +232,22 @@
236232#define VM_INITIAL_PAGEIN 16
237233#endif
238234
239#define UMA_MD_SMALL_ALLOC
235#define UMA_USE_DMAP
240236
241237#ifndef LOCORE
242238extern vm_paddr_t dmap_phys_base;
243239extern vm_paddr_t dmap_phys_max;
244240extern vm_offset_t dmap_max_addr;
245extern vm_offset_t init_pt_va;
246241#endif
247242
248243#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
249244
245/*
246 * The top of KVA is reserved for early device mappings.
247 */
250248#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS
251#define PMAP_MAPDEV_EARLY_SIZE L2_SIZE
249#define DEVMAP_MIN_VADDR (DEVMAP_MAX_VADDR - PMAP_MAPDEV_EARLY_SIZE)
250#define PMAP_MAPDEV_EARLY_SIZE (4 * L2_SIZE)
252251
253252/*
254253 * No non-transparent large page support in the pmap.
......@@ -259,5 +258,6 @@ extern vm_offset_t init_pt_va;
259258 * Need a page dump array for minidump.
260259 */
261260#define MINIDUMP_PAGE_TRACKING 1
261#define MINIDUMP_STARTUP_PAGE_TRACKING 1
262262
263263#endif /* !_MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/fenv.h deleted-348
......@@ -1,348 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/cdefs.h>
33#include <sys/_types.h>
34#include <ieeefp.h>
35
36#ifndef __fenv_static
37#define __fenv_static static
38#endif
39
40typedef __uint16_t fexcept_t;
41
42/* Exception flags */
43#define FE_INVALID 0x01
44#define FE_DENORMAL 0x02
45#define FE_DIVBYZERO 0x04
46#define FE_OVERFLOW 0x08
47#define FE_UNDERFLOW 0x10
48#define FE_INEXACT 0x20
49#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
50 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
51
52/* Rounding modes */
53#define FE_TONEAREST 0x0000
54#define FE_DOWNWARD 0x0400
55#define FE_UPWARD 0x0800
56#define FE_TOWARDZERO 0x0c00
57#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
58 FE_UPWARD | FE_TOWARDZERO)
59
60/*
61 * As compared to the x87 control word, the SSE unit's control word
62 * has the rounding control bits offset by 3 and the exception mask
63 * bits offset by 7.
64 */
65#define _SSE_ROUND_SHIFT 3
66#define _SSE_EMASK_SHIFT 7
67
68#ifdef __i386__
69/*
70 * To preserve binary compatibility with FreeBSD 5.3, we pack the
71 * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
72 */
73typedef struct {
74 __uint16_t __control;
75 __uint16_t __mxcsr_hi;
76 __uint16_t __status;
77 __uint16_t __mxcsr_lo;
78 __uint32_t __tag;
79 char __other[16];
80} fenv_t;
81#else /* __amd64__ */
82typedef struct {
83 struct {
84 __uint32_t __control;
85 __uint32_t __status;
86 __uint32_t __tag;
87 char __other[16];
88 } __x87;
89 __uint32_t __mxcsr;
90} fenv_t;
91#endif /* __i386__ */
92
93__BEGIN_DECLS
94
95/* Default floating-point environment */
96extern const fenv_t __fe_dfl_env;
97#define FE_DFL_ENV (&__fe_dfl_env)
98
99#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \
100 : "st", "st(1)", "st(2)", "st(3)", "st(4)", \
101 "st(5)", "st(6)", "st(7)")
102#define __fwait() __asm __volatile("fwait")
103
104int fegetenv(fenv_t *__envp);
105int feholdexcept(fenv_t *__envp);
106int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
107int feraiseexcept(int __excepts);
108int feupdateenv(const fenv_t *__envp);
109
110__fenv_static inline int
111fegetround(void)
112{
113 __uint16_t __control;
114
115 /*
116 * We assume that the x87 and the SSE unit agree on the
117 * rounding mode. Reading the control word on the x87 turns
118 * out to be about 5 times faster than reading it on the SSE
119 * unit on an Opteron 244.
120 */
121 __fnstcw(&__control);
122 return (__control & _ROUND_MASK);
123}
124
125#if __BSD_VISIBLE
126
127int feenableexcept(int __mask);
128int fedisableexcept(int __mask);
129
130/* We currently provide no external definition of fegetexcept(). */
131static inline int
132fegetexcept(void)
133{
134 __uint16_t __control;
135
136 /*
137 * We assume that the masks for the x87 and the SSE unit are
138 * the same.
139 */
140 __fnstcw(&__control);
141 return (~__control & FE_ALL_EXCEPT);
142}
143
144#endif /* __BSD_VISIBLE */
145
146#ifdef __i386__
147
148/* After testing for SSE support once, we cache the result in __has_sse. */
149enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
150extern enum __sse_support __has_sse;
151int __test_sse(void);
152#ifdef __SSE__
153#define __HAS_SSE() 1
154#else
155#define __HAS_SSE() (__has_sse == __SSE_YES || \
156 (__has_sse == __SSE_UNK && __test_sse()))
157#endif
158
159#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \
160 ((env).__mxcsr_lo))
161#define __set_mxcsr(env, x) do { \
162 (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \
163 (env).__mxcsr_lo = (__uint16_t)(x); \
164} while (0)
165
166__fenv_static inline int
167feclearexcept(int __excepts)
168{
169 fenv_t __env;
170 __uint32_t __mxcsr;
171
172 if (__excepts == FE_ALL_EXCEPT) {
173 __fnclex();
174 } else {
175 __fnstenv(&__env);
176 __env.__status &= ~__excepts;
177 __fldenv(&__env);
178 }
179 if (__HAS_SSE()) {
180 __stmxcsr(&__mxcsr);
181 __mxcsr &= ~__excepts;
182 __ldmxcsr(&__mxcsr);
183 }
184 return (0);
185}
186
187__fenv_static inline int
188fegetexceptflag(fexcept_t *__flagp, int __excepts)
189{
190 __uint32_t __mxcsr;
191 __uint16_t __status;
192
193 __fnstsw(&__status);
194 if (__HAS_SSE())
195 __stmxcsr(&__mxcsr);
196 else
197 __mxcsr = 0;
198 *__flagp = (__mxcsr | __status) & __excepts;
199 return (0);
200}
201
202__fenv_static inline int
203fetestexcept(int __excepts)
204{
205 __uint32_t __mxcsr;
206 __uint16_t __status;
207
208 __fnstsw(&__status);
209 if (__HAS_SSE())
210 __stmxcsr(&__mxcsr);
211 else
212 __mxcsr = 0;
213 return ((__status | __mxcsr) & __excepts);
214}
215
216__fenv_static inline int
217fesetround(int __round)
218{
219 __uint32_t __mxcsr;
220 __uint16_t __control;
221
222 if (__round & ~_ROUND_MASK)
223 return (-1);
224
225 __fnstcw(&__control);
226 __control &= ~_ROUND_MASK;
227 __control |= __round;
228 __fldcw(&__control);
229
230 if (__HAS_SSE()) {
231 __stmxcsr(&__mxcsr);
232 __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
233 __mxcsr |= __round << _SSE_ROUND_SHIFT;
234 __ldmxcsr(&__mxcsr);
235 }
236
237 return (0);
238}
239
240__fenv_static inline int
241fesetenv(const fenv_t *__envp)
242{
243 fenv_t __env = *__envp;
244 __uint32_t __mxcsr;
245
246 __mxcsr = __get_mxcsr(__env);
247 __set_mxcsr(__env, 0xffffffff);
248 /*
249 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
250 * instruction clobbers the i387 register stack. This happens because
251 * we restore the tag word from the saved environment. Normally, this
252 * would happen anyway and we wouldn't care, because the ABI allows
253 * function calls to clobber the i387 regs. However, fesetenv() is
254 * inlined, so we need to be more careful.
255 */
256 __fldenvx(__env);
257 if (__HAS_SSE())
258 __ldmxcsr(&__mxcsr);
259 return (0);
260}
261
262#else /* __amd64__ */
263
264__fenv_static inline int
265feclearexcept(int __excepts)
266{
267 fenv_t __env;
268
269 if (__excepts == FE_ALL_EXCEPT) {
270 __fnclex();
271 } else {
272 __fnstenv(&__env.__x87);
273 __env.__x87.__status &= ~__excepts;
274 __fldenv(&__env.__x87);
275 }
276 __stmxcsr(&__env.__mxcsr);
277 __env.__mxcsr &= ~__excepts;
278 __ldmxcsr(&__env.__mxcsr);
279 return (0);
280}
281
282__fenv_static inline int
283fegetexceptflag(fexcept_t *__flagp, int __excepts)
284{
285 __uint32_t __mxcsr;
286 __uint16_t __status;
287
288 __stmxcsr(&__mxcsr);
289 __fnstsw(&__status);
290 *__flagp = (__mxcsr | __status) & __excepts;
291 return (0);
292}
293
294__fenv_static inline int
295fetestexcept(int __excepts)
296{
297 __uint32_t __mxcsr;
298 __uint16_t __status;
299
300 __stmxcsr(&__mxcsr);
301 __fnstsw(&__status);
302 return ((__status | __mxcsr) & __excepts);
303}
304
305__fenv_static inline int
306fesetround(int __round)
307{
308 __uint32_t __mxcsr;
309 __uint16_t __control;
310
311 if (__round & ~_ROUND_MASK)
312 return (-1);
313
314 __fnstcw(&__control);
315 __control &= ~_ROUND_MASK;
316 __control |= __round;
317 __fldcw(&__control);
318
319 __stmxcsr(&__mxcsr);
320 __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
321 __mxcsr |= __round << _SSE_ROUND_SHIFT;
322 __ldmxcsr(&__mxcsr);
323
324 return (0);
325}
326
327__fenv_static inline int
328fesetenv(const fenv_t *__envp)
329{
330
331 /*
332 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
333 * instruction clobbers the i387 register stack. This happens because
334 * we restore the tag word from the saved environment. Normally, this
335 * would happen anyway and we wouldn't care, because the ABI allows
336 * function calls to clobber the i387 regs. However, fesetenv() is
337 * inlined, so we need to be more careful.
338 */
339 __fldenvx(__envp->__x87);
340 __ldmxcsr(&__envp->__mxcsr);
341 return (0);
342}
343
344#endif /* __i386__ */
345
346__END_DECLS
347
348#endif /* !_FENV_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/float.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/float.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/floatingpoint.h deleted-44
......@@ -1,44 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1993 Andrew Moore, Talke Studio
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
36 */
37
38#ifndef _FLOATINGPOINT_H_
39#define _FLOATINGPOINT_H_
40
41#include <sys/cdefs.h>
42#include <machine/ieeefp.h>
43
44#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/_align.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_align.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/_bus.h+7-24
......@@ -1,30 +1,13 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
2 * Copyright (c) 2005 The FreeBSD Foundation.
53 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer,
11 * without modification, immediately at the beginning of the file.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
4 * SPDX-License-Identifier: BSD-2-Clause
165 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
6 * Derived in part from NetBSD's bus.h files by (alphabetically):
7 * Christopher G. Demetriou
8 * Charles M. Hannum
9 * Jason Thorpe
10 * The NetBSD Foundation.
2811 */
2912
3013#ifndef I386_INCLUDE__BUS_H
lib/libc/include/x86-freebsd-none/machine/_inttypes.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_inttypes.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/_limits.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_limits.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/_stdint.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_stdint.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/_types.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_types.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/asm.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
3533 */
3634
3735#ifndef _MACHINE_ASM_H_
lib/libc/include/x86-freebsd-none/machine/atomic.h+20-27
......@@ -49,8 +49,8 @@ static __inline void
4949__mbk(void)
5050{
5151
52 __asm __volatile("lock; addl $0,%%fs:%0"
53 : "+m" (*(u_int *)__OFFSETOF_MONITORBUF) : : "memory", "cc");
52 __asm __volatile("lock; addl $0,%%fs:%c0"
53 : : "i" (__OFFSETOF_MONITORBUF) : "memory", "cc");
5454}
5555
5656static __inline void
......@@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)
249249
250250#define ATOMIC_LOAD(TYPE) \
251251static __inline u_##TYPE \
252atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
252atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
253253{ \
254254 u_##TYPE res; \
255255 \
......@@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void)
299299
300300#ifdef _KERNEL
301301
302#ifdef WANT_FUNCTIONS
303int atomic_cmpset_64_i386(volatile uint64_t *, uint64_t, uint64_t);
304int atomic_cmpset_64_i586(volatile uint64_t *, uint64_t, uint64_t);
305uint64_t atomic_load_acq_64_i386(volatile uint64_t *);
306uint64_t atomic_load_acq_64_i586(volatile uint64_t *);
307void atomic_store_rel_64_i386(volatile uint64_t *, uint64_t);
308void atomic_store_rel_64_i586(volatile uint64_t *, uint64_t);
309uint64_t atomic_swap_64_i386(volatile uint64_t *, uint64_t);
310uint64_t atomic_swap_64_i586(volatile uint64_t *, uint64_t);
311#endif
312
313302/* I486 does not support SMP or CMPXCHG8B. */
314303static __inline int
315304atomic_cmpset_64_i386(volatile uint64_t *dst, uint64_t expect, uint64_t src)
......@@ -353,12 +342,12 @@ atomic_fcmpset_64_i386(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
353342}
354343
355344static __inline uint64_t
356atomic_load_acq_64_i386(volatile uint64_t *p)
345atomic_load_acq_64_i386(const volatile uint64_t *p)
357346{
358 volatile uint32_t *q;
347 const volatile uint32_t *q;
359348 uint64_t res;
360349
361 q = (volatile uint32_t *)p;
350 q = (const volatile uint32_t *)p;
362351 __asm __volatile(
363352 " pushfl ; "
364353 " cli ; "
......@@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
447436 return (res);
448437}
449438
439/*
440 * Architecturally always writes back some value to '*p' so will trigger
441 * a #GP(0) on read-only mappings.
442 */
450443static __inline uint64_t
451atomic_load_acq_64_i586(volatile uint64_t *p)
444atomic_load_acq_64_i586(const volatile uint64_t *p)
452445{
453446 uint64_t res;
454447
......@@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p)
456449 " movl %%ebx,%%eax ; "
457450 " movl %%ecx,%%edx ; "
458451 " lock; cmpxchg8b %1"
459 : "=&A" (res), /* 0 */
460 "+m" (*p) /* 1 */
461 : : "memory", "cc");
452 : "=&A" (res) /* 0 */
453 : "m" (*p) /* 1 */
454 : "memory", "cc");
462455 return (res);
463456}
464457
......@@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
514507}
515508
516509static __inline uint64_t
517atomic_load_acq_64(volatile uint64_t *p)
510atomic_load_acq_64(const volatile uint64_t *p)
518511{
519512
520513 if ((cpu_feature & CPUID_CX8) == 0)
......@@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long);
614607#undef ATOMIC_STORE
615608#undef ATOMIC_LOADSTORE
616609
617#ifndef WANT_FUNCTIONS
618
619610static __inline int
620611atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
621612{
......@@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v)
842833#define atomic_subtract_rel_ptr(p, v) \
843834 atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v))
844835#define atomic_load_acq_ptr(p) \
845 atomic_load_acq_int((volatile u_int *)(p))
836 atomic_load_acq_int((const volatile u_int *)(p))
846837#define atomic_store_rel_ptr(p, v) \
847838 atomic_store_rel_int((volatile u_int *)(p), (v))
848839#define atomic_cmpset_ptr(dst, old, new) \
......@@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v)
865856 atomic_swap_int((volatile u_int *)(p), (u_int)(v))
866857#define atomic_readandclear_ptr(p) \
867858 atomic_readandclear_int((volatile u_int *)(p))
868
869#endif /* !WANT_FUNCTIONS */
859#define atomic_testandclear_ptr(p, val) \
860 atomic_testandclear_int((volatile u_int *)(p), (val))
861#define atomic_testandset_ptr(p, val) \
862 atomic_testandset_int((volatile u_int *)(p), (val))
870863
871864#if defined(_KERNEL)
872865#define mb() __mbk()
lib/libc/include/x86-freebsd-none/machine/bus.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/bus.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/clock.h deleted-5
......@@ -1,5 +0,0 @@
1/*
2 * This file is in the public domain.
3 */
4
5#include <x86/clock.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/cpu.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
3533 */
3634
3735#ifndef _MACHINE_CPU_H_
lib/libc/include/x86-freebsd-none/machine/cpufunc.h+1-10
......@@ -63,15 +63,6 @@ bsfl(u_int mask)
6363 return (result);
6464}
6565
66static __inline __pure2 u_int
67bsrl(u_int mask)
68{
69 u_int result;
70
71 __asm("bsrl %1,%0" : "=r" (result) : "rm" (mask) : "cc");
72 return (result);
73}
74
7566static __inline void
7667clflush(u_long addr)
7768{
......@@ -83,7 +74,7 @@ static __inline void
8374clflushopt(u_long addr)
8475{
8576
86 __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr));
77 __asm __volatile("clflushopt %0" : : "m" (*(char *)addr));
8778}
8879
8980static __inline void
lib/libc/include/x86-freebsd-none/machine/dump.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/dump.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/elf.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/elf.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/endian.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/endian.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/exec.h deleted-39
......@@ -1,39 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)exec.h 8.1 (Berkeley) 6/11/93
32 */
33
34#ifndef _MACHINE_EXEC_H_
35#define _MACHINE_EXEC_H_
36
37#define __LDPGSZ 4096
38
39#endif /* !_MACHINE_EXEC_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/float.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/float.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/floatingpoint.h deleted-44
......@@ -1,44 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1993 Andrew Moore, Talke Studio
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
36 */
37
38#ifndef _FLOATINGPOINT_H_
39#define _FLOATINGPOINT_H_
40
41#include <sys/cdefs.h>
42#include <machine/ieeefp.h>
43
44#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/ieeefp.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
3735 */
3836
3937#ifndef _MACHINE_IEEEFP_H_
lib/libc/include/x86-freebsd-none/machine/in_cksum.h-1
......@@ -29,7 +29,6 @@
2929 * SUCH DAMAGE.
3030 *
3131 * from tahoe: in_cksum.c 1.2 86/01/05
32 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
3332 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
3433 */
3534
lib/libc/include/x86-freebsd-none/machine/metadata.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/metadata.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/npx.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
3533 */
3634
3735/*
lib/libc/include/x86-freebsd-none/machine/ofw_machdep.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/ofw_machdep.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/param.h-11
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
3533 */
3634
3735#ifndef _I386_INCLUDE_PARAM_H_
......@@ -43,9 +41,7 @@
4341 * Machine dependent constants for Intel 386.
4442 */
4543
46#define __HAVE_ACPI
4744#define __HAVE_PIR
48#define __PCI_REROUTE_INTERRUPT
4945
5046#ifndef MACHINE
5147#define MACHINE "i386"
......@@ -146,19 +142,12 @@
146142/*
147143 * Mach derived conversion macros
148144 */
149#define trunc_page(x) ((x) & ~PAGE_MASK)
150#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
151145#define trunc_4mpage(x) ((x) & ~PDRMASK)
152146#define round_4mpage(x) ((((x)) + PDRMASK) & ~PDRMASK)
153147
154#define atop(x) ((x) >> PAGE_SHIFT)
155#define ptoa(x) ((x) << PAGE_SHIFT)
156
157148#define i386_btop(x) ((x) >> PAGE_SHIFT)
158149#define i386_ptob(x) ((x) << PAGE_SHIFT)
159150
160#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
161
162151#define INKERNEL(va) (TRUE)
163152
164153#endif /* !_I386_INCLUDE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/pcb.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
3533 */
3634
3735#ifndef _I386_PCB_H_
lib/libc/include/x86-freebsd-none/machine/pcpu.h+20-27
......@@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
108108/*
109109 * Evaluates to the address of the per-cpu variable name.
110110 */
111#define __PCPU_PTR(name) __extension__ ({ \
112 __pcpu_type(name) *__p; \
113 \
114 __asm __volatile("movl %%fs:%1,%0; addl %2,%0" \
115 : "=r" (__p) \
116 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \
117 "i" (__pcpu_offset(name))); \
118 \
119 __p; \
120})
111#define __PCPU_PTR(name) \
112 (&get_pcpu()->name)
121113
122114/*
123115 * Evaluates to the value of the per-cpu variable name.
......@@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
126118 __pcpu_type(name) __res; \
127119 struct __s { \
128120 u_char __b[MIN(sizeof(__res), 4)]; \
129 } __s; \
121 }; \
130122 \
131123 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \
132124 sizeof(__res) == 4) { \
133 __asm __volatile("mov %%fs:%1,%0" \
134 : "=r" (__s) \
135 : "m" (*(struct __s *)(__pcpu_offset(name)))); \
136 *(struct __s *)(void *)&__res = __s; \
125 __asm __volatile("mov %%fs:%c1,%0" \
126 : "=r" (*(struct __s *)(void *)&__res) \
127 : "i" (__pcpu_offset(name))); \
137128 } else { \
138129 __res = *__PCPU_PTR(name); \
139130 } \
......@@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
148139 __pcpu_type(name) __val; \
149140 struct __s { \
150141 u_char __b[MIN(sizeof(__val), 4)]; \
151 } __s; \
142 }; \
152143 \
153144 __val = (val); \
154145 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
155146 sizeof(__val) == 4) { \
156 __s = *(struct __s *)(void *)&__val; \
157 __asm __volatile("add %1,%%fs:%0" \
158 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
159 : "r" (__s)); \
147 __asm __volatile("add %1,%%fs:%c0" \
148 : \
149 : "i" (__pcpu_offset(name)), \
150 "r" (*(struct __s *)(void *)&__val) \
151 : "cc", "memory"); \
160152 } else \
161153 *__PCPU_PTR(name) += __val; \
162154} while (0)
......@@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
168160 __pcpu_type(name) __val; \
169161 struct __s { \
170162 u_char __b[MIN(sizeof(__val), 4)]; \
171 } __s; \
163 }; \
172164 \
173165 __val = (val); \
174166 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
175167 sizeof(__val) == 4) { \
176 __s = *(struct __s *)(void *)&__val; \
177 __asm __volatile("mov %1,%%fs:%0" \
178 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
179 : "r" (__s)); \
168 __asm __volatile("mov %1,%%fs:%c0" \
169 : \
170 : "i" (__pcpu_offset(name)), \
171 "r" (*(struct __s *)(void *)&__val) \
172 : "memory"); \
180173 } else { \
181174 *__PCPU_PTR(name) = __val; \
182175 } \
......@@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
185178#define get_pcpu() __extension__ ({ \
186179 struct pcpu *__pc; \
187180 \
188 __asm __volatile("movl %%fs:%1,%0" \
181 __asm __volatile("movl %%fs:%c1,%0" \
189182 : "=r" (__pc) \
190 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \
183 : "i" (__pcpu_offset(pc_prvspace))); \
191184 __pc; \
192185})
193186
lib/libc/include/x86-freebsd-none/machine/pcpu_aux.h+4-4
......@@ -49,8 +49,8 @@ __curthread(void)
4949{
5050 struct thread *td;
5151
52 __asm("movl %%fs:%1,%0" : "=r" (td)
53 : "m" (*(char *)offsetof(struct pcpu, pc_curthread)));
52 __asm("movl %%fs:%c1,%0" : "=r" (td)
53 : "i" (offsetof(struct pcpu, pc_curthread)));
5454 return (td);
5555}
5656#define curthread (__curthread())
......@@ -60,8 +60,8 @@ __curpcb(void)
6060{
6161 struct pcb *pcb;
6262
63 __asm("movl %%fs:%1,%0" : "=r" (pcb)
64 : "m" (*(char *)offsetof(struct pcpu, pc_curpcb)));
63 __asm("movl %%fs:%c1,%0" : "=r" (pcb)
64 : "i" (offsetof(struct pcpu, pc_curpcb)));
6565 return (pcb);
6666}
6767#define curpcb (__curpcb())
lib/libc/include/x86-freebsd-none/machine/pmap.h+3-6
......@@ -37,9 +37,6 @@
3737 * map the page tables using the pagetables themselves. This is done to
3838 * reduce the impact on kernel virtual memory for lots of sparse address
3939 * space, and to reduce the cost of memory to each process.
40 *
41 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
42 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
4340 */
4441
4542#ifndef _MACHINE_PMAP_H_
......@@ -83,7 +80,7 @@
8380 * 4KB (PTE) page mappings have identical settings for the following fields:
8481 */
8582#define PG_PTE_PROMOTE (PG_MANAGED | PG_W | PG_G | PG_PTE_PAT | \
86 PG_M | PG_A | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V)
83 PG_M | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V)
8784
8885/*
8986 * Page Protection Exception bits
......@@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem);
221218void *pmap_bios16_enter(void);
222219void pmap_bios16_leave(void *handle);
223220void pmap_bootstrap(vm_paddr_t);
224int pmap_cache_bits(pmap_t, int mode, boolean_t is_pde);
221int pmap_cache_bits(pmap_t, int mode, bool is_pde);
225222int pmap_change_attr(vm_offset_t, vm_size_t, int);
226223caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits);
227224void pmap_cp_slow0_map(vm_offset_t kaddr, int plen, vm_page_t *ma);
......@@ -239,7 +236,7 @@ void pmap_ksetrw(vm_offset_t va);
239236void *pmap_mapbios(vm_paddr_t, vm_size_t);
240237void *pmap_mapdev(vm_paddr_t, vm_size_t);
241238void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);
242boolean_t pmap_page_is_mapped(vm_page_t m);
239bool pmap_page_is_mapped(vm_page_t m);
243240void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
244241vm_paddr_t pmap_pg_frame(vm_paddr_t pa);
245242bool pmap_ps_enabled(pmap_t pmap);
lib/libc/include/x86-freebsd-none/machine/pmap_base.h+8-8
......@@ -58,8 +58,8 @@ struct pmap_methods {
5858 void *(*pm_bios16_enter)(void);
5959 void (*pm_bios16_leave)(void *handle);
6060 void (*pm_bootstrap)(vm_paddr_t firstaddr);
61 boolean_t (*pm_is_valid_memattr)(pmap_t, vm_memattr_t);
62 int (*pm_cache_bits)(pmap_t, int, boolean_t);
61 bool (*pm_is_valid_memattr)(pmap_t, vm_memattr_t);
62 int (*pm_cache_bits)(pmap_t, int, bool);
6363 bool (*pm_ps_enabled)(pmap_t);
6464 void (*pm_pinit0)(pmap_t);
6565 int (*pm_pinit)(pmap_t);
......@@ -84,13 +84,13 @@ struct pmap_methods {
8484 void (*pm_object_init_pt)(pmap_t, vm_offset_t, vm_object_t,
8585 vm_pindex_t, vm_size_t);
8686 void (*pm_unwire)(pmap_t, vm_offset_t, vm_offset_t);
87 boolean_t (*pm_page_exists_quick)(pmap_t, vm_page_t);
87 bool (*pm_page_exists_quick)(pmap_t, vm_page_t);
8888 int (*pm_page_wired_mappings)(vm_page_t);
89 boolean_t (*pm_page_is_mapped)(vm_page_t);
89 bool (*pm_page_is_mapped)(vm_page_t);
9090 void (*pm_remove_pages)(pmap_t);
91 boolean_t (*pm_is_modified)(vm_page_t);
92 boolean_t (*pm_is_prefaultable)(pmap_t, vm_offset_t);
93 boolean_t (*pm_is_referenced)(vm_page_t);
91 bool (*pm_is_modified)(vm_page_t);
92 bool (*pm_is_prefaultable)(pmap_t, vm_offset_t);
93 bool (*pm_is_referenced)(vm_page_t);
9494 void (*pm_remove_write)(vm_page_t);
9595 int (*pm_ts_referenced)(vm_page_t);
9696 void *(*pm_mapdev_attr)(vm_paddr_t, vm_size_t, int, int);
......@@ -107,7 +107,7 @@ struct pmap_methods {
107107 void (*pm_remove_all)(vm_page_t);
108108 void (*pm_init)(void);
109109 void (*pm_init_pat)(void);
110 void (*pm_growkernel)(vm_offset_t);
110 int (*pm_growkernel)(vm_offset_t);
111111 void (*pm_invalidate_page)(pmap_t, vm_offset_t);
112112 void (*pm_invalidate_range)(pmap_t, vm_offset_t, vm_offset_t);
113113 void (*pm_invalidate_all)(pmap_t);
lib/libc/include/x86-freebsd-none/machine/pmap_nopae.h-3
......@@ -44,9 +44,6 @@
4444 * map the page tables using the pagetables themselves. This is done to
4545 * reduce the impact on kernel virtual memory for lots of sparse address
4646 * space, and to reduce the cost of memory to each process.
47 *
48 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
49 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
5047 */
5148
5249#ifndef _MACHINE_PMAP_NOPAE_H
lib/libc/include/x86-freebsd-none/machine/pmap_pae.h-3
......@@ -44,9 +44,6 @@
4444 * map the page tables using the pagetables themselves. This is done to
4545 * reduce the impact on kernel virtual memory for lots of sparse address
4646 * space, and to reduce the cost of memory to each process.
47 *
48 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
49 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
5047 */
5148
5249#ifndef _MACHINE_PMAP_PAE_H
lib/libc/include/x86-freebsd-none/machine/proc.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3230 */
3331
3432#ifndef _MACHINE_PROC_H_
lib/libc/include/x86-freebsd-none/machine/profile.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
3230 */
3331
3432#ifndef _MACHINE_PROFILE_H_
lib/libc/include/x86-freebsd-none/machine/psl.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/psl.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/ptrace.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/ptrace.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/reg.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/reg.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/reloc.h deleted-50
......@@ -1,50 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)reloc.h 8.1 (Berkeley) 6/10/93
32 */
33
34#ifndef _I386_MACHINE_RELOC_H_
35#define _I386_MACHINE_RELOC_H_
36
37/* Relocation format. */
38struct relocation_info {
39 int r_address; /* offset in text or data segment */
40 unsigned int r_symbolnum : 24, /* ordinal number of add symbol */
41 r_pcrel : 1, /* 1 if value should be pc-relative */
42 r_length : 2, /* log base 2 of value's width */
43 r_extern : 1, /* 1 if need to add symbol to value */
44 r_baserel : 1, /* linkage table relative */
45 r_jmptable : 1, /* relocate to jump table */
46 r_relative : 1, /* load address relative */
47 r_copy : 1; /* run time copy */
48};
49
50#endif
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/resource.h-2
......@@ -39,8 +39,6 @@
3939#define SYS_RES_DRQ 2 /* isa dma lines */
4040#define SYS_RES_MEMORY 3 /* i/o memory */
4141#define SYS_RES_IOPORT 4 /* i/o ports */
42#ifdef NEW_PCIB
4342#define PCI_RES_BUS 5 /* PCI bus numbers */
44#endif
4543
4644#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/runq.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RUNQ_H_
30#define _MACHINE_RUNQ_H_
31
32#define RQB_LEN (2) /* Number of priority status words. */
33#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */
34#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */
35
36#define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1)))
37#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
38
39#define RQB_FFS(word) (ffs(word) - 1)
40
41/*
42 * Type of run queue status word.
43 */
44typedef u_int32_t rqb_word_t;
45
46#endif
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/sdt_machdep.h created+19
......@@ -0,0 +1,19 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org>
5 */
6
7#ifndef _SYS_SDT_MACHDEP_H_
8#define _SYS_SDT_MACHDEP_H_
9
10#define _SDT_ASM_PATCH_INSTR "nop; nop; nop; nop; nop"
11
12/*
13 * Work around an apparent clang bug or limitation which prevents the use of the
14 * "i" (immediate) constraint with the probe structure.
15 */
16#define _SDT_ASM_PROBE_CONSTRAINT "Ws"
17#define _SDT_ASM_PROBE_OPERAND "p"
18
19#endif
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/segments.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
3634 */
3735
3836#ifndef _MACHINE_SEGMENTS_H_
lib/libc/include/x86-freebsd-none/machine/setjmp.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/setjmp.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/signal.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.1 (Berkeley) 6/11/93
3230 */
3331
3432#ifndef _MACHINE_SIGNAL_H_
lib/libc/include/x86-freebsd-none/machine/sysarch.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/sysarch.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/tls.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/tls.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/trap.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/trap.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/tss.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)tss.h 5.4 (Berkeley) 1/18/91
3533 */
3634
3735#ifndef _MACHINE_TSS_H_
lib/libc/include/x86-freebsd-none/machine/vdso.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/vdso.h>
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/vm.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2009 Hudson River Trading LLC
5 * Written by: John H. Baldwin <jhb@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_VM_H_
31#define _MACHINE_VM_H_
32
33#include <machine/specialreg.h>
34
35/* Memory attributes. */
36#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE)
37#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING)
38#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH)
39#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED)
40#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK)
41#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED)
42
43#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
44#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE
45
46#endif /* !_MACHINE_VM_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/machine/vmparam.h+1-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
3735 */
3836
3937#ifndef _MACHINE_VMPARAM_H_
......@@ -248,5 +246,6 @@
248246 * Need a page dump array for minidump.
249247 */
250248#define MINIDUMP_PAGE_TRACKING 1
249#define MINIDUMP_STARTUP_PAGE_TRACKING 0
251250
252251#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/x86-freebsd-none/stdarg.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/stdarg.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/fenv.h deleted-348
......@@ -1,348 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/cdefs.h>
33#include <sys/_types.h>
34#include <ieeefp.h>
35
36#ifndef __fenv_static
37#define __fenv_static static
38#endif
39
40typedef __uint16_t fexcept_t;
41
42/* Exception flags */
43#define FE_INVALID 0x01
44#define FE_DENORMAL 0x02
45#define FE_DIVBYZERO 0x04
46#define FE_OVERFLOW 0x08
47#define FE_UNDERFLOW 0x10
48#define FE_INEXACT 0x20
49#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
50 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
51
52/* Rounding modes */
53#define FE_TONEAREST 0x0000
54#define FE_DOWNWARD 0x0400
55#define FE_UPWARD 0x0800
56#define FE_TOWARDZERO 0x0c00
57#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
58 FE_UPWARD | FE_TOWARDZERO)
59
60/*
61 * As compared to the x87 control word, the SSE unit's control word
62 * has the rounding control bits offset by 3 and the exception mask
63 * bits offset by 7.
64 */
65#define _SSE_ROUND_SHIFT 3
66#define _SSE_EMASK_SHIFT 7
67
68#ifdef __i386__
69/*
70 * To preserve binary compatibility with FreeBSD 5.3, we pack the
71 * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
72 */
73typedef struct {
74 __uint16_t __control;
75 __uint16_t __mxcsr_hi;
76 __uint16_t __status;
77 __uint16_t __mxcsr_lo;
78 __uint32_t __tag;
79 char __other[16];
80} fenv_t;
81#else /* __amd64__ */
82typedef struct {
83 struct {
84 __uint32_t __control;
85 __uint32_t __status;
86 __uint32_t __tag;
87 char __other[16];
88 } __x87;
89 __uint32_t __mxcsr;
90} fenv_t;
91#endif /* __i386__ */
92
93__BEGIN_DECLS
94
95/* Default floating-point environment */
96extern const fenv_t __fe_dfl_env;
97#define FE_DFL_ENV (&__fe_dfl_env)
98
99#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \
100 : "st", "st(1)", "st(2)", "st(3)", "st(4)", \
101 "st(5)", "st(6)", "st(7)")
102#define __fwait() __asm __volatile("fwait")
103
104int fegetenv(fenv_t *__envp);
105int feholdexcept(fenv_t *__envp);
106int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
107int feraiseexcept(int __excepts);
108int feupdateenv(const fenv_t *__envp);
109
110__fenv_static inline int
111fegetround(void)
112{
113 __uint16_t __control;
114
115 /*
116 * We assume that the x87 and the SSE unit agree on the
117 * rounding mode. Reading the control word on the x87 turns
118 * out to be about 5 times faster than reading it on the SSE
119 * unit on an Opteron 244.
120 */
121 __fnstcw(&__control);
122 return (__control & _ROUND_MASK);
123}
124
125#if __BSD_VISIBLE
126
127int feenableexcept(int __mask);
128int fedisableexcept(int __mask);
129
130/* We currently provide no external definition of fegetexcept(). */
131static inline int
132fegetexcept(void)
133{
134 __uint16_t __control;
135
136 /*
137 * We assume that the masks for the x87 and the SSE unit are
138 * the same.
139 */
140 __fnstcw(&__control);
141 return (~__control & FE_ALL_EXCEPT);
142}
143
144#endif /* __BSD_VISIBLE */
145
146#ifdef __i386__
147
148/* After testing for SSE support once, we cache the result in __has_sse. */
149enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
150extern enum __sse_support __has_sse;
151int __test_sse(void);
152#ifdef __SSE__
153#define __HAS_SSE() 1
154#else
155#define __HAS_SSE() (__has_sse == __SSE_YES || \
156 (__has_sse == __SSE_UNK && __test_sse()))
157#endif
158
159#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \
160 ((env).__mxcsr_lo))
161#define __set_mxcsr(env, x) do { \
162 (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \
163 (env).__mxcsr_lo = (__uint16_t)(x); \
164} while (0)
165
166__fenv_static inline int
167feclearexcept(int __excepts)
168{
169 fenv_t __env;
170 __uint32_t __mxcsr;
171
172 if (__excepts == FE_ALL_EXCEPT) {
173 __fnclex();
174 } else {
175 __fnstenv(&__env);
176 __env.__status &= ~__excepts;
177 __fldenv(&__env);
178 }
179 if (__HAS_SSE()) {
180 __stmxcsr(&__mxcsr);
181 __mxcsr &= ~__excepts;
182 __ldmxcsr(&__mxcsr);
183 }
184 return (0);
185}
186
187__fenv_static inline int
188fegetexceptflag(fexcept_t *__flagp, int __excepts)
189{
190 __uint32_t __mxcsr;
191 __uint16_t __status;
192
193 __fnstsw(&__status);
194 if (__HAS_SSE())
195 __stmxcsr(&__mxcsr);
196 else
197 __mxcsr = 0;
198 *__flagp = (__mxcsr | __status) & __excepts;
199 return (0);
200}
201
202__fenv_static inline int
203fetestexcept(int __excepts)
204{
205 __uint32_t __mxcsr;
206 __uint16_t __status;
207
208 __fnstsw(&__status);
209 if (__HAS_SSE())
210 __stmxcsr(&__mxcsr);
211 else
212 __mxcsr = 0;
213 return ((__status | __mxcsr) & __excepts);
214}
215
216__fenv_static inline int
217fesetround(int __round)
218{
219 __uint32_t __mxcsr;
220 __uint16_t __control;
221
222 if (__round & ~_ROUND_MASK)
223 return (-1);
224
225 __fnstcw(&__control);
226 __control &= ~_ROUND_MASK;
227 __control |= __round;
228 __fldcw(&__control);
229
230 if (__HAS_SSE()) {
231 __stmxcsr(&__mxcsr);
232 __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
233 __mxcsr |= __round << _SSE_ROUND_SHIFT;
234 __ldmxcsr(&__mxcsr);
235 }
236
237 return (0);
238}
239
240__fenv_static inline int
241fesetenv(const fenv_t *__envp)
242{
243 fenv_t __env = *__envp;
244 __uint32_t __mxcsr;
245
246 __mxcsr = __get_mxcsr(__env);
247 __set_mxcsr(__env, 0xffffffff);
248 /*
249 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
250 * instruction clobbers the i387 register stack. This happens because
251 * we restore the tag word from the saved environment. Normally, this
252 * would happen anyway and we wouldn't care, because the ABI allows
253 * function calls to clobber the i387 regs. However, fesetenv() is
254 * inlined, so we need to be more careful.
255 */
256 __fldenvx(__env);
257 if (__HAS_SSE())
258 __ldmxcsr(&__mxcsr);
259 return (0);
260}
261
262#else /* __amd64__ */
263
264__fenv_static inline int
265feclearexcept(int __excepts)
266{
267 fenv_t __env;
268
269 if (__excepts == FE_ALL_EXCEPT) {
270 __fnclex();
271 } else {
272 __fnstenv(&__env.__x87);
273 __env.__x87.__status &= ~__excepts;
274 __fldenv(&__env.__x87);
275 }
276 __stmxcsr(&__env.__mxcsr);
277 __env.__mxcsr &= ~__excepts;
278 __ldmxcsr(&__env.__mxcsr);
279 return (0);
280}
281
282__fenv_static inline int
283fegetexceptflag(fexcept_t *__flagp, int __excepts)
284{
285 __uint32_t __mxcsr;
286 __uint16_t __status;
287
288 __stmxcsr(&__mxcsr);
289 __fnstsw(&__status);
290 *__flagp = (__mxcsr | __status) & __excepts;
291 return (0);
292}
293
294__fenv_static inline int
295fetestexcept(int __excepts)
296{
297 __uint32_t __mxcsr;
298 __uint16_t __status;
299
300 __stmxcsr(&__mxcsr);
301 __fnstsw(&__status);
302 return ((__status | __mxcsr) & __excepts);
303}
304
305__fenv_static inline int
306fesetround(int __round)
307{
308 __uint32_t __mxcsr;
309 __uint16_t __control;
310
311 if (__round & ~_ROUND_MASK)
312 return (-1);
313
314 __fnstcw(&__control);
315 __control &= ~_ROUND_MASK;
316 __control |= __round;
317 __fldcw(&__control);
318
319 __stmxcsr(&__mxcsr);
320 __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT);
321 __mxcsr |= __round << _SSE_ROUND_SHIFT;
322 __ldmxcsr(&__mxcsr);
323
324 return (0);
325}
326
327__fenv_static inline int
328fesetenv(const fenv_t *__envp)
329{
330
331 /*
332 * XXX Using fldenvx() instead of fldenv() tells the compiler that this
333 * instruction clobbers the i387 register stack. This happens because
334 * we restore the tag word from the saved environment. Normally, this
335 * would happen anyway and we wouldn't care, because the ABI allows
336 * function calls to clobber the i387 regs. However, fesetenv() is
337 * inlined, so we need to be more careful.
338 */
339 __fldenvx(__envp->__x87);
340 __ldmxcsr(&__envp->__mxcsr);
341 return (0);
342}
343
344#endif /* __i386__ */
345
346__END_DECLS
347
348#endif /* !_FENV_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/float.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/float.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/floatingpoint.h deleted-44
......@@ -1,44 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1993 Andrew Moore, Talke Studio
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
36 */
37
38#ifndef _FLOATINGPOINT_H_
39#define _FLOATINGPOINT_H_
40
41#include <sys/cdefs.h>
42#include <machine/ieeefp.h>
43
44#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/i386/asm.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
3533 */
3634
3735#ifndef _MACHINE_ASM_H_
lib/libc/include/x86_64-freebsd-none/i386/atomic.h+20-27
......@@ -49,8 +49,8 @@ static __inline void
4949__mbk(void)
5050{
5151
52 __asm __volatile("lock; addl $0,%%fs:%0"
53 : "+m" (*(u_int *)__OFFSETOF_MONITORBUF) : : "memory", "cc");
52 __asm __volatile("lock; addl $0,%%fs:%c0"
53 : : "i" (__OFFSETOF_MONITORBUF) : "memory", "cc");
5454}
5555
5656static __inline void
......@@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)
249249
250250#define ATOMIC_LOAD(TYPE) \
251251static __inline u_##TYPE \
252atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
252atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
253253{ \
254254 u_##TYPE res; \
255255 \
......@@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void)
299299
300300#ifdef _KERNEL
301301
302#ifdef WANT_FUNCTIONS
303int atomic_cmpset_64_i386(volatile uint64_t *, uint64_t, uint64_t);
304int atomic_cmpset_64_i586(volatile uint64_t *, uint64_t, uint64_t);
305uint64_t atomic_load_acq_64_i386(volatile uint64_t *);
306uint64_t atomic_load_acq_64_i586(volatile uint64_t *);
307void atomic_store_rel_64_i386(volatile uint64_t *, uint64_t);
308void atomic_store_rel_64_i586(volatile uint64_t *, uint64_t);
309uint64_t atomic_swap_64_i386(volatile uint64_t *, uint64_t);
310uint64_t atomic_swap_64_i586(volatile uint64_t *, uint64_t);
311#endif
312
313302/* I486 does not support SMP or CMPXCHG8B. */
314303static __inline int
315304atomic_cmpset_64_i386(volatile uint64_t *dst, uint64_t expect, uint64_t src)
......@@ -353,12 +342,12 @@ atomic_fcmpset_64_i386(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
353342}
354343
355344static __inline uint64_t
356atomic_load_acq_64_i386(volatile uint64_t *p)
345atomic_load_acq_64_i386(const volatile uint64_t *p)
357346{
358 volatile uint32_t *q;
347 const volatile uint32_t *q;
359348 uint64_t res;
360349
361 q = (volatile uint32_t *)p;
350 q = (const volatile uint32_t *)p;
362351 __asm __volatile(
363352 " pushfl ; "
364353 " cli ; "
......@@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
447436 return (res);
448437}
449438
439/*
440 * Architecturally always writes back some value to '*p' so will trigger
441 * a #GP(0) on read-only mappings.
442 */
450443static __inline uint64_t
451atomic_load_acq_64_i586(volatile uint64_t *p)
444atomic_load_acq_64_i586(const volatile uint64_t *p)
452445{
453446 uint64_t res;
454447
......@@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p)
456449 " movl %%ebx,%%eax ; "
457450 " movl %%ecx,%%edx ; "
458451 " lock; cmpxchg8b %1"
459 : "=&A" (res), /* 0 */
460 "+m" (*p) /* 1 */
461 : : "memory", "cc");
452 : "=&A" (res) /* 0 */
453 : "m" (*p) /* 1 */
454 : "memory", "cc");
462455 return (res);
463456}
464457
......@@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
514507}
515508
516509static __inline uint64_t
517atomic_load_acq_64(volatile uint64_t *p)
510atomic_load_acq_64(const volatile uint64_t *p)
518511{
519512
520513 if ((cpu_feature & CPUID_CX8) == 0)
......@@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long);
614607#undef ATOMIC_STORE
615608#undef ATOMIC_LOADSTORE
616609
617#ifndef WANT_FUNCTIONS
618
619610static __inline int
620611atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
621612{
......@@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v)
842833#define atomic_subtract_rel_ptr(p, v) \
843834 atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v))
844835#define atomic_load_acq_ptr(p) \
845 atomic_load_acq_int((volatile u_int *)(p))
836 atomic_load_acq_int((const volatile u_int *)(p))
846837#define atomic_store_rel_ptr(p, v) \
847838 atomic_store_rel_int((volatile u_int *)(p), (v))
848839#define atomic_cmpset_ptr(dst, old, new) \
......@@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v)
865856 atomic_swap_int((volatile u_int *)(p), (u_int)(v))
866857#define atomic_readandclear_ptr(p) \
867858 atomic_readandclear_int((volatile u_int *)(p))
868
869#endif /* !WANT_FUNCTIONS */
859#define atomic_testandclear_ptr(p, val) \
860 atomic_testandclear_int((volatile u_int *)(p), (val))
861#define atomic_testandset_ptr(p, val) \
862 atomic_testandset_int((volatile u_int *)(p), (val))
870863
871864#if defined(_KERNEL)
872865#define mb() __mbk()
lib/libc/include/x86_64-freebsd-none/i386/cpufunc.h+1-10
......@@ -63,15 +63,6 @@ bsfl(u_int mask)
6363 return (result);
6464}
6565
66static __inline __pure2 u_int
67bsrl(u_int mask)
68{
69 u_int result;
70
71 __asm("bsrl %1,%0" : "=r" (result) : "rm" (mask) : "cc");
72 return (result);
73}
74
7566static __inline void
7667clflush(u_long addr)
7768{
......@@ -83,7 +74,7 @@ static __inline void
8374clflushopt(u_long addr)
8475{
8576
86 __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr));
77 __asm __volatile("clflushopt %0" : : "m" (*(char *)addr));
8778}
8879
8980static __inline void
lib/libc/include/x86_64-freebsd-none/i386/pcpu.h+20-27
......@@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
108108/*
109109 * Evaluates to the address of the per-cpu variable name.
110110 */
111#define __PCPU_PTR(name) __extension__ ({ \
112 __pcpu_type(name) *__p; \
113 \
114 __asm __volatile("movl %%fs:%1,%0; addl %2,%0" \
115 : "=r" (__p) \
116 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \
117 "i" (__pcpu_offset(name))); \
118 \
119 __p; \
120})
111#define __PCPU_PTR(name) \
112 (&get_pcpu()->name)
121113
122114/*
123115 * Evaluates to the value of the per-cpu variable name.
......@@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
126118 __pcpu_type(name) __res; \
127119 struct __s { \
128120 u_char __b[MIN(sizeof(__res), 4)]; \
129 } __s; \
121 }; \
130122 \
131123 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \
132124 sizeof(__res) == 4) { \
133 __asm __volatile("mov %%fs:%1,%0" \
134 : "=r" (__s) \
135 : "m" (*(struct __s *)(__pcpu_offset(name)))); \
136 *(struct __s *)(void *)&__res = __s; \
125 __asm __volatile("mov %%fs:%c1,%0" \
126 : "=r" (*(struct __s *)(void *)&__res) \
127 : "i" (__pcpu_offset(name))); \
137128 } else { \
138129 __res = *__PCPU_PTR(name); \
139130 } \
......@@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
148139 __pcpu_type(name) __val; \
149140 struct __s { \
150141 u_char __b[MIN(sizeof(__val), 4)]; \
151 } __s; \
142 }; \
152143 \
153144 __val = (val); \
154145 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
155146 sizeof(__val) == 4) { \
156 __s = *(struct __s *)(void *)&__val; \
157 __asm __volatile("add %1,%%fs:%0" \
158 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
159 : "r" (__s)); \
147 __asm __volatile("add %1,%%fs:%c0" \
148 : \
149 : "i" (__pcpu_offset(name)), \
150 "r" (*(struct __s *)(void *)&__val) \
151 : "cc", "memory"); \
160152 } else \
161153 *__PCPU_PTR(name) += __val; \
162154} while (0)
......@@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
168160 __pcpu_type(name) __val; \
169161 struct __s { \
170162 u_char __b[MIN(sizeof(__val), 4)]; \
171 } __s; \
163 }; \
172164 \
173165 __val = (val); \
174166 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
175167 sizeof(__val) == 4) { \
176 __s = *(struct __s *)(void *)&__val; \
177 __asm __volatile("mov %1,%%fs:%0" \
178 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
179 : "r" (__s)); \
168 __asm __volatile("mov %1,%%fs:%c0" \
169 : \
170 : "i" (__pcpu_offset(name)), \
171 "r" (*(struct __s *)(void *)&__val) \
172 : "memory"); \
180173 } else { \
181174 *__PCPU_PTR(name) = __val; \
182175 } \
......@@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
185178#define get_pcpu() __extension__ ({ \
186179 struct pcpu *__pc; \
187180 \
188 __asm __volatile("movl %%fs:%1,%0" \
181 __asm __volatile("movl %%fs:%c1,%0" \
189182 : "=r" (__pc) \
190 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \
183 : "i" (__pcpu_offset(pc_prvspace))); \
191184 __pc; \
192185})
193186
lib/libc/include/x86_64-freebsd-none/i386/pcpu_aux.h+4-4
......@@ -49,8 +49,8 @@ __curthread(void)
4949{
5050 struct thread *td;
5151
52 __asm("movl %%fs:%1,%0" : "=r" (td)
53 : "m" (*(char *)offsetof(struct pcpu, pc_curthread)));
52 __asm("movl %%fs:%c1,%0" : "=r" (td)
53 : "i" (offsetof(struct pcpu, pc_curthread)));
5454 return (td);
5555}
5656#define curthread (__curthread())
......@@ -60,8 +60,8 @@ __curpcb(void)
6060{
6161 struct pcb *pcb;
6262
63 __asm("movl %%fs:%1,%0" : "=r" (pcb)
64 : "m" (*(char *)offsetof(struct pcpu, pc_curpcb)));
63 __asm("movl %%fs:%c1,%0" : "=r" (pcb)
64 : "i" (offsetof(struct pcpu, pc_curpcb)));
6565 return (pcb);
6666}
6767#define curpcb (__curpcb())
lib/libc/include/x86_64-freebsd-none/i386/pmap.h+3-6
......@@ -37,9 +37,6 @@
3737 * map the page tables using the pagetables themselves. This is done to
3838 * reduce the impact on kernel virtual memory for lots of sparse address
3939 * space, and to reduce the cost of memory to each process.
40 *
41 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
42 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
4340 */
4441
4542#ifndef _MACHINE_PMAP_H_
......@@ -83,7 +80,7 @@
8380 * 4KB (PTE) page mappings have identical settings for the following fields:
8481 */
8582#define PG_PTE_PROMOTE (PG_MANAGED | PG_W | PG_G | PG_PTE_PAT | \
86 PG_M | PG_A | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V)
83 PG_M | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V)
8784
8885/*
8986 * Page Protection Exception bits
......@@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem);
221218void *pmap_bios16_enter(void);
222219void pmap_bios16_leave(void *handle);
223220void pmap_bootstrap(vm_paddr_t);
224int pmap_cache_bits(pmap_t, int mode, boolean_t is_pde);
221int pmap_cache_bits(pmap_t, int mode, bool is_pde);
225222int pmap_change_attr(vm_offset_t, vm_size_t, int);
226223caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits);
227224void pmap_cp_slow0_map(vm_offset_t kaddr, int plen, vm_page_t *ma);
......@@ -239,7 +236,7 @@ void pmap_ksetrw(vm_offset_t va);
239236void *pmap_mapbios(vm_paddr_t, vm_size_t);
240237void *pmap_mapdev(vm_paddr_t, vm_size_t);
241238void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);
242boolean_t pmap_page_is_mapped(vm_page_t m);
239bool pmap_page_is_mapped(vm_page_t m);
243240void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
244241vm_paddr_t pmap_pg_frame(vm_paddr_t pa);
245242bool pmap_ps_enabled(pmap_t pmap);
lib/libc/include/x86_64-freebsd-none/i386/proc.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3230 */
3331
3432#ifndef _MACHINE_PROC_H_
lib/libc/include/x86_64-freebsd-none/i386/profile.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
3230 */
3331
3432#ifndef _MACHINE_PROFILE_H_
lib/libc/include/x86_64-freebsd-none/i386/segments.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
3634 */
3735
3836#ifndef _MACHINE_SEGMENTS_H_
lib/libc/include/x86_64-freebsd-none/i386/vmparam.h+1-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
3735 */
3836
3937#ifndef _MACHINE_VMPARAM_H_
......@@ -248,5 +246,6 @@
248246 * Need a page dump array for minidump.
249247 */
250248#define MINIDUMP_PAGE_TRACKING 1
249#define MINIDUMP_STARTUP_PAGE_TRACKING 0
251250
252251#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/_align.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_align.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/_bus.h+7-24
......@@ -1,30 +1,13 @@
11/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
2 * Copyright (c) 2005 The FreeBSD Foundation.
53 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer,
11 * without modification, immediately at the beginning of the file.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
4 * SPDX-License-Identifier: BSD-2-Clause
165 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
6 * Derived in part from NetBSD's bus.h files by (alphabetically):
7 * Christopher G. Demetriou
8 * Charles M. Hannum
9 * Jason Thorpe
10 * The NetBSD Foundation.
2811 */
2912
3013#ifndef AMD64_INCLUDE__BUS_H
lib/libc/include/x86_64-freebsd-none/machine/_inttypes.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_inttypes.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/_limits.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_limits.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/_stdint.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_stdint.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/_types.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/_types.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/asm.h+1-3
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
3533 */
3634
3735#ifdef __i386__
......@@ -94,7 +92,7 @@
9492
9593#define END(x) .size x, . - x; .cfi_endproc
9694/*
97 * WEAK_REFERENCE(): create a weak reference alias from sym.
95 * WEAK_REFERENCE(): create a weak reference alias from sym.
9896 * The macro is not a general asm macro that takes arbitrary names,
9997 * but one that takes only C names. It does the non-null name
10098 * translation inside the macro.
lib/libc/include/x86_64-freebsd-none/machine/atomic.h+6-7
......@@ -102,7 +102,7 @@
102102 */
103103
104104/*
105 * Always use lock prefixes. The result is slighly less optimal for
105 * Always use lock prefixes. The result is slightly less optimal for
106106 * UP systems, but it matters less now, and sometimes UP is emulated
107107 * over SMP.
108108 *
......@@ -295,8 +295,8 @@ static __inline void
295295__storeload_barrier(void)
296296{
297297#if defined(_KERNEL)
298 __asm __volatile("lock; addl $0,%%gs:%0"
299 : "+m" (*(u_int *)OFFSETOF_MONITORBUF) : : "memory", "cc");
298 __asm __volatile("lock; addl $0,%%gs:%c0"
299 : : "i" (OFFSETOF_MONITORBUF) : "memory", "cc");
300300#else /* !_KERNEL */
301301 __asm __volatile("lock; addl $0,-8(%%rsp)" : : : "memory", "cc");
302302#endif /* _KERNEL*/
......@@ -304,7 +304,7 @@ __storeload_barrier(void)
304304
305305#define ATOMIC_LOAD(TYPE) \
306306static __inline u_##TYPE \
307atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
307atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
308308{ \
309309 u_##TYPE res; \
310310 \
......@@ -385,7 +385,6 @@ ATOMIC_LOADSTORE(long);
385385#undef ATOMIC_LOAD
386386#undef ATOMIC_STORE
387387#undef ATOMIC_LOADSTORE
388#ifndef WANT_FUNCTIONS
389388
390389/* Read the current value and store a new value in the destination. */
391390static __inline u_int
......@@ -589,8 +588,8 @@ atomic_swap_long(volatile u_long *p, u_long v)
589588#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long
590589#define atomic_swap_ptr atomic_swap_long
591590#define atomic_readandclear_ptr atomic_readandclear_long
592
593#endif /* !WANT_FUNCTIONS */
591#define atomic_testandset_ptr atomic_testandset_long
592#define atomic_testandclear_ptr atomic_testandclear_long
594593
595594#endif /* !SAN_NEEDS_INTERCEPTORS || SAN_RUNTIME */
596595
lib/libc/include/x86_64-freebsd-none/machine/bus.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/bus.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/bus_dma.h+1-1
......@@ -29,6 +29,6 @@
2929#ifndef _AMD64_BUS_DMA_H_
3030#define _AMD64_BUS_DMA_H_
3131
32#include <x86/bus_dma.h>
32#include <x86/bus_dma.h>
3333
3434#endif /* _AMD64_BUS_DMA_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/clock.h deleted-5
......@@ -1,5 +0,0 @@
1/*
2 * This file is in the public domain.
3 */
4
5#include <x86/clock.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/cpu.h+2-3
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
3533 */
3634
3735#ifndef _MACHINE_CPU_H_
......@@ -72,7 +70,8 @@ extern char btext[];
7270extern char _end[];
7371extern char etext[];
7472
75/* Resume hook for VMM. */
73/* Suspend and resume hook for VMM. */
74extern void (*vmm_suspend_p)(void);
7675extern void (*vmm_resume_p)(void);
7776
7877void cpu_halt(void);
lib/libc/include/x86_64-freebsd-none/machine/cpufunc.h+33-5
......@@ -65,10 +65,6 @@ breakpoint(void)
6565
6666#define bsfq(mask) __builtin_ctzl(mask)
6767
68#define bsrl(mask) (__builtin_clz(mask) ^ 0x1f)
69
70#define bsrq(mask) (__builtin_clzl(mask) ^ 0x3f)
71
7268static __inline void
7369clflush(u_long addr)
7470{
......@@ -80,7 +76,7 @@ static __inline void
8076clflushopt(u_long addr)
8177{
8278
83 __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr));
79 __asm __volatile("clflushopt %0" : : "m" (*(char *)addr));
8480}
8581
8682static __inline void
......@@ -576,6 +572,15 @@ rss(void)
576572 return (sel);
577573}
578574
575static __inline u_short
576rcs(void)
577{
578 u_short sel;
579
580 __asm __volatile("movw %%cs,%0" : "=rm" (sel));
581 return (sel);
582}
583
579584static __inline void
580585load_ds(u_short sel)
581586{
......@@ -946,6 +951,29 @@ sgx_eremove(void *epc)
946951 return (sgx_encls(SGX_EREMOVE, 0, (uint64_t)epc, 0));
947952}
948953
954static __inline void
955xrstors(uint8_t *save_area, uint64_t state_bitmap)
956{
957 uint32_t low, hi;
958
959 low = state_bitmap;
960 hi = state_bitmap >> 32;
961 __asm __volatile("xrstors %0" : : "m"(*save_area), "a"(low),
962 "d"(hi));
963}
964
965static __inline void
966xsaves(uint8_t *save_area, uint64_t state_bitmap)
967{
968 uint32_t low, hi;
969
970 low = state_bitmap;
971 hi = state_bitmap >> 32;
972 __asm __volatile("xsaves %0" : "=m"(*save_area) : "a"(low),
973 "d"(hi)
974 : "memory");
975}
976
949977void reset_dbregs(void);
950978
951979#ifdef _KERNEL
lib/libc/include/x86_64-freebsd-none/machine/dump.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/dump.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/efi.h+6
......@@ -29,6 +29,8 @@
2929#ifndef __AMD64_INCLUDE_EFI_H_
3030#define __AMD64_INCLUDE_EFI_H_
3131
32#include <sys/types.h>
33
3234/*
3335 * XXX: from gcc 6.2 manual:
3436 * Note, the ms_abi attribute for Microsoft Windows 64-bit targets
......@@ -51,6 +53,10 @@
5153#define EFI_TIME_OWNED() mtx_assert(&atrtc_time_lock, MA_OWNED)
5254
5355#define EFI_RT_HANDLE_FAULTS_DEFAULT 1
56
57#define EFI_MAP_BOOTTYPE_ALLOWED(type) (((efi_map_regs >> (type)) & 1) != 0)
58
59extern uint32_t efi_map_regs;
5460#endif
5561
5662struct efirt_callinfo {
lib/libc/include/x86_64-freebsd-none/machine/elf.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/elf.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/endian.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/endian.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/exec.h deleted-39
......@@ -1,39 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)exec.h 8.1 (Berkeley) 6/11/93
32 */
33
34#ifndef _MACHINE_EXEC_H_
35#define _MACHINE_EXEC_H_
36
37#define __LDPGSZ 4096
38
39#endif /* !_MACHINE_EXEC_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/float.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/float.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/floatingpoint.h deleted-44
......@@ -1,44 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 1993 Andrew Moore, Talke Studio
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
36 */
37
38#ifndef _FLOATINGPOINT_H_
39#define _FLOATINGPOINT_H_
40
41#include <sys/cdefs.h>
42#include <machine/ieeefp.h>
43
44#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/fpu.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
3533 */
3634
3735/*
lib/libc/include/x86_64-freebsd-none/machine/ieeefp.h-2
......@@ -32,8 +32,6 @@
3232 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3333 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3434 * SUCH DAMAGE.
35 *
36 * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
3735 */
3836
3937#ifndef _MACHINE_IEEEFP_H_
lib/libc/include/x86_64-freebsd-none/machine/md_var.h+5
......@@ -50,6 +50,7 @@ extern vm_paddr_t intel_graphics_stolen_base;
5050extern vm_paddr_t intel_graphics_stolen_size;
5151
5252extern int la57;
53extern int prefer_uva_la48;
5354
5455extern vm_paddr_t kernphys;
5556extern vm_paddr_t KERNend;
......@@ -98,6 +99,10 @@ void get_fpcontext(struct thread *td, struct __mcontext *mcp,
9899int set_fpcontext(struct thread *td, struct __mcontext *mcp,
99100 char *xfpustate, size_t xfpustate_len);
100101
102void wrmsr_early_safe_start(void);
103void wrmsr_early_safe_end(void);
104int wrmsr_early_safe(u_int msr, uint64_t data);
105
101106#endif /* !_MACHINE_MD_VAR_H_ */
102107
103108#endif /* __i386__ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/metadata.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/metadata.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/msan.h+1-1
......@@ -81,7 +81,7 @@ kmsan_md_unsupported(vm_offset_t addr)
8181 * The kernel itself isn't shadowed: for most purposes global variables
8282 * are always initialized, and because KMSAN kernels are large
8383 * (GENERIC-KMSAN is ~80MB at the time of writing), shadowing would
84 * incur signficant memory usage.
84 * incur significant memory usage.
8585 */
8686 return (addr < VM_MIN_KERNEL_ADDRESS || addr >= KERNBASE);
8787}
lib/libc/include/x86_64-freebsd-none/machine/ofw_machdep.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/ofw_machdep.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/param.h+4-17
......@@ -36,8 +36,6 @@
3636 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3737 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3838 * SUCH DAMAGE.
39 *
40 * @(#)param.h 8.1 (Berkeley) 6/10/93
4139 */
4240
4341#ifndef _AMD64_INCLUDE_PARAM_H_
......@@ -49,9 +47,6 @@
4947 * Machine dependent constants for AMD64.
5048 */
5149
52#define __HAVE_ACPI
53#define __PCI_REROUTE_INTERRUPT
54
5550#ifndef MACHINE
5651#define MACHINE "amd64"
5752#endif
......@@ -80,7 +75,7 @@
8075 * ALIGNED_POINTER is a boolean macro that checks whether an address
8176 * is valid to fetch data elements of type t from on this architecture.
8277 * This does not reflect the optimal alignment, just the possibility
83 * (within reasonable limits).
78 * (within reasonable limits).
8479 */
8580#define ALIGNED_POINTER(p, t) 1
8681
......@@ -144,25 +139,17 @@
144139/*
145140 * Mach derived conversion macros
146141 */
147#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
148#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK))
149142#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK)
150143#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK)
151144#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK)
152145
153#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT)
154#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT)
155
156146#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
157147#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
158148
159#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
149#define INKERNEL(va) \
150 (((va) >= kva_layout.dmap_low && (va) < kva_layout.dmap_high) || \
151 ((va) >= kva_layout.km_low && (va) < kva_layout.km_high))
160152
161#define INKERNEL(va) (((va) >= DMAP_MIN_ADDRESS && (va) < DMAP_MAX_ADDRESS) \
162 || ((va) >= VM_MIN_KERNEL_ADDRESS && (va) < VM_MAX_KERNEL_ADDRESS))
163
164#ifdef SMP
165153#define SC_TABLESIZE 1024 /* Must be power of 2. */
166#endif
167154
168155#endif /* !_AMD64_INCLUDE_PARAM_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/pcb.h+3-3
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
3634 */
3735
3836#ifndef _AMD64_PCB_H_
......@@ -86,6 +84,7 @@ struct pcb {
8684#define PCB_KERNFPU_THR 0x0020 /* fpu_kern_thread() */
8785#define PCB_32BIT 0x0040 /* process has 32 bit context (segs etc) */
8886#define PCB_FPUNOSAVE 0x0080 /* no save area for current FPU ctx */
87#define PCB_TLSBASE 0x0100 /* tlsbase was set */
8988
9089 uint16_t pcb_initial_fpucw;
9190
......@@ -106,7 +105,8 @@ struct pcb {
106105
107106 struct savefpu *pcb_save;
108107
109 uint64_t pcb_pad[5];
108 register_t pcb_tlsbase; /* not same as pcb_fsbase */
109 uint64_t pcb_pad[4];
110110};
111111
112112/* Per-CPU state saved during suspend and resume. */
lib/libc/include/x86_64-freebsd-none/machine/pcpu.h+22-29
......@@ -182,16 +182,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
182182/*
183183 * Evaluates to the address of the per-cpu variable name.
184184 */
185#define __PCPU_PTR(name) __extension__ ({ \
186 __pcpu_type(name) *__p; \
187 \
188 __asm __volatile("movq %%gs:%1,%0; addq %2,%0" \
189 : "=r" (__p) \
190 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \
191 "i" (__pcpu_offset(name))); \
192 \
193 __p; \
194})
185#define __PCPU_PTR(name) \
186 (&get_pcpu()->name)
195187
196188/*
197189 * Evaluates to the value of the per-cpu variable name.
......@@ -200,14 +192,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
200192 __pcpu_type(name) __res; \
201193 struct __s { \
202194 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
203 } __s; \
195 }; \
204196 \
205197 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \
206198 sizeof(__res) == 4 || sizeof(__res) == 8) { \
207 __asm __volatile("mov %%gs:%1,%0" \
208 : "=r" (__s) \
209 : "m" (*(struct __s *)(__pcpu_offset(name)))); \
210 *(struct __s *)(void *)&__res = __s; \
199 __asm __volatile("mov %%gs:%c1,%0" \
200 : "=r" (*(struct __s *)(void *)&__res) \
201 : "i" (__pcpu_offset(name))); \
211202 } else { \
212203 __res = *__PCPU_PTR(name); \
213204 } \
......@@ -222,15 +213,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
222213 __pcpu_type(name) __val; \
223214 struct __s { \
224215 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
225 } __s; \
216 }; \
226217 \
227218 __val = (val); \
228219 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
229220 sizeof(__val) == 4 || sizeof(__val) == 8) { \
230 __s = *(struct __s *)(void *)&__val; \
231 __asm __volatile("add %1,%%gs:%0" \
232 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
233 : "r" (__s)); \
221 __asm __volatile("add %1,%%gs:%c0" \
222 : \
223 : "i" (__pcpu_offset(name)), \
224 "r" (*(struct __s *)(void *)&__val) \
225 : "cc", "memory"); \
234226 } else \
235227 *__PCPU_PTR(name) += __val; \
236228} while (0)
......@@ -238,30 +230,31 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
238230/*
239231 * Sets the value of the per-cpu variable name to value val.
240232 */
241#define __PCPU_SET(name, val) { \
233#define __PCPU_SET(name, val) do { \
242234 __pcpu_type(name) __val; \
243235 struct __s { \
244236 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
245 } __s; \
237 }; \
246238 \
247239 __val = (val); \
248240 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
249241 sizeof(__val) == 4 || sizeof(__val) == 8) { \
250 __s = *(struct __s *)(void *)&__val; \
251 __asm __volatile("mov %1,%%gs:%0" \
252 : "=m" (*(struct __s *)(__pcpu_offset(name))) \
253 : "r" (__s)); \
242 __asm __volatile("mov %1,%%gs:%c0" \
243 : \
244 : "i" (__pcpu_offset(name)), \
245 "r" (*(struct __s *)(void *)&__val) \
246 : "memory"); \
254247 } else { \
255248 *__PCPU_PTR(name) = __val; \
256249 } \
257}
250} while (0)
258251
259252#define get_pcpu() __extension__ ({ \
260253 struct pcpu *__pc; \
261254 \
262 __asm __volatile("movq %%gs:%1,%0" \
255 __asm __volatile("movq %%gs:%c1,%0" \
263256 : "=r" (__pc) \
264 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \
257 : "i" (__pcpu_offset(pc_prvspace))); \
265258 __pc; \
266259})
267260#endif /* !__SEG_GS */
lib/libc/include/x86_64-freebsd-none/machine/pcpu_aux.h+2-2
......@@ -54,8 +54,8 @@ __curthread(void)
5454{
5555 struct thread *td;
5656
57 __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu,
58 pc_curthread)));
57 __asm("movq %%gs:%c1,%0" : "=r" (td)
58 : "i" (offsetof(struct pcpu, pc_curthread)));
5959 return (td);
6060}
6161#define curthread (__curthread())
lib/libc/include/x86_64-freebsd-none/machine/pmap.h+35-73
......@@ -38,9 +38,6 @@
3838 * map the page tables using the pagetables themselves. This is done to
3939 * reduce the impact on kernel virtual memory for lots of sparse address
4040 * space, and to reduce the cost of memory to each process.
41 *
42 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
43 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
4441 */
4542
4643#ifdef __i386__
......@@ -50,48 +47,7 @@
5047#ifndef _MACHINE_PMAP_H_
5148#define _MACHINE_PMAP_H_
5249
53/*
54 * Page-directory and page-table entries follow this format, with a few
55 * of the fields not present here and there, depending on a lot of things.
56 */
57 /* ---- Intel Nomenclature ---- */
58#define X86_PG_V 0x001 /* P Valid */
59#define X86_PG_RW 0x002 /* R/W Read/Write */
60#define X86_PG_U 0x004 /* U/S User/Supervisor */
61#define X86_PG_NC_PWT 0x008 /* PWT Write through */
62#define X86_PG_NC_PCD 0x010 /* PCD Cache disable */
63#define X86_PG_A 0x020 /* A Accessed */
64#define X86_PG_M 0x040 /* D Dirty */
65#define X86_PG_PS 0x080 /* PS Page size (0=4k,1=2M) */
66#define X86_PG_PTE_PAT 0x080 /* PAT PAT index */
67#define X86_PG_G 0x100 /* G Global */
68#define X86_PG_AVAIL1 0x200 /* / Available for system */
69#define X86_PG_AVAIL2 0x400 /* < programmers use */
70#define X86_PG_AVAIL3 0x800 /* \ */
71#define X86_PG_PDE_PAT 0x1000 /* PAT PAT index */
72#define X86_PG_PKU(idx) ((pt_entry_t)idx << 59)
73#define X86_PG_NX (1ul<<63) /* No-execute */
74#define X86_PG_AVAIL(x) (1ul << (x))
75
76/* Page level cache control fields used to determine the PAT type */
77#define X86_PG_PDE_CACHE (X86_PG_PDE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD)
78#define X86_PG_PTE_CACHE (X86_PG_PTE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD)
79
80/* Protection keys indexes */
81#define PMAP_MAX_PKRU_IDX 0xf
82#define X86_PG_PKU_MASK X86_PG_PKU(PMAP_MAX_PKRU_IDX)
83
84/*
85 * Intel extended page table (EPT) bit definitions.
86 */
87#define EPT_PG_READ 0x001 /* R Read */
88#define EPT_PG_WRITE 0x002 /* W Write */
89#define EPT_PG_EXECUTE 0x004 /* X Execute */
90#define EPT_PG_IGNORE_PAT 0x040 /* IPAT Ignore PAT */
91#define EPT_PG_PS 0x080 /* PS Page size */
92#define EPT_PG_A 0x100 /* A Accessed */
93#define EPT_PG_M 0x200 /* D Dirty */
94#define EPT_PG_MEMORY_TYPE(x) ((x) << 3) /* MT Memory Type */
50#include <machine/pte.h>
9551
9652/*
9753 * Define the PG_xx macros in terms of the bits on x86 PTEs.
......@@ -120,9 +76,6 @@
12076#define EPT_PG_EMUL_V X86_PG_AVAIL(52)
12177#define EPT_PG_EMUL_RW X86_PG_AVAIL(53)
12278#define PG_PROMOTED X86_PG_AVAIL(54) /* PDE only */
123#define PG_FRAME (0x000ffffffffff000ul)
124#define PG_PS_FRAME (0x000fffffffe00000ul)
125#define PG_PS_PDP_FRAME (0x000fffffc0000000ul)
12679
12780/*
12881 * Promotion to a 2MB (PDE) page mapping requires that the corresponding 4KB
......@@ -132,18 +85,6 @@
13285 PG_M | PG_U | PG_RW | PG_V | PG_PKU_MASK)
13386
13487/*
135 * Page Protection Exception bits
136 */
137
138#define PGEX_P 0x01 /* Protection violation vs. not present */
139#define PGEX_W 0x02 /* during a Write cycle */
140#define PGEX_U 0x04 /* access from User mode (UPL) */
141#define PGEX_RSV 0x08 /* reserved PTE field is non-zero */
142#define PGEX_I 0x10 /* during an instruction fetch */
143#define PGEX_PK 0x20 /* protection key violation */
144#define PGEX_SGX 0x8000 /* SGX-related */
145
146/*
14788 * undef the PG_xx macros that define bits in the regular x86 PTEs that
14889 * have a different position in nested PTEs. This is done when compiling
14990 * code that needs to be aware of the differences between regular x86 and
......@@ -169,12 +110,7 @@
169110 * Pte related macros. This is complicated by having to deal with
170111 * the sign extension of the 48th bit.
171112 */
172#define KV4ADDR(l4, l3, l2, l1) ( \
173 ((unsigned long)-1 << 47) | \
174 ((unsigned long)(l4) << PML4SHIFT) | \
175 ((unsigned long)(l3) << PDPSHIFT) | \
176 ((unsigned long)(l2) << PDRSHIFT) | \
177 ((unsigned long)(l1) << PAGE_SHIFT))
113#define KV4ADDR(l4, l3, l2, l1) KV5ADDR(-1, l4, l3, l2, l1)
178114#define KV5ADDR(l5, l4, l3, l2, l1) ( \
179115 ((unsigned long)-1 << 56) | \
180116 ((unsigned long)(l5) << PML5SHIFT) | \
......@@ -233,11 +169,12 @@
233169 * the recursive page table map.
234170 */
235171#define NDMPML4E 8
172#define NDMPML5E 32
236173
237174/*
238 * These values control the layout of virtual memory. The starting address
239 * of the direct map, which is controlled by DMPML4I, must be a multiple of
240 * its size. (See the PHYS_TO_DMAP() and DMAP_TO_PHYS() macros.)
175 * These values control the layout of virtual memory. The starting
176 * address of the direct map is controlled by DMPML4I on LA48 and
177 * DMPML5I on LA57.
241178 *
242179 * Note: KPML4I is the index of the (single) level 4 page that maps
243180 * the KVA that holds KERNBASE, while KPML4BASE is the index of the
......@@ -255,6 +192,7 @@
255192
256193#define KPML4BASE (NPML4EPG-NKPML4E) /* KVM at highest addresses */
257194#define DMPML4I rounddown(KPML4BASE-NDMPML4E, NDMPML4E) /* Below KVM */
195#define DMPML5I (NPML5EPG / 2 + 1)
258196
259197#define KPML4I (NPML4EPG-1)
260198#define KPDPI (NPDPEPG-2) /* kernbase at -2GB */
......@@ -264,9 +202,14 @@
264202#define KMSANSHADPML4I (KPML4BASE - NKMSANSHADPML4E)
265203#define KMSANORIGPML4I (DMPML4I - NKMSANORIGPML4E)
266204
267/* Large map: index of the first and max last pml4 entry */
205/*
206 * Large map: index of the first and max last pml4/la48 and pml5/la57
207 * entry.
208 */
268209#define LMSPML4I (PML4PML4I + 1)
269210#define LMEPML4I (KASANPML4I - 1)
211#define LMSPML5I (DMPML5I + NDMPML5E)
212#define LMEPML5I (LMSPML5I + 32 - 1) /* 32 slots for large map */
270213
271214/*
272215 * XXX doesn't really belong here I guess...
......@@ -448,10 +391,10 @@ void pmap_activate_boot(pmap_t pmap);
448391void pmap_activate_sw(struct thread *);
449392void pmap_allow_2m_x_ept_recalculate(void);
450393void pmap_bootstrap(vm_paddr_t *);
451int pmap_cache_bits(pmap_t pmap, int mode, boolean_t is_pde);
394int pmap_cache_bits(pmap_t pmap, int mode, bool is_pde);
452395int pmap_change_attr(vm_offset_t, vm_size_t, int);
453396int pmap_change_prot(vm_offset_t, vm_size_t, vm_prot_t);
454void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate);
397void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, bool invalidate);
455398void pmap_flush_cache_range(vm_offset_t, vm_offset_t);
456399void pmap_flush_cache_phys_range(vm_paddr_t, vm_paddr_t, vm_memattr_t);
457400void pmap_init_pat(void);
......@@ -467,7 +410,7 @@ void *pmap_mapdev(vm_paddr_t, vm_size_t);
467410void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);
468411void *pmap_mapdev_pciecfg(vm_paddr_t pa, vm_size_t size);
469412bool pmap_not_in_di(void);
470boolean_t pmap_page_is_mapped(vm_page_t m);
413bool pmap_page_is_mapped(vm_page_t m);
471414void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
472415void pmap_page_set_memattr_noflush(vm_page_t m, vm_memattr_t ma);
473416void pmap_pinit_pml4(vm_page_t);
......@@ -612,6 +555,25 @@ pmap_pml5e_index(vm_offset_t va)
612555 return ((va >> PML5SHIFT) & ((1ul << NPML5EPGSHIFT) - 1));
613556}
614557
558struct kva_layout_s {
559 vm_offset_t kva_min;
560 vm_offset_t kva_max;
561 vm_offset_t dmap_low; /* DMAP_MIN_ADDRESS */
562 vm_offset_t dmap_high; /* DMAP_MAX_ADDRESS */
563 vm_offset_t lm_low; /* LARGEMAP_MIN_ADDRESS */
564 vm_offset_t lm_high; /* LARGEMAP_MAX_ADDRESS */
565 vm_offset_t km_low; /* VM_MIN_KERNEL_ADDRESS */
566 vm_offset_t km_high; /* VM_MAX_KERNEL_ADDRESS */
567 vm_offset_t rec_pt;
568 vm_offset_t kasan_shadow_low; /* KASAN_MIN_ADDRESS */
569 vm_offset_t kasan_shadow_high; /* KASAN_MAX_ADDRESS */
570 vm_offset_t kmsan_shadow_low; /* KMSAN_SHAD_MIN_ADDRESS */
571 vm_offset_t kmsan_shadow_high; /* KMSAN_SHAD_MAX_ADDRESS */
572 vm_offset_t kmsan_origin_low; /* KMSAN_ORIG_MIN_ADDRESS */
573 vm_offset_t kmsan_origin_high; /* KMSAN_ORIG_MAX_ADDRESS */
574};
575extern struct kva_layout_s kva_layout;
576
615577#endif /* !LOCORE */
616578
617579#endif /* !_MACHINE_PMAP_H_ */
lib/libc/include/x86_64-freebsd-none/machine/proc.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
3230 */
3331
3432#ifdef __i386__
lib/libc/include/x86_64-freebsd-none/machine/profile.h-2
......@@ -27,8 +27,6 @@
2727 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2828 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2929 * SUCH DAMAGE.
30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
3230 */
3331
3432#ifdef __i386__
lib/libc/include/x86_64-freebsd-none/machine/psl.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/psl.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/pte.h created+104
......@@ -0,0 +1,104 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2003 Peter Wemm.
5 * Copyright (c) 1991 Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department and William Jolitz of UUNET Technologies Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * Derived from hp300 version by Mike Hibler, this version by William
37 * Jolitz uses a recursive map [a pde points to the page directory] to
38 * map the page tables using the pagetables themselves. This is done to
39 * reduce the impact on kernel virtual memory for lots of sparse address
40 * space, and to reduce the cost of memory to each process.
41 */
42
43#ifndef _MACHINE_PTE_H_
44#define _MACHINE_PTE_H_
45
46/*
47 * Page-directory and page-table entries follow this format, with a few
48 * of the fields not present here and there, depending on a lot of things.
49 */
50 /* ---- Intel Nomenclature ---- */
51#define X86_PG_V 0x001 /* P Valid */
52#define X86_PG_RW 0x002 /* R/W Read/Write */
53#define X86_PG_U 0x004 /* U/S User/Supervisor */
54#define X86_PG_NC_PWT 0x008 /* PWT Write through */
55#define X86_PG_NC_PCD 0x010 /* PCD Cache disable */
56#define X86_PG_A 0x020 /* A Accessed */
57#define X86_PG_M 0x040 /* D Dirty */
58#define X86_PG_PS 0x080 /* PS Page size (0=4k,1=2M) */
59#define X86_PG_PTE_PAT 0x080 /* PAT PAT index */
60#define X86_PG_G 0x100 /* G Global */
61#define X86_PG_AVAIL1 0x200 /* / Available for system */
62#define X86_PG_AVAIL2 0x400 /* < programmers use */
63#define X86_PG_AVAIL3 0x800 /* \ */
64#define X86_PG_PDE_PAT 0x1000 /* PAT PAT index */
65#define X86_PG_PKU(idx) ((pt_entry_t)idx << 59)
66#define X86_PG_NX (1ul<<63) /* No-execute */
67#define X86_PG_AVAIL(x) (1ul << (x))
68
69/* Page level cache control fields used to determine the PAT type */
70#define X86_PG_PDE_CACHE (X86_PG_PDE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD)
71#define X86_PG_PTE_CACHE (X86_PG_PTE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD)
72
73/* Protection keys indexes */
74#define PMAP_MAX_PKRU_IDX 0xf
75#define X86_PG_PKU_MASK X86_PG_PKU(PMAP_MAX_PKRU_IDX)
76
77/*
78 * Intel extended page table (EPT) bit definitions.
79 */
80#define EPT_PG_READ 0x001 /* R Read */
81#define EPT_PG_WRITE 0x002 /* W Write */
82#define EPT_PG_EXECUTE 0x004 /* X Execute */
83#define EPT_PG_IGNORE_PAT 0x040 /* IPAT Ignore PAT */
84#define EPT_PG_PS 0x080 /* PS Page size */
85#define EPT_PG_A 0x100 /* A Accessed */
86#define EPT_PG_M 0x200 /* D Dirty */
87#define EPT_PG_MEMORY_TYPE(x) ((x) << 3) /* MT Memory Type */
88
89#define PG_FRAME (0x000ffffffffff000ul)
90#define PG_PS_FRAME (0x000fffffffe00000ul)
91#define PG_PS_PDP_FRAME (0x000fffffc0000000ul)
92
93/*
94 * Page Protection Exception bits
95 */
96#define PGEX_P 0x01 /* Protection violation vs. not present */
97#define PGEX_W 0x02 /* during a Write cycle */
98#define PGEX_U 0x04 /* access from User mode (UPL) */
99#define PGEX_RSV 0x08 /* reserved PTE field is non-zero */
100#define PGEX_I 0x10 /* during an instruction fetch */
101#define PGEX_PK 0x20 /* protection key violation */
102#define PGEX_SGX 0x8000 /* SGX-related */
103
104#endif
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/ptrace.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/ptrace.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/reg.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/reg.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/reloc.h deleted-50
......@@ -1,50 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)reloc.h 8.1 (Berkeley) 6/10/93
32 */
33
34#ifndef _I386_MACHINE_RELOC_H_
35#define _I386_MACHINE_RELOC_H_
36
37/* Relocation format. */
38struct relocation_info {
39 int r_address; /* offset in text or data segment */
40 unsigned int r_symbolnum : 24, /* ordinal number of add symbol */
41 r_pcrel : 1, /* 1 if value should be pc-relative */
42 r_length : 2, /* log base 2 of value's width */
43 r_extern : 1, /* 1 if need to add symbol to value */
44 r_baserel : 1, /* linkage table relative */
45 r_jmptable : 1, /* relocate to jump table */
46 r_relative : 1, /* load address relative */
47 r_copy : 1; /* run time copy */
48};
49
50#endif
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/resource.h+1-3
......@@ -12,7 +12,7 @@
1212 * no representations about the suitability of this software for any
1313 * purpose. It is provided "as is" without express or implied
1414 * warranty.
15 *
15 *
1616 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
1717 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
1818 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
......@@ -39,8 +39,6 @@
3939#define SYS_RES_DRQ 2 /* isa dma lines */
4040#define SYS_RES_MEMORY 3 /* i/o memory */
4141#define SYS_RES_IOPORT 4 /* i/o ports */
42#ifdef NEW_PCIB
4342#define PCI_RES_BUS 5 /* PCI bus numbers */
44#endif
4543
4644#endif /* !_MACHINE_RESOURCE_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/runq.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _MACHINE_RUNQ_H_
30#define _MACHINE_RUNQ_H_
31
32#define RQB_LEN (1) /* Number of priority status words. */
33#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */
34#define RQB_BPW (1<<RQB_L2BPW) /* Bits in an rqb_word_t. */
35
36#define RQB_BIT(pri) (1ul << ((pri) & (RQB_BPW - 1)))
37#define RQB_WORD(pri) ((pri) >> RQB_L2BPW)
38
39#define RQB_FFS(word) (bsfq(word))
40
41/*
42 * Type of run queue status word.
43 */
44typedef u_int64_t rqb_word_t;
45
46#endif
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/sdt_machdep.h created+12
......@@ -0,0 +1,12 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org>
5 */
6
7#ifndef _SYS_SDT_MACHDEP_H_
8#define _SYS_SDT_MACHDEP_H_
9
10#define _SDT_ASM_PATCH_INSTR "nopw 0(%%rax,%%rax,1)"
11
12#endif
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/segments.h-2
......@@ -31,8 +31,6 @@
3131 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3333 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
3634 */
3735
3836#ifdef __i386__
lib/libc/include/x86_64-freebsd-none/machine/setjmp.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/setjmp.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/sf_buf.h+1-1
......@@ -34,7 +34,7 @@
3434 * On this machine, the only purpose for which sf_buf is used is to implement
3535 * an opaque pointer required by the machine-independent parts of the kernel.
3636 * That pointer references the vm_page that is "mapped" by the sf_buf. The
37 * actual mapping is provided by the direct virtual-to-physical mapping.
37 * actual mapping is provided by the direct virtual-to-physical mapping.
3838 */
3939static inline vm_offset_t
4040sf_buf_kva(struct sf_buf *sf)
lib/libc/include/x86_64-freebsd-none/machine/smp.h-3
......@@ -13,8 +13,6 @@
1313
1414#ifdef _KERNEL
1515
16#ifdef SMP
17
1816#ifndef LOCORE
1917
2018#include <x86/x86_smp.h>
......@@ -39,7 +37,6 @@ void invlop_handler(void);
3937int start_all_aps(void);
4038
4139#endif /* !LOCORE */
42#endif /* SMP */
4340
4441#endif /* _KERNEL */
4542#endif /* _MACHINE_SMP_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/sysarch.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/sysarch.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/tls.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/tls.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/trap.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/trap.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/tss.h-2
......@@ -30,8 +30,6 @@
3030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232 * SUCH DAMAGE.
33 *
34 * from: @(#)tss.h 5.4 (Berkeley) 1/18/91
3533 */
3634
3735#ifndef _MACHINE_TSS_H_
lib/libc/include/x86_64-freebsd-none/machine/vdso.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/vdso.h>
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/vm.h deleted-46
......@@ -1,46 +0,0 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2009 Hudson River Trading LLC
5 * Written by: John H. Baldwin <jhb@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _MACHINE_VM_H_
31#define _MACHINE_VM_H_
32
33#include <machine/specialreg.h>
34
35/* Memory attributes. */
36#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE)
37#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING)
38#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH)
39#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED)
40#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK)
41#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED)
42
43#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
44#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE
45
46#endif /* !_MACHINE_VM_H_ */
\ No newline at end of file
lib/libc/include/x86_64-freebsd-none/machine/vmm.h+11-32
......@@ -46,6 +46,7 @@ enum vm_suspend_how {
4646 VM_SUSPEND_POWEROFF,
4747 VM_SUSPEND_HALT,
4848 VM_SUSPEND_TRIPLEFAULT,
49 VM_SUSPEND_DESTROY,
4950 VM_SUSPEND_LAST
5051};
5152
......@@ -124,7 +125,7 @@ enum x2apic_state {
124125/*
125126 * The VM name has to fit into the pathname length constraints of devfs,
126127 * governed primarily by SPECNAMELEN. The length is the total number of
127 * characters in the full path, relative to the mount point and not
128 * characters in the full path, relative to the mount point and not
128129 * including any leading '/' characters.
129130 * A prefix and a suffix are added to the name specified by the user.
130131 * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters
......@@ -150,6 +151,7 @@ CTASSERT(VM_MAX_NAMELEN >= VM_MIN_NAMELEN);
150151
151152struct vm;
152153struct vm_exception;
154struct vm_mem;
153155struct seg_desc;
154156struct vm_exit;
155157struct vm_run;
......@@ -170,6 +172,7 @@ struct vm_eventinfo {
170172
171173typedef int (*vmm_init_func_t)(int ipinum);
172174typedef int (*vmm_cleanup_func_t)(void);
175typedef void (*vmm_suspend_func_t)(void);
173176typedef void (*vmm_resume_func_t)(void);
174177typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);
175178typedef int (*vmi_run_func_t)(void *vcpui, register_t rip,
......@@ -194,6 +197,7 @@ typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now);
194197struct vmm_ops {
195198 vmm_init_func_t modinit; /* module wide initialization */
196199 vmm_cleanup_func_t modcleanup;
200 vmm_resume_func_t modsuspend;
197201 vmm_resume_func_t modresume;
198202
199203 vmi_init_func_t init; /* vm-specific initialization */
......@@ -236,39 +240,11 @@ void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores,
236240int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
237241 uint16_t threads, uint16_t maxcpus);
238242
239/*
240 * APIs that modify the guest memory map require all vcpus to be frozen.
241 */
242void vm_slock_memsegs(struct vm *vm);
243void vm_xlock_memsegs(struct vm *vm);
244void vm_unlock_memsegs(struct vm *vm);
245int vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t off,
246 size_t len, int prot, int flags);
247int vm_munmap_memseg(struct vm *vm, vm_paddr_t gpa, size_t len);
248int vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem);
249void vm_free_memseg(struct vm *vm, int ident);
250243int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
251244int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len);
252245int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
253246int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func);
254247
255/*
256 * APIs that inspect the guest memory map require only a *single* vcpu to
257 * be frozen. This acts like a read lock on the guest memory map since any
258 * modification requires *all* vcpus to be frozen.
259 */
260int vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid,
261 vm_ooffset_t *segoff, size_t *len, int *prot, int *flags);
262int vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem,
263 struct vm_object **objptr);
264vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm);
265void *vm_gpa_hold(struct vcpu *vcpu, vm_paddr_t gpa, size_t len,
266 int prot, void **cookie);
267void *vm_gpa_hold_global(struct vm *vm, vm_paddr_t gpa, size_t len,
268 int prot, void **cookie);
269void vm_gpa_release(void *cookie);
270bool vm_mem_allocated(struct vcpu *vcpu, vm_paddr_t gpa);
271
272248int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
273249int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
274250int vm_get_seg_desc(struct vcpu *vcpu, int reg,
......@@ -399,7 +375,8 @@ vcpu_should_yield(struct vcpu *vcpu)
399375
400376void *vcpu_stats(struct vcpu *vcpu);
401377void vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr);
402struct vmspace *vm_get_vmspace(struct vm *vm);
378struct vmspace *vm_vmspace(struct vm *vm);
379struct vm_mem *vm_mem(struct vm *vm);
403380struct vatpic *vm_atpic(struct vm *vm);
404381struct vatpit *vm_atpit(struct vm *vm);
405382struct vpmtmr *vm_pmtmr(struct vm *vm);
......@@ -448,7 +425,7 @@ int vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2);
448425
449426/*
450427 * Function used to keep track of the guest's TSC offset. The
451 * offset is used by the virutalization extensions to provide a consistent
428 * offset is used by the virtualization extensions to provide a consistent
452429 * value for the Time Stamp Counter to the guest.
453430 */
454431void vm_set_tsc_offset(struct vcpu *vcpu, uint64_t offset);
......@@ -465,7 +442,7 @@ struct vm_copyinfo {
465442/*
466443 * Set up 'copyinfo[]' to copy to/from guest linear address space starting
467444 * at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for
468 * a copyin or PROT_WRITE for a copyout.
445 * a copyin or PROT_WRITE for a copyout.
469446 *
470447 * retval is_fault Interpretation
471448 * 0 0 Success
......@@ -673,6 +650,8 @@ struct vm_inout_str {
673650 int addrsize;
674651 enum vm_reg_name seg_name;
675652 struct seg_desc seg_desc;
653 int cs_d;
654 uint64_t cs_base;
676655};
677656
678657enum task_switch_reason {
lib/libc/include/x86_64-freebsd-none/machine/vmm_dev.h+8-18
......@@ -29,12 +29,10 @@
2929#ifndef _VMM_DEV_H_
3030#define _VMM_DEV_H_
3131
32struct vm_snapshot_meta;
32#include <sys/domainset.h>
3333
34#ifdef _KERNEL
35void vmmdev_init(void);
36int vmmdev_cleanup(void);
37#endif
34#include <machine/vmm.h>
35#include <machine/vmm_snapshot.h>
3836
3937struct vm_memmap {
4038 vm_paddr_t gpa;
......@@ -56,16 +54,12 @@ struct vm_munmap {
5654struct vm_memseg {
5755 int segid;
5856 size_t len;
59 char name[VM_MAX_SUFFIXLEN + 1];
57 char name[VM_MAX_SUFFIXLEN + 1];
58 domainset_t *ds_mask;
59 size_t ds_mask_size;
60 int ds_policy;
6061};
6162
62struct vm_memseg_fbsd12 {
63 int segid;
64 size_t len;
65 char name[64];
66};
67_Static_assert(sizeof(struct vm_memseg_fbsd12) == 80, "COMPAT_FREEBSD12 ABI");
68
6963struct vm_register {
7064 int cpuid;
7165 int regnum; /* enum vm_reg_name */
......@@ -312,7 +306,7 @@ enum {
312306 IOCNUM_UNMAP_PPTDEV_MMIO = 46,
313307
314308 /* statistics */
315 IOCNUM_VM_STATS = 50,
309 IOCNUM_VM_STATS = 50,
316310 IOCNUM_VM_STAT_DESC = 51,
317311
318312 /* kernel device state */
......@@ -354,12 +348,8 @@ enum {
354348 _IOW('v', IOCNUM_SUSPEND, struct vm_suspend)
355349#define VM_REINIT \
356350 _IO('v', IOCNUM_REINIT)
357#define VM_ALLOC_MEMSEG_FBSD12 \
358 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg_fbsd12)
359351#define VM_ALLOC_MEMSEG \
360352 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg)
361#define VM_GET_MEMSEG_FBSD12 \
362 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg_fbsd12)
363353#define VM_GET_MEMSEG \
364354 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg)
365355#define VM_MMAP_MEMSEG \
lib/libc/include/x86_64-freebsd-none/machine/vmm_instruction_emul.h+26-1
......@@ -31,6 +31,31 @@
3131
3232#include <sys/mman.h>
3333
34/* struct vie_op.op_type */
35enum {
36 VIE_OP_TYPE_NONE = 0,
37 VIE_OP_TYPE_MOV,
38 VIE_OP_TYPE_MOVSX,
39 VIE_OP_TYPE_MOVZX,
40 VIE_OP_TYPE_AND,
41 VIE_OP_TYPE_OR,
42 VIE_OP_TYPE_SUB,
43 VIE_OP_TYPE_TWO_BYTE,
44 VIE_OP_TYPE_PUSH,
45 VIE_OP_TYPE_CMP,
46 VIE_OP_TYPE_POP,
47 VIE_OP_TYPE_MOVS,
48 VIE_OP_TYPE_GROUP1,
49 VIE_OP_TYPE_STOS,
50 VIE_OP_TYPE_BITTEST,
51 VIE_OP_TYPE_TWOB_GRP15,
52 VIE_OP_TYPE_ADD,
53 VIE_OP_TYPE_TEST,
54 VIE_OP_TYPE_BEXTR,
55 VIE_OP_TYPE_OUTS,
56 VIE_OP_TYPE_LAST
57};
58
3459/*
3560 * Callback functions to read and write memory regions.
3661 */
......@@ -112,7 +137,7 @@ void vie_init(struct vie *vie, const char *inst_bytes, int inst_length);
112137 * 'gla' is the guest linear address provided by the hardware assist
113138 * that caused the nested page table fault. It is used to verify that
114139 * the software instruction decoding is in agreement with the hardware.
115 *
140 *
116141 * Some hardware assists do not provide the 'gla' to the hypervisor.
117142 * To skip the 'gla' verification for this or any other reason pass
118143 * in VIE_INVALID_GLA instead.
lib/libc/include/x86_64-freebsd-none/machine/vmparam.h+46-42
......@@ -38,8 +38,6 @@
3838 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3939 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4040 * SUCH DAMAGE.
41 *
42 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
4341 */
4442
4543#ifdef __i386__
......@@ -74,12 +72,12 @@
7472#endif
7573
7674/*
77 * We provide a machine specific single page allocator through the use
78 * of the direct mapped segment. This uses 2MB pages for reduced
75 * We provide a single page allocator through the use of the
76 * direct mapped segment. This uses 2MB pages for reduced
7977 * TLB pressure.
8078 */
8179#if !defined(KASAN) && !defined(KMSAN)
82#define UMA_MD_SMALL_ALLOC
80#define UMA_USE_DMAP
8381#endif
8482
8583/*
......@@ -91,19 +89,21 @@
9189 * The number of PHYSSEG entries must be one greater than the number
9290 * of phys_avail entries because the phys_avail entry that spans the
9391 * largest physical address that is accessible by ISA DMA is split
94 * into two PHYSSEG entries.
92 * into two PHYSSEG entries.
9593 */
9694#define VM_PHYSSEG_MAX 63
9795
9896/*
99 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool
100 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
101 * the pool from which physical pages for page tables and small UMA
102 * objects are allocated.
97 * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool from
98 * which physical pages are allocated and VM_FREEPOOL_DIRECT is the pool from
99 * which physical pages for page tables and small UMA objects are allocated.
100 * VM_FREEPOOL_LAZYINIT is a special-purpose pool that is populated only during
101 * boot and is used to implement deferred initialization of page structures.
103102 */
104#define VM_NFREEPOOL 2
105#define VM_FREEPOOL_DEFAULT 0
106#define VM_FREEPOOL_DIRECT 1
103#define VM_NFREEPOOL 3
104#define VM_FREEPOOL_LAZYINIT 0
105#define VM_FREEPOOL_DEFAULT 1
106#define VM_FREEPOOL_DIRECT 2
107107
108108/*
109109 * Create up to three free page lists: VM_FREELIST_DMA32 is for physical pages
......@@ -149,10 +149,6 @@
149149#define VM_LEVEL_0_ORDER 9
150150#endif
151151
152#ifdef SMP
153#define PA_LOCK_COUNT 256
154#endif
155
156152/*
157153 * Kernel physical load address for non-UEFI boot and for legacy UEFI loader.
158154 * Newer UEFI loader loads kernel anywhere below 4G, with memory allocated
......@@ -167,6 +163,7 @@
167163 * Virtual addresses of things. Derived from the page directory and
168164 * page table indexes from pmap.h for precision.
169165 *
166 * LA48:
170167 * 0x0000000000000000 - 0x00007fffffffffff user map
171168 * 0x0000800000000000 - 0xffff7fffffffffff does not exist (hole)
172169 * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot)
......@@ -179,32 +176,38 @@
179176 * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional
180177 * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map
181178 *
179 * LA57:
180 * 0x0000000000000000 - 0x00ffffffffffffff user map
181 * 0x0100000000000000 - 0xf0ffffffffffffff does not exist (hole)
182 * 0xff00000000000000 - 0xff00ffffffffffff recursive page table (2048TB slot)
183 * 0xff01000000000000 - 0xff20ffffffffffff direct map (32 x 2048TB slots)
184 * 0xff21000000000000 - 0xff40ffffffffffff large map
185 * 0xff41000000000000 - 0xffff7fffffffffff unused
186 * 0xffff800000000000 - 0xfffff5ffffffffff unused (start of kernel pml4 entry)
187 * 0xfffff60000000000 - 0xfffff7ffffffffff 2TB KMSAN origin map, optional
188 * 0xfffff78000000000 - 0xfffff7bfffffffff 512GB KASAN shadow map, optional
189 * 0xfffff80000000000 - 0xfffffbffffffffff 4TB unused
190 * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional
191 * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map
192 *
182193 * Within the kernel map:
183194 *
184195 * 0xfffffe0000000000 vm_page_array
185196 * 0xffffffff80000000 KERNBASE
186197 */
187198
188#define VM_MIN_KERNEL_ADDRESS KV4ADDR(KPML4BASE, 0, 0, 0)
189#define VM_MAX_KERNEL_ADDRESS KV4ADDR(KPML4BASE + NKPML4E - 1, \
190 NPDPEPG-1, NPDEPG-1, NPTEPG-1)
191
192#define DMAP_MIN_ADDRESS KV4ADDR(DMPML4I, 0, 0, 0)
193#define DMAP_MAX_ADDRESS KV4ADDR(DMPML4I + NDMPML4E, 0, 0, 0)
194
195#define KASAN_MIN_ADDRESS KV4ADDR(KASANPML4I, 0, 0, 0)
196#define KASAN_MAX_ADDRESS KV4ADDR(KASANPML4I + NKASANPML4E, 0, 0, 0)
199#define VM_MIN_KERNEL_ADDRESS_LA48 KV4ADDR(KPML4BASE, 0, 0, 0)
200#define VM_MIN_KERNEL_ADDRESS kva_layout.km_low
201#define VM_MAX_KERNEL_ADDRESS kva_layout.km_high
197202
198#define KMSAN_SHAD_MIN_ADDRESS KV4ADDR(KMSANSHADPML4I, 0, 0, 0)
199#define KMSAN_SHAD_MAX_ADDRESS KV4ADDR(KMSANSHADPML4I + NKMSANSHADPML4E, \
200 0, 0, 0)
203#define KASAN_MIN_ADDRESS (kva_layout.kasan_shadow_low)
204#define KASAN_MAX_ADDRESS (kva_layout.kasan_shadow_high)
201205
202#define KMSAN_ORIG_MIN_ADDRESS KV4ADDR(KMSANORIGPML4I, 0, 0, 0)
203#define KMSAN_ORIG_MAX_ADDRESS KV4ADDR(KMSANORIGPML4I + NKMSANORIGPML4E, \
204 0, 0, 0)
206#define KMSAN_SHAD_MIN_ADDRESS (kva_layout.kmsan_shadow_low)
207#define KMSAN_SHAD_MAX_ADDRESS (kva_layout.kmsan_shadow_high)
205208
206#define LARGEMAP_MIN_ADDRESS KV4ADDR(LMSPML4I, 0, 0, 0)
207#define LARGEMAP_MAX_ADDRESS KV4ADDR(LMEPML4I + 1, 0, 0, 0)
209#define KMSAN_ORIG_MIN_ADDRESS (kva_layout.kmsan_origin_low)
210#define KMSAN_ORIG_MAX_ADDRESS (kva_layout.kmsan_origin_high)
208211
209212/*
210213 * Formally kernel mapping starts at KERNBASE, but kernel linker
......@@ -243,21 +246,21 @@
243246 * vt fb startup needs to be reworked.
244247 */
245248#define PHYS_IN_DMAP(pa) (dmaplimit == 0 || (pa) < dmaplimit)
246#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \
247 (va) < (DMAP_MIN_ADDRESS + dmaplimit))
249#define VIRT_IN_DMAP(va) \
250 ((va) >= kva_layout.dmap_low && (va) < kva_layout.dmap_low + dmaplimit)
248251
249252#define PMAP_HAS_DMAP 1
250#define PHYS_TO_DMAP(x) ({ \
253#define PHYS_TO_DMAP(x) __extension__ ({ \
251254 KASSERT(PHYS_IN_DMAP(x), \
252255 ("physical address %#jx not covered by the DMAP", \
253256 (uintmax_t)x)); \
254 (x) | DMAP_MIN_ADDRESS; })
257 (x) + kva_layout.dmap_low; })
255258
256#define DMAP_TO_PHYS(x) ({ \
259#define DMAP_TO_PHYS(x) __extension__ ({ \
257260 KASSERT(VIRT_IN_DMAP(x), \
258261 ("virtual address %#jx not covered by the DMAP", \
259262 (uintmax_t)x)); \
260 (x) & ~DMAP_MIN_ADDRESS; })
263 (x) - kva_layout.dmap_low; })
261264
262265/*
263266 * amd64 maps the page array into KVA so that it can be more easily
......@@ -278,7 +281,7 @@
278281 */
279282#ifndef VM_KMEM_SIZE_MAX
280283#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \
281 VM_MIN_KERNEL_ADDRESS + 1) * 3 / 5)
284 kva_layout.km_low + 1) * 3 / 5)
282285#endif
283286
284287/* initial pagein size of beginning of executable file */
......@@ -296,7 +299,8 @@
296299/*
297300 * Need a page dump array for minidump.
298301 */
299#define MINIDUMP_PAGE_TRACKING 1
302#define MINIDUMP_PAGE_TRACKING 1
303#define MINIDUMP_STARTUP_PAGE_TRACKING 1
300304
301305#endif /* _MACHINE_VMPARAM_H_ */
302306
lib/libc/include/x86_64-freebsd-none/stdarg.h deleted-5
......@@ -1,5 +0,0 @@
1/*-
2 * This file is in the public domain.
3 */
4
5#include <x86/stdarg.h>
\ No newline at end of file
lib/std/Target.zig+1-2
......@@ -510,7 +510,7 @@ pub const Os = struct {
510510
511511 break :blk default_min;
512512 },
513 .max = .{ .major = 14, .minor = 3, .patch = 0 },
513 .max = .{ .major = 15, .minor = 0, .patch = 0 },
514514 },
515515 },
516516 .netbsd => .{
......@@ -865,7 +865,6 @@ pub const Abi = enum {
865865 },
866866 .freebsd => switch (arch) {
867867 .arm,
868 .powerpc,
869868 => .eabihf,
870869 else => .none,
871870 },
lib/std/zig/target.zig-1
......@@ -71,7 +71,6 @@ pub const available_libcs = [_]ArchOsAbi{
7171 .{ .arch = .mips64el, .os = .linux, .abi = .gnuabin32, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 }, .glibc_triple = "mips64el-linux-gnu-n32" },
7272 .{ .arch = .mips64el, .os = .linux, .abi = .muslabi64, .os_ver = .{ .major = 2, .minor = 3, .patch = 48 } },
7373 .{ .arch = .mips64el, .os = .linux, .abi = .muslabin32, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } },
74 .{ .arch = .powerpc, .os = .freebsd, .abi = .eabihf, .os_ver = .{ .major = 7, .minor = 1, .patch = 0 } },
7574 .{ .arch = .powerpc, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu-soft" },
7675 .{ .arch = .powerpc, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu" },
7776 .{ .arch = .powerpc, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 } },
src/libs/freebsd.zig+32-13
......@@ -139,10 +139,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
139139 .path = "common" ++ path.sep_str ++ "crtbrand.S",
140140 .flags = acflags.items,
141141 },
142 .{
143 .path = "common" ++ path.sep_str ++ "crtend.c",
144 .flags = cflags.items,
145 },
146142 .{
147143 .path = "common" ++ path.sep_str ++ "feature_note.S",
148144 .flags = acflags.items,
......@@ -257,6 +253,12 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
257253pub const Lib = struct {
258254 name: []const u8,
259255 sover: u8,
256 added_in: ?Version = null,
257
258 pub fn getSoVersion(lib: Lib, os: *const std.Target.Os) u8 {
259 if (std.mem.eql(u8, lib.name, "util") and os.version_range.semver.min.major >= 15) return 10;
260 return lib.sover;
261 }
260262};
261263
262264pub const libs = [_]Lib{
......@@ -269,6 +271,7 @@ pub const libs = [_]Lib{
269271 .{ .name = "ld", .sover = 1 },
270272 .{ .name = "util", .sover = 9 },
271273 .{ .name = "execinfo", .sover = 1 },
274 .{ .name = "sys", .sover = 7, .added_in = .{ .major = 15, .minor = 0, .patch = 0 } },
272275};
273276
274277pub const ABI = struct {
......@@ -434,7 +437,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
434437
435438 const target = comp.getTarget();
436439 // FreeBSD 7 == FBSD_1.0, ..., FreeBSD 14 == FBSD_1.7
437 const target_version: Version = .{ .major = 1, .minor = target.os.version_range.semver.min.major - 7, .patch = 0 };
440 const target_os_version: Version = target.os.version_range.semver.min;
441 const target_libc_version: Version = .{ .major = 1, .minor = target_os_version.major - 7, .patch = 0 };
438442
439443 // Use the global cache directory.
440444 var cache: Cache = .{
......@@ -452,7 +456,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
452456 man.hash.addBytes(build_options.version);
453457 man.hash.add(target.cpu.arch);
454458 man.hash.add(target.abi);
455 man.hash.add(target_version);
459 man.hash.add(target_os_version);
456460
457461 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});
458462 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);
......@@ -494,19 +498,19 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
494498 };
495499
496500 const target_ver_index = for (metadata.all_versions, 0..) |ver, i| {
497 switch (ver.order(target_version)) {
501 switch (ver.order(target_libc_version)) {
498502 .eq => break i,
499503 .lt => continue,
500504 .gt => {
501505 // TODO Expose via compile error mechanism instead of log.
502 log.warn("invalid target FreeBSD libc version: {f}", .{target_version});
506 log.warn("invalid target FreeBSD libc version: {f}", .{target_libc_version});
503507 return error.InvalidTargetLibCVersion;
504508 },
505509 }
506510 } else blk: {
507511 const latest_index = metadata.all_versions.len - 1;
508512 log.warn("zig cannot build new FreeBSD libc version {f}; providing instead {f}", .{
509 target_version, metadata.all_versions[latest_index],
513 target_libc_version, metadata.all_versions[latest_index],
510514 });
511515 break :blk latest_index;
512516 };
......@@ -524,6 +528,11 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
524528 defer stubs_asm.deinit();
525529
526530 for (libs, 0..) |lib, lib_i| {
531 if (lib.added_in) |add_in| {
532 // Note: Compare OS version, not libc version.
533 if (target.os.version_range.semver.min.order(add_in) == .lt) continue;
534 }
535
527536 stubs_asm.shrinkRetainingCapacity(0);
528537
529538 try stubs_asm.appendSlice(".text\n");
......@@ -983,6 +992,9 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
983992}
984993
985994fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
995 const target = comp.getTarget();
996 const target_os_version = target.os.version_range.semver.min;
997
986998 assert(comp.freebsd_so_files == null);
987999 comp.freebsd_so_files = so_files;
9881000
......@@ -994,10 +1006,14 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
9941006 defer comp.mutex.unlock();
9951007
9961008 for (libs) |lib| {
1009 if (lib.added_in) |add_in| {
1010 if (target_os_version.order(add_in) == .lt) continue;
1011 }
1012
9971013 const so_path: Path = .{
9981014 .root_dir = so_files.dir_path.root_dir,
9991015 .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{
1000 so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover,
1016 so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.getSoVersion(&target.os),
10011017 }) catch return comp.setAllocFailure(),
10021018 };
10031019 task_buffer[task_buffer_i] = .{ .load_dso = so_path };
......@@ -1019,10 +1035,13 @@ fn buildSharedLib(
10191035 const tracy = trace(@src());
10201036 defer tracy.end();
10211037
1038 const target = comp.getTarget();
1039
10221040 const io = comp.io;
1023 const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, lib.sover });
1024 const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };
1025 const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);
1041 const sover = lib.getSoVersion(&target.os);
1042 const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, sover });
1043 const version: Version = .{ .major = sover, .minor = 0, .patch = 0 };
1044 const ld_basename = path.basename(target.standardDynamicLinkerPath().get().?);
10261045 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
10271046 const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });
10281047
src/link/Lld.zig+5-1
......@@ -1190,8 +1190,12 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
11901190 }));
11911191 } else if (target.isFreeBSDLibC()) {
11921192 for (freebsd.libs) |lib| {
1193 if (lib.added_in) |add_in| {
1194 if (target.os.version_range.semver.min.order(add_in) == .lt) continue;
1195 }
1196
11931197 const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{
1194 comp.freebsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.sover,
1198 comp.freebsd_so_files.?.dir_path, fs.path.sep, lib.name, lib.getSoVersion(&target.os),
11951199 });
11961200 try argv.append(lib_path);
11971201 }
tools/process_headers.zig-1
......@@ -81,7 +81,6 @@ const musl_targets = [_]LibCTarget{
8181const freebsd_targets = [_]LibCTarget{
8282 .{ .arch = .arm, .abi = .eabihf },
8383 .{ .arch = .aarch64, .abi = .none },
84 .{ .arch = .powerpc, .abi = .eabihf },
8584 .{ .arch = .powerpc64, .abi = .none },
8685 .{ .arch = .riscv64, .abi = .none },
8786 .{ .arch = .x86, .abi = .none },