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,9 +1,8 @@
1# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
21
3The compilation of software known as FreeBSD is distributed under the2The compilation of software known as FreeBSD is distributed under the
4following terms:3following terms:
54
6Copyright (c) 1992-2023 The FreeBSD Project.5Copyright (c) 1992-2025 The FreeBSD Project.
76
8Redistribution and use in source and binary forms, with or without7Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions8modification, 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:...@@ -49,15 +49,12 @@ _start:
49#ifdef GCRT49#ifdef GCRT
50 subq $16, %rsp50 subq $16, %rsp
51#endif51#endif
52 movq %rsi, %rcx52 movq %rsi, %rcx /* cleanup */
53 movq %rdi, %rsi /* argv = ap */53 movslq (%rdi), %rax /* long *ap; tmpargc = *ap */
54 addq $8, %rsi /* argv += 1 */54 leaq 0x8(%rdi), %rsi /* argv = ap + 1 */
55 movq %rdi, %rdx /* env = ap */55 leaq 0x10(%rdi, %rax, 8), %rdx /* env = ap + 2 + tmpargc */
56 addq $16, %rdx /* env += 2 */56 movl %eax, %edi /* argc = tmpargc */
57 movslq (%rdi), %rax57
58 movl %eax, %edi /* argc = *(long *)(void *)ap */
59 shlq $3, %rax
60 addq %rax, %rdx /* env += argc */
61#ifdef PIC58#ifdef PIC
62 /*59 /*
63 * XXX. %rip relative addressing is not intended for use in the60 * 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 @@...@@ -41,7 +41,6 @@
41 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.41 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */42 */
4343
44#include <sys/cdefs.h>
45#include <sys/param.h>44#include <sys/param.h>
46#include <sys/elf_common.h>45#include <sys/elf_common.h>
4746
lib/libc/freebsd/lib/csu/common/crtbegin.c+2-43
...@@ -21,7 +21,6 @@...@@ -21,7 +21,6 @@
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 */22 */
2323
24#include <sys/cdefs.h>
25#include <sys/param.h>24#include <sys/param.h>
2625
27#include "crt.h"26#include "crt.h"
...@@ -41,9 +40,8 @@ void __cxa_finalize(void *) __weak_symbol;...@@ -41,9 +40,8 @@ void __cxa_finalize(void *) __weak_symbol;
41 * When we have ctors/dtors call from the dtor handler before calling40 * When we have ctors/dtors call from the dtor handler before calling
42 * any dtors, otherwise use a destructor.41 * any dtors, otherwise use a destructor.
43 */42 */
44#ifndef HAVE_CTORS43/* zig patch: no HAVE_CTORS */
45__attribute__((destructor))44__attribute__((destructor))
46#endif
47static void45static void
48run_cxa_finalize(void)46run_cxa_finalize(void)
49{47{
...@@ -53,43 +51,4 @@ run_cxa_finalize(void)...@@ -53,43 +51,4 @@ run_cxa_finalize(void)
53}51}
54#endif52#endif
5553
56/*54/* zig patch: no HAVE_CTORS */
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 */
lib/libc/freebsd/lib/csu/common/crtbrand.S+1-1
...@@ -36,7 +36,7 @@...@@ -36,7 +36,7 @@
36 * for more information.36 * for more information.
37 */37 */
3838
39 .section .note.tag,"aG",%note,.freebsd.noteG,comdat39 .section .note.tag,"aGR",%note,.freebsd.noteG,comdat
40 .p2align 240 .p2align 2
41 .4byte 2f-1f41 .4byte 2f-1f
42 .4byte 4f-3f42 .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 @@...@@ -29,7 +29,7 @@
29#include <sys/elf_common.h>29#include <sys/elf_common.h>
30#include "notes.h"30#include "notes.h"
3131
32 .section .note.tag,"a",%note32 .section .note.tag,"aR",%note
33 .p2align 233 .p2align 2
34 .4byte 2f-1f34 .4byte 2f-1f
35 .4byte 4f-3f35 .4byte 4f-3f
lib/libc/freebsd/lib/csu/common/ignore_init_note.S+1-1
...@@ -30,7 +30,7 @@...@@ -30,7 +30,7 @@
3030
31#include "notes.h"31#include "notes.h"
3232
33 .section .note.tag,"a",%note33 .section .note.tag,"aR",%note
34 .p2align 234 .p2align 2
35 .4byte 2f-1f35 .4byte 2f-1f
36 .4byte 4f-3f36 .4byte 4f-3f
lib/libc/freebsd/lib/csu/powerpc/crt.h+1-2
...@@ -24,8 +24,7 @@...@@ -24,8 +24,7 @@
24#ifndef _CRT_H_24#ifndef _CRT_H_
25#define _CRT_H_25#define _CRT_H_
2626
27/* zig patch: no HAVE_CTORS */27/* zig patch: no HAVE_CTORS/CTORS_CONSTRUCTORS */
28#define CTORS_CONSTRUCTORS
29#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"28#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
3029
31#endif30#endif
lib/libc/freebsd/lib/csu/powerpc64/crt.h+1-2
...@@ -24,8 +24,7 @@...@@ -24,8 +24,7 @@
24#ifndef _CRT_H_24#ifndef _CRT_H_
25#define _CRT_H_25#define _CRT_H_
2626
27/* zig patch: no HAVE_CTORS */27/* zig patch: no HAVE_CTORS/CTORS_CONSTRUCTORS */
28#define CTORS_CONSTRUCTORS
29#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"28#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
3029
31#endif30#endif
lib/libc/freebsd/lib/libc/include/libc_private.h+22-86
...@@ -37,6 +37,8 @@...@@ -37,6 +37,8 @@
37#include <sys/_types.h>37#include <sys/_types.h>
38#include <sys/_pthreadtypes.h>38#include <sys/_pthreadtypes.h>
3939
40#include <libsys.h>
41
40extern char **environ;42extern char **environ;
4143
42/*44/*
...@@ -185,10 +187,12 @@ typedef enum {...@@ -185,10 +187,12 @@ typedef enum {
185 PJT_GETTHREADID_NP,187 PJT_GETTHREADID_NP,
186 PJT_ATTR_GET_NP,188 PJT_ATTR_GET_NP,
187 PJT_GETNAME_NP,189 PJT_GETNAME_NP,
190 PJT_SUSPEND_ALL_NP,
191 PJT_RESUME_ALL_NP,
188 PJT_MAX192 PJT_MAX
189} pjt_index_t;193} pjt_index_t;
190194
191typedef int (*pthread_func_t)(void);195typedef void (*pthread_func_t)(void);
192typedef pthread_func_t pthread_func_entry_t[2];196typedef pthread_func_t pthread_func_entry_t[2];
193197
194extern pthread_func_entry_t __thr_jtable[];198extern pthread_func_entry_t __thr_jtable[];
...@@ -197,9 +201,10 @@ void __set_error_selector(int *(*arg)(void));...@@ -197,9 +201,10 @@ void __set_error_selector(int *(*arg)(void));
197int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,201int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
198 void *(calloc_cb)(__size_t, __size_t));202 void *(calloc_cb)(__size_t, __size_t));
199203
200typedef int (*interpos_func_t)(void);204typedef void (*interpos_func_t)(void);
201interpos_func_t *__libc_interposing_slot(int interposno);205interpos_func_t *__libc_interposing_slot(int interposno);
202extern interpos_func_t __libc_interposing[] __hidden;206extern interpos_func_t __libc_interposing[] __hidden;
207interpos_func_t *__libsys_interposing_slot(int interposno);
203208
204enum {209enum {
205 INTERPOS_accept,210 INTERPOS_accept,
...@@ -244,11 +249,18 @@ enum {...@@ -244,11 +249,18 @@ enum {
244 INTERPOS_map_stacks_exec,249 INTERPOS_map_stacks_exec,
245 INTERPOS_fdatasync,250 INTERPOS_fdatasync,
246 INTERPOS_clock_nanosleep,251 INTERPOS_clock_nanosleep,
247 INTERPOS_distribute_static_tls,252 INTERPOS__reserved0, /* was distribute_static_tls */
248 INTERPOS_pdfork,253 INTERPOS_pdfork,
254 INTERPOS_uexterr_gettext,
249 INTERPOS_MAX255 INTERPOS_MAX
250};256};
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
252/*264/*
253 * yplib internal interfaces265 * yplib internal interfaces
254 */266 */
...@@ -333,102 +345,22 @@ struct __siginfo;...@@ -333,102 +345,22 @@ struct __siginfo;
333struct __ucontext;345struct __ucontext;
334struct __wrusage;346struct __wrusage;
335enum idtype;347enum 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 *);
410int __libc_sigaction(int, const struct sigaction *,350int __libc_sigaction(int, const struct sigaction *,
411 struct sigaction *) __hidden;351 struct sigaction *) __hidden;
412int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)352int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)
413 __hidden;353 __hidden;
414int __libc_sigsuspend(const __sigset_t *) __hidden;354int __libc_sigsuspend(const __sigset_t *) __hidden;
415int __libc_sigwait(const __sigset_t * __restrict,355int __libsys_sigwait(const __sigset_t *, int *) __hidden;
416 int * restrict sig);
417int __libc_system(const char *);356int __libc_system(const char *);
418int __libc_tcdrain(int);357int __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
425int _elf_aux_info(int aux, void *buf, int buflen);359int _elf_aux_info(int aux, void *buf, int buflen);
426struct dl_phdr_info;360struct dl_phdr_info;
427int __elf_phdr_match_addr(struct dl_phdr_info *, void *);361int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
428void __init_elf_aux_vector(void);362void __init_elf_aux_vector(void);
429void __libc_map_stacks_exec(void);363void __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
433void _pthread_cancel_enter(int);365void _pthread_cancel_enter(int);
434void _pthread_cancel_leave(int);366void _pthread_cancel_leave(int);
...@@ -444,7 +376,11 @@ struct __nl_cat_d;...@@ -444,7 +376,11 @@ struct __nl_cat_d;
444struct _xlocale;376struct _xlocale;
445struct __nl_cat_d *__catopen_l(const char *name, int type,377struct __nl_cat_d *__catopen_l(const char *name, int type,
446 struct _xlocale *locale);378 struct _xlocale *locale);
447int __strerror_rl(int errnum, char *strerrbuf, __size_t buflen,379int __strerror_rl(int errnum, char *strerrbuf, size_t buflen,
448 struct _xlocale *locale);380 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
450#endif /* _LIBC_PRIVATE_H_ */386#endif /* _LIBC_PRIVATE_H_ */
lib/libc/include/aarch64-freebsd-none/arm/_align.h-2
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
40 */38 */
4139
42#ifndef _ARM_INCLUDE__ALIGN_H_40#ifndef _ARM_INCLUDE__ALIGN_H_
lib/libc/include/aarch64-freebsd-none/arm/_limits.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _MACHINE__LIMITS_H_32#ifndef _MACHINE__LIMITS_H_
lib/libc/include/aarch64-freebsd-none/arm/_types.h-3
...@@ -32,9 +32,6 @@...@@ -32,9 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
38 */35 */
3936
40#ifndef _MACHINE__TYPES_H_37#ifndef _MACHINE__TYPES_H_
lib/libc/include/aarch64-freebsd-none/arm/acle-compat.h+3-155
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (c) 2014 ARM Ltd2 * Copyright (c) 2024 Arm Ltd
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * Redistribution and use in source and binary forms, with or without5 * Redistribution and use in source and binary forms, with or without
...@@ -27,157 +27,5 @@...@@ -27,157 +27,5 @@
27 */27 */
2828
29#ifndef __ARM_ARCH29#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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
37 */35 */
3836
39#ifndef _MACHINE_ASM_H_37#ifndef _MACHINE_ASM_H_
...@@ -176,7 +174,6 @@...@@ -176,7 +174,6 @@
176# define RETne bxne lr174# define RETne bxne lr
177# define RETc(c) bx##c lr175# define RETc(c) bx##c lr
178176
179#if __ARM_ARCH >= 7
180#define ISB isb177#define ISB isb
181#define DSB dsb178#define DSB dsb
182#define DMB dmb179#define DMB dmb
...@@ -190,12 +187,5 @@...@@ -190,12 +187,5 @@
190#define ERET .word 0xe160006e187#define ERET .word 0xe160006e
191#endif188#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
201#endif /* !_MACHINE_ASM_H_ */191#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 @@...@@ -41,15 +41,9 @@
4141
42#include <sys/atomic_common.h>42#include <sys/atomic_common.h>
4343
44#if __ARM_ARCH >= 7
45#define isb() __asm __volatile("isb" : : : "memory")44#define isb() __asm __volatile("isb" : : : "memory")
46#define dsb() __asm __volatile("dsb" : : : "memory")45#define dsb() __asm __volatile("dsb" : : : "memory")
47#define dmb() __asm __volatile("dmb" : : : "memory")46#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
54#define mb() dmb()48#define mb() dmb()
55#define wmb() dmb()49#define wmb() dmb()
...@@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val)...@@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val)
614}608}
615609
616static __inline uint32_t610static __inline uint32_t
617atomic_load_acq_32(volatile uint32_t *p)611atomic_load_acq_32(const volatile uint32_t *p)
618{612{
619 uint32_t v;613 uint32_t v;
620614
...@@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p)...@@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p)
624}618}
625619
626static __inline uint64_t620static __inline uint64_t
627atomic_load_64(volatile uint64_t *p)621atomic_load_64(const volatile uint64_t *p)
628{622{
629 uint64_t ret;623 uint64_t ret;
630624
...@@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p)...@@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p)
643}637}
644638
645static __inline uint64_t639static __inline uint64_t
646atomic_load_acq_64(volatile uint64_t *p)640atomic_load_acq_64(const volatile uint64_t *p)
647{641{
648 uint64_t ret;642 uint64_t ret;
649643
...@@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p)...@@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p)
653}647}
654648
655static __inline u_long649static __inline u_long
656atomic_load_acq_long(volatile u_long *p)650atomic_load_acq_long(const volatile u_long *p)
657{651{
658 u_long v;652 u_long v;
659653
...@@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v)...@@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v)
898892
899 return (atomic_testandclear_32((volatile uint32_t *)p, v));893 return (atomic_testandclear_32((volatile uint32_t *)p, v));
900}894}
901#define atomic_testandclear_long atomic_testandclear_long
902
903895
904static __inline int896static __inline int
905atomic_testandclear_64(volatile uint64_t *p, u_int v)897atomic_testandclear_64(volatile uint64_t *p, u_int v)
...@@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v)...@@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v)
958950
959 return (atomic_testandset_32((volatile uint32_t *)p, v));951 return (atomic_testandset_32((volatile uint32_t *)p, v));
960}952}
961#define atomic_testandset_long atomic_testandset_long953
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
963static __inline int964static __inline int
964atomic_testandset_64(volatile uint64_t *p, u_int v)965atomic_testandset_64(volatile uint64_t *p, u_int v)
...@@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void)...@@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void)
1052 dmb();1053 dmb();
1053}1054}
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
1055#define atomic_clear_ptr atomic_clear_321062#define atomic_clear_ptr atomic_clear_32
1056#define atomic_clear_acq_ptr atomic_clear_acq_321063#define atomic_clear_acq_ptr atomic_clear_acq_32
1057#define atomic_clear_rel_ptr atomic_clear_rel_321064#define atomic_clear_rel_ptr atomic_clear_rel_32
...@@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void)...@@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void)
1059#define atomic_set_acq_ptr atomic_set_acq_321066#define atomic_set_acq_ptr atomic_set_acq_32
1060#define atomic_set_rel_ptr atomic_set_rel_321067#define atomic_set_rel_ptr atomic_set_rel_32
1061#define atomic_fcmpset_ptr atomic_fcmpset_321068#define atomic_fcmpset_ptr atomic_fcmpset_32
1062#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
1063#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_321069#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32
1070#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
1064#define atomic_cmpset_ptr atomic_cmpset_321071#define atomic_cmpset_ptr atomic_cmpset_32
1065#define atomic_cmpset_acq_ptr atomic_cmpset_acq_321072#define atomic_cmpset_acq_ptr atomic_cmpset_acq_32
1066#define atomic_cmpset_rel_ptr atomic_cmpset_rel_321073#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
1067#define atomic_load_acq_ptr atomic_load_acq_321076#define atomic_load_acq_ptr atomic_load_acq_32
1068#define atomic_store_rel_ptr atomic_store_rel_321077#define atomic_store_rel_ptr atomic_store_rel_32
1069#define atomic_swap_ptr atomic_swap_321078#define atomic_swap_ptr atomic_swap_32
1070#define atomic_readandclear_ptr atomic_readandclear_321079#define atomic_testandset_ptr atomic_testandset_32
1080#define atomic_testandclear_ptr atomic_testandclear_32
10711081
1072#define atomic_add_int atomic_add_321082#define atomic_add_int atomic_add_32
1073#define atomic_add_acq_int atomic_add_acq_321083#define atomic_add_acq_int atomic_add_acq_32
...@@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void)...@@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void)
1093#define atomic_store_rel_int atomic_store_rel_321103#define atomic_store_rel_int atomic_store_rel_32
1094#define atomic_swap_int atomic_swap_321104#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 */
1102#include <sys/_atomic_subword.h>1106#include <sys/_atomic_subword.h>
11031107
1108#define atomic_set_short atomic_set_16
1109#define atomic_clear_short atomic_clear_16
1110
1104#endif /* _MACHINE_ATOMIC_H_ */1111#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);...@@ -45,13 +45,7 @@ void cpu_halt(void);
45 * unconditionally with -DSMP. Although it looks like a bug,45 * unconditionally with -DSMP. Although it looks like a bug,
46 * handle this case here and in #elif condition in ARM_SMP_UP macro.46 * handle this case here and in #elif condition in ARM_SMP_UP macro.
47 */47 */
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
56#if !defined(SMP) && defined(SMP_ON_UP)50#if !defined(SMP) && defined(SMP_ON_UP)
57#error SMP option must be defined for SMP_ON_UP option51#error SMP option must be defined for SMP_ON_UP option
...@@ -68,7 +62,7 @@ do { \...@@ -68,7 +62,7 @@ do { \
68 up_code; \62 up_code; \
69 } \63 } \
70} while (0)64} while (0)
71#elif defined(SMP) && __ARM_ARCH > 665#elif defined(SMP)
72#define ARM_SMP_UP(smp_code, up_code) \66#define ARM_SMP_UP(smp_code, up_code) \
73do { \67do { \
74 smp_code; \68 smp_code; \
...@@ -146,15 +140,15 @@ fname(uint64_t reg) \...@@ -146,15 +140,15 @@ fname(uint64_t reg) \
146/* TLB */140/* TLB */
147141
148_WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */142_WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */
149#if __ARM_ARCH >= 7 && defined(SMP)143#if defined(SMP)
150_WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */144_WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */
151#endif145#endif
152_WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */146_WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */
153#if __ARM_ARCH >= 7 && defined(SMP)147#if defined(SMP)
154_WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */148_WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */
155#endif149#endif
156_WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */150_WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */
157#if __ARM_ARCH >= 7 && defined(SMP)151#if defined(SMP)
158_WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */152_WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */
159#endif153#endif
160_WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */154_WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */
...@@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0))...@@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0))
164/* Cache and Branch predictor */158/* Cache and Branch predictor */
165159
166_WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */160_WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */
167#if __ARM_ARCH >= 7 && defined(SMP)161#if defined(SMP)
168_WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */162_WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */
169#endif163#endif
170_WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */164_WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */
171_WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */165_WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */
172_WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */166_WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */
173_WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */167_WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */
174#if __ARM_ARCH >= 7
175_WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */168_WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */
176#endif
177_WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */169_WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */
178_WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */170_WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */
179_WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */171_WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */
180_WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */172_WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */
181#if __ARM_ARCH >= 7 && defined(SMP)173#if defined(SMP)
182_WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */174_WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */
183#endif175#endif
184_WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */176_WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */
...@@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0))...@@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0))
209_WF1(cp15_nmrr_set, CP15_NMRR(%0))201_WF1(cp15_nmrr_set, CP15_NMRR(%0))
210_RF0(cp15_ttbr_get, CP15_TTBR0(%0))202_RF0(cp15_ttbr_get, CP15_TTBR0(%0))
211_RF0(cp15_dfar_get, CP15_DFAR(%0))203_RF0(cp15_dfar_get, CP15_DFAR(%0))
212#if __ARM_ARCH >= 7
213_RF0(cp15_ifar_get, CP15_IFAR(%0))204_RF0(cp15_ifar_get, CP15_IFAR(%0))
214_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))205_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))
215#endif
216_RF0(cp15_actlr_get, CP15_ACTLR(%0))206_RF0(cp15_actlr_get, CP15_ACTLR(%0))
217_WF1(cp15_actlr_set, CP15_ACTLR(%0))207_WF1(cp15_actlr_set, CP15_ACTLR(%0))
218_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0))208_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0))
...@@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0))...@@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0))
251241
252/* Performance Monitor registers */242/* 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
262_RF0(cp15_pmcr_get, CP15_PMCR(%0))244_RF0(cp15_pmcr_get, CP15_PMCR(%0))
263_WF1(cp15_pmcr_set, CP15_PMCR(%0))245_WF1(cp15_pmcr_set, CP15_PMCR(%0))
264_RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0))246_RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0))
...@@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))...@@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))
280_RF0(cp15_pminten_get, CP15_PMINTENSET(%0))262_RF0(cp15_pminten_get, CP15_PMINTENSET(%0))
281_WF1(cp15_pminten_set, CP15_PMINTENSET(%0))263_WF1(cp15_pminten_set, CP15_PMINTENSET(%0))
282_WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0))264_WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0))
283#endif
284265
285_RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0))266_RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0))
286_WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0))267_WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0))
...@@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size)...@@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size)
380}361}
381362
382/* Broadcasting operations. */363/* Broadcasting operations. */
383#if __ARM_ARCH >= 7 && defined(SMP)364#if defined(SMP)
384365
385static __inline void366static __inline void
386tlb_flush_all(void)367tlb_flush_all(void)
...@@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size)...@@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size)
442 );423 );
443 dsb();424 dsb();
444}425}
445#else /* __ARM_ARCH < 7 */426#else /* !SMP */
446427
447#define tlb_flush_all() tlb_flush_all_local()428#define tlb_flush_all() tlb_flush_all_local()
448#define tlb_flush_all_ng() tlb_flush_all_ng_local()429#define tlb_flush_all_ng() tlb_flush_all_ng_local()
449#define tlb_flush(va) tlb_flush_local(va)430#define tlb_flush(va) tlb_flush_local(va)
450#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)431#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)
451432
452#endif /* __ARM_ARCH < 7 */433#endif /* !SMP */
453434
454/*435/*
455 * Cache maintenance operations.436 * Cache maintenance operations.
...@@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size)...@@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size)
465 va &= ~cpuinfo.dcache_line_mask;446 va &= ~cpuinfo.dcache_line_mask;
466447
467 for ( ; va < eva; va += cpuinfo.dcache_line_size) {448 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
468#if __ARM_ARCH >= 7
469 _CP15_DCCMVAU(va);449 _CP15_DCCMVAU(va);
470#else
471 _CP15_DCCMVAC(va);
472#endif
473 }450 }
474 dsb();451 dsb();
475 ARM_SMP_UP(452 ARM_SMP_UP(
...@@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size)...@@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size)
515 dsb();492 dsb();
516 va &= ~cpuinfo.dcache_line_mask;493 va &= ~cpuinfo.dcache_line_mask;
517 for ( ; va < eva; va += cpuinfo.dcache_line_size) {494 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
518#if __ARM_ARCH >= 7
519 _CP15_DCCMVAU(va);495 _CP15_DCCMVAU(va);
520#else
521 _CP15_DCCMVAC(va);
522#endif
523 }496 }
524 dsb();497 dsb();
525}498}
...@@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr)...@@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr)
686static __inline uint64_t659static __inline uint64_t
687get_cyclecount(void)660get_cyclecount(void)
688{661{
689#if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176))662#if defined(DEV_PMU)
690#if (__ARM_ARCH > 6) && defined(DEV_PMU)
691 if (pmu_attched) {663 if (pmu_attched) {
692 u_int cpu;664 u_int cpu;
693 uint64_t h, h2;665 uint64_t h, h2;
...@@ -711,12 +683,6 @@ get_cyclecount(void)...@@ -711,12 +683,6 @@ get_cyclecount(void)
711 } else683 } else
712#endif684#endif
713 return cp15_pmccntr_get();685 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
720}686}
721#endif687#endif
722688
...@@ -729,7 +695,7 @@ get_cyclecount(void)...@@ -729,7 +695,7 @@ get_cyclecount(void)
729#define cpu_spinwait() /* nothing */695#define cpu_spinwait() /* nothing */
730#define cpu_lock_delay() DELAY(1)696#define cpu_lock_delay() DELAY(1)
731697
732#define ARM_NVEC 8698#define ARM_NVEC 7
733#define ARM_VEC_ALL 0xffffffff699#define ARM_VEC_ALL 0xffffffff
734700
735extern vm_offset_t vector_page;701extern vm_offset_t vector_page;
lib/libc/include/aarch64-freebsd-none/arm/cpufunc.h-3
...@@ -97,9 +97,6 @@ void armv7_cpu_sleep (int);...@@ -97,9 +97,6 @@ void armv7_cpu_sleep (int);
97void pj4b_config (void);97void pj4b_config (void);
98#endif98#endif
9999
100#if defined(CPU_ARM1176)
101void arm11x6_sleep (int); /* no ref. for errata */
102#endif
103100
104101
105/*102/*
lib/libc/include/aarch64-freebsd-none/arm/fenv.h+1
...@@ -29,6 +29,7 @@...@@ -29,6 +29,7 @@
29#ifndef _FENV_H_29#ifndef _FENV_H_
30#define _FENV_H_30#define _FENV_H_
3131
32#include <sys/cdefs.h>
32#include <sys/_types.h>33#include <sys/_types.h>
3334
34#ifndef __fenv_static35#ifndef __fenv_static
lib/libc/include/aarch64-freebsd-none/arm/float.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
32 */30 */
3331
34#ifndef _MACHINE_FLOAT_H_32#ifndef _MACHINE_FLOAT_H_
lib/libc/include/aarch64-freebsd-none/arm/ieeefp.h+10
...@@ -49,4 +49,14 @@ typedef enum {...@@ -49,4 +49,14 @@ typedef enum {
4949
50#define fp_except_t int50#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
52#endif /* _MACHINE_IEEEFP_H_ */62#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 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
40 */38 */
4139
42#ifndef _ARM_INCLUDE_PARAM_H_40#ifndef _ARM_INCLUDE_PARAM_H_
...@@ -51,17 +49,11 @@...@@ -51,17 +49,11 @@
51#define STACKALIGNBYTES (8 - 1)49#define STACKALIGNBYTES (8 - 1)
52#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)50#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)
5351
54#define __PCI_REROUTE_INTERRUPT
55
56#ifndef MACHINE52#ifndef MACHINE
57#define MACHINE "arm"53#define MACHINE "arm"
58#endif54#endif
59#ifndef MACHINE_ARCH55#ifndef MACHINE_ARCH
60#if __ARM_ARCH >= 7
61#define MACHINE_ARCH "armv7"56#define MACHINE_ARCH "armv7"
62#else
63#define MACHINE_ARCH "armv6"
64#endif
65#endif57#endif
6658
67#ifdef SMP59#ifdef SMP
...@@ -76,6 +68,8 @@...@@ -76,6 +68,8 @@
76#define MAXMEMDOM 168#define MAXMEMDOM 1
77#endif69#endif
7870
71#define __HAVE_STATIC_DEVMAP
72
79#define ALIGNBYTES _ALIGNBYTES73#define ALIGNBYTES _ALIGNBYTES
80#define ALIGN(p) _ALIGN(p)74#define ALIGN(p) _ALIGN(p)
81/*75/*
...@@ -129,17 +123,10 @@...@@ -129,17 +123,10 @@
129/*123/*
130 * Mach derived conversion macros124 * Mach derived conversion macros
131 */125 */
132#define trunc_page(x) ((x) & ~PAGE_MASK)
133#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
134#define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK)126#define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK)
135#define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK)127#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
140#define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT)129#define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT)
141#define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT)130#define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT)
142131
143#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
144
145#endif /* !_ARM_INCLUDE_PARAM_H_ */132#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 @@...@@ -39,9 +39,6 @@
39 * map the page tables using the pagetables themselves. This is done to39 * map the page tables using the pagetables themselves. This is done to
40 * reduce the impact on kernel virtual memory for lots of sparse address40 * reduce the impact on kernel virtual memory for lots of sparse address
41 * space, and to reduce the cost of memory to each process.41 * 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
45 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/3042 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30
46 */43 */
4744
...@@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */...@@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */
138 * vtopte2().135 * vtopte2().
139 */136 */
140void pmap_bootstrap(vm_offset_t);137void 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);
142void pmap_kremove(vm_offset_t);139void pmap_kremove(vm_offset_t);
143boolean_t pmap_page_is_mapped(vm_page_t);140bool pmap_page_is_mapped(vm_page_t);
144bool pmap_ps_enabled(pmap_t pmap);141bool pmap_ps_enabled(pmap_t pmap);
145142
146void pmap_tlb_flush(pmap_t, vm_offset_t);143void pmap_tlb_flush(pmap_t, vm_offset_t);
...@@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t);...@@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
175#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)172#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)
176173
177void *pmap_mapdev(vm_paddr_t, vm_size_t);174void *pmap_mapdev(vm_paddr_t, vm_size_t);
175void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
178void pmap_unmapdev(void *, vm_size_t);176void 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
187struct pcb;178struct pcb;
188void pmap_set_pcb_pagedir(pmap_t, struct pcb *);179void pmap_set_pcb_pagedir(pmap_t, struct pcb *);
189180
lib/libc/include/aarch64-freebsd-none/arm/proc.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
36 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/2934 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
37 */35 */
3836
lib/libc/include/aarch64-freebsd-none/arm/profile.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)profile.h 8.1 (Berkeley) 6/11/93
36 */34 */
3735
38#ifndef _MACHINE_PROFILE_H_36#ifndef _MACHINE_PROFILE_H_
lib/libc/include/aarch64-freebsd-none/arm/reloc.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)reloc.h 8.1 (Berkeley) 6/10/93
36 */34 */
3735
38#ifndef _MACHINE_RELOC_H_36#ifndef _MACHINE_RELOC_H_
lib/libc/include/aarch64-freebsd-none/arm/resource.h-2
...@@ -40,8 +40,6 @@...@@ -40,8 +40,6 @@
40#define SYS_RES_MEMORY 3 /* i/o memory */40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */41#define SYS_RES_IOPORT 4 /* i/o ports */
42#define SYS_RES_GPIO 5 /* general purpose i/o */42#define SYS_RES_GPIO 5 /* general purpose i/o */
43#ifdef NEW_PCIB
44#define PCI_RES_BUS 6 /* PCI bus numbers */43#define PCI_RES_BUS 6 /* PCI bus numbers */
45#endif
4644
47#endif /* !_MACHINE_RESOURCE_H_ */45#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.1 (Berkeley) 6/11/93
32 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/0930 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
33 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:1731 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
34 */32 */
lib/libc/include/aarch64-freebsd-none/arm/sysarch.h+2
...@@ -38,6 +38,8 @@...@@ -38,6 +38,8 @@
38#ifndef _ARM_SYSARCH_H_38#ifndef _ARM_SYSARCH_H_
39#define _ARM_SYSARCH_H_39#define _ARM_SYSARCH_H_
4040
41#include <sys/cdefs.h>
42
41#include <machine/armreg.h>43#include <machine/armreg.h>
4244
43#ifndef LOCORE45#ifndef LOCORE
lib/libc/include/aarch64-freebsd-none/arm/sysreg.h+2-36
...@@ -127,11 +127,9 @@...@@ -127,11 +127,9 @@
127127
128/* From ARMv6: */128/* From ARMv6: */
129#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */129#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */
130#if __ARM_ARCH >= 7
131/* From ARMv7: */130/* From ARMv7: */
132#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */131#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */
133#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */132#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */
134#endif
135133
136/*134/*
137 * CP15 C6 registers135 * CP15 C6 registers
...@@ -147,7 +145,7 @@...@@ -147,7 +145,7 @@
147/*145/*
148 * CP15 C7 registers146 * CP15 C7 registers
149 */147 */
150#if __ARM_ARCH >= 7 && defined(SMP)148#if defined(SMP)
151/* From ARMv7: */149/* From ARMv7: */
152#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */150#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */
153#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */151#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */
...@@ -157,17 +155,9 @@...@@ -157,17 +155,9 @@
157155
158#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */156#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */
159#define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */157#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
164#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */158#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */
165#define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */159#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
171#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */161#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */
172#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */162#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */
173163
...@@ -176,43 +166,25 @@...@@ -176,43 +166,25 @@
176#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */166#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */
177#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */167#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */
178168
179#if __ARM_ARCH >= 7
180/* From ARMv7: */169/* From ARMv7: */
181#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */170#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */
182#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */171#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */
183#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */172#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */
184#define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */173#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
191#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */175#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */
192#define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */176#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
201/* From ARMv7: */178/* From ARMv7: */
202#define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */179#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
209#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */181#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */
210#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */182#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */
211183
212/*184/*
213 * CP15 C8 registers185 * CP15 C8 registers
214 */186 */
215#if __ARM_ARCH >= 7 && defined(SMP)187#if defined(SMP)
216/* From ARMv7: */188/* From ARMv7: */
217#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */189#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */
218#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */190#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */
...@@ -232,11 +204,6 @@...@@ -232,11 +204,6 @@
232/*204/*
233 * CP15 C9 registers205 * CP15 C9 registers
234 */206 */
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
240#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */207#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */
241#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */208#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */
242#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */209#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */
...@@ -250,7 +217,6 @@...@@ -250,7 +217,6 @@
250#define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */217#define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */
251#define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */218#define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */
252#define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */219#define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */
253#endif
254220
255/*221/*
256 * CP15 C10 registers222 * 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;...@@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address;
200 * Need a page dump array for minidump.200 * Need a page dump array for minidump.
201 */201 */
202#define MINIDUMP_PAGE_TRACKING 1202#define MINIDUMP_PAGE_TRACKING 1
203#define MINIDUMP_STARTUP_PAGE_TRACKING 0
203204
204#endif /* _MACHINE_VMPARAM_H_ */205#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/fenv.h+1
...@@ -31,6 +31,7 @@...@@ -31,6 +31,7 @@
31#ifndef _FENV_H_31#ifndef _FENV_H_
32#define _FENV_H_32#define _FENV_H_
3333
34#include <sys/cdefs.h>
34#include <sys/_types.h>35#include <sys/_types.h>
3536
36#ifndef __fenv_static37#ifndef __fenv_static
lib/libc/include/aarch64-freebsd-none/float.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
30 */28 */
3129
32#ifdef __arm__30#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/_align.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
30 */28 */
3129
32#ifdef __arm__30#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 @@...@@ -22,8 +22,6 @@
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22 * 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 OF23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.24 * SUCH DAMAGE.
25 *
26 * @(#)limits.h 8.3 (Berkeley) 1/4/94
27 */25 */
2826
29#ifdef __arm__27#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/_types.h-3
...@@ -26,9 +26,6 @@...@@ -26,9 +26,6 @@
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26 * 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 OF27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.28 * SUCH DAMAGE.
29 *
30 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
31 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
32 */29 */
3330
34#ifdef __arm__31#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/armreg.h+477-166
...@@ -36,29 +36,6 @@...@@ -36,29 +36,6 @@
3636
37#define INSN_SIZE 437#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
62#define __MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \39#define __MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \
63 S##op0##_##op1##_C##crn##_C##crm##_##op240 S##op0##_##op1##_C##crn##_C##crm##_##op2
64#define _MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \41#define _MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \
...@@ -231,8 +208,21 @@...@@ -231,8 +208,21 @@
231#define CLIDR_CTYPE_ID 0x3 /* Split instruction and data */208#define CLIDR_CTYPE_ID 0x3 /* Split instruction and data */
232#define CLIDR_CTYPE_UNIFIED 0x4 /* Unified */209#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
234/* CNTP_CTL_EL0 - Counter-timer Physical Timer Control register */225/* CNTP_CTL_EL0 - Counter-timer Physical Timer Control register */
235#define CNTP_CTL_EL0 MRS_REG(CNTP_CTL_EL0)
236#define CNTP_CTL_EL0_op0 3226#define CNTP_CTL_EL0_op0 3
237#define CNTP_CTL_EL0_op1 3227#define CNTP_CTL_EL0_op1 3
238#define CNTP_CTL_EL0_CRn 14228#define CNTP_CTL_EL0_CRn 14
...@@ -243,7 +233,6 @@...@@ -243,7 +233,6 @@
243#define CNTP_CTL_ISTATUS (1 << 2)233#define CNTP_CTL_ISTATUS (1 << 2)
244234
245/* CNTP_CVAL_EL0 - Counter-timer Physical Timer CompareValue register */235/* CNTP_CVAL_EL0 - Counter-timer Physical Timer CompareValue register */
246#define CNTP_CVAL_EL0 MRS_REG(CNTP_CVAL_EL0)
247#define CNTP_CVAL_EL0_op0 3236#define CNTP_CVAL_EL0_op0 3
248#define CNTP_CVAL_EL0_op1 3237#define CNTP_CVAL_EL0_op1 3
249#define CNTP_CVAL_EL0_CRn 14238#define CNTP_CVAL_EL0_CRn 14
...@@ -251,7 +240,6 @@...@@ -251,7 +240,6 @@
251#define CNTP_CVAL_EL0_op2 2240#define CNTP_CVAL_EL0_op2 2
252241
253/* CNTP_TVAL_EL0 - Counter-timer Physical Timer TimerValue register */242/* CNTP_TVAL_EL0 - Counter-timer Physical Timer TimerValue register */
254#define CNTP_TVAL_EL0 MRS_REG(CNTP_TVAL_EL0)
255#define CNTP_TVAL_EL0_op0 3243#define CNTP_TVAL_EL0_op0 3
256#define CNTP_TVAL_EL0_op1 3244#define CNTP_TVAL_EL0_op1 3
257#define CNTP_TVAL_EL0_CRn 14245#define CNTP_TVAL_EL0_CRn 14
...@@ -259,15 +247,42 @@...@@ -259,15 +247,42 @@
259#define CNTP_TVAL_EL0_op2 0247#define CNTP_TVAL_EL0_op2 0
260248
261/* CNTPCT_EL0 - Counter-timer Physical Count register */249/* 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)
263#define CNTPCT_EL0_op0 3251#define CNTPCT_EL0_op0 3
264#define CNTPCT_EL0_op1 3252#define CNTPCT_EL0_op1 3
265#define CNTPCT_EL0_CRn 14253#define CNTPCT_EL0_CRn 14
266#define CNTPCT_EL0_CRm 0254#define CNTPCT_EL0_CRm 0
267#define CNTPCT_EL0_op2 1255#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
269/* CONTEXTIDR_EL1 - Context ID register */285/* CONTEXTIDR_EL1 - Context ID register */
270#define CONTEXTIDR_EL1 MRS_REG(CONTEXTIDR_EL1)
271#define CONTEXTIDR_EL1_REG MRS_REG_ALT_NAME(CONTEXTIDR_EL1)286#define CONTEXTIDR_EL1_REG MRS_REG_ALT_NAME(CONTEXTIDR_EL1)
272#define CONTEXTIDR_EL1_op0 3287#define CONTEXTIDR_EL1_op0 3
273#define CONTEXTIDR_EL1_op1 0288#define CONTEXTIDR_EL1_op1 0
...@@ -315,36 +330,52 @@...@@ -315,36 +330,52 @@
315#define CSSELR_InD 0x00000001330#define CSSELR_InD 0x00000001
316331
317/* CTR_EL0 - Cache Type Register */332/* 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
318#define CTR_RES1 (1 << 31)340#define CTR_RES1 (1 << 31)
319#define CTR_TminLine_SHIFT 32341#define CTR_TminLine_SHIFT 32
320#define CTR_TminLine_MASK (UL(0x3f) << CTR_TminLine_SHIFT)342#define CTR_TminLine_MASK (UL(0x3f) << CTR_TminLine_SHIFT)
321#define CTR_TminLine_VAL(reg) ((reg) & CTR_TminLine_MASK)343#define CTR_TminLine_VAL(reg) ((reg) & CTR_TminLine_MASK)
322#define CTR_DIC_SHIFT 29344#define CTR_DIC_SHIFT 29
345#define CTR_DIC_WIDTH 1
323#define CTR_DIC_MASK (0x1 << CTR_DIC_SHIFT)346#define CTR_DIC_MASK (0x1 << CTR_DIC_SHIFT)
324#define CTR_DIC_VAL(reg) ((reg) & CTR_DIC_MASK)347#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)
325#define CTR_IDC_SHIFT 28350#define CTR_IDC_SHIFT 28
351#define CTR_IDC_WIDTH 1
326#define CTR_IDC_MASK (0x1 << CTR_IDC_SHIFT)352#define CTR_IDC_MASK (0x1 << CTR_IDC_SHIFT)
327#define CTR_IDC_VAL(reg) ((reg) & CTR_IDC_MASK)353#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)
328#define CTR_CWG_SHIFT 24356#define CTR_CWG_SHIFT 24
357#define CTR_CWG_WIDTH 4
329#define CTR_CWG_MASK (0xf << CTR_CWG_SHIFT)358#define CTR_CWG_MASK (0xf << CTR_CWG_SHIFT)
330#define CTR_CWG_VAL(reg) ((reg) & CTR_CWG_MASK)359#define CTR_CWG_VAL(reg) ((reg) & CTR_CWG_MASK)
331#define CTR_CWG_SIZE(reg) (4 << (CTR_CWG_VAL(reg) >> CTR_CWG_SHIFT))360#define CTR_CWG_SIZE(reg) (4 << (CTR_CWG_VAL(reg) >> CTR_CWG_SHIFT))
332#define CTR_ERG_SHIFT 20361#define CTR_ERG_SHIFT 20
362#define CTR_ERG_WIDTH 4
333#define CTR_ERG_MASK (0xf << CTR_ERG_SHIFT)363#define CTR_ERG_MASK (0xf << CTR_ERG_SHIFT)
334#define CTR_ERG_VAL(reg) ((reg) & CTR_ERG_MASK)364#define CTR_ERG_VAL(reg) ((reg) & CTR_ERG_MASK)
335#define CTR_ERG_SIZE(reg) (4 << (CTR_ERG_VAL(reg) >> CTR_ERG_SHIFT))365#define CTR_ERG_SIZE(reg) (4 << (CTR_ERG_VAL(reg) >> CTR_ERG_SHIFT))
336#define CTR_DLINE_SHIFT 16366#define CTR_DLINE_SHIFT 16
367#define CTR_DLINE_WIDTH 4
337#define CTR_DLINE_MASK (0xf << CTR_DLINE_SHIFT)368#define CTR_DLINE_MASK (0xf << CTR_DLINE_SHIFT)
338#define CTR_DLINE_VAL(reg) ((reg) & CTR_DLINE_MASK)369#define CTR_DLINE_VAL(reg) ((reg) & CTR_DLINE_MASK)
339#define CTR_DLINE_SIZE(reg) (4 << (CTR_DLINE_VAL(reg) >> CTR_DLINE_SHIFT))370#define CTR_DLINE_SIZE(reg) (4 << (CTR_DLINE_VAL(reg) >> CTR_DLINE_SHIFT))
340#define CTR_L1IP_SHIFT 14371#define CTR_L1IP_SHIFT 14
372#define CTR_L1IP_WIDTH 2
341#define CTR_L1IP_MASK (0x3 << CTR_L1IP_SHIFT)373#define CTR_L1IP_MASK (0x3 << CTR_L1IP_SHIFT)
342#define CTR_L1IP_VAL(reg) ((reg) & CTR_L1IP_MASK)374#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)
345#define CTR_L1IP_VIPT (2 << CTR_L1IP_SHIFT)375#define CTR_L1IP_VIPT (2 << CTR_L1IP_SHIFT)
346#define CTR_L1IP_PIPT (3 << CTR_L1IP_SHIFT)376#define CTR_L1IP_PIPT (3 << CTR_L1IP_SHIFT)
347#define CTR_ILINE_SHIFT 0377#define CTR_ILINE_SHIFT 0
378#define CTR_ILINE_WIDTH 4
348#define CTR_ILINE_MASK (0xf << CTR_ILINE_SHIFT)379#define CTR_ILINE_MASK (0xf << CTR_ILINE_SHIFT)
349#define CTR_ILINE_VAL(reg) ((reg) & CTR_ILINE_MASK)380#define CTR_ILINE_VAL(reg) ((reg) & CTR_ILINE_MASK)
350#define CTR_ILINE_SIZE(reg) (4 << (CTR_ILINE_VAL(reg) >> CTR_ILINE_SHIFT))381#define CTR_ILINE_SIZE(reg) (4 << (CTR_ILINE_VAL(reg) >> CTR_ILINE_SHIFT))
...@@ -363,7 +394,7 @@...@@ -363,7 +394,7 @@
363#define DAIF_I (1 << 1)394#define DAIF_I (1 << 1)
364#define DAIF_F (1 << 0)395#define DAIF_F (1 << 0)
365#define DAIF_ALL (DAIF_D | DAIF_A | DAIF_I | DAIF_F)396#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 */
367 /* through the intr framework */398 /* through the intr framework */
368399
369/* DBGBCR<n>_EL1 - Debug Breakpoint Control Registers */400/* DBGBCR<n>_EL1 - Debug Breakpoint Control Registers */
...@@ -435,7 +466,6 @@...@@ -435,7 +466,6 @@
435#define DCZID_BS_SIZE(reg) (((reg) & DCZID_BS_MASK) >> DCZID_BS_SHIFT)466#define DCZID_BS_SIZE(reg) (((reg) & DCZID_BS_MASK) >> DCZID_BS_SHIFT)
436467
437/* DBGAUTHSTATUS_EL1 */468/* DBGAUTHSTATUS_EL1 */
438#define DBGAUTHSTATUS_EL1 MRS_REG(DBGAUTHSTATUS_EL1)
439#define DBGAUTHSTATUS_EL1_op0 2469#define DBGAUTHSTATUS_EL1_op0 2
440#define DBGAUTHSTATUS_EL1_op1 0470#define DBGAUTHSTATUS_EL1_op1 0
441#define DBGAUTHSTATUS_EL1_CRn 7471#define DBGAUTHSTATUS_EL1_CRn 7
...@@ -443,7 +473,6 @@...@@ -443,7 +473,6 @@
443#define DBGAUTHSTATUS_EL1_op2 6473#define DBGAUTHSTATUS_EL1_op2 6
444474
445/* DBGCLAIMCLR_EL1 */475/* DBGCLAIMCLR_EL1 */
446#define DBGCLAIMCLR_EL1 MRS_REG(DBGCLAIMCLR_EL1)
447#define DBGCLAIMCLR_EL1_op0 2476#define DBGCLAIMCLR_EL1_op0 2
448#define DBGCLAIMCLR_EL1_op1 0477#define DBGCLAIMCLR_EL1_op1 0
449#define DBGCLAIMCLR_EL1_CRn 7478#define DBGCLAIMCLR_EL1_CRn 7
...@@ -451,7 +480,6 @@...@@ -451,7 +480,6 @@
451#define DBGCLAIMCLR_EL1_op2 6480#define DBGCLAIMCLR_EL1_op2 6
452481
453/* DBGCLAIMSET_EL1 */482/* DBGCLAIMSET_EL1 */
454#define DBGCLAIMSET_EL1 MRS_REG(DBGCLAIMSET_EL1)
455#define DBGCLAIMSET_EL1_op0 2483#define DBGCLAIMSET_EL1_op0 2
456#define DBGCLAIMSET_EL1_op1 0484#define DBGCLAIMSET_EL1_op1 0
457#define DBGCLAIMSET_EL1_CRn 7485#define DBGCLAIMSET_EL1_CRn 7
...@@ -459,7 +487,6 @@...@@ -459,7 +487,6 @@
459#define DBGCLAIMSET_EL1_op2 6487#define DBGCLAIMSET_EL1_op2 6
460488
461/* DBGPRCR_EL1 */489/* DBGPRCR_EL1 */
462#define DBGPRCR_EL1 MRS_REG(DBGPRCR_EL1)
463#define DBGPRCR_EL1_op0 2490#define DBGPRCR_EL1_op0 2
464#define DBGPRCR_EL1_op1 0491#define DBGPRCR_EL1_op1 0
465#define DBGPRCR_EL1_CRn 1492#define DBGPRCR_EL1_CRn 1
...@@ -540,12 +567,14 @@...@@ -540,12 +567,14 @@
540#define ISS_MSR_REG_MASK \567#define ISS_MSR_REG_MASK \
541 (ISS_MSR_OP0_MASK | ISS_MSR_OP2_MASK | ISS_MSR_OP1_MASK | \568 (ISS_MSR_OP0_MASK | ISS_MSR_OP2_MASK | ISS_MSR_OP1_MASK | \
542 ISS_MSR_CRn_MASK | ISS_MSR_CRm_MASK)569 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))
543#define ISS_MSR_REG(reg) \576#define ISS_MSR_REG(reg) \
544 (((reg ## _op0) << ISS_MSR_OP0_SHIFT) | \577 __ISS_MSR_REG(reg##_op0, reg##_op1, reg##_CRn, reg##_CRm, reg##_op2)
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))
549578
550#define ISS_DATA_ISV_SHIFT 24579#define ISS_DATA_ISV_SHIFT 24
551#define ISS_DATA_ISV (0x01 << ISS_DATA_ISV_SHIFT)580#define ISS_DATA_ISV (0x01 << ISS_DATA_ISV_SHIFT)
...@@ -667,7 +696,6 @@...@@ -667,7 +696,6 @@
667#define ICC_PMR_EL1_PRIO_MASK (0xFFUL)696#define ICC_PMR_EL1_PRIO_MASK (0xFFUL)
668697
669/* ICC_SGI1R_EL1 */698/* ICC_SGI1R_EL1 */
670#define ICC_SGI1R_EL1 MRS_REG(ICC_SGI1R_EL1)
671#define ICC_SGI1R_EL1_op0 3699#define ICC_SGI1R_EL1_op0 3
672#define ICC_SGI1R_EL1_op1 0700#define ICC_SGI1R_EL1_op1 0
673#define ICC_SGI1R_EL1_CRn 12701#define ICC_SGI1R_EL1_CRn 12
...@@ -697,8 +725,8 @@...@@ -697,8 +725,8 @@
697#define ICC_SRE_EL1_SRE (1U << 0)725#define ICC_SRE_EL1_SRE (1U << 0)
698726
699/* ID_AA64AFR0_EL1 */727/* ID_AA64AFR0_EL1 */
700#define ID_AA64AFR0_EL1 MRS_REG(ID_AA64AFR0_EL1)
701#define ID_AA64AFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR0_EL1)728#define ID_AA64AFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR0_EL1)
729#define ID_AA64AFR0_EL1_ISS ISS_MSR_REG(ID_AA64AFR0_EL1)
702#define ID_AA64AFR0_EL1_op0 3730#define ID_AA64AFR0_EL1_op0 3
703#define ID_AA64AFR0_EL1_op1 0731#define ID_AA64AFR0_EL1_op1 0
704#define ID_AA64AFR0_EL1_CRn 0732#define ID_AA64AFR0_EL1_CRn 0
...@@ -706,8 +734,8 @@...@@ -706,8 +734,8 @@
706#define ID_AA64AFR0_EL1_op2 4734#define ID_AA64AFR0_EL1_op2 4
707735
708/* ID_AA64AFR1_EL1 */736/* ID_AA64AFR1_EL1 */
709#define ID_AA64AFR1_EL1 MRS_REG(ID_AA64AFR1_EL1)
710#define ID_AA64AFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR1_EL1)737#define ID_AA64AFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR1_EL1)
738#define ID_AA64AFR1_EL1_ISS ISS_MSR_REG(ID_AA64AFR1_EL1)
711#define ID_AA64AFR1_EL1_op0 3739#define ID_AA64AFR1_EL1_op0 3
712#define ID_AA64AFR1_EL1_op1 0740#define ID_AA64AFR1_EL1_op1 0
713#define ID_AA64AFR1_EL1_CRn 0741#define ID_AA64AFR1_EL1_CRn 0
...@@ -715,14 +743,15 @@...@@ -715,14 +743,15 @@
715#define ID_AA64AFR1_EL1_op2 5743#define ID_AA64AFR1_EL1_op2 5
716744
717/* ID_AA64DFR0_EL1 */745/* ID_AA64DFR0_EL1 */
718#define ID_AA64DFR0_EL1 MRS_REG(ID_AA64DFR0_EL1)
719#define ID_AA64DFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR0_EL1)746#define ID_AA64DFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR0_EL1)
747#define ID_AA64DFR0_EL1_ISS ISS_MSR_REG(ID_AA64DFR0_EL1)
720#define ID_AA64DFR0_EL1_op0 3748#define ID_AA64DFR0_EL1_op0 3
721#define ID_AA64DFR0_EL1_op1 0749#define ID_AA64DFR0_EL1_op1 0
722#define ID_AA64DFR0_EL1_CRn 0750#define ID_AA64DFR0_EL1_CRn 0
723#define ID_AA64DFR0_EL1_CRm 5751#define ID_AA64DFR0_EL1_CRm 5
724#define ID_AA64DFR0_EL1_op2 0752#define ID_AA64DFR0_EL1_op2 0
725#define ID_AA64DFR0_DebugVer_SHIFT 0753#define ID_AA64DFR0_DebugVer_SHIFT 0
754#define ID_AA64DFR0_DebugVer_WIDTH 4
726#define ID_AA64DFR0_DebugVer_MASK (UL(0xf) << ID_AA64DFR0_DebugVer_SHIFT)755#define ID_AA64DFR0_DebugVer_MASK (UL(0xf) << ID_AA64DFR0_DebugVer_SHIFT)
727#define ID_AA64DFR0_DebugVer_VAL(x) ((x) & ID_AA64DFR0_DebugVer_MASK)756#define ID_AA64DFR0_DebugVer_VAL(x) ((x) & ID_AA64DFR0_DebugVer_MASK)
728#define ID_AA64DFR0_DebugVer_8 (UL(0x6) << ID_AA64DFR0_DebugVer_SHIFT)757#define ID_AA64DFR0_DebugVer_8 (UL(0x6) << ID_AA64DFR0_DebugVer_SHIFT)
...@@ -730,12 +759,15 @@...@@ -730,12 +759,15 @@
730#define ID_AA64DFR0_DebugVer_8_2 (UL(0x8) << ID_AA64DFR0_DebugVer_SHIFT)759#define ID_AA64DFR0_DebugVer_8_2 (UL(0x8) << ID_AA64DFR0_DebugVer_SHIFT)
731#define ID_AA64DFR0_DebugVer_8_4 (UL(0x9) << ID_AA64DFR0_DebugVer_SHIFT)760#define ID_AA64DFR0_DebugVer_8_4 (UL(0x9) << ID_AA64DFR0_DebugVer_SHIFT)
732#define ID_AA64DFR0_DebugVer_8_8 (UL(0xa) << ID_AA64DFR0_DebugVer_SHIFT)761#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)
733#define ID_AA64DFR0_TraceVer_SHIFT 4763#define ID_AA64DFR0_TraceVer_SHIFT 4
764#define ID_AA64DFR0_TraceVer_WIDTH 4
734#define ID_AA64DFR0_TraceVer_MASK (UL(0xf) << ID_AA64DFR0_TraceVer_SHIFT)765#define ID_AA64DFR0_TraceVer_MASK (UL(0xf) << ID_AA64DFR0_TraceVer_SHIFT)
735#define ID_AA64DFR0_TraceVer_VAL(x) ((x) & ID_AA64DFR0_TraceVer_MASK)766#define ID_AA64DFR0_TraceVer_VAL(x) ((x) & ID_AA64DFR0_TraceVer_MASK)
736#define ID_AA64DFR0_TraceVer_NONE (UL(0x0) << ID_AA64DFR0_TraceVer_SHIFT)767#define ID_AA64DFR0_TraceVer_NONE (UL(0x0) << ID_AA64DFR0_TraceVer_SHIFT)
737#define ID_AA64DFR0_TraceVer_IMPL (UL(0x1) << ID_AA64DFR0_TraceVer_SHIFT)768#define ID_AA64DFR0_TraceVer_IMPL (UL(0x1) << ID_AA64DFR0_TraceVer_SHIFT)
738#define ID_AA64DFR0_PMUVer_SHIFT 8769#define ID_AA64DFR0_PMUVer_SHIFT 8
770#define ID_AA64DFR0_PMUVer_WIDTH 4
739#define ID_AA64DFR0_PMUVer_MASK (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT)771#define ID_AA64DFR0_PMUVer_MASK (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT)
740#define ID_AA64DFR0_PMUVer_VAL(x) ((x) & ID_AA64DFR0_PMUVer_MASK)772#define ID_AA64DFR0_PMUVer_VAL(x) ((x) & ID_AA64DFR0_PMUVer_MASK)
741#define ID_AA64DFR0_PMUVer_NONE (UL(0x0) << ID_AA64DFR0_PMUVer_SHIFT)773#define ID_AA64DFR0_PMUVer_NONE (UL(0x0) << ID_AA64DFR0_PMUVer_SHIFT)
...@@ -745,25 +777,31 @@...@@ -745,25 +777,31 @@
745#define ID_AA64DFR0_PMUVer_3_5 (UL(0x6) << ID_AA64DFR0_PMUVer_SHIFT)777#define ID_AA64DFR0_PMUVer_3_5 (UL(0x6) << ID_AA64DFR0_PMUVer_SHIFT)
746#define ID_AA64DFR0_PMUVer_3_7 (UL(0x7) << ID_AA64DFR0_PMUVer_SHIFT)778#define ID_AA64DFR0_PMUVer_3_7 (UL(0x7) << ID_AA64DFR0_PMUVer_SHIFT)
747#define ID_AA64DFR0_PMUVer_3_8 (UL(0x8) << ID_AA64DFR0_PMUVer_SHIFT)779#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)
748#define ID_AA64DFR0_PMUVer_IMPL (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT)781#define ID_AA64DFR0_PMUVer_IMPL (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT)
749#define ID_AA64DFR0_BRPs_SHIFT 12782#define ID_AA64DFR0_BRPs_SHIFT 12
783#define ID_AA64DFR0_BRPs_WIDTH 4
750#define ID_AA64DFR0_BRPs_MASK (UL(0xf) << ID_AA64DFR0_BRPs_SHIFT)784#define ID_AA64DFR0_BRPs_MASK (UL(0xf) << ID_AA64DFR0_BRPs_SHIFT)
751#define ID_AA64DFR0_BRPs_VAL(x) \785#define ID_AA64DFR0_BRPs_VAL(x) \
752 ((((x) >> ID_AA64DFR0_BRPs_SHIFT) & 0xf) + 1)786 ((((x) >> ID_AA64DFR0_BRPs_SHIFT) & 0xf) + 1)
753#define ID_AA64DFR0_PMSS_SHIFT 16787#define ID_AA64DFR0_PMSS_SHIFT 16
788#define ID_AA64DFR0_PMSS_WIDTH 4
754#define ID_AA64DFR0_PMSS_MASK (UL(0xf) << ID_AA64DFR0_PMSS_SHIFT)789#define ID_AA64DFR0_PMSS_MASK (UL(0xf) << ID_AA64DFR0_PMSS_SHIFT)
755#define ID_AA64DFR0_PMSS_VAL(x) ((x) & ID_AA64DFR0_PMSS_MASK)790#define ID_AA64DFR0_PMSS_VAL(x) ((x) & ID_AA64DFR0_PMSS_MASK)
756#define ID_AA64DFR0_PMSS_NONE (UL(0x0) << ID_AA64DFR0_PMSS_SHIFT)791#define ID_AA64DFR0_PMSS_NONE (UL(0x0) << ID_AA64DFR0_PMSS_SHIFT)
757#define ID_AA64DFR0_PMSS_IMPL (UL(0x1) << ID_AA64DFR0_PMSS_SHIFT)792#define ID_AA64DFR0_PMSS_IMPL (UL(0x1) << ID_AA64DFR0_PMSS_SHIFT)
758#define ID_AA64DFR0_WRPs_SHIFT 20793#define ID_AA64DFR0_WRPs_SHIFT 20
794#define ID_AA64DFR0_WRPs_WIDTH 4
759#define ID_AA64DFR0_WRPs_MASK (UL(0xf) << ID_AA64DFR0_WRPs_SHIFT)795#define ID_AA64DFR0_WRPs_MASK (UL(0xf) << ID_AA64DFR0_WRPs_SHIFT)
760#define ID_AA64DFR0_WRPs_VAL(x) \796#define ID_AA64DFR0_WRPs_VAL(x) \
761 ((((x) >> ID_AA64DFR0_WRPs_SHIFT) & 0xf) + 1)797 ((((x) >> ID_AA64DFR0_WRPs_SHIFT) & 0xf) + 1)
762#define ID_AA64DFR0_CTX_CMPs_SHIFT 28798#define ID_AA64DFR0_CTX_CMPs_SHIFT 28
799#define ID_AA64DFR0_CTX_CMPs_WIDTH 4
763#define ID_AA64DFR0_CTX_CMPs_MASK (UL(0xf) << ID_AA64DFR0_CTX_CMPs_SHIFT)800#define ID_AA64DFR0_CTX_CMPs_MASK (UL(0xf) << ID_AA64DFR0_CTX_CMPs_SHIFT)
764#define ID_AA64DFR0_CTX_CMPs_VAL(x) \801#define ID_AA64DFR0_CTX_CMPs_VAL(x) \
765 ((((x) >> ID_AA64DFR0_CTX_CMPs_SHIFT) & 0xf) + 1)802 ((((x) >> ID_AA64DFR0_CTX_CMPs_SHIFT) & 0xf) + 1)
766#define ID_AA64DFR0_PMSVer_SHIFT 32803#define ID_AA64DFR0_PMSVer_SHIFT 32
804#define ID_AA64DFR0_PMSVer_WIDTH 4
767#define ID_AA64DFR0_PMSVer_MASK (UL(0xf) << ID_AA64DFR0_PMSVer_SHIFT)805#define ID_AA64DFR0_PMSVer_MASK (UL(0xf) << ID_AA64DFR0_PMSVer_SHIFT)
768#define ID_AA64DFR0_PMSVer_VAL(x) ((x) & ID_AA64DFR0_PMSVer_MASK)806#define ID_AA64DFR0_PMSVer_VAL(x) ((x) & ID_AA64DFR0_PMSVer_MASK)
769#define ID_AA64DFR0_PMSVer_NONE (UL(0x0) << ID_AA64DFR0_PMSVer_SHIFT)807#define ID_AA64DFR0_PMSVer_NONE (UL(0x0) << ID_AA64DFR0_PMSVer_SHIFT)
...@@ -771,150 +809,192 @@...@@ -771,150 +809,192 @@
771#define ID_AA64DFR0_PMSVer_SPE_1_1 (UL(0x2) << ID_AA64DFR0_PMSVer_SHIFT)809#define ID_AA64DFR0_PMSVer_SPE_1_1 (UL(0x2) << ID_AA64DFR0_PMSVer_SHIFT)
772#define ID_AA64DFR0_PMSVer_SPE_1_2 (UL(0x3) << ID_AA64DFR0_PMSVer_SHIFT)810#define ID_AA64DFR0_PMSVer_SPE_1_2 (UL(0x3) << ID_AA64DFR0_PMSVer_SHIFT)
773#define ID_AA64DFR0_PMSVer_SPE_1_3 (UL(0x4) << ID_AA64DFR0_PMSVer_SHIFT)811#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)
774#define ID_AA64DFR0_DoubleLock_SHIFT 36813#define ID_AA64DFR0_DoubleLock_SHIFT 36
814#define ID_AA64DFR0_DoubleLock_WIDTH 4
775#define ID_AA64DFR0_DoubleLock_MASK (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT)815#define ID_AA64DFR0_DoubleLock_MASK (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT)
776#define ID_AA64DFR0_DoubleLock_VAL(x) ((x) & ID_AA64DFR0_DoubleLock_MASK)816#define ID_AA64DFR0_DoubleLock_VAL(x) ((x) & ID_AA64DFR0_DoubleLock_MASK)
777#define ID_AA64DFR0_DoubleLock_IMPL (UL(0x0) << ID_AA64DFR0_DoubleLock_SHIFT)817#define ID_AA64DFR0_DoubleLock_IMPL (UL(0x0) << ID_AA64DFR0_DoubleLock_SHIFT)
778#define ID_AA64DFR0_DoubleLock_NONE (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT)818#define ID_AA64DFR0_DoubleLock_NONE (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT)
779#define ID_AA64DFR0_TraceFilt_SHIFT 40819#define ID_AA64DFR0_TraceFilt_SHIFT 40
820#define ID_AA64DFR0_TraceFilt_WIDTH 4
780#define ID_AA64DFR0_TraceFilt_MASK (UL(0xf) << ID_AA64DFR0_TraceFilt_SHIFT)821#define ID_AA64DFR0_TraceFilt_MASK (UL(0xf) << ID_AA64DFR0_TraceFilt_SHIFT)
781#define ID_AA64DFR0_TraceFilt_VAL(x) ((x) & ID_AA64DFR0_TraceFilt_MASK)822#define ID_AA64DFR0_TraceFilt_VAL(x) ((x) & ID_AA64DFR0_TraceFilt_MASK)
782#define ID_AA64DFR0_TraceFilt_NONE (UL(0x0) << ID_AA64DFR0_TraceFilt_SHIFT)823#define ID_AA64DFR0_TraceFilt_NONE (UL(0x0) << ID_AA64DFR0_TraceFilt_SHIFT)
783#define ID_AA64DFR0_TraceFilt_8_4 (UL(0x1) << ID_AA64DFR0_TraceFilt_SHIFT)824#define ID_AA64DFR0_TraceFilt_8_4 (UL(0x1) << ID_AA64DFR0_TraceFilt_SHIFT)
784#define ID_AA64DFR0_TraceBuffer_SHIFT 44825#define ID_AA64DFR0_TraceBuffer_SHIFT 44
826#define ID_AA64DFR0_TraceBuffer_WIDTH 4
785#define ID_AA64DFR0_TraceBuffer_MASK (UL(0xf) << ID_AA64DFR0_TraceBuffer_SHIFT)827#define ID_AA64DFR0_TraceBuffer_MASK (UL(0xf) << ID_AA64DFR0_TraceBuffer_SHIFT)
786#define ID_AA64DFR0_TraceBuffer_VAL(x) ((x) & ID_AA64DFR0_TraceBuffer_MASK)828#define ID_AA64DFR0_TraceBuffer_VAL(x) ((x) & ID_AA64DFR0_TraceBuffer_MASK)
787#define ID_AA64DFR0_TraceBuffer_NONE (UL(0x0) << ID_AA64DFR0_TraceBuffer_SHIFT)829#define ID_AA64DFR0_TraceBuffer_NONE (UL(0x0) << ID_AA64DFR0_TraceBuffer_SHIFT)
788#define ID_AA64DFR0_TraceBuffer_IMPL (UL(0x1) << ID_AA64DFR0_TraceBuffer_SHIFT)830#define ID_AA64DFR0_TraceBuffer_IMPL (UL(0x1) << ID_AA64DFR0_TraceBuffer_SHIFT)
789#define ID_AA64DFR0_MTPMU_SHIFT 48831#define ID_AA64DFR0_MTPMU_SHIFT 48
832#define ID_AA64DFR0_MTPMU_WIDTH 4
790#define ID_AA64DFR0_MTPMU_MASK (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT)833#define ID_AA64DFR0_MTPMU_MASK (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT)
791#define ID_AA64DFR0_MTPMU_VAL(x) ((x) & ID_AA64DFR0_MTPMU_MASK)834#define ID_AA64DFR0_MTPMU_VAL(x) ((x) & ID_AA64DFR0_MTPMU_MASK)
792#define ID_AA64DFR0_MTPMU_NONE (UL(0x0) << ID_AA64DFR0_MTPMU_SHIFT)835#define ID_AA64DFR0_MTPMU_NONE (UL(0x0) << ID_AA64DFR0_MTPMU_SHIFT)
793#define ID_AA64DFR0_MTPMU_IMPL (UL(0x1) << ID_AA64DFR0_MTPMU_SHIFT)836#define ID_AA64DFR0_MTPMU_IMPL (UL(0x1) << ID_AA64DFR0_MTPMU_SHIFT)
794#define ID_AA64DFR0_MTPMU_NONE_MT_RES0 (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT)837#define ID_AA64DFR0_MTPMU_NONE_MT_RES0 (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT)
795#define ID_AA64DFR0_BRBE_SHIFT 52838#define ID_AA64DFR0_BRBE_SHIFT 52
839#define ID_AA64DFR0_BRBE_WIDTH 4
796#define ID_AA64DFR0_BRBE_MASK (UL(0xf) << ID_AA64DFR0_BRBE_SHIFT)840#define ID_AA64DFR0_BRBE_MASK (UL(0xf) << ID_AA64DFR0_BRBE_SHIFT)
797#define ID_AA64DFR0_BRBE_VAL(x) ((x) & ID_AA64DFR0_BRBE_MASK)841#define ID_AA64DFR0_BRBE_VAL(x) ((x) & ID_AA64DFR0_BRBE_MASK)
798#define ID_AA64DFR0_BRBE_NONE (UL(0x0) << ID_AA64DFR0_BRBE_SHIFT)842#define ID_AA64DFR0_BRBE_NONE (UL(0x0) << ID_AA64DFR0_BRBE_SHIFT)
799#define ID_AA64DFR0_BRBE_IMPL (UL(0x1) << ID_AA64DFR0_BRBE_SHIFT)843#define ID_AA64DFR0_BRBE_IMPL (UL(0x1) << ID_AA64DFR0_BRBE_SHIFT)
800#define ID_AA64DFR0_BRBE_EL3 (UL(0x2) << ID_AA64DFR0_BRBE_SHIFT)844#define ID_AA64DFR0_BRBE_EL3 (UL(0x2) << ID_AA64DFR0_BRBE_SHIFT)
801#define ID_AA64DFR0_HPMN0_SHIFT 60845#define ID_AA64DFR0_HPMN0_SHIFT 60
846#define ID_AA64DFR0_HPMN0_WIDTH 4
802#define ID_AA64DFR0_HPMN0_MASK (UL(0xf) << ID_AA64DFR0_HPMN0_SHIFT)847#define ID_AA64DFR0_HPMN0_MASK (UL(0xf) << ID_AA64DFR0_HPMN0_SHIFT)
803#define ID_AA64DFR0_HPMN0_VAL(x) ((x) & ID_AA64DFR0_HPMN0_MASK)848#define ID_AA64DFR0_HPMN0_VAL(x) ((x) & ID_AA64DFR0_HPMN0_MASK)
804#define ID_AA64DFR0_HPMN0_CONSTR (UL(0x0) << ID_AA64DFR0_HPMN0_SHIFT)849#define ID_AA64DFR0_HPMN0_CONSTR (UL(0x0) << ID_AA64DFR0_HPMN0_SHIFT)
805#define ID_AA64DFR0_HPMN0_DEFINED (UL(0x1) << ID_AA64DFR0_HPMN0_SHIFT)850#define ID_AA64DFR0_HPMN0_DEFINED (UL(0x1) << ID_AA64DFR0_HPMN0_SHIFT)
806851
807/* ID_AA64DFR1_EL1 */852/* ID_AA64DFR1_EL1 */
808#define ID_AA64DFR1_EL1 MRS_REG(ID_AA64DFR1_EL1)
809#define ID_AA64DFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR1_EL1)853#define ID_AA64DFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR1_EL1)
854#define ID_AA64DFR1_EL1_ISS ISS_MSR_REG(ID_AA64DFR1_EL1)
810#define ID_AA64DFR1_EL1_op0 3855#define ID_AA64DFR1_EL1_op0 3
811#define ID_AA64DFR1_EL1_op1 0856#define ID_AA64DFR1_EL1_op1 0
812#define ID_AA64DFR1_EL1_CRn 0857#define ID_AA64DFR1_EL1_CRn 0
813#define ID_AA64DFR1_EL1_CRm 5858#define ID_AA64DFR1_EL1_CRm 5
814#define ID_AA64DFR1_EL1_op2 1859#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
816/* ID_AA64ISAR0_EL1 */879/* ID_AA64ISAR0_EL1 */
817#define ID_AA64ISAR0_EL1 MRS_REG(ID_AA64ISAR0_EL1)
818#define ID_AA64ISAR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR0_EL1)880#define ID_AA64ISAR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR0_EL1)
881#define ID_AA64ISAR0_EL1_ISS ISS_MSR_REG(ID_AA64ISAR0_EL1)
819#define ID_AA64ISAR0_EL1_op0 3882#define ID_AA64ISAR0_EL1_op0 3
820#define ID_AA64ISAR0_EL1_op1 0883#define ID_AA64ISAR0_EL1_op1 0
821#define ID_AA64ISAR0_EL1_CRn 0884#define ID_AA64ISAR0_EL1_CRn 0
822#define ID_AA64ISAR0_EL1_CRm 6885#define ID_AA64ISAR0_EL1_CRm 6
823#define ID_AA64ISAR0_EL1_op2 0886#define ID_AA64ISAR0_EL1_op2 0
824#define ID_AA64ISAR0_AES_SHIFT 4887#define ID_AA64ISAR0_AES_SHIFT 4
888#define ID_AA64ISAR0_AES_WIDTH 4
825#define ID_AA64ISAR0_AES_MASK (UL(0xf) << ID_AA64ISAR0_AES_SHIFT)889#define ID_AA64ISAR0_AES_MASK (UL(0xf) << ID_AA64ISAR0_AES_SHIFT)
826#define ID_AA64ISAR0_AES_VAL(x) ((x) & ID_AA64ISAR0_AES_MASK)890#define ID_AA64ISAR0_AES_VAL(x) ((x) & ID_AA64ISAR0_AES_MASK)
827#define ID_AA64ISAR0_AES_NONE (UL(0x0) << ID_AA64ISAR0_AES_SHIFT)891#define ID_AA64ISAR0_AES_NONE (UL(0x0) << ID_AA64ISAR0_AES_SHIFT)
828#define ID_AA64ISAR0_AES_BASE (UL(0x1) << ID_AA64ISAR0_AES_SHIFT)892#define ID_AA64ISAR0_AES_BASE (UL(0x1) << ID_AA64ISAR0_AES_SHIFT)
829#define ID_AA64ISAR0_AES_PMULL (UL(0x2) << ID_AA64ISAR0_AES_SHIFT)893#define ID_AA64ISAR0_AES_PMULL (UL(0x2) << ID_AA64ISAR0_AES_SHIFT)
830#define ID_AA64ISAR0_SHA1_SHIFT 8894#define ID_AA64ISAR0_SHA1_SHIFT 8
895#define ID_AA64ISAR0_SHA1_WIDTH 4
831#define ID_AA64ISAR0_SHA1_MASK (UL(0xf) << ID_AA64ISAR0_SHA1_SHIFT)896#define ID_AA64ISAR0_SHA1_MASK (UL(0xf) << ID_AA64ISAR0_SHA1_SHIFT)
832#define ID_AA64ISAR0_SHA1_VAL(x) ((x) & ID_AA64ISAR0_SHA1_MASK)897#define ID_AA64ISAR0_SHA1_VAL(x) ((x) & ID_AA64ISAR0_SHA1_MASK)
833#define ID_AA64ISAR0_SHA1_NONE (UL(0x0) << ID_AA64ISAR0_SHA1_SHIFT)898#define ID_AA64ISAR0_SHA1_NONE (UL(0x0) << ID_AA64ISAR0_SHA1_SHIFT)
834#define ID_AA64ISAR0_SHA1_BASE (UL(0x1) << ID_AA64ISAR0_SHA1_SHIFT)899#define ID_AA64ISAR0_SHA1_BASE (UL(0x1) << ID_AA64ISAR0_SHA1_SHIFT)
835#define ID_AA64ISAR0_SHA2_SHIFT 12900#define ID_AA64ISAR0_SHA2_SHIFT 12
901#define ID_AA64ISAR0_SHA2_WIDTH 4
836#define ID_AA64ISAR0_SHA2_MASK (UL(0xf) << ID_AA64ISAR0_SHA2_SHIFT)902#define ID_AA64ISAR0_SHA2_MASK (UL(0xf) << ID_AA64ISAR0_SHA2_SHIFT)
837#define ID_AA64ISAR0_SHA2_VAL(x) ((x) & ID_AA64ISAR0_SHA2_MASK)903#define ID_AA64ISAR0_SHA2_VAL(x) ((x) & ID_AA64ISAR0_SHA2_MASK)
838#define ID_AA64ISAR0_SHA2_NONE (UL(0x0) << ID_AA64ISAR0_SHA2_SHIFT)904#define ID_AA64ISAR0_SHA2_NONE (UL(0x0) << ID_AA64ISAR0_SHA2_SHIFT)
839#define ID_AA64ISAR0_SHA2_BASE (UL(0x1) << ID_AA64ISAR0_SHA2_SHIFT)905#define ID_AA64ISAR0_SHA2_BASE (UL(0x1) << ID_AA64ISAR0_SHA2_SHIFT)
840#define ID_AA64ISAR0_SHA2_512 (UL(0x2) << ID_AA64ISAR0_SHA2_SHIFT)906#define ID_AA64ISAR0_SHA2_512 (UL(0x2) << ID_AA64ISAR0_SHA2_SHIFT)
841#define ID_AA64ISAR0_CRC32_SHIFT 16907#define ID_AA64ISAR0_CRC32_SHIFT 16
908#define ID_AA64ISAR0_CRC32_WIDTH 4
842#define ID_AA64ISAR0_CRC32_MASK (UL(0xf) << ID_AA64ISAR0_CRC32_SHIFT)909#define ID_AA64ISAR0_CRC32_MASK (UL(0xf) << ID_AA64ISAR0_CRC32_SHIFT)
843#define ID_AA64ISAR0_CRC32_VAL(x) ((x) & ID_AA64ISAR0_CRC32_MASK)910#define ID_AA64ISAR0_CRC32_VAL(x) ((x) & ID_AA64ISAR0_CRC32_MASK)
844#define ID_AA64ISAR0_CRC32_NONE (UL(0x0) << ID_AA64ISAR0_CRC32_SHIFT)911#define ID_AA64ISAR0_CRC32_NONE (UL(0x0) << ID_AA64ISAR0_CRC32_SHIFT)
845#define ID_AA64ISAR0_CRC32_BASE (UL(0x1) << ID_AA64ISAR0_CRC32_SHIFT)912#define ID_AA64ISAR0_CRC32_BASE (UL(0x1) << ID_AA64ISAR0_CRC32_SHIFT)
846#define ID_AA64ISAR0_Atomic_SHIFT 20913#define ID_AA64ISAR0_Atomic_SHIFT 20
914#define ID_AA64ISAR0_Atomic_WIDTH 4
847#define ID_AA64ISAR0_Atomic_MASK (UL(0xf) << ID_AA64ISAR0_Atomic_SHIFT)915#define ID_AA64ISAR0_Atomic_MASK (UL(0xf) << ID_AA64ISAR0_Atomic_SHIFT)
848#define ID_AA64ISAR0_Atomic_VAL(x) ((x) & ID_AA64ISAR0_Atomic_MASK)916#define ID_AA64ISAR0_Atomic_VAL(x) ((x) & ID_AA64ISAR0_Atomic_MASK)
849#define ID_AA64ISAR0_Atomic_NONE (UL(0x0) << ID_AA64ISAR0_Atomic_SHIFT)917#define ID_AA64ISAR0_Atomic_NONE (UL(0x0) << ID_AA64ISAR0_Atomic_SHIFT)
850#define ID_AA64ISAR0_Atomic_IMPL (UL(0x2) << ID_AA64ISAR0_Atomic_SHIFT)918#define ID_AA64ISAR0_Atomic_IMPL (UL(0x2) << ID_AA64ISAR0_Atomic_SHIFT)
851#define ID_AA64ISAR0_TME_SHIFT 24919#define ID_AA64ISAR0_TME_SHIFT 24
920#define ID_AA64ISAR0_TME_WIDTH 4
852#define ID_AA64ISAR0_TME_MASK (UL(0xf) << ID_AA64ISAR0_TME_SHIFT)921#define ID_AA64ISAR0_TME_MASK (UL(0xf) << ID_AA64ISAR0_TME_SHIFT)
853#define ID_AA64ISAR0_TME_NONE (UL(0x0) << ID_AA64ISAR0_TME_SHIFT)922#define ID_AA64ISAR0_TME_NONE (UL(0x0) << ID_AA64ISAR0_TME_SHIFT)
854#define ID_AA64ISAR0_TME_IMPL (UL(0x1) << ID_AA64ISAR0_TME_SHIFT)923#define ID_AA64ISAR0_TME_IMPL (UL(0x1) << ID_AA64ISAR0_TME_SHIFT)
855#define ID_AA64ISAR0_RDM_SHIFT 28924#define ID_AA64ISAR0_RDM_SHIFT 28
925#define ID_AA64ISAR0_RDM_WIDTH 4
856#define ID_AA64ISAR0_RDM_MASK (UL(0xf) << ID_AA64ISAR0_RDM_SHIFT)926#define ID_AA64ISAR0_RDM_MASK (UL(0xf) << ID_AA64ISAR0_RDM_SHIFT)
857#define ID_AA64ISAR0_RDM_VAL(x) ((x) & ID_AA64ISAR0_RDM_MASK)927#define ID_AA64ISAR0_RDM_VAL(x) ((x) & ID_AA64ISAR0_RDM_MASK)
858#define ID_AA64ISAR0_RDM_NONE (UL(0x0) << ID_AA64ISAR0_RDM_SHIFT)928#define ID_AA64ISAR0_RDM_NONE (UL(0x0) << ID_AA64ISAR0_RDM_SHIFT)
859#define ID_AA64ISAR0_RDM_IMPL (UL(0x1) << ID_AA64ISAR0_RDM_SHIFT)929#define ID_AA64ISAR0_RDM_IMPL (UL(0x1) << ID_AA64ISAR0_RDM_SHIFT)
860#define ID_AA64ISAR0_SHA3_SHIFT 32930#define ID_AA64ISAR0_SHA3_SHIFT 32
931#define ID_AA64ISAR0_SHA3_WIDTH 4
861#define ID_AA64ISAR0_SHA3_MASK (UL(0xf) << ID_AA64ISAR0_SHA3_SHIFT)932#define ID_AA64ISAR0_SHA3_MASK (UL(0xf) << ID_AA64ISAR0_SHA3_SHIFT)
862#define ID_AA64ISAR0_SHA3_VAL(x) ((x) & ID_AA64ISAR0_SHA3_MASK)933#define ID_AA64ISAR0_SHA3_VAL(x) ((x) & ID_AA64ISAR0_SHA3_MASK)
863#define ID_AA64ISAR0_SHA3_NONE (UL(0x0) << ID_AA64ISAR0_SHA3_SHIFT)934#define ID_AA64ISAR0_SHA3_NONE (UL(0x0) << ID_AA64ISAR0_SHA3_SHIFT)
864#define ID_AA64ISAR0_SHA3_IMPL (UL(0x1) << ID_AA64ISAR0_SHA3_SHIFT)935#define ID_AA64ISAR0_SHA3_IMPL (UL(0x1) << ID_AA64ISAR0_SHA3_SHIFT)
865#define ID_AA64ISAR0_SM3_SHIFT 36936#define ID_AA64ISAR0_SM3_SHIFT 36
937#define ID_AA64ISAR0_SM3_WIDTH 4
866#define ID_AA64ISAR0_SM3_MASK (UL(0xf) << ID_AA64ISAR0_SM3_SHIFT)938#define ID_AA64ISAR0_SM3_MASK (UL(0xf) << ID_AA64ISAR0_SM3_SHIFT)
867#define ID_AA64ISAR0_SM3_VAL(x) ((x) & ID_AA64ISAR0_SM3_MASK)939#define ID_AA64ISAR0_SM3_VAL(x) ((x) & ID_AA64ISAR0_SM3_MASK)
868#define ID_AA64ISAR0_SM3_NONE (UL(0x0) << ID_AA64ISAR0_SM3_SHIFT)940#define ID_AA64ISAR0_SM3_NONE (UL(0x0) << ID_AA64ISAR0_SM3_SHIFT)
869#define ID_AA64ISAR0_SM3_IMPL (UL(0x1) << ID_AA64ISAR0_SM3_SHIFT)941#define ID_AA64ISAR0_SM3_IMPL (UL(0x1) << ID_AA64ISAR0_SM3_SHIFT)
870#define ID_AA64ISAR0_SM4_SHIFT 40942#define ID_AA64ISAR0_SM4_SHIFT 40
943#define ID_AA64ISAR0_SM4_WIDTH 4
871#define ID_AA64ISAR0_SM4_MASK (UL(0xf) << ID_AA64ISAR0_SM4_SHIFT)944#define ID_AA64ISAR0_SM4_MASK (UL(0xf) << ID_AA64ISAR0_SM4_SHIFT)
872#define ID_AA64ISAR0_SM4_VAL(x) ((x) & ID_AA64ISAR0_SM4_MASK)945#define ID_AA64ISAR0_SM4_VAL(x) ((x) & ID_AA64ISAR0_SM4_MASK)
873#define ID_AA64ISAR0_SM4_NONE (UL(0x0) << ID_AA64ISAR0_SM4_SHIFT)946#define ID_AA64ISAR0_SM4_NONE (UL(0x0) << ID_AA64ISAR0_SM4_SHIFT)
874#define ID_AA64ISAR0_SM4_IMPL (UL(0x1) << ID_AA64ISAR0_SM4_SHIFT)947#define ID_AA64ISAR0_SM4_IMPL (UL(0x1) << ID_AA64ISAR0_SM4_SHIFT)
875#define ID_AA64ISAR0_DP_SHIFT 44948#define ID_AA64ISAR0_DP_SHIFT 44
949#define ID_AA64ISAR0_DP_WIDTH 4
876#define ID_AA64ISAR0_DP_MASK (UL(0xf) << ID_AA64ISAR0_DP_SHIFT)950#define ID_AA64ISAR0_DP_MASK (UL(0xf) << ID_AA64ISAR0_DP_SHIFT)
877#define ID_AA64ISAR0_DP_VAL(x) ((x) & ID_AA64ISAR0_DP_MASK)951#define ID_AA64ISAR0_DP_VAL(x) ((x) & ID_AA64ISAR0_DP_MASK)
878#define ID_AA64ISAR0_DP_NONE (UL(0x0) << ID_AA64ISAR0_DP_SHIFT)952#define ID_AA64ISAR0_DP_NONE (UL(0x0) << ID_AA64ISAR0_DP_SHIFT)
879#define ID_AA64ISAR0_DP_IMPL (UL(0x1) << ID_AA64ISAR0_DP_SHIFT)953#define ID_AA64ISAR0_DP_IMPL (UL(0x1) << ID_AA64ISAR0_DP_SHIFT)
880#define ID_AA64ISAR0_FHM_SHIFT 48954#define ID_AA64ISAR0_FHM_SHIFT 48
955#define ID_AA64ISAR0_FHM_WIDTH 4
881#define ID_AA64ISAR0_FHM_MASK (UL(0xf) << ID_AA64ISAR0_FHM_SHIFT)956#define ID_AA64ISAR0_FHM_MASK (UL(0xf) << ID_AA64ISAR0_FHM_SHIFT)
882#define ID_AA64ISAR0_FHM_VAL(x) ((x) & ID_AA64ISAR0_FHM_MASK)957#define ID_AA64ISAR0_FHM_VAL(x) ((x) & ID_AA64ISAR0_FHM_MASK)
883#define ID_AA64ISAR0_FHM_NONE (UL(0x0) << ID_AA64ISAR0_FHM_SHIFT)958#define ID_AA64ISAR0_FHM_NONE (UL(0x0) << ID_AA64ISAR0_FHM_SHIFT)
884#define ID_AA64ISAR0_FHM_IMPL (UL(0x1) << ID_AA64ISAR0_FHM_SHIFT)959#define ID_AA64ISAR0_FHM_IMPL (UL(0x1) << ID_AA64ISAR0_FHM_SHIFT)
885#define ID_AA64ISAR0_TS_SHIFT 52960#define ID_AA64ISAR0_TS_SHIFT 52
961#define ID_AA64ISAR0_TS_WIDTH 4
886#define ID_AA64ISAR0_TS_MASK (UL(0xf) << ID_AA64ISAR0_TS_SHIFT)962#define ID_AA64ISAR0_TS_MASK (UL(0xf) << ID_AA64ISAR0_TS_SHIFT)
887#define ID_AA64ISAR0_TS_VAL(x) ((x) & ID_AA64ISAR0_TS_MASK)963#define ID_AA64ISAR0_TS_VAL(x) ((x) & ID_AA64ISAR0_TS_MASK)
888#define ID_AA64ISAR0_TS_NONE (UL(0x0) << ID_AA64ISAR0_TS_SHIFT)964#define ID_AA64ISAR0_TS_NONE (UL(0x0) << ID_AA64ISAR0_TS_SHIFT)
889#define ID_AA64ISAR0_TS_CondM_8_4 (UL(0x1) << ID_AA64ISAR0_TS_SHIFT)965#define ID_AA64ISAR0_TS_CondM_8_4 (UL(0x1) << ID_AA64ISAR0_TS_SHIFT)
890#define ID_AA64ISAR0_TS_CondM_8_5 (UL(0x2) << ID_AA64ISAR0_TS_SHIFT)966#define ID_AA64ISAR0_TS_CondM_8_5 (UL(0x2) << ID_AA64ISAR0_TS_SHIFT)
891#define ID_AA64ISAR0_TLB_SHIFT 56967#define ID_AA64ISAR0_TLB_SHIFT 56
968#define ID_AA64ISAR0_TLB_WIDTH 4
892#define ID_AA64ISAR0_TLB_MASK (UL(0xf) << ID_AA64ISAR0_TLB_SHIFT)969#define ID_AA64ISAR0_TLB_MASK (UL(0xf) << ID_AA64ISAR0_TLB_SHIFT)
893#define ID_AA64ISAR0_TLB_VAL(x) ((x) & ID_AA64ISAR0_TLB_MASK)970#define ID_AA64ISAR0_TLB_VAL(x) ((x) & ID_AA64ISAR0_TLB_MASK)
894#define ID_AA64ISAR0_TLB_NONE (UL(0x0) << ID_AA64ISAR0_TLB_SHIFT)971#define ID_AA64ISAR0_TLB_NONE (UL(0x0) << ID_AA64ISAR0_TLB_SHIFT)
895#define ID_AA64ISAR0_TLB_TLBIOS (UL(0x1) << ID_AA64ISAR0_TLB_SHIFT)972#define ID_AA64ISAR0_TLB_TLBIOS (UL(0x1) << ID_AA64ISAR0_TLB_SHIFT)
896#define ID_AA64ISAR0_TLB_TLBIOSR (UL(0x2) << ID_AA64ISAR0_TLB_SHIFT)973#define ID_AA64ISAR0_TLB_TLBIOSR (UL(0x2) << ID_AA64ISAR0_TLB_SHIFT)
897#define ID_AA64ISAR0_RNDR_SHIFT 60974#define ID_AA64ISAR0_RNDR_SHIFT 60
975#define ID_AA64ISAR0_RNDR_WIDTH 4
898#define ID_AA64ISAR0_RNDR_MASK (UL(0xf) << ID_AA64ISAR0_RNDR_SHIFT)976#define ID_AA64ISAR0_RNDR_MASK (UL(0xf) << ID_AA64ISAR0_RNDR_SHIFT)
899#define ID_AA64ISAR0_RNDR_VAL(x) ((x) & ID_AA64ISAR0_RNDR_MASK)977#define ID_AA64ISAR0_RNDR_VAL(x) ((x) & ID_AA64ISAR0_RNDR_MASK)
900#define ID_AA64ISAR0_RNDR_NONE (UL(0x0) << ID_AA64ISAR0_RNDR_SHIFT)978#define ID_AA64ISAR0_RNDR_NONE (UL(0x0) << ID_AA64ISAR0_RNDR_SHIFT)
901#define ID_AA64ISAR0_RNDR_IMPL (UL(0x1) << ID_AA64ISAR0_RNDR_SHIFT)979#define ID_AA64ISAR0_RNDR_IMPL (UL(0x1) << ID_AA64ISAR0_RNDR_SHIFT)
902980
903/* ID_AA64ISAR1_EL1 */981/* ID_AA64ISAR1_EL1 */
904#define ID_AA64ISAR1_EL1 MRS_REG(ID_AA64ISAR1_EL1)
905#define ID_AA64ISAR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR1_EL1)982#define ID_AA64ISAR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR1_EL1)
983#define ID_AA64ISAR1_EL1_ISS ISS_MSR_REG(ID_AA64ISAR1_EL1)
906#define ID_AA64ISAR1_EL1_op0 3984#define ID_AA64ISAR1_EL1_op0 3
907#define ID_AA64ISAR1_EL1_op1 0985#define ID_AA64ISAR1_EL1_op1 0
908#define ID_AA64ISAR1_EL1_CRn 0986#define ID_AA64ISAR1_EL1_CRn 0
909#define ID_AA64ISAR1_EL1_CRm 6987#define ID_AA64ISAR1_EL1_CRm 6
910#define ID_AA64ISAR1_EL1_op2 1988#define ID_AA64ISAR1_EL1_op2 1
911#define ID_AA64ISAR1_DPB_SHIFT 0989#define ID_AA64ISAR1_DPB_SHIFT 0
990#define ID_AA64ISAR1_DPB_WIDTH 4
912#define ID_AA64ISAR1_DPB_MASK (UL(0xf) << ID_AA64ISAR1_DPB_SHIFT)991#define ID_AA64ISAR1_DPB_MASK (UL(0xf) << ID_AA64ISAR1_DPB_SHIFT)
913#define ID_AA64ISAR1_DPB_VAL(x) ((x) & ID_AA64ISAR1_DPB_MASK)992#define ID_AA64ISAR1_DPB_VAL(x) ((x) & ID_AA64ISAR1_DPB_MASK)
914#define ID_AA64ISAR1_DPB_NONE (UL(0x0) << ID_AA64ISAR1_DPB_SHIFT)993#define ID_AA64ISAR1_DPB_NONE (UL(0x0) << ID_AA64ISAR1_DPB_SHIFT)
915#define ID_AA64ISAR1_DPB_DCCVAP (UL(0x1) << ID_AA64ISAR1_DPB_SHIFT)994#define ID_AA64ISAR1_DPB_DCCVAP (UL(0x1) << ID_AA64ISAR1_DPB_SHIFT)
916#define ID_AA64ISAR1_DPB_DCCVADP (UL(0x2) << ID_AA64ISAR1_DPB_SHIFT)995#define ID_AA64ISAR1_DPB_DCCVADP (UL(0x2) << ID_AA64ISAR1_DPB_SHIFT)
917#define ID_AA64ISAR1_APA_SHIFT 4996#define ID_AA64ISAR1_APA_SHIFT 4
997#define ID_AA64ISAR1_APA_WIDTH 4
918#define ID_AA64ISAR1_APA_MASK (UL(0xf) << ID_AA64ISAR1_APA_SHIFT)998#define ID_AA64ISAR1_APA_MASK (UL(0xf) << ID_AA64ISAR1_APA_SHIFT)
919#define ID_AA64ISAR1_APA_VAL(x) ((x) & ID_AA64ISAR1_APA_MASK)999#define ID_AA64ISAR1_APA_VAL(x) ((x) & ID_AA64ISAR1_APA_MASK)
920#define ID_AA64ISAR1_APA_NONE (UL(0x0) << ID_AA64ISAR1_APA_SHIFT)1000#define ID_AA64ISAR1_APA_NONE (UL(0x0) << ID_AA64ISAR1_APA_SHIFT)
...@@ -924,6 +1004,7 @@...@@ -924,6 +1004,7 @@
924#define ID_AA64ISAR1_APA_FPAC (UL(0x4) << ID_AA64ISAR1_APA_SHIFT)1004#define ID_AA64ISAR1_APA_FPAC (UL(0x4) << ID_AA64ISAR1_APA_SHIFT)
925#define ID_AA64ISAR1_APA_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_APA_SHIFT)1005#define ID_AA64ISAR1_APA_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_APA_SHIFT)
926#define ID_AA64ISAR1_API_SHIFT 81006#define ID_AA64ISAR1_API_SHIFT 8
1007#define ID_AA64ISAR1_API_WIDTH 4
927#define ID_AA64ISAR1_API_MASK (UL(0xf) << ID_AA64ISAR1_API_SHIFT)1008#define ID_AA64ISAR1_API_MASK (UL(0xf) << ID_AA64ISAR1_API_SHIFT)
928#define ID_AA64ISAR1_API_VAL(x) ((x) & ID_AA64ISAR1_API_MASK)1009#define ID_AA64ISAR1_API_VAL(x) ((x) & ID_AA64ISAR1_API_MASK)
929#define ID_AA64ISAR1_API_NONE (UL(0x0) << ID_AA64ISAR1_API_SHIFT)1010#define ID_AA64ISAR1_API_NONE (UL(0x0) << ID_AA64ISAR1_API_SHIFT)
...@@ -933,68 +1014,82 @@...@@ -933,68 +1014,82 @@
933#define ID_AA64ISAR1_API_FPAC (UL(0x4) << ID_AA64ISAR1_API_SHIFT)1014#define ID_AA64ISAR1_API_FPAC (UL(0x4) << ID_AA64ISAR1_API_SHIFT)
934#define ID_AA64ISAR1_API_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_API_SHIFT)1015#define ID_AA64ISAR1_API_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_API_SHIFT)
935#define ID_AA64ISAR1_JSCVT_SHIFT 121016#define ID_AA64ISAR1_JSCVT_SHIFT 12
1017#define ID_AA64ISAR1_JSCVT_WIDTH 4
936#define ID_AA64ISAR1_JSCVT_MASK (UL(0xf) << ID_AA64ISAR1_JSCVT_SHIFT)1018#define ID_AA64ISAR1_JSCVT_MASK (UL(0xf) << ID_AA64ISAR1_JSCVT_SHIFT)
937#define ID_AA64ISAR1_JSCVT_VAL(x) ((x) & ID_AA64ISAR1_JSCVT_MASK)1019#define ID_AA64ISAR1_JSCVT_VAL(x) ((x) & ID_AA64ISAR1_JSCVT_MASK)
938#define ID_AA64ISAR1_JSCVT_NONE (UL(0x0) << ID_AA64ISAR1_JSCVT_SHIFT)1020#define ID_AA64ISAR1_JSCVT_NONE (UL(0x0) << ID_AA64ISAR1_JSCVT_SHIFT)
939#define ID_AA64ISAR1_JSCVT_IMPL (UL(0x1) << ID_AA64ISAR1_JSCVT_SHIFT)1021#define ID_AA64ISAR1_JSCVT_IMPL (UL(0x1) << ID_AA64ISAR1_JSCVT_SHIFT)
940#define ID_AA64ISAR1_FCMA_SHIFT 161022#define ID_AA64ISAR1_FCMA_SHIFT 16
1023#define ID_AA64ISAR1_FCMA_WIDTH 4
941#define ID_AA64ISAR1_FCMA_MASK (UL(0xf) << ID_AA64ISAR1_FCMA_SHIFT)1024#define ID_AA64ISAR1_FCMA_MASK (UL(0xf) << ID_AA64ISAR1_FCMA_SHIFT)
942#define ID_AA64ISAR1_FCMA_VAL(x) ((x) & ID_AA64ISAR1_FCMA_MASK)1025#define ID_AA64ISAR1_FCMA_VAL(x) ((x) & ID_AA64ISAR1_FCMA_MASK)
943#define ID_AA64ISAR1_FCMA_NONE (UL(0x0) << ID_AA64ISAR1_FCMA_SHIFT)1026#define ID_AA64ISAR1_FCMA_NONE (UL(0x0) << ID_AA64ISAR1_FCMA_SHIFT)
944#define ID_AA64ISAR1_FCMA_IMPL (UL(0x1) << ID_AA64ISAR1_FCMA_SHIFT)1027#define ID_AA64ISAR1_FCMA_IMPL (UL(0x1) << ID_AA64ISAR1_FCMA_SHIFT)
945#define ID_AA64ISAR1_LRCPC_SHIFT 201028#define ID_AA64ISAR1_LRCPC_SHIFT 20
1029#define ID_AA64ISAR1_LRCPC_WIDTH 4
946#define ID_AA64ISAR1_LRCPC_MASK (UL(0xf) << ID_AA64ISAR1_LRCPC_SHIFT)1030#define ID_AA64ISAR1_LRCPC_MASK (UL(0xf) << ID_AA64ISAR1_LRCPC_SHIFT)
947#define ID_AA64ISAR1_LRCPC_VAL(x) ((x) & ID_AA64ISAR1_LRCPC_MASK)1031#define ID_AA64ISAR1_LRCPC_VAL(x) ((x) & ID_AA64ISAR1_LRCPC_MASK)
948#define ID_AA64ISAR1_LRCPC_NONE (UL(0x0) << ID_AA64ISAR1_LRCPC_SHIFT)1032#define ID_AA64ISAR1_LRCPC_NONE (UL(0x0) << ID_AA64ISAR1_LRCPC_SHIFT)
949#define ID_AA64ISAR1_LRCPC_RCPC_8_3 (UL(0x1) << ID_AA64ISAR1_LRCPC_SHIFT)1033#define ID_AA64ISAR1_LRCPC_RCPC_8_3 (UL(0x1) << ID_AA64ISAR1_LRCPC_SHIFT)
950#define ID_AA64ISAR1_LRCPC_RCPC_8_4 (UL(0x2) << ID_AA64ISAR1_LRCPC_SHIFT)1034#define ID_AA64ISAR1_LRCPC_RCPC_8_4 (UL(0x2) << ID_AA64ISAR1_LRCPC_SHIFT)
951#define ID_AA64ISAR1_GPA_SHIFT 241035#define ID_AA64ISAR1_GPA_SHIFT 24
1036#define ID_AA64ISAR1_GPA_WIDTH 4
952#define ID_AA64ISAR1_GPA_MASK (UL(0xf) << ID_AA64ISAR1_GPA_SHIFT)1037#define ID_AA64ISAR1_GPA_MASK (UL(0xf) << ID_AA64ISAR1_GPA_SHIFT)
953#define ID_AA64ISAR1_GPA_VAL(x) ((x) & ID_AA64ISAR1_GPA_MASK)1038#define ID_AA64ISAR1_GPA_VAL(x) ((x) & ID_AA64ISAR1_GPA_MASK)
954#define ID_AA64ISAR1_GPA_NONE (UL(0x0) << ID_AA64ISAR1_GPA_SHIFT)1039#define ID_AA64ISAR1_GPA_NONE (UL(0x0) << ID_AA64ISAR1_GPA_SHIFT)
955#define ID_AA64ISAR1_GPA_IMPL (UL(0x1) << ID_AA64ISAR1_GPA_SHIFT)1040#define ID_AA64ISAR1_GPA_IMPL (UL(0x1) << ID_AA64ISAR1_GPA_SHIFT)
956#define ID_AA64ISAR1_GPI_SHIFT 281041#define ID_AA64ISAR1_GPI_SHIFT 28
1042#define ID_AA64ISAR1_GPI_WIDTH 4
957#define ID_AA64ISAR1_GPI_MASK (UL(0xf) << ID_AA64ISAR1_GPI_SHIFT)1043#define ID_AA64ISAR1_GPI_MASK (UL(0xf) << ID_AA64ISAR1_GPI_SHIFT)
958#define ID_AA64ISAR1_GPI_VAL(x) ((x) & ID_AA64ISAR1_GPI_MASK)1044#define ID_AA64ISAR1_GPI_VAL(x) ((x) & ID_AA64ISAR1_GPI_MASK)
959#define ID_AA64ISAR1_GPI_NONE (UL(0x0) << ID_AA64ISAR1_GPI_SHIFT)1045#define ID_AA64ISAR1_GPI_NONE (UL(0x0) << ID_AA64ISAR1_GPI_SHIFT)
960#define ID_AA64ISAR1_GPI_IMPL (UL(0x1) << ID_AA64ISAR1_GPI_SHIFT)1046#define ID_AA64ISAR1_GPI_IMPL (UL(0x1) << ID_AA64ISAR1_GPI_SHIFT)
961#define ID_AA64ISAR1_FRINTTS_SHIFT 321047#define ID_AA64ISAR1_FRINTTS_SHIFT 32
1048#define ID_AA64ISAR1_FRINTTS_WIDTH 4
962#define ID_AA64ISAR1_FRINTTS_MASK (UL(0xf) << ID_AA64ISAR1_FRINTTS_SHIFT)1049#define ID_AA64ISAR1_FRINTTS_MASK (UL(0xf) << ID_AA64ISAR1_FRINTTS_SHIFT)
963#define ID_AA64ISAR1_FRINTTS_VAL(x) ((x) & ID_AA64ISAR1_FRINTTS_MASK)1050#define ID_AA64ISAR1_FRINTTS_VAL(x) ((x) & ID_AA64ISAR1_FRINTTS_MASK)
964#define ID_AA64ISAR1_FRINTTS_NONE (UL(0x0) << ID_AA64ISAR1_FRINTTS_SHIFT)1051#define ID_AA64ISAR1_FRINTTS_NONE (UL(0x0) << ID_AA64ISAR1_FRINTTS_SHIFT)
965#define ID_AA64ISAR1_FRINTTS_IMPL (UL(0x1) << ID_AA64ISAR1_FRINTTS_SHIFT)1052#define ID_AA64ISAR1_FRINTTS_IMPL (UL(0x1) << ID_AA64ISAR1_FRINTTS_SHIFT)
966#define ID_AA64ISAR1_SB_SHIFT 361053#define ID_AA64ISAR1_SB_SHIFT 36
1054#define ID_AA64ISAR1_SB_WIDTH 4
967#define ID_AA64ISAR1_SB_MASK (UL(0xf) << ID_AA64ISAR1_SB_SHIFT)1055#define ID_AA64ISAR1_SB_MASK (UL(0xf) << ID_AA64ISAR1_SB_SHIFT)
968#define ID_AA64ISAR1_SB_VAL(x) ((x) & ID_AA64ISAR1_SB_MASK)1056#define ID_AA64ISAR1_SB_VAL(x) ((x) & ID_AA64ISAR1_SB_MASK)
969#define ID_AA64ISAR1_SB_NONE (UL(0x0) << ID_AA64ISAR1_SB_SHIFT)1057#define ID_AA64ISAR1_SB_NONE (UL(0x0) << ID_AA64ISAR1_SB_SHIFT)
970#define ID_AA64ISAR1_SB_IMPL (UL(0x1) << ID_AA64ISAR1_SB_SHIFT)1058#define ID_AA64ISAR1_SB_IMPL (UL(0x1) << ID_AA64ISAR1_SB_SHIFT)
971#define ID_AA64ISAR1_SPECRES_SHIFT 401059#define ID_AA64ISAR1_SPECRES_SHIFT 40
1060#define ID_AA64ISAR1_SPECRES_WIDTH 4
972#define ID_AA64ISAR1_SPECRES_MASK (UL(0xf) << ID_AA64ISAR1_SPECRES_SHIFT)1061#define ID_AA64ISAR1_SPECRES_MASK (UL(0xf) << ID_AA64ISAR1_SPECRES_SHIFT)
973#define ID_AA64ISAR1_SPECRES_VAL(x) ((x) & ID_AA64ISAR1_SPECRES_MASK)1062#define ID_AA64ISAR1_SPECRES_VAL(x) ((x) & ID_AA64ISAR1_SPECRES_MASK)
974#define ID_AA64ISAR1_SPECRES_NONE (UL(0x0) << ID_AA64ISAR1_SPECRES_SHIFT)1063#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)
976#define ID_AA64ISAR1_BF16_SHIFT 441066#define ID_AA64ISAR1_BF16_SHIFT 44
1067#define ID_AA64ISAR1_BF16_WIDTH 4
977#define ID_AA64ISAR1_BF16_MASK (UL(0xf) << ID_AA64ISAR1_BF16_SHIFT)1068#define ID_AA64ISAR1_BF16_MASK (UL(0xf) << ID_AA64ISAR1_BF16_SHIFT)
978#define ID_AA64ISAR1_BF16_VAL(x) ((x) & ID_AA64ISAR1_BF16_MASK)1069#define ID_AA64ISAR1_BF16_VAL(x) ((x) & ID_AA64ISAR1_BF16_MASK)
979#define ID_AA64ISAR1_BF16_NONE (UL(0x0) << ID_AA64ISAR1_BF16_SHIFT)1070#define ID_AA64ISAR1_BF16_NONE (UL(0x0) << ID_AA64ISAR1_BF16_SHIFT)
980#define ID_AA64ISAR1_BF16_IMPL (UL(0x1) << ID_AA64ISAR1_BF16_SHIFT)1071#define ID_AA64ISAR1_BF16_IMPL (UL(0x1) << ID_AA64ISAR1_BF16_SHIFT)
981#define ID_AA64ISAR1_BF16_EBF (UL(0x2) << ID_AA64ISAR1_BF16_SHIFT)1072#define ID_AA64ISAR1_BF16_EBF (UL(0x2) << ID_AA64ISAR1_BF16_SHIFT)
982#define ID_AA64ISAR1_DGH_SHIFT 481073#define ID_AA64ISAR1_DGH_SHIFT 48
1074#define ID_AA64ISAR1_DGH_WIDTH 4
983#define ID_AA64ISAR1_DGH_MASK (UL(0xf) << ID_AA64ISAR1_DGH_SHIFT)1075#define ID_AA64ISAR1_DGH_MASK (UL(0xf) << ID_AA64ISAR1_DGH_SHIFT)
984#define ID_AA64ISAR1_DGH_VAL(x) ((x) & ID_AA64ISAR1_DGH_MASK)1076#define ID_AA64ISAR1_DGH_VAL(x) ((x) & ID_AA64ISAR1_DGH_MASK)
985#define ID_AA64ISAR1_DGH_NONE (UL(0x0) << ID_AA64ISAR1_DGH_SHIFT)1077#define ID_AA64ISAR1_DGH_NONE (UL(0x0) << ID_AA64ISAR1_DGH_SHIFT)
986#define ID_AA64ISAR1_DGH_IMPL (UL(0x1) << ID_AA64ISAR1_DGH_SHIFT)1078#define ID_AA64ISAR1_DGH_IMPL (UL(0x1) << ID_AA64ISAR1_DGH_SHIFT)
987#define ID_AA64ISAR1_I8MM_SHIFT 521079#define ID_AA64ISAR1_I8MM_SHIFT 52
1080#define ID_AA64ISAR1_I8MM_WIDTH 4
988#define ID_AA64ISAR1_I8MM_MASK (UL(0xf) << ID_AA64ISAR1_I8MM_SHIFT)1081#define ID_AA64ISAR1_I8MM_MASK (UL(0xf) << ID_AA64ISAR1_I8MM_SHIFT)
989#define ID_AA64ISAR1_I8MM_VAL(x) ((x) & ID_AA64ISAR1_I8MM_MASK)1082#define ID_AA64ISAR1_I8MM_VAL(x) ((x) & ID_AA64ISAR1_I8MM_MASK)
990#define ID_AA64ISAR1_I8MM_NONE (UL(0x0) << ID_AA64ISAR1_I8MM_SHIFT)1083#define ID_AA64ISAR1_I8MM_NONE (UL(0x0) << ID_AA64ISAR1_I8MM_SHIFT)
991#define ID_AA64ISAR1_I8MM_IMPL (UL(0x1) << ID_AA64ISAR1_I8MM_SHIFT)1084#define ID_AA64ISAR1_I8MM_IMPL (UL(0x1) << ID_AA64ISAR1_I8MM_SHIFT)
992#define ID_AA64ISAR1_XS_SHIFT 561085#define ID_AA64ISAR1_XS_SHIFT 56
1086#define ID_AA64ISAR1_XS_WIDTH 4
993#define ID_AA64ISAR1_XS_MASK (UL(0xf) << ID_AA64ISAR1_XS_SHIFT)1087#define ID_AA64ISAR1_XS_MASK (UL(0xf) << ID_AA64ISAR1_XS_SHIFT)
994#define ID_AA64ISAR1_XS_VAL(x) ((x) & ID_AA64ISAR1_XS_MASK)1088#define ID_AA64ISAR1_XS_VAL(x) ((x) & ID_AA64ISAR1_XS_MASK)
995#define ID_AA64ISAR1_XS_NONE (UL(0x0) << ID_AA64ISAR1_XS_SHIFT)1089#define ID_AA64ISAR1_XS_NONE (UL(0x0) << ID_AA64ISAR1_XS_SHIFT)
996#define ID_AA64ISAR1_XS_IMPL (UL(0x1) << ID_AA64ISAR1_XS_SHIFT)1090#define ID_AA64ISAR1_XS_IMPL (UL(0x1) << ID_AA64ISAR1_XS_SHIFT)
997#define ID_AA64ISAR1_LS64_SHIFT 601091#define ID_AA64ISAR1_LS64_SHIFT 60
1092#define ID_AA64ISAR1_LS64_WIDTH 4
998#define ID_AA64ISAR1_LS64_MASK (UL(0xf) << ID_AA64ISAR1_LS64_SHIFT)1093#define ID_AA64ISAR1_LS64_MASK (UL(0xf) << ID_AA64ISAR1_LS64_SHIFT)
999#define ID_AA64ISAR1_LS64_VAL(x) ((x) & ID_AA64ISAR1_LS64_MASK)1094#define ID_AA64ISAR1_LS64_VAL(x) ((x) & ID_AA64ISAR1_LS64_MASK)
1000#define ID_AA64ISAR1_LS64_NONE (UL(0x0) << ID_AA64ISAR1_LS64_SHIFT)1095#define ID_AA64ISAR1_LS64_NONE (UL(0x0) << ID_AA64ISAR1_LS64_SHIFT)
...@@ -1003,29 +1098,33 @@...@@ -1003,29 +1098,33 @@
1003#define ID_AA64ISAR1_LS64_ACCDATA (UL(0x3) << ID_AA64ISAR1_LS64_SHIFT)1098#define ID_AA64ISAR1_LS64_ACCDATA (UL(0x3) << ID_AA64ISAR1_LS64_SHIFT)
10041099
1005/* ID_AA64ISAR2_EL1 */1100/* ID_AA64ISAR2_EL1 */
1006#define ID_AA64ISAR2_EL1 MRS_REG(ID_AA64ISAR2_EL1)
1007#define ID_AA64ISAR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR2_EL1)1101#define ID_AA64ISAR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR2_EL1)
1102#define ID_AA64ISAR2_EL1_ISS ISS_MSR_REG(ID_AA64ISAR2_EL1)
1008#define ID_AA64ISAR2_EL1_op0 31103#define ID_AA64ISAR2_EL1_op0 3
1009#define ID_AA64ISAR2_EL1_op1 01104#define ID_AA64ISAR2_EL1_op1 0
1010#define ID_AA64ISAR2_EL1_CRn 01105#define ID_AA64ISAR2_EL1_CRn 0
1011#define ID_AA64ISAR2_EL1_CRm 61106#define ID_AA64ISAR2_EL1_CRm 6
1012#define ID_AA64ISAR2_EL1_op2 21107#define ID_AA64ISAR2_EL1_op2 2
1013#define ID_AA64ISAR2_WFxT_SHIFT 01108#define ID_AA64ISAR2_WFxT_SHIFT 0
1109#define ID_AA64ISAR2_WFxT_WIDTH 4
1014#define ID_AA64ISAR2_WFxT_MASK (UL(0xf) << ID_AA64ISAR2_WFxT_SHIFT)1110#define ID_AA64ISAR2_WFxT_MASK (UL(0xf) << ID_AA64ISAR2_WFxT_SHIFT)
1015#define ID_AA64ISAR2_WFxT_VAL(x) ((x) & ID_AA64ISAR2_WFxT_MASK)1111#define ID_AA64ISAR2_WFxT_VAL(x) ((x) & ID_AA64ISAR2_WFxT_MASK)
1016#define ID_AA64ISAR2_WFxT_NONE (UL(0x0) << ID_AA64ISAR2_WFxT_SHIFT)1112#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)
1018#define ID_AA64ISAR2_RPRES_SHIFT 41114#define ID_AA64ISAR2_RPRES_SHIFT 4
1115#define ID_AA64ISAR2_RPRES_WIDTH 4
1019#define ID_AA64ISAR2_RPRES_MASK (UL(0xf) << ID_AA64ISAR2_RPRES_SHIFT)1116#define ID_AA64ISAR2_RPRES_MASK (UL(0xf) << ID_AA64ISAR2_RPRES_SHIFT)
1020#define ID_AA64ISAR2_RPRES_VAL(x) ((x) & ID_AA64ISAR2_RPRES_MASK)1117#define ID_AA64ISAR2_RPRES_VAL(x) ((x) & ID_AA64ISAR2_RPRES_MASK)
1021#define ID_AA64ISAR2_RPRES_NONE (UL(0x0) << ID_AA64ISAR2_RPRES_SHIFT)1118#define ID_AA64ISAR2_RPRES_NONE (UL(0x0) << ID_AA64ISAR2_RPRES_SHIFT)
1022#define ID_AA64ISAR2_RPRES_IMPL (UL(0x1) << ID_AA64ISAR2_RPRES_SHIFT)1119#define ID_AA64ISAR2_RPRES_IMPL (UL(0x1) << ID_AA64ISAR2_RPRES_SHIFT)
1023#define ID_AA64ISAR2_GPA3_SHIFT 81120#define ID_AA64ISAR2_GPA3_SHIFT 8
1121#define ID_AA64ISAR2_GPA3_WIDTH 4
1024#define ID_AA64ISAR2_GPA3_MASK (UL(0xf) << ID_AA64ISAR2_GPA3_SHIFT)1122#define ID_AA64ISAR2_GPA3_MASK (UL(0xf) << ID_AA64ISAR2_GPA3_SHIFT)
1025#define ID_AA64ISAR2_GPA3_VAL(x) ((x) & ID_AA64ISAR2_GPA3_MASK)1123#define ID_AA64ISAR2_GPA3_VAL(x) ((x) & ID_AA64ISAR2_GPA3_MASK)
1026#define ID_AA64ISAR2_GPA3_NONE (UL(0x0) << ID_AA64ISAR2_GPA3_SHIFT)1124#define ID_AA64ISAR2_GPA3_NONE (UL(0x0) << ID_AA64ISAR2_GPA3_SHIFT)
1027#define ID_AA64ISAR2_GPA3_IMPL (UL(0x1) << ID_AA64ISAR2_GPA3_SHIFT)1125#define ID_AA64ISAR2_GPA3_IMPL (UL(0x1) << ID_AA64ISAR2_GPA3_SHIFT)
1028#define ID_AA64ISAR2_APA3_SHIFT 121126#define ID_AA64ISAR2_APA3_SHIFT 12
1127#define ID_AA64ISAR2_APA3_WIDTH 4
1029#define ID_AA64ISAR2_APA3_MASK (UL(0xf) << ID_AA64ISAR2_APA3_SHIFT)1128#define ID_AA64ISAR2_APA3_MASK (UL(0xf) << ID_AA64ISAR2_APA3_SHIFT)
1030#define ID_AA64ISAR2_APA3_VAL(x) ((x) & ID_AA64ISAR2_APA3_MASK)1129#define ID_AA64ISAR2_APA3_VAL(x) ((x) & ID_AA64ISAR2_APA3_MASK)
1031#define ID_AA64ISAR2_APA3_NONE (UL(0x0) << ID_AA64ISAR2_APA3_SHIFT)1130#define ID_AA64ISAR2_APA3_NONE (UL(0x0) << ID_AA64ISAR2_APA3_SHIFT)
...@@ -1035,30 +1134,64 @@...@@ -1035,30 +1134,64 @@
1035#define ID_AA64ISAR2_APA3_FPAC (UL(0x4) << ID_AA64ISAR2_APA3_SHIFT)1134#define ID_AA64ISAR2_APA3_FPAC (UL(0x4) << ID_AA64ISAR2_APA3_SHIFT)
1036#define ID_AA64ISAR2_APA3_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR2_APA3_SHIFT)1135#define ID_AA64ISAR2_APA3_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR2_APA3_SHIFT)
1037#define ID_AA64ISAR2_MOPS_SHIFT 161136#define ID_AA64ISAR2_MOPS_SHIFT 16
1137#define ID_AA64ISAR2_MOPS_WIDTH 4
1038#define ID_AA64ISAR2_MOPS_MASK (UL(0xf) << ID_AA64ISAR2_MOPS_SHIFT)1138#define ID_AA64ISAR2_MOPS_MASK (UL(0xf) << ID_AA64ISAR2_MOPS_SHIFT)
1039#define ID_AA64ISAR2_MOPS_VAL(x) ((x) & ID_AA64ISAR2_MOPS_MASK)1139#define ID_AA64ISAR2_MOPS_VAL(x) ((x) & ID_AA64ISAR2_MOPS_MASK)
1040#define ID_AA64ISAR2_MOPS_NONE (UL(0x0) << ID_AA64ISAR2_MOPS_SHIFT)1140#define ID_AA64ISAR2_MOPS_NONE (UL(0x0) << ID_AA64ISAR2_MOPS_SHIFT)
1041#define ID_AA64ISAR2_MOPS_IMPL (UL(0x1) << ID_AA64ISAR2_MOPS_SHIFT)1141#define ID_AA64ISAR2_MOPS_IMPL (UL(0x1) << ID_AA64ISAR2_MOPS_SHIFT)
1042#define ID_AA64ISAR2_BC_SHIFT 201142#define ID_AA64ISAR2_BC_SHIFT 20
1143#define ID_AA64ISAR2_BC_WIDTH 4
1043#define ID_AA64ISAR2_BC_MASK (UL(0xf) << ID_AA64ISAR2_BC_SHIFT)1144#define ID_AA64ISAR2_BC_MASK (UL(0xf) << ID_AA64ISAR2_BC_SHIFT)
1044#define ID_AA64ISAR2_BC_VAL(x) ((x) & ID_AA64ISAR2_BC_MASK)1145#define ID_AA64ISAR2_BC_VAL(x) ((x) & ID_AA64ISAR2_BC_MASK)
1045#define ID_AA64ISAR2_BC_NONE (UL(0x0) << ID_AA64ISAR2_BC_SHIFT)1146#define ID_AA64ISAR2_BC_NONE (UL(0x0) << ID_AA64ISAR2_BC_SHIFT)
1046#define ID_AA64ISAR2_BC_IMPL (UL(0x1) << ID_AA64ISAR2_BC_SHIFT)1147#define ID_AA64ISAR2_BC_IMPL (UL(0x1) << ID_AA64ISAR2_BC_SHIFT)
1047#define ID_AA64ISAR2_PAC_frac_SHIFT 281148#define ID_AA64ISAR2_PAC_frac_SHIFT 24
1149#define ID_AA64ISAR2_PAC_frac_WIDTH 4
1048#define ID_AA64ISAR2_PAC_frac_MASK (UL(0xf) << ID_AA64ISAR2_PAC_frac_SHIFT)1150#define ID_AA64ISAR2_PAC_frac_MASK (UL(0xf) << ID_AA64ISAR2_PAC_frac_SHIFT)
1049#define ID_AA64ISAR2_PAC_frac_VAL(x) ((x) & ID_AA64ISAR2_PAC_frac_MASK)1151#define ID_AA64ISAR2_PAC_frac_VAL(x) ((x) & ID_AA64ISAR2_PAC_frac_MASK)
1050#define ID_AA64ISAR2_PAC_frac_NONE (UL(0x0) << ID_AA64ISAR2_PAC_frac_SHIFT)1152#define ID_AA64ISAR2_PAC_frac_NONE (UL(0x0) << ID_AA64ISAR2_PAC_frac_SHIFT)
1051#define ID_AA64ISAR2_PAC_frac_IMPL (UL(0x1) << ID_AA64ISAR2_PAC_frac_SHIFT)1153#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
1053/* ID_AA64MMFR0_EL1 */1185/* ID_AA64MMFR0_EL1 */
1054#define ID_AA64MMFR0_EL1 MRS_REG(ID_AA64MMFR0_EL1)
1055#define ID_AA64MMFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR0_EL1)1186#define ID_AA64MMFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR0_EL1)
1187#define ID_AA64MMFR0_EL1_ISS ISS_MSR_REG(ID_AA64MMFR0_EL1)
1056#define ID_AA64MMFR0_EL1_op0 31188#define ID_AA64MMFR0_EL1_op0 3
1057#define ID_AA64MMFR0_EL1_op1 01189#define ID_AA64MMFR0_EL1_op1 0
1058#define ID_AA64MMFR0_EL1_CRn 01190#define ID_AA64MMFR0_EL1_CRn 0
1059#define ID_AA64MMFR0_EL1_CRm 71191#define ID_AA64MMFR0_EL1_CRm 7
1060#define ID_AA64MMFR0_EL1_op2 01192#define ID_AA64MMFR0_EL1_op2 0
1061#define ID_AA64MMFR0_PARange_SHIFT 01193#define ID_AA64MMFR0_PARange_SHIFT 0
1194#define ID_AA64MMFR0_PARange_WIDTH 4
1062#define ID_AA64MMFR0_PARange_MASK (UL(0xf) << ID_AA64MMFR0_PARange_SHIFT)1195#define ID_AA64MMFR0_PARange_MASK (UL(0xf) << ID_AA64MMFR0_PARange_SHIFT)
1063#define ID_AA64MMFR0_PARange_VAL(x) ((x) & ID_AA64MMFR0_PARange_MASK)1196#define ID_AA64MMFR0_PARange_VAL(x) ((x) & ID_AA64MMFR0_PARange_MASK)
1064#define ID_AA64MMFR0_PARange_4G (UL(0x0) << ID_AA64MMFR0_PARange_SHIFT)1197#define ID_AA64MMFR0_PARange_4G (UL(0x0) << ID_AA64MMFR0_PARange_SHIFT)
...@@ -1069,43 +1202,51 @@...@@ -1069,43 +1202,51 @@
1069#define ID_AA64MMFR0_PARange_256T (UL(0x5) << ID_AA64MMFR0_PARange_SHIFT)1202#define ID_AA64MMFR0_PARange_256T (UL(0x5) << ID_AA64MMFR0_PARange_SHIFT)
1070#define ID_AA64MMFR0_PARange_4P (UL(0x6) << ID_AA64MMFR0_PARange_SHIFT)1203#define ID_AA64MMFR0_PARange_4P (UL(0x6) << ID_AA64MMFR0_PARange_SHIFT)
1071#define ID_AA64MMFR0_ASIDBits_SHIFT 41204#define ID_AA64MMFR0_ASIDBits_SHIFT 4
1205#define ID_AA64MMFR0_ASIDBits_WIDTH 4
1072#define ID_AA64MMFR0_ASIDBits_MASK (UL(0xf) << ID_AA64MMFR0_ASIDBits_SHIFT)1206#define ID_AA64MMFR0_ASIDBits_MASK (UL(0xf) << ID_AA64MMFR0_ASIDBits_SHIFT)
1073#define ID_AA64MMFR0_ASIDBits_VAL(x) ((x) & ID_AA64MMFR0_ASIDBits_MASK)1207#define ID_AA64MMFR0_ASIDBits_VAL(x) ((x) & ID_AA64MMFR0_ASIDBits_MASK)
1074#define ID_AA64MMFR0_ASIDBits_8 (UL(0x0) << ID_AA64MMFR0_ASIDBits_SHIFT)1208#define ID_AA64MMFR0_ASIDBits_8 (UL(0x0) << ID_AA64MMFR0_ASIDBits_SHIFT)
1075#define ID_AA64MMFR0_ASIDBits_16 (UL(0x2) << ID_AA64MMFR0_ASIDBits_SHIFT)1209#define ID_AA64MMFR0_ASIDBits_16 (UL(0x2) << ID_AA64MMFR0_ASIDBits_SHIFT)
1076#define ID_AA64MMFR0_BigEnd_SHIFT 81210#define ID_AA64MMFR0_BigEnd_SHIFT 8
1211#define ID_AA64MMFR0_BigEnd_WIDTH 4
1077#define ID_AA64MMFR0_BigEnd_MASK (UL(0xf) << ID_AA64MMFR0_BigEnd_SHIFT)1212#define ID_AA64MMFR0_BigEnd_MASK (UL(0xf) << ID_AA64MMFR0_BigEnd_SHIFT)
1078#define ID_AA64MMFR0_BigEnd_VAL(x) ((x) & ID_AA64MMFR0_BigEnd_MASK)1213#define ID_AA64MMFR0_BigEnd_VAL(x) ((x) & ID_AA64MMFR0_BigEnd_MASK)
1079#define ID_AA64MMFR0_BigEnd_FIXED (UL(0x0) << ID_AA64MMFR0_BigEnd_SHIFT)1214#define ID_AA64MMFR0_BigEnd_FIXED (UL(0x0) << ID_AA64MMFR0_BigEnd_SHIFT)
1080#define ID_AA64MMFR0_BigEnd_MIXED (UL(0x1) << ID_AA64MMFR0_BigEnd_SHIFT)1215#define ID_AA64MMFR0_BigEnd_MIXED (UL(0x1) << ID_AA64MMFR0_BigEnd_SHIFT)
1081#define ID_AA64MMFR0_SNSMem_SHIFT 121216#define ID_AA64MMFR0_SNSMem_SHIFT 12
1217#define ID_AA64MMFR0_SNSMem_WIDTH 4
1082#define ID_AA64MMFR0_SNSMem_MASK (UL(0xf) << ID_AA64MMFR0_SNSMem_SHIFT)1218#define ID_AA64MMFR0_SNSMem_MASK (UL(0xf) << ID_AA64MMFR0_SNSMem_SHIFT)
1083#define ID_AA64MMFR0_SNSMem_VAL(x) ((x) & ID_AA64MMFR0_SNSMem_MASK)1219#define ID_AA64MMFR0_SNSMem_VAL(x) ((x) & ID_AA64MMFR0_SNSMem_MASK)
1084#define ID_AA64MMFR0_SNSMem_NONE (UL(0x0) << ID_AA64MMFR0_SNSMem_SHIFT)1220#define ID_AA64MMFR0_SNSMem_NONE (UL(0x0) << ID_AA64MMFR0_SNSMem_SHIFT)
1085#define ID_AA64MMFR0_SNSMem_DISTINCT (UL(0x1) << ID_AA64MMFR0_SNSMem_SHIFT)1221#define ID_AA64MMFR0_SNSMem_DISTINCT (UL(0x1) << ID_AA64MMFR0_SNSMem_SHIFT)
1086#define ID_AA64MMFR0_BigEndEL0_SHIFT 161222#define ID_AA64MMFR0_BigEndEL0_SHIFT 16
1223#define ID_AA64MMFR0_BigEndEL0_WIDTH 4
1087#define ID_AA64MMFR0_BigEndEL0_MASK (UL(0xf) << ID_AA64MMFR0_BigEndEL0_SHIFT)1224#define ID_AA64MMFR0_BigEndEL0_MASK (UL(0xf) << ID_AA64MMFR0_BigEndEL0_SHIFT)
1088#define ID_AA64MMFR0_BigEndEL0_VAL(x) ((x) & ID_AA64MMFR0_BigEndEL0_MASK)1225#define ID_AA64MMFR0_BigEndEL0_VAL(x) ((x) & ID_AA64MMFR0_BigEndEL0_MASK)
1089#define ID_AA64MMFR0_BigEndEL0_FIXED (UL(0x0) << ID_AA64MMFR0_BigEndEL0_SHIFT)1226#define ID_AA64MMFR0_BigEndEL0_FIXED (UL(0x0) << ID_AA64MMFR0_BigEndEL0_SHIFT)
1090#define ID_AA64MMFR0_BigEndEL0_MIXED (UL(0x1) << ID_AA64MMFR0_BigEndEL0_SHIFT)1227#define ID_AA64MMFR0_BigEndEL0_MIXED (UL(0x1) << ID_AA64MMFR0_BigEndEL0_SHIFT)
1091#define ID_AA64MMFR0_TGran16_SHIFT 201228#define ID_AA64MMFR0_TGran16_SHIFT 20
1229#define ID_AA64MMFR0_TGran16_WIDTH 4
1092#define ID_AA64MMFR0_TGran16_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_SHIFT)1230#define ID_AA64MMFR0_TGran16_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_SHIFT)
1093#define ID_AA64MMFR0_TGran16_VAL(x) ((x) & ID_AA64MMFR0_TGran16_MASK)1231#define ID_AA64MMFR0_TGran16_VAL(x) ((x) & ID_AA64MMFR0_TGran16_MASK)
1094#define ID_AA64MMFR0_TGran16_NONE (UL(0x0) << ID_AA64MMFR0_TGran16_SHIFT)1232#define ID_AA64MMFR0_TGran16_NONE (UL(0x0) << ID_AA64MMFR0_TGran16_SHIFT)
1095#define ID_AA64MMFR0_TGran16_IMPL (UL(0x1) << ID_AA64MMFR0_TGran16_SHIFT)1233#define ID_AA64MMFR0_TGran16_IMPL (UL(0x1) << ID_AA64MMFR0_TGran16_SHIFT)
1096#define ID_AA64MMFR0_TGran16_LPA2 (UL(0x2) << ID_AA64MMFR0_TGran16_SHIFT)1234#define ID_AA64MMFR0_TGran16_LPA2 (UL(0x2) << ID_AA64MMFR0_TGran16_SHIFT)
1097#define ID_AA64MMFR0_TGran64_SHIFT 241235#define ID_AA64MMFR0_TGran64_SHIFT 24
1236#define ID_AA64MMFR0_TGran64_WIDTH 4
1098#define ID_AA64MMFR0_TGran64_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT)1237#define ID_AA64MMFR0_TGran64_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT)
1099#define ID_AA64MMFR0_TGran64_VAL(x) ((x) & ID_AA64MMFR0_TGran64_MASK)1238#define ID_AA64MMFR0_TGran64_VAL(x) ((x) & ID_AA64MMFR0_TGran64_MASK)
1100#define ID_AA64MMFR0_TGran64_IMPL (UL(0x0) << ID_AA64MMFR0_TGran64_SHIFT)1239#define ID_AA64MMFR0_TGran64_IMPL (UL(0x0) << ID_AA64MMFR0_TGran64_SHIFT)
1101#define ID_AA64MMFR0_TGran64_NONE (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT)1240#define ID_AA64MMFR0_TGran64_NONE (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT)
1102#define ID_AA64MMFR0_TGran4_SHIFT 281241#define ID_AA64MMFR0_TGran4_SHIFT 28
1242#define ID_AA64MMFR0_TGran4_WIDTH 4
1103#define ID_AA64MMFR0_TGran4_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT)1243#define ID_AA64MMFR0_TGran4_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT)
1104#define ID_AA64MMFR0_TGran4_VAL(x) ((x) & ID_AA64MMFR0_TGran4_MASK)1244#define ID_AA64MMFR0_TGran4_VAL(x) ((x) & ID_AA64MMFR0_TGran4_MASK)
1105#define ID_AA64MMFR0_TGran4_IMPL (UL(0x0) << ID_AA64MMFR0_TGran4_SHIFT)1245#define ID_AA64MMFR0_TGran4_IMPL (UL(0x0) << ID_AA64MMFR0_TGran4_SHIFT)
1106#define ID_AA64MMFR0_TGran4_LPA2 (UL(0x1) << ID_AA64MMFR0_TGran4_SHIFT)1246#define ID_AA64MMFR0_TGran4_LPA2 (UL(0x1) << ID_AA64MMFR0_TGran4_SHIFT)
1107#define ID_AA64MMFR0_TGran4_NONE (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT)1247#define ID_AA64MMFR0_TGran4_NONE (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT)
1108#define ID_AA64MMFR0_TGran16_2_SHIFT 321248#define ID_AA64MMFR0_TGran16_2_SHIFT 32
1249#define ID_AA64MMFR0_TGran16_2_WIDTH 4
1109#define ID_AA64MMFR0_TGran16_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_2_SHIFT)1250#define ID_AA64MMFR0_TGran16_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_2_SHIFT)
1110#define ID_AA64MMFR0_TGran16_2_VAL(x) ((x) & ID_AA64MMFR0_TGran16_2_MASK)1251#define ID_AA64MMFR0_TGran16_2_VAL(x) ((x) & ID_AA64MMFR0_TGran16_2_MASK)
1111#define ID_AA64MMFR0_TGran16_2_TGran16 (UL(0x0) << ID_AA64MMFR0_TGran16_2_SHIFT)1252#define ID_AA64MMFR0_TGran16_2_TGran16 (UL(0x0) << ID_AA64MMFR0_TGran16_2_SHIFT)
...@@ -1113,12 +1254,14 @@...@@ -1113,12 +1254,14 @@
1113#define ID_AA64MMFR0_TGran16_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran16_2_SHIFT)1254#define ID_AA64MMFR0_TGran16_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran16_2_SHIFT)
1114#define ID_AA64MMFR0_TGran16_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran16_2_SHIFT)1255#define ID_AA64MMFR0_TGran16_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran16_2_SHIFT)
1115#define ID_AA64MMFR0_TGran64_2_SHIFT 361256#define ID_AA64MMFR0_TGran64_2_SHIFT 36
1257#define ID_AA64MMFR0_TGran64_2_WIDTH 4
1116#define ID_AA64MMFR0_TGran64_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_2_SHIFT)1258#define ID_AA64MMFR0_TGran64_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_2_SHIFT)
1117#define ID_AA64MMFR0_TGran64_2_VAL(x) ((x) & ID_AA64MMFR0_TGran64_2_MASK)1259#define ID_AA64MMFR0_TGran64_2_VAL(x) ((x) & ID_AA64MMFR0_TGran64_2_MASK)
1118#define ID_AA64MMFR0_TGran64_2_TGran64 (UL(0x0) << ID_AA64MMFR0_TGran64_2_SHIFT)1260#define ID_AA64MMFR0_TGran64_2_TGran64 (UL(0x0) << ID_AA64MMFR0_TGran64_2_SHIFT)
1119#define ID_AA64MMFR0_TGran64_2_NONE (UL(0x1) << ID_AA64MMFR0_TGran64_2_SHIFT)1261#define ID_AA64MMFR0_TGran64_2_NONE (UL(0x1) << ID_AA64MMFR0_TGran64_2_SHIFT)
1120#define ID_AA64MMFR0_TGran64_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran64_2_SHIFT)1262#define ID_AA64MMFR0_TGran64_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran64_2_SHIFT)
1121#define ID_AA64MMFR0_TGran4_2_SHIFT 401263#define ID_AA64MMFR0_TGran4_2_SHIFT 40
1264#define ID_AA64MMFR0_TGran4_2_WIDTH 4
1122#define ID_AA64MMFR0_TGran4_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_2_SHIFT)1265#define ID_AA64MMFR0_TGran4_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_2_SHIFT)
1123#define ID_AA64MMFR0_TGran4_2_VAL(x) ((x) & ID_AA64MMFR0_TGran4_2_MASK)1266#define ID_AA64MMFR0_TGran4_2_VAL(x) ((x) & ID_AA64MMFR0_TGran4_2_MASK)
1124#define ID_AA64MMFR0_TGran4_2_TGran4 (UL(0x0) << ID_AA64MMFR0_TGran4_2_SHIFT)1267#define ID_AA64MMFR0_TGran4_2_TGran4 (UL(0x0) << ID_AA64MMFR0_TGran4_2_SHIFT)
...@@ -1126,229 +1269,328 @@...@@ -1126,229 +1269,328 @@
1126#define ID_AA64MMFR0_TGran4_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran4_2_SHIFT)1269#define ID_AA64MMFR0_TGran4_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran4_2_SHIFT)
1127#define ID_AA64MMFR0_TGran4_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran4_2_SHIFT)1270#define ID_AA64MMFR0_TGran4_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran4_2_SHIFT)
1128#define ID_AA64MMFR0_ExS_SHIFT 441271#define ID_AA64MMFR0_ExS_SHIFT 44
1272#define ID_AA64MMFR0_ExS_WIDTH 4
1129#define ID_AA64MMFR0_ExS_MASK (UL(0xf) << ID_AA64MMFR0_ExS_SHIFT)1273#define ID_AA64MMFR0_ExS_MASK (UL(0xf) << ID_AA64MMFR0_ExS_SHIFT)
1130#define ID_AA64MMFR0_ExS_VAL(x) ((x) & ID_AA64MMFR0_ExS_MASK)1274#define ID_AA64MMFR0_ExS_VAL(x) ((x) & ID_AA64MMFR0_ExS_MASK)
1131#define ID_AA64MMFR0_ExS_ALL (UL(0x0) << ID_AA64MMFR0_ExS_SHIFT)1275#define ID_AA64MMFR0_ExS_ALL (UL(0x0) << ID_AA64MMFR0_ExS_SHIFT)
1132#define ID_AA64MMFR0_ExS_IMPL (UL(0x1) << ID_AA64MMFR0_ExS_SHIFT)1276#define ID_AA64MMFR0_ExS_IMPL (UL(0x1) << ID_AA64MMFR0_ExS_SHIFT)
1133#define ID_AA64MMFR0_FGT_SHIFT 561277#define ID_AA64MMFR0_FGT_SHIFT 56
1278#define ID_AA64MMFR0_FGT_WIDTH 4
1134#define ID_AA64MMFR0_FGT_MASK (UL(0xf) << ID_AA64MMFR0_FGT_SHIFT)1279#define ID_AA64MMFR0_FGT_MASK (UL(0xf) << ID_AA64MMFR0_FGT_SHIFT)
1135#define ID_AA64MMFR0_FGT_VAL(x) ((x) & ID_AA64MMFR0_FGT_MASK)1280#define ID_AA64MMFR0_FGT_VAL(x) ((x) & ID_AA64MMFR0_FGT_MASK)
1136#define ID_AA64MMFR0_FGT_NONE (UL(0x0) << ID_AA64MMFR0_FGT_SHIFT)1281#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)
1138#define ID_AA64MMFR0_ECV_SHIFT 601284#define ID_AA64MMFR0_ECV_SHIFT 60
1285#define ID_AA64MMFR0_ECV_WIDTH 4
1139#define ID_AA64MMFR0_ECV_MASK (UL(0xf) << ID_AA64MMFR0_ECV_SHIFT)1286#define ID_AA64MMFR0_ECV_MASK (UL(0xf) << ID_AA64MMFR0_ECV_SHIFT)
1140#define ID_AA64MMFR0_ECV_VAL(x) ((x) & ID_AA64MMFR0_ECV_MASK)1287#define ID_AA64MMFR0_ECV_VAL(x) ((x) & ID_AA64MMFR0_ECV_MASK)
1141#define ID_AA64MMFR0_ECV_NONE (UL(0x0) << ID_AA64MMFR0_ECV_SHIFT)1288#define ID_AA64MMFR0_ECV_NONE (UL(0x0) << ID_AA64MMFR0_ECV_SHIFT)
1142#define ID_AA64MMFR0_ECV_IMPL (UL(0x1) << ID_AA64MMFR0_ECV_SHIFT)1289#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
1145/* ID_AA64MMFR1_EL1 */1292/* ID_AA64MMFR1_EL1 */
1146#define ID_AA64MMFR1_EL1 MRS_REG(ID_AA64MMFR1_EL1)
1147#define ID_AA64MMFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR1_EL1)1293#define ID_AA64MMFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR1_EL1)
1294#define ID_AA64MMFR1_EL1_ISS ISS_MSR_REG(ID_AA64MMFR1_EL1)
1148#define ID_AA64MMFR1_EL1_op0 31295#define ID_AA64MMFR1_EL1_op0 3
1149#define ID_AA64MMFR1_EL1_op1 01296#define ID_AA64MMFR1_EL1_op1 0
1150#define ID_AA64MMFR1_EL1_CRn 01297#define ID_AA64MMFR1_EL1_CRn 0
1151#define ID_AA64MMFR1_EL1_CRm 71298#define ID_AA64MMFR1_EL1_CRm 7
1152#define ID_AA64MMFR1_EL1_op2 11299#define ID_AA64MMFR1_EL1_op2 1
1153#define ID_AA64MMFR1_HAFDBS_SHIFT 01300#define ID_AA64MMFR1_HAFDBS_SHIFT 0
1301#define ID_AA64MMFR1_HAFDBS_WIDTH 4
1154#define ID_AA64MMFR1_HAFDBS_MASK (UL(0xf) << ID_AA64MMFR1_HAFDBS_SHIFT)1302#define ID_AA64MMFR1_HAFDBS_MASK (UL(0xf) << ID_AA64MMFR1_HAFDBS_SHIFT)
1155#define ID_AA64MMFR1_HAFDBS_VAL(x) ((x) & ID_AA64MMFR1_HAFDBS_MASK)1303#define ID_AA64MMFR1_HAFDBS_VAL(x) ((x) & ID_AA64MMFR1_HAFDBS_MASK)
1156#define ID_AA64MMFR1_HAFDBS_NONE (UL(0x0) << ID_AA64MMFR1_HAFDBS_SHIFT)1304#define ID_AA64MMFR1_HAFDBS_NONE (UL(0x0) << ID_AA64MMFR1_HAFDBS_SHIFT)
1157#define ID_AA64MMFR1_HAFDBS_AF (UL(0x1) << ID_AA64MMFR1_HAFDBS_SHIFT)1305#define ID_AA64MMFR1_HAFDBS_AF (UL(0x1) << ID_AA64MMFR1_HAFDBS_SHIFT)
1158#define ID_AA64MMFR1_HAFDBS_AF_DBS (UL(0x2) << ID_AA64MMFR1_HAFDBS_SHIFT)1306#define ID_AA64MMFR1_HAFDBS_AF_DBS (UL(0x2) << ID_AA64MMFR1_HAFDBS_SHIFT)
1159#define ID_AA64MMFR1_VMIDBits_SHIFT 41307#define ID_AA64MMFR1_VMIDBits_SHIFT 4
1308#define ID_AA64MMFR1_VMIDBits_WIDTH 4
1160#define ID_AA64MMFR1_VMIDBits_MASK (UL(0xf) << ID_AA64MMFR1_VMIDBits_SHIFT)1309#define ID_AA64MMFR1_VMIDBits_MASK (UL(0xf) << ID_AA64MMFR1_VMIDBits_SHIFT)
1161#define ID_AA64MMFR1_VMIDBits_VAL(x) ((x) & ID_AA64MMFR1_VMIDBits_MASK)1310#define ID_AA64MMFR1_VMIDBits_VAL(x) ((x) & ID_AA64MMFR1_VMIDBits_MASK)
1162#define ID_AA64MMFR1_VMIDBits_8 (UL(0x0) << ID_AA64MMFR1_VMIDBits_SHIFT)1311#define ID_AA64MMFR1_VMIDBits_8 (UL(0x0) << ID_AA64MMFR1_VMIDBits_SHIFT)
1163#define ID_AA64MMFR1_VMIDBits_16 (UL(0x2) << ID_AA64MMFR1_VMIDBits_SHIFT)1312#define ID_AA64MMFR1_VMIDBits_16 (UL(0x2) << ID_AA64MMFR1_VMIDBits_SHIFT)
1164#define ID_AA64MMFR1_VH_SHIFT 81313#define ID_AA64MMFR1_VH_SHIFT 8
1314#define ID_AA64MMFR1_VH_WIDTH 4
1165#define ID_AA64MMFR1_VH_MASK (UL(0xf) << ID_AA64MMFR1_VH_SHIFT)1315#define ID_AA64MMFR1_VH_MASK (UL(0xf) << ID_AA64MMFR1_VH_SHIFT)
1166#define ID_AA64MMFR1_VH_VAL(x) ((x) & ID_AA64MMFR1_VH_MASK)1316#define ID_AA64MMFR1_VH_VAL(x) ((x) & ID_AA64MMFR1_VH_MASK)
1167#define ID_AA64MMFR1_VH_NONE (UL(0x0) << ID_AA64MMFR1_VH_SHIFT)1317#define ID_AA64MMFR1_VH_NONE (UL(0x0) << ID_AA64MMFR1_VH_SHIFT)
1168#define ID_AA64MMFR1_VH_IMPL (UL(0x1) << ID_AA64MMFR1_VH_SHIFT)1318#define ID_AA64MMFR1_VH_IMPL (UL(0x1) << ID_AA64MMFR1_VH_SHIFT)
1169#define ID_AA64MMFR1_HPDS_SHIFT 121319#define ID_AA64MMFR1_HPDS_SHIFT 12
1320#define ID_AA64MMFR1_HPDS_WIDTH 4
1170#define ID_AA64MMFR1_HPDS_MASK (UL(0xf) << ID_AA64MMFR1_HPDS_SHIFT)1321#define ID_AA64MMFR1_HPDS_MASK (UL(0xf) << ID_AA64MMFR1_HPDS_SHIFT)
1171#define ID_AA64MMFR1_HPDS_VAL(x) ((x) & ID_AA64MMFR1_HPDS_MASK)1322#define ID_AA64MMFR1_HPDS_VAL(x) ((x) & ID_AA64MMFR1_HPDS_MASK)
1172#define ID_AA64MMFR1_HPDS_NONE (UL(0x0) << ID_AA64MMFR1_HPDS_SHIFT)1323#define ID_AA64MMFR1_HPDS_NONE (UL(0x0) << ID_AA64MMFR1_HPDS_SHIFT)
1173#define ID_AA64MMFR1_HPDS_HPD (UL(0x1) << ID_AA64MMFR1_HPDS_SHIFT)1324#define ID_AA64MMFR1_HPDS_HPD (UL(0x1) << ID_AA64MMFR1_HPDS_SHIFT)
1174#define ID_AA64MMFR1_HPDS_TTPBHA (UL(0x2) << ID_AA64MMFR1_HPDS_SHIFT)1325#define ID_AA64MMFR1_HPDS_TTPBHA (UL(0x2) << ID_AA64MMFR1_HPDS_SHIFT)
1175#define ID_AA64MMFR1_LO_SHIFT 161326#define ID_AA64MMFR1_LO_SHIFT 16
1327#define ID_AA64MMFR1_LO_WIDTH 4
1176#define ID_AA64MMFR1_LO_MASK (UL(0xf) << ID_AA64MMFR1_LO_SHIFT)1328#define ID_AA64MMFR1_LO_MASK (UL(0xf) << ID_AA64MMFR1_LO_SHIFT)
1177#define ID_AA64MMFR1_LO_VAL(x) ((x) & ID_AA64MMFR1_LO_MASK)1329#define ID_AA64MMFR1_LO_VAL(x) ((x) & ID_AA64MMFR1_LO_MASK)
1178#define ID_AA64MMFR1_LO_NONE (UL(0x0) << ID_AA64MMFR1_LO_SHIFT)1330#define ID_AA64MMFR1_LO_NONE (UL(0x0) << ID_AA64MMFR1_LO_SHIFT)
1179#define ID_AA64MMFR1_LO_IMPL (UL(0x1) << ID_AA64MMFR1_LO_SHIFT)1331#define ID_AA64MMFR1_LO_IMPL (UL(0x1) << ID_AA64MMFR1_LO_SHIFT)
1180#define ID_AA64MMFR1_PAN_SHIFT 201332#define ID_AA64MMFR1_PAN_SHIFT 20
1333#define ID_AA64MMFR1_PAN_WIDTH 4
1181#define ID_AA64MMFR1_PAN_MASK (UL(0xf) << ID_AA64MMFR1_PAN_SHIFT)1334#define ID_AA64MMFR1_PAN_MASK (UL(0xf) << ID_AA64MMFR1_PAN_SHIFT)
1182#define ID_AA64MMFR1_PAN_VAL(x) ((x) & ID_AA64MMFR1_PAN_MASK)1335#define ID_AA64MMFR1_PAN_VAL(x) ((x) & ID_AA64MMFR1_PAN_MASK)
1183#define ID_AA64MMFR1_PAN_NONE (UL(0x0) << ID_AA64MMFR1_PAN_SHIFT)1336#define ID_AA64MMFR1_PAN_NONE (UL(0x0) << ID_AA64MMFR1_PAN_SHIFT)
1184#define ID_AA64MMFR1_PAN_IMPL (UL(0x1) << ID_AA64MMFR1_PAN_SHIFT)1337#define ID_AA64MMFR1_PAN_IMPL (UL(0x1) << ID_AA64MMFR1_PAN_SHIFT)
1185#define ID_AA64MMFR1_PAN_ATS1E1 (UL(0x2) << ID_AA64MMFR1_PAN_SHIFT)1338#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)
1187#define ID_AA64MMFR1_SpecSEI_SHIFT 241340#define ID_AA64MMFR1_SpecSEI_SHIFT 24
1341#define ID_AA64MMFR1_SpecSEI_WIDTH 4
1188#define ID_AA64MMFR1_SpecSEI_MASK (UL(0xf) << ID_AA64MMFR1_SpecSEI_SHIFT)1342#define ID_AA64MMFR1_SpecSEI_MASK (UL(0xf) << ID_AA64MMFR1_SpecSEI_SHIFT)
1189#define ID_AA64MMFR1_SpecSEI_VAL(x) ((x) & ID_AA64MMFR1_SpecSEI_MASK)1343#define ID_AA64MMFR1_SpecSEI_VAL(x) ((x) & ID_AA64MMFR1_SpecSEI_MASK)
1190#define ID_AA64MMFR1_SpecSEI_NONE (UL(0x0) << ID_AA64MMFR1_SpecSEI_SHIFT)1344#define ID_AA64MMFR1_SpecSEI_NONE (UL(0x0) << ID_AA64MMFR1_SpecSEI_SHIFT)
1191#define ID_AA64MMFR1_SpecSEI_IMPL (UL(0x1) << ID_AA64MMFR1_SpecSEI_SHIFT)1345#define ID_AA64MMFR1_SpecSEI_IMPL (UL(0x1) << ID_AA64MMFR1_SpecSEI_SHIFT)
1192#define ID_AA64MMFR1_XNX_SHIFT 281346#define ID_AA64MMFR1_XNX_SHIFT 28
1347#define ID_AA64MMFR1_XNX_WIDTH 4
1193#define ID_AA64MMFR1_XNX_MASK (UL(0xf) << ID_AA64MMFR1_XNX_SHIFT)1348#define ID_AA64MMFR1_XNX_MASK (UL(0xf) << ID_AA64MMFR1_XNX_SHIFT)
1194#define ID_AA64MMFR1_XNX_VAL(x) ((x) & ID_AA64MMFR1_XNX_MASK)1349#define ID_AA64MMFR1_XNX_VAL(x) ((x) & ID_AA64MMFR1_XNX_MASK)
1195#define ID_AA64MMFR1_XNX_NONE (UL(0x0) << ID_AA64MMFR1_XNX_SHIFT)1350#define ID_AA64MMFR1_XNX_NONE (UL(0x0) << ID_AA64MMFR1_XNX_SHIFT)
1196#define ID_AA64MMFR1_XNX_IMPL (UL(0x1) << ID_AA64MMFR1_XNX_SHIFT)1351#define ID_AA64MMFR1_XNX_IMPL (UL(0x1) << ID_AA64MMFR1_XNX_SHIFT)
1197#define ID_AA64MMFR1_TWED_SHIFT 321352#define ID_AA64MMFR1_TWED_SHIFT 32
1353#define ID_AA64MMFR1_TWED_WIDTH 4
1198#define ID_AA64MMFR1_TWED_MASK (UL(0xf) << ID_AA64MMFR1_TWED_SHIFT)1354#define ID_AA64MMFR1_TWED_MASK (UL(0xf) << ID_AA64MMFR1_TWED_SHIFT)
1199#define ID_AA64MMFR1_TWED_VAL(x) ((x) & ID_AA64MMFR1_TWED_MASK)1355#define ID_AA64MMFR1_TWED_VAL(x) ((x) & ID_AA64MMFR1_TWED_MASK)
1200#define ID_AA64MMFR1_TWED_NONE (UL(0x0) << ID_AA64MMFR1_TWED_SHIFT)1356#define ID_AA64MMFR1_TWED_NONE (UL(0x0) << ID_AA64MMFR1_TWED_SHIFT)
1201#define ID_AA64MMFR1_TWED_IMPL (UL(0x1) << ID_AA64MMFR1_TWED_SHIFT)1357#define ID_AA64MMFR1_TWED_IMPL (UL(0x1) << ID_AA64MMFR1_TWED_SHIFT)
1202#define ID_AA64MMFR1_ETS_SHIFT 361358#define ID_AA64MMFR1_ETS_SHIFT 36
1359#define ID_AA64MMFR1_ETS_WIDTH 4
1203#define ID_AA64MMFR1_ETS_MASK (UL(0xf) << ID_AA64MMFR1_ETS_SHIFT)1360#define ID_AA64MMFR1_ETS_MASK (UL(0xf) << ID_AA64MMFR1_ETS_SHIFT)
1204#define ID_AA64MMFR1_ETS_VAL(x) ((x) & ID_AA64MMFR1_ETS_MASK)1361#define ID_AA64MMFR1_ETS_VAL(x) ((x) & ID_AA64MMFR1_ETS_MASK)
1205#define ID_AA64MMFR1_ETS_NONE (UL(0x0) << ID_AA64MMFR1_ETS_SHIFT)1362#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)
1207#define ID_AA64MMFR1_HCX_SHIFT 401365#define ID_AA64MMFR1_HCX_SHIFT 40
1366#define ID_AA64MMFR1_HCX_WIDTH 4
1208#define ID_AA64MMFR1_HCX_MASK (UL(0xf) << ID_AA64MMFR1_HCX_SHIFT)1367#define ID_AA64MMFR1_HCX_MASK (UL(0xf) << ID_AA64MMFR1_HCX_SHIFT)
1209#define ID_AA64MMFR1_HCX_VAL(x) ((x) & ID_AA64MMFR1_HCX_MASK)1368#define ID_AA64MMFR1_HCX_VAL(x) ((x) & ID_AA64MMFR1_HCX_MASK)
1210#define ID_AA64MMFR1_HCX_NONE (UL(0x0) << ID_AA64MMFR1_HCX_SHIFT)1369#define ID_AA64MMFR1_HCX_NONE (UL(0x0) << ID_AA64MMFR1_HCX_SHIFT)
1211#define ID_AA64MMFR1_HCX_IMPL (UL(0x1) << ID_AA64MMFR1_HCX_SHIFT)1370#define ID_AA64MMFR1_HCX_IMPL (UL(0x1) << ID_AA64MMFR1_HCX_SHIFT)
1212#define ID_AA64MMFR1_AFP_SHIFT 441371#define ID_AA64MMFR1_AFP_SHIFT 44
1372#define ID_AA64MMFR1_AFP_WIDTH 4
1213#define ID_AA64MMFR1_AFP_MASK (UL(0xf) << ID_AA64MMFR1_AFP_SHIFT)1373#define ID_AA64MMFR1_AFP_MASK (UL(0xf) << ID_AA64MMFR1_AFP_SHIFT)
1214#define ID_AA64MMFR1_AFP_VAL(x) ((x) & ID_AA64MMFR1_AFP_MASK)1374#define ID_AA64MMFR1_AFP_VAL(x) ((x) & ID_AA64MMFR1_AFP_MASK)
1215#define ID_AA64MMFR1_AFP_NONE (UL(0x0) << ID_AA64MMFR1_AFP_SHIFT)1375#define ID_AA64MMFR1_AFP_NONE (UL(0x0) << ID_AA64MMFR1_AFP_SHIFT)
1216#define ID_AA64MMFR1_AFP_IMPL (UL(0x1) << ID_AA64MMFR1_AFP_SHIFT)1376#define ID_AA64MMFR1_AFP_IMPL (UL(0x1) << ID_AA64MMFR1_AFP_SHIFT)
1217#define ID_AA64MMFR1_nTLBPA_SHIFT 481377#define ID_AA64MMFR1_nTLBPA_SHIFT 48
1378#define ID_AA64MMFR1_nTLBPA_WIDTH 4
1218#define ID_AA64MMFR1_nTLBPA_MASK (UL(0xf) << ID_AA64MMFR1_nTLBPA_SHIFT)1379#define ID_AA64MMFR1_nTLBPA_MASK (UL(0xf) << ID_AA64MMFR1_nTLBPA_SHIFT)
1219#define ID_AA64MMFR1_nTLBPA_VAL(x) ((x) & ID_AA64MMFR1_nTLBPA_MASK)1380#define ID_AA64MMFR1_nTLBPA_VAL(x) ((x) & ID_AA64MMFR1_nTLBPA_MASK)
1220#define ID_AA64MMFR1_nTLBPA_NONE (UL(0x0) << ID_AA64MMFR1_nTLBPA_SHIFT)1381#define ID_AA64MMFR1_nTLBPA_NONE (UL(0x0) << ID_AA64MMFR1_nTLBPA_SHIFT)
1221#define ID_AA64MMFR1_nTLBPA_IMPL (UL(0x1) << ID_AA64MMFR1_nTLBPA_SHIFT)1382#define ID_AA64MMFR1_nTLBPA_IMPL (UL(0x1) << ID_AA64MMFR1_nTLBPA_SHIFT)
1222#define ID_AA64MMFR1_TIDCP1_SHIFT 521383#define ID_AA64MMFR1_TIDCP1_SHIFT 52
1384#define ID_AA64MMFR1_TIDCP1_WIDTH 4
1223#define ID_AA64MMFR1_TIDCP1_MASK (UL(0xf) << ID_AA64MMFR1_TIDCP1_SHIFT)1385#define ID_AA64MMFR1_TIDCP1_MASK (UL(0xf) << ID_AA64MMFR1_TIDCP1_SHIFT)
1224#define ID_AA64MMFR1_TIDCP1_VAL(x) ((x) & ID_AA64MMFR1_TIDCP1_MASK)1386#define ID_AA64MMFR1_TIDCP1_VAL(x) ((x) & ID_AA64MMFR1_TIDCP1_MASK)
1225#define ID_AA64MMFR1_TIDCP1_NONE (UL(0x0) << ID_AA64MMFR1_TIDCP1_SHIFT)1387#define ID_AA64MMFR1_TIDCP1_NONE (UL(0x0) << ID_AA64MMFR1_TIDCP1_SHIFT)
1226#define ID_AA64MMFR1_TIDCP1_IMPL (UL(0x1) << ID_AA64MMFR1_TIDCP1_SHIFT)1388#define ID_AA64MMFR1_TIDCP1_IMPL (UL(0x1) << ID_AA64MMFR1_TIDCP1_SHIFT)
1227#define ID_AA64MMFR1_CMOVW_SHIFT 561389#define ID_AA64MMFR1_CMOVW_SHIFT 56
1390#define ID_AA64MMFR1_CMOVW_WIDTH 4
1228#define ID_AA64MMFR1_CMOVW_MASK (UL(0xf) << ID_AA64MMFR1_CMOVW_SHIFT)1391#define ID_AA64MMFR1_CMOVW_MASK (UL(0xf) << ID_AA64MMFR1_CMOVW_SHIFT)
1229#define ID_AA64MMFR1_CMOVW_VAL(x) ((x) & ID_AA64MMFR1_CMOVW_MASK)1392#define ID_AA64MMFR1_CMOVW_VAL(x) ((x) & ID_AA64MMFR1_CMOVW_MASK)
1230#define ID_AA64MMFR1_CMOVW_NONE (UL(0x0) << ID_AA64MMFR1_CMOVW_SHIFT)1393#define ID_AA64MMFR1_CMOVW_NONE (UL(0x0) << ID_AA64MMFR1_CMOVW_SHIFT)
1231#define ID_AA64MMFR1_CMOVW_IMPL (UL(0x1) << ID_AA64MMFR1_CMOVW_SHIFT)1394#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
1233/* ID_AA64MMFR2_EL1 */1402/* ID_AA64MMFR2_EL1 */
1234#define ID_AA64MMFR2_EL1 MRS_REG(ID_AA64MMFR2_EL1)
1235#define ID_AA64MMFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR2_EL1)1403#define ID_AA64MMFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR2_EL1)
1404#define ID_AA64MMFR2_EL1_ISS ISS_MSR_REG(ID_AA64MMFR2_EL1)
1236#define ID_AA64MMFR2_EL1_op0 31405#define ID_AA64MMFR2_EL1_op0 3
1237#define ID_AA64MMFR2_EL1_op1 01406#define ID_AA64MMFR2_EL1_op1 0
1238#define ID_AA64MMFR2_EL1_CRn 01407#define ID_AA64MMFR2_EL1_CRn 0
1239#define ID_AA64MMFR2_EL1_CRm 71408#define ID_AA64MMFR2_EL1_CRm 7
1240#define ID_AA64MMFR2_EL1_op2 21409#define ID_AA64MMFR2_EL1_op2 2
1241#define ID_AA64MMFR2_CnP_SHIFT 01410#define ID_AA64MMFR2_CnP_SHIFT 0
1411#define ID_AA64MMFR2_CnP_WIDTH 4
1242#define ID_AA64MMFR2_CnP_MASK (UL(0xf) << ID_AA64MMFR2_CnP_SHIFT)1412#define ID_AA64MMFR2_CnP_MASK (UL(0xf) << ID_AA64MMFR2_CnP_SHIFT)
1243#define ID_AA64MMFR2_CnP_VAL(x) ((x) & ID_AA64MMFR2_CnP_MASK)1413#define ID_AA64MMFR2_CnP_VAL(x) ((x) & ID_AA64MMFR2_CnP_MASK)
1244#define ID_AA64MMFR2_CnP_NONE (UL(0x0) << ID_AA64MMFR2_CnP_SHIFT)1414#define ID_AA64MMFR2_CnP_NONE (UL(0x0) << ID_AA64MMFR2_CnP_SHIFT)
1245#define ID_AA64MMFR2_CnP_IMPL (UL(0x1) << ID_AA64MMFR2_CnP_SHIFT)1415#define ID_AA64MMFR2_CnP_IMPL (UL(0x1) << ID_AA64MMFR2_CnP_SHIFT)
1246#define ID_AA64MMFR2_UAO_SHIFT 41416#define ID_AA64MMFR2_UAO_SHIFT 4
1417#define ID_AA64MMFR2_UAO_WIDTH 4
1247#define ID_AA64MMFR2_UAO_MASK (UL(0xf) << ID_AA64MMFR2_UAO_SHIFT)1418#define ID_AA64MMFR2_UAO_MASK (UL(0xf) << ID_AA64MMFR2_UAO_SHIFT)
1248#define ID_AA64MMFR2_UAO_VAL(x) ((x) & ID_AA64MMFR2_UAO_MASK)1419#define ID_AA64MMFR2_UAO_VAL(x) ((x) & ID_AA64MMFR2_UAO_MASK)
1249#define ID_AA64MMFR2_UAO_NONE (UL(0x0) << ID_AA64MMFR2_UAO_SHIFT)1420#define ID_AA64MMFR2_UAO_NONE (UL(0x0) << ID_AA64MMFR2_UAO_SHIFT)
1250#define ID_AA64MMFR2_UAO_IMPL (UL(0x1) << ID_AA64MMFR2_UAO_SHIFT)1421#define ID_AA64MMFR2_UAO_IMPL (UL(0x1) << ID_AA64MMFR2_UAO_SHIFT)
1251#define ID_AA64MMFR2_LSM_SHIFT 81422#define ID_AA64MMFR2_LSM_SHIFT 8
1423#define ID_AA64MMFR2_LSM_WIDTH 4
1252#define ID_AA64MMFR2_LSM_MASK (UL(0xf) << ID_AA64MMFR2_LSM_SHIFT)1424#define ID_AA64MMFR2_LSM_MASK (UL(0xf) << ID_AA64MMFR2_LSM_SHIFT)
1253#define ID_AA64MMFR2_LSM_VAL(x) ((x) & ID_AA64MMFR2_LSM_MASK)1425#define ID_AA64MMFR2_LSM_VAL(x) ((x) & ID_AA64MMFR2_LSM_MASK)
1254#define ID_AA64MMFR2_LSM_NONE (UL(0x0) << ID_AA64MMFR2_LSM_SHIFT)1426#define ID_AA64MMFR2_LSM_NONE (UL(0x0) << ID_AA64MMFR2_LSM_SHIFT)
1255#define ID_AA64MMFR2_LSM_IMPL (UL(0x1) << ID_AA64MMFR2_LSM_SHIFT)1427#define ID_AA64MMFR2_LSM_IMPL (UL(0x1) << ID_AA64MMFR2_LSM_SHIFT)
1256#define ID_AA64MMFR2_IESB_SHIFT 121428#define ID_AA64MMFR2_IESB_SHIFT 12
1429#define ID_AA64MMFR2_IESB_WIDTH 4
1257#define ID_AA64MMFR2_IESB_MASK (UL(0xf) << ID_AA64MMFR2_IESB_SHIFT)1430#define ID_AA64MMFR2_IESB_MASK (UL(0xf) << ID_AA64MMFR2_IESB_SHIFT)
1258#define ID_AA64MMFR2_IESB_VAL(x) ((x) & ID_AA64MMFR2_IESB_MASK)1431#define ID_AA64MMFR2_IESB_VAL(x) ((x) & ID_AA64MMFR2_IESB_MASK)
1259#define ID_AA64MMFR2_IESB_NONE (UL(0x0) << ID_AA64MMFR2_IESB_SHIFT)1432#define ID_AA64MMFR2_IESB_NONE (UL(0x0) << ID_AA64MMFR2_IESB_SHIFT)
1260#define ID_AA64MMFR2_IESB_IMPL (UL(0x1) << ID_AA64MMFR2_IESB_SHIFT)1433#define ID_AA64MMFR2_IESB_IMPL (UL(0x1) << ID_AA64MMFR2_IESB_SHIFT)
1261#define ID_AA64MMFR2_VARange_SHIFT 161434#define ID_AA64MMFR2_VARange_SHIFT 16
1435#define ID_AA64MMFR2_VARange_WIDTH 4
1262#define ID_AA64MMFR2_VARange_MASK (UL(0xf) << ID_AA64MMFR2_VARange_SHIFT)1436#define ID_AA64MMFR2_VARange_MASK (UL(0xf) << ID_AA64MMFR2_VARange_SHIFT)
1263#define ID_AA64MMFR2_VARange_VAL(x) ((x) & ID_AA64MMFR2_VARange_MASK)1437#define ID_AA64MMFR2_VARange_VAL(x) ((x) & ID_AA64MMFR2_VARange_MASK)
1264#define ID_AA64MMFR2_VARange_48 (UL(0x0) << ID_AA64MMFR2_VARange_SHIFT)1438#define ID_AA64MMFR2_VARange_48 (UL(0x0) << ID_AA64MMFR2_VARange_SHIFT)
1265#define ID_AA64MMFR2_VARange_52 (UL(0x1) << ID_AA64MMFR2_VARange_SHIFT)1439#define ID_AA64MMFR2_VARange_52 (UL(0x1) << ID_AA64MMFR2_VARange_SHIFT)
1266#define ID_AA64MMFR2_CCIDX_SHIFT 201440#define ID_AA64MMFR2_CCIDX_SHIFT 20
1441#define ID_AA64MMFR2_CCIDX_WIDTH 4
1267#define ID_AA64MMFR2_CCIDX_MASK (UL(0xf) << ID_AA64MMFR2_CCIDX_SHIFT)1442#define ID_AA64MMFR2_CCIDX_MASK (UL(0xf) << ID_AA64MMFR2_CCIDX_SHIFT)
1268#define ID_AA64MMFR2_CCIDX_VAL(x) ((x) & ID_AA64MMFR2_CCIDX_MASK)1443#define ID_AA64MMFR2_CCIDX_VAL(x) ((x) & ID_AA64MMFR2_CCIDX_MASK)
1269#define ID_AA64MMFR2_CCIDX_32 (UL(0x0) << ID_AA64MMFR2_CCIDX_SHIFT)1444#define ID_AA64MMFR2_CCIDX_32 (UL(0x0) << ID_AA64MMFR2_CCIDX_SHIFT)
1270#define ID_AA64MMFR2_CCIDX_64 (UL(0x1) << ID_AA64MMFR2_CCIDX_SHIFT)1445#define ID_AA64MMFR2_CCIDX_64 (UL(0x1) << ID_AA64MMFR2_CCIDX_SHIFT)
1271#define ID_AA64MMFR2_NV_SHIFT 241446#define ID_AA64MMFR2_NV_SHIFT 24
1447#define ID_AA64MMFR2_NV_WIDTH 4
1272#define ID_AA64MMFR2_NV_MASK (UL(0xf) << ID_AA64MMFR2_NV_SHIFT)1448#define ID_AA64MMFR2_NV_MASK (UL(0xf) << ID_AA64MMFR2_NV_SHIFT)
1273#define ID_AA64MMFR2_NV_VAL(x) ((x) & ID_AA64MMFR2_NV_MASK)1449#define ID_AA64MMFR2_NV_VAL(x) ((x) & ID_AA64MMFR2_NV_MASK)
1274#define ID_AA64MMFR2_NV_NONE (UL(0x0) << ID_AA64MMFR2_NV_SHIFT)1450#define ID_AA64MMFR2_NV_NONE (UL(0x0) << ID_AA64MMFR2_NV_SHIFT)
1275#define ID_AA64MMFR2_NV_8_3 (UL(0x1) << ID_AA64MMFR2_NV_SHIFT)1451#define ID_AA64MMFR2_NV_8_3 (UL(0x1) << ID_AA64MMFR2_NV_SHIFT)
1276#define ID_AA64MMFR2_NV_8_4 (UL(0x2) << ID_AA64MMFR2_NV_SHIFT)1452#define ID_AA64MMFR2_NV_8_4 (UL(0x2) << ID_AA64MMFR2_NV_SHIFT)
1277#define ID_AA64MMFR2_ST_SHIFT 281453#define ID_AA64MMFR2_ST_SHIFT 28
1454#define ID_AA64MMFR2_ST_WIDTH 4
1278#define ID_AA64MMFR2_ST_MASK (UL(0xf) << ID_AA64MMFR2_ST_SHIFT)1455#define ID_AA64MMFR2_ST_MASK (UL(0xf) << ID_AA64MMFR2_ST_SHIFT)
1279#define ID_AA64MMFR2_ST_VAL(x) ((x) & ID_AA64MMFR2_ST_MASK)1456#define ID_AA64MMFR2_ST_VAL(x) ((x) & ID_AA64MMFR2_ST_MASK)
1280#define ID_AA64MMFR2_ST_NONE (UL(0x0) << ID_AA64MMFR2_ST_SHIFT)1457#define ID_AA64MMFR2_ST_NONE (UL(0x0) << ID_AA64MMFR2_ST_SHIFT)
1281#define ID_AA64MMFR2_ST_IMPL (UL(0x1) << ID_AA64MMFR2_ST_SHIFT)1458#define ID_AA64MMFR2_ST_IMPL (UL(0x1) << ID_AA64MMFR2_ST_SHIFT)
1282#define ID_AA64MMFR2_AT_SHIFT 321459#define ID_AA64MMFR2_AT_SHIFT 32
1460#define ID_AA64MMFR2_AT_WIDTH 4
1283#define ID_AA64MMFR2_AT_MASK (UL(0xf) << ID_AA64MMFR2_AT_SHIFT)1461#define ID_AA64MMFR2_AT_MASK (UL(0xf) << ID_AA64MMFR2_AT_SHIFT)
1284#define ID_AA64MMFR2_AT_VAL(x) ((x) & ID_AA64MMFR2_AT_MASK)1462#define ID_AA64MMFR2_AT_VAL(x) ((x) & ID_AA64MMFR2_AT_MASK)
1285#define ID_AA64MMFR2_AT_NONE (UL(0x0) << ID_AA64MMFR2_AT_SHIFT)1463#define ID_AA64MMFR2_AT_NONE (UL(0x0) << ID_AA64MMFR2_AT_SHIFT)
1286#define ID_AA64MMFR2_AT_IMPL (UL(0x1) << ID_AA64MMFR2_AT_SHIFT)1464#define ID_AA64MMFR2_AT_IMPL (UL(0x1) << ID_AA64MMFR2_AT_SHIFT)
1287#define ID_AA64MMFR2_IDS_SHIFT 361465#define ID_AA64MMFR2_IDS_SHIFT 36
1466#define ID_AA64MMFR2_IDS_WIDTH 4
1288#define ID_AA64MMFR2_IDS_MASK (UL(0xf) << ID_AA64MMFR2_IDS_SHIFT)1467#define ID_AA64MMFR2_IDS_MASK (UL(0xf) << ID_AA64MMFR2_IDS_SHIFT)
1289#define ID_AA64MMFR2_IDS_VAL(x) ((x) & ID_AA64MMFR2_IDS_MASK)1468#define ID_AA64MMFR2_IDS_VAL(x) ((x) & ID_AA64MMFR2_IDS_MASK)
1290#define ID_AA64MMFR2_IDS_NONE (UL(0x0) << ID_AA64MMFR2_IDS_SHIFT)1469#define ID_AA64MMFR2_IDS_NONE (UL(0x0) << ID_AA64MMFR2_IDS_SHIFT)
1291#define ID_AA64MMFR2_IDS_IMPL (UL(0x1) << ID_AA64MMFR2_IDS_SHIFT)1470#define ID_AA64MMFR2_IDS_IMPL (UL(0x1) << ID_AA64MMFR2_IDS_SHIFT)
1292#define ID_AA64MMFR2_FWB_SHIFT 401471#define ID_AA64MMFR2_FWB_SHIFT 40
1472#define ID_AA64MMFR2_FWB_WIDTH 4
1293#define ID_AA64MMFR2_FWB_MASK (UL(0xf) << ID_AA64MMFR2_FWB_SHIFT)1473#define ID_AA64MMFR2_FWB_MASK (UL(0xf) << ID_AA64MMFR2_FWB_SHIFT)
1294#define ID_AA64MMFR2_FWB_VAL(x) ((x) & ID_AA64MMFR2_FWB_MASK)1474#define ID_AA64MMFR2_FWB_VAL(x) ((x) & ID_AA64MMFR2_FWB_MASK)
1295#define ID_AA64MMFR2_FWB_NONE (UL(0x0) << ID_AA64MMFR2_FWB_SHIFT)1475#define ID_AA64MMFR2_FWB_NONE (UL(0x0) << ID_AA64MMFR2_FWB_SHIFT)
1296#define ID_AA64MMFR2_FWB_IMPL (UL(0x1) << ID_AA64MMFR2_FWB_SHIFT)1476#define ID_AA64MMFR2_FWB_IMPL (UL(0x1) << ID_AA64MMFR2_FWB_SHIFT)
1297#define ID_AA64MMFR2_TTL_SHIFT 481477#define ID_AA64MMFR2_TTL_SHIFT 48
1478#define ID_AA64MMFR2_TTL_WIDTH 4
1298#define ID_AA64MMFR2_TTL_MASK (UL(0xf) << ID_AA64MMFR2_TTL_SHIFT)1479#define ID_AA64MMFR2_TTL_MASK (UL(0xf) << ID_AA64MMFR2_TTL_SHIFT)
1299#define ID_AA64MMFR2_TTL_VAL(x) ((x) & ID_AA64MMFR2_TTL_MASK)1480#define ID_AA64MMFR2_TTL_VAL(x) ((x) & ID_AA64MMFR2_TTL_MASK)
1300#define ID_AA64MMFR2_TTL_NONE (UL(0x0) << ID_AA64MMFR2_TTL_SHIFT)1481#define ID_AA64MMFR2_TTL_NONE (UL(0x0) << ID_AA64MMFR2_TTL_SHIFT)
1301#define ID_AA64MMFR2_TTL_IMPL (UL(0x1) << ID_AA64MMFR2_TTL_SHIFT)1482#define ID_AA64MMFR2_TTL_IMPL (UL(0x1) << ID_AA64MMFR2_TTL_SHIFT)
1302#define ID_AA64MMFR2_BBM_SHIFT 521483#define ID_AA64MMFR2_BBM_SHIFT 52
1484#define ID_AA64MMFR2_BBM_WIDTH 4
1303#define ID_AA64MMFR2_BBM_MASK (UL(0xf) << ID_AA64MMFR2_BBM_SHIFT)1485#define ID_AA64MMFR2_BBM_MASK (UL(0xf) << ID_AA64MMFR2_BBM_SHIFT)
1304#define ID_AA64MMFR2_BBM_VAL(x) ((x) & ID_AA64MMFR2_BBM_MASK)1486#define ID_AA64MMFR2_BBM_VAL(x) ((x) & ID_AA64MMFR2_BBM_MASK)
1305#define ID_AA64MMFR2_BBM_LEVEL0 (UL(0x0) << ID_AA64MMFR2_BBM_SHIFT)1487#define ID_AA64MMFR2_BBM_LEVEL0 (UL(0x0) << ID_AA64MMFR2_BBM_SHIFT)
1306#define ID_AA64MMFR2_BBM_LEVEL1 (UL(0x1) << ID_AA64MMFR2_BBM_SHIFT)1488#define ID_AA64MMFR2_BBM_LEVEL1 (UL(0x1) << ID_AA64MMFR2_BBM_SHIFT)
1307#define ID_AA64MMFR2_BBM_LEVEL2 (UL(0x2) << ID_AA64MMFR2_BBM_SHIFT)1489#define ID_AA64MMFR2_BBM_LEVEL2 (UL(0x2) << ID_AA64MMFR2_BBM_SHIFT)
1308#define ID_AA64MMFR2_EVT_SHIFT 561490#define ID_AA64MMFR2_EVT_SHIFT 56
1491#define ID_AA64MMFR2_EVT_WIDTH 4
1309#define ID_AA64MMFR2_EVT_MASK (UL(0xf) << ID_AA64MMFR2_EVT_SHIFT)1492#define ID_AA64MMFR2_EVT_MASK (UL(0xf) << ID_AA64MMFR2_EVT_SHIFT)
1310#define ID_AA64MMFR2_EVT_VAL(x) ((x) & ID_AA64MMFR2_EVT_MASK)1493#define ID_AA64MMFR2_EVT_VAL(x) ((x) & ID_AA64MMFR2_EVT_MASK)
1311#define ID_AA64MMFR2_EVT_NONE (UL(0x0) << ID_AA64MMFR2_EVT_SHIFT)1494#define ID_AA64MMFR2_EVT_NONE (UL(0x0) << ID_AA64MMFR2_EVT_SHIFT)
1312#define ID_AA64MMFR2_EVT_8_2 (UL(0x1) << ID_AA64MMFR2_EVT_SHIFT)1495#define ID_AA64MMFR2_EVT_8_2 (UL(0x1) << ID_AA64MMFR2_EVT_SHIFT)
1313#define ID_AA64MMFR2_EVT_8_5 (UL(0x2) << ID_AA64MMFR2_EVT_SHIFT)1496#define ID_AA64MMFR2_EVT_8_5 (UL(0x2) << ID_AA64MMFR2_EVT_SHIFT)
1314#define ID_AA64MMFR2_E0PD_SHIFT 601497#define ID_AA64MMFR2_E0PD_SHIFT 60
1498#define ID_AA64MMFR2_E0PD_WIDTH 4
1315#define ID_AA64MMFR2_E0PD_MASK (UL(0xf) << ID_AA64MMFR2_E0PD_SHIFT)1499#define ID_AA64MMFR2_E0PD_MASK (UL(0xf) << ID_AA64MMFR2_E0PD_SHIFT)
1316#define ID_AA64MMFR2_E0PD_VAL(x) ((x) & ID_AA64MMFR2_E0PD_MASK)1500#define ID_AA64MMFR2_E0PD_VAL(x) ((x) & ID_AA64MMFR2_E0PD_MASK)
1317#define ID_AA64MMFR2_E0PD_NONE (UL(0x0) << ID_AA64MMFR2_E0PD_SHIFT)1501#define ID_AA64MMFR2_E0PD_NONE (UL(0x0) << ID_AA64MMFR2_E0PD_SHIFT)
1318#define ID_AA64MMFR2_E0PD_IMPL (UL(0x1) << ID_AA64MMFR2_E0PD_SHIFT)1502#define ID_AA64MMFR2_E0PD_IMPL (UL(0x1) << ID_AA64MMFR2_E0PD_SHIFT)
13191503
1320/* ID_AA64MMFR3_EL1 */1504/* ID_AA64MMFR3_EL1 */
1321#define ID_AA64MMFR3_EL1 MRS_REG(ID_AA64MMFR3_EL1)
1322#define ID_AA64MMFR3_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR3_EL1)1505#define ID_AA64MMFR3_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR3_EL1)
1506#define ID_AA64MMFR3_EL1_ISS ISS_MSR_REG(ID_AA64MMFR3_EL1)
1323#define ID_AA64MMFR3_EL1_op0 31507#define ID_AA64MMFR3_EL1_op0 3
1324#define ID_AA64MMFR3_EL1_op1 01508#define ID_AA64MMFR3_EL1_op1 0
1325#define ID_AA64MMFR3_EL1_CRn 01509#define ID_AA64MMFR3_EL1_CRn 0
1326#define ID_AA64MMFR3_EL1_CRm 71510#define ID_AA64MMFR3_EL1_CRm 7
1327#define ID_AA64MMFR3_EL1_op2 31511#define ID_AA64MMFR3_EL1_op2 3
1328#define ID_AA64MMFR3_TCRX_SHIFT 01512#define ID_AA64MMFR3_TCRX_SHIFT 0
1513#define ID_AA64MMFR3_TCRX_WIDTH 4
1329#define ID_AA64MMFR3_TCRX_MASK (UL(0xf) << ID_AA64MMFR3_TCRX_SHIFT)1514#define ID_AA64MMFR3_TCRX_MASK (UL(0xf) << ID_AA64MMFR3_TCRX_SHIFT)
1330#define ID_AA64MMFR3_TCRX_VAL(x) ((x) & ID_AA64MMFR3_TCRX_MASK)1515#define ID_AA64MMFR3_TCRX_VAL(x) ((x) & ID_AA64MMFR3_TCRX_MASK)
1331#define ID_AA64MMFR3_TCRX_NONE (UL(0x0) << ID_AA64MMFR3_TCRX_SHIFT)1516#define ID_AA64MMFR3_TCRX_NONE (UL(0x0) << ID_AA64MMFR3_TCRX_SHIFT)
1332#define ID_AA64MMFR3_TCRX_IMPL (UL(0x1) << ID_AA64MMFR3_TCRX_SHIFT)1517#define ID_AA64MMFR3_TCRX_IMPL (UL(0x1) << ID_AA64MMFR3_TCRX_SHIFT)
1333#define ID_AA64MMFR3_SCTLRX_SHIFT 41518#define ID_AA64MMFR3_SCTLRX_SHIFT 4
1519#define ID_AA64MMFR3_SCTLRX_WIDTH 4
1334#define ID_AA64MMFR3_SCTLRX_MASK (UL(0xf) << ID_AA64MMFR3_SCTLRX_SHIFT)1520#define ID_AA64MMFR3_SCTLRX_MASK (UL(0xf) << ID_AA64MMFR3_SCTLRX_SHIFT)
1335#define ID_AA64MMFR3_SCTLRX_VAL(x) ((x) & ID_AA64MMFR3_SCTLRX_MASK)1521#define ID_AA64MMFR3_SCTLRX_VAL(x) ((x) & ID_AA64MMFR3_SCTLRX_MASK)
1336#define ID_AA64MMFR3_SCTLRX_NONE (UL(0x0) << ID_AA64MMFR3_SCTLRX_SHIFT)1522#define ID_AA64MMFR3_SCTLRX_NONE (UL(0x0) << ID_AA64MMFR3_SCTLRX_SHIFT)
1337#define ID_AA64MMFR3_SCTLRX_IMPL (UL(0x1) << ID_AA64MMFR3_SCTLRX_SHIFT)1523#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)
1338#define ID_AA64MMFR3_MEC_SHIFT 281554#define ID_AA64MMFR3_MEC_SHIFT 28
1555#define ID_AA64MMFR3_MEC_WIDTH 4
1339#define ID_AA64MMFR3_MEC_MASK (UL(0xf) << ID_AA64MMFR3_MEC_SHIFT)1556#define ID_AA64MMFR3_MEC_MASK (UL(0xf) << ID_AA64MMFR3_MEC_SHIFT)
1340#define ID_AA64MMFR3_MEC_VAL(x) ((x) & ID_AA64MMFR3_MEC_MASK)1557#define ID_AA64MMFR3_MEC_VAL(x) ((x) & ID_AA64MMFR3_MEC_MASK)
1341#define ID_AA64MMFR3_MEC_NONE (UL(0x0) << ID_AA64MMFR3_MEC_SHIFT)1558#define ID_AA64MMFR3_MEC_NONE (UL(0x0) << ID_AA64MMFR3_MEC_SHIFT)
1342#define ID_AA64MMFR3_MEC_IMPL (UL(0x1) << ID_AA64MMFR3_MEC_SHIFT)1559#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)
1343#define ID_AA64MMFR3_Spec_FPACC_SHIFT 601584#define ID_AA64MMFR3_Spec_FPACC_SHIFT 60
1585#define ID_AA64MMFR3_Spec_FPACC_WIDTH 4
1344#define ID_AA64MMFR3_Spec_FPACC_MASK (UL(0xf) << ID_AA64MMFR3_Spec_FPACC_SHIFT)1586#define ID_AA64MMFR3_Spec_FPACC_MASK (UL(0xf) << ID_AA64MMFR3_Spec_FPACC_SHIFT)
1345#define ID_AA64MMFR3_Spec_FPACC_VAL(x) ((x) & ID_AA64MMFR3_Spec_FPACC_MASK)1587#define ID_AA64MMFR3_Spec_FPACC_VAL(x) ((x) & ID_AA64MMFR3_Spec_FPACC_MASK)
1346#define ID_AA64MMFR3_Spec_FPACC_NONE (UL(0x0) << ID_AA64MMFR3_Spec_FPACC_SHIFT)1588#define ID_AA64MMFR3_Spec_FPACC_NONE (UL(0x0) << ID_AA64MMFR3_Spec_FPACC_SHIFT)
1347#define ID_AA64MMFR3_Spec_FPACC_IMPL (UL(0x1) << ID_AA64MMFR3_Spec_FPACC_SHIFT)1589#define ID_AA64MMFR3_Spec_FPACC_IMPL (UL(0x1) << ID_AA64MMFR3_Spec_FPACC_SHIFT)
13481590
1349/* ID_AA64MMFR4_EL1 */1591/* ID_AA64MMFR4_EL1 */
1350#define ID_AA64MMFR4_EL1 MRS_REG(ID_AA64MMFR4_EL1)
1351#define ID_AA64MMFR4_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR4_EL1)1592#define ID_AA64MMFR4_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR4_EL1)
1593#define ID_AA64MMFR4_EL1_ISS ISS_MSR_REG(ID_AA64MMFR4_EL1)
1352#define ID_AA64MMFR4_EL1_op0 31594#define ID_AA64MMFR4_EL1_op0 3
1353#define ID_AA64MMFR4_EL1_op1 01595#define ID_AA64MMFR4_EL1_op1 0
1354#define ID_AA64MMFR4_EL1_CRn 01596#define ID_AA64MMFR4_EL1_CRn 0
...@@ -1356,42 +1598,48 @@...@@ -1356,42 +1598,48 @@
1356#define ID_AA64MMFR4_EL1_op2 41598#define ID_AA64MMFR4_EL1_op2 4
13571599
1358/* ID_AA64PFR0_EL1 */1600/* ID_AA64PFR0_EL1 */
1359#define ID_AA64PFR0_EL1 MRS_REG(ID_AA64PFR0_EL1)
1360#define ID_AA64PFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR0_EL1)1601#define ID_AA64PFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR0_EL1)
1602#define ID_AA64PFR0_EL1_ISS ISS_MSR_REG(ID_AA64PFR0_EL1)
1361#define ID_AA64PFR0_EL1_op0 31603#define ID_AA64PFR0_EL1_op0 3
1362#define ID_AA64PFR0_EL1_op1 01604#define ID_AA64PFR0_EL1_op1 0
1363#define ID_AA64PFR0_EL1_CRn 01605#define ID_AA64PFR0_EL1_CRn 0
1364#define ID_AA64PFR0_EL1_CRm 41606#define ID_AA64PFR0_EL1_CRm 4
1365#define ID_AA64PFR0_EL1_op2 01607#define ID_AA64PFR0_EL1_op2 0
1366#define ID_AA64PFR0_EL0_SHIFT 01608#define ID_AA64PFR0_EL0_SHIFT 0
1609#define ID_AA64PFR0_EL0_WIDTH 4
1367#define ID_AA64PFR0_EL0_MASK (UL(0xf) << ID_AA64PFR0_EL0_SHIFT)1610#define ID_AA64PFR0_EL0_MASK (UL(0xf) << ID_AA64PFR0_EL0_SHIFT)
1368#define ID_AA64PFR0_EL0_VAL(x) ((x) & ID_AA64PFR0_EL0_MASK)1611#define ID_AA64PFR0_EL0_VAL(x) ((x) & ID_AA64PFR0_EL0_MASK)
1369#define ID_AA64PFR0_EL0_64 (UL(0x1) << ID_AA64PFR0_EL0_SHIFT)1612#define ID_AA64PFR0_EL0_64 (UL(0x1) << ID_AA64PFR0_EL0_SHIFT)
1370#define ID_AA64PFR0_EL0_64_32 (UL(0x2) << ID_AA64PFR0_EL0_SHIFT)1613#define ID_AA64PFR0_EL0_64_32 (UL(0x2) << ID_AA64PFR0_EL0_SHIFT)
1371#define ID_AA64PFR0_EL1_SHIFT 41614#define ID_AA64PFR0_EL1_SHIFT 4
1615#define ID_AA64PFR0_EL1_WIDTH 4
1372#define ID_AA64PFR0_EL1_MASK (UL(0xf) << ID_AA64PFR0_EL1_SHIFT)1616#define ID_AA64PFR0_EL1_MASK (UL(0xf) << ID_AA64PFR0_EL1_SHIFT)
1373#define ID_AA64PFR0_EL1_VAL(x) ((x) & ID_AA64PFR0_EL1_MASK)1617#define ID_AA64PFR0_EL1_VAL(x) ((x) & ID_AA64PFR0_EL1_MASK)
1374#define ID_AA64PFR0_EL1_64 (UL(0x1) << ID_AA64PFR0_EL1_SHIFT)1618#define ID_AA64PFR0_EL1_64 (UL(0x1) << ID_AA64PFR0_EL1_SHIFT)
1375#define ID_AA64PFR0_EL1_64_32 (UL(0x2) << ID_AA64PFR0_EL1_SHIFT)1619#define ID_AA64PFR0_EL1_64_32 (UL(0x2) << ID_AA64PFR0_EL1_SHIFT)
1376#define ID_AA64PFR0_EL2_SHIFT 81620#define ID_AA64PFR0_EL2_SHIFT 8
1621#define ID_AA64PFR0_EL2_WIDTH 4
1377#define ID_AA64PFR0_EL2_MASK (UL(0xf) << ID_AA64PFR0_EL2_SHIFT)1622#define ID_AA64PFR0_EL2_MASK (UL(0xf) << ID_AA64PFR0_EL2_SHIFT)
1378#define ID_AA64PFR0_EL2_VAL(x) ((x) & ID_AA64PFR0_EL2_MASK)1623#define ID_AA64PFR0_EL2_VAL(x) ((x) & ID_AA64PFR0_EL2_MASK)
1379#define ID_AA64PFR0_EL2_NONE (UL(0x0) << ID_AA64PFR0_EL2_SHIFT)1624#define ID_AA64PFR0_EL2_NONE (UL(0x0) << ID_AA64PFR0_EL2_SHIFT)
1380#define ID_AA64PFR0_EL2_64 (UL(0x1) << ID_AA64PFR0_EL2_SHIFT)1625#define ID_AA64PFR0_EL2_64 (UL(0x1) << ID_AA64PFR0_EL2_SHIFT)
1381#define ID_AA64PFR0_EL2_64_32 (UL(0x2) << ID_AA64PFR0_EL2_SHIFT)1626#define ID_AA64PFR0_EL2_64_32 (UL(0x2) << ID_AA64PFR0_EL2_SHIFT)
1382#define ID_AA64PFR0_EL3_SHIFT 121627#define ID_AA64PFR0_EL3_SHIFT 12
1628#define ID_AA64PFR0_EL3_WIDTH 4
1383#define ID_AA64PFR0_EL3_MASK (UL(0xf) << ID_AA64PFR0_EL3_SHIFT)1629#define ID_AA64PFR0_EL3_MASK (UL(0xf) << ID_AA64PFR0_EL3_SHIFT)
1384#define ID_AA64PFR0_EL3_VAL(x) ((x) & ID_AA64PFR0_EL3_MASK)1630#define ID_AA64PFR0_EL3_VAL(x) ((x) & ID_AA64PFR0_EL3_MASK)
1385#define ID_AA64PFR0_EL3_NONE (UL(0x0) << ID_AA64PFR0_EL3_SHIFT)1631#define ID_AA64PFR0_EL3_NONE (UL(0x0) << ID_AA64PFR0_EL3_SHIFT)
1386#define ID_AA64PFR0_EL3_64 (UL(0x1) << ID_AA64PFR0_EL3_SHIFT)1632#define ID_AA64PFR0_EL3_64 (UL(0x1) << ID_AA64PFR0_EL3_SHIFT)
1387#define ID_AA64PFR0_EL3_64_32 (UL(0x2) << ID_AA64PFR0_EL3_SHIFT)1633#define ID_AA64PFR0_EL3_64_32 (UL(0x2) << ID_AA64PFR0_EL3_SHIFT)
1388#define ID_AA64PFR0_FP_SHIFT 161634#define ID_AA64PFR0_FP_SHIFT 16
1635#define ID_AA64PFR0_FP_WIDTH 4
1389#define ID_AA64PFR0_FP_MASK (UL(0xf) << ID_AA64PFR0_FP_SHIFT)1636#define ID_AA64PFR0_FP_MASK (UL(0xf) << ID_AA64PFR0_FP_SHIFT)
1390#define ID_AA64PFR0_FP_VAL(x) ((x) & ID_AA64PFR0_FP_MASK)1637#define ID_AA64PFR0_FP_VAL(x) ((x) & ID_AA64PFR0_FP_MASK)
1391#define ID_AA64PFR0_FP_IMPL (UL(0x0) << ID_AA64PFR0_FP_SHIFT)1638#define ID_AA64PFR0_FP_IMPL (UL(0x0) << ID_AA64PFR0_FP_SHIFT)
1392#define ID_AA64PFR0_FP_HP (UL(0x1) << ID_AA64PFR0_FP_SHIFT)1639#define ID_AA64PFR0_FP_HP (UL(0x1) << ID_AA64PFR0_FP_SHIFT)
1393#define ID_AA64PFR0_FP_NONE (UL(0xf) << ID_AA64PFR0_FP_SHIFT)1640#define ID_AA64PFR0_FP_NONE (UL(0xf) << ID_AA64PFR0_FP_SHIFT)
1394#define ID_AA64PFR0_AdvSIMD_SHIFT 201641#define ID_AA64PFR0_AdvSIMD_SHIFT 20
1642#define ID_AA64PFR0_AdvSIMD_WIDTH 4
1395#define ID_AA64PFR0_AdvSIMD_MASK (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT)1643#define ID_AA64PFR0_AdvSIMD_MASK (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT)
1396#define ID_AA64PFR0_AdvSIMD_VAL(x) ((x) & ID_AA64PFR0_AdvSIMD_MASK)1644#define ID_AA64PFR0_AdvSIMD_VAL(x) ((x) & ID_AA64PFR0_AdvSIMD_MASK)
1397#define ID_AA64PFR0_AdvSIMD_IMPL (UL(0x0) << ID_AA64PFR0_AdvSIMD_SHIFT)1645#define ID_AA64PFR0_AdvSIMD_IMPL (UL(0x0) << ID_AA64PFR0_AdvSIMD_SHIFT)
...@@ -1399,49 +1647,59 @@...@@ -1399,49 +1647,59 @@
1399#define ID_AA64PFR0_AdvSIMD_NONE (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT)1647#define ID_AA64PFR0_AdvSIMD_NONE (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT)
1400#define ID_AA64PFR0_GIC_BITS 0x4 /* Number of bits in GIC field */1648#define ID_AA64PFR0_GIC_BITS 0x4 /* Number of bits in GIC field */
1401#define ID_AA64PFR0_GIC_SHIFT 241649#define ID_AA64PFR0_GIC_SHIFT 24
1650#define ID_AA64PFR0_GIC_WIDTH 4
1402#define ID_AA64PFR0_GIC_MASK (UL(0xf) << ID_AA64PFR0_GIC_SHIFT)1651#define ID_AA64PFR0_GIC_MASK (UL(0xf) << ID_AA64PFR0_GIC_SHIFT)
1403#define ID_AA64PFR0_GIC_VAL(x) ((x) & ID_AA64PFR0_GIC_MASK)1652#define ID_AA64PFR0_GIC_VAL(x) ((x) & ID_AA64PFR0_GIC_MASK)
1404#define ID_AA64PFR0_GIC_CPUIF_NONE (UL(0x0) << ID_AA64PFR0_GIC_SHIFT)1653#define ID_AA64PFR0_GIC_CPUIF_NONE (UL(0x0) << ID_AA64PFR0_GIC_SHIFT)
1405#define ID_AA64PFR0_GIC_CPUIF_EN (UL(0x1) << ID_AA64PFR0_GIC_SHIFT)1654#define ID_AA64PFR0_GIC_CPUIF_EN (UL(0x1) << ID_AA64PFR0_GIC_SHIFT)
1406#define ID_AA64PFR0_GIC_CPUIF_4_1 (UL(0x3) << ID_AA64PFR0_GIC_SHIFT)1655#define ID_AA64PFR0_GIC_CPUIF_4_1 (UL(0x3) << ID_AA64PFR0_GIC_SHIFT)
1407#define ID_AA64PFR0_RAS_SHIFT 281656#define ID_AA64PFR0_RAS_SHIFT 28
1657#define ID_AA64PFR0_RAS_WIDTH 4
1408#define ID_AA64PFR0_RAS_MASK (UL(0xf) << ID_AA64PFR0_RAS_SHIFT)1658#define ID_AA64PFR0_RAS_MASK (UL(0xf) << ID_AA64PFR0_RAS_SHIFT)
1409#define ID_AA64PFR0_RAS_VAL(x) ((x) & ID_AA64PFR0_RAS_MASK)1659#define ID_AA64PFR0_RAS_VAL(x) ((x) & ID_AA64PFR0_RAS_MASK)
1410#define ID_AA64PFR0_RAS_NONE (UL(0x0) << ID_AA64PFR0_RAS_SHIFT)1660#define ID_AA64PFR0_RAS_NONE (UL(0x0) << ID_AA64PFR0_RAS_SHIFT)
1411#define ID_AA64PFR0_RAS_IMPL (UL(0x1) << ID_AA64PFR0_RAS_SHIFT)1661#define ID_AA64PFR0_RAS_IMPL (UL(0x1) << ID_AA64PFR0_RAS_SHIFT)
1412#define ID_AA64PFR0_RAS_8_4 (UL(0x2) << ID_AA64PFR0_RAS_SHIFT)1662#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)
1413#define ID_AA64PFR0_SVE_SHIFT 321664#define ID_AA64PFR0_SVE_SHIFT 32
1665#define ID_AA64PFR0_SVE_WIDTH 4
1414#define ID_AA64PFR0_SVE_MASK (UL(0xf) << ID_AA64PFR0_SVE_SHIFT)1666#define ID_AA64PFR0_SVE_MASK (UL(0xf) << ID_AA64PFR0_SVE_SHIFT)
1415#define ID_AA64PFR0_SVE_VAL(x) ((x) & ID_AA64PFR0_SVE_MASK)1667#define ID_AA64PFR0_SVE_VAL(x) ((x) & ID_AA64PFR0_SVE_MASK)
1416#define ID_AA64PFR0_SVE_NONE (UL(0x0) << ID_AA64PFR0_SVE_SHIFT)1668#define ID_AA64PFR0_SVE_NONE (UL(0x0) << ID_AA64PFR0_SVE_SHIFT)
1417#define ID_AA64PFR0_SVE_IMPL (UL(0x1) << ID_AA64PFR0_SVE_SHIFT)1669#define ID_AA64PFR0_SVE_IMPL (UL(0x1) << ID_AA64PFR0_SVE_SHIFT)
1418#define ID_AA64PFR0_SEL2_SHIFT 361670#define ID_AA64PFR0_SEL2_SHIFT 36
1671#define ID_AA64PFR0_SEL2_WIDTH 4
1419#define ID_AA64PFR0_SEL2_MASK (UL(0xf) << ID_AA64PFR0_SEL2_SHIFT)1672#define ID_AA64PFR0_SEL2_MASK (UL(0xf) << ID_AA64PFR0_SEL2_SHIFT)
1420#define ID_AA64PFR0_SEL2_VAL(x) ((x) & ID_AA64PFR0_SEL2_MASK)1673#define ID_AA64PFR0_SEL2_VAL(x) ((x) & ID_AA64PFR0_SEL2_MASK)
1421#define ID_AA64PFR0_SEL2_NONE (UL(0x0) << ID_AA64PFR0_SEL2_SHIFT)1674#define ID_AA64PFR0_SEL2_NONE (UL(0x0) << ID_AA64PFR0_SEL2_SHIFT)
1422#define ID_AA64PFR0_SEL2_IMPL (UL(0x1) << ID_AA64PFR0_SEL2_SHIFT)1675#define ID_AA64PFR0_SEL2_IMPL (UL(0x1) << ID_AA64PFR0_SEL2_SHIFT)
1423#define ID_AA64PFR0_MPAM_SHIFT 401676#define ID_AA64PFR0_MPAM_SHIFT 40
1677#define ID_AA64PFR0_MPAM_WIDTH 4
1424#define ID_AA64PFR0_MPAM_MASK (UL(0xf) << ID_AA64PFR0_MPAM_SHIFT)1678#define ID_AA64PFR0_MPAM_MASK (UL(0xf) << ID_AA64PFR0_MPAM_SHIFT)
1425#define ID_AA64PFR0_MPAM_VAL(x) ((x) & ID_AA64PFR0_MPAM_MASK)1679#define ID_AA64PFR0_MPAM_VAL(x) ((x) & ID_AA64PFR0_MPAM_MASK)
1426#define ID_AA64PFR0_MPAM_NONE (UL(0x0) << ID_AA64PFR0_MPAM_SHIFT)1680#define ID_AA64PFR0_MPAM_NONE (UL(0x0) << ID_AA64PFR0_MPAM_SHIFT)
1427#define ID_AA64PFR0_MPAM_IMPL (UL(0x1) << ID_AA64PFR0_MPAM_SHIFT)1681#define ID_AA64PFR0_MPAM_IMPL (UL(0x1) << ID_AA64PFR0_MPAM_SHIFT)
1428#define ID_AA64PFR0_AMU_SHIFT 441682#define ID_AA64PFR0_AMU_SHIFT 44
1683#define ID_AA64PFR0_AMU_WIDTH 4
1429#define ID_AA64PFR0_AMU_MASK (UL(0xf) << ID_AA64PFR0_AMU_SHIFT)1684#define ID_AA64PFR0_AMU_MASK (UL(0xf) << ID_AA64PFR0_AMU_SHIFT)
1430#define ID_AA64PFR0_AMU_VAL(x) ((x) & ID_AA64PFR0_AMU_MASK)1685#define ID_AA64PFR0_AMU_VAL(x) ((x) & ID_AA64PFR0_AMU_MASK)
1431#define ID_AA64PFR0_AMU_NONE (UL(0x0) << ID_AA64PFR0_AMU_SHIFT)1686#define ID_AA64PFR0_AMU_NONE (UL(0x0) << ID_AA64PFR0_AMU_SHIFT)
1432#define ID_AA64PFR0_AMU_V1 (UL(0x1) << ID_AA64PFR0_AMU_SHIFT)1687#define ID_AA64PFR0_AMU_V1 (UL(0x1) << ID_AA64PFR0_AMU_SHIFT)
1433#define ID_AA64PFR0_AMU_V1_1 (UL(0x2) << ID_AA64PFR0_AMU_SHIFT)1688#define ID_AA64PFR0_AMU_V1_1 (UL(0x2) << ID_AA64PFR0_AMU_SHIFT)
1434#define ID_AA64PFR0_DIT_SHIFT 481689#define ID_AA64PFR0_DIT_SHIFT 48
1690#define ID_AA64PFR0_DIT_WIDTH 4
1435#define ID_AA64PFR0_DIT_MASK (UL(0xf) << ID_AA64PFR0_DIT_SHIFT)1691#define ID_AA64PFR0_DIT_MASK (UL(0xf) << ID_AA64PFR0_DIT_SHIFT)
1436#define ID_AA64PFR0_DIT_VAL(x) ((x) & ID_AA64PFR0_DIT_MASK)1692#define ID_AA64PFR0_DIT_VAL(x) ((x) & ID_AA64PFR0_DIT_MASK)
1437#define ID_AA64PFR0_DIT_NONE (UL(0x0) << ID_AA64PFR0_DIT_SHIFT)1693#define ID_AA64PFR0_DIT_NONE (UL(0x0) << ID_AA64PFR0_DIT_SHIFT)
1438#define ID_AA64PFR0_DIT_PSTATE (UL(0x1) << ID_AA64PFR0_DIT_SHIFT)1694#define ID_AA64PFR0_DIT_PSTATE (UL(0x1) << ID_AA64PFR0_DIT_SHIFT)
1439#define ID_AA64PFR0_RME_SHIFT 521695#define ID_AA64PFR0_RME_SHIFT 52
1696#define ID_AA64PFR0_RME_WIDTH 4
1440#define ID_AA64PFR0_RME_MASK (UL(0xf) << ID_AA64PFR0_RME_SHIFT)1697#define ID_AA64PFR0_RME_MASK (UL(0xf) << ID_AA64PFR0_RME_SHIFT)
1441#define ID_AA64PFR0_RME_VAL(x) ((x) & ID_AA64PFR0_RME_MASK)1698#define ID_AA64PFR0_RME_VAL(x) ((x) & ID_AA64PFR0_RME_MASK)
1442#define ID_AA64PFR0_RME_NONE (UL(0x0) << ID_AA64PFR0_RME_SHIFT)1699#define ID_AA64PFR0_RME_NONE (UL(0x0) << ID_AA64PFR0_RME_SHIFT)
1443#define ID_AA64PFR0_RME_IMPL (UL(0x1) << ID_AA64PFR0_RME_SHIFT)1700#define ID_AA64PFR0_RME_IMPL (UL(0x1) << ID_AA64PFR0_RME_SHIFT)
1444#define ID_AA64PFR0_CSV2_SHIFT 561701#define ID_AA64PFR0_CSV2_SHIFT 56
1702#define ID_AA64PFR0_CSV2_WIDTH 4
1445#define ID_AA64PFR0_CSV2_MASK (UL(0xf) << ID_AA64PFR0_CSV2_SHIFT)1703#define ID_AA64PFR0_CSV2_MASK (UL(0xf) << ID_AA64PFR0_CSV2_SHIFT)
1446#define ID_AA64PFR0_CSV2_VAL(x) ((x) & ID_AA64PFR0_CSV2_MASK)1704#define ID_AA64PFR0_CSV2_VAL(x) ((x) & ID_AA64PFR0_CSV2_MASK)
1447#define ID_AA64PFR0_CSV2_NONE (UL(0x0) << ID_AA64PFR0_CSV2_SHIFT)1705#define ID_AA64PFR0_CSV2_NONE (UL(0x0) << ID_AA64PFR0_CSV2_SHIFT)
...@@ -1449,31 +1707,35 @@...@@ -1449,31 +1707,35 @@
1449#define ID_AA64PFR0_CSV2_SCXTNUM (UL(0x2) << ID_AA64PFR0_CSV2_SHIFT)1707#define ID_AA64PFR0_CSV2_SCXTNUM (UL(0x2) << ID_AA64PFR0_CSV2_SHIFT)
1450#define ID_AA64PFR0_CSV2_3 (UL(0x3) << ID_AA64PFR0_CSV2_SHIFT)1708#define ID_AA64PFR0_CSV2_3 (UL(0x3) << ID_AA64PFR0_CSV2_SHIFT)
1451#define ID_AA64PFR0_CSV3_SHIFT 601709#define ID_AA64PFR0_CSV3_SHIFT 60
1710#define ID_AA64PFR0_CSV3_WIDTH 4
1452#define ID_AA64PFR0_CSV3_MASK (UL(0xf) << ID_AA64PFR0_CSV3_SHIFT)1711#define ID_AA64PFR0_CSV3_MASK (UL(0xf) << ID_AA64PFR0_CSV3_SHIFT)
1453#define ID_AA64PFR0_CSV3_VAL(x) ((x) & ID_AA64PFR0_CSV3_MASK)1712#define ID_AA64PFR0_CSV3_VAL(x) ((x) & ID_AA64PFR0_CSV3_MASK)
1454#define ID_AA64PFR0_CSV3_NONE (UL(0x0) << ID_AA64PFR0_CSV3_SHIFT)1713#define ID_AA64PFR0_CSV3_NONE (UL(0x0) << ID_AA64PFR0_CSV3_SHIFT)
1455#define ID_AA64PFR0_CSV3_ISOLATED (UL(0x1) << ID_AA64PFR0_CSV3_SHIFT)1714#define ID_AA64PFR0_CSV3_ISOLATED (UL(0x1) << ID_AA64PFR0_CSV3_SHIFT)
14561715
1457/* ID_AA64PFR1_EL1 */1716/* ID_AA64PFR1_EL1 */
1458#define ID_AA64PFR1_EL1 MRS_REG(ID_AA64PFR1_EL1)
1459#define ID_AA64PFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR1_EL1)1717#define ID_AA64PFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR1_EL1)
1718#define ID_AA64PFR1_EL1_ISS ISS_MSR_REG(ID_AA64PFR1_EL1)
1460#define ID_AA64PFR1_EL1_op0 31719#define ID_AA64PFR1_EL1_op0 3
1461#define ID_AA64PFR1_EL1_op1 01720#define ID_AA64PFR1_EL1_op1 0
1462#define ID_AA64PFR1_EL1_CRn 01721#define ID_AA64PFR1_EL1_CRn 0
1463#define ID_AA64PFR1_EL1_CRm 41722#define ID_AA64PFR1_EL1_CRm 4
1464#define ID_AA64PFR1_EL1_op2 11723#define ID_AA64PFR1_EL1_op2 1
1465#define ID_AA64PFR1_BT_SHIFT 01724#define ID_AA64PFR1_BT_SHIFT 0
1725#define ID_AA64PFR1_BT_WIDTH 4
1466#define ID_AA64PFR1_BT_MASK (UL(0xf) << ID_AA64PFR1_BT_SHIFT)1726#define ID_AA64PFR1_BT_MASK (UL(0xf) << ID_AA64PFR1_BT_SHIFT)
1467#define ID_AA64PFR1_BT_VAL(x) ((x) & ID_AA64PFR1_BT_MASK)1727#define ID_AA64PFR1_BT_VAL(x) ((x) & ID_AA64PFR1_BT_MASK)
1468#define ID_AA64PFR1_BT_NONE (UL(0x0) << ID_AA64PFR1_BT_SHIFT)1728#define ID_AA64PFR1_BT_NONE (UL(0x0) << ID_AA64PFR1_BT_SHIFT)
1469#define ID_AA64PFR1_BT_IMPL (UL(0x1) << ID_AA64PFR1_BT_SHIFT)1729#define ID_AA64PFR1_BT_IMPL (UL(0x1) << ID_AA64PFR1_BT_SHIFT)
1470#define ID_AA64PFR1_SSBS_SHIFT 41730#define ID_AA64PFR1_SSBS_SHIFT 4
1731#define ID_AA64PFR1_SSBS_WIDTH 4
1471#define ID_AA64PFR1_SSBS_MASK (UL(0xf) << ID_AA64PFR1_SSBS_SHIFT)1732#define ID_AA64PFR1_SSBS_MASK (UL(0xf) << ID_AA64PFR1_SSBS_SHIFT)
1472#define ID_AA64PFR1_SSBS_VAL(x) ((x) & ID_AA64PFR1_SSBS_MASK)1733#define ID_AA64PFR1_SSBS_VAL(x) ((x) & ID_AA64PFR1_SSBS_MASK)
1473#define ID_AA64PFR1_SSBS_NONE (UL(0x0) << ID_AA64PFR1_SSBS_SHIFT)1734#define ID_AA64PFR1_SSBS_NONE (UL(0x0) << ID_AA64PFR1_SSBS_SHIFT)
1474#define ID_AA64PFR1_SSBS_PSTATE (UL(0x1) << ID_AA64PFR1_SSBS_SHIFT)1735#define ID_AA64PFR1_SSBS_PSTATE (UL(0x1) << ID_AA64PFR1_SSBS_SHIFT)
1475#define ID_AA64PFR1_SSBS_PSTATE_MSR (UL(0x2) << ID_AA64PFR1_SSBS_SHIFT)1736#define ID_AA64PFR1_SSBS_PSTATE_MSR (UL(0x2) << ID_AA64PFR1_SSBS_SHIFT)
1476#define ID_AA64PFR1_MTE_SHIFT 81737#define ID_AA64PFR1_MTE_SHIFT 8
1738#define ID_AA64PFR1_MTE_WIDTH 4
1477#define ID_AA64PFR1_MTE_MASK (UL(0xf) << ID_AA64PFR1_MTE_SHIFT)1739#define ID_AA64PFR1_MTE_MASK (UL(0xf) << ID_AA64PFR1_MTE_SHIFT)
1478#define ID_AA64PFR1_MTE_VAL(x) ((x) & ID_AA64PFR1_MTE_MASK)1740#define ID_AA64PFR1_MTE_VAL(x) ((x) & ID_AA64PFR1_MTE_MASK)
1479#define ID_AA64PFR1_MTE_NONE (UL(0x0) << ID_AA64PFR1_MTE_SHIFT)1741#define ID_AA64PFR1_MTE_NONE (UL(0x0) << ID_AA64PFR1_MTE_SHIFT)
...@@ -1481,41 +1743,77 @@...@@ -1481,41 +1743,77 @@
1481#define ID_AA64PFR1_MTE_MTE2 (UL(0x2) << ID_AA64PFR1_MTE_SHIFT)1743#define ID_AA64PFR1_MTE_MTE2 (UL(0x2) << ID_AA64PFR1_MTE_SHIFT)
1482#define ID_AA64PFR1_MTE_MTE3 (UL(0x3) << ID_AA64PFR1_MTE_SHIFT)1744#define ID_AA64PFR1_MTE_MTE3 (UL(0x3) << ID_AA64PFR1_MTE_SHIFT)
1483#define ID_AA64PFR1_RAS_frac_SHIFT 121745#define ID_AA64PFR1_RAS_frac_SHIFT 12
1746#define ID_AA64PFR1_RAS_frac_WIDTH 4
1484#define ID_AA64PFR1_RAS_frac_MASK (UL(0xf) << ID_AA64PFR1_RAS_frac_SHIFT)1747#define ID_AA64PFR1_RAS_frac_MASK (UL(0xf) << ID_AA64PFR1_RAS_frac_SHIFT)
1485#define ID_AA64PFR1_RAS_frac_VAL(x) ((x) & ID_AA64PFR1_RAS_frac_MASK)1748#define ID_AA64PFR1_RAS_frac_VAL(x) ((x) & ID_AA64PFR1_RAS_frac_MASK)
1486#define ID_AA64PFR1_RAS_frac_p0 (UL(0x0) << ID_AA64PFR1_RAS_frac_SHIFT)1749#define ID_AA64PFR1_RAS_frac_p0 (UL(0x0) << ID_AA64PFR1_RAS_frac_SHIFT)
1487#define ID_AA64PFR1_RAS_frac_p1 (UL(0x1) << ID_AA64PFR1_RAS_frac_SHIFT)1750#define ID_AA64PFR1_RAS_frac_p1 (UL(0x1) << ID_AA64PFR1_RAS_frac_SHIFT)
1488#define ID_AA64PFR1_MPAM_frac_SHIFT 161751#define ID_AA64PFR1_MPAM_frac_SHIFT 16
1752#define ID_AA64PFR1_MPAM_frac_WIDTH 4
1489#define ID_AA64PFR1_MPAM_frac_MASK (UL(0xf) << ID_AA64PFR1_MPAM_frac_SHIFT)1753#define ID_AA64PFR1_MPAM_frac_MASK (UL(0xf) << ID_AA64PFR1_MPAM_frac_SHIFT)
1490#define ID_AA64PFR1_MPAM_frac_VAL(x) ((x) & ID_AA64PFR1_MPAM_frac_MASK)1754#define ID_AA64PFR1_MPAM_frac_VAL(x) ((x) & ID_AA64PFR1_MPAM_frac_MASK)
1491#define ID_AA64PFR1_MPAM_frac_p0 (UL(0x0) << ID_AA64PFR1_MPAM_frac_SHIFT)1755#define ID_AA64PFR1_MPAM_frac_p0 (UL(0x0) << ID_AA64PFR1_MPAM_frac_SHIFT)
1492#define ID_AA64PFR1_MPAM_frac_p1 (UL(0x1) << ID_AA64PFR1_MPAM_frac_SHIFT)1756#define ID_AA64PFR1_MPAM_frac_p1 (UL(0x1) << ID_AA64PFR1_MPAM_frac_SHIFT)
1493#define ID_AA64PFR1_SME_SHIFT 241757#define ID_AA64PFR1_SME_SHIFT 24
1758#define ID_AA64PFR1_SME_WIDTH 4
1494#define ID_AA64PFR1_SME_MASK (UL(0xf) << ID_AA64PFR1_SME_SHIFT)1759#define ID_AA64PFR1_SME_MASK (UL(0xf) << ID_AA64PFR1_SME_SHIFT)
1495#define ID_AA64PFR1_SME_VAL(x) ((x) & ID_AA64PFR1_SME_MASK)1760#define ID_AA64PFR1_SME_VAL(x) ((x) & ID_AA64PFR1_SME_MASK)
1496#define ID_AA64PFR1_SME_NONE (UL(0x0) << ID_AA64PFR1_SME_SHIFT)1761#define ID_AA64PFR1_SME_NONE (UL(0x0) << ID_AA64PFR1_SME_SHIFT)
1497#define ID_AA64PFR1_SME_SME (UL(0x1) << ID_AA64PFR1_SME_SHIFT)1762#define ID_AA64PFR1_SME_SME (UL(0x1) << ID_AA64PFR1_SME_SHIFT)
1498#define ID_AA64PFR1_SME_SME2 (UL(0x2) << ID_AA64PFR1_SME_SHIFT)1763#define ID_AA64PFR1_SME_SME2 (UL(0x2) << ID_AA64PFR1_SME_SHIFT)
1499#define ID_AA64PFR1_RNDR_trap_SHIFT 281764#define ID_AA64PFR1_RNDR_trap_SHIFT 28
1765#define ID_AA64PFR1_RNDR_trap_WIDTH 4
1500#define ID_AA64PFR1_RNDR_trap_MASK (UL(0xf) << ID_AA64PFR1_RNDR_trap_SHIFT)1766#define ID_AA64PFR1_RNDR_trap_MASK (UL(0xf) << ID_AA64PFR1_RNDR_trap_SHIFT)
1501#define ID_AA64PFR1_RNDR_trap_VAL(x) ((x) & ID_AA64PFR1_RNDR_trap_MASK)1767#define ID_AA64PFR1_RNDR_trap_VAL(x) ((x) & ID_AA64PFR1_RNDR_trap_MASK)
1502#define ID_AA64PFR1_RNDR_trap_NONE (UL(0x0) << ID_AA64PFR1_RNDR_trap_SHIFT)1768#define ID_AA64PFR1_RNDR_trap_NONE (UL(0x0) << ID_AA64PFR1_RNDR_trap_SHIFT)
1503#define ID_AA64PFR1_RNDR_trap_IMPL (UL(0x1) << ID_AA64PFR1_RNDR_trap_SHIFT)1769#define ID_AA64PFR1_RNDR_trap_IMPL (UL(0x1) << ID_AA64PFR1_RNDR_trap_SHIFT)
1504#define ID_AA64PFR1_CSV2_frac_SHIFT 321770#define ID_AA64PFR1_CSV2_frac_SHIFT 32
1771#define ID_AA64PFR1_CSV2_frac_WIDTH 4
1505#define ID_AA64PFR1_CSV2_frac_MASK (UL(0xf) << ID_AA64PFR1_CSV2_frac_SHIFT)1772#define ID_AA64PFR1_CSV2_frac_MASK (UL(0xf) << ID_AA64PFR1_CSV2_frac_SHIFT)
1506#define ID_AA64PFR1_CSV2_frac_VAL(x) ((x) & ID_AA64PFR1_CSV2_frac_MASK)1773#define ID_AA64PFR1_CSV2_frac_VAL(x) ((x) & ID_AA64PFR1_CSV2_frac_MASK)
1507#define ID_AA64PFR1_CSV2_frac_p0 (UL(0x0) << ID_AA64PFR1_CSV2_frac_SHIFT)1774#define ID_AA64PFR1_CSV2_frac_p0 (UL(0x0) << ID_AA64PFR1_CSV2_frac_SHIFT)
1508#define ID_AA64PFR1_CSV2_frac_p1 (UL(0x1) << ID_AA64PFR1_CSV2_frac_SHIFT)1775#define ID_AA64PFR1_CSV2_frac_p1 (UL(0x1) << ID_AA64PFR1_CSV2_frac_SHIFT)
1509#define ID_AA64PFR1_CSV2_frac_p2 (UL(0x2) << ID_AA64PFR1_CSV2_frac_SHIFT)1776#define ID_AA64PFR1_CSV2_frac_p2 (UL(0x2) << ID_AA64PFR1_CSV2_frac_SHIFT)
1510#define ID_AA64PFR1_NMI_SHIFT 361777#define ID_AA64PFR1_NMI_SHIFT 36
1778#define ID_AA64PFR1_NMI_WIDTH 4
1511#define ID_AA64PFR1_NMI_MASK (UL(0xf) << ID_AA64PFR1_NMI_SHIFT)1779#define ID_AA64PFR1_NMI_MASK (UL(0xf) << ID_AA64PFR1_NMI_SHIFT)
1512#define ID_AA64PFR1_NMI_VAL(x) ((x) & ID_AA64PFR1_NMI_MASK)1780#define ID_AA64PFR1_NMI_VAL(x) ((x) & ID_AA64PFR1_NMI_MASK)
1513#define ID_AA64PFR1_NMI_NONE (UL(0x0) << ID_AA64PFR1_NMI_SHIFT)1781#define ID_AA64PFR1_NMI_NONE (UL(0x0) << ID_AA64PFR1_NMI_SHIFT)
1514#define ID_AA64PFR1_NMI_IMPL (UL(0x1) << ID_AA64PFR1_NMI_SHIFT)1782#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
1516/* ID_AA64PFR2_EL1 */1814/* ID_AA64PFR2_EL1 */
1517#define ID_AA64PFR2_EL1 MRS_REG(ID_AA64PFR2_EL1)
1518#define ID_AA64PFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR2_EL1)1815#define ID_AA64PFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR2_EL1)
1816#define ID_AA64PFR2_EL1_ISS ISS_MSR_REG(ID_AA64PFR2_EL1)
1519#define ID_AA64PFR2_EL1_op0 31817#define ID_AA64PFR2_EL1_op0 3
1520#define ID_AA64PFR2_EL1_op1 01818#define ID_AA64PFR2_EL1_op1 0
1521#define ID_AA64PFR2_EL1_CRn 01819#define ID_AA64PFR2_EL1_CRn 0
...@@ -1523,101 +1821,117 @@...@@ -1523,101 +1821,117 @@
1523#define ID_AA64PFR2_EL1_op2 21821#define ID_AA64PFR2_EL1_op2 2
15241822
1525/* ID_AA64ZFR0_EL1 */1823/* ID_AA64ZFR0_EL1 */
1526#define ID_AA64ZFR0_EL1 MRS_REG(ID_AA64ZFR0_EL1)
1527#define ID_AA64ZFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ZFR0_EL1)1824#define ID_AA64ZFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ZFR0_EL1)
1825#define ID_AA64ZFR0_EL1_ISS ISS_MSR_REG(ID_AA64ZFR0_EL1)
1528#define ID_AA64ZFR0_EL1_op0 31826#define ID_AA64ZFR0_EL1_op0 3
1529#define ID_AA64ZFR0_EL1_op1 01827#define ID_AA64ZFR0_EL1_op1 0
1530#define ID_AA64ZFR0_EL1_CRn 01828#define ID_AA64ZFR0_EL1_CRn 0
1531#define ID_AA64ZFR0_EL1_CRm 41829#define ID_AA64ZFR0_EL1_CRm 4
1532#define ID_AA64ZFR0_EL1_op2 41830#define ID_AA64ZFR0_EL1_op2 4
1533#define ID_AA64ZFR0_SVEver_SHIFT 01831#define ID_AA64ZFR0_SVEver_SHIFT 0
1832#define ID_AA64ZFR0_SVEver_WIDTH 4
1534#define ID_AA64ZFR0_SVEver_MASK (UL(0xf) << ID_AA64ZFR0_SVEver_SHIFT)1833#define ID_AA64ZFR0_SVEver_MASK (UL(0xf) << ID_AA64ZFR0_SVEver_SHIFT)
1535#define ID_AA64ZFR0_SVEver_VAL(x) ((x) & ID_AA64ZFR0_SVEver_MASK1834#define ID_AA64ZFR0_SVEver_VAL(x) ((x) & ID_AA64ZFR0_SVEver_MASK)
1536#define ID_AA64ZFR0_SVEver_SVE1 (UL(0x0) << ID_AA64ZFR0_SVEver_SHIFT)1835#define ID_AA64ZFR0_SVEver_SVE1 (UL(0x0) << ID_AA64ZFR0_SVEver_SHIFT)
1537#define ID_AA64ZFR0_SVEver_SVE2 (UL(0x1) << ID_AA64ZFR0_SVEver_SHIFT)1836#define ID_AA64ZFR0_SVEver_SVE2 (UL(0x1) << ID_AA64ZFR0_SVEver_SHIFT)
1538#define ID_AA64ZFR0_SVEver_SVE2P1 (UL(0x2) << ID_AA64ZFR0_SVEver_SHIFT)1837#define ID_AA64ZFR0_SVEver_SVE2P1 (UL(0x2) << ID_AA64ZFR0_SVEver_SHIFT)
1539#define ID_AA64ZFR0_AES_SHIFT 41838#define ID_AA64ZFR0_AES_SHIFT 4
1839#define ID_AA64ZFR0_AES_WIDTH 4
1540#define ID_AA64ZFR0_AES_MASK (UL(0xf) << ID_AA64ZFR0_AES_SHIFT)1840#define ID_AA64ZFR0_AES_MASK (UL(0xf) << ID_AA64ZFR0_AES_SHIFT)
1541#define ID_AA64ZFR0_AES_VAL(x) ((x) & ID_AA64ZFR0_AES_MASK1841#define ID_AA64ZFR0_AES_VAL(x) ((x) & ID_AA64ZFR0_AES_MASK)
1542#define ID_AA64ZFR0_AES_NONE (UL(0x0) << ID_AA64ZFR0_AES_SHIFT)1842#define ID_AA64ZFR0_AES_NONE (UL(0x0) << ID_AA64ZFR0_AES_SHIFT)
1543#define ID_AA64ZFR0_AES_BASE (UL(0x1) << ID_AA64ZFR0_AES_SHIFT)1843#define ID_AA64ZFR0_AES_BASE (UL(0x1) << ID_AA64ZFR0_AES_SHIFT)
1544#define ID_AA64ZFR0_AES_PMULL (UL(0x2) << ID_AA64ZFR0_AES_SHIFT)1844#define ID_AA64ZFR0_AES_PMULL (UL(0x2) << ID_AA64ZFR0_AES_SHIFT)
1545#define ID_AA64ZFR0_BitPerm_SHIFT 161845#define ID_AA64ZFR0_BitPerm_SHIFT 16
1846#define ID_AA64ZFR0_BitPerm_WIDTH 4
1546#define ID_AA64ZFR0_BitPerm_MASK (UL(0xf) << ID_AA64ZFR0_BitPerm_SHIFT)1847#define ID_AA64ZFR0_BitPerm_MASK (UL(0xf) << ID_AA64ZFR0_BitPerm_SHIFT)
1547#define ID_AA64ZFR0_BitPerm_VAL(x) ((x) & ID_AA64ZFR0_BitPerm_MASK1848#define ID_AA64ZFR0_BitPerm_VAL(x) ((x) & ID_AA64ZFR0_BitPerm_MASK)
1548#define ID_AA64ZFR0_BitPerm_NONE (UL(0x0) << ID_AA64ZFR0_BitPerm_SHIFT)1849#define ID_AA64ZFR0_BitPerm_NONE (UL(0x0) << ID_AA64ZFR0_BitPerm_SHIFT)
1549#define ID_AA64ZFR0_BitPerm_IMPL (UL(0x1) << ID_AA64ZFR0_BitPerm_SHIFT)1850#define ID_AA64ZFR0_BitPerm_IMPL (UL(0x1) << ID_AA64ZFR0_BitPerm_SHIFT)
1550#define ID_AA64ZFR0_BF16_SHIFT 201851#define ID_AA64ZFR0_BF16_SHIFT 20
1852#define ID_AA64ZFR0_BF16_WIDTH 4
1551#define ID_AA64ZFR0_BF16_MASK (UL(0xf) << ID_AA64ZFR0_BF16_SHIFT)1853#define ID_AA64ZFR0_BF16_MASK (UL(0xf) << ID_AA64ZFR0_BF16_SHIFT)
1552#define ID_AA64ZFR0_BF16_VAL(x) ((x) & ID_AA64ZFR0_BF16_MASK1854#define ID_AA64ZFR0_BF16_VAL(x) ((x) & ID_AA64ZFR0_BF16_MASK)
1553#define ID_AA64ZFR0_BF16_NONE (UL(0x0) << ID_AA64ZFR0_BF16_SHIFT)1855#define ID_AA64ZFR0_BF16_NONE (UL(0x0) << ID_AA64ZFR0_BF16_SHIFT)
1554#define ID_AA64ZFR0_BF16_BASE (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)1856#define ID_AA64ZFR0_BF16_BASE (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)
1555#define ID_AA64ZFR0_BF16_EBF (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)1857#define ID_AA64ZFR0_BF16_EBF (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT)
1556#define ID_AA64ZFR0_SHA3_SHIFT 321858#define ID_AA64ZFR0_SHA3_SHIFT 32
1859#define ID_AA64ZFR0_SHA3_WIDTH 4
1557#define ID_AA64ZFR0_SHA3_MASK (UL(0xf) << ID_AA64ZFR0_SHA3_SHIFT)1860#define ID_AA64ZFR0_SHA3_MASK (UL(0xf) << ID_AA64ZFR0_SHA3_SHIFT)
1558#define ID_AA64ZFR0_SHA3_VAL(x) ((x) & ID_AA64ZFR0_SHA3_MASK1861#define ID_AA64ZFR0_SHA3_VAL(x) ((x) & ID_AA64ZFR0_SHA3_MASK)
1559#define ID_AA64ZFR0_SHA3_NONE (UL(0x0) << ID_AA64ZFR0_SHA3_SHIFT)1862#define ID_AA64ZFR0_SHA3_NONE (UL(0x0) << ID_AA64ZFR0_SHA3_SHIFT)
1560#define ID_AA64ZFR0_SHA3_IMPL (UL(0x1) << ID_AA64ZFR0_SHA3_SHIFT)1863#define ID_AA64ZFR0_SHA3_IMPL (UL(0x1) << ID_AA64ZFR0_SHA3_SHIFT)
1561#define ID_AA64ZFR0_SM4_SHIFT 401864#define ID_AA64ZFR0_SM4_SHIFT 40
1865#define ID_AA64ZFR0_SM4_WIDTH 4
1562#define ID_AA64ZFR0_SM4_MASK (UL(0xf) << ID_AA64ZFR0_SM4_SHIFT)1866#define ID_AA64ZFR0_SM4_MASK (UL(0xf) << ID_AA64ZFR0_SM4_SHIFT)
1563#define ID_AA64ZFR0_SM4_VAL(x) ((x) & ID_AA64ZFR0_SM4_MASK1867#define ID_AA64ZFR0_SM4_VAL(x) ((x) & ID_AA64ZFR0_SM4_MASK)
1564#define ID_AA64ZFR0_SM4_NONE (UL(0x0) << ID_AA64ZFR0_SM4_SHIFT)1868#define ID_AA64ZFR0_SM4_NONE (UL(0x0) << ID_AA64ZFR0_SM4_SHIFT)
1565#define ID_AA64ZFR0_SM4_IMPL (UL(0x1) << ID_AA64ZFR0_SM4_SHIFT)1869#define ID_AA64ZFR0_SM4_IMPL (UL(0x1) << ID_AA64ZFR0_SM4_SHIFT)
1566#define ID_AA64ZFR0_I8MM_SHIFT 441870#define ID_AA64ZFR0_I8MM_SHIFT 44
1871#define ID_AA64ZFR0_I8MM_WIDTH 4
1567#define ID_AA64ZFR0_I8MM_MASK (UL(0xf) << ID_AA64ZFR0_I8MM_SHIFT)1872#define ID_AA64ZFR0_I8MM_MASK (UL(0xf) << ID_AA64ZFR0_I8MM_SHIFT)
1568#define ID_AA64ZFR0_I8MM_VAL(x) ((x) & ID_AA64ZFR0_I8MM_MASK1873#define ID_AA64ZFR0_I8MM_VAL(x) ((x) & ID_AA64ZFR0_I8MM_MASK)
1569#define ID_AA64ZFR0_I8MM_NONE (UL(0x0) << ID_AA64ZFR0_I8MM_SHIFT)1874#define ID_AA64ZFR0_I8MM_NONE (UL(0x0) << ID_AA64ZFR0_I8MM_SHIFT)
1570#define ID_AA64ZFR0_I8MM_IMPL (UL(0x1) << ID_AA64ZFR0_I8MM_SHIFT)1875#define ID_AA64ZFR0_I8MM_IMPL (UL(0x1) << ID_AA64ZFR0_I8MM_SHIFT)
1571#define ID_AA64ZFR0_F32MM_SHIFT 521876#define ID_AA64ZFR0_F32MM_SHIFT 52
1877#define ID_AA64ZFR0_F32MM_WIDTH 4
1572#define ID_AA64ZFR0_F32MM_MASK (UL(0xf) << ID_AA64ZFR0_F32MM_SHIFT)1878#define ID_AA64ZFR0_F32MM_MASK (UL(0xf) << ID_AA64ZFR0_F32MM_SHIFT)
1573#define ID_AA64ZFR0_F32MM_VAL(x) ((x) & ID_AA64ZFR0_F32MM_MASK1879#define ID_AA64ZFR0_F32MM_VAL(x) ((x) & ID_AA64ZFR0_F32MM_MASK)
1574#define ID_AA64ZFR0_F32MM_NONE (UL(0x0) << ID_AA64ZFR0_F32MM_SHIFT)1880#define ID_AA64ZFR0_F32MM_NONE (UL(0x0) << ID_AA64ZFR0_F32MM_SHIFT)
1575#define ID_AA64ZFR0_F32MM_IMPL (UL(0x1) << ID_AA64ZFR0_F32MM_SHIFT)1881#define ID_AA64ZFR0_F32MM_IMPL (UL(0x1) << ID_AA64ZFR0_F32MM_SHIFT)
1576#define ID_AA64ZFR0_F64MM_SHIFT 561882#define ID_AA64ZFR0_F64MM_SHIFT 56
1883#define ID_AA64ZFR0_F64MM_WIDTH 4
1577#define ID_AA64ZFR0_F64MM_MASK (UL(0xf) << ID_AA64ZFR0_F64MM_SHIFT)1884#define ID_AA64ZFR0_F64MM_MASK (UL(0xf) << ID_AA64ZFR0_F64MM_SHIFT)
1578#define ID_AA64ZFR0_F64MM_VAL(x) ((x) & ID_AA64ZFR0_F64MM_MASK1885#define ID_AA64ZFR0_F64MM_VAL(x) ((x) & ID_AA64ZFR0_F64MM_MASK)
1579#define ID_AA64ZFR0_F64MM_NONE (UL(0x0) << ID_AA64ZFR0_F64MM_SHIFT)1886#define ID_AA64ZFR0_F64MM_NONE (UL(0x0) << ID_AA64ZFR0_F64MM_SHIFT)
1580#define ID_AA64ZFR0_F64MM_IMPL (UL(0x1) << ID_AA64ZFR0_F64MM_SHIFT)1887#define ID_AA64ZFR0_F64MM_IMPL (UL(0x1) << ID_AA64ZFR0_F64MM_SHIFT)
15811888
1582/* ID_ISAR5_EL1 */1889/* 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)
1584#define ID_ISAR5_EL1_op0 0x31891#define ID_ISAR5_EL1_op0 0x3
1585#define ID_ISAR5_EL1_op1 0x01892#define ID_ISAR5_EL1_op1 0x0
1586#define ID_ISAR5_EL1_CRn 0x01893#define ID_ISAR5_EL1_CRn 0x0
1587#define ID_ISAR5_EL1_CRm 0x21894#define ID_ISAR5_EL1_CRm 0x2
1588#define ID_ISAR5_EL1_op2 0x51895#define ID_ISAR5_EL1_op2 0x5
1589#define ID_ISAR5_SEVL_SHIFT 01896#define ID_ISAR5_SEVL_SHIFT 0
1897#define ID_ISAR5_SEVL_WIDTH 4
1590#define ID_ISAR5_SEVL_MASK (UL(0xf) << ID_ISAR5_SEVL_SHIFT)1898#define ID_ISAR5_SEVL_MASK (UL(0xf) << ID_ISAR5_SEVL_SHIFT)
1591#define ID_ISAR5_SEVL_VAL(x) ((x) & ID_ISAR5_SEVL_MASK)1899#define ID_ISAR5_SEVL_VAL(x) ((x) & ID_ISAR5_SEVL_MASK)
1592#define ID_ISAR5_SEVL_NOP (UL(0x0) << ID_ISAR5_SEVL_SHIFT)1900#define ID_ISAR5_SEVL_NOP (UL(0x0) << ID_ISAR5_SEVL_SHIFT)
1593#define ID_ISAR5_SEVL_IMPL (UL(0x1) << ID_ISAR5_SEVL_SHIFT)1901#define ID_ISAR5_SEVL_IMPL (UL(0x1) << ID_ISAR5_SEVL_SHIFT)
1594#define ID_ISAR5_AES_SHIFT 41902#define ID_ISAR5_AES_SHIFT 4
1903#define ID_ISAR5_AES_WIDTH 4
1595#define ID_ISAR5_AES_MASK (UL(0xf) << ID_ISAR5_AES_SHIFT)1904#define ID_ISAR5_AES_MASK (UL(0xf) << ID_ISAR5_AES_SHIFT)
1596#define ID_ISAR5_AES_VAL(x) ((x) & ID_ISAR5_AES_MASK)1905#define ID_ISAR5_AES_VAL(x) ((x) & ID_ISAR5_AES_MASK)
1597#define ID_ISAR5_AES_NONE (UL(0x0) << ID_ISAR5_AES_SHIFT)1906#define ID_ISAR5_AES_NONE (UL(0x0) << ID_ISAR5_AES_SHIFT)
1598#define ID_ISAR5_AES_BASE (UL(0x1) << ID_ISAR5_AES_SHIFT)1907#define ID_ISAR5_AES_BASE (UL(0x1) << ID_ISAR5_AES_SHIFT)
1599#define ID_ISAR5_AES_VMULL (UL(0x2) << ID_ISAR5_AES_SHIFT)1908#define ID_ISAR5_AES_VMULL (UL(0x2) << ID_ISAR5_AES_SHIFT)
1600#define ID_ISAR5_SHA1_SHIFT 81909#define ID_ISAR5_SHA1_SHIFT 8
1910#define ID_ISAR5_SHA1_WIDTH 4
1601#define ID_ISAR5_SHA1_MASK (UL(0xf) << ID_ISAR5_SHA1_SHIFT)1911#define ID_ISAR5_SHA1_MASK (UL(0xf) << ID_ISAR5_SHA1_SHIFT)
1602#define ID_ISAR5_SHA1_VAL(x) ((x) & ID_ISAR5_SHA1_MASK)1912#define ID_ISAR5_SHA1_VAL(x) ((x) & ID_ISAR5_SHA1_MASK)
1603#define ID_ISAR5_SHA1_NONE (UL(0x0) << ID_ISAR5_SHA1_SHIFT)1913#define ID_ISAR5_SHA1_NONE (UL(0x0) << ID_ISAR5_SHA1_SHIFT)
1604#define ID_ISAR5_SHA1_IMPL (UL(0x1) << ID_ISAR5_SHA1_SHIFT)1914#define ID_ISAR5_SHA1_IMPL (UL(0x1) << ID_ISAR5_SHA1_SHIFT)
1605#define ID_ISAR5_SHA2_SHIFT 121915#define ID_ISAR5_SHA2_SHIFT 12
1916#define ID_ISAR5_SHA2_WIDTH 4
1606#define ID_ISAR5_SHA2_MASK (UL(0xf) << ID_ISAR5_SHA2_SHIFT)1917#define ID_ISAR5_SHA2_MASK (UL(0xf) << ID_ISAR5_SHA2_SHIFT)
1607#define ID_ISAR5_SHA2_VAL(x) ((x) & ID_ISAR5_SHA2_MASK)1918#define ID_ISAR5_SHA2_VAL(x) ((x) & ID_ISAR5_SHA2_MASK)
1608#define ID_ISAR5_SHA2_NONE (UL(0x0) << ID_ISAR5_SHA2_SHIFT)1919#define ID_ISAR5_SHA2_NONE (UL(0x0) << ID_ISAR5_SHA2_SHIFT)
1609#define ID_ISAR5_SHA2_IMPL (UL(0x1) << ID_ISAR5_SHA2_SHIFT)1920#define ID_ISAR5_SHA2_IMPL (UL(0x1) << ID_ISAR5_SHA2_SHIFT)
1610#define ID_ISAR5_CRC32_SHIFT 161921#define ID_ISAR5_CRC32_SHIFT 16
1922#define ID_ISAR5_CRC32_WIDTH 4
1611#define ID_ISAR5_CRC32_MASK (UL(0xf) << ID_ISAR5_CRC32_SHIFT)1923#define ID_ISAR5_CRC32_MASK (UL(0xf) << ID_ISAR5_CRC32_SHIFT)
1612#define ID_ISAR5_CRC32_VAL(x) ((x) & ID_ISAR5_CRC32_MASK)1924#define ID_ISAR5_CRC32_VAL(x) ((x) & ID_ISAR5_CRC32_MASK)
1613#define ID_ISAR5_CRC32_NONE (UL(0x0) << ID_ISAR5_CRC32_SHIFT)1925#define ID_ISAR5_CRC32_NONE (UL(0x0) << ID_ISAR5_CRC32_SHIFT)
1614#define ID_ISAR5_CRC32_IMPL (UL(0x1) << ID_ISAR5_CRC32_SHIFT)1926#define ID_ISAR5_CRC32_IMPL (UL(0x1) << ID_ISAR5_CRC32_SHIFT)
1615#define ID_ISAR5_RDM_SHIFT 241927#define ID_ISAR5_RDM_SHIFT 24
1928#define ID_ISAR5_RDM_WIDTH 4
1616#define ID_ISAR5_RDM_MASK (UL(0xf) << ID_ISAR5_RDM_SHIFT)1929#define ID_ISAR5_RDM_MASK (UL(0xf) << ID_ISAR5_RDM_SHIFT)
1617#define ID_ISAR5_RDM_VAL(x) ((x) & ID_ISAR5_RDM_MASK)1930#define ID_ISAR5_RDM_VAL(x) ((x) & ID_ISAR5_RDM_MASK)
1618#define ID_ISAR5_RDM_NONE (UL(0x0) << ID_ISAR5_RDM_SHIFT)1931#define ID_ISAR5_RDM_NONE (UL(0x0) << ID_ISAR5_RDM_SHIFT)
1619#define ID_ISAR5_RDM_IMPL (UL(0x1) << ID_ISAR5_RDM_SHIFT)1932#define ID_ISAR5_RDM_IMPL (UL(0x1) << ID_ISAR5_RDM_SHIFT)
1620#define ID_ISAR5_VCMA_SHIFT 281933#define ID_ISAR5_VCMA_SHIFT 28
1934#define ID_ISAR5_VCMA_WIDTH 4
1621#define ID_ISAR5_VCMA_MASK (UL(0xf) << ID_ISAR5_VCMA_SHIFT)1935#define ID_ISAR5_VCMA_MASK (UL(0xf) << ID_ISAR5_VCMA_SHIFT)
1622#define ID_ISAR5_VCMA_VAL(x) ((x) & ID_ISAR5_VCMA_MASK)1936#define ID_ISAR5_VCMA_VAL(x) ((x) & ID_ISAR5_VCMA_MASK)
1623#define ID_ISAR5_VCMA_NONE (UL(0x0) << ID_ISAR5_VCMA_SHIFT)1937#define ID_ISAR5_VCMA_NONE (UL(0x0) << ID_ISAR5_VCMA_SHIFT)
...@@ -1647,7 +1961,6 @@...@@ -1647,7 +1961,6 @@
1647#define MAIR_EL12_op2 01961#define MAIR_EL12_op2 0
16481962
1649/* MDCCINT_EL1 */1963/* MDCCINT_EL1 */
1650#define MDCCINT_EL1 MRS_REG(MDCCINT_EL1)
1651#define MDCCINT_EL1_op0 21964#define MDCCINT_EL1_op0 2
1652#define MDCCINT_EL1_op1 01965#define MDCCINT_EL1_op1 0
1653#define MDCCINT_EL1_CRn 01966#define MDCCINT_EL1_CRn 0
...@@ -1655,7 +1968,6 @@...@@ -1655,7 +1968,6 @@
1655#define MDCCINT_EL1_op2 01968#define MDCCINT_EL1_op2 0
16561969
1657/* MDCCSR_EL0 */1970/* MDCCSR_EL0 */
1658#define MDCCSR_EL0 MRS_REG(MDCCSR_EL0)
1659#define MDCCSR_EL0_op0 21971#define MDCCSR_EL0_op0 2
1660#define MDCCSR_EL0_op1 31972#define MDCCSR_EL0_op1 3
1661#define MDCCSR_EL0_CRn 01973#define MDCCSR_EL0_CRn 0
...@@ -1663,7 +1975,6 @@...@@ -1663,7 +1975,6 @@
1663#define MDCCSR_EL0_op2 01975#define MDCCSR_EL0_op2 0
16641976
1665/* MDSCR_EL1 - Monitor Debug System Control Register */1977/* MDSCR_EL1 - Monitor Debug System Control Register */
1666#define MDSCR_EL1 MRS_REG(MDSCR_EL1)
1667#define MDSCR_EL1_op0 21978#define MDSCR_EL1_op0 2
1668#define MDSCR_EL1_op1 01979#define MDSCR_EL1_op1 0
1669#define MDSCR_EL1_CRn 01980#define MDSCR_EL1_CRn 0
...@@ -1677,7 +1988,6 @@...@@ -1677,7 +1988,6 @@
1677#define MDSCR_MDE (UL(0x1) << MDSCR_MDE_SHIFT)1988#define MDSCR_MDE (UL(0x1) << MDSCR_MDE_SHIFT)
16781989
1679/* MIDR_EL1 - Main ID Register */1990/* MIDR_EL1 - Main ID Register */
1680#define MIDR_EL1 MRS_REG(MIDR_EL1)
1681#define MIDR_EL1_op0 31991#define MIDR_EL1_op0 3
1682#define MIDR_EL1_op1 01992#define MIDR_EL1_op1 0
1683#define MIDR_EL1_CRn 01993#define MIDR_EL1_CRn 0
...@@ -1685,7 +1995,6 @@...@@ -1685,7 +1995,6 @@
1685#define MIDR_EL1_op2 01995#define MIDR_EL1_op2 0
16861996
1687/* MPIDR_EL1 - Multiprocessor Affinity Register */1997/* MPIDR_EL1 - Multiprocessor Affinity Register */
1688#define MPIDR_EL1 MRS_REG(MPIDR_EL1)
1689#define MPIDR_EL1_op0 31998#define MPIDR_EL1_op0 3
1690#define MPIDR_EL1_op1 01999#define MPIDR_EL1_op1 0
1691#define MPIDR_EL1_CRn 02000#define MPIDR_EL1_CRn 0
...@@ -1709,95 +2018,110 @@...@@ -1709,95 +2018,110 @@
1709#define MPIDR_AFF3_VAL(x) ((x) & MPIDR_AFF3_MASK)2018#define MPIDR_AFF3_VAL(x) ((x) & MPIDR_AFF3_MASK)
17102019
1711/* MVFR0_EL1 */2020/* MVFR0_EL1 */
1712#define MVFR0_EL1 MRS_REG(MVFR0_EL1)2021#define MVFR0_EL1_ISS ISS_MSR_REG(MVFR0_EL1)
1713#define MVFR0_EL1_op0 0x32022#define MVFR0_EL1_op0 0x3
1714#define MVFR0_EL1_op1 0x02023#define MVFR0_EL1_op1 0x0
1715#define MVFR0_EL1_CRn 0x02024#define MVFR0_EL1_CRn 0x0
1716#define MVFR0_EL1_CRm 0x32025#define MVFR0_EL1_CRm 0x3
1717#define MVFR0_EL1_op2 0x02026#define MVFR0_EL1_op2 0x0
1718#define MVFR0_SIMDReg_SHIFT 02027#define MVFR0_SIMDReg_SHIFT 0
2028#define MVFR0_SIMDReg_WIDTH 4
1719#define MVFR0_SIMDReg_MASK (UL(0xf) << MVFR0_SIMDReg_SHIFT)2029#define MVFR0_SIMDReg_MASK (UL(0xf) << MVFR0_SIMDReg_SHIFT)
1720#define MVFR0_SIMDReg_VAL(x) ((x) & MVFR0_SIMDReg_MASK)2030#define MVFR0_SIMDReg_VAL(x) ((x) & MVFR0_SIMDReg_MASK)
1721#define MVFR0_SIMDReg_NONE (UL(0x0) << MVFR0_SIMDReg_SHIFT)2031#define MVFR0_SIMDReg_NONE (UL(0x0) << MVFR0_SIMDReg_SHIFT)
1722#define MVFR0_SIMDReg_FP (UL(0x1) << MVFR0_SIMDReg_SHIFT)2032#define MVFR0_SIMDReg_FP (UL(0x1) << MVFR0_SIMDReg_SHIFT)
1723#define MVFR0_SIMDReg_AdvSIMD (UL(0x2) << MVFR0_SIMDReg_SHIFT)2033#define MVFR0_SIMDReg_AdvSIMD (UL(0x2) << MVFR0_SIMDReg_SHIFT)
1724#define MVFR0_FPSP_SHIFT 42034#define MVFR0_FPSP_SHIFT 4
2035#define MVFR0_FPSP_WIDTH 4
1725#define MVFR0_FPSP_MASK (UL(0xf) << MVFR0_FPSP_SHIFT)2036#define MVFR0_FPSP_MASK (UL(0xf) << MVFR0_FPSP_SHIFT)
1726#define MVFR0_FPSP_VAL(x) ((x) & MVFR0_FPSP_MASK)2037#define MVFR0_FPSP_VAL(x) ((x) & MVFR0_FPSP_MASK)
1727#define MVFR0_FPSP_NONE (UL(0x0) << MVFR0_FPSP_SHIFT)2038#define MVFR0_FPSP_NONE (UL(0x0) << MVFR0_FPSP_SHIFT)
1728#define MVFR0_FPSP_VFP_v2 (UL(0x1) << MVFR0_FPSP_SHIFT)2039#define MVFR0_FPSP_VFP_v2 (UL(0x1) << MVFR0_FPSP_SHIFT)
1729#define MVFR0_FPSP_VFP_v3_v4 (UL(0x2) << MVFR0_FPSP_SHIFT)2040#define MVFR0_FPSP_VFP_v3_v4 (UL(0x2) << MVFR0_FPSP_SHIFT)
1730#define MVFR0_FPDP_SHIFT 82041#define MVFR0_FPDP_SHIFT 8
2042#define MVFR0_FPDP_WIDTH 4
1731#define MVFR0_FPDP_MASK (UL(0xf) << MVFR0_FPDP_SHIFT)2043#define MVFR0_FPDP_MASK (UL(0xf) << MVFR0_FPDP_SHIFT)
1732#define MVFR0_FPDP_VAL(x) ((x) & MVFR0_FPDP_MASK)2044#define MVFR0_FPDP_VAL(x) ((x) & MVFR0_FPDP_MASK)
1733#define MVFR0_FPDP_NONE (UL(0x0) << MVFR0_FPDP_SHIFT)2045#define MVFR0_FPDP_NONE (UL(0x0) << MVFR0_FPDP_SHIFT)
1734#define MVFR0_FPDP_VFP_v2 (UL(0x1) << MVFR0_FPDP_SHIFT)2046#define MVFR0_FPDP_VFP_v2 (UL(0x1) << MVFR0_FPDP_SHIFT)
1735#define MVFR0_FPDP_VFP_v3_v4 (UL(0x2) << MVFR0_FPDP_SHIFT)2047#define MVFR0_FPDP_VFP_v3_v4 (UL(0x2) << MVFR0_FPDP_SHIFT)
1736#define MVFR0_FPTrap_SHIFT 122048#define MVFR0_FPTrap_SHIFT 12
2049#define MVFR0_FPTrap_WIDTH 4
1737#define MVFR0_FPTrap_MASK (UL(0xf) << MVFR0_FPTrap_SHIFT)2050#define MVFR0_FPTrap_MASK (UL(0xf) << MVFR0_FPTrap_SHIFT)
1738#define MVFR0_FPTrap_VAL(x) ((x) & MVFR0_FPTrap_MASK)2051#define MVFR0_FPTrap_VAL(x) ((x) & MVFR0_FPTrap_MASK)
1739#define MVFR0_FPTrap_NONE (UL(0x0) << MVFR0_FPTrap_SHIFT)2052#define MVFR0_FPTrap_NONE (UL(0x0) << MVFR0_FPTrap_SHIFT)
1740#define MVFR0_FPTrap_IMPL (UL(0x1) << MVFR0_FPTrap_SHIFT)2053#define MVFR0_FPTrap_IMPL (UL(0x1) << MVFR0_FPTrap_SHIFT)
1741#define MVFR0_FPDivide_SHIFT 162054#define MVFR0_FPDivide_SHIFT 16
2055#define MVFR0_FPDivide_WIDTH 4
1742#define MVFR0_FPDivide_MASK (UL(0xf) << MVFR0_FPDivide_SHIFT)2056#define MVFR0_FPDivide_MASK (UL(0xf) << MVFR0_FPDivide_SHIFT)
1743#define MVFR0_FPDivide_VAL(x) ((x) & MVFR0_FPDivide_MASK)2057#define MVFR0_FPDivide_VAL(x) ((x) & MVFR0_FPDivide_MASK)
1744#define MVFR0_FPDivide_NONE (UL(0x0) << MVFR0_FPDivide_SHIFT)2058#define MVFR0_FPDivide_NONE (UL(0x0) << MVFR0_FPDivide_SHIFT)
1745#define MVFR0_FPDivide_IMPL (UL(0x1) << MVFR0_FPDivide_SHIFT)2059#define MVFR0_FPDivide_IMPL (UL(0x1) << MVFR0_FPDivide_SHIFT)
1746#define MVFR0_FPSqrt_SHIFT 202060#define MVFR0_FPSqrt_SHIFT 20
2061#define MVFR0_FPSqrt_WIDTH 4
1747#define MVFR0_FPSqrt_MASK (UL(0xf) << MVFR0_FPSqrt_SHIFT)2062#define MVFR0_FPSqrt_MASK (UL(0xf) << MVFR0_FPSqrt_SHIFT)
1748#define MVFR0_FPSqrt_VAL(x) ((x) & MVFR0_FPSqrt_MASK)2063#define MVFR0_FPSqrt_VAL(x) ((x) & MVFR0_FPSqrt_MASK)
1749#define MVFR0_FPSqrt_NONE (UL(0x0) << MVFR0_FPSqrt_SHIFT)2064#define MVFR0_FPSqrt_NONE (UL(0x0) << MVFR0_FPSqrt_SHIFT)
1750#define MVFR0_FPSqrt_IMPL (UL(0x1) << MVFR0_FPSqrt_SHIFT)2065#define MVFR0_FPSqrt_IMPL (UL(0x1) << MVFR0_FPSqrt_SHIFT)
1751#define MVFR0_FPShVec_SHIFT 242066#define MVFR0_FPShVec_SHIFT 24
2067#define MVFR0_FPShVec_WIDTH 4
1752#define MVFR0_FPShVec_MASK (UL(0xf) << MVFR0_FPShVec_SHIFT)2068#define MVFR0_FPShVec_MASK (UL(0xf) << MVFR0_FPShVec_SHIFT)
1753#define MVFR0_FPShVec_VAL(x) ((x) & MVFR0_FPShVec_MASK)2069#define MVFR0_FPShVec_VAL(x) ((x) & MVFR0_FPShVec_MASK)
1754#define MVFR0_FPShVec_NONE (UL(0x0) << MVFR0_FPShVec_SHIFT)2070#define MVFR0_FPShVec_NONE (UL(0x0) << MVFR0_FPShVec_SHIFT)
1755#define MVFR0_FPShVec_IMPL (UL(0x1) << MVFR0_FPShVec_SHIFT)2071#define MVFR0_FPShVec_IMPL (UL(0x1) << MVFR0_FPShVec_SHIFT)
1756#define MVFR0_FPRound_SHIFT 282072#define MVFR0_FPRound_SHIFT 28
2073#define MVFR0_FPRound_WIDTH 4
1757#define MVFR0_FPRound_MASK (UL(0xf) << MVFR0_FPRound_SHIFT)2074#define MVFR0_FPRound_MASK (UL(0xf) << MVFR0_FPRound_SHIFT)
1758#define MVFR0_FPRound_VAL(x) ((x) & MVFR0_FPRound_MASK)2075#define MVFR0_FPRound_VAL(x) ((x) & MVFR0_FPRound_MASK)
1759#define MVFR0_FPRound_NONE (UL(0x0) << MVFR0_FPRound_SHIFT)2076#define MVFR0_FPRound_NONE (UL(0x0) << MVFR0_FPRound_SHIFT)
1760#define MVFR0_FPRound_IMPL (UL(0x1) << MVFR0_FPRound_SHIFT)2077#define MVFR0_FPRound_IMPL (UL(0x1) << MVFR0_FPRound_SHIFT)
17612078
1762/* MVFR1_EL1 */2079/* MVFR1_EL1 */
1763#define MVFR1_EL1 MRS_REG(MVFR1_EL1)2080#define MVFR1_EL1_ISS ISS_MSR_REG(MVFR1_EL1)
1764#define MVFR1_EL1_op0 0x32081#define MVFR1_EL1_op0 0x3
1765#define MVFR1_EL1_op1 0x02082#define MVFR1_EL1_op1 0x0
1766#define MVFR1_EL1_CRn 0x02083#define MVFR1_EL1_CRn 0x0
1767#define MVFR1_EL1_CRm 0x32084#define MVFR1_EL1_CRm 0x3
1768#define MVFR1_EL1_op2 0x12085#define MVFR1_EL1_op2 0x1
1769#define MVFR1_FPFtZ_SHIFT 02086#define MVFR1_FPFtZ_SHIFT 0
2087#define MVFR1_FPFtZ_WIDTH 4
1770#define MVFR1_FPFtZ_MASK (UL(0xf) << MVFR1_FPFtZ_SHIFT)2088#define MVFR1_FPFtZ_MASK (UL(0xf) << MVFR1_FPFtZ_SHIFT)
1771#define MVFR1_FPFtZ_VAL(x) ((x) & MVFR1_FPFtZ_MASK)2089#define MVFR1_FPFtZ_VAL(x) ((x) & MVFR1_FPFtZ_MASK)
1772#define MVFR1_FPFtZ_NONE (UL(0x0) << MVFR1_FPFtZ_SHIFT)2090#define MVFR1_FPFtZ_NONE (UL(0x0) << MVFR1_FPFtZ_SHIFT)
1773#define MVFR1_FPFtZ_IMPL (UL(0x1) << MVFR1_FPFtZ_SHIFT)2091#define MVFR1_FPFtZ_IMPL (UL(0x1) << MVFR1_FPFtZ_SHIFT)
1774#define MVFR1_FPDNaN_SHIFT 42092#define MVFR1_FPDNaN_SHIFT 4
2093#define MVFR1_FPDNaN_WIDTH 4
1775#define MVFR1_FPDNaN_MASK (UL(0xf) << MVFR1_FPDNaN_SHIFT)2094#define MVFR1_FPDNaN_MASK (UL(0xf) << MVFR1_FPDNaN_SHIFT)
1776#define MVFR1_FPDNaN_VAL(x) ((x) & MVFR1_FPDNaN_MASK)2095#define MVFR1_FPDNaN_VAL(x) ((x) & MVFR1_FPDNaN_MASK)
1777#define MVFR1_FPDNaN_NONE (UL(0x0) << MVFR1_FPDNaN_SHIFT)2096#define MVFR1_FPDNaN_NONE (UL(0x0) << MVFR1_FPDNaN_SHIFT)
1778#define MVFR1_FPDNaN_IMPL (UL(0x1) << MVFR1_FPDNaN_SHIFT)2097#define MVFR1_FPDNaN_IMPL (UL(0x1) << MVFR1_FPDNaN_SHIFT)
1779#define MVFR1_SIMDLS_SHIFT 82098#define MVFR1_SIMDLS_SHIFT 8
2099#define MVFR1_SIMDLS_WIDTH 4
1780#define MVFR1_SIMDLS_MASK (UL(0xf) << MVFR1_SIMDLS_SHIFT)2100#define MVFR1_SIMDLS_MASK (UL(0xf) << MVFR1_SIMDLS_SHIFT)
1781#define MVFR1_SIMDLS_VAL(x) ((x) & MVFR1_SIMDLS_MASK)2101#define MVFR1_SIMDLS_VAL(x) ((x) & MVFR1_SIMDLS_MASK)
1782#define MVFR1_SIMDLS_NONE (UL(0x0) << MVFR1_SIMDLS_SHIFT)2102#define MVFR1_SIMDLS_NONE (UL(0x0) << MVFR1_SIMDLS_SHIFT)
1783#define MVFR1_SIMDLS_IMPL (UL(0x1) << MVFR1_SIMDLS_SHIFT)2103#define MVFR1_SIMDLS_IMPL (UL(0x1) << MVFR1_SIMDLS_SHIFT)
1784#define MVFR1_SIMDInt_SHIFT 122104#define MVFR1_SIMDInt_SHIFT 12
2105#define MVFR1_SIMDInt_WIDTH 4
1785#define MVFR1_SIMDInt_MASK (UL(0xf) << MVFR1_SIMDInt_SHIFT)2106#define MVFR1_SIMDInt_MASK (UL(0xf) << MVFR1_SIMDInt_SHIFT)
1786#define MVFR1_SIMDInt_VAL(x) ((x) & MVFR1_SIMDInt_MASK)2107#define MVFR1_SIMDInt_VAL(x) ((x) & MVFR1_SIMDInt_MASK)
1787#define MVFR1_SIMDInt_NONE (UL(0x0) << MVFR1_SIMDInt_SHIFT)2108#define MVFR1_SIMDInt_NONE (UL(0x0) << MVFR1_SIMDInt_SHIFT)
1788#define MVFR1_SIMDInt_IMPL (UL(0x1) << MVFR1_SIMDInt_SHIFT)2109#define MVFR1_SIMDInt_IMPL (UL(0x1) << MVFR1_SIMDInt_SHIFT)
1789#define MVFR1_SIMDSP_SHIFT 162110#define MVFR1_SIMDSP_SHIFT 16
2111#define MVFR1_SIMDSP_WIDTH 4
1790#define MVFR1_SIMDSP_MASK (UL(0xf) << MVFR1_SIMDSP_SHIFT)2112#define MVFR1_SIMDSP_MASK (UL(0xf) << MVFR1_SIMDSP_SHIFT)
1791#define MVFR1_SIMDSP_VAL(x) ((x) & MVFR1_SIMDSP_MASK)2113#define MVFR1_SIMDSP_VAL(x) ((x) & MVFR1_SIMDSP_MASK)
1792#define MVFR1_SIMDSP_NONE (UL(0x0) << MVFR1_SIMDSP_SHIFT)2114#define MVFR1_SIMDSP_NONE (UL(0x0) << MVFR1_SIMDSP_SHIFT)
1793#define MVFR1_SIMDSP_IMPL (UL(0x1) << MVFR1_SIMDSP_SHIFT)2115#define MVFR1_SIMDSP_IMPL (UL(0x1) << MVFR1_SIMDSP_SHIFT)
1794#define MVFR1_SIMDHP_SHIFT 202116#define MVFR1_SIMDHP_SHIFT 20
2117#define MVFR1_SIMDHP_WIDTH 4
1795#define MVFR1_SIMDHP_MASK (UL(0xf) << MVFR1_SIMDHP_SHIFT)2118#define MVFR1_SIMDHP_MASK (UL(0xf) << MVFR1_SIMDHP_SHIFT)
1796#define MVFR1_SIMDHP_VAL(x) ((x) & MVFR1_SIMDHP_MASK)2119#define MVFR1_SIMDHP_VAL(x) ((x) & MVFR1_SIMDHP_MASK)
1797#define MVFR1_SIMDHP_NONE (UL(0x0) << MVFR1_SIMDHP_SHIFT)2120#define MVFR1_SIMDHP_NONE (UL(0x0) << MVFR1_SIMDHP_SHIFT)
1798#define MVFR1_SIMDHP_CONV_SP (UL(0x1) << MVFR1_SIMDHP_SHIFT)2121#define MVFR1_SIMDHP_CONV_SP (UL(0x1) << MVFR1_SIMDHP_SHIFT)
1799#define MVFR1_SIMDHP_ARITH (UL(0x2) << MVFR1_SIMDHP_SHIFT)2122#define MVFR1_SIMDHP_ARITH (UL(0x2) << MVFR1_SIMDHP_SHIFT)
1800#define MVFR1_FPHP_SHIFT 242123#define MVFR1_FPHP_SHIFT 24
2124#define MVFR1_FPHP_WIDTH 4
1801#define MVFR1_FPHP_MASK (UL(0xf) << MVFR1_FPHP_SHIFT)2125#define MVFR1_FPHP_MASK (UL(0xf) << MVFR1_FPHP_SHIFT)
1802#define MVFR1_FPHP_VAL(x) ((x) & MVFR1_FPHP_MASK)2126#define MVFR1_FPHP_VAL(x) ((x) & MVFR1_FPHP_MASK)
1803#define MVFR1_FPHP_NONE (UL(0x0) << MVFR1_FPHP_SHIFT)2127#define MVFR1_FPHP_NONE (UL(0x0) << MVFR1_FPHP_SHIFT)
...@@ -1805,13 +2129,13 @@...@@ -1805,13 +2129,13 @@
1805#define MVFR1_FPHP_CONV_DP (UL(0x2) << MVFR1_FPHP_SHIFT)2129#define MVFR1_FPHP_CONV_DP (UL(0x2) << MVFR1_FPHP_SHIFT)
1806#define MVFR1_FPHP_ARITH (UL(0x3) << MVFR1_FPHP_SHIFT)2130#define MVFR1_FPHP_ARITH (UL(0x3) << MVFR1_FPHP_SHIFT)
1807#define MVFR1_SIMDFMAC_SHIFT 282131#define MVFR1_SIMDFMAC_SHIFT 28
2132#define MVFR1_SIMDFMAC_WIDTH 4
1808#define MVFR1_SIMDFMAC_MASK (UL(0xf) << MVFR1_SIMDFMAC_SHIFT)2133#define MVFR1_SIMDFMAC_MASK (UL(0xf) << MVFR1_SIMDFMAC_SHIFT)
1809#define MVFR1_SIMDFMAC_VAL(x) ((x) & MVFR1_SIMDFMAC_MASK)2134#define MVFR1_SIMDFMAC_VAL(x) ((x) & MVFR1_SIMDFMAC_MASK)
1810#define MVFR1_SIMDFMAC_NONE (UL(0x0) << MVFR1_SIMDFMAC_SHIFT)2135#define MVFR1_SIMDFMAC_NONE (UL(0x0) << MVFR1_SIMDFMAC_SHIFT)
1811#define MVFR1_SIMDFMAC_IMPL (UL(0x1) << MVFR1_SIMDFMAC_SHIFT)2136#define MVFR1_SIMDFMAC_IMPL (UL(0x1) << MVFR1_SIMDFMAC_SHIFT)
18122137
1813/* OSDLR_EL1 */2138/* OSDLR_EL1 */
1814#define OSDLR_EL1 MRS_REG(OSDLR_EL1)
1815#define OSDLR_EL1_op0 22139#define OSDLR_EL1_op0 2
1816#define OSDLR_EL1_op1 02140#define OSDLR_EL1_op1 0
1817#define OSDLR_EL1_CRn 12141#define OSDLR_EL1_CRn 1
...@@ -1819,20 +2143,23 @@...@@ -1819,20 +2143,23 @@
1819#define OSDLR_EL1_op2 42143#define OSDLR_EL1_op2 4
18202144
1821/* OSLAR_EL1 */2145/* OSLAR_EL1 */
1822#define OSLAR_EL1 MRS_REG(OSLAR_EL1)
1823#define OSLAR_EL1_op0 22146#define OSLAR_EL1_op0 2
1824#define OSLAR_EL1_op1 02147#define OSLAR_EL1_op1 0
1825#define OSLAR_EL1_CRn 12148#define OSLAR_EL1_CRn 1
1826#define OSLAR_EL1_CRm 02149#define OSLAR_EL1_CRm 0
1827#define OSLAR_EL1_op2 42150#define OSLAR_EL1_op2 4
2151#define OSLAR_OSLK (0x1ul << 0)
18282152
1829/* OSLSR_EL1 */2153/* OSLSR_EL1 */
1830#define OSLSR_EL1 MRS_REG(OSLSR_EL1)
1831#define OSLSR_EL1_op0 22154#define OSLSR_EL1_op0 2
1832#define OSLSR_EL1_op1 02155#define OSLSR_EL1_op1 0
1833#define OSLSR_EL1_CRn 12156#define OSLSR_EL1_CRn 1
1834#define OSLSR_EL1_CRm 12157#define OSLSR_EL1_CRm 1
1835#define OSLSR_EL1_op2 42158#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
1837/* PAR_EL1 - Physical Address Register */2164/* PAR_EL1 - Physical Address Register */
1838#define PAR_F_SHIFT 02165#define PAR_F_SHIFT 0
...@@ -1845,7 +2172,7 @@...@@ -1845,7 +2172,7 @@
1845#define PAR_NS_SHIFT 92172#define PAR_NS_SHIFT 9
1846#define PAR_NS_MASK (0x3 << PAR_NS_SHIFT)2173#define PAR_NS_MASK (0x3 << PAR_NS_SHIFT)
1847#define PAR_PA_SHIFT 122174#define PAR_PA_SHIFT 12
1848#define PAR_PA_MASK 0x0000fffffffff0002175#define PAR_PA_MASK 0x000ffffffffff000
1849#define PAR_ATTR_SHIFT 562176#define PAR_ATTR_SHIFT 56
1850#define PAR_ATTR_MASK (0xff << PAR_ATTR_SHIFT)2177#define PAR_ATTR_MASK (0xff << PAR_ATTR_SHIFT)
1851/* When PAR_F == 1 (aborted) */2178/* When PAR_F == 1 (aborted) */
...@@ -1857,7 +2184,6 @@...@@ -1857,7 +2184,6 @@
1857#define PAR_S_MASK (0x1 << PAR_S_SHIFT)2184#define PAR_S_MASK (0x1 << PAR_S_SHIFT)
18582185
1859/* PMBIDR_EL1 */2186/* PMBIDR_EL1 */
1860#define PMBIDR_EL1 MRS_REG(PMBIDR_EL1)
1861#define PMBIDR_EL1_REG MRS_REG_ALT_NAME(PMBIDR_EL1)2187#define PMBIDR_EL1_REG MRS_REG_ALT_NAME(PMBIDR_EL1)
1862#define PMBIDR_EL1_op0 32188#define PMBIDR_EL1_op0 3
1863#define PMBIDR_EL1_op1 02189#define PMBIDR_EL1_op1 0
...@@ -1872,7 +2198,6 @@...@@ -1872,7 +2198,6 @@
1872#define PMBIDR_F (UL(0x1) << PMBIDR_F_SHIFT)2198#define PMBIDR_F (UL(0x1) << PMBIDR_F_SHIFT)
18732199
1874/* PMBLIMITR_EL1 */2200/* PMBLIMITR_EL1 */
1875#define PMBLIMITR_EL1 MRS_REG(PMBLIMITR_EL1)
1876#define PMBLIMITR_EL1_REG MRS_REG_ALT_NAME(PMBLIMITR_EL1)2201#define PMBLIMITR_EL1_REG MRS_REG_ALT_NAME(PMBLIMITR_EL1)
1877#define PMBLIMITR_EL1_op0 32202#define PMBLIMITR_EL1_op0 3
1878#define PMBLIMITR_EL1_op1 02203#define PMBLIMITR_EL1_op1 0
...@@ -1890,7 +2215,6 @@...@@ -1890,7 +2215,6 @@
1890 (UL(0xfffffffffffff) << PMBLIMITR_LIMIT_SHIFT)2215 (UL(0xfffffffffffff) << PMBLIMITR_LIMIT_SHIFT)
18912216
1892/* PMBPTR_EL1 */2217/* PMBPTR_EL1 */
1893#define PMBPTR_EL1 MRS_REG(PMBPTR_EL1)
1894#define PMBPTR_EL1_REG MRS_REG_ALT_NAME(PMBPTR_EL1)2218#define PMBPTR_EL1_REG MRS_REG_ALT_NAME(PMBPTR_EL1)
1895#define PMBPTR_EL1_op0 32219#define PMBPTR_EL1_op0 3
1896#define PMBPTR_EL1_op1 02220#define PMBPTR_EL1_op1 0
...@@ -1902,7 +2226,6 @@...@@ -1902,7 +2226,6 @@
1902 (UL(0xffffffffffffffff) << PMBPTR_PTR_SHIFT)2226 (UL(0xffffffffffffffff) << PMBPTR_PTR_SHIFT)
19032227
1904/* PMBSR_EL1 */2228/* PMBSR_EL1 */
1905#define PMBSR_EL1 MRS_REG(PMBSR_EL1)
1906#define PMBSR_EL1_REG MRS_REG_ALT_NAME(PMBSR_EL1)2229#define PMBSR_EL1_REG MRS_REG_ALT_NAME(PMBSR_EL1)
1907#define PMBSR_EL1_op0 32230#define PMBSR_EL1_op0 3
1908#define PMBSR_EL1_op1 02231#define PMBSR_EL1_op1 0
...@@ -1925,7 +2248,6 @@...@@ -1925,7 +2248,6 @@
1925#define PMBSR_EC_MASK (UL(0x3f) << PMBSR_EC_SHIFT)2248#define PMBSR_EC_MASK (UL(0x3f) << PMBSR_EC_SHIFT)
19262249
1927/* PMCCFILTR_EL0 */2250/* PMCCFILTR_EL0 */
1928#define PMCCFILTR_EL0 MRS_REG(PMCCFILTR_EL0)
1929#define PMCCFILTR_EL0_op0 32251#define PMCCFILTR_EL0_op0 3
1930#define PMCCFILTR_EL0_op1 32252#define PMCCFILTR_EL0_op1 3
1931#define PMCCFILTR_EL0_CRn 142253#define PMCCFILTR_EL0_CRn 14
...@@ -1933,7 +2255,6 @@...@@ -1933,7 +2255,6 @@
1933#define PMCCFILTR_EL0_op2 72255#define PMCCFILTR_EL0_op2 7
19342256
1935/* PMCCNTR_EL0 */2257/* PMCCNTR_EL0 */
1936#define PMCCNTR_EL0 MRS_REG(PMCCNTR_EL0)
1937#define PMCCNTR_EL0_op0 32258#define PMCCNTR_EL0_op0 3
1938#define PMCCNTR_EL0_op1 32259#define PMCCNTR_EL0_op1 3
1939#define PMCCNTR_EL0_CRn 92260#define PMCCNTR_EL0_CRn 9
...@@ -1941,7 +2262,6 @@...@@ -1941,7 +2262,6 @@
1941#define PMCCNTR_EL0_op2 02262#define PMCCNTR_EL0_op2 0
19422263
1943/* PMCEID0_EL0 */2264/* PMCEID0_EL0 */
1944#define PMCEID0_EL0 MRS_REG(PMCEID0_EL0)
1945#define PMCEID0_EL0_op0 32265#define PMCEID0_EL0_op0 3
1946#define PMCEID0_EL0_op1 32266#define PMCEID0_EL0_op1 3
1947#define PMCEID0_EL0_CRn 92267#define PMCEID0_EL0_CRn 9
...@@ -1949,7 +2269,6 @@...@@ -1949,7 +2269,6 @@
1949#define PMCEID0_EL0_op2 62269#define PMCEID0_EL0_op2 6
19502270
1951/* PMCEID1_EL0 */2271/* PMCEID1_EL0 */
1952#define PMCEID1_EL0 MRS_REG(PMCEID1_EL0)
1953#define PMCEID1_EL0_op0 32272#define PMCEID1_EL0_op0 3
1954#define PMCEID1_EL0_op1 32273#define PMCEID1_EL0_op1 3
1955#define PMCEID1_EL0_CRn 92274#define PMCEID1_EL0_CRn 9
...@@ -1957,7 +2276,6 @@...@@ -1957,7 +2276,6 @@
1957#define PMCEID1_EL0_op2 72276#define PMCEID1_EL0_op2 7
19582277
1959/* PMCNTENCLR_EL0 */2278/* PMCNTENCLR_EL0 */
1960#define PMCNTENCLR_EL0 MRS_REG(PMCNTENCLR_EL0)
1961#define PMCNTENCLR_EL0_op0 32279#define PMCNTENCLR_EL0_op0 3
1962#define PMCNTENCLR_EL0_op1 32280#define PMCNTENCLR_EL0_op1 3
1963#define PMCNTENCLR_EL0_CRn 92281#define PMCNTENCLR_EL0_CRn 9
...@@ -1965,7 +2283,6 @@...@@ -1965,7 +2283,6 @@
1965#define PMCNTENCLR_EL0_op2 22283#define PMCNTENCLR_EL0_op2 2
19662284
1967/* PMCNTENSET_EL0 */2285/* PMCNTENSET_EL0 */
1968#define PMCNTENSET_EL0 MRS_REG(PMCNTENSET_EL0)
1969#define PMCNTENSET_EL0_op0 32286#define PMCNTENSET_EL0_op0 3
1970#define PMCNTENSET_EL0_op1 32287#define PMCNTENSET_EL0_op1 3
1971#define PMCNTENSET_EL0_CRn 92288#define PMCNTENSET_EL0_CRn 9
...@@ -1973,24 +2290,24 @@...@@ -1973,24 +2290,24 @@
1973#define PMCNTENSET_EL0_op2 12290#define PMCNTENSET_EL0_op2 1
19742291
1975/* PMCR_EL0 - Perfomance Monitoring Counters */2292/* PMCR_EL0 - Perfomance Monitoring Counters */
1976#define PMCR_EL0 MRS_REG(PMCR_EL0)
1977#define PMCR_EL0_op0 32293#define PMCR_EL0_op0 3
1978#define PMCR_EL0_op1 32294#define PMCR_EL0_op1 3
1979#define PMCR_EL0_CRn 92295#define PMCR_EL0_CRn 9
1980#define PMCR_EL0_CRm 122296#define PMCR_EL0_CRm 12
1981#define PMCR_EL0_op2 02297#define PMCR_EL0_op2 0
1982#define PMCR_E (1 << 0) /* Enable all counters */2298#define PMCR_E (1ul << 0) /* Enable all counters */
1983#define PMCR_P (1 << 1) /* Reset all counters */2299#define PMCR_P (1ul << 1) /* Reset all counters */
1984#define PMCR_C (1 << 2) /* Clock counter reset */2300#define PMCR_C (1ul << 2) /* Clock counter reset */
1985#define PMCR_D (1 << 3) /* CNTR counts every 64 clk cycles */2301#define PMCR_D (1ul << 3) /* CNTR counts every 64 clk cycles */
1986#define PMCR_X (1 << 4) /* Export to ext. monitoring (ETM) */2302#define PMCR_X (1ul << 4) /* Export to ext. monitoring (ETM) */
1987#define PMCR_DP (1 << 5) /* Disable CCNT if non-invasive debug*/2303#define PMCR_DP (1ul << 5) /* Disable CCNT if non-invasive debug*/
1988#define PMCR_LC (1 << 6) /* Long cycle count enable */2304#define PMCR_LC (1ul << 6) /* Long cycle count enable */
1989#define PMCR_IMP_SHIFT 24 /* Implementer code */2305#define PMCR_LP (1ul << 7) /* Long event count enable */
1990#define PMCR_IMP_MASK (0xff << PMCR_IMP_SHIFT)2306#define PMCR_FZO (1ul << 9) /* Freeze-on-overflow */
1991#define PMCR_IMP_ARM 0x412307#define PMCR_N_SHIFT 11 /* Number of counters implemented */
2308#define PMCR_N_MASK (0x1ful << PMCR_N_SHIFT)
1992#define PMCR_IDCODE_SHIFT 16 /* Identification code */2309#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)
1994#define PMCR_IDCODE_CORTEX_A57 0x012311#define PMCR_IDCODE_CORTEX_A57 0x01
1995#define PMCR_IDCODE_CORTEX_A72 0x022312#define PMCR_IDCODE_CORTEX_A72 0x02
1996#define PMCR_IDCODE_CORTEX_A53 0x032313#define PMCR_IDCODE_CORTEX_A53 0x03
...@@ -2002,8 +2319,10 @@...@@ -2002,8 +2319,10 @@
2002#define PMCR_IDCODE_CORTEX_A55 0x452319#define PMCR_IDCODE_CORTEX_A55 0x45
2003#define PMCR_IDCODE_NEOVERSE_E1 0x462320#define PMCR_IDCODE_NEOVERSE_E1 0x46
2004#define PMCR_IDCODE_CORTEX_A75 0x4a2321#define PMCR_IDCODE_CORTEX_A75 0x4a
2005#define PMCR_N_SHIFT 11 /* Number of counters implemented */2322#define PMCR_IMP_SHIFT 24 /* Implementer code */
2006#define PMCR_N_MASK (0x1f << PMCR_N_SHIFT)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
2008/* PMEVCNTR<n>_EL0 */2327/* PMEVCNTR<n>_EL0 */
2009#define PMEVCNTR_EL0_op0 32328#define PMEVCNTR_EL0_op0 3
...@@ -2035,7 +2354,6 @@...@@ -2035,7 +2354,6 @@
2035#define PMEVTYPER_P (1 << 31) /* Privileged filtering */2354#define PMEVTYPER_P (1 << 31) /* Privileged filtering */
20362355
2037/* PMINTENCLR_EL1 */2356/* PMINTENCLR_EL1 */
2038#define PMINTENCLR_EL1 MRS_REG(PMINTENCLR_EL1)
2039#define PMINTENCLR_EL1_op0 32357#define PMINTENCLR_EL1_op0 3
2040#define PMINTENCLR_EL1_op1 02358#define PMINTENCLR_EL1_op1 0
2041#define PMINTENCLR_EL1_CRn 92359#define PMINTENCLR_EL1_CRn 9
...@@ -2043,7 +2361,6 @@...@@ -2043,7 +2361,6 @@
2043#define PMINTENCLR_EL1_op2 22361#define PMINTENCLR_EL1_op2 2
20442362
2045/* PMINTENSET_EL1 */2363/* PMINTENSET_EL1 */
2046#define PMINTENSET_EL1 MRS_REG(PMINTENSET_EL1)
2047#define PMINTENSET_EL1_op0 32364#define PMINTENSET_EL1_op0 3
2048#define PMINTENSET_EL1_op1 02365#define PMINTENSET_EL1_op1 0
2049#define PMINTENSET_EL1_CRn 92366#define PMINTENSET_EL1_CRn 9
...@@ -2051,7 +2368,6 @@...@@ -2051,7 +2368,6 @@
2051#define PMINTENSET_EL1_op2 12368#define PMINTENSET_EL1_op2 1
20522369
2053/* PMMIR_EL1 */2370/* PMMIR_EL1 */
2054#define PMMIR_EL1 MRS_REG(PMMIR_EL1)
2055#define PMMIR_EL1_op0 32371#define PMMIR_EL1_op0 3
2056#define PMMIR_EL1_op1 02372#define PMMIR_EL1_op1 0
2057#define PMMIR_EL1_CRn 92373#define PMMIR_EL1_CRn 9
...@@ -2059,7 +2375,6 @@...@@ -2059,7 +2375,6 @@
2059#define PMMIR_EL1_op2 62375#define PMMIR_EL1_op2 6
20602376
2061/* PMOVSCLR_EL0 */2377/* PMOVSCLR_EL0 */
2062#define PMOVSCLR_EL0 MRS_REG(PMOVSCLR_EL0)
2063#define PMOVSCLR_EL0_op0 32378#define PMOVSCLR_EL0_op0 3
2064#define PMOVSCLR_EL0_op1 32379#define PMOVSCLR_EL0_op1 3
2065#define PMOVSCLR_EL0_CRn 92380#define PMOVSCLR_EL0_CRn 9
...@@ -2067,7 +2382,6 @@...@@ -2067,7 +2382,6 @@
2067#define PMOVSCLR_EL0_op2 32382#define PMOVSCLR_EL0_op2 3
20682383
2069/* PMOVSSET_EL0 */2384/* PMOVSSET_EL0 */
2070#define PMOVSSET_EL0 MRS_REG(PMOVSSET_EL0)
2071#define PMOVSSET_EL0_op0 32385#define PMOVSSET_EL0_op0 3
2072#define PMOVSSET_EL0_op1 32386#define PMOVSSET_EL0_op1 3
2073#define PMOVSSET_EL0_CRn 92387#define PMOVSSET_EL0_CRn 9
...@@ -2075,7 +2389,6 @@...@@ -2075,7 +2389,6 @@
2075#define PMOVSSET_EL0_op2 32389#define PMOVSSET_EL0_op2 3
20762390
2077/* PMSCR_EL1 */2391/* PMSCR_EL1 */
2078#define PMSCR_EL1 MRS_REG(PMSCR_EL1)
2079#define PMSCR_EL1_REG MRS_REG_ALT_NAME(PMSCR_EL1)2392#define PMSCR_EL1_REG MRS_REG_ALT_NAME(PMSCR_EL1)
2080#define PMSCR_EL1_op0 32393#define PMSCR_EL1_op0 3
2081#define PMSCR_EL1_op1 02394#define PMSCR_EL1_op1 0
...@@ -2096,7 +2409,6 @@...@@ -2096,7 +2409,6 @@
2096#define PMSCR_PCT_MASK (UL(0x3) << PMSCR_PCT_SHIFT)2409#define PMSCR_PCT_MASK (UL(0x3) << PMSCR_PCT_SHIFT)
20972410
2098/* PMSELR_EL0 */2411/* PMSELR_EL0 */
2099#define PMSELR_EL0 MRS_REG(PMSELR_EL0)
2100#define PMSELR_EL0_op0 32412#define PMSELR_EL0_op0 3
2101#define PMSELR_EL0_op1 32413#define PMSELR_EL0_op1 3
2102#define PMSELR_EL0_CRn 92414#define PMSELR_EL0_CRn 9
...@@ -2105,7 +2417,6 @@...@@ -2105,7 +2417,6 @@
2105#define PMSELR_SEL_MASK 0x1f2417#define PMSELR_SEL_MASK 0x1f
21062418
2107/* PMSEVFR_EL1 */2419/* PMSEVFR_EL1 */
2108#define PMSEVFR_EL1 MRS_REG(PMSEVFR_EL1)
2109#define PMSEVFR_EL1_REG MRS_REG_ALT_NAME(PMSEVFR_EL1)2420#define PMSEVFR_EL1_REG MRS_REG_ALT_NAME(PMSEVFR_EL1)
2110#define PMSEVFR_EL1_op0 32421#define PMSEVFR_EL1_op0 3
2111#define PMSEVFR_EL1_op1 02422#define PMSEVFR_EL1_op1 0
...@@ -2114,7 +2425,6 @@...@@ -2114,7 +2425,6 @@
2114#define PMSEVFR_EL1_op2 52425#define PMSEVFR_EL1_op2 5
21152426
2116/* PMSFCR_EL1 */2427/* PMSFCR_EL1 */
2117#define PMSFCR_EL1 MRS_REG(PMSFCR_EL1)
2118#define PMSFCR_EL1_REG MRS_REG_ALT_NAME(PMSFCR_EL1)2428#define PMSFCR_EL1_REG MRS_REG_ALT_NAME(PMSFCR_EL1)
2119#define PMSFCR_EL1_op0 32429#define PMSFCR_EL1_op0 3
2120#define PMSFCR_EL1_op1 02430#define PMSFCR_EL1_op1 0
...@@ -2137,7 +2447,6 @@...@@ -2137,7 +2447,6 @@
2137#define PMSFCR_ST (UL(0x1) << PMSFCR_ST_SHIFT)2447#define PMSFCR_ST (UL(0x1) << PMSFCR_ST_SHIFT)
21382448
2139/* PMSICR_EL1 */2449/* PMSICR_EL1 */
2140#define PMSICR_EL1 MRS_REG(PMSICR_EL1)
2141#define PMSICR_EL1_REG MRS_REG_ALT_NAME(PMSICR_EL1)2450#define PMSICR_EL1_REG MRS_REG_ALT_NAME(PMSICR_EL1)
2142#define PMSICR_EL1_op0 32451#define PMSICR_EL1_op0 3
2143#define PMSICR_EL1_op1 02452#define PMSICR_EL1_op1 0
...@@ -2150,7 +2459,6 @@...@@ -2150,7 +2459,6 @@
2150#define PMSICR_ECOUNT_MASK (UL(0xff) << PMSICR_ECOUNT_SHIFT)2459#define PMSICR_ECOUNT_MASK (UL(0xff) << PMSICR_ECOUNT_SHIFT)
21512460
2152/* PMSIDR_EL1 */2461/* PMSIDR_EL1 */
2153#define PMSIDR_EL1 MRS_REG(PMSIDR_EL1)
2154#define PMSIDR_EL1_REG MRS_REG_ALT_NAME(PMSIDR_EL1)2462#define PMSIDR_EL1_REG MRS_REG_ALT_NAME(PMSIDR_EL1)
2155#define PMSIDR_EL1_op0 32463#define PMSIDR_EL1_op0 3
2156#define PMSIDR_EL1_op1 02464#define PMSIDR_EL1_op1 0
...@@ -2183,7 +2491,6 @@...@@ -2183,7 +2491,6 @@
2183#define PMSIDR_PBT (UL(0x1) << PMSIDR_PBT_SHIFT)2491#define PMSIDR_PBT (UL(0x1) << PMSIDR_PBT_SHIFT)
21842492
2185/* PMSIRR_EL1 */2493/* PMSIRR_EL1 */
2186#define PMSIRR_EL1 MRS_REG(PMSIRR_EL1)
2187#define PMSIRR_EL1_REG MRS_REG_ALT_NAME(PMSIRR_EL1)2494#define PMSIRR_EL1_REG MRS_REG_ALT_NAME(PMSIRR_EL1)
2188#define PMSIRR_EL1_op0 32495#define PMSIRR_EL1_op0 3
2189#define PMSIRR_EL1_op1 02496#define PMSIRR_EL1_op1 0
...@@ -2196,7 +2503,6 @@...@@ -2196,7 +2503,6 @@
2196#define PMSIRR_INTERVAL_MASK (UL(0xffffff) << PMSIRR_INTERVAL_SHIFT)2503#define PMSIRR_INTERVAL_MASK (UL(0xffffff) << PMSIRR_INTERVAL_SHIFT)
21972504
2198/* PMSLATFR_EL1 */2505/* PMSLATFR_EL1 */
2199#define PMSLATFR_EL1 MRS_REG(PMSLATFR_EL1)
2200#define PMSLATFR_EL1_REG MRS_REG_ALT_NAME(PMSLATFR_EL1)2506#define PMSLATFR_EL1_REG MRS_REG_ALT_NAME(PMSLATFR_EL1)
2201#define PMSLATFR_EL1_op0 32507#define PMSLATFR_EL1_op0 3
2202#define PMSLATFR_EL1_op1 02508#define PMSLATFR_EL1_op1 0
...@@ -2207,7 +2513,6 @@...@@ -2207,7 +2513,6 @@
2207#define PMSLATFR_MINLAT_MASK (UL(0xfff) << PMSLATFR_MINLAT_SHIFT)2513#define PMSLATFR_MINLAT_MASK (UL(0xfff) << PMSLATFR_MINLAT_SHIFT)
22082514
2209/* PMSNEVFR_EL1 */2515/* PMSNEVFR_EL1 */
2210#define PMSNEVFR_EL1 MRS_REG(PMSNEVFR_EL1)
2211#define PMSNEVFR_EL1_REG MRS_REG_ALT_NAME(PMSNEVFR_EL1)2516#define PMSNEVFR_EL1_REG MRS_REG_ALT_NAME(PMSNEVFR_EL1)
2212#define PMSNEVFR_EL1_op0 32517#define PMSNEVFR_EL1_op0 3
2213#define PMSNEVFR_EL1_op1 02518#define PMSNEVFR_EL1_op1 0
...@@ -2216,7 +2521,6 @@...@@ -2216,7 +2521,6 @@
2216#define PMSNEVFR_EL1_op2 12521#define PMSNEVFR_EL1_op2 1
22172522
2218/* PMSWINC_EL0 */2523/* PMSWINC_EL0 */
2219#define PMSWINC_EL0 MRS_REG(PMSWINC_EL0)
2220#define PMSWINC_EL0_op0 32524#define PMSWINC_EL0_op0 3
2221#define PMSWINC_EL0_op1 32525#define PMSWINC_EL0_op1 3
2222#define PMSWINC_EL0_CRn 92526#define PMSWINC_EL0_CRn 9
...@@ -2224,7 +2528,6 @@...@@ -2224,7 +2528,6 @@
2224#define PMSWINC_EL0_op2 42528#define PMSWINC_EL0_op2 4
22252529
2226/* PMUSERENR_EL0 */2530/* PMUSERENR_EL0 */
2227#define PMUSERENR_EL0 MRS_REG(PMUSERENR_EL0)
2228#define PMUSERENR_EL0_op0 32531#define PMUSERENR_EL0_op0 3
2229#define PMUSERENR_EL0_op1 32532#define PMUSERENR_EL0_op1 3
2230#define PMUSERENR_EL0_CRn 92533#define PMUSERENR_EL0_CRn 9
...@@ -2232,7 +2535,6 @@...@@ -2232,7 +2535,6 @@
2232#define PMUSERENR_EL0_op2 02535#define PMUSERENR_EL0_op2 0
22332536
2234/* PMXEVCNTR_EL0 */2537/* PMXEVCNTR_EL0 */
2235#define PMXEVCNTR_EL0 MRS_REG(PMXEVCNTR_EL0)
2236#define PMXEVCNTR_EL0_op0 32538#define PMXEVCNTR_EL0_op0 3
2237#define PMXEVCNTR_EL0_op1 32539#define PMXEVCNTR_EL0_op1 3
2238#define PMXEVCNTR_EL0_CRn 92540#define PMXEVCNTR_EL0_CRn 9
...@@ -2240,7 +2542,6 @@...@@ -2240,7 +2542,6 @@
2240#define PMXEVCNTR_EL0_op2 22542#define PMXEVCNTR_EL0_op2 2
22412543
2242/* PMXEVTYPER_EL0 */2544/* PMXEVTYPER_EL0 */
2243#define PMXEVTYPER_EL0 MRS_REG(PMXEVTYPER_EL0)
2244#define PMXEVTYPER_EL0_op0 32545#define PMXEVTYPER_EL0_op0 3
2245#define PMXEVTYPER_EL0_op1 32546#define PMXEVTYPER_EL0_op1 3
2246#define PMXEVTYPER_EL0_CRn 92547#define PMXEVTYPER_EL0_CRn 9
...@@ -2248,7 +2549,6 @@...@@ -2248,7 +2549,6 @@
2248#define PMXEVTYPER_EL0_op2 12549#define PMXEVTYPER_EL0_op2 1
22492550
2250/* RNDRRS */2551/* RNDRRS */
2251#define RNDRRS MRS_REG(RNDRRS)
2252#define RNDRRS_REG MRS_REG_ALT_NAME(RNDRRS)2552#define RNDRRS_REG MRS_REG_ALT_NAME(RNDRRS)
2253#define RNDRRS_op0 32553#define RNDRRS_op0 3
2254#define RNDRRS_op1 32554#define RNDRRS_op1 3
...@@ -2313,6 +2613,26 @@...@@ -2313,6 +2613,26 @@
2313#define SCTLR_EnALS (UL(0x1) << 56)2613#define SCTLR_EnALS (UL(0x1) << 56)
2314#define SCTLR_EPAN (UL(0x1) << 57)2614#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
2316/* SCTLR_EL12 */2636/* SCTLR_EL12 */
2317#define SCTLR_EL12_REG MRS_REG_ALT_NAME(SCTLR_EL12)2637#define SCTLR_EL12_REG MRS_REG_ALT_NAME(SCTLR_EL12)
2318#define SCTLR_EL12_op0 32638#define SCTLR_EL12_op0 3
...@@ -2354,7 +2674,8 @@...@@ -2354,7 +2674,8 @@
2354#define PSR_D 0x00000200UL2674#define PSR_D 0x00000200UL
2355#define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F)2675#define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F)
2356/* The default DAIF mask. These bits are valid in spsr_el1 and daif */2676/* 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)
2358#define PSR_BTYPE 0x00000c00UL2679#define PSR_BTYPE 0x00000c00UL
2359#define PSR_SSBS 0x00001000UL2680#define PSR_SSBS 0x00001000UL
2360#define PSR_ALLINT 0x00002000UL2681#define PSR_ALLINT 0x00002000UL
...@@ -2382,7 +2703,6 @@...@@ -2382,7 +2703,6 @@
2382#define SPSR_EL12_op2 02703#define SPSR_EL12_op2 0
23832704
2384/* REVIDR_EL1 - Revision ID Register */2705/* REVIDR_EL1 - Revision ID Register */
2385#define REVIDR_EL1 MRS_REG(REVIDR_EL1)
2386#define REVIDR_EL1_op0 32706#define REVIDR_EL1_op0 3
2387#define REVIDR_EL1_op1 02707#define REVIDR_EL1_op1 0
2388#define REVIDR_EL1_CRn 02708#define REVIDR_EL1_CRn 0
...@@ -2496,14 +2816,6 @@...@@ -2496,14 +2816,6 @@
2496#define TCR_T0SZ(x) ((x) << TCR_T0SZ_SHIFT)2816#define TCR_T0SZ(x) ((x) << TCR_T0SZ_SHIFT)
2497#define TCR_TxSZ(x) (TCR_T1SZ(x) | TCR_T0SZ(x))2817#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
2507/* TCR_EL12 */2819/* TCR_EL12 */
2508#define TCR_EL12_REG MRS_REG_ALT_NAME(TCR_EL12)2820#define TCR_EL12_REG MRS_REG_ALT_NAME(TCR_EL12)
2509#define TCR_EL12_op0 32821#define TCR_EL12_op0 3
...@@ -2568,13 +2880,12 @@...@@ -2568,13 +2880,12 @@
2568#define VBAR_EL12_op2 02880#define VBAR_EL12_op2 0
25692881
2570/* ZCR_EL1 - SVE Control Register */2882/* ZCR_EL1 - SVE Control Register */
2571#define ZCR_EL1 MRS_REG(ZCR_EL1)2883#define ZCR_EL1_REG MRS_REG_ALT_NAME(ZCR_EL1)
2572#define ZCR_EL1_REG MRS_REG_ALT_NAME(ZCR_EL1_REG)2884#define ZCR_EL1_op0 3
2573#define ZCR_EL1_REG_op0 32885#define ZCR_EL1_op1 0
2574#define ZCR_EL1_REG_op1 02886#define ZCR_EL1_CRn 1
2575#define ZCR_EL1_REG_CRn 12887#define ZCR_EL1_CRm 2
2576#define ZCR_EL1_REG_CRm 22888#define ZCR_EL1_op2 0
2577#define ZCR_EL1_REG_op2 0
2578#define ZCR_LEN_SHIFT 02889#define ZCR_LEN_SHIFT 0
2579#define ZCR_LEN_MASK (0xf << ZCR_LEN_SHIFT)2890#define ZCR_LEN_MASK (0xf << ZCR_LEN_SHIFT)
2580#define ZCR_LEN_BYTES(x) ((((x) & ZCR_LEN_MASK) + 1) * 16)2891#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 @@...@@ -72,6 +72,17 @@
72/* Alias for link register x30 */72/* Alias for link register x30 */
73#define lr x3073#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
75/*86/*
76 * Sets the trap fault handler. The exception handler will return to the87 * Sets the trap fault handler. The exception handler will return to the
77 * address in the handler register on a data abort or the xzr register to88 * address in the handler register on a data abort or the xzr register to
...@@ -87,19 +98,25 @@...@@ -87,19 +98,25 @@
87 ldr tmp, =has_pan; /* Get the addr of has_pan */ \98 ldr tmp, =has_pan; /* Get the addr of has_pan */ \
88 ldr reg, [tmp]; /* Read it */ \99 ldr reg, [tmp]; /* Read it */ \
89 cbz reg, 997f; /* If no PAN skip */ \100 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; \
91 997:104 997:
92105
93#define EXIT_USER_ACCESS(reg) \106#define EXIT_USER_ACCESS(reg) \
94 cbz reg, 998f; /* If no PAN skip */ \107 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; \
96 998:111 998:
97112
98#define EXIT_USER_ACCESS_CHECK(reg, tmp) \113#define EXIT_USER_ACCESS_CHECK(reg, tmp) \
99 ldr tmp, =has_pan; /* Get the addr of has_pan */ \114 ldr tmp, =has_pan; /* Get the addr of has_pan */ \
100 ldr reg, [tmp]; /* Read it */ \115 ldr reg, [tmp]; /* Read it */ \
101 cbz reg, 999f; /* If no PAN skip */ \116 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; \
103 999:120 999:
104121
105/*122/*
lib/libc/include/aarch64-freebsd-none/machine/atomic.h+3-1
...@@ -465,7 +465,7 @@ _ATOMIC_TEST_OP(set, orr, set)...@@ -465,7 +465,7 @@ _ATOMIC_TEST_OP(set, orr, set)
465465
466#define _ATOMIC_LOAD_ACQ_IMPL(t, w, s) \466#define _ATOMIC_LOAD_ACQ_IMPL(t, w, s) \
467static __inline uint##t##_t \467static __inline uint##t##_t \
468atomic_load_acq_##t(volatile uint##t##_t *p) \468atomic_load_acq_##t(const volatile uint##t##_t *p) \
469{ \469{ \
470 uint##t##_t ret; \470 uint##t##_t ret; \
471 \471 \
...@@ -609,6 +609,8 @@ _ATOMIC_STORE_REL_IMPL(64, , )...@@ -609,6 +609,8 @@ _ATOMIC_STORE_REL_IMPL(64, , )
609#define atomic_set_ptr atomic_set_64609#define atomic_set_ptr atomic_set_64
610#define atomic_swap_ptr atomic_swap_64610#define atomic_swap_ptr atomic_swap_64
611#define atomic_subtract_ptr atomic_subtract_64611#define atomic_subtract_ptr atomic_subtract_64
612#define atomic_testandclear_ptr atomic_testandclear_64
613#define atomic_testandset_ptr atomic_testandset_64
612614
613#define atomic_add_acq_long atomic_add_acq_64615#define atomic_add_acq_long atomic_add_acq_64
614#define atomic_fcmpset_acq_long atomic_fcmpset_acq_64616#define atomic_fcmpset_acq_long atomic_fcmpset_acq_64
lib/libc/include/aarch64-freebsd-none/machine/bus.h+1
...@@ -76,6 +76,7 @@...@@ -76,6 +76,7 @@
7676
77#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL77#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL
78#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL78#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL
79#define BUS_SPACE_MAXADDR_36BIT 0xFFFFFFFFFUL
79#define BUS_SPACE_MAXADDR_40BIT 0xFFFFFFFFFFUL80#define BUS_SPACE_MAXADDR_40BIT 0xFFFFFFFFFFUL
80#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL81#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL
81#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL82#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,...@@ -61,7 +61,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
6161
62/*62/*
63 * Free a piece of memory and it's allociated dmamap, that was allocated63 * 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.
65 */65 */
66static inline void66static inline void
67bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)67bus_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,...@@ -148,4 +148,16 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
148 return (tc->impl->map_complete(dmat, map, segs, nsegs, error));148 return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
149}149}
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
151#endif /* !_MACHINE_BUS_DMA_H_ */163#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 @@...@@ -31,28 +31,23 @@
3131
32struct bus_dma_tag_common {32struct bus_dma_tag_common {
33 struct bus_dma_impl *impl;33 struct bus_dma_impl *impl;
34 struct bus_dma_tag_common *parent;
35 bus_size_t alignment;34 bus_size_t alignment;
36 bus_addr_t boundary;35 bus_addr_t boundary;
37 bus_addr_t lowaddr;36 bus_addr_t lowaddr;
38 bus_addr_t highaddr;37 bus_addr_t highaddr;
39 bus_dma_filter_t *filter;
40 void *filterarg;
41 bus_size_t maxsize;38 bus_size_t maxsize;
42 u_int nsegments;39 u_int nsegments;
43 bus_size_t maxsegsz;40 bus_size_t maxsegsz;
44 int flags;41 int flags;
45 bus_dma_lock_t *lockfunc;42 bus_dma_lock_t *lockfunc;
46 void *lockfuncarg;43 void *lockfuncarg;
47 int ref_count;
48 int domain;44 int domain;
49};45};
5046
51struct bus_dma_impl {47struct bus_dma_impl {
52 int (*tag_create)(bus_dma_tag_t parent,48 int (*tag_create)(bus_dma_tag_t parent,
53 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,49 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
54 bus_addr_t highaddr, bus_dma_filter_t *filter,50 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
55 void *filterarg, bus_size_t maxsize, int nsegments,
56 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,51 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
57 void *lockfuncarg, bus_dma_tag_t *dmat);52 void *lockfuncarg, bus_dma_tag_t *dmat);
58 int (*tag_destroy)(bus_dma_tag_t dmat);53 int (*tag_destroy)(bus_dma_tag_t dmat);
...@@ -80,14 +75,15 @@ struct bus_dma_impl {...@@ -80,14 +75,15 @@ struct bus_dma_impl {
80 void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map);75 void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map);
81 void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map,76 void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map,
82 bus_dmasync_op_t op);77 bus_dmasync_op_t op);
78#ifdef KMSAN
79 void (*load_kmsan)(bus_dmamap_t map, struct memdesc *mem);
80#endif
83};81};
8482
85int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
86int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,83int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
87 bus_size_t alignment,84 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
88 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,85 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
89 bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,86 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
90 int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
91 void *lockfuncarg, size_t sz, void **dmat);87 void *lockfuncarg, size_t sz, void **dmat);
9288
93extern struct bus_dma_impl bus_dma_bounce_impl;89extern struct bus_dma_impl bus_dma_bounce_impl;
lib/libc/include/aarch64-freebsd-none/machine/cpu.h+65-8
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
37 * from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/2935 * from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/29
38 */36 */
3937
...@@ -77,6 +75,7 @@...@@ -77,6 +75,7 @@
77#define CPU_IMPL_CAVIUM 0x4375#define CPU_IMPL_CAVIUM 0x43
78#define CPU_IMPL_DEC 0x4476#define CPU_IMPL_DEC 0x44
79#define CPU_IMPL_FUJITSU 0x4677#define CPU_IMPL_FUJITSU 0x46
78#define CPU_IMPL_HISILICON 0x48
80#define CPU_IMPL_INFINEON 0x4979#define CPU_IMPL_INFINEON 0x49
81#define CPU_IMPL_FREESCALE 0x4D80#define CPU_IMPL_FREESCALE 0x4D
82#define CPU_IMPL_NVIDIA 0x4E81#define CPU_IMPL_NVIDIA 0x4E
...@@ -86,6 +85,7 @@...@@ -86,6 +85,7 @@
86#define CPU_IMPL_APPLE 0x6185#define CPU_IMPL_APPLE 0x61
87#define CPU_IMPL_INTEL 0x6986#define CPU_IMPL_INTEL 0x69
88#define CPU_IMPL_AMPERE 0xC087#define CPU_IMPL_AMPERE 0xC0
88#define CPU_IMPL_MICROSOFT 0x6D
8989
90/* ARM Part numbers */90/* ARM Part numbers */
91#define CPU_PART_FOUNDATION 0xD0091#define CPU_PART_FOUNDATION 0xD00
...@@ -105,6 +105,7 @@...@@ -105,6 +105,7 @@
105#define CPU_PART_AEM_V8 0xD0F105#define CPU_PART_AEM_V8 0xD0F
106#define CPU_PART_NEOVERSE_V1 0xD40106#define CPU_PART_NEOVERSE_V1 0xD40
107#define CPU_PART_CORTEX_A78 0xD41107#define CPU_PART_CORTEX_A78 0xD41
108#define CPU_PART_CORTEX_A78AE 0xD42
108#define CPU_PART_CORTEX_A65AE 0xD43109#define CPU_PART_CORTEX_A65AE 0xD43
109#define CPU_PART_CORTEX_X1 0xD44110#define CPU_PART_CORTEX_X1 0xD44
110#define CPU_PART_CORTEX_A510 0xD46111#define CPU_PART_CORTEX_A510 0xD46
...@@ -117,6 +118,18 @@...@@ -117,6 +118,18 @@
117#define CPU_PART_CORTEX_A715 0xD4D118#define CPU_PART_CORTEX_A715 0xD4D
118#define CPU_PART_CORTEX_X3 0xD4E119#define CPU_PART_CORTEX_X3 0xD4E
119#define CPU_PART_NEOVERSE_V2 0xD4F120#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
121/* Cavium Part numbers */134/* Cavium Part numbers */
122#define CPU_PART_THUNDERX 0x0A1135#define CPU_PART_THUNDERX 0x0A1
...@@ -129,9 +142,16 @@...@@ -129,9 +142,16 @@
129142
130#define CPU_REV_THUNDERX2_0 0x00143#define CPU_REV_THUNDERX2_0 0x00
131144
132/* APM / Ampere Part Number */145/* APM (now Ampere) Part number */
133#define CPU_PART_EMAG8180 0x000146#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
135/* Qualcomm */155/* Qualcomm */
136#define CPU_PART_KRYO400_GOLD 0x804156#define CPU_PART_KRYO400_GOLD 0x804
137#define CPU_PART_KRYO400_SILVER 0x805157#define CPU_PART_KRYO400_SILVER 0x805
...@@ -177,8 +197,30 @@...@@ -177,8 +197,30 @@
177 (((mask) & PCPU_GET(midr)) == \197 (((mask) & PCPU_GET(midr)) == \
178 ((mask) & CPU_ID_RAW((impl), (part), (var), (rev))))198 ((mask) & CPU_ID_RAW((impl), (part), (var), (rev))))
179199
180#define CPU_MATCH_RAW(mask, devid) \200#if !defined(__ASSEMBLER__)
181 (((mask) & PCPU_GET(midr)) == ((mask) & (devid)))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
183/*225/*
184 * Chip-specific errata. This defines are intended to be226 * Chip-specific errata. This defines are intended to be
...@@ -210,6 +252,12 @@ extern uint64_t __cpu_affinity[];...@@ -210,6 +252,12 @@ extern uint64_t __cpu_affinity[];
210252
211struct arm64_addr_mask;253struct arm64_addr_mask;
212extern struct arm64_addr_mask elf64_addr_mask;254extern 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
214void cpu_halt(void) __dead2;262void cpu_halt(void) __dead2;
215void cpu_reset(void) __dead2;263void cpu_reset(void) __dead2;
...@@ -231,9 +279,18 @@ void ptrauth_mp_start(uint64_t);...@@ -231,9 +279,18 @@ void ptrauth_mp_start(uint64_t);
231279
232/* Functions to read the sanitised view of the special registers */280/* Functions to read the sanitised view of the special registers */
233void update_special_regs(u_int);281void update_special_regs(u_int);
234bool extract_user_id_field(u_int, u_int, uint8_t *);282void update_special_reg_iss(u_int, uint64_t, uint64_t);
235bool get_kernel_reg(u_int, uint64_t *);283#define update_special_reg(reg, clear, set) \
236bool get_kernel_reg_masked(u_int, uint64_t *, uint64_t);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
238void cpu_desc_init(void);295void 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)...@@ -41,8 +41,6 @@ breakpoint(void)
41#ifdef _KERNEL41#ifdef _KERNEL
42#include <machine/armreg.h>42#include <machine/armreg.h>
4343
44void pan_enable(void);
45
46static __inline register_t44static __inline register_t
47dbg_disable(void)45dbg_disable(void)
48{46{
...@@ -160,6 +158,26 @@ invalidate_local_icache(void)...@@ -160,6 +158,26 @@ invalidate_local_icache(void)
160 "isb \n");158 "isb \n");
161}159}
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
163extern bool icache_aliasing;181extern bool icache_aliasing;
164extern bool icache_vmid;182extern bool icache_vmid;
165183
...@@ -177,21 +195,21 @@ extern int64_t dczva_line_size;...@@ -177,21 +195,21 @@ extern int64_t dczva_line_size;
177#define cpu_dcache_inv_range(a, s) arm64_dcache_inv_range((a), (s))195#define cpu_dcache_inv_range(a, s) arm64_dcache_inv_range((a), (s))
178#define cpu_dcache_wb_range(a, s) arm64_dcache_wb_range((a), (s))196#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
182#define cpu_icache_sync_range(a, s) arm64_icache_sync_range((a), (s))200#define cpu_icache_sync_range(a, s) arm64_icache_sync_range((a), (s))
183#define cpu_icache_sync_range_checked(a, s) arm64_icache_sync_range_checked((a), (s))201#define cpu_icache_sync_range_checked(a, s) arm64_icache_sync_range_checked((a), (s))
184202
185void arm64_nullop(void);203void arm64_nullop(void);
186void arm64_tlb_flushID(void);204void arm64_tlb_flushID(void);
187void arm64_dic_idc_icache_sync_range(vm_offset_t, vm_size_t);205void arm64_dic_idc_icache_sync_range(void *, vm_size_t);
188void arm64_idc_aliasing_icache_sync_range(vm_offset_t, vm_size_t);206void arm64_idc_aliasing_icache_sync_range(void *, vm_size_t);
189void arm64_aliasing_icache_sync_range(vm_offset_t, vm_size_t);207void arm64_aliasing_icache_sync_range(void *, vm_size_t);
190int arm64_icache_sync_range_checked(vm_offset_t, vm_size_t);208int arm64_icache_sync_range_checked(void *, vm_size_t);
191void arm64_dcache_wbinv_range(vm_offset_t, vm_size_t);209void arm64_dcache_wbinv_range(void *, vm_size_t);
192void arm64_dcache_inv_range(vm_offset_t, vm_size_t);210void arm64_dcache_inv_range(void *, vm_size_t);
193void arm64_dcache_wb_range(vm_offset_t, vm_size_t);211void arm64_dcache_wb_range(void *, vm_size_t);
194bool arm64_get_writable_addr(vm_offset_t, vm_offset_t *);212bool arm64_get_writable_addr(void *, void **);
195213
196#endif /* _KERNEL */214#endif /* _KERNEL */
197#endif /* _MACHINE_CPUFUNC_H_ */215#endif /* _MACHINE_CPUFUNC_H_ */
lib/libc/include/aarch64-freebsd-none/machine/db_machdep.h+3
...@@ -40,6 +40,9 @@...@@ -40,6 +40,9 @@
40#define T_SINGLESTEP (EXCP_SOFTSTP_EL1)40#define T_SINGLESTEP (EXCP_SOFTSTP_EL1)
41#define T_WATCHPOINT (EXCP_WATCHPT_EL1)41#define T_WATCHPOINT (EXCP_WATCHPT_EL1)
4242
43#define HAS_HW_BREAKPOINT
44#define NHBREAKPOINTS 16
45
43typedef vm_offset_t db_addr_t;46typedef vm_offset_t db_addr_t;
44typedef long db_expr_t;47typedef 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);...@@ -56,6 +56,7 @@ void dbg_monitor_init(void);
56void dbg_register_sync(struct debug_monitor_state *);56void dbg_register_sync(struct debug_monitor_state *);
5757
58#ifdef DDB58#ifdef DDB
59void dbg_show_breakpoint(void);
59void dbg_show_watchpoint(void);60void dbg_show_watchpoint(void);
60#endif61#endif
6162
lib/libc/include/aarch64-freebsd-none/machine/efi.h+3-1
...@@ -35,6 +35,8 @@...@@ -35,6 +35,8 @@
35#ifndef __ARM64_INCLUDE_EFI_H_35#ifndef __ARM64_INCLUDE_EFI_H_
36#define __ARM64_INCLUDE_EFI_H_36#define __ARM64_INCLUDE_EFI_H_
3737
38#include <sys/types.h>
39
38#define EFIABI_ATTR40#define EFIABI_ATTR
3941
40#ifdef _KERNEL42#ifdef _KERNEL
...@@ -44,7 +46,7 @@...@@ -44,7 +46,7 @@
44#define EFI_TIME_UNLOCK()46#define EFI_TIME_UNLOCK()
45#define EFI_TIME_OWNED()47#define EFI_TIME_OWNED()
4648
47#define EFI_RT_HANDLE_FAULTS_DEFAULT 049#define EFI_RT_HANDLE_FAULTS_DEFAULT 1
48#endif50#endif
4951
50struct efirt_callinfo {52struct efirt_callinfo {
lib/libc/include/aarch64-freebsd-none/machine/elf.h+100-77
...@@ -93,91 +93,114 @@ __ElfType(Auxinfo);...@@ -93,91 +93,114 @@ __ElfType(Auxinfo);
93#define ET_DYN_LOAD_ADDR 0x10000093#define ET_DYN_LOAD_ADDR 0x100000
94#endif94#endif
9595
96/* First __FreeBSD_version that supports Top Byte Ignore (TBI) */
97#define TBI_VERSION 1500058
98
96/* HWCAP */99/* HWCAP */
97#define HWCAP_FP 0x00000001100#define HWCAP_FP (1 << 0)
98#define HWCAP_ASIMD 0x00000002101#define HWCAP_ASIMD (1 << 1)
99#define HWCAP_EVTSTRM 0x00000004102#define HWCAP_EVTSTRM (1 << 2)
100#define HWCAP_AES 0x00000008103#define HWCAP_AES (1 << 3)
101#define HWCAP_PMULL 0x00000010104#define HWCAP_PMULL (1 << 4)
102#define HWCAP_SHA1 0x00000020105#define HWCAP_SHA1 (1 << 5)
103#define HWCAP_SHA2 0x00000040106#define HWCAP_SHA2 (1 << 6)
104#define HWCAP_CRC32 0x00000080107#define HWCAP_CRC32 (1 << 7)
105#define HWCAP_ATOMICS 0x00000100108#define HWCAP_ATOMICS (1 << 8)
106#define HWCAP_FPHP 0x00000200109#define HWCAP_FPHP (1 << 9)
107#define HWCAP_ASIMDHP 0x00000400110#define HWCAP_ASIMDHP (1 << 10)
108/*111/*
109 * XXX: The following bits (from CPUID to FLAGM) were originally incorrect,112 * XXX: The following bits (from CPUID to FLAGM) were originally incorrect,
110 * but later changed to match the Linux definitions. No compatibility code is113 * but later changed to match the Linux definitions. No compatibility code is
111 * provided, as the fix was expected to result in near-zero fallout.114 * provided, as the fix was expected to result in near-zero fallout.
112 */115 */
113#define HWCAP_CPUID 0x00000800116#define HWCAP_CPUID (1 << 11)
114#define HWCAP_ASIMDRDM 0x00001000117#define HWCAP_ASIMDRDM (1 << 12)
115#define HWCAP_JSCVT 0x00002000118#define HWCAP_JSCVT (1 << 13)
116#define HWCAP_FCMA 0x00004000119#define HWCAP_FCMA (1 << 14)
117#define HWCAP_LRCPC 0x00008000120#define HWCAP_LRCPC (1 << 15)
118#define HWCAP_DCPOP 0x00010000121#define HWCAP_DCPOP (1 << 16)
119#define HWCAP_SHA3 0x00020000122#define HWCAP_SHA3 (1 << 17)
120#define HWCAP_SM3 0x00040000123#define HWCAP_SM3 (1 << 18)
121#define HWCAP_SM4 0x00080000124#define HWCAP_SM4 (1 << 19)
122#define HWCAP_ASIMDDP 0x00100000125#define HWCAP_ASIMDDP (1 << 20)
123#define HWCAP_SHA512 0x00200000126#define HWCAP_SHA512 (1 << 21)
124#define HWCAP_SVE 0x00400000127#define HWCAP_SVE (1 << 22)
125#define HWCAP_ASIMDFHM 0x00800000128#define HWCAP_ASIMDFHM (1 << 23)
126#define HWCAP_DIT 0x01000000129#define HWCAP_DIT (1 << 24)
127#define HWCAP_USCAT 0x02000000130#define HWCAP_USCAT (1 << 25)
128#define HWCAP_ILRCPC 0x04000000131#define HWCAP_ILRCPC (1 << 26)
129#define HWCAP_FLAGM 0x08000000132#define HWCAP_FLAGM (1 << 27)
130#define HWCAP_SSBS 0x10000000133#define HWCAP_SSBS (1 << 28)
131#define HWCAP_SB 0x20000000134#define HWCAP_SB (1 << 29)
132#define HWCAP_PACA 0x40000000135#define HWCAP_PACA (1 << 30)
133#define HWCAP_PACG 0x80000000136#define HWCAP_PACG (1UL << 31)
137#define HWCAP_GCS (1UL << 32)
134138
135/* HWCAP2 */139/* HWCAP2 */
136#define HWCAP2_DCPODP 0x0000000000000001ul140#define HWCAP2_DCPODP (1 << 0)
137#define HWCAP2_SVE2 0x0000000000000002ul141#define HWCAP2_SVE2 (1 << 1)
138#define HWCAP2_SVEAES 0x0000000000000004ul142#define HWCAP2_SVEAES (1 << 2)
139#define HWCAP2_SVEPMULL 0x0000000000000008ul143#define HWCAP2_SVEPMULL (1 << 3)
140#define HWCAP2_SVEBITPERM 0x0000000000000010ul144#define HWCAP2_SVEBITPERM (1 << 4)
141#define HWCAP2_SVESHA3 0x0000000000000020ul145#define HWCAP2_SVESHA3 (1 << 5)
142#define HWCAP2_SVESM4 0x0000000000000040ul146#define HWCAP2_SVESM4 (1 << 6)
143#define HWCAP2_FLAGM2 0x0000000000000080ul147#define HWCAP2_FLAGM2 (1 << 7)
144#define HWCAP2_FRINT 0x0000000000000100ul148#define HWCAP2_FRINT (1 << 8)
145#define HWCAP2_SVEI8MM 0x0000000000000200ul149#define HWCAP2_SVEI8MM (1 << 9)
146#define HWCAP2_SVEF32MM 0x0000000000000400ul150#define HWCAP2_SVEF32MM (1 << 10)
147#define HWCAP2_SVEF64MM 0x0000000000000800ul151#define HWCAP2_SVEF64MM (1 << 11)
148#define HWCAP2_SVEBF16 0x0000000000001000ul152#define HWCAP2_SVEBF16 (1 << 12)
149#define HWCAP2_I8MM 0x0000000000002000ul153#define HWCAP2_I8MM (1 << 13)
150#define HWCAP2_BF16 0x0000000000004000ul154#define HWCAP2_BF16 (1 << 14)
151#define HWCAP2_DGH 0x0000000000008000ul155#define HWCAP2_DGH (1 << 15)
152#define HWCAP2_RNG 0x0000000000010000ul156#define HWCAP2_RNG (1 << 16)
153#define HWCAP2_BTI 0x0000000000020000ul157#define HWCAP2_BTI (1 << 17)
154#define HWCAP2_MTE 0x0000000000040000ul158#define HWCAP2_MTE (1 << 18)
155#define HWCAP2_ECV 0x0000000000080000ul159#define HWCAP2_ECV (1 << 19)
156#define HWCAP2_AFP 0x0000000000100000ul160#define HWCAP2_AFP (1 << 20)
157#define HWCAP2_RPRES 0x0000000000200000ul161#define HWCAP2_RPRES (1 << 21)
158#define HWCAP2_MTE3 0x0000000000400000ul162#define HWCAP2_MTE3 (1 << 22)
159#define HWCAP2_SME 0x0000000000800000ul163#define HWCAP2_SME (1 << 23)
160#define HWCAP2_SME_I16I64 0x0000000001000000ul164#define HWCAP2_SME_I16I64 (1 << 24)
161#define HWCAP2_SME_F64F64 0x0000000002000000ul165#define HWCAP2_SME_F64F64 (1 << 25)
162#define HWCAP2_SME_I8I32 0x0000000004000000ul166#define HWCAP2_SME_I8I32 (1 << 26)
163#define HWCAP2_SME_F16F32 0x0000000008000000ul167#define HWCAP2_SME_F16F32 (1 << 27)
164#define HWCAP2_SME_B16F32 0x0000000010000000ul168#define HWCAP2_SME_B16F32 (1 << 28)
165#define HWCAP2_SME_F32F32 0x0000000020000000ul169#define HWCAP2_SME_F32F32 (1 << 29)
166#define HWCAP2_SME_FA64 0x0000000040000000ul170#define HWCAP2_SME_FA64 (1 << 30)
167#define HWCAP2_WFXT 0x0000000080000000ul171#define HWCAP2_WFXT (1UL << 31)
168#define HWCAP2_EBF16 0x0000000100000000ul172#define HWCAP2_EBF16 (1UL << 32)
169#define HWCAP2_SVE_EBF16 0x0000000200000000ul173#define HWCAP2_SVE_EBF16 (1UL << 33)
170#define HWCAP2_CSSC 0x0000000400000000ul174#define HWCAP2_CSSC (1UL << 34)
171#define HWCAP2_RPRFM 0x0000000800000000ul175#define HWCAP2_RPRFM (1UL << 35)
172#define HWCAP2_SVE2P1 0x0000001000000000ul176#define HWCAP2_SVE2P1 (1UL << 36)
173#define HWCAP2_SME2 0x0000002000000000ul177#define HWCAP2_SME2 (1UL << 37)
174#define HWCAP2_SME2P1 0x0000004000000000ul178#define HWCAP2_SME2P1 (1UL << 38)
175#define HWCAP2_SME_I16I32 0x0000008000000000ul179#define HWCAP2_SME_I16I32 (1UL << 39)
176#define HWCAP2_SME_BI32I32 0x0000010000000000ul180#define HWCAP2_SME_BI32I32 (1UL << 40)
177#define HWCAP2_SME_B16B16 0x0000020000000000ul181#define HWCAP2_SME_B16B16 (1UL << 41)
178#define HWCAP2_SME_F16F16 0x0000040000000000ul182#define HWCAP2_SME_F16F16 (1UL << 42)
179#define HWCAP2_MOPS 0x0000080000000000ul183#define HWCAP2_MOPS (1UL << 43)
180#define HWCAP2_HBC 0x0000100000000000ul184#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
182#ifdef COMPAT_FREEBSD32205#ifdef COMPAT_FREEBSD32
183/* ARM HWCAP */206/* ARM HWCAP */
lib/libc/include/aarch64-freebsd-none/machine/endian.h-2
...@@ -24,8 +24,6 @@...@@ -24,8 +24,6 @@
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24 * 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 OF25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.26 * SUCH DAMAGE.
27 *
28 * @(#)endian.h 8.1 (Berkeley) 6/10/93
29 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $27 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
30 */28 */
3129
lib/libc/include/aarch64-freebsd-none/machine/float.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
30 */28 */
3129
32#ifdef __arm__30#ifdef __arm__
lib/libc/include/aarch64-freebsd-none/machine/frame.h+1-1
...@@ -70,7 +70,7 @@ struct frame {...@@ -70,7 +70,7 @@ struct frame {
7070
71#ifdef COMPAT_FREEBSD3271#ifdef COMPAT_FREEBSD32
72struct sigframe32 {72struct sigframe32 {
73 struct siginfo32 sf_si;73 struct __siginfo32 sf_si;
74 ucontext32_t sf_uc;74 ucontext32_t sf_uc;
75 mcontext32_vfp_t sf_vfp;75 mcontext32_vfp_t sf_vfp;
76};76};
lib/libc/include/aarch64-freebsd-none/machine/hypervisor.h+105-50
...@@ -41,21 +41,38 @@...@@ -41,21 +41,38 @@
41#define CNTHCTL_EL1PCTEN (1 << 0) /* Allow physical counter access */41#define CNTHCTL_EL1PCTEN (1 << 0) /* Allow physical counter access */
42#define CNTHCTL_EL1PCEN (1 << 1) /* Allow physical timer access */42#define CNTHCTL_EL1PCEN (1 << 1) /* Allow physical timer access */
43/* Valid if HCR_EL2.E2H == 1 */43/* 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)
44#define CNTHCTL_E2H_EL1PCTEN (1 << 10) /* Allow physical counter access */48#define CNTHCTL_E2H_EL1PCTEN (1 << 10) /* Allow physical counter access */
45#define CNTHCTL_E2H_EL1PTEN (1 << 11) /* Allow physical timer access */49#define CNTHCTL_E2H_EL1PTEN (1 << 11) /* Allow physical timer access */
46/* Unconditionally valid */50/* Unconditionally valid */
47#define CNTHCTL_EVNTDIR (1 << 3) /* Control transition trigger bit */51#define CNTHCTL_EVNTDIR (1 << 3) /* Control transition trigger bit */
48#define CNTHCTL_EVNTEN (1 << 2) /* Enable event stream */52#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
50/* CPTR_EL2 - Architecture feature trap register */62/* CPTR_EL2 - Architecture feature trap register */
51/* Valid if HCR_EL2.E2H == 0 */63/* Valid if HCR_EL2.E2H == 0 */
64#define CPTR_TRAP_ALL 0xc01037ff /* Enable all traps */
52#define CPTR_RES0 0x7fefc80065#define CPTR_RES0 0x7fefc800
53#define CPTR_RES1 0x000032ff66#define CPTR_RES1 0x000032ff
67#define CPTR_TZ 0x00000100
54#define CPTR_TFP 0x0000040068#define CPTR_TFP 0x00000400
69#define CPTR_TTA 0x00100000
55/* Valid if HCR_EL2.E2H == 1 */70/* Valid if HCR_EL2.E2H == 1 */
56#define CPTR_FPEN 0x0030000071#define CPTR_E2H_TRAP_ALL 0xd0000000
72#define CPTR_E2H_ZPEN 0x00030000
73#define CPTR_E2H_FPEN 0x00300000
74#define CPTR_E2H_TTA 0x10000000
57/* Unconditionally valid */75/* Unconditionally valid */
58#define CPTR_TTA 0x00100000
59#define CPTR_TCPAC 0x8000000076#define CPTR_TCPAC 0x80000000
6077
61/* HCR_EL2 - Hypervisor Config Register */78/* HCR_EL2 - Hypervisor Config Register */
...@@ -123,6 +140,41 @@...@@ -123,6 +140,41 @@
123#define HCR_TWEDEn (UL(0x1) << 59)140#define HCR_TWEDEn (UL(0x1) << 59)
124#define HCR_TWEDEL_MASK (UL(0xf) << 60)141#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
126/* HPFAR_EL2 - Hypervisor IPA Fault Address Register */178/* HPFAR_EL2 - Hypervisor IPA Fault Address Register */
127#define HPFAR_EL2_FIPA_SHIFT 4179#define HPFAR_EL2_FIPA_SHIFT 4
128#define HPFAR_EL2_FIPA_MASK 0xfffffffff0180#define HPFAR_EL2_FIPA_MASK 0xfffffffff0
...@@ -138,6 +190,54 @@...@@ -138,6 +190,54 @@
138#define ICC_SRE_EL2_SRE (1UL << 0)190#define ICC_SRE_EL2_SRE (1UL << 0)
139#define ICC_SRE_EL2_EN (1UL << 3)191#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
141/* SCTLR_EL2 - System Control Register */241/* SCTLR_EL2 - System Control Register */
142#define SCTLR_EL2_RES1 0x30c50830242#define SCTLR_EL2_RES1 0x30c50830
143#define SCTLR_EL2_M_SHIFT 0243#define SCTLR_EL2_M_SHIFT 0
...@@ -237,6 +337,9 @@...@@ -237,6 +337,9 @@
237#define VTCR_EL2_PS_42BIT (0x3UL << VTCR_EL2_PS_SHIFT)337#define VTCR_EL2_PS_42BIT (0x3UL << VTCR_EL2_PS_SHIFT)
238#define VTCR_EL2_PS_44BIT (0x4UL << VTCR_EL2_PS_SHIFT)338#define VTCR_EL2_PS_44BIT (0x4UL << VTCR_EL2_PS_SHIFT)
239#define VTCR_EL2_PS_48BIT (0x5UL << VTCR_EL2_PS_SHIFT)339#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
241/* VTTBR_EL2 - Virtualization Translation Table Base Register */344/* VTTBR_EL2 - Virtualization Translation Table Base Register */
242#define VTTBR_VMID_MASK 0xffff000000000000345#define VTTBR_VMID_MASK 0xffff000000000000
...@@ -244,52 +347,4 @@...@@ -244,52 +347,4 @@
244/* Assumed to be 0 by locore.S */347/* Assumed to be 0 by locore.S */
245#define VTTBR_HOST 0x0000000000000000348#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
295#endif /* !_MACHINE_HYPERVISOR_H_ */350#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 @@...@@ -27,7 +27,6 @@
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *28 *
29 * from tahoe: in_cksum.c 1.2 86/01/0529 * from tahoe: in_cksum.c 1.2 86/01/05
30 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
31 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp30 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
32 */31 */
3332
lib/libc/include/aarch64-freebsd-none/machine/intr.h+10-6
...@@ -27,20 +27,20 @@...@@ -27,20 +27,20 @@
27#ifndef _MACHINE_INTR_H_27#ifndef _MACHINE_INTR_H_
28#define _MACHINE_INTR_H_28#define _MACHINE_INTR_H_
2929
30#ifndef LOCORE
30#ifdef FDT31#ifdef FDT
31#include <dev/ofw/openfirm.h>32#include <dev/ofw/openfirm.h>
32#endif33#endif
3334
34#include <sys/intr.h>
35
36#ifndef NIRQ
37#define NIRQ 16384 /* XXX - It should be an option. */
38#endif
39
40static inline void35static inline void
41arm_irq_memory_barrier(uintptr_t irq)36arm_irq_memory_barrier(uintptr_t irq)
42{37{
43}38}
39#endif /* !LOCORE */
40
41#ifndef NIRQ
42#define NIRQ 16384 /* XXX - It should be an option. */
43#endif
4444
45#ifdef DEV_ACPI45#ifdef DEV_ACPI
46#define ACPI_INTR_XREF 146#define ACPI_INTR_XREF 1
...@@ -48,4 +48,8 @@ arm_irq_memory_barrier(uintptr_t irq)...@@ -48,4 +48,8 @@ arm_irq_memory_barrier(uintptr_t irq)
48#define ACPI_GPIO_XREF 348#define ACPI_GPIO_XREF 3
49#endif49#endif
5050
51#define INTR_ROOT_IRQ 0
52#define INTR_ROOT_FIQ 1
53#define INTR_ROOT_COUNT 2
54
51#endif /* _MACHINE_INTR_H */55#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 @@...@@ -37,6 +37,8 @@
3737
38void kdb_cpu_clear_singlestep(void);38void kdb_cpu_clear_singlestep(void);
39void kdb_cpu_set_singlestep(void);39void kdb_cpu_set_singlestep(void);
40int kdb_cpu_set_breakpoint(vm_offset_t addr);
41int kdb_cpu_clr_breakpoint(vm_offset_t addr);
40int kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access);42int kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access);
41int kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size);43int kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size);
4244
...@@ -44,7 +46,7 @@ static __inline void...@@ -44,7 +46,7 @@ static __inline void
44kdb_cpu_sync_icache(unsigned char *addr, size_t size)46kdb_cpu_sync_icache(unsigned char *addr, size_t size)
45{47{
4648
47 cpu_icache_sync_range((vm_offset_t)addr, size);49 cpu_icache_sync_range(addr, size);
48}50}
4951
50static __inline void52static __inline void
lib/libc/include/aarch64-freebsd-none/machine/machdep.h+1-1
...@@ -33,7 +33,6 @@ struct arm64_bootparams {...@@ -33,7 +33,6 @@ struct arm64_bootparams {
33 vm_offset_t modulep;33 vm_offset_t modulep;
34 vm_offset_t kern_stack;34 vm_offset_t kern_stack;
35 vm_paddr_t kern_ttbr0;35 vm_paddr_t kern_ttbr0;
36 uint64_t hcr_el2;
37 int boot_el; /* EL the kernel booted from */36 int boot_el; /* EL the kernel booted from */
38 int pad;37 int pad;
39};38};
...@@ -48,6 +47,7 @@ extern enum arm64_bus arm64_bus_method;...@@ -48,6 +47,7 @@ extern enum arm64_bus arm64_bus_method;
4847
49void dbg_init(void);48void dbg_init(void);
50bool has_hyp(void);49bool has_hyp(void);
50bool in_vhe(void);
51void initarm(struct arm64_bootparams *);51void initarm(struct arm64_bootparams *);
52vm_offset_t parse_boot_param(struct arm64_bootparams *abp);52vm_offset_t parse_boot_param(struct arm64_bootparams *abp);
53#ifdef FDT53#ifdef FDT
lib/libc/include/aarch64-freebsd-none/machine/md_var.h+4
...@@ -37,8 +37,12 @@ extern char sigcode[];...@@ -37,8 +37,12 @@ extern char sigcode[];
37extern int szsigcode;37extern int szsigcode;
38extern u_long elf_hwcap;38extern u_long elf_hwcap;
39extern u_long elf_hwcap2;39extern u_long elf_hwcap2;
40extern u_long elf_hwcap3;
41extern u_long elf_hwcap4;
40extern u_long linux_elf_hwcap;42extern u_long linux_elf_hwcap;
41extern u_long linux_elf_hwcap2;43extern u_long linux_elf_hwcap2;
44extern u_long linux_elf_hwcap3;
45extern u_long linux_elf_hwcap4;
42#ifdef COMPAT_FREEBSD3246#ifdef COMPAT_FREEBSD32
43extern u_long elf32_hwcap;47extern u_long elf32_hwcap;
44extern u_long elf32_hwcap2;48extern u_long elf32_hwcap2;
lib/libc/include/aarch64-freebsd-none/machine/metadata.h+8-3
...@@ -31,10 +31,15 @@...@@ -31,10 +31,15 @@
31#define MODINFOMD_DTBP 0x100231#define MODINFOMD_DTBP 0x1002
32#define MODINFOMD_EFI_FB 0x100332#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 */
34struct efi_map_header {39struct efi_map_header {
35 size_t memory_size;40 size_t memory_size; /* Numnber of bytes that follow */
36 size_t descriptor_size;41 size_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
37 uint32_t descriptor_version;42 uint32_t descriptor_version; /* Currently '1' */
38};43};
3944
40struct efi_fb {45struct 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 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
30 */28 */
3129
32#ifdef __arm__30#ifdef __arm__
...@@ -45,8 +43,6 @@...@@ -45,8 +43,6 @@
45#define STACKALIGNBYTES (16 - 1)43#define STACKALIGNBYTES (16 - 1)
46#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)44#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
4745
48#define __PCI_REROUTE_INTERRUPT
49
50#ifndef MACHINE46#ifndef MACHINE
51#define MACHINE "arm64"47#define MACHINE "arm64"
52#endif48#endif
...@@ -99,7 +95,7 @@...@@ -99,7 +95,7 @@
99#define PAGE_SIZE (1 << PAGE_SHIFT)95#define PAGE_SIZE (1 << PAGE_SHIFT)
100#define PAGE_MASK (PAGE_SIZE - 1)96#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
104#ifndef KSTACK_PAGES100#ifndef KSTACK_PAGES
105#if defined(KASAN) || defined(KMSAN)101#if defined(KASAN) || defined(KMSAN)
...@@ -121,17 +117,9 @@...@@ -121,17 +117,9 @@
121/*117/*
122 * Mach derived conversion macros118 * Mach derived conversion macros
123 */119 */
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
130#define arm64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)120#define arm64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
131#define arm64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)121#define arm64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
132122
133#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
134
135#endif /* !_MACHINE_PARAM_H_ */123#endif /* !_MACHINE_PARAM_H_ */
136124
137#endif /* !__arm__ */125#endif /* !__arm__ */
\ No newline at end of file
lib/libc/include/aarch64-freebsd-none/machine/pci_cfgreg.h+2-5
...@@ -27,10 +27,7 @@...@@ -27,10 +27,7 @@
27#define _MACHINE_PCI_CFGREG_H27#define _MACHINE_PCI_CFGREG_H
2828
29int pci_cfgregopen(void);29int pci_cfgregopen(void);
30uint32_t pci_cfgregread_domain(int, int, int, int, int, int);30uint32_t pci_cfgregread(int, int, int, int, int, int);
31void pci_cfgregwrite_domain(int, int, int, int, int, uint32_t, int);31void pci_cfgregwrite(int, int, int, int, int, uint32_t, int);
32
33#define pci_cfgregread pci_cfgregread_domain
34#define pci_cfgregwrite pci_cfgregwrite_domain
3532
36#endif /* !_MACHINE_PCI_CFGREG_H */33#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;...@@ -48,7 +48,6 @@ struct debug_monitor_state;
48 pcpu_ssbd pc_ssbd; \48 pcpu_ssbd pc_ssbd; \
49 struct pmap *pc_curpmap; \49 struct pmap *pc_curpmap; \
50 struct pmap *pc_curvmpmap; \50 struct pmap *pc_curvmpmap; \
51 /* Store as two u_int values to preserve KBI */ \
52 uint64_t pc_mpidr; \51 uint64_t pc_mpidr; \
53 u_int pc_bcast_tlbi_workaround; \52 u_int pc_bcast_tlbi_workaround; \
54 char __pad[197]53 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);...@@ -63,10 +63,13 @@ void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
63 * Pmap stuff63 * Pmap stuff
64 */64 */
6565
66struct rangeset;
67
66struct md_page {68struct md_page {
67 TAILQ_HEAD(,pv_entry) pv_list;69 TAILQ_HEAD(,pv_entry) pv_list;
68 int pv_gen;70 int pv_gen;
69 vm_memattr_t pv_memattr;71 vm_memattr_t pv_memattr;
72 uint8_t pv_reserve[3];
70};73};
7174
72enum pmap_stage {75enum pmap_stage {
...@@ -87,7 +90,8 @@ struct pmap {...@@ -87,7 +90,8 @@ struct pmap {
87 struct asid_set *pm_asid_set; /* The ASID/VMID set to use */90 struct asid_set *pm_asid_set; /* The ASID/VMID set to use */
88 enum pmap_stage pm_stage;91 enum pmap_stage pm_stage;
89 int pm_levels;92 int pm_levels;
90 uint64_t pm_reserved[4];93 struct rangeset *pm_bti;
94 uint64_t pm_reserved[3];
91};95};
92typedef struct pmap *pmap_t;96typedef struct pmap *pmap_t;
9397
...@@ -98,6 +102,8 @@ extern struct pmap kernel_pmap_store;...@@ -98,6 +102,8 @@ extern struct pmap kernel_pmap_store;
98#define kernel_pmap (&kernel_pmap_store)102#define kernel_pmap (&kernel_pmap_store)
99#define pmap_kernel() kernel_pmap103#define pmap_kernel() kernel_pmap
100104
105extern bool pmap_lpa_enabled;
106
101#define PMAP_ASSERT_LOCKED(pmap) \107#define PMAP_ASSERT_LOCKED(pmap) \
102 mtx_assert(&(pmap)->pm_mtx, MA_OWNED)108 mtx_assert(&(pmap)->pm_mtx, MA_OWNED)
103#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)109#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)
...@@ -124,6 +130,8 @@ extern struct pmap kernel_pmap_store;...@@ -124,6 +130,8 @@ extern struct pmap kernel_pmap_store;
124extern vm_offset_t virtual_avail;130extern vm_offset_t virtual_avail;
125extern vm_offset_t virtual_end;131extern vm_offset_t virtual_end;
126132
133extern pt_entry_t pmap_sh_attr;
134
127/*135/*
128 * Macros to test if a mapping is mappable with an L1 Section mapping136 * Macros to test if a mapping is mappable with an L1 Section mapping
129 * or an L2 Large Page mapping.137 * or an L2 Large Page mapping.
...@@ -134,7 +142,8 @@ extern vm_offset_t virtual_end;...@@ -134,7 +142,8 @@ extern vm_offset_t virtual_end;
134#define pmap_vm_page_alloc_check(m)142#define pmap_vm_page_alloc_check(m)
135143
136void pmap_activate_vm(pmap_t);144void pmap_activate_vm(pmap_t);
137void pmap_bootstrap(vm_size_t);145void pmap_bootstrap_dmap(vm_size_t);
146void pmap_bootstrap(void);
138int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);147int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);
139int pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot);148int pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot);
140void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);149void 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);...@@ -166,18 +175,17 @@ int pmap_fault(pmap_t, uint64_t, uint64_t);
166175
167struct pcb *pmap_switch(struct thread *);176struct pcb *pmap_switch(struct thread *);
168177
178void pmap_s1_invalidate_all_kernel(void);
179
169extern void (*pmap_clean_stage2_tlbi)(void);180extern void (*pmap_clean_stage2_tlbi)(void);
170extern void (*pmap_invalidate_vpipt_icache)(void);
171extern void (*pmap_stage2_invalidate_range)(uint64_t, vm_offset_t, vm_offset_t,181extern void (*pmap_stage2_invalidate_range)(uint64_t, vm_offset_t, vm_offset_t,
172 bool);182 bool);
173extern void (*pmap_stage2_invalidate_all)(uint64_t);183extern void (*pmap_stage2_invalidate_all)(uint64_t);
174184
175static inline int185int pmap_vmspace_copy(pmap_t, pmap_t);
176pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused)
177{
178186
179 return (0);187int pmap_bti_set(pmap_t, vm_offset_t, vm_offset_t);
180}188int pmap_bti_clear(pmap_t, vm_offset_t, vm_offset_t);
181189
182#if defined(KASAN) || defined(KMSAN)190#if defined(KASAN) || defined(KMSAN)
183struct arm64_bootparams;191struct arm64_bootparams;
lib/libc/include/aarch64-freebsd-none/machine/proc.h+12-4
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
30 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/2928 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
31 */29 */
3230
...@@ -37,6 +35,7 @@...@@ -37,6 +35,7 @@
37#ifndef _MACHINE_PROC_H_35#ifndef _MACHINE_PROC_H_
38#define _MACHINE_PROC_H_36#define _MACHINE_PROC_H_
3937
38#ifndef LOCORE
40struct ptrauth_key {39struct ptrauth_key {
41 uint64_t pa_key_lo;40 uint64_t pa_key_lo;
42 uint64_t pa_key_hi;41 uint64_t pa_key_hi;
...@@ -67,12 +66,21 @@ struct mdthread {...@@ -67,12 +66,21 @@ struct mdthread {
67 struct ptrauth_key apia;66 struct ptrauth_key apia;
68 } md_ptrauth_kern;67 } 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];
71};74};
7275
73struct mdproc {76struct mdproc {
74 long md_dummy;77 uint64_t md_tcr; /* TCR_EL1 fields to update */
78 uint64_t md_reserved[2];
75};79};
80#endif /* !LOCORE */
81
82/* Fields that can be set in md_tcr */
83#define MD_TCR_FIELDS TCR_TBI0
7684
77#define KINFO_PROC_SIZE 108885#define KINFO_PROC_SIZE 1088
78#define KINFO_PROC32_SIZE 81686#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 */...@@ -54,13 +54,6 @@ typedef uint64_t pt_entry_t; /* page table entry */
54#define ATTR_MASK_L UINT64_C(0x0000000000000fff)54#define ATTR_MASK_L UINT64_C(0x0000000000000fff)
55#define ATTR_MASK (ATTR_MASK_H | ATTR_MASK_L)55#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
64/* Bits 58:55 are reserved for software */57/* Bits 58:55 are reserved for software */
65#define ATTR_SW_UNUSED1 (1UL << 58)58#define ATTR_SW_UNUSED1 (1UL << 58)
66#define ATTR_SW_NO_PROMOTE (1UL << 57)59#define ATTR_SW_NO_PROMOTE (1UL << 57)
...@@ -80,13 +73,37 @@ typedef uint64_t pt_entry_t; /* page table entry */...@@ -80,13 +73,37 @@ typedef uint64_t pt_entry_t; /* page table entry */
8073
81#define ATTR_CONTIGUOUS (1UL << 52)74#define ATTR_CONTIGUOUS (1UL << 52)
82#define ATTR_DBM (1UL << 51)75#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
83#define ATTR_S1_nG (1 << 11)95#define ATTR_S1_nG (1 << 11)
84#define ATTR_AF (1 << 10)96#define ATTR_AF (1 << 10)
97/* When TCR_EL1.DS == 0 */
85#define ATTR_SH(x) ((x) << 8)98#define ATTR_SH(x) ((x) << 8)
86#define ATTR_SH_MASK ATTR_SH(3)99#define ATTR_SH_MASK ATTR_SH(3)
87#define ATTR_SH_NS 0 /* Non-shareable */100#define ATTR_SH_NS 0 /* Non-shareable */
88#define ATTR_SH_OS 2 /* Outer-shareable */101#define ATTR_SH_OS 2 /* Outer-shareable */
89#define ATTR_SH_IS 3 /* Inner-shareable */102#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
91#define ATTR_S1_AP_RW_BIT (1 << 7)108#define ATTR_S1_AP_RW_BIT (1 << 7)
92#define ATTR_S1_AP(x) ((x) << 6)109#define ATTR_S1_AP(x) ((x) << 6)
...@@ -110,8 +127,6 @@ typedef uint64_t pt_entry_t; /* page table entry */...@@ -110,8 +127,6 @@ typedef uint64_t pt_entry_t; /* page table entry */
110#define ATTR_S2_MEMATTR_WT 0xa127#define ATTR_S2_MEMATTR_WT 0xa
111#define ATTR_S2_MEMATTR_WB 0xf128#define ATTR_S2_MEMATTR_WB 0xf
112129
113#define ATTR_DEFAULT (ATTR_AF | ATTR_SH(ATTR_SH_IS))
114
115#define ATTR_DESCR_MASK 3130#define ATTR_DESCR_MASK 3
116#define ATTR_DESCR_VALID 1131#define ATTR_DESCR_VALID 1
117#define ATTR_DESCR_TYPE_MASK 2132#define ATTR_DESCR_TYPE_MASK 2
...@@ -119,6 +134,35 @@ typedef uint64_t pt_entry_t; /* page table entry */...@@ -119,6 +134,35 @@ typedef uint64_t pt_entry_t; /* page table entry */
119#define ATTR_DESCR_TYPE_PAGE 2134#define ATTR_DESCR_TYPE_PAGE 2
120#define ATTR_DESCR_TYPE_BLOCK 0135#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
122#if PAGE_SIZE == PAGE_SIZE_4K166#if PAGE_SIZE == PAGE_SIZE_4K
123#define L0_SHIFT 39167#define L0_SHIFT 39
124#define L1_SHIFT 30168#define L1_SHIFT 30
...@@ -186,6 +230,26 @@ typedef uint64_t pt_entry_t; /* page table entry */...@@ -186,6 +230,26 @@ typedef uint64_t pt_entry_t; /* page table entry */
186#define Ln_ADDR_MASK (Ln_ENTRIES - 1)230#define Ln_ADDR_MASK (Ln_ENTRIES - 1)
187#define Ln_TABLE_MASK ((1 << 12) - 1)231#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
189#define pmap_l0_index(va) (((va) >> L0_SHIFT) & L0_ADDR_MASK)253#define pmap_l0_index(va) (((va) >> L0_SHIFT) & L0_ADDR_MASK)
190#define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK)254#define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK)
191#define pmap_l2_index(va) (((va) >> L2_SHIFT) & Ln_ADDR_MASK)255#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 @@...@@ -44,9 +44,7 @@
44#define SYS_RES_MEMORY 3 /* i/o memory */44#define SYS_RES_MEMORY 3 /* i/o memory */
45#define SYS_RES_IOPORT 4 /* i/o ports */45#define SYS_RES_IOPORT 4 /* i/o ports */
46#define SYS_RES_GPIO 5 /* general purpose i/o */46#define SYS_RES_GPIO 5 /* general purpose i/o */
47#ifdef NEW_PCIB
48#define PCI_RES_BUS 6 /* PCI bus numbers */47#define PCI_RES_BUS 6 /* PCI bus numbers */
49#endif
5048
51#endif /* !_MACHINE_RESOURCE_H_ */49#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 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * @(#)signal.h 8.1 (Berkeley) 6/11/93
30 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/0928 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
31 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:1729 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
32 */30 */
lib/libc/include/aarch64-freebsd-none/machine/sysarch.h+9
...@@ -39,6 +39,15 @@...@@ -39,6 +39,15 @@
39#ifndef _MACHINE_SYSARCH_H_39#ifndef _MACHINE_SYSARCH_H_
40#define _MACHINE_SYSARCH_H_40#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
42#define ARM64_GET_SVE_VL 0x20051#define ARM64_GET_SVE_VL 0x200
43/* Reserved ARM64_SET_SVE_VL 0x201 */52/* Reserved ARM64_SET_SVE_VL 0x201 */
4453
lib/libc/include/aarch64-freebsd-none/machine/undefined.h+8-22
...@@ -35,31 +35,17 @@...@@ -35,31 +35,17 @@
3535
36typedef int (*undef_handler_t)(vm_offset_t, uint32_t, struct trapframe *,36typedef int (*undef_handler_t)(vm_offset_t, uint32_t, struct trapframe *,
37 uint32_t);37 uint32_t);
3838typedef bool (*undef_sys_handler_t)(uint64_t, struct trapframe *);
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)
5839
59void undef_init(void);40void 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
61void remove_undef_handler(void *);46void remove_undef_handler(void *);
62int undef_insn(u_int, struct trapframe *);47bool undef_sys(uint64_t, struct trapframe *);
48int undef_insn(struct trapframe *);
6349
64#endif /* _KERNEL */50#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
35 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/3033 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30
36 */34 */
3735
...@@ -75,14 +73,16 @@...@@ -75,14 +73,16 @@
75#define VM_PHYSSEG_MAX 6473#define VM_PHYSSEG_MAX 64
7674
77/*75/*
78 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool76 * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool from
79 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is77 * which physical pages are allocated and VM_FREEPOOL_DIRECT is the pool from
80 * the pool from which physical pages for small UMA objects are78 * which physical pages for page tables and small UMA objects are allocated.
81 * 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.
82 */81 */
83#define VM_NFREEPOOL 282#define VM_NFREEPOOL 3
84#define VM_FREEPOOL_DEFAULT 083#define VM_FREEPOOL_LAZYINIT 0
85#define VM_FREEPOOL_DIRECT 184#define VM_FREEPOOL_DEFAULT 1
85#define VM_FREEPOOL_DIRECT 2
8686
87/*87/*
88 * Create two free page lists: VM_FREELIST_DMA32 is for physical pages that have88 * Create two free page lists: VM_FREELIST_DMA32 is for physical pages that have
...@@ -101,21 +101,46 @@...@@ -101,21 +101,46 @@
101 * are used by UMA, the physical memory allocator reduces the likelihood of101 * are used by UMA, the physical memory allocator reduces the likelihood of
102 * both 2MB page TLB misses and cache misses during the page table walk when102 * both 2MB page TLB misses and cache misses during the page table walk when
103 * a 2MB page TLB miss does occur.103 * 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.
104 */107 */
108#if PAGE_SIZE == PAGE_SIZE_4K
105#define VM_NFREEORDER 13109#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
107/*116/*
108 * Enable superpage reservations: 1 level.117 * Enable superpage reservations: 2 levels.
109 */118 */
110#ifndef VM_NRESERVLEVEL119#ifndef VM_NRESERVLEVEL
111#define VM_NRESERVLEVEL 1120#define VM_NRESERVLEVEL 2
112#endif121#endif
113122
114/*123/*
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.
116 */127 */
128#if PAGE_SIZE == PAGE_SIZE_4K
117#ifndef VM_LEVEL_0_ORDER129#ifndef VM_LEVEL_0_ORDER
118#define VM_LEVEL_0_ORDER 9130#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
119#endif144#endif
120145
121/**146/**
...@@ -133,6 +158,12 @@...@@ -133,6 +158,12 @@
133 * 0xfffffeffffffffff End of DMAP158 * 0xfffffeffffffffff End of DMAP
134 * 0xffffa00000000000 Start of DMAP159 * 0xffffa00000000000 Start of DMAP
135 *160 *
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 *
136 * 0xffff009fffffffff End of KASAN shadow map167 * 0xffff009fffffffff End of KASAN shadow map
137 * 0xffff008000000000 Start of KASAN shadow map168 * 0xffff008000000000 Start of KASAN shadow map
138 *169 *
...@@ -169,11 +200,25 @@...@@ -169,11 +200,25 @@
169#define KASAN_MIN_ADDRESS (0xffff008000000000UL)200#define KASAN_MIN_ADDRESS (0xffff008000000000UL)
170#define KASAN_MAX_ADDRESS (0xffff00a000000000UL)201#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
172/* The address bits that hold a pointer authentication code */211/* 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
175/* If true addr is in the kernel address space */218/* If true addr is in the kernel address space */
176#define ADDR_IS_KERNEL(addr) (((addr) & (1ul << 55)) == (1ul << 55))219#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)
177/* If true addr is in its canonical form (i.e. no TBI, PAC, etc.) */222/* If true addr is in its canonical form (i.e. no TBI, PAC, etc.) */
178#define ADDR_IS_CANONICAL(addr) \223#define ADDR_IS_CANONICAL(addr) \
179 (((addr) & 0xffff000000000000UL) == 0 || \224 (((addr) & 0xffff000000000000UL) == 0 || \
...@@ -265,7 +310,7 @@...@@ -265,7 +310,7 @@
265#endif310#endif
266311
267#if !defined(KASAN) && !defined(KMSAN)312#if !defined(KASAN) && !defined(KMSAN)
268#define UMA_MD_SMALL_ALLOC313#define UMA_USE_DMAP
269#endif314#endif
270315
271#ifndef LOCORE316#ifndef LOCORE
...@@ -289,6 +334,7 @@ extern vm_offset_t dmap_max_addr;...@@ -289,6 +334,7 @@ extern vm_offset_t dmap_max_addr;
289 * Need a page dump array for minidump.334 * Need a page dump array for minidump.
290 */335 */
291#define MINIDUMP_PAGE_TRACKING 1336#define MINIDUMP_PAGE_TRACKING 1
337#define MINIDUMP_STARTUP_PAGE_TRACKING 1
292338
293#endif /* !_MACHINE_VMPARAM_H_ */339#endif /* !_MACHINE_VMPARAM_H_ */
294340
lib/libc/include/arm-freebsd-eabihf/fenv.h+1
...@@ -29,6 +29,7 @@...@@ -29,6 +29,7 @@
29#ifndef _FENV_H_29#ifndef _FENV_H_
30#define _FENV_H_30#define _FENV_H_
3131
32#include <sys/cdefs.h>
32#include <sys/_types.h>33#include <sys/_types.h>
3334
34#ifndef __fenv_static35#ifndef __fenv_static
lib/libc/include/arm-freebsd-eabihf/float.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
32 */30 */
3331
34#ifndef _MACHINE_FLOAT_H_32#ifndef _MACHINE_FLOAT_H_
lib/libc/include/arm-freebsd-eabihf/floatingpoint.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
36 */34 */
3735
38#ifndef _FLOATINGPOINT_H_36#ifndef _FLOATINGPOINT_H_
lib/libc/include/arm-freebsd-eabihf/machine/_align.h-2
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
40 */38 */
4139
42#ifndef _ARM_INCLUDE__ALIGN_H_40#ifndef _ARM_INCLUDE__ALIGN_H_
lib/libc/include/arm-freebsd-eabihf/machine/_bus.h+7-24
...@@ -1,30 +1,13 @@...@@ -1,30 +1,13 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * Copyright (c) 2005 The FreeBSD Foundation.
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
5 *3 *
6 * Redistribution and use in source and binary forms, with or without4 * SPDX-License-Identifier: BSD-2-Clause
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.
16 *5 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND6 * Derived in part from NetBSD's bus.h files by (alphabetically):
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE7 * Christopher G. Demetriou
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE8 * Charles M. Hannum
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR9 * Jason Thorpe
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL10 * The NetBSD Foundation.
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 */11 */
2912
30#ifndef ARM_INCLUDE__BUS_H13#ifndef ARM_INCLUDE__BUS_H
lib/libc/include/arm-freebsd-eabihf/machine/_limits.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _MACHINE__LIMITS_H_32#ifndef _MACHINE__LIMITS_H_
lib/libc/include/arm-freebsd-eabihf/machine/_types.h-3
...@@ -32,9 +32,6 @@...@@ -32,9 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
38 */35 */
3936
40#ifndef _MACHINE__TYPES_H_37#ifndef _MACHINE__TYPES_H_
lib/libc/include/arm-freebsd-eabihf/machine/acle-compat.h+3-155
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (c) 2014 ARM Ltd2 * Copyright (c) 2024 Arm Ltd
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * Redistribution and use in source and binary forms, with or without5 * Redistribution and use in source and binary forms, with or without
...@@ -27,157 +27,5 @@...@@ -27,157 +27,5 @@
27 */27 */
2828
29#ifndef __ARM_ARCH29#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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
37 */35 */
3836
39#ifndef _MACHINE_ASM_H_37#ifndef _MACHINE_ASM_H_
...@@ -176,7 +174,6 @@...@@ -176,7 +174,6 @@
176# define RETne bxne lr174# define RETne bxne lr
177# define RETc(c) bx##c lr175# define RETc(c) bx##c lr
178176
179#if __ARM_ARCH >= 7
180#define ISB isb177#define ISB isb
181#define DSB dsb178#define DSB dsb
182#define DMB dmb179#define DMB dmb
...@@ -190,12 +187,5 @@...@@ -190,12 +187,5 @@
190#define ERET .word 0xe160006e187#define ERET .word 0xe160006e
191#endif188#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
201#endif /* !_MACHINE_ASM_H_ */191#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 @@...@@ -41,15 +41,9 @@
4141
42#include <sys/atomic_common.h>42#include <sys/atomic_common.h>
4343
44#if __ARM_ARCH >= 7
45#define isb() __asm __volatile("isb" : : : "memory")44#define isb() __asm __volatile("isb" : : : "memory")
46#define dsb() __asm __volatile("dsb" : : : "memory")45#define dsb() __asm __volatile("dsb" : : : "memory")
47#define dmb() __asm __volatile("dmb" : : : "memory")46#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
54#define mb() dmb()48#define mb() dmb()
55#define wmb() dmb()49#define wmb() dmb()
...@@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val)...@@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val)
614}608}
615609
616static __inline uint32_t610static __inline uint32_t
617atomic_load_acq_32(volatile uint32_t *p)611atomic_load_acq_32(const volatile uint32_t *p)
618{612{
619 uint32_t v;613 uint32_t v;
620614
...@@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p)...@@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p)
624}618}
625619
626static __inline uint64_t620static __inline uint64_t
627atomic_load_64(volatile uint64_t *p)621atomic_load_64(const volatile uint64_t *p)
628{622{
629 uint64_t ret;623 uint64_t ret;
630624
...@@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p)...@@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p)
643}637}
644638
645static __inline uint64_t639static __inline uint64_t
646atomic_load_acq_64(volatile uint64_t *p)640atomic_load_acq_64(const volatile uint64_t *p)
647{641{
648 uint64_t ret;642 uint64_t ret;
649643
...@@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p)...@@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p)
653}647}
654648
655static __inline u_long649static __inline u_long
656atomic_load_acq_long(volatile u_long *p)650atomic_load_acq_long(const volatile u_long *p)
657{651{
658 u_long v;652 u_long v;
659653
...@@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v)...@@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v)
898892
899 return (atomic_testandclear_32((volatile uint32_t *)p, v));893 return (atomic_testandclear_32((volatile uint32_t *)p, v));
900}894}
901#define atomic_testandclear_long atomic_testandclear_long
902
903895
904static __inline int896static __inline int
905atomic_testandclear_64(volatile uint64_t *p, u_int v)897atomic_testandclear_64(volatile uint64_t *p, u_int v)
...@@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v)...@@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v)
958950
959 return (atomic_testandset_32((volatile uint32_t *)p, v));951 return (atomic_testandset_32((volatile uint32_t *)p, v));
960}952}
961#define atomic_testandset_long atomic_testandset_long953
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
963static __inline int964static __inline int
964atomic_testandset_64(volatile uint64_t *p, u_int v)965atomic_testandset_64(volatile uint64_t *p, u_int v)
...@@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void)...@@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void)
1052 dmb();1053 dmb();
1053}1054}
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
1055#define atomic_clear_ptr atomic_clear_321062#define atomic_clear_ptr atomic_clear_32
1056#define atomic_clear_acq_ptr atomic_clear_acq_321063#define atomic_clear_acq_ptr atomic_clear_acq_32
1057#define atomic_clear_rel_ptr atomic_clear_rel_321064#define atomic_clear_rel_ptr atomic_clear_rel_32
...@@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void)...@@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void)
1059#define atomic_set_acq_ptr atomic_set_acq_321066#define atomic_set_acq_ptr atomic_set_acq_32
1060#define atomic_set_rel_ptr atomic_set_rel_321067#define atomic_set_rel_ptr atomic_set_rel_32
1061#define atomic_fcmpset_ptr atomic_fcmpset_321068#define atomic_fcmpset_ptr atomic_fcmpset_32
1062#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
1063#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_321069#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32
1070#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32
1064#define atomic_cmpset_ptr atomic_cmpset_321071#define atomic_cmpset_ptr atomic_cmpset_32
1065#define atomic_cmpset_acq_ptr atomic_cmpset_acq_321072#define atomic_cmpset_acq_ptr atomic_cmpset_acq_32
1066#define atomic_cmpset_rel_ptr atomic_cmpset_rel_321073#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
1067#define atomic_load_acq_ptr atomic_load_acq_321076#define atomic_load_acq_ptr atomic_load_acq_32
1068#define atomic_store_rel_ptr atomic_store_rel_321077#define atomic_store_rel_ptr atomic_store_rel_32
1069#define atomic_swap_ptr atomic_swap_321078#define atomic_swap_ptr atomic_swap_32
1070#define atomic_readandclear_ptr atomic_readandclear_321079#define atomic_testandset_ptr atomic_testandset_32
1080#define atomic_testandclear_ptr atomic_testandclear_32
10711081
1072#define atomic_add_int atomic_add_321082#define atomic_add_int atomic_add_32
1073#define atomic_add_acq_int atomic_add_acq_321083#define atomic_add_acq_int atomic_add_acq_32
...@@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void)...@@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void)
1093#define atomic_store_rel_int atomic_store_rel_321103#define atomic_store_rel_int atomic_store_rel_32
1094#define atomic_swap_int atomic_swap_321104#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 */
1102#include <sys/_atomic_subword.h>1106#include <sys/_atomic_subword.h>
11031107
1108#define atomic_set_short atomic_set_16
1109#define atomic_clear_short atomic_clear_16
1110
1104#endif /* _MACHINE_ATOMIC_H_ */1111#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);...@@ -45,13 +45,7 @@ void cpu_halt(void);
45 * unconditionally with -DSMP. Although it looks like a bug,45 * unconditionally with -DSMP. Although it looks like a bug,
46 * handle this case here and in #elif condition in ARM_SMP_UP macro.46 * handle this case here and in #elif condition in ARM_SMP_UP macro.
47 */47 */
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
56#if !defined(SMP) && defined(SMP_ON_UP)50#if !defined(SMP) && defined(SMP_ON_UP)
57#error SMP option must be defined for SMP_ON_UP option51#error SMP option must be defined for SMP_ON_UP option
...@@ -68,7 +62,7 @@ do { \...@@ -68,7 +62,7 @@ do { \
68 up_code; \62 up_code; \
69 } \63 } \
70} while (0)64} while (0)
71#elif defined(SMP) && __ARM_ARCH > 665#elif defined(SMP)
72#define ARM_SMP_UP(smp_code, up_code) \66#define ARM_SMP_UP(smp_code, up_code) \
73do { \67do { \
74 smp_code; \68 smp_code; \
...@@ -146,15 +140,15 @@ fname(uint64_t reg) \...@@ -146,15 +140,15 @@ fname(uint64_t reg) \
146/* TLB */140/* TLB */
147141
148_WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */142_WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */
149#if __ARM_ARCH >= 7 && defined(SMP)143#if defined(SMP)
150_WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */144_WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */
151#endif145#endif
152_WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */146_WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */
153#if __ARM_ARCH >= 7 && defined(SMP)147#if defined(SMP)
154_WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */148_WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */
155#endif149#endif
156_WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */150_WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */
157#if __ARM_ARCH >= 7 && defined(SMP)151#if defined(SMP)
158_WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */152_WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */
159#endif153#endif
160_WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */154_WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */
...@@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0))...@@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0))
164/* Cache and Branch predictor */158/* Cache and Branch predictor */
165159
166_WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */160_WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */
167#if __ARM_ARCH >= 7 && defined(SMP)161#if defined(SMP)
168_WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */162_WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */
169#endif163#endif
170_WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */164_WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */
171_WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */165_WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */
172_WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */166_WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */
173_WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */167_WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */
174#if __ARM_ARCH >= 7
175_WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */168_WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */
176#endif
177_WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */169_WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */
178_WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */170_WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */
179_WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */171_WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */
180_WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */172_WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */
181#if __ARM_ARCH >= 7 && defined(SMP)173#if defined(SMP)
182_WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */174_WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */
183#endif175#endif
184_WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */176_WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */
...@@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0))...@@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0))
209_WF1(cp15_nmrr_set, CP15_NMRR(%0))201_WF1(cp15_nmrr_set, CP15_NMRR(%0))
210_RF0(cp15_ttbr_get, CP15_TTBR0(%0))202_RF0(cp15_ttbr_get, CP15_TTBR0(%0))
211_RF0(cp15_dfar_get, CP15_DFAR(%0))203_RF0(cp15_dfar_get, CP15_DFAR(%0))
212#if __ARM_ARCH >= 7
213_RF0(cp15_ifar_get, CP15_IFAR(%0))204_RF0(cp15_ifar_get, CP15_IFAR(%0))
214_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))205_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))
215#endif
216_RF0(cp15_actlr_get, CP15_ACTLR(%0))206_RF0(cp15_actlr_get, CP15_ACTLR(%0))
217_WF1(cp15_actlr_set, CP15_ACTLR(%0))207_WF1(cp15_actlr_set, CP15_ACTLR(%0))
218_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0))208_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0))
...@@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0))...@@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0))
251241
252/* Performance Monitor registers */242/* 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
262_RF0(cp15_pmcr_get, CP15_PMCR(%0))244_RF0(cp15_pmcr_get, CP15_PMCR(%0))
263_WF1(cp15_pmcr_set, CP15_PMCR(%0))245_WF1(cp15_pmcr_set, CP15_PMCR(%0))
264_RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0))246_RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0))
...@@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))...@@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0))
280_RF0(cp15_pminten_get, CP15_PMINTENSET(%0))262_RF0(cp15_pminten_get, CP15_PMINTENSET(%0))
281_WF1(cp15_pminten_set, CP15_PMINTENSET(%0))263_WF1(cp15_pminten_set, CP15_PMINTENSET(%0))
282_WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0))264_WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0))
283#endif
284265
285_RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0))266_RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0))
286_WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0))267_WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0))
...@@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size)...@@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size)
380}361}
381362
382/* Broadcasting operations. */363/* Broadcasting operations. */
383#if __ARM_ARCH >= 7 && defined(SMP)364#if defined(SMP)
384365
385static __inline void366static __inline void
386tlb_flush_all(void)367tlb_flush_all(void)
...@@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size)...@@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size)
442 );423 );
443 dsb();424 dsb();
444}425}
445#else /* __ARM_ARCH < 7 */426#else /* !SMP */
446427
447#define tlb_flush_all() tlb_flush_all_local()428#define tlb_flush_all() tlb_flush_all_local()
448#define tlb_flush_all_ng() tlb_flush_all_ng_local()429#define tlb_flush_all_ng() tlb_flush_all_ng_local()
449#define tlb_flush(va) tlb_flush_local(va)430#define tlb_flush(va) tlb_flush_local(va)
450#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)431#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)
451432
452#endif /* __ARM_ARCH < 7 */433#endif /* !SMP */
453434
454/*435/*
455 * Cache maintenance operations.436 * Cache maintenance operations.
...@@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size)...@@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size)
465 va &= ~cpuinfo.dcache_line_mask;446 va &= ~cpuinfo.dcache_line_mask;
466447
467 for ( ; va < eva; va += cpuinfo.dcache_line_size) {448 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
468#if __ARM_ARCH >= 7
469 _CP15_DCCMVAU(va);449 _CP15_DCCMVAU(va);
470#else
471 _CP15_DCCMVAC(va);
472#endif
473 }450 }
474 dsb();451 dsb();
475 ARM_SMP_UP(452 ARM_SMP_UP(
...@@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size)...@@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size)
515 dsb();492 dsb();
516 va &= ~cpuinfo.dcache_line_mask;493 va &= ~cpuinfo.dcache_line_mask;
517 for ( ; va < eva; va += cpuinfo.dcache_line_size) {494 for ( ; va < eva; va += cpuinfo.dcache_line_size) {
518#if __ARM_ARCH >= 7
519 _CP15_DCCMVAU(va);495 _CP15_DCCMVAU(va);
520#else
521 _CP15_DCCMVAC(va);
522#endif
523 }496 }
524 dsb();497 dsb();
525}498}
...@@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr)...@@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr)
686static __inline uint64_t659static __inline uint64_t
687get_cyclecount(void)660get_cyclecount(void)
688{661{
689#if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176))662#if defined(DEV_PMU)
690#if (__ARM_ARCH > 6) && defined(DEV_PMU)
691 if (pmu_attched) {663 if (pmu_attched) {
692 u_int cpu;664 u_int cpu;
693 uint64_t h, h2;665 uint64_t h, h2;
...@@ -711,12 +683,6 @@ get_cyclecount(void)...@@ -711,12 +683,6 @@ get_cyclecount(void)
711 } else683 } else
712#endif684#endif
713 return cp15_pmccntr_get();685 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
720}686}
721#endif687#endif
722688
...@@ -729,7 +695,7 @@ get_cyclecount(void)...@@ -729,7 +695,7 @@ get_cyclecount(void)
729#define cpu_spinwait() /* nothing */695#define cpu_spinwait() /* nothing */
730#define cpu_lock_delay() DELAY(1)696#define cpu_lock_delay() DELAY(1)
731697
732#define ARM_NVEC 8698#define ARM_NVEC 7
733#define ARM_VEC_ALL 0xffffffff699#define ARM_VEC_ALL 0xffffffff
734700
735extern vm_offset_t vector_page;701extern vm_offset_t vector_page;
lib/libc/include/arm-freebsd-eabihf/machine/cpufunc.h-3
...@@ -97,9 +97,6 @@ void armv7_cpu_sleep (int);...@@ -97,9 +97,6 @@ void armv7_cpu_sleep (int);
97void pj4b_config (void);97void pj4b_config (void);
98#endif98#endif
9999
100#if defined(CPU_ARM1176)
101void arm11x6_sleep (int); /* no ref. for errata */
102#endif
103100
104101
105/*102/*
lib/libc/include/arm-freebsd-eabihf/machine/endian.h-2
...@@ -26,8 +26,6 @@...@@ -26,8 +26,6 @@
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26 * 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 OF27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.28 * SUCH DAMAGE.
29 *
30 * @(#)endian.h 8.1 (Berkeley) 6/10/93
31 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $29 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
32 */30 */
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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
32 */30 */
3331
34#ifndef _MACHINE_FLOAT_H_32#ifndef _MACHINE_FLOAT_H_
lib/libc/include/arm-freebsd-eabihf/machine/floatingpoint.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
36 */34 */
3735
38#ifndef _FLOATINGPOINT_H_36#ifndef _FLOATINGPOINT_H_
lib/libc/include/arm-freebsd-eabihf/machine/ieee.h-2
...@@ -39,8 +39,6 @@...@@ -39,8 +39,6 @@
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.40 * SUCH DAMAGE.
41 *41 *
42 * @(#)ieee.h 8.1 (Berkeley) 6/11/93
43 *
44 */42 */
4543
46/*44/*
lib/libc/include/arm-freebsd-eabihf/machine/ieeefp.h+10
...@@ -49,4 +49,14 @@ typedef enum {...@@ -49,4 +49,14 @@ typedef enum {
4949
50#define fp_except_t int50#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
52#endif /* _MACHINE_IEEEFP_H_ */62#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 @@...@@ -29,7 +29,6 @@
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *30 *
31 * from tahoe: in_cksum.c 1.2 86/01/0531 * from tahoe: in_cksum.c 1.2 86/01/05
32 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
33 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp32 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
34 */33 */
3534
lib/libc/include/arm-freebsd-eabihf/machine/intr.h+6-3
...@@ -39,16 +39,19 @@...@@ -39,16 +39,19 @@
39#ifndef _MACHINE_INTR_H_39#ifndef _MACHINE_INTR_H_
40#define _MACHINE_INTR_H_40#define _MACHINE_INTR_H_
4141
42#ifndef LOCORE
42#ifdef FDT43#ifdef FDT
43#include <dev/ofw/openfirm.h>44#include <dev/ofw/openfirm.h>
44#endif45#endif
4546
47void arm_irq_memory_barrier(uintptr_t);
48#endif /* !LOCORE */
49
46#ifndef NIRQ50#ifndef NIRQ
47#define NIRQ 1024 /* XXX - It should be an option. */51#define NIRQ 1024 /* XXX - It should be an option. */
48#endif52#endif
4953
50#include <sys/intr.h>54#define INTR_ROOT_IRQ 0
5155#define INTR_ROOT_COUNT 1
52void arm_irq_memory_barrier(uintptr_t);
5356
54#endif /* _MACHINE_INTR_H */57#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,...@@ -51,6 +51,13 @@ void arm_add_efi_map_entries(struct efi_map_header *efihdr,
51 struct mem_region *mr, int *mrcnt);51 struct mem_region *mr, int *mrcnt);
52#endif52#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
54/*61/*
55 * Symbols created by ldscript.arm which are accessible in the kernel as global62 * Symbols created by ldscript.arm which are accessible in the kernel as global
56 * symbols. They have uint8 type because they mark the byte location where the63 * 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 @@...@@ -33,10 +33,15 @@
33#define MODINFOMD_DTBP 0x100233#define MODINFOMD_DTBP 0x1002
34#define MODINFOMD_EFI_MAP 0x100334#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 */
36struct efi_map_header {41struct efi_map_header {
37 uint64_t memory_size;42 uint64_t memory_size; /* Numnber of bytes that follow */
38 uint64_t descriptor_size;43 uint64_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
39 uint32_t descriptor_version;44 uint32_t descriptor_version; /* Currently '1' */
40};45};
4146
42/*47/*
lib/libc/include/arm-freebsd-eabihf/machine/param.h+2-15
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
40 */38 */
4139
42#ifndef _ARM_INCLUDE_PARAM_H_40#ifndef _ARM_INCLUDE_PARAM_H_
...@@ -51,17 +49,11 @@...@@ -51,17 +49,11 @@
51#define STACKALIGNBYTES (8 - 1)49#define STACKALIGNBYTES (8 - 1)
52#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)50#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)
5351
54#define __PCI_REROUTE_INTERRUPT
55
56#ifndef MACHINE52#ifndef MACHINE
57#define MACHINE "arm"53#define MACHINE "arm"
58#endif54#endif
59#ifndef MACHINE_ARCH55#ifndef MACHINE_ARCH
60#if __ARM_ARCH >= 7
61#define MACHINE_ARCH "armv7"56#define MACHINE_ARCH "armv7"
62#else
63#define MACHINE_ARCH "armv6"
64#endif
65#endif57#endif
6658
67#ifdef SMP59#ifdef SMP
...@@ -76,6 +68,8 @@...@@ -76,6 +68,8 @@
76#define MAXMEMDOM 168#define MAXMEMDOM 1
77#endif69#endif
7870
71#define __HAVE_STATIC_DEVMAP
72
79#define ALIGNBYTES _ALIGNBYTES73#define ALIGNBYTES _ALIGNBYTES
80#define ALIGN(p) _ALIGN(p)74#define ALIGN(p) _ALIGN(p)
81/*75/*
...@@ -129,17 +123,10 @@...@@ -129,17 +123,10 @@
129/*123/*
130 * Mach derived conversion macros124 * Mach derived conversion macros
131 */125 */
132#define trunc_page(x) ((x) & ~PAGE_MASK)
133#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
134#define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK)126#define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK)
135#define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK)127#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
140#define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT)129#define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT)
141#define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT)130#define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT)
142131
143#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
144
145#endif /* !_ARM_INCLUDE_PARAM_H_ */132#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 @@...@@ -39,9 +39,6 @@
39 * map the page tables using the pagetables themselves. This is done to39 * map the page tables using the pagetables themselves. This is done to
40 * reduce the impact on kernel virtual memory for lots of sparse address40 * reduce the impact on kernel virtual memory for lots of sparse address
41 * space, and to reduce the cost of memory to each process.41 * 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
45 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/3042 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30
46 */43 */
4744
...@@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */...@@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */
138 * vtopte2().135 * vtopte2().
139 */136 */
140void pmap_bootstrap(vm_offset_t);137void 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);
142void pmap_kremove(vm_offset_t);139void pmap_kremove(vm_offset_t);
143boolean_t pmap_page_is_mapped(vm_page_t);140bool pmap_page_is_mapped(vm_page_t);
144bool pmap_ps_enabled(pmap_t pmap);141bool pmap_ps_enabled(pmap_t pmap);
145142
146void pmap_tlb_flush(pmap_t, vm_offset_t);143void pmap_tlb_flush(pmap_t, vm_offset_t);
...@@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t);...@@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
175#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)172#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva)
176173
177void *pmap_mapdev(vm_paddr_t, vm_size_t);174void *pmap_mapdev(vm_paddr_t, vm_size_t);
175void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
178void pmap_unmapdev(void *, vm_size_t);176void 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
187struct pcb;178struct pcb;
188void pmap_set_pcb_pagedir(pmap_t, struct pcb *);179void 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)...@@ -161,7 +161,7 @@ pte1_clear_bit(pt1_entry_t *pte1p, uint32_t bit)
161 pte1_sync(pte1p);161 pte1_sync(pte1p);
162}162}
163163
164static __inline boolean_t164static __inline bool
165pte1_is_link(pt1_entry_t pte1)165pte1_is_link(pt1_entry_t pte1)
166{166{
167167
...@@ -175,21 +175,21 @@ pte1_is_section(pt1_entry_t pte1)...@@ -175,21 +175,21 @@ pte1_is_section(pt1_entry_t pte1)
175 return ((pte1 & L1_TYPE_MASK) == L1_TYPE_S);175 return ((pte1 & L1_TYPE_MASK) == L1_TYPE_S);
176}176}
177177
178static __inline boolean_t178static __inline bool
179pte1_is_dirty(pt1_entry_t pte1)179pte1_is_dirty(pt1_entry_t pte1)
180{180{
181181
182 return ((pte1 & (PTE1_NM | PTE1_RO)) == 0);182 return ((pte1 & (PTE1_NM | PTE1_RO)) == 0);
183}183}
184184
185static __inline boolean_t185static __inline bool
186pte1_is_global(pt1_entry_t pte1)186pte1_is_global(pt1_entry_t pte1)
187{187{
188188
189 return ((pte1 & PTE1_NG) == 0);189 return ((pte1 & PTE1_NG) == 0);
190}190}
191191
192static __inline boolean_t192static __inline bool
193pte1_is_valid(pt1_entry_t pte1)193pte1_is_valid(pt1_entry_t pte1)
194{194{
195 int l1_type;195 int l1_type;
...@@ -198,7 +198,7 @@ pte1_is_valid(pt1_entry_t pte1)...@@ -198,7 +198,7 @@ pte1_is_valid(pt1_entry_t pte1)
198 return ((l1_type == L1_TYPE_C) || (l1_type == L1_TYPE_S));198 return ((l1_type == L1_TYPE_C) || (l1_type == L1_TYPE_S));
199}199}
200200
201static __inline boolean_t201static __inline bool
202pte1_is_wired(pt1_entry_t pte1)202pte1_is_wired(pt1_entry_t pte1)
203{203{
204204
...@@ -301,28 +301,28 @@ pte2_clear_bit(pt2_entry_t *pte2p, uint32_t bit)...@@ -301,28 +301,28 @@ pte2_clear_bit(pt2_entry_t *pte2p, uint32_t bit)
301 pte2_sync(pte2p);301 pte2_sync(pte2p);
302}302}
303303
304static __inline boolean_t304static __inline bool
305pte2_is_dirty(pt2_entry_t pte2)305pte2_is_dirty(pt2_entry_t pte2)
306{306{
307307
308 return ((pte2 & (PTE2_NM | PTE2_RO)) == 0);308 return ((pte2 & (PTE2_NM | PTE2_RO)) == 0);
309}309}
310310
311static __inline boolean_t311static __inline bool
312pte2_is_global(pt2_entry_t pte2)312pte2_is_global(pt2_entry_t pte2)
313{313{
314314
315 return ((pte2 & PTE2_NG) == 0);315 return ((pte2 & PTE2_NG) == 0);
316}316}
317317
318static __inline boolean_t318static __inline bool
319pte2_is_valid(pt2_entry_t pte2)319pte2_is_valid(pt2_entry_t pte2)
320{320{
321321
322 return (pte2 & PTE2_V);322 return (pte2 & PTE2_V);
323}323}
324324
325static __inline boolean_t325static __inline bool
326pte2_is_wired(pt2_entry_t pte2)326pte2_is_wired(pt2_entry_t pte2)
327{327{
328328
...@@ -358,7 +358,7 @@ pte2_set_bit(pt2_entry_t *pte2p, uint32_t bit)...@@ -358,7 +358,7 @@ pte2_set_bit(pt2_entry_t *pte2p, uint32_t bit)
358}358}
359359
360static __inline void360static __inline void
361pte2_set_wired(pt2_entry_t *pte2p, boolean_t wired)361pte2_set_wired(pt2_entry_t *pte2p, bool wired)
362{362{
363363
364 /*364 /*
lib/libc/include/arm-freebsd-eabihf/machine/proc.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
36 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/2934 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
37 */35 */
3836
lib/libc/include/arm-freebsd-eabihf/machine/profile.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)profile.h 8.1 (Berkeley) 6/11/93
36 */34 */
3735
38#ifndef _MACHINE_PROFILE_H_36#ifndef _MACHINE_PROFILE_H_
lib/libc/include/arm-freebsd-eabihf/machine/reloc.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)reloc.h 8.1 (Berkeley) 6/10/93
36 */34 */
3735
38#ifndef _MACHINE_RELOC_H_36#ifndef _MACHINE_RELOC_H_
lib/libc/include/arm-freebsd-eabihf/machine/resource.h-2
...@@ -40,8 +40,6 @@...@@ -40,8 +40,6 @@
40#define SYS_RES_MEMORY 3 /* i/o memory */40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */41#define SYS_RES_IOPORT 4 /* i/o ports */
42#define SYS_RES_GPIO 5 /* general purpose i/o */42#define SYS_RES_GPIO 5 /* general purpose i/o */
43#ifdef NEW_PCIB
44#define PCI_RES_BUS 6 /* PCI bus numbers */43#define PCI_RES_BUS 6 /* PCI bus numbers */
45#endif
4644
47#endif /* !_MACHINE_RESOURCE_H_ */45#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.1 (Berkeley) 6/11/93
32 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/0930 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
33 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:1731 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
34 */32 */
lib/libc/include/arm-freebsd-eabihf/machine/sysarch.h+2
...@@ -38,6 +38,8 @@...@@ -38,6 +38,8 @@
38#ifndef _ARM_SYSARCH_H_38#ifndef _ARM_SYSARCH_H_
39#define _ARM_SYSARCH_H_39#define _ARM_SYSARCH_H_
4040
41#include <sys/cdefs.h>
42
41#include <machine/armreg.h>43#include <machine/armreg.h>
4244
43#ifndef LOCORE45#ifndef LOCORE
lib/libc/include/arm-freebsd-eabihf/machine/sysreg.h+2-36
...@@ -127,11 +127,9 @@...@@ -127,11 +127,9 @@
127127
128/* From ARMv6: */128/* From ARMv6: */
129#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */129#define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */
130#if __ARM_ARCH >= 7
131/* From ARMv7: */130/* From ARMv7: */
132#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */131#define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */
133#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */132#define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */
134#endif
135133
136/*134/*
137 * CP15 C6 registers135 * CP15 C6 registers
...@@ -147,7 +145,7 @@...@@ -147,7 +145,7 @@
147/*145/*
148 * CP15 C7 registers146 * CP15 C7 registers
149 */147 */
150#if __ARM_ARCH >= 7 && defined(SMP)148#if defined(SMP)
151/* From ARMv7: */149/* From ARMv7: */
152#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */150#define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */
153#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */151#define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */
...@@ -157,17 +155,9 @@...@@ -157,17 +155,9 @@
157155
158#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */156#define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */
159#define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */157#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
164#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */158#define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */
165#define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */159#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
171#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */161#define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */
172#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */162#define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */
173163
...@@ -176,43 +166,25 @@...@@ -176,43 +166,25 @@
176#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */166#define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */
177#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */167#define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */
178168
179#if __ARM_ARCH >= 7
180/* From ARMv7: */169/* From ARMv7: */
181#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */170#define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */
182#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */171#define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */
183#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */172#define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */
184#define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */173#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
191#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */175#define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */
192#define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */176#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
201/* From ARMv7: */178/* From ARMv7: */
202#define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */179#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
209#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */181#define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */
210#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */182#define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */
211183
212/*184/*
213 * CP15 C8 registers185 * CP15 C8 registers
214 */186 */
215#if __ARM_ARCH >= 7 && defined(SMP)187#if defined(SMP)
216/* From ARMv7: */188/* From ARMv7: */
217#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */189#define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */
218#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */190#define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */
...@@ -232,11 +204,6 @@...@@ -232,11 +204,6 @@
232/*204/*
233 * CP15 C9 registers205 * CP15 C9 registers
234 */206 */
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
240#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */207#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */
241#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */208#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */
242#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */209#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */
...@@ -250,7 +217,6 @@...@@ -250,7 +217,6 @@
250#define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */217#define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */
251#define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */218#define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */
252#define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */219#define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */
253#endif
254220
255/*221/*
256 * CP15 C10 registers222 * CP15 C10 registers
lib/libc/include/arm-freebsd-eabihf/machine/vm.h+1-1
...@@ -36,7 +36,7 @@...@@ -36,7 +36,7 @@
36#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)4)36#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)4)
3737
38#define VM_MEMATTR_DEFAULT VM_MEMATTR_WB_WA38#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 */
40#ifdef _KERNEL40#ifdef _KERNEL
41/* Don't export aliased VM_MEMATTR to userland */41/* Don't export aliased VM_MEMATTR to userland */
42#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH /* for DRM */42#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;...@@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address;
200 * Need a page dump array for minidump.200 * Need a page dump array for minidump.
201 */201 */
202#define MINIDUMP_PAGE_TRACKING 1202#define MINIDUMP_PAGE_TRACKING 1
203#define MINIDUMP_STARTUP_PAGE_TRACKING 0
203204
204#endif /* _MACHINE_VMPARAM_H_ */205#endif /* _MACHINE_VMPARAM_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/_ctype.h-2
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * From @(#)ctype.h 8.4 (Berkeley) 1/21/94
40 * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp38 * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp
41 */39 */
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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)a.out.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _AOUT_H_32#ifndef _AOUT_H_
lib/libc/include/generic-freebsd/aio.h+1-1
...@@ -97,7 +97,7 @@...@@ -97,7 +97,7 @@
97struct __aiocb_private {97struct __aiocb_private {
98 long status;98 long status;
99 long error;99 long error;
100 void *kernelinfo;100 void *spare;
101};101};
102102
103/*103/*
lib/libc/include/generic-freebsd/ar.h-2
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * @(#)ar.h 8.2 (Berkeley) 1/21/94
40 */38 */
4139
42#ifndef _AR_H_40#ifndef _AR_H_
lib/libc/include/generic-freebsd/arpa/ftp.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ftp.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _ARPA_FTP_H_32#ifndef _ARPA_FTP_H_
lib/libc/include/generic-freebsd/arpa/inet.h-1
...@@ -52,7 +52,6 @@...@@ -52,7 +52,6 @@
52 */52 */
5353
54/*%54/*%
55 * @(#)inet.h 8.1 (Berkeley) 6/2/93
56 * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $55 * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
57 */56 */
5857
lib/libc/include/generic-freebsd/arpa/telnet.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)telnet.h 8.2 (Berkeley) 12/15/93
32 */30 */
3331
34#ifndef _ARPA_TELNET_H_32#ifndef _ARPA_TELNET_H_
lib/libc/include/generic-freebsd/arpa/tftp.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tftp.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _ARPA_TFTP_H_32#ifndef _ARPA_TFTP_H_
lib/libc/include/generic-freebsd/assert.h+7-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)assert.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#include <sys/cdefs.h>37#include <sys/cdefs.h>
...@@ -45,15 +43,22 @@...@@ -45,15 +43,22 @@
4543
46#undef assert44#undef assert
47#undef _assert45#undef _assert
46#undef __assert_unreachable
4847
49#ifdef NDEBUG48#ifdef NDEBUG
50#define assert(e) ((void)0)49#define assert(e) ((void)0)
51#define _assert(e) ((void)0)50#define _assert(e) ((void)0)
51#if __BSD_VISIBLE
52#define __assert_unreachable() __unreachable()
53#endif /* __BSD_VISIBLE */
52#else54#else
53#define _assert(e) assert(e)55#define _assert(e) assert(e)
5456
55#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \57#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
56 __LINE__, #e))58 __LINE__, #e))
59#if __BSD_VISIBLE
60#define __assert_unreachable() assert(0 && "unreachable segment reached")
61#endif /* __BSD_VISIBLE */
57#endif /* NDEBUG */62#endif /* NDEBUG */
5863
59#ifndef _ASSERT_H_64#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 @@...@@ -35,9 +35,9 @@
35#include "opt_cam.h"35#include "opt_cam.h"
36#endif36#endif
3737
38#include <sys/cdefs.h>
39#ifndef _KERNEL38#ifndef _KERNEL
40#include <stdbool.h>39#include <stdbool.h>
40#include <stdio.h>
41#endif41#endif
4242
43typedef u_int path_id_t;43typedef u_int path_id_t;
...@@ -350,6 +350,11 @@ typedef enum {...@@ -350,6 +350,11 @@ typedef enum {
350 CAM_EAF_PRINT_RESULT = 0x20350 CAM_EAF_PRINT_RESULT = 0x20
351} cam_error_ata_flags;351} 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
353typedef enum {358typedef enum {
354 CAM_STRVIS_FLAG_NONE = 0x00,359 CAM_STRVIS_FLAG_NONE = 0x00,
355 CAM_STRVIS_FLAG_NONASCII_MASK = 0x03,360 CAM_STRVIS_FLAG_NONASCII_MASK = 0x03,
lib/libc/include/generic-freebsd/cam/cam_ccb.h+39-2
...@@ -32,7 +32,6 @@...@@ -32,7 +32,6 @@
32#define _CAM_CAM_CCB_H 132#define _CAM_CAM_CCB_H 1
3333
34#include <sys/queue.h>34#include <sys/queue.h>
35#include <sys/cdefs.h>
36#include <sys/time.h>35#include <sys/time.h>
37#include <sys/limits.h>36#include <sys/limits.h>
38#ifndef _KERNEL37#ifndef _KERNEL
...@@ -298,15 +297,18 @@ typedef enum {...@@ -298,15 +297,18 @@ typedef enum {
298 XPORT_SRP, /* SCSI RDMA Protocol */297 XPORT_SRP, /* SCSI RDMA Protocol */
299 XPORT_NVME, /* NVMe over PCIe */298 XPORT_NVME, /* NVMe over PCIe */
300 XPORT_MMCSD, /* MMC, SD, SDIO card */299 XPORT_MMCSD, /* MMC, SD, SDIO card */
300 XPORT_NVMF, /* NVMe over Fabrics */
301 XPORT_UFSHCI, /* Universal Flash Storage Host Interface */
301} cam_xport;302} cam_xport;
302303
303#define XPORT_IS_NVME(t) ((t) == XPORT_NVME)304#define XPORT_IS_NVME(t) ((t) == XPORT_NVME || (t) == XPORT_NVMF)
304#define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA)305#define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA)
305#define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \306#define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \
306 (t) != XPORT_UNSPECIFIED && \307 (t) != XPORT_UNSPECIFIED && \
307 !XPORT_IS_ATA(t) && !XPORT_IS_NVME(t))308 !XPORT_IS_ATA(t) && !XPORT_IS_NVME(t))
308#define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \309#define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \
309 XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \310 XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \
311 XPORT_IS_NVME(t) ? DEVSTAT_TYPE_IF_NVME : \
310 DEVSTAT_TYPE_IF_OTHER)312 DEVSTAT_TYPE_IF_OTHER)
311313
312#define PROTO_VERSION_UNKNOWN (UINT_MAX - 1)314#define PROTO_VERSION_UNKNOWN (UINT_MAX - 1)
...@@ -653,6 +655,12 @@ struct ccb_pathinq_settings_nvme {...@@ -653,6 +655,12 @@ struct ccb_pathinq_settings_nvme {
653_Static_assert(sizeof(struct ccb_pathinq_settings_nvme) == 64,655_Static_assert(sizeof(struct ccb_pathinq_settings_nvme) == 64,
654 "ccb_pathinq_settings_nvme too big");656 "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
656#define PATHINQ_SETTINGS_SIZE 128664#define PATHINQ_SETTINGS_SIZE 128
657665
658struct ccb_pathinq {666struct ccb_pathinq {
...@@ -684,6 +692,7 @@ struct ccb_pathinq {...@@ -684,6 +692,7 @@ struct ccb_pathinq {
684 struct ccb_pathinq_settings_fc fc;692 struct ccb_pathinq_settings_fc fc;
685 struct ccb_pathinq_settings_sas sas;693 struct ccb_pathinq_settings_sas sas;
686 struct ccb_pathinq_settings_nvme nvme;694 struct ccb_pathinq_settings_nvme nvme;
695 struct ccb_pathinq_settings_nvmf nvmf;
687 char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];696 char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];
688 } xport_specific;697 } xport_specific;
689 u_int maxio; /* Max supported I/O size, in bytes. */698 u_int maxio; /* Max supported I/O size, in bytes. */
...@@ -1050,6 +1059,31 @@ struct ccb_trans_settings_nvme...@@ -1050,6 +1059,31 @@ struct ccb_trans_settings_nvme
1050 uint8_t max_speed; /* PCIe generation for each lane */1059 uint8_t max_speed; /* PCIe generation for each lane */
1051};1060};
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
1053#include <cam/mmc/mmc_bus.h>1087#include <cam/mmc/mmc_bus.h>
1054struct ccb_trans_settings_mmc {1088struct ccb_trans_settings_mmc {
1055 struct mmc_ios ios;1089 struct mmc_ios ios;
...@@ -1122,6 +1156,8 @@ struct ccb_trans_settings {...@@ -1122,6 +1156,8 @@ struct ccb_trans_settings {
1122 struct ccb_trans_settings_pata ata;1156 struct ccb_trans_settings_pata ata;
1123 struct ccb_trans_settings_sata sata;1157 struct ccb_trans_settings_sata sata;
1124 struct ccb_trans_settings_nvme nvme;1158 struct ccb_trans_settings_nvme nvme;
1159 struct ccb_trans_settings_nvmf nvmf;
1160 struct ccb_trans_settings_ufshci ufshci;
1125 } xport_specific;1161 } xport_specific;
1126};1162};
11271163
...@@ -1488,6 +1524,7 @@ cam_fill_mmcio(struct ccb_mmcio *mmcio, uint32_t retries,...@@ -1488,6 +1524,7 @@ cam_fill_mmcio(struct ccb_mmcio *mmcio, uint32_t retries,
1488 mmcio->cmd.opcode = mmc_opcode;1524 mmcio->cmd.opcode = mmc_opcode;
1489 mmcio->cmd.arg = mmc_arg;1525 mmcio->cmd.arg = mmc_arg;
1490 mmcio->cmd.flags = mmc_flags;1526 mmcio->cmd.flags = mmc_flags;
1527 mmcio->cmd.error = 0;
1491 mmcio->stop.opcode = 0;1528 mmcio->stop.opcode = 0;
1492 mmcio->stop.arg = 0;1529 mmcio->stop.arg = 0;
1493 mmcio->stop.flags = 0;1530 mmcio->stop.flags = 0;
lib/libc/include/generic-freebsd/cam/cam_debug.h+28-39
...@@ -81,57 +81,46 @@ extern uint32_t cam_dflags;...@@ -81,57 +81,46 @@ extern uint32_t cam_dflags;
81/* Printf delay value (to prevent scrolling) */81/* Printf delay value (to prevent scrolling) */
82extern uint32_t cam_debug_delay;82extern uint32_t cam_debug_delay;
8383
84/* Debugging macros. */84/* Helper routines -- helps conserve stack */
85#define CAM_DEBUGGED(path, flag) \85struct cam_ed;
86 (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \86void xpt_cam_path_debug(struct cam_path *path, const char *fmt, ...);
87 && (cam_dpath != NULL) \87void xpt_cam_dev_debug(struct cam_ed *dev, const char *fmt, ...);
88 && (xpt_path_comp(cam_dpath, path) >= 0) \88void xpt_cam_debug(const char *fmt, ...);
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 }
10189
102#define CAM_DEBUG_DEV(dev, flag, printfargs) \90/* Stupid macro to remove a layer of parens */
103 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \91#define _CAM_X(...) __VA_ARGS__
104 && (cam_dpath != NULL) \92
105 && (xpt_path_comp_dev(cam_dpath, dev) >= 0) \93/* Debugging macros. */
106 && (xpt_path_comp_dev(cam_dpath, dev) < 2)) { \94#define CAM_DEBUGGED(path, flag) \
107 xpt_print_device(dev); \95 (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
108 printf printfargs; \96 && (cam_dpath != NULL) \
109 if (cam_debug_delay != 0) \97 && (xpt_path_comp(cam_dpath, (path)) >= 0) \
110 DELAY(cam_debug_delay); \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); \
111 }103 }
112104
113#define CAM_DEBUG_PRINT(flag, printfargs) \105#define CAM_DEBUG_DEV(dev, flag, printfargs) \
114 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \106 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
115 printf("cam_debug: "); \107 && (cam_dpath != NULL) \
116 printf printfargs; \108 && (xpt_path_comp_dev(cam_dpath, (dev)) >= 0) \
117 if (cam_debug_delay != 0) \109 && (xpt_path_comp_dev(cam_dpath, (dev)) < 2)) { \
118 DELAY(cam_debug_delay); \110 xpt_cam_dev_debug(dev, _CAM_X printfargs); \
119 }111 }
120112
121#define CAM_DEBUG_PATH_PRINT(flag, path, printfargs) \113#define CAM_DEBUG_PRINT(flag, printfargs) \
122 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \114 if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
123 xpt_print(path, "cam_debug: "); \115 xpt_cam_debug(_CAM_X printfargs); \
124 printf printfargs; \
125 if (cam_debug_delay != 0) \
126 DELAY(cam_debug_delay); \
127 }116 }
128117
129#else /* !_KERNEL */118#else /* !_KERNEL */
130119
131#define CAM_DEBUGGED(A, B) 0120#define CAM_DEBUGGED(A, B) 0
132#define CAM_DEBUG(A, B, C)121#define CAM_DEBUG(A, B, C)
122#define CAM_DEBUG_DEV(A, B, C)
133#define CAM_DEBUG_PRINT(A, B)123#define CAM_DEBUG_PRINT(A, B)
134#define CAM_DEBUG_PATH_PRINT(A, B, C)
135124
136#endif /* _KERNEL */125#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)...@@ -79,8 +79,10 @@ cam_iosched_sbintime_t(uintptr_t delta)
79}79}
8080
81typedef void (*cam_iosched_latfcn_t)(void *, sbintime_t, struct bio *);81typedef 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);
84void cam_iosched_fini(struct cam_iosched_softc *);86void cam_iosched_fini(struct cam_iosched_softc *);
85void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *);87void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *);
86struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc);88struct 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,...@@ -60,15 +60,6 @@ struct cam_sim * cam_sim_alloc(sim_action_func sim_action,
60 int max_dev_transactions,60 int max_dev_transactions,
61 int max_tagged_dev_transactions,61 int max_tagged_dev_transactions,
62 struct cam_devq *queue);62 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);
72void cam_sim_free(struct cam_sim *sim, int free_devq);63void cam_sim_free(struct cam_sim *sim, int free_devq);
73void cam_sim_hold(struct cam_sim *sim);64void cam_sim_hold(struct cam_sim *sim);
74void cam_sim_release(struct cam_sim *sim);65void cam_sim_release(struct cam_sim *sim);
lib/libc/include/generic-freebsd/cam/cam_xpt.h+17-7
...@@ -33,16 +33,15 @@...@@ -33,16 +33,15 @@
33#define _CAM_CAM_XPT_H 133#define _CAM_CAM_XPT_H 1
3434
35#ifdef _KERNEL35#ifdef _KERNEL
36#include <sys/cdefs.h>
37#include <cam/cam_ccb.h>36#include <cam/cam_ccb.h>
38#endif37#endif
38#include <sys/sbuf.h>
3939
40/* Forward Declarations */40/* Forward Declarations */
41union ccb;41union ccb;
42struct cam_periph;42struct cam_periph;
43struct cam_ed;43struct cam_ed;
44struct cam_sim;44struct cam_sim;
45struct sbuf;
4645
47/*46/*
48 * Definition of a CAM path. Paths are created from bus, target, and lun ids47 * 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);...@@ -113,7 +112,6 @@ struct cam_sim *xpt_path_sim(struct cam_path *path);
113struct cam_periph *xpt_path_periph(struct cam_path *path);112struct cam_periph *xpt_path_periph(struct cam_path *path);
114device_t xpt_path_sim_device(const struct cam_path *path);113device_t xpt_path_sim_device(const struct cam_path *path);
115void xpt_print_path(struct cam_path *path);114void xpt_print_path(struct cam_path *path);
116void xpt_print_device(struct cam_ed *device);
117void xpt_print(struct cam_path *path, const char *fmt, ...);115void xpt_print(struct cam_path *path, const char *fmt, ...);
118void xpt_async(uint32_t async_code, struct cam_path *path,116void xpt_async(uint32_t async_code, struct cam_path *path,
119 void *async_arg);117 void *async_arg);
...@@ -147,19 +145,31 @@ uint32_t xpt_poll_setup(union ccb *start_ccb);...@@ -147,19 +145,31 @@ uint32_t xpt_poll_setup(union ccb *start_ccb);
147void xpt_sim_poll(struct cam_sim *sim);145void xpt_sim_poll(struct cam_sim *sim);
148146
149/*147/*
150 * Perform a path inquiry at the request priority. The bzero may be148 * Perform a path inquiry. bzero may be redundant for allocated CCBs, but for
151 * unnecessary.149 * the on-stack CCBs it's required.
152 */150 */
153static inline void151static inline void
154xpt_path_inq(struct ccb_pathinq *cpi, struct cam_path *path)152xpt_path_inq(struct ccb_pathinq *cpi, struct cam_path *path)
155{153{
156
157 bzero(cpi, sizeof(*cpi));154 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);
159 cpi->ccb_h.func_code = XPT_PATH_INQ;156 cpi->ccb_h.func_code = XPT_PATH_INQ;
160 xpt_action((union ccb *)cpi);157 xpt_action((union ccb *)cpi);
161}158}
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
163#endif /* _KERNEL */173#endif /* _KERNEL */
164174
165#endif /* _CAM_CAM_XPT_H */175#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;...@@ -42,10 +42,10 @@ struct sbuf;
42void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *);42void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *);
43void nvme_print_ident_short(const struct nvme_controller_data *,43void nvme_print_ident_short(const struct nvme_controller_data *,
44 const struct nvme_namespace_data *, struct sbuf *);44 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);
47void nvme_cmd_sbuf(const struct nvme_command *, struct sbuf *sb);45void nvme_cmd_sbuf(const struct nvme_command *, struct sbuf *sb);
48int nvme_command_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb);46int 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);
49const void *nvme_get_identify_cntrl(struct cam_periph *);49const void *nvme_get_identify_cntrl(struct cam_periph *);
50const void *nvme_get_identify_ns(struct cam_periph *);50const 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,18 +1,12 @@
1/*-1/*
2 * Largely written by Julian Elischer (julian@tfs.com)2 * Copyright (c) 1997-2017 Kenneth D. Merry <ken@FreeBSD.org>
3 * for TRW Financial Systems.3 * Copyright (c) 2012-2020 Alexander Motin <mav@FreeBSD.org>
4 *4 * Copyright (c) 1997-2011 Justin T. Gibbs <gibbs@FreeBSD.org>
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.
10 *5 *
11 * TFS supplies this software to be publicly redistributed6 * SPDX-License-Identifier: BSD-2-Clause
12 * on the understanding that TFS is not responsible for the correct
13 * functioning of this software in any circumstances.
14 *7 *
15 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 19928 * 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.
16 */10 */
1711
18/*12/*
...@@ -22,10 +16,9 @@...@@ -22,10 +16,9 @@
22#ifndef _SCSI_SCSI_ALL_H16#ifndef _SCSI_SCSI_ALL_H
23#define _SCSI_SCSI_ALL_H 117#define _SCSI_SCSI_ALL_H 1
2418
25#include <sys/cdefs.h>
26#ifdef _KERNEL19#ifdef _KERNEL
27#include <sys/malloc.h>20#include <sys/malloc.h>
28#include <machine/stdarg.h>21#include <sys/stdarg.h>
29#else22#else
30#include <stdarg.h>23#include <stdarg.h>
31#endif24#endif
lib/libc/include/generic-freebsd/cam/scsi/scsi_ch.h-1
...@@ -64,7 +64,6 @@...@@ -64,7 +64,6 @@
64#ifndef _SCSI_SCSI_CH_H64#ifndef _SCSI_SCSI_CH_H
65#define _SCSI_SCSI_CH_H 165#define _SCSI_SCSI_CH_H 1
6666
67#include <sys/cdefs.h>
6867
69/*68/*
70 * SCSI command format69 * SCSI command format
lib/libc/include/generic-freebsd/cam/scsi/scsi_da.h-1
...@@ -50,7 +50,6 @@...@@ -50,7 +50,6 @@
50#ifndef _SCSI_SCSI_DA_H50#ifndef _SCSI_SCSI_DA_H
51#define _SCSI_SCSI_DA_H 151#define _SCSI_SCSI_DA_H 1
5252
53#include <sys/cdefs.h>
5453
55struct scsi_rezero_unit54struct scsi_rezero_unit
56{55{
lib/libc/include/generic-freebsd/cam/scsi/scsi_sa.h-1
...@@ -33,7 +33,6 @@...@@ -33,7 +33,6 @@
33#ifndef _SCSI_SCSI_SA_H33#ifndef _SCSI_SCSI_SA_H
34#define _SCSI_SCSI_SA_H 134#define _SCSI_SCSI_SA_H 1
3535
36#include <sys/cdefs.h>
3736
38struct scsi_read_block_limits37struct scsi_read_block_limits
39{38{
lib/libc/include/generic-freebsd/crypto/cryptodev.h+1-1
...@@ -433,7 +433,7 @@ struct cryptop {...@@ -433,7 +433,7 @@ struct cryptop {
433 int crp_flags;433 int crp_flags;
434434
435#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */435#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 */
437#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */437#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */
438#define CRYPTO_F_ASYNC_ORDERED 0x0100 /* Completions must happen in order */438#define CRYPTO_F_ASYNC_ORDERED 0x0100 /* Completions must happen in order */
439#define CRYPTO_F_IV_SEPARATE 0x0200 /* Use crp_iv[] as IV. */439#define CRYPTO_F_IV_SEPARATE 0x0200 /* Use crp_iv[] as IV. */
lib/libc/include/generic-freebsd/ctype.h-2
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * @(#)ctype.h 8.4 (Berkeley) 1/21/94
40 */38 */
4139
42#ifndef _CTYPE_H_40#ifndef _CTYPE_H_
lib/libc/include/generic-freebsd/db.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)db.h 8.7 (Berkeley) 6/16/94
32 */30 */
3331
34#ifndef _DB_H_32#ifndef _DB_H_
lib/libc/include/generic-freebsd/dev/ciss/cissreg.h+1-1
...@@ -684,7 +684,7 @@ struct ciss_bmic_id_table {...@@ -684,7 +684,7 @@ struct ciss_bmic_id_table {
684 u_int8_t percent_write_cache; /* Percent of memory allocated to write cache */684 u_int8_t percent_write_cache; /* Percent of memory allocated to write cache */
685 u_int16_t daughterboard_size_mb; /* Total size (MB) of cache board */685 u_int16_t daughterboard_size_mb; /* Total size (MB) of cache board */
686 u_int8_t cache_batter_count; /* Number of cache batteries */686 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 */
688 u_int8_t more_controller_flags; /* Additional controller flags byte */688 u_int8_t more_controller_flags; /* Additional controller flags byte */
689 u_int8_t x_board_host_i2c_rev; /* 2nd byte of 3 byte autorev field */689 u_int8_t x_board_host_i2c_rev; /* 2nd byte of 3 byte autorev field */
690 u_int8_t battery_pic_rev; /* BBWC PIC revision */690 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...@@ -184,7 +184,7 @@ struct ciss_softc
184{184{
185 /* bus connections */185 /* bus connections */
186 device_t ciss_dev; /* bus attachment */186 device_t ciss_dev; /* bus attachment */
187 struct cdev *ciss_dev_t; /* control device */187 struct cdev *ciss_dev_t; /* control device */
188188
189 struct resource *ciss_regs_resource; /* register interface window */189 struct resource *ciss_regs_resource; /* register interface window */
190 int ciss_regs_rid; /* resource ID */190 int ciss_regs_rid; /* resource ID */
...@@ -236,6 +236,7 @@ struct ciss_softc...@@ -236,6 +236,7 @@ struct ciss_softc
236 int ciss_max_bus_number; /* maximum bus number */236 int ciss_max_bus_number; /* maximum bus number */
237 int ciss_max_logical_bus;237 int ciss_max_logical_bus;
238 int ciss_max_physical_bus;238 int ciss_max_physical_bus;
239 int ciss_max_physical_target; /* highest physical target number */
239240
240 struct cam_devq *ciss_cam_devq;241 struct cam_devq *ciss_cam_devq;
241 struct cam_sim **ciss_cam_sim;242 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;...@@ -293,7 +293,7 @@ extern int firewire_debug;
293extern devclass_t firewire_devclass;293extern devclass_t firewire_devclass;
294extern int firewire_phydma_enable;294extern int firewire_phydma_enable;
295295
296#define FWPRI ((PZERO + 8) | PCATCH)296#define FWPRI (PWAIT | PCATCH)
297297
298#define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */)298#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 @@...@@ -57,6 +57,7 @@
57#define HUP_SCALE 0x008c57#define HUP_SCALE 0x008c
58#define HUP_CAMERA_CONTROL 0x009058#define HUP_CAMERA_CONTROL 0x0090
59#define HUP_ARCADE 0x009159#define HUP_ARCADE 0x0091
60#define HUP_FIDO 0xf1d0
60#define HUP_MICROSOFT 0xff0061#define HUP_MICROSOFT 0xff00
6162
62/* Usages, generic desktop */63/* Usages, generic desktop */
...@@ -161,6 +162,9 @@...@@ -161,6 +162,9 @@
161#define HUC_HEADPHONE 0x0005162#define HUC_HEADPHONE 0x0005
162#define HUC_AC_PAN 0x0238163#define HUC_AC_PAN 0x0238
163164
165/* Usages, FIDO */
166#define HUF_U2FHID 0x0001
167
164#define HID_USAGE2(p,u) (((p) << 16) | (u))168#define HID_USAGE2(p,u) (((p) << 16) | (u))
165#define HID_GET_USAGE(u) ((u) & 0xffff)169#define HID_GET_USAGE(u) ((u) & 0xffff)
166#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff)170#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff)
...@@ -233,31 +237,31 @@ struct hid_location {...@@ -233,31 +237,31 @@ struct hid_location {
233237
234struct hid_item {238struct hid_item {
235 /* Global */239 /* Global */
236 int32_t _usage_page;240 uint32_t _usage_page;
237 int32_t logical_minimum;241 int32_t logical_minimum;
238 int32_t logical_maximum;242 int32_t logical_maximum;
239 int32_t physical_minimum;243 int32_t physical_minimum;
240 int32_t physical_maximum;244 int32_t physical_maximum;
241 int32_t unit_exponent;245 uint32_t unit_exponent;
242 int32_t unit;246 uint32_t unit;
243 int32_t report_ID;247 uint32_t report_ID;
244 /* Local */248 /* Local */
245 int nusages;249 int nusages;
246 union {250 union {
247 int32_t usage;251 uint32_t usage;
248 int32_t usages[HID_ITEM_MAXUSAGE];252 uint32_t usages[HID_ITEM_MAXUSAGE];
249 };253 };
250 int32_t usage_minimum;254 uint32_t usage_minimum;
251 int32_t usage_maximum;255 uint32_t usage_maximum;
252 int32_t designator_index;256 uint32_t designator_index;
253 int32_t designator_minimum;257 uint32_t designator_minimum;
254 int32_t designator_maximum;258 uint32_t designator_maximum;
255 int32_t string_index;259 uint32_t string_index;
256 int32_t string_minimum;260 uint32_t string_minimum;
257 int32_t string_maximum;261 uint32_t string_maximum;
258 int32_t set_delimiter;262 uint32_t set_delimiter;
259 /* Misc */263 /* Misc */
260 int32_t collection;264 uint32_t collection;
261 int collevel;265 int collevel;
262 enum hid_kind kind;266 enum hid_kind kind;
263 uint32_t flags;267 uint32_t flags;
lib/libc/include/generic-freebsd/dev/hid/hidraw.h+4
...@@ -92,5 +92,9 @@ struct hidraw_devinfo {...@@ -92,5 +92,9 @@ struct hidraw_devinfo {
92#define HIDIOCSFEATURE(len) _IOC(IOC_IN, 'U', 35, len)92#define HIDIOCSFEATURE(len) _IOC(IOC_IN, 'U', 35, len)
93#define HIDIOCGFEATURE(len) _IOC(IOC_INOUT, 'U', 36, len)93#define HIDIOCGFEATURE(len) _IOC(IOC_INOUT, 'U', 36, len)
94#define HIDIOCGRAWUNIQ(len) _IOC(IOC_OUT, 'U', 37, len)94#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
96#endif /* _HID_HIDRAW_H */100#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 @@...@@ -31,7 +31,7 @@
31#ifndef _DEV_HWPMC_AMD_H_31#ifndef _DEV_HWPMC_AMD_H_
32#define _DEV_HWPMC_AMD_H_ 132#define _DEV_HWPMC_AMD_H_ 1
3333
34/* AMD K7 and K8 PMCs */34/* AMD K8 PMCs */
3535
36#define AMD_PMC_EVSEL_0 0xC001000036#define AMD_PMC_EVSEL_0 0xC0010000
37#define AMD_PMC_EVSEL_1 0xC001000137#define AMD_PMC_EVSEL_1 0xC0010001
lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_arm64.h+1-1
...@@ -42,7 +42,7 @@...@@ -42,7 +42,7 @@
42#ifdef _KERNEL42#ifdef _KERNEL
43/* MD extension for 'struct pmc' */43/* MD extension for 'struct pmc' */
44struct pmc_md_arm64_pmc {44struct pmc_md_arm64_pmc {
45 uint32_t pm_arm64_evsel;45 uint64_t pm_arm64_evsel;
46};46};
47#endif /* _KERNEL */47#endif /* _KERNEL */
48#endif /* _DEV_HWPMC_ARMV8_H_ */48#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,...@@ -198,11 +198,9 @@ int pmc_core_initialize(struct pmc_mdep *_md, int _maxcpu,
198void pmc_core_finalize(struct pmc_mdep *_md);198void pmc_core_finalize(struct pmc_mdep *_md);
199199
200int pmc_iaf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width);200int pmc_iaf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width);
201void pmc_iaf_finalize(struct pmc_mdep *_md);
202201
203int pmc_iap_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width,202int pmc_iap_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width,
204 int _flags);203 int _flags);
205void pmc_iap_finalize(struct pmc_mdep *_md);
206204
207#endif /* _KERNEL */205#endif /* _KERNEL */
208#endif /* _DEV_HWPMC_CORE_H */206#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)...@@ -62,39 +62,6 @@ __PMC_EV_ALIAS("cycles", TSC_TSC)
62#define PMC_EV_SOFT_FIRST 0x2000062#define PMC_EV_SOFT_FIRST 0x20000
63#define PMC_EV_SOFT_LAST (PMC_EV_SOFT_FIRST + PMC_EV_DYN_COUNT - 1)63#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
98/* AMD K8 PMCs */65/* AMD K8 PMCs */
9966
100#define __PMC_EV_K8() \67#define __PMC_EV_K8() \
...@@ -2431,7 +2398,7 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF)...@@ -2431,7 +2398,7 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF)
2431 * START #EVENTS DESCRIPTION2398 * START #EVENTS DESCRIPTION
2432 * 0 0x1000 Reserved2399 * 0 0x1000 Reserved
2433 * 0x1000 0x0001 TSC2400 * 0x1000 0x0001 TSC
2434 * 0x2000 0x0080 AMD K7 events2401 * 0x2000 0x0080 free (was AMD K7 events)
2435 * 0x2080 0x0100 AMD K8 events2402 * 0x2080 0x0100 AMD K8 events
2436 * 0x10000 0x0080 INTEL architectural fixed-function events2403 * 0x10000 0x0080 INTEL architectural fixed-function events
2437 * 0x10080 0x0F80 free (was INTEL architectural programmable events)2404 * 0x10080 0x0F80 free (was INTEL architectural programmable events)
...@@ -2457,8 +2424,6 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF)...@@ -2457,8 +2424,6 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF)
2457#define __PMC_EVENTS() \2424#define __PMC_EVENTS() \
2458 __PMC_EV_BLOCK(TSC, 0x01000) \2425 __PMC_EV_BLOCK(TSC, 0x01000) \
2459 __PMC_EV_TSC() \2426 __PMC_EV_TSC() \
2460 __PMC_EV_BLOCK(K7, 0x02000) \
2461 __PMC_EV_K7() \
2462 __PMC_EV_BLOCK(K8, 0x02080) \2427 __PMC_EV_BLOCK(K8, 0x02080) \
2463 __PMC_EV_K8() \2428 __PMC_EV_K8() \
2464 __PMC_EV_BLOCK(IAF, 0x10000) \2429 __PMC_EV_BLOCK(IAF, 0x10000) \
lib/libc/include/generic-freebsd/dev/ic/nec765.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)nec765.h 7.1 (Berkeley) 5/9/91
32 */30 */
3331
34/*32/*
lib/libc/include/generic-freebsd/dev/ic/ns16550.h-5
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)ns16550.h 7.1 (Berkeley) 5/9/91
32 */30 */
3331
34/*32/*
...@@ -162,9 +160,6 @@...@@ -162,9 +160,6 @@
162#define FIFO_XMT_RST FCR_XMT_RST160#define FIFO_XMT_RST FCR_XMT_RST
163#define FCR_DMA 0x08161#define FCR_DMA 0x08
164#define FIFO_DMA_MODE FCR_DMA162#define FIFO_DMA_MODE FCR_DMA
165#ifdef CPU_XBURST
166#define FCR_UART_ON 0x10
167#endif
168#define FCR_RX_LOW 0x00163#define FCR_RX_LOW 0x00
169#define FIFO_RX_LOW FCR_RX_LOW164#define FIFO_RX_LOW FCR_RX_LOW
170#define FCR_RX_MEDL 0x40165#define FCR_RX_MEDL 0x40
lib/libc/include/generic-freebsd/dev/iicbus/iiconf.h+1-1
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32#include <dev/iicbus/iic.h>32#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
37#define LSB 0x137#define LSB 0x1
3838
lib/libc/include/generic-freebsd/dev/mfi/mfireg.h+1-1
...@@ -1028,7 +1028,7 @@ struct mfi_evt_detail {...@@ -1028,7 +1028,7 @@ struct mfi_evt_detail {
1028 } pd_prog;1028 } pd_prog;
10291029
1030 struct {1030 struct {
1031 struct mfi_evt_pd ld;1031 struct mfi_evt_pd pd;
1032 uint32_t prev_state;1032 uint32_t prev_state;
1033 uint32_t new_state;1033 uint32_t new_state;
1034 } pd_state;1034 } pd_state;
lib/libc/include/generic-freebsd/dev/mmc/bridge.h+5
...@@ -103,6 +103,10 @@ enum mmc_chip_select {...@@ -103,6 +103,10 @@ enum mmc_chip_select {
103 cs_dontcare = 0, cs_high, cs_low103 cs_dontcare = 0, cs_high, cs_low
104};104};
105105
106enum mmc_bus_type {
107 bus_type_default = 0, bus_type_spi
108};
109
106enum mmc_bus_width {110enum mmc_bus_width {
107 bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3111 bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3
108};112};
...@@ -123,6 +127,7 @@ struct mmc_ios {...@@ -123,6 +127,7 @@ struct mmc_ios {
123 uint32_t clock; /* Speed of the clock in Hz to move data */127 uint32_t clock; /* Speed of the clock in Hz to move data */
124 enum mmc_vdd vdd; /* Voltage to apply to the power pins */128 enum mmc_vdd vdd; /* Voltage to apply to the power pins */
125 enum mmc_vccq vccq; /* Voltage to use for signaling */129 enum mmc_vccq vccq; /* Voltage to use for signaling */
130 enum mmc_bus_type bus_type;
126 enum mmc_bus_mode bus_mode;131 enum mmc_bus_mode bus_mode;
127 enum mmc_chip_select chip_select;132 enum mmc_chip_select chip_select;
128 enum mmc_bus_width bus_width;133 enum mmc_bus_width bus_width;
lib/libc/include/generic-freebsd/dev/mmc/mmc_fdt_helpers.h+1-1
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
31#include <dev/gpio/gpiobusvar.h>31#include <dev/gpio/gpiobusvar.h>
32#include <dev/ofw/ofw_bus.h>32#include <dev/ofw/ofw_bus.h>
3333
34#include <dev/extres/regulator/regulator.h>34#include <dev/regulator/regulator.h>
3535
36#include <dev/mmc/mmc_helpers.h>36#include <dev/mmc/mmc_helpers.h>
3737
lib/libc/include/generic-freebsd/dev/mmc/mmc_helpers.h+1-1
...@@ -30,7 +30,7 @@...@@ -30,7 +30,7 @@
3030
31#include <dev/gpio/gpiobusvar.h>31#include <dev/gpio/gpiobusvar.h>
3232
33#include <dev/extres/regulator/regulator.h>33#include <dev/regulator/regulator.h>
3434
35struct mmc_helper {35struct mmc_helper {
36 device_t dev;36 device_t dev;
lib/libc/include/generic-freebsd/dev/mmc/mmcbrvar.h+12
...@@ -60,6 +60,7 @@...@@ -60,6 +60,7 @@
60#include "mmcbr_if.h"60#include "mmcbr_if.h"
6161
62enum mmcbr_device_ivars {62enum mmcbr_device_ivars {
63 MMCBR_IVAR_BUS_TYPE,
63 MMCBR_IVAR_BUS_MODE,64 MMCBR_IVAR_BUS_MODE,
64 MMCBR_IVAR_BUS_WIDTH,65 MMCBR_IVAR_BUS_WIDTH,
65 MMCBR_IVAR_CHIP_SELECT,66 MMCBR_IVAR_CHIP_SELECT,
...@@ -113,6 +114,17 @@ mmcbr_get_retune_req(device_t dev)...@@ -113,6 +114,17 @@ mmcbr_get_retune_req(device_t dev)
113 return ((int)v);114 return ((int)v);
114}115}
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
116/*128/*
117 * Convenience wrappers for the mmcbr interface129 * Convenience wrappers for the mmcbr interface
118 */130 */
lib/libc/include/generic-freebsd/dev/mmc/mmcreg.h+1
...@@ -80,6 +80,7 @@ struct mmc_command {...@@ -80,6 +80,7 @@ struct mmc_command {
80#define MMC_CMD_BC (2ul << 5) /* Broadcast command, no response */80#define MMC_CMD_BC (2ul << 5) /* Broadcast command, no response */
81#define MMC_CMD_BCR (3ul << 5) /* Broadcast command with response */81#define MMC_CMD_BCR (3ul << 5) /* Broadcast command with response */
82#define MMC_CMD_MASK (3ul << 5)82#define MMC_CMD_MASK (3ul << 5)
83#define MMC_CMD_IS_APP (1ul << 7) /* Next cmd after MMC_APP_CMD */
8384
84/* Possible response types defined in the standard: */85/* Possible response types defined in the standard: */
85#define MMC_RSP_NONE (0)86#define MMC_RSP_NONE (0)
lib/libc/include/generic-freebsd/dev/nvme/nvme.h+80-7
...@@ -35,15 +35,23 @@...@@ -35,15 +35,23 @@
3535
36#include <sys/param.h>36#include <sys/param.h>
37#include <sys/endian.h>37#include <sys/endian.h>
38#ifndef _KERNEL
39#include <stdbool.h>
40#endif
41
42struct sbuf;
3843
39#define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command)44#define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command)
40#define NVME_RESET_CONTROLLER _IO('n', 1)45#define NVME_RESET_CONTROLLER _IO('n', 1)
41#define NVME_GET_NSID _IOR('n', 2, struct nvme_get_nsid)46#define NVME_GET_NSID _IOR('n', 2, struct nvme_get_nsid)
42#define NVME_GET_MAX_XFER_SIZE _IOR('n', 3, uint64_t)47#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
44#define NVME_IO_TEST _IOWR('n', 100, struct nvme_io_test)50#define NVME_IO_TEST _IOWR('n', 100, struct nvme_io_test)
45#define NVME_BIO_TEST _IOWR('n', 101, struct nvme_io_test)51#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
47/*55/*
48 * Macros to deal with NVME revisions, as defined VS register56 * Macros to deal with NVME revisions, as defined VS register
49 */57 */
...@@ -211,6 +219,11 @@...@@ -211,6 +219,11 @@
211219
212/* Command field definitions */220/* Command field definitions */
213221
222enum nvme_fuse {
223 NVME_FUSE_NORMAL = 0x0,
224 NVME_FUSE_FIRST = 0x1,
225 NVME_FUSE_SECOND = 0x2
226};
214#define NVME_CMD_FUSE_SHIFT (0)227#define NVME_CMD_FUSE_SHIFT (0)
215#define NVME_CMD_FUSE_MASK (0x3)228#define NVME_CMD_FUSE_MASK (0x3)
216229
...@@ -390,9 +403,24 @@ enum nvme_psdt {...@@ -390,9 +403,24 @@ enum nvme_psdt {
390/* per namespace smart/health log page */403/* per namespace smart/health log page */
391#define NVME_CTRLR_DATA_LPA_NS_SMART_SHIFT (0)404#define NVME_CTRLR_DATA_LPA_NS_SMART_SHIFT (0)
392#define NVME_CTRLR_DATA_LPA_NS_SMART_MASK (0x1)405#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)
393/* extended data for Get Log Page command */409/* extended data for Get Log Page command */
394#define NVME_CTRLR_DATA_LPA_EXT_DATA_SHIFT (2)410#define NVME_CTRLR_DATA_LPA_EXT_DATA_SHIFT (2)
395#define NVME_CTRLR_DATA_LPA_EXT_DATA_MASK (0x1)411#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
397/** AVSCC - admin vendor specific command configuration */425/** AVSCC - admin vendor specific command configuration */
398/* admin vendor specific commands use spec format */426/* admin vendor specific commands use spec format */
...@@ -623,10 +651,19 @@ enum nvme_critical_warning_state {...@@ -623,10 +651,19 @@ enum nvme_critical_warning_state {
623 NVME_CRIT_WARN_ST_DEVICE_RELIABILITY = 0x4,651 NVME_CRIT_WARN_ST_DEVICE_RELIABILITY = 0x4,
624 NVME_CRIT_WARN_ST_READ_ONLY = 0x8,652 NVME_CRIT_WARN_ST_READ_ONLY = 0x8,
625 NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP = 0x10,653 NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP = 0x10,
654 NVME_CRIT_WARN_ST_PERSISTENT_MEMORY_REGION = 0x20,
626};655};
627#define NVME_CRIT_WARN_ST_RESERVED_MASK (0xE0)656#define NVME_CRIT_WARN_ST_RESERVED_MASK (0xC0)
628#define NVME_ASYNC_EVENT_NS_ATTRIBUTE (0x100)657#define NVME_ASYNC_EVENT_NS_ATTRIBUTE (1U << 8)
629#define NVME_ASYNC_EVENT_FW_ACTIVATE (0x200)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
631/* slot for current FW */668/* slot for current FW */
632#define NVME_FIRMWARE_PAGE_AFI_SLOT_SHIFT (0)669#define NVME_FIRMWARE_PAGE_AFI_SLOT_SHIFT (0)
...@@ -809,7 +846,7 @@ struct nvme_command {...@@ -809,7 +846,7 @@ struct nvme_command {
809 uint32_t cdw13; /* command-specific */846 uint32_t cdw13; /* command-specific */
810 uint32_t cdw14; /* command-specific */847 uint32_t cdw14; /* command-specific */
811 uint32_t cdw15; /* command-specific */848 uint32_t cdw15; /* command-specific */
812};849} __aligned(8);
813850
814_Static_assert(sizeof(struct nvme_command) == 16 * 4, "bad size for nvme_command");851_Static_assert(sizeof(struct nvme_command) == 16 * 4, "bad size for nvme_command");
815852
...@@ -1578,7 +1615,7 @@ struct nvme_health_information_page {...@@ -1578,7 +1615,7 @@ struct nvme_health_information_page {
1578 uint32_t ttftmt2;1615 uint32_t ttftmt2;
15791616
1580 uint8_t reserved2[280];1617 uint8_t reserved2[280];
1581} __packed __aligned(4);1618} __packed __aligned(8);
15821619
1583_Static_assert(sizeof(struct nvme_health_information_page) == 512, "bad size for nvme_health_information_page");1620_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 {...@@ -1629,6 +1666,30 @@ struct nvme_device_self_test_page {
1629_Static_assert(sizeof(struct nvme_device_self_test_page) == 564,1666_Static_assert(sizeof(struct nvme_device_self_test_page) == 564,
1630 "bad size for nvme_device_self_test_page");1667 "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
1632struct nvme_discovery_log_entry {1693struct nvme_discovery_log_entry {
1633 uint8_t trtype;1694 uint8_t trtype;
1634 uint8_t adrfam;1695 uint8_t adrfam;
...@@ -1845,6 +1906,9 @@ struct nvme_hmb_desc {...@@ -1845,6 +1906,9 @@ struct nvme_hmb_desc {
1845#define nvme_completion_is_error(cpl) \1906#define nvme_completion_is_error(cpl) \
1846 (NVME_STATUS_GET_SC((cpl)->status) != 0 || NVME_STATUS_GET_SCT((cpl)->status) != 0)1907 (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);
1848void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen);1912void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen);
18491913
1850#ifdef _KERNEL1914#ifdef _KERNEL
...@@ -1855,6 +1919,7 @@ struct thread;...@@ -1855,6 +1919,7 @@ struct thread;
1855struct nvme_namespace;1919struct nvme_namespace;
1856struct nvme_controller;1920struct nvme_controller;
1857struct nvme_consumer;1921struct nvme_consumer;
1922struct nvme_passthru_cmd;
18581923
1859typedef void (*nvme_cb_fn_t)(void *, const struct nvme_completion *);1924typedef 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 *,...@@ -1865,8 +1930,11 @@ typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *,
1865typedef void (*nvme_cons_fail_fn_t)(void *);1930typedef void (*nvme_cons_fail_fn_t)(void *);
18661931
1867enum nvme_namespace_flags {1932enum nvme_namespace_flags {
1868 NVME_NS_DEALLOCATE_SUPPORTED = 0x1,1933 NVME_NS_DEALLOCATE_SUPPORTED = 0x01,
1869 NVME_NS_FLUSH_SUPPORTED = 0x2,1934 NVME_NS_FLUSH_SUPPORTED = 0x02,
1935 NVME_NS_ADDED = 0x04,
1936 NVME_NS_CHANGED = 0x08,
1937 NVME_NS_GONE = 0x10,
1870};1938};
18711939
1872int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,1940int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
...@@ -1874,6 +1942,11 @@ int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,...@@ -1874,6 +1942,11 @@ int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
1874 uint32_t nsid, int is_user_buffer,1942 uint32_t nsid, int is_user_buffer,
1875 int is_admin_cmd);1943 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
1877/* Admin functions */1950/* Admin functions */
1878void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr,1951void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr,
1879 uint8_t feature, uint32_t cdw11,1952 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 @@...@@ -30,6 +30,6 @@
30#define _DEV_OFW_OFW_CPU_H_30#define _DEV_OFW_OFW_CPU_H_
3131
32typedef bool (*ofw_cpu_foreach_cb)(u_int, phandle_t, u_int, pcell_t *);32typedef 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
35#endif /* _DEV_OFW_OFW_CPU_H_ */35#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);...@@ -83,8 +83,8 @@ MALLOC_DECLARE(M_OFWPROP);
83 * interface as the Open Firmware access mechanism, OF_init initializes it.83 * interface as the Open Firmware access mechanism, OF_init initializes it.
84 */84 */
8585
86boolean_t OF_install(char *name, int prio);86bool OF_install(char *name, int prio);
87int OF_init(void *cookie);87int OF_init(void *cookie);
8888
89/*89/*
90 * Known Open Firmware interface names90 * Known Open Firmware interface names
...@@ -149,6 +149,7 @@ phandle_t OF_xref_from_node(phandle_t node);...@@ -149,6 +149,7 @@ phandle_t OF_xref_from_node(phandle_t node);
149device_t OF_device_from_xref(phandle_t xref);149device_t OF_device_from_xref(phandle_t xref);
150phandle_t OF_xref_from_device(device_t dev);150phandle_t OF_xref_from_device(device_t dev);
151int OF_device_register_xref(phandle_t xref, device_t dev);151int OF_device_register_xref(phandle_t xref, device_t dev);
152void OF_device_unregister_xref(phandle_t xref, device_t dev);
152153
153/* Device I/O functions */154/* Device I/O functions */
154ihandle_t OF_open(const char *path);155ihandle_t OF_open(const char *path);
lib/libc/include/generic-freebsd/dev/ofw/openfirmio.h-2
...@@ -33,8 +33,6 @@...@@ -33,8 +33,6 @@
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.35 * SUCH DAMAGE.
36 *
37 * @(#)openpromio.h 8.1 (Berkeley) 6/11/93
38 */36 */
3937
40#ifndef _DEV_OFW_OPENFIRMIO_H_38#ifndef _DEV_OFW_OPENFIRMIO_H_
lib/libc/include/generic-freebsd/dev/pci/pcireg.h+3
...@@ -616,6 +616,8 @@...@@ -616,6 +616,8 @@
616#define PCIM_MSICTRL_MMC_16 0x0008616#define PCIM_MSICTRL_MMC_16 0x0008
617#define PCIM_MSICTRL_MMC_32 0x000A617#define PCIM_MSICTRL_MMC_32 0x000A
618#define PCIM_MSICTRL_MSI_ENABLE 0x0001618#define PCIM_MSICTRL_MSI_ENABLE 0x0001
619#define PCI_MSI_MSGNUM(ctrl) \
620 (1 << (((ctrl) & PCIM_MSICTRL_MMC_MASK) >> 1))
619#define PCIR_MSI_ADDR 0x4621#define PCIR_MSI_ADDR 0x4
620#define PCIR_MSI_ADDR_HIGH 0x8622#define PCIR_MSI_ADDR_HIGH 0x8
621#define PCIR_MSI_DATA 0x8623#define PCIR_MSI_DATA 0x8
...@@ -965,6 +967,7 @@...@@ -965,6 +967,7 @@
965#define PCIM_MSIXCTRL_MSIX_ENABLE 0x8000967#define PCIM_MSIXCTRL_MSIX_ENABLE 0x8000
966#define PCIM_MSIXCTRL_FUNCTION_MASK 0x4000968#define PCIM_MSIXCTRL_FUNCTION_MASK 0x4000
967#define PCIM_MSIXCTRL_TABLE_SIZE 0x07FF969#define PCIM_MSIXCTRL_TABLE_SIZE 0x07FF
970#define PCI_MSIX_MSGNUM(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1)
968#define PCIR_MSIX_TABLE 0x4971#define PCIR_MSIX_TABLE 0x4
969#define PCIR_MSIX_PBA 0x8972#define PCIR_MSIX_PBA 0x8
970#define PCIM_MSIX_BIR_MASK 0x7973#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 @@...@@ -32,7 +32,6 @@
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * Distantly from :34 * Distantly from :
35 * @(#)lptreg.h 1.1 (Berkeley) 12/19/90
36 * Id: lptreg.h,v 1.6 1997/02/22 09:36:52 peter Exp35 * Id: lptreg.h,v 1.6 1997/02/22 09:36:52 peter Exp
37 * From Id: nlpt.h,v 1.3 1999/01/10 12:04:54 nsouch Exp36 * From Id: nlpt.h,v 1.3 1999/01/10 12:04:54 nsouch Exp
38 */37 */
lib/libc/include/generic-freebsd/dev/ppbus/ppbconf.h+1-1
...@@ -63,7 +63,7 @@...@@ -63,7 +63,7 @@
63/*63/*
64 * Parallel Port Bus sleep/wakeup queue.64 * Parallel Port Bus sleep/wakeup queue.
65 */65 */
66#define PPBPRI (PZERO+8)66#define PPBPRI (PWAIT)
6767
68/*68/*
69 * Parallel Port Chipset mode masks.69 * Parallel Port Chipset mode masks.
lib/libc/include/generic-freebsd/dev/smbus/smbconf.h+1-1
...@@ -30,7 +30,7 @@...@@ -30,7 +30,7 @@
3030
31#include <sys/queue.h>31#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
35#define n(flags) (~(flags) & (flags))35#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);...@@ -114,7 +114,7 @@ MALLOC_DECLARE(M_USBDEV);
114/* Allow for marginal and non-conforming devices. */114/* Allow for marginal and non-conforming devices. */
115#define USB_PORT_RESET_DELAY 50 /* ms */115#define USB_PORT_RESET_DELAY 50 /* ms */
116#define USB_PORT_ROOT_RESET_DELAY 200 /* ms */116#define USB_PORT_ROOT_RESET_DELAY 200 /* ms */
117#define USB_PORT_RESET_RECOVERY 10 /* ms */117#define USB_PORT_RESET_RECOVERY 20 /* ms */
118#define USB_PORT_POWERUP_DELAY 300 /* ms */118#define USB_PORT_POWERUP_DELAY 300 /* ms */
119#define USB_PORT_RESUME_DELAY (20*2) /* ms */119#define USB_PORT_RESUME_DELAY (20*2) /* ms */
120#define USB_SET_ADDRESS_SETTLE 10 /* ms */120#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 {...@@ -86,7 +86,7 @@ struct usb_bus {
86 struct usb_bus_msg shutdown_msg[2];86 struct usb_bus_msg shutdown_msg[2];
87#if USB_HAVE_UGEN87#if USB_HAVE_UGEN
88 struct usb_bus_msg cleanup_msg[2];88 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;
90#endif90#endif
91 /*91 /*
92 * This mutex protects the USB hardware:92 * 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 {...@@ -96,7 +96,7 @@ struct usb_fs_privdata {
96 int fifo_index;96 int fifo_index;
97 struct cdev *cdev;97 struct cdev *cdev;
9898
99 LIST_ENTRY(usb_fs_privdata) pd_next;99 SLIST_ENTRY(usb_fs_privdata) pd_next;
100};100};
101101
102/*102/*
lib/libc/include/generic-freebsd/dev/usb/usb_device.h+1-1
...@@ -225,7 +225,7 @@ struct usb_device {...@@ -225,7 +225,7 @@ struct usb_device {
225 struct usb_fifo *fifo[USB_FIFO_MAX];225 struct usb_fifo *fifo[USB_FIFO_MAX];
226 struct usb_symlink *ugen_symlink; /* our generic symlink */226 struct usb_symlink *ugen_symlink; /* our generic symlink */
227 struct usb_fs_privdata *ctrl_dev; /* Control Endpoint 0 device node */227 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;
229 char ugen_name[20]; /* name of ugenX.X device */229 char ugen_name[20]; /* name of ugenX.X device */
230#endif230#endif
231 usb_ticks_t plugtime; /* copy of "ticks" */231 usb_ticks_t plugtime; /* copy of "ticks" */
lib/libc/include/generic-freebsd/dev/usb/usb_freebsd.h+1
...@@ -42,6 +42,7 @@...@@ -42,6 +42,7 @@
42#define USB_HAVE_TT_SUPPORT 142#define USB_HAVE_TT_SUPPORT 1
43#define USB_HAVE_POWERD 143#define USB_HAVE_POWERD 1
44#define USB_HAVE_MSCTEST 144#define USB_HAVE_MSCTEST 1
45#define USB_HAVE_MSCTEST_AUTOQUIRK 0
45#define USB_HAVE_MSCTEST_DETACH 146#define USB_HAVE_MSCTEST_DETACH 1
46#define USB_HAVE_PF 147#define USB_HAVE_PF 1
47#define USB_HAVE_ROOT_MOUNT_HOLD 148#define USB_HAVE_ROOT_MOUNT_HOLD 1
lib/libc/include/generic-freebsd/dev/usb/usb_freebsd_loader.h+1
...@@ -42,6 +42,7 @@...@@ -42,6 +42,7 @@
42#define USB_HAVE_TT_SUPPORT 142#define USB_HAVE_TT_SUPPORT 1
43#define USB_HAVE_POWERD 143#define USB_HAVE_POWERD 1
44#define USB_HAVE_MSCTEST 144#define USB_HAVE_MSCTEST 1
45#define USB_HAVE_MSCTEST_AUTOQUIRK 0
45#define USB_HAVE_MSCTEST_DETACH 046#define USB_HAVE_MSCTEST_DETACH 0
46#define USB_HAVE_PF 047#define USB_HAVE_PF 0
47#define USB_HAVE_ROOT_MOUNT_HOLD 048#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 {...@@ -239,7 +239,7 @@ struct usb_gen_quirk {
239#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)239#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)
240#define USB_DEVICEENUMERATE _IOW ('U', 6, int)240#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. */
243#define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor)243#define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor)
244#define USB_SET_IMMED _IOW ('U', 22, int)244#define USB_SET_IMMED _IOW ('U', 22, int)
245#define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor)245#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 @@...@@ -31,7 +31,6 @@
31#ifndef USB_GLOBAL_INCLUDE_FILE31#ifndef USB_GLOBAL_INCLUDE_FILE
32#include <sys/interrupt.h>32#include <sys/interrupt.h>
33#include <sys/priority.h>33#include <sys/priority.h>
34#include <sys/runq.h>
35#endif34#endif
3635
37/* defines */36/* defines */
...@@ -76,6 +75,7 @@ int usb_proc_create(struct usb_process *up, struct mtx *p_mtx,...@@ -76,6 +75,7 @@ int usb_proc_create(struct usb_process *up, struct mtx *p_mtx,
76 const char *pmesg, uint8_t prio);75 const char *pmesg, uint8_t prio);
77void usb_proc_drain(struct usb_process *up);76void usb_proc_drain(struct usb_process *up);
78void usb_proc_mwait(struct usb_process *up, void *pm0, void *pm1);77void usb_proc_mwait(struct usb_process *up, void *pm0, void *pm1);
78int usb_proc_mwait_sig(struct usb_process *up, void *pm0, void *pm1);
79void usb_proc_free(struct usb_process *up);79void usb_proc_free(struct usb_process *up);
80void *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1);80void *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1);
81void usb_proc_rewakeup(struct usb_process *up);81void usb_proc_rewakeup(struct usb_process *up);
lib/libc/include/generic-freebsd/dev/usb/usbdi.h+5
...@@ -38,6 +38,7 @@ struct usb_process;...@@ -38,6 +38,7 @@ struct usb_process;
38struct usb_proc_msg;38struct usb_proc_msg;
39struct usb_mbuf;39struct usb_mbuf;
40struct usb_fs_privdata;40struct usb_fs_privdata;
41struct usb_device_info;
41struct mbuf;42struct mbuf;
4243
43typedef enum { /* keep in sync with usb_errstr_table */44typedef enum { /* keep in sync with usb_errstr_table */
...@@ -525,6 +526,8 @@ struct usb_proc_msg {...@@ -525,6 +526,8 @@ struct usb_proc_msg {
525 usb_size_t pm_num;526 usb_size_t pm_num;
526};527};
527528
529#define USB_PROC_MSG_ENQUEUED(msg) ((msg)->pm_qentry.tqe_prev != NULL)
530
528#define USB_FIFO_TX 0531#define USB_FIFO_TX 0
529#define USB_FIFO_RX 1532#define USB_FIFO_RX 1
530533
...@@ -585,6 +588,8 @@ usb_error_t usbd_set_endpoint_mode(struct usb_device *udev,...@@ -585,6 +588,8 @@ usb_error_t usbd_set_endpoint_mode(struct usb_device *udev,
585 struct usb_endpoint *ep, uint8_t ep_mode);588 struct usb_endpoint *ep, uint8_t ep_mode);
586uint8_t usbd_get_endpoint_mode(struct usb_device *udev,589uint8_t usbd_get_endpoint_mode(struct usb_device *udev,
587 struct usb_endpoint *ep);590 struct usb_endpoint *ep);
591int usbd_fill_deviceinfo(struct usb_device *udev,
592 struct usb_device_info *di);
588593
589const struct usb_device_id *usbd_lookup_id_by_info(594const struct usb_device_id *usbd_lookup_id_by_info(
590 const struct usb_device_id *id, usb_size_t sizeof_id,595 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 {...@@ -63,7 +63,7 @@ struct verified_exec_label_params {
63#define VERIEXEC_DEBUG_OFF _IO('S', 0x6) /* reset debug */63#define VERIEXEC_DEBUG_OFF _IO('S', 0x6) /* reset debug */
64#define VERIEXEC_GETSTATE _IOR('S', 0x7, int) /* get state */64#define VERIEXEC_GETSTATE _IOR('S', 0x7, int) /* get state */
65#define VERIEXEC_SIGNED_LOAD32 _IOW('S', 0x8, struct verified_exec_params32)65#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 */
67#define VERIEXEC_GETVERSION _IOR('S', 0xa, int) /* get version */67#define VERIEXEC_GETVERSION _IOR('S', 0xa, int) /* get version */
68#define VERIEXEC_LABEL_LOAD _IOW('S', 0xb, struct verified_exec_label_params)68#define VERIEXEC_LABEL_LOAD _IOW('S', 0xb, struct verified_exec_label_params)
69#define VERIEXEC_SIGNED_LOAD _IOW('S', 0xc, struct verified_exec_params)69#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 {...@@ -32,4 +32,10 @@ struct wg_data_io {
32#define SIOCSWG _IOWR('i', 210, struct wg_data_io)32#define SIOCSWG _IOWR('i', 210, struct wg_data_io)
33#define SIOCGWG _IOWR('i', 211, struct wg_data_io)33#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
35#endif /* __IF_WG_H__ */41#endif /* __IF_WG_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/dirent.h+15-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)dirent.h 8.2 (Berkeley) 7/28/94
32 */30 */
3331
34#ifndef _DIRENT_H_32#ifndef _DIRENT_H_
...@@ -118,7 +116,8 @@ DIR *fdopendir(int);...@@ -118,7 +116,8 @@ DIR *fdopendir(int);
118struct dirent *116struct dirent *
119 readdir(DIR *);117 readdir(DIR *);
120#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500118#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");
122#endif121#endif
123void rewinddir(DIR *);122void rewinddir(DIR *);
124#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700123#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700
...@@ -132,9 +131,22 @@ int scandir_b(const char *, struct dirent ***,...@@ -132,9 +131,22 @@ int scandir_b(const char *, struct dirent ***,
132#endif131#endif
133#endif132#endif
134#if __BSD_VISIBLE133#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
135int scandirat(int, const char *, struct dirent ***,142int scandirat(int, const char *, struct dirent ***,
136 int (*)(const struct dirent *), int (*)(const struct dirent **,143 int (*)(const struct dirent *), int (*)(const struct dirent **,
137 const struct dirent **));144 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
138#endif150#endif
139#if __XSI_VISIBLE151#if __XSI_VISIBLE
140void seekdir(DIR *, long);152void seekdir(DIR *, long);
lib/libc/include/generic-freebsd/dlfcn.h+1
...@@ -32,6 +32,7 @@...@@ -32,6 +32,7 @@
32#ifndef _DLFCN_H_32#ifndef _DLFCN_H_
33#define _DLFCN_H_33#define _DLFCN_H_
3434
35#include <sys/cdefs.h>
35#include <sys/_types.h>36#include <sys/_types.h>
3637
37/*38/*
lib/libc/include/generic-freebsd/endian.h+26-1
...@@ -11,9 +11,34 @@...@@ -11,9 +11,34 @@
11#ifndef _ENDIAN_H_11#ifndef _ENDIAN_H_
12#define _ENDIAN_H_12#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
14/*39/*
15 * FreeBSD's sys/_endian.h is very close to the interface provided on Linux by40 * 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.
17 */42 */
18#include <sys/_endian.h>43#include <sys/_endian.h>
1944
lib/libc/include/generic-freebsd/err.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)err.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _ERR_H_32#ifndef _ERR_H_
lib/libc/include/generic-freebsd/errno.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)errno.h 8.5 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_ERRNO_H_37#ifndef _SYS_ERRNO_H_
lib/libc/include/generic-freebsd/execinfo.h+2
...@@ -32,6 +32,8 @@...@@ -32,6 +32,8 @@
32#ifndef _EXECINFO_H_32#ifndef _EXECINFO_H_
33#define _EXECINFO_H_33#define _EXECINFO_H_
3434
35#include <sys/cdefs.h>
36
35#include <stddef.h>37#include <stddef.h>
3638
37__BEGIN_DECLS39__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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_FCNTL_H_37#ifndef _SYS_FCNTL_H_
...@@ -142,8 +140,24 @@ typedef __pid_t pid_t;...@@ -142,8 +140,24 @@ typedef __pid_t pid_t;
142#define O_DSYNC 0x01000000 /* POSIX data sync */140#define O_DSYNC 0x01000000 /* POSIX data sync */
143#if __BSD_VISIBLE141#if __BSD_VISIBLE
144#define O_EMPTY_PATH 0x02000000142#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
145#endif149#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
147/*161/*
148 * XXX missing O_RSYNC.162 * XXX missing O_RSYNC.
149 */163 */
...@@ -270,6 +284,16 @@ typedef __pid_t pid_t;...@@ -270,6 +284,16 @@ typedef __pid_t pid_t;
270#define F_GET_SEALS 20284#define F_GET_SEALS 20
271#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */285#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */
272#define F_KINFO 22 /* Return kinfo_file for this fd */286#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
274/* Seals (F_ADD_SEALS, F_GET_SEALS). */298/* Seals (F_ADD_SEALS, F_GET_SEALS). */
275#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */299#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */
...@@ -280,6 +304,11 @@ typedef __pid_t pid_t;...@@ -280,6 +304,11 @@ typedef __pid_t pid_t;
280304
281/* file descriptor flags (F_GETFD, F_SETFD) */305/* file descriptor flags (F_GETFD, F_SETFD) */
282#define FD_CLOEXEC 1 /* close-on-exec flag */306#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
284/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */313/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
285#define F_RDLCK 1 /* shared or read lock */314#define F_RDLCK 1 /* shared or read lock */
lib/libc/include/generic-freebsd/fenv.h+229-186
...@@ -29,276 +29,319 @@...@@ -29,276 +29,319 @@
29#ifndef _FENV_H_29#ifndef _FENV_H_
30#define _FENV_H_30#define _FENV_H_
3131
32#include <sys/cdefs.h>
32#include <sys/_types.h>33#include <sys/_types.h>
33#include <machine/endian.h>34#include <ieeefp.h>
3435
35#ifndef __fenv_static36#ifndef __fenv_static
36#define __fenv_static static37#define __fenv_static static
37#endif38#endif
3839
39typedef __uint32_t fenv_t;40typedef __uint16_t fexcept_t;
40typedef __uint32_t fexcept_t;
4141
42/* Exception flags */42/* Exception flags */
43#ifdef __SPE__43#define FE_INVALID 0x01
44#define FE_OVERFLOW 0x0000010044#define FE_DENORMAL 0x02
45#define FE_UNDERFLOW 0x0000020045#define FE_DIVBYZERO 0x04
46#define FE_DIVBYZERO 0x0000040046#define FE_OVERFLOW 0x08
47#define FE_INVALID 0x0000080047#define FE_UNDERFLOW 0x10
48#define FE_INEXACT 0x0000100048#define FE_INEXACT 0x20
4949#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
50#define FE_ALL_INVALID FE_INVALID50 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
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)
8451
85/* Rounding modes */52/* Rounding modes */
86#define FE_TONEAREST 0x000053#define FE_TONEAREST 0x0000
87#define FE_TOWARDZERO 0x000154#define FE_DOWNWARD 0x0400
88#define FE_UPWARD 0x000255#define FE_UPWARD 0x0800
89#define FE_DOWNWARD 0x000356#define FE_TOWARDZERO 0x0c00
90#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \57#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
91 FE_UPWARD | FE_TOWARDZERO)58 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
93__BEGIN_DECLS93__BEGIN_DECLS
9494
95/* Default floating-point environment */95/* Default floating-point environment */
96extern const fenv_t __fe_dfl_env;96extern const fenv_t __fe_dfl_env;
97#define FE_DFL_ENV (&__fe_dfl_env)97#define FE_DFL_ENV (&__fe_dfl_env)
9898
99/* We need to be able to map status flag positions to mask flag positions */99#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \
100#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \100 : "st", "st(1)", "st(2)", "st(3)", "st(4)", \
101 FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)101 "st(5)", "st(6)", "st(7)")
102102#define __fwait() __asm __volatile("fwait")
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
119103
120union __fpscr {104int fegetenv(fenv_t *__envp);
121 double __d;105int feholdexcept(fenv_t *__envp);
122 struct {106int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
123#if _BYTE_ORDER == _LITTLE_ENDIAN107int feraiseexcept(int __excepts);
124 fenv_t __reg;108int feupdateenv(const fenv_t *__envp);
125 __uint32_t __junk;
126#else
127 __uint32_t __junk;
128 fenv_t __reg;
129#endif
130 } __bits;
131};
132109
133__fenv_static inline int110__fenv_static inline int
134feclearexcept(int __excepts)111fegetround(void)
135{112{
136 union __fpscr __r;113 __uint16_t __control;
137114
138 if (__excepts & FE_INVALID)115 /*
139 __excepts |= FE_ALL_INVALID;116 * We assume that the x87 and the SSE unit agree on the
140 __mffs(&__r);117 * rounding mode. Reading the control word on the x87 turns
141 __r.__bits.__reg &= ~__excepts;118 * out to be about 5 times faster than reading it on the SSE
142 __mtfsf(__r);119 * unit on an Opteron 244.
143 return (0);120 */
121 __fnstcw(&__control);
122 return (__control & _ROUND_MASK);
144}123}
145124
146__fenv_static inline int125#if __BSD_VISIBLE
147fegetexceptflag(fexcept_t *__flagp, int __excepts)
148{
149 union __fpscr __r;
150126
151 __mffs(&__r);127int feenableexcept(int __mask);
152 *__flagp = __r.__bits.__reg & __excepts;128int fedisableexcept(int __mask);
153 return (0);
154}
155129
156__fenv_static inline int130/* We currently provide no external definition of fegetexcept(). */
157fesetexceptflag(const fexcept_t *__flagp, int __excepts)131static inline int
132fegetexcept(void)
158{133{
159 union __fpscr __r;134 __uint16_t __control;
160135
161 if (__excepts & FE_INVALID)136 /*
162 __excepts |= FE_ALL_INVALID;137 * We assume that the masks for the x87 and the SSE unit are
163 __mffs(&__r);138 * the same.
164 __r.__bits.__reg &= ~__excepts;139 */
165 __r.__bits.__reg |= *__flagp & __excepts;140 __fnstcw(&__control);
166 __mtfsf(__r);141 return (~__control & FE_ALL_EXCEPT);
167 return (0);
168}142}
169143
170#ifdef __SPE__144#endif /* __BSD_VISIBLE */
171extern int feraiseexcept(int __excepts);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
172#else154#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
173__fenv_static inline int166__fenv_static inline int
174feraiseexcept(int __excepts)167feclearexcept(int __excepts)
175{168{
176 union __fpscr __r;169 fenv_t __env;
177170 __uint32_t __mxcsr;
178 if (__excepts & FE_INVALID)171
179 __excepts |= FE_VXSOFT;172 if (__excepts == FE_ALL_EXCEPT) {
180 __mffs(&__r);173 __fnclex();
181 __r.__bits.__reg |= __excepts;174 } else {
182 __mtfsf(__r);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 }
183 return (0);184 return (0);
184}185}
185#endif
186186
187__fenv_static inline int187__fenv_static inline int
188fetestexcept(int __excepts)188fegetexceptflag(fexcept_t *__flagp, int __excepts)
189{189{
190 union __fpscr __r;190 __uint32_t __mxcsr;
191191 __uint16_t __status;
192 __mffs(&__r);192
193 return (__r.__bits.__reg & __excepts);193 __fnstsw(&__status);
194 if (__HAS_SSE())
195 __stmxcsr(&__mxcsr);
196 else
197 __mxcsr = 0;
198 *__flagp = (__mxcsr | __status) & __excepts;
199 return (0);
194}200}
195201
196__fenv_static inline int202__fenv_static inline int
197fegetround(void)203fetestexcept(int __excepts)
198{204{
199 union __fpscr __r;205 __uint32_t __mxcsr;
200206 __uint16_t __status;
201 __mffs(&__r);207
202 return (__r.__bits.__reg & _ROUND_MASK);208 __fnstsw(&__status);
209 if (__HAS_SSE())
210 __stmxcsr(&__mxcsr);
211 else
212 __mxcsr = 0;
213 return ((__status | __mxcsr) & __excepts);
203}214}
204215
205__fenv_static inline int216__fenv_static inline int
206fesetround(int __round)217fesetround(int __round)
207{218{
208 union __fpscr __r;219 __uint32_t __mxcsr;
220 __uint16_t __control;
209221
210 if (__round & ~_ROUND_MASK)222 if (__round & ~_ROUND_MASK)
211 return (-1);223 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 int225 __fnstcw(&__control);
220fegetenv(fenv_t *__envp)226 __control &= ~_ROUND_MASK;
221{227 __control |= __round;
222 union __fpscr __r;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;
226 return (0);237 return (0);
227}238}
228239
229__fenv_static inline int240__fenv_static inline int
230feholdexcept(fenv_t *__envp)241fesetenv(const fenv_t *__envp)
231{242{
232 union __fpscr __r;243 fenv_t __env = *__envp;
233244 __uint32_t __mxcsr;
234 __mffs(&__r);245
235 *__envp = __r.__bits.__reg;246 __mxcsr = __get_mxcsr(__env);
236 __r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);247 __set_mxcsr(__env, 0xffffffff);
237 __mtfsf(__r);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);
238 return (0);259 return (0);
239}260}
240261
262#else /* __amd64__ */
263
241__fenv_static inline int264__fenv_static inline int
242fesetenv(const fenv_t *__envp)265feclearexcept(int __excepts)
243{266{
244 union __fpscr __r;267 fenv_t __env;
245268
246 __r.__bits.__reg = *__envp;269 if (__excepts == FE_ALL_EXCEPT) {
247 __mtfsf(__r);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);
248 return (0);279 return (0);
249}280}
250281
251__fenv_static inline int282__fenv_static inline int
252feupdateenv(const fenv_t *__envp)283fegetexceptflag(fexcept_t *__flagp, int __excepts)
253{284{
254 union __fpscr __r;285 __uint32_t __mxcsr;
286 __uint16_t __status;
255287
256 __mffs(&__r);288 __stmxcsr(&__mxcsr);
257 __r.__bits.__reg &= FE_ALL_EXCEPT;289 __fnstsw(&__status);
258 __r.__bits.__reg |= *__envp;290 *__flagp = (__mxcsr | __status) & __excepts;
259 __mtfsf(__r);
260 return (0);291 return (0);
261}292}
262293
263#if __BSD_VISIBLE
264
265__fenv_static inline int294__fenv_static inline int
266feenableexcept(int __mask)295fetestexcept(int __excepts)
267{296{
268 union __fpscr __r;297 __uint32_t __mxcsr;
269 fenv_t __oldmask;298 __uint16_t __status;
270299
271 __mffs(&__r);300 __stmxcsr(&__mxcsr);
272 __oldmask = __r.__bits.__reg;301 __fnstsw(&__status);
273 __r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT;302 return ((__status | __mxcsr) & __excepts);
274 __mtfsf(__r);
275 return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
276}303}
277304
278__fenv_static inline int305__fenv_static inline int
279fedisableexcept(int __mask)306fesetround(int __round)
280{307{
281 union __fpscr __r;308 __uint32_t __mxcsr;
282 fenv_t __oldmask;309 __uint16_t __control;
283310
284 __mffs(&__r);311 if (__round & ~_ROUND_MASK)
285 __oldmask = __r.__bits.__reg;312 return (-1);
286 __r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT);313
287 __mtfsf(__r);314 __fnstcw(&__control);
288 return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);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);
289}325}
290326
291/* We currently provide no external definition of fegetexcept(). */327__fenv_static inline int
292static inline int328fesetenv(const fenv_t *__envp)
293fegetexcept(void)
294{329{
295 union __fpscr __r;
296330
297 __mffs(&__r);331 /*
298 return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT);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);
299}342}
300343
301#endif /* __BSD_VISIBLE */344#endif /* __i386__ */
302345
303__END_DECLS346__END_DECLS
304347
lib/libc/include/generic-freebsd/float.h+2-97
...@@ -1,100 +1,5 @@...@@ -1,100 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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
33 */3 */
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 @@...@@ -1,7 +1,7 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-4-Clause
3 *3 *
4 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>4 * Copyright (c) 1993 Andrew Moore, Talke Studio
5 * All rights reserved.5 * All rights reserved.
6 *6 *
7 * Redistribution and use in source and binary forms, with or without7 * Redistribution and use in source and binary forms, with or without
...@@ -12,11 +12,15 @@...@@ -12,11 +12,15 @@
12 * 2. Redistributions in binary form must reproduce the above copyright12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors15 * 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
16 * may be used to endorse or promote products derived from this software20 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.21 * without specific prior written permission.
18 *22 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
...@@ -32,6 +36,7 @@...@@ -32,6 +36,7 @@
32#ifndef _FLOATINGPOINT_H_36#ifndef _FLOATINGPOINT_H_
33#define _FLOATINGPOINT_H_37#define _FLOATINGPOINT_H_
3438
39#include <sys/cdefs.h>
35#include <machine/ieeefp.h>40#include <machine/ieeefp.h>
3641
37#endif /* !_FLOATINGPOINT_H_ */42#endif /* !_FLOATINGPOINT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/fnmatch.h-1
...@@ -27,7 +27,6 @@...@@ -27,7 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93
31 */30 */
3231
33#ifndef _FNMATCH_H_32#ifndef _FNMATCH_H_
lib/libc/include/generic-freebsd/fs/devfs/devfs.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)kernfs.h 8.6 (Berkeley) 3/29/95
36 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.1434 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
37 */35 */
3836
lib/libc/include/generic-freebsd/fs/fdescfs/fdesc.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)fdesc.h 8.5 (Berkeley) 1/21/94
35 */33 */
3634
37#ifndef _FS_FDESC_H_35#ifndef _FS_FDESC_H_
lib/libc/include/generic-freebsd/fs/msdosfs/bootsect.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
2020
21/*21/*
22 * Format of a boot sector. This is the first sector on a DOS floppy disk22 * 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 the23 * or the first sector of a partition on a hard disk. But, it is not the
24 * first sector of a partitioned hard disk.24 * first sector of a partitioned hard disk.
25 */25 */
26struct bootsector33 {26struct bootsector33 {
lib/libc/include/generic-freebsd/fs/msdosfs/denode.h+2-2
...@@ -212,7 +212,7 @@ struct denode {...@@ -212,7 +212,7 @@ struct denode {
212 ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \212 ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \
213 putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16))213 putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16))
214214
215#if defined(_KERNEL) || defined(MAKEFS)215#if defined(_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS)
216216
217#define VTODE(vp) ((struct denode *)(vp)->v_data)217#define VTODE(vp) ((struct denode *)(vp)->v_data)
218#define DETOV(de) ((de)->de_vnode)218#define DETOV(de) ((de)->de_vnode)
...@@ -294,5 +294,5 @@ int removede(struct denode *pdep, struct denode *dep);...@@ -294,5 +294,5 @@ int removede(struct denode *pdep, struct denode *dep);
294int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred);294int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred);
295int doscheckpath( struct denode *source, struct denode *target,295int doscheckpath( struct denode *source, struct denode *target,
296 daddr_t *wait_scn);296 daddr_t *wait_scn);
297#endif /* _KERNEL || MAKEFS */297#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */
298#endif /* !_FS_MSDOSFS_DENODE_H_ */298#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 @@...@@ -81,7 +81,7 @@
8181
82#define MSDOSFSEOF(pmp, cn) ((((cn) | ~(pmp)->pm_fatmask) & CLUST_EOFS) == CLUST_EOFS)82#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)
85/*85/*
86 * These are the values for the function argument to the function86 * These are the values for the function argument to the function
87 * fatentry().87 * fatentry().
...@@ -110,5 +110,5 @@ markvoldirty(struct msdosfsmount *pmp, bool dirty)...@@ -110,5 +110,5 @@ markvoldirty(struct msdosfsmount *pmp, bool dirty)
110 return (markvoldirty_upgrade(pmp, dirty, false));110 return (markvoldirty_upgrade(pmp, dirty, false));
111}111}
112112
113#endif /* _KERNEL || MAKEFS */113#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */
114#endif /* !_FS_MSDOSFS_FAT_H_ */114#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 @@...@@ -52,14 +52,17 @@
52#ifndef _MSDOSFS_MSDOSFSMOUNT_H_52#ifndef _MSDOSFS_MSDOSFSMOUNT_H_
53#define _MSDOSFS_MSDOSFSMOUNT_H_53#define _MSDOSFS_MSDOSFSMOUNT_H_
5454
55#if defined (_KERNEL) || defined(MAKEFS)55#if defined(_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS)
5656
57#include <sys/types.h>57#include <sys/types.h>
58#ifndef MAKEFS58#ifdef _KERNEL
59#include <sys/lock.h>59#include <sys/lock.h>
60#include <sys/lockmgr.h>60#include <sys/lockmgr.h>
61#include <sys/_task.h>61#else
62#include <sys/_lock.h>
63#include <sys/_lockmgr.h>
62#endif64#endif
65#include <sys/_task.h>
63#include <sys/tree.h>66#include <sys/tree.h>
6467
65#ifdef MALLOC_DECLARE68#ifdef MALLOC_DECLARE
...@@ -114,11 +117,8 @@ struct msdosfsmount {...@@ -114,11 +117,8 @@ struct msdosfsmount {
114 void *pm_w2u; /* Unicode->Local iconv handle */117 void *pm_w2u; /* Unicode->Local iconv handle */
115 void *pm_u2d; /* Unicode->DOS iconv handle */118 void *pm_u2d; /* Unicode->DOS iconv handle */
116 void *pm_d2u; /* DOS->Local iconv handle */119 void *pm_d2u; /* DOS->Local iconv handle */
117#ifndef MAKEFS
118 struct lock pm_fatlock; /* lockmgr protecting allocations */120 struct lock pm_fatlock; /* lockmgr protecting allocations */
119 struct lock pm_checkpath_lock; /* protects doscheckpath result */
120 struct task pm_rw2ro_task; /* context for emergency remount ro */121 struct task pm_rw2ro_task; /* context for emergency remount ro */
121#endif
122};122};
123123
124/*124/*
...@@ -245,9 +245,9 @@ struct msdosfs_fileno {...@@ -245,9 +245,9 @@ struct msdosfs_fileno {
245#define MSDOSFS_ASSERT_MP_LOCKED(pmp) \245#define MSDOSFS_ASSERT_MP_LOCKED(pmp) \
246 lockmgr_assert(&(pmp)->pm_fatlock, KA_XLOCKED)246 lockmgr_assert(&(pmp)->pm_fatlock, KA_XLOCKED)
247247
248#endif /* _KERNEL || MAKEFS */248#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */
249249
250#ifndef MAKEFS250#ifdef _KERNEL
251/*251/*
252 * Arguments to mount MSDOS filesystems.252 * Arguments to mount MSDOS filesystems.
253 */253 */
...@@ -265,7 +265,7 @@ struct msdosfs_args {...@@ -265,7 +265,7 @@ struct msdosfs_args {
265 char *cs_local; /* Local Charset */265 char *cs_local; /* Local Charset */
266 mode_t dirmask; /* dir mask to be applied for msdosfs perms */266 mode_t dirmask; /* dir mask to be applied for msdosfs perms */
267};267};
268#endif /* MAKEFS */268#endif /* _KERNEL */
269269
270/*270/*
271 * Msdosfs mount options:271 * Msdosfs mount options:
lib/libc/include/generic-freebsd/fs/nfs/nfs.h+2
...@@ -865,6 +865,8 @@ struct nfsslot {...@@ -865,6 +865,8 @@ struct nfsslot {
865/* Enumerated type for nfsuserd state. */865/* Enumerated type for nfsuserd state. */
866typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state;866typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state;
867867
868typedef enum { UNKNOWN=0, DELETED=1, NLINK_ZERO=2, VALID=3 } nfsremove_status;
869
868#endif /* _KERNEL */870#endif /* _KERNEL */
869871
870#endif /* _NFS_NFS_H */872#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 *,...@@ -169,6 +169,7 @@ int nfsrv_mdscopymr(char *, char *, char *, char *, int *, char *, NFSPROC_T *,
169 struct vnode **, struct vnode **, struct pnfsdsfile **, struct nfsdevice **,169 struct vnode **, struct vnode **, struct pnfsdsfile **, struct nfsdevice **,
170 struct nfsdevice **);170 struct nfsdevice **);
171void nfsrv_marknospc(char *, bool);171void nfsrv_marknospc(char *, bool);
172void nfsrv_removedeleg(fhandle_t *, struct nfsrv_descript *, NFSPROC_T *);
172173
173/* nfs_nfsdserv.c */174/* nfs_nfsdserv.c */
174int nfsrvd_access(struct nfsrv_descript *, int,175int nfsrvd_access(struct nfsrv_descript *, int,
...@@ -285,6 +286,8 @@ int nfsrvd_deallocate(struct nfsrv_descript *, int,...@@ -285,6 +286,8 @@ int nfsrvd_deallocate(struct nfsrv_descript *, int,
285 vnode_t, struct nfsexstuff *);286 vnode_t, struct nfsexstuff *);
286int nfsrvd_copy_file_range(struct nfsrv_descript *, int,287int nfsrvd_copy_file_range(struct nfsrv_descript *, int,
287 vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *);288 vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *);
289int nfsrvd_clone(struct nfsrv_descript *, int,
290 vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *);
288int nfsrvd_seek(struct nfsrv_descript *, int,291int nfsrvd_seek(struct nfsrv_descript *, int,
289 vnode_t, struct nfsexstuff *);292 vnode_t, struct nfsexstuff *);
290int nfsrvd_getxattr(struct nfsrv_descript *, int,293int nfsrvd_getxattr(struct nfsrv_descript *, int,
...@@ -340,7 +343,8 @@ int nfsv4_loadattr(struct nfsrv_descript *, vnode_t,...@@ -340,7 +343,8 @@ int nfsv4_loadattr(struct nfsrv_descript *, vnode_t,
340 struct nfsvattr *, struct nfsfh **, fhandle_t *, int,343 struct nfsvattr *, struct nfsfh **, fhandle_t *, int,
341 struct nfsv3_pathconf *, struct statfs *, struct nfsstatfs *,344 struct nfsv3_pathconf *, struct statfs *, struct nfsstatfs *,
342 struct nfsfsinfo *, NFSACL_T *,345 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 *);
344int nfsv4_lock(struct nfsv4lock *, int, int *, struct mtx *, struct mount *);348int nfsv4_lock(struct nfsv4lock *, int, int *, struct mtx *, struct mount *);
345void nfsv4_unlock(struct nfsv4lock *, int);349void nfsv4_unlock(struct nfsv4lock *, int);
346void nfsv4_relref(struct nfsv4lock *);350void nfsv4_relref(struct nfsv4lock *);
...@@ -394,8 +398,9 @@ int nfsrv_putopbit(struct nfsrv_descript *, nfsopbit_t *);...@@ -394,8 +398,9 @@ int nfsrv_putopbit(struct nfsrv_descript *, nfsopbit_t *);
394void nfsrv_wcc(struct nfsrv_descript *, int, struct nfsvattr *, int,398void nfsrv_wcc(struct nfsrv_descript *, int, struct nfsvattr *, int,
395 struct nfsvattr *);399 struct nfsvattr *);
396int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,400int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,
397 struct vattr *, fhandle_t *, int, nfsattrbit_t *,401 struct vattr *, fhandle_t *, int, nfsattrbit_t *, struct ucred *,
398 struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *);402 NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *, bool, bool,
403 bool, uint32_t);
399void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);404void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
400struct mbuf *nfsrv_adj(struct mbuf *, int, int);405struct mbuf *nfsrv_adj(struct mbuf *, int, int);
401void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);406void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
...@@ -438,6 +443,7 @@ int nfs_supportsnfsv4acls(vnode_t);...@@ -438,6 +443,7 @@ int nfs_supportsnfsv4acls(vnode_t);
438/* nfs_commonacl.c */443/* nfs_commonacl.c */
439int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *,444int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *,
440 bool, int *, int *, NFSPROC_T *);445 bool, int *, int *, NFSPROC_T *);
446uint32_t nfs_aceperm(acl_perm_t);
441int nfsrv_buildacl(struct nfsrv_descript *, NFSACL_T *, __enum_uint8(vtype),447int nfsrv_buildacl(struct nfsrv_descript *, NFSACL_T *, __enum_uint8(vtype),
442 NFSPROC_T *);448 NFSPROC_T *);
443int nfsrv_compareacl(NFSACL_T *, NFSACL_T *);449int nfsrv_compareacl(NFSACL_T *, NFSACL_T *);
...@@ -481,11 +487,13 @@ int nfsrpc_mknod(vnode_t, char *, int, struct vattr *, u_int32_t,...@@ -481,11 +487,13 @@ int nfsrpc_mknod(vnode_t, char *, int, struct vattr *, u_int32_t,
481int nfsrpc_create(vnode_t, char *, int, struct vattr *, nfsquad_t,487int nfsrpc_create(vnode_t, char *, int, struct vattr *, nfsquad_t,
482 int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,488 int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,
483 struct nfsfh **, int *, int *);489 struct nfsfh **, int *, int *);
484int nfsrpc_remove(vnode_t, char *, int, vnode_t, struct ucred *, NFSPROC_T *,490int nfsrpc_remove(struct vnode *, char *, int, struct vnode *,
485 struct nfsvattr *, int *);491 struct nfsvattr *, int *, nfsremove_status *, struct nfsvattr *, int *,
486int nfsrpc_rename(vnode_t, vnode_t, char *, int, vnode_t, vnode_t, char *, int,492 struct ucred *, NFSPROC_T *);
487 struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,493int nfsrpc_rename(struct vnode *, struct vnode *, char *, int, struct vnode *,
488 int *, int *);494 struct vnode *, char *, int, nfsremove_status *, struct nfsvattr *,
495 struct nfsvattr *, int *, int *, struct nfsvattr *, int *, struct ucred *,
496 NFSPROC_T *);
489int nfsrpc_link(vnode_t, vnode_t, char *, int,497int nfsrpc_link(vnode_t, vnode_t, char *, int,
490 struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,498 struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *,
491 int *, int *);499 int *, int *);
...@@ -512,10 +520,10 @@ int nfsrpc_lock(struct nfsrv_descript *, struct nfsmount *, vnode_t,...@@ -512,10 +520,10 @@ int nfsrpc_lock(struct nfsrv_descript *, struct nfsmount *, vnode_t,
512 u_int8_t *, int, struct nfscllockowner *, int, int, u_int64_t,520 u_int8_t *, int, struct nfscllockowner *, int, int, u_int64_t,
513 u_int64_t, short, struct ucred *, NFSPROC_T *, int);521 u_int64_t, short, struct ucred *, NFSPROC_T *, int);
514int nfsrpc_statfs(vnode_t, struct nfsstatfs *, struct nfsfsinfo *, uint32_t *,522int 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 *);
516int nfsrpc_fsinfo(vnode_t, struct nfsfsinfo *, struct ucred *,524int nfsrpc_fsinfo(vnode_t, struct nfsfsinfo *, struct ucred *,
517 NFSPROC_T *, struct nfsvattr *, int *);525 NFSPROC_T *, struct nfsvattr *, int *);
518int nfsrpc_pathconf(vnode_t, struct nfsv3_pathconf *,526int nfsrpc_pathconf(vnode_t, struct nfsv3_pathconf *, bool *, uint32_t *,
519 struct ucred *, NFSPROC_T *, struct nfsvattr *, int *);527 struct ucred *, NFSPROC_T *, struct nfsvattr *, int *);
520int nfsrpc_renew(struct nfsclclient *, struct nfsclds *, struct ucred *,528int nfsrpc_renew(struct nfsclclient *, struct nfsclds *, struct ucred *,
521 NFSPROC_T *);529 NFSPROC_T *);
...@@ -557,6 +565,8 @@ int nfsrpc_deallocate(vnode_t, off_t, off_t, struct nfsvattr *, int *,...@@ -557,6 +565,8 @@ int nfsrpc_deallocate(vnode_t, off_t, off_t, struct nfsvattr *, int *,
557int nfsrpc_copy_file_range(vnode_t, off_t *, vnode_t, off_t *, size_t *,565int nfsrpc_copy_file_range(vnode_t, off_t *, vnode_t, off_t *, size_t *,
558 unsigned int, int *, struct nfsvattr *, int *, struct nfsvattr *,566 unsigned int, int *, struct nfsvattr *, int *, struct nfsvattr *,
559 struct ucred *, bool, bool *);567 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 *);
560int nfsrpc_seek(vnode_t, off_t *, bool *, int, struct ucred *,570int nfsrpc_seek(vnode_t, off_t *, bool *, int, struct ucred *,
561 struct nfsvattr *, int *);571 struct nfsvattr *, int *);
562int nfsrpc_getextattr(vnode_t, const char *, struct uio *, ssize_t *,572int 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 *,...@@ -568,6 +578,9 @@ int nfsrpc_listextattr(vnode_t, uint64_t *, struct uio *, size_t *, bool *,
568int nfsrpc_rmextattr(vnode_t, const char *, struct nfsvattr *, int *,578int nfsrpc_rmextattr(vnode_t, const char *, struct nfsvattr *, int *,
569 struct ucred *, NFSPROC_T *);579 struct ucred *, NFSPROC_T *);
570void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *);580void 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
572/* nfs_clstate.c */585/* nfs_clstate.c */
573int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,586int 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 *);...@@ -606,12 +619,12 @@ int nfscl_doclose(vnode_t, struct nfsclclient **, NFSPROC_T *);
606int nfsrpc_doclose(struct nfsmount *, struct nfsclopen *, NFSPROC_T *, bool,619int nfsrpc_doclose(struct nfsmount *, struct nfsclopen *, NFSPROC_T *, bool,
607 bool);620 bool);
608int nfscl_deleg(mount_t, struct nfsclclient *, u_int8_t *, int,621int nfscl_deleg(mount_t, struct nfsclclient *, u_int8_t *, int,
609 struct ucred *, NFSPROC_T *, struct nfscldeleg **);622 struct ucred *, NFSPROC_T *, struct nfscldeleg *);
610void nfscl_lockinit(struct nfsv4lock *);623void nfscl_lockinit(struct nfsv4lock *);
611void nfscl_lockexcl(struct nfsv4lock *, void *);624void nfscl_lockexcl(struct nfsv4lock *, void *);
612void nfscl_lockunlock(struct nfsv4lock *);625void nfscl_lockunlock(struct nfsv4lock *);
613void nfscl_lockderef(struct nfsv4lock *);626void nfscl_lockderef(struct nfsv4lock *);
614void nfscl_delegreturnvp(vnode_t, NFSPROC_T *);627void nfscl_delegreturnvp(struct vnode *, bool, NFSPROC_T *);
615void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *);628void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *);
616void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *,629void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *,
617 int);630 int);
...@@ -626,7 +639,7 @@ int nfscl_renamedeleg(vnode_t, nfsv4stateid_t *, int *, vnode_t,...@@ -626,7 +639,7 @@ int nfscl_renamedeleg(vnode_t, nfsv4stateid_t *, int *, vnode_t,
626 nfsv4stateid_t *, int *, NFSPROC_T *);639 nfsv4stateid_t *, int *, NFSPROC_T *);
627void nfscl_reclaimnode(vnode_t);640void nfscl_reclaimnode(vnode_t);
628void nfscl_newnode(vnode_t);641void nfscl_newnode(vnode_t);
629void nfscl_delegmodtime(vnode_t);642void nfscl_delegmodtime(struct vnode *, struct timespec *);
630void nfscl_deleggetmodtime(vnode_t, struct timespec *);643void nfscl_deleggetmodtime(vnode_t, struct timespec *);
631int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *,644int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *,
632 struct nfsmount *, NFSPROC_T *);645 struct nfsmount *, NFSPROC_T *);
...@@ -651,6 +664,8 @@ void nfscl_freelayout(struct nfscllayout *);...@@ -651,6 +664,8 @@ void nfscl_freelayout(struct nfscllayout *);
651void nfscl_freeflayout(struct nfsclflayout *);664void nfscl_freeflayout(struct nfsclflayout *);
652void nfscl_freedevinfo(struct nfscldevinfo *);665void nfscl_freedevinfo(struct nfscldevinfo *);
653int nfscl_layoutcommit(vnode_t, NFSPROC_T *);666int nfscl_layoutcommit(vnode_t, NFSPROC_T *);
667int nfscl_delegacecheck(struct vnode *, accmode_t, struct ucred *);
668void nfscl_startdelegrecall(struct nfsclclient *, struct nfsfh *);
654669
655/* nfs_clport.c */670/* nfs_clport.c */
656int nfscl_nget(mount_t, vnode_t, struct nfsfh *,671int nfscl_nget(mount_t, vnode_t, struct nfsfh *,
...@@ -658,7 +673,7 @@ int nfscl_nget(mount_t, vnode_t, struct nfsfh *,...@@ -658,7 +673,7 @@ int nfscl_nget(mount_t, vnode_t, struct nfsfh *,
658NFSPROC_T *nfscl_getparent(NFSPROC_T *);673NFSPROC_T *nfscl_getparent(NFSPROC_T *);
659void nfscl_start_renewthread(struct nfsclclient *);674void nfscl_start_renewthread(struct nfsclclient *);
660void nfscl_loadsbinfo(struct nfsmount *, struct nfsstatfs *, void *);675void nfscl_loadsbinfo(struct nfsmount *, struct nfsstatfs *, void *);
661void nfscl_loadfsinfo (struct nfsmount *, struct nfsfsinfo *);676void nfscl_loadfsinfo(struct nfsmount *, struct nfsfsinfo *, uint32_t);
662void nfscl_delegreturn(struct nfscldeleg *, int, struct nfsmount *,677void nfscl_delegreturn(struct nfscldeleg *, int, struct nfsmount *,
663 struct ucred *, NFSPROC_T *);678 struct ucred *, NFSPROC_T *);
664void nfsrvd_cbinit(int);679void nfsrvd_cbinit(int);
...@@ -707,12 +722,12 @@ int nfsvno_symlink(struct nameidata *, struct nfsvattr *, char *, int, int,...@@ -707,12 +722,12 @@ int nfsvno_symlink(struct nameidata *, struct nfsvattr *, char *, int, int,
707 uid_t, struct ucred *, NFSPROC_T *, struct nfsexstuff *);722 uid_t, struct ucred *, NFSPROC_T *, struct nfsexstuff *);
708int nfsvno_getsymlink(struct nfsrv_descript *, struct nfsvattr *,723int nfsvno_getsymlink(struct nfsrv_descript *, struct nfsvattr *,
709 NFSPROC_T *, char **, int *);724 NFSPROC_T *, char **, int *);
710int nfsvno_removesub(struct nameidata *, int, struct ucred *, NFSPROC_T *,725int nfsvno_removesub(struct nameidata *, bool, struct nfsrv_descript *,
711 struct nfsexstuff *);726 NFSPROC_T *, struct nfsexstuff *);
712int nfsvno_rmdirsub(struct nameidata *, int, struct ucred *, NFSPROC_T *,727int nfsvno_rmdirsub(struct nameidata *, int, struct ucred *, NFSPROC_T *,
713 struct nfsexstuff *);728 struct nfsexstuff *);
714int nfsvno_rename(struct nameidata *, struct nameidata *, u_int32_t,729int nfsvno_rename(struct nameidata *, struct nameidata *,
715 u_int32_t, struct ucred *, NFSPROC_T *);730 struct nfsrv_descript *, NFSPROC_T *);
716int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *,731int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *,
717 NFSPROC_T *, struct nfsexstuff *);732 NFSPROC_T *, struct nfsexstuff *);
718int nfsvno_fsync(vnode_t, u_int64_t, int, struct ucred *, NFSPROC_T *);733int 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 *,...@@ -726,7 +741,8 @@ int nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct nfsrv_descript *,
726 NFSPROC_T *);741 NFSPROC_T *);
727int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,742int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,
728 struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *,743 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);
730int nfsrv_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,746int nfsrv_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,
731 NFSACL_T *, NFSPROC_T *);747 NFSACL_T *, NFSPROC_T *);
732int nfsv4_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,748int nfsv4_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,
...@@ -780,6 +796,7 @@ int newnfs_request(struct nfsrv_descript *, struct nfsmount *,...@@ -780,6 +796,7 @@ int newnfs_request(struct nfsrv_descript *, struct nfsmount *,
780 struct nfsclient *, struct nfssockreq *, vnode_t, NFSPROC_T *,796 struct nfsclient *, struct nfssockreq *, vnode_t, NFSPROC_T *,
781 struct ucred *, u_int32_t, u_int32_t, u_char *, int, u_int64_t *,797 struct ucred *, u_int32_t, u_int32_t, u_char *, int, u_int64_t *,
782 struct nfsclsession *);798 struct nfsclsession *);
799void nfs_resetslots(struct nfsclsession *);
783int newnfs_connect(struct nfsmount *, struct nfssockreq *,800int newnfs_connect(struct nfsmount *, struct nfssockreq *,
784 struct ucred *, NFSPROC_T *, int, bool, struct __rpc_client **);801 struct ucred *, NFSPROC_T *, int, bool, struct __rpc_client **);
785void newnfs_disconnect(struct nfsmount *, struct nfssockreq *);802void newnfs_disconnect(struct nfsmount *, struct nfssockreq *);
lib/libc/include/generic-freebsd/fs/nfs/nfscl.h+5-4
...@@ -68,10 +68,11 @@ struct nfsv4node {...@@ -68,10 +68,11 @@ struct nfsv4node {
68 * These flag bits are used for the argument to nfscl_fillsattr() to68 * These flag bits are used for the argument to nfscl_fillsattr() to
69 * indicate special handling of the attributes.69 * indicate special handling of the attributes.
70 */70 */
71#define NFSSATTR_FULL 0x171#define NFSSATTR_FULL 0x01
72#define NFSSATTR_SIZE0 0x272#define NFSSATTR_SIZE0 0x02
73#define NFSSATTR_SIZENEG1 0x473#define NFSSATTR_SIZENEG1 0x04
74#define NFSSATTR_SIZERDEV 0x874#define NFSSATTR_SIZERDEV 0x08
75#define NFSSATTR_NEWFILE 0x10
7576
76/* Use this macro for debug printfs. */77/* Use this macro for debug printfs. */
77#define NFSCL_DEBUG(level, ...) do { \78#define NFSCL_DEBUG(level, ...) do { \
lib/libc/include/generic-freebsd/fs/nfs/nfsclstate.h+4
...@@ -116,6 +116,10 @@ struct nfsclclient {...@@ -116,6 +116,10 @@ struct nfsclclient {
116 struct proc *nfsc_renewthread;116 struct proc *nfsc_renewthread;
117 struct nfsmount *nfsc_nmp;117 struct nfsmount *nfsc_nmp;
118 time_t nfsc_expire;118 time_t nfsc_expire;
119 int nfsc_delegcnt;
120 int nfsc_deleghighwater;
121 int nfsc_layoutcnt;
122 int nfsc_layouthighwater;
119 u_int32_t nfsc_clientidrev;123 u_int32_t nfsc_clientidrev;
120 u_int32_t nfsc_rev;124 u_int32_t nfsc_rev;
121 u_int32_t nfsc_renew;125 u_int32_t nfsc_renew;
lib/libc/include/generic-freebsd/fs/nfs/nfsport.h+14-17
...@@ -439,10 +439,16 @@...@@ -439,10 +439,16 @@
439/* Do an NFSv4 Verify+Write. */439/* Do an NFSv4 Verify+Write. */
440#define NFSPROC_APPENDWRITE 69440#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
442/*448/*
443 * Must be defined as one higher than the last NFSv4.2 Proc# above.449 * Must be defined as one higher than the last NFSv4.2 Proc# above.
444 */450 */
445#define NFSV42_NPROCS 70451#define NFSV42_NPROCS 72
446452
447/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */453/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */
448#define NFSV42_OLDNPROCS 69454#define NFSV42_OLDNPROCS 69
...@@ -474,7 +480,7 @@ struct nfsstatsv1 {...@@ -474,7 +480,7 @@ struct nfsstatsv1 {
474 uint64_t readlink_bios;480 uint64_t readlink_bios;
475 uint64_t biocache_readdirs;481 uint64_t biocache_readdirs;
476 uint64_t readdir_bios;482 uint64_t readdir_bios;
477 uint64_t rpccnt[NFSV42_NPROCS + 10];483 uint64_t rpccnt[NFSV42_NPROCS + 8];
478 uint64_t rpcretries;484 uint64_t rpcretries;
479 uint64_t srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];485 uint64_t srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];
480 uint64_t srvlayouts;486 uint64_t srvlayouts;
...@@ -690,6 +696,7 @@ struct nfsvattr {...@@ -690,6 +696,7 @@ struct nfsvattr {
690#define na_bytes na_vattr.va_bytes696#define na_bytes na_vattr.va_bytes
691#define na_filerev na_vattr.va_filerev697#define na_filerev na_vattr.va_filerev
692#define na_vaflags na_vattr.va_vaflags698#define na_vaflags na_vattr.va_vaflags
699#define na_bsdflags na_vattr.va_bsdflags
693700
694#include <fs/nfsclient/nfsnode.h>701#include <fs/nfsclient/nfsnode.h>
695702
...@@ -901,15 +908,6 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *);...@@ -901,15 +908,6 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *);
901#define NFSBCMP(s, d, l) bcmp((s), (d), (l))908#define NFSBCMP(s, d, l) bcmp((s), (d), (l))
902#define NFSBZERO(s, l) bzero((s), (l))909#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
913/*911/*
914 * This must be defined to be a global variable that increments once912 * This must be defined to be a global variable that increments once
915 * per second, but never stops or goes backwards, even when a "date"913 * per second, but never stops or goes backwards, even when a "date"
...@@ -1019,7 +1017,7 @@ MALLOC_DECLARE(M_NEWNFSDSESSION);...@@ -1019,7 +1017,7 @@ MALLOC_DECLARE(M_NEWNFSDSESSION);
1019int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, int, int);1017int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, int, int);
1020int newnfs_realign(struct mbuf **, int);1018int newnfs_realign(struct mbuf **, int);
1021bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep);1019bool 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
1024/*1022/*
1025 * If the port runs on an SMP box that can enforce Atomic ops with low1023 * 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);...@@ -1030,9 +1028,6 @@ void ncl_copy_vattr(struct vattr *dst, struct vattr *src);
1030#define NFSINCRGLOBAL(a) ((a)++)1028#define NFSINCRGLOBAL(a) ((a)++)
1031#define NFSDECRGLOBAL(a) ((a)--)1029#define NFSDECRGLOBAL(a) ((a)--)
10321030
1033/*
1034 * Assorted funky stuff to make things work under Darwin8.
1035 */
1036/*1031/*
1037 * These macros checks for a field in vattr being set.1032 * These macros checks for a field in vattr being set.
1038 */1033 */
...@@ -1180,9 +1175,11 @@ struct nfsreq {...@@ -1180,9 +1175,11 @@ struct nfsreq {
1180 */1175 */
1181#ifdef VV_DISABLEDELEG1176#ifdef VV_DISABLEDELEG
1182#define NFSVNO_DELEGOK(v) \1177#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)
1184#else1180#else
1185#define NFSVNO_DELEGOK(v) (1)1181#define NFSVNO_DELEGOK(v) \
1182 ((v) == NULL || (vn_irflag_read(v) & VIRF_NAMEDATTR) == 0)
1186#endif1183#endif
11871184
1188/*1185/*
lib/libc/include/generic-freebsd/fs/nfs/nfsproto.h+50-7
...@@ -275,6 +275,8 @@...@@ -275,6 +275,8 @@
275#define NFSX_V4SESSIONID 16275#define NFSX_V4SESSIONID 16
276#define NFSX_V4DEVICEID 16276#define NFSX_V4DEVICEID 16
277#define NFSX_V4PNFSFH (sizeof(fhandle_t) + 1)277#define NFSX_V4PNFSFH (sizeof(fhandle_t) + 1)
278#define NFSX_V4NAMEDDIRFH 2
279#define NFSX_V4NAMEDATTRFH 3
278#define NFSX_V4FILELAYOUT (4 * NFSX_UNSIGNED + NFSX_V4DEVICEID + \280#define NFSX_V4FILELAYOUT (4 * NFSX_UNSIGNED + NFSX_V4DEVICEID + \
279 NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH))281 NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH))
280#define NFSX_V4FLEXLAYOUT(m) (NFSX_HYPER + 3 * NFSX_UNSIGNED + \282#define NFSX_V4FLEXLAYOUT(m) (NFSX_HYPER + 3 * NFSX_UNSIGNED + \
...@@ -406,10 +408,16 @@...@@ -406,10 +408,16 @@
406/* Do an NFSv4 Verify+Write. */408/* Do an NFSv4 Verify+Write. */
407#define NFSPROC_APPENDWRITE 69409#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
409/*417/*
410 * Must be defined as one higher than the last NFSv4.2 Proc# above.418 * Must be defined as one higher than the last NFSv4.2 Proc# above.
411 */419 */
412#define NFSV42_NPROCS 70420#define NFSV42_NPROCS 72
413421
414/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */422/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */
415#define NFSV42_OLDNPROCS 69423#define NFSV42_OLDNPROCS 69
...@@ -744,6 +752,17 @@...@@ -744,6 +752,17 @@
744#define NFSSECINFONONAME_CURFH 0752#define NFSSECINFONONAME_CURFH 0
745#define NFSSECINFONONAME_PARENT 1753#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
747#if defined(_KERNEL) || defined(KERNEL)766#if defined(_KERNEL) || defined(KERNEL)
748/* Conversion macros */767/* Conversion macros */
749#define vtonfsv2_mode(t,m) \768#define vtonfsv2_mode(t,m) \
...@@ -1126,6 +1145,7 @@ struct nfsv3_sattr {...@@ -1126,6 +1145,7 @@ struct nfsv3_sattr {
1126 NFSATTRBM_FILESFREE | \1145 NFSATTRBM_FILESFREE | \
1127 NFSATTRBM_FILESTOTAL | \1146 NFSATTRBM_FILESTOTAL | \
1128 NFSATTRBM_FSLOCATIONS | \1147 NFSATTRBM_FSLOCATIONS | \
1148 NFSATTRBM_HIDDEN | \
1129 NFSATTRBM_HOMOGENEOUS | \1149 NFSATTRBM_HOMOGENEOUS | \
1130 NFSATTRBM_MAXFILESIZE | \1150 NFSATTRBM_MAXFILESIZE | \
1131 NFSATTRBM_MAXLINK | \1151 NFSATTRBM_MAXLINK | \
...@@ -1147,6 +1167,7 @@ struct nfsv3_sattr {...@@ -1147,6 +1167,7 @@ struct nfsv3_sattr {
1147 NFSATTRBM_SPACEFREE | \1167 NFSATTRBM_SPACEFREE | \
1148 NFSATTRBM_SPACETOTAL | \1168 NFSATTRBM_SPACETOTAL | \
1149 NFSATTRBM_SPACEUSED | \1169 NFSATTRBM_SPACEUSED | \
1170 NFSATTRBM_SYSTEM | \
1150 NFSATTRBM_TIMEACCESS | \1171 NFSATTRBM_TIMEACCESS | \
1151 NFSATTRBM_TIMECREATE | \1172 NFSATTRBM_TIMECREATE | \
1152 NFSATTRBM_TIMEDELTA | \1173 NFSATTRBM_TIMEDELTA | \
...@@ -1176,6 +1197,8 @@ struct nfsv3_sattr {...@@ -1176,6 +1197,8 @@ struct nfsv3_sattr {
1176 NFSATTRBM_LAYOUTBLKSIZE | \1197 NFSATTRBM_LAYOUTBLKSIZE | \
1177 NFSATTRBM_LAYOUTALIGNMENT | \1198 NFSATTRBM_LAYOUTALIGNMENT | \
1178 NFSATTRBM_SUPPATTREXCLCREAT | \1199 NFSATTRBM_SUPPATTREXCLCREAT | \
1200 NFSATTRBM_CLONEBLKSIZE | \
1201 NFSATTRBM_CHANGEATTRTYPE | \
1179 NFSATTRBM_XATTRSUPPORT)1202 NFSATTRBM_XATTRSUPPORT)
11801203
1181/*1204/*
...@@ -1183,7 +1206,8 @@ struct nfsv3_sattr {...@@ -1183,7 +1206,8 @@ struct nfsv3_sattr {
1183 */1206 */
1184#define NFSATTRBIT_SUPPSETONLY1 (NFSATTRBM_TIMEACCESSSET | \1207#define NFSATTRBIT_SUPPSETONLY1 (NFSATTRBM_TIMEACCESSSET | \
1185 NFSATTRBM_TIMEMODIFYSET)1208 NFSATTRBM_TIMEMODIFYSET)
1186#define NFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED)1209#define NFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED | \
1210 NFSATTRBM_MODEUMASK)
11871211
1188/*1212/*
1189 * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->311213 * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31
...@@ -1192,16 +1216,19 @@ struct nfsv3_sattr {...@@ -1192,16 +1216,19 @@ struct nfsv3_sattr {
1192 */1216 */
1193#define NFSATTRBIT_SETABLE0 \1217#define NFSATTRBIT_SETABLE0 \
1194 (NFSATTRBM_SIZE | \1218 (NFSATTRBM_SIZE | \
1219 NFSATTRBM_HIDDEN | \
1195 NFSATTRBM_ACL)1220 NFSATTRBM_ACL)
1196#define NFSATTRBIT_SETABLE1 \1221#define NFSATTRBIT_SETABLE1 \
1197 (NFSATTRBM_MODE | \1222 (NFSATTRBM_MODE | \
1198 NFSATTRBM_OWNER | \1223 NFSATTRBM_OWNER | \
1199 NFSATTRBM_OWNERGROUP | \1224 NFSATTRBM_OWNERGROUP | \
1200 NFSATTRBM_TIMECREATE | \1225 NFSATTRBM_SYSTEM | \
1226 NFSATTRBM_TIMECREATE | \
1201 NFSATTRBM_TIMEACCESSSET | \1227 NFSATTRBM_TIMEACCESSSET | \
1202 NFSATTRBM_TIMEMODIFYSET)1228 NFSATTRBM_TIMEMODIFYSET)
1203#define NFSATTRBIT_SETABLE2 \1229#define NFSATTRBIT_SETABLE2 \
1204 (NFSATTRBM_MODESETMASKED)1230 (NFSATTRBM_MODESETMASKED | \
1231 NFSATTRBM_MODEUMASK)
12051232
1206/*1233/*
1207 * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1.1234 * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1.
...@@ -1218,7 +1245,11 @@ struct nfsv3_sattr {...@@ -1218,7 +1245,11 @@ struct nfsv3_sattr {
1218/*1245/*
1219 * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2.1246 * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2.
1220 */1247 */
1221#define NFSATTRBIT_NFSV42_2 NFSATTRBM_XATTRSUPPORT1248#define NFSATTRBIT_NFSV42_2 \
1249 (NFSATTRBM_CLONEBLKSIZE | \
1250 NFSATTRBM_CHANGEATTRTYPE | \
1251 NFSATTRBM_XATTRSUPPORT | \
1252 NFSATTRBM_MODEUMASK)
12221253
1223/*1254/*
1224 * Set of attributes that the getattr vnode op needs.1255 * Set of attributes that the getattr vnode op needs.
...@@ -1232,6 +1263,7 @@ struct nfsv3_sattr {...@@ -1232,6 +1263,7 @@ struct nfsv3_sattr {
1232 NFSATTRBM_SIZE | \1263 NFSATTRBM_SIZE | \
1233 NFSATTRBM_FSID | \1264 NFSATTRBM_FSID | \
1234 NFSATTRBM_FILEID | \1265 NFSATTRBM_FILEID | \
1266 NFSATTRBM_HIDDEN | \
1235 NFSATTRBM_MAXREAD)1267 NFSATTRBM_MAXREAD)
12361268
1237/*1269/*
...@@ -1244,6 +1276,7 @@ struct nfsv3_sattr {...@@ -1244,6 +1276,7 @@ struct nfsv3_sattr {
1244 NFSATTRBM_OWNERGROUP | \1276 NFSATTRBM_OWNERGROUP | \
1245 NFSATTRBM_RAWDEV | \1277 NFSATTRBM_RAWDEV | \
1246 NFSATTRBM_SPACEUSED | \1278 NFSATTRBM_SPACEUSED | \
1279 NFSATTRBM_SYSTEM | \
1247 NFSATTRBM_TIMEACCESS | \1280 NFSATTRBM_TIMEACCESS | \
1248 NFSATTRBM_TIMECREATE | \1281 NFSATTRBM_TIMECREATE | \
1249 NFSATTRBM_TIMEMETADATA | \1282 NFSATTRBM_TIMEMETADATA | \
...@@ -1266,6 +1299,7 @@ struct nfsv3_sattr {...@@ -1266,6 +1299,7 @@ struct nfsv3_sattr {
1266 NFSATTRBM_SIZE | \1299 NFSATTRBM_SIZE | \
1267 NFSATTRBM_FSID | \1300 NFSATTRBM_FSID | \
1268 NFSATTRBM_FILEID | \1301 NFSATTRBM_FILEID | \
1302 NFSATTRBM_HIDDEN | \
1269 NFSATTRBM_MAXREAD)1303 NFSATTRBM_MAXREAD)
12701304
1271/*1305/*
...@@ -1276,6 +1310,7 @@ struct nfsv3_sattr {...@@ -1276,6 +1310,7 @@ struct nfsv3_sattr {
1276 NFSATTRBM_NUMLINKS | \1310 NFSATTRBM_NUMLINKS | \
1277 NFSATTRBM_RAWDEV | \1311 NFSATTRBM_RAWDEV | \
1278 NFSATTRBM_SPACEUSED | \1312 NFSATTRBM_SPACEUSED | \
1313 NFSATTRBM_SYSTEM | \
1279 NFSATTRBM_TIMEACCESS | \1314 NFSATTRBM_TIMEACCESS | \
1280 NFSATTRBM_TIMECREATE | \1315 NFSATTRBM_TIMECREATE | \
1281 NFSATTRBM_TIMEMETADATA | \1316 NFSATTRBM_TIMEMETADATA | \
...@@ -1385,13 +1420,14 @@ struct nfsv3_sattr {...@@ -1385,13 +1420,14 @@ struct nfsv3_sattr {
1385/*1420/*
1386 * NFSGETATTRBIT_STATFS2 - bits 64<->951421 * NFSGETATTRBIT_STATFS2 - bits 64<->95
1387 */1422 */
1388#define NFSGETATTRBIT_STATFS2 01423#define NFSGETATTRBIT_STATFS2 (NFSATTRBM_CLONEBLKSIZE)
13891424
1390/*1425/*
1391 * Set of attributes for the equivalent of an nfsv3 pathconf rpc.1426 * Set of attributes for the equivalent of an nfsv3 pathconf rpc.
1392 * NFSGETATTRBIT_PATHCONF0 - bits 0<->311427 * NFSGETATTRBIT_PATHCONF0 - bits 0<->31
1393 */1428 */
1394#define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 | \1429#define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 | \
1430 NFSATTRBM_NAMEDATTR | \
1395 NFSATTRBM_CASEINSENSITIVE | \1431 NFSATTRBM_CASEINSENSITIVE | \
1396 NFSATTRBM_CASEPRESERVING | \1432 NFSATTRBM_CASEPRESERVING | \
1397 NFSATTRBM_CHOWNRESTRICTED | \1433 NFSATTRBM_CHOWNRESTRICTED | \
...@@ -1407,7 +1443,7 @@ struct nfsv3_sattr {...@@ -1407,7 +1443,7 @@ struct nfsv3_sattr {
1407/*1443/*
1408 * NFSGETATTRBIT_PATHCONF2 - bits 64<->951444 * NFSGETATTRBIT_PATHCONF2 - bits 64<->95
1409 */1445 */
1410#define NFSGETATTRBIT_PATHCONF2 01446#define NFSGETATTRBIT_PATHCONF2 (NFSATTRBM_CLONEBLKSIZE)
14111447
1412/*1448/*
1413 * Sets of attributes required by readdir and readdirplus.1449 * Sets of attributes required by readdir and readdirplus.
...@@ -1653,4 +1689,11 @@ typedef struct nfsv4stateid nfsv4stateid_t;...@@ -1653,4 +1689,11 @@ typedef struct nfsv4stateid nfsv4stateid_t;
1653#define NFSV4SXATTR_CREATE 11689#define NFSV4SXATTR_CREATE 1
1654#define NFSV4SXATTR_REPLACE 21690#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
1656#endif /* _NFS_NFSPROTO_H_ */1699#endif /* _NFS_NFSPROTO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/fs/nullfs/null.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)null.h 8.3 (Berkeley) 8/20/94
35 */33 */
3634
37#ifndef FS_NULL_H35#ifndef FS_NULL_H
lib/libc/include/generic-freebsd/fs/procfs/procfs.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *34 *
35 * @(#)procfs.h 8.9 (Berkeley) 5/14/95
36 *
37 * From:35 * From:
38 */36 */
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);...@@ -93,7 +93,7 @@ u_int32_t smbfs_hash(const u_char *name, int nmlen);
9393
94int smbfs_getpages(struct vop_getpages_args *);94int smbfs_getpages(struct vop_getpages_args *);
95int smbfs_putpages(struct vop_putpages_args *);95int 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);
97int smbfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag);97int smbfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag);
98void smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap);98void smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap);
99int smbfs_attr_cachelookup(struct vnode *vp ,struct vattr *va);99int 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 {...@@ -243,7 +243,7 @@ struct part_map_spare {
243 uint8_t n_st; /* Number of Sparing Tables */243 uint8_t n_st; /* Number of Sparing Tables */
244 uint8_t reserved1;244 uint8_t reserved1;
245 uint32_t st_size;245 uint32_t st_size;
246 uint32_t st_loc[1];246 uint32_t st_loc[];
247} __packed;247} __packed;
248248
249union udf_pmap {249union udf_pmap {
...@@ -266,7 +266,7 @@ struct udf_sparing_table {...@@ -266,7 +266,7 @@ struct udf_sparing_table {
266 uint16_t rt_l; /* Relocation Table len */266 uint16_t rt_l; /* Relocation Table len */
267 uint8_t reserved[2];267 uint8_t reserved[2];
268 uint32_t seq_num;268 uint32_t seq_num;
269 struct spare_map_entry entries[1];269 struct spare_map_entry entries[];
270} __packed;270} __packed;
271271
272/* Partition Descriptor [3/10.5] */272/* Partition Descriptor [3/10.5] */
lib/libc/include/generic-freebsd/fs/unionfs/union.h+17-19
...@@ -33,8 +33,6 @@...@@ -33,8 +33,6 @@
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.35 * SUCH DAMAGE.
36 *
37 * @(#)union.h 8.9 (Berkeley) 12/10/94
38 */36 */
3937
40#ifdef _KERNEL38#ifdef _KERNEL
...@@ -99,15 +97,17 @@ struct unionfs_node {...@@ -99,15 +97,17 @@ struct unionfs_node {
9997
100 char *un_path; /* path */98 char *un_path; /* path */
101 int un_pathlen; /* strlen of path */99 int un_pathlen; /* strlen of path */
102 int un_flag; /* unionfs node flag */
103};
104100
105/*101 /*
106 * unionfs node flags102 * unionfs node flags
107 * It needs the vnode with exclusive lock, when changing the un_flag variable.103 * Changing these flags requires the vnode to be locked exclusive.
108 */104 */
109#define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */105 #define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */
110#define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */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
112extern struct vop_vector unionfs_vnodeops;112extern struct vop_vector unionfs_vnodeops;
113113
...@@ -133,34 +133,32 @@ int unionfs_uninit(struct vfsconf *);...@@ -133,34 +133,32 @@ int unionfs_uninit(struct vfsconf *);
133int unionfs_nodeget(struct mount *, struct vnode *, struct vnode *,133int unionfs_nodeget(struct mount *, struct vnode *, struct vnode *,
134 struct vnode *, struct vnode **, struct componentname *);134 struct vnode *, struct vnode **, struct componentname *);
135void unionfs_noderem(struct vnode *);135void unionfs_noderem(struct vnode *);
136struct unionfs_node_status * unionfs_find_node_status(struct unionfs_node *,
137 struct thread *td);
136void unionfs_get_node_status(struct unionfs_node *, struct thread *,138void unionfs_get_node_status(struct unionfs_node *, struct thread *,
137 struct unionfs_node_status **);139 struct unionfs_node_status **);
138void unionfs_tryrem_node_status(struct unionfs_node *,140void unionfs_tryrem_node_status(struct unionfs_node *,
139 struct unionfs_node_status *);141 struct unionfs_node_status *);
140int unionfs_check_rmdir(struct vnode *, struct ucred *, struct thread *td);142int 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 *,
142 struct thread *);144 struct thread *);
143void unionfs_create_uppervattr_core(struct unionfs_mount *, struct vattr *,145void unionfs_create_uppervattr_core(struct unionfs_mount *, struct vattr *,
144 struct vattr *, struct thread *);146 struct vattr *, struct thread *);
145int unionfs_create_uppervattr(struct unionfs_mount *, struct vnode *,147int unionfs_create_uppervattr(struct unionfs_mount *, struct vnode *,
146 struct vattr *, struct ucred *, struct thread *);148 struct vattr *, struct ucred *, struct thread *);
147int unionfs_mkshadowdir(struct unionfs_mount *, struct vnode *,149int unionfs_mkshadowdir(struct vnode *, struct vnode *,
148 struct unionfs_node *, struct componentname *, struct thread *);150 struct componentname *, struct thread *);
149int unionfs_mkwhiteout(struct vnode *, struct vnode *,151int unionfs_mkwhiteout(struct vnode *, struct vnode *,
150 struct componentname *, struct thread *, char *, int);152 struct componentname *, struct thread *, char *, int);
151int unionfs_relookup(struct vnode *, struct vnode **,153int unionfs_relookup(struct vnode *, struct vnode **,
152 struct componentname *, struct componentname *, struct thread *,154 struct componentname *, struct componentname *, struct thread *,
153 char *, int, u_long);155 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 *);
160void unionfs_forward_vop_start_pair(struct vnode *, int *,156void unionfs_forward_vop_start_pair(struct vnode *, int *,
161 struct vnode *, int *);157 struct vnode *, int *);
162bool unionfs_forward_vop_finish_pair(struct vnode *, struct vnode *, int,158bool unionfs_forward_vop_finish_pair(struct vnode *, struct vnode *, int,
163 struct vnode *, struct vnode *, int);159 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
165static inline void163static inline void
166unionfs_forward_vop_start(struct vnode *basevp, int *lkflags)164unionfs_forward_vop_start(struct vnode *basevp, int *lkflags)
lib/libc/include/generic-freebsd/fstab.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)fstab.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _FSTAB_H_32#ifndef _FSTAB_H_
lib/libc/include/generic-freebsd/fts.h+43-22
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)fts.h 8.3 (Berkeley) 8/14/94
32 */30 */
3331
34#ifndef _FTS_H_32#ifndef _FTS_H_
...@@ -36,35 +34,54 @@...@@ -36,35 +34,54 @@
3634
37#include <sys/_types.h>35#include <sys/_types.h>
3836
37typedef struct _ftsent FTSENT;
38
39typedef struct {39typedef struct {
40 struct _ftsent *fts_cur; /* current node */40 FTSENT *fts_cur; /* current node */
41 struct _ftsent *fts_child; /* linked list of children */41 FTSENT *fts_child; /* linked list of children */
42 struct _ftsent **fts_array; /* sort array */42 FTSENT **fts_array; /* sort array */
43 __dev_t fts_dev; /* starting device # */43 __dev_t fts_dev; /* starting device # */
44 char *fts_path; /* path for this descent */44 char *fts_path; /* path for this descent */
45 int fts_rfd; /* fd for root */45 int fts_rfd; /* fd for root */
46 __size_t fts_pathlen; /* sizeof(path) */46 __size_t fts_pathlen; /* sizeof(path) */
47 __size_t fts_nitems; /* elements in the sort array */47 __size_t fts_nitems; /* elements in the sort array */
48 int (*fts_compar) /* compare function */48 union {
49 (const struct _ftsent * const *, const struct _ftsent * const *);49 int (*fts_compar) /* compare function */
5050 (const FTSENT * const *, const FTSENT * const *);
51#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */51#ifdef __BLOCKS__
52#define FTS_LOGICAL 0x002 /* logical walk */52 int (^fts_compar_b)
53#define FTS_NOCHDIR 0x004 /* don't change directories */53 (const FTSENT * const *, const FTSENT * const *);
54#define FTS_NOSTAT 0x008 /* don't get stat info */54#else
55#define FTS_PHYSICAL 0x010 /* physical walk */55 void *fts_compar_b;
56#define FTS_SEEDOT 0x020 /* return dot and dot-dot */56#endif /* __BLOCKS__ */
57#define FTS_XDEV 0x040 /* don't cross devices */57 };
58#define FTS_WHITEOUT 0x080 /* return whiteout information */58
59#define FTS_OPTIONMASK 0x0ff /* valid user option mask */59/* valid for fts_open() */
6060#define FTS_COMFOLLOW 0x000001 /* follow command line symlinks */
61#define FTS_NAMEONLY 0x100 /* (private) child names only */61#define FTS_LOGICAL 0x000002 /* logical walk */
62#define FTS_STOP 0x200 /* (private) unrecoverable error */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 */
63 int fts_options; /* fts_open options, global flags */80 int fts_options; /* fts_open options, global flags */
64 void *fts_clientptr; /* thunk for sort function */81 void *fts_clientptr; /* thunk for sort function */
65} FTS;82} FTS;
6683
67typedef struct _ftsent {84struct _ftsent {
68 struct _ftsent *fts_cycle; /* cycle node */85 struct _ftsent *fts_cycle; /* cycle node */
69 struct _ftsent *fts_parent; /* parent directory */86 struct _ftsent *fts_parent; /* parent directory */
70 struct _ftsent *fts_link; /* next file in directory */87 struct _ftsent *fts_link; /* next file in directory */
...@@ -116,7 +133,7 @@ typedef struct _ftsent {...@@ -116,7 +133,7 @@ typedef struct _ftsent {
116 struct stat *fts_statp; /* stat(2) information */133 struct stat *fts_statp; /* stat(2) information */
117 char *fts_name; /* file name */134 char *fts_name; /* file name */
118 FTS *fts_fts; /* back pointer to main FTS */135 FTS *fts_fts; /* back pointer to main FTS */
119} FTSENT;136};
120137
121#include <sys/cdefs.h>138#include <sys/cdefs.h>
122139
...@@ -129,6 +146,10 @@ FTS *fts_get_stream(FTSENT *);...@@ -129,6 +146,10 @@ FTS *fts_get_stream(FTSENT *);
129#define fts_get_stream(ftsent) ((ftsent)->fts_fts)146#define fts_get_stream(ftsent) ((ftsent)->fts_fts)
130FTS *fts_open(char * const *, int,147FTS *fts_open(char * const *, int,
131 int (*)(const FTSENT * const *, const FTSENT * const *));148 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__ */
132FTSENT *fts_read(FTS *);153FTSENT *fts_read(FTS *);
133int fts_set(FTS *, FTSENT *, int);154int fts_set(FTS *, FTSENT *, int);
134void fts_set_clientptr(FTS *, void *);155void 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);...@@ -282,7 +282,7 @@ void g_detach(struct g_consumer *cp);
282void g_error_provider(struct g_provider *pp, int error);282void g_error_provider(struct g_provider *pp, int error);
283struct g_provider *g_provider_by_name(char const *arg);283struct g_provider *g_provider_by_name(char const *arg);
284int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);284int 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)))
286int g_handleattr(struct bio *bp, const char *attribute, const void *val,286int g_handleattr(struct bio *bp, const char *attribute, const void *val,
287 int len);287 int len);
288int g_handleattr_int(struct bio *bp, const char *attribute, int val);288int g_handleattr_int(struct bio *bp, const char *attribute, int val);
...@@ -417,7 +417,7 @@ g_free(void *ptr)...@@ -417,7 +417,7 @@ g_free(void *ptr)
417 static moduledata_t name##_mod = { \417 static moduledata_t name##_mod = { \
418 #name, g_modevent, &class \418 #name, g_modevent, &class \
419 }; \419 }; \
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
422int g_is_geom_thread(struct thread *td);422int 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;...@@ -73,12 +73,12 @@ extern struct g_label_desc g_label_ufs_volume;
73extern struct g_label_desc g_label_iso9660;73extern struct g_label_desc g_label_iso9660;
74extern struct g_label_desc g_label_msdosfs;74extern struct g_label_desc g_label_msdosfs;
75extern struct g_label_desc g_label_ext2fs;75extern struct g_label_desc g_label_ext2fs;
76extern struct g_label_desc g_label_reiserfs;
77extern struct g_label_desc g_label_ntfs;76extern struct g_label_desc g_label_ntfs;
78extern struct g_label_desc g_label_gpt;77extern struct g_label_desc g_label_gpt;
79extern struct g_label_desc g_label_gpt_uuid;78extern struct g_label_desc g_label_gpt_uuid;
80extern struct g_label_desc g_label_disk_ident;79extern struct g_label_desc g_label_disk_ident;
81extern struct g_label_desc g_label_flashmap;80extern struct g_label_desc g_label_flashmap;
81extern struct g_label_desc g_label_swaplinux;
8282
83extern void g_label_rtrim(char *label, size_t size);83extern void g_label_rtrim(char *label, size_t size);
84#endif /* _KERNEL */84#endif /* _KERNEL */
lib/libc/include/generic-freebsd/glob.h+14-4
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)glob.h 8.1 (Berkeley) 6/2/93
35 */33 */
3634
37#ifndef _GLOB_H_35#ifndef _GLOB_H_
...@@ -52,8 +50,15 @@ typedef struct {...@@ -52,8 +50,15 @@ typedef struct {
52 size_t gl_offs; /* Reserved at beginning of gl_pathv. */50 size_t gl_offs; /* Reserved at beginning of gl_pathv. */
53 int gl_flags; /* Copy of flags parameter to glob. */51 int gl_flags; /* Copy of flags parameter to glob. */
54 char **gl_pathv; /* List of paths matching pattern. */52 char **gl_pathv; /* List of paths matching pattern. */
55 /* Copy of errfunc parameter to glob. */53 /* Copy of error callback parameter to glob. */
56 int (*gl_errfunc)(const char *, int);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
58 /*63 /*
59 * Alternate filesystem access methods for glob; replacement64 * Alternate filesystem access methods for glob; replacement
...@@ -92,6 +97,7 @@ typedef struct {...@@ -92,6 +97,7 @@ typedef struct {
92#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */97#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
93#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */98#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
94#define GLOB_LIMIT 0x1000 /* limit number of returned paths */99#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
100#define _GLOB_ERR_BLOCK 0x08000000 /* (internal) error callback is a block */
95101
96/* source compatibility, these are the old names */102/* source compatibility, these are the old names */
97#define GLOB_MAXPATH GLOB_LIMIT103#define GLOB_MAXPATH GLOB_LIMIT
...@@ -101,6 +107,10 @@ typedef struct {...@@ -101,6 +107,10 @@ typedef struct {
101__BEGIN_DECLS107__BEGIN_DECLS
102int glob(const char * __restrict, int,108int glob(const char * __restrict, int,
103 int (*)(const char *, int), glob_t * __restrict);109 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
104void globfree(glob_t *);114void globfree(glob_t *);
105__END_DECLS115__END_DECLS
106116
lib/libc/include/generic-freebsd/grp.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)grp.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _GRP_H_37#ifndef _GRP_H_
lib/libc/include/generic-freebsd/iconv.h-2
...@@ -33,12 +33,10 @@...@@ -33,12 +33,10 @@
33#ifndef _ICONV_H_33#ifndef _ICONV_H_
34#define _ICONV_H_34#define _ICONV_H_
3535
36#include <sys/cdefs.h>
37#include <sys/types.h>36#include <sys/types.h>
3837
39#include <wchar.h>38#include <wchar.h>
4039
41#include <sys/cdefs.h>
42#include <sys/types.h>40#include <sys/types.h>
4341
44#ifdef __cplusplus42#ifdef __cplusplus
lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_mount.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)cd9660_mount.h 8.1 (Berkeley) 5/24/95
37 */35 */
3836
39/*37/*
lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_node.h+1-3
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95
37 */35 */
3836
39/*37/*
...@@ -58,7 +56,7 @@ typedef struct {...@@ -58,7 +56,7 @@ typedef struct {
5856
59struct iso_node {57struct iso_node {
60 struct vnode *i_vnode; /* vnode associated with this inode */58 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 */
62 /* we use the actual starting block of the file */60 /* we use the actual starting block of the file */
63 struct iso_mnt *i_mnt; /* filesystem associated with this inode */61 struct iso_mnt *i_mnt; /* filesystem associated with this inode */
64 struct lockf *i_lockf; /* head of byte-level lock list */62 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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)cd9660_rrip.h 8.2 (Berkeley) 12/5/94
37 */35 */
3836
39#ifndef _ISOFS_CD9660_CD9660_RRIP_H_37#ifndef _ISOFS_CD9660_CD9660_RRIP_H_
lib/libc/include/generic-freebsd/isofs/cd9660/iso.h+9-16
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)iso.h 8.6 (Berkeley) 5/10/95
37 */35 */
3836
39#ifndef _ISOFS_CD9660_ISO_H_37#ifndef _ISOFS_CD9660_ISO_H_
...@@ -214,21 +212,12 @@ struct iso_extended_attributes {...@@ -214,21 +212,12 @@ struct iso_extended_attributes {
214 u_char len_au [ISODCL (247, 250)]; /* 723 */212 u_char len_au [ISODCL (247, 250)]; /* 723 */
215};213};
216214
217#ifdef _KERNEL215#if defined(_KERNEL) || defined(_WANT_ISO_MNT)
218216
219/* CD-ROM Format type */217/* CD-ROM Format type */
220enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP,218enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP,
221 ISO_FTYPE_JOLIET, ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA };219 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
232struct iso_mnt {221struct iso_mnt {
233 uint64_t im_flags;222 uint64_t im_flags;
234223
...@@ -264,12 +253,16 @@ struct iso_mnt {...@@ -264,12 +253,16 @@ struct iso_mnt {
264 void *im_l2d;253 void *im_l2d;
265};254};
266255
256#endif /* defined(_KERNEL) || defined(_WANT_ISO_MNT) */
257
258#ifdef _KERNEL
259
267struct ifid {260struct ifid {
268 u_short ifid_len;261 u_short ifid_len;
269 u_short ifid_pad;262 u_short ifid_pad;
270 cd_ino_t ifid_ino;263 ino_t ifid_ino;
271 long ifid_start;264 long ifid_start;
272};265} __packed;
273266
274#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data))267#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data))
275268
...@@ -278,7 +271,7 @@ struct ifid {...@@ -278,7 +271,7 @@ struct ifid {
278#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift)271#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift)
279#define blksize(imp, ip, lbn) ((imp)->logical_block_size)272#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,
282 struct iso_directory_record *);275 struct iso_directory_record *);
283#define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \276#define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
284 size_t, struct proc *))eopnotsupp)277 size_t, struct proc *))eopnotsupp)
...@@ -289,7 +282,7 @@ extern struct vop_vector cd9660_fifoops;...@@ -289,7 +282,7 @@ extern struct vop_vector cd9660_fifoops;
289int isochar(u_char *, u_char *, int, u_short *, int *, int, void *);282int isochar(u_char *, u_char *, int, u_short *, int *, int, void *);
290int isofncmp(u_char *, int, u_char *, int, int, int, void *, void *);283int isofncmp(u_char *, int, u_char *, int, int, int, void *, void *);
291void isofntrans(u_char *, int, u_char *, u_short *, int, int, int, int, void *);284void 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 *);
293u_short sgetrune(const char *, size_t, char const **, int, void *);286u_short sgetrune(const char *, size_t, char const **, int, void *);
294287
295#endif /* _KERNEL */288#endif /* _KERNEL */
lib/libc/include/generic-freebsd/isofs/cd9660/iso_rrip.h+2-4
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)iso_rrip.h 8.2 (Berkeley) 1/23/94
37 */35 */
3836
39#ifndef _ISOFS_CD9660_ISO_RRIP_H_37#ifndef _ISOFS_CD9660_ISO_RRIP_H_
...@@ -65,7 +63,7 @@ typedef struct {...@@ -65,7 +63,7 @@ typedef struct {
65 off_t iso_ce_off; /* offset of continuation area */63 off_t iso_ce_off; /* offset of continuation area */
66 int iso_ce_len; /* length of continuation area */64 int iso_ce_len; /* length of continuation area */
67 struct iso_mnt *imp; /* mount structure */65 struct iso_mnt *imp; /* mount structure */
68 cd_ino_t *inump; /* inode number pointer */66 ino_t *inump; /* inode number pointer */
69 char *outbuf; /* name/symbolic link output area */67 char *outbuf; /* name/symbolic link output area */
70 u_short *outlen; /* length of above */68 u_short *outlen; /* length of above */
71 u_short maxlen; /* maximum length of above */69 u_short maxlen; /* maximum length of above */
...@@ -78,7 +76,7 @@ int cd9660_rrip_analyze(struct iso_directory_record *isodir,...@@ -78,7 +76,7 @@ int cd9660_rrip_analyze(struct iso_directory_record *isodir,
78 struct iso_node *inop, struct iso_mnt *imp);76 struct iso_node *inop, struct iso_mnt *imp);
79int cd9660_rrip_getname(struct iso_directory_record *isodir,77int cd9660_rrip_getname(struct iso_directory_record *isodir,
80 char *outbuf, u_short *outlen,78 char *outbuf, u_short *outlen,
81 cd_ino_t *inump, struct iso_mnt *imp);79 ino_t *inump, struct iso_mnt *imp);
82int cd9660_rrip_getsymname(struct iso_directory_record *isodir,80int cd9660_rrip_getsymname(struct iso_directory_record *isodir,
83 char *outbuf, u_short *outlen,81 char *outbuf, u_short *outlen,
84 struct iso_mnt *imp);82 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;...@@ -86,10 +86,17 @@ struct termios;
86struct winsize;86struct winsize;
8787
88__BEGIN_DECLS88__BEGIN_DECLS
89char *auth_getval(const char *_name);
90void clean_environment(const char * const *_white,89void clean_environment(const char * const *_white,
91 const char * const *_more_white);90 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
93int extattr_namespace_to_string(int _attrnamespace, char **_string);100int extattr_namespace_to_string(int _attrnamespace, char **_string);
94int extattr_string_to_namespace(const char *_string, int *_attrnamespace);101int extattr_string_to_namespace(const char *_string, int *_attrnamespace);
95int flopen(const char *_path, int _flags, ...);102int flopen(const char *_path, int _flags, ...);
...@@ -213,7 +220,13 @@ int cpuset_parselist(const char *list, cpuset_t *mask);...@@ -213,7 +220,13 @@ int cpuset_parselist(const char *list, cpuset_t *mask);
213#define CPUSET_PARSE_OK 0220#define CPUSET_PARSE_OK 0
214#define CPUSET_PARSE_GETAFFINITY -1221#define CPUSET_PARSE_GETAFFINITY -1
215#define CPUSET_PARSE_ERROR -2222#define CPUSET_PARSE_ERROR -2
216#define CPUSET_PARSE_INVALID_CPU -3223#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);
217#endif230#endif
218231
219__END_DECLS232__END_DECLS
lib/libc/include/generic-freebsd/limits.h+5-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.2 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _LIMITS_H_32#ifndef _LIMITS_H_
...@@ -139,6 +137,11 @@...@@ -139,6 +137,11 @@
139137
140#define MB_LEN_MAX 6 /* 31-bit UTF-8 */138#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
142#include <sys/limits.h>145#include <sys/limits.h>
143146
144#if __POSIX_VISIBLE147#if __POSIX_VISIBLE
lib/libc/include/generic-freebsd/locale.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)locale.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _LOCALE_H_32#ifndef _LOCALE_H_
lib/libc/include/generic-freebsd/machine/_align.h+2-50
...@@ -1,53 +1,5 @@...@@ -1,53 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-4-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,47 +1,28 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * Copyright (c) 2005 The FreeBSD Foundation.
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
5 *3 *
6 * Redistribution and use in source and binary forms, with or without4 * SPDX-License-Identifier: BSD-2-Clause
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.
16 *5 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND6 * Derived in part from NetBSD's bus.h files by (alphabetically):
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE7 * Christopher G. Demetriou
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE8 * Charles M. Hannum
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR9 * Jason Thorpe
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL10 * The NetBSD Foundation.
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 */11 */
2912
30#ifndef POWERPC_INCLUDE__BUS_H13#ifndef _MACHINE__BUS_H_
31#define POWERPC_INCLUDE__BUS_H14#define _MACHINE__BUS_H_
32
33#include <vm/vm_param.h>
3415
35/*16/*
36 * Bus address and size types17 * Addresses (in bus space).
37 */18 */
38typedef vm_paddr_t bus_addr_t;19typedef u_long bus_addr_t;
39typedef vm_size_t bus_size_t;20typedef u_long bus_size_t;
4021
41/*22/*
42 * Access methods for bus resources and address space.23 * Access methods for bus space.
43 */24 */
25typedef u_long bus_space_handle_t;
44typedef struct bus_space *bus_space_tag_t;26typedef 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 @@...@@ -1,222 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,98 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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
32 */3 */
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 @@...@@ -1,200 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-4-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,92 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-4-Clause2 * This file is in the public domain.
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
38 */3 */
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,493 +1,5 @@
1/* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */
2
3/*-1/*-
4 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause2 * This file is in the public domain.
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 */3 */
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,18 +1,5 @@
1/*-1/*
2 * Kernel interface to machine-dependent clock driver.
3 * Garrett Wollman, September 1994.
4 * This file is in the public domain.2 * This file is in the public domain.
5 */3 */
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 @@...@@ -1,73 +1,5 @@
1/*-1/*-
2 * Copyright (c) 2014 EMC Corp.2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,146 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,40 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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
32 */3 */
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 @@...@@ -1,8 +1,8 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-3-Clause
3 *3 *
4 * Copyright (c) 2001 David E. O'Brien4 * Copyright (c) 1992, 1993
5 * All rights reserved.5 * The Regents of the University of California. All rights reserved.
6 *6 *
7 * Redistribution and use in source and binary forms, with or without7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions8 * modification, are permitted provided that the following conditions
...@@ -12,11 +12,11 @@...@@ -12,11 +12,11 @@
12 * 2. Redistributions in binary form must reproduce the above copyright12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors15 * 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 software16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.17 * without specific prior written permission.
18 *18 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22 * 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 @@...@@ -1,100 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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
33 */3 */
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 @@...@@ -1,7 +1,7 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-4-Clause
3 *3 *
4 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>4 * Copyright (c) 1993 Andrew Moore, Talke Studio
5 * All rights reserved.5 * All rights reserved.
6 *6 *
7 * Redistribution and use in source and binary forms, with or without7 * Redistribution and use in source and binary forms, with or without
...@@ -12,11 +12,15 @@...@@ -12,11 +12,15 @@
12 * 2. Redistributions in binary form must reproduce the above copyright12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors15 * 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
16 * may be used to endorse or promote products derived from this software20 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.21 * without specific prior written permission.
18 *22 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
...@@ -32,6 +36,7 @@...@@ -32,6 +36,7 @@
32#ifndef _FLOATINGPOINT_H_36#ifndef _FLOATINGPOINT_H_
33#define _FLOATINGPOINT_H_37#define _FLOATINGPOINT_H_
3438
39#include <sys/cdefs.h>
35#include <machine/ieeefp.h>40#include <machine/ieeefp.h>
3641
37#endif /* !_FLOATINGPOINT_H_ */42#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 @@...@@ -29,7 +29,6 @@
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *30 *
31 * from tahoe: in_cksum.c 1.2 86/01/0531 * from tahoe: in_cksum.c 1.2 86/01/05
32 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
33 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp32 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
34 */33 */
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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _MACHINE_LIMITS_H_32#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 @@...@@ -1,38 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,58 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,101 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-4-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,44 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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
32 */3 */
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,92 +1,5 @@
1/* $NetBSD: reg.h,v 1.4 2000/06/04 09:30:44 tsubai Exp $ */1/*-
22 * This file is in the public domain.
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.
74 */3 */
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 @@...@@ -1,8 +1,8 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-3-Clause
3 *3 *
4 * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.4 * Copyright (c) 1992, 1993
5 * All rights reserved.5 * The Regents of the University of California. All rights reserved.
6 *6 *
7 * Redistribution and use in source and binary forms, with or without7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions8 * modification, are permitted provided that the following conditions
...@@ -12,11 +12,11 @@...@@ -12,11 +12,11 @@
12 * 2. Redistributions in binary form must reproduce the above copyright12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of any co-contributors15 * 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 software16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.17 * without specific prior written permission.
18 *18 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
...@@ -27,4 +27,22 @@...@@ -27,4 +27,22 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * 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 @@...@@ -1,27 +1,5 @@
1/*-1/*-
2 * $NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $2 * This file is in the public domain.
3 */3 */
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 @@...@@ -1,43 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,66 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,160 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-4-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,43 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * This file is in the public domain.
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 */3 */
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 @@...@@ -1,7 +1,8 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * SPDX-License-Identifier: BSD-2-Clause
3 *3 *
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>
5 * All rights reserved.6 * All rights reserved.
6 *7 *
7 * Redistribution and use in source and binary forms, with or without8 * Redistribution and use in source and binary forms, with or without
...@@ -29,17 +30,17 @@...@@ -29,17 +30,17 @@
29#ifndef _MACHINE_VM_H_30#ifndef _MACHINE_VM_H_
30#define _MACHINE_VM_H_31#define _MACHINE_VM_H_
3132
32#include <machine/pte.h>33#include <machine/specialreg.h>
3334
34/* Memory attributes. */35/* Memory attributes. */
35#define VM_MEMATTR_DEFAULT 036#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE)
36#define VM_MEMATTR_UNCACHEABLE 0x0137#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING)
37#define VM_MEMATTR_CACHEABLE 0x0238#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH)
38#define VM_MEMATTR_WRITE_COMBINING 0x0439#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED)
39#define VM_MEMATTR_WRITE_BACK 0x0840#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK)
40#define VM_MEMATTR_WRITE_THROUGH 0x1041#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED)
41#define VM_MEMATTR_PREFETCHABLE 0x20
4242
43#define VM_MEMATTR_DEVICE VM_MEMATTR_DEFAULT43#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
44#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE
4445
45#endif /* !_MACHINE_VM_H_ */46#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 @@...@@ -10,12 +10,12 @@
10 */10 */
1111
12/*12/*
13 * from: @(#)fdlibm.h 5.1 93/09/24
14 */13 */
1514
16#ifndef _MATH_H_15#ifndef _MATH_H_
17#define _MATH_H_16#define _MATH_H_
1817
18#include <sys/cdefs.h>
19#include <sys/_types.h>19#include <sys/_types.h>
20#include <machine/_limits.h>20#include <machine/_limits.h>
2121
...@@ -32,13 +32,8 @@ extern const union __nan_un {...@@ -32,13 +32,8 @@ extern const union __nan_un {
32 float __uf;32 float __uf;
33} __nan;33} __nan;
3434
35#if __GNUC_PREREQ__(3, 3)
36#define __MATH_BUILTIN_CONSTANTS35#define __MATH_BUILTIN_CONSTANTS
37#endif
38
39#if __GNUC_PREREQ__(3, 0)
40#define __MATH_BUILTIN_RELOPS36#define __MATH_BUILTIN_RELOPS
41#endif
4237
43#ifdef __MATH_BUILTIN_CONSTANTS38#ifdef __MATH_BUILTIN_CONSTANTS
44#define HUGE_VAL __builtin_huge_val()39#define HUGE_VAL __builtin_huge_val()
...@@ -77,10 +72,10 @@ extern const union __nan_un {...@@ -77,10 +72,10 @@ extern const union __nan_un {
7772
78#if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections)73#if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections)
79#define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \74#define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \
80 float: f(x), \75 float: f, \
81 double: d(x), \76 double: d, \
82 long double: ld(x))77 long double: ld)(x)
83#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)78#elif !defined(__cplusplus)
84#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \79#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
85 __builtin_types_compatible_p(__typeof(x), long double), ld(x), \80 __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
86 __builtin_choose_expr( \81 __builtin_choose_expr( \
...@@ -143,6 +138,22 @@ typedef __float_t float_t;...@@ -143,6 +138,22 @@ typedef __float_t float_t;
143#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */138#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
144#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */139#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
146#define MAXFLOAT ((float)3.40282346638528860e+38)157#define MAXFLOAT ((float)3.40282346638528860e+38)
147extern int signgam;158extern int signgam;
148#endif /* __BSD_VISIBLE || __XSI_VISIBLE */159#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
...@@ -182,21 +193,21 @@ int __signbitf(float) __pure2;...@@ -182,21 +193,21 @@ int __signbitf(float) __pure2;
182int __signbitl(long double) __pure2;193int __signbitl(long double) __pure2;
183194
184static __inline int195static __inline int
185__inline_isnan(__const double __x)196__inline_isnan(const double __x)
186{197{
187198
188 return (__x != __x);199 return (__x != __x);
189}200}
190201
191static __inline int202static __inline int
192__inline_isnanf(__const float __x)203__inline_isnanf(const float __x)
193{204{
194205
195 return (__x != __x);206 return (__x != __x);
196}207}
197208
198static __inline int209static __inline int
199__inline_isnanl(__const long double __x)210__inline_isnanl(const long double __x)
200{211{
201212
202 return (__x != __x);213 return (__x != __x);
lib/libc/include/generic-freebsd/memory.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)memory.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#include <string.h>32#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)mpool.h 8.4 (Berkeley) 11/2/95
32 */30 */
3331
34#ifndef _MPOOL_H_32#ifndef _MPOOL_H_
lib/libc/include/generic-freebsd/mqueue.h-1
...@@ -29,7 +29,6 @@...@@ -29,7 +29,6 @@
29#ifndef _MQUEUE_H_29#ifndef _MQUEUE_H_
30#define _MQUEUE_H_30#define _MQUEUE_H_
3131
32#include <sys/cdefs.h>
33#include <sys/types.h>32#include <sys/types.h>
34#include <sys/mqueue.h>33#include <sys/mqueue.h>
35#include <sys/signal.h>34#include <sys/signal.h>
lib/libc/include/generic-freebsd/ndbm.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)ndbm.h 8.1 (Berkeley) 6/2/93
35 */33 */
3634
37#ifndef _NDBM_H_35#ifndef _NDBM_H_
lib/libc/include/generic-freebsd/net/altq/altq_rmclass.h-2
...@@ -38,8 +38,6 @@...@@ -38,8 +38,6 @@
3838
39#include <net/altq/altq_classq.h>39#include <net/altq/altq_classq.h>
4040
41/* #pragma ident "@(#)rm_class.h 1.20 97/10/23 SMI" */
42
43#ifdef __cplusplus41#ifdef __cplusplus
44extern "C" {42extern "C" {
45#endif43#endif
lib/libc/include/generic-freebsd/net/altq/altq_rmclass_debug.h-2
...@@ -33,8 +33,6 @@...@@ -33,8 +33,6 @@
33#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_33#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_
34#define _ALTQ_ALTQ_RMCLASS_DEBUG_H_34#define _ALTQ_ALTQ_RMCLASS_DEBUG_H_
3535
36/* #pragma ident "@(#)rm_class_debug.h 1.7 98/05/04 SMI" */
37
38/*36/*
39 * Cbq debugging macros37 * Cbq debugging macros
40 */38 */
lib/libc/include/generic-freebsd/net/bpf.h+2-3
...@@ -32,14 +32,12 @@...@@ -32,14 +32,12 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)bpf.h 8.1 (Berkeley) 6/10/93
37 * @(#)bpf.h 1.34 (LBL) 6/16/96
38 */35 */
3936
40#ifndef _NET_BPF_H_37#ifndef _NET_BPF_H_
41#define _NET_BPF_H_38#define _NET_BPF_H_
4239
40#include <sys/types.h>
43#include <sys/_eventhandler.h>41#include <sys/_eventhandler.h>
44#include <sys/ck.h>42#include <sys/ck.h>
45#include <net/dlt.h>43#include <net/dlt.h>
...@@ -431,6 +429,7 @@ void bpfdetach(struct ifnet *);...@@ -431,6 +429,7 @@ void bpfdetach(struct ifnet *);
431bool bpf_peers_present_if(struct ifnet *);429bool bpf_peers_present_if(struct ifnet *);
432#ifdef VIMAGE430#ifdef VIMAGE
433int bpf_get_bp_params(struct bpf_if *, u_int *, u_int *);431int bpf_get_bp_params(struct bpf_if *, u_int *, u_int *);
432void bpf_ifdetach(struct ifnet *);
434#endif433#endif
435434
436void bpfilterattach(int);435void bpfilterattach(int);
lib/libc/include/generic-freebsd/net/bpfdesc.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93
37 */35 */
3836
39#ifndef _NET_BPFDESC_H_37#ifndef _NET_BPFDESC_H_
lib/libc/include/generic-freebsd/net/dlt.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)bpf.h 7.1 (Berkeley) 5/7/91
35 */33 */
3634
37#ifndef _NET_DLT_H_35#ifndef _NET_DLT_H_
lib/libc/include/generic-freebsd/net/ethernet.h+28-1
...@@ -40,7 +40,6 @@...@@ -40,7 +40,6 @@
40/*40/*
41 * Ethernet-specific mbuf flags.41 * Ethernet-specific mbuf flags.
42 */42 */
43#define M_HASFCS M_PROTO5 /* FCS included at end of frame */
44#define M_BRIDGE_INJECT M_PROTO6 /* if_bridge-injected frame */43#define M_BRIDGE_INJECT M_PROTO6 /* if_bridge-injected frame */
4544
46/*45/*
...@@ -63,6 +62,8 @@ struct ether_header {...@@ -63,6 +62,8 @@ struct ether_header {
63 u_char ether_shost[ETHER_ADDR_LEN];62 u_char ether_shost[ETHER_ADDR_LEN];
64 u_short ether_type;63 u_short ether_type;
65} __packed;64} __packed;
65_Static_assert(sizeof(struct ether_header) == ETHER_HDR_LEN,
66 "size of struct ether_header is wrong");
6667
67/*68/*
68 * Structure of a 48-bit Ethernet address.69 * Structure of a 48-bit Ethernet address.
...@@ -70,6 +71,8 @@ struct ether_header {...@@ -70,6 +71,8 @@ struct ether_header {
70struct ether_addr {71struct ether_addr {
71 u_char octet[ETHER_ADDR_LEN];72 u_char octet[ETHER_ADDR_LEN];
72} __packed;73} __packed;
74_Static_assert(sizeof(struct ether_addr) == ETHER_ADDR_LEN,
75 "size of struct ether_addr is wrong");
7376
74#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */77#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
75#define ETHER_IS_IPV6_MULTICAST(addr) \78#define ETHER_IS_IPV6_MULTICAST(addr) \
...@@ -81,6 +84,28 @@ struct ether_addr {...@@ -81,6 +84,28 @@ struct ether_addr {
81 (((addr)[0] | (addr)[1] | (addr)[2] | \84 (((addr)[0] | (addr)[1] | (addr)[2] | \
82 (addr)[3] | (addr)[4] | (addr)[5]) == 0x00)85 (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
84/*109/*
85 * 802.1q Virtual LAN header.110 * 802.1q Virtual LAN header.
86 */111 */
...@@ -91,6 +116,8 @@ struct ether_vlan_header {...@@ -91,6 +116,8 @@ struct ether_vlan_header {
91 uint16_t evl_tag;116 uint16_t evl_tag;
92 uint16_t evl_proto;117 uint16_t evl_proto;
93} __packed;118} __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
95#define EVL_VLID_MASK 0x0FFF122#define EVL_VLID_MASK 0x0FFF
96#define EVL_PRI_MASK 0xE000123#define EVL_PRI_MASK 0xE000
lib/libc/include/generic-freebsd/net/if.h+3-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)if.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IF_H_32#ifndef _NET_IF_H_
...@@ -257,7 +255,8 @@ struct if_data {...@@ -257,7 +255,8 @@ struct if_data {
257#define IFCAP_B_TXTLS_RTLMT 31 /* can do TLS with rate limiting */255#define IFCAP_B_TXTLS_RTLMT 31 /* can do TLS with rate limiting */
258#define IFCAP_B_RXTLS4 32 /* can to TLS receive for TCP */256#define IFCAP_B_RXTLS4 32 /* can to TLS receive for TCP */
259#define IFCAP_B_RXTLS6 33 /* can to TLS receive for TCP6 */257#define IFCAP_B_RXTLS6 33 /* can to TLS receive for TCP6 */
260#define __IFCAP_B_SIZE 34258#define IFCAP_B_IPSEC_OFFLOAD 34 /* inline IPSEC offload */
259#define __IFCAP_B_SIZE 35
261260
262#define IFCAP_B_MAX (__IFCAP_B_MAX - 1)261#define IFCAP_B_MAX (__IFCAP_B_MAX - 1)
263#define IFCAP_B_SIZE (__IFCAP_B_SIZE)262#define IFCAP_B_SIZE (__IFCAP_B_SIZE)
...@@ -300,6 +299,7 @@ struct if_data {...@@ -300,6 +299,7 @@ struct if_data {
300/* IFCAP2_* are integers, not bits. */299/* IFCAP2_* are integers, not bits. */
301#define IFCAP2_RXTLS4 (IFCAP_B_RXTLS4 - 32)300#define IFCAP2_RXTLS4 (IFCAP_B_RXTLS4 - 32)
302#define IFCAP2_RXTLS6 (IFCAP_B_RXTLS6 - 32)301#define IFCAP2_RXTLS6 (IFCAP_B_RXTLS6 - 32)
302#define IFCAP2_IPSEC_OFFLOAD (IFCAP_B_IPSEC_OFFLOAD - 32)
303303
304#define IFCAP2_BIT(x) (1UL << (x))304#define IFCAP2_BIT(x) (1UL << (x))
305305
lib/libc/include/generic-freebsd/net/if_arp.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)if_arp.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IF_ARP_H_32#ifndef _NET_IF_ARP_H_
lib/libc/include/generic-freebsd/net/if_bridgevar.h+58-5
...@@ -74,7 +74,12 @@...@@ -74,7 +74,12 @@
74 * Data structure and control definitions for bridge interfaces.74 * Data structure and control definitions for bridge interfaces.
75 */75 */
7676
77#ifndef _NET_IF_BRIDGEVAR_H_
78#define _NET_IF_BRIDGEVAR_H_
79
77#include <sys/types.h>80#include <sys/types.h>
81#include <sys/_bitset.h>
82#include <sys/bitset.h>
78#include <sys/callout.h>83#include <sys/callout.h>
79#include <sys/queue.h>84#include <sys/queue.h>
80#include <sys/condvar.h>85#include <sys/condvar.h>
...@@ -119,6 +124,22 @@...@@ -119,6 +124,22 @@
119#define BRDGSPROTO 28 /* set protocol (ifbrparam) */124#define BRDGSPROTO 28 /* set protocol (ifbrparam) */
120#define BRDGSTXHC 29 /* set tx hold count (ifbrparam) */125#define BRDGSTXHC 29 /* set tx hold count (ifbrparam) */
121#define BRDGSIFAMAX 30 /* set max interface addrs (ifbreq) */126#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
123/*144/*
124 * Generic bridge control request.145 * Generic bridge control request.
...@@ -136,7 +157,9 @@ struct ifbreq {...@@ -136,7 +157,9 @@ struct ifbreq {
136 uint32_t ifbr_addrcnt; /* member if addr number */157 uint32_t ifbr_addrcnt; /* member if addr number */
137 uint32_t ifbr_addrmax; /* member if addr max */158 uint32_t ifbr_addrmax; /* member if addr max */
138 uint32_t ifbr_addrexceeded; /* member if addr violations */159 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];
140};163};
141164
142/* BRDGGIFFLAGS, BRDGSIFFLAGS */165/* BRDGGIFFLAGS, BRDGSIFFLAGS */
...@@ -152,10 +175,11 @@ struct ifbreq {...@@ -152,10 +175,11 @@ struct ifbreq {
152#define IFBIF_BSTP_ADMEDGE 0x0200 /* member stp admin edge enabled */175#define IFBIF_BSTP_ADMEDGE 0x0200 /* member stp admin edge enabled */
153#define IFBIF_BSTP_ADMCOST 0x0400 /* member stp admin path cost */176#define IFBIF_BSTP_ADMCOST 0x0400 /* member stp admin path cost */
154#define IFBIF_PRIVATE 0x0800 /* if is a private segment */177#define IFBIF_PRIVATE 0x0800 /* if is a private segment */
178#define IFBIF_QINQ 0x1000 /* if allows 802.1ad Q-in-Q */
155179
156#define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \180#define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \
157 "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \181 "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \
158 "\011AUTOPTP"182 "\011AUTOPTP\015QINQ"
159#define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \183#define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \
160 IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \184 IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \
161 IFBIF_BSTP_ADMCOST) /* not saved */185 IFBIF_BSTP_ADMCOST) /* not saved */
...@@ -185,7 +209,7 @@ struct ifbareq {...@@ -185,7 +209,7 @@ struct ifbareq {
185 unsigned long ifba_expire; /* address expire time */209 unsigned long ifba_expire; /* address expire time */
186 uint8_t ifba_flags; /* address flags */210 uint8_t ifba_flags; /* address flags */
187 uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */211 uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */
188 uint16_t ifba_vlan; /* vlan id */212 ether_vlanid_t ifba_vlan; /* vlan id */
189};213};
190214
191#define IFBAF_TYPEMASK 0x03 /* address type mask */215#define IFBAF_TYPEMASK 0x03 /* address type mask */
...@@ -227,7 +251,11 @@ struct ifbrparam {...@@ -227,7 +251,11 @@ struct ifbrparam {
227#define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */251#define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */
228#define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */252#define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */
229#define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32 /* # of cache dropped253#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
231/*259/*
232 * Bridge current operational parameters structure.260 * Bridge current operational parameters structure.
233 */261 */
...@@ -301,6 +329,26 @@ struct ifbpstpconf {...@@ -301,6 +329,26 @@ struct ifbpstpconf {
301 eaddr[5] = pv >> 0; \329 eaddr[5] = pv >> 0; \
302} while (0)330} 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
304#ifdef _KERNEL352#ifdef _KERNEL
305353
306#define BRIDGE_INPUT(_ifp, _m) do { \354#define BRIDGE_INPUT(_ifp, _m) do { \
...@@ -320,5 +368,10 @@ struct ifbpstpconf {...@@ -320,5 +368,10 @@ struct ifbpstpconf {
320} while (0)368} while (0)
321369
322extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *);370extern 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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IF_CLONE_H_32#ifndef _NET_IF_CLONE_H_
...@@ -150,13 +148,12 @@ typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);...@@ -150,13 +148,12 @@ typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);
150EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);148EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
151149
152/* The below interfaces used only by net/if.c. */150/* The below interfaces used only by net/if.c. */
153void vnet_if_clone_init(void);
154int if_clone_create(char *, size_t, caddr_t);151int if_clone_create(char *, size_t, caddr_t);
155int if_clone_destroy(const char *);152int if_clone_destroy(const char *);
156int if_clone_list(struct if_clonereq *);153int if_clone_list(struct if_clonereq *);
157void if_clone_restoregroup(struct ifnet *);154void 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). */
160void if_clone_addif(struct if_clone *, struct ifnet *);157void if_clone_addif(struct if_clone *, struct ifnet *);
161int if_clone_destroyif(struct if_clone *, struct ifnet *);158int if_clone_destroyif(struct if_clone *, struct ifnet *);
162159
lib/libc/include/generic-freebsd/net/if_dl.h+11-8
...@@ -27,13 +27,13 @@...@@ -27,13 +27,13 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)if_dl.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IF_DL_H_32#ifndef _NET_IF_DL_H_
35#define _NET_IF_DL_H_33#define _NET_IF_DL_H_
3634
35#include <sys/_types.h>
36
37/*37/*
38 * A Link-Level Sockaddr may specify the interface in one of two38 * A Link-Level Sockaddr may specify the interface in one of two
39 * ways: either by means of a system-provided index number (computed39 * ways: either by means of a system-provided index number (computed
...@@ -67,22 +67,25 @@ struct sockaddr_dl {...@@ -67,22 +67,25 @@ struct sockaddr_dl {
67 contains both if name and ll address */67 contains both if name and ll address */
68};68};
6969
70#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))70#define LLADDR(s) (&(s)->sdl_data[(s)->sdl_nlen])
71#define CLLADDR(s) ((c_caddr_t)((s)->sdl_data + (s)->sdl_nlen))
72#define LLINDEX(s) ((s)->sdl_index)71#define LLINDEX(s) ((s)->sdl_index)
7372
73#ifdef _KERNEL
74
74struct ifnet;75struct ifnet;
75struct sockaddr_dl *link_alloc_sdl(size_t, int);76struct sockaddr_dl *link_alloc_sdl(size_t size, int flags);
76void link_free_sdl(struct sockaddr *sa);77void 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 _KERNEL81#else /* !_KERNEL */
8082
81#include <sys/cdefs.h>83#include <sys/cdefs.h>
8284
83__BEGIN_DECLS85__BEGIN_DECLS
84void link_addr(const char *, struct sockaddr_dl *);86int link_addr(const char *, struct sockaddr_dl *);
85char *link_ntoa(const struct sockaddr_dl *);87char *link_ntoa(const struct sockaddr_dl *);
88int link_ntoa_r(const struct sockaddr_dl *, char *, size_t *);
86__END_DECLS89__END_DECLS
8790
88#endif /* !_KERNEL */91#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);...@@ -120,7 +120,8 @@ int in6_gif_setopts(struct gif_softc *, u_int);
120#define GIFGOPTS _IOWR('i', 150, struct ifreq)120#define GIFGOPTS _IOWR('i', 150, struct ifreq)
121#define GIFSOPTS _IOW('i', 151, struct ifreq)121#define GIFSOPTS _IOW('i', 151, struct ifreq)
122122
123#define GIF_NOCLAMP 0x0001
123#define GIF_IGNORE_SOURCE 0x0002124#define GIF_IGNORE_SOURCE 0x0002
124#define GIF_OPTMASK (GIF_IGNORE_SOURCE)125#define GIF_OPTMASK (GIF_NOCLAMP|GIF_IGNORE_SOURCE)
125126
126#endif /* _NET_IF_GIF_H_ */127#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 @@...@@ -29,8 +29,6 @@
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29 * 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 OF30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.31 * SUCH DAMAGE.
32 *
33 * @(#)if_llc.h 8.1 (Berkeley) 6/10/93
34 */32 */
3533
36#ifndef _NET_IF_LLC_H_34#ifndef _NET_IF_LLC_H_
lib/libc/include/generic-freebsd/net/if_media.h+6
...@@ -258,6 +258,8 @@ uint64_t ifmedia_baudrate(int);...@@ -258,6 +258,8 @@ uint64_t ifmedia_baudrate(int);
258#define IFM_400G_AUI8 IFM_X(117) /* 400G-AUI8 */258#define IFM_400G_AUI8 IFM_X(117) /* 400G-AUI8 */
259#define IFM_50G_KR4 IFM_X(118) /* 50GBase-KR4 */259#define IFM_50G_KR4 IFM_X(118) /* 50GBase-KR4 */
260#define IFM_40G_LM4 IFM_X(119) /* 40GBase-LM4 */260#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
262/*264/*
263 * Please update ieee8023ad_lacp.c:lacp_compose_key()265 * Please update ieee8023ad_lacp.c:lacp_compose_key()
...@@ -437,11 +439,13 @@ struct ifmedia_description {...@@ -437,11 +439,13 @@ struct ifmedia_description {
437 { IFM_100_T4, "100baseT4" }, \439 { IFM_100_T4, "100baseT4" }, \
438 { IFM_100_VG, "100baseVG" }, \440 { IFM_100_VG, "100baseVG" }, \
439 { IFM_100_T2, "100baseT2" }, \441 { IFM_100_T2, "100baseT2" }, \
442 { IFM_100_BX, "100baseBX" }, \
440 { IFM_10_STP, "10baseSTP" }, \443 { IFM_10_STP, "10baseSTP" }, \
441 { IFM_10_FL, "10baseFL" }, \444 { IFM_10_FL, "10baseFL" }, \
442 { IFM_1000_SX, "1000baseSX" }, \445 { IFM_1000_SX, "1000baseSX" }, \
443 { IFM_1000_LX, "1000baseLX" }, \446 { IFM_1000_LX, "1000baseLX" }, \
444 { IFM_1000_CX, "1000baseCX" }, \447 { IFM_1000_CX, "1000baseCX" }, \
448 { IFM_1000_BX, "1000baseBX" }, \
445 { IFM_1000_T, "1000baseT" }, \449 { IFM_1000_T, "1000baseT" }, \
446 { IFM_HPNA_1, "homePNA" }, \450 { IFM_HPNA_1, "homePNA" }, \
447 { IFM_10G_LR, "10Gbase-LR" }, \451 { IFM_10G_LR, "10Gbase-LR" }, \
...@@ -784,11 +788,13 @@ struct ifmedia_baudrate {...@@ -784,11 +788,13 @@ struct ifmedia_baudrate {
784 { IFM_ETHER | IFM_100_T4, IF_Mbps(100) }, \788 { IFM_ETHER | IFM_100_T4, IF_Mbps(100) }, \
785 { IFM_ETHER | IFM_100_VG, IF_Mbps(100) }, \789 { IFM_ETHER | IFM_100_VG, IF_Mbps(100) }, \
786 { IFM_ETHER | IFM_100_T2, IF_Mbps(100) }, \790 { IFM_ETHER | IFM_100_T2, IF_Mbps(100) }, \
791 { IFM_ETHER | IFM_100_BX, IF_Mbps(100) }, \
787 { IFM_ETHER | IFM_1000_SX, IF_Mbps(1000) }, \792 { IFM_ETHER | IFM_1000_SX, IF_Mbps(1000) }, \
788 { IFM_ETHER | IFM_10_STP, IF_Mbps(10) }, \793 { IFM_ETHER | IFM_10_STP, IF_Mbps(10) }, \
789 { IFM_ETHER | IFM_10_FL, IF_Mbps(10) }, \794 { IFM_ETHER | IFM_10_FL, IF_Mbps(10) }, \
790 { IFM_ETHER | IFM_1000_LX, IF_Mbps(1000) }, \795 { IFM_ETHER | IFM_1000_LX, IF_Mbps(1000) }, \
791 { IFM_ETHER | IFM_1000_CX, IF_Mbps(1000) }, \796 { IFM_ETHER | IFM_1000_CX, IF_Mbps(1000) }, \
797 { IFM_ETHER | IFM_1000_BX, IF_Mbps(1000) }, \
792 { IFM_ETHER | IFM_1000_T, IF_Mbps(1000) }, \798 { IFM_ETHER | IFM_1000_T, IF_Mbps(1000) }, \
793 { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \799 { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \
794 { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \800 { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \
lib/libc/include/generic-freebsd/net/if_ovpn.h+1
...@@ -37,6 +37,7 @@...@@ -37,6 +37,7 @@
37enum ovpn_notif_type {37enum ovpn_notif_type {
38 OVPN_NOTIF_DEL_PEER,38 OVPN_NOTIF_DEL_PEER,
39 OVPN_NOTIF_ROTATE_KEY,39 OVPN_NOTIF_ROTATE_KEY,
40 OVPN_NOTIF_FLOAT,
40};41};
4142
42enum ovpn_del_reason {43enum ovpn_del_reason {
lib/libc/include/generic-freebsd/net/if_pflog.h+5-5
...@@ -33,8 +33,6 @@...@@ -33,8 +33,6 @@
3333
34#include <net/if.h>34#include <net/if.h>
3535
36#define PFLOGIFS_MAX 16
37
38#define PFLOG_RULESET_NAME_SIZE 1636#define PFLOG_RULESET_NAME_SIZE 16
3937
40struct pfloghdr {38struct pfloghdr {
...@@ -51,7 +49,9 @@ struct pfloghdr {...@@ -51,7 +49,9 @@ struct pfloghdr {
51 uid_t rule_uid;49 uid_t rule_uid;
52 pid_t rule_pid;50 pid_t rule_pid;
53 u_int8_t dir;51 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];
55 u_int32_t ridentifier;55 u_int32_t ridentifier;
56 u_int8_t reserve; /* Appease broken software like Wireshark. */56 u_int8_t reserve; /* Appease broken software like Wireshark. */
57 u_int8_t pad2[3];57 u_int8_t pad2[3];
...@@ -69,9 +69,9 @@ struct pf_ruleset;...@@ -69,9 +69,9 @@ struct pf_ruleset;
69struct pfi_kif;69struct pfi_kif;
70struct pf_pdesc;70struct 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 { \
73 if (pflog_packet_ptr != NULL) \73 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); \
75} while (0)75} while (0)
76#endif /* _KERNEL */76#endif /* _KERNEL */
77#endif /* _NET_IF_PFLOG_H_ */77#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 {...@@ -62,9 +62,10 @@ enum pfsync_msg_versions {
62 PFSYNC_MSG_VERSION_UNSPECIFIED = 0,62 PFSYNC_MSG_VERSION_UNSPECIFIED = 0,
63 PFSYNC_MSG_VERSION_1301 = 1301,63 PFSYNC_MSG_VERSION_1301 = 1301,
64 PFSYNC_MSG_VERSION_1400 = 1400,64 PFSYNC_MSG_VERSION_1400 = 1400,
65 PFSYNC_MSG_VERSION_1500 = 1500,
65};66};
6667
67#define PFSYNC_MSG_VERSION_DEFAULT PFSYNC_MSG_VERSION_140068#define PFSYNC_MSG_VERSION_DEFAULT PFSYNC_MSG_VERSION_1500
6869
69#define PFSYNC_ACT_CLR 0 /* clear all states */70#define PFSYNC_ACT_CLR 0 /* clear all states */
70#define PFSYNC_ACT_INS_1301 1 /* insert state */71#define PFSYNC_ACT_INS_1301 1 /* insert state */
...@@ -81,7 +82,9 @@ enum pfsync_msg_versions {...@@ -81,7 +82,9 @@ enum pfsync_msg_versions {
81#define PFSYNC_ACT_EOF 12 /* end of frame */82#define PFSYNC_ACT_EOF 12 /* end of frame */
82#define PFSYNC_ACT_INS_1400 13 /* insert state */83#define PFSYNC_ACT_INS_1400 13 /* insert state */
83#define PFSYNC_ACT_UPD_1400 14 /* update state */84#define PFSYNC_ACT_UPD_1400 14 /* update state */
84#define PFSYNC_ACT_MAX 1585#define PFSYNC_ACT_INS_1500 15 /* insert state */
86#define PFSYNC_ACT_UPD_1500 16 /* update state */
87#define PFSYNC_ACT_MAX 17
8588
86/*89/*
87 * A pfsync frame is built from a header followed by several sections which90 * A pfsync frame is built from a header followed by several sections which
...@@ -160,8 +163,8 @@ struct pfsync_ins_ack {...@@ -160,8 +163,8 @@ struct pfsync_ins_ack {
160163
161struct pfsync_upd_c {164struct pfsync_upd_c {
162 u_int64_t id;165 u_int64_t id;
163 struct pfsync_state_peer src;166 struct pf_state_peer_export src;
164 struct pfsync_state_peer dst;167 struct pf_state_peer_export dst;
165 u_int32_t creatorid;168 u_int32_t creatorid;
166 u_int32_t expire;169 u_int32_t expire;
167 u_int8_t timeout;170 u_int8_t timeout;
lib/libc/include/generic-freebsd/net/if_private.h+2-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IF_PRIVATE_H_32#ifndef _NET_IF_PRIVATE_H_
...@@ -140,6 +138,8 @@ struct ifnet {...@@ -140,6 +138,8 @@ struct ifnet {
140 int (*if_requestencap) /* make link header from request */138 int (*if_requestencap) /* make link header from request */
141 (struct ifnet *, struct if_encap_req *);139 (struct ifnet *, struct if_encap_req *);
142140
141 const struct if_ipsec_accel_methods *if_ipsec_accel_m;
142
143 /* Statistics. */143 /* Statistics. */
144 counter_u64_t if_counters[IFCOUNTERS];144 counter_u64_t if_counters[IFCOUNTERS];
145145
lib/libc/include/generic-freebsd/net/if_strings.h+5
...@@ -60,10 +60,13 @@...@@ -60,10 +60,13 @@
60#define IFCAP_TXTLS_RTLMT_NAME "TXTLS_RTLMT"60#define IFCAP_TXTLS_RTLMT_NAME "TXTLS_RTLMT"
61#define IFCAP_RXTLS4_NAME "RXTLS4"61#define IFCAP_RXTLS4_NAME "RXTLS4"
62#define IFCAP_RXTLS6_NAME "RXTLS6"62#define IFCAP_RXTLS6_NAME "RXTLS6"
63#define IFCAP_IPSEC_OFFLOAD_NAME "IPSEC"
6364
64#define IFCAP2_RXTLS4_NAME IFCAP_RXTLS4_NAME65#define IFCAP2_RXTLS4_NAME IFCAP_RXTLS4_NAME
65#define IFCAP2_RXTLS6_NAME IFCAP_RXTLS6_NAME66#define IFCAP2_RXTLS6_NAME IFCAP_RXTLS6_NAME
67#define IFCAP2_IPSEC_OFFLOAD_NAME IFCAP_IPSEC_OFFLOAD_NAME
6668
69#ifdef _WANT_IFCAP_BIT_NAMES
67static const char *ifcap_bit_names[] = {70static const char *ifcap_bit_names[] = {
68 IFCAP_RXCSUM_NAME,71 IFCAP_RXCSUM_NAME,
69 IFCAP_TXCSUM_NAME,72 IFCAP_TXCSUM_NAME,
...@@ -99,11 +102,13 @@ static const char *ifcap_bit_names[] = {...@@ -99,11 +102,13 @@ static const char *ifcap_bit_names[] = {
99 IFCAP_TXTLS_RTLMT_NAME,102 IFCAP_TXTLS_RTLMT_NAME,
100 IFCAP_RXTLS4_NAME,103 IFCAP_RXTLS4_NAME,
101 IFCAP_RXTLS6_NAME,104 IFCAP_RXTLS6_NAME,
105 IFCAP_IPSEC_OFFLOAD_NAME,
102};106};
103107
104#ifdef IFCAP_B_SIZE108#ifdef IFCAP_B_SIZE
105_Static_assert(sizeof(ifcap_bit_names) >= IFCAP_B_SIZE * sizeof(char *),109_Static_assert(sizeof(ifcap_bit_names) >= IFCAP_B_SIZE * sizeof(char *),
106 "ifcap bit names missing from ifcap_bit_names");110 "ifcap bit names missing from ifcap_bit_names");
107#endif111#endif
112#endif
108113
109#endif114#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/net/if_tap.h+2
...@@ -57,6 +57,8 @@...@@ -57,6 +57,8 @@
57#define TAPGIFNAME TUNGIFNAME57#define TAPGIFNAME TUNGIFNAME
58#define TAPSVNETHDR _IOW('t', 91, int)58#define TAPSVNETHDR _IOW('t', 91, int)
59#define TAPGVNETHDR _IOR('t', 94, int)59#define TAPGVNETHDR _IOR('t', 94, int)
60#define TAPSTRANSIENT TUNSTRANSIENT
61#define TAPGTRANSIENT TUNGTRANSIENT
6062
61/* VMware ioctl's */63/* VMware ioctl's */
62#define VMIO_SIOCSIFFLAGS _IOWINT('V', 0)64#define VMIO_SIOCSIFFLAGS _IOWINT('V', 0)
lib/libc/include/generic-freebsd/net/if_tun.h+2
...@@ -43,5 +43,7 @@ struct tuninfo {...@@ -43,5 +43,7 @@ struct tuninfo {
43#define TUNSIFPID _IO('t', 95)43#define TUNSIFPID _IO('t', 95)
44#define TUNSIFHEAD _IOW('t', 96, int)44#define TUNSIFHEAD _IOW('t', 96, int)
45#define TUNGIFHEAD _IOR('t', 97, int)45#define TUNGIFHEAD _IOR('t', 97, int)
46#define TUNSTRANSIENT _IOW('t', 98, int)
47#define TUNGTRANSIENT _IOR('t', 99, int)
4648
47#endif /* !_NET_IF_TUN_H_ */49#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)if_types.h 8.3 (Berkeley) 4/28/95
32 * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $30 * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $
33 */31 */
3432
...@@ -256,6 +254,7 @@ typedef enum {...@@ -256,6 +254,7 @@ typedef enum {
256 IFT_PFLOG = 0xf6, /* PF packet filter logging */254 IFT_PFLOG = 0xf6, /* PF packet filter logging */
257 IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */255 IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */
258 IFT_WIREGUARD = 0xf8, /* WireGuard tunnel */256 IFT_WIREGUARD = 0xf8, /* WireGuard tunnel */
257 IFT_MBIM = 0xf9, /* Mobile Broadband Interface Model */
259} ifType;258} ifType;
260259
261/*260/*
lib/libc/include/generic-freebsd/net/if_var.h+37-6
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IF_VAR_H_32#ifndef _NET_IF_VAR_H_
...@@ -133,6 +131,25 @@ typedef void (*if_qflush_fn_t)(if_t);...@@ -133,6 +131,25 @@ typedef void (*if_qflush_fn_t)(if_t);
133typedef int (*if_transmit_fn_t)(if_t, struct mbuf *);131typedef int (*if_transmit_fn_t)(if_t, struct mbuf *);
134typedef uint64_t (*if_get_counter_t)(if_t, ift_counter);132typedef uint64_t (*if_get_counter_t)(if_t, ift_counter);
135typedef void (*if_reassign_fn_t)(if_t, struct vnet *, char *);133typedef 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
137struct ifnet_hw_tsomax {154struct ifnet_hw_tsomax {
138 u_int tsomaxbytes; /* TSO total burst length limit in bytes */155 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...@@ -280,12 +297,14 @@ typedef int (if_snd_tag_modify_t)(struct m_snd_tag *, union if_snd_tag_modify_pa
280typedef int (if_snd_tag_query_t)(struct m_snd_tag *, union if_snd_tag_query_params *);297typedef int (if_snd_tag_query_t)(struct m_snd_tag *, union if_snd_tag_query_params *);
281typedef void (if_snd_tag_free_t)(struct m_snd_tag *);298typedef void (if_snd_tag_free_t)(struct m_snd_tag *);
282typedef struct m_snd_tag *(if_next_send_tag_t)(struct m_snd_tag *);299typedef 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
284struct if_snd_tag_sw {302struct if_snd_tag_sw {
285 if_snd_tag_modify_t *snd_tag_modify;303 if_snd_tag_modify_t *snd_tag_modify;
286 if_snd_tag_query_t *snd_tag_query;304 if_snd_tag_query_t *snd_tag_query;
287 if_snd_tag_free_t *snd_tag_free;305 if_snd_tag_free_t *snd_tag_free;
288 if_next_send_tag_t *next_snd_tag;306 if_next_send_tag_t *next_snd_tag;
307 if_snd_tag_status_str_t *snd_tag_status_str;
289 u_int type; /* One of IF_SND_TAG_TYPE_*. */308 u_int type; /* One of IF_SND_TAG_TYPE_*. */
290};309};
291310
...@@ -603,6 +622,7 @@ int if_setmtu(if_t ifp, int mtu);...@@ -603,6 +622,7 @@ int if_setmtu(if_t ifp, int mtu);
603int if_getmtu(const if_t ifp);622int if_getmtu(const if_t ifp);
604int if_getmtu_family(const if_t ifp, int family);623int if_getmtu_family(const if_t ifp, int family);
605void if_notifymtu(if_t ifp);624void if_notifymtu(if_t ifp);
625void if_setppromisc(const if_t ifp, bool ppromisc);
606int if_setflagbits(if_t ifp, int set, int clear);626int if_setflagbits(if_t ifp, int set, int clear);
607int if_setflags(if_t ifp, int flags);627int if_setflags(if_t ifp, int flags);
608int if_getflags(const if_t ifp);628int if_getflags(const if_t ifp);
...@@ -626,11 +646,9 @@ void if_setrcvif(struct mbuf *m, if_t ifp);...@@ -626,11 +646,9 @@ void if_setrcvif(struct mbuf *m, if_t ifp);
626void if_setvtag(struct mbuf *m, u_int16_t tag);646void if_setvtag(struct mbuf *m, u_int16_t tag);
627u_int16_t if_getvtag(struct mbuf *m);647u_int16_t if_getvtag(struct mbuf *m);
628int if_vlantrunkinuse(if_t ifp);648int if_vlantrunkinuse(if_t ifp);
629caddr_t if_getlladdr(const if_t ifp);649char *if_getlladdr(const if_t ifp);
630struct vnet *if_getvnet(const if_t ifp);650struct vnet *if_getvnet(const if_t ifp);
631void *if_gethandle(u_char);651void *if_gethandle(u_char);
632void if_bpfmtap(if_t ifp, struct mbuf *m);
633void if_etherbpfmtap(if_t ifp, struct mbuf *m);
634void if_vlancap(if_t ifp);652void if_vlancap(if_t ifp);
635int if_transmit(if_t ifp, struct mbuf *m);653int if_transmit(if_t ifp, struct mbuf *m);
636void if_init(if_t ifp, void *ctx);654void if_init(if_t ifp, void *ctx);
...@@ -703,6 +721,20 @@ void if_setdebugnet_methods(if_t, struct debugnet_methods *);...@@ -703,6 +721,20 @@ void if_setdebugnet_methods(if_t, struct debugnet_methods *);
703void if_setreassignfn(if_t ifp, if_reassign_fn_t);721void if_setreassignfn(if_t ifp, if_reassign_fn_t);
704void if_setratelimitqueryfn(if_t ifp, if_ratelimit_query_t);722void 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
706/* TSO */738/* TSO */
707void if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *);739void if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *);
708int if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsomax *);740int if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsomax *);
...@@ -724,7 +756,6 @@ int ether_poll_deregister(if_t ifp);...@@ -724,7 +756,6 @@ int ether_poll_deregister(if_t ifp);
724756
725#endif /* _KERNEL */757#endif /* _KERNEL */
726758
727#include <net/if_private.h> /* XXX: temporary until drivers converted. */
728#include <net/ifq.h> /* XXXAO: temporary unconditional include */759#include <net/ifq.h> /* XXXAO: temporary unconditional include */
729760
730#endif /* !_NET_IF_VAR_H_ */761#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 {...@@ -126,11 +126,6 @@ struct vlanreq {
126126
127#define VLAN_PCP_MAX 7127#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
134/*129/*
135 * 802.1q full tag. Proto and vid are stored in host byte order.130 * 802.1q full tag. Proto and vid are stored in host byte order.
136 */131 */
...@@ -166,6 +161,7 @@ extern int (*vlan_tag_p)(struct ifnet *, uint16_t *);...@@ -166,6 +161,7 @@ extern int (*vlan_tag_p)(struct ifnet *, uint16_t *);
166extern int (*vlan_pcp_p)(struct ifnet *, uint16_t *);161extern int (*vlan_pcp_p)(struct ifnet *, uint16_t *);
167extern int (*vlan_setcookie_p)(struct ifnet *, void *);162extern int (*vlan_setcookie_p)(struct ifnet *, void *);
168extern void *(*vlan_cookie_p)(struct ifnet *);163extern void *(*vlan_cookie_p)(struct ifnet *);
164extern void (*vlan_input_p)(struct ifnet *, struct mbuf *);
169165
170#include <sys/_eventhandler.h>166#include <sys/_eventhandler.h>
171167
lib/libc/include/generic-freebsd/net/iflib.h+6-6
...@@ -121,13 +121,13 @@ typedef struct if_pkt_info {...@@ -121,13 +121,13 @@ typedef struct if_pkt_info {
121 uint16_t ipi_tso_segsz; /* tso segment size */121 uint16_t ipi_tso_segsz; /* tso segment size */
122 uint16_t ipi_vtag; /* VLAN tag */122 uint16_t ipi_vtag; /* VLAN tag */
123 uint16_t ipi_etype; /* ether header type */123 uint16_t ipi_etype; /* ether header type */
124 uint8_t ipi_tcp_hflags; /* tcp header flags */124 uint16_t ipi_tcp_hflags; /* tcp header flags */
125 uint8_t ipi_mflags; /* packet mbuf flags */
126125
127 uint32_t ipi_tcp_seq; /* tcp seqno */126 uint32_t ipi_tcp_seq; /* tcp seqno */
128 uint8_t ipi_ip_tos; /* IP ToS field data */127 uint8_t ipi_ip_tos; /* IP ToS field data */
128 uint8_t ipi_mflags; /* packet mbuf flags */
129 uint8_t __spare0__;129 uint8_t __spare0__;
130 uint16_t __spare1__;130 uint8_t __spare1__;
131} *if_pkt_info_t;131} *if_pkt_info_t;
132132
133typedef struct if_irq {133typedef struct if_irq {
...@@ -470,9 +470,9 @@ void iflib_irq_free(if_ctx_t ctx, if_irq_t irq);...@@ -470,9 +470,9 @@ void iflib_irq_free(if_ctx_t ctx, if_irq_t irq);
470void iflib_io_tqg_attach(struct grouptask *gt, void *uniq, int cpu,470void iflib_io_tqg_attach(struct grouptask *gt, void *uniq, int cpu,
471 const char *name);471 const char *name);
472472
473void iflib_config_gtask_init(void *ctx, struct grouptask *gtask,473void iflib_config_task_init(if_ctx_t ctx, struct task *config_task,
474 gtask_fn_t *fn, const char *name);474 task_fn_t *fn);
475void iflib_config_gtask_deinit(struct grouptask *gtask);475void iflib_config_task_enqueue(if_ctx_t ctx, struct task *config_task);
476476
477void iflib_tx_intr_deferred(if_ctx_t ctx, int txqid);477void iflib_tx_intr_deferred(if_ctx_t ctx, int txqid);
478void iflib_rx_intr_deferred(if_ctx_t ctx, int rxqid);478void iflib_rx_intr_deferred(if_ctx_t ctx, int rxqid);
lib/libc/include/generic-freebsd/net/ifq.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NET_IFQ_H_32#ifndef _NET_IFQ_H_
lib/libc/include/generic-freebsd/net/pfkeyv2.h+15-5
...@@ -296,6 +296,13 @@ struct sadb_x_sa_replay {...@@ -296,6 +296,13 @@ struct sadb_x_sa_replay {
296};296};
297_Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");297_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
299#define SADB_EXT_RESERVED 0306#define SADB_EXT_RESERVED 0
300#define SADB_EXT_SA 1307#define SADB_EXT_SA 1
301#define SADB_EXT_LIFETIME_CURRENT 2308#define SADB_EXT_LIFETIME_CURRENT 2
...@@ -326,7 +333,10 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");...@@ -326,7 +333,10 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");
326#define SADB_X_EXT_SA_REPLAY 26 /* Replay window override. */333#define SADB_X_EXT_SA_REPLAY 26 /* Replay window override. */
327#define SADB_X_EXT_NEW_ADDRESS_SRC 27334#define SADB_X_EXT_NEW_ADDRESS_SRC 27
328#define SADB_X_EXT_NEW_ADDRESS_DST 28335#define SADB_X_EXT_NEW_ADDRESS_DST 28
329#define SADB_EXT_MAX 28336#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
331#define SADB_SATYPE_UNSPEC 0341#define SADB_SATYPE_UNSPEC 0
332#define SADB_SATYPE_AH 2342#define SADB_SATYPE_AH 2
...@@ -444,13 +454,13 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");...@@ -444,13 +454,13 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");
444/* Utilities */454/* Utilities */
445#define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1)))455#define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1)))
446#define PFKEY_EXTLEN(msg) \456#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)
448#define PFKEY_ADDR_PREFIX(ext) \458#define PFKEY_ADDR_PREFIX(ext) \
449 (((struct sadb_address *)(ext))->sadb_address_prefixlen)459 (((const struct sadb_address *)(ext))->sadb_address_prefixlen)
450#define PFKEY_ADDR_PROTO(ext) \460#define PFKEY_ADDR_PROTO(ext) \
451 (((struct sadb_address *)(ext))->sadb_address_proto)461 (((const struct sadb_address *)(ext))->sadb_address_proto)
452#define PFKEY_ADDR_SADDR(ext) \462#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
455/* in 64bits */465/* in 64bits */
456#define PFKEY_UNUNIT64(a) ((a) << 3)466#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 @@...@@ -70,6 +70,8 @@
7070
71#ifdef _KERNEL71#ifdef _KERNEL
7272
73#define PF_PFIL_NOREFRAGMENT 0x80000000
74
73#if defined(__arm__)75#if defined(__arm__)
74#define PF_WANT_32_TO_64_COUNTER76#define PF_WANT_32_TO_64_COUNTER
75#endif77#endif
...@@ -127,6 +129,14 @@ pf_counter_u64_critical_exit(void)...@@ -127,6 +129,14 @@ pf_counter_u64_critical_exit(void)
127 critical_exit();129 critical_exit();
128}130}
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
130static inline void140static inline void
131pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)141pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)
132{142{
...@@ -250,6 +260,13 @@ pf_counter_u64_critical_exit(void)...@@ -250,6 +260,13 @@ pf_counter_u64_critical_exit(void)
250260
251}261}
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
253static inline void270static inline void
254pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)271pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n)
255{272{
...@@ -309,10 +326,20 @@ pf_counter_u64_zero(struct pf_counter_u64 *pfcu64)...@@ -309,10 +326,20 @@ pf_counter_u64_zero(struct pf_counter_u64 *pfcu64)
309_Static_assert(sizeof(time_t) == 4 || sizeof(time_t) == 8, "unexpected time_t size");326_Static_assert(sizeof(time_t) == 4 || sizeof(time_t) == 8, "unexpected time_t size");
310327
311SYSCTL_DECL(_net_pf);328SYSCTL_DECL(_net_pf);
329MALLOC_DECLARE(M_PF);
312MALLOC_DECLARE(M_PFHASH);330MALLOC_DECLARE(M_PFHASH);
313MALLOC_DECLARE(M_PF_RULE_ITEM);331MALLOC_DECLARE(M_PF_RULE_ITEM);
314332
315SDT_PROVIDER_DECLARE(pf);333SDT_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
317struct pfi_dynaddr {344struct pfi_dynaddr {
318 TAILQ_ENTRY(pfi_dynaddr) entry;345 TAILQ_ENTRY(pfi_dynaddr) entry;
...@@ -329,14 +356,6 @@ struct pfi_dynaddr {...@@ -329,14 +356,6 @@ struct pfi_dynaddr {
329 u_int8_t pfid_iflags; /* PFI_AFLAG_* */356 u_int8_t pfid_iflags; /* PFI_AFLAG_* */
330};357};
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
340#define PF_NAME "pf"359#define PF_NAME "pf"
341360
342#define PF_HASHROW_ASSERT(h) mtx_assert(&(h)->lock, MA_OWNED)361#define PF_HASHROW_ASSERT(h) mtx_assert(&(h)->lock, MA_OWNED)
...@@ -433,6 +452,16 @@ VNET_DECLARE(struct rmlock, pf_rules_lock);...@@ -433,6 +452,16 @@ VNET_DECLARE(struct rmlock, pf_rules_lock);
433#define PF_RULES_RASSERT() rm_assert(&V_pf_rules_lock, RA_RLOCKED)452#define PF_RULES_RASSERT() rm_assert(&V_pf_rules_lock, RA_RLOCKED)
434#define PF_RULES_WASSERT() rm_assert(&V_pf_rules_lock, RA_WLOCKED)453#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
436extern struct mtx_padalign pf_table_stats_lock;465extern struct mtx_padalign pf_table_stats_lock;
437#define PF_TABLE_STATS_LOCK() mtx_lock(&pf_table_stats_lock)466#define PF_TABLE_STATS_LOCK() mtx_lock(&pf_table_stats_lock)
438#define PF_TABLE_STATS_UNLOCK() mtx_unlock(&pf_table_stats_lock)467#define PF_TABLE_STATS_UNLOCK() mtx_unlock(&pf_table_stats_lock)
...@@ -498,18 +527,6 @@ extern struct sx pf_end_lock;...@@ -498,18 +527,6 @@ extern struct sx pf_end_lock;
498 (c == AF_INET6 && !(a)->addr32[0] && !(a)->addr32[1] && \527 (c == AF_INET6 && !(a)->addr32[0] && !(a)->addr32[1] && \
499 !(a)->addr32[2] && !(a)->addr32[3] )) \528 !(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
513#else530#else
514531
515/* Just IPv6 */532/* Just IPv6 */
...@@ -534,18 +551,6 @@ extern struct sx pf_end_lock;...@@ -534,18 +551,6 @@ extern struct sx pf_end_lock;
534 !(a)->addr32[2] && \551 !(a)->addr32[2] && \
535 !(a)->addr32[3] ) \552 !(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
549#else554#else
550555
551/* Just IPv4 */556/* Just IPv4 */
...@@ -560,27 +565,34 @@ extern struct sx pf_end_lock;...@@ -560,27 +565,34 @@ extern struct sx pf_end_lock;
560#define PF_AZERO(a, c) \565#define PF_AZERO(a, c) \
561 (!(a)->addr32[0])566 (!(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
580#endif /* PF_INET_ONLY */568#endif /* PF_INET_ONLY */
581#endif /* PF_INET6_ONLY */569#endif /* PF_INET6_ONLY */
582#endif /* PF_INET_INET6 */570#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
584/*596/*
585 * XXX callers not FIB-aware in our version of pf yet.597 * XXX callers not FIB-aware in our version of pf yet.
586 * OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio.598 * OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio.
...@@ -600,19 +612,35 @@ extern struct sx pf_end_lock;...@@ -600,19 +612,35 @@ extern struct sx pf_end_lock;
600 &(aw)->v.a.mask, (x), (af))) || \612 &(aw)->v.a.mask, (x), (af))) || \
601 ((aw)->type == PF_ADDR_ADDRMASK && \613 ((aw)->type == PF_ADDR_ADDRMASK && \
602 !PF_AZERO(&(aw)->v.a.mask, (af)) && \614 !PF_AZERO(&(aw)->v.a.mask, (af)) && \
603 !PF_MATCHA(0, &(aw)->v.a.addr, \615 !pf_match_addr(0, &(aw)->v.a.addr, \
604 &(aw)->v.a.mask, (x), (af))))) != \616 &(aw)->v.a.mask, (x), (af))))) != \
605 (neg) \617 (neg) \
606 )618 )
607619
608#define PF_ALGNMNT(off) (((off) % 2) == 0)620#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
610#ifdef _KERNEL637#ifdef _KERNEL
611638
612struct pf_kpooladdr {639struct pf_kpooladdr {
613 struct pf_addr_wrap addr;640 struct pf_addr_wrap addr;
614 TAILQ_ENTRY(pf_kpooladdr) entries;641 TAILQ_ENTRY(pf_kpooladdr) entries;
615 char ifname[IFNAMSIZ];642 char ifname[IFNAMSIZ];
643 sa_family_t af;
616 struct pfi_kkif *kif;644 struct pfi_kkif *kif;
617};645};
618646
...@@ -628,20 +656,27 @@ struct pf_kpool {...@@ -628,20 +656,27 @@ struct pf_kpool {
628 int tblidx;656 int tblidx;
629 u_int16_t proxy_port[2];657 u_int16_t proxy_port[2];
630 u_int8_t opts;658 u_int8_t opts;
659 sa_family_t ipv6_nexthop_af;
631};660};
632661
633struct pf_rule_actions {662struct pf_rule_actions {
663 struct pf_addr rt_addr;
664 struct pfi_kkif *rt_kif;
634 int32_t rtableid;665 int32_t rtableid;
666 uint32_t flags;
635 uint16_t qid;667 uint16_t qid;
636 uint16_t pqid;668 uint16_t pqid;
637 uint16_t max_mss;669 uint16_t max_mss;
670 uint16_t dnpipe;
671 uint16_t dnrpipe; /* Reverse direction pipe */
672 sa_family_t rt_af;
638 uint8_t log;673 uint8_t log;
639 uint8_t set_tos;674 uint8_t set_tos;
640 uint8_t min_ttl;675 uint8_t min_ttl;
641 uint16_t dnpipe;
642 uint16_t dnrpipe; /* Reverse direction pipe */
643 uint32_t flags;
644 uint8_t set_prio[2];676 uint8_t set_prio[2];
677 uint8_t rt;
678 uint8_t allow_opts;
679 uint16_t max_pkt_size;
645};680};
646681
647union pf_keth_rule_ptr {682union pf_keth_rule_ptr {
...@@ -667,7 +702,6 @@ struct pf_keth_ruleset {...@@ -667,7 +702,6 @@ struct pf_keth_ruleset {
667 int open;702 int open;
668 uint32_t ticket;703 uint32_t ticket;
669 } active, inactive;704 } active, inactive;
670 struct epoch_context epoch_ctx;
671 struct vnet *vnet;705 struct vnet *vnet;
672 struct pf_keth_anchor *anchor;706 struct pf_keth_anchor *anchor;
673};707};
...@@ -746,9 +780,10 @@ struct pf_keth_rule {...@@ -746,9 +780,10 @@ struct pf_keth_rule {
746 uint32_t ridentifier;780 uint32_t ridentifier;
747};781};
748782
749union pf_krule_ptr {783struct pf_kthreshold {
750 struct pf_krule *ptr;784 uint32_t limit;
751 u_int32_t nr;785 uint32_t seconds;
786 struct counter_rate *cr;
752};787};
753788
754RB_HEAD(pf_krule_global, pf_krule);789RB_HEAD(pf_krule_global, pf_krule);
...@@ -757,10 +792,11 @@ RB_PROTOTYPE(pf_krule_global, pf_krule, entry_global, pf_krule_compare);...@@ -757,10 +792,11 @@ RB_PROTOTYPE(pf_krule_global, pf_krule, entry_global, pf_krule_compare);
757struct pf_krule {792struct pf_krule {
758 struct pf_rule_addr src;793 struct pf_rule_addr src;
759 struct pf_rule_addr dst;794 struct pf_rule_addr dst;
760 union pf_krule_ptr skip[PF_SKIP_COUNT];795 struct pf_krule *skip[PF_SKIP_COUNT];
761 char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE];796 char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE];
762 uint32_t ridentifier;797 uint32_t ridentifier;
763 char ifname[IFNAMSIZ];798 char ifname[IFNAMSIZ];
799 char rcv_ifname[IFNAMSIZ];
764 char qname[PF_QNAME_SIZE];800 char qname[PF_QNAME_SIZE];
765 char pqname[PF_QNAME_SIZE];801 char pqname[PF_QNAME_SIZE];
766 char tagname[PF_TAG_NAME_SIZE];802 char tagname[PF_TAG_NAME_SIZE];
...@@ -769,7 +805,10 @@ struct pf_krule {...@@ -769,7 +805,10 @@ struct pf_krule {
769 char overload_tblname[PF_TABLE_NAME_SIZE];805 char overload_tblname[PF_TABLE_NAME_SIZE];
770806
771 TAILQ_ENTRY(pf_krule) entries;807 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
774 struct pf_counter_u64 evaluations;813 struct pf_counter_u64 evaluations;
775 struct pf_counter_u64 packets[2];814 struct pf_counter_u64 packets[2];
...@@ -777,6 +816,7 @@ struct pf_krule {...@@ -777,6 +816,7 @@ struct pf_krule {
777 time_t *timestamp;816 time_t *timestamp;
778817
779 struct pfi_kkif *kif;818 struct pfi_kkif *kif;
819 struct pfi_kkif *rcv_kif;
780 struct pf_kanchor *anchor;820 struct pf_kanchor *anchor;
781 struct pfr_ktable *overload_tbl;821 struct pfr_ktable *overload_tbl;
782822
...@@ -792,6 +832,7 @@ struct pf_krule {...@@ -792,6 +832,7 @@ struct pf_krule {
792 u_int32_t limit;832 u_int32_t limit;
793 u_int32_t seconds;833 u_int32_t seconds;
794 } max_src_conn_rate;834 } max_src_conn_rate;
835 uint16_t max_pkt_size;
795 u_int16_t qid;836 u_int16_t qid;
796 u_int16_t pqid;837 u_int16_t pqid;
797 u_int16_t dnpipe;838 u_int16_t dnpipe;
...@@ -804,7 +845,7 @@ struct pf_krule {...@@ -804,7 +845,7 @@ struct pf_krule {
804845
805 counter_u64_t states_cur;846 counter_u64_t states_cur;
806 counter_u64_t states_tot;847 counter_u64_t states_tot;
807 counter_u64_t src_nodes;848 counter_u64_t src_nodes[PF_SN_MAX];
808849
809 u_int16_t return_icmp;850 u_int16_t return_icmp;
810 u_int16_t return_icmp6;851 u_int16_t return_icmp6;
...@@ -830,8 +871,8 @@ struct pf_krule {...@@ -830,8 +871,8 @@ struct pf_krule {
830 u_int8_t keep_state;871 u_int8_t keep_state;
831 sa_family_t af;872 sa_family_t af;
832 u_int8_t proto;873 u_int8_t proto;
833 u_int8_t type;874 uint16_t type;
834 u_int8_t code;875 uint16_t code;
835 u_int8_t flags;876 u_int8_t flags;
836 u_int8_t flagset;877 u_int8_t flagset;
837 u_int8_t min_ttl;878 u_int8_t min_ttl;
...@@ -846,6 +887,8 @@ struct pf_krule {...@@ -846,6 +887,8 @@ struct pf_krule {
846 u_int8_t flush;887 u_int8_t flush;
847 u_int8_t prio;888 u_int8_t prio;
848 u_int8_t set_prio[2];889 u_int8_t set_prio[2];
890 sa_family_t naf;
891 u_int8_t rcvifnot;
849892
850 struct {893 struct {
851 struct pf_addr addr;894 struct pf_addr addr;
...@@ -869,21 +912,23 @@ SLIST_HEAD(pf_krule_slist, pf_krule_item);...@@ -869,21 +912,23 @@ SLIST_HEAD(pf_krule_slist, pf_krule_item);
869912
870struct pf_ksrc_node {913struct pf_ksrc_node {
871 LIST_ENTRY(pf_ksrc_node) entry;914 LIST_ENTRY(pf_ksrc_node) entry;
872 struct pf_addr addr;915 struct pf_addr addr;
873 struct pf_addr raddr;916 struct pf_addr raddr;
874 struct pf_krule_slist match_rules;917 struct pf_krule_slist match_rules;
875 union pf_krule_ptr rule;918 struct pf_krule *rule;
876 struct pfi_kkif *rkif;919 struct pfi_kkif *rkif;
877 counter_u64_t bytes[2];920 counter_u64_t bytes[2];
878 counter_u64_t packets[2];921 counter_u64_t packets[2];
879 u_int32_t states;922 u_int32_t states;
880 u_int32_t conn;923 u_int32_t conn;
881 struct pf_threshold conn_rate;924 struct pf_kthreshold conn_rate;
882 u_int32_t creation;925 u_int32_t creation;
883 u_int32_t expire;926 u_int32_t expire;
884 sa_family_t af;927 sa_family_t af;
885 u_int8_t ruletype;928 sa_family_t raf;
886 struct mtx *lock;929 u_int8_t ruletype;
930 pf_sn_types_t type;
931 struct mtx *lock;
887};932};
888#endif933#endif
889934
...@@ -925,6 +970,29 @@ struct pf_state_peer {...@@ -925,6 +970,29 @@ struct pf_state_peer {
925 u_int8_t pad[1];970 u_int8_t pad[1];
926};971};
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
928/* Keep synced with struct pf_state_key. */996/* Keep synced with struct pf_state_key. */
929struct pf_state_key_cmp {997struct pf_state_key_cmp {
930 struct pf_addr addr[2];998 struct pf_addr addr[2];
...@@ -945,6 +1013,11 @@ struct pf_state_key {...@@ -945,6 +1013,11 @@ struct pf_state_key {
945 TAILQ_HEAD(, pf_kstate) states[2];1013 TAILQ_HEAD(, pf_kstate) states[2];
946};1014};
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
948/* Keep synced with struct pf_kstate. */1021/* Keep synced with struct pf_kstate. */
949struct pf_state_cmp {1022struct pf_state_cmp {
950 u_int64_t id;1023 u_int64_t id;
...@@ -959,7 +1032,7 @@ struct pf_state_scrub_export {...@@ -959,7 +1032,7 @@ struct pf_state_scrub_export {
959#define PF_SCRUB_FLAG_VALID 0x011032#define PF_SCRUB_FLAG_VALID 0x01
960 uint8_t scrub_flag;1033 uint8_t scrub_flag;
961 uint32_t pfss_ts_mod; /* timestamp modulation */1034 uint32_t pfss_ts_mod; /* timestamp modulation */
962};1035} __packed;
9631036
964struct pf_state_key_export {1037struct pf_state_key_export {
965 struct pf_addr addr[2];1038 struct pf_addr addr[2];
...@@ -976,7 +1049,7 @@ struct pf_state_peer_export {...@@ -976,7 +1049,7 @@ struct pf_state_peer_export {
976 uint8_t state; /* active state level */1049 uint8_t state; /* active state level */
977 uint8_t wscale; /* window scaling factor */1050 uint8_t wscale; /* window scaling factor */
978 uint8_t dummy[6];1051 uint8_t dummy[6];
979};1052} __packed;
980_Static_assert(sizeof(struct pf_state_peer_export) == 32, "size incorrect");1053_Static_assert(sizeof(struct pf_state_peer_export) == 32, "size incorrect");
9811054
982struct pf_state_export {1055struct pf_state_export {
...@@ -1040,7 +1113,7 @@ struct pf_kstate {...@@ -1040,7 +1113,7 @@ struct pf_kstate {
1040 u_int16_t state_flags;1113 u_int16_t state_flags;
1041 u_int8_t timeout;1114 u_int8_t timeout;
1042 u_int8_t sync_state; /* PFSYNC_S_x */1115 u_int8_t sync_state; /* PFSYNC_S_x */
1043 u_int8_t sync_updates; /* XXX */1116 u_int8_t sync_updates;
1044 u_int refs;1117 u_int refs;
1045 struct mtx *lock;1118 struct mtx *lock;
1046 TAILQ_ENTRY(pf_kstate) sync_list;1119 TAILQ_ENTRY(pf_kstate) sync_list;
...@@ -1049,56 +1122,74 @@ struct pf_kstate {...@@ -1049,56 +1122,74 @@ struct pf_kstate {
1049 struct pf_state_peer src;1122 struct pf_state_peer src;
1050 struct pf_state_peer dst;1123 struct pf_state_peer dst;
1051 struct pf_krule_slist match_rules;1124 struct pf_krule_slist match_rules;
1052 union pf_krule_ptr rule;1125 struct pf_krule *rule;
1053 union pf_krule_ptr anchor;1126 struct pf_krule *anchor;
1054 union pf_krule_ptr nat_rule;1127 struct pf_krule *nat_rule;
1055 struct pf_addr rt_addr;
1056 struct pf_state_key *key[2]; /* addresses stack and wire */1128 struct pf_state_key *key[2]; /* addresses stack and wire */
1129 struct pf_udp_mapping *udp_mapping;
1057 struct pfi_kkif *kif;1130 struct pfi_kkif *kif;
1058 struct pfi_kkif *orig_kif; /* The real kif, even if we're a floating state (i.e. if == V_pfi_all). */1131 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;1132 struct pf_ksrc_node *sns[PF_SN_MAX];/* source nodes */
1060 struct pf_ksrc_node *src_node;
1061 struct pf_ksrc_node *nat_src_node;
1062 u_int64_t packets[2];1133 u_int64_t packets[2];
1063 u_int64_t bytes[2];1134 u_int64_t bytes[2];
1064 u_int32_t creation;1135 u_int64_t creation;
1065 u_int32_t expire;1136 u_int64_t expire;
1066 u_int32_t pfsync_time;1137 u_int32_t pfsync_time;
1067 struct pf_rule_actions act;1138 struct pf_rule_actions act;
1068 u_int16_t tag;1139 u_int16_t tag;
1069 u_int8_t rt;1140 u_int16_t if_index_in;
1141 u_int16_t if_index_out;
1070};1142};
10711143
1072/*1144/*
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.
1074 */1147 */
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
1076#endif1187#endif
10771188
1078/*1189/*
1079 * Unified state structures for pulling states out of the kernel1190 * Unified state structures for pulling states out of the kernel
1080 * used by pfsync(4) and the pf(4) ioctl.1191 * used by pfsync(4) and the pf(4) ioctl.
1081 */1192 */
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
1102struct pfsync_state_key {1193struct pfsync_state_key {
1103 struct pf_addr addr[2];1194 struct pf_addr addr[2];
1104 u_int16_t port[2];1195 u_int16_t port[2];
...@@ -1108,8 +1199,8 @@ struct pfsync_state_1301 {...@@ -1108,8 +1199,8 @@ struct pfsync_state_1301 {
1108 u_int64_t id;1199 u_int64_t id;
1109 char ifname[IFNAMSIZ];1200 char ifname[IFNAMSIZ];
1110 struct pfsync_state_key key[2];1201 struct pfsync_state_key key[2];
1111 struct pfsync_state_peer src;1202 struct pf_state_peer_export src;
1112 struct pfsync_state_peer dst;1203 struct pf_state_peer_export dst;
1113 struct pf_addr rt_addr;1204 struct pf_addr rt_addr;
1114 u_int32_t rule;1205 u_int32_t rule;
1115 u_int32_t anchor;1206 u_int32_t anchor;
...@@ -1127,16 +1218,16 @@ struct pfsync_state_1301 {...@@ -1127,16 +1218,16 @@ struct pfsync_state_1301 {
1127 u_int8_t state_flags;1218 u_int8_t state_flags;
1128 u_int8_t timeout;1219 u_int8_t timeout;
1129 u_int8_t sync_flags;1220 u_int8_t sync_flags;
1130 u_int8_t updates;1221 u_int8_t updates; /* unused */
1131} __packed;1222} __packed;
11321223
1133struct pfsync_state_1400 {1224struct 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 */
1135 u_int64_t id;1226 u_int64_t id;
1136 char ifname[IFNAMSIZ];1227 char ifname[IFNAMSIZ];
1137 struct pfsync_state_key key[2];1228 struct pfsync_state_key key[2];
1138 struct pfsync_state_peer src;1229 struct pf_state_peer_export src;
1139 struct pfsync_state_peer dst;1230 struct pf_state_peer_export dst;
1140 struct pf_addr rt_addr;1231 struct pf_addr rt_addr;
1141 u_int32_t rule;1232 u_int32_t rule;
1142 u_int32_t anchor;1233 u_int32_t anchor;
...@@ -1154,7 +1245,7 @@ struct pfsync_state_1400 {...@@ -1154,7 +1245,7 @@ struct pfsync_state_1400 {
1154 u_int8_t __spare;1245 u_int8_t __spare;
1155 u_int8_t timeout;1246 u_int8_t timeout;
1156 u_int8_t sync_flags;1247 u_int8_t sync_flags;
1157 u_int8_t updates;1248 u_int8_t updates; /* unused */
1158 /* The rest is not */1249 /* The rest is not */
1159 u_int16_t qid;1250 u_int16_t qid;
1160 u_int16_t pqid;1251 u_int16_t pqid;
...@@ -1167,12 +1258,54 @@ struct pfsync_state_1400 {...@@ -1167,12 +1258,54 @@ struct pfsync_state_1400 {
1167 u_int8_t set_prio[2];1258 u_int8_t set_prio[2];
1168 u_int8_t rt;1259 u_int8_t rt;
1169 char rt_ifname[IFNAMSIZ];1260 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 */
1171} __packed;1303} __packed;
11721304
1173union pfsync_state_union {1305union pfsync_state_union {
1174 struct pfsync_state_1301 pfs_1301;1306 struct pfsync_state_1301 pfs_1301;
1175 struct pfsync_state_1400 pfs_1400;1307 struct pfsync_state_1400 pfs_1400;
1308 struct pfsync_state_1500 pfs_1500;
1176} __packed;1309} __packed;
11771310
1178#ifdef _KERNEL1311#ifdef _KERNEL
...@@ -1184,6 +1317,8 @@ typedef void pfsync_delete_state_t(struct pf_kstate *);...@@ -1184,6 +1317,8 @@ typedef void pfsync_delete_state_t(struct pf_kstate *);
1184typedef void pfsync_clear_states_t(u_int32_t, const char *);1317typedef void pfsync_clear_states_t(u_int32_t, const char *);
1185typedef int pfsync_defer_t(struct pf_kstate *, struct mbuf *);1318typedef int pfsync_defer_t(struct pf_kstate *, struct mbuf *);
1186typedef void pfsync_detach_ifnet_t(struct ifnet *);1319typedef 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
1188VNET_DECLARE(pfsync_state_import_t *, pfsync_state_import_ptr);1323VNET_DECLARE(pfsync_state_import_t *, pfsync_state_import_ptr);
1189#define V_pfsync_state_import_ptr VNET(pfsync_state_import_ptr)1324#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);...@@ -1197,6 +1332,8 @@ VNET_DECLARE(pfsync_clear_states_t *, pfsync_clear_states_ptr);
1197#define V_pfsync_clear_states_ptr VNET(pfsync_clear_states_ptr)1332#define V_pfsync_clear_states_ptr VNET(pfsync_clear_states_ptr)
1198VNET_DECLARE(pfsync_defer_t *, pfsync_defer_ptr);1333VNET_DECLARE(pfsync_defer_t *, pfsync_defer_ptr);
1199#define V_pfsync_defer_ptr VNET(pfsync_defer_ptr)1334#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)
1200extern pfsync_detach_ifnet_t *pfsync_detach_ifnet_ptr;1337extern pfsync_detach_ifnet_t *pfsync_detach_ifnet_ptr;
12011338
1202void pfsync_state_export(union pfsync_state_union *,1339void pfsync_state_export(union pfsync_state_union *,
...@@ -1207,9 +1344,9 @@ void pf_state_export(struct pf_state_export *,...@@ -1207,9 +1344,9 @@ void pf_state_export(struct pf_state_export *,
1207/* pflog */1344/* pflog */
1208struct pf_kruleset;1345struct pf_kruleset;
1209struct pf_pdesc;1346struct pf_pdesc;
1210typedef int pflog_packet_t(struct pfi_kkif *, struct mbuf *, sa_family_t,1347typedef int pflog_packet_t(uint8_t, u_int8_t,
1211 u_int8_t, struct pf_krule *, struct pf_krule *, struct pf_kruleset *,1348 struct pf_krule *, struct pf_krule *, struct pf_kruleset *,
1212 struct pf_pdesc *, int);1349 struct pf_pdesc *, int, struct pf_krule *);
1213extern pflog_packet_t *pflog_packet_ptr;1350extern pflog_packet_t *pflog_packet_ptr;
12141351
1215#endif /* _KERNEL */1352#endif /* _KERNEL */
...@@ -1219,39 +1356,10 @@ extern pflog_packet_t *pflog_packet_ptr;...@@ -1219,39 +1356,10 @@ extern pflog_packet_t *pflog_packet_ptr;
12191356
1220/* for copies to/from network byte order */1357/* for copies to/from network byte order */
1221/* ioctl interface also uses network byte order */1358/* ioctl interface also uses network byte order */
1222#define pf_state_peer_hton(s,d) do { \1359void pf_state_peer_hton(const struct pf_state_peer *,
1223 (d)->seqlo = htonl((s)->seqlo); \1360 struct pf_state_peer_export *);
1224 (d)->seqhi = htonl((s)->seqhi); \1361void pf_state_peer_ntoh(const struct pf_state_peer_export *,
1225 (d)->seqdiff = htonl((s)->seqdiff); \1362 struct pf_state_peer *);
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)
12551363
1256#define pf_state_counter_hton(s,d) do { \1364#define pf_state_counter_hton(s,d) do { \
1257 d[0] = htonl((s>>32)&0xffffffff); \1365 d[0] = htonl((s>>32)&0xffffffff); \
...@@ -1276,7 +1384,6 @@ struct pf_kruleset {...@@ -1276,7 +1384,6 @@ struct pf_kruleset {
1276 struct pf_krulequeue queues[2];1384 struct pf_krulequeue queues[2];
1277 struct {1385 struct {
1278 struct pf_krulequeue *ptr;1386 struct pf_krulequeue *ptr;
1279 struct pf_krule **ptr_array;
1280 u_int32_t rcount;1387 u_int32_t rcount;
1281 u_int32_t ticket;1388 u_int32_t ticket;
1282 int open;1389 int open;
...@@ -1329,7 +1436,6 @@ RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare);...@@ -1329,7 +1436,6 @@ RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare);
1329 PFR_TFLAG_REFDANCHOR | \1436 PFR_TFLAG_REFDANCHOR | \
1330 PFR_TFLAG_COUNTERS)1437 PFR_TFLAG_COUNTERS)
13311438
1332struct pf_kanchor_stackframe;
1333struct pf_keth_anchor_stackframe;1439struct pf_keth_anchor_stackframe;
13341440
1335struct pfr_table {1441struct pfr_table {
...@@ -1366,7 +1472,7 @@ struct pfr_astats {...@@ -1366,7 +1472,7 @@ struct pfr_astats {
1366 struct pfr_addr pfras_a;1472 struct pfr_addr pfras_a;
1367 u_int64_t pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX];1473 u_int64_t pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
1368 u_int64_t pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX];1474 u_int64_t pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
1369 long pfras_tzero;1475 time_t pfras_tzero;
1370};1476};
13711477
1372enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX };1478enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX };
...@@ -1377,7 +1483,7 @@ struct pfr_tstats {...@@ -1377,7 +1483,7 @@ struct pfr_tstats {
1377 u_int64_t pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];1483 u_int64_t pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
1378 u_int64_t pfrts_match;1484 u_int64_t pfrts_match;
1379 u_int64_t pfrts_nomatch;1485 u_int64_t pfrts_nomatch;
1380 long pfrts_tzero;1486 time_t pfrts_tzero;
1381 int pfrts_cnt;1487 int pfrts_cnt;
1382 int pfrts_refcnt[PFR_REFCNT_MAX];1488 int pfrts_refcnt[PFR_REFCNT_MAX];
1383};1489};
...@@ -1439,7 +1545,7 @@ struct pfr_ktstats {...@@ -1439,7 +1545,7 @@ struct pfr_ktstats {
1439 struct pfr_kstate_counter pfrkts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];1545 struct pfr_kstate_counter pfrkts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
1440 struct pfr_kstate_counter pfrkts_match;1546 struct pfr_kstate_counter pfrkts_match;
1441 struct pfr_kstate_counter pfrkts_nomatch;1547 struct pfr_kstate_counter pfrkts_nomatch;
1442 long pfrkts_tzero;1548 time_t pfrkts_tzero;
1443 int pfrkts_cnt;1549 int pfrkts_cnt;
1444 int pfrkts_refcnt[PFR_REFCNT_MAX];1550 int pfrkts_refcnt[PFR_REFCNT_MAX];
1445};1551};
...@@ -1460,7 +1566,7 @@ union sockaddr_union {...@@ -1460,7 +1566,7 @@ union sockaddr_union {
14601566
1461struct pfr_kcounters {1567struct pfr_kcounters {
1462 counter_u64_t pfrkc_counters;1568 counter_u64_t pfrkc_counters;
1463 long pfrkc_tzero;1569 time_t pfrkc_tzero;
1464};1570};
1465#define pfr_kentry_counter(kc, dir, op, t) \1571#define pfr_kentry_counter(kc, dir, op, t) \
1466 ((kc)->pfrkc_counters + \1572 ((kc)->pfrkc_counters + \
...@@ -1518,7 +1624,7 @@ struct pfi_kkif {...@@ -1518,7 +1624,7 @@ struct pfi_kkif {
1518#define pfik_list _pfik_glue._pfik_list1624#define pfik_list _pfik_glue._pfik_list
1519 struct pf_counter_u64 pfik_packets[2][2][2];1625 struct pf_counter_u64 pfik_packets[2][2][2];
1520 struct pf_counter_u64 pfik_bytes[2][2][2];1626 struct pf_counter_u64 pfik_bytes[2][2][2];
1521 u_int32_t pfik_tzero;1627 time_t pfik_tzero;
1522 u_int pfik_flags;1628 u_int pfik_flags;
1523 struct ifnet *pfik_ifp;1629 struct ifnet *pfik_ifp;
1524 struct ifg_group *pfik_group;1630 struct ifg_group *pfik_group;
...@@ -1532,6 +1638,7 @@ struct pfi_kkif {...@@ -1532,6 +1638,7 @@ struct pfi_kkif {
15321638
1533#define PFI_IFLAG_REFS 0x0001 /* has state references */1639#define PFI_IFLAG_REFS 0x0001 /* has state references */
1534#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */1640#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */
1641#define PFI_IFLAG_ANY 0x0200 /* match any non-loopback interface */
15351642
1536#ifdef _KERNEL1643#ifdef _KERNEL
1537struct pf_sctp_multihome_job;1644struct pf_sctp_multihome_job;
...@@ -1555,25 +1662,49 @@ struct pf_pdesc {...@@ -1555,25 +1662,49 @@ struct pf_pdesc {
1555 char any[0];1662 char any[0];
1556 } hdr;1663 } 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
1559 struct pf_addr *src; /* src address */1671 struct pf_addr *src; /* src address */
1560 struct pf_addr *dst; /* dst address */1672 struct pf_addr *dst; /* dst address */
1561 u_int16_t *sport;1673 struct pf_addr osrc;
1562 u_int16_t *dport;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 */
1563 struct pf_mtag *pf_mtag;1682 struct pf_mtag *pf_mtag;
1564 struct pf_rule_actions act;1683 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
1568 u_int16_t *ip_sum;1697 u_int16_t *ip_sum;
1569 u_int16_t *proto_sum;
1570 u_int16_t flags; /* Let SCRUB trigger behavior in1698 u_int16_t flags; /* Let SCRUB trigger behavior in
1571 * state code. Easier than tags */1699 * state code. Easier than tags */
1572#define PFDESC_TCP_NORM 0x0001 /* TCP shall be statefully scrubbed */1700#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
1574 sa_family_t af;1703 sa_family_t af;
1704 sa_family_t naf;
1575 u_int8_t proto;1705 u_int8_t proto;
1576 u_int8_t tos;1706 u_int8_t tos;
1707 u_int8_t ttl;
1577 u_int8_t dir; /* direction */1708 u_int8_t dir; /* direction */
1578 u_int8_t sidx; /* key index for source */1709 u_int8_t sidx; /* key index for source */
1579 u_int8_t didx; /* key index for destination */1710 u_int8_t didx; /* key index for destination */
...@@ -1592,6 +1723,8 @@ struct pf_pdesc {...@@ -1592,6 +1723,8 @@ struct pf_pdesc {
1592#define PFDESC_SCTP_ADD_IP 0x10001723#define PFDESC_SCTP_ADD_IP 0x1000
1593 u_int16_t sctp_flags;1724 u_int16_t sctp_flags;
1594 u_int32_t sctp_initiate_tag;1725 u_int32_t sctp_initiate_tag;
1726 u_int16_t sctp_dummy_sum;
1727 struct pf_krule *related_rule;
15951728
1596 struct pf_sctp_multihome_jobs sctp_multihome_jobs;1729 struct pf_sctp_multihome_jobs sctp_multihome_jobs;
1597};1730};
...@@ -1601,7 +1734,6 @@ struct pf_sctp_multihome_job {...@@ -1601,7 +1734,6 @@ struct pf_sctp_multihome_job {
1601 struct pf_pdesc pd;1734 struct pf_pdesc pd;
1602 struct pf_addr src;1735 struct pf_addr src;
1603 struct pf_addr dst;1736 struct pf_addr dst;
1604 struct mbuf *m;
1605 int op;1737 int op;
1606};1738};
16071739
...@@ -1647,6 +1779,7 @@ struct pf_sctp_multihome_job {...@@ -1647,6 +1779,7 @@ struct pf_sctp_multihome_job {
16471779
1648#define REASON_SET(a, x) \1780#define REASON_SET(a, x) \
1649 do { \1781 do { \
1782 SDT_PROBE2(pf, , test, reason_set, x, __LINE__); \
1650 if ((a) != NULL) \1783 if ((a) != NULL) \
1651 *(a) = (x); \1784 *(a) = (x); \
1652 if (x < PFRES_MAX) \1785 if (x < PFRES_MAX) \
...@@ -1697,6 +1830,13 @@ struct pf_divert {...@@ -1697,6 +1830,13 @@ struct pf_divert {
1697#define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */1830#define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */
1698#define PFR_KENTRY_HIWAT 200000 /* Number of table entries */1831#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
1700/*1840/*
1701 * Limit the length of the fragment queue traversal. Remember1841 * Limit the length of the fragment queue traversal. Remember
1702 * search entry points based on the fragment offset.1842 * search entry points based on the fragment offset.
...@@ -1773,6 +1913,7 @@ struct pf_kstate_kill {...@@ -1773,6 +1913,7 @@ struct pf_kstate_kill {
1773 char psk_label[PF_RULE_LABEL_SIZE];1913 char psk_label[PF_RULE_LABEL_SIZE];
1774 u_int psk_killed;1914 u_int psk_killed;
1775 bool psk_kill_match;1915 bool psk_kill_match;
1916 bool psk_nat;
1776};1917};
1777#endif1918#endif
17781919
...@@ -1944,29 +2085,25 @@ struct pfioc_iface {...@@ -1944,29 +2085,25 @@ struct pfioc_iface {
1944#define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule)2085#define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule)
1945#define DIOCADDRULENV _IOWR('D', 4, struct pfioc_nv)2086#define DIOCADDRULENV _IOWR('D', 4, struct pfioc_nv)
1946#define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule)2087#define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule)
1947#define DIOCGETRULE _IOWR('D', 7, struct pfioc_rule)
1948#define DIOCGETRULENV _IOWR('D', 7, struct pfioc_nv)2088#define DIOCGETRULENV _IOWR('D', 7, struct pfioc_nv)
1949/* XXX cut 8 - 17 */
1950#define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill)
1951#define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv)2089#define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv)
1952#define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state)2090#define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state)
1953#define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv)2091#define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv)
1954#define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if)2092#define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if)
1955#define DIOCGETSTATUS _IOWR('D', 21, struct pf_status)
1956#define DIOCGETSTATUSNV _IOWR('D', 21, struct pfioc_nv)2093#define DIOCGETSTATUSNV _IOWR('D', 21, struct pfioc_nv)
1957#define DIOCCLRSTATUS _IO ('D', 22)2094#define DIOCCLRSTATUS _IO ('D', 22)
1958#define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook)2095#define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook)
1959#define DIOCSETDEBUG _IOWR('D', 24, u_int32_t)2096#define DIOCSETDEBUG _IOWR('D', 24, u_int32_t)
2097#ifdef COMPAT_FREEBSD14
1960#define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states)2098#define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states)
2099#endif
1961#define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule)2100#define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule)
1962/* XXX cut 26 - 28 */
1963#define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm)2101#define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm)
1964#define DIOCGETTIMEOUT _IOWR('D', 30, struct pfioc_tm)2102#define DIOCGETTIMEOUT _IOWR('D', 30, struct pfioc_tm)
1965#define DIOCADDSTATE _IOWR('D', 37, struct pfioc_state)2103#define DIOCADDSTATE _IOWR('D', 37, struct pfioc_state)
1966#define DIOCCLRRULECTRS _IO ('D', 38)2104#define DIOCCLRRULECTRS _IO ('D', 38)
1967#define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit)2105#define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit)
1968#define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit)2106#define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit)
1969#define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill)
1970#define DIOCKILLSTATESNV _IOWR('D', 41, struct pfioc_nv)2107#define DIOCKILLSTATESNV _IOWR('D', 41, struct pfioc_nv)
1971#define DIOCSTARTALTQ _IO ('D', 42)2108#define DIOCSTARTALTQ _IO ('D', 42)
1972#define DIOCSTOPALTQ _IO ('D', 43)2109#define DIOCSTOPALTQ _IO ('D', 43)
...@@ -1985,7 +2122,6 @@ struct pfioc_iface {...@@ -1985,7 +2122,6 @@ struct pfioc_iface {
1985#define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr)2122#define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr)
1986#define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr)2123#define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr)
1987#define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr)2124#define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr)
1988/* XXX cut 55 - 57 */
1989#define DIOCGETRULESETS _IOWR('D', 58, struct pfioc_ruleset)2125#define DIOCGETRULESETS _IOWR('D', 58, struct pfioc_ruleset)
1990#define DIOCGETRULESET _IOWR('D', 59, struct pfioc_ruleset)2126#define DIOCGETRULESET _IOWR('D', 59, struct pfioc_ruleset)
1991#define DIOCRCLRTABLES _IOWR('D', 60, struct pfioc_table)2127#define DIOCRCLRTABLES _IOWR('D', 60, struct pfioc_table)
...@@ -2019,7 +2155,9 @@ struct pfioc_iface {...@@ -2019,7 +2155,9 @@ struct pfioc_iface {
2019#define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill)2155#define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill)
2020#define DIOCGIFSPEEDV0 _IOWR('D', 92, struct pf_ifspeed_v0)2156#define DIOCGIFSPEEDV0 _IOWR('D', 92, struct pf_ifspeed_v0)
2021#define DIOCGIFSPEEDV1 _IOWR('D', 92, struct pf_ifspeed_v1)2157#define DIOCGIFSPEEDV1 _IOWR('D', 92, struct pf_ifspeed_v1)
2158#ifdef COMPAT_FREEBSD14
2022#define DIOCGETSTATESV2 _IOWR('D', 93, struct pfioc_states_v2)2159#define DIOCGETSTATESV2 _IOWR('D', 93, struct pfioc_states_v2)
2160#endif
2023#define DIOCGETSYNCOOKIES _IOWR('D', 94, struct pfioc_nv)2161#define DIOCGETSYNCOOKIES _IOWR('D', 94, struct pfioc_nv)
2024#define DIOCSETSYNCOOKIES _IOWR('D', 95, struct pfioc_nv)2162#define DIOCSETSYNCOOKIES _IOWR('D', 95, struct pfioc_nv)
2025#define DIOCKEEPCOUNTERS _IOWR('D', 96, struct pfioc_nv)2163#define DIOCKEEPCOUNTERS _IOWR('D', 96, struct pfioc_nv)
...@@ -2103,21 +2241,33 @@ struct pf_idhash {...@@ -2103,21 +2241,33 @@ struct pf_idhash {
2103 struct mtx lock;2241 struct mtx lock;
2104};2242};
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
2106extern u_long pf_ioctl_maxcount;2250extern u_long pf_ioctl_maxcount;
2107VNET_DECLARE(u_long, pf_hashmask);2251VNET_DECLARE(u_long, pf_hashmask);
2108#define V_pf_hashmask VNET(pf_hashmask)2252#define V_pf_hashmask VNET(pf_hashmask)
2109VNET_DECLARE(u_long, pf_srchashmask);2253VNET_DECLARE(u_long, pf_srchashmask);
2110#define V_pf_srchashmask VNET(pf_srchashmask)2254#define V_pf_srchashmask VNET(pf_srchashmask)
2255VNET_DECLARE(u_long, pf_udpendpointhashmask);
2256#define V_pf_udpendpointhashmask VNET(pf_udpendpointhashmask)
2111#define PF_HASHSIZ (131072)2257#define PF_HASHSIZ (131072)
2112#define PF_SRCHASHSIZ (PF_HASHSIZ/4)2258#define PF_SRCHASHSIZ (PF_HASHSIZ/4)
2259#define PF_UDPENDHASHSIZ (PF_HASHSIZ/4)
2113VNET_DECLARE(struct pf_keyhash *, pf_keyhash);2260VNET_DECLARE(struct pf_keyhash *, pf_keyhash);
2114VNET_DECLARE(struct pf_idhash *, pf_idhash);2261VNET_DECLARE(struct pf_idhash *, pf_idhash);
2262VNET_DECLARE(struct pf_udpendpointhash *, pf_udpendpointhash);
2115#define V_pf_keyhash VNET(pf_keyhash)2263#define V_pf_keyhash VNET(pf_keyhash)
2116#define V_pf_idhash VNET(pf_idhash)2264#define V_pf_idhash VNET(pf_idhash)
2265#define V_pf_udpendpointhash VNET(pf_udpendpointhash)
2117VNET_DECLARE(struct pf_srchash *, pf_srchash);2266VNET_DECLARE(struct pf_srchash *, pf_srchash);
2118#define V_pf_srchash VNET(pf_srchash)2267#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
2122VNET_DECLARE(void *, pf_swi_cookie);2272VNET_DECLARE(void *, pf_swi_cookie);
2123#define V_pf_swi_cookie VNET(pf_swi_cookie)2273#define V_pf_swi_cookie VNET(pf_swi_cookie)
...@@ -2130,7 +2280,7 @@ VNET_DECLARE(struct unrhdr64, pf_stateid);...@@ -2130,7 +2280,7 @@ VNET_DECLARE(struct unrhdr64, pf_stateid);
2130TAILQ_HEAD(pf_altqqueue, pf_altq);2280TAILQ_HEAD(pf_altqqueue, pf_altq);
2131VNET_DECLARE(struct pf_altqqueue, pf_altqs[4]);2281VNET_DECLARE(struct pf_altqqueue, pf_altqs[4]);
2132#define V_pf_altqs VNET(pf_altqs)2282#define V_pf_altqs VNET(pf_altqs)
2133VNET_DECLARE(struct pf_kpalist, pf_pabuf);2283VNET_DECLARE(struct pf_kpalist, pf_pabuf[3]);
2134#define V_pf_pabuf VNET(pf_pabuf)2284#define V_pf_pabuf VNET(pf_pabuf)
21352285
2136VNET_DECLARE(u_int32_t, ticket_altqs_active);2286VNET_DECLARE(u_int32_t, ticket_altqs_active);
...@@ -2171,6 +2321,8 @@ VNET_DECLARE(struct pf_krule *, pf_rulemarker);...@@ -2171,6 +2321,8 @@ VNET_DECLARE(struct pf_krule *, pf_rulemarker);
2171#define V_pf_rulemarker VNET(pf_rulemarker)2321#define V_pf_rulemarker VNET(pf_rulemarker)
2172#endif2322#endif
21732323
2324int pf_start(void);
2325int pf_stop(void);
2174void pf_initialize(void);2326void pf_initialize(void);
2175void pf_mtag_initialize(void);2327void pf_mtag_initialize(void);
2176void pf_mtag_cleanup(void);2328void pf_mtag_cleanup(void);
...@@ -2186,15 +2338,21 @@ VNET_DECLARE(uma_zone_t, pf_state_z);...@@ -2186,15 +2338,21 @@ VNET_DECLARE(uma_zone_t, pf_state_z);
2186#define V_pf_state_z VNET(pf_state_z)2338#define V_pf_state_z VNET(pf_state_z)
2187VNET_DECLARE(uma_zone_t, pf_state_key_z);2339VNET_DECLARE(uma_zone_t, pf_state_key_z);
2188#define V_pf_state_key_z VNET(pf_state_key_z)2340#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)
2189VNET_DECLARE(uma_zone_t, pf_state_scrub_z);2343VNET_DECLARE(uma_zone_t, pf_state_scrub_z);
2190#define V_pf_state_scrub_z VNET(pf_state_scrub_z)2344#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
2192extern void pf_purge_thread(void *);2350extern void pf_purge_thread(void *);
2193extern void pf_unload_vnet_purge(void);2351extern void pf_unload_vnet_purge(void);
2194extern void pf_intr(void *);2352extern void pf_intr(void *);
2195extern void pf_purge_expired_src_nodes(void);2353extern void pf_purge_expired_src_nodes(void);
21962354
2197extern int pf_unlink_state(struct pf_kstate *);2355extern int pf_remove_state(struct pf_kstate *);
2198extern int pf_state_insert(struct pfi_kkif *,2356extern int pf_state_insert(struct pfi_kkif *,
2199 struct pfi_kkif *,2357 struct pfi_kkif *,
2200 struct pf_state_key *,2358 struct pf_state_key *,
...@@ -2202,6 +2360,9 @@ extern int pf_state_insert(struct pfi_kkif *,...@@ -2202,6 +2360,9 @@ extern int pf_state_insert(struct pfi_kkif *,
2202 struct pf_kstate *);2360 struct pf_kstate *);
2203extern struct pf_kstate *pf_alloc_state(int);2361extern struct pf_kstate *pf_alloc_state(int);
2204extern void pf_free_state(struct pf_kstate *);2362extern 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
2206static __inline void2367static __inline void
2207pf_ref_state(struct pf_kstate *s)2368pf_ref_state(struct pf_kstate *s)
...@@ -2232,6 +2393,22 @@ pf_release_staten(struct pf_kstate *s, u_int n)...@@ -2232,6 +2393,22 @@ pf_release_staten(struct pf_kstate *s, u_int n)
2232 return (0);2393 return (0);
2233}2394}
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
2235extern struct pf_kstate *pf_find_state_byid(uint64_t, uint32_t);2412extern struct pf_kstate *pf_find_state_byid(uint64_t, uint32_t);
2236extern struct pf_kstate *pf_find_state_all(2413extern struct pf_kstate *pf_find_state_all(
2237 const struct pf_state_key_cmp *,2414 const struct pf_state_key_cmp *,
...@@ -2239,13 +2416,25 @@ extern struct pf_kstate *pf_find_state_all(...@@ -2239,13 +2416,25 @@ extern struct pf_kstate *pf_find_state_all(
2239extern bool pf_find_state_all_exists(2416extern bool pf_find_state_all_exists(
2240 const struct pf_state_key_cmp *,2417 const struct pf_state_key_cmp *,
2241 u_int);2418 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 *);
2242extern struct pf_ksrc_node *pf_find_src_node(struct pf_addr *,2431extern struct pf_ksrc_node *pf_find_src_node(struct pf_addr *,
2243 struct pf_krule *, sa_family_t,2432 struct pf_krule *, sa_family_t,
2244 struct pf_srchash **, bool);2433 struct pf_srchash **, pf_sn_types_t, bool);
2245extern void pf_unlink_src_node(struct pf_ksrc_node *);2434extern void pf_unlink_src_node(struct pf_ksrc_node *);
2246extern u_int pf_free_src_nodes(struct pf_ksrc_node_list *);2435extern u_int pf_free_src_nodes(struct pf_ksrc_node_list *);
2247extern void pf_print_state(struct pf_kstate *);2436extern void pf_print_state(struct pf_kstate *);
2248extern void pf_print_flags(u_int8_t);2437extern void pf_print_flags(uint16_t);
2249extern int pf_addr_wrap_neq(struct pf_addr_wrap *,2438extern int pf_addr_wrap_neq(struct pf_addr_wrap *,
2250 struct pf_addr_wrap *);2439 struct pf_addr_wrap *);
2251extern u_int16_t pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t,2440extern 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);...@@ -2257,80 +2446,85 @@ VNET_DECLARE(struct ifnet *, sync_ifp);
2257#define V_sync_ifp VNET(sync_ifp);2446#define V_sync_ifp VNET(sync_ifp);
2258VNET_DECLARE(struct pf_krule, pf_default_rule);2447VNET_DECLARE(struct pf_krule, pf_default_rule);
2259#define V_pf_default_rule VNET(pf_default_rule)2448#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 *,
2261 sa_family_t);2450 sa_family_t);
2262void pf_free_rule(struct pf_krule *);2451void pf_free_rule(struct pf_krule *);
22632452
2264int pf_test_eth(int, int, struct ifnet *, struct mbuf **, struct inpcb *);2453int pf_test_eth(int, int, struct ifnet *, struct mbuf **, struct inpcb *);
2265#ifdef INET2454int pf_scan_sctp(struct pf_pdesc *);
2266int pf_test(int, int, struct ifnet *, struct mbuf **, struct inpcb *,2455#if defined(INET) || defined(INET6)
2456int pf_test(sa_family_t, int, int, struct ifnet *, struct mbuf **, struct inpcb *,
2267 struct pf_rule_actions *);2457 struct pf_rule_actions *);
2268int pf_normalize_ip(struct mbuf **, struct pfi_kkif *, u_short *,2458#endif
2269 struct pf_pdesc *);2459#ifdef INET
2460int pf_normalize_ip(u_short *, struct pf_pdesc *);
2270#endif /* INET */2461#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 *);
2277void pf_poolmask(struct pf_addr *, struct pf_addr*,2463void pf_poolmask(struct pf_addr *, struct pf_addr*,
2278 struct pf_addr *, struct pf_addr *, sa_family_t);2464 struct pf_addr *, struct pf_addr *, sa_family_t);
2279void pf_addr_inc(struct pf_addr *, sa_family_t);2465void 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);
2281#endif /* INET6 */2471#endif /* INET6 */
22822472
2283int pf_multihome_scan_init(struct mbuf *, int, int, struct pf_pdesc *,2473int pf_multihome_scan_init(int, int, struct pf_pdesc *);
2284 struct pfi_kkif *);2474int pf_multihome_scan_asconf(int, int, struct pf_pdesc *);
2285int pf_multihome_scan_asconf(struct mbuf *, int, int, struct pf_pdesc *,
2286 struct pfi_kkif *);
22872475
2288u_int32_t pf_new_isn(struct pf_kstate *);2476u_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 *,
2290 sa_family_t);2478 sa_family_t);
2291void pf_change_a(void *, u_int16_t *, u_int32_t, u_int8_t);2479void pf_change_a(void *, u_int16_t *, u_int32_t, u_int8_t);
2292void pf_change_proto_a(struct mbuf *, void *, u_int16_t *, u_int32_t,2480void pf_change_proto_a(struct mbuf *, void *, u_int16_t *, u_int32_t,
2293 u_int8_t);2481 u_int8_t);
2294void pf_change_tcp_a(struct mbuf *, void *, u_int16_t *, u_int32_t);2482void 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,2483int pf_patch_16(struct pf_pdesc *, void *, u_int16_t, bool);
2296 bool, u_int8_t);2484int pf_patch_32(struct pf_pdesc *, void *, u_int32_t, bool);
2297void pf_patch_32_unaligned(struct mbuf *, u_int16_t *, void *, u_int32_t,
2298 bool, u_int8_t);
2299void pf_send_deferred_syn(struct pf_kstate *);2485void pf_send_deferred_syn(struct pf_kstate *);
2300int pf_match_addr(u_int8_t, struct pf_addr *, struct pf_addr *,2486int pf_match_addr(u_int8_t, const struct pf_addr *,
2301 struct pf_addr *, sa_family_t);2487 const struct pf_addr *, const struct pf_addr *, sa_family_t);
2302int pf_match_addr_range(struct pf_addr *, struct pf_addr *,2488int pf_match_addr_range(const struct pf_addr *, const struct pf_addr *,
2303 struct pf_addr *, sa_family_t);2489 const struct pf_addr *, sa_family_t);
2304int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t);2490int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t);
23052491
2306void pf_normalize_init(void);2492void pf_normalize_init(void);
2307void pf_normalize_cleanup(void);2493void pf_normalize_cleanup(void);
2308int pf_normalize_tcp(struct pfi_kkif *, struct mbuf *, int, int, void *,2494int pf_normalize_tcp(struct pf_pdesc *);
2309 struct pf_pdesc *);
2310void pf_normalize_tcp_cleanup(struct pf_kstate *);2495void pf_normalize_tcp_cleanup(struct pf_kstate *);
2311int pf_normalize_tcp_init(struct mbuf *, int, struct pf_pdesc *,2496int pf_normalize_tcp_init(struct pf_pdesc *,
2312 struct tcphdr *, struct pf_state_peer *, struct pf_state_peer *);2497 struct tcphdr *, struct pf_state_peer *);
2313int pf_normalize_tcp_stateful(struct mbuf *, int, struct pf_pdesc *,2498int pf_normalize_tcp_stateful(struct pf_pdesc *,
2314 u_short *, struct tcphdr *, struct pf_kstate *,2499 u_short *, struct tcphdr *, struct pf_kstate *,
2315 struct pf_state_peer *, struct pf_state_peer *, int *);2500 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 *,
2317 struct pf_state_peer *, struct pf_state_peer *);2502 struct pf_state_peer *, struct pf_state_peer *);
2318int pf_normalize_sctp(int, struct pfi_kkif *, struct mbuf *, int,2503int pf_normalize_sctp(struct pf_pdesc *);
2319 int, void *, struct pf_pdesc *);
2320u_int32_t2504u_int32_t
2321 pf_state_expires(const struct pf_kstate *);2505 pf_state_expires(const struct pf_kstate *);
2322void pf_purge_expired_fragments(void);2506void pf_purge_expired_fragments(void);
2323void pf_purge_fragments(uint32_t);2507void pf_purge_fragments(uint32_t);
2324int pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kkif *,2508int pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kkif *,
2325 int);2509 int);
2326int pf_socket_lookup(struct pf_pdesc *, struct mbuf *);2510int pf_socket_lookup(struct pf_pdesc *);
2327struct pf_state_key *pf_alloc_state_key(int);2511struct 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
2328void pfr_initialize(void);2521void pfr_initialize(void);
2329void pfr_cleanup(void);2522void pfr_cleanup(void);
2330int pfr_match_addr(struct pfr_ktable *, struct pf_addr *, sa_family_t);2523int pfr_match_addr(struct pfr_ktable *, struct pf_addr *, sa_family_t);
2331void pfr_update_stats(struct pfr_ktable *, struct pf_addr *, sa_family_t,2524void pfr_update_stats(struct pfr_ktable *, struct pf_addr *, sa_family_t,
2332 u_int64_t, int, int, int);2525 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);
2334void pfr_dynaddr_update(struct pfr_ktable *, struct pfi_dynaddr *);2528void pfr_dynaddr_update(struct pfr_ktable *, struct pfi_dynaddr *);
2335struct pfr_ktable *2529struct pfr_ktable *
2336 pfr_attach_table(struct pf_kruleset *, char *);2530 pfr_attach_table(struct pf_kruleset *, char *);
...@@ -2346,7 +2540,7 @@ int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int);...@@ -2346,7 +2540,7 @@ int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int);
2346int pfr_clr_tstats(struct pfr_table *, int, int *, int);2540int pfr_clr_tstats(struct pfr_table *, int, int *, int);
2347int pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int);2541int pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int);
2348int pfr_clr_addrs(struct pfr_table *, int *, int);2542int 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);
2350int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *,2544int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
2351 int);2545 int);
2352int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *,2546int 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);...@@ -2364,6 +2558,8 @@ int pfr_ina_rollback(struct pfr_table *, u_int32_t, int *, int);
2364int pfr_ina_commit(struct pfr_table *, u_int32_t, int *, int *, int);2558int pfr_ina_commit(struct pfr_table *, u_int32_t, int *, int *, int);
2365int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,2559int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,
2366 int *, u_int32_t, int);2560 int *, u_int32_t, int);
2561struct pfr_ktable
2562 *pfr_ktable_select_active(struct pfr_ktable *);
23672563
2368MALLOC_DECLARE(PFI_MTYPE);2564MALLOC_DECLARE(PFI_MTYPE);
2369VNET_DECLARE(struct pfi_kkif *, pfi_all);2565VNET_DECLARE(struct pfi_kkif *, pfi_all);
...@@ -2390,21 +2586,23 @@ int pfi_set_flags(const char *, int);...@@ -2390,21 +2586,23 @@ int pfi_set_flags(const char *, int);
2390int pfi_clear_flags(const char *, int);2586int pfi_clear_flags(const char *, int);
23912587
2392int pf_match_tag(struct mbuf *, struct pf_krule *, int *, int);2588int 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);
2394int pf_addr_cmp(struct pf_addr *, struct pf_addr *,2590int pf_addr_cmp(struct pf_addr *, struct pf_addr *,
2395 sa_family_t);2591 sa_family_t);
23962592
2397u_int16_t pf_get_mss(struct mbuf *, int, u_int16_t, sa_family_t);2593uint8_t* pf_find_tcpopt(u_int8_t *, u_int8_t *, size_t,
2398u_int8_t pf_get_wscale(struct mbuf *, int, u_int16_t, sa_family_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 *);
2399struct mbuf *pf_build_tcp(const struct pf_krule *, sa_family_t,2597struct mbuf *pf_build_tcp(const struct pf_krule *, sa_family_t,
2400 const struct pf_addr *, const struct pf_addr *,2598 const struct pf_addr *, const struct pf_addr *,
2401 u_int16_t, u_int16_t, u_int32_t, u_int32_t,2599 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,2600 u_int8_t, u_int16_t, u_int16_t, u_int8_t, int,
2403 u_int16_t, u_int16_t, int);2601 u_int16_t, u_int16_t, u_int, int);
2404void pf_send_tcp(const struct pf_krule *, sa_family_t,2602void pf_send_tcp(const struct pf_krule *, sa_family_t,
2405 const struct pf_addr *, const struct pf_addr *,2603 const struct pf_addr *, const struct pf_addr *,
2406 u_int16_t, u_int16_t, u_int32_t, u_int32_t,2604 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,
2408 u_int16_t, u_int16_t, int);2606 u_int16_t, u_int16_t, int);
24092607
2410void pf_syncookies_init(void);2608void pf_syncookies_init(void);
...@@ -2412,12 +2610,10 @@ void pf_syncookies_cleanup(void);...@@ -2412,12 +2610,10 @@ void pf_syncookies_cleanup(void);
2412int pf_get_syncookies(struct pfioc_nv *);2610int pf_get_syncookies(struct pfioc_nv *);
2413int pf_set_syncookies(struct pfioc_nv *);2611int pf_set_syncookies(struct pfioc_nv *);
2414int pf_synflood_check(struct pf_pdesc *);2612int pf_synflood_check(struct pf_pdesc *);
2415void pf_syncookie_send(struct mbuf *m, int off,2613void pf_syncookie_send(struct pf_pdesc *);
2416 struct pf_pdesc *);
2417bool pf_syncookie_check(struct pf_pdesc *);2614bool pf_syncookie_check(struct pf_pdesc *);
2418u_int8_t pf_syncookie_validate(struct pf_pdesc *);2615u_int8_t pf_syncookie_validate(struct pf_pdesc *);
2419struct mbuf * pf_syncookie_recreate_syn(uint8_t, int,2616struct mbuf * pf_syncookie_recreate_syn(struct pf_pdesc *);
2420 struct pf_pdesc *);
24212617
2422VNET_DECLARE(struct pf_kstatus, pf_status);2618VNET_DECLARE(struct pf_kstatus, pf_status);
2423#define V_pf_status VNET(pf_status)2619#define V_pf_status VNET(pf_status)
...@@ -2432,6 +2628,20 @@ VNET_DECLARE(struct pf_limit, pf_limits[PF_LIMIT_MAX]);...@@ -2432,6 +2628,20 @@ VNET_DECLARE(struct pf_limit, pf_limits[PF_LIMIT_MAX]);
2432#endif /* _KERNEL */2628#endif /* _KERNEL */
24332629
2434#ifdef _KERNEL2630#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
2435VNET_DECLARE(struct pf_kanchor_global, pf_anchors);2645VNET_DECLARE(struct pf_kanchor_global, pf_anchors);
2436#define V_pf_anchors VNET(pf_anchors)2646#define V_pf_anchors VNET(pf_anchors)
2437VNET_DECLARE(struct pf_kanchor, pf_main_anchor);2647VNET_DECLARE(struct pf_kanchor, pf_main_anchor);
...@@ -2449,15 +2659,17 @@ void pf_init_kruleset(struct pf_kruleset *);...@@ -2449,15 +2659,17 @@ void pf_init_kruleset(struct pf_kruleset *);
2449void pf_init_keth(struct pf_keth_ruleset *);2659void pf_init_keth(struct pf_keth_ruleset *);
2450int pf_kanchor_setup(struct pf_krule *,2660int pf_kanchor_setup(struct pf_krule *,
2451 const struct pf_kruleset *, const char *);2661 const struct pf_kruleset *, const char *);
2662int pf_kanchor_copyout(const struct pf_kruleset *,
2663 const struct pf_krule *, char *, size_t);
2452int pf_kanchor_nvcopyout(const struct pf_kruleset *,2664int pf_kanchor_nvcopyout(const struct pf_kruleset *,
2453 const struct pf_krule *, nvlist_t *);2665 const struct pf_krule *, nvlist_t *);
2454int pf_kanchor_copyout(const struct pf_kruleset *,2666void pf_remove_kanchor(struct pf_krule *);
2455 const struct pf_krule *, struct pfioc_rule *);
2456void pf_kanchor_remove(struct pf_krule *);
2457void pf_remove_if_empty_kruleset(struct pf_kruleset *);2667void pf_remove_if_empty_kruleset(struct pf_kruleset *);
2458struct pf_kruleset *pf_find_kruleset(const char *);2668struct pf_kruleset *pf_find_kruleset(const char *);
2669struct pf_kruleset *pf_get_leaf_kruleset(char *, char **);
2459struct pf_kruleset *pf_find_or_create_kruleset(const char *);2670struct pf_kruleset *pf_find_or_create_kruleset(const char *);
2460void pf_rs_initialize(void);2671void pf_rs_initialize(void);
2672void pf_rule_tree_free(struct pf_krule_global *);
24612673
24622674
2463struct pf_krule *pf_krule_alloc(void);2675struct pf_krule *pf_krule_alloc(void);
...@@ -2474,15 +2686,33 @@ int pf_keth_anchor_nvcopyout(...@@ -2474,15 +2686,33 @@ int pf_keth_anchor_nvcopyout(
2474struct pf_keth_ruleset *pf_find_or_create_keth_ruleset(const char *);2686struct pf_keth_ruleset *pf_find_or_create_keth_ruleset(const char *);
2475void pf_keth_anchor_remove(struct pf_keth_rule *);2687void 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
2477void pf_krule_free(struct pf_krule *);2706void pf_krule_free(struct pf_krule *);
2707void pf_krule_clear_counters(struct pf_krule *);
2708void pf_addr_copyout(struct pf_addr_wrap *);
2478#endif2709#endif
24792710
2480/* The fingerprint functions can be linked into userland programs (tcpdump) */2711/* The fingerprint functions can be linked into userland programs (tcpdump) */
2481int pf_osfp_add(struct pf_osfp_ioctl *);2712int pf_osfp_add(struct pf_osfp_ioctl *);
2482#ifdef _KERNEL2713#ifdef _KERNEL
2483struct pf_osfp_enlist *2714struct pf_osfp_enlist *
2484 pf_osfp_fingerprint(struct pf_pdesc *, struct mbuf *, int,2715 pf_osfp_fingerprint(struct pf_pdesc *, const struct tcphdr *);
2485 const struct tcphdr *);
2486#endif /* _KERNEL */2716#endif /* _KERNEL */
2487void pf_osfp_flush(void);2717void pf_osfp_flush(void);
2488int pf_osfp_get(struct pf_osfp_ioctl *);2718int pf_osfp_get(struct pf_osfp_ioctl *);
...@@ -2491,12 +2721,10 @@ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t);...@@ -2491,12 +2721,10 @@ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t);
2491#ifdef _KERNEL2721#ifdef _KERNEL
2492void pf_print_host(struct pf_addr *, u_int16_t, sa_family_t);2722void pf_print_host(struct pf_addr *, u_int16_t, sa_family_t);
24932723
2494void pf_step_into_anchor(struct pf_kanchor_stackframe *, int *,2724enum pf_test_status pf_step_into_anchor(struct pf_test_ctx *, struct pf_krule *,
2495 struct pf_kruleset **, int, struct pf_krule **,2725 struct pf_krule_slist *match_rules);
2496 struct pf_krule **, int *);2726enum pf_test_status pf_match_rule(struct pf_test_ctx *, struct pf_kruleset *,
2497int pf_step_out_of_anchor(struct pf_kanchor_stackframe *, int *,2727 struct pf_krule_slist *);
2498 struct pf_kruleset **, int, struct pf_krule **,
2499 struct pf_krule **, int *);
2500void pf_step_into_keth_anchor(struct pf_keth_anchor_stackframe *,2728void pf_step_into_keth_anchor(struct pf_keth_anchor_stackframe *,
2501 int *, struct pf_keth_ruleset **,2729 int *, struct pf_keth_ruleset **,
2502 struct pf_keth_rule **, struct pf_keth_rule **,2730 struct pf_keth_rule **, struct pf_keth_rule **,
...@@ -2506,33 +2734,48 @@ int pf_step_out_of_keth_anchor(struct pf_keth_anchor_stackframe *,...@@ -2506,33 +2734,48 @@ int pf_step_out_of_keth_anchor(struct pf_keth_anchor_stackframe *,
2506 struct pf_keth_rule **, struct pf_keth_rule **,2734 struct pf_keth_rule **, struct pf_keth_rule **,
2507 int *);2735 int *);
25082736
2509u_short pf_map_addr(u_int8_t, struct pf_krule *,2737u_short pf_map_addr(sa_family_t, struct pf_krule *,
2510 struct pf_addr *, struct pf_addr *,2738 struct pf_addr *, struct pf_addr *,
2511 struct pfi_kkif **nkif, struct pf_addr *,2739 struct pfi_kkif **nkif, sa_family_t *,
2512 struct pf_ksrc_node **);2740 struct pf_addr *, struct pf_kpool *);
2513struct pf_krule *pf_get_translation(struct pf_pdesc *, struct mbuf *,2741u_short pf_map_addr_sn(u_int8_t, struct pf_krule *,
2514 int, struct pfi_kkif *, struct pf_ksrc_node **,
2515 struct pf_state_key **, struct pf_state_key **,
2516 struct pf_addr *, struct pf_addr *,2742 struct pf_addr *, struct pf_addr *,
2517 uint16_t, uint16_t, struct pf_kanchor_stackframe *);2743 sa_family_t *, struct pfi_kkif **,
25182744 struct pf_addr *, struct pf_kpool *,
2519struct pf_state_key *pf_state_key_setup(struct pf_pdesc *, struct mbuf *, int,2745 pf_sn_types_t);
2520 struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_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);
2521struct pf_state_key *pf_state_key_clone(const struct pf_state_key *);2757struct pf_state_key *pf_state_key_clone(const struct pf_state_key *);
2522void pf_rule_to_actions(struct pf_krule *,2758void pf_rule_to_actions(struct pf_krule *,
2523 struct pf_rule_actions *);2759 struct pf_rule_actions *);
2524int pf_normalize_mss(struct mbuf *m, int off,2760int pf_normalize_mss(struct pf_pdesc *pd);
2525 struct pf_pdesc *pd);2761#if defined(INET) || defined(INET6)
2526#ifdef INET2762void pf_scrub(struct pf_pdesc *);
2527void pf_scrub_ip(struct mbuf **, struct pf_pdesc *);2763#endif
2528#endif /* INET */
2529#ifdef INET6
2530void pf_scrub_ip6(struct mbuf **, struct pf_pdesc *);
2531#endif /* INET6 */
25322764
2533struct pfi_kkif *pf_kkif_create(int);2765struct pfi_kkif *pf_kkif_create(int);
2534void pf_kkif_free(struct pfi_kkif *);2766void pf_kkif_free(struct pfi_kkif *);
2535void pf_kkif_zero(struct pfi_kkif *);2767void 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
2536#endif /* _KERNEL */2779#endif /* _KERNEL */
25372780
2538#endif /* _NET_PFVAR_H_ */2781#endif /* _NET_PFVAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/net/radix.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)radix.h 8.2 (Berkeley) 10/31/94
32 */30 */
3331
34#ifndef _RADIX_H_32#ifndef _RADIX_H_
lib/libc/include/generic-freebsd/net/rndis.h+1-1
...@@ -339,7 +339,7 @@ struct rndis_diag_info {...@@ -339,7 +339,7 @@ struct rndis_diag_info {
339 uint32_t rm_erroffset;339 uint32_t rm_erroffset;
340};340};
341341
342/* Keepalive messsage. May be sent by device. */342/* Keepalive message. May be sent by device. */
343#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008343#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008
344#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008344#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008
345345
lib/libc/include/generic-freebsd/net/route.h+2-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)route.h 8.4 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _NET_ROUTE_H_32#ifndef _NET_ROUTE_H_
...@@ -241,6 +239,7 @@ struct rtstat {...@@ -241,6 +239,7 @@ struct rtstat {
241 uint64_t rts_add_retry; /* # of route addition retries */239 uint64_t rts_add_retry; /* # of route addition retries */
242 uint64_t rts_del_failure; /* # of route deletion failure */240 uint64_t rts_del_failure; /* # of route deletion failure */
243 uint64_t rts_del_retry; /* # of route deletion retries */241 uint64_t rts_del_retry; /* # of route deletion retries */
242 uint64_t rts_spare[5];
244};243};
245244
246/*245/*
...@@ -296,6 +295,7 @@ struct rt_msghdr {...@@ -296,6 +295,7 @@ struct rt_msghdr {
296#define RTM_DELMADDR 0x10 /* (4) mcast group membership being deleted */295#define RTM_DELMADDR 0x10 /* (4) mcast group membership being deleted */
297#define RTM_IFANNOUNCE 0x11 /* (5) iface arrival/departure */296#define RTM_IFANNOUNCE 0x11 /* (5) iface arrival/departure */
298#define RTM_IEEE80211 0x12 /* (5) IEEE80211 wireless event */297#define RTM_IEEE80211 0x12 /* (5) IEEE80211 wireless event */
298#define RTM_IPFWLOG 0x13 /* (1) IPFW rule match log event */
299299
300#endif /* NETLINK_COMPAT*/300#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,...@@ -61,11 +61,11 @@ int rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen,
61 const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc);61 const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc);
6262
63/* operation flags */63/* operation flags */
64#define RTM_F_CREATE 0x0164#define RTM_F_CREATE 0x01 /* Create object if not exists */
65#define RTM_F_EXCL 0x0265#define RTM_F_EXCL 0x02 /* (Deprecated) Do not replace or append if exists */
66#define RTM_F_REPLACE 0x0466#define RTM_F_REPLACE 0x04 /* Replace if route (even multipath) if exists */
67#define RTM_F_APPEND 0x0867#define RTM_F_APPEND 0x08 /* Append path to the route */
68#define RTM_F_FORCE 0x1068#define RTM_F_FORCE 0x10 /* Bump operation priority to highest */
6969
70int rib_add_route(uint32_t fibnum, struct rt_addrinfo *info,70int rib_add_route(uint32_t fibnum, struct rt_addrinfo *info,
71 struct rib_cmd_info *rc);71 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);...@@ -116,10 +116,11 @@ SYSCTL_DECL(_net_route_debug);
116 * Example: [nhop_neigh] nhops_update_neigh: <message>116 * Example: [nhop_neigh] nhops_update_neigh: <message>
117 */117 */
118#define RT_LOG(_l, _fmt, ...) RT_LOG_##_l(_l, _fmt, ## __VA_ARGS__)118#define RT_LOG(_l, _fmt, ...) RT_LOG_##_l(_l, _fmt, ## __VA_ARGS__)
119#define _RT_LOG(_l, _fmt, ...) if (_DEBUG_PASS_MSG(_l)) { \119#define _RT_LOG(_l, _fmt, ...) do { \
120 _output("[" DEBUG_PREFIX_NAME "] %s: " _fmt "\n", __func__, ##__VA_ARGS__); \120 if (_DEBUG_PASS_MSG(_l)) \
121}121 _output("[" DEBUG_PREFIX_NAME "] %s: " _fmt "\n", \
122122 __func__, ##__VA_ARGS__); \
123} while (0)
123124
124/*125/*
125 * Wrapper logic to avoid compiling high levels of debugging messages for126 * 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 @@...@@ -26,6 +26,9 @@
26 * SUCH DAMAGE.26 * SUCH DAMAGE.
27 */27 */
2828
29#ifndef _NET_SFF8472_H_
30#define _NET_SFF8472_H_
31
29/*32/*
30 * The following set of constants are from Document SFF-847233 * The following set of constants are from Document SFF-8472
31 * "Diagnostic Monitoring Interface for Optical Transceivers" revision34 * "Diagnostic Monitoring Interface for Optical Transceivers" revision
...@@ -415,6 +418,7 @@ enum {...@@ -415,6 +418,7 @@ enum {
415 SFF_8024_ID_LAST = SFF_8024_ID_QSFP_CMIS418 SFF_8024_ID_LAST = SFF_8024_ID_QSFP_CMIS
416};419};
417420
421#if defined(_WANT_SFF_8024_ID) || defined(_WANT_SFF_8472_ID)
418static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {422static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {
419 "Unknown",423 "Unknown",
420 "GBIC",424 "GBIC",
...@@ -448,6 +452,7 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {...@@ -448,6 +452,7 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {
448 "x8MiniLink",452 "x8MiniLink",
449 "QSFP+(CIMS)"453 "QSFP+(CIMS)"
450};454};
455#endif
451456
452/* Keep compatibility with old definitions */457/* Keep compatibility with old definitions */
453#define SFF_8472_ID_UNKNOWN SFF_8024_ID_UNKNOWN458#define SFF_8472_ID_UNKNOWN SFF_8024_ID_UNKNOWN
...@@ -523,4 +528,6 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {...@@ -523,4 +528,6 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {
523 * yielding a total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm).528 * yielding a total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm).
524 */529 */
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);...@@ -311,6 +311,12 @@ void *vnet_data_alloc(int size);
311void vnet_data_copy(void *start, int size);311void vnet_data_copy(void *start, int size);
312void vnet_data_free(void *start_arg, int size);312void 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
314/*320/*
315 * Virtual sysinit mechanism, allowing network stack components to declare321 * Virtual sysinit mechanism, allowing network stack components to declare
316 * startup and shutdown methods to be run when virtual network stack322 * startup and shutdown methods to be run when virtual network stack
...@@ -400,7 +406,7 @@ do { \...@@ -400,7 +406,7 @@ do { \
400#define CURVNET_SET(arg)406#define CURVNET_SET(arg)
401#define CURVNET_SET_QUIET(arg)407#define CURVNET_SET_QUIET(arg)
402#define CURVNET_RESTORE()408#define CURVNET_RESTORE()
403#define CURVNET_ASSERT_SET() \409#define CURVNET_ASSERT_SET()
404410
405#define VNET_LIST_RLOCK()411#define VNET_LIST_RLOCK()
406#define VNET_LIST_RLOCK_NOSLEEP()412#define VNET_LIST_RLOCK_NOSLEEP()
lib/libc/include/generic-freebsd/net80211/_ieee80211.h+26-2
...@@ -536,6 +536,27 @@ struct ieee80211_mimo_info {...@@ -536,6 +536,27 @@ struct ieee80211_mimo_info {
536 "\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS\32TXLDPC\33RXAMSDUAMPDU" \536 "\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS\32TXLDPC\33RXAMSDUAMPDU" \
537 "\34TXAMSDUAMPDU"537 "\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
539/*560/*
540 * RX status notification - which fields are valid.561 * RX status notification - which fields are valid.
541 */562 */
...@@ -564,15 +585,18 @@ struct ieee80211_mimo_info {...@@ -564,15 +585,18 @@ struct ieee80211_mimo_info {
564#define IEEE80211_RX_F_AMPDU 0x00000010 /* This is the start of an decap AMPDU list */585#define IEEE80211_RX_F_AMPDU 0x00000010 /* This is the start of an decap AMPDU list */
565#define IEEE80211_RX_F_AMPDU_MORE 0x00000020 /* This is another decap AMPDU frame in the batch */586#define IEEE80211_RX_F_AMPDU_MORE 0x00000020 /* This is another decap AMPDU frame in the batch */
566#define IEEE80211_RX_F_FAIL_FCSCRC 0x00000040 /* Failed CRC/FCS */587#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 */
568#define IEEE80211_RX_F_DECRYPTED 0x00000100 /* Hardware decrypted */589#define IEEE80211_RX_F_DECRYPTED 0x00000100 /* Hardware decrypted */
569#define IEEE80211_RX_F_IV_STRIP 0x00000200 /* Decrypted; IV stripped */590#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 */
571#define IEEE80211_RX_F_SHORTGI 0x00000800 /* This is a short-GI frame */592#define IEEE80211_RX_F_SHORTGI 0x00000800 /* This is a short-GI frame */
572#define IEEE80211_RX_F_CCK 0x00001000593#define IEEE80211_RX_F_CCK 0x00001000
573#define IEEE80211_RX_F_OFDM 0x00002000594#define IEEE80211_RX_F_OFDM 0x00002000
574#define IEEE80211_RX_F_HT 0x00004000595#define IEEE80211_RX_F_HT 0x00004000
575#define IEEE80211_RX_F_VHT 0x00008000596#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
577/* Channel width */601/* Channel width */
578#define IEEE80211_RX_FW_20MHZ 1602#define IEEE80211_RX_FW_20MHZ 1
lib/libc/include/generic-freebsd/net80211/ieee80211.h+665-45
...@@ -4,6 +4,10 @@...@@ -4,6 +4,10 @@
4 * Copyright (c) 2001 Atsushi Onoe4 * Copyright (c) 2001 Atsushi Onoe
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
6 * All rights reserved.6 * 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.
7 *11 *
8 * Redistribution and use in source and binary forms, with or without12 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions13 * modification, are permitted provided that the following conditions
...@@ -28,6 +32,12 @@...@@ -28,6 +32,12 @@
28#ifndef _NET80211_IEEE80211_H_32#ifndef _NET80211_IEEE80211_H_
29#define _NET80211_IEEE80211_H_33#define _NET80211_IEEE80211_H_
3034
35#include <sys/types.h>
36
37#ifndef _KERNEL
38#include <stdbool.h>
39#endif
40
31/*41/*
32 * 802.11 protocol definitions.42 * 802.11 protocol definitions.
33 */43 */
...@@ -161,6 +171,7 @@ struct ieee80211_qosframe_addr4 {...@@ -161,6 +171,7 @@ struct ieee80211_qosframe_addr4 {
161/* 0001-0011 Reserved 0x10-0x30 */ /* Were: CF_ACK, CF_POLL, CF_ACPL */171/* 0001-0011 Reserved 0x10-0x30 */ /* Were: CF_ACK, CF_POLL, CF_ACPL */
162#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 /* Null */172#define IEEE80211_FC0_SUBTYPE_NODATA 0x40 /* Null */
163/* 0101-0111 Reserved 0x50-0x70 */ /* Were: CFACK, CFPOLL, CF_ACK_CF_ACK */173/* 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 */
164#define IEEE80211_FC0_SUBTYPE_QOS_DATA 0x80 /* QoS Data */175#define IEEE80211_FC0_SUBTYPE_QOS_DATA 0x80 /* QoS Data */
165#define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFACK 0x90 /* QoS Data +CF-Ack */176#define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFACK 0x90 /* QoS Data +CF-Ack */
166#define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFPOLL 0xa0 /* QoS Data +CF-Poll */177#define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFPOLL 0xa0 /* QoS Data +CF-Poll */
...@@ -190,24 +201,98 @@ struct ieee80211_qosframe_addr4 {...@@ -190,24 +201,98 @@ struct ieee80211_qosframe_addr4 {
190#define IEEE80211_CTL_EXT_TDD_BF 0x0b /* TDD Beamforming, 80211ay-2021 */201#define IEEE80211_CTL_EXT_TDD_BF 0x0b /* TDD Beamforming, 80211ay-2021 */
191/* 1100-1111 Reserved 0xc-0xf */202/* 1100-1111 Reserved 0xc-0xf */
192203
193#define IEEE80211_IS_MGMT(wh) \204/* Check the version field */
194 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \205#define IEEE80211_IS_FC0_CHECK_VER(wh, v) \
195 == IEEE80211_FC0_TYPE_MGT))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))
196#define IEEE80211_IS_CTL(wh) \222#define IEEE80211_IS_CTL(wh) \
197 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \223 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
198 == IEEE80211_FC0_TYPE_CTL))224 IEEE80211_FC0_TYPE_CTL))
199#define IEEE80211_IS_DATA(wh) \225#define IEEE80211_IS_DATA(wh) \
200 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \226 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
201 == IEEE80211_FC0_TYPE_DATA))227 IEEE80211_FC0_TYPE_DATA))
202#define IEEE80211_IS_EXT(wh) \228#define IEEE80211_IS_EXT(wh) \
203 (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \229 (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \
204 == IEEE80211_FC0_TYPE_EXT))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 \240#define IEEE80211_IS_MGMT_PROBE_RESP(wh) \
207 (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS_DATA|IEEE80211_FC0_VERSION_0)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
212#define IEEE80211_FC1_DIR_MASK 0x03297#define IEEE80211_FC1_DIR_MASK 0x03
213#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */298#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
...@@ -421,7 +506,7 @@ struct ieee80211_action {...@@ -421,7 +506,7 @@ struct ieee80211_action {
421#define IEEE80211_ACTION_CAT_BA 3 /* 9.6.4 Block Ack */506#define IEEE80211_ACTION_CAT_BA 3 /* 9.6.4 Block Ack */
422#define IEEE80211_ACTION_CAT_PUBLIC 4 /* 9.6.7 Public */507#define IEEE80211_ACTION_CAT_PUBLIC 4 /* 9.6.7 Public */
423#define IEEE80211_ACTION_CAT_RADIO_MEASUREMENT 5 /* 9.6.6 Radio Measurement */508#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 */
425#define IEEE80211_ACTION_CAT_HT 7 /* 9.6.11 HT */510#define IEEE80211_ACTION_CAT_HT 7 /* 9.6.11 HT */
426#define IEEE80211_ACTION_CAT_SA_QUERY 8 /* 9.6.9 SA Query */511#define IEEE80211_ACTION_CAT_SA_QUERY 8 /* 9.6.9 SA Query */
427#define IEEE80211_ACTION_CAT_PROTECTED_DUAL_OF_PUBLIC_ACTION 9 /* 9.6.10 Protected Dual of Public Action */512#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 {...@@ -856,6 +941,7 @@ enum ieee80211_vht_mcs_support {
856 IEEE80211_VHT_MCS_NOT_SUPPORTED = 3 /* not supported */941 IEEE80211_VHT_MCS_NOT_SUPPORTED = 3 /* not supported */
857};942};
858943
944/* 802.11ac-2013, 8.4.2.160.3 Supported VHT-MCS and NSS Set field */
859struct ieee80211_vht_mcs_info {945struct ieee80211_vht_mcs_info {
860 uint16_t rx_mcs_map;946 uint16_t rx_mcs_map;
861 uint16_t rx_highest;947 uint16_t rx_highest;
...@@ -869,12 +955,15 @@ struct ieee80211_vht_cap {...@@ -869,12 +955,15 @@ struct ieee80211_vht_cap {
869 struct ieee80211_vht_mcs_info supp_mcs;955 struct ieee80211_vht_mcs_info supp_mcs;
870} __packed;956} __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 */
873enum ieee80211_vht_chanwidth {962enum ieee80211_vht_chanwidth {
874 IEEE80211_VHT_CHANWIDTH_USE_HT = 0, /* 20 MHz or 40 MHz */963 IEEE80211_VHT_CHANWIDTH_USE_HT = 0, /* 20 MHz or 40 MHz */
875 IEEE80211_VHT_CHANWIDTH_80MHZ = 1, /* 80MHz */964 IEEE80211_VHT_CHANWIDTH_80MHZ = 1, /* 80MHz */
876 IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz */965 IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz (deprecated) */
877 IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz */966 IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz (deprecated) */
878 /* 4..255 reserved. */967 /* 4..255 reserved. */
879};968};
880969
...@@ -898,7 +987,7 @@ struct ieee80211_vht_operation {...@@ -898,7 +987,7 @@ struct ieee80211_vht_operation {
898987
899#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK 0x0000000C988#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK 0x0000000C
900#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S 2989#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S 2
901#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NONE 0990#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NO160 0
902#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ 1991#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ 1
903#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ 2992#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ 2
904#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_RESERVED 3993#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_RESERVED 3
...@@ -969,11 +1058,15 @@ struct ieee80211_vht_operation {...@@ -969,11 +1058,15 @@ struct ieee80211_vht_operation {
969#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN 0x200000001058#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN 0x20000000
970#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN_S 291059#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
972/*1065/*
973 * XXX TODO: add the rest of the bits1066 * XXX TODO: add the rest of the bits
974 */1067 */
975#define IEEE80211_VHTCAP_BITS \1068#define IEEE80211_VHTCAP_BITS \
976 "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN8080\5RXLDPC\6SHORTGI80" \1069 "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN160+80P80\5RXLDPC\6SHORTGI80" \
977 "\7SHORTGI160\10RXSTBC1\11RXSTBC2\12RXSTBC3\13RXSTBC4\14BFERCAP" \1070 "\7SHORTGI160\10RXSTBC1\11RXSTBC2\12RXSTBC3\13RXSTBC4\14BFERCAP" \
978 "\15BFEECAP\27VHT\37RXANTPTN\40TXANTPTN"1071 "\15BFEECAP\27VHT\37RXANTPTN\40TXANTPTN"
9791072
...@@ -1015,22 +1108,296 @@ struct ieee80211_ie_vht_txpwrenv {...@@ -1015,22 +1108,296 @@ struct ieee80211_ie_vht_txpwrenv {
1015#define WLAN_ACTION_VHT_GROUPID_MGMT 11108#define WLAN_ACTION_VHT_GROUPID_MGMT 1
1016#define WLAN_ACTION_VHT_OPMODE_NOTIF 21109#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
1018/*1376/*
1019 * Management information element payloads.1377 * Management information element payloads.
1378 *
1379 * 802.11-2020 Table 9-92 (Element IDs).
1380 * 802.11ax-2021
1020 */1381 */
10211382
1022enum {1383enum {
1023 IEEE80211_ELEMID_SSID = 0,1384 IEEE80211_ELEMID_SSID = 0,
1024 IEEE80211_ELEMID_RATES = 1,1385 IEEE80211_ELEMID_RATES = 1,
1025 IEEE80211_ELEMID_FHPARMS = 2,1386 /* 2 Reserved */
1387 IEEE80211_ELEMID_FHPARMS = 2, /* remove? */
1026 IEEE80211_ELEMID_DSPARMS = 3,1388 IEEE80211_ELEMID_DSPARMS = 3,
1027 IEEE80211_ELEMID_CFPARMS = 4,1389 /* 4 Reserved */
1390 IEEE80211_ELEMID_CFPARMS = 4, /* remove? */
1028 IEEE80211_ELEMID_TIM = 5,1391 IEEE80211_ELEMID_TIM = 5,
1029 IEEE80211_ELEMID_IBSSPARMS = 6,1392 IEEE80211_ELEMID_IBSSPARMS = 6,
1030 IEEE80211_ELEMID_COUNTRY = 7,1393 IEEE80211_ELEMID_COUNTRY = 7,
1394 /* 8, 9 reserved */
1395 IEEE80211_ELEMID_REQUEST = 10,
1031 IEEE80211_ELEMID_BSSLOAD = 11,1396 IEEE80211_ELEMID_BSSLOAD = 11,
1397 IEEE80211_ELEMID_EDCA_PARAM_SET = 12,
1032 IEEE80211_ELEMID_TSPEC = 13,1398 IEEE80211_ELEMID_TSPEC = 13,
1033 IEEE80211_ELEMID_TCLAS = 14,1399 IEEE80211_ELEMID_TCLAS = 14,
1400 IEEE80211_ELEMID_SCHEDULE = 15,
1034 IEEE80211_ELEMID_CHALLENGE = 16,1401 IEEE80211_ELEMID_CHALLENGE = 16,
1035 /* 17-31 reserved for challenge text extension */1402 /* 17-31 reserved for challenge text extension */
1036 IEEE80211_ELEMID_PWRCNSTR = 32,1403 IEEE80211_ELEMID_PWRCNSTR = 32,
...@@ -1044,28 +1411,77 @@ enum {...@@ -1044,28 +1411,77 @@ enum {
1044 IEEE80211_ELEMID_QUIET = 40,1411 IEEE80211_ELEMID_QUIET = 40,
1045 IEEE80211_ELEMID_IBSSDFS = 41,1412 IEEE80211_ELEMID_IBSSDFS = 41,
1046 IEEE80211_ELEMID_ERP = 42,1413 IEEE80211_ELEMID_ERP = 42,
1414 IEEE80211_ELEMID_TS_DELAY = 43,
1415 IEEE80211_ELEMID_TCLAS_PROCES = 44,
1047 IEEE80211_ELEMID_HTCAP = 45,1416 IEEE80211_ELEMID_HTCAP = 45,
1048 IEEE80211_ELEMID_QOS = 46,1417 IEEE80211_ELEMID_QOS = 46,
1418 /* 47 reserved */
1049 IEEE80211_ELEMID_RESERVED_47 = 47,1419 IEEE80211_ELEMID_RESERVED_47 = 47,
1050 IEEE80211_ELEMID_RSN = 48,1420 IEEE80211_ELEMID_RSN = 48,
1421 /* 49 reserved */
1051 IEEE80211_ELEMID_XRATES = 50,1422 IEEE80211_ELEMID_XRATES = 50,
1052 IEEE80211_ELEMID_APCHANREP = 51,1423 IEEE80211_ELEMID_APCHANREP = 51,
1053 IEEE80211_ELEMID_MOBILITY_DOMAIN = 54,1424 IEEE80211_ELEMID_NEIGHBOR_REP = 52,
1054 IEEE80211_ELEMID_HTINFO = 61,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 */
1055 IEEE80211_ELEMID_SECCHAN_OFFSET = 62,1434 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 */
1057 IEEE80211_ELEMID_MULTIBSSID = 71,1443 IEEE80211_ELEMID_MULTIBSSID = 71,
1058 IEEE80211_ELEMID_COEX_2040 = 72,1444 IEEE80211_ELEMID_COEX_2040 = 72,
1059 IEEE80211_ELEMID_INTOL_CHN_REPORT = 73,1445 IEEE80211_ELEMID_2040_INTOL_CHAN_REPORT = 73,
1060 IEEE80211_ELEMID_OVERLAP_BSS_SCAN_PARAM = 74,1446 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,
1061 IEEE80211_ELEMID_TSF_REQ = 91,1463 IEEE80211_ELEMID_TSF_REQ = 91,
1062 IEEE80211_ELEMID_TSF_RESP = 92,1464 IEEE80211_ELEMID_TSF_RESP = 92,
1063 IEEE80211_ELEMID_WNM_SLEEP_MODE = 93,1465 IEEE80211_ELEMID_WNM_SLEEP_MODE = 93,
1064 IEEE80211_ELEMID_TIM_BCAST_REQ = 94,1466 IEEE80211_ELEMID_TIM_BCAST_REQ = 94,
1065 IEEE80211_ELEMID_TIM_BCAST_RESP = 95,1467 IEEE80211_ELEMID_TIM_BCAST_RESP = 95,
1066 IEEE80211_ELEMID_TPC = 150,1468 IEEE80211_ELEMID_COL_INTERF_REP = 96,
1067 IEEE80211_ELEMID_CCKM = 156,1469 IEEE80211_ELEMID_CHAN_USAGE = 97,
1068 IEEE80211_ELEMID_VENDOR = 221, /* vendor private */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
1070 /*1486 /*
1071 * 802.11s IEs1487 * 802.11s IEs
...@@ -1095,17 +1511,180 @@ enum {...@@ -1095,17 +1511,180 @@ enum {
1095 IEEE80211_ELEMID_MESHPXU = 137,1511 IEEE80211_ELEMID_MESHPXU = 137,
1096 IEEE80211_ELEMID_MESHPXUC = 138,1512 IEEE80211_ELEMID_MESHPXUC = 138,
1097 IEEE80211_ELEMID_MESHAH = 60, /* XXX: remove */1513 IEEE80211_ELEMID_MESHAH = 60, /* XXX: remove */
10981514 /* XXX 139 */
1099 /* 802.11ac-2013, Table 8-54-Element IDs */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,
1100 IEEE80211_ELEMID_VHT_CAP = 191,1565 IEEE80211_ELEMID_VHT_CAP = 191,
1101 IEEE80211_ELEMID_VHT_OPMODE = 192,1566 IEEE80211_ELEMID_VHT_OPMODE = 192,
1102 IEEE80211_ELEMID_EXTENDED_BSS_LOAD = 193,1567 IEEE80211_ELEMID_EXTENDED_BSS_LOAD = 193,
1103 IEEE80211_ELEMID_WIDE_BW_CHANNEL_SWITCH = 194,1568 IEEE80211_ELEMID_WIDE_BW_CHAN_SW = 194,
1104 IEEE80211_ELEMID_VHT_PWR_ENV = 195,1569 IEEE80211_ELEMID_VHT_PWR_ENV = 195, /* TX_PWR_ENV */
1105 IEEE80211_ELEMID_CHANNEL_SWITCH_WRAPPER = 196,1570 IEEE80211_ELEMID_CHANNEL_SWITCH_WRAPPER = 196,
1106 IEEE80211_ELEMID_AID = 197,1571 IEEE80211_ELEMID_AID = 197,
1107 IEEE80211_ELEMID_QUIET_CHANNEL = 198,1572 IEEE80211_ELEMID_QUIET_CHANNEL = 198,
1108 IEEE80211_ELEMID_OPMODE_NOTIF = 199,1573 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. */
1109};1688};
11101689
1111struct ieee80211_tim_ie {1690struct ieee80211_tim_ie {
...@@ -1266,7 +1845,7 @@ struct ieee80211_csa_ie {...@@ -1266,7 +1845,7 @@ struct ieee80211_csa_ie {
1266#define WPA_CSE_NULL 0x001845#define WPA_CSE_NULL 0x00
1267#define WPA_CSE_WEP40 0x011846#define WPA_CSE_WEP40 0x01
1268#define WPA_CSE_TKIP 0x021847#define WPA_CSE_TKIP 0x02
1269#define WPA_CSE_CCMP 0x041848#define WPA_CSE_CCMP 0x04 /* CCMP 128-bit */
1270#define WPA_CSE_WEP104 0x051849#define WPA_CSE_WEP104 0x05
12711850
1272#define WPA_ASE_NONE 0x001851#define WPA_ASE_NONE 0x00
...@@ -1275,21 +1854,62 @@ struct ieee80211_csa_ie {...@@ -1275,21 +1854,62 @@ struct ieee80211_csa_ie {
12751854
1276#define WPS_OUI_TYPE 0x041855#define WPS_OUI_TYPE 0x04
12771856
1857/* 802.11-2016 Table 9-131 - Cipher Suite Selectors */
1278#define RSN_OUI 0xac0f001858#define RSN_OUI 0xac0f00
1279#define RSN_VERSION 1 /* current supported version */1859#define RSN_VERSION 1 /* current supported version */
12801860
1281#define RSN_CSE_NULL 0x001861/* RSN cipher suite element */
1282#define RSN_CSE_WEP40 0x011862#define RSN_CSE_NULL 0
1283#define RSN_CSE_TKIP 0x021863#define RSN_CSE_WEP40 1
1284#define RSN_CSE_WRAP 0x031864#define RSN_CSE_TKIP 2
1285#define RSN_CSE_CCMP 0x041865#define RSN_CSE_WRAP 3 /* Reserved in the 802.11-2016 */
1286#define RSN_CSE_WEP104 0x051866#define RSN_CSE_CCMP 4 /* CCMP 128 bit */
12871867#define RSN_CSE_WEP104 5
1288#define RSN_ASE_NONE 0x001868#define RSN_CSE_BIP_CMAC_128 6
1289#define RSN_ASE_8021X_UNSPEC 0x011869/* 7 - "Group addressed traffic not allowed" */
1290#define RSN_ASE_8021X_PSK 0x021870#define RSN_CSE_GCMP_128 8
12911871#define RSN_CSE_GCMP_256 9
1292#define RSN_CAP_PREAUTH 0x011872#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
1294#define WME_OUI 0xf250001914#define WME_OUI 0xf25000
1295#define WME_OUI_TYPE 0x021915#define WME_OUI_TYPE 0x02
lib/libc/include/generic-freebsd/net80211/ieee80211_amrr.h+4
...@@ -49,6 +49,10 @@ struct ieee80211_amrr_node {...@@ -49,6 +49,10 @@ struct ieee80211_amrr_node {
49 struct ieee80211_amrr *amn_amrr;/* backpointer */49 struct ieee80211_amrr *amn_amrr;/* backpointer */
50 int amn_rix; /* current rate index */50 int amn_rix; /* current rate index */
51 int amn_ticks; /* time of last update */51 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
52 /* statistics */56 /* statistics */
53 u_int amn_txcnt;57 u_int amn_txcnt;
54 u_int amn_success;58 u_int amn_success;
lib/libc/include/generic-freebsd/net80211/ieee80211_crypto.h+57-7
...@@ -118,8 +118,8 @@ struct ieee80211_key {...@@ -118,8 +118,8 @@ struct ieee80211_key {
118 IEEE80211_KEY_NOIVMGT|IEEE80211_KEY_NOMIC|IEEE80211_KEY_NOMICMGT)118 IEEE80211_KEY_NOIVMGT|IEEE80211_KEY_NOMIC|IEEE80211_KEY_NOMICMGT)
119119
120#define IEEE80211_KEY_BITS \120#define IEEE80211_KEY_BITS \
121 "\20\1XMIT\2RECV\3GROUP\4SWENCRYPT\5SWDECRYPT\6SWENMIC\7SWDEMIC" \121 "\20\1XMIT\2RECV\3GROUP\4NOREPLAY\5SWENCRYPT\6SWDECRYPT\7SWENMIC\10SWDEMIC" \
122 "\10DEVKEY\11CIPHER0\12CIPHER1"122 "\11DEVKEY\12CIPHER0\13CIPHER1\14NOIV\15NOIVMGT\16NOMIC\17NOMICMGT"
123123
124#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1)124#define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1)
125125
...@@ -137,8 +137,17 @@ struct ieee80211_key {...@@ -137,8 +137,17 @@ struct ieee80211_key {
137#define IEEE80211_CIPHER_TKIPMIC 4 /* TKIP MIC capability */137#define IEEE80211_CIPHER_TKIPMIC 4 /* TKIP MIC capability */
138#define IEEE80211_CIPHER_CKIP 5138#define IEEE80211_CIPHER_CKIP 5
139#define IEEE80211_CIPHER_NONE 6 /* pseudo value */139#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
143/* capability bits in ic_cryptocaps/iv_cryptocaps */152/* capability bits in ic_cryptocaps/iv_cryptocaps */
144#define IEEE80211_CRYPTO_WEP (1<<IEEE80211_CIPHER_WEP)153#define IEEE80211_CRYPTO_WEP (1<<IEEE80211_CIPHER_WEP)
...@@ -147,9 +156,18 @@ struct ieee80211_key {...@@ -147,9 +156,18 @@ struct ieee80211_key {
147#define IEEE80211_CRYPTO_AES_CCM (1<<IEEE80211_CIPHER_AES_CCM)156#define IEEE80211_CRYPTO_AES_CCM (1<<IEEE80211_CIPHER_AES_CCM)
148#define IEEE80211_CRYPTO_TKIPMIC (1<<IEEE80211_CIPHER_TKIPMIC)157#define IEEE80211_CRYPTO_TKIPMIC (1<<IEEE80211_CIPHER_TKIPMIC)
149#define IEEE80211_CRYPTO_CKIP (1<<IEEE80211_CIPHER_CKIP)158#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
151#define IEEE80211_CRYPTO_BITS \167#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
154#if defined(__KERNEL__) || defined(_KERNEL)172#if defined(__KERNEL__) || defined(_KERNEL)
155173
...@@ -162,6 +180,12 @@ MALLOC_DECLARE(M_80211_CRYPTO);...@@ -162,6 +180,12 @@ MALLOC_DECLARE(M_80211_CRYPTO);
162180
163void ieee80211_crypto_attach(struct ieee80211com *);181void ieee80211_crypto_attach(struct ieee80211com *);
164void ieee80211_crypto_detach(struct ieee80211com *);182void 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);
165void ieee80211_crypto_vattach(struct ieee80211vap *);189void ieee80211_crypto_vattach(struct ieee80211vap *);
166void ieee80211_crypto_vdetach(struct ieee80211vap *);190void ieee80211_crypto_vdetach(struct ieee80211vap *);
167int ieee80211_crypto_newkey(struct ieee80211vap *,191int ieee80211_crypto_newkey(struct ieee80211vap *,
...@@ -192,6 +216,11 @@ struct ieee80211_cipher {...@@ -192,6 +216,11 @@ struct ieee80211_cipher {
192 void (*ic_setiv)(struct ieee80211_key *, uint8_t *);216 void (*ic_setiv)(struct ieee80211_key *, uint8_t *);
193 int (*ic_encap)(struct ieee80211_key *, struct mbuf *);217 int (*ic_encap)(struct ieee80211_key *, struct mbuf *);
194 int (*ic_decap)(struct ieee80211_key *, struct mbuf *, int);218 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 */
195 int (*ic_enmic)(struct ieee80211_key *, struct mbuf *, int);224 int (*ic_enmic)(struct ieee80211_key *, struct mbuf *, int);
196 int (*ic_demic)(struct ieee80211_key *, struct mbuf *, int);225 int (*ic_demic)(struct ieee80211_key *, struct mbuf *, int);
197};226};
...@@ -216,8 +245,24 @@ int ieee80211_crypto_decap(struct ieee80211_node *,...@@ -216,8 +245,24 @@ int ieee80211_crypto_decap(struct ieee80211_node *,
216 struct mbuf *, int, struct ieee80211_key **);245 struct mbuf *, int, struct ieee80211_key **);
217int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,246int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
218 struct mbuf *, int);247 struct mbuf *, int);
219/*248/**
220 * Add any MIC.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
221 */266 */
222static __inline int267static __inline int
223ieee80211_crypto_enmic(struct ieee80211vap *vap,268ieee80211_crypto_enmic(struct ieee80211vap *vap,
...@@ -249,6 +294,11 @@ void ieee80211_notify_replay_failure(struct ieee80211vap *,...@@ -249,6 +294,11 @@ void ieee80211_notify_replay_failure(struct ieee80211vap *,
249 const struct ieee80211_frame *, const struct ieee80211_key *,294 const struct ieee80211_frame *, const struct ieee80211_key *,
250 uint64_t rsc, int tid);295 uint64_t rsc, int tid);
251void ieee80211_notify_michael_failure(struct ieee80211vap *,296void 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
253#endif /* defined(__KERNEL__) || defined(_KERNEL) */303#endif /* defined(__KERNEL__) || defined(_KERNEL) */
254#endif /* _NET80211_IEEE80211_CRYPTO_H_ */304#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 {...@@ -73,6 +73,8 @@ typedef struct {
73 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED)73 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED)
74#define IEEE80211_UNLOCK_ASSERT(_ic) \74#define IEEE80211_UNLOCK_ASSERT(_ic) \
75 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_NOTOWNED)75 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_NOTOWNED)
76#define IEEE80211_IS_LOCKED(_ic) \
77 mtx_owned(IEEE80211_LOCK_OBJ(_ic))
7678
77/*79/*
78 * Transmit lock.80 * Transmit lock.
...@@ -91,12 +93,22 @@ typedef struct {...@@ -91,12 +93,22 @@ typedef struct {
91} while (0)93} while (0)
92#define IEEE80211_TX_LOCK_OBJ(_ic) (&(_ic)->ic_txlock.mtx)94#define IEEE80211_TX_LOCK_OBJ(_ic) (&(_ic)->ic_txlock.mtx)
93#define IEEE80211_TX_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_TX_LOCK_OBJ(_ic))95#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))96#define IEEE80211_TX_LOCK(_ic) do { \
95#define IEEE80211_TX_UNLOCK(_ic) mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic))97 if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \
96#define IEEE80211_TX_LOCK_ASSERT(_ic) \98 mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic)); \
97 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED)99 } while (0);
98#define IEEE80211_TX_UNLOCK_ASSERT(_ic) \100#define IEEE80211_TX_UNLOCK(_ic) do { \
99 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED)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
101/*113/*
102 * Stageq / ni_tx_superg lock114 * Stageq / ni_tx_superg lock
...@@ -260,9 +272,9 @@ void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);...@@ -260,9 +272,9 @@ void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
260void ieee80211_vap_destroy(struct ieee80211vap *);272void ieee80211_vap_destroy(struct ieee80211vap *);
261const char * ieee80211_get_vap_ifname(struct ieee80211vap *);273const char * ieee80211_get_vap_ifname(struct ieee80211vap *);
262274
263#define IFNET_IS_UP_RUNNING(_ifp) \275#define IFNET_IS_UP_RUNNING(_ifp) \
264 (((_ifp)->if_flags & IFF_UP) && \276 (((if_getflags(_ifp) & IFF_UP) != 0) && \
265 ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))277 ((if_getdrvflags(_ifp) & IFF_DRV_RUNNING) != 0))
266278
267#define msecs_to_ticks(ms) MSEC_2_TICKS(ms)279#define msecs_to_ticks(ms) MSEC_2_TICKS(ms)
268#define ticks_to_msecs(t) TICKS_2_MSEC(t)280#define ticks_to_msecs(t) TICKS_2_MSEC(t)
...@@ -329,11 +341,16 @@ struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);...@@ -329,11 +341,16 @@ struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
329#define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)341#define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)
330342
331/*343/*
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.
333 */350 */
334#define M_SEQNO_SET(m, seqno) \351#define M_SEQNO_SET(m, seqno) \
335 ((m)->m_pkthdr.tso_segsz = (seqno))352 ((m)->m_pkthdr.tso_segsz = ((seqno) % IEEE80211_SEQ_RANGE))
336#define M_SEQNO_GET(m) ((m)->m_pkthdr.tso_segsz)353#define M_SEQNO_GET(m) (((m)->m_pkthdr.tso_segsz) % IEEE80211_SEQ_RANGE)
337354
338#define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */355#define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */
339356
...@@ -417,8 +434,7 @@ MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)...@@ -417,8 +434,7 @@ MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
417/*434/*
418 * Crypto modules implement cipher support.435 * Crypto modules implement cipher support.
419 */436 */
420#define IEEE80211_CRYPTO_MODULE(name, version) \437#define IEEE80211_CRYPTO_MODULE_ADD(name) \
421_IEEE80211_POLICY_MODULE(crypto, name, version); \
422static void \438static void \
423name##_modevent(int type) \439name##_modevent(int type) \
424{ \440{ \
...@@ -429,6 +445,10 @@ name##_modevent(int type) \...@@ -429,6 +445,10 @@ name##_modevent(int type) \
429} \445} \
430TEXT_SET(crypto##_set, name##_modevent)446TEXT_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
432/*452/*
433 * Scanner modules provide scanning policy.453 * Scanner modules provide scanning policy.
434 */454 */
...@@ -535,6 +555,21 @@ struct debugnet80211_methods {...@@ -535,6 +555,21 @@ struct debugnet80211_methods {
535#define DEBUGNET80211_SET(ic, driver)555#define DEBUGNET80211_SET(ic, driver)
536#endif /* DEBUGNET */556#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
538#endif /* _KERNEL */573#endif /* _KERNEL */
539574
540/* XXX this stuff belongs elsewhere */575/* XXX this stuff belongs elsewhere */
lib/libc/include/generic-freebsd/net80211/ieee80211_ht.h+8-1
...@@ -87,7 +87,8 @@ struct ieee80211_tx_ampdu {...@@ -87,7 +87,8 @@ struct ieee80211_tx_ampdu {
87 (IEEE80211_AGGR_RUNNING|IEEE80211_AGGR_XCHGPEND|IEEE80211_AGGR_NAK)) != 0)87 (IEEE80211_AGGR_RUNNING|IEEE80211_AGGR_XCHGPEND|IEEE80211_AGGR_NAK)) != 0)
8888
89#define IEEE80211_AGGR_BITS \89#define IEEE80211_AGGR_BITS \
90 "\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK"90 "\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK" \
91 "\6BARPEND\7WAITRX\10AMSDU"
9192
92/*93/*
93 * Traffic estimator support. We estimate packets/sec for94 * Traffic estimator support. We estimate packets/sec for
...@@ -240,5 +241,11 @@ int ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid);...@@ -240,5 +241,11 @@ int ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid);
240int ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni,241int ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni,
241 int tid, int status);242 int tid, int status);
242void ieee80211_htinfo_notify(struct ieee80211vap *vap);243void 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
244#endif /* _NET80211_IEEE80211_HT_H_ */251#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 {...@@ -253,6 +253,14 @@ struct ieee80211_stats {
253 uint32_t is_ff_encapfail; /* failed FF encap */253 uint32_t is_ff_encapfail; /* failed FF encap */
254 uint32_t is_amsdu_encapfail; /* failed A-MSDU encap */254 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
256 uint32_t is_spare[5];264 uint32_t is_spare[5];
257};265};
258266
...@@ -551,13 +559,13 @@ struct ieee80211_regdomain_req {...@@ -551,13 +559,13 @@ struct ieee80211_regdomain_req {
551 IEEE80211_REGDOMAIN_SIZE((_req)->chaninfo.ic_nchans)559 IEEE80211_REGDOMAIN_SIZE((_req)->chaninfo.ic_nchans)
552560
553/*561/*
554 * Get driver capabilities. Driver, hardware crypto, and562 * Get driver capabilities. Driver, hardware/software crypto, and
555 * HT/802.11n capabilities, and a table that describes what563 * HT/802.11n capabilities, and a table that describes what
556 * the radio can do.564 * the radio can do.
557 */565 */
558struct ieee80211_devcaps_req {566struct ieee80211_devcaps_req {
559 uint32_t dc_drivercaps; /* general driver caps */567 uint32_t dc_drivercaps; /* general driver caps */
560 uint32_t dc_cryptocaps; /* hardware crypto support */568 uint32_t dc_cryptocaps; /* software + hardware crypto support */
561 uint32_t dc_htcaps; /* HT/802.11n support */569 uint32_t dc_htcaps; /* HT/802.11n support */
562 uint32_t dc_vhtcaps; /* VHT/802.11ac capabilities */570 uint32_t dc_vhtcaps; /* VHT/802.11ac capabilities */
563 struct ieee80211req_chaninfo dc_chaninfo;571 struct ieee80211req_chaninfo dc_chaninfo;
lib/libc/include/generic-freebsd/net80211/ieee80211_node.h+91-5
...@@ -108,6 +108,69 @@ enum ieee80211_mesh_mlstate {...@@ -108,6 +108,69 @@ enum ieee80211_mesh_mlstate {
108#define IEEE80211_MESH_MLSTATE_BITS \108#define IEEE80211_MESH_MLSTATE_BITS \
109 "\20\1IDLE\2OPENSNT\2OPENRCV\3CONFIRMRCV\4ESTABLISHED\5HOLDING"109 "\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
111/*174/*
112 * Node specific information. Note that drivers are expected175 * Node specific information. Note that drivers are expected
113 * to derive from this structure to add device-specific per-node176 * to derive from this structure to add device-specific per-node
...@@ -222,15 +285,15 @@ struct ieee80211_node {...@@ -222,15 +285,15 @@ struct ieee80211_node {
222 uint8_t ni_ht2ndchan; /* HT 2nd channel */285 uint8_t ni_ht2ndchan; /* HT 2nd channel */
223 uint8_t ni_htopmode; /* HT operating mode */286 uint8_t ni_htopmode; /* HT operating mode */
224 uint8_t ni_htstbc; /* HT */287 uint8_t ni_htstbc; /* HT */
225 uint8_t ni_chw; /* negotiated channel width */288 enum net80211_sta_rx_bw ni_chw; /* negotiated channel width */
226 struct ieee80211_htrateset ni_htrates; /* negotiated ht rate set */289 struct ieee80211_htrateset ni_htrates; /* negotiated ht rate set */
227 struct ieee80211_tx_ampdu ni_tx_ampdu[WME_NUM_TID];290 struct ieee80211_tx_ampdu ni_tx_ampdu[WME_NUM_TID];
228 struct ieee80211_rx_ampdu ni_rx_ampdu[WME_NUM_TID];291 struct ieee80211_rx_ampdu ni_rx_ampdu[WME_NUM_TID];
229292
230 /* VHT state */293 /* VHT state */
231 uint32_t ni_vhtcap;294 uint32_t ni_vhtcap;
232 uint16_t ni_vht_basicmcs;295 uint16_t ni_vht_basicmcs; /* Basic VHT MCS bitmap from IE */
233 uint16_t ni_vht_pad2;296 uint16_t ni_vht_tx_map; /* Negotiated MCS TX map with peer */
234 struct ieee80211_vht_mcs_info ni_vht_mcsinfo;297 struct ieee80211_vht_mcs_info ni_vht_mcsinfo;
235 uint8_t ni_vht_chan1; /* 20/40/80/160 - VHT chan1 */298 uint8_t ni_vht_chan1; /* 20/40/80/160 - VHT chan1 */
236 uint8_t ni_vht_chan2; /* 80+80 - VHT chan2 */299 uint8_t ni_vht_chan2; /* 80+80 - VHT chan2 */
...@@ -244,7 +307,7 @@ struct ieee80211_node {...@@ -244,7 +307,7 @@ struct ieee80211_node {
244 /* others */307 /* others */
245 short ni_inact; /* inactivity mark count */308 short ni_inact; /* inactivity mark count */
246 short ni_inact_reload;/* inactivity reload value */309 short ni_inact_reload;/* inactivity reload value */
247 int ni_txrate; /* legacy rate/MCS */310 struct ieee80211_node_txrate ni_txrate; /* current transmit rate */
248 struct ieee80211_psq ni_psq; /* power save queue */311 struct ieee80211_psq ni_psq; /* power save queue */
249 struct ieee80211_nodestats ni_stats; /* per-node statistics */312 struct ieee80211_nodestats ni_stats; /* per-node statistics */
250313
...@@ -279,7 +342,7 @@ MALLOC_DECLARE(M_80211_NODE_IE);...@@ -279,7 +342,7 @@ MALLOC_DECLARE(M_80211_NODE_IE);
279#define IEEE80211_NODE_BITS \342#define IEEE80211_NODE_BITS \
280 "\20\1AUTH\2QOS\3ERP\5PWR_MGT\6AREF\7HT\10HTCOMPAT\11WPS\12TSN" \343 "\20\1AUTH\2QOS\3ERP\5PWR_MGT\6AREF\7HT\10HTCOMPAT\11WPS\12TSN" \
281 "\13AMPDU_RX\14AMPDU_TX\15MIMO_PS\16MIMO_RTS\17RIFS\20SGI20\21SGI40" \344 "\13AMPDU_RX\14AMPDU_TX\15MIMO_PS\16MIMO_RTS\17RIFS\20SGI20\21SGI40" \
282 "\22ASSOCID"345 "\22ASSOCID\23AMSDU_RX\24AMSDU_TX\25VHT\26LDPC\27UAPSD"
283346
284#define IEEE80211_NODE_AID(ni) IEEE80211_AID(ni->ni_associd)347#define IEEE80211_NODE_AID(ni) IEEE80211_AID(ni->ni_associd)
285348
...@@ -467,4 +530,27 @@ void ieee80211_node_join(struct ieee80211_node *,int);...@@ -467,4 +530,27 @@ void ieee80211_node_join(struct ieee80211_node *,int);
467void ieee80211_node_leave(struct ieee80211_node *);530void ieee80211_node_leave(struct ieee80211_node *);
468int8_t ieee80211_getrssi(struct ieee80211vap *);531int8_t ieee80211_getrssi(struct ieee80211vap *);
469void ieee80211_getsignal(struct ieee80211vap *, int8_t *, int8_t *);532void 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
470#endif /* _NET80211_IEEE80211_NODE_H_ */556#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,...@@ -221,5 +221,14 @@ uint32_t ieee80211_compute_duration_ht(uint32_t frameLen,
221 uint16_t rate, int streams, int isht40,221 uint16_t rate, int streams, int isht40,
222 int isShortGI);222 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
224#endif /* _KERNEL */233#endif /* _KERNEL */
225#endif /* !_NET80211_IEEE80211_PHY_H_ */234#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 *,...@@ -123,6 +123,10 @@ struct mbuf * ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *,
123 const struct ether_header *);123 const struct ether_header *);
124void ieee80211_tx_complete(struct ieee80211_node *,124void ieee80211_tx_complete(struct ieee80211_node *,
125 struct mbuf *, int);125 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
127/*131/*
128 * The formation of ProbeResponse frames requires guidance to132 * 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)...@@ -127,12 +127,12 @@ ieee80211_ratectl_node_deinit(struct ieee80211_node *ni)
127 vap->iv_rate->ir_node_deinit(ni);127 vap->iv_rate->ir_node_deinit(ni);
128}128}
129129
130static int __inline130static void __inline
131ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg)131ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg)
132{132{
133 const struct ieee80211vap *vap = ni->ni_vap;133 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);
136}136}
137137
138static __inline void138static __inline void
lib/libc/include/generic-freebsd/net80211/ieee80211_var.h+45-9
...@@ -100,6 +100,8 @@...@@ -100,6 +100,8 @@
100 ((ic)->ic_flags_ext & IEEE80211_FEXT_SEQNO_OFFLOAD)100 ((ic)->ic_flags_ext & IEEE80211_FEXT_SEQNO_OFFLOAD)
101#define IEEE80211_CONF_FRAG_OFFLOAD(ic) \101#define IEEE80211_CONF_FRAG_OFFLOAD(ic) \
102 ((ic)->ic_flags_ext & IEEE80211_FEXT_FRAG_OFFLOAD)102 ((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
104/*106/*
105 * 802.11 control state is split into a common portion that maps107 * 802.11 control state is split into a common portion that maps
...@@ -163,8 +165,12 @@ struct ieee80211com {...@@ -163,8 +165,12 @@ struct ieee80211com {
163 uint32_t ic_caps; /* capabilities */165 uint32_t ic_caps; /* capabilities */
164 uint32_t ic_htcaps; /* HT capabilities */166 uint32_t ic_htcaps; /* HT capabilities */
165 uint32_t ic_htextcaps; /* HT extended capabilities */167 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 */
167 /* set of mode capabilities */171 /* set of mode capabilities */
172 /* driver/net80211 sw KEYMGMT capabilities */
173 uint32_t ic_sw_keymgmtcaps;
168 uint8_t ic_modecaps[IEEE80211_MODE_BYTES];174 uint8_t ic_modecaps[IEEE80211_MODE_BYTES];
169 uint8_t ic_promisc; /* vap's needing promisc mode */175 uint8_t ic_promisc; /* vap's needing promisc mode */
170 uint8_t ic_allmulti; /* vap's needing all multicast*/176 uint8_t ic_allmulti; /* vap's needing all multicast*/
...@@ -693,13 +699,14 @@ MALLOC_DECLARE(M_80211_VAP);...@@ -693,13 +699,14 @@ MALLOC_DECLARE(M_80211_VAP);
693#define IEEE80211_FEXT_VHT 0x00400000 /* CONF: VHT support */699#define IEEE80211_FEXT_VHT 0x00400000 /* CONF: VHT support */
694#define IEEE80211_FEXT_QUIET_IE 0x00800000 /* STATUS: quiet IE in a beacon has been added */700#define IEEE80211_FEXT_QUIET_IE 0x00800000 /* STATUS: quiet IE in a beacon has been added */
695#define IEEE80211_FEXT_UAPSD 0x01000000 /* CONF: enable U-APSD */701#define IEEE80211_FEXT_UAPSD 0x01000000 /* CONF: enable U-APSD */
702#define IEEE80211_FEXT_AMPDU_OFFLOAD 0x02000000 /* CONF: driver/fw handles AMPDU[-TX] itself */
696703
697#define IEEE80211_FEXT_BITS \704#define IEEE80211_FEXT_BITS \
698 "\20\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \705 "\20\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \
699 "\0114ADDR\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\16STATEWAIT\17REINIT" \706 "\0114ADDR\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\16STATEWAIT\17REINIT" \
700 "\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC\24SCAN_OFFLOAD\25SEQNO_OFFLOAD" \707 "\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC\24SCAN_OFFLOAD\25SEQNO_OFFLOAD" \
701 "\26FRAG_OFFLOAD\27VHT" \708 "\26FRAG_OFFLOAD\27VHT" \
702 "\30QUIET_IE\31UAPSD"709 "\30QUIET_IE\31UAPSD\32AMPDU_OFFLOAD"
703710
704/* ic_flags_ht/iv_flags_ht */711/* ic_flags_ht/iv_flags_ht */
705#define IEEE80211_FHT_NONHT_PR 0x00000001 /* STATUS: non-HT sta present */712#define IEEE80211_FHT_NONHT_PR 0x00000001 /* STATUS: non-HT sta present */
...@@ -728,17 +735,29 @@ MALLOC_DECLARE(M_80211_VAP);...@@ -728,17 +735,29 @@ MALLOC_DECLARE(M_80211_VAP);
728735
729#define IEEE80211_FVEN_BITS "\20"736#define IEEE80211_FVEN_BITS "\20"
730737
738/*
739 * These flags are compared in ieee80211_setupcurchan().
740 * Thus 160 should be > 80P80.
741 */
731#define IEEE80211_FVHT_VHT 0x000000001 /* CONF: VHT supported */742#define IEEE80211_FVHT_VHT 0x000000001 /* CONF: VHT supported */
732#define IEEE80211_FVHT_USEVHT40 0x000000002 /* CONF: Use VHT40 */743#define IEEE80211_FVHT_USEVHT40 0x000000002 /* CONF: Use VHT40 */
733#define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */744#define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */
734#define IEEE80211_FVHT_USEVHT160 0x000000008 /* CONF: Use VHT160 */745#define IEEE80211_FVHT_USEVHT80P80 0x000000008 /* CONF: Use VHT 80+80 */
735#define IEEE80211_FVHT_USEVHT80P80 0x000000010 /* CONF: Use VHT 80+80 */746#define IEEE80211_FVHT_USEVHT160 0x000000010 /* CONF: Use VHT160 */
736#define IEEE80211_FVHT_MASK \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 \
737 (IEEE80211_FVHT_VHT | IEEE80211_FVHT_USEVHT40 | \751 (IEEE80211_FVHT_VHT | IEEE80211_FVHT_USEVHT40 | \
738 IEEE80211_FVHT_USEVHT80 | IEEE80211_FVHT_USEVHT160 | \752 IEEE80211_FVHT_USEVHT80 | IEEE80211_FVHT_USEVHT160 | \
739 IEEE80211_FVHT_USEVHT80P80)753 IEEE80211_FVHT_USEVHT80P80)
754
755#define IEEE80211_FVHT_MASK \
756 (IEEE80211_FVHT_CHANWIDTH_MASK | \
757 IEEE80211_FVHT_STBC_TX | IEEE80211_FVHT_STBC_RX)
758
740#define IEEE80211_VFHT_BITS \759#define IEEE80211_VFHT_BITS \
741 "\20\1VHT\2VHT40\3VHT80\4VHT160\5VHT80P80"760 "\20\1VHT\2VHT40\3VHT80\4VHT80P80\5VHT160\6STBC_TX\7STBC_RX"
742761
743#define IEEE80211_COM_DETACHED 0x00000001 /* ieee80211_ifdetach called */762#define IEEE80211_COM_DETACHED 0x00000001 /* ieee80211_ifdetach called */
744#define IEEE80211_COM_REF_ADD 0x00000002 /* add / remove reference */763#define IEEE80211_COM_REF_ADD 0x00000002 /* add / remove reference */
...@@ -746,9 +765,17 @@ MALLOC_DECLARE(M_80211_VAP);...@@ -746,9 +765,17 @@ MALLOC_DECLARE(M_80211_VAP);
746#define IEEE80211_COM_REF_S 1765#define IEEE80211_COM_REF_S 1
747#define IEEE80211_COM_REF_MAX (IEEE80211_COM_REF >> IEEE80211_COM_REF_S)766#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
750void ieee80211_ifattach(struct ieee80211com *);771void ieee80211_ifattach(struct ieee80211com *);
751void ieee80211_ifdetach(struct ieee80211com *);772void 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);
752int ieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *,779int ieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *,
753 const char name[IFNAMSIZ], int unit,780 const char name[IFNAMSIZ], int unit,
754 enum ieee80211_opmode opmode, int flags,781 enum ieee80211_opmode opmode, int flags,
...@@ -772,7 +799,8 @@ void ieee80211_iterate_coms(ieee80211_com_iter_func *, void *);...@@ -772,7 +799,8 @@ void ieee80211_iterate_coms(ieee80211_com_iter_func *, void *);
772int ieee80211_media_change(struct ifnet *);799int ieee80211_media_change(struct ifnet *);
773void ieee80211_media_status(struct ifnet *, struct ifmediareq *);800void ieee80211_media_status(struct ifnet *, struct ifmediareq *);
774int ieee80211_ioctl(struct ifnet *, u_long, caddr_t);801int 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 *,
776 enum ieee80211_phymode);804 enum ieee80211_phymode);
777int ieee80211_media2rate(int);805int ieee80211_media2rate(int);
778int ieee80211_mhz2ieee(u_int, u_int);806int ieee80211_mhz2ieee(u_int, u_int);
...@@ -814,6 +842,14 @@ char ieee80211_channel_type_char(const struct ieee80211_channel *c);...@@ -814,6 +842,14 @@ char ieee80211_channel_type_char(const struct ieee80211_channel *c);
814#define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan)842#define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan)
815#define ieee80211_get_vap_desired_channel(_iv) ((_iv)->iv_des_chan)843#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
817void ieee80211_radiotap_attach(struct ieee80211com *,853void ieee80211_radiotap_attach(struct ieee80211com *,
818 struct ieee80211_radiotap_header *th, int tlen,854 struct ieee80211_radiotap_header *th, int tlen,
819 uint32_t tx_radiotap,855 uint32_t tx_radiotap,
...@@ -976,7 +1012,7 @@ ieee80211_get_node_txpower(struct ieee80211_node *ni)...@@ -976,7 +1012,7 @@ ieee80211_get_node_txpower(struct ieee80211_node *ni)
976 * Debugging facilities compiled in when IEEE80211_DEBUG is defined.1012 * Debugging facilities compiled in when IEEE80211_DEBUG is defined.
977 *1013 *
978 * The intent is that any problem in the net80211 layer can be1014 * The intent is that any problem in the net80211 layer can be
979 * diagnosed by inspecting the statistics (dumped by the wlanstats1015 * diagnosed by inspecting the statistics (dumped by the wlanstat
980 * program) and/or the msgs generated by net80211. Messages are1016 * program) and/or the msgs generated by net80211. Messages are
981 * broken into functional classes and can be controlled with the1017 * broken into functional classes and can be controlled with the
982 * wlandebug program. Certain of these msg groups are for facilities1018 * 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 *);...@@ -40,8 +40,7 @@ void ieee80211_parse_vhtcap(struct ieee80211_node *, const uint8_t *);
4040
41int ieee80211_vht_updateparams(struct ieee80211_node *,41int ieee80211_vht_updateparams(struct ieee80211_node *,
42 const uint8_t *, const uint8_t *);42 const uint8_t *, const uint8_t *);
43void ieee80211_setup_vht_rates(struct ieee80211_node *,43void ieee80211_setup_vht_rates(struct ieee80211_node *);
44 const uint8_t *, const uint8_t *);
4544
46void ieee80211_vht_timeout(struct ieee80211vap *vap);45void ieee80211_vht_timeout(struct ieee80211vap *vap);
4746
...@@ -53,8 +52,7 @@ uint8_t * ieee80211_add_vhtinfo(uint8_t *frm, struct ieee80211_node *);...@@ -53,8 +52,7 @@ uint8_t * ieee80211_add_vhtinfo(uint8_t *frm, struct ieee80211_node *);
53uint8_t *ieee80211_add_vhtcap_ch(uint8_t *, struct ieee80211vap *,52uint8_t *ieee80211_add_vhtcap_ch(uint8_t *, struct ieee80211vap *,
54 struct ieee80211_channel *);53 struct ieee80211_channel *);
5554
56void ieee80211_vht_update_cap(struct ieee80211_node *,55void ieee80211_vht_update_cap(struct ieee80211_node *, const uint8_t *);
57 const uint8_t *, const uint8_t *);
5856
59struct ieee80211_channel *57struct ieee80211_channel *
60 ieee80211_vht_adjust_channel(struct ieee80211com *,58 ieee80211_vht_adjust_channel(struct ieee80211com *,
...@@ -65,4 +63,10 @@ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,...@@ -65,4 +63,10 @@ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni,
65void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni,63void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni,
66 struct ieee80211_vht_operation *, int);64 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
68#endif /* _NET80211_IEEE80211_VHT_H_ */72#endif /* _NET80211_IEEE80211_VHT_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netdb.h-1
...@@ -51,7 +51,6 @@...@@ -51,7 +51,6 @@
51 */51 */
5252
53/*53/*
54 * @(#)netdb.h 8.1 (Berkeley) 6/2/93
55 * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $54 * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
56 */55 */
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 *,...@@ -78,11 +78,10 @@ int ng_btsocket_hci_raw_control (struct socket *, u_long, void *,
78int ng_btsocket_hci_raw_ctloutput (struct socket *, struct sockopt *);78int ng_btsocket_hci_raw_ctloutput (struct socket *, struct sockopt *);
79void ng_btsocket_hci_raw_detach (struct socket *);79void ng_btsocket_hci_raw_detach (struct socket *);
80int ng_btsocket_hci_raw_disconnect (struct socket *);80int ng_btsocket_hci_raw_disconnect (struct socket *);
81int ng_btsocket_hci_raw_peeraddr (struct socket *, struct sockaddr **);
82int ng_btsocket_hci_raw_send (struct socket *, int, struct mbuf *,81int ng_btsocket_hci_raw_send (struct socket *, int, struct mbuf *,
83 struct sockaddr *, struct mbuf *,82 struct sockaddr *, struct mbuf *,
84 struct thread *);83 struct thread *);
85int ng_btsocket_hci_raw_sockaddr (struct socket *, struct sockaddr **);84int ng_btsocket_hci_raw_sockaddr (struct socket *, struct sockaddr *);
8685
87#endif /* _KERNEL */86#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 *,...@@ -105,11 +105,11 @@ int ng_btsocket_l2cap_raw_control (struct socket *, u_long, void *,
105 struct ifnet *, struct thread *);105 struct ifnet *, struct thread *);
106void ng_btsocket_l2cap_raw_detach (struct socket *);106void ng_btsocket_l2cap_raw_detach (struct socket *);
107int ng_btsocket_l2cap_raw_disconnect (struct socket *);107int 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 *);
109int ng_btsocket_l2cap_raw_send (struct socket *, int, struct mbuf *,109int ng_btsocket_l2cap_raw_send (struct socket *, int, struct mbuf *,
110 struct sockaddr *, struct mbuf *,110 struct sockaddr *, struct mbuf *,
111 struct thread *);111 struct thread *);
112int ng_btsocket_l2cap_raw_sockaddr (struct socket *, struct sockaddr **);112int ng_btsocket_l2cap_raw_sockaddr (struct socket *, struct sockaddr *);
113113
114#endif /* _KERNEL */114#endif /* _KERNEL */
115115
...@@ -191,7 +191,6 @@ typedef struct ng_btsocket_l2cap_pcb * ng_btsocket_l2cap_pcb_p;...@@ -191,7 +191,6 @@ typedef struct ng_btsocket_l2cap_pcb * ng_btsocket_l2cap_pcb_p;
191191
192void ng_btsocket_l2cap_abort (struct socket *);192void ng_btsocket_l2cap_abort (struct socket *);
193void ng_btsocket_l2cap_close (struct socket *);193void ng_btsocket_l2cap_close (struct socket *);
194int ng_btsocket_l2cap_accept (struct socket *, struct sockaddr **);
195int ng_btsocket_l2cap_attach (struct socket *, int, struct thread *);194int ng_btsocket_l2cap_attach (struct socket *, int, struct thread *);
196int ng_btsocket_l2cap_bind (struct socket *, struct sockaddr *,195int ng_btsocket_l2cap_bind (struct socket *, struct sockaddr *,
197 struct thread *);196 struct thread *);
...@@ -203,11 +202,11 @@ int ng_btsocket_l2cap_ctloutput (struct socket *, struct sockopt *);...@@ -203,11 +202,11 @@ int ng_btsocket_l2cap_ctloutput (struct socket *, struct sockopt *);
203void ng_btsocket_l2cap_detach (struct socket *);202void ng_btsocket_l2cap_detach (struct socket *);
204int ng_btsocket_l2cap_disconnect (struct socket *);203int ng_btsocket_l2cap_disconnect (struct socket *);
205int ng_btsocket_l2cap_listen (struct socket *, int, struct thread *);204int 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 *);
207int ng_btsocket_l2cap_send (struct socket *, int, struct mbuf *,206int ng_btsocket_l2cap_send (struct socket *, int, struct mbuf *,
208 struct sockaddr *, struct mbuf *,207 struct sockaddr *, struct mbuf *,
209 struct thread *);208 struct thread *);
210int ng_btsocket_l2cap_sockaddr (struct socket *, struct sockaddr **);209int ng_btsocket_l2cap_sockaddr (struct socket *, struct sockaddr *);
211210
212#endif /* _KERNEL */211#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;...@@ -316,7 +316,7 @@ typedef struct ng_btsocket_rfcomm_pcb * ng_btsocket_rfcomm_pcb_p;
316316
317void ng_btsocket_rfcomm_abort (struct socket *);317void ng_btsocket_rfcomm_abort (struct socket *);
318void ng_btsocket_rfcomm_close (struct socket *);318void ng_btsocket_rfcomm_close (struct socket *);
319int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr **);319int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr *);
320int ng_btsocket_rfcomm_attach (struct socket *, int, struct thread *);320int ng_btsocket_rfcomm_attach (struct socket *, int, struct thread *);
321int ng_btsocket_rfcomm_bind (struct socket *, struct sockaddr *,321int ng_btsocket_rfcomm_bind (struct socket *, struct sockaddr *,
322 struct thread *);322 struct thread *);
...@@ -328,11 +328,11 @@ int ng_btsocket_rfcomm_ctloutput (struct socket *, struct sockopt *);...@@ -328,11 +328,11 @@ int ng_btsocket_rfcomm_ctloutput (struct socket *, struct sockopt *);
328void ng_btsocket_rfcomm_detach (struct socket *);328void ng_btsocket_rfcomm_detach (struct socket *);
329int ng_btsocket_rfcomm_disconnect (struct socket *);329int ng_btsocket_rfcomm_disconnect (struct socket *);
330int ng_btsocket_rfcomm_listen (struct socket *, int, struct thread *);330int 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 *);
332int ng_btsocket_rfcomm_send (struct socket *, int, struct mbuf *,332int ng_btsocket_rfcomm_send (struct socket *, int, struct mbuf *,
333 struct sockaddr *, struct mbuf *,333 struct sockaddr *, struct mbuf *,
334 struct thread *);334 struct thread *);
335int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr **);335int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr *);
336336
337#endif /* _KERNEL */337#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;...@@ -106,7 +106,7 @@ typedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p;
106106
107void ng_btsocket_sco_abort (struct socket *);107void ng_btsocket_sco_abort (struct socket *);
108void ng_btsocket_sco_close (struct socket *);108void ng_btsocket_sco_close (struct socket *);
109int ng_btsocket_sco_accept (struct socket *, struct sockaddr **);109int ng_btsocket_sco_accept (struct socket *, struct sockaddr *);
110int ng_btsocket_sco_attach (struct socket *, int, struct thread *);110int ng_btsocket_sco_attach (struct socket *, int, struct thread *);
111int ng_btsocket_sco_bind (struct socket *, struct sockaddr *,111int ng_btsocket_sco_bind (struct socket *, struct sockaddr *,
112 struct thread *);112 struct thread *);
...@@ -118,11 +118,11 @@ int ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *);...@@ -118,11 +118,11 @@ int ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *);
118void ng_btsocket_sco_detach (struct socket *);118void ng_btsocket_sco_detach (struct socket *);
119int ng_btsocket_sco_disconnect (struct socket *);119int ng_btsocket_sco_disconnect (struct socket *);
120int ng_btsocket_sco_listen (struct socket *, int, struct thread *);120int 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 *);
122int ng_btsocket_sco_send (struct socket *, int, struct mbuf *,122int ng_btsocket_sco_send (struct socket *, int, struct mbuf *,
123 struct sockaddr *, struct mbuf *,123 struct sockaddr *, struct mbuf *,
124 struct thread *);124 struct thread *);
125int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr **);125int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr *);
126126
127#endif /* _KERNEL */127#endif /* _KERNEL */
128128
lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_hci.h+79-1
...@@ -114,6 +114,8 @@...@@ -114,6 +114,8 @@
114#define NG_HCI_LMP_FLOW_CONTROL_LAG0 0x10114#define NG_HCI_LMP_FLOW_CONTROL_LAG0 0x10
115#define NG_HCI_LMP_FLOW_CONTROL_LAG1 0x20115#define NG_HCI_LMP_FLOW_CONTROL_LAG1 0x20
116#define NG_HCI_LMP_FLOW_CONTROL_LAG2 0x40116#define NG_HCI_LMP_FLOW_CONTROL_LAG2 0x40
117/* ------------------- byte 6 --------------------*/
118#define NG_HCI_LMP_SECURE_SIMPLE_PAIRING 0x08
117119
118/* Link types */120/* Link types */
119#define NG_HCI_LINK_SCO 0x00 /* Voice */121#define NG_HCI_LINK_SCO 0x00 /* Voice */
...@@ -446,7 +448,7 @@ typedef struct {...@@ -446,7 +448,7 @@ typedef struct {
446typedef bdaddr_t * bdaddr_p;448typedef bdaddr_t * bdaddr_p;
447449
448/* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */450/* 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
451/* HCI status return parameter */453/* HCI status return parameter */
452typedef struct {454typedef struct {
...@@ -860,6 +862,50 @@ typedef struct {...@@ -860,6 +862,50 @@ typedef struct {
860} __attribute__ ((packed)) ng_hci_read_clock_offset_cp;862} __attribute__ ((packed)) ng_hci_read_clock_offset_cp;
861/* No return parameter(s) */863/* 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
863/**************************************************************************909/**************************************************************************
864 **************************************************************************910 **************************************************************************
865 ** Link policy commands and return parameters911 ** Link policy commands and return parameters
...@@ -1374,6 +1420,13 @@ typedef struct {...@@ -1374,6 +1420,13 @@ typedef struct {
13741420
1375typedef ng_hci_status_rp ng_hci_write_page_scan_rp;1421typedef 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
1377#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c1430#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c
1378typedef struct {1431typedef struct {
1379 u_int8_t status; /* 0x00 - success */1432 u_int8_t status; /* 0x00 - success */
...@@ -1389,6 +1442,13 @@ typedef struct {...@@ -1389,6 +1442,13 @@ typedef struct {
13891442
1390typedef ng_hci_status_rp ng_hci_write_le_host_supported_rp;1443typedef 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
1392/**************************************************************************1452/**************************************************************************
1393 **************************************************************************1453 **************************************************************************
1394 ** Informational commands and return parameters 1454 ** Informational commands and return parameters
...@@ -2025,6 +2085,24 @@ typedef struct {...@@ -2025,6 +2085,24 @@ typedef struct {
2025 bdaddr_t bdaddr; /* destination address */2085 bdaddr_t bdaddr; /* destination address */
2026 u_int8_t page_scan_rep_mode; /* page scan repetition mode */2086 u_int8_t page_scan_rep_mode; /* page scan repetition mode */
2027} __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep;2087} __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
2028#define NG_HCI_EVENT_LE 0x3e2106#define NG_HCI_EVENT_LE 0x3e
2029typedef struct {2107typedef struct {
2030 u_int8_t subevent_code; 2108 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 {...@@ -259,7 +259,7 @@ struct flow_entry_data {
259 u_long bytes;259 u_long bytes;
260 long first; /* uptime on first packet */260 long first; /* uptime on first packet */
261 long last; /* uptime on last packet */261 long last; /* uptime on last packet */
262 u_char tcp_flags; /* cumulative OR */262 uint16_t tcp_flags; /* cumulative OR */
263};263};
264264
265struct flow6_entry_data {265struct flow6_entry_data {
...@@ -277,7 +277,7 @@ struct flow6_entry_data {...@@ -277,7 +277,7 @@ struct flow6_entry_data {
277 u_long bytes;277 u_long bytes;
278 long first; /* uptime on first packet */278 long first; /* uptime on first packet */
279 long last; /* uptime on last packet */279 long last; /* uptime on last packet */
280 u_char tcp_flags; /* cumulative OR */280 uint16_t tcp_flags; /* cumulative OR */
281};281};
282282
283/*283/*
lib/libc/include/generic-freebsd/netgraph/netgraph.h+14-5
...@@ -69,11 +69,20 @@...@@ -69,11 +69,20 @@
69 * modules.69 * modules.
70 */70 */
71#define _NG_ABI_VERSION 1271#define _NG_ABI_VERSION 12
72#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/72
73#define NG_ABI_VERSION (_NG_ABI_VERSION + 0x10000)73#ifdef NETGRAPH_DEBUG
74#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/74#define _NG_ABI_PREFIX1 0x10000
75#define NG_ABI_VERSION _NG_ABI_VERSION75#else
76#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/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
78/*87/*
79 * Forward references for the basic structures so we can88 * Forward references for the basic structures so we can
lib/libc/include/generic-freebsd/netgraph/ng_message.h+4-1
...@@ -42,7 +42,10 @@...@@ -42,7 +42,10 @@
42#ifndef _NETGRAPH_NG_MESSAGE_H_42#ifndef _NETGRAPH_NG_MESSAGE_H_
43#define _NETGRAPH_NG_MESSAGE_H_43#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 */
46#define NG_TYPESIZ 32 /* max type name len (including null) */49#define NG_TYPESIZ 32 /* max type name len (including null) */
47#define NG_HOOKSIZ 32 /* max hook name len (including null) */50#define NG_HOOKSIZ 32 /* max hook name len (including null) */
48#define NG_NODESIZ 32 /* max node name len (including null) */51#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 {...@@ -53,6 +53,7 @@ struct ng_nat_mode {
53#define NG_NAT_PROXY_ONLY 0x4053#define NG_NAT_PROXY_ONLY 0x40
54#define NG_NAT_REVERSE 0x8054#define NG_NAT_REVERSE 0x80
55#define NG_NAT_UNREGISTERED_CGN 0x10055#define NG_NAT_UNREGISTERED_CGN 0x100
56#define NG_NAT_UDP_EIM 0x200
5657
57#define NG_NAT_DESC_LENGTH 6458#define NG_NAT_DESC_LENGTH 64
58#define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */59#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 {...@@ -60,7 +60,7 @@ enum {
60struct sockaddr_ng {60struct sockaddr_ng {
61 unsigned char sg_len; /* total length */61 unsigned char sg_len; /* total length */
62 sa_family_t sg_family; /* address family */62 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 */
64};64};
6565
66#endif /* _NETGRAPH_NG_SOCKET_H_ */66#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);...@@ -87,21 +87,12 @@ int cc_deregister_algo(struct cc_algo *remove_cc);
87#endif /* _KERNEL */87#endif /* _KERNEL */
8888
89#if defined(_KERNEL) || defined(_WANT_TCPCB)89#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 */
95struct cc_var {90struct cc_var {
96 void *cc_data; /* Per-connection private CC algorithm data. */91 void *cc_data; /* Per-connection private CC algorithm data. */
97 int bytes_this_ack; /* # bytes acked by the current ACK. */92 int bytes_this_ack; /* # bytes acked by the current ACK. */
98 tcp_seq curack; /* Most recent ACK. */93 tcp_seq curack; /* Most recent ACK. */
99 uint32_t flags; /* Flags for cc_var (see below) */94 uint32_t flags; /* Flags for cc_var (see below) */
100 int type; /* Indicates which ptr is valid in ccvc. */95 struct tcpcb *tp; /* Pointer to tcpcb */
101 union ccv_container {
102 struct tcpcb *tcp;
103 struct sctp_nets *sctp;
104 } ccvc;
105 uint16_t nsegs; /* # segments coalesced into current chain. */96 uint16_t nsegs; /* # segments coalesced into current chain. */
106 uint8_t labc; /* Dont use system abc use passed in */97 uint8_t labc; /* Dont use system abc use passed in */
107};98};
...@@ -113,32 +104,34 @@ struct cc_var {...@@ -113,32 +104,34 @@ struct cc_var {
113#define CCF_ACKNOW 0x0008 /* Will this ack be sent now? */104#define CCF_ACKNOW 0x0008 /* Will this ack be sent now? */
114#define CCF_IPHDR_CE 0x0010 /* Does this packet set CE bit? */105#define CCF_IPHDR_CE 0x0010 /* Does this packet set CE bit? */
115#define CCF_TCPHDR_CWR 0x0020 /* Does this packet set CWR bit? */106#define CCF_TCPHDR_CWR 0x0020 /* Does this packet set CWR bit? */
116#define CCF_MAX_CWND 0x0040 /* Have we reached maximum cwnd? */107#define CCF_UNUSED1 0x0040
117#define CCF_CHG_MAX_CWND 0x0080 /* CUBIC max_cwnd changed, for K */108#define CCF_UNUSED2 0x0080
118#define CCF_USR_IWND 0x0100 /* User specified initial window */109#define CCF_UNUSED3 0x0100
119#define CCF_USR_IWND_INIT_NSEG 0x0200 /* Convert segs to bytes on conn init */110#define CCF_UNUSED4 0x0200
120#define CCF_HYSTART_ALLOWED 0x0400 /* If the CC supports it Hystart is allowed */111#define CCF_HYSTART_ALLOWED 0x0400 /* If the CC supports it Hystart is allowed */
121#define CCF_HYSTART_CAN_SH_CWND 0x0800 /* Can hystart when going CSS -> CA slam the cwnd */112#define CCF_HYSTART_CAN_SH_CWND 0x0800 /* Can hystart when going CSS -> CA slam the cwnd */
122#define CCF_HYSTART_CONS_SSTH 0x1000 /* Should hystart use the more conservative ssthresh */113#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. */
129#endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */115#endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */
130116typedef enum {
131/*117#if defined(_KERNEL) || defined(_WANT_TCPCB)
132 * Congestion signal types passed to the cong_signal() hook. The highest order 8118 /* ACK types passed to the ack_received() hook. */
133 * bits (0x01000000 - 0x80000000) are reserved for CC algos to declare their own119 CC_ACK = 0x0001, /* Regular in sequence ACK. */
134 * congestion signal types.120 CC_DUPACK = 0x0002, /* Duplicate ACK. */
135 */121 CC_PARTIALACK = 0x0004, /* Not yet. */
136#define CC_ECN 0x00000001 /* ECN marked packet received. */122 CC_SACK = 0x0008, /* Not yet. */
137#define CC_RTO 0x00000002 /* RTO fired. */123#endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */
138#define CC_RTO_ERR 0x00000004 /* RTO fired in error. */124 /* Congestion signal types passed to the cong_signal() hook. */
139#define CC_NDUPACK 0x00000008 /* Threshold of dupack's reached. */125 CC_ECN = 0x0100, /* ECN marked packet received. */
140126 CC_RTO = 0x0200, /* RTO fired. */
141#define CC_SIGPRIVMASK 0xFF000000 /* Mask to check if sig is private. */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
143#ifdef _KERNEL136#ifdef _KERNEL
144/*137/*
...@@ -175,10 +168,10 @@ struct cc_algo {...@@ -175,10 +168,10 @@ struct cc_algo {
175 void (*conn_init)(struct cc_var *ccv);168 void (*conn_init)(struct cc_var *ccv);
176169
177 /* Called on receipt of an ack. */170 /* 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
180 /* Called on detection of a congestion signal. */173 /* 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
183 /* Called after exiting congestion recovery. */176 /* Called after exiting congestion recovery. */
184 void (*post_recovery)(struct cc_var *ccv);177 void (*post_recovery)(struct cc_var *ccv);
...@@ -236,8 +229,11 @@ extern struct rwlock cc_list_lock;...@@ -236,8 +229,11 @@ extern struct rwlock cc_list_lock;
236 */229 */
237void newreno_cc_post_recovery(struct cc_var *);230void newreno_cc_post_recovery(struct cc_var *);
238void newreno_cc_after_idle(struct cc_var *);231void newreno_cc_after_idle(struct cc_var *);
239void newreno_cc_cong_signal(struct cc_var *, uint32_t );232void newreno_cc_cong_signal(struct cc_var *, ccsignal_t);
240void newreno_cc_ack_received(struct cc_var *, uint16_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
242/* Called to temporarily keep an algo from going away during change */238/* Called to temporarily keep an algo from going away during change */
243void cc_refer(struct cc_algo *algo);239void cc_refer(struct cc_algo *algo);
lib/libc/include/generic-freebsd/netinet/cc/cc_cubic.h+102-88
...@@ -83,26 +83,28 @@...@@ -83,26 +83,28 @@
83#define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */83#define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */
84#define CUBICFLAG_HYSTART_ENABLED 0x00000010 /* Hystart++ is enabled */84#define CUBICFLAG_HYSTART_ENABLED 0x00000010 /* Hystart++ is enabled */
85#define CUBICFLAG_HYSTART_IN_CSS 0x00000020 /* We are in Hystart++ CSS */85#define CUBICFLAG_HYSTART_IN_CSS 0x00000020 /* We are in Hystart++ CSS */
86#define CUBICFLAG_IN_TF 0x00000040 /* We are in TCP friendly region */
8687
87/* Kernel only bits */88/* Kernel only bits */
88#ifdef _KERNEL89#ifdef _KERNEL
89struct cubic {90struct 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 */
91 int64_t K;97 int64_t K;
92 /* Sum of RTT samples across an epoch in usecs. */98 /* Sum of RTT samples across an epoch in usecs. */
93 int64_t sum_rtt_usecs;99 int64_t sum_rtt_usecs;
94 /* Size of cwnd just before cwnd was reduced in the last congestion event */100 /* Size of cwnd (in bytes) just before cwnd was reduced in the last congestion event. */
95 uint64_t W_max;101 uint32_t W_max;
96 /* An estimate for the congestion window in the Reno-friendly region */102 /* An estimate (in bytes) for the congestion window in the Reno-friendly region */
97 uint64_t W_est;103 uint32_t W_est;
98 /* The cwnd at the beginning of the current congestion avoidance stage */104 /* An estimate (in bytes) for the congestion window in the CUBIC region */
99 uint64_t cwnd_epoch;105 uint32_t W_cubic;
100 /*106 /* The cwnd (in bytes) at the beginning of the current congestion avoidance stage. */
101 * Size of cwnd at the time of setting ssthresh most recently,107 uint32_t cwnd_epoch;
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;
106 /* various flags */108 /* various flags */
107 uint32_t flags;109 uint32_t flags;
108 /* Minimum observed rtt in usecs. */110 /* Minimum observed rtt in usecs. */
...@@ -117,12 +119,8 @@ struct cubic {...@@ -117,12 +119,8 @@ struct cubic {
117 int undo_t_epoch;119 int undo_t_epoch;
118 /* Few variables to restore the state after RTO_ERR */120 /* Few variables to restore the state after RTO_ERR */
119 int64_t undo_K;121 int64_t undo_K;
120 uint64_t undo_cwnd_prior;122 uint32_t undo_W_max;
121 uint64_t undo_W_max;123 uint32_t undo_cwnd_epoch;
122 uint64_t undo_W_est;
123 uint64_t undo_cwnd_epoch;
124 /* Number of congestion events experienced */
125 uint64_t num_cong_events;
126 uint32_t css_baseline_minrtt;124 uint32_t css_baseline_minrtt;
127 uint32_t css_current_round_minrtt;125 uint32_t css_current_round_minrtt;
128 uint32_t css_lastround_minrtt;126 uint32_t css_lastround_minrtt;
...@@ -141,60 +139,103 @@ struct cubic {...@@ -141,60 +139,103 @@ struct cubic {
141extern int hz;139extern int hz;
142140
143/*141/*
144 * Implementation based on the formulae found in the CUBIC Internet Draft142 * Implementation based on the formulas in RFC9438.
145 * "draft-ietf-tcpm-cubic-04".
146 *143 *
147 */144 */
148145
149static __inline float146
150theoretical_cubic_k(double wmax_pkts)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)
151{154{
152 double C;155 double C;
153156
154 C = 0.4;157 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));
157}165}
158166
159static __inline unsigned long167/*
160theoretical_cubic_cwnd(int ticks_since_epoch, unsigned long wmax, uint32_t smss)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)
161{175{
162 double C, wmax_pkts;176 double C, t;
177 float K;
163178
164 C = 0.4;179 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 +183 /*
168 (C * pow(ticks_since_epoch / (double)hz -184 * Figure 1: W_cubic(t) = C * (t - K)^3 + W_max
169 theoretical_cubic_k(wmax_pkts) / pow(2, CUBIC_SHIFT), 3.0))));185 */
186 return (C * pow(t - K / pow(2, CUBIC_SHIFT), 3.0) + wmax_segs);
170}187}
171188
172static __inline unsigned long189/*
173theoretical_reno_cwnd(int ticks_since_epoch, int rtt_ticks, unsigned long wmax,190 * Returns estimated Reno congestion window in segments.
174 uint32_t smss)191 */
192static inline unsigned long
193theoretical_reno_cwnd(int ticks_elapsed, int rtt_ticks, uint32_t wmax_segs)
175{194{
176195
177 return ((wmax * 0.5) + ((ticks_since_epoch / (float)rtt_ticks) * smss));196 return (wmax_segs * 0.5 + ticks_elapsed / (float)rtt_ticks);
178}197}
179198
180static __inline unsigned long199/*
181theoretical_tf_cwnd(int ticks_since_epoch, int rtt_ticks, unsigned long wmax,200 * Returns an estimate for the congestion window in segments in the
182 uint32_t smss)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)
183{213{
214 float cubic_alpha, cubic_beta;
184215
185 return ((wmax * 0.7) + ((3 * 0.3) / (2 - 0.3) *216 /* RFC9438 Section 4.6: The parameter β_cubic SHOULD be set to 0.7. */
186 (ticks_since_epoch / (float)rtt_ticks) * smss));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);
187}228}
188229
189#endif /* !_KERNEL */230#endif /* !_KERNEL */
190231
191/*232/*
192 * Compute the CUBIC K value used in the cwnd calculation, using an233 * Compute the CUBIC K value used in the cwnd calculation, using an
193 * implementation of eqn 2 in the I-D. The method used234 * implementation mentioned in Figure. 2 of RFC9438.
194 * here is adapted from Apple Computer Technical Report #KT-32.235 * The method used here is adapted from Apple Computer Technical Report #KT-32.
195 */236 */
196static __inline int64_t237static inline int64_t
197cubic_k(unsigned long wmax_pkts)238cubic_k(uint32_t wmax_segs, uint32_t cwnd_epoch_segs)
198{239{
199 int64_t s, K;240 int64_t s, K;
200 uint16_t p;241 uint16_t p;
...@@ -202,8 +243,13 @@ cubic_k(unsigned long wmax_pkts)...@@ -202,8 +243,13 @@ cubic_k(unsigned long wmax_pkts)
202 K = s = 0;243 K = s = 0;
203 p = 0;244 p = 0;
204245
205 /* (wmax * beta)/C with CUBIC_SHIFT worth of precision. */246 /* Handle the corner case where W_max <= cwnd_epoch */
206 s = ((wmax_pkts * ONE_SUB_CUBIC_BETA) << CUBIC_SHIFT) / CUBIC_C_FACTOR;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
208 /* Rebase s to be between 1 and 1/8 with a shift of CUBIC_SHIFT. */254 /* Rebase s to be between 1 and 1/8 with a shift of CUBIC_SHIFT. */
209 while (s >= 256) {255 while (s >= 256) {
...@@ -224,13 +270,14 @@ cubic_k(unsigned long wmax_pkts)...@@ -224,13 +270,14 @@ cubic_k(unsigned long wmax_pkts)
224}270}
225271
226/*272/*
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.
228 * Thanks to Kip Macy for help debugging this function.275 * Thanks to Kip Macy for help debugging this function.
229 *276 *
230 * XXXLAS: Characterise bounds for overflow.277 * XXXLAS: Characterise bounds for overflow.
231 */278 */
232static __inline unsigned long279static inline uint32_t
233cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)280cubic_cwnd(int usecs_since_epoch, uint32_t wmax, uint32_t smss, int64_t K)
234{281{
235 int64_t cwnd;282 int64_t cwnd;
236283
...@@ -249,7 +296,7 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)...@@ -249,7 +296,7 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)
249 cwnd *= (cwnd * cwnd);296 cwnd *= (cwnd * cwnd);
250297
251 /*298 /*
252 * C(t - K)^3 + wmax299 * Figure 1: C * (t - K)^3 + wmax
253 * The down shift by CUBIC_SHIFT_4 is because cwnd has 4 lots of300 * The down shift by CUBIC_SHIFT_4 is because cwnd has 4 lots of
254 * CUBIC_SHIFT included in the value. 3 from the cubing of cwnd above,301 * CUBIC_SHIFT included in the value. 3 from the cubing of cwnd above,
255 * and an extra from multiplying through by CUBIC_C_FACTOR.302 * 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)...@@ -264,46 +311,13 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K)
264}311}
265312
266/*313/*
267 * Compute an approximation of the NewReno cwnd some number of usecs after a314 * Compute the "TCP friendly" cwnd by newreno in congestion avoidance state.
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
275 */315 */
276static __inline unsigned long316static inline uint32_t
277reno_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax,317tf_cwnd(struct cc_var *ccv)
278 uint32_t smss)
279{318{
280319 /* newreno is "TCP friendly" */
281 /*320 return newreno_cc_cwnd_in_cong_avoid(ccv);
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);
307}321}
308322
309#endif /* _NETINET_CC_CUBIC_H_ */323#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 @@...@@ -43,18 +43,7 @@
43#ifndef _NETINET_CC_MODULE_H_43#ifndef _NETINET_CC_MODULE_H_
44#define _NETINET_CC_MODULE_H_44#define _NETINET_CC_MODULE_H_
4545
46/*46#define CCV(ccv, what) (ccv)->tp->what
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
5847
59#define DECLARE_CC_MODULE(ccname, ccalgo) \48#define DECLARE_CC_MODULE(ccname, ccalgo) \
60 static moduledata_t cc_##ccname = { \49 static moduledata_t cc_##ccname = { \
lib/libc/include/generic-freebsd/netinet/dccp.h+1-1
...@@ -64,7 +64,7 @@ struct dccphdr {...@@ -64,7 +64,7 @@ struct dccphdr {
64 uint8_t seq[6];64 uint8_t seq[6];
65 } longseq;65 } longseq;
66 } d_seqno;66 } d_seqno;
67};67} __packed;
6868
69#define d_seqno_short d_seqno.shortseq;69#define d_seqno_short d_seqno.shortseq;
70#define d_seqno_long d_seqno.longseq.seq;70#define d_seqno_long d_seqno.longseq.seq;
lib/libc/include/generic-freebsd/netinet/icmp6.h+43-46
...@@ -58,13 +58,13 @@...@@ -58,13 +58,13 @@
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.60 * SUCH DAMAGE.
61 *
62 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
63 */61 */
6462
65#ifndef _NETINET_ICMP6_H_63#ifndef _NETINET_ICMP6_H_
66#define _NETINET_ICMP6_H_64#define _NETINET_ICMP6_H_
6765
66#include <sys/stdint.h>
67
68#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)68#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
69 - sizeof(struct icmp6_hdr) */69 - sizeof(struct icmp6_hdr) */
7070
...@@ -309,7 +309,8 @@ struct nd_opt_hdr { /* Neighbor discovery option header */...@@ -309,7 +309,8 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
309#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */309#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */
310#define ND_OPT_RDNSS 25 /* RFC 6106 */310#define ND_OPT_RDNSS 25 /* RFC 6106 */
311#define ND_OPT_DNSSL 31 /* RFC 6106 */311#define ND_OPT_DNSSL 31 /* RFC 6106 */
312#define ND_OPT_MAX 31312#define ND_OPT_PREF64 38 /* RFC 8781 */
313#define ND_OPT_MAX 38
313314
314struct nd_opt_prefix_info { /* prefix information */315struct nd_opt_prefix_info { /* prefix information */
315 u_int8_t nd_opt_pi_type;316 u_int8_t nd_opt_pi_type;
...@@ -375,6 +376,14 @@ struct nd_opt_dnssl { /* DNSSL option (RFC 6106) */...@@ -375,6 +376,14 @@ struct nd_opt_dnssl { /* DNSSL option (RFC 6106) */
375 /* followed by list of DNS search domains */376 /* followed by list of DNS search domains */
376} __packed;377} __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
378/*387/*
379 * icmp6 namelookup388 * icmp6 namelookup
380 */389 */
...@@ -574,22 +583,6 @@ do { \...@@ -574,22 +583,6 @@ do { \
574 * Variables related to this implementation583 * Variables related to this implementation
575 * of the internet control message protocol version 6.584 * of the internet control message protocol version 6.
576 */585 */
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
593struct icmp6stat {586struct icmp6stat {
594/* statistics related to icmp6 packets generated */587/* statistics related to icmp6 packets generated */
595 uint64_t icp6s_error; /* # of calls to icmp6_error */588 uint64_t icp6s_error; /* # of calls to icmp6_error */
...@@ -609,25 +602,19 @@ struct icmp6stat {...@@ -609,25 +602,19 @@ struct icmp6stat {
609 uint64_t icp6s_reflect;602 uint64_t icp6s_reflect;
610 uint64_t icp6s_inhist[256];603 uint64_t icp6s_inhist[256];
611 uint64_t icp6s_nd_toomanyopt; /* too many ND options */604 uint64_t icp6s_nd_toomanyopt; /* too many ND options */
612 struct icmp6errstat icp6s_outerrhist;605 uint64_t icp6s_odst_unreach_noroute;
613#define icp6s_odst_unreach_noroute \606 uint64_t icp6s_odst_unreach_admin;
614 icp6s_outerrhist.icp6errs_dst_unreach_noroute607 uint64_t icp6s_odst_unreach_beyondscope;
615#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin608 uint64_t icp6s_odst_unreach_addr;
616#define icp6s_odst_unreach_beyondscope \609 uint64_t icp6s_odst_unreach_noport;
617 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope610 uint64_t icp6s_opacket_too_big;
618#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr611 uint64_t icp6s_otime_exceed_transit;
619#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport612 uint64_t icp6s_otime_exceed_reassembly;
620#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big613 uint64_t icp6s_oparamprob_header;
621#define icp6s_otime_exceed_transit \614 uint64_t icp6s_oparamprob_nextheader;
622 icp6s_outerrhist.icp6errs_time_exceed_transit615 uint64_t icp6s_oparamprob_option;
623#define icp6s_otime_exceed_reassembly \616 uint64_t icp6s_oredirect;
624 icp6s_outerrhist.icp6errs_time_exceed_reassembly617 uint64_t icp6s_ounknown;
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
631 uint64_t icp6s_pmtuchg; /* path MTU changes */618 uint64_t icp6s_pmtuchg; /* path MTU changes */
632 uint64_t icp6s_nd_badopt; /* bad ND options */619 uint64_t icp6s_nd_badopt; /* bad ND options */
633 uint64_t icp6s_badns; /* bad neighbor solicitation */620 uint64_t icp6s_badns; /* bad neighbor solicitation */
...@@ -645,6 +632,7 @@ struct icmp6stat {...@@ -645,6 +632,7 @@ struct icmp6stat {
645632
646#ifdef _KERNEL633#ifdef _KERNEL
647#include <sys/counter.h>634#include <sys/counter.h>
635#include <netinet/in_kdtrace.h>
648636
649#ifdef SYSCTL_DECL637#ifdef SYSCTL_DECL
650SYSCTL_DECL(_net_inet6_icmp6);638SYSCTL_DECL(_net_inet6_icmp6);
...@@ -655,16 +643,28 @@ VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat);...@@ -655,16 +643,28 @@ VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat);
655 * In-kernel consumers can use these accessor macros directly to update643 * In-kernel consumers can use these accessor macros directly to update
656 * stats.644 * stats.
657 */645 */
658#define ICMP6STAT_ADD(name, val) \646#define ICMP6STAT_ADD(name, val) \
659 VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val))647 do { \
660#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1)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
662/*658/*
663 * Kernel module consumers must use this accessor macro.659 * Kernel module consumers must use this accessor macro.
664 */660 */
665void kmod_icmp6stat_inc(int statnum);661void kmod_icmp6stat_inc(int statnum);
666#define KMOD_ICMP6STAT_INC(name) \662#define KMOD_ICMP6STAT_INC(name) \
667 kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(uint64_t))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)
668#endif668#endif
669669
670/*670/*
...@@ -713,9 +713,6 @@ void icmp6_redirect_input(struct mbuf *, int);...@@ -713,9 +713,6 @@ void icmp6_redirect_input(struct mbuf *, int);
713void icmp6_redirect_output(struct mbuf *, struct nhop_object *);713void icmp6_redirect_output(struct mbuf *, struct nhop_object *);
714int icmp6_ratelimit(const struct in6_addr *, const int, const int);714int icmp6_ratelimit(const struct in6_addr *, const int, const int);
715715
716struct ip6ctlparam;
717void icmp6_mtudisc_update(struct ip6ctlparam *, int);
718
719/* XXX: is this the right place for these macros? */716/* XXX: is this the right place for these macros? */
720#define icmp6_ifstat_inc(ifp, tag) \717#define icmp6_ifstat_inc(ifp, tag) \
721do { \718do { \
lib/libc/include/generic-freebsd/netinet/icmp_var.h+22-12
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NETINET_ICMP_VAR_H_32#ifndef _NETINET_ICMP_VAR_H_
...@@ -59,22 +57,36 @@ struct icmpstat {...@@ -59,22 +57,36 @@ struct icmpstat {
5957
60#ifdef _KERNEL58#ifdef _KERNEL
61#include <sys/counter.h>59#include <sys/counter.h>
60#include <netinet/in_kdtrace.h>
6261
63VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);62VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);
64/*63/*
65 * In-kernel consumers can use these accessor macros directly to update64 * In-kernel consumers can use these accessor macros directly to update
66 * stats.65 * stats.
67 */66 */
68#define ICMPSTAT_ADD(name, val) \67#define ICMPSTAT_ADD(name, val) \
69 VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, 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
70#define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1)73#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
72/*80/*
73 * Kernel module consumers must use this accessor macro.81 * Kernel module consumers must use this accessor macro.
74 */82 */
75void kmod_icmpstat_inc(int statnum);83void kmod_icmpstat_inc(int statnum);
76#define KMOD_ICMPSTAT_INC(name) \84#define KMOD_ICMPSTAT_INC(name) \
77 kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t))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)
78#endif90#endif
7991
80/*92/*
...@@ -88,15 +100,13 @@ void kmod_icmpstat_inc(int statnum);...@@ -88,15 +100,13 @@ void kmod_icmpstat_inc(int statnum);
88SYSCTL_DECL(_net_inet_icmp);100SYSCTL_DECL(_net_inet_icmp);
89101
90extern int badport_bandlim(int);102extern int badport_bandlim(int);
91#define BANDLIM_UNLIMITED -1
92#define BANDLIM_ICMP_UNREACH 0103#define BANDLIM_ICMP_UNREACH 0
93#define BANDLIM_ICMP_ECHO 1104#define BANDLIM_ICMP_ECHO 1
94#define BANDLIM_ICMP_TSTAMP 2105#define BANDLIM_ICMP_TSTAMP 2
95#define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */106#define BANDLIM_TCP_RST 3
96#define BANDLIM_RST_OPENPORT 4 /* No connection, listener */107#define BANDLIM_ICMP6_UNREACH 4
97#define BANDLIM_ICMP6_UNREACH 5108#define BANDLIM_SCTP_OOTB 5
98#define BANDLIM_SCTP_OOTB 6109#define BANDLIM_MAX 6
99#define BANDLIM_MAX 7
100#endif110#endif
101111
102#endif112#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/if_ether.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)if_ether.h 8.3 (Berkeley) 5/2/95
32 */30 */
3331
34#ifndef _NETINET_IF_ETHER_H_32#ifndef _NETINET_IF_ETHER_H_
lib/libc/include/generic-freebsd/netinet/igmp.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)igmp.h 8.1 (Berkeley) 6/10/93
36 */34 */
3735
38#ifndef _NETINET_IGMP_H_36#ifndef _NETINET_IGMP_H_
lib/libc/include/generic-freebsd/netinet/igmp_var.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)igmp_var.h 8.1 (Berkeley) 7/19/93
36 */34 */
3735
38#ifndef _NETINET_IGMP_VAR_H_36#ifndef _NETINET_IGMP_VAR_H_
lib/libc/include/generic-freebsd/netinet/in.h+12-7
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)in.h 8.3 (Berkeley) 1/3/94
32 */30 */
3331
34#ifndef _NETINET_IN_H_32#ifndef _NETINET_IN_H_
...@@ -674,13 +672,13 @@ int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,...@@ -674,13 +672,13 @@ int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
674struct ifnet; struct mbuf; /* forward declarations for Standard C */672struct ifnet; struct mbuf; /* forward declarations for Standard C */
675struct in_ifaddr;673struct in_ifaddr;
676674
677int in_broadcast(struct in_addr, struct ifnet *);675bool in_ifnet_broadcast(struct in_addr, struct ifnet *);
678int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);676bool in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
679int in_canforward(struct in_addr);677bool in_canforward(struct in_addr);
680int in_localaddr(struct in_addr);678bool in_localaddr(struct in_addr);
681bool in_localip(struct in_addr);679bool in_localip(struct in_addr);
682bool in_localip_fib(struct in_addr, uint16_t);680bool in_localip_fib(struct in_addr, uint16_t);
683int in_ifhasaddr(struct ifnet *, struct in_addr);681bool in_ifhasaddr(struct ifnet *, struct in_addr);
684struct in_ifaddr *in_findlocal(uint32_t, bool);682struct in_ifaddr *in_findlocal(uint32_t, bool);
685int inet_aton(const char *, struct in_addr *); /* in libkern */683int inet_aton(const char *, struct in_addr *); /* in libkern */
686char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */684char *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 */...@@ -688,6 +686,13 @@ char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
688int inet_pton(int af, const char *, void *); /* in libkern */686int inet_pton(int af, const char *, void *); /* in libkern */
689void in_ifdetach(struct ifnet *);687void 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
691#define in_hosteq(s, t) ((s).s_addr == (t).s_addr)696#define in_hosteq(s, t) ((s).s_addr == (t).s_addr)
692#define in_nullhost(x) ((x).s_addr == INADDR_ANY)697#define in_nullhost(x) ((x).s_addr == INADDR_ANY)
693#define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP))698#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 @@...@@ -28,6 +28,8 @@
28#ifndef _SYS_IN_KDTRACE_H_28#ifndef _SYS_IN_KDTRACE_H_
29#define _SYS_IN_KDTRACE_H_29#define _SYS_IN_KDTRACE_H_
3030
31#include <sys/sdt.h>
32
31#define IP_PROBE(probe, arg0, arg1, arg2, arg3, arg4, arg5) \33#define IP_PROBE(probe, arg0, arg1, arg2, arg3, arg4, arg5) \
32 SDT_PROBE6(ip, , , probe, arg0, arg1, arg2, arg3, arg4, arg5)34 SDT_PROBE6(ip, , , probe, arg0, arg1, arg2, arg3, arg4, arg5)
33#define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4) \35#define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4) \
...@@ -52,6 +54,371 @@ SDT_PROVIDER_DECLARE(tcp);...@@ -52,6 +54,371 @@ SDT_PROVIDER_DECLARE(tcp);
52SDT_PROVIDER_DECLARE(udp);54SDT_PROVIDER_DECLARE(udp);
53SDT_PROVIDER_DECLARE(udplite);55SDT_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
55SDT_PROBE_DECLARE(ip, , , receive);422SDT_PROBE_DECLARE(ip, , , receive);
56SDT_PROBE_DECLARE(ip, , , send);423SDT_PROBE_DECLARE(ip, , , send);
57424
lib/libc/include/generic-freebsd/netinet/in_pcb.h+45-58
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
37 */35 */
3836
39#ifndef _NETINET_IN_PCB_H_37#ifndef _NETINET_IN_PCB_H_
...@@ -66,7 +64,6 @@...@@ -66,7 +64,6 @@
66 * protocol-specific control block) are stored here.64 * protocol-specific control block) are stored here.
67 */65 */
68CK_LIST_HEAD(inpcbhead, inpcb);66CK_LIST_HEAD(inpcbhead, inpcb);
69CK_LIST_HEAD(inpcbporthead, inpcbport);
70CK_LIST_HEAD(inpcblbgrouphead, inpcblbgroup);67CK_LIST_HEAD(inpcblbgrouphead, inpcblbgroup);
71typedef uint64_t inp_gen_t;68typedef uint64_t inp_gen_t;
7269
...@@ -135,8 +132,9 @@ struct in_conninfo {...@@ -135,8 +132,9 @@ struct in_conninfo {
135/*132/*
136 * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4 and133 * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4 and
137 * IPv6 sockets. In the case of TCP and UDP, further per-connection state is134 * 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 inpcb135 * located in a larger protocol specific structure that embeds inpcb in it.
139 * are static after creation or protected by a per-inpcb rwlock, inp_lock.136 * Almost all fields of struct inpcb are static after creation or protected by
137 * a per-inpcb rwlock, inp_lock.
140 *138 *
141 * A inpcb database is indexed by addresses/ports hash as well as list of139 * A inpcb database is indexed by addresses/ports hash as well as list of
142 * all pcbs that belong to a certain proto. Database lookups or list traversals140 * all pcbs that belong to a certain proto. Database lookups or list traversals
...@@ -168,7 +166,10 @@ struct inpcbpolicy;...@@ -168,7 +166,10 @@ struct inpcbpolicy;
168struct m_snd_tag;166struct m_snd_tag;
169struct inpcb {167struct inpcb {
170 /* Cache line #1 (amd64) */168 /* 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 };
172 CK_LIST_ENTRY(inpcb) inp_hash_wild; /* hash table linkage */173 CK_LIST_ENTRY(inpcb) inp_hash_wild; /* hash table linkage */
173 struct rwlock inp_lock;174 struct rwlock inp_lock;
174 /* Cache line #2 (amd64) */175 /* Cache line #2 (amd64) */
...@@ -179,7 +180,6 @@ struct inpcb {...@@ -179,7 +180,6 @@ struct inpcb {
179 int inp_flags; /* (i) generic IP/datagram flags */180 int inp_flags; /* (i) generic IP/datagram flags */
180 int inp_flags2; /* (i) generic IP/datagram flags #2*/181 int inp_flags2; /* (i) generic IP/datagram flags #2*/
181 uint8_t inp_numa_domain; /* numa domain */182 uint8_t inp_numa_domain; /* numa domain */
182 void *inp_ppcb; /* (i) pointer to per-protocol pcb */
183 struct socket *inp_socket; /* (i) back pointer to socket */183 struct socket *inp_socket; /* (i) back pointer to socket */
184 struct inpcbinfo *inp_pcbinfo; /* (c) PCB list info */184 struct inpcbinfo *inp_pcbinfo; /* (c) PCB list info */
185 struct ucred *inp_cred; /* (c) cache of socket cred */185 struct ucred *inp_cred; /* (c) cache of socket cred */
...@@ -220,7 +220,6 @@ struct inpcb {...@@ -220,7 +220,6 @@ struct inpcb {
220 short in6p_hops;220 short in6p_hops;
221 };221 };
222 CK_LIST_ENTRY(inpcb) inp_portlist; /* (r:e/w:h) port list */222 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 */
224 inp_gen_t inp_gencnt; /* (c) generation count */223 inp_gen_t inp_gencnt; /* (c) generation count */
225 void *spare_ptr; /* Spare pointer. */224 void *spare_ptr; /* Spare pointer. */
226 rt_gen_t inp_rt_cookie; /* generation for route entry */225 rt_gen_t inp_rt_cookie; /* generation for route entry */
...@@ -268,8 +267,7 @@ struct xinpcb {...@@ -268,8 +267,7 @@ struct xinpcb {
268 struct xsocket xi_socket; /* (s,p) */267 struct xsocket xi_socket; /* (s,p) */
269 struct in_conninfo inp_inc; /* (s,p) */268 struct in_conninfo inp_inc; /* (s,p) */
270 uint64_t inp_gencnt; /* (s,p) */269 uint64_t inp_gencnt; /* (s,p) */
271 kvaddr_t inp_ppcb; /* (s) netstat(1) */270 int64_t inp_spare64[5];
272 int64_t inp_spare64[4];
273 uint32_t inp_flow; /* (s) */271 uint32_t inp_flow; /* (s) */
274 uint32_t inp_flowid; /* (s) */272 uint32_t inp_flowid; /* (s) */
275 uint32_t inp_flowtype; /* (s) */273 uint32_t inp_flowtype; /* (s) */
...@@ -305,6 +303,30 @@ struct sockopt_parameters {...@@ -305,6 +303,30 @@ struct sockopt_parameters {
305 char sop_optval[];303 char sop_optval[];
306};304};
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
308#ifdef _KERNEL330#ifdef _KERNEL
309int sysctl_setsockopt(SYSCTL_HANDLER_ARGS, struct inpcbinfo *pcbinfo,331int sysctl_setsockopt(SYSCTL_HANDLER_ARGS, struct inpcbinfo *pcbinfo,
310 int (*ctloutput_set)(struct inpcb *, struct sockopt *));332 int (*ctloutput_set)(struct inpcb *, struct sockopt *));
...@@ -370,7 +392,7 @@ struct inpcbinfo {...@@ -370,7 +392,7 @@ struct inpcbinfo {
370 /*392 /*
371 * Global hash of inpcbs, hashed by only local port number.393 * Global hash of inpcbs, hashed by only local port number.
372 */394 */
373 struct inpcbporthead *ipi_porthashbase; /* (h) */395 struct inpcbhead *ipi_porthashbase; /* (h) */
374 u_long ipi_porthashmask; /* (h) */396 u_long ipi_porthashmask; /* (h) */
375397
376 /*398 /*
...@@ -392,11 +414,9 @@ struct inpcbinfo {...@@ -392,11 +414,9 @@ struct inpcbinfo {
392 */414 */
393struct inpcbstorage {415struct inpcbstorage {
394 uma_zone_t ips_zone;416 uma_zone_t ips_zone;
395 uma_zone_t ips_portzone;
396 uma_init ips_pcbinit;417 uma_init ips_pcbinit;
397 size_t ips_size;418 size_t ips_size;
398 const char * ips_zone_name;419 const char * ips_zone_name;
399 const char * ips_portzone_name;
400 const char * ips_infolock_name;420 const char * ips_infolock_name;
401 const char * ips_hashlock_name;421 const char * ips_hashlock_name;
402};422};
...@@ -414,7 +434,6 @@ static struct inpcbstorage prot = { \...@@ -414,7 +434,6 @@ static struct inpcbstorage prot = { \
414 .ips_size = sizeof(struct ppcb), \434 .ips_size = sizeof(struct ppcb), \
415 .ips_pcbinit = prot##_inpcb_init, \435 .ips_pcbinit = prot##_inpcb_init, \
416 .ips_zone_name = zname, \436 .ips_zone_name = zname, \
417 .ips_portzone_name = zname " ports", \
418 .ips_infolock_name = iname, \437 .ips_infolock_name = iname, \
419 .ips_hashlock_name = hname, \438 .ips_hashlock_name = hname, \
420}; \439}; \
...@@ -423,28 +442,6 @@ SYSINIT(prot##_inpcbstorage_init, SI_SUB_PROTO_DOMAIN, \...@@ -423,28 +442,6 @@ SYSINIT(prot##_inpcbstorage_init, SI_SUB_PROTO_DOMAIN, \
423SYSUNINIT(prot##_inpcbstorage_uninit, SI_SUB_PROTO_DOMAIN, \442SYSUNINIT(prot##_inpcbstorage_uninit, SI_SUB_PROTO_DOMAIN, \
424 SI_ORDER_SECOND, in_pcbstorage_destroy, &prot)443 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
448#define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock)445#define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock)
449#define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock)446#define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock)
450#define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock)447#define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock)
...@@ -481,12 +478,8 @@ void inp_unlock_assert(struct inpcb *);...@@ -481,12 +478,8 @@ void inp_unlock_assert(struct inpcb *);
481478
482void inp_apply_all(struct inpcbinfo *, void (*func)(struct inpcb *, void *),479void inp_apply_all(struct inpcbinfo *, void (*func)(struct inpcb *, void *),
483 void *arg);480 void *arg);
484int inp_ip_tos_get(const struct inpcb *inp);
485void inp_ip_tos_set(struct inpcb *inp, int val);
486struct socket *481struct socket *
487 inp_inpcbtosocket(struct inpcb *inp);482 inp_inpcbtosocket(struct inpcb *inp);
488struct tcpcb *
489 inp_inpcbtotcpcb(struct inpcb *inp);
490void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,483void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
491 uint32_t *faddr, uint16_t *fp);484 uint32_t *faddr, uint16_t *fp);
492485
...@@ -578,7 +571,7 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,...@@ -578,7 +571,7 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
578#define INP_DROPPED 0x04000000 /* protocol drop flag */571#define INP_DROPPED 0x04000000 /* protocol drop flag */
579#define INP_SOCKREF 0x08000000 /* strong socket reference */572#define INP_SOCKREF 0x08000000 /* strong socket reference */
580#define INP_RESERVED_0 0x10000000 /* reserved field */573#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. */
582#define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */575#define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */
583#define IN6P_MTU 0x80000000 /* receive path MTU */576#define IN6P_MTU 0x80000000 /* receive path MTU */
584577
...@@ -624,10 +617,11 @@ typedef enum {...@@ -624,10 +617,11 @@ typedef enum {
624 INPLOOKUP_WILDCARD = 0x00000001, /* Allow wildcard sockets. */617 INPLOOKUP_WILDCARD = 0x00000001, /* Allow wildcard sockets. */
625 INPLOOKUP_RLOCKPCB = 0x00000002, /* Return inpcb read-locked. */618 INPLOOKUP_RLOCKPCB = 0x00000002, /* Return inpcb read-locked. */
626 INPLOOKUP_WLOCKPCB = 0x00000004, /* Return inpcb write-locked. */619 INPLOOKUP_WLOCKPCB = 0x00000004, /* Return inpcb write-locked. */
620 INPLOOKUP_FIB = 0x00000008, /* inp must be from same FIB. */
627} inp_lookup_t;621} inp_lookup_t;
628622
629#define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB | \623#define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB | \
630 INPLOOKUP_WLOCKPCB)624 INPLOOKUP_WLOCKPCB | INPLOOKUP_FIB)
631#define INPLOOKUP_LOCKMASK (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)625#define INPLOOKUP_LOCKMASK (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)
632626
633#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)627#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
...@@ -665,34 +659,29 @@ void in_pcbstorage_destroy(void *);...@@ -665,34 +659,29 @@ void in_pcbstorage_destroy(void *);
665659
666void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);660void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
667int in_pcballoc(struct socket *, struct inpcbinfo *);661int 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 *);
669int in_pcbbind_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *,664int in_pcbbind_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *,
670 u_short *, struct ucred *);665 u_short *, int, struct ucred *);
671int in_pcbconnect(struct inpcb *, struct sockaddr_in *, struct ucred *,666int 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 *);
675void in_pcbdisconnect(struct inpcb *);667void in_pcbdisconnect(struct inpcb *);
676void in_pcbdrop(struct inpcb *);668void in_pcbdrop(struct inpcb *);
677void in_pcbfree(struct inpcb *);669void in_pcbfree(struct inpcb *);
678int in_pcbinshash(struct inpcb *);670int in_pcbladdr(const struct inpcb *, struct in_addr *, struct in_addr *,
679int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *,
680 struct ucred *);671 struct ucred *);
681int in_pcblbgroup_numa(struct inpcb *, int arg);672int in_pcblbgroup_numa(struct inpcb *, int arg);
673void in_pcblisten(struct inpcb *);
682struct inpcb *674struct inpcb *
683 in_pcblookup(struct inpcbinfo *, struct in_addr, u_int,675 in_pcblookup(struct inpcbinfo *, struct in_addr, u_int,
684 struct in_addr, u_int, int, struct ifnet *);676 struct in_addr, u_int, int, struct ifnet *);
685struct inpcb *677struct inpcb *
686 in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int,678 in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int,
687 struct in_addr, u_int, int, struct ifnet *, struct mbuf *);679 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));
690void in_pcbref(struct inpcb *);680void in_pcbref(struct inpcb *);
691void in_pcbrehash(struct inpcb *);
692void in_pcbremhash_locked(struct inpcb *);
693bool in_pcbrele(struct inpcb *, inp_lookup_t);681bool in_pcbrele(struct inpcb *, inp_lookup_t);
694bool in_pcbrele_rlocked(struct inpcb *);682bool in_pcbrele_rlocked(struct inpcb *);
695bool in_pcbrele_wlocked(struct inpcb *);683bool in_pcbrele_wlocked(struct inpcb *);
684bool in_pcbrele_rlock(struct inpcb *inp);
696685
697typedef bool inp_match_t(const struct inpcb *, void *);686typedef bool inp_match_t(const struct inpcb *, void *);
698struct inpcb_iterator {687struct inpcb_iterator {
...@@ -724,10 +713,8 @@ struct inpcb_iterator {...@@ -724,10 +713,8 @@ struct inpcb_iterator {
724struct inpcb *inp_next(struct inpcb_iterator *);713struct inpcb *inp_next(struct inpcb_iterator *);
725void in_losing(struct inpcb *);714void in_losing(struct inpcb *);
726void in_pcbsetsolabel(struct socket *so);715void in_pcbsetsolabel(struct socket *so);
727int in_getpeeraddr(struct socket *so, struct sockaddr **nam);716int in_getpeeraddr(struct socket *, struct sockaddr *sa);
728int in_getsockaddr(struct socket *so, struct sockaddr **nam);717int in_getsockaddr(struct socket *, struct sockaddr *sa);
729struct sockaddr *
730 in_sockaddr(in_port_t port, struct in_addr *addr);
731void in_pcbsosetlabel(struct socket *so);718void in_pcbsosetlabel(struct socket *so);
732#ifdef RATELIMIT719#ifdef RATELIMIT
733int720int
lib/libc/include/generic-freebsd/netinet/in_pcb_var.h+28-9
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
37 */35 */
3836
39#ifndef _NETINET_IN_PCB_VAR_H_37#ifndef _NETINET_IN_PCB_VAR_H_
...@@ -52,16 +50,37 @@ int inp_trylock(struct inpcb *inp, const inp_lookup_t lock);...@@ -52,16 +50,37 @@ int inp_trylock(struct inpcb *inp, const inp_lookup_t lock);
52bool inp_smr_lock(struct inpcb *, const inp_lookup_t);50bool inp_smr_lock(struct inpcb *, const inp_lookup_t);
53int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,51int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,
54 struct ucred *, int);52 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,
56 u_short *lportp, struct sockaddr *fsa, u_short fport,54 u_short *lportp, struct sockaddr *fsa, u_short fport,
57 struct ucred *cred, int lookupflags);55 struct ucred *cred, int lookupflags);
58struct inpcb * in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short,56struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short,
59 int, struct ucred *);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/*
62 struct inpcbhead phd_pcblist;63 * Load balance groups used for the SO_REUSEPORT_LB socket option. Each group
63 CK_LIST_ENTRY(inpcbport) phd_hash;64 * (or unique address:port combination) can be re-used at most
64 u_short phd_port;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) */
65};84};
6685
67#endif /* !_NETINET_IN_PCB_VAR_H_ */86#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 @@...@@ -27,13 +27,13 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)in_systm.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NETINET_IN_SYSTM_H_32#ifndef _NETINET_IN_SYSTM_H_
35#define _NETINET_IN_SYSTM_H_33#define _NETINET_IN_SYSTM_H_
3634
35#include <sys/types.h>
36
37/*37/*
38 * Miscellaneous internetwork38 * Miscellaneous internetwork
39 * definitions for kernel.39 * definitions for kernel.
...@@ -58,8 +58,10 @@ typedef u_int32_t n_time; /* ms since 00:00 UTC, byte rev */...@@ -58,8 +58,10 @@ typedef u_int32_t n_time; /* ms since 00:00 UTC, byte rev */
58#ifdef _KERNEL58#ifdef _KERNEL
59struct inpcb;59struct inpcb;
60struct ucred;60struct ucred;
61struct thread;
6162
62int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp);63int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp);
64bool cr_canexport_ktlskeys(struct thread *td, struct inpcb *inp);
6365
64uint32_t iptime(void);66uint32_t iptime(void);
65#endif67#endif
lib/libc/include/generic-freebsd/netinet/in_var.h+6-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)in_var.h 8.2 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _NETINET_IN_VAR_H_32#ifndef _NETINET_IN_VAR_H_
...@@ -99,6 +97,11 @@ struct in_ifaddr {...@@ -99,6 +97,11 @@ struct in_ifaddr {
99#define IN_LNAOF(in, ifa) \97#define IN_LNAOF(in, ifa) \
100 ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask))98 ((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
102#define LLTABLE(ifp) \105#define LLTABLE(ifp) \
103 ((struct in_ifinfo *)(ifp)->if_afdata[AF_INET])->ii_llt106 ((struct in_ifinfo *)(ifp)->if_afdata[AF_INET])->ii_llt
104/*107/*
...@@ -456,6 +459,7 @@ int in_joingroup_locked(struct ifnet *, const struct in_addr *,...@@ -456,6 +459,7 @@ int in_joingroup_locked(struct ifnet *, const struct in_addr *,
456int in_leavegroup(struct in_multi *, /*const*/ struct in_mfilter *);459int in_leavegroup(struct in_multi *, /*const*/ struct in_mfilter *);
457int in_leavegroup_locked(struct in_multi *,460int in_leavegroup_locked(struct in_multi *,
458 /*const*/ struct in_mfilter *);461 /*const*/ struct in_mfilter *);
462int in_mask2len(struct in_addr *);
459int in_control(struct socket *, u_long, void *, struct ifnet *,463int in_control(struct socket *, u_long, void *, struct ifnet *,
460 struct thread *);464 struct thread *);
461int in_control_ioctl(u_long, void *, struct ifnet *,465int in_control_ioctl(u_long, void *, struct ifnet *,
lib/libc/include/generic-freebsd/netinet/ip.h+4-5
...@@ -28,14 +28,13 @@...@@ -28,14 +28,13 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * @(#)ip.h 8.2 (Berkeley) 6/1/94
33 */31 */
3432
35#ifndef _NETINET_IP_H_33#ifndef _NETINET_IP_H_
36#define _NETINET_IP_H_34#define _NETINET_IP_H_
3735
38#include <sys/cdefs.h>36#include <sys/types.h>
37#include <netinet/in.h>
3938
40/*39/*
41 * Definitions for internet protocol version 4.40 * Definitions for internet protocol version 4.
...@@ -68,7 +67,7 @@ struct ip {...@@ -68,7 +67,7 @@ struct ip {
68 u_char ip_p; /* protocol */67 u_char ip_p; /* protocol */
69 u_short ip_sum; /* checksum */68 u_short ip_sum; /* checksum */
70 struct in_addr ip_src,ip_dst; /* source and dest address */69 struct in_addr ip_src,ip_dst; /* source and dest address */
71} __packed __aligned(2);70} __packed;
7271
73#define IP_MAXPACKET 65535 /* maximum packet size */72#define IP_MAXPACKET 65535 /* maximum packet size */
7473
...@@ -188,7 +187,7 @@ struct ip_timestamp {...@@ -188,7 +187,7 @@ struct ip_timestamp {
188 uint32_t ipt_time; /* network format */187 uint32_t ipt_time; /* network format */
189 } ipt_ta[1];188 } ipt_ta[1];
190 } ipt_timestamp;189 } ipt_timestamp;
191};190} __packed;
192191
193/* Flag bits for ipt_flg. */192/* Flag bits for ipt_flg. */
194#define IPOPT_TS_TSONLY 0 /* timestamps only */193#define IPOPT_TS_TSONLY 0 /* timestamps only */
lib/libc/include/generic-freebsd/netinet/ip6.h-2
...@@ -58,8 +58,6 @@...@@ -58,8 +58,6 @@
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.60 * SUCH DAMAGE.
61 *
62 * @(#)ip.h 8.1 (Berkeley) 6/10/93
63 */61 */
6462
65#ifndef _NETINET_IP6_H_63#ifndef _NETINET_IP6_H_
lib/libc/include/generic-freebsd/netinet/ip_carp.h+51-4
...@@ -31,6 +31,7 @@...@@ -31,6 +31,7 @@
31#ifndef _IP_CARP_H31#ifndef _IP_CARP_H
32#define _IP_CARP_H32#define _IP_CARP_H
3333
34#ifdef _KERNEL
34/*35/*
35 * The CARP header layout is as follows:36 * The CARP header layout is as follows:
36 *37 *
...@@ -77,14 +78,53 @@ struct carp_header {...@@ -77,14 +78,53 @@ struct carp_header {
77 unsigned char carp_md[20]; /* SHA1 HMAC */78 unsigned char carp_md[20]; /* SHA1 HMAC */
78} __packed;79} __packed;
7980
80#ifdef CTASSERT
81CTASSERT(sizeof(struct carp_header) == 36);81CTASSERT(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;
82#endif116#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 255124CTASSERT(sizeof(struct vrrpv3_header) == 8);
125#endif /* _KERNEL */
85126
86/* carp_version */127#define CARP_DFLTTL 255
87#define CARP_VERSION 2
88128
89/* carp_type */129/* carp_type */
90#define CARP_ADVERTISEMENT 0x01130#define CARP_ADVERTISEMENT 0x01
...@@ -94,6 +134,8 @@ CTASSERT(sizeof(struct carp_header) == 36);...@@ -94,6 +134,8 @@ CTASSERT(sizeof(struct carp_header) == 36);
94/* carp_advbase */134/* carp_advbase */
95#define CARP_DFLTINTV 1135#define CARP_DFLTINTV 1
96136
137#define VRRP_TYPE_ADVERTISEMENT 0x01
138#define VRRP_MAX_INTERVAL (0x1000 - 1)
97/*139/*
98 * Statistics.140 * Statistics.
99 */141 */
...@@ -136,6 +178,11 @@ struct carpreq {...@@ -136,6 +178,11 @@ struct carpreq {
136#define SIOCSVH _IOWR('i', 245, struct ifreq)178#define SIOCSVH _IOWR('i', 245, struct ifreq)
137#define SIOCGVH _IOWR('i', 246, struct ifreq)179#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
139#ifdef _KERNEL186#ifdef _KERNEL
140int carp_ioctl(struct ifreq *, u_long, struct thread *);187int carp_ioctl(struct ifreq *, u_long, struct thread *);
141int carp_attach(struct ifaddr *, int);188int 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 {...@@ -32,6 +32,9 @@ enum carp_nl_type_t {
32 CARP_NL_ADDR = 7, /* in_addr_t */32 CARP_NL_ADDR = 7, /* in_addr_t */
33 CARP_NL_ADDR6 = 8, /* in6_addr_t */33 CARP_NL_ADDR6 = 8, /* in6_addr_t */
34 CARP_NL_IFNAME = 9, /* string */34 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*/
35};38};
3639
37#endif40#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/ip_compat.h+4-12
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_compat.h 1.8 1/14/96
7 * Id: ip_compat.h,v 2.142.2.57 2007/10/10 09:51:42 darrenr Exp $5 * Id: ip_compat.h,v 2.142.2.57 2007/10/10 09:51:42 darrenr Exp $
8 */6 */
97
...@@ -689,12 +687,6 @@ typedef struct tcpiphdr tcpiphdr_t;...@@ -689,12 +687,6 @@ typedef struct tcpiphdr tcpiphdr_t;
689#ifndef IP_HL_A687#ifndef IP_HL_A
690# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf)688# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf)
691#endif689#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
698#ifndef TCP_OFF690#ifndef TCP_OFF
699# define TCP_OFF(x) (x)->th_off691# define TCP_OFF(x) (x)->th_off
700#endif692#endif
...@@ -703,9 +695,6 @@ typedef struct tcpiphdr tcpiphdr_t;...@@ -703,9 +695,6 @@ typedef struct tcpiphdr tcpiphdr_t;
703#endif695#endif
704#define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h)))696#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
709#if !SOLARIS && !defined(m_act)698#if !SOLARIS && !defined(m_act)
710# define m_act m_nextpkt699# define m_act m_nextpkt
711#endif700#endif
...@@ -1136,7 +1125,10 @@ typedef struct tcpiphdr tcpiphdr_t;...@@ -1136,7 +1125,10 @@ typedef struct tcpiphdr tcpiphdr_t;
1136#ifndef TH_CWR1125#ifndef TH_CWR
1137# define TH_CWR 0x801126# define TH_CWR 0x80
1138#endif1127#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
1141/*1133/*
1142 * TCP States1134 * TCP States
lib/libc/include/generic-freebsd/netinet/ip_dummynet.h+2-1
...@@ -145,7 +145,7 @@ struct dn_fs {...@@ -145,7 +145,7 @@ struct dn_fs {
145 uint32_t fs_nr; /* the flowset number */145 uint32_t fs_nr; /* the flowset number */
146 uint32_t flags; /* userland flags */146 uint32_t flags; /* userland flags */
147 int qsize; /* queue size in slots or bytes */147 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 */
149 uint32_t buckets; /* buckets used for the queue hash table */149 uint32_t buckets; /* buckets used for the queue hash table */
150150
151 struct ipfw_flow_id flow_mask;151 struct ipfw_flow_id flow_mask;
...@@ -168,6 +168,7 @@ struct dn_fs {...@@ -168,6 +168,7 @@ struct dn_fs {
168 int min_th ; /* minimum threshold for queue (scaled) */168 int min_th ; /* minimum threshold for queue (scaled) */
169 int max_p ; /* maximum value for p_b (scaled) */169 int max_p ; /* maximum value for p_b (scaled) */
170170
171 int32_t plr[4]; /* PLR, pkt loss rate (2^31-1 means 100%) */
171};172};
172173
173/*174/*
lib/libc/include/generic-freebsd/netinet/ip_fil.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_fil.h 1.35 6/5/96
7 * Id: ip_fil.h,v 2.170.2.51 2007/10/10 09:48:03 darrenr Exp $5 * Id: ip_fil.h,v 2.170.2.51 2007/10/10 09:48:03 darrenr Exp $
8 */6 */
97
lib/libc/include/generic-freebsd/netinet/ip_frag.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_frag.h 1.5 3/24/96
7 * Id: ip_frag.h,v 2.23.2.1 2004/03/29 16:21:56 darrenr Exp5 * Id: ip_frag.h,v 2.23.2.1 2004/03/29 16:21:56 darrenr Exp
8 */6 */
97
lib/libc/include/generic-freebsd/netinet/ip_fw.h+251-176
...@@ -75,6 +75,10 @@ typedef struct _ip_fw3_opheader {...@@ -75,6 +75,10 @@ typedef struct _ip_fw3_opheader {
75 uint16_t reserved[2]; /* Align to 64-bit boundary */75 uint16_t reserved[2]; /* Align to 64-bit boundary */
76} ip_fw3_opheader;76} 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
78/* IP_FW3 opcodes */82/* IP_FW3 opcodes */
79#define IP_FW_TABLE_XADD 86 /* add entry */83#define IP_FW_TABLE_XADD 86 /* add entry */
80#define IP_FW_TABLE_XDEL 87 /* delete entry */84#define IP_FW_TABLE_XDEL 87 /* delete entry */
...@@ -109,6 +113,7 @@ typedef struct _ip_fw3_opheader {...@@ -109,6 +113,7 @@ typedef struct _ip_fw3_opheader {
109113
110#define IP_FW_DUMP_SOPTCODES 116 /* Dump available sopts/versions */114#define IP_FW_DUMP_SOPTCODES 116 /* Dump available sopts/versions */
111#define IP_FW_DUMP_SRVOBJECTS 117 /* Dump existing named objects */115#define IP_FW_DUMP_SRVOBJECTS 117 /* Dump existing named objects */
116#define IP_FW_SKIPTO_CACHE 118 /* Manage skipto cache */
112117
113#define IP_FW_NAT64STL_CREATE 130 /* Create stateless NAT64 instance */118#define IP_FW_NAT64STL_CREATE 130 /* Create stateless NAT64 instance */
114#define IP_FW_NAT64STL_DESTROY 131 /* Destroy stateless NAT64 instance */119#define IP_FW_NAT64STL_DESTROY 131 /* Destroy stateless NAT64 instance */
...@@ -162,162 +167,153 @@ typedef struct _ip_fw3_opheader {...@@ -162,162 +167,153 @@ typedef struct _ip_fw3_opheader {
162 */167 */
163168
164enum ipfw_opcodes { /* arguments (4 byte each) */169enum ipfw_opcodes { /* arguments (4 byte each) */
165 O_NOP,170 O_NOP = 0,
166171
167 O_IP_SRC, /* u32 = IP */172 O_IP_SRC = 1, /* u32 = IP */
168 O_IP_SRC_MASK, /* ip = IP/mask */173 O_IP_SRC_MASK = 2, /* ip = IP/mask */
169 O_IP_SRC_ME, /* none */174 O_IP_SRC_ME = 3, /* none */
170 O_IP_SRC_SET, /* u32=base, arg1=len, bitmap */175 O_IP_SRC_SET = 4, /* u32=base, arg1=len, bitmap */
171176
172 O_IP_DST, /* u32 = IP */177 O_IP_DST = 5, /* u32 = IP */
173 O_IP_DST_MASK, /* ip = IP/mask */178 O_IP_DST_MASK = 6, /* ip = IP/mask */
174 O_IP_DST_ME, /* none */179 O_IP_DST_ME = 7, /* none */
175 O_IP_DST_SET, /* u32=base, arg1=len, bitmap */180 O_IP_DST_SET = 8, /* u32=base, arg1=len, bitmap */
176181
177 O_IP_SRCPORT, /* (n)port list:mask 4 byte ea */182 O_IP_SRCPORT = 9, /* (n)port list:mask 4 byte ea */
178 O_IP_DSTPORT, /* (n)port list:mask 4 byte ea */183 O_IP_DSTPORT = 10, /* (n)port list:mask 4 byte ea */
179 O_PROTO, /* arg1=protocol */184 O_PROTO = 11, /* arg1=protocol */
180185
181 O_MACADDR2, /* 2 mac addr:mask */186 O_MACADDR2 = 12, /* 2 mac addr:mask */
182 O_MAC_TYPE, /* same as srcport */187 O_MAC_TYPE = 13, /* same as srcport */
183188
184 O_LAYER2, /* none */189 O_LAYER2 = 14, /* none */
185 O_IN, /* none */190 O_IN = 15, /* none */
186 O_FRAG, /* none */191 O_FRAG = 16, /* none */
187192
188 O_RECV, /* none */193 O_RECV = 17, /* none */
189 O_XMIT, /* none */194 O_XMIT = 18, /* none */
190 O_VIA, /* none */195 O_VIA = 19, /* none */
191196
192 O_IPOPT, /* arg1 = 2*u8 bitmap */197 O_IPOPT = 20, /* arg1 = 2*u8 bitmap */
193 O_IPLEN, /* arg1 = len */198 O_IPLEN = 21, /* arg1 = len */
194 O_IPID, /* arg1 = id */199 O_IPID = 22, /* arg1 = id */
195200
196 O_IPTOS, /* arg1 = id */201 O_IPTOS = 23, /* arg1 = id */
197 O_IPPRECEDENCE, /* arg1 = precedence << 5 */202 O_IPPRECEDENCE = 24, /* arg1 = precedence << 5 */
198 O_IPTTL, /* arg1 = TTL */203 O_IPTTL = 25, /* arg1 = TTL */
199204
200 O_IPVER, /* arg1 = version */205 O_IPVER = 26, /* arg1 = version */
201 O_UID, /* u32 = id */206 O_UID = 27, /* u32 = id */
202 O_GID, /* u32 = id */207 O_GID = 28, /* u32 = id */
203 O_ESTAB, /* none (tcp established) */208 O_ESTAB = 29, /* none (tcp established) */
204 O_TCPFLAGS, /* arg1 = 2*u8 bitmap */209 O_TCPFLAGS = 30, /* arg1 = 2*u8 bitmap */
205 O_TCPWIN, /* arg1 = desired win */210 O_TCPWIN = 31, /* arg1 = desired win */
206 O_TCPSEQ, /* u32 = desired seq. */211 O_TCPSEQ = 32, /* u32 = desired seq. */
207 O_TCPACK, /* u32 = desired seq. */212 O_TCPACK = 33, /* u32 = desired seq. */
208 O_ICMPTYPE, /* u32 = icmp bitmap */213 O_ICMPTYPE = 34, /* u32 = icmp bitmap */
209 O_TCPOPTS, /* arg1 = 2*u8 bitmap */214 O_TCPOPTS = 35, /* arg1 = 2*u8 bitmap */
210215
211 O_VERREVPATH, /* none */216 O_VERREVPATH = 36, /* none */
212 O_VERSRCREACH, /* none */217 O_VERSRCREACH = 37, /* none */
213218
214 O_PROBE_STATE, /* none */219 O_PROBE_STATE = 38, /* v0:arg1=kidx, v1:kidx=kidx */
215 O_KEEP_STATE, /* none */220 O_KEEP_STATE = 39, /* v0:arg1=kidx, v1:kidx=kidx */
216 O_LIMIT, /* ipfw_insn_limit */221 O_LIMIT = 40, /* ipfw_insn_limit */
217 O_LIMIT_PARENT, /* dyn_type, not an opcode. */222 O_LIMIT_PARENT = 41, /* dyn_type, not an opcode. */
218223
219 /*224 /*
220 * These are really 'actions'.225 * These are really 'actions'.
221 */226 */
222227
223 O_LOG, /* ipfw_insn_log */228 O_LOG = 42, /* ipfw_insn_log */
224 O_PROB, /* u32 = match probability */229 O_PROB = 43, /* u32 = match probability */
225230
226 O_CHECK_STATE, /* none */231 O_CHECK_STATE = 44, /* v0:arg1=kidx, v1:kidx=kidx */
227 O_ACCEPT, /* none */232 O_ACCEPT = 45, /* none */
228 O_DENY, /* none */233 O_DENY = 46, /* none */
229 O_REJECT, /* arg1=icmp arg (same as deny) */234 O_REJECT = 47, /* arg1=icmp arg (same as deny) */
230 O_COUNT, /* none */235 O_COUNT = 48, /* none */
231 O_SKIPTO, /* arg1=next rule number */236 O_SKIPTO = 49, /* v0:arg1=next rule number */
232 O_PIPE, /* arg1=pipe number */237 /* v1:kidx= next rule number */
233 O_QUEUE, /* arg1=queue number */238 O_PIPE = 50, /* arg1=pipe number */
234 O_DIVERT, /* arg1=port number */239 O_QUEUE = 51, /* arg1=queue number */
235 O_TEE, /* arg1=port number */240 O_DIVERT = 52, /* arg1=port number */
236 O_FORWARD_IP, /* fwd sockaddr */241 O_TEE = 53, /* arg1=port number */
237 O_FORWARD_MAC, /* fwd mac */242 O_FORWARD_IP = 54, /* fwd sockaddr */
238 O_NAT, /* nope */243 O_FORWARD_MAC = 55, /* fwd mac */
239 O_REASS, /* none */244 O_NAT = 56, /* nope */
245 O_REASS = 57, /* none */
240246
241 /*247 /*
242 * More opcodes.248 * More opcodes.
243 */249 */
244 O_IPSEC, /* has ipsec history */250 O_IPSEC = 58, /* has ipsec history */
245 O_IP_SRC_LOOKUP, /* arg1=table number, u32=value */251 O_IP_SRC_LOOKUP = 59, /* v0:arg1=table number, u32=value */
246 O_IP_DST_LOOKUP, /* arg1=table number, u32=value */252 /* v1:kidx=name, u32=value, arg1=key */
247 O_ANTISPOOF, /* none */253 O_IP_DST_LOOKUP = 60, /* arg1=table number, u32=value */
248 O_JAIL, /* u32 = id */254 /* v1:kidx=name, u32=value, arg1=key */
249 O_ALTQ, /* u32 = altq classif. qid */255 O_ANTISPOOF = 61, /* none */
250 O_DIVERTED, /* arg1=bitmap (1:loop, 2:out) */256 O_JAIL = 62, /* u32 = id */
251 O_TCPDATALEN, /* arg1 = tcp data len */257 O_ALTQ = 63, /* u32 = altq classif. qid */
252 O_IP6_SRC, /* address without mask */258 O_DIVERTED = 64, /* arg1=bitmap (1:loop, 2:out) */
253 O_IP6_SRC_ME, /* my addresses */259 O_TCPDATALEN = 65, /* arg1 = tcp data len */
254 O_IP6_SRC_MASK, /* address with the mask */260 O_IP6_SRC = 66, /* address without mask */
255 O_IP6_DST,261 O_IP6_SRC_ME = 67, /* my addresses */
256 O_IP6_DST_ME,262 O_IP6_SRC_MASK = 68, /* address with the mask */
257 O_IP6_DST_MASK,263 O_IP6_DST = 69,
258 O_FLOW6ID, /* for flow id tag in the ipv6 pkt */264 O_IP6_DST_ME = 70,
259 O_ICMP6TYPE, /* icmp6 packet type filtering */265 O_IP6_DST_MASK = 71,
260 O_EXT_HDR, /* filtering for ipv6 extension header */266 O_FLOW6ID = 72, /* for flow id tag in the ipv6 pkt */
261 O_IP6,267 O_ICMP6TYPE = 73, /* icmp6 packet type filtering */
268 O_EXT_HDR = 74, /* filtering for ipv6 extension header */
269 O_IP6 = 75,
262270
263 /*271 /*
264 * actions for ng_ipfw272 * actions for ng_ipfw
265 */273 */
266 O_NETGRAPH, /* send to ng_ipfw */274 O_NETGRAPH = 76, /* send to ng_ipfw */
267 O_NGTEE, /* copy 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 */281 O_TAG = 80, /* arg1=tag number */
274 O_TAGGED, /* arg1=tag number */282 O_TAGGED = 81, /* arg1=tag number */
275283
276 O_SETFIB, /* arg1=FIB number */284 O_SETFIB = 82, /* arg1=FIB number */
277 O_FIB, /* arg1=FIB desired 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 */294 O_DSCP = 87, /* 2 u32 = DSCP mask */
286 O_SETDSCP, /* arg1=DSCP value */295 O_SETDSCP = 88, /* arg1=DSCP value */
287 O_IP_FLOW_LOOKUP, /* arg1=table number, u32=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 */299 O_EXTERNAL_ACTION = 90, /* v0:arg1=id of external action handler */
290 O_EXTERNAL_INSTANCE, /* arg1=id of eaction handler instance */300 /* v1:kidx=id of external action handler */
291 O_EXTERNAL_DATA, /* variable length data */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 */305 O_SKIP_ACTION = 93, /* none */
294 O_TCPMSS, /* arg1=MSS value */306 O_TCPMSS = 94, /* arg1=MSS value */
295307
296 O_MAC_SRC_LOOKUP, /* arg1=table number, u32=value */308 O_MAC_SRC_LOOKUP = 95, /* kidx=name, u32=value, arg1=key */
297 O_MAC_DST_LOOKUP, /* arg1=table number, u32=value */309 O_MAC_DST_LOOKUP = 96, /* kidx=name, u32=value, arg1=key */
298310
299 O_SETMARK, /* u32 = value */311 O_SETMARK = 97, /* u32 = value */
300 O_MARK, /* 2 u32 = value, bitmask */312 O_MARK = 98, /* 2 u32 = value, bitmask */
301313
302 O_LAST_OPCODE /* not an opcode! */314 O_LAST_OPCODE /* not an opcode! */
303};315};
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
321/*317/*
322 * The extension header are filtered only for presence using a bit318 * The extension header are filtered only for presence using a bit
323 * vector with a flag for each header.319 * vector with a flag for each header.
...@@ -392,6 +388,11 @@ typedef struct _ipfw_insn_u32 {...@@ -392,6 +388,11 @@ typedef struct _ipfw_insn_u32 {
392 u_int32_t d[1]; /* one or more */388 u_int32_t d[1]; /* one or more */
393} ipfw_insn_u32;389} ipfw_insn_u32;
394390
391typedef struct _ipfw_insn_kidx {
392 ipfw_insn o;
393 uint32_t kidx;
394} ipfw_insn_kidx;
395
395/*396/*
396 * This is used to store IP addr-mask pairs.397 * This is used to store IP addr-mask pairs.
397 */398 */
...@@ -401,6 +402,47 @@ typedef struct _ipfw_insn_ip {...@@ -401,6 +402,47 @@ typedef struct _ipfw_insn_ip {
401 struct in_addr mask;402 struct in_addr mask;
402} ipfw_insn_ip;403} 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
404/*446/*
405 * This is used to forward to a given address (ip).447 * This is used to forward to a given address (ip).
406 */448 */
...@@ -434,7 +476,8 @@ typedef struct _ipfw_insn_if {...@@ -434,7 +476,8 @@ typedef struct _ipfw_insn_if {
434 union {476 union {
435 struct in_addr ip;477 struct in_addr ip;
436 int glob;478 int glob;
437 uint16_t kidx;479 uint16_t kidx_v0;
480 uint32_t kidx;
438 } p;481 } p;
439 char name[IFNAMSIZ];482 char name[IFNAMSIZ];
440} ipfw_insn_if;483} ipfw_insn_if;
...@@ -452,6 +495,7 @@ typedef struct _ipfw_insn_altq {...@@ -452,6 +495,7 @@ typedef struct _ipfw_insn_altq {
452 */495 */
453typedef struct _ipfw_insn_limit {496typedef struct _ipfw_insn_limit {
454 ipfw_insn o;497 ipfw_insn o;
498 u_int32_t kidx;
455 u_int8_t _pad;499 u_int8_t _pad;
456 u_int8_t limit_mask; /* combination of DYN_* below */500 u_int8_t limit_mask; /* combination of DYN_* below */
457#define DYN_SRC_ADDR 0x1501#define DYN_SRC_ADDR 0x1
...@@ -462,6 +506,9 @@ typedef struct _ipfw_insn_limit {...@@ -462,6 +506,9 @@ typedef struct _ipfw_insn_limit {
462 u_int16_t conn_limit;506 u_int16_t conn_limit;
463} ipfw_insn_limit;507} ipfw_insn_limit;
464508
509/* MAC/InfiniBand/etc address length */
510#define IPFW_MAX_L2_ADDR_LEN 20
511
465/*512/*
466 * This is used for log instructions.513 * This is used for log instructions.
467 */514 */
...@@ -471,6 +518,22 @@ typedef struct _ipfw_insn_log {...@@ -471,6 +518,22 @@ typedef struct _ipfw_insn_log {
471 u_int32_t log_left; /* how many left to log */518 u_int32_t log_left; /* how many left to log */
472} ipfw_insn_log;519} 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
474/* Legacy NAT structures, compat only */537/* Legacy NAT structures, compat only */
475#ifndef _KERNEL538#ifndef _KERNEL
476/*539/*
...@@ -604,6 +667,10 @@ typedef struct _ipfw_insn_icmp6 {...@@ -604,6 +667,10 @@ typedef struct _ipfw_insn_icmp6 {
604 */667 */
605} ipfw_insn_icmp6;668} 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
607/*674/*
608 * Here we have the structure representing an ipfw rule.675 * Here we have the structure representing an ipfw rule.
609 *676 *
...@@ -719,30 +786,29 @@ struct ipfw_flow_id {...@@ -719,30 +786,29 @@ struct ipfw_flow_id {
719/*786/*
720 * Dynamic ipfw rule.787 * Dynamic ipfw rule.
721 */788 */
722typedef struct _ipfw_dyn_rule ipfw_dyn_rule;789#define IPFW_DYN_ORPHANED 0x40000 /* state's parent rule was deleted */
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) */
728790
729 ipfw_dyn_rule *parent; /* pointer to parent rule */791typedef struct _ipfw_dyn_rule {
730 u_int64_t pcnt; /* packet match counter */
731 u_int64_t bcnt; /* byte match counter */
732 struct ipfw_flow_id id; /* (masked) flow id */792 struct ipfw_flow_id id; /* (masked) flow id */
733 u_int32_t expire; /* expire time */793 uint8_t set;
734 u_int32_t bucket; /* which bucket in hash table */794 uint8_t type; /* rule type */
735 u_int32_t state; /* state of this rule (typically a795 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
736 * combination of TCP flags)804 * combination of TCP flags)
737 */805 */
738#define IPFW_DYN_ORPHANED 0x40000 /* state's parent rule was deleted */806 uint32_t count; /* number of linked states */
739 u_int32_t ack_fwd; /* most recent ACKs in forward */807 };
740 u_int32_t ack_rev; /* and reverse directions (used */808 uint32_t ack_fwd; /* most recent ACKs in forward */
809 uint32_t ack_rev; /* and reverse directions (used */
741 /* to generate keepalives) */810 /* to generate keepalives) */
742 u_int16_t dyn_type; /* rule type */811} __packed __aligned(8) ipfw_dyn_rule;
743 u_int16_t count; /* refcount */
744 u_int16_t kidx; /* index of named object */
745} __packed __aligned(8);
746812
747/*813/*
748 * Definitions for IP option names.814 * Definitions for IP option names.
...@@ -794,16 +860,6 @@ struct _ipfw_dyn_rule {...@@ -794,16 +860,6 @@ struct _ipfw_dyn_rule {
794#define IPFW_VTYPE_NH6 0x00000400 /* IPv6 nexthop */860#define IPFW_VTYPE_NH6 0x00000400 /* IPv6 nexthop */
795#define IPFW_VTYPE_MARK 0x00000800 /* [fw]mark */861#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
807typedef struct _ipfw_table_xentry {863typedef struct _ipfw_table_xentry {
808 uint16_t len; /* Total entry length */864 uint16_t len; /* Total entry length */
809 uint8_t type; /* entry type */865 uint8_t type; /* entry type */
...@@ -819,13 +875,6 @@ typedef struct _ipfw_table_xentry {...@@ -819,13 +875,6 @@ typedef struct _ipfw_table_xentry {
819} ipfw_table_xentry;875} ipfw_table_xentry;
820#define IPFW_TCF_INET 0x01 /* CIDR flags: IPv4 record */876#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
829typedef struct _ipfw_xtable {878typedef struct _ipfw_xtable {
830 ip_fw3_opheader opheader; /* IP_FW3 opcode */879 ip_fw3_opheader opheader; /* IP_FW3 opcode */
831 uint32_t size; /* size of entries in bytes */880 uint32_t size; /* size of entries in bytes */
...@@ -865,10 +914,10 @@ typedef struct _ipfw_obj_data {...@@ -865,10 +914,10 @@ typedef struct _ipfw_obj_data {
865/* Object name TLV */914/* Object name TLV */
866typedef struct _ipfw_obj_ntlv {915typedef struct _ipfw_obj_ntlv {
867 ipfw_obj_tlv head; /* TLV header */916 ipfw_obj_tlv head; /* TLV header */
868 uint16_t idx; /* Name index */917 uint32_t idx; /* Name index */
869 uint8_t set; /* set, if applicable */918 uint8_t set; /* set, if applicable */
870 uint8_t type; /* object type, if applicable */919 uint8_t type; /* object type, if applicable */
871 uint32_t spare; /* unused */920 uint16_t spare; /* unused */
872 char name[64]; /* Null-terminated name */921 char name[64]; /* Null-terminated name */
873} ipfw_obj_ntlv;922} ipfw_obj_ntlv;
874923
...@@ -891,19 +940,40 @@ struct tflow_entry {...@@ -891,19 +940,40 @@ struct tflow_entry {
891 } a;940 } a;
892};941};
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
894/* 64-byte structure representing multi-field table value */964/* 64-byte structure representing multi-field table value */
895typedef struct _ipfw_table_value {965typedef struct _ipfw_table_value {
896 uint32_t tag; /* O_TAG/O_TAGGED */966 uint32_t tag; /* O_TAG/O_TAGGED */
897 uint32_t pipe; /* O_PIPE/O_QUEUE */967 uint16_t pipe; /* O_PIPE/O_QUEUE */
898 uint16_t divert; /* O_DIVERT/O_TEE */968 uint16_t divert; /* O_DIVERT/O_TEE */
899 uint16_t skipto; /* skipto, CALLRET */969 uint32_t skipto; /* skipto, CALLRET */
900 uint32_t netgraph; /* O_NETGRAPH/O_NGTEE */970 uint32_t netgraph; /* O_NETGRAPH/O_NGTEE */
901 uint32_t fib; /* O_SETFIB */
902 uint32_t nat; /* O_NAT */971 uint32_t nat; /* O_NAT */
903 uint32_t nh4;972 uint32_t nh4;
973 uint16_t fib; /* O_SETFIB */
904 uint8_t dscp;974 uint8_t dscp;
905 uint8_t spare0;975 uint8_t spare0;
906 uint16_t kidx; /* value kernel index */976 uint32_t kidx; /* value kernel index */
907 struct in6_addr nh6;977 struct in6_addr nh6;
908 uint32_t limit; /* O_LIMIT */978 uint32_t limit; /* O_LIMIT */
909 uint32_t zoneid; /* scope zone id for nh6 */979 uint32_t zoneid; /* scope zone id for nh6 */
...@@ -918,8 +988,7 @@ typedef struct _ipfw_obj_tentry {...@@ -918,8 +988,7 @@ typedef struct _ipfw_obj_tentry {
918 uint8_t masklen; /* mask length */988 uint8_t masklen; /* mask length */
919 uint8_t result; /* request result */989 uint8_t result; /* request result */
920 uint8_t spare0;990 uint8_t spare0;
921 uint16_t idx; /* Table name index */991 uint32_t idx; /* Table name index */
922 uint16_t spare1;
923 union {992 union {
924 /* Longest field needs to be aligned by 8-byte boundary */993 /* Longest field needs to be aligned by 8-byte boundary */
925 struct in_addr addr; /* IPv4 address */994 struct in_addr addr; /* IPv4 address */
...@@ -966,8 +1035,8 @@ typedef struct _ipfw_obj_ctlv {...@@ -966,8 +1035,8 @@ typedef struct _ipfw_obj_ctlv {
966typedef struct _ipfw_range_tlv {1035typedef struct _ipfw_range_tlv {
967 ipfw_obj_tlv head; /* TLV header */1036 ipfw_obj_tlv head; /* TLV header */
968 uint32_t flags; /* Range flags */1037 uint32_t flags; /* Range flags */
969 uint16_t start_rule; /* Range start */1038 uint32_t start_rule; /* Range start */
970 uint16_t end_rule; /* Range end */1039 uint32_t end_rule; /* Range end */
971 uint32_t set; /* Range set to match */1040 uint32_t set; /* Range set to match */
972 uint32_t new_set; /* New set to move/swap to */1041 uint32_t new_set; /* New set to move/swap to */
973} ipfw_range_tlv;1042} ipfw_range_tlv;
...@@ -1051,10 +1120,16 @@ typedef struct _ipfw_ta_info {...@@ -1051,10 +1120,16 @@ typedef struct _ipfw_ta_info {
1051 uint64_t spare1;1120 uint64_t spare1;
1052} ipfw_ta_info;1121} 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
1054typedef struct _ipfw_obj_header {1129typedef struct _ipfw_obj_header {
1055 ip_fw3_opheader opheader; /* IP_FW3 opcode */1130 ip_fw3_opheader opheader; /* IP_FW3 opcode */
1056 uint32_t spare;1131 uint32_t idx; /* object name index */
1057 uint16_t idx; /* object name index */1132 uint16_t spare;
1058 uint8_t objtype; /* object type */1133 uint8_t objtype; /* object type */
1059 uint8_t objsubtype; /* object subtype */1134 uint8_t objsubtype; /* object subtype */
1060 ipfw_obj_ntlv ntlv; /* object name tlv */1135 ipfw_obj_ntlv ntlv; /* object name tlv */
lib/libc/include/generic-freebsd/netinet/ip_icmp.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NETINET_IP_ICMP_H_32#ifndef _NETINET_IP_ICMP_H_
lib/libc/include/generic-freebsd/netinet/ip_mroute.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93
36 */34 */
3735
38#ifndef _NETINET_IP_MROUTE_H_36#ifndef _NETINET_IP_MROUTE_H_
lib/libc/include/generic-freebsd/netinet/ip_nat.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_nat.h 1.5 2/4/96
7 * Id: ip_nat.h,v 2.90.2.20 2007/09/25 08:27:32 darrenr Exp $5 * Id: ip_nat.h,v 2.90.2.20 2007/09/25 08:27:32 darrenr Exp $
8 */6 */
97
lib/libc/include/generic-freebsd/netinet/ip_scan.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_fil.h 1.35 6/5/96
7 * $Id$5 * $Id$
8 */6 */
97
lib/libc/include/generic-freebsd/netinet/ip_state.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_state.h 1.3 1/12/96 (C) 1995 Darren Reed
7 * Id: ip_state.h,v 2.68.2.10 2007/10/16 09:33:24 darrenr Exp $5 * Id: ip_state.h,v 2.68.2.10 2007/10/16 09:33:24 darrenr Exp $
8 */6 */
9#ifndef __IP_STATE_H__7#ifndef __IP_STATE_H__
lib/libc/include/generic-freebsd/netinet/ip_sync.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_fil.h 1.35 6/5/96
7 * $Id$5 * $Id$
8 */6 */
97
lib/libc/include/generic-freebsd/netinet/ip_var.h+25-12
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ip_var.h 8.2 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _NETINET_IP_VAR_H_32#ifndef _NETINET_IP_VAR_H_
...@@ -49,7 +47,7 @@ struct ipovly {...@@ -49,7 +47,7 @@ struct ipovly {
49 u_short ih_len; /* protocol length */47 u_short ih_len; /* protocol length */
50 struct in_addr ih_src; /* source internet address */48 struct in_addr ih_src; /* source internet address */
51 struct in_addr ih_dst; /* destination internet address */49 struct in_addr ih_dst; /* destination internet address */
52};50} __packed;
5351
54#ifdef _KERNEL52#ifdef _KERNEL
55/*53/*
...@@ -138,15 +136,19 @@ struct ipstat {...@@ -138,15 +136,19 @@ struct ipstat {
138136
139#include <sys/counter.h>137#include <sys/counter.h>
140#include <net/vnet.h>138#include <net/vnet.h>
139#include <netinet/in_kdtrace.h>
141140
142VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);141VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);
143/*142/*
144 * In-kernel consumers can use these accessor macros directly to update143 * In-kernel consumers can use these accessor macros directly to update
145 * stats.144 * stats.
146 */145 */
147#define IPSTAT_ADD(name, val) \146#define IPSTAT_ADD(name, val) \
148 VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val))147 do { \
149#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val))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))
150#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)152#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)
151#define IPSTAT_DEC(name) IPSTAT_SUB(name, 1)153#define IPSTAT_DEC(name) IPSTAT_SUB(name, 1)
152154
...@@ -154,11 +156,19 @@ VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);...@@ -154,11 +156,19 @@ VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);
154 * Kernel module consumers must use this accessor macro.156 * Kernel module consumers must use this accessor macro.
155 */157 */
156void kmod_ipstat_inc(int statnum);158void kmod_ipstat_inc(int statnum);
157#define KMOD_IPSTAT_INC(name) \159#define KMOD_IPSTAT_INC(name) \
158 kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t))160 do { \
159void kmod_ipstat_dec(int statnum);161 MIB_SDT_PROBE1(ip, count, name, 1); \
160#define KMOD_IPSTAT_DEC(name) \162 kmod_ipstat_inc( \
161 kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t))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
163/* flags passed to ip_output as last parameter */173/* flags passed to ip_output as last parameter */
164#define IP_FORWARDING 0x1 /* most of ip header exists */174#define IP_FORWARDING 0x1 /* most of ip header exists */
...@@ -194,6 +204,7 @@ extern int (*legal_vif_num)(int);...@@ -194,6 +204,7 @@ extern int (*legal_vif_num)(int);
194extern u_long (*ip_mcast_src)(int);204extern u_long (*ip_mcast_src)(int);
195VNET_DECLARE(int, rsvp_on);205VNET_DECLARE(int, rsvp_on);
196VNET_DECLARE(int, drop_redirect);206VNET_DECLARE(int, drop_redirect);
207VNET_DECLARE(int, ip_random_id);
197208
198#define V_ip_id VNET(ip_id)209#define V_ip_id VNET(ip_id)
199#define V_ip_defttl VNET(ip_defttl)210#define V_ip_defttl VNET(ip_defttl)
...@@ -206,6 +217,7 @@ VNET_DECLARE(int, drop_redirect);...@@ -206,6 +217,7 @@ VNET_DECLARE(int, drop_redirect);
206#define V_ip_mrouter VNET(ip_mrouter)217#define V_ip_mrouter VNET(ip_mrouter)
207#define V_rsvp_on VNET(rsvp_on)218#define V_rsvp_on VNET(rsvp_on)
208#define V_drop_redirect VNET(drop_redirect)219#define V_drop_redirect VNET(drop_redirect)
220#define V_ip_random_id VNET(ip_random_id)
209221
210void inp_freemoptions(struct ip_moptions *);222void inp_freemoptions(struct ip_moptions *);
211int inp_getmoptions(struct inpcb *, struct sockopt *);223int inp_getmoptions(struct inpcb *, struct sockopt *);
...@@ -225,7 +237,7 @@ struct mbuf *...@@ -225,7 +237,7 @@ struct mbuf *
225 ip_reass(struct mbuf *);237 ip_reass(struct mbuf *);
226void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,238void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,
227 struct mbuf *);239 struct mbuf *);
228void ip_fillid(struct ip *);240void ip_fillid(struct ip *, bool);
229int rip_ctloutput(struct socket *, struct sockopt *);241int rip_ctloutput(struct socket *, struct sockopt *);
230int ipip_input(struct mbuf **, int *, int);242int ipip_input(struct mbuf **, int *, int);
231int rsvp_input(struct mbuf **, int *, int);243int rsvp_input(struct mbuf **, int *, int);
...@@ -259,6 +271,7 @@ VNET_DECLARE(struct pfil_head *, inet_local_pfil_head);...@@ -259,6 +271,7 @@ VNET_DECLARE(struct pfil_head *, inet_local_pfil_head);
259#define PFIL_INET_LOCAL_NAME "inet-local"271#define PFIL_INET_LOCAL_NAME "inet-local"
260272
261void in_delayed_cksum(struct mbuf *m);273void in_delayed_cksum(struct mbuf *m);
274void in_delayed_cksum_o(struct mbuf *m, uint16_t o);
262275
263/* Hooks for ipfw, dummynet, divert etc. Most are declared in raw_ip.c */276/* Hooks for ipfw, dummynet, divert etc. Most are declared in raw_ip.c */
264/*277/*
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)\...@@ -305,13 +305,11 @@ _n##_rb_walktree(struct _n##_rb_head *head, _n##_rb_walker_t func, void *arg)\
305 _t *prev; \305 _t *prev; \
306 _t *next; \306 _t *next; \
307 _t *node = head->top._f.right; \307 _t *node = head->top._f.right; \
308 _t *base; \
309 \308 \
310 while (node != &_n##_rb_zero) \309 while (node != &_n##_rb_zero) \
311 node = node->_f.left; \310 node = node->_f.left; \
312 \311 \
313 for (;;) { \312 for (;;) { \
314 base = node; \
315 prev = node; \313 prev = node; \
316 while ((node->_f.parent->_f.right == node) && \314 while ((node->_f.parent->_f.right == node) && \
317 (node != &_n##_rb_zero)) { \315 (node != &_n##_rb_zero)) { \
lib/libc/include/generic-freebsd/netinet/ipl.h-2
...@@ -2,8 +2,6 @@...@@ -2,8 +2,6 @@
2 * Copyright (C) 2012 by Darren Reed.2 * Copyright (C) 2012 by Darren Reed.
3 *3 *
4 * See the IPFILTER.LICENCE file for details on licencing.4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ipl.h 1.21 6/5/96
7 * Id: ipl.h,v 2.52.2.30 2007/10/16 09:41:00 darrenr Exp $5 * Id: ipl.h,v 2.52.2.30 2007/10/16 09:41:00 darrenr Exp $
8 */6 */
97
lib/libc/include/generic-freebsd/netinet/pim.h+1-1
...@@ -71,7 +71,7 @@ struct pim {...@@ -71,7 +71,7 @@ struct pim {
71#endif /* ! _PIM_VT */71#endif /* ! _PIM_VT */
72 uint8_t pim_reserved; /* Reserved */72 uint8_t pim_reserved; /* Reserved */
73 uint16_t pim_cksum; /* IP-style checksum */73 uint16_t pim_cksum; /* IP-style checksum */
74};74} __packed;
75/* KAME-related name backward compatibility */75/* KAME-related name backward compatibility */
76#define pim_ver pim_vers76#define pim_ver pim_vers
77#define pim_rsv pim_reserved77#define pim_rsv pim_reserved
lib/libc/include/generic-freebsd/netinet/sctp.h-1
...@@ -35,7 +35,6 @@...@@ -35,7 +35,6 @@
35#ifndef _NETINET_SCTP_H_35#ifndef _NETINET_SCTP_H_
36#define _NETINET_SCTP_H_36#define _NETINET_SCTP_H_
3737
38#include <sys/cdefs.h>
39#include <sys/types.h>38#include <sys/types.h>
4039
41#define SCTP_PACKED __attribute__((packed))40#define SCTP_PACKED __attribute__((packed))
lib/libc/include/generic-freebsd/netinet/sctp_os.h-3
...@@ -39,9 +39,6 @@...@@ -39,9 +39,6 @@
39 * General kernel memory allocation:39 * General kernel memory allocation:
40 * SCTP_MALLOC(element, type, size, name)40 * SCTP_MALLOC(element, type, size, name)
41 * SCTP_FREE(element)41 * 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)
45 */42 */
4643
47/*44/*
lib/libc/include/generic-freebsd/netinet/sctp_os_bsd.h+1-8
...@@ -219,13 +219,6 @@ MALLOC_DECLARE(SCTP_M_MCORE);...@@ -219,13 +219,6 @@ MALLOC_DECLARE(SCTP_M_MCORE);
219219
220#define SCTP_FREE(var, type) free(var, type)220#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
229#define SCTP_PROCESS_STRUCT struct proc *222#define SCTP_PROCESS_STRUCT struct proc *
230223
231/*224/*
...@@ -349,7 +342,7 @@ typedef struct callout sctp_os_timer_t;...@@ -349,7 +342,7 @@ typedef struct callout sctp_os_timer_t;
349 } while(0)342 } while(0)
350343
351/* Other m_pkthdr type things */344/* 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)
353#define SCTP_IS_IT_LOOPBACK(m) ((m->m_flags & M_PKTHDR) && ((m->m_pkthdr.rcvif == NULL) || (m->m_pkthdr.rcvif->if_type == IFT_LOOP)))346#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
355/* This converts any input packet header348/* This converts any input packet header
lib/libc/include/generic-freebsd/netinet/sctp_var.h+4-4
...@@ -331,17 +331,17 @@ void...@@ -331,17 +331,17 @@ void
331sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,331sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
332 uint8_t, uint8_t, uint16_t, uint32_t);332 uint8_t, uint8_t, uint16_t, uint32_t);
333int sctp_flush(struct socket *, int);333int sctp_flush(struct socket *, int);
334int sctp_shutdown(struct socket *);334int sctp_shutdown(struct socket *, enum shutdown_how);
335int335int
336sctp_bindx(struct socket *, int, struct sockaddr_storage *,336sctp_bindx(struct socket *, int, struct sockaddr_storage *,
337 int, int, struct proc *);337 int, int, struct proc *);
338338
339/* can't use sctp_assoc_t here */339/* can't use sctp_assoc_t here */
340int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);340int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
341int sctp_ingetaddr(struct socket *, struct sockaddr **);341int sctp_ingetaddr(struct socket *, struct sockaddr *);
342int sctp_peeraddr(struct socket *, struct sockaddr **);342int sctp_peeraddr(struct socket *, struct sockaddr *);
343int sctp_listen(struct socket *, int, struct thread *);343int sctp_listen(struct socket *, int, struct thread *);
344int sctp_accept(struct socket *, struct sockaddr **);344int sctp_accept(struct socket *, struct sockaddr *);
345345
346#endif /* _KERNEL */346#endif /* _KERNEL */
347347
lib/libc/include/generic-freebsd/netinet/tcp.h+204-166
...@@ -27,14 +27,11 @@...@@ -27,14 +27,11 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcp.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NETINET_TCP_H_32#ifndef _NETINET_TCP_H_
35#define _NETINET_TCP_H_33#define _NETINET_TCP_H_
3634
37#include <sys/cdefs.h>
38#include <sys/types.h>35#include <sys/types.h>
3936
40#if __BSD_VISIBLE37#if __BSD_VISIBLE
...@@ -74,13 +71,31 @@ struct tcphdr {...@@ -74,13 +71,31 @@ struct tcphdr {
74#define TH_RES3 0x20071#define TH_RES3 0x200
75#define TH_RES2 0x40072#define TH_RES2 0x400
76#define TH_RES1 0x80073#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)
78#define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR\11AE"75#define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR\11AE"
7976
80 u_short th_win; /* window */77 u_short th_win; /* window */
81 u_short th_sum; /* checksum */78 u_short th_sum; /* checksum */
82 u_short th_urp; /* urgent pointer */79 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
85#define PADTCPOLEN(len) ((((len) / 4) + !!((len) % 4)) * 4)100#define PADTCPOLEN(len) ((((len) / 4) + !!((len) % 4)) * 4)
86101
...@@ -151,8 +166,6 @@ struct tcphdr {...@@ -151,8 +166,6 @@ struct tcphdr {
151166
152#define TCP_MAX_WINSHIFT 14 /* maximum window shift */167#define TCP_MAX_WINSHIFT 14 /* maximum window shift */
153168
154#define TCP_MAXBURST 4 /* maximum segments in a burst */
155
156#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */169#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */
157#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr))170#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr))
158 /* max space left for options */171 /* max space left for options */
...@@ -167,165 +180,170 @@ struct tcphdr {...@@ -167,165 +180,170 @@ struct tcphdr {
167 * values and are not masked together. Some values appear to be180 * values and are not masked together. Some values appear to be
168 * bitmasks for historical reasons.181 * bitmasks for historical reasons.
169 */182 */
170#define TCP_NODELAY 1 /* don't delay send to coalesce packets */183#define TCP_NODELAY 1 /* don't delay send to coalesce packets */
171#if __BSD_VISIBLE184#if __BSD_VISIBLE
172#define TCP_MAXSEG 2 /* set maximum segment size */185#define TCP_MAXSEG 2 /* set maximum segment size */
173#define TCP_NOPUSH 4 /* don't push last block of write */186#define TCP_NOPUSH 4 /* don't push last block of write */
174#define TCP_NOOPT 8 /* don't use TCP options */187#define TCP_NOOPT 8 /* don't use TCP options */
175#define TCP_MD5SIG 16 /* use MD5 digests (RFC2385) */188#define TCP_MD5SIG 16 /* use MD5 digests (RFC2385) */
176#define TCP_INFO 32 /* retrieve tcp_info structure */189#define TCP_INFO 32 /* retrieve tcp_info structure */
177#define TCP_STATS 33 /* retrieve stats blob structure */190#define TCP_STATS 33 /* retrieve stats blob structure */
178#define TCP_LOG 34 /* configure event logging for connection */191#define TCP_LOG 34 /* configure event logging for connection */
179#define TCP_LOGBUF 35 /* retrieve event log for connection */192#define TCP_LOGBUF 35 /* retrieve event log for connection */
180#define TCP_LOGID 36 /* configure log ID to correlate connections */193#define TCP_LOGID 36 /* configure log ID to correlate connections */
181#define TCP_LOGDUMP 37 /* dump connection log events to device */194#define TCP_LOGDUMP 37 /* dump connection log events to device */
182#define TCP_LOGDUMPID 38 /* dump events from connections with same ID to195#define TCP_LOGDUMPID 38 /* dump events from connections with same ID to
183 device */196 device */
184#define TCP_TXTLS_ENABLE 39 /* TLS framing and encryption for transmit */197#define TCP_TXTLS_ENABLE 39 /* TLS framing and encryption for transmit */
185#define TCP_TXTLS_MODE 40 /* Transmit TLS mode */198#define TCP_TXTLS_MODE 40 /* Transmit TLS mode */
186#define TCP_RXTLS_ENABLE 41 /* TLS framing and encryption for receive */199#define TCP_RXTLS_ENABLE 41 /* TLS framing and encryption for receive */
187#define TCP_RXTLS_MODE 42 /* Receive TLS mode */200#define TCP_RXTLS_MODE 42 /* Receive TLS mode */
188#define TCP_IWND_NB 43 /* Override initial window (units: bytes) */201#define TCP_IWND_NB 43 /* Override initial window (units: bytes) */
189#define TCP_IWND_NSEG 44 /* Override initial window (units: MSS segs) */202#define TCP_IWND_NSEG 44 /* Override initial window (units: MSS segs) */
190#ifdef _KERNEL203#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 */
192#endif205#endif
193#define TCP_LOGID_CNT 46 /* get number of connections with the same ID */206#define TCP_LOGID_CNT 46 /* get number of connections with the same ID */
194#define TCP_LOG_TAG 47 /* configure tag for grouping logs */207#define TCP_LOG_TAG 47 /* configure tag for grouping logs */
195#define TCP_USER_LOG 48 /* userspace log event */208#define TCP_USER_LOG 48 /* userspace log event */
196#define TCP_CONGESTION 64 /* get/set congestion control algorithm */209#define TCP_CONGESTION 64 /* get/set congestion control algorithm */
197#define TCP_CCALGOOPT 65 /* get/set cc algorithm specific options */210#define TCP_CCALGOOPT 65 /* get/set cc algorithm specific options */
198#define TCP_MAXUNACKTIME 68 /* maximum time without making progress (sec) */211#define TCP_MAXUNACKTIME 68 /* maximum time without making progress (sec) */
199#define TCP_MAXPEAKRATE 69 /* maximum peak rate allowed (kbps) */212/* unused 69 */
200#define TCP_IDLE_REDUCE 70 /* Reduce cwnd on idle input */213#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 */214#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 */215#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 */216#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 */217#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 */218#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 */219#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 */220#define TCP_USE_CMP_ACKS 77 /* The transport can handle the Compressed mbuf acks */
208#define TCP_PERF_INFO 78 /* retrieve accounting counters */221#define TCP_PERF_INFO 78 /* retrieve accounting counters */
209#define TCP_LRD 79 /* toggle Lost Retransmission Detection for A/B testing */222#define TCP_KEEPINIT 128 /* N, time to establish connection */
210#define TCP_KEEPINIT 128 /* N, time to establish connection */223#define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */
211#define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */224#define TCP_KEEPINTVL 512 /* L,N interval between keepalives */
212#define TCP_KEEPINTVL 512 /* L,N interval between keepalives */225#define TCP_KEEPCNT 1024 /* L,N number of keepalives before close */
213#define TCP_KEEPCNT 1024 /* L,N number of keepalives before close */226#define TCP_FASTOPEN 1025 /* enable TFO / was created via TFO */
214#define TCP_FASTOPEN 1025 /* enable TFO / was created via TFO */227/* unused 2048 was TCP_PCAP_OUT */
215#define TCP_PCAP_OUT 2048 /* number of output packets to keep */228/* unused 4096 was TCP_PCAP_IN */
216#define TCP_PCAP_IN 4096 /* number of input packets to keep */229#define TCP_FUNCTION_BLK 8192 /* Set the tcp function pointers to the specified stack */
217#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 */
218#define TCP_FUNCTION_ALIAS 8193 /* Get the current tcp function pointer name alias */
219/* Options for Rack and BBR */231/* Options for Rack and BBR */
220#define TCP_REUSPORT_LB_NUMA 1026 /* set listen socket numa domain */232#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 */233#define TCP_RACK_MBUF_QUEUE 1050 /* Do we allow mbuf queuing if supported */
222#define TCP_RACK_PROP 1051 /* Not used */234/* unused 1051 */
223#define TCP_RACK_TLP_REDUCE 1052 /* RACK TLP cwnd reduction (bool) */235#define TCP_RACK_TLP_REDUCE 1052 /* RACK TLP cwnd reduction (bool) */
224#define TCP_RACK_PACE_REDUCE 1053 /* RACK Pacingv reduction factor (divisor) */236/* unused 1053 */
225#define TCP_RACK_PACE_MAX_SEG 1054 /* Max TSO size we will send */237#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 */238#define TCP_RACK_PACE_ALWAYS 1055 /* Use the always pace method */
227#define TCP_RACK_PROP_RATE 1056 /* Not used */239/* unused 1056 */
228#define TCP_RACK_PRR_SENDALOT 1057 /* Allow PRR to send more than one seg */240#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 */241#define TCP_RACK_MIN_TO 1058 /* Minimum time between rack t-o's in ms */
230#define TCP_RACK_EARLY_RECOV 1059 /* Not used */242/* unused 1059 */
231#define TCP_RACK_EARLY_SEG 1060 /* If early recovery max segments */243#define TCP_RACK_EARLY_SEG 1060 /* If early recovery max segments */
232#define TCP_RACK_REORD_THRESH 1061 /* RACK reorder threshold (shift amount) */244#define TCP_RACK_REORD_THRESH 1061 /* RACK reorder threshold (shift amount) */
233#define TCP_RACK_REORD_FADE 1062 /* Does reordering fade after ms time */245#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) */246#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 */247#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 */248/* unused 1065 */
237#define TCP_BBR_IWINTSO 1067 /* Initial TSO window for BBRs first sends */249/* unused 1066 */
238#define TCP_BBR_RECFORCE 1068 /* Enter recovery force out a segment disregard pacer no longer valid */250#define TCP_BBR_IWINTSO 1067 /* Initial TSO window for BBRs first sends */
239#define TCP_BBR_STARTUP_PG 1069 /* Startup pacing gain */251/* unused 1068 */
240#define TCP_BBR_DRAIN_PG 1070 /* Drain pacing gain */252#define TCP_BBR_STARTUP_PG 1069 /* Startup pacing gain */
241#define TCP_BBR_RWND_IS_APP 1071 /* Rwnd limited is considered app limited */253#define TCP_BBR_DRAIN_PG 1070 /* Drain pacing gain */
242#define TCP_BBR_PROBE_RTT_INT 1072 /* How long in useconds between probe-rtt */254/* unused 1071 */
243#define TCP_BBR_ONE_RETRAN 1073 /* Is only one segment allowed out during retran */255#define TCP_BBR_PROBE_RTT_INT 1072 /* How long in useconds between probe-rtt */
244#define TCP_BBR_STARTUP_LOSS_EXIT 1074 /* Do we exit a loss during startup if not 20% incr */256/* unused 1073 */
245#define TCP_BBR_USE_LOWGAIN 1075 /* lower the gain in PROBE_BW enable */257#define TCP_BBR_STARTUP_LOSS_EXIT 1074 /* Do we exit a loss during startup if not 20% incr */
246#define TCP_BBR_LOWGAIN_THRESH 1076 /* Unused after 2.3 morphs to TSLIMITS >= 2.3 */258/* unused 1075 */
247#define TCP_BBR_TSLIMITS 1076 /* Do we use experimental Timestamp limiting for our algo */259#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 */260#define TCP_BBR_PACE_OH 1077 /* pacing overhead setting */
249#define TCP_BBR_PACE_OH 1077 /* Reused in 4.2 for pacing overhead setting */261/* unused 1078 */
250#define TCP_BBR_LOWGAIN_FD 1078 /* Unused after 2.3 */262#define TCP_BBR_USEDEL_RATE 1079 /* Enable use of delivery rate for loss recovery */
251#define TCP_BBR_HOLD_TARGET 1078 /* For 4.3 on */263#define TCP_BBR_MIN_RTO 1080 /* Min RTO in milliseconds */
252#define TCP_BBR_USEDEL_RATE 1079 /* Enable use of delivery rate for loss recovery */264#define TCP_BBR_MAX_RTO 1081 /* Max RTO in milliseconds */
253#define TCP_BBR_MIN_RTO 1080 /* Min RTO in milliseconds */265/* unused 1082 */
254#define TCP_BBR_MAX_RTO 1081 /* Max RTO in milliseconds */266#define TCP_BBR_ALGORITHM 1083 /* What measurement algo does BBR use netflix=0, google=1 */
255#define TCP_BBR_REC_OVER_HPTS 1082 /* Recovery override htps settings 0/1/3 */267/* unused 1084 */
256#define TCP_BBR_UNLIMITED 1083 /* Not used before 2.3 and morphs to algorithm >= 2.3 */268/* unused 1085 */
257#define TCP_BBR_ALGORITHM 1083 /* What measurement algo does BBR use netflix=0, google=1 */269#define TCP_BBR_PACE_PER_SEC 1086
258#define TCP_BBR_DRAIN_INC_EXTRA 1084 /* Does the 3/4 drain target include the extra gain */270#define TCP_BBR_PACE_DEL_TAR 1087
259#define TCP_BBR_STARTUP_EXIT_EPOCH 1085 /* what epoch gets us out of startup */271#define TCP_BBR_PACE_SEG_MAX 1088
260#define TCP_BBR_PACE_PER_SEC 1086272#define TCP_BBR_PACE_SEG_MIN 1089
261#define TCP_BBR_PACE_DEL_TAR 1087273#define TCP_BBR_PACE_CROSS 1090
262#define TCP_BBR_PACE_SEG_MAX 1088274/* unused 1091 */
263#define TCP_BBR_PACE_SEG_MIN 1089275/* unused 1092 */
264#define TCP_BBR_PACE_CROSS 1090276/* unused 1093 */
265#define TCP_RACK_IDLE_REDUCE_HIGH 1092 /* Reduce the highest cwnd seen to IW on idle */277/* unused 1094 */
266#define TCP_RACK_MIN_PACE 1093 /* Do we enforce rack min pace time */278#define TCP_RACK_TLP_USE 1095
267#define TCP_RACK_MIN_PACE_SEG 1094 /* If so what is the seg threshould */279#define TCP_BBR_TMR_PACE_OH 1096 /* ??? */
268#define TCP_RACK_GP_INCREASE 1094 /* After 4.1 its the GP increase in older rack */280#define TCP_RACK_DO_DETECTION 1097 /* Recycle of extra gain for rack, attack detection */
269#define TCP_RACK_TLP_USE 1095281#define TCP_BBR_RACK_RTT_USE 1098 /* what RTT should we use 0, 1, or 2? */
270#define TCP_BBR_ACK_COMP_ALG 1096 /* Not used */282#define TCP_BBR_RETRAN_WTSO 1099
271#define TCP_BBR_TMR_PACE_OH 1096 /* Recycled in 4.2 */283#define TCP_DATA_AFTER_CLOSE 1100
272#define TCP_BBR_EXTRA_GAIN 1097284#define TCP_BBR_PROBE_RTT_GAIN 1101
273#define TCP_RACK_DO_DETECTION 1097 /* Recycle of extra gain for rack, attack detection */285#define TCP_BBR_PROBE_RTT_LEN 1102
274#define TCP_BBR_RACK_RTT_USE 1098 /* what RTT should we use 0, 1, or 2? */286#define TCP_BBR_SEND_IWND_IN_TSO 1103 /* Do we burst out whole iwin size chunks at start? */
275#define TCP_BBR_RETRAN_WTSO 1099287#define TCP_BBR_USE_RACK_RR 1104 /* Do we use the rack rapid recovery for pacing rxt's */
276#define TCP_DATA_AFTER_CLOSE 1100288#define TCP_BBR_USE_RACK_CHEAT TCP_BBR_USE_RACK_RR /* Compat. */
277#define TCP_BBR_PROBE_RTT_GAIN 1101289#define TCP_BBR_HDWR_PACE 1105 /* Enable/disable hardware pacing */
278#define TCP_BBR_PROBE_RTT_LEN 1102290#define TCP_BBR_UTTER_MAX_TSO 1106 /* Do we enforce an utter max TSO size */
279#define TCP_BBR_SEND_IWND_IN_TSO 1103 /* Do we burst out whole iwin size chunks at start? */291#define TCP_BBR_EXTRA_STATE 1107 /* Special exit-persist catch up */
280#define TCP_BBR_USE_RACK_RR 1104 /* Do we use the rack rapid recovery for pacing rxt's */292#define TCP_BBR_FLOOR_MIN_TSO 1108 /* The min tso size */
281#define TCP_BBR_USE_RACK_CHEAT TCP_BBR_USE_RACK_RR /* Compat. */293#define TCP_BBR_MIN_TOPACEOUT 1109 /* Do we suspend pacing until */
282#define TCP_BBR_HDWR_PACE 1105 /* Enable/disable hardware pacing */294#define TCP_BBR_TSTMP_RAISES 1110 /* Can a timestamp measurement raise the b/w */
283#define TCP_BBR_UTTER_MAX_TSO 1106 /* Do we enforce an utter max TSO size */295#define TCP_BBR_POLICER_DETECT 1111 /* Turn on/off google mode policer detection */
284#define TCP_BBR_EXTRA_STATE 1107 /* Special exit-persist catch up */296#define TCP_BBR_RACK_INIT_RATE 1112 /* Set an initial pacing rate for when we have no b/w in kbits per sec */
285#define TCP_BBR_FLOOR_MIN_TSO 1108 /* The min tso size */297#define TCP_RACK_RR_CONF 1113 /* Rack rapid recovery configuration control*/
286#define TCP_BBR_MIN_TOPACEOUT 1109 /* Do we suspend pacing until */298#define TCP_RACK_GP_INCREASE_CA 1114 /* GP increase for Congestion Avoidance */
287#define TCP_BBR_TSTMP_RAISES 1110 /* Can a timestamp measurement raise the b/w */299#define TCP_RACK_GP_INCREASE_SS 1115 /* GP increase for Slow Start */
288#define TCP_BBR_POLICER_DETECT 1111 /* Turn on/off google mode policer detection */300#define TCP_RACK_GP_INCREASE_REC 1116 /* GP increase for Recovery */
289#define TCP_BBR_RACK_INIT_RATE 1112 /* Set an initial pacing rate for when we have no b/w in kbits per sec */301#define TCP_RACK_FORCE_MSEG 1117 /* Override to use the user set max-seg value */
290#define TCP_RACK_RR_CONF 1113 /* Rack rapid recovery configuration control*/302#define TCP_RACK_PACE_RATE_CA 1118 /* Pacing rate for Congestion Avoidance */
291#define TCP_RACK_CHEAT_NOT_CONF_RATE TCP_RACK_RR_CONF303#define TCP_RACK_PACE_RATE_SS 1119 /* Pacing rate for Slow Start */
292#define TCP_RACK_GP_INCREASE_CA 1114 /* GP increase for Congestion Avoidance */304#define TCP_RACK_PACE_RATE_REC 1120 /* Pacing rate for Recovery */
293#define TCP_RACK_GP_INCREASE_SS 1115 /* GP increase for Slow Start */305#define TCP_NO_PRR 1122 /* If pacing, don't use prr */
294#define TCP_RACK_GP_INCREASE_REC 1116 /* GP increase for Recovery */306#define TCP_RACK_NONRXT_CFG_RATE 1123 /* In recovery does a non-rxt use the cfg rate */
295#define TCP_RACK_FORCE_MSEG 1117 /* Override to use the user set max-seg value */307#define TCP_SHARED_CWND_ENABLE 1124 /* Use a shared cwnd if allowed */
296#define TCP_RACK_PACE_RATE_CA 1118 /* Pacing rate for Congestion Avoidance */308#define TCP_TIMELY_DYN_ADJ 1125 /* Do we attempt dynamic multipler adjustment with timely. */
297#define TCP_RACK_PACE_RATE_SS 1119 /* Pacing rate for Slow Start */309#define TCP_RACK_NO_PUSH_AT_MAX 1126 /* For timely do not push if we are over max rtt */
298#define TCP_RACK_PACE_RATE_REC 1120 /* Pacing rate for Recovery */310#define TCP_RACK_PACE_TO_FILL 1127 /* If we are not in recovery, always pace to fill the cwnd in 1 RTT */
299#define TCP_NO_PRR 1122 /* If pacing, don't use prr */311#define TCP_SHARED_CWND_TIME_LIMIT 1128 /* we should limit to low time values the scwnd life */
300#define TCP_RACK_NONRXT_CFG_RATE 1123 /* In recovery does a non-rxt use the cfg rate */312#define TCP_RACK_PROFILE 1129 /* Select a profile that sets multiple options */
301#define TCP_SHARED_CWND_ENABLE 1124 /* Use a shared cwnd if allowed */313#define TCP_HDWR_RATE_CAP 1130 /* Allow hardware rates to cap pacing rate */
302#define TCP_TIMELY_DYN_ADJ 1125 /* Do we attempt dynamic multipler adjustment with timely. */314#define TCP_PACING_RATE_CAP 1131 /* Highest rate allowed in pacing in bytes per second (uint64_t) */
303#define TCP_RACK_NO_PUSH_AT_MAX 1126 /* For timely do not push if we are over max rtt */315#define TCP_HDWR_UP_ONLY 1132 /* Allow the pacing rate to climb but not descend (with the exception of fill-cw */
304#define TCP_RACK_PACE_TO_FILL 1127 /* If we are not in recovery, always pace to fill the cwnd in 1 RTT */316#define TCP_RACK_ABC_VAL 1133 /* Set a local ABC value different then the system default */
305#define TCP_SHARED_CWND_TIME_LIMIT 1128 /* we should limit to low time values the scwnd life */317#define TCP_REC_ABC_VAL 1134 /* Do we use the ABC value for recovery or the override one from sysctl */
306#define TCP_RACK_PROFILE 1129 /* Select a profile that sets multiple options */318#define TCP_RACK_MEASURE_CNT 1135 /* How many measurements are required in GP pacing */
307#define TCP_HDWR_RATE_CAP 1130 /* Allow hardware rates to cap pacing rate */319#define TCP_DEFER_OPTIONS 1136 /* Defer options until the proper number of measurements occur, does not defer TCP_RACK_MEASURE_CNT */
308#define TCP_PACING_RATE_CAP 1131 /* Highest rate allowed in pacing in bytes per second (uint64_t) */320/* unused 1137 */
309#define TCP_HDWR_UP_ONLY 1132 /* Allow the pacing rate to climb but not descend (with the exception of fill-cw */321#define TCP_RACK_PACING_BETA 1138 /* Changing the beta for pacing */
310#define TCP_RACK_ABC_VAL 1133 /* Set a local ABC value different then the system default */322#define TCP_RACK_PACING_BETA_ECN 1139 /* Changing the beta for ecn with pacing */
311#define TCP_REC_ABC_VAL 1134 /* Do we use the ABC value for recovery or the override one from sysctl */323#define TCP_RACK_TIMER_SLOP 1140 /* Set or get the timer slop used */
312#define TCP_RACK_MEASURE_CNT 1135 /* How many measurements are required in GP pacing */324#define TCP_RACK_DSACK_OPT 1141 /* How do we setup rack timer DSACK options bit 1/2 */
313#define TCP_DEFER_OPTIONS 1136 /* Defer options until the proper number of measurements occur, does not defer TCP_RACK_MEASURE_CNT */325#define TCP_RACK_ENABLE_HYSTART 1142 /* Do we allow hystart in the CC modules */
314#define TCP_FAST_RSM_HACK 1137 /* Not used in modern stacks */326#define TCP_RACK_SET_RXT_OPTIONS 1143 /* Set the bits in the retransmit options */
315#define TCP_RACK_PACING_BETA 1138 /* Changing the beta for pacing */327#define TCP_RACK_HI_BETA 1144 /* Turn on/off high beta */
316#define TCP_RACK_PACING_BETA_ECN 1139 /* Changing the beta for ecn with pacing */328#define TCP_RACK_SPLIT_LIMIT 1145 /* Set a split limit for split allocations */
317#define TCP_RACK_TIMER_SLOP 1140 /* Set or get the timer slop used */329#define TCP_RACK_PACING_DIVISOR 1146 /* Pacing divisor given to rate-limit code for burst sizing */
318#define TCP_RACK_DSACK_OPT 1141 /* How do we setup rack timer DSACK options bit 1/2 */330#define TCP_RACK_PACE_MIN_SEG 1147 /* Pacing min seg size rack will use */
319#define TCP_RACK_ENABLE_HYSTART 1142 /* Do we allow hystart in the CC modules */331#define TCP_RACK_DGP_IN_REC 1148 /* Do we use full DGP in recovery? */
320#define TCP_RACK_SET_RXT_OPTIONS 1143 /* Set the bits in the retransmit options */332/* unused 1149 */
321#define TCP_RACK_HI_BETA 1144 /* Turn on/off high beta */333#define TCP_HYBRID_PACING 1150 /* Hybrid pacing enablement */
322#define TCP_RACK_SPLIT_LIMIT 1145 /* Set a split limit for split allocations */334#define TCP_PACING_DND 1151 /* When pacing with rr_config=3 can sacks disturb us */
323#define TCP_RACK_PACING_DIVISOR 1146 /* Pacing divisor given to rate-limit code for burst sizing */335#define TCP_SS_EEXIT 1152 /* Do we do early exit from slowtart if no b/w growth */
324#define TCP_RACK_PACE_MIN_SEG 1147 /* Pacing min seg size rack will use */336#define TCP_DGP_UPPER_BOUNDS 1153 /* SS and CA upper bound in percentage */
325#define TCP_RACK_DGP_IN_REC 1148 /* Do we use full DGP in recovery? */337#define TCP_NO_TIMELY 1154 /* Disable/enable Timely */
326#define TCP_RXT_CLAMP 1149 /* Do we apply a threshold to rack so if excess rxt clamp cwnd? */338#define TCP_HONOR_HPTS_MIN 1155 /* Do we honor hpts min to */
327#define TCP_HYBRID_PACING 1150 /* Hybrid pacing enablement */339#define TCP_REC_IS_DYN 1156 /* Do we allow timely to change recovery multiplier? */
328#define TCP_PACING_DND 1151 /* When pacing with rr_config=3 can sacks disturb us */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
330/* Start of reserved space for third-party user-settable options. */348/* Start of reserved space for third-party user-settable options. */
331#define TCP_VENDOR SO_VENDOR349#define TCP_VENDOR SO_VENDOR
...@@ -436,8 +454,9 @@ struct tcp_info {...@@ -436,8 +454,9 @@ struct tcp_info {
436 u_int32_t tcpi_rcv_adv; /* Peer advertised window */454 u_int32_t tcpi_rcv_adv; /* Peer advertised window */
437 u_int32_t tcpi_dupacks; /* Consecutive dup ACKs recvd */455 u_int32_t tcpi_dupacks; /* Consecutive dup ACKs recvd */
438456
457 u_int32_t tcpi_rttmin; /* Min observed RTT */
439 /* Padding to grow without breaking ABI. */458 /* Padding to grow without breaking ABI. */
440 u_int32_t __tcpi_pad[10]; /* Padding. */459 u_int32_t __tcpi_pad[14]; /* Padding. */
441};460};
442461
443/*462/*
...@@ -449,9 +468,23 @@ struct tcp_fastopen {...@@ -449,9 +468,23 @@ struct tcp_fastopen {
449 int enable;468 int enable;
450 uint8_t psk[TCP_FASTOPEN_PSK_LEN];469 uint8_t psk[TCP_FASTOPEN_PSK_LEN];
451};470};
452#endif471
453#define TCP_FUNCTION_NAME_LEN_MAX 32472#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
455struct tcp_function_set {488struct tcp_function_set {
456 char function_set_name[TCP_FUNCTION_NAME_LEN_MAX];489 char function_set_name[TCP_FUNCTION_NAME_LEN_MAX];
457 uint32_t pcbcnt;490 uint32_t pcbcnt;
...@@ -477,6 +510,7 @@ struct tcp_snd_req {...@@ -477,6 +510,7 @@ struct tcp_snd_req {
477 uint64_t start;510 uint64_t start;
478 uint64_t end;511 uint64_t end;
479 uint32_t flags;512 uint32_t flags;
513 uint32_t playout_ms;
480};514};
481515
482union tcp_log_userdata {516union tcp_log_userdata {
...@@ -507,9 +541,12 @@ struct tcp_log_user {...@@ -507,9 +541,12 @@ struct tcp_log_user {
507#define TCP_HYBRID_PACING_H_MS 0x0008 /* A client hint for maxseg is present */541#define TCP_HYBRID_PACING_H_MS 0x0008 /* A client hint for maxseg is present */
508#define TCP_HYBRID_PACING_ENABLE 0x0010 /* We are enabling hybrid pacing else disable */542#define TCP_HYBRID_PACING_ENABLE 0x0010 /* We are enabling hybrid pacing else disable */
509#define TCP_HYBRID_PACING_S_MSS 0x0020 /* Clent wants us to set the mss overriding gp est in CU */543#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 */
511#define TCP_HYBRID_PACING_WASSET 0x2000 /* We init to this to know if a hybrid command was issued */548#define TCP_HYBRID_PACING_WASSET 0x2000 /* We init to this to know if a hybrid command was issued */
512549#define TCP_HYBRID_PACING_SENDTIME 0x4000 /* Duplicate tm to last, use sendtime for catch up mode */
513550
514struct tcp_hybrid_req {551struct tcp_hybrid_req {
515 struct tcp_snd_req req;552 struct tcp_snd_req req;
...@@ -536,4 +573,5 @@ struct tcp_hybrid_req {...@@ -536,4 +573,5 @@ struct tcp_hybrid_req {
536#define TCP_REUSPORT_LB_NUMA_NODOM (-2) /* remove numa binding */573#define TCP_REUSPORT_LB_NUMA_NODOM (-2) /* remove numa binding */
537#define TCP_REUSPORT_LB_NUMA_CURDOM (-1) /* bind to current domain */574#define TCP_REUSPORT_LB_NUMA_CURDOM (-1) /* bind to current domain */
538575
576#endif /* __BSD_VISIBLE */
539#endif /* !_NETINET_TCP_H_ */577#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcp_ecn.h 8.4 (Berkeley) 5/24/95
32 */30 */
3331
34#ifndef _NETINET_TCP_ECN_H_32#ifndef _NETINET_TCP_ECN_H_
...@@ -40,6 +38,8 @@...@@ -40,6 +38,8 @@
40#include <netinet/tcp_var.h>38#include <netinet/tcp_var.h>
41#include <netinet/tcp_syncache.h>39#include <netinet/tcp_syncache.h>
4240
41#define TH_ACE_SHIFT 6
42
43void tcp_ecn_input_syn_sent(struct tcpcb *, uint16_t, int);43void tcp_ecn_input_syn_sent(struct tcpcb *, uint16_t, int);
44void tcp_ecn_input_parallel_syn(struct tcpcb *, uint16_t, int);44void tcp_ecn_input_parallel_syn(struct tcpcb *, uint16_t, int);
45int tcp_ecn_input_segment(struct tcpcb *, uint16_t, int, int, int);45int 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);...@@ -48,7 +48,6 @@ int tcp_ecn_output_established(struct tcpcb *, uint16_t *, int, bool);
48void tcp_ecn_syncache_socket(struct tcpcb *, struct syncache *);48void tcp_ecn_syncache_socket(struct tcpcb *, struct syncache *);
49int tcp_ecn_syncache_add(uint16_t, int);49int tcp_ecn_syncache_add(uint16_t, int);
50uint16_t tcp_ecn_syncache_respond(uint16_t, struct syncache *);50uint16_t tcp_ecn_syncache_respond(uint16_t, struct syncache *);
51int tcp_ecn_get_ace(uint16_t);
5251
53#endif /* _KERNEL */52#endif /* _KERNEL */
5453
lib/libc/include/generic-freebsd/netinet/tcp_fastopen.h+1
...@@ -79,6 +79,7 @@ struct tcp_fastopen_ccache {...@@ -79,6 +79,7 @@ struct tcp_fastopen_ccache {
79 uint32_t secret;79 uint32_t secret;
80};80};
8181
82struct tcpcb;
82#ifdef TCP_RFC741383#ifdef TCP_RFC7413
83void tcp_fastopen_init(void);84void tcp_fastopen_init(void);
84void tcp_fastopen_destroy(void);85void tcp_fastopen_destroy(void);
lib/libc/include/generic-freebsd/netinet/tcp_fsm.h-2
...@@ -28,8 +28,6 @@...@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93
33 */31 */
3432
35#ifndef _NETINET_TCP_FSM_H_33#ifndef _NETINET_TCP_FSM_H_
lib/libc/include/generic-freebsd/netinet/tcp_hpts.h+46-91
...@@ -26,14 +26,38 @@...@@ -26,14 +26,38 @@
26#ifndef __tcp_hpts_h__26#ifndef __tcp_hpts_h__
27#define __tcp_hpts_h__27#define __tcp_hpts_h__
2828
29/* Number of useconds in a hpts tick */29/* Number of useconds represented by an hpts slot */
30#define HPTS_TICKS_PER_SLOT 1030#define HPTS_USECS_PER_SLOT 10
31#define HPTS_MS_TO_SLOTS(x) ((x * 100) + 1)31#define HPTS_MS_TO_SLOTS(x) ((x * 100) + 1)
32#define HPTS_USEC_TO_SLOTS(x) ((x+9) /10)32#define HPTS_USEC_TO_SLOTS(x) ((x+9) /10)
33#define HPTS_USEC_IN_SEC 100000033#define HPTS_USEC_IN_SEC 1000000
34#define HPTS_MSEC_IN_SEC 100034#define HPTS_MSEC_IN_SEC 1000
35#define HPTS_USEC_IN_MSEC 100035#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
37struct hpts_diag {61struct hpts_diag {
38 uint32_t p_hpts_active; /* bbr->flex7 x */62 uint32_t p_hpts_active; /* bbr->flex7 x */
39 uint32_t p_nxt_slot; /* bbr->flex1 x */63 uint32_t p_nxt_slot; /* bbr->flex1 x */
...@@ -66,52 +90,16 @@ struct hpts_diag {...@@ -66,52 +90,16 @@ struct hpts_diag {
66#define PACE_PKT_OUTPUT 0x40 /* Output Packets being paced */90#define PACE_PKT_OUTPUT 0x40 /* Output Packets being paced */
67#define PACE_TMR_MASK (PACE_TMR_KEEP|PACE_TMR_PERSIT|PACE_TMR_RXT|PACE_TMR_TLP|PACE_TMR_RACK|PACE_TMR_DELACK)91#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 10093#ifdef _KERNEL
7094
71/*95/*
72 * When using the hpts, a TCP stack must make sure96 * The following are the definitions for the kernel HPTS interface for managing
73 * that once a INP_DROPPED flag is applied to a INP97 * the HPTS ring and the TCBs on it.
74 * that it does not expect tcp_output() to ever be98*/
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 */
11199
112#ifdef _KERNEL
113void tcp_hpts_init(struct tcpcb *);100void tcp_hpts_init(struct tcpcb *);
114void tcp_hpts_remove(struct tcpcb *);101void tcp_hpts_remove(struct tcpcb *);
102
115static inline bool103static inline bool
116tcp_in_hpts(struct tcpcb *tp)104tcp_in_hpts(struct tcpcb *tp)
117{105{
...@@ -149,57 +137,17 @@ uint32_t tcp_hpts_insert_diag(struct tcpcb *tp, uint32_t slot, int32_t line,...@@ -149,57 +137,17 @@ uint32_t tcp_hpts_insert_diag(struct tcpcb *tp, uint32_t slot, int32_t line,
149#define tcp_hpts_insert(inp, slot) \137#define tcp_hpts_insert(inp, slot) \
150 tcp_hpts_insert_diag((inp), (slot), __LINE__, NULL)138 tcp_hpts_insert_diag((inp), (slot), __LINE__, NULL)
151139
152void __tcp_set_hpts(struct tcpcb *tp, int32_t line);140void tcp_set_hpts(struct tcpcb *tp);
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
193141
194extern int32_t tcp_min_hptsi_time;142extern int32_t tcp_min_hptsi_time;
195143
196static inline int32_t144static inline int32_t
197get_hpts_min_sleep_time(void)145get_hpts_min_sleep_time(void)
198{146{
199 return (tcp_min_hptsi_time + HPTS_TICKS_PER_SLOT);147 return (tcp_min_hptsi_time + HPTS_USECS_PER_SLOT);
200}148}
201149
202static __inline uint32_t150static inline uint32_t
203tcp_gethptstick(struct timeval *sv)151tcp_gethptstick(struct timeval *sv)
204{152{
205 struct timeval tv;153 struct timeval tv;
...@@ -207,10 +155,10 @@ tcp_gethptstick(struct timeval *sv)...@@ -207,10 +155,10 @@ tcp_gethptstick(struct timeval *sv)
207 if (sv == NULL)155 if (sv == NULL)
208 sv = &tv;156 sv = &tv;
209 microuptime(sv);157 microuptime(sv);
210 return (tcp_tv_to_hptstick(sv));158 return (tcp_tv_to_hpts_slot(sv));
211}159}
212160
213static __inline uint64_t161static inline uint64_t
214tcp_get_u64_usecs(struct timeval *tv)162tcp_get_u64_usecs(struct timeval *tv)
215{163{
216 struct timeval tvd;164 struct timeval tvd;
...@@ -218,10 +166,10 @@ tcp_get_u64_usecs(struct timeval *tv)...@@ -218,10 +166,10 @@ tcp_get_u64_usecs(struct timeval *tv)
218 if (tv == NULL)166 if (tv == NULL)
219 tv = &tvd;167 tv = &tvd;
220 microuptime(tv);168 microuptime(tv);
221 return (tcp_tv_to_lusectick(tv));169 return (tcp_tv_to_lusec(tv));
222}170}
223171
224static __inline uint32_t172static inline uint32_t
225tcp_get_usecs(struct timeval *tv)173tcp_get_usecs(struct timeval *tv)
226{174{
227 struct timeval tvd;175 struct timeval tvd;
...@@ -229,8 +177,15 @@ tcp_get_usecs(struct timeval *tv)...@@ -229,8 +177,15 @@ tcp_get_usecs(struct timeval *tv)
229 if (tv == NULL)177 if (tv == NULL)
230 tv = &tvd;178 tv = &tvd;
231 microuptime(tv);179 microuptime(tv);
232 return (tcp_tv_to_usectick(tv));180 return (tcp_tv_to_usec(tv));
233}181}
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
235#endif /* _KERNEL */190#endif /* _KERNEL */
236#endif /* __tcp_hpts_h__ */191#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...@@ -60,14 +60,6 @@ struct tcp_log_verbose
60 uint8_t _pad[4];60 uint8_t _pad[4];
61} ALIGN_TCP_LOG;61} 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
71struct tcp_log_bbr {63struct tcp_log_bbr {
72 uint64_t cur_del_rate;64 uint64_t cur_del_rate;
73 uint64_t delRate;65 uint64_t delRate;
...@@ -126,7 +118,6 @@ struct tcp_log_sendfile {...@@ -126,7 +118,6 @@ struct tcp_log_sendfile {
126 */118 */
127union tcp_log_stackspecific119union tcp_log_stackspecific
128{120{
129 struct tcp_log_rack u_rack;
130 struct tcp_log_bbr u_bbr;121 struct tcp_log_bbr u_bbr;
131 struct tcp_log_sendfile u_sf;122 struct tcp_log_sendfile u_sf;
132 struct tcp_log_raw u_raw; /* "raw" log access */123 struct tcp_log_raw u_raw; /* "raw" log access */
...@@ -185,7 +176,6 @@ struct tcp_log_buffer...@@ -185,7 +176,6 @@ struct tcp_log_buffer
185 uint8_t _pad[3]; /* Padding */176 uint8_t _pad[3]; /* Padding */
186 /* Per-stack info */177 /* Per-stack info */
187 union tcp_log_stackspecific tlb_stackinfo;178 union tcp_log_stackspecific tlb_stackinfo;
188#define tlb_rack tlb_stackinfo.u_rack
189179
190 /* The packet */180 /* The packet */
191 uint32_t tlb_len; /* The packet's data length */181 uint32_t tlb_len; /* The packet's data length */
...@@ -201,14 +191,14 @@ enum tcp_log_events {...@@ -201,14 +191,14 @@ enum tcp_log_events {
201 TCP_LOG_OUT, /* Transmit (without other event) 2 */191 TCP_LOG_OUT, /* Transmit (without other event) 2 */
202 TCP_LOG_RTO, /* Retransmit timeout 3 */192 TCP_LOG_RTO, /* Retransmit timeout 3 */
203 TCP_LOG_SB_WAKE, /* Awaken socket buffer 4 */193 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 */
205 TCP_LOG_PRR, /* Doing PRR 6 */195 TCP_LOG_PRR, /* Doing PRR 6 */
206 TCP_LOG_REORDER, /* Detected reorder 7 */196 TCP_UNUSED_7, /* Detected reorder 7 */
207 TCP_LOG_HPTS, /* Hpts sending a packet 8 */197 TCP_LOG_HPTS, /* Hpts sending a packet 8 */
208 BBR_LOG_BBRUPD, /* We updated BBR info 9 */198 BBR_LOG_BBRUPD, /* We updated BBR info 9 */
209 BBR_LOG_BBRSND, /* We did a slot calculation and sending is done 10 */199 BBR_LOG_BBRSND, /* We did a slot calculation and sending is done 10 */
210 BBR_LOG_ACKCLEAR, /* A ack clears all outstanding 11 */200 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 */
212 BBR_LOG_TIMERSTAR, /* Start a timer 13 */202 BBR_LOG_TIMERSTAR, /* Start a timer 13 */
213 BBR_LOG_TIMERCANC, /* Cancel a timer 14 */203 BBR_LOG_TIMERCANC, /* Cancel a timer 14 */
214 BBR_LOG_ENTREC, /* Entered recovery 15 */204 BBR_LOG_ENTREC, /* Entered recovery 15 */
...@@ -245,7 +235,7 @@ enum tcp_log_events {...@@ -245,7 +235,7 @@ enum tcp_log_events {
245 BBR_LOG_REDUCE, /* old bbr log reduce for 4.1 and earlier 46*/235 BBR_LOG_REDUCE, /* old bbr log reduce for 4.1 and earlier 46*/
246 TCP_LOG_RTT, /* A rtt (in useconds) is being sampled and applied to the srtt algo 47 */236 TCP_LOG_RTT, /* A rtt (in useconds) is being sampled and applied to the srtt algo 47 */
247 BBR_LOG_SETTINGS_CHG, /* Settings changed for loss response 48 */237 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 */
249 TCP_LOG_REASS, /* Reassembly buffer logging 50 */239 TCP_LOG_REASS, /* Reassembly buffer logging 50 */
250 TCP_HDWR_PACE_SIZE, /* TCP pacing size set (rl and rack uses this) 51 */240 TCP_HDWR_PACE_SIZE, /* TCP pacing size set (rl and rack uses this) 51 */
251 BBR_LOG_HDWR_PACE, /* TCP Hardware pacing log 52 */241 BBR_LOG_HDWR_PACE, /* TCP Hardware pacing log 52 */
...@@ -253,9 +243,9 @@ enum tcp_log_events {...@@ -253,9 +243,9 @@ enum tcp_log_events {
253 TCP_LOG_CONNEND, /* End of connection 54 */243 TCP_LOG_CONNEND, /* End of connection 54 */
254 TCP_LOG_LRO, /* LRO entry 55 */244 TCP_LOG_LRO, /* LRO entry 55 */
255 TCP_SACK_FILTER_RES, /* Results of SACK Filter 56 */245 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 */
257 TCP_TIMELY_WORK, /* Logs regarding Timely CC tweaks 58 */247 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 */
259 TCP_LOG_SENDFILE, /* sendfile() logging for TCP connections 60 */249 TCP_LOG_SENDFILE, /* sendfile() logging for TCP connections 60 */
260 TCP_LOG_REQ_T, /* logging of request tracking 61 */250 TCP_LOG_REQ_T, /* logging of request tracking 61 */
261 TCP_LOG_ACCOUNTING, /* Log of TCP Accounting data 62 */251 TCP_LOG_ACCOUNTING, /* Log of TCP Accounting data 62 */
...@@ -267,7 +257,9 @@ enum tcp_log_events {...@@ -267,7 +257,9 @@ enum tcp_log_events {
267 TCP_RACK_TP_TRIGGERED, /* A rack tracepoint is triggered 68 */257 TCP_RACK_TP_TRIGGERED, /* A rack tracepoint is triggered 68 */
268 TCP_HYBRID_PACING_LOG, /* Hybrid pacing log 69 */258 TCP_HYBRID_PACING_LOG, /* Hybrid pacing log 69 */
269 TCP_LOG_PRU, /* TCP protocol user request 70 */259 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 */
271};263};
272264
273enum tcp_log_states {265enum tcp_log_states {
...@@ -371,10 +363,11 @@ struct tcp_log_dev_log_queue {...@@ -371,10 +363,11 @@ struct tcp_log_dev_log_queue {
371#define TCP_TP_COLLAPSED_RXT 0x00000004 /* When we actually retransmit a collapsed window rsm */363#define TCP_TP_COLLAPSED_RXT 0x00000004 /* When we actually retransmit a collapsed window rsm */
372#define TCP_TP_REQ_LOG_FAIL 0x00000005 /* We tried to allocate a Request log but had no space */364#define TCP_TP_REQ_LOG_FAIL 0x00000005 /* We tried to allocate a Request log but had no space */
373#define TCP_TP_RESET_RCV 0x00000006 /* Triggers when we receive a RST */365#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 */
375#define TCP_TP_SAD_TRIGGERED 0x00000008 /* Sack Attack Detection triggers */368#define TCP_TP_SAD_TRIGGERED 0x00000008 /* Sack Attack Detection triggers */
376
377#define TCP_TP_SAD_SUSPECT 0x0000000a /* A sack has supicious information in it */369#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
379#ifdef _KERNEL372#ifdef _KERNEL
380373
...@@ -384,12 +377,12 @@ extern int32_t tcp_trace_point_count;...@@ -384,12 +377,12 @@ extern int32_t tcp_trace_point_count;
384377
385/*378/*
386 * Returns true if any sort of BB logging is enabled,379 * Returns true if any sort of BB logging is enabled,
387 * commonly used throughout the codebase. 380 * commonly used throughout the codebase.
388 */381 */
389static inline int382static inline int
390tcp_bblogging_on(struct tcpcb *tp)383tcp_bblogging_on(struct tcpcb *tp)
391{384{
392 if (tp->_t_logstate <= TCP_LOG_STATE_OFF) 385 if (tp->_t_logstate <= TCP_LOG_STATE_OFF)
393 return (0);386 return (0);
394 if (tp->_t_logstate == TCP_LOG_VIA_BBPOINTS)387 if (tp->_t_logstate == TCP_LOG_VIA_BBPOINTS)
395 return (0);388 return (0);
...@@ -434,7 +427,7 @@ tcp_set_bblog_state(struct tcpcb *tp, uint8_t ls, uint8_t bbpoint)...@@ -434,7 +427,7 @@ tcp_set_bblog_state(struct tcpcb *tp, uint8_t ls, uint8_t bbpoint)
434 }427 }
435}428}
436429
437static inline uint32_t 430static inline uint32_t
438tcp_get_bblog_state(struct tcpcb *tp)431tcp_get_bblog_state(struct tcpcb *tp)
439{432{
440 return (tp->_t_logstate);433 return (tp->_t_logstate);
...@@ -546,12 +539,12 @@ struct tcpcb;...@@ -546,12 +539,12 @@ struct tcpcb;
546 NULL, NULL, 0, NULL); \539 NULL, NULL, 0, NULL); \
547 } while (0)540 } while (0)
548#endif /* TCP_LOG_FORCEVERBOSE */541#endif /* TCP_LOG_FORCEVERBOSE */
542/* Assumes/requires the caller has already checked tcp_bblogging_on(tp). */
549#define TCP_LOG_EVENTP(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder, tv) \543#define TCP_LOG_EVENTP(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder, tv) \
550 do { \544 do { \
551 if (tcp_bblogging_on(tp)) \545 KASSERT(tcp_bblogging_on(tp), ("bblogging is off")); \
552 tcp_log_event(tp, th, rxbuf, txbuf, eventid, \546 tcp_log_event(tp, th, rxbuf, txbuf, eventid, errornum, len, \
553 errornum, len, stackinfo, th_hostorder, \547 stackinfo, th_hostorder, NULL, NULL, 0, tv); \
554 NULL, NULL, 0, tv); \
555 } while (0)548 } while (0)
556549
557#ifdef TCP_BLACKBOX550#ifdef TCP_BLACKBOX
...@@ -577,6 +570,9 @@ void tcp_log_flowend(struct tcpcb *tp);...@@ -577,6 +570,9 @@ void tcp_log_flowend(struct tcpcb *tp);
577void tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes,570void tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes,
578 int flags);571 int flags);
579int tcp_log_apply_ratio(struct tcpcb *tp, int ratio);572int 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
580#else /* !TCP_BLACKBOX */576#else /* !TCP_BLACKBOX */
581#define tcp_log_verbose (false)577#define tcp_log_verbose (false)
582578
lib/libc/include/generic-freebsd/netinet/tcp_offload.h+2
...@@ -38,6 +38,8 @@...@@ -38,6 +38,8 @@
3838
39extern int registered_toedevs;39extern int registered_toedevs;
4040
41struct tcpcb;
42
41int tcp_offload_connect(struct socket *, struct sockaddr *);43int tcp_offload_connect(struct socket *, struct sockaddr *);
42void tcp_offload_listen_start(struct tcpcb *);44void tcp_offload_listen_start(struct tcpcb *);
43void tcp_offload_listen_stop(struct tcpcb *);45void 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);...@@ -94,6 +94,8 @@ CK_LIST_HEAD(head_tcp_rate_set, tcp_rate_set);
94#ifndef ETHERNET_SEGMENT_SIZE94#ifndef ETHERNET_SEGMENT_SIZE
95#define ETHERNET_SEGMENT_SIZE 151495#define ETHERNET_SEGMENT_SIZE 1514
96#endif96#endif
97struct tcpcb;
98
97#ifdef RATELIMIT99#ifdef RATELIMIT
98#define DETAILED_RATELIMIT_SYSCTL 1 /*100#define DETAILED_RATELIMIT_SYSCTL 1 /*
99 * Undefine this if you don't want101 * 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...@@ -131,6 +133,9 @@ tcp_get_pacing_burst_size_w_divisor(struct tcpcb *tp, uint64_t bw, uint32_t segs
131void133void
132tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte);134tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte);
133135
136void
137tcp_rl_release_ifnet(struct ifnet *ifp);
138
134#else139#else
135static inline const struct tcp_hwrate_limit_table *140static inline const struct tcp_hwrate_limit_table *
136tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *ifp,141tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *ifp,
...@@ -218,6 +223,10 @@ tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte)...@@ -218,6 +223,10 @@ tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte)
218{223{
219}224}
220225
226static inline void
227tcp_rl_release_ifnet(struct ifnet *ifp)
228{
229}
221#endif230#endif
222231
223/*232/*
lib/libc/include/generic-freebsd/netinet/tcp_seq.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcp_seq.h 8.3 (Berkeley) 6/21/95
32 */30 */
3331
34#ifndef _NETINET_TCP_SEQ_H_32#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);...@@ -89,30 +89,25 @@ int ctf_do_queued_segments(struct tcpcb *tp, int have_pkt);
89uint32_t ctf_outstanding(struct tcpcb *tp);89uint32_t ctf_outstanding(struct tcpcb *tp);
90uint32_t ctf_flight_size(struct tcpcb *tp, uint32_t rc_sacked);90uint32_t ctf_flight_size(struct tcpcb *tp, uint32_t rc_sacked);
91int91int
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,
93 struct tcpcb *tp, int32_t *tlenp,93 struct tcpcb *tp, int32_t *tlenp,
94 int32_t *thf, int32_t *drop_hdrlen, int32_t *ret_val,94 int32_t *thf, int32_t *drop_hdrlen, int32_t *ret_val);
95 uint32_t *ts, uint32_t *cnt);95void ctf_ack_war_checks(struct tcpcb *tp);
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)
9896
99void97void
100__ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp,98ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp,
101 struct tcphdr *th, int32_t thflags, int32_t tlen,99 struct tcphdr *th, int32_t thflags, int32_t tlen,
102 int32_t *ret_val, uint32_t *ts, uint32_t *cnt);100 int32_t *ret_val);
103
104#define ctf_do_dropafterack(a, b, c, d, e, f) __ctf_do_dropafterack(a, b, c, d, e, f, NULL, NULL)
105101
106void102void
107ctf_do_dropwithreset(struct mbuf *m, struct tcpcb *tp,103ctf_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);
109void105void
110ctf_do_drop(struct mbuf *m, struct tcpcb *tp);106ctf_do_drop(struct mbuf *m, struct tcpcb *tp);
111107
112int108int
113__ctf_process_rst(struct mbuf *m, struct tcphdr *th,109ctf_process_rst(struct mbuf *m, struct tcphdr *th,
114 struct socket *so, struct tcpcb *tp, uint32_t *ts, uint32_t *cnt);110 struct socket *so, struct tcpcb *tp);
115#define ctf_process_rst(m, t, s, p) __ctf_process_rst(m, t, s, p, NULL, NULL)
116111
117void112void
118ctf_challenge_ack(struct mbuf *m, struct tcphdr *th,113ctf_challenge_ack(struct mbuf *m, struct tcphdr *th,
...@@ -130,7 +125,7 @@ ctf_calc_rwin(struct socket *so, struct tcpcb *tp);...@@ -130,7 +125,7 @@ ctf_calc_rwin(struct socket *so, struct tcpcb *tp);
130125
131void126void
132ctf_do_dropwithreset_conn(struct mbuf *m, struct tcpcb *tp, struct tcphdr *th,127ctf_do_dropwithreset_conn(struct mbuf *m, struct tcpcb *tp, struct tcphdr *th,
133 int32_t rstreason, int32_t tlen);128 int32_t tlen);
134129
135uint32_t130uint32_t
136ctf_fixed_maxseg(struct tcpcb *tp);131ctf_fixed_maxseg(struct tcpcb *tp);
lib/libc/include/generic-freebsd/netinet/tcp_stacks/sack_filter.h+83-13
...@@ -25,19 +25,84 @@...@@ -25,19 +25,84 @@
25 * SUCH DAMAGE.25 * SUCH DAMAGE.
26 */26 */
2727
28/*28/**
29 * Seven entry's is carefully choosen to29 *
30 * fit in one cache line. We can easily30 * The Sack filter is designed to do two functions, first it trys to reduce
31 * change this to 15 (but it gets very31 * the processing of sacks. Consider that often times you get something like
32 * little extra filtering). To change it32 *
33 * to be larger than 15 would require either33 * ack 1 (sack 100:200)
34 * sf_bits becoming a uint32_t and then you34 * ack 1 (sack 100:300)
35 * could go to 31.. or change it to a full35 * ack 1 (sack(100:400)
36 * bitstring.. It is really doubtful you36 *
37 * will get much benefit beyond 7, in testing37 * You really want to process the 100:200 and then on the next sack process
38 * there was a small amount but very very small.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 *
39 */103 */
40#define SACK_FILTER_BLOCKS 7104
105#define SACK_FILTER_BLOCKS 15
41106
42struct sack_filter {107struct sack_filter {
43 tcp_seq sf_ack;108 tcp_seq sf_ack;
...@@ -48,8 +113,13 @@ struct sack_filter {...@@ -48,8 +113,13 @@ struct sack_filter {
48};113};
49#ifdef _KERNEL114#ifdef _KERNEL
50void sack_filter_clear(struct sack_filter *sf, tcp_seq seq);115void 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,
52 tcp_seq th_ack);117 tcp_seq th_ack);
53void sack_filter_reject(struct sack_filter *sf, struct sackblk *in);118void 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
54#endif124#endif
55#endif125#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_stacks/tailq_hash.h+7-1
...@@ -13,10 +13,12 @@...@@ -13,10 +13,12 @@
13#define MAX_ALLOWED_SEQ_RANGE (SEQ_BUCKET_SIZE * (MAX_HASH_ENTRIES-1))13#define MAX_ALLOWED_SEQ_RANGE (SEQ_BUCKET_SIZE * (MAX_HASH_ENTRIES-1))
1414
15struct tailq_hash {15struct tailq_hash {
16 struct rack_head ht[MAX_HASH_ENTRIES];
17 uint32_t min;16 uint32_t min;
18 uint32_t max;17 uint32_t max;
19 uint32_t count;18 uint32_t count;
19 struct rack_sendmap *rsm_min;
20 struct rack_sendmap *rsm_max;
21 struct rack_head ht[MAX_HASH_ENTRIES];
20};22};
2123
22struct rack_sendmap *24struct rack_sendmap *
...@@ -53,6 +55,10 @@ tqhash_init(struct tailq_hash *hs);...@@ -53,6 +55,10 @@ tqhash_init(struct tailq_hash *hs);
53int55int
54tqhash_trim(struct tailq_hash *hs, uint32_t th_ack);56tqhash_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
57#define TQHASH_FOREACH(var, head) \63#define TQHASH_FOREACH(var, head) \
58 for ((var) = tqhash_min((head)); \64 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 {...@@ -347,8 +347,6 @@ struct bbr_log_sysctl_out {
347/*347/*
348 * Locking for the rack control block.348 * Locking for the rack control block.
349 * a) Locked by INP_WLOCK349 * a) Locked by INP_WLOCK
350 * b) Locked by the hpts-mutex
351 *
352 */350 */
353#define BBR_STATE_STARTUP 0x01351#define BBR_STATE_STARTUP 0x01
354#define BBR_STATE_DRAIN 0x02352#define BBR_STATE_DRAIN 0x02
lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_rack.h+89-66
...@@ -48,6 +48,8 @@...@@ -48,6 +48,8 @@
48#define RACK_MERGED 0x080000/* The RSM was merged */48#define RACK_MERGED 0x080000/* The RSM was merged */
49#define RACK_PMTU_CHG 0x100000/* The path mtu changed on this guy */49#define RACK_PMTU_CHG 0x100000/* The path mtu changed on this guy */
50#define RACK_STRADDLE 0x200000/* The seq straddles the bucket line */50#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 */
51#define RACK_NUM_OF_RETRANS 353#define RACK_NUM_OF_RETRANS 3
5254
53#define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */55#define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */
...@@ -63,6 +65,7 @@ struct rack_sendmap {...@@ -63,6 +65,7 @@ struct rack_sendmap {
63 uint32_t r_rtr_bytes; /* How many bytes have been retransmitted */65 uint32_t r_rtr_bytes; /* How many bytes have been retransmitted */
64 uint32_t r_flags : 24, /* Flags as defined above */66 uint32_t r_flags : 24, /* Flags as defined above */
65 r_rtr_cnt : 8; /* Retran count, index this -1 to get time */67 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 */
66 struct mbuf *m;69 struct mbuf *m;
67 uint32_t soff;70 uint32_t soff;
68 uint32_t orig_m_len; /* The original mbuf len when we sent (can update) */71 uint32_t orig_m_len; /* The original mbuf len when we sent (can update) */
...@@ -174,6 +177,8 @@ struct rack_rtt_sample {...@@ -174,6 +177,8 @@ struct rack_rtt_sample {
174#define RACK_TO_FRM_PERSIST 5177#define RACK_TO_FRM_PERSIST 5
175#define RACK_TO_FRM_DELACK 6178#define RACK_TO_FRM_DELACK 6
176179
180#define RCV_PATH_RTT_MS 10 /* How many ms between recv path RTT's */
181
177struct rack_opts_stats {182struct rack_opts_stats {
178 uint64_t tcp_rack_tlp_reduce;183 uint64_t tcp_rack_tlp_reduce;
179 uint64_t tcp_rack_pace_always;184 uint64_t tcp_rack_pace_always;
...@@ -194,7 +199,6 @@ struct rack_opts_stats {...@@ -194,7 +199,6 @@ struct rack_opts_stats {
194 uint64_t tcp_rack_min_pace_seg;199 uint64_t tcp_rack_min_pace_seg;
195 uint64_t tcp_rack_pace_rate_ca;200 uint64_t tcp_rack_pace_rate_ca;
196 uint64_t tcp_rack_rr;201 uint64_t tcp_rack_rr;
197 uint64_t tcp_rack_do_detection;
198 uint64_t tcp_rack_rrr_no_conf_rate;202 uint64_t tcp_rack_rrr_no_conf_rate;
199 uint64_t tcp_initial_rate;203 uint64_t tcp_initial_rate;
200 uint64_t tcp_initial_win;204 uint64_t tcp_initial_win;
...@@ -232,7 +236,7 @@ struct rack_opts_stats {...@@ -232,7 +236,7 @@ struct rack_opts_stats {
232 uint64_t tcp_rack_rtt_use;236 uint64_t tcp_rack_rtt_use;
233 uint64_t tcp_data_after_close;237 uint64_t tcp_data_after_close;
234 uint64_t tcp_defer_opt;238 uint64_t tcp_defer_opt;
235 uint64_t tcp_rxt_clamp;239 uint64_t tcp_pol_detect;
236 uint64_t tcp_rack_beta;240 uint64_t tcp_rack_beta;
237 uint64_t tcp_rack_beta_ecn;241 uint64_t tcp_rack_beta_ecn;
238 uint64_t tcp_rack_timer_slop;242 uint64_t tcp_rack_timer_slop;
...@@ -242,6 +246,11 @@ struct rack_opts_stats {...@@ -242,6 +246,11 @@ struct rack_opts_stats {
242 uint64_t tcp_rack_pacing_divisor;246 uint64_t tcp_rack_pacing_divisor;
243 uint64_t tcp_rack_min_seg;247 uint64_t tcp_rack_min_seg;
244 uint64_t tcp_dgp_in_rec;248 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;
245};254};
246255
247/* RTT shrink reasons */256/* RTT shrink reasons */
...@@ -263,6 +272,9 @@ struct rack_opts_stats {...@@ -263,6 +272,9 @@ struct rack_opts_stats {
263#define TLP_USE_TWO_TWO 3 /* Use 2.2 behavior */272#define TLP_USE_TWO_TWO 3 /* Use 2.2 behavior */
264#define RACK_MIN_BW 8000 /* 64kbps in Bps */273#define RACK_MIN_BW 8000 /* 64kbps in Bps */
265274
275#define CCSP_DIS_MASK 0x0001
276#define HYBRID_DIS_MASK 0x0002
277
266/* Rack quality indicators for GPUT measurements */278/* Rack quality indicators for GPUT measurements */
267#define RACK_QUALITY_NONE 0 /* No quality stated */279#define RACK_QUALITY_NONE 0 /* No quality stated */
268#define RACK_QUALITY_HIGH 1 /* A normal measurement of a GP RTT */280#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];...@@ -315,10 +327,9 @@ extern counter_u64_t rack_opts_arry[RACK_OPTS_SIZE];
315/*327/*
316 * Locking for the rack control block.328 * Locking for the rack control block.
317 * a) Locked by INP_WLOCK329 * a) Locked by INP_WLOCK
318 * b) Locked by the hpts-mutex
319 *
320 */330 */
321#define RACK_GP_HIST 4 /* How much goodput history do we maintain? */331#define RACK_GP_HIST 4 /* How much goodput history do we maintain? */
332#define RETRAN_CNT_SIZE 16
322333
323#define RACK_NUM_FSB_DEBUG 16334#define RACK_NUM_FSB_DEBUG 16
324#ifdef _KERNEL335#ifdef _KERNEL
...@@ -342,6 +353,26 @@ struct rack_fast_send_blk {...@@ -342,6 +353,26 @@ struct rack_fast_send_blk {
342353
343struct tailq_hash;354struct 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
345struct rack_control {376struct rack_control {
346 /* Second cache line 0x40 from tcp_rack */377 /* Second cache line 0x40 from tcp_rack */
347 struct tailq_hash *tqh; /* Tree of all segments Lock(a) */378 struct tailq_hash *tqh; /* Tree of all segments Lock(a) */
...@@ -423,20 +454,14 @@ struct rack_control {...@@ -423,20 +454,14 @@ struct rack_control {
423 uint16_t rack_per_of_gp_rec; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */454 uint16_t rack_per_of_gp_rec; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
424 uint16_t rack_per_of_gp_probertt; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */455 uint16_t rack_per_of_gp_probertt; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
425 uint32_t rc_high_rwnd;456 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;
430 struct rack_rtt_sample rack_rs;457 struct rack_rtt_sample rack_rs;
431 const struct tcp_hwrate_limit_table *crte;458 const struct tcp_hwrate_limit_table *crte;
432 uint32_t rc_agg_early;459 uint32_t rc_agg_early;
433 uint32_t rc_agg_delayed;460 uint32_t rc_agg_delayed;
434 uint32_t rc_tlp_rxt_last_time;461 uint32_t rc_tlp_rxt_last_time;
435 uint32_t rc_saved_cwnd;
436 uint64_t rc_gp_output_ts; /* chg*/462 uint64_t rc_gp_output_ts; /* chg*/
437 uint64_t rc_gp_cumack_ts; /* chg*/463 uint64_t rc_gp_cumack_ts; /* chg*/
438 struct timeval act_rcv_time;464 struct timeval act_rcv_time;
439 struct timeval rc_last_time_decay; /* SAD time decay happened here */
440 uint64_t gp_bw;465 uint64_t gp_bw;
441 uint64_t init_rate;466 uint64_t init_rate;
442#ifdef NETFLIX_SHARED_CWND467#ifdef NETFLIX_SHARED_CWND
...@@ -452,19 +477,29 @@ struct rack_control {...@@ -452,19 +477,29 @@ struct rack_control {
452 struct tcp_sendfile_track *rc_last_sft;477 struct tcp_sendfile_track *rc_last_sft;
453 uint32_t lt_seq; /* Seq at start of lt_bw gauge */478 uint32_t lt_seq; /* Seq at start of lt_bw gauge */
454 int32_t rc_rtt_diff; /* Timely style rtt diff of our gp_srtt */479 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;
458 uint64_t last_tmit_time_acked; /* Holds the last cumack point's last send time */480 uint64_t last_tmit_time_acked; /* Holds the last cumack point's last send time */
459 uint32_t last_rnd_rxt_clamped;481 /* Recovery stats */
460 uint32_t num_of_clamps_applied;482 uint64_t last_sendtime;
461 uint32_t clamp_options;483
462 uint32_t max_clamps;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
464 uint32_t rc_gp_srtt; /* Current GP srtt */498 uint32_t rc_gp_srtt; /* Current GP srtt */
465 uint32_t rc_prev_gp_srtt; /* Previous RTT */499 uint32_t rc_prev_gp_srtt; /* Previous RTT */
466 uint32_t rc_entry_gp_rtt; /* Entry to PRTT gp-rtt */500 uint32_t rc_entry_gp_rtt; /* Entry to PRTT gp-rtt */
467 uint32_t rc_loss_at_start; /* At measurement window where was our lost value */501 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
469 uint32_t dsack_round_end; /* In a round of seeing a DSACK */504 uint32_t dsack_round_end; /* In a round of seeing a DSACK */
470 uint32_t current_round; /* Starting at zero */505 uint32_t current_round; /* Starting at zero */
...@@ -491,22 +526,23 @@ struct rack_control {...@@ -491,22 +526,23 @@ struct rack_control {
491 uint32_t rc_snd_max_at_rto; /* For non-sack when the RTO occurred what was snd-max */526 uint32_t rc_snd_max_at_rto; /* For non-sack when the RTO occurred what was snd-max */
492 uint32_t rc_out_at_rto;527 uint32_t rc_out_at_rto;
493 int32_t rc_scw_index;528 int32_t rc_scw_index;
529 uint32_t max_reduction;
530 uint32_t side_chan_dis_mask; /* Bit mask of socket opt's disabled */
494 uint32_t rc_tlp_threshold; /* Socket option value Lock(a) */531 uint32_t rc_tlp_threshold; /* Socket option value Lock(a) */
495 uint32_t rc_last_timeout_snduna;532 uint32_t rc_last_timeout_snduna;
496 uint32_t last_tlp_acked_start;533 uint32_t last_tlp_acked_start;
497 uint32_t last_tlp_acked_end;534 uint32_t last_tlp_acked_end;
498 uint32_t challenge_ack_ts;
499 uint32_t challenge_ack_cnt;
500 uint32_t rc_min_to; /* Socket option value Lock(a) */535 uint32_t rc_min_to; /* Socket option value Lock(a) */
501 uint32_t rc_pkt_delay; /* Socket option value Lock(a) */536 uint32_t rc_pkt_delay; /* Socket option value Lock(a) */
502 uint32_t persist_lost_ends;537 uint32_t persist_lost_ends;
503 uint32_t ack_during_sd;538 uint32_t cleared_app_ack_seq;
504 uint32_t input_pkt;539 uint32_t last_rcv_tstmp_for_rtt;
505 uint32_t saved_input_pkt;540 uint32_t last_time_of_arm_rcv;
506 uint32_t saved_rxt_clamp_val; /* The encoded value we used to setup clamping */541 uint32_t rto_ssthresh;
507 struct newreno rc_saved_beta; /*542 uint32_t rc_saved_beta;
508 * For newreno cc:543 uint32_t rc_saved_beta_ecn; /*
509 * rc_saved_cc are the values we have had544 * For newreno cc: rc_saved_beta and
545 * rc_saved_beta_ecn are the values we have had
510 * set by the user, if pacing is not happening546 * set by the user, if pacing is not happening
511 * (i.e. its early and we have not turned on yet547 * (i.e. its early and we have not turned on yet
512 * or it was turned off). The minute pacing548 * or it was turned off). The minute pacing
...@@ -516,10 +552,12 @@ struct rack_control {...@@ -516,10 +552,12 @@ struct rack_control {
516 * we also set the flag (if ecn_beta is set) to make552 * we also set the flag (if ecn_beta is set) to make
517 * new_reno do less of a backoff for ecn (think abe).553 * new_reno do less of a backoff for ecn (think abe).
518 */554 */
555 uint16_t rc_cnt_of_retran[RETRAN_CNT_SIZE];
519 uint16_t rc_early_recovery_segs; /* Socket option value Lock(a) */556 uint16_t rc_early_recovery_segs; /* Socket option value Lock(a) */
520 uint16_t rc_reorder_shift; /* Socket option value Lock(a) */557 uint16_t rc_reorder_shift; /* Socket option value Lock(a) */
521 uint8_t rack_per_upper_bound_ss;558 uint8_t rack_per_upper_bound_ss;
522 uint8_t rack_per_upper_bound_ca;559 uint8_t rack_per_upper_bound_ca;
560 uint8_t cleared_app_ack;
523 uint8_t dsack_persist;561 uint8_t dsack_persist;
524 uint8_t rc_no_push_at_mrtt; /* No push when we exceed max rtt */562 uint8_t rc_no_push_at_mrtt; /* No push when we exceed max rtt */
525 uint8_t num_measurements; /* Number of measurements (up to 0xff, we freeze at 0xff) */563 uint8_t num_measurements; /* Number of measurements (up to 0xff, we freeze at 0xff) */
...@@ -528,37 +566,15 @@ struct rack_control {...@@ -528,37 +566,15 @@ struct rack_control {
528 uint8_t rc_tlp_cwnd_reduce; /* Socket option value Lock(a) */566 uint8_t rc_tlp_cwnd_reduce; /* Socket option value Lock(a) */
529 uint8_t rc_prr_sendalot;/* Socket option value Lock(a) */567 uint8_t rc_prr_sendalot;/* Socket option value Lock(a) */
530 uint8_t rc_rate_sample_method;568 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 */
533 uint8_t client_suggested_maxseg; /* Not sure what to do with this yet */569 uint8_t client_suggested_maxseg; /* Not sure what to do with this yet */
534 uint8_t pacing_discount_amm; /*570 uint8_t use_gp_not_last;
535 * This is a multipler to the base discount that571 uint8_t pacing_method; /* If pace_always, what type of pacing */
536 * can be used to increase the discount.
537 */
538 uint8_t already_had_a_excess;
539};572};
540#endif573#endif
541574
542/* DGP with no buffer level mitigations */575#define RACK_PACING_NONE 0x00
543#define DGP_LEVEL0 0576#define RACK_DGP_PACING 0x01
544577#define RACK_REG_PACING 0x02
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
562578
563/* Hybrid pacing log defines */579/* Hybrid pacing log defines */
564#define HYBRID_LOG_NO_ROOM 0 /* No room for the clients request */580#define HYBRID_LOG_NO_ROOM 0 /* No room for the clients request */
...@@ -579,7 +595,6 @@ struct rack_control {...@@ -579,7 +595,6 @@ struct rack_control {
579#define HYBRID_LOG_SENT_LOST 15 /* A closing sent/lost report */595#define HYBRID_LOG_SENT_LOST 15 /* A closing sent/lost report */
580596
581#define RACK_TIMELY_CNT_BOOST 5 /* At 5th increase boost */597#define RACK_TIMELY_CNT_BOOST 5 /* At 5th increase boost */
582#define RACK_MINRTT_FILTER_TIM 10 /* Seconds */
583598
584#define RACK_HYSTART_OFF 0599#define RACK_HYSTART_OFF 0
585#define RACK_HYSTART_ON 1 /* hystart++ on */600#define RACK_HYSTART_ON 1 /* hystart++ on */
...@@ -590,19 +605,20 @@ struct rack_control {...@@ -590,19 +605,20 @@ struct rack_control {
590 */605 */
591606
592#define MAX_USER_SET_SEG 0x3f /* The max we can set is 63 which is probably too many */607#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
594#ifdef _KERNEL610#ifdef _KERNEL
595611
596struct tcp_rack {612struct tcp_rack {
597 /* First cache line 0x00 */613 /* First cache line 0x00 */
598 TAILQ_ENTRY(tcp_rack) r_hpts; /* hptsi queue next Lock(b) */
599 int32_t(*r_substate) (struct mbuf *, struct tcphdr *,614 int32_t(*r_substate) (struct mbuf *, struct tcphdr *,
600 struct socket *, struct tcpcb *, struct tcpopt *,615 struct socket *, struct tcpcb *, struct tcpopt *,
601 int32_t, int32_t, uint32_t, int, int, uint8_t); /* Lock(a) */616 int32_t, int32_t, uint32_t, int, int, uint8_t); /* Lock(a) */
602 struct tcpcb *rc_tp; /* The tcpcb Lock(a) */617 struct tcpcb *rc_tp; /* The tcpcb Lock(a) */
603 struct inpcb *rc_inp; /* The inpcb Lock(a) */618 struct inpcb *rc_inp; /* The inpcb Lock(a) */
604 uint8_t rc_free_cnt; /* Number of free entries on the rc_free list619 uint8_t rc_free_cnt : 6,
605 * Lock(a) */620 rc_skip_timely : 1,
621 pcm_enabled : 1; /* Is PCM enabled */
606 uint8_t client_bufferlvl : 3, /* Expected range [0,5]: 0=unset, 1=low/empty */622 uint8_t client_bufferlvl : 3, /* Expected range [0,5]: 0=unset, 1=low/empty */
607 rack_deferred_inited : 1,623 rack_deferred_inited : 1,
608 /* ******************************************************************** */624 /* ******************************************************************** */
...@@ -612,11 +628,11 @@ struct tcp_rack {...@@ -612,11 +628,11 @@ struct tcp_rack {
612 shape_rxt_to_pacing_min : 1,628 shape_rxt_to_pacing_min : 1,
613 /* ******************************************************************** */629 /* ******************************************************************** */
614 rc_ack_required: 1,630 rc_ack_required: 1,
615 r_pacing_discount : 1;631 r_use_hpts_min : 1;
616 uint8_t no_prr_addback : 1,632 uint8_t no_prr_addback : 1,
617 gp_ready : 1,633 gp_ready : 1,
618 defer_options: 1,634 defer_options: 1,
619 excess_rxt_on: 1, /* Are actions on for excess retransmissions? */635 dis_lt_bw : 1,
620 rc_ack_can_sendout_data: 1, /*636 rc_ack_can_sendout_data: 1, /*
621 * If set it will override pacing restrictions on not sending637 * If set it will override pacing restrictions on not sending
622 * data when the pacing timer is running. I.e. you set this638 * data when the pacing timer is running. I.e. you set this
...@@ -659,7 +675,7 @@ struct tcp_rack {...@@ -659,7 +675,7 @@ struct tcp_rack {
659 r_rack_hw_rate_caps: 1,675 r_rack_hw_rate_caps: 1,
660 r_up_only: 1,676 r_up_only: 1,
661 r_via_fill_cw : 1,677 r_via_fill_cw : 1,
662 r_fill_less_agg : 1;678 r_rcvpath_rtt_up : 1;
663679
664 uint8_t rc_user_set_max_segs : 7, /* Socket option value Lock(a) */680 uint8_t rc_user_set_max_segs : 7, /* Socket option value Lock(a) */
665 rc_fillcw_apply_discount;681 rc_fillcw_apply_discount;
...@@ -673,7 +689,7 @@ struct tcp_rack {...@@ -673,7 +689,7 @@ struct tcp_rack {
673 rc_highly_buffered: 1, /* The path is highly buffered */689 rc_highly_buffered: 1, /* The path is highly buffered */
674 rc_dragged_bottom: 1,690 rc_dragged_bottom: 1,
675 rc_pace_dnd : 1, /* The pace do not disturb bit */691 rc_pace_dnd : 1, /* The pace do not disturb bit */
676 rc_avali2 : 1,692 rc_initial_ss_comp : 1,
677 rc_gp_filled : 1,693 rc_gp_filled : 1,
678 rc_hw_nobuf : 1;694 rc_hw_nobuf : 1;
679 uint8_t r_state : 4, /* Current rack state Lock(a) */695 uint8_t r_state : 4, /* Current rack state Lock(a) */
...@@ -696,8 +712,8 @@ struct tcp_rack {...@@ -696,8 +712,8 @@ struct tcp_rack {
696 uint8_t app_limited_needs_set : 1,712 uint8_t app_limited_needs_set : 1,
697 use_fixed_rate : 1,713 use_fixed_rate : 1,
698 rc_has_collapsed : 1,714 rc_has_collapsed : 1,
699 r_cwnd_was_clamped : 1,715 use_lesser_lt_bw : 1,
700 r_clamped_gets_lower : 1,716 cspr_is_fcc : 1,
701 rack_hdrw_pacing : 1, /* We are doing Hardware pacing */717 rack_hdrw_pacing : 1, /* We are doing Hardware pacing */
702 rack_hdw_pace_ena : 1, /* Is hardware pacing enabled? */718 rack_hdw_pace_ena : 1, /* Is hardware pacing enabled? */
703 rack_attempt_hdwr_pace : 1; /* Did we attempt hdwr pacing (if allowed) */719 rack_attempt_hdwr_pace : 1; /* Did we attempt hdwr pacing (if allowed) */
...@@ -712,8 +728,7 @@ struct tcp_rack {...@@ -712,8 +728,7 @@ struct tcp_rack {
712 set_pacing_done_a_iw : 1,728 set_pacing_done_a_iw : 1,
713 use_rack_rr : 1,729 use_rack_rr : 1,
714 alloc_limit_reported : 1,730 alloc_limit_reported : 1,
715 sack_attack_disable : 1,731 rack_avail : 2,
716 do_detection : 1,
717 rc_force_max_seg : 1;732 rc_force_max_seg : 1;
718 uint8_t r_early : 1,733 uint8_t r_early : 1,
719 r_late : 1,734 r_late : 1,
...@@ -722,7 +737,11 @@ struct tcp_rack {...@@ -722,7 +737,11 @@ struct tcp_rack {
722 r_persist_lt_bw_off : 1,737 r_persist_lt_bw_off : 1,
723 r_collapse_point_valid : 1,738 r_collapse_point_valid : 1,
724 dgp_on : 1;739 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 */
726 rc_gp_rtt_set : 1,745 rc_gp_rtt_set : 1,
727 rc_gp_dyn_mul : 1,746 rc_gp_dyn_mul : 1,
728 rc_gp_saw_rec : 1,747 rc_gp_saw_rec : 1,
...@@ -735,5 +754,9 @@ struct tcp_rack {...@@ -735,5 +754,9 @@ struct tcp_rack {
735 struct rack_control r_ctl;754 struct rack_control r_ctl;
736} __aligned(CACHE_LINE_SIZE);755} __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
738#endif761#endif
739#endif762#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcp_syncache.h+7-6
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
32 */30 */
3331
34#ifndef _NETINET_TCP_SYNCACHE_H_32#ifndef _NETINET_TCP_SYNCACHE_H_
...@@ -47,12 +45,11 @@ struct socket * syncache_add(struct in_conninfo *, struct tcpopt *,...@@ -47,12 +45,11 @@ struct socket * syncache_add(struct in_conninfo *, struct tcpopt *,
47 void *, void *, uint8_t, uint16_t);45 void *, void *, uint8_t, uint16_t);
48void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *,46void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *,
49 uint16_t);47 uint16_t);
50void syncache_badack(struct in_conninfo *, uint16_t);
51int syncache_pcblist(struct sysctl_req *);48int syncache_pcblist(struct sysctl_req *);
5249
53struct syncache {50struct syncache {
54 TAILQ_ENTRY(syncache) sc_hash;51 TAILQ_ENTRY(syncache) sc_hash;
55 struct in_conninfo sc_inc; /* addresses */52 struct in_conninfo sc_inc; /* addresses */
56 int sc_rxttime; /* retransmit time */53 int sc_rxttime; /* retransmit time */
57 u_int16_t sc_rxmits; /* retransmit counter */54 u_int16_t sc_rxmits; /* retransmit counter */
58 u_int16_t sc_port; /* remote UDP encaps port */55 u_int16_t sc_port; /* remote UDP encaps port */
...@@ -61,7 +58,7 @@ struct syncache {...@@ -61,7 +58,7 @@ struct syncache {
61 u_int32_t sc_flowlabel; /* IPv6 flowlabel */58 u_int32_t sc_flowlabel; /* IPv6 flowlabel */
62 tcp_seq sc_irs; /* seq from peer */59 tcp_seq sc_irs; /* seq from peer */
63 tcp_seq sc_iss; /* our ISS */60 tcp_seq sc_iss; /* our ISS */
64 struct mbuf *sc_ipopts; /* source route */61 struct mbuf *sc_ipopts; /* source route */
65 u_int16_t sc_peer_mss; /* peer's MSS */62 u_int16_t sc_peer_mss; /* peer's MSS */
66 u_int16_t sc_wnd; /* advertised window */63 u_int16_t sc_wnd; /* advertised window */
67 u_int8_t sc_ip_ttl; /* TTL / Hop Limit */64 u_int8_t sc_ip_ttl; /* TTL / Hop Limit */
...@@ -69,7 +66,9 @@ struct syncache {...@@ -69,7 +66,9 @@ struct syncache {
69 u_int8_t sc_requested_s_scale:4,66 u_int8_t sc_requested_s_scale:4,
70 sc_requested_r_scale:4;67 sc_requested_r_scale:4;
71 u_int16_t sc_flags;68 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)
73 struct toedev *sc_tod; /* entry added by this TOE */72 struct toedev *sc_tod; /* entry added by this TOE */
74 void *sc_todctx; /* TOE driver context */73 void *sc_todctx; /* TOE driver context */
75#endif74#endif
...@@ -129,7 +128,9 @@ struct tcp_syncache {...@@ -129,7 +128,9 @@ struct tcp_syncache {
129 u_int cache_limit;128 u_int cache_limit;
130 u_int rexmt_limit;129 u_int rexmt_limit;
131 uint32_t hash_secret;130 uint32_t hash_secret;
131#ifdef VIMAGE
132 struct vnet *vnet;132 struct vnet *vnet;
133#endif
133 struct syncookie_secret secret;134 struct syncookie_secret secret;
134 struct mtx pause_mtx;135 struct mtx pause_mtx;
135 struct callout pause_co;136 struct callout pause_co;
lib/libc/include/generic-freebsd/netinet/tcp_timer.h+18-18
...@@ -27,13 +27,13 @@...@@ -27,13 +27,13 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NETINET_TCP_TIMER_H_32#ifndef _NETINET_TCP_TIMER_H_
35#define _NETINET_TCP_TIMER_H_33#define _NETINET_TCP_TIMER_H_
3634
35#ifdef _KERNEL
36
37/*37/*
38 * The TCPT_REXMT timer is used to force retransmissions.38 * The TCPT_REXMT timer is used to force retransmissions.
39 * The TCP has the TCPT_REXMT timer set whenever segments39 * The TCP has the TCPT_REXMT timer set whenever segments
...@@ -73,21 +73,22 @@...@@ -73,21 +73,22 @@
73/*73/*
74 * Time constants.74 * Time constants.
75 */75 */
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 */
77#define TCPTV_SRTTBASE 0 /* base roundtrip time;78#define TCPTV_SRTTBASE 0 /* base roundtrip time;
78 if 0, no idea yet */79 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_PERSMIN MSEC_2_TICKS(5000) /* minimum persist interval */
82#define TCPTV_PERSMAX ( 60*hz) /* maximum 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_INIT MSEC_2_TICKS(75000) /* initial connect keepalive */
85#define TCPTV_KEEP_IDLE (120*60*hz) /* dflt time before probing */86#define TCPTV_KEEP_IDLE MSEC_2_TICKS(120*60*1000) /* dflt time before probing */
86#define TCPTV_KEEPINTVL ( 75*hz) /* default probe interval */87#define TCPTV_KEEPINTVL MSEC_2_TICKS(75000) /* default probe interval */
87#define TCPTV_KEEPCNT 8 /* max probes before drop */88#define TCPTV_KEEPCNT 8 /* max probes before drop */
88#define TCPTV_MAXUNACKTIME 0 /* max time without making progress */89#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
92/*93/*
93 * Minimum retransmit timer is 3 ticks, for algorithmic stability.94 * Minimum retransmit timer is 3 ticks, for algorithmic stability.
...@@ -109,15 +110,13 @@...@@ -109,15 +110,13 @@
109 * The prior minimum of 1*hz (1 second) badly breaks throughput on any110 * The prior minimum of 1*hz (1 second) badly breaks throughput on any
110 * networks faster then a modem that has minor (e.g. 1%) packet loss.111 * networks faster then a modem that has minor (e.g. 1%) packet loss.
111 */112 */
112#define TCPTV_MIN ( hz/33 ) /* minimum allowable value */113#define TCPTV_MIN MSEC_2_TICKS(30) /* minimum allowable value */
113#define TCPTV_CPU_VAR ( hz/5 ) /* cpu variance allowed (200ms) */114#define TCPTV_CPU_VAR MSEC_2_TICKS(200) /* cpu variance allowed (200ms) */
114#define TCPTV_REXMTMAX ( 64*hz) /* max allowable REXMT value */115#define TCPTV_REXMTMAX MSEC_2_TICKS(64000) /* max allowable REXMT value */
115
116#define TCPTV_TWTRUNC 8 /* RTO factor to truncate TW */
117116
118#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */117#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
122/*121/*
123 * If we exceed this number of retransmits for a single segment, we'll consider122 * If we exceed this number of retransmits for a single segment, we'll consider
...@@ -137,8 +136,6 @@...@@ -137,8 +136,6 @@
137 (tv) = (tvmax); \136 (tv) = (tvmax); \
138} while(0)137} while(0)
139138
140#ifdef _KERNEL
141
142#define TP_KEEPINIT(tp) ((tp)->t_keepinit ? (tp)->t_keepinit : tcp_keepinit)139#define TP_KEEPINIT(tp) ((tp)->t_keepinit ? (tp)->t_keepinit : tcp_keepinit)
143#define TP_KEEPIDLE(tp) ((tp)->t_keepidle ? (tp)->t_keepidle : tcp_keepidle)140#define TP_KEEPIDLE(tp) ((tp)->t_keepidle ? (tp)->t_keepidle : tcp_keepidle)
144#define TP_KEEPINTVL(tp) ((tp)->t_keepintvl ? (tp)->t_keepintvl : tcp_keepintvl)141#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 */...@@ -167,6 +164,7 @@ extern int tcp_maxunacktime; /* max time without making progress */
167extern int tcp_maxpersistidle;164extern int tcp_maxpersistidle;
168extern int tcp_rexmit_initial;165extern int tcp_rexmit_initial;
169extern int tcp_rexmit_min;166extern int tcp_rexmit_min;
167extern int tcp_rexmit_max;
170extern int tcp_rexmit_slop;168extern int tcp_rexmit_slop;
171extern int tcp_ttl; /* time to live for TCP segs */169extern int tcp_ttl; /* time to live for TCP segs */
172extern int tcp_backoff[];170extern int tcp_backoff[];
...@@ -186,6 +184,8 @@ VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss);...@@ -186,6 +184,8 @@ VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss);
186#define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss)184#define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss)
187VNET_DECLARE(int, tcp_msl);185VNET_DECLARE(int, tcp_msl);
188#define V_tcp_msl VNET(tcp_msl)186#define V_tcp_msl VNET(tcp_msl)
187VNET_DECLARE(int, tcp_msl_local);
188#define V_tcp_msl_local VNET(tcp_msl_local)
189189
190#endif /* _KERNEL */190#endif /* _KERNEL */
191191
lib/libc/include/generic-freebsd/netinet/tcp_var.h+89-112
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
32 */30 */
3331
34#ifndef _NETINET_TCP_VAR_H_32#ifndef _NETINET_TCP_VAR_H_
...@@ -130,6 +128,8 @@ struct sackhint {...@@ -130,6 +128,8 @@ struct sackhint {
130 uint32_t recover_fs; /* Flight Size at the start of Loss recovery */128 uint32_t recover_fs; /* Flight Size at the start of Loss recovery */
131 uint32_t prr_delivered; /* Total bytes delivered using PRR */129 uint32_t prr_delivered; /* Total bytes delivered using PRR */
132 uint32_t prr_out; /* Bytes sent during IN_RECOVERY */130 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 */
133};133};
134134
135#define SEGQ_EMPTY(tp) TAILQ_EMPTY(&(tp)->t_segq)135#define SEGQ_EMPTY(tp) TAILQ_EMPTY(&(tp)->t_segq)
...@@ -141,7 +141,8 @@ STAILQ_HEAD(tcp_log_stailq, tcp_log_mem);...@@ -141,7 +141,8 @@ STAILQ_HEAD(tcp_log_stailq, tcp_log_mem);
141#define TCP_TRK_TRACK_FLG_OPEN 0x02 /* End is not valid (open range request) */141#define TCP_TRK_TRACK_FLG_OPEN 0x02 /* End is not valid (open range request) */
142#define TCP_TRK_TRACK_FLG_SEQV 0x04 /* We had a sendfile that touched it */142#define TCP_TRK_TRACK_FLG_SEQV 0x04 /* We had a sendfile that touched it */
143#define TCP_TRK_TRACK_FLG_COMP 0x08 /* Sendfile as placed the last bits (range req only) */143#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 */
145#define MAX_TCP_TRK_REQ 5 /* Max we will have at once */146#define MAX_TCP_TRK_REQ 5 /* Max we will have at once */
146147
147struct tcp_sendfile_track {148struct tcp_sendfile_track {
...@@ -154,11 +155,14 @@ struct tcp_sendfile_track {...@@ -154,11 +155,14 @@ struct tcp_sendfile_track {
154 uint64_t cspr; /* Client suggested pace rate */155 uint64_t cspr; /* Client suggested pace rate */
155 uint64_t sent_at_fs; /* What was t_sndbytes as we begun sending */156 uint64_t sent_at_fs; /* What was t_sndbytes as we begun sending */
156 uint64_t rxt_at_fs; /* What was t_snd_rxt_bytes as we begun sending */157 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 */
157 tcp_seq start_seq; /* First TCP Seq assigned */160 tcp_seq start_seq; /* First TCP Seq assigned */
158 tcp_seq end_seq; /* If range req last seq */161 tcp_seq end_seq; /* If range req last seq */
159 uint32_t flags; /* Type of request open etc */162 uint32_t flags; /* Type of request open etc */
160 uint32_t sbcc_at_s; /* When we allocate what is the sb_cc */163 uint32_t sbcc_at_s; /* When we allocate what is the sb_cc */
161 uint32_t hint_maxseg; /* Client hinted maxseg */164 uint32_t hint_maxseg; /* Client hinted maxseg */
165 uint32_t playout_ms; /* Client playout ms */
162 uint32_t hybrid_flags; /* Hybrid flags on this request */166 uint32_t hybrid_flags; /* Hybrid flags on this request */
163};167};
164168
...@@ -178,7 +182,7 @@ struct tcp_sendfile_track {...@@ -178,7 +182,7 @@ struct tcp_sendfile_track {
178 * snd_una). When the response comes back indicating182 * snd_una). When the response comes back indicating
179 * that there was data (return value 1), then the caller183 * that there was data (return value 1), then the caller
180 * can build a sendmap entry based on the range and the184 * 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
182 * newly created sendmap_end. Repeated until sendmap_end == snd_max.186 * newly created sendmap_end. Repeated until sendmap_end == snd_max.
183 *187 *
184 * Flags in sendmap_flags are defined below as well.188 * Flags in sendmap_flags are defined below as well.
...@@ -193,7 +197,7 @@ struct tcp_sendfile_track {...@@ -193,7 +197,7 @@ struct tcp_sendfile_track {
193 * The rack_times are a misc collection of information that197 * The rack_times are a misc collection of information that
194 * the old stack might possibly fill in. Of course its possible198 * the old stack might possibly fill in. Of course its possible
195 * that an old stack may not have a piece of information. If so199 * 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
197 * timestamp passed should only place a zero in it when it201 * timestamp passed should only place a zero in it when it
198 * is unfilled. This may mean that a time is off by a micro-second202 * is unfilled. This may mean that a time is off by a micro-second
199 * but this is ok in the grand scheme of things.203 * but this is ok in the grand scheme of things.
...@@ -201,13 +205,13 @@ struct tcp_sendfile_track {...@@ -201,13 +205,13 @@ struct tcp_sendfile_track {
201 * When switching stacks it is desireable to get as much information205 * When switching stacks it is desireable to get as much information
202 * from the old stack to the new stack as possible. Though not always206 * from the old stack to the new stack as possible. Though not always
203 * will the stack be compatible in the types of information. The207 * 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
205 * things such as inp_flags2 and the timer units to position these209 * things such as inp_flags2 and the timer units to position these
206 * changes at a point where it is unlikely they will fail after210 * changes at a point where it is unlikely they will fail after
207 * making such changes. A stack optionally can have an "undo"211 * making such changes. A stack optionally can have an "undo"
208 * function 212 * function
209 *213 *
210 * To transfer information to the old stack from the new in 214 * To transfer information to the old stack from the new in
211 * respect to LRO and the inp_flags2, the new stack should set215 * respect to LRO and the inp_flags2, the new stack should set
212 * the inp_flags2 to what it supports. The old stack in its216 * the inp_flags2 to what it supports. The old stack in its
213 * fini() function should call the tcp_handle_orphaned_packets()217 * fini() function should call the tcp_handle_orphaned_packets()
...@@ -448,7 +452,6 @@ struct tcpcb {...@@ -448,7 +452,6 @@ struct tcpcb {
448 tcp_seq gput_seq; /* Outbound measurement seq */452 tcp_seq gput_seq; /* Outbound measurement seq */
449 tcp_seq gput_ack; /* Inbound measurement ack */453 tcp_seq gput_ack; /* Inbound measurement ack */
450 int32_t t_stats_gput_prev; /* XXXLAS: Prev gput measurement */454 int32_t t_stats_gput_prev; /* XXXLAS: Prev gput measurement */
451 uint32_t t_maxpeakrate; /* max peak rate set by user, bytes/s */
452 uint32_t t_sndtlppack; /* tail loss probe packets sent */455 uint32_t t_sndtlppack; /* tail loss probe packets sent */
453 uint64_t t_sndtlpbyte; /* total tail loss probe bytes sent */456 uint64_t t_sndtlpbyte; /* total tail loss probe bytes sent */
454 uint64_t t_sndbytes; /* total bytes sent */457 uint64_t t_sndbytes; /* total bytes sent */
...@@ -496,10 +499,6 @@ struct tcpcb {...@@ -496,10 +499,6 @@ struct tcpcb {
496 uint64_t tcp_cnt_counters[TCP_NUM_CNT_COUNTERS];499 uint64_t tcp_cnt_counters[TCP_NUM_CNT_COUNTERS];
497 uint64_t tcp_proc_time[TCP_NUM_CNT_COUNTERS];500 uint64_t tcp_proc_time[TCP_NUM_CNT_COUNTERS];
498#endif501#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
503};502};
504#endif /* _KERNEL || _WANT_TCPCB */503#endif /* _KERNEL || _WANT_TCPCB */
505504
...@@ -529,31 +528,12 @@ typedef enum {...@@ -529,31 +528,12 @@ typedef enum {
529/* Minimum map entries limit value, if set */528/* Minimum map entries limit value, if set */
530#define TCP_MIN_MAP_ENTRIES_LIMIT 128529#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 */
541/* Flags for tcp functions */531/* Flags for tcp functions */
542#define TCP_FUNC_BEING_REMOVED 0x01 /* Can no longer be referenced */532#define TCP_FUNC_BEING_REMOVED 0x01 /* Can no longer be referenced */
543#define TCP_FUNC_OUTPUT_CANDROP 0x02 /* tfb_tcp_output may ask tcp_drop */533#define TCP_FUNC_OUTPUT_CANDROP 0x02 /* tfb_tcp_output may ask tcp_drop */
544#define TCP_FUNC_DEFAULT_OK 0x04 /* Can be used as default */534#define TCP_FUNC_DEFAULT_OK 0x04 /* Can be used as default */
545535
546/**536/**
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 *
557 * tfb_tcp_handoff_ok is a mandatory function allowing537 * tfb_tcp_handoff_ok is a mandatory function allowing
558 * to query a stack, if it can take over a tcpcb.538 * to query a stack, if it can take over a tcpcb.
559 * You return 0 to say you can take over and run your stack,539 * You return 0 to say you can take over and run your stack,
...@@ -564,13 +544,13 @@ typedef enum {...@@ -564,13 +544,13 @@ typedef enum {
564 * do is:544 * do is:
565 * a) Make sure that the inp_flags2 is setup correctly545 * a) Make sure that the inp_flags2 is setup correctly
566 * for LRO. There are two flags that the previous546 * 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
568 * INP_SUPPORTS_MBUFQ. If the new stack does not548 * INP_SUPPORTS_MBUFQ. If the new stack does not
569 * support these it *should* clear the flags.549 * support these it *should* clear the flags.
570 * b) Make sure that the timers are in the proper550 * b) Make sure that the timers are in the proper
571 * granularity that the stack wants. The stack551 * granularity that the stack wants. The stack
572 * should check the t_tmr_granularity field. Currently552 * 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
574 * TCP_TMR_GRANULARITY_TICKS and TCP_TMR_GRANULARITY_USEC.554 * TCP_TMR_GRANULARITY_TICKS and TCP_TMR_GRANULARITY_USEC.
575 * Use the functions tcp_timer_convert(tp, granularity);555 * Use the functions tcp_timer_convert(tp, granularity);
576 * to move the timers to the correct format for your stack.556 * to move the timers to the correct format for your stack.
...@@ -578,14 +558,14 @@ typedef enum {...@@ -578,14 +558,14 @@ typedef enum {
578 * The new stack may also optionally query the tfb_chg_query558 * The new stack may also optionally query the tfb_chg_query
579 * function if the old stack has one. The new stack may ask559 * function if the old stack has one. The new stack may ask
580 * for one of three entries and can also state to the old560 * 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
582 * INP_SUPPORTS_MBUFQ. This is important since if there are562 * INP_SUPPORTS_MBUFQ. This is important since if there are
583 * queued ack's without that statement the old stack will563 * queued ack's without that statement the old stack will
584 * be forced to discard the queued acks. The requests that564 * be forced to discard the queued acks. The requests that
585 * can be made for information by the new stacks are:565 * can be made for information by the new stacks are:
586 *566 *
587 * Note also that the tfb_tcp_fb_init() when called can567 * 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
589 * value passed in the ptr. The ptr is designed to be569 * value passed in the ptr. The ptr is designed to be
590 * set in with any allocated memory, but the address570 * set in with any allocated memory, but the address
591 * of the condtion (ptr == &tp->t_fb_ptr) will be571 * of the condtion (ptr == &tp->t_fb_ptr) will be
...@@ -593,17 +573,17 @@ typedef enum {...@@ -593,17 +573,17 @@ typedef enum {
593 * setup of a tcb (which means no query would be needed).573 * setup of a tcb (which means no query would be needed).
594 * If, however, the value is not t_fb_ptr, then the caller574 * If, however, the value is not t_fb_ptr, then the caller
595 * is in the middle of a stack switch and is the new stack.575 * 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
597 * the query mechanism).577 * the query mechanism).
598 *578 *
599 * TCP_QUERY_SENDMAP - Query of outstanding data.579 * TCP_QUERY_SENDMAP - Query of outstanding data.
600 * TCP_QUERY_TIMERS_UP - Query about running timers.580 * TCP_QUERY_TIMERS_UP - Query about running timers.
601 * TCP_SUPPORTED_LRO - Declaration in req_param of 581 * TCP_SUPPORTED_LRO - Declaration in req_param of
602 * the inp_flags2 supported by 582 * the inp_flags2 supported by
603 * the new stack.583 * the new stack.
604 * TCP_QUERY_RACK_TIMES - Enquire about various timestamps584 * TCP_QUERY_RACK_TIMES - Enquire about various timestamps
605 * and states the old stack may be in.585 * and states the old stack may be in.
606 * 586 *
607 * tfb_tcp_fb_fini is changed to add a flag to tell587 * tfb_tcp_fb_fini is changed to add a flag to tell
608 * the old stack if the tcb is being destroyed or588 * the old stack if the tcb is being destroyed or
609 * not. A one in the flag means the TCB is being589 * not. A one in the flag means the TCB is being
...@@ -639,6 +619,8 @@ struct tcp_function_block {...@@ -639,6 +619,8 @@ struct tcp_function_block {
639 void (*tfb_switch_failed)(struct tcpcb *);619 void (*tfb_switch_failed)(struct tcpcb *);
640 bool (*tfb_early_wake_check)(struct tcpcb *);620 bool (*tfb_early_wake_check)(struct tcpcb *);
641 int (*tfb_compute_pipe)(struct tcpcb *tp);621 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);
642 volatile uint32_t tfb_refcnt;624 volatile uint32_t tfb_refcnt;
643 uint32_t tfb_flags;625 uint32_t tfb_flags;
644 uint8_t tfb_id;626 uint8_t tfb_id;
...@@ -807,7 +789,7 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)...@@ -807,7 +789,7 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
807#define TF_TSO 0x01000000 /* TSO enabled on this connection */789#define TF_TSO 0x01000000 /* TSO enabled on this connection */
808#define TF_TOE 0x02000000 /* this connection is offloaded */790#define TF_TOE 0x02000000 /* this connection is offloaded */
809#define TF_CLOSED 0x04000000 /* close(2) called on socket */791#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 */
811#define TF_LRD 0x10000000 /* Lost Retransmission Detection */793#define TF_LRD 0x10000000 /* Lost Retransmission Detection */
812#define TF_CONGRECOVERY 0x20000000 /* congestion recovery mode */794#define TF_CONGRECOVERY 0x20000000 /* congestion recovery mode */
813#define TF_WASCRECOVERY 0x40000000 /* was in congestion recovery */795#define TF_WASCRECOVERY 0x40000000 /* was in congestion recovery */
...@@ -825,14 +807,6 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)...@@ -825,14 +807,6 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
825#define ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY)807#define ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY)
826#define EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY | TF_FASTRECOVERY)808#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
836#define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una)810#define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una)
837811
838/*812/*
...@@ -864,6 +838,8 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)...@@ -864,6 +838,8 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
864#define TF2_MBUF_QUEUE_READY 0x00020000 /* Inputs can be queued */838#define TF2_MBUF_QUEUE_READY 0x00020000 /* Inputs can be queued */
865#define TF2_DONT_SACK_QUEUE 0x00040000 /* Don't wake on sack */839#define TF2_DONT_SACK_QUEUE 0x00040000 /* Don't wake on sack */
866#define TF2_CANNOT_DO_ECN 0x00080000 /* The stack does not do ECN */840#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 */
867#define TF2_NO_ISS_CHECK 0x00400000 /* Don't check SEG.ACK against ISS */843#define TF2_NO_ISS_CHECK 0x00400000 /* Don't check SEG.ACK against ISS */
868844
869/*845/*
...@@ -902,24 +878,13 @@ struct tcpopt {...@@ -902,24 +878,13 @@ struct tcpopt {
902#define TO_SYN 0x01 /* parse SYN-only options */878#define TO_SYN 0x01 /* parse SYN-only options */
903879
904struct hc_metrics_lite { /* must stay in sync with hc_metrics */880struct hc_metrics_lite { /* must stay in sync with hc_metrics */
905 uint32_t rmx_mtu; /* MTU for this path */881 uint32_t hc_mtu; /* MTU for this path */
906 uint32_t rmx_ssthresh; /* outbound gateway buffer limit */882 uint32_t hc_ssthresh; /* outbound gateway buffer limit */
907 uint32_t rmx_rtt; /* estimated round trip time */883 uint32_t hc_rtt; /* estimated round trip time */
908 uint32_t rmx_rttvar; /* estimated rtt variance */884 uint32_t hc_rttvar; /* estimated rtt variance */
909 uint32_t rmx_cwnd; /* congestion window */885 uint32_t hc_cwnd; /* congestion window */
910 uint32_t rmx_sendpipe; /* outbound delay-bandwidth product */886 uint32_t hc_sendpipe; /* outbound delay-bandwidth product */
911 uint32_t rmx_recvpipe; /* inbound delay-bandwidth product */887 uint32_t hc_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;
923};888};
924889
925#ifndef _NETINET_IN_PCB_H_890#ifndef _NETINET_IN_PCB_H_
...@@ -962,9 +927,12 @@ struct in_conninfo;...@@ -962,9 +927,12 @@ struct in_conninfo;
962 + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)927 + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
963928
964/*929/*
965 * TCP statistics.930 * Global (per-VNET) TCP statistics. The below structure represents what we
966 * Many of these should be kept per connection,931 * export to the userland, but in the kernel we have an array of counter_u64_t
967 * but that's inconvenient at the moment.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.
968 */936 */
969struct tcpstat {937struct tcpstat {
970 uint64_t tcps_connattempt; /* connections initiated */938 uint64_t tcps_connattempt; /* connections initiated */
...@@ -1050,6 +1018,8 @@ struct tcpstat {...@@ -1050,6 +1018,8 @@ struct tcpstat {
1050 uint64_t tcps_sc_zonefail; /* zalloc() failed */1018 uint64_t tcps_sc_zonefail; /* zalloc() failed */
1051 uint64_t tcps_sc_sendcookie; /* SYN cookie sent */1019 uint64_t tcps_sc_sendcookie; /* SYN cookie sent */
1052 uint64_t tcps_sc_recvcookie; /* SYN cookie received */1020 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
1054 uint64_t tcps_hc_added; /* entry added to hostcache */1024 uint64_t tcps_hc_added; /* entry added to hostcache */
1055 uint64_t tcps_hc_bucketoverflow;/* hostcache per bucket limit hit */1025 uint64_t tcps_hc_bucketoverflow;/* hostcache per bucket limit hit */
...@@ -1059,6 +1029,7 @@ struct tcpstat {...@@ -1059,6 +1029,7 @@ struct tcpstat {
1059 /* SACK related stats */1029 /* SACK related stats */
1060 uint64_t tcps_sack_recovery_episode; /* SACK recovery episodes */1030 uint64_t tcps_sack_recovery_episode; /* SACK recovery episodes */
1061 uint64_t tcps_sack_rexmits; /* SACK rexmit segments */1031 uint64_t tcps_sack_rexmits; /* SACK rexmit segments */
1032 uint64_t tcps_sack_rexmits_tso; /* SACK rexmit TSO chunks */
1062 uint64_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */1033 uint64_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */
1063 uint64_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */1034 uint64_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */
1064 uint64_t tcps_sack_send_blocks; /* SACK blocks (options) sent */1035 uint64_t tcps_sack_send_blocks; /* SACK blocks (options) sent */
...@@ -1120,31 +1091,39 @@ struct tcpstat {...@@ -1120,31 +1091,39 @@ struct tcpstat {
1120 uint64_t tcps_rcvghostack; /* received ACK for data never sent */1091 uint64_t tcps_rcvghostack; /* received ACK for data never sent */
1121 uint64_t tcps_rcvacktooold; /* received ACK for data too long ago */1092 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 */
1124};1096};
11251097
1126#define tcps_rcvmemdrop tcps_rcvreassfull /* compat */1098#define tcps_rcvmemdrop tcps_rcvreassfull /* compat */
11271099
1128#ifdef _KERNEL1100#ifdef _KERNEL
1129#define TI_UNLOCKED 1
1130#define TI_RLOCKED 2
1131#include <sys/counter.h>1101#include <sys/counter.h>
1102#include <netinet/in_kdtrace.h>
11321103
1133VNET_PCPUSTAT_DECLARE(struct tcpstat, tcpstat); /* tcp statistics */1104VNET_PCPUSTAT_DECLARE(struct tcpstat, tcpstat); /* tcp statistics */
1134/*1105/*
1135 * In-kernel consumers can use these accessor macros directly to update1106 * In-kernel consumers can use these accessor macros directly to update
1136 * stats.1107 * stats.
1137 */1108 */
1138#define TCPSTAT_ADD(name, val) \1109#define TCPSTAT_ADD(name, val) \
1139 VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val))1110 do { \
1111 MIB_SDT_PROBE1(tcp, count, name, (val)); \
1112 VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val)); \
1113 } while (0)
1140#define TCPSTAT_INC(name) TCPSTAT_ADD(name, 1)1114#define TCPSTAT_INC(name) TCPSTAT_ADD(name, 1)
11411115
1142/*1116/*
1143 * Kernel module consumers must use this accessor macro.1117 * Kernel module consumers must use this accessor macro.
1144 */1118 */
1145void kmod_tcpstat_add(int statnum, int val);1119void kmod_tcpstat_add(int statnum, int val);
1146#define KMOD_TCPSTAT_ADD(name, val) \1120#define KMOD_TCPSTAT_ADD(name, val) \
1147 kmod_tcpstat_add(offsetof(struct tcpstat, name) / sizeof(uint64_t), 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)
1148#define KMOD_TCPSTAT_INC(name) KMOD_TCPSTAT_ADD(name, 1)1127#define KMOD_TCPSTAT_INC(name) KMOD_TCPSTAT_ADD(name, 1)
11491128
1150/*1129/*
...@@ -1260,6 +1239,9 @@ struct tcp_function_info {...@@ -1260,6 +1239,9 @@ struct tcp_function_info {
1260#define TCPCTL_SACK 14 /* Selective Acknowledgement,rfc 2018 */1239#define TCPCTL_SACK 14 /* Selective Acknowledgement,rfc 2018 */
1261#define TCPCTL_DROP 15 /* drop tcp connection */1240#define TCPCTL_DROP 15 /* drop tcp connection */
1262#define TCPCTL_STATES 16 /* connection counts by TCP state */1241#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
1264#ifdef _KERNEL1246#ifdef _KERNEL
1265#ifdef SYSCTL_DECL1247#ifdef SYSCTL_DECL
...@@ -1283,6 +1265,7 @@ VNET_DECLARE(uint32_t, tcp_ack_war_time_window);...@@ -1283,6 +1265,7 @@ VNET_DECLARE(uint32_t, tcp_ack_war_time_window);
1283VNET_DECLARE(int, tcp_autorcvbuf_max);1265VNET_DECLARE(int, tcp_autorcvbuf_max);
1284VNET_DECLARE(int, tcp_autosndbuf_inc);1266VNET_DECLARE(int, tcp_autosndbuf_inc);
1285VNET_DECLARE(int, tcp_autosndbuf_max);1267VNET_DECLARE(int, tcp_autosndbuf_max);
1268VNET_DECLARE(int, tcp_bind_all_fibs);
1286VNET_DECLARE(int, tcp_delack_enabled);1269VNET_DECLARE(int, tcp_delack_enabled);
1287VNET_DECLARE(int, tcp_do_autorcvbuf);1270VNET_DECLARE(int, tcp_do_autorcvbuf);
1288VNET_DECLARE(int, tcp_do_autosndbuf);1271VNET_DECLARE(int, tcp_do_autosndbuf);
...@@ -1317,6 +1300,7 @@ VNET_DECLARE(int, tcp_retries);...@@ -1317,6 +1300,7 @@ VNET_DECLARE(int, tcp_retries);
1317VNET_DECLARE(int, tcp_sack_globalholes);1300VNET_DECLARE(int, tcp_sack_globalholes);
1318VNET_DECLARE(int, tcp_sack_globalmaxholes);1301VNET_DECLARE(int, tcp_sack_globalmaxholes);
1319VNET_DECLARE(int, tcp_sack_maxholes);1302VNET_DECLARE(int, tcp_sack_maxholes);
1303VNET_DECLARE(int, tcp_sack_tso);
1320VNET_DECLARE(int, tcp_sc_rst_sock_fail);1304VNET_DECLARE(int, tcp_sc_rst_sock_fail);
1321VNET_DECLARE(int, tcp_sendspace);1305VNET_DECLARE(int, tcp_sendspace);
1322VNET_DECLARE(int, tcp_udp_tunneling_overhead);1306VNET_DECLARE(int, tcp_udp_tunneling_overhead);
...@@ -1335,6 +1319,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo);...@@ -1335,6 +1319,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo);
1335#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max)1319#define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max)
1336#define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc)1320#define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc)
1337#define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max)1321#define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max)
1322#define V_tcp_bind_all_fibs VNET(tcp_bind_all_fibs)
1338#define V_tcp_delack_enabled VNET(tcp_delack_enabled)1323#define V_tcp_delack_enabled VNET(tcp_delack_enabled)
1339#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf)1324#define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf)
1340#define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf)1325#define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf)
...@@ -1366,6 +1351,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo);...@@ -1366,6 +1351,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo);
1366#define V_tcp_sack_globalholes VNET(tcp_sack_globalholes)1351#define V_tcp_sack_globalholes VNET(tcp_sack_globalholes)
1367#define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes)1352#define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes)
1368#define V_tcp_sack_maxholes VNET(tcp_sack_maxholes)1353#define V_tcp_sack_maxholes VNET(tcp_sack_maxholes)
1354#define V_tcp_sack_tso VNET(tcp_sack_tso)
1369#define V_tcp_sc_rst_sock_fail VNET(tcp_sc_rst_sock_fail)1355#define V_tcp_sc_rst_sock_fail VNET(tcp_sc_rst_sock_fail)
1370#define V_tcp_sendspace VNET(tcp_sendspace)1356#define V_tcp_sendspace VNET(tcp_sendspace)
1371#define V_tcp_udp_tunneling_overhead VNET(tcp_udp_tunneling_overhead)1357#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 *,...@@ -1393,8 +1379,7 @@ int tcp_reass(struct tcpcb *, struct tcphdr *, tcp_seq *, int *,
1393void tcp_reass_global_init(void);1379void tcp_reass_global_init(void);
1394void tcp_reass_flush(struct tcpcb *);1380void tcp_reass_flush(struct tcpcb *);
1395void tcp_dooptions(struct tcpopt *, u_char *, int, int);1381void tcp_dooptions(struct tcpopt *, u_char *, int, int);
1396void tcp_dropwithreset(struct mbuf *, struct tcphdr *,1382void tcp_dropwithreset(struct mbuf *, struct tcphdr *, struct tcpcb *, int);
1397 struct tcpcb *, int, int);
1398void tcp_pulloutofband(struct socket *,1383void tcp_pulloutofband(struct socket *,
1399 struct tcphdr *, struct mbuf *, int);1384 struct tcphdr *, struct mbuf *, int);
1400void tcp_xmit_timer(struct tcpcb *, int);1385void tcp_xmit_timer(struct tcpcb *, int);
...@@ -1447,24 +1432,23 @@ extern counter_u64_t tcp_comp_total;...@@ -1447,24 +1432,23 @@ extern counter_u64_t tcp_comp_total;
1447extern counter_u64_t tcp_uncomp_total;1432extern counter_u64_t tcp_uncomp_total;
1448extern counter_u64_t tcp_bad_csums;1433extern 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
1463extern uint32_t tcp_ack_war_time_window;1435extern uint32_t tcp_ack_war_time_window;
1464extern uint32_t tcp_ack_war_cnt;1436extern 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};
1466uint32_t tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *);1449uint32_t tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *);
1467uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *);1450uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *);
1451
1468void tcp6_use_min_mtu(struct tcpcb *);1452void tcp6_use_min_mtu(struct tcpcb *);
1469u_int tcp_maxseg(const struct tcpcb *);1453u_int tcp_maxseg(const struct tcpcb *);
1470u_int tcp_fixed_maxseg(const struct tcpcb *);1454u_int tcp_fixed_maxseg(const struct tcpcb *);
...@@ -1478,6 +1462,7 @@ int tcp_default_output(struct tcpcb *);...@@ -1478,6 +1462,7 @@ int tcp_default_output(struct tcpcb *);
1478void tcp_state_change(struct tcpcb *, int);1462void tcp_state_change(struct tcpcb *, int);
1479void tcp_respond(struct tcpcb *, void *,1463void tcp_respond(struct tcpcb *, void *,
1480 struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, uint16_t);1464 struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, uint16_t);
1465bool tcp_challenge_ack_check(sbintime_t *, uint32_t *);
1481void tcp_send_challenge_ack(struct tcpcb *, struct tcphdr *, struct mbuf *);1466void tcp_send_challenge_ack(struct tcpcb *, struct tcphdr *, struct mbuf *);
1482bool tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *,1467bool tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *,
1483 struct mbuf *, int);1468 struct mbuf *, int);
...@@ -1497,10 +1482,10 @@ void tcp_hc_init(void);...@@ -1497,10 +1482,10 @@ void tcp_hc_init(void);
1497#ifdef VIMAGE1482#ifdef VIMAGE
1498void tcp_hc_destroy(void);1483void tcp_hc_destroy(void);
1499#endif1484#endif
1500void tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *);1485void tcp_hc_get(const struct in_conninfo *, struct hc_metrics_lite *);
1501uint32_t tcp_hc_getmtu(struct in_conninfo *);1486uint32_t tcp_hc_getmtu(const struct in_conninfo *);
1502void tcp_hc_updatemtu(struct in_conninfo *, uint32_t);1487void tcp_hc_updatemtu(const struct in_conninfo *, uint32_t);
1503void tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *);1488void tcp_hc_update(const struct in_conninfo *, struct hc_metrics_lite *);
1504void cc_after_idle(struct tcpcb *tp);1489void cc_after_idle(struct tcpcb *tp);
15051490
1506extern struct protosw tcp_protosw; /* shared for TOE */1491extern struct protosw tcp_protosw; /* shared for TOE */
...@@ -1513,14 +1498,17 @@ sackstatus_t...@@ -1513,14 +1498,17 @@ sackstatus_t
1513 tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq);1498 tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq);
1514int tcp_dsack_block_exists(struct tcpcb *);1499int tcp_dsack_block_exists(struct tcpcb *);
1515void tcp_update_dsack_list(struct tcpcb *, tcp_seq, tcp_seq);1500void 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);
1517void tcp_clean_dsack_blocks(struct tcpcb *tp);1503void tcp_clean_dsack_blocks(struct tcpcb *tp);
1518void tcp_clean_sackreport(struct tcpcb *tp);1504void tcp_clean_sackreport(struct tcpcb *tp);
1519int tcp_sack_adjust(struct tcpcb *tp);1505int tcp_sack_adjust(struct tcpcb *tp);
1520struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt);1506struct 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 *);
1522void tcp_lost_retransmission(struct tcpcb *, struct tcphdr *);1509void 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);
1524void tcp_free_sackholes(struct tcpcb *tp);1512void tcp_free_sackholes(struct tcpcb *tp);
1525void tcp_sack_lost_retransmission(struct tcpcb *, struct tcphdr *);1513void tcp_sack_lost_retransmission(struct tcpcb *, struct tcphdr *);
1526int tcp_newreno(struct tcpcb *, struct tcphdr *);1514int tcp_newreno(struct tcpcb *, struct tcphdr *);
...@@ -1530,6 +1518,8 @@ void tcp_sndbuf_autoscale(struct tcpcb *, struct socket *, uint32_t);...@@ -1530,6 +1518,8 @@ void tcp_sndbuf_autoscale(struct tcpcb *, struct socket *, uint32_t);
1530int tcp_stats_sample_rollthedice(struct tcpcb *tp, void *seed_bytes,1518int tcp_stats_sample_rollthedice(struct tcpcb *tp, void *seed_bytes,
1531 size_t seed_len);1519 size_t seed_len);
1532int tcp_can_enable_pacing(void);1520int tcp_can_enable_pacing(void);
1521int tcp_incr_dgp_pacing_cnt(void);
1522void tcp_dec_dgp_pacing_cnt(void);
1533void tcp_decrement_paced_conn(void);1523void tcp_decrement_paced_conn(void);
1534void tcp_change_time_units(struct tcpcb *, int);1524void tcp_change_time_units(struct tcpcb *, int);
1535void tcp_handle_orphaned_packets(struct tcpcb *);1525void tcp_handle_orphaned_packets(struct tcpcb *);
...@@ -1598,19 +1588,6 @@ tcp_fields_to_net(struct tcphdr *th)...@@ -1598,19 +1588,6 @@ tcp_fields_to_net(struct tcphdr *th)
1598 th->th_win = htons(th->th_win);1588 th->th_win = htons(th->th_win);
1599 th->th_urp = htons(th->th_urp);1589 th->th_urp = htons(th->th_urp);
1600}1590}
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}
1614#endif /* _KERNEL */1591#endif /* _KERNEL */
16151592
1616#endif /* _NETINET_TCP_VAR_H_ */1593#endif /* _NETINET_TCP_VAR_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/netinet/tcpip.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)tcpip.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _NETINET_TCPIP_H_32#ifndef _NETINET_TCPIP_H_
lib/libc/include/generic-freebsd/netinet/toecore.h+2-1
...@@ -36,6 +36,7 @@...@@ -36,6 +36,7 @@
36#include <netinet/tcp.h>36#include <netinet/tcp.h>
37#include <sys/_eventhandler.h>37#include <sys/_eventhandler.h>
3838
39struct tcpcb;
39struct tcpopt;40struct tcpopt;
40struct tcphdr;41struct tcphdr;
41struct in_conninfo;42struct in_conninfo;
...@@ -65,7 +66,7 @@ struct toedev {...@@ -65,7 +66,7 @@ struct toedev {
65 void (*tod_input)(struct toedev *, struct tcpcb *, struct mbuf *);66 void (*tod_input)(struct toedev *, struct tcpcb *, struct mbuf *);
6667
67 /*68 /*
68 * This is called by the kernel during pru_rcvd for an offloaded TCP69 * This is called by the kernel during pr_rcvd() for an offloaded TCP
69 * connection and provides an opportunity for the TOE driver to manage70 * connection and provides an opportunity for the TOE driver to manage
70 * its rx window and credits.71 * its rx window and credits.
71 */72 */
lib/libc/include/generic-freebsd/netinet/udp.h+1-3
...@@ -28,8 +28,6 @@...@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * @(#)udp.h 8.1 (Berkeley) 6/10/93
33 */31 */
3432
35#ifndef _NETINET_UDP_H_33#ifndef _NETINET_UDP_H_
...@@ -46,7 +44,7 @@ struct udphdr {...@@ -46,7 +44,7 @@ struct udphdr {
46 u_short uh_dport; /* destination port */44 u_short uh_dport; /* destination port */
47 u_short uh_ulen; /* udp length */45 u_short uh_ulen; /* udp length */
48 u_short uh_sum; /* udp checksum */46 u_short uh_sum; /* udp checksum */
49};47} __packed;
5048
51/*49/*
52 * User-settable options (used with setsockopt).50 * User-settable options (used with setsockopt).
lib/libc/include/generic-freebsd/netinet/udp_var.h+20-11
...@@ -28,8 +28,6 @@...@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93
33 */31 */
3432
35#ifndef _NETINET_UDP_VAR_H_33#ifndef _NETINET_UDP_VAR_H_
...@@ -95,6 +93,7 @@ struct udpstat {...@@ -95,6 +93,7 @@ struct udpstat {
95#ifdef _KERNEL93#ifdef _KERNEL
96#include <netinet/in_pcb.h>94#include <netinet/in_pcb.h>
97#include <sys/counter.h>95#include <sys/counter.h>
96#include <netinet/in_kdtrace.h>
98struct mbuf;97struct mbuf;
9998
100typedef bool udp_tun_func_t(struct mbuf *, int, struct inpcb *,99typedef bool udp_tun_func_t(struct mbuf *, int, struct inpcb *,
...@@ -121,7 +120,7 @@ struct udpcb {...@@ -121,7 +120,7 @@ struct udpcb {
121 void *u_tun_ctx; /* Tunneling callback context. */120 void *u_tun_ctx; /* Tunneling callback context. */
122};121};
123122
124#define intoudpcb(ip) __containerof((inp), struct udpcb, u_inpcb)123#define intoudpcb(ip) __containerof((ip), struct udpcb, u_inpcb)
125#define sotoudpcb(so) (intoudpcb(sotoinpcb(so)))124#define sotoudpcb(so) (intoudpcb(sotoinpcb(so)))
126125
127VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);126VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);
...@@ -129,18 +128,26 @@ VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);...@@ -129,18 +128,26 @@ VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);
129 * In-kernel consumers can use these accessor macros directly to update128 * In-kernel consumers can use these accessor macros directly to update
130 * stats.129 * stats.
131 */130 */
132#define UDPSTAT_ADD(name, val) \131#define UDPSTAT_ADD(name, val) \
133 VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val))132 do { \
134#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1)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
136/*138/*
137 * Kernel module consumers must use this accessor macro.139 * Kernel module consumers must use this accessor macro.
138 */140 */
139void kmod_udpstat_inc(int statnum);141void kmod_udpstat_inc(int statnum);
140#define KMOD_UDPSTAT_INC(name) \142#define KMOD_UDPSTAT_INC(name) \
141 kmod_udpstat_inc(offsetof(struct udpstat, name) / sizeof(uint64_t))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
143SYSCTL_DECL(_net_inet_udp);149SYSCTL_DECL(_net_inet_udp);
150SYSCTL_DECL(_net_inet_udplite);
144151
145VNET_DECLARE(struct inpcbinfo, udbinfo);152VNET_DECLARE(struct inpcbinfo, udbinfo);
146VNET_DECLARE(struct inpcbinfo, ulitecbinfo);153VNET_DECLARE(struct inpcbinfo, ulitecbinfo);
...@@ -149,13 +156,15 @@ VNET_DECLARE(struct inpcbinfo, ulitecbinfo);...@@ -149,13 +156,15 @@ VNET_DECLARE(struct inpcbinfo, ulitecbinfo);
149156
150extern u_long udp_sendspace;157extern u_long udp_sendspace;
151extern u_long udp_recvspace;158extern u_long udp_recvspace;
152VNET_DECLARE(int, udp_cksum);159VNET_DECLARE(int, udp_bind_all_fibs);
153VNET_DECLARE(int, udp_blackhole);160VNET_DECLARE(int, udp_blackhole);
154VNET_DECLARE(bool, udp_blackhole_local);161VNET_DECLARE(bool, udp_blackhole_local);
162VNET_DECLARE(int, udp_cksum);
155VNET_DECLARE(int, udp_log_in_vain);163VNET_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)
157#define V_udp_blackhole VNET(udp_blackhole)165#define V_udp_blackhole VNET(udp_blackhole)
158#define V_udp_blackhole_local VNET(udp_blackhole_local)166#define V_udp_blackhole_local VNET(udp_blackhole_local)
167#define V_udp_cksum VNET(udp_cksum)
159#define V_udp_log_in_vain VNET(udp_log_in_vain)168#define V_udp_log_in_vain VNET(udp_log_in_vain)
160169
161VNET_DECLARE(int, zero_checksum_port);170VNET_DECLARE(int, zero_checksum_port);
...@@ -170,7 +179,7 @@ udp_get_inpcbinfo(int protocol)...@@ -170,7 +179,7 @@ udp_get_inpcbinfo(int protocol)
170int udp_ctloutput(struct socket *, struct sockopt *);179int udp_ctloutput(struct socket *, struct sockopt *);
171void udplite_input(struct mbuf *, int);180void udplite_input(struct mbuf *, int);
172struct inpcb *udp_notify(struct inpcb *inp, int errno);181struct inpcb *udp_notify(struct inpcb *inp, int errno);
173int udp_shutdown(struct socket *so);182int udp_shutdown(struct socket *, enum shutdown_how);
174183
175int udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f,184int udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f,
176 udp_tun_icmp_t i, void *ctx);185 udp_tun_icmp_t i, void *ctx);
lib/libc/include/generic-freebsd/netinet6/in6.h+7-8
...@@ -58,8 +58,6 @@...@@ -58,8 +58,6 @@
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.60 * SUCH DAMAGE.
61 *
62 * @(#)in.h 8.3 (Berkeley) 1/3/94
63 */61 */
6462
65#ifndef __KAME_NETINET_IN_H_INCLUDED_63#ifndef __KAME_NETINET_IN_H_INCLUDED_
...@@ -360,11 +358,11 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;...@@ -360,11 +358,11 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
360358
361#define IFA6_IS_DEPRECATED(a) \359#define IFA6_IS_DEPRECATED(a) \
362 ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \360 ((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)) >= \
364 (a)->ia6_lifetime.ia6t_pltime)362 (a)->ia6_lifetime.ia6t_pltime)
365#define IFA6_IS_INVALID(a) \363#define IFA6_IS_INVALID(a) \
366 ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \364 ((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)) >= \
368 (a)->ia6_lifetime.ia6t_vltime)366 (a)->ia6_lifetime.ia6t_vltime)
369#endif /* _KERNEL */367#endif /* _KERNEL */
370368
...@@ -666,6 +664,8 @@ struct ip6_hdr;...@@ -666,6 +664,8 @@ struct ip6_hdr;
666664
667int in6_cksum(struct mbuf *, uint8_t, uint32_t, uint32_t);665int in6_cksum(struct mbuf *, uint8_t, uint32_t, uint32_t);
668int in6_cksum_partial(struct mbuf *, uint8_t, uint32_t, uint32_t, uint32_t);666int 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);
669int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t);669int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t);
670670
671int in6_localaddr(struct in6_addr *);671int in6_localaddr(struct in6_addr *);
...@@ -679,11 +679,10 @@ extern void in6_if_up(struct ifnet *);...@@ -679,11 +679,10 @@ extern void in6_if_up(struct ifnet *);
679struct sockaddr;679struct sockaddr;
680680
681void in6_sin6_2_sin(struct sockaddr_in *sin,681void in6_sin6_2_sin(struct sockaddr_in *sin,
682 struct sockaddr_in6 *sin6);682 const struct sockaddr_in6 *sin6);
683void in6_sin_2_v4mapsin6(struct sockaddr_in *sin,683void in6_sin_2_v4mapsin6(const struct sockaddr_in *sin,
684 struct sockaddr_in6 *sin6);684 struct sockaddr_in6 *sin6);
685void in6_sin6_2_sin_in_sock(struct sockaddr *nam);685void in6_sin6_2_sin_in_sock(struct sockaddr *nam);
686void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam);
687extern void addrsel_policy_init(void);686extern void addrsel_policy_init(void);
688687
689#define satosin6(sa) ((struct sockaddr_in6 *)(sa))688#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 *);...@@ -39,7 +39,6 @@ void in6_ifattach(struct ifnet *, struct ifnet *);
39void in6_ifattach_destroy(void);39void in6_ifattach_destroy(void);
40void in6_ifdetach(struct ifnet *);40void in6_ifdetach(struct ifnet *);
41void in6_ifdetach_destroy(struct ifnet *);41void in6_ifdetach_destroy(struct ifnet *);
42int in6_get_tmpifid(struct ifnet *, u_int8_t *, const u_int8_t *, int);
43void in6_tmpaddrtimer(void *);42void in6_tmpaddrtimer(void *);
44int in6_get_hw_ifid(struct ifnet *, struct in6_addr *);43int in6_get_hw_ifid(struct ifnet *, struct in6_addr *);
45int in6_nigroup(struct ifnet *, const char *, int, struct in6_addr *);44int 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 @@...@@ -58,8 +58,6 @@
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.60 * SUCH DAMAGE.
61 *
62 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
63 */61 */
6462
65#ifndef _NETINET6_IN6_PCB_H_63#ifndef _NETINET6_IN6_PCB_H_
...@@ -72,40 +70,30 @@...@@ -72,40 +70,30 @@
7270
73void in6_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);71void in6_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
74void in6_losing(struct inpcb *);72void 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 *);
76int in6_pcbconnect(struct inpcb *, struct sockaddr_in6 *, struct ucred *,74int in6_pcbconnect(struct inpcb *, struct sockaddr_in6 *, struct ucred *,
77 bool);75 bool);
78void in6_pcbdisconnect(struct inpcb *);76void in6_pcbdisconnect(struct inpcb *);
79struct inpcb *77struct inpcb *in6_pcblookup_local(struct inpcbinfo *, const struct in6_addr *,
80 in6_pcblookup_local(struct inpcbinfo *,78 u_short, int, int, struct ucred *);
81 struct in6_addr *, u_short, int,79struct inpcb *in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo,
82 struct ucred *);
83struct inpcb *
84 in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo,
85 const struct in6_addr *faddr, u_int fport_arg,80 const struct in6_addr *faddr, u_int fport_arg,
86 const struct in6_addr *laddr, u_int lport_arg,81 const struct in6_addr *laddr, u_int lport_arg,
87 int lookupflags, uint8_t);82 int lookupflags, uint8_t numa_domain, int fib);
88struct inpcb *83struct inpcb *in6_pcblookup(struct inpcbinfo *, const struct in6_addr *, u_int,
89 in6_pcblookup(struct inpcbinfo *, struct in6_addr *,84 const struct in6_addr *, u_int, int, struct ifnet *);
90 u_int, struct in6_addr *, u_int, int,85struct inpcb *in6_pcblookup_mbuf(struct inpcbinfo *, const struct in6_addr *,
91 struct ifnet *);86 u_int, const struct in6_addr *, u_int, int, struct ifnet *ifp,
92struct inpcb *87 struct mbuf *);
93 in6_pcblookup_mbuf(struct inpcbinfo *, struct in6_addr *,
94 u_int, struct in6_addr *, u_int, int,
95 struct ifnet *ifp, struct mbuf *);
96void in6_pcbnotify(struct inpcbinfo *, struct sockaddr_in6 *, u_int,88void in6_pcbnotify(struct inpcbinfo *, struct sockaddr_in6 *, u_int,
97 const struct sockaddr_in6 *, u_int, int, void *,89 const struct sockaddr_in6 *, u_int, int, void *,
98 struct inpcb *(*)(struct inpcb *, int));90 struct inpcb *(*)(struct inpcb *, int));
99struct inpcb *91struct inpcb *
100 in6_rtchange(struct inpcb *, int);92 in6_rtchange(struct inpcb *, int);
101struct sockaddr *93int in6_getpeeraddr(struct socket *, struct sockaddr *);
102 in6_sockaddr(in_port_t port, struct in6_addr *addr_p);94int in6_getsockaddr(struct socket *, struct sockaddr *);
103struct sockaddr *95int in6_mapped_sockaddr(struct socket *, struct sockaddr *);
104 in6_v4mapsin6_sockaddr(in_port_t port, struct in_addr *addr_p);96int in6_mapped_peeraddr(struct socket *, struct sockaddr *);
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);
109int in6_selecthlim(struct inpcb *, struct ifnet *);97int in6_selecthlim(struct inpcb *, struct ifnet *);
110int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *);98int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *);
111void init_sin6(struct sockaddr_in6 *sin6, struct mbuf *m, int);99void 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 @@...@@ -58,8 +58,6 @@
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.60 * SUCH DAMAGE.
61 *
62 * @(#)in_var.h 8.1 (Berkeley) 6/10/93
63 */61 */
6462
65#ifndef _NETINET6_IN6_VAR_H_63#ifndef _NETINET6_IN6_VAR_H_
...@@ -117,7 +115,7 @@ struct in6_ifextra {...@@ -117,7 +115,7 @@ struct in6_ifextra {
117SLIST_HEAD(in6_multi_head, in6_multi);115SLIST_HEAD(in6_multi_head, in6_multi);
118MALLOC_DECLARE(M_IP6MADDR);116MALLOC_DECLARE(M_IP6MADDR);
119117
120struct in6_ifaddr {118struct in6_ifaddr {
121 struct ifaddr ia_ifa; /* protocol-independent info */119 struct ifaddr ia_ifa; /* protocol-independent info */
122#define ia_ifp ia_ifa.ifa_ifp120#define ia_ifp ia_ifa.ifa_ifp
123#define ia_flags ia_ifa.ifa_flags121#define ia_flags ia_ifa.ifa_flags
...@@ -325,8 +323,7 @@ struct in6_prflags {...@@ -325,8 +323,7 @@ struct in6_prflags {
325 struct prf_ra {323 struct prf_ra {
326 u_char onlink : 1;324 u_char onlink : 1;
327 u_char autonomous : 1;325 u_char autonomous : 1;
328 u_char ra_derived: 1;326 u_char reserved : 6;
329 u_char reserved : 5;
330 } prf_ra;327 } prf_ra;
331 u_char prf_reserved1;328 u_char prf_reserved1;
332 u_short prf_reserved2;329 u_short prf_reserved2;
...@@ -357,7 +354,6 @@ struct in6_prefixreq {...@@ -357,7 +354,6 @@ struct in6_prefixreq {
357354
358#define ipr_raf_onlink ipr_flags.prf_ra.onlink355#define ipr_raf_onlink ipr_flags.prf_ra.onlink
359#define ipr_raf_auto ipr_flags.prf_ra.autonomous356#define ipr_raf_auto ipr_flags.prf_ra.autonomous
360#define ipr_raf_ra_derived ipr_flags.prf_ra.ra_derived
361357
362#define ipr_statef_onlink ipr_flags.prf_state.onlink358#define ipr_statef_onlink ipr_flags.prf_state.onlink
363359
...@@ -551,9 +547,6 @@ do { \...@@ -551,9 +547,6 @@ do { \
551 ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[ \547 ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[ \
552 offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\548 offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\
553} while (/*CONSTCOND*/ 0)549} while (/*CONSTCOND*/ 0)
554
555VNET_DECLARE(unsigned long, in6_maxmtu);
556#define V_in6_maxmtu VNET(in6_maxmtu)
557#endif /* _KERNEL */550#endif /* _KERNEL */
558551
559/*552/*
...@@ -877,7 +870,6 @@ void in6_domifdetach(struct ifnet *, void *);...@@ -877,7 +870,6 @@ void in6_domifdetach(struct ifnet *, void *);
877int in6_domifmtu(struct ifnet *);870int in6_domifmtu(struct ifnet *);
878struct rib_head *in6_inithead(uint32_t fibnum);871struct rib_head *in6_inithead(uint32_t fibnum);
879void in6_detachhead(struct rib_head *rh);872void in6_detachhead(struct rib_head *rh);
880void in6_setmaxmtu(void);
881int in6_if2idlen(struct ifnet *);873int in6_if2idlen(struct ifnet *);
882struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);874struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
883struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, const struct in6_addr *);875struct 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 @@...@@ -58,8 +58,6 @@
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.60 * SUCH DAMAGE.
61 *
62 * @(#)ip_var.h 8.1 (Berkeley) 6/10/93
63 */61 */
6462
65#ifndef _NETINET6_IP6_VAR_H_63#ifndef _NETINET6_IP6_VAR_H_
...@@ -132,27 +130,26 @@ struct ip6po_nhinfo {...@@ -132,27 +130,26 @@ struct ip6po_nhinfo {
132#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop130#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
133#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route131#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 */
135struct ip6_pktopts {141struct ip6_pktopts {
136 struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */142 uint32_t ip6po_valid;
137 int ip6po_hlim; /* Hoplimit for outgoing packets */143#define IP6PO_VALID_HLIM 0x0001
138144#define IP6PO_VALID_PKTINFO 0x0002
139 /* Outgoing IF/address information */145#define IP6PO_VALID_NHINFO 0x0004
140 struct in6_pktinfo *ip6po_pktinfo;146#define IP6PO_VALID_HBH 0x0008
141147#define IP6PO_VALID_DEST1 0x0010
142 /* Next-hop address information */148#define IP6PO_VALID_RHINFO 0x0020
143 struct ip6po_nhinfo ip6po_nhinfo;149#define IP6PO_VALID_DEST2 0x0040
144150#define IP6PO_VALID_TC 0x0080
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;
155151
152 int ip6po_hlim; /* Hoplimit for outgoing packets */
156 int ip6po_tclass; /* traffic class */153 int ip6po_tclass; /* traffic class */
157154
158 int ip6po_minmtu; /* fragment vs PMTU discovery policy */155 int ip6po_minmtu; /* fragment vs PMTU discovery policy */
...@@ -173,6 +170,25 @@ struct ip6_pktopts {...@@ -173,6 +170,25 @@ struct ip6_pktopts {
173#endif170#endif
174#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */171#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
175#define IP6PO_USECOA 0x08 /* use care of address */172#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;
176};192};
177193
178/*194/*
...@@ -247,13 +263,22 @@ struct ip6stat {...@@ -247,13 +263,22 @@ struct ip6stat {
247263
248#ifdef _KERNEL264#ifdef _KERNEL
249#include <sys/counter.h>265#include <sys/counter.h>
266#include <netinet/in_kdtrace.h>
250267
251VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat);268VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat);
252#define IP6STAT_ADD(name, val) \269#define IP6STAT_ADD(name, val) \
253 VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val))270 do { \
254#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val))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))
255#define IP6STAT_INC(name) IP6STAT_ADD(name, 1)275#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)
257#endif282#endif
258283
259#ifdef _KERNEL284#ifdef _KERNEL
...@@ -389,7 +414,7 @@ int route6_input(struct mbuf **, int *, int);...@@ -389,7 +414,7 @@ int route6_input(struct mbuf **, int *, int);
389void frag6_init(void);414void frag6_init(void);
390void frag6_destroy(void);415void frag6_destroy(void);
391int frag6_input(struct mbuf **, int *, int);416int frag6_input(struct mbuf **, int *, int);
392void frag6_drain(void);417void frag6_drain(void *, int);
393418
394void rip6_init(void);419void rip6_init(void);
395int rip6_ctloutput(struct socket *, struct sockopt *);420int 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 {...@@ -84,9 +84,9 @@ struct ipfw_nat64lsn_stats {
84 uint64_t spgcreated; /* Number of portgroups created */84 uint64_t spgcreated; /* Number of portgroups created */
85 uint64_t spgdeleted; /* Number of portgroups deleted */85 uint64_t spgdeleted; /* Number of portgroups deleted */
86 uint64_t hostcount; /* Number of hosts */86 uint64_t hostcount; /* Number of hosts */
87 uint64_t tcpchunks; /* Number of TCP chunks */87 uint64_t tcpchunks; /* Number of TCP portgroups */
88 uint64_t udpchunks; /* Number of UDP chunks */88 uint64_t udpchunks; /* Number of UDP portgroups */
89 uint64_t icmpchunks; /* Number of ICMP chunks */89 uint64_t icmpchunks; /* Number of ICMP portgroups */
9090
91 uint64_t _reserved[4];91 uint64_t _reserved[4];
92};92};
...@@ -95,6 +95,10 @@ struct ipfw_nat64lsn_stats {...@@ -95,6 +95,10 @@ struct ipfw_nat64lsn_stats {
95#define NAT64_ALLOW_PRIVATE 0x0002 /* Allow private IPv4 address95#define NAT64_ALLOW_PRIVATE 0x0002 /* Allow private IPv4 address
96 * translation96 * translation
97 */97 */
98#define NAT64LSN_ALLOW_SWAPCONF 0x0004 /* Allow configuration exchange
99 * between NAT64LSN instances
100 * during the sets swapping.
101 */
98typedef struct _ipfw_nat64stl_cfg {102typedef struct _ipfw_nat64stl_cfg {
99 char name[64]; /* NAT name */103 char name[64]; /* NAT name */
100 ipfw_obj_ntlv ntlv6; /* object name tlv */104 ipfw_obj_ntlv ntlv6; /* object name tlv */
lib/libc/include/generic-freebsd/netinet6/nd6.h+4-3
...@@ -184,10 +184,10 @@ struct in6_ndifreq {...@@ -184,10 +184,10 @@ struct in6_ndifreq {
184#define RETRANS_TIMER 1000 /* msec */184#define RETRANS_TIMER 1000 /* msec */
185#define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */185#define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
186#define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */186#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 */
188#define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */188#define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
189#define TEMPADDR_REGEN_ADVANCE 5 /* sec */189#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 */
191#define ND_COMPUTE_RTIME(x) \191#define ND_COMPUTE_RTIME(x) \
192 (((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \192 (((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \
193 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)193 ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
...@@ -242,7 +242,6 @@ struct nd_prefix {...@@ -242,7 +242,6 @@ struct nd_prefix {
242#define ndpr_raf ndpr_flags242#define ndpr_raf ndpr_flags
243#define ndpr_raf_onlink ndpr_flags.onlink243#define ndpr_raf_onlink ndpr_flags.onlink
244#define ndpr_raf_auto ndpr_flags.autonomous244#define ndpr_raf_auto ndpr_flags.autonomous
245#define ndpr_raf_ra_derived ndpr_flags.ra_derived
246#define ndpr_raf_router ndpr_flags.router245#define ndpr_raf_router ndpr_flags.router
247246
248struct nd_pfxrouter {247struct nd_pfxrouter {
...@@ -293,11 +292,13 @@ VNET_DECLARE(struct mtx, nd6_onlink_mtx);...@@ -293,11 +292,13 @@ VNET_DECLARE(struct mtx, nd6_onlink_mtx);
293/* nd6_rtr.c */292/* nd6_rtr.c */
294VNET_DECLARE(int, nd6_defifindex);293VNET_DECLARE(int, nd6_defifindex);
295VNET_DECLARE(int, ip6_desync_factor); /* seconds */294VNET_DECLARE(int, ip6_desync_factor); /* seconds */
295VNET_DECLARE(uint32_t, ip6_temp_max_desync_factor); /* seconds */
296VNET_DECLARE(u_int32_t, ip6_temp_preferred_lifetime); /* seconds */296VNET_DECLARE(u_int32_t, ip6_temp_preferred_lifetime); /* seconds */
297VNET_DECLARE(u_int32_t, ip6_temp_valid_lifetime); /* seconds */297VNET_DECLARE(u_int32_t, ip6_temp_valid_lifetime); /* seconds */
298VNET_DECLARE(int, ip6_temp_regen_advance); /* seconds */298VNET_DECLARE(int, ip6_temp_regen_advance); /* seconds */
299#define V_nd6_defifindex VNET(nd6_defifindex)299#define V_nd6_defifindex VNET(nd6_defifindex)
300#define V_ip6_desync_factor VNET(ip6_desync_factor)300#define V_ip6_desync_factor VNET(ip6_desync_factor)
301#define V_ip6_temp_max_desync_factor VNET(ip6_temp_max_desync_factor)
301#define V_ip6_temp_preferred_lifetime VNET(ip6_temp_preferred_lifetime)302#define V_ip6_temp_preferred_lifetime VNET(ip6_temp_preferred_lifetime)
302#define V_ip6_temp_valid_lifetime VNET(ip6_temp_valid_lifetime)303#define V_ip6_temp_valid_lifetime VNET(ip6_temp_valid_lifetime)
303#define V_ip6_temp_regen_advance VNET(ip6_temp_regen_advance)304#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 @@...@@ -56,8 +56,6 @@
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.58 * SUCH DAMAGE.
59 *
60 * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
61 */59 */
6260
63#ifndef _NETINET_TCP6_VAR_H_61#ifndef _NETINET_TCP6_VAR_H_
lib/libc/include/generic-freebsd/netinet6/udp6_var.h-2
...@@ -57,8 +57,6 @@...@@ -57,8 +57,6 @@
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE.59 * SUCH DAMAGE.
60 *
61 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93
62 */60 */
6361
64#ifndef _NETINET6_UDP6_VAR_H_62#ifndef _NETINET6_UDP6_VAR_H_
lib/libc/include/generic-freebsd/netipsec/ah_var.h+11-2
...@@ -71,13 +71,22 @@ struct ahstat {...@@ -71,13 +71,22 @@ struct ahstat {
7171
72#ifdef _KERNEL72#ifdef _KERNEL
73#include <sys/counter.h>73#include <sys/counter.h>
74#include <netinet/in_kdtrace.h>
7475
75VNET_DECLARE(int, ah_enable);76VNET_DECLARE(int, ah_enable);
76VNET_DECLARE(int, ah_cleartos);77VNET_DECLARE(int, ah_cleartos);
77VNET_PCPUSTAT_DECLARE(struct ahstat, ahstat);78VNET_PCPUSTAT_DECLARE(struct ahstat, ahstat);
7879
79#define AHSTAT_ADD(name, val) \80#define AHSTAT_ADD(name, val) \
80 VNET_PCPUSTAT_ADD(struct ahstat, ahstat, 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)
81#define AHSTAT_INC(name) AHSTAT_ADD(name, 1)90#define AHSTAT_INC(name) AHSTAT_ADD(name, 1)
82#define V_ah_enable VNET(ah_enable)91#define V_ah_enable VNET(ah_enable)
83#define V_ah_cleartos VNET(ah_cleartos)92#define V_ah_cleartos VNET(ah_cleartos)
lib/libc/include/generic-freebsd/netipsec/esp_var.h+14-2
...@@ -72,13 +72,25 @@ struct espstat {...@@ -72,13 +72,25 @@ struct espstat {
7272
73#ifdef _KERNEL73#ifdef _KERNEL
74#include <sys/counter.h>74#include <sys/counter.h>
75#include <netinet/in_kdtrace.h>
7576
76VNET_DECLARE(int, esp_enable);77VNET_DECLARE(int, esp_enable);
78VNET_DECLARE(int, esp_ctr_compatibility);
79#define V_esp_ctr_compatibility VNET(esp_ctr_compatibility)
77VNET_PCPUSTAT_DECLARE(struct espstat, espstat);80VNET_PCPUSTAT_DECLARE(struct espstat, espstat);
7881
79#define ESPSTAT_ADD(name, val) \82#define ESPSTAT_ADD(name, val) \
80 VNET_PCPUSTAT_ADD(struct espstat, espstat, name, (val))83 do { \
84 MIB_SDT_PROBE1(esp, count, name, (val)); \
85 VNET_PCPUSTAT_ADD(struct espstat, espstat, name, (val)); \
86 } while (0)
81#define ESPSTAT_INC(name) ESPSTAT_ADD(name, 1)87#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
82#define V_esp_enable VNET(esp_enable)94#define V_esp_enable VNET(esp_enable)
83#endif /* _KERNEL */95#endif /* _KERNEL */
84#endif /*_NETIPSEC_ESP_VAR_H_*/96#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 {...@@ -66,12 +66,22 @@ struct ipcompstat {
6666
67#ifdef _KERNEL67#ifdef _KERNEL
68#include <sys/counter.h>68#include <sys/counter.h>
69#include <netinet/in_kdtrace.h>
6970
70VNET_DECLARE(int, ipcomp_enable);71VNET_DECLARE(int, ipcomp_enable);
71VNET_PCPUSTAT_DECLARE(struct ipcompstat, ipcompstat);72VNET_PCPUSTAT_DECLARE(struct ipcompstat, ipcompstat);
7273
73#define IPCOMPSTAT_ADD(name, val) \74#define IPCOMPSTAT_ADD(name, val) \
74 VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, 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)
75#define IPCOMPSTAT_INC(name) IPCOMPSTAT_ADD(name, 1)85#define IPCOMPSTAT_INC(name) IPCOMPSTAT_ADD(name, 1)
76#define V_ipcomp_enable VNET(ipcomp_enable)86#define V_ipcomp_enable VNET(ipcomp_enable)
77#endif /* _KERNEL */87#endif /* _KERNEL */
lib/libc/include/generic-freebsd/netipsec/ipsec.h+44-17
...@@ -46,6 +46,9 @@...@@ -46,6 +46,9 @@
46#include <sys/_lock.h>46#include <sys/_lock.h>
47#include <sys/_mutex.h>47#include <sys/_mutex.h>
48#include <sys/_rwlock.h>48#include <sys/_rwlock.h>
49#include <sys/sysctl.h>
50
51#include <netinet/in_kdtrace.h>
4952
50#define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m)53#define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m)
5154
...@@ -71,6 +74,12 @@ struct ipsecrequest {...@@ -71,6 +74,12 @@ struct ipsecrequest {
71 u_int level; /* IPsec level defined below. */74 u_int level; /* IPsec level defined below. */
72};75};
7376
77struct ipsec_accel_adddel_sp_tq {
78 struct vnet *adddel_vnet;
79 struct task adddel_task;
80 int adddel_scheduled;
81};
82
74/* Security Policy Data Base */83/* Security Policy Data Base */
75struct secpolicy {84struct secpolicy {
76 TAILQ_ENTRY(secpolicy) chain;85 TAILQ_ENTRY(secpolicy) chain;
...@@ -93,7 +102,7 @@ struct secpolicy {...@@ -93,7 +102,7 @@ struct secpolicy {
93 uint32_t id; /* It's unique number on the system. */102 uint32_t id; /* It's unique number on the system. */
94 /*103 /*
95 * lifetime handler.104 * lifetime handler.
96 * the policy can be used without limitiation if both lifetime and105 * the policy can be used without limitation if both lifetime and
97 * validtime are zero.106 * validtime are zero.
98 * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime.107 * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime.
99 * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime.108 * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime.
...@@ -102,6 +111,11 @@ struct secpolicy {...@@ -102,6 +111,11 @@ struct secpolicy {
102 time_t lastused; /* updated every when kernel sends a packet */111 time_t lastused; /* updated every when kernel sends a packet */
103 long lifetime; /* duration of the lifetime of this policy */112 long lifetime; /* duration of the lifetime of this policy */
104 long validtime; /* duration this policy is valid without use */113 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;
105};119};
106120
107/*121/*
...@@ -246,6 +260,7 @@ struct ipsecstat {...@@ -246,6 +260,7 @@ struct ipsecstat {
246#define IPSECCTL_DEBUG 12260#define IPSECCTL_DEBUG 12
247#define IPSECCTL_ESP_RANDPAD 13261#define IPSECCTL_ESP_RANDPAD 13
248#define IPSECCTL_MIN_PMTU 14262#define IPSECCTL_MIN_PMTU 14
263#define IPSECCTL_RANDOM_ID 15
249264
250#ifdef _KERNEL265#ifdef _KERNEL
251#include <sys/counter.h>266#include <sys/counter.h>
...@@ -279,12 +294,17 @@ VNET_DECLARE(int, ip4_ah_net_deflev);...@@ -279,12 +294,17 @@ VNET_DECLARE(int, ip4_ah_net_deflev);
279VNET_DECLARE(int, ip4_ipsec_dfbit);294VNET_DECLARE(int, ip4_ipsec_dfbit);
280VNET_DECLARE(int, ip4_ipsec_min_pmtu);295VNET_DECLARE(int, ip4_ipsec_min_pmtu);
281VNET_DECLARE(int, ip4_ipsec_ecn);296VNET_DECLARE(int, ip4_ipsec_ecn);
297VNET_DECLARE(int, ip4_ipsec_random_id);
282VNET_DECLARE(int, crypto_support);298VNET_DECLARE(int, crypto_support);
283VNET_DECLARE(int, async_crypto);299VNET_DECLARE(int, async_crypto);
284VNET_DECLARE(int, natt_cksum_policy);300VNET_DECLARE(int, natt_cksum_policy);
285301
286#define IPSECSTAT_INC(name) \302#define IPSECSTAT_INC(name) \
287 VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1)303 do { \
304 MIB_SDT_PROBE1(ipsec, count, name, 1); \
305 VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1); \
306 } while (0)
307
288#define V_ip4_esp_trans_deflev VNET(ip4_esp_trans_deflev)308#define V_ip4_esp_trans_deflev VNET(ip4_esp_trans_deflev)
289#define V_ip4_esp_net_deflev VNET(ip4_esp_net_deflev)309#define V_ip4_esp_net_deflev VNET(ip4_esp_net_deflev)
290#define V_ip4_ah_trans_deflev VNET(ip4_ah_trans_deflev)310#define V_ip4_ah_trans_deflev VNET(ip4_ah_trans_deflev)
...@@ -292,6 +312,7 @@ VNET_DECLARE(int, natt_cksum_policy);...@@ -292,6 +312,7 @@ VNET_DECLARE(int, natt_cksum_policy);
292#define V_ip4_ipsec_dfbit VNET(ip4_ipsec_dfbit)312#define V_ip4_ipsec_dfbit VNET(ip4_ipsec_dfbit)
293#define V_ip4_ipsec_min_pmtu VNET(ip4_ipsec_min_pmtu)313#define V_ip4_ipsec_min_pmtu VNET(ip4_ipsec_min_pmtu)
294#define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn)314#define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn)
315#define V_ip4_ipsec_random_id VNET(ip4_ipsec_random_id)
295#define V_crypto_support VNET(crypto_support)316#define V_crypto_support VNET(crypto_support)
296#define V_async_crypto VNET(async_crypto)317#define V_async_crypto VNET(async_crypto)
297#define V_natt_cksum_policy VNET(natt_cksum_policy)318#define V_natt_cksum_policy VNET(natt_cksum_policy)
...@@ -307,6 +328,7 @@ VNET_DECLARE(int, natt_cksum_policy);...@@ -307,6 +328,7 @@ VNET_DECLARE(int, natt_cksum_policy);
307#endif328#endif
308329
309struct inpcb;330struct inpcb;
331struct ip;
310struct m_tag;332struct m_tag;
311struct secasvar;333struct secasvar;
312struct sockopt;334struct sockopt;
...@@ -318,7 +340,7 @@ int ipsec_if_input(struct mbuf *, struct secasvar *, uint32_t);...@@ -318,7 +340,7 @@ int ipsec_if_input(struct mbuf *, struct secasvar *, uint32_t);
318struct ipsecrequest *ipsec_newisr(void);340struct ipsecrequest *ipsec_newisr(void);
319void ipsec_delisr(struct ipsecrequest *);341void ipsec_delisr(struct ipsecrequest *);
320struct secpolicy *ipsec4_checkpolicy(const struct mbuf *, struct inpcb *,342struct secpolicy *ipsec4_checkpolicy(const struct mbuf *, struct inpcb *,
321 int *, int);343 struct ip *, int *, int);
322344
323u_int ipsec_get_reqlevel(struct secpolicy *, u_int);345u_int ipsec_get_reqlevel(struct secpolicy *, u_int);
324346
...@@ -333,27 +355,32 @@ size_t ipsec_hdrsiz_internal(struct secpolicy *);...@@ -333,27 +355,32 @@ size_t ipsec_hdrsiz_internal(struct secpolicy *);
333355
334void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int);356void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int);
335357
336void ipsec4_setsockaddrs(const struct mbuf *, union sockaddr_union *,358void ipsec4_setsockaddrs(const struct mbuf *, const struct ip *,
337 union sockaddr_union *);359 union sockaddr_union *, union sockaddr_union *);
338int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int);360int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int);
339int ipsec4_check_pmtu(struct mbuf *, struct secpolicy *, int);361int ipsec4_check_pmtu(struct ifnet *, struct mbuf *, struct ip *ip1,
340int ipsec4_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *);362 struct secpolicy *, int);
363int ipsec4_process_packet(struct ifnet *, struct mbuf *, struct ip *ip1,
364 struct secpolicy *, struct inpcb *, u_long);
341int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *,365int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *,
342 u_int);366 u_int);
343367
344extern void m_checkalignment(const char* where, struct mbuf *m0,368void m_checkalignment(const char* where, struct mbuf *m0,
345 int off, int len);369 int off, int len);
346extern struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off);370struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off);
347extern caddr_t m_pad(struct mbuf *m, int n);371caddr_t m_pad(struct mbuf *m, int n);
348extern int m_striphdr(struct mbuf *m, int skip, int hlen);372int m_striphdr(struct mbuf *m, int skip, int hlen);
373
374SYSCTL_DECL(_net_inet_ipsec);
375SYSCTL_DECL(_net_inet6_ipsec6);
349376
350#endif /* _KERNEL */377#endif /* _KERNEL */
351378
352#ifndef _KERNEL379#ifndef _KERNEL
353extern caddr_t ipsec_set_policy(char *, int);380caddr_t ipsec_set_policy(const char *, int);
354extern int ipsec_get_policylen(caddr_t);381int ipsec_get_policylen(c_caddr_t);
355extern char *ipsec_dump_policy(caddr_t, char *);382char *ipsec_dump_policy(c_caddr_t, const char *);
356extern const char *ipsec_strerror(void);383const char *ipsec_strerror(void);
357384
358#endif /* ! KERNEL */385#endif /* ! KERNEL */
359386
lib/libc/include/generic-freebsd/netipsec/ipsec6.h+3-2
...@@ -66,8 +66,9 @@ struct secpolicy *ipsec6_checkpolicy(const struct mbuf *,...@@ -66,8 +66,9 @@ struct secpolicy *ipsec6_checkpolicy(const struct mbuf *,
66void ipsec6_setsockaddrs(const struct mbuf *, union sockaddr_union *,66void ipsec6_setsockaddrs(const struct mbuf *, union sockaddr_union *,
67 union sockaddr_union *);67 union sockaddr_union *);
68int ipsec6_common_input_cb(struct mbuf *, struct secasvar *, int, int);68int ipsec6_common_input_cb(struct mbuf *, struct secasvar *, int, int);
69int ipsec6_check_pmtu(struct mbuf *, struct secpolicy *, int);69int ipsec6_check_pmtu(struct ifnet *, struct mbuf *, struct secpolicy *, int);
70int ipsec6_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *);70int ipsec6_process_packet(struct ifnet *, struct mbuf *, struct secpolicy *,
71 struct inpcb *, u_long);
7172
72int ip6_ipsec_filtertunnel(struct mbuf *);73int ip6_ipsec_filtertunnel(struct mbuf *);
73int ip6_ipsec_pcbctl(struct inpcb *, struct sockopt *);74int 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 @@...@@ -29,6 +29,8 @@
2929
30#ifdef _KERNEL30#ifdef _KERNEL
31#if defined(IPSEC) || defined(IPSEC_SUPPORT)31#if defined(IPSEC) || defined(IPSEC_SUPPORT)
32struct ifnet;
33struct ip;
32struct mbuf;34struct mbuf;
33struct inpcb;35struct inpcb;
34struct tcphdr;36struct tcphdr;
...@@ -49,14 +51,17 @@ int ipsec_init_pcbpolicy(struct inpcb *);...@@ -49,14 +51,17 @@ int ipsec_init_pcbpolicy(struct inpcb *);
49int ipsec_delete_pcbpolicy(struct inpcb *);51int ipsec_delete_pcbpolicy(struct inpcb *);
50int ipsec_copy_pcbpolicy(struct inpcb *, struct inpcb *);52int ipsec_copy_pcbpolicy(struct inpcb *, struct inpcb *);
5153
52#ifdef INET54#if defined(INET) || defined(INET6)
53int udp_ipsec_input(struct mbuf *, int, int);55int udp_ipsec_input(struct mbuf *, int, int);
54int udp_ipsec_pcbctl(struct inpcb *, struct sockopt *);56int udp_ipsec_pcbctl(struct inpcb *, struct sockopt *);
57#endif
58#ifdef INET
55int ipsec4_in_reject(const struct mbuf *, struct inpcb *);59int ipsec4_in_reject(const struct mbuf *, struct inpcb *);
60int ipsec4_in_reject1(const struct mbuf *m, struct ip *ip1, struct inpcb *inp);
56int ipsec4_input(struct mbuf *, int, int);61int ipsec4_input(struct mbuf *, int, int);
57int ipsec4_forward(struct mbuf *);62int ipsec4_forward(struct mbuf *);
58int ipsec4_pcbctl(struct inpcb *, struct sockopt *);63int ipsec4_pcbctl(struct inpcb *, struct sockopt *);
59int ipsec4_output(struct mbuf *, struct inpcb *);64int ipsec4_output(struct ifnet *, struct mbuf *, struct inpcb *, u_long);
60int ipsec4_capability(struct mbuf *, u_int);65int ipsec4_capability(struct mbuf *, u_int);
61int ipsec4_ctlinput(ipsec_ctlinput_param_t);66int ipsec4_ctlinput(ipsec_ctlinput_param_t);
62#endif /* INET */67#endif /* INET */
...@@ -66,7 +71,7 @@ int ipsec6_input(struct mbuf *, int, int);...@@ -66,7 +71,7 @@ int ipsec6_input(struct mbuf *, int, int);
66int ipsec6_in_reject(const struct mbuf *, struct inpcb *);71int ipsec6_in_reject(const struct mbuf *, struct inpcb *);
67int ipsec6_forward(struct mbuf *);72int ipsec6_forward(struct mbuf *);
68int ipsec6_pcbctl(struct inpcb *, struct sockopt *);73int ipsec6_pcbctl(struct inpcb *, struct sockopt *);
69int ipsec6_output(struct mbuf *, struct inpcb *);74int ipsec6_output(struct ifnet *, struct mbuf *, struct inpcb *, u_long);
70int ipsec6_capability(struct mbuf *, u_int);75int ipsec6_capability(struct mbuf *, u_int);
71int ipsec6_ctlinput(ipsec_ctlinput_param_t);76int ipsec6_ctlinput(ipsec_ctlinput_param_t);
72#endif /* INET6 */77#endif /* INET6 */
...@@ -75,7 +80,8 @@ struct ipsec_methods {...@@ -75,7 +80,8 @@ struct ipsec_methods {
75 int (*input)(struct mbuf *, int, int);80 int (*input)(struct mbuf *, int, int);
76 int (*check_policy)(const struct mbuf *, struct inpcb *);81 int (*check_policy)(const struct mbuf *, struct inpcb *);
77 int (*forward)(struct mbuf *);82 int (*forward)(struct mbuf *);
78 int (*output)(struct mbuf *, struct inpcb *);83 int (*output)(struct ifnet *, struct mbuf *, struct inpcb *,
84 u_long);
79 int (*pcbctl)(struct inpcb *, struct sockopt *);85 int (*pcbctl)(struct inpcb *, struct sockopt *);
80 size_t (*hdrsize)(struct inpcb *);86 size_t (*hdrsize)(struct inpcb *);
81 int (*capability)(struct mbuf *, u_int);87 int (*capability)(struct mbuf *, u_int);
...@@ -164,10 +170,10 @@ extern const struct ipsec_support * const ipv6_ipsec_support;...@@ -164,10 +170,10 @@ extern const struct ipsec_support * const ipv6_ipsec_support;
164#define IPSEC_CTLINPUT(proto, param) \170#define IPSEC_CTLINPUT(proto, param) \
165 (*(proto ## _ipsec_support)->methods->ctlinput)(param)171 (*(proto ## _ipsec_support)->methods->ctlinput)(param)
166172
167#define UDPENCAP_INPUT(m, ...) \173#define UDPENCAP_INPUT(proto, m, ...) \
168 (*ipv4_ipsec_support->methods->udp_input)(m, __VA_ARGS__)174 (*(proto ## _ipsec_support)->methods->udp_input)(m, __VA_ARGS__)
169#define UDPENCAP_PCBCTL(inp, sopt) \175#define UDPENCAP_PCBCTL(proto, inp, sopt) \
170 (*ipv4_ipsec_support->methods->udp_pcbctl)(inp, sopt)176 (*(proto ## _ipsec_support)->methods->udp_pcbctl)(inp, sopt)
171177
172#elif defined(IPSEC_SUPPORT)178#elif defined(IPSEC_SUPPORT)
173struct ipsec_support {179struct ipsec_support {
...@@ -185,8 +191,8 @@ int ipsec_kmod_input(struct ipsec_support * const, struct mbuf *, int, int);...@@ -185,8 +191,8 @@ int ipsec_kmod_input(struct ipsec_support * const, struct mbuf *, int, int);
185int ipsec_kmod_check_policy(struct ipsec_support * const, struct mbuf *,191int ipsec_kmod_check_policy(struct ipsec_support * const, struct mbuf *,
186 struct inpcb *);192 struct inpcb *);
187int ipsec_kmod_forward(struct ipsec_support * const, struct mbuf *);193int ipsec_kmod_forward(struct ipsec_support * const, struct mbuf *);
188int ipsec_kmod_output(struct ipsec_support * const, struct mbuf *,194int ipsec_kmod_output(struct ipsec_support * const, struct ifnet *,
189 struct inpcb *);195 struct mbuf *, struct inpcb *, u_long);
190int ipsec_kmod_pcbctl(struct ipsec_support * const, struct inpcb *,196int ipsec_kmod_pcbctl(struct ipsec_support * const, struct inpcb *,
191 struct sockopt *);197 struct sockopt *);
192int ipsec_kmod_capability(struct ipsec_support * const, struct mbuf *, u_int);198int 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);...@@ -196,10 +202,10 @@ int ipsec_kmod_udp_input(struct ipsec_support * const, struct mbuf *, int, int);
196int ipsec_kmod_udp_pcbctl(struct ipsec_support * const, struct inpcb *,202int ipsec_kmod_udp_pcbctl(struct ipsec_support * const, struct inpcb *,
197 struct sockopt *);203 struct sockopt *);
198204
199#define UDPENCAP_INPUT(m, ...) \205#define UDPENCAP_INPUT(proto, m, ...) \
200 ipsec_kmod_udp_input(ipv4_ipsec_support, m, __VA_ARGS__)206 ipsec_kmod_udp_input(proto ## _ipsec_support, m, __VA_ARGS__)
201#define UDPENCAP_PCBCTL(inp, sopt) \207#define UDPENCAP_PCBCTL(proto, inp, sopt) \
202 ipsec_kmod_udp_pcbctl(ipv4_ipsec_support, inp, sopt)208 ipsec_kmod_udp_pcbctl(proto ## _ipsec_support, inp, sopt)
203209
204#define IPSEC_INPUT(proto, ...) \210#define IPSEC_INPUT(proto, ...) \
205 ipsec_kmod_input(proto ## _ipsec_support, __VA_ARGS__)211 ipsec_kmod_input(proto ## _ipsec_support, __VA_ARGS__)
lib/libc/include/generic-freebsd/netipsec/key.h+7
...@@ -36,6 +36,7 @@...@@ -36,6 +36,7 @@
3636
37#ifdef _KERNEL37#ifdef _KERNEL
3838
39struct mbuf;
39struct secpolicy;40struct secpolicy;
40struct secpolicyindex;41struct secpolicyindex;
41struct secasvar;42struct secasvar;
...@@ -49,6 +50,7 @@ struct xformsw;...@@ -49,6 +50,7 @@ struct xformsw;
4950
50struct secpolicy *key_newsp(void);51struct secpolicy *key_newsp(void);
51struct secpolicy *key_allocsp(struct secpolicyindex *, u_int);52struct secpolicy *key_allocsp(struct secpolicyindex *, u_int);
53struct secpolicy *key_do_allocsp(struct secpolicyindex *spidx, u_int dir);
52struct secpolicy *key_msg2sp(struct sadb_x_policy *, size_t, int *);54struct secpolicy *key_msg2sp(struct sadb_x_policy *, size_t, int *);
53int key_sp2msg(struct secpolicy *, void *, size_t *);55int key_sp2msg(struct secpolicy *, void *, size_t *);
54void key_addref(struct secpolicy *);56void key_addref(struct secpolicy *);
...@@ -59,6 +61,7 @@ int key_havesp_any(void);...@@ -59,6 +61,7 @@ int key_havesp_any(void);
59void key_bumpspgen(void);61void key_bumpspgen(void);
60uint32_t key_getspgen(void);62uint32_t key_getspgen(void);
61uint32_t key_newreqid(void);63uint32_t key_newreqid(void);
64struct mbuf *key_setaccelif(const char *ifname);
6265
63struct secasvar *key_allocsa(union sockaddr_union *, uint8_t, uint32_t);66struct secasvar *key_allocsa(union sockaddr_union *, uint8_t, uint32_t);
64struct secasvar *key_allocsa_tunnel(union sockaddr_union *,67struct secasvar *key_allocsa_tunnel(union sockaddr_union *,
...@@ -84,6 +87,10 @@ extern void key_sa_recordxfer(struct secasvar *, struct mbuf *);...@@ -84,6 +87,10 @@ extern void key_sa_recordxfer(struct secasvar *, struct mbuf *);
84uint16_t key_portfromsaddr(struct sockaddr *);87uint16_t key_portfromsaddr(struct sockaddr *);
85void key_porttosaddr(struct sockaddr *, uint16_t port);88void 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
87#ifdef MALLOC_DECLARE94#ifdef MALLOC_DECLARE
88MALLOC_DECLARE(M_IPSEC_SA);95MALLOC_DECLARE(M_IPSEC_SA);
89MALLOC_DECLARE(M_IPSEC_SAH);96MALLOC_DECLARE(M_IPSEC_SAH);
lib/libc/include/generic-freebsd/netipsec/keydb.h+14
...@@ -36,9 +36,11 @@...@@ -36,9 +36,11 @@
3636
37#ifdef _KERNEL37#ifdef _KERNEL
38#include <sys/counter.h>38#include <sys/counter.h>
39#include <sys/ck.h>
39#include <sys/lock.h>40#include <sys/lock.h>
40#include <sys/mutex.h>41#include <sys/mutex.h>
41#include <sys/rmlock.h>42#include <sys/rmlock.h>
43#include <sys/_task.h>
4244
43#include <netipsec/key_var.h>45#include <netipsec/key_var.h>
44#include <opencrypto/_cryptodev.h>46#include <opencrypto/_cryptodev.h>
...@@ -125,6 +127,7 @@ struct xformsw;...@@ -125,6 +127,7 @@ struct xformsw;
125struct enc_xform;127struct enc_xform;
126struct auth_hash;128struct auth_hash;
127struct comp_algo;129struct comp_algo;
130struct ifp_handle_sav;
128131
129/*132/*
130 * Security Association133 * Security Association
...@@ -185,8 +188,19 @@ struct secasvar {...@@ -185,8 +188,19 @@ struct secasvar {
185188
186 uint64_t cntr; /* counter for GCM and CTR */189 uint64_t cntr; /* counter for GCM and CTR */
187 volatile u_int refcnt; /* reference count */190 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;
188};199};
189200
201#define SADB_KEY_ACCEL_INST 0x00000001
202#define SADB_KEY_ACCEL_DEINST 0x00000002
203
190#define SECASVAR_RLOCK_TRACKER struct rm_priotracker _secas_tracker204#define SECASVAR_RLOCK_TRACKER struct rm_priotracker _secas_tracker
191#define SECASVAR_RLOCK(_sav) rm_rlock((_sav)->lock, &_secas_tracker)205#define SECASVAR_RLOCK(_sav) rm_rlock((_sav)->lock, &_secas_tracker)
192#define SECASVAR_RUNLOCK(_sav) rm_runlock((_sav)->lock, &_secas_tracker)206#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 @@...@@ -30,28 +30,14 @@
3030
31#if defined(_KERNEL) && defined(INVARIANTS)31#if defined(_KERNEL) && defined(INVARIANTS)
3232
33bool nlmsg_get_buf_type_wrapper(struct nl_writer *nw, int size, int type, bool waitok);33bool nlmsg_get_buf_wrapper(struct nl_writer *nw, size_t size, bool waitok);
34void nlmsg_set_callback_wrapper(struct nl_writer *nw);
35struct mbuf *nl_get_mbuf_chain_wrapper(int len, int malloc_flags);
3634
37#ifndef KTEST_CALLER35#ifndef KTEST_CALLER
3836
39bool37bool
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)
41{39{
42 return (nlmsg_get_buf_type(nw, size, type, waitok));40 return (nlmsg_get_buf(nw, size, 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));
55}41}
56#endif42#endif
5743
lib/libc/include/generic-freebsd/netlink/netlink.h+11-15
...@@ -61,7 +61,7 @@...@@ -61,7 +61,7 @@
61#ifndef _NETLINK_NETLINK_H_61#ifndef _NETLINK_NETLINK_H_
62#define _NETLINK_NETLINK_H_62#define _NETLINK_NETLINK_H_
6363
64#include <sys/types.h>64#include <sys/param.h>
65#include <sys/socket.h>65#include <sys/socket.h>
6666
67struct sockaddr_nl {67struct sockaddr_nl {
...@@ -194,11 +194,8 @@ enum nlmsginfo_attrs {...@@ -194,11 +194,8 @@ enum nlmsginfo_attrs {
194};194};
195195
196196
197#ifndef roundup2
198#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
199#endif
200#define NL_ITEM_ALIGN_SIZE sizeof(uint32_t)197#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)
202#define NL_ITEM_DATA(_ptr, _off) ((void *)((char *)(_ptr) + _off))199#define NL_ITEM_DATA(_ptr, _off) ((void *)((char *)(_ptr) + _off))
203#define NL_ITEM_DATA_CONST(_ptr, _off) ((const void *)((const char *)(_ptr) + _off))200#define NL_ITEM_DATA_CONST(_ptr, _off) ((const void *)((const char *)(_ptr) + _off))
204201
...@@ -208,25 +205,24 @@ enum nlmsginfo_attrs {...@@ -208,25 +205,24 @@ enum nlmsginfo_attrs {
208#define NL_ITEM_ITER(_ptr, _len, _LEN_MACRO) \205#define NL_ITEM_ITER(_ptr, _len, _LEN_MACRO) \
209 ((_len) -= _LEN_MACRO(_ptr), NL_ITEM_NEXT(_ptr, _LEN_MACRO))206 ((_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
212#ifndef _KERNEL212#ifndef _KERNEL
213/* part of netlink(3) API */213/* part of netlink(3) API */
214#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE214#define NLMSG_HDRLEN (sizeof(struct nlmsghdr))
215#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len)215#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN)
216#define NLMSG_HDRLEN ((int)sizeof(struct nlmsghdr))216#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len))
217#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN)217#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN)
218#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len))218#define _NLMSG_LEN(_hdr) ((_hdr)->nlmsg_len)
219#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN)
220#define _NLMSG_LEN(_hdr) ((int)(_hdr)->nlmsg_len)
221#define _NLMSG_ALIGNED_LEN(_hdr) NLMSG_ALIGN(_NLMSG_LEN(_hdr))219#define _NLMSG_ALIGNED_LEN(_hdr) NLMSG_ALIGN(_NLMSG_LEN(_hdr))
222#define NLMSG_OK(_hdr, _len) NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)220#define NLMSG_OK(_hdr, _len) NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN)
223#define NLMSG_PAYLOAD(_hdr,_len) (_NLMSG_LEN(_hdr) - NLMSG_SPACE((_len)))221#define NLMSG_PAYLOAD(_hdr,_len) (_NLMSG_LEN(_hdr) - NLMSG_SPACE((_len)))
224#define NLMSG_NEXT(_hdr, _len) NL_ITEM_ITER(_hdr, _len, _NLMSG_ALIGNED_LEN)222#define NLMSG_NEXT(_hdr, _len) NL_ITEM_ITER(_hdr, _len, _NLMSG_ALIGNED_LEN)
225223
226#else224#else
227#define NLMSG_ALIGNTO 4U225#define NLMSG_HDRLEN (NLMSG_ALIGN(sizeof(struct nlmsghdr)))
228#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
229#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr)))
230#endif226#endif
231227
232/*228/*
lib/libc/include/generic-freebsd/netlink/netlink_ctl.h+11-16
...@@ -47,8 +47,8 @@ MALLOC_DECLARE(M_NETLINK);...@@ -47,8 +47,8 @@ MALLOC_DECLARE(M_NETLINK);
4747
48#define NLA_ALIGN_SIZE sizeof(uint32_t)48#define NLA_ALIGN_SIZE sizeof(uint32_t)
49#define NLA_ALIGN(_len) _roundup2(_len, NLA_ALIGN_SIZE)49#define NLA_ALIGN(_len) _roundup2(_len, NLA_ALIGN_SIZE)
50#define NLA_HDRLEN ((int)sizeof(struct nlattr))50#define NLA_HDRLEN ((uint16_t)sizeof(struct nlattr))
51#define NLA_DATA_LEN(_nla) ((int)((_nla)->nla_len - NLA_HDRLEN))51#define NLA_DATA_LEN(_nla) ((_nla)->nla_len - NLA_HDRLEN)
52#define NLA_DATA(_nla) NL_ITEM_DATA(_nla, NLA_HDRLEN)52#define NLA_DATA(_nla) NL_ITEM_DATA(_nla, NLA_HDRLEN)
53#define NLA_DATA_CONST(_nla) NL_ITEM_DATA_CONST(_nla, NLA_HDRLEN)53#define NLA_DATA_CONST(_nla) NL_ITEM_DATA_CONST(_nla, NLA_HDRLEN)
54#define NLA_TYPE(_nla) ((_nla)->nla_type & 0x3FFF)54#define NLA_TYPE(_nla) ((_nla)->nla_type & 0x3FFF)
...@@ -65,8 +65,6 @@ MALLOC_DECLARE(M_NETLINK);...@@ -65,8 +65,6 @@ MALLOC_DECLARE(M_NETLINK);
65 ((char *)NLA_NEXT(_attr) <= (char *)_end); \65 ((char *)NLA_NEXT(_attr) <= (char *)_end); \
66 _attr = (_len -= NLA_ALIGN(_attr->nla_len), NLA_NEXT(_attr)))66 _attr = (_len -= NLA_ALIGN(_attr->nla_len), NLA_NEXT(_attr)))
6767
68#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0]))
69
70#include <netlink/netlink_message_writer.h>68#include <netlink/netlink_message_writer.h>
71#include <netlink/netlink_message_parser.h>69#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...@@ -79,7 +77,6 @@ bool netlink_register_proto(int proto, const char *proto_name, nl_handler_f hand
79bool netlink_unregister_proto(int proto);77bool netlink_unregister_proto(int proto);
8078
81/* Common helpers */79/* Common helpers */
82bool nl_has_listeners(int netlink_family, uint32_t groups_mask);
83bool nlp_has_priv(struct nlpcb *nlp, int priv);80bool nlp_has_priv(struct nlpcb *nlp, int priv);
84struct ucred *nlp_get_cred(struct nlpcb *nlp);81struct ucred *nlp_get_cred(struct nlpcb *nlp);
85uint32_t nlp_get_pid(const struct nlpcb *nlp);82uint32_t nlp_get_pid(const struct nlpcb *nlp);
...@@ -94,18 +91,16 @@ struct genl_cmd {...@@ -94,18 +91,16 @@ struct genl_cmd {
94 uint32_t cmd_num;91 uint32_t cmd_num;
95};92};
9693
97uint32_t genl_register_family(const char *family_name, size_t hdrsize,94uint16_t genl_register_family(const char *family_name, size_t hdrsize,
98 int family_version, int max_attr_idx);95 uint16_t family_version, uint16_t max_attr_idx);
99bool genl_unregister_family(const char *family_name);96void genl_unregister_family(uint16_t family);
100bool genl_register_cmds(const char *family_name, const struct genl_cmd *cmds,97bool genl_register_cmds(uint16_t family, const struct genl_cmd *cmds,
101 int count);98 u_int count);
102uint32_t genl_register_group(const char *family_name, const char *group_name);99uint32_t genl_register_group(uint16_t family, const char *group_name);
103100void genl_unregister_group(uint16_t family, uint32_t group);
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);
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);
109EVENTHANDLER_DECLARE(genl_family_event, genl_family_event_handler_t);104EVENTHANDLER_DECLARE(genl_family_event, genl_family_event_handler_t);
110105
111struct thread;106struct thread;
lib/libc/include/generic-freebsd/netlink/netlink_linux.h+5-6
...@@ -27,6 +27,7 @@...@@ -27,6 +27,7 @@
2727
28#ifndef _NETLINK_LINUX_VAR_H_28#ifndef _NETLINK_LINUX_VAR_H_
29#define _NETLINK_LINUX_VAR_H_29#define _NETLINK_LINUX_VAR_H_
30#ifdef _KERNEL
3031
31/*32/*
32 * The file contains headers for the bridge interface between33 * The file contains headers for the bridge interface between
...@@ -34,16 +35,13 @@...@@ -34,16 +35,13 @@
34 */35 */
35struct nlpcb;36struct nlpcb;
36struct nl_pstate;37struct nl_pstate;
38struct nl_writer;
3739
38typedef struct mbuf *mbufs_to_linux_cb_t(int netlink_family, struct mbuf *m,40typedef struct nl_buf * msgs_to_linux_cb_t(struct nl_buf *, struct nlpcb *);
39 struct nlpcb *nlp);41typedef int msg_from_linux_cb_t(int netlink_family, struct nlmsghdr **hdr,
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,
43 struct nl_pstate *npt);42 struct nl_pstate *npt);
4443
45struct linux_netlink_provider {44struct linux_netlink_provider {
46 mbufs_to_linux_cb_t *mbufs_to_linux;
47 msgs_to_linux_cb_t *msgs_to_linux;45 msgs_to_linux_cb_t *msgs_to_linux;
48 msg_from_linux_cb_t *msg_from_linux;46 msg_from_linux_cb_t *msg_from_linux;
4947
...@@ -51,4 +49,5 @@ struct linux_netlink_provider {...@@ -51,4 +49,5 @@ struct linux_netlink_provider {
5149
52extern struct linux_netlink_provider *linux_netlink_p;50extern struct linux_netlink_provider *linux_netlink_p;
5351
52#endif
54#endif53#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)...@@ -64,15 +64,15 @@ lb_clear(struct linear_buffer *lb)
64#define NL_MAX_ERROR_BUF 12864#define NL_MAX_ERROR_BUF 128
65#define SCRATCH_BUFFER_SIZE (1024 + NL_MAX_ERROR_BUF)65#define SCRATCH_BUFFER_SIZE (1024 + NL_MAX_ERROR_BUF)
66struct nl_pstate {66struct nl_pstate {
67 struct linear_buffer lb; /* Per-message scratch buffer */67 struct linear_buffer lb; /* Per-message scratch buffer */
68 struct nlpcb *nlp; /* Originator socket */68 struct nlpcb *nlp; /* Originator socket */
69 struct nl_writer *nw; /* Message writer to use */69 struct nl_writer *nw; /* Message writer to use */
70 struct nlmsghdr *hdr; /* Current parsed message header */70 struct nlmsghdr *hdr; /* Current parsed message header */
71 uint32_t err_off; /* error offset from hdr start */71 uint32_t err_off; /* error offset from hdr start */
72 int error; /* last operation error */72 int error; /* last operation error */
73 char *err_msg; /* Description of last error */73 char *err_msg; /* Description of last error */
74 struct nlattr *cookie; /* NLA to return to the userspace */74 struct nlattr *cookie; /* NLA to return to the userspace */
75 bool strict; /* Strict parsing required */75 bool strict; /* Strict parsing required */
76};76};
7777
78static inline void *78static inline void *
...@@ -80,10 +80,10 @@ npt_alloc(struct nl_pstate *npt, int len)...@@ -80,10 +80,10 @@ npt_alloc(struct nl_pstate *npt, int len)
80{80{
81 return (lb_alloc(&npt->lb, len));81 return (lb_alloc(&npt->lb, len));
82}82}
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,86typedef int parse_field_f(void *hdr, struct nl_pstate *npt, void *target);
86 void *target);
87struct nlfield_parser {87struct nlfield_parser {
88 uint16_t off_in;88 uint16_t off_in;
89 uint16_t off_out;89 uint16_t off_out;
...@@ -98,29 +98,28 @@ int nlf_get_u16(void *src, struct nl_pstate *npt, void *target);...@@ -98,29 +98,28 @@ int nlf_get_u16(void *src, struct nl_pstate *npt, void *target);
98int nlf_get_u32(void *src, struct nl_pstate *npt, void *target);98int nlf_get_u32(void *src, struct nl_pstate *npt, void *target);
99int nlf_get_u8_u32(void *src, struct nl_pstate *npt, void *target);99int nlf_get_u8_u32(void *src, struct nl_pstate *npt, void *target);
100100
101
102struct nlattr_parser;101struct nlattr_parser;
103typedef int parse_attr_f(struct nlattr *attr, struct nl_pstate *npt,102typedef int parse_attr_f(struct nlattr *attr, struct nl_pstate *npt,
104 const void *arg, void *target);103 const void *arg, void *target);
105struct nlattr_parser {104struct nlattr_parser {
106 uint16_t type; /* Attribute type */105 uint16_t type; /* Attribute type */
107 uint16_t off; /* field offset in the target structure */106 uint16_t off; /* field offset in the target structure */
108 parse_attr_f *cb; /* parser function to call */107 parse_attr_f *cb; /* parser function to call */
109 const void *arg;108 const void *arg;
110};109};
111110
112typedef bool strict_parser_f(void *hdr, struct nl_pstate *npt);111typedef bool strict_parser_f(void *hdr, struct nl_pstate *npt);
113typedef bool post_parser_f(void *parsed_attrs, struct nl_pstate *npt);112typedef bool post_parser_f(void *parsed_attrs, struct nl_pstate *npt);
114113
115struct nlhdr_parser {114struct nlhdr_parser {
116 int nl_hdr_off; /* aligned netlink header size */115 u_int nl_hdr_off; /* aligned netlink header size */
117 int out_hdr_off; /* target header size */116 u_int out_hdr_off; /* target header size */
118 int fp_size;117 u_int fp_size;
119 int np_size;118 u_int np_size;
120 const struct nlfield_parser *fp; /* array of header field parsers */119 const struct nlfield_parser *fp; /* array of header field parsers */
121 const struct nlattr_parser *np; /* array of attribute parsers */120 const struct nlattr_parser *np; /* array of attribute parsers */
122 strict_parser_f *sp; /* Pre-parse strict validation function */121 strict_parser_f *sp; /* Pre-parse strict validation function */
123 post_parser_f *post_parse;122 post_parser_f *post_parse;
124};123};
125124
126#define NL_DECLARE_PARSER_EXT(_name, _t, _sp, _fp, _np, _pp) \125#define NL_DECLARE_PARSER_EXT(_name, _t, _sp, _fp, _np, _pp) \
...@@ -128,8 +127,8 @@ static const struct nlhdr_parser _name = { \...@@ -128,8 +127,8 @@ static const struct nlhdr_parser _name = { \
128 .nl_hdr_off = sizeof(_t), \127 .nl_hdr_off = sizeof(_t), \
129 .fp = &((_fp)[0]), \128 .fp = &((_fp)[0]), \
130 .np = &((_np)[0]), \129 .np = &((_np)[0]), \
131 .fp_size = NL_ARRAY_LEN(_fp), \130 .fp_size = nitems(_fp), \
132 .np_size = NL_ARRAY_LEN(_np), \131 .np_size = nitems(_np), \
133 .sp = _sp, \132 .sp = _sp, \
134 .post_parse = _pp, \133 .post_parse = _pp, \
135}134}
...@@ -146,29 +145,37 @@ static const struct nlhdr_parser _name = { \...@@ -146,29 +145,37 @@ static const struct nlhdr_parser _name = { \
146 .out_hdr_off = sizeof(_o), \145 .out_hdr_off = sizeof(_o), \
147 .fp = &((_fp)[0]), \146 .fp = &((_fp)[0]), \
148 .np = &((_np)[0]), \147 .np = &((_np)[0]), \
149 .fp_size = NL_ARRAY_LEN(_fp), \148 .fp_size = nitems(_fp), \
150 .np_size = NL_ARRAY_LEN(_np), \149 .np_size = nitems(_np), \
151}150}
152151
153#define NL_DECLARE_ATTR_PARSER(_name, _np) \152#define NL_DECLARE_ATTR_PARSER_EXT(_name, _np, _pp) \
154static const struct nlhdr_parser _name = { \153static const struct nlhdr_parser _name = { \
155 .np = &((_np)[0]), \154 .np = &((_np)[0]), \
156 .np_size = NL_ARRAY_LEN(_np), \155 .np_size = nitems(_np), \
156 .post_parse = (_pp) \
157}157}
158158
159#define NL_DECLARE_ATTR_PARSER(_name, _np) \
160 NL_DECLARE_ATTR_PARSER_EXT(_name, _np, NULL)
161
159#define NL_ATTR_BMASK_SIZE 128162#define NL_ATTR_BMASK_SIZE 128
160BITSET_DEFINE(nlattr_bmask, NL_ATTR_BMASK_SIZE);163BITSET_DEFINE(nlattr_bmask, NL_ATTR_BMASK_SIZE);
161164
162void nl_get_attrs_bmask_raw(struct nlattr *nla_head, int len, struct nlattr_bmask *bm);165void nl_get_attrs_bmask_raw(struct nlattr *nla_head, uint32_t len,
163bool nl_has_attr(const struct nlattr_bmask *bm, unsigned int nla_type);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,169int nl_parse_attrs_raw(struct nlattr *nla_head, uint16_t len,
166 int pslen, struct nl_pstate *npt, void *target);170 const struct nlattr_parser *ps, u_int pslen, struct nl_pstate *npt,
171 void *target);
167172
168int nlattr_get_flag(struct nlattr *nla, struct nl_pstate *npt,173int nlattr_get_flag(struct nlattr *nla, struct nl_pstate *npt,
169 const void *arg, void *target);174 const void *arg, void *target);
170int nlattr_get_ip(struct nlattr *nla, struct nl_pstate *npt,175int nlattr_get_ip(struct nlattr *nla, struct nl_pstate *npt,
171 const void *arg, void *target);176 const void *arg, void *target);
177int nlattr_get_bool(struct nlattr *nla, struct nl_pstate *npt,
178 const void *arg, void *target);
172int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt,179int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt,
173 const void *arg, void *target);180 const void *arg, void *target);
174int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt,181int 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,...@@ -187,16 +194,23 @@ int nlattr_get_ifpz(struct nlattr *nla, struct nl_pstate *npt,
187 const void *arg, void *target);194 const void *arg, void *target);
188int nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt,195int nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt,
189 const void *arg, void *target);196 const void *arg, void *target);
197int nlattr_get_chara(struct nlattr *nla, struct nl_pstate *npt,
198 const void *arg, void *target);
190int nlattr_get_string(struct nlattr *nla, struct nl_pstate *npt,199int nlattr_get_string(struct nlattr *nla, struct nl_pstate *npt,
191 const void *arg, void *target);200 const void *arg, void *target);
192int nlattr_get_stringn(struct nlattr *nla, struct nl_pstate *npt,201int nlattr_get_stringn(struct nlattr *nla, struct nl_pstate *npt,
193 const void *arg, void *target);202 const void *arg, void *target);
203int nlattr_get_bytes(struct nlattr *nla, struct nl_pstate *npt,
204 const void *arg, void *target);
194int nlattr_get_nla(struct nlattr *nla, struct nl_pstate *npt,205int nlattr_get_nla(struct nlattr *nla, struct nl_pstate *npt,
195 const void *arg, void *target);206 const void *arg, void *target);
196int nlattr_get_nested(struct nlattr *nla, struct nl_pstate *npt,207int nlattr_get_nested(struct nlattr *nla, struct nl_pstate *npt,
197 const void *arg, void *target);208 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
201#define NLMSG_REPORT_ERR_MSG(_npt, _fmt, ...) { \215#define NLMSG_REPORT_ERR_MSG(_npt, _fmt, ...) { \
202 nlmsg_report_err_msg(_npt, _fmt, ## __VA_ARGS__); \216 nlmsg_report_err_msg(_npt, _fmt, ## __VA_ARGS__); \
...@@ -213,20 +227,26 @@ void nlmsg_report_cookie_u32(struct nl_pstate *npt, uint32_t val);...@@ -213,20 +227,26 @@ void nlmsg_report_cookie_u32(struct nl_pstate *npt, uint32_t val);
213 * the list of direct function calls without iteration.227 * the list of direct function calls without iteration.
214 */228 */
215static inline int229static 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,
217 struct nl_pstate *npt, void *target)231 struct nl_pstate *npt, void *target)
218{232{
219 int error;233 int error;
220234
221 if (__predict_false(len < parser->nl_hdr_off)) {235 if (__predict_false(len < parser->nl_hdr_off)) {
236 void *tmp_hdr;
237
222 if (npt->strict) {238 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",
224 parser->nl_hdr_off, len);241 parser->nl_hdr_off, len);
225 return (EINVAL);242 return (EINVAL);
226 }243 }
227244
228 /* Compat with older applications: pretend there's a full header */245 /*
229 void *tmp_hdr = npt_alloc(npt, parser->nl_hdr_off);246 * Compatibility with older applications:
247 * pretend there's a full header.
248 */
249 tmp_hdr = npt_alloc(npt, parser->nl_hdr_off);
230 if (tmp_hdr == NULL)250 if (tmp_hdr == NULL)
231 return (EINVAL);251 return (EINVAL);
232 memcpy(tmp_hdr, hdr, len);252 memcpy(tmp_hdr, hdr, len);
...@@ -238,7 +258,7 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,...@@ -238,7 +258,7 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,
238 return (EINVAL);258 return (EINVAL);
239259
240 /* Extract fields first */260 /* Extract fields first */
241 for (int i = 0; i < parser->fp_size; i++) {261 for (u_int i = 0; i < parser->fp_size; i++) {
242 const struct nlfield_parser *fp = &parser->fp[i];262 const struct nlfield_parser *fp = &parser->fp[i];
243 void *src = (char *)hdr + fp->off_in;263 void *src = (char *)hdr + fp->off_in;
244 void *dst = (char *)target + fp->off_out;264 void *dst = (char *)target + fp->off_out;
...@@ -248,9 +268,9 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,...@@ -248,9 +268,9 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser,
248 return (error);268 return (error);
249 }269 }
250270
251 struct nlattr *nla_head = (struct nlattr *)((char *)hdr + parser->nl_hdr_off);271 error = nl_parse_attrs_raw(
252 error = nl_parse_attrs_raw(nla_head, len - parser->nl_hdr_off, parser->np,272 (struct nlattr *)((char *)hdr + parser->nl_hdr_off),
253 parser->np_size, npt, target);273 len - parser->nl_hdr_off, parser->np, parser->np_size, npt, target);
254274
255 if (parser->post_parse != NULL && error == 0) {275 if (parser->post_parse != NULL && error == 0) {
256 if (!parser->post_parse(target, npt))276 if (!parser->post_parse(target, npt))
...@@ -264,10 +284,8 @@ static inline int...@@ -264,10 +284,8 @@ static inline int
264nl_parse_nested(struct nlattr *nla, const struct nlhdr_parser *parser,284nl_parse_nested(struct nlattr *nla, const struct nlhdr_parser *parser,
265 struct nl_pstate *npt, void *target)285 struct nl_pstate *npt, void *target)
266{286{
267 struct nlattr *nla_head = (struct nlattr *)NLA_DATA(nla);287 return (nl_parse_attrs_raw((struct nlattr *)NLA_DATA(nla),
268288 NLA_DATA_LEN(nla), parser->np, parser->np_size, npt, target));
269 return (nl_parse_attrs_raw(nla_head, NLA_DATA_LEN(nla), parser->np,
270 parser->np_size, npt, target));
271}289}
272290
273/*291/*
...@@ -283,30 +301,36 @@ nl_verify_parsers(const struct nlhdr_parser **parser, int count)...@@ -283,30 +301,36 @@ nl_verify_parsers(const struct nlhdr_parser **parser, int count)
283 for (int j = 0; j < p->np_size; j++) {301 for (int j = 0; j < p->np_size; j++) {
284 MPASS(p->np[j].type > attr_type);302 MPASS(p->np[j].type > attr_type);
285 attr_type = p->np[j].type;303 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 }
286 }312 }
287 }313 }
288#endif314#endif
289}315}
290void nl_verify_parsers(const struct nlhdr_parser **parser, int count);316void 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
293static inline int319static inline int
294nl_parse_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser,320nl_parse_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser,
295 struct nl_pstate *npt, void *target)321 struct nl_pstate *npt, void *target)
296{322{
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));
298}325}
299326
300static inline void327static inline void
301nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser,328nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr,
302 struct nlattr_bmask *bm)329 const struct nlhdr_parser *parser, struct nlattr_bmask *bm)
303{330{
304 struct nlattr *nla_head;331 nl_get_attrs_bmask_raw(
305332 (struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off),
306 nla_head = (struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off);333 hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off, bm);
307 int len = hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off;
308
309 nl_get_attrs_bmask_raw(nla_head, len, bm);
310}334}
311335
312#endif336#endif
lib/libc/include/generic-freebsd/netlink/netlink_message_writer.h+59-115
...@@ -37,62 +37,45 @@...@@ -37,62 +37,45 @@
37 * It is not meant to be included directly37 * It is not meant to be included directly
38 */38 */
3939
40struct mbuf;40struct nl_buf;
41struct nl_writer;41struct 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
44struct nl_writer {44struct nl_writer {
45 int alloc_len; /* allocated buffer length */45 struct nl_buf *buf; /* Underlying storage pointer */
46 int offset; /* offset from the start of the buffer */46 struct nlmsghdr *hdr; /* Pointer to the currently-filled msg */
47 struct nlmsghdr *hdr; /* Pointer to the currently-filled msg */47 nl_writer_cb *cb; /* Callback to flush data */
48 char *data; /* pointer to the contiguous storage */
49 void *_storage; /* Underlying storage pointer */
50 nl_writer_cb *cb; /* Callback to flush data */
51 union {48 union {
52 void *ptr;49 struct nlpcb *nlp;
53 struct {50 struct {
54 uint16_t proto;51 uint16_t proto;
55 uint16_t id;52 uint16_t id;
53 int priv;
56 } group;54 } group;
57 } arg;55 };
58 int num_messages; /* Number of messages in the buffer */56 u_int num_messages; /* Number of messages in the buffer */
59 int malloc_flag; /* M_WAITOK or M_NOWAIT */57 int malloc_flag; /* M_WAITOK or M_NOWAIT */
60 uint8_t writer_type; /* NS_WRITER_TYPE_* */58 bool ignore_limit; /* If true, ignores RCVBUF limit */
61 uint8_t writer_target; /* NS_WRITER_TARGET_* */59 bool enomem; /* True if ENOMEM occured */
62 bool ignore_limit; /* If true, ignores RCVBUF limit */60 bool suppress_ack; /* If true, don't send NLMSG_ERR */
63 bool enomem; /* True if ENOMEM occured */
64 bool suppress_ack; /* If true, don't send NLMSG_ERR */
65};61};
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
77#define NLMSG_SMALL 12863#define NLMSG_SMALL 128
78#define NLMSG_LARGE 204864#define NLMSG_LARGE 2048
7965
80/* Message and attribute writing */66/* Message and attribute writing */
81
82struct nlpcb;
83
84#if defined(NETLINK) || defined(NETLINK_MODULE)67#if defined(NETLINK) || defined(NETLINK_MODULE)
85/* Provide optimized calls to the functions inside the same linking unit */68/* 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);70bool _nl_writer_unicast(struct nl_writer *, size_t, struct nlpcb *nlp, bool);
88bool _nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id);71bool _nl_writer_group(struct nl_writer *, size_t, uint16_t, uint16_t, int,
89bool _nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm);72 bool);
90bool _nlmsg_flush(struct nl_writer *nw);73bool _nlmsg_flush(struct nl_writer *nw);
91void _nlmsg_ignore_limit(struct nl_writer *nw);74void _nlmsg_ignore_limit(struct nl_writer *nw);
9275
93bool _nlmsg_refill_buffer(struct nl_writer *nw, int required_size);76bool _nlmsg_refill_buffer(struct nl_writer *nw, size_t required_len);
94bool _nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,77bool _nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq,
95 uint16_t flags, uint32_t len);78 uint16_t type, uint16_t flags, uint32_t len);
96bool _nlmsg_end(struct nl_writer *nw);79bool _nlmsg_end(struct nl_writer *nw);
97void _nlmsg_abort(struct nl_writer *nw);80void _nlmsg_abort(struct nl_writer *nw);
9881
...@@ -100,21 +83,17 @@ bool _nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr);...@@ -100,21 +83,17 @@ bool _nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr);
10083
10184
102static inline bool85static inline bool
103nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp)86nl_writer_unicast(struct nl_writer *nw, size_t size, struct nlpcb *nlp,
104{87 bool waitok)
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)
110{88{
111 return (_nlmsg_get_group_writer(nw, expected_size, proto, group_id));89 return (_nl_writer_unicast(nw, size, nlp, waitok));
112}90}
11391
114static inline bool92static 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)
116{95{
117 return (_nlmsg_get_chain_writer(nw, expected_size, pm));96 return (_nl_writer_group(nw, size, proto, group_id, priv, waitok));
118}97}
11998
120static inline bool99static inline bool
...@@ -130,7 +109,7 @@ nlmsg_ignore_limit(struct nl_writer *nw)...@@ -130,7 +109,7 @@ nlmsg_ignore_limit(struct nl_writer *nw)
130}109}
131110
132static inline bool111static inline bool
133nlmsg_refill_buffer(struct nl_writer *nw, int required_size)112nlmsg_refill_buffer(struct nl_writer *nw, size_t required_size)
134{113{
135 return (_nlmsg_refill_buffer(nw, required_size));114 return (_nlmsg_refill_buffer(nw, required_size));
136}115}
...@@ -163,15 +142,15 @@ nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr)...@@ -163,15 +142,15 @@ nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr)
163#else142#else
164/* Provide access to the functions via netlink_glue.c */143/* 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);145bool nl_writer_unicast(struct nl_writer *, size_t, struct nlpcb *, bool waitok);
167bool nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id);146bool nl_writer_group(struct nl_writer *, size_t, uint16_t, uint16_t, int,
168bool nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm);147 bool waitok);
169bool nlmsg_flush(struct nl_writer *nw);148bool nlmsg_flush(struct nl_writer *nw);
170void nlmsg_ignore_limit(struct nl_writer *nw);149void nlmsg_ignore_limit(struct nl_writer *nw);
171150
172bool nlmsg_refill_buffer(struct nl_writer *nw, int required_size);151bool nlmsg_refill_buffer(struct nl_writer *nw, size_t required_size);
173bool nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,152bool nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq,
174 uint16_t flags, uint32_t len);153 uint16_t type, uint16_t flags, uint32_t len);
175bool nlmsg_end(struct nl_writer *nw);154bool nlmsg_end(struct nl_writer *nw);
176void nlmsg_abort(struct nl_writer *nw);155void nlmsg_abort(struct nl_writer *nw);
177156
...@@ -186,18 +165,12 @@ nlmsg_reply(struct nl_writer *nw, const struct nlmsghdr *hdr, int payload_len)...@@ -186,18 +165,12 @@ nlmsg_reply(struct nl_writer *nw, const struct nlmsghdr *hdr, int payload_len)
186 hdr->nlmsg_flags, payload_len));165 hdr->nlmsg_flags, payload_len));
187}166}
188167
189#define nlmsg_data(_hdr) ((void *)((_hdr) + 1))
190
191/*168/*
192 * KPI similar to mtodo():169 * KPI similar to mtodo():
193 * current (uncompleted) header is guaranteed to be contiguous,170 * current (uncompleted) header is guaranteed to be contiguous,
194 * but can be reallocated, thus pointers may need to be readjusted.171 * but can be reallocated, thus pointers may need to be readjusted.
195 */172 */
196static inline int173u_int nlattr_save_offset(const struct nl_writer *nw);
197nlattr_save_offset(const struct nl_writer *nw)
198{
199 return (nw->offset - ((char *)nw->hdr - nw->data));
200}
201174
202static inline void *175static inline void *
203_nlattr_restore_offset(const struct nl_writer *nw, int off)176_nlattr_restore_offset(const struct nl_writer *nw, int off)
...@@ -213,22 +186,7 @@ nlattr_set_len(const struct nl_writer *nw, int off)...@@ -213,22 +186,7 @@ nlattr_set_len(const struct nl_writer *nw, int off)
213 nla->nla_len = nlattr_save_offset(nw) - off;186 nla->nla_len = nlattr_save_offset(nw) - off;
214}187}
215188
216static inline void *189void *nlmsg_reserve_data_raw(struct nl_writer *nw, size_t sz);
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}
232#define nlmsg_reserve_object(_ns, _t) ((_t *)nlmsg_reserve_data_raw(_ns, sizeof(_t)))190#define nlmsg_reserve_object(_ns, _t) ((_t *)nlmsg_reserve_data_raw(_ns, sizeof(_t)))
233#define nlmsg_reserve_data(_ns, _sz, _t) ((_t *)nlmsg_reserve_data_raw(_ns, _sz))191#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)...@@ -258,109 +216,95 @@ _nlmsg_reserve_attr(struct nl_writer *nw, uint16_t nla_type, uint16_t sz)
258}216}
259#define nlmsg_reserve_attr(_ns, _at, _t) ((_t *)_nlmsg_reserve_attr(_ns, _at, NLA_ALIGN(sizeof(_t))))217#define nlmsg_reserve_attr(_ns, _at, _t) ((_t *)_nlmsg_reserve_attr(_ns, _at, NLA_ALIGN(sizeof(_t))))
260218
261static inline bool219bool nlattr_add(struct nl_writer *nw, uint16_t attr_type, uint16_t attr_len,
262nlattr_add(struct nl_writer *nw, int attr_type, int attr_len, const void *data)220 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}
285221
286static inline bool222static inline bool
287nlattr_add_raw(struct nl_writer *nw, const struct nlattr *nla_src)223nlattr_add_raw(struct nl_writer *nw, const struct nlattr *nla_src)
288{224{
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));
294}236}
295237
296static inline bool238static 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)
298{240{
299 return (nlattr_add(nw, attrtype, sizeof(uint8_t), &value));241 return (nlattr_add(nw, attrtype, sizeof(uint8_t), &value));
300}242}
301243
302static inline bool244static 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)
304{246{
305 return (nlattr_add(nw, attrtype, sizeof(uint16_t), &value));247 return (nlattr_add(nw, attrtype, sizeof(uint16_t), &value));
306}248}
307249
308static inline bool250static 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)
310{252{
311 return (nlattr_add(nw, attrtype, sizeof(uint32_t), &value));253 return (nlattr_add(nw, attrtype, sizeof(uint32_t), &value));
312}254}
313255
314static inline bool256static 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)
316{258{
317 return (nlattr_add(nw, attrtype, sizeof(uint64_t), &value));259 return (nlattr_add(nw, attrtype, sizeof(uint64_t), &value));
318}260}
319261
320static inline bool262static 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)
322{264{
323 return (nlattr_add(nw, attrtype, sizeof(int8_t), &value));265 return (nlattr_add(nw, attrtype, sizeof(int8_t), &value));
324}266}
325267
326static inline bool268static 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)
328{270{
329 return (nlattr_add(nw, attrtype, sizeof(int16_t), &value));271 return (nlattr_add(nw, attrtype, sizeof(int16_t), &value));
330}272}
331273
332static inline bool274static 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)
334{276{
335 return (nlattr_add(nw, attrtype, sizeof(int32_t), &value));277 return (nlattr_add(nw, attrtype, sizeof(int32_t), &value));
336}278}
337279
338static inline bool280static 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)
340{282{
341 return (nlattr_add(nw, attrtype, sizeof(int64_t), &value));283 return (nlattr_add(nw, attrtype, sizeof(int64_t), &value));
342}284}
343285
344static inline bool286static inline bool
345nlattr_add_flag(struct nl_writer *nw, int attrtype)287nlattr_add_flag(struct nl_writer *nw, uint16_t attrtype)
346{288{
347 return (nlattr_add(nw, attrtype, 0, NULL));289 return (nlattr_add(nw, attrtype, 0, NULL));
348}290}
349291
350static inline bool292static 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)
352{294{
353 return (nlattr_add(nw, attrtype, strlen(str) + 1, str));295 return (nlattr_add(nw, attrtype, strlen(str) + 1, str));
354}296}
355297
356static inline bool298static 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)
358{301{
359 return (nlattr_add(nw, attrtype, sizeof(*in), in));302 return (nlattr_add(nw, attrtype, sizeof(*in), in));
360}303}
361304
362static inline bool305static 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)
364{308{
365 return (nlattr_add(nw, attrtype, sizeof(*in6), in6));309 return (nlattr_add(nw, attrtype, sizeof(*in6), in6));
366}310}
lib/libc/include/generic-freebsd/netlink/netlink_snl.h+70-31
...@@ -31,6 +31,12 @@...@@ -31,6 +31,12 @@
31 * Simple Netlink Library31 * Simple Netlink Library
32 */32 */
3333
34#include <sys/param.h>
35#include <sys/socket.h>
36
37#include <netlink/netlink.h>
38#include <netlink/netlink_bitset.h>
39
34#include <assert.h>40#include <assert.h>
35#include <errno.h>41#include <errno.h>
36#include <stdalign.h>42#include <stdalign.h>
...@@ -41,11 +47,6 @@...@@ -41,11 +47,6 @@
41#include <string.h>47#include <string.h>
42#include <unistd.h>48#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
49#define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1)))50#define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1)))
5051
51#define NETLINK_ALIGN_SIZE sizeof(uint32_t)52#define NETLINK_ALIGN_SIZE sizeof(uint32_t)
...@@ -68,8 +69,6 @@...@@ -68,8 +69,6 @@
68 ((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len)); \69 ((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len)); \
69 _attr = NLA_NEXT(_attr))70 _attr = NLA_NEXT(_attr))
7071
71#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0]))
72
73struct linear_buffer {72struct linear_buffer {
74 char *base; /* Base allocated memory pointer */73 char *base; /* Base allocated memory pointer */
75 uint32_t offset; /* Currently used offset */74 uint32_t offset; /* Currently used offset */
...@@ -133,6 +132,7 @@ struct snl_field_parser {...@@ -133,6 +132,7 @@ struct snl_field_parser {
133 uint16_t off_out;132 uint16_t off_out;
134 snl_parse_field_f *cb;133 snl_parse_field_f *cb;
135};134};
135static const struct snl_field_parser snl_f_p_empty[] = {};
136136
137typedef bool snl_parse_attr_f(struct snl_state *ss, struct nlattr *attr,137typedef bool snl_parse_attr_f(struct snl_state *ss, struct nlattr *attr,
138 const void *arg, void *target);138 const void *arg, void *target);
...@@ -166,8 +166,8 @@ static const struct snl_hdr_parser _name = { \...@@ -166,8 +166,8 @@ static const struct snl_hdr_parser _name = { \
166 .out_size = _sz_out, \166 .out_size = _sz_out, \
167 .fp = &((_fp)[0]), \167 .fp = &((_fp)[0]), \
168 .np = &((_np)[0]), \168 .np = &((_np)[0]), \
169 .fp_size = NL_ARRAY_LEN(_fp), \169 .fp_size = nitems(_fp), \
170 .np_size = NL_ARRAY_LEN(_np), \170 .np_size = nitems(_np), \
171 .cb_post = _cb, \171 .cb_post = _cb, \
172}172}
173173
...@@ -179,7 +179,7 @@ static const struct snl_hdr_parser _name = { \...@@ -179,7 +179,7 @@ static const struct snl_hdr_parser _name = { \
179 .in_hdr_size = _sz_h_in, \179 .in_hdr_size = _sz_h_in, \
180 .out_size = _sz_out, \180 .out_size = _sz_out, \
181 .fp = &((_fp)[0]), \181 .fp = &((_fp)[0]), \
182 .fp_size = NL_ARRAY_LEN(_fp), \182 .fp_size = nitems(_fp), \
183 .cb_post = _cb, \183 .cb_post = _cb, \
184}184}
185185
...@@ -190,7 +190,7 @@ static const struct snl_hdr_parser _name = { \...@@ -190,7 +190,7 @@ static const struct snl_hdr_parser _name = { \
190static const struct snl_hdr_parser _name = { \190static const struct snl_hdr_parser _name = { \
191 .out_size = _sz_out, \191 .out_size = _sz_out, \
192 .np = &((_np)[0]), \192 .np = &((_np)[0]), \
193 .np_size = NL_ARRAY_LEN(_np), \193 .np_size = nitems(_np), \
194 .cb_post = _cb, \194 .cb_post = _cb, \
195}195}
196196
...@@ -240,14 +240,13 @@ snl_clear_lb(struct snl_state *ss)...@@ -240,14 +240,13 @@ snl_clear_lb(struct snl_state *ss)
240static void240static void
241snl_free(struct snl_state *ss)241snl_free(struct snl_state *ss)
242{242{
243 if (ss->init_done) {243 if (ss->init_done)
244 close(ss->fd);244 close(ss->fd);
245 if (ss->buf != NULL)245 if (ss->buf != NULL)
246 free(ss->buf);246 free(ss->buf);
247 if (ss->lb != NULL) {247 if (ss->lb != NULL) {
248 snl_clear_lb(ss);248 snl_clear_lb(ss);
249 lb_free(ss->lb);249 lb_free(ss->lb);
250 }
251 }250 }
252}251}
253252
...@@ -290,6 +289,16 @@ snl_init(struct snl_state *ss, int netlink_family)...@@ -290,6 +289,16 @@ snl_init(struct snl_state *ss, int netlink_family)
290 return (true);289 return (true);
291}290}
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
293static inline bool302static inline bool
294snl_send(struct snl_state *ss, void *data, int sz)303snl_send(struct snl_state *ss, void *data, int sz)
295{304{
...@@ -418,7 +427,7 @@ snl_verify_parsers(const struct snl_hdr_parser **parser, int count)...@@ -418,7 +427,7 @@ snl_verify_parsers(const struct snl_hdr_parser **parser, int count)
418 }427 }
419 }428 }
420}429}
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
423static const struct snl_attr_parser *432static const struct snl_attr_parser *
424find_parser(const struct snl_attr_parser *ps, int pslen, int key)433find_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...@@ -526,6 +535,29 @@ snl_attr_get_flag(struct snl_state *ss __unused, struct nlattr *nla, const void
526 return (false);535 return (false);
527}536}
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
529static inline bool561static inline bool
530snl_attr_get_uint8(struct snl_state *ss __unused, struct nlattr *nla,562snl_attr_get_uint8(struct snl_state *ss __unused, struct nlattr *nla,
531 const void *arg __unused, void *target)563 const void *arg __unused, void *target)
...@@ -1086,20 +1118,22 @@ snl_reserve_msg_data_raw(struct snl_writer *nw, size_t sz)...@@ -1086,20 +1118,22 @@ snl_reserve_msg_data_raw(struct snl_writer *nw, size_t sz)
1086#define snl_reserve_msg_object(_ns, _t) ((_t *)snl_reserve_msg_data_raw(_ns, sizeof(_t)))1118#define snl_reserve_msg_object(_ns, _t) ((_t *)snl_reserve_msg_data_raw(_ns, sizeof(_t)))
1087#define snl_reserve_msg_data(_ns, _sz, _t) ((_t *)snl_reserve_msg_data_raw(_ns, _sz))1119#define snl_reserve_msg_data(_ns, _sz, _t) ((_t *)snl_reserve_msg_data_raw(_ns, _sz))
10881120
1089static inline void *1121static inline struct nlattr *
1090_snl_reserve_msg_attr(struct snl_writer *nw, uint16_t nla_type, uint16_t sz)1122snl_reserve_msg_attr_raw(struct snl_writer *nw, uint16_t nla_type, uint16_t sz)
1091{1123{
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);
1095 if (__predict_false(nla == NULL))1128 if (__predict_false(nla == NULL))
1096 return (NULL);1129 return (NULL);
1097 nla->nla_type = nla_type;1130 nla->nla_type = nla_type;
1098 nla->nla_len = sz;1131 nla->nla_len = sz;
10991132
1100 return ((void *)(nla + 1));1133 return (nla);
1101}1134}
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
1104static inline bool1138static inline bool
1105snl_add_msg_attr(struct snl_writer *nw, int attr_type, int attr_len, const void *data)1139snl_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)...@@ -1136,6 +1170,12 @@ snl_add_msg_attr_raw(struct snl_writer *nw, const struct nlattr *nla_src)
1136 return (snl_add_msg_attr(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1)));1170 return (snl_add_msg_attr(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1)));
1137}1171}
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
1139static inline bool1179static inline bool
1140snl_add_msg_attr_u8(struct snl_writer *nw, int attrtype, uint8_t value)1180snl_add_msg_attr_u8(struct snl_writer *nw, int attrtype, uint8_t value)
1141{1181{
...@@ -1233,9 +1273,13 @@ snl_end_attr_nested(const struct snl_writer *nw, int off)...@@ -1233,9 +1273,13 @@ snl_end_attr_nested(const struct snl_writer *nw, int off)
1233static inline struct nlmsghdr *1273static inline struct nlmsghdr *
1234snl_create_msg_request(struct snl_writer *nw, int nlmsg_type)1274snl_create_msg_request(struct snl_writer *nw, int nlmsg_type)
1235{1275{
1276 struct nlmsghdr *hdr;
1277
1236 assert(nw->hdr == NULL);1278 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);
1239 hdr->nlmsg_type = nlmsg_type;1283 hdr->nlmsg_type = nlmsg_type;
1240 hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;1284 hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
1241 nw->hdr = hdr;1285 nw->hdr = hdr;
...@@ -1283,9 +1327,4 @@ snl_send_msgs(struct snl_writer *nw)...@@ -1283,9 +1327,4 @@ snl_send_msgs(struct snl_writer *nw)
1283 return (snl_send(nw->ss, nw->base, offset));1327 return (snl_send(nw->ss, nw->base, offset));
1284}1328}
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
1291#endif1330#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netlink/netlink_snl_generic.h+64-23
...@@ -33,16 +33,24 @@...@@ -33,16 +33,24 @@
3333
34/* Genetlink helpers */34/* Genetlink helpers */
35static inline struct nlmsghdr *35static 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)
37{38{
39 struct nlmsghdr *hdr;
40 struct genlmsghdr *ghdr;
41
38 assert(nw->hdr == NULL);42 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);
41 hdr->nlmsg_type = genl_family;47 hdr->nlmsg_type = genl_family;
42 hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;48 hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
43 nw->hdr = hdr;49 ghdr = snl_reserve_msg_object(nw, struct genlmsghdr);
44 struct genlmsghdr *ghdr = snl_reserve_msg_object(nw, struct genlmsghdr);50 if (__predict_false(ghdr == NULL))
51 return (NULL);
45 ghdr->cmd = genl_cmd;52 ghdr->cmd = genl_cmd;
53 nw->hdr = hdr;
4654
47 return (hdr);55 return (hdr);
48}56}
...@@ -52,37 +60,52 @@ static struct snl_field_parser snl_fp_genl[] = {};...@@ -52,37 +60,52 @@ static struct snl_field_parser snl_fp_genl[] = {};
52#define SNL_DECLARE_GENL_PARSER(_name, _np) SNL_DECLARE_PARSER(_name,\60#define SNL_DECLARE_GENL_PARSER(_name, _np) SNL_DECLARE_PARSER(_name,\
53 struct genlmsghdr, snl_fp_genl, _np)61 struct genlmsghdr, snl_fp_genl, _np)
5462
55struct snl_genl_ctrl_mcast_group {63struct _snl_genl_ctrl_mcast_group {
56 uint32_t mcast_grp_id;64 uint32_t mcast_grp_id;
57 char *mcast_grp_name;65 const char *mcast_grp_name;
58};66};
5967
60struct snl_genl_ctrl_mcast_groups {68struct _snl_genl_ctrl_mcast_groups {
61 uint32_t num_groups;69 uint32_t num_groups;
62 struct snl_genl_ctrl_mcast_group **groups;70 struct _snl_genl_ctrl_mcast_group **groups;
63};71};
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)
66static struct snl_attr_parser _nla_p_getmc[] = {74static struct snl_attr_parser _nla_p_getmc[] = {
67 { .type = CTRL_ATTR_MCAST_GRP_NAME, .off = _OUT(mcast_grp_name), .cb = snl_attr_get_string },75 {
68 { .type = CTRL_ATTR_MCAST_GRP_ID, .off = _OUT(mcast_grp_id), .cb = snl_attr_get_uint32 },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 },
69};85};
70#undef _OUT86#undef _OUT
71SNL_DECLARE_ATTR_PARSER_EXT(_genl_ctrl_mc_parser,87SNL_DECLARE_ATTR_PARSER_EXT(_genl_ctrl_mc_parser,
72 sizeof(struct snl_genl_ctrl_mcast_group),88 sizeof(struct _snl_genl_ctrl_mcast_group), _nla_p_getmc, NULL);
73 _nla_p_getmc, NULL);
7489
75struct _getfamily_attrs {90struct _getfamily_attrs {
76 uint16_t family_id;91 uint16_t family_id;
77 char *family_name;92 const char *family_name;
78 struct snl_genl_ctrl_mcast_groups mcast_groups;93 struct _snl_genl_ctrl_mcast_groups mcast_groups;
79};94};
8095
81#define _IN(_field) offsetof(struct genlmsghdr, _field)96#define _IN(_field) offsetof(struct genlmsghdr, _field)
82#define _OUT(_field) offsetof(struct _getfamily_attrs, _field)97#define _OUT(_field) offsetof(struct _getfamily_attrs, _field)
83static struct snl_attr_parser _nla_p_getfam[] = {98static struct snl_attr_parser _nla_p_getfam[] = {
84 { .type = CTRL_ATTR_FAMILY_ID , .off = _OUT(family_id), .cb = snl_attr_get_uint16 },99 {
85 { .type = CTRL_ATTR_FAMILY_NAME, .off = _OUT(family_name), .cb = snl_attr_get_string },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 },
86 {109 {
87 .type = CTRL_ATTR_MCAST_GROUPS,110 .type = CTRL_ATTR_MCAST_GROUPS,
88 .off = _OUT(mcast_groups),111 .off = _OUT(mcast_groups),
...@@ -95,7 +118,7 @@ static struct snl_attr_parser _nla_p_getfam[] = {...@@ -95,7 +118,7 @@ static struct snl_attr_parser _nla_p_getfam[] = {
95SNL_DECLARE_GENL_PARSER(_genl_ctrl_getfam_parser, _nla_p_getfam);118SNL_DECLARE_GENL_PARSER(_genl_ctrl_getfam_parser, _nla_p_getfam);
96119
97static bool120static 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,
99 struct _getfamily_attrs *attrs)122 struct _getfamily_attrs *attrs)
100{123{
101 struct snl_writer nw;124 struct snl_writer nw;
...@@ -104,7 +127,7 @@ snl_get_genl_family_info(struct snl_state *ss, const char *family_name,...@@ -104,7 +127,7 @@ snl_get_genl_family_info(struct snl_state *ss, const char *family_name,
104 memset(attrs, 0, sizeof(*attrs));127 memset(attrs, 0, sizeof(*attrs));
105128
106 snl_init_writer(ss, &nw);129 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);
108 snl_add_msg_attr_string(&nw, CTRL_ATTR_FAMILY_NAME, family_name);131 snl_add_msg_attr_string(&nw, CTRL_ATTR_FAMILY_NAME, family_name);
109 if ((hdr = snl_finalize_msg(&nw)) == NULL || !snl_send_message(ss, hdr))132 if ((hdr = snl_finalize_msg(&nw)) == NULL || !snl_send_message(ss, hdr))
110 return (false);133 return (false);
...@@ -123,12 +146,30 @@ snl_get_genl_family(struct snl_state *ss, const char *family_name)...@@ -123,12 +146,30 @@ snl_get_genl_family(struct snl_state *ss, const char *family_name)
123{146{
124 struct _getfamily_attrs attrs = {};147 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);
127 return (attrs.family_id);152 return (attrs.family_id);
128}153}
129154
130static const struct snl_hdr_parser *snl_all_genl_parsers[] = {155static inline uint16_t
131 &_genl_ctrl_getfam_parser, &_genl_ctrl_mc_parser,156snl_get_genl_mcast_group(struct snl_state *ss, const char *family_name,
132};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
134#endif175#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)...@@ -389,11 +389,4 @@ _cb_p_nh(struct snl_state *ss __unused, void *_target)
389SNL_DECLARE_PARSER_EXT(snl_nhmsg_parser, sizeof(struct nhmsg),389SNL_DECLARE_PARSER_EXT(snl_nhmsg_parser, sizeof(struct nhmsg),
390 sizeof(struct snl_parsed_nhop), _fp_p_nh, _nla_p_nh, _cb_p_nh);390 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
399#endif392#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/netlink/netlink_var.h+23-58
...@@ -43,33 +43,32 @@...@@ -43,33 +43,32 @@
4343
44struct ucred;44struct ucred;
4545
46struct nl_io_queue {46struct nl_buf {
47 STAILQ_HEAD(, mbuf) head;47 TAILQ_ENTRY(nl_buf) tailq;
48 int length;48 u_int buflen;
49 int hiwat;49 u_int datalen;
50 u_int offset;
51 char data[];
50};52};
5153
52#define NLP_MAX_GROUPS 12854#define NLP_MAX_GROUPS 128
5355
56BITSET_DEFINE(nl_groups, NLP_MAX_GROUPS);
54struct nlpcb {57struct nlpcb {
55 struct socket *nl_socket;58 struct socket *nl_socket;
56 uint64_t nl_groups[NLP_MAX_GROUPS / 64];59 struct nl_groups nl_groups;
57 uint32_t nl_port;60 uint32_t nl_port;
58 uint32_t nl_flags;61 uint32_t nl_flags;
59 uint32_t nl_process_id;62 uint32_t nl_process_id;
60 int nl_proto;63 int nl_proto;
61 bool nl_active;
62 bool nl_bound;64 bool nl_bound;
63 bool nl_task_pending;65 bool nl_task_pending;
64 bool nl_tx_blocked; /* No new requests accepted */66 bool nl_tx_blocked; /* No new requests accepted */
65 bool nl_linux; /* true if running under compat */67 bool nl_linux; /* true if running under compat */
66 bool nl_unconstrained_vnet; /* true if running under VNET jail (or without jail) */68 bool nl_unconstrained_vnet; /* true if running under VNET jail (or without jail) */
67 bool nl_need_thread_setup;69 bool nl_need_thread_setup;
68 struct nl_io_queue rx_queue;
69 struct nl_io_queue tx_queue;
70 struct taskqueue *nl_taskqueue;70 struct taskqueue *nl_taskqueue;
71 struct task nl_task;71 struct task nl_task;
72 struct ucred *nl_cred; /* Copy of nl_socket->so_cred */
73 uint64_t nl_dropped_bytes;72 uint64_t nl_dropped_bytes;
74 uint64_t nl_dropped_messages;73 uint64_t nl_dropped_messages;
75 CK_LIST_ENTRY(nlpcb) nl_next;74 CK_LIST_ENTRY(nlpcb) nl_next;
...@@ -96,31 +95,19 @@ struct nlpcb {...@@ -96,31 +95,19 @@ struct nlpcb {
96SYSCTL_DECL(_net_netlink);95SYSCTL_DECL(_net_netlink);
97SYSCTL_DECL(_net_netlink_debug);96SYSCTL_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
106struct nl_control {98struct nl_control {
107 CK_LIST_HEAD(nl_pid_head, nlpcb) ctl_port_head;99 CK_LIST_HEAD(nl_pid_head, nlpcb) ctl_port_head;
108 CK_LIST_HEAD(nlpcb_head, nlpcb) ctl_pcb_head;100 CK_LIST_HEAD(nlpcb_head, nlpcb) ctl_pcb_head;
109 CK_LIST_ENTRY(nl_control) ctl_next;101 CK_LIST_ENTRY(nl_control) ctl_next;
110 struct nl_io ctl_io;
111 struct rmlock ctl_lock;102 struct rmlock ctl_lock;
112};103};
113VNET_DECLARE(struct nl_control *, nl_ctl);104VNET_DECLARE(struct nl_control, nl_ctl);
114#define V_nl_ctl VNET(nl_ctl)105#define V_nl_ctl VNET(nl_ctl)
115106
116
117struct sockaddr_nl;107struct sockaddr_nl;
118struct sockaddr;108struct sockaddr;
119struct nlmsghdr;109struct nlmsghdr;
120110
121/* netlink_module.c */
122struct nl_control *vnet_nl_ctl_init(void);
123
124int nl_verify_proto(int proto);111int nl_verify_proto(int proto);
125const char *nl_get_proto_name(int proto);112const char *nl_get_proto_name(int proto);
126113
...@@ -133,57 +120,34 @@ struct nl_proto_handler {...@@ -133,57 +120,34 @@ struct nl_proto_handler {
133extern struct nl_proto_handler *nl_handlers;120extern struct nl_proto_handler *nl_handlers;
134121
135/* netlink_domain.c */122/* 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);
137void nl_osd_register(void);125void nl_osd_register(void);
138void nl_osd_unregister(void);126void nl_osd_unregister(void);
139void nl_set_thread_nlp(struct thread *td, struct nlpcb *nlp);127void nl_set_thread_nlp(struct thread *td, struct nlpcb *nlp);
140128
141/* netlink_io.c */129/* netlink_io.c */
142#define NL_IOF_UNTRANSLATED 0x01130bool nl_send(struct nl_writer *, struct nlpcb *);
143#define NL_IOF_IGNORE_LIMIT 0x02
144bool nl_send_one(struct mbuf *m, struct nlpcb *nlp, int cnt, int io_flags);
145void nlmsg_ack(struct nlpcb *nlp, int error, struct nlmsghdr *nlmsg,131void nlmsg_ack(struct nlpcb *nlp, int error, struct nlmsghdr *nlmsg,
146 struct nl_pstate *npt);132 struct nl_pstate *npt);
147void nl_on_transmit(struct nlpcb *nlp);133void nl_on_transmit(struct nlpcb *nlp);
148void nl_init_io(struct nlpcb *nlp);
149void nl_free_io(struct nlpcb *nlp);
150134
151void nl_taskqueue_handler(void *_arg, int pending);135void nl_taskqueue_handler(void *_arg, int pending);
152int nl_receive_async(struct mbuf *m, struct socket *so);136void nl_schedule_taskqueue(struct nlpcb *nlp);
153void nl_process_receive_locked(struct nlpcb *nlp);137void nl_process_receive_locked(struct nlpcb *nlp);
154void nl_set_source_metadata(struct mbuf *m, int num_messages);138void nl_set_source_metadata(struct mbuf *m, int num_messages);
155void nl_add_msg_info(struct mbuf *m);139struct nl_buf *nl_buf_alloc(size_t len, int mflag);
156140void nl_buf_free(struct nl_buf *nb);
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);
180141
181#define MAX_FAMILIES 20142#define MAX_FAMILIES 20
182#define MAX_GROUPS 64143#define MAX_GROUPS 64
183144
184#define MIN_GROUP_NUM 48145#define MIN_GROUP_NUM 48
185146
147#define CTRL_FAMILY_ID 0
186#define CTRL_FAMILY_NAME "nlctrl"148#define CTRL_FAMILY_NAME "nlctrl"
149#define CTRL_GROUP_ID 0
150#define CTRL_GROUP_NAME "notify"
187151
188struct ifnet;152struct ifnet;
189struct nl_parsed_link;153struct nl_parsed_link;
...@@ -194,14 +158,15 @@ struct nl_pstate;...@@ -194,14 +158,15 @@ struct nl_pstate;
194struct nl_function_wrapper {158struct nl_function_wrapper {
195 bool (*nlmsg_add)(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,159 bool (*nlmsg_add)(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type,
196 uint16_t flags, uint32_t len);160 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);
198 bool (*nlmsg_flush)(struct nl_writer *nw);162 bool (*nlmsg_flush)(struct nl_writer *nw);
199 bool (*nlmsg_end)(struct nl_writer *nw);163 bool (*nlmsg_end)(struct nl_writer *nw);
200 void (*nlmsg_abort)(struct nl_writer *nw);164 void (*nlmsg_abort)(struct nl_writer *nw);
201 void (*nlmsg_ignore_limit)(struct nl_writer *nw);165 void (*nlmsg_ignore_limit)(struct nl_writer *nw);
202 bool (*nlmsg_get_unicast_writer)(struct nl_writer *nw, int size, struct nlpcb *nlp);166 bool (*nl_writer_unicast)(struct nl_writer *nw, size_t size,
203 bool (*nlmsg_get_group_writer)(struct nl_writer *nw, int size, int protocol, int group_id);167 struct nlpcb *nlp, bool waitok);
204 bool (*nlmsg_get_chain_writer)(struct nl_writer *nw, int size, struct mbuf **pm);168 bool (*nl_writer_group)(struct nl_writer *nw, size_t size,
169 uint16_t protocol, uint16_t group_id, int priv, bool waitok);
205 bool (*nlmsg_end_dump)(struct nl_writer *nw, int error, struct nlmsghdr *hdr);170 bool (*nlmsg_end_dump)(struct nl_writer *nw, int error, struct nlmsghdr *hdr);
206 int (*nl_modify_ifp_generic)(struct ifnet *ifp, struct nl_parsed_link *lattrs,171 int (*nl_modify_ifp_generic)(struct ifnet *ifp, struct nl_parsed_link *lattrs,
207 const struct nlattr_bmask *bm, struct nl_pstate *npt);172 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 {...@@ -134,9 +134,10 @@ enum rt_scope_t {
134134
135/*135/*
136 * Routing table identifiers.136 * Routing table identifiers.
137 * FreeBSD route table numbering starts from 0, where 0 is a valid default routing table.137 * FreeBSD route table numbering starts from 0, where 0 is a valid default
138 * Indicating "all tables" via netlink can be done by not including RTA_TABLE attribute138 * routing table. Indicating "all tables" via netlink can be done by not
139 * and keeping rtm_table=0 (compatibility) or setting RTA_TABLE value to RT_TABLE_UNSPEC.139 * including RTA_TABLE attribute and keeping rtm_table=0 (compatibility) or
140 * setting RTA_TABLE value to RT_TABLE_UNSPEC.
140 */141 */
141#define RT_TABLE_MAIN 0 /* RT_DEFAULT_FIB */142#define RT_TABLE_MAIN 0 /* RT_DEFAULT_FIB */
142#define RT_TABLE_UNSPEC 0xFFFFFFFF /* RT_ALL_FIBS */143#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 {...@@ -69,6 +69,7 @@ struct nl_parsed_link {
69 char *ifla_cloner;69 char *ifla_cloner;
70 char *ifla_ifalias;70 char *ifla_ifalias;
71 struct nlattr *ifla_idata;71 struct nlattr *ifla_idata;
72 struct nlattr *ifla_address;
72 unsigned short ifi_type;73 unsigned short ifi_type;
73 int ifi_index;74 int ifi_index;
74 uint32_t ifla_link;75 uint32_t ifla_link;
lib/libc/include/generic-freebsd/netpfil/pf/pf.h+33-9
...@@ -49,7 +49,7 @@...@@ -49,7 +49,7 @@
49enum { PF_INOUT, PF_IN, PF_OUT };49enum { PF_INOUT, PF_IN, PF_OUT };
50enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT,50enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT,
51 PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP, PF_DEFER,51 PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP, PF_DEFER,
52 PF_MATCH };52 PF_MATCH, PF_AFRT, PF_RT };
53enum { PF_RULESET_SCRUB, PF_RULESET_FILTER, PF_RULESET_NAT,53enum { PF_RULESET_SCRUB, PF_RULESET_FILTER, PF_RULESET_NAT,
54 PF_RULESET_BINAT, PF_RULESET_RDR, PF_RULESET_MAX };54 PF_RULESET_BINAT, PF_RULESET_RDR, PF_RULESET_MAX };
55enum { PF_OP_NONE, PF_OP_IRG, PF_OP_EQ, PF_OP_NE, PF_OP_LT,55enum { PF_OP_NONE, PF_OP_IRG, PF_OP_EQ, PF_OP_NE, PF_OP_LT,
...@@ -113,29 +113,38 @@ enum {...@@ -113,29 +113,38 @@ enum {
113#define PFTM_OTHER_FIRST_PACKET_VAL 60 /* First packet */113#define PFTM_OTHER_FIRST_PACKET_VAL 60 /* First packet */
114#define PFTM_OTHER_SINGLE_VAL 30 /* Unidirectional */114#define PFTM_OTHER_SINGLE_VAL 30 /* Unidirectional */
115#define PFTM_OTHER_MULTIPLE_VAL 60 /* Bidirectional */115#define PFTM_OTHER_MULTIPLE_VAL 60 /* Bidirectional */
116#define PFTM_FRAG_VAL 30 /* Fragment expire */116#define PFTM_FRAG_VAL 60 /* Fragment expire */
117#define PFTM_INTERVAL_VAL 10 /* Expire interval */117#define PFTM_INTERVAL_VAL 10 /* Expire interval */
118#define PFTM_SRC_NODE_VAL 0 /* Source tracking */118#define PFTM_SRC_NODE_VAL 0 /* Source tracking */
119#define PFTM_TS_DIFF_VAL 30 /* Allowed TS diff */119#define PFTM_TS_DIFF_VAL 30 /* Allowed TS diff */
120120
121enum { PF_NOPFROUTE, PF_FASTROUTE, PF_ROUTETO, PF_DUPTO, PF_REPLYTO };121enum { PF_NOPFROUTE, PF_FASTROUTE, PF_ROUTETO, PF_DUPTO, PF_REPLYTO };
122enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS,122enum { 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 };
124#define PF_POOL_IDMASK 0x0f125#define PF_POOL_IDMASK 0x0f
125enum { PF_POOL_NONE, PF_POOL_BITMASK, PF_POOL_RANDOM,126enum { PF_POOL_NONE, PF_POOL_BITMASK, PF_POOL_RANDOM,
126 PF_POOL_SRCHASH, PF_POOL_ROUNDROBIN };127 PF_POOL_SRCHASH, PF_POOL_ROUNDROBIN };
127enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,128enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
128 PF_ADDR_TABLE, PF_ADDR_URPFFAILED,129 PF_ADDR_TABLE, PF_ADDR_URPFFAILED,
129 PF_ADDR_RANGE };130 PF_ADDR_RANGE, PF_ADDR_NONE };
130#define PF_POOL_TYPEMASK 0x0f131#define PF_POOL_TYPEMASK 0x0f
131#define PF_POOL_STICKYADDR 0x20132#define PF_POOL_STICKYADDR 0x20
133#define PF_POOL_ENDPI 0x40
134#define PF_POOL_IPV6NH 0x80
132#define PF_WSCALE_FLAG 0x80135#define PF_WSCALE_FLAG 0x80
133#define PF_WSCALE_MASK 0x0f136#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
135#define PF_LOG 0x01143#define PF_LOG 0x01
136#define PF_LOG_ALL 0x02144#define PF_LOG_ALL 0x02
137#define PF_LOG_SOCKET_LOOKUP 0x04145#define PF_LOG_USER 0x04
138#define PF_LOG_FORCE 0x08146#define PF_LOG_FORCE 0x08
147#define PF_LOG_MATCHES 0x10
139148
140/* Reasons code for passing/dropping a packet */149/* Reasons code for passing/dropping a packet */
141#define PFRES_MATCH 0 /* Explicit match of a rule */150#define PFRES_MATCH 0 /* Explicit match of a rule */
...@@ -154,7 +163,8 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,...@@ -154,7 +163,8 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
154#define PFRES_SRCLIMIT 13 /* Source node/conn limit */163#define PFRES_SRCLIMIT 13 /* Source node/conn limit */
155#define PFRES_SYNPROXY 14 /* SYN proxy */164#define PFRES_SYNPROXY 14 /* SYN proxy */
156#define PFRES_MAPFAILED 15 /* pf_map_addr() failed */165#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
159#define PFRES_NAMES { \169#define PFRES_NAMES { \
160 "match", \170 "match", \
...@@ -173,6 +183,7 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,...@@ -173,6 +183,7 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL,
173 "src-limit", \183 "src-limit", \
174 "synproxy", \184 "synproxy", \
175 "map-failed", \185 "map-failed", \
186 "translate", \
176 NULL \187 NULL \
177}188}
178189
...@@ -480,6 +491,9 @@ struct pf_osfp_ioctl {...@@ -480,6 +491,9 @@ struct pf_osfp_ioctl {
480};491};
481492
482#define PF_ANCHOR_NAME_SIZE 64493#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
484struct pf_rule {498struct pf_rule {
485 struct pf_rule_addr src;499 struct pf_rule_addr src;
...@@ -489,8 +503,8 @@ struct pf_rule {...@@ -489,8 +503,8 @@ struct pf_rule {
489#define PF_SKIP_AF 2503#define PF_SKIP_AF 2
490#define PF_SKIP_PROTO 3504#define PF_SKIP_PROTO 3
491#define PF_SKIP_SRC_ADDR 4505#define PF_SKIP_SRC_ADDR 4
492#define PF_SKIP_SRC_PORT 5506#define PF_SKIP_DST_ADDR 5
493#define PF_SKIP_DST_ADDR 6507#define PF_SKIP_SRC_PORT 6
494#define PF_SKIP_DST_PORT 7508#define PF_SKIP_DST_PORT 7
495#define PF_SKIP_COUNT 8509#define PF_SKIP_COUNT 8
496 union pf_rule_ptr skip[PF_SKIP_COUNT];510 union pf_rule_ptr skip[PF_SKIP_COUNT];
...@@ -614,6 +628,9 @@ struct pf_rule {...@@ -614,6 +628,9 @@ struct pf_rule {
614#define PFRULE_SET_TOS 0x00002000628#define PFRULE_SET_TOS 0x00002000
615#define PFRULE_IFBOUND 0x00010000 /* if-bound */629#define PFRULE_IFBOUND 0x00010000 /* if-bound */
616#define PFRULE_STATESLOPPY 0x00020000 /* sloppy state tracking */630#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
618#ifdef _KERNEL635#ifdef _KERNEL
619#define PFRULE_REFS 0x0080 /* rule has references */636#define PFRULE_REFS 0x0080 /* rule has references */
...@@ -626,7 +643,7 @@ struct pf_rule {...@@ -626,7 +643,7 @@ struct pf_rule {
626/* pf_state->state_flags, pf_rule_actions->flags, pf_krule->scrub_flags */643/* pf_state->state_flags, pf_rule_actions->flags, pf_krule->scrub_flags */
627#define PFSTATE_ALLOWOPTS 0x0001644#define PFSTATE_ALLOWOPTS 0x0001
628#define PFSTATE_SLOPPY 0x0002645#define PFSTATE_SLOPPY 0x0002
629/* was PFSTATE_PFLOW 0x0004 */646#define PFSTATE_PFLOW 0x0004
630#define PFSTATE_NOSYNC 0x0008647#define PFSTATE_NOSYNC 0x0008
631#define PFSTATE_ACK 0x0010648#define PFSTATE_ACK 0x0010
632#define PFSTATE_NODF 0x0020649#define PFSTATE_NODF 0x0020
...@@ -642,6 +659,12 @@ struct pf_rule {...@@ -642,6 +659,12 @@ struct pf_rule {
642#define PFSTATE_SCRUBMASK (PFSTATE_NODF|PFSTATE_RANDOMID|PFSTATE_SCRUB_TCP)659#define PFSTATE_SCRUBMASK (PFSTATE_NODF|PFSTATE_RANDOMID|PFSTATE_SCRUB_TCP)
643#define PFSTATE_SETMASK (PFSTATE_SETTOS|PFSTATE_SETPRIO)660#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
645#define PFSTATE_HIWAT 100000 /* default state table size */668#define PFSTATE_HIWAT 100000 /* default state table size */
646#define PFSTATE_ADAPT_START 60000 /* default adaptive timeout start */669#define PFSTATE_ADAPT_START 60000 /* default adaptive timeout start */
647#define PFSTATE_ADAPT_END 120000 /* default adaptive timeout end */670#define PFSTATE_ADAPT_END 120000 /* default adaptive timeout end */
...@@ -670,6 +693,7 @@ struct pf_src_node {...@@ -670,6 +693,7 @@ struct pf_src_node {
670 u_int32_t creation;693 u_int32_t creation;
671 u_int32_t expire;694 u_int32_t expire;
672 sa_family_t af;695 sa_family_t af;
696 sa_family_t naf;
673 u_int8_t ruletype;697 u_int8_t ruletype;
674};698};
675699
lib/libc/include/generic-freebsd/netpfil/pf/pf_mtag.h+1-1
...@@ -41,7 +41,7 @@...@@ -41,7 +41,7 @@
41#define PF_MTAG_FLAG_TRANSLATE_LOCALHOST 0x0441#define PF_MTAG_FLAG_TRANSLATE_LOCALHOST 0x04
42#define PF_MTAG_FLAG_PACKET_LOOPED 0x0842#define PF_MTAG_FLAG_PACKET_LOOPED 0x08
43#define PF_MTAG_FLAG_FASTFWD_OURS_PRESENT 0x1043#define PF_MTAG_FLAG_FASTFWD_OURS_PRESENT 0x10
44/* 0x20 unused */44#define PF_MTAG_FLAG_DUMMYNETED 0x20
45#define PF_MTAG_FLAG_DUPLICATED 0x4045#define PF_MTAG_FLAG_DUPLICATED 0x40
46#define PF_MTAG_FLAG_SYNCOOKIE_RECREATED 0x8046#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfsdiskless.h 8.2 (Berkeley) 3/30/95
35 */33 */
3634
37#ifndef _NFSCLIENT_NFSDISKLESS_H_35#ifndef _NFSCLIENT_NFSDISKLESS_H_
lib/libc/include/generic-freebsd/nfs/nfsproto.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
35 */33 */
3634
37#ifndef _NFS_NFSPROTO_H_35#ifndef _NFS_NFSPROTO_H_
lib/libc/include/generic-freebsd/nfs/xdr_subs.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95
35 */33 */
3634
37#ifndef _NFS_XDR_SUBS_H_35#ifndef _NFS_XDR_SUBS_H_
lib/libc/include/generic-freebsd/nfsclient/nfs.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
35 */33 */
3634
37#ifndef _NFSCLIENT_NFS_H_35#ifndef _NFSCLIENT_NFS_H_
lib/libc/include/generic-freebsd/nfsclient/nfsargs.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
35 */33 */
3634
37#ifndef _NFSCLIENT_NFSARGS_H_35#ifndef _NFSCLIENT_NFSARGS_H_
lib/libc/include/generic-freebsd/nfsclient/nfsmount.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfsmount.h 8.3 (Berkeley) 3/30/95
35 */33 */
3634
37#ifndef _NFSCLIENT_NFSMOUNT_H_35#ifndef _NFSCLIENT_NFSMOUNT_H_
lib/libc/include/generic-freebsd/nfsclient/nfsnode.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95
35 */33 */
3634
37#ifndef _NFSCLIENT_NFSNODE_H_35#ifndef _NFSCLIENT_NFSNODE_H_
lib/libc/include/generic-freebsd/nfsclient/nfsstats.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
35 */33 */
3634
37#ifndef _NFSCLIENT_NFSSTATS_H_35#ifndef _NFSCLIENT_NFSSTATS_H_
lib/libc/include/generic-freebsd/nfsserver/nfs.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
35 */33 */
3634
37#ifndef _NFSSERVER_NFS_H_35#ifndef _NFSSERVER_NFS_H_
lib/libc/include/generic-freebsd/nfsserver/nfsrvstats.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
35 */33 */
3634
37#ifndef _NFSSERVER_NFSRVSTATS_H_35#ifndef _NFSSERVER_NFSRVSTATS_H_
lib/libc/include/generic-freebsd/nl_types.h-1
...@@ -34,7 +34,6 @@...@@ -34,7 +34,6 @@
34#ifndef _NL_TYPES_H_34#ifndef _NL_TYPES_H_
35#define _NL_TYPES_H_35#define _NL_TYPES_H_
3636
37#include <sys/cdefs.h>
38#include <sys/types.h>37#include <sys/types.h>
3938
40#ifdef _NLS_PRIVATE39#ifdef _NLS_PRIVATE
lib/libc/include/generic-freebsd/nlist.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)nlist.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _NLIST_H_37#ifndef _NLIST_H_
lib/libc/include/generic-freebsd/osreldate.h+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/*-1/*-
2 * Copyright (c) 1992-2023 The FreeBSD Project.2 * Copyright (c) 1992-2025 The FreeBSD Project.
3 *3 *
4 */4 */
5#ifdef _KERNEL5#ifdef _KERNEL
lib/libc/include/generic-freebsd/paths.h+1-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)paths.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _PATHS_H_32#ifndef _PATHS_H_
...@@ -63,7 +61,6 @@...@@ -63,7 +61,6 @@
63#define _PATH_FIRMWARE "/usr/share/firmware"61#define _PATH_FIRMWARE "/usr/share/firmware"
64#define _PATH_FTPUSERS "/etc/ftpusers"62#define _PATH_FTPUSERS "/etc/ftpusers"
65#define _PATH_FWMEM "/dev/fwmem"63#define _PATH_FWMEM "/dev/fwmem"
66#define _PATH_GBDE "/sbin/gbde"
67#define _PATH_GELI "/sbin/geli"64#define _PATH_GELI "/sbin/geli"
68#define _PATH_HALT "/sbin/halt"65#define _PATH_HALT "/sbin/halt"
69#ifdef COMPAT_libcompat66#ifdef COMPAT_libcompat
...@@ -84,6 +81,7 @@...@@ -84,6 +81,7 @@
84#define _PATH_MOUNT "/sbin/mount"81#define _PATH_MOUNT "/sbin/mount"
85#define _PATH_NEWFS "/sbin/newfs"82#define _PATH_NEWFS "/sbin/newfs"
86#define _PATH_NOLOGIN "/var/run/nologin"83#define _PATH_NOLOGIN "/var/run/nologin"
84#define _PATH_NOSHUTDOWN "/var/run/noshutdown"
87#define _PATH_RCP "/bin/rcp"85#define _PATH_RCP "/bin/rcp"
88#define _PATH_REBOOT "/sbin/reboot"86#define _PATH_REBOOT "/sbin/reboot"
89#define _PATH_RLOGIN "/usr/bin/rlogin"87#define _PATH_RLOGIN "/usr/bin/rlogin"
lib/libc/include/generic-freebsd/poll.h+6-2
...@@ -96,7 +96,7 @@ struct pollfd {...@@ -96,7 +96,7 @@ struct pollfd {
9696
97#ifndef _KERNEL97#ifndef _KERNEL
9898
99#if __BSD_VISIBLE99#if __POSIX_VISIBLE >= 202405
100#include <sys/_types.h>100#include <sys/_types.h>
101101
102#include <sys/_sigset.h>102#include <sys/_sigset.h>
...@@ -109,9 +109,13 @@ typedef __sigset_t sigset_t;...@@ -109,9 +109,13 @@ typedef __sigset_t sigset_t;
109109
110#endif110#endif
111111
112#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
113#include <ssp/poll.h>
114#endif
115
112__BEGIN_DECLS116__BEGIN_DECLS
113int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);117int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
114#if __BSD_VISIBLE118#if __POSIX_VISIBLE >= 202405
115int ppoll(struct pollfd _pfd[], nfds_t _nfds,119int ppoll(struct pollfd _pfd[], nfds_t _nfds,
116 const struct timespec *__restrict _timeout,120 const struct timespec *__restrict _timeout,
117 const sigset_t *__restrict _newsigmask);121 const sigset_t *__restrict _newsigmask);
lib/libc/include/generic-freebsd/protocols/dumprestore.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _PROTOCOLS_DUMPRESTORE_H_37#ifndef _PROTOCOLS_DUMPRESTORE_H_
lib/libc/include/generic-freebsd/protocols/routed.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)routed.h 8.1 (Berkeley) 6/2/93
32 * $Revision: 2.26 $30 * $Revision: 2.26 $
33 */31 */
3432
lib/libc/include/generic-freebsd/protocols/rwhod.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)rwhod.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _PROTOCOLS_RWHOD_H_32#ifndef _PROTOCOLS_RWHOD_H_
lib/libc/include/generic-freebsd/protocols/talkd.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)talkd.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _PROTOCOLS_TALKD_H_32#ifndef _PROTOCOLS_TALKD_H_
lib/libc/include/generic-freebsd/protocols/timed.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)timed.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _PROTOCOLS_TIMED_H_32#ifndef _PROTOCOLS_TIMED_H_
lib/libc/include/generic-freebsd/pthread_np.h+2-7
...@@ -34,11 +34,6 @@...@@ -34,11 +34,6 @@
34#include <sys/param.h>34#include <sys/param.h>
35#include <sys/cpuset.h>35#include <sys/cpuset.h>
3636
37/*
38 * Non-POSIX type definitions:
39 */
40typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t);
41
42/*37/*
43 * Non-POSIX thread function prototype definitions:38 * Non-POSIX thread function prototype definitions:
44 */39 */
...@@ -64,11 +59,11 @@ int pthread_resume_np(pthread_t);...@@ -64,11 +59,11 @@ int pthread_resume_np(pthread_t);
64int pthread_peekjoin_np(pthread_t, void **);59int pthread_peekjoin_np(pthread_t, void **);
65void pthread_set_name_np(pthread_t, const char *);60void pthread_set_name_np(pthread_t, const char *);
66int pthread_setaffinity_np(pthread_t, size_t, const cpuset_t *);61int pthread_setaffinity_np(pthread_t, size_t, const cpuset_t *);
62void pthread_signals_block_np(void);
63void pthread_signals_unblock_np(void);
67int pthread_single_np(void);64int pthread_single_np(void);
68void pthread_suspend_all_np(void);65void pthread_suspend_all_np(void);
69int pthread_suspend_np(pthread_t);66int pthread_suspend_np(pthread_t);
70int pthread_switch_add_np(pthread_switch_routine_t);
71int pthread_switch_delete_np(pthread_switch_routine_t);
72int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);67int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
73__END_DECLS68__END_DECLS
7469
lib/libc/include/generic-freebsd/pwd.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)pwd.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _PWD_H_37#ifndef _PWD_H_
lib/libc/include/generic-freebsd/ranlib.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ranlib.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _RANLIB_H_32#ifndef _RANLIB_H_
lib/libc/include/generic-freebsd/regex.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)regex.h 8.2 (Berkeley) 1/3/94
36 */34 */
3735
38#ifndef _REGEX_H_36#ifndef _REGEX_H_
lib/libc/include/generic-freebsd/resolv.h-1
...@@ -47,7 +47,6 @@...@@ -47,7 +47,6 @@
47 */47 */
4848
49/*%49/*%
50 * @(#)resolv.h 8.1 (Berkeley) 6/2/93
51 * $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $50 * $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $
52 */51 */
5352
lib/libc/include/generic-freebsd/rpc/auth.h-4
...@@ -28,10 +28,6 @@...@@ -28,10 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
35 */31 */
3632
37/*33/*
lib/libc/include/generic-freebsd/rpc/auth_des.h-3
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */
2/*-1/*-
3 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-3-Clause
4 *3 *
...@@ -28,8 +27,6 @@...@@ -28,8 +27,6 @@
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.28 * POSSIBILITY OF SUCH DAMAGE.
30 * 29 *
31 * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC
32 * from: @(#)auth_des.h 1.14 94/04/25 SMI
33 */30 */
3431
35/*32/*
lib/libc/include/generic-freebsd/rpc/auth_unix.h-3
...@@ -26,9 +26,6 @@...@@ -26,9 +26,6 @@
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.28 * 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
32 */29 */
3330
34/*31/*
lib/libc/include/generic-freebsd/rpc/clnt.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
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 @@...@@ -11,8 +11,6 @@
11#ifndef _RPC_CLNT_STAT_H11#ifndef _RPC_CLNT_STAT_H
12#define _RPC_CLNT_STAT_H12#define _RPC_CLNT_STAT_H
1313
14/* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */
15
16#ifdef __cplusplus14#ifdef __cplusplus
17extern "C" {15extern "C" {
18#endif16#endif
lib/libc/include/generic-freebsd/rpc/des.h-21
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
2/*-1/*-
3 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-3-Clause
4 *3 *
...@@ -57,26 +56,6 @@ struct desparams {...@@ -57,26 +56,6 @@ struct desparams {
57# define des_buf UDES.UDES_buf /* otherwise, pointer to data */56# define des_buf UDES.UDES_buf /* otherwise, pointer to data */
58};57};
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
80/*59/*
81 * Software DES.60 * Software DES.
82 */61 */
lib/libc/include/generic-freebsd/rpc/des_crypt.h-1
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1/*1/*
2 * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI
3 *2 *
4 * des_crypt.h, des library routine interface3 * des_crypt.h, des library routine interface
5 * Copyright (C) 1986, Sun Microsystems, Inc.4 * Copyright (C) 1986, Sun Microsystems, Inc.
lib/libc/include/generic-freebsd/rpc/key_prot.h-4
...@@ -42,10 +42,6 @@ extern "C" {...@@ -42,10 +42,6 @@ extern "C" {
42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 */44 */
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
49/* 45/*
50 * Compiled from key_prot.x using rpcgen.46 * Compiled from key_prot.x using rpcgen.
51 * DO NOT EDIT THIS FILE!47 * DO NOT EDIT THIS FILE!
lib/libc/include/generic-freebsd/rpc/pmap_clnt.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/pmap_prot.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/pmap_rmt.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/raw.h-3
...@@ -36,9 +36,6 @@...@@ -36,9 +36,6 @@
36#ifndef _RPC_RAW_H36#ifndef _RPC_RAW_H
37#define _RPC_RAW_H37#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
42#ifdef __cplusplus39#ifdef __cplusplus
43extern "C" {40extern "C" {
44#endif41#endif
lib/libc/include/generic-freebsd/rpc/rpc.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/rpc_com.h-2
...@@ -44,8 +44,6 @@...@@ -44,8 +44,6 @@
4444
45#include <sys/cdefs.h>45#include <sys/cdefs.h>
4646
47/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */
48
49/*47/*
50 * The max size of the transport, if the size cannot be determined48 * The max size of the transport, if the size cannot be determined
51 * by other means.49 * by other means.
lib/libc/include/generic-freebsd/rpc/rpc_msg.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/rpcb_clnt.h-1
...@@ -55,7 +55,6 @@...@@ -55,7 +55,6 @@
55#ifndef _RPC_RPCB_CLNT_H55#ifndef _RPC_RPCB_CLNT_H
56#define _RPC_RPCB_CLNT_H56#define _RPC_RPCB_CLNT_H
5757
58/* #pragma ident "@(#)rpcb_clnt.h 1.13 94/04/25 SMI" */
59/* rpcb_clnt.h 1.3 88/12/05 SMI */58/* rpcb_clnt.h 1.3 88/12/05 SMI */
6059
61#include <rpc/types.h>60#include <rpc/types.h>
lib/libc/include/generic-freebsd/rpc/rpcb_prot.h-2
...@@ -44,8 +44,6 @@ extern "C" {...@@ -44,8 +44,6 @@ extern "C" {
44 */44 */
45/* from rpcb_prot.x */45/* from rpcb_prot.x */
4646
47/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */
48
49#ifndef _KERNEL47#ifndef _KERNEL
5048
5149
lib/libc/include/generic-freebsd/rpc/rpcb_prot.x-2
...@@ -33,8 +33,6 @@...@@ -33,8 +33,6 @@
3333
34#ifdef RPC_HDR34#ifdef RPC_HDR
35%35%
36%/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */
37%
38%#ifndef _KERNEL36%#ifndef _KERNEL
39%37%
40#endif38#endif
lib/libc/include/generic-freebsd/rpc/rpcent.h-4
...@@ -42,10 +42,6 @@...@@ -42,10 +42,6 @@
42#ifndef _RPC_RPCENT_H42#ifndef _RPC_RPCENT_H
43#define _RPC_RPCENT_H43#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
49struct rpcent {45struct rpcent {
50 char *r_name; /* name of server for this rpc program */46 char *r_name; /* name of server for this rpc program */
51 char **r_aliases; /* alias list */47 char **r_aliases; /* alias list */
lib/libc/include/generic-freebsd/rpc/rpcsec_tls.h+7-26
...@@ -28,20 +28,8 @@...@@ -28,20 +28,8 @@
28#ifndef _RPC_RPCSEC_TLS_H_28#ifndef _RPC_RPCSEC_TLS_H_
29#define _RPC_RPCSEC_TLS_H_29#define _RPC_RPCSEC_TLS_H_
3030
31/* Operation values for rpctls syscall. */31/* System call used by the rpc.tlsclntd(8), rpc.tlsservd(8) daemons. */
32#define RPCTLS_SYSC_CLSETPATH 132int rpctls_syscall(uint64_t);
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 *);
4533
46/* Flag bits to indicate certificate results. */34/* Flag bits to indicate certificate results. */
47#define RPCTLS_FLAGS_HANDSHAKE 0x0135#define RPCTLS_FLAGS_HANDSHAKE 0x01
...@@ -61,15 +49,11 @@ int rpctls_syscall(int, const char *);...@@ -61,15 +49,11 @@ int rpctls_syscall(int, const char *);
61#ifdef _KERNEL49#ifdef _KERNEL
62/* Functions that perform upcalls to the rpctlsd daemon. */50/* Functions that perform upcalls to the rpctlsd daemon. */
63enum clnt_stat rpctls_connect(CLIENT *newclient, char *certname,51enum clnt_stat rpctls_connect(CLIENT *newclient, char *certname,
64 struct socket *so, uint64_t *sslp, uint32_t *reterr);52 struct socket *so, uint32_t *reterr);
65enum clnt_stat rpctls_cl_handlerecord(uint64_t sec, uint64_t usec,53enum clnt_stat rpctls_cl_handlerecord(void *socookie, uint32_t *reterr);
66 uint64_t ssl, uint32_t *reterr);54enum clnt_stat rpctls_srv_handlerecord(void *socookie, uint32_t *reterr);
67enum clnt_stat rpctls_srv_handlerecord(uint64_t sec, uint64_t usec,55enum clnt_stat rpctls_cl_disconnect(void *socookie, uint32_t *reterr);
68 uint64_t ssl, int procpos, uint32_t *reterr);56enum clnt_stat rpctls_srv_disconnect(void *socookie, 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);
7357
74/* Initialization function for rpcsec_tls. */58/* Initialization function for rpcsec_tls. */
75int rpctls_init(void);59int rpctls_init(void);
...@@ -81,9 +65,6 @@ bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run,...@@ -81,9 +65,6 @@ bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run,
81/* String for AUTH_TLS reply verifier. */65/* String for AUTH_TLS reply verifier. */
82#define RPCTLS_START_STRING "STARTTLS"66#define RPCTLS_START_STRING "STARTTLS"
8367
84/* ssl refno value to indicate TLS handshake being done. */
85#define RPCTLS_REFNO_HANDSHAKE 0xFFFFFFFFFFFFFFFFULL
86
87/* Macros for VIMAGE. */68/* Macros for VIMAGE. */
88/* Just define the KRPC_VNETxxx() macros as VNETxxx() macros. */69/* Just define the KRPC_VNETxxx() macros as VNETxxx() macros. */
89#define KRPC_VNET_NAME(n) VNET_NAME(n)70#define KRPC_VNET_NAME(n) VNET_NAME(n)
lib/libc/include/generic-freebsd/rpc/svc.h+13-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
...@@ -458,6 +455,19 @@ extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);...@@ -458,6 +455,19 @@ extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int);
458 */455 */
459extern SVCXPRT *svcunixfd_create(int, u_int, u_int);456extern 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
461/*471/*
462 * Memory based rpc (for speed check and testing)472 * Memory based rpc (for speed check and testing)
463 */473 */
lib/libc/include/generic-freebsd/rpc/svc_auth.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/svc_soc.h-1
...@@ -41,7 +41,6 @@...@@ -41,7 +41,6 @@
41#define _RPC_SVC_SOC_H41#define _RPC_SVC_SOC_H
42#include <sys/cdefs.h>42#include <sys/cdefs.h>
4343
44/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */
45/* svc_soc.h 1.8 89/05/01 SMI */44/* svc_soc.h 1.8 89/05/01 SMI */
4645
47/*46/*
lib/libc/include/generic-freebsd/rpc/types.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpc/xdr.h-3
...@@ -28,9 +28,6 @@...@@ -28,9 +28,6 @@
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.30 * 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
34 */31 */
3532
36/*33/*
lib/libc/include/generic-freebsd/rpcsvc/bootparam_prot.x-6
...@@ -45,12 +45,6 @@...@@ -45,12 +45,6 @@
45%#include <sys/errno.h>45%#include <sys/errno.h>
46%#include <sys/param.h>46%#include <sys/param.h>
47%#include <sys/syslimits.h>47%#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>
54#endif48#endif
5549
56const MAX_MACHINE_NAME = 255;50const MAX_MACHINE_NAME = 255;
lib/libc/include/generic-freebsd/rpcsvc/crypt.x-4
...@@ -30,10 +30,6 @@...@@ -30,10 +30,6 @@
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 */31 */
3232
33#ifndef RPC_HDR
34%#include <sys/cdefs.h>
35#endif
36
37/*33/*
38 * This protocol definition exists because of the U.S. government and34 * This protocol definition exists because of the U.S. government and
39 * its stupid export laws. We can't export DES code from the United35 * 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" {...@@ -42,10 +42,6 @@ extern "C" {
42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 */44 */
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
49/* 45/*
50 * Compiled from key_prot.x using rpcgen.46 * Compiled from key_prot.x using rpcgen.
51 * DO NOT EDIT THIS FILE!47 * DO NOT EDIT THIS FILE!
lib/libc/include/generic-freebsd/rpcsvc/key_prot.x-4
...@@ -45,10 +45,6 @@...@@ -45,10 +45,6 @@
45 * requirements.45 * requirements.
46 */46 */
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%
52%/* 48%/*
53% * Compiled from key_prot.x using rpcgen.49% * Compiled from key_prot.x using rpcgen.
54% * DO NOT EDIT THIS FILE!50% * DO NOT EDIT THIS FILE!
lib/libc/include/generic-freebsd/rpcsvc/klm_prot.x-8
...@@ -38,14 +38,6 @@...@@ -38,14 +38,6 @@
38 * above the kernel.38 * above the kernel.
39 */39 */
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
49const LM_MAXSTRLEN = 1024;41const LM_MAXSTRLEN = 1024;
5042
51/*43/*
lib/libc/include/generic-freebsd/rpcsvc/mount.x-8
...@@ -33,14 +33,6 @@...@@ -33,14 +33,6 @@
33 * Protocol description for the mount program33 * Protocol description for the mount program
34 */34 */
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
44const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */36const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */
45const MNTNAMLEN = 255; /* maximum bytes in a name argument */37const MNTNAMLEN = 255; /* maximum bytes in a name argument */
46const FHSIZE = 32; /* size in bytes of a file handle */38const FHSIZE = 32; /* size in bytes of a file handle */
lib/libc/include/generic-freebsd/rpcsvc/nfs_prot.x-8
...@@ -29,14 +29,6 @@...@@ -29,14 +29,6 @@
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */30 */
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
40const NFS_PORT = 2049;32const NFS_PORT = 2049;
41const NFS_MAXDATA = 8192;33const NFS_MAXDATA = 8192;
42const NFS_MAXPATHLEN = 1024;34const NFS_MAXPATHLEN = 1024;
lib/libc/include/generic-freebsd/rpcsvc/nis.x-5
...@@ -29,12 +29,7 @@...@@ -29,12 +29,7 @@
29% * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29% * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30% */30% */
3131
32#ifndef RPC_HDR
33%#include <sys/cdefs.h>
34#endif
35
36/* 32/*
37 * From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems
38 *33 *
39 * RPC Language Protocol description file for NIS Plus34 * RPC Language Protocol description file for NIS Plus
40 * This version : 1.6135 * This version : 1.61
lib/libc/include/generic-freebsd/rpcsvc/nis_cache.x-6
...@@ -35,12 +35,6 @@...@@ -35,12 +35,6 @@
35 * All Rights Reserved.35 * All Rights Reserved.
36 */36 */
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
44#ifdef RPC_HDR38#ifdef RPC_HDR
45%#include <rpc/types.h>39%#include <rpc/types.h>
46%#include <rpcsvc/nis.h>40%#include <rpcsvc/nis.h>
lib/libc/include/generic-freebsd/rpcsvc/nis_callback.x-7
...@@ -36,14 +36,7 @@...@@ -36,14 +36,7 @@
36 * All Rights Reserved.36 * All Rights Reserved.
37 */37 */
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
45/*39/*
46 * "@(#)zns_cback.x 1.2 90/09/10 Copyr 1990 Sun Micro"
47 *40 *
48 * RPCL description of the Callback Service.41 * RPCL description of the Callback Service.
49 */42 */
lib/libc/include/generic-freebsd/rpcsvc/nis_db.h-2
...@@ -42,8 +42,6 @@...@@ -42,8 +42,6 @@
42#define _RPCSVC_NIS_DB_H42#define _RPCSVC_NIS_DB_H
4343
4444
45/* From: #pragma ident "@(#)nis_db.h 1.8 94/05/03 SMI" */
46
47/*45/*
48 * Note: although the version of <rpcsvc/nis_db.h> shipped with Solaris46 * Note: although the version of <rpcsvc/nis_db.h> shipped with Solaris
49 * 2.5/2.5.x is actually older than this one (according to the ident47 * 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 @@...@@ -36,8 +36,6 @@
36 * All Rights Reserved.36 * All Rights Reserved.
37 */37 */
3838
39/* From: %#pragma ident "@(#)nis_object.x 1.10 94/05/03 SMI" */
40
41#if RPC_HDR39#if RPC_HDR
42%40%
43%#ifndef __nis_object_h41%#ifndef __nis_object_h
lib/libc/include/generic-freebsd/rpcsvc/nis_tags.h-1
...@@ -45,7 +45,6 @@...@@ -45,7 +45,6 @@
45#ifndef _RPCSVC_NIS_TAGS_H45#ifndef _RPCSVC_NIS_TAGS_H
46#define _RPCSVC_NIS_TAGS_H46#define _RPCSVC_NIS_TAGS_H
4747
48/* From: #pragma ident "@(#)nis_tags.h 1.10 94/05/03 SMI" */
49/* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */48/* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */
5049
51#ifdef __cplusplus50#ifdef __cplusplus
lib/libc/include/generic-freebsd/rpcsvc/nislib.h-2
...@@ -39,8 +39,6 @@...@@ -39,8 +39,6 @@
39#ifndef _RPCSVC_NISLIB_H39#ifndef _RPCSVC_NISLIB_H
40#define _RPCSVC_NISLIB_H40#define _RPCSVC_NISLIB_H
4141
42/* From: #pragma ident "@(#)nislib.h 1.16 94/05/03 SMI" */
43
44#ifdef __cplusplus42#ifdef __cplusplus
45extern "C" {43extern "C" {
46#endif44#endif
lib/libc/include/generic-freebsd/rpcsvc/nlm_prot.x+1-7
...@@ -8,14 +8,8 @@...@@ -8,14 +8,8 @@
8#ifdef RPC_HDR8#ifdef RPC_HDR
9%#define LM_MAXSTRLEN 10249%#define LM_MAXSTRLEN 1024
10%#define MAXNAMELEN LM_MAXSTRLEN+110%#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 */
18#endif11#endif
12/* $NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $ */
1913
20/*14/*
21 * status of a call to the lock manager15 * status of a call to the lock manager
lib/libc/include/generic-freebsd/rpcsvc/rex.x-8
...@@ -33,14 +33,6 @@...@@ -33,14 +33,6 @@
33 * Remote execution (rex) protocol specification33 * Remote execution (rex) protocol specification
34 */34 */
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
44const STRINGSIZE = 1024;36const STRINGSIZE = 1024;
45typedef string rexstring<1024>;37typedef string rexstring<1024>;
4638
lib/libc/include/generic-freebsd/rpcsvc/rnusers.x-8
...@@ -33,14 +33,6 @@...@@ -33,14 +33,6 @@
33 * Find out about remote users33 * Find out about remote users
34 */34 */
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
44const MAXUSERS = 100;36const MAXUSERS = 100;
45const MAXUTLEN = 256;37const MAXUTLEN = 256;
4638
lib/libc/include/generic-freebsd/rpcsvc/rquota.x-7
...@@ -1,15 +1,8 @@...@@ -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
4/*1/*
5 * Remote quota protocol2 * Remote quota protocol
6 * Requires unix authentication3 * Requires unix authentication
7 */4 */
85
9#ifndef RPC_HDR
10%#include <sys/cdefs.h>
11#endif
12
13const RQ_PATHLEN = 1024;6const RQ_PATHLEN = 1024;
147
15struct sq_dqblk {8struct sq_dqblk {
lib/libc/include/generic-freebsd/rpcsvc/rstat.x-7
...@@ -44,13 +44,6 @@...@@ -44,13 +44,6 @@
44%44%
45%#endif /* ndef FSCALE */45%#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>
54#endif /* def RPC_HDR */47#endif /* def RPC_HDR */
5548
56const RSTAT_CPUSTATES = 4;49const RSTAT_CPUSTATES = 4;
lib/libc/include/generic-freebsd/rpcsvc/rwall.h-2
...@@ -45,8 +45,6 @@ extern "C" {...@@ -45,8 +45,6 @@ extern "C" {
45 * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.45 * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.
46 */46 */
4747
48/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */
49
50#ifndef _rpcsvc_rwall_h48#ifndef _rpcsvc_rwall_h
51#define _rpcsvc_rwall_h49#define _rpcsvc_rwall_h
5250
lib/libc/include/generic-freebsd/rpcsvc/rwall.x-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31%/*31%/*
32% * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.32% * Copyright (c) 1984, 1990 by Sun Microsystems, Inc.
33% */33% */
34%
35%/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */
3634
37#ifdef RPC_HDR35#ifdef RPC_HDR
38%36%
lib/libc/include/generic-freebsd/rpcsvc/sm_inter.x-7
...@@ -1,6 +1,3 @@...@@ -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
4/*-1/*-
5 * Copyright (c) 2010, Oracle America, Inc.2 * Copyright (c) 2010, Oracle America, Inc.
6 *3 *
...@@ -38,10 +35,6 @@...@@ -38,10 +35,6 @@
38 *35 *
39 */36 */
4037
41#ifndef RPC_HDR
42%#include <sys/cdefs.h>
43#endif
44
45program SM_PROG { 38program SM_PROG {
46 version SM_VERS {39 version SM_VERS {
47 /* res_stat = stat_succ if status monitor agrees to monitor */40 /* res_stat = stat_succ if status monitor agrees to monitor */
lib/libc/include/generic-freebsd/rpcsvc/spray.x-8
...@@ -34,14 +34,6 @@...@@ -34,14 +34,6 @@
34 * Useful for testing flakiness of network interfaces34 * Useful for testing flakiness of network interfaces
35 */35 */
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
45const SPRAYMAX = 8845; /* max amount can spray */37const SPRAYMAX = 8845; /* max amount can spray */
4638
47/*39/*
lib/libc/include/generic-freebsd/rpcsvc/yp.x-6
...@@ -1,5 +1,3 @@...@@ -1,5 +1,3 @@
1/* @(#)yp.x 2.1 88/08/01 4.0 RPCSRC */
2
3/*-1/*-
4 * Copyright (c) 2010, Oracle America, Inc.2 * Copyright (c) 2010, Oracle America, Inc.
5 *3 *
...@@ -35,10 +33,6 @@...@@ -35,10 +33,6 @@
35 * Protocol description file for the Yellow Pages Service33 * Protocol description file for the Yellow Pages Service
36 */34 */
3735
38#ifndef RPC_HDR
39%#include <sys/cdefs.h>
40#endif
41
42const YPMAXRECORD = 16777216;36const YPMAXRECORD = 16777216;
43const YPMAXDOMAIN = 64;37const YPMAXDOMAIN = 64;
44const YPMAXMAP = 64;38const YPMAXMAP = 64;
lib/libc/include/generic-freebsd/rpcsvc/yp_prot.h+1-1
...@@ -271,7 +271,7 @@ struct ypbind_setdom {...@@ -271,7 +271,7 @@ struct ypbind_setdom {
271 *271 *
272 * Sun says:272 * Sun says:
273 * "Protocol between clients (ypxfr, only) and yppush273 * "Protocol between clients (ypxfr, only) and yppush
274 * yppush speaks a protocol in the transient range, which274 * speaks a protocol in the transient range, which
275 * is supplied to ypxfr as a command-line parameter when it275 * is supplied to ypxfr as a command-line parameter when it
276 * is activated by ypserv."276 * is activated by ypserv."
277 *277 *
lib/libc/include/generic-freebsd/rpcsvc/yppasswd.x-8
...@@ -34,14 +34,6 @@...@@ -34,14 +34,6 @@
34 * Requires unix authentication34 * Requires unix authentication
35 */35 */
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
45program YPPASSWDPROG {37program YPPASSWDPROG {
46 version YPPASSWDVERS {38 version YPPASSWDVERS {
47 /*39 /*
lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.h-1
...@@ -45,7 +45,6 @@ extern "C" {...@@ -45,7 +45,6 @@ extern "C" {
45 * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.45 * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.
46 */46 */
4747
48/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */
4948
50/*49/*
51 * Compiled from ypupdate_prot.x using rpcgen50 * Compiled from ypupdate_prot.x using rpcgen
lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.x-1
...@@ -32,7 +32,6 @@...@@ -32,7 +32,6 @@
32% * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.32% * Copyright (c) 1986, 1990 by Sun Microsystems, Inc.
33% */33% */
34%34%
35%/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */
36#ifndef RPC_HDR35#ifndef RPC_HDR
37%#include <sys/cdefs.h>36%#include <sys/cdefs.h>
38#endif37#endif
lib/libc/include/generic-freebsd/runetype.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)runetype.h 8.1 (Berkeley) 6/2/93
35 */33 */
3634
37#ifndef _RUNETYPE_H_35#ifndef _RUNETYPE_H_
lib/libc/include/generic-freebsd/sched.h-1
...@@ -29,7 +29,6 @@...@@ -29,7 +29,6 @@
29#ifndef __SCHED_H__29#ifndef __SCHED_H__
30#define __SCHED_H__30#define __SCHED_H__
3131
32#include <sys/cdefs.h>
33#include <sys/types.h>32#include <sys/types.h>
34#include <sys/sched.h>33#include <sys/sched.h>
35#if __BSD_VISIBLE34#if __BSD_VISIBLE
lib/libc/include/generic-freebsd/security/audit/audit.h+439-303
...@@ -1,19 +1,18 @@...@@ -1,19 +1,18 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause2 * SPDX-License-Identifier: BSD-3-Clause
3 *3 *
4 * Copyright (c) 2005-2009 Apple Inc.4 * Copyright (c) 1999-2005 Apple Inc.
5 * Copyright (c) 2016 Robert N. M. Watson5 * Copyright (c) 2016-2018 Robert N. M. Watson
6 * All rights reserved.6 * All rights reserved.
7 *7 *
8 * Portions of this software were developed by BAE Systems, the University of8 * This software was developed by BAE Systems, the University of Cambridge
9 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL9 * Computer Laboratory, and Memorial University under DARPA/AFRL contract
10 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent10 * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing
11 * Computing (TC) research program.11 * (TC) research program.
12 *12 *
13 * Redistribution and use in source and binary forms, with or without13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions14 * modification, are permitted provided that the following conditions
15 * are met:15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright16 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.17 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright18 * 2. Redistributions in binary form must reproduce the above copyright
...@@ -23,323 +22,460 @@...@@ -23,323 +22,460 @@
23 * its contributors may be used to endorse or promote products derived22 * its contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.23 * from this software without specific prior written permission.
25 *24 *
26 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY25 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
27 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY28 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 */35 * POSSIBILITY OF SUCH DAMAGE.
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 */36 */
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
72/*38/*
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.
74 */41 */
75#define AUDITDEV_FILENAME "audit"
76#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME)
7742
78/*43#ifndef _SECURITY_AUDIT_KERNEL_H_
79 * Pre-defined audit IDs44#define _SECURITY_AUDIT_KERNEL_H_
80 */
81#define AU_DEFAUDITID (uid_t)(-1)
82#define AU_DEFAUDITSID 0
83#define AU_ASSIGN_ASID -1
8445
85/*46#ifndef _KERNEL
86 * IPC types.47#error "no user-serviceable parts inside"
87 */48#endif
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. */
9149
92/*50#include <bsm/audit.h>
93 * Audit conditions.
94 */
95#define AUC_UNSET 0
96#define AUC_AUDITING 1
97#define AUC_NOAUDIT 2
98#define AUC_DISABLED -1
9951
100/*52#include <sys/file.h>
101 * auditon(2) commands.53#include <sys/sysctl.h>
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. */
13654
137/*55/*
138 * Audit policy controls.56 * Audit subsystem condition flags. The audit_trail_enabled flag is set and
139 */57 * removed automatically as a result of configuring log files, and can be
140#define AUDIT_CNT 0x000158 * observed but should not be directly manipulated. The audit suspension
141#define AUDIT_AHLT 0x000259 * flag permits audit to be temporarily disabled without reconfiguring the
142#define AUDIT_ARGV 0x000460 * audit target.
143#define AUDIT_ARGE 0x000861 *
144#define AUDIT_SEQ 0x001062 * As DTrace can also request system-call auditing, a further
145#define AUDIT_WINDATA 0x002063 * audit_syscalls_enabled flag tracks whether newly entering system calls
146#define AUDIT_USER 0x004064 * should be considered for auditing or not.
147#define AUDIT_GROUP 0x008065 *
148#define AUDIT_TRAIL 0x010066 * XXXRW: Move trail flags to audit_private.h, as they no longer need to be
149#define AUDIT_PATH 0x020067 * visible outside the audit code...?
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 */68 */
259struct au_qctrl {69extern u_int audit_dtrace_enabled;
260 int aq_hiwater; /* Max # of audit recs in queue when */70extern int audit_trail_enabled;
261 /* threads with new ARs get blocked. */ 71extern int audit_trail_suspended;
72extern bool audit_syscalls_enabled;
26273
263 int aq_lowater; /* # of audit recs in queue when */74void audit_syscall_enter(unsigned short code, struct thread *td);
264 /* blocked threads get unblocked. */75void audit_syscall_exit(int error, struct thread *td);
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;
29276
293/*77/*
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.
295 */81 */
296struct audit_fstat {82#ifdef AUDIT
297 u_int64_t af_filesz;83struct ipc_perm;
298 u_int64_t af_currsz;84struct sockaddr;
299};85union auditon_udata;
300typedef struct audit_fstat au_fstat_t;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
302/*151/*
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.
304 */154 */
305struct au_evclass_map {155#define AUDITING_TD(td) (__predict_false((td)->td_pflags & TDP_AUDITREC))
306 au_event_t ec_number;156
307 au_class_t ec_class;157#define AUDIT_ARG_ADDR(addr) do { \
308};158 if (AUDITING_TD(curthread)) \
309typedef struct au_evclass_map au_evclass_map_t;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
311/*403/*
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.
313 */407 */
314#define EVNAMEMAP_NAME_SIZE 64408#define AUDIT_SYSCALL_EXIT(error, td) do { \
315struct au_evname_map {409 if (AUDITING_TD(td)) \
316 au_event_t en_number;410 audit_syscall_exit(error, td); \
317 char en_name[EVNAMEMAP_NAME_SIZE];411} while (0)
318};
319typedef struct au_evname_map au_evname_map_t;
320412
321/*413/*
322 * Audit system calls.414 * A Macro to wrap the audit_sysclose() function.
323 */415 */
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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)setjmp.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SETJMP_H_37#ifndef _SETJMP_H_
lib/libc/include/generic-freebsd/signal.h+14-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.3 (Berkeley) 3/30/94
32 */30 */
3331
34#ifndef _SIGNAL_H_32#ifndef _SIGNAL_H_
...@@ -42,6 +40,10 @@...@@ -42,6 +40,10 @@
42#include <sys/_ucontext.h>40#include <sys/_ucontext.h>
43#endif41#endif
4442
43#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE
44#define SIG2STR_MAX 32 /* size of buffer required for sig2str() */
45#endif
46
45__NULLABILITY_PRAGMA_PUSH47__NULLABILITY_PRAGMA_PUSH
4648
47#if __BSD_VISIBLE49#if __BSD_VISIBLE
...@@ -70,6 +72,10 @@ typedef __pthread_t pthread_t;...@@ -70,6 +72,10 @@ typedef __pthread_t pthread_t;
70#endif72#endif
71#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */73#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */
7274
75#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
76#include <ssp/signal.h>
77#endif
78
73__BEGIN_DECLS79__BEGIN_DECLS
74int raise(int);80int raise(int);
7581
...@@ -117,9 +123,15 @@ int siginterrupt(int, int);...@@ -117,9 +123,15 @@ int siginterrupt(int, int);
117#endif123#endif
118124
119#if __POSIX_VISIBLE >= 200809125#if __POSIX_VISIBLE >= 200809
126void psiginfo(const siginfo_t *, const char *);
120void psignal(int, const char *);127void psignal(int, const char *);
121#endif128#endif
122129
130#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE
131int sig2str(int, char *);
132int str2sig(const char * __restrict, int * __restrict);
133#endif
134
123#if __BSD_VISIBLE135#if __BSD_VISIBLE
124int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right);136int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right);
125int sigblock(int);137int 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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)stab.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _STAB_H_32#ifndef _STAB_H_
lib/libc/include/generic-freebsd/stdarg.h+3-34
...@@ -1,37 +1,6 @@...@@ -1,37 +1,6 @@
1/*-1#ifndef __SYS_STDARG_H__
2 * SPDX-License-Identifier: BSD-2-Clause2#define __SYS_STDARG_H__
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_
303
31#include <sys/_stdarg.h>4#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 @@...@@ -33,7 +33,8 @@
33#include <sys/cdefs.h>33#include <sys/cdefs.h>
34#include <sys/_types.h>34#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__)
37#define __CLANG_ATOMICS38#define __CLANG_ATOMICS
38#elif __GNUC_PREREQ__(4, 7)39#elif __GNUC_PREREQ__(4, 7)
39#define __GNUC_ATOMICS40#define __GNUC_ATOMICS
lib/libc/include/generic-freebsd/stdckdint.h+3-3
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
1313
14#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_add_overflow)14#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_add_overflow)
15#define ckd_add(result, a, b) \15#define ckd_add(result, a, b) \
16 (_Bool)__builtin_add_overflow((a), (b), (result))16 __builtin_add_overflow((a), (b), (result))
17#else17#else
18#define ckd_add(result, a, b) \18#define ckd_add(result, a, b) \
19 _Static_assert(0, "checked addition not supported")19 _Static_assert(0, "checked addition not supported")
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
2121
22#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_sub_overflow)22#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_sub_overflow)
23#define ckd_sub(result, a, b) \23#define ckd_sub(result, a, b) \
24 (_Bool)__builtin_sub_overflow((a), (b), (result))24 __builtin_sub_overflow((a), (b), (result))
25#else25#else
26#define ckd_sub(result, a, b) \26#define ckd_sub(result, a, b) \
27 _Static_assert(0, "checked subtraction not supported")27 _Static_assert(0, "checked subtraction not supported")
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
2929
30#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_mul_overflow)30#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_mul_overflow)
31#define ckd_mul(result, a, b) \31#define ckd_mul(result, a, b) \
32 (_Bool)__builtin_mul_overflow((a), (b), (result))32 __builtin_mul_overflow((a), (b), (result))
33#else33#else
34#define ckd_mul(result, a, b) \34#define ckd_mul(result, a, b) \
35 _Static_assert(0, "checked multiplication not supported")35 _Static_assert(0, "checked multiplication not supported")
lib/libc/include/generic-freebsd/stddef.h+4-11
...@@ -27,29 +27,20 @@...@@ -27,29 +27,20 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)stddef.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _STDDEF_H_32#ifndef _STDDEF_H_
35#define _STDDEF_H_33#define _STDDEF_H_
3634
37#include <sys/cdefs.h>
38#include <sys/_null.h>35#include <sys/_null.h>
39#include <sys/_types.h>36#include <sys/_types.h>
37#include <sys/_visible.h>
4038
41#ifndef _PTRDIFF_T_DECLARED39#ifndef _PTRDIFF_T_DECLARED
42typedef __ptrdiff_t ptrdiff_t;40typedef __ptrdiff_t ptrdiff_t;
43#define _PTRDIFF_T_DECLARED41#define _PTRDIFF_T_DECLARED
44#endif42#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
53#ifndef _SIZE_T_DECLARED44#ifndef _SIZE_T_DECLARED
54typedef __size_t size_t;45typedef __size_t size_t;
55#define _SIZE_T_DECLARED46#define _SIZE_T_DECLARED
...@@ -70,7 +61,9 @@ typedef __max_align_t max_align_t;...@@ -70,7 +61,9 @@ typedef __max_align_t max_align_t;
70#endif61#endif
71#endif62#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
75#if __EXT1_VISIBLE68#if __EXT1_VISIBLE
76/* ISO/IEC 9899:2011 K.3.3.2 */69/* ISO/IEC 9899:2011 K.3.3.2 */
lib/libc/include/generic-freebsd/stdio.h+26-21
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)stdio.h 8.5 (Berkeley) 4/29/95
35 */33 */
3634
37#ifndef _STDIO_H_35#ifndef _STDIO_H_
...@@ -50,10 +48,13 @@ typedef __size_t size_t;...@@ -50,10 +48,13 @@ typedef __size_t size_t;
50#define _SIZE_T_DECLARED48#define _SIZE_T_DECLARED
51#endif49#endif
5250
51#if __EXT1_VISIBLE
52/* ISO/IEC 9899:2011 K.3.3.2 */
53#ifndef _RSIZE_T_DEFINED53#ifndef _RSIZE_T_DEFINED
54#define _RSIZE_T_DEFINED54#define _RSIZE_T_DEFINED
55typedef size_t rsize_t;55typedef size_t rsize_t;
56#endif56#endif
57#endif /* __EXT1_VISIBLE */
5758
58#if __POSIX_VISIBLE >= 20080959#if __POSIX_VISIBLE >= 200809
59#ifndef _OFF_T_DECLARED60#ifndef _OFF_T_DECLARED
...@@ -73,7 +74,7 @@ typedef __off64_t off64_t;...@@ -73,7 +74,7 @@ typedef __off64_t off64_t;
7374
74#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE75#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
75#ifndef _VA_LIST_DECLARED76#ifndef _VA_LIST_DECLARED
76typedef __va_list va_list;77typedef __builtin_va_list va_list;
77#define _VA_LIST_DECLARED78#define _VA_LIST_DECLARED
78#endif79#endif
79#endif80#endif
...@@ -240,6 +241,21 @@ __END_DECLS...@@ -240,6 +241,21 @@ __END_DECLS
240#define stdout __stdoutp241#define stdout __stdoutp
241#define stderr __stderrp242#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
243__BEGIN_DECLS259__BEGIN_DECLS
244#ifdef _XLOCALE_H_260#ifdef _XLOCALE_H_
245#include <xlocale/_stdio.h>261#include <xlocale/_stdio.h>
...@@ -254,7 +270,7 @@ int ferror(FILE *);...@@ -254,7 +270,7 @@ int ferror(FILE *);
254int fflush(FILE *);270int fflush(FILE *);
255int fgetc(FILE *);271int fgetc(FILE *);
256int fgetpos(FILE * __restrict, fpos_t * __restrict);272int fgetpos(FILE * __restrict, fpos_t * __restrict);
257char *fgets(char * __restrict, int, FILE * __restrict);273char *(fgets)(char * __restrict, int, FILE * __restrict);
258FILE *fopen(const char * __restrict, const char * __restrict);274FILE *fopen(const char * __restrict, const char * __restrict);
259int fprintf(FILE * __restrict, const char * __restrict, ...);275int fprintf(FILE * __restrict, const char * __restrict, ...);
260int fputc(int, FILE *);276int fputc(int, FILE *);
...@@ -282,7 +298,7 @@ void rewind(FILE *);...@@ -282,7 +298,7 @@ void rewind(FILE *);
282int scanf(const char * __restrict, ...);298int scanf(const char * __restrict, ...);
283void setbuf(FILE * __restrict, char * __restrict);299void setbuf(FILE * __restrict, char * __restrict);
284int setvbuf(FILE * __restrict, char * __restrict, int, size_t);300int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
285int sprintf(char * __restrict, const char * __restrict, ...);301int (sprintf)(char * __restrict, const char * __restrict, ...);
286int sscanf(const char * __restrict, const char * __restrict, ...);302int sscanf(const char * __restrict, const char * __restrict, ...);
287FILE *tmpfile(void);303FILE *tmpfile(void);
288char *tmpnam(char *);304char *tmpnam(char *);
...@@ -290,13 +306,13 @@ int ungetc(int, FILE *);...@@ -290,13 +306,13 @@ int ungetc(int, FILE *);
290int vfprintf(FILE * __restrict, const char * __restrict,306int vfprintf(FILE * __restrict, const char * __restrict,
291 __va_list);307 __va_list);
292int vprintf(const char * __restrict, __va_list);308int vprintf(const char * __restrict, __va_list);
293int vsprintf(char * __restrict, const char * __restrict,309int (vsprintf)(char * __restrict, const char * __restrict,
294 __va_list);310 __va_list);
295311
296#if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 199506312#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,
298 ...) __printflike(3, 4);314 ...) __printflike(3, 4);
299int vsnprintf(char * __restrict, size_t, const char * __restrict,315int (vsnprintf)(char * __restrict, size_t, const char * __restrict,
300 __va_list) __printflike(3, 0);316 __va_list) __printflike(3, 0);
301#endif317#endif
302#if __ISO_C_VISIBLE >= 1999318#if __ISO_C_VISIBLE >= 1999
...@@ -307,16 +323,7 @@ int vsscanf(const char * __restrict, const char * __restrict, __va_list)...@@ -307,16 +323,7 @@ int vsscanf(const char * __restrict, const char * __restrict, __va_list)
307 __scanflike(2, 0);323 __scanflike(2, 0);
308#endif324#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
317#if __POSIX_VISIBLE326#if __POSIX_VISIBLE
318#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
319
320char *ctermid(char *);327char *ctermid(char *);
321FILE *fdopen(int, const char *);328FILE *fdopen(int, const char *);
322int fileno(FILE *);329int fileno(FILE *);
...@@ -415,6 +422,7 @@ FILE *funopen(const void *,...@@ -415,6 +422,7 @@ FILE *funopen(const void *,
415#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)422#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
416#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)423#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
417424
425#if __BSD_VISIBLE
418typedef __ssize_t cookie_read_function_t(void *, char *, size_t);426typedef __ssize_t cookie_read_function_t(void *, char *, size_t);
419typedef __ssize_t cookie_write_function_t(void *, const char *, size_t);427typedef __ssize_t cookie_write_function_t(void *, const char *, size_t);
420typedef int cookie_seek_function_t(void *, off64_t *, int);428typedef int cookie_seek_function_t(void *, off64_t *, int);
...@@ -426,6 +434,7 @@ typedef struct {...@@ -426,6 +434,7 @@ typedef struct {
426 cookie_close_function_t *close;434 cookie_close_function_t *close;
427} cookie_io_functions_t;435} cookie_io_functions_t;
428FILE *fopencookie(void *, const char *, cookie_io_functions_t);436FILE *fopencookie(void *, const char *, cookie_io_functions_t);
437#endif
429438
430/*439/*
431 * Portability hacks. See <sys/types.h>.440 * Portability hacks. See <sys/types.h>.
...@@ -497,10 +506,6 @@ extern int __isthreaded;...@@ -497,10 +506,6 @@ extern int __isthreaded;
497#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))506#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
498#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))507#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
504#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))509#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
505#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))510#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
32 */30 */
3331
34#ifndef _STDLIB_H_32#ifndef _STDLIB_H_
...@@ -40,13 +38,6 @@...@@ -40,13 +38,6 @@
4038
41__NULLABILITY_PRAGMA_PUSH39__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
50#ifndef _SIZE_T_DECLARED41#ifndef _SIZE_T_DECLARED
51typedef __size_t size_t;42typedef __size_t size_t;
52#define _SIZE_T_DECLARED43#define _SIZE_T_DECLARED
...@@ -78,6 +69,10 @@ typedef struct {...@@ -78,6 +69,10 @@ typedef struct {
78 */69 */
79#define RAND_MAX 0x7fffffff70#define RAND_MAX 0x7fffffff
8071
72#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
73#include <ssp/stdlib.h>
74#endif
75
81__BEGIN_DECLS76__BEGIN_DECLS
82#ifdef _XLOCALE_H_77#ifdef _XLOCALE_H_
83#include <xlocale/_stdlib.h>78#include <xlocale/_stdlib.h>
...@@ -86,9 +81,9 @@ extern int __mb_cur_max;...@@ -86,9 +81,9 @@ extern int __mb_cur_max;
86extern int ___mb_cur_max(void);81extern int ___mb_cur_max(void);
87#define MB_CUR_MAX ((size_t)___mb_cur_max())82#define MB_CUR_MAX ((size_t)___mb_cur_max())
8883
89_Noreturn void abort(void);84_Noreturn void abort(void) __noexcept;
90int abs(int) __pure2;85int abs(int) __pure2;
91int atexit(void (* _Nonnull)(void));86int atexit(void (* _Nonnull)(void)) __noexcept;
92double atof(const char *);87double atof(const char *);
93int atoi(const char *);88int atoi(const char *);
94long atol(const char *);89long atol(const char *);
...@@ -100,6 +95,9 @@ div_t div(int, int) __pure2;...@@ -100,6 +95,9 @@ div_t div(int, int) __pure2;
100_Noreturn void exit(int);95_Noreturn void exit(int);
101void free(void *);96void free(void *);
102char *getenv(const char *);97char *getenv(const char *);
98#if __BSD_VISIBLE
99int getenv_r(const char *, char * _Nonnull, size_t);
100#endif
103long labs(long) __pure2;101long labs(long) __pure2;
104ldiv_t ldiv(long, long) __pure2;102ldiv_t ldiv(long, long) __pure2;
105void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);103void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
...@@ -156,7 +154,7 @@ unsigned long long...@@ -156,7 +154,7 @@ unsigned long long
156 strtoull(const char * __restrict, char ** __restrict, int);154 strtoull(const char * __restrict, char ** __restrict, int);
157#endif /* __LONG_LONG_SUPPORTED */155#endif /* __LONG_LONG_SUPPORTED */
158156
159_Noreturn void _Exit(int);157_Noreturn void _Exit(int) __noexcept;
160#endif /* __ISO_C_VISIBLE >= 1999 */158#endif /* __ISO_C_VISIBLE >= 1999 */
161159
162/*160/*
...@@ -165,9 +163,9 @@ _Noreturn void _Exit(int);...@@ -165,9 +163,9 @@ _Noreturn void _Exit(int);
165#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L163#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
166void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)164void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
167 __alloc_size(2);165 __alloc_size(2);
168int at_quick_exit(void (*)(void));166int at_quick_exit(void (*)(void)) __noexcept;
169_Noreturn void167_Noreturn void
170 quick_exit(int);168 quick_exit(int) /* __noexcept -- not ready ABI issues? */;
171#endif /* __ISO_C_VISIBLE >= 2011 */169#endif /* __ISO_C_VISIBLE >= 2011 */
172/*170/*
173 * Extensions made by POSIX relative to C.171 * Extensions made by POSIX relative to C.
...@@ -339,23 +337,26 @@ __uint64_t...@@ -339,23 +337,26 @@ __uint64_t
339 * parameter, and both are different from the ones expected by the historical337 * parameter, and both are different from the ones expected by the historical
340 * FreeBSD qsort_r() interface.338 * FreeBSD qsort_r() interface.
341 *339 *
342 * Apply a workaround where we explicitly link against the historical340 * Apply a workaround where we explicitly link against the historical interface,
343 * interface, qsort_r@FBSD_1.0, in case when qsort_r() is called with341 * qsort_r@FBSD_1.0, in case when qsort_r() is called with the last parameter
344 * the last parameter with a function pointer that exactly matches the342 * with a function pointer that exactly matches the historical FreeBSD qsort_r()
345 * historical FreeBSD qsort_r() comparator signature, so applications343 * comparator signature, so applications written for the historical interface
346 * written for the historical interface can continue to work without344 * can continue to work without modification. Toolchains that don't support
347 * modification.345 * symbol versioning don't define __sym_compat, so only provide this symbol in
346 * supported environments.
348 */347 */
348#ifdef __sym_compat
349#if defined(__generic) || defined(__cplusplus)349#if defined(__generic) || defined(__cplusplus)
350void __qsort_r_compat(void *, size_t, size_t, void *,350void __qsort_r_compat(void *, size_t, size_t, void *,
351 int (*)(void *, const void *, const void *));351 int (*)(void *, const void *, const void *));
352__sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0);352__sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0);
353#endif353#endif
354#endif
354#if defined(__generic) && !defined(__cplusplus)355#if defined(__generic) && !defined(__cplusplus)
355#define qsort_r(base, nel, width, arg4, arg5) \356#define qsort_r(base, nel, width, arg4, arg5) \
356 __generic(arg5, int (*)(void *, const void *, const void *), \357 __generic(arg5, int (*)(void *, const void *, const void *), \
357 __qsort_r_compat, qsort_r)(base, nel, width, arg4, arg5)358 __qsort_r_compat, qsort_r)(base, nel, width, arg4, arg5)
358#elif defined(__cplusplus)359#elif defined(__cplusplus) && defined(__sym_compat)
359__END_DECLS360__END_DECLS
360extern "C++" {361extern "C++" {
361static inline void qsort_r(void *base, size_t nmemb, size_t size,362static 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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)string.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _STRING_H_32#ifndef _STRING_H_
...@@ -51,8 +49,12 @@ typedef __size_t size_t;...@@ -51,8 +49,12 @@ typedef __size_t size_t;
51#define _SIZE_T_DECLARED49#define _SIZE_T_DECLARED
52#endif50#endif
5351
52#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
53#include <ssp/string.h>
54#endif
55
54__BEGIN_DECLS56__BEGIN_DECLS
55#if __XSI_VISIBLE >= 60057#if __XSI_VISIBLE >= 600 || __ISO_C_VISIBLE >= 2023
56void *memccpy(void * __restrict, const void * __restrict, int, size_t);58void *memccpy(void * __restrict, const void * __restrict, int, size_t);
57#endif59#endif
58void *memchr(const void *, int, size_t) __pure;60void *memchr(const void *, int, size_t) __pure;
...@@ -60,23 +62,26 @@ void *memchr(const void *, int, size_t) __pure;...@@ -60,23 +62,26 @@ void *memchr(const void *, int, size_t) __pure;
60void *memrchr(const void *, int, size_t) __pure;62void *memrchr(const void *, int, size_t) __pure;
61#endif63#endif
62int memcmp(const void *, const void *, size_t) __pure;64int 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);
64#if __BSD_VISIBLE66#if __BSD_VISIBLE
65void *memmem(const void *, size_t, const void *, size_t) __pure;67void *memmem(const void *, size_t, const void *, size_t) __pure;
66#endif68#endif
67void *memmove(void *, const void *, size_t);69void *(memmove)(void *, const void *, size_t);
68#if __BSD_VISIBLE70#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);
70#endif76#endif
71void *memset(void *, int, size_t);
72#if __POSIX_VISIBLE >= 20080977#if __POSIX_VISIBLE >= 200809
73char *stpcpy(char * __restrict, const char * __restrict);78char *(stpcpy)(char * __restrict, const char * __restrict);
74char *stpncpy(char * __restrict, const char * __restrict, size_t);79char *(stpncpy)(char * __restrict, const char * __restrict, size_t);
75#endif80#endif
76#if __BSD_VISIBLE81#if __BSD_VISIBLE
77char *strcasestr(const char *, const char *) __pure;82char *strcasestr(const char *, const char *) __pure;
78#endif83#endif
79char *strcat(char * __restrict, const char * __restrict);84char *(strcat)(char * __restrict, const char * __restrict);
80char *strchr(const char *, int) __pure;85char *strchr(const char *, int) __pure;
81#if __BSD_VISIBLE86#if __BSD_VISIBLE
82char *strchrnul(const char*, int) __pure;87char *strchrnul(const char*, int) __pure;
...@@ -84,9 +89,9 @@ int strverscmp(const char *, const char *) __pure;...@@ -84,9 +89,9 @@ int strverscmp(const char *, const char *) __pure;
84#endif89#endif
85int strcmp(const char *, const char *) __pure;90int strcmp(const char *, const char *) __pure;
86int strcoll(const char *, const char *);91int strcoll(const char *, const char *);
87char *strcpy(char * __restrict, const char * __restrict);92char *(strcpy)(char * __restrict, const char * __restrict);
88size_t strcspn(const char *, const char *) __pure;93size_t strcspn(const char *, const char *) __pure;
89#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE94#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE || __ISO_C_VISIBLE >= 2023
90char *strdup(const char *) __malloc_like;95char *strdup(const char *) __malloc_like;
91#endif96#endif
92char *strerror(int);97char *strerror(int);
...@@ -94,8 +99,8 @@ char *strerror(int);...@@ -94,8 +99,8 @@ char *strerror(int);
94int strerror_r(int, char *, size_t);99int strerror_r(int, char *, size_t);
95#endif100#endif
96#if __BSD_VISIBLE101#if __BSD_VISIBLE
97size_t strlcat(char * __restrict, const char * __restrict, size_t);102size_t (strlcat)(char * __restrict, const char * __restrict, size_t);
98size_t strlcpy(char * __restrict, const char * __restrict, size_t);103size_t (strlcpy)(char * __restrict, const char * __restrict, size_t);
99#endif104#endif
100size_t strlen(const char *) __pure;105size_t strlen(const char *) __pure;
101#if __BSD_VISIBLE106#if __BSD_VISIBLE
...@@ -107,11 +112,13 @@ typedef __mode_t mode_t;...@@ -107,11 +112,13 @@ typedef __mode_t mode_t;
107112
108void strmode(mode_t, char *);113void strmode(mode_t, char *);
109#endif114#endif
110char *strncat(char * __restrict, const char * __restrict, size_t);115char *(strncat)(char * __restrict, const char * __restrict, size_t);
111int strncmp(const char *, const char *, size_t) __pure;116int strncmp(const char *, const char *, size_t) __pure;
112char *strncpy(char * __restrict, const char * __restrict, size_t);117char *(strncpy)(char * __restrict, const char * __restrict, size_t);
113#if __POSIX_VISIBLE >= 200809118#if __POSIX_VISIBLE >= 200809 || __ISO_C_VISIBLE >= 2023
114char *strndup(const char *, size_t) __malloc_like;119char *strndup(const char *, size_t) __malloc_like;
120#endif
121#if __POSIX_VISIBLE >= 200809
115size_t strnlen(const char *, size_t) __pure;122size_t strnlen(const char *, size_t) __pure;
116#endif123#endif
117#if __BSD_VISIBLE124#if __BSD_VISIBLE
lib/libc/include/generic-freebsd/stringlist.h+1-1
...@@ -30,7 +30,7 @@...@@ -30,7 +30,7 @@
3030
31#ifndef _STRINGLIST_H31#ifndef _STRINGLIST_H
32#define _STRINGLIST_H 32#define _STRINGLIST_H
33#include <sys/cdefs.h>33
34#include <sys/types.h>34#include <sys/types.h>
3535
36/*36/*
lib/libc/include/generic-freebsd/strings.h+6-2
...@@ -37,11 +37,15 @@ typedef __size_t size_t;...@@ -37,11 +37,15 @@ typedef __size_t size_t;
37#define _SIZE_T_DECLARED37#define _SIZE_T_DECLARED
38#endif38#endif
3939
40#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
41#include <ssp/strings.h>
42#endif
43
40__BEGIN_DECLS44__BEGIN_DECLS
41#if __BSD_VISIBLE || __POSIX_VISIBLE <= 20011245#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
42int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */46int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
43void bcopy(const void *, void *, size_t); /* LEGACY */47void (bcopy)(const void *, void *, size_t); /* LEGACY */
44void bzero(void *, size_t); /* LEGACY */48void (bzero)(void *, size_t); /* LEGACY */
45#endif49#endif
46#if __BSD_VISIBLE50#if __BSD_VISIBLE
47void explicit_bzero(void *, size_t);51void 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);...@@ -55,7 +55,7 @@ int atomic_fcmpset_64(volatile u_int64_t *, u_int64_t *, u_int64_t);
5555
56u_int64_t atomic_fetchadd_64(volatile u_int64_t *, u_int64_t);56u_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 *);
59#define atomic_load_acq_64 atomic_load_6459#define atomic_load_acq_64 atomic_load_64
6060
61void atomic_readandclear_64(volatile u_int64_t *);61void 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)...@@ -176,7 +176,7 @@ atomic_fcmpset_16(__volatile uint16_t *addr, uint16_t *old, uint16_t val)
176176
177#ifndef atomic_load_acq_8177#ifndef atomic_load_acq_8
178static __inline uint8_t178static __inline uint8_t
179atomic_load_acq_8(volatile uint8_t *p)179atomic_load_acq_8(const volatile uint8_t *p)
180{180{
181 int shift;181 int shift;
182 uint8_t ret;182 uint8_t ret;
...@@ -189,7 +189,7 @@ atomic_load_acq_8(volatile uint8_t *p)...@@ -189,7 +189,7 @@ atomic_load_acq_8(volatile uint8_t *p)
189189
190#ifndef atomic_load_acq_16190#ifndef atomic_load_acq_16
191static __inline uint16_t191static __inline uint16_t
192atomic_load_acq_16(volatile uint16_t *p)192atomic_load_acq_16(const volatile uint16_t *p)
193{193{
194 int shift;194 int shift;
195 uint16_t ret;195 uint16_t ret;
...@@ -205,67 +205,31 @@ atomic_load_acq_16(volatile uint16_t *p)...@@ -205,67 +205,31 @@ atomic_load_acq_16(volatile uint16_t *p)
205#undef _ATOMIC_BYTE_SHIFT205#undef _ATOMIC_BYTE_SHIFT
206#undef _ATOMIC_HWORD_SHIFT206#undef _ATOMIC_HWORD_SHIFT
207207
208/*208#ifndef atomic_set_16
209 * Provide generic testandset_long implementation based on fcmpset long209static __inline void
210 * primitive. It may not be ideal for any given arch, so machine/atomic.h210atomic_set_16(volatile uint16_t *p, uint16_t bit)
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)
239{211{
240 u_long bit, old;212 uint16_t v;
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);
249213
250 return (!ret);214 v = atomic_load_16(p);
215 for (;;) {
216 if (atomic_fcmpset_16(p, &v, v | bit))
217 break;
218 }
251}219}
252#endif220#endif
253221
254#ifndef atomic_testandclear_long222#ifndef atomic_clear_16
255static __inline int223static __inline void
256atomic_testandclear_long(volatile u_long *p, u_int v)224atomic_clear_16(volatile uint16_t *p, uint16_t bit)
257{225{
258 u_long bit, old;226 uint16_t v;
259 bool ret;
260
261 bit = (1ul << (v % (sizeof(*p) * NBBY)));
262227
263 old = atomic_load_long(p);228 v = atomic_load_16(p);
264 ret = false;229 for (;;) {
265 while (!ret && (old & bit) != 0)230 if (atomic_fcmpset_16(p, &v, v & ~bit))
266 ret = atomic_fcmpset_long(p, &old, old & ~bit);231 break;
267232 }
268 return (ret);
269}233}
270#endif234#endif
271235
lib/libc/include/generic-freebsd/sys/_bitset.h+2-2
...@@ -36,7 +36,7 @@...@@ -36,7 +36,7 @@
36 * Macros addressing word and bit within it, tuned to make compiler36 * Macros addressing word and bit within it, tuned to make compiler
37 * optimize cases when SETSIZE fits into single machine word.37 * optimize cases when SETSIZE fits into single machine word.
38 */38 */
39#define _BITSET_BITS (sizeof(long) * 8)39#define _BITSET_BITS (sizeof(unsigned long) * 8)
4040
41#define __howmany(x, y) (((x) + ((y) - 1)) / (y))41#define __howmany(x, y) (((x) + ((y) - 1)) / (y))
4242
...@@ -44,7 +44,7 @@...@@ -44,7 +44,7 @@
4444
45#define __BITSET_DEFINE(_t, _s) \45#define __BITSET_DEFINE(_t, _s) \
46struct _t { \46struct _t { \
47 long __bits[__bitset_words((_s))]; \47 unsigned long __bits[__bitset_words((_s))]; \
48}48}
4949
50/*50/*
lib/libc/include/generic-freebsd/sys/_callout.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)callout.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS__CALLOUT_H37#ifndef _SYS__CALLOUT_H
lib/libc/include/generic-freebsd/sys/_clock_id.h+5-1
...@@ -74,11 +74,15 @@...@@ -74,11 +74,15 @@
74#define CLOCK_PROCESS_CPUTIME_ID 1574#define CLOCK_PROCESS_CPUTIME_ID 15
75#endif /* __POSIX_VISIBLE >= 199309 */75#endif /* __POSIX_VISIBLE >= 199309 */
7676
77#ifdef __BSD_VISIBLE
78#define CLOCK_TAI 16
79#endif
80
77/*81/*
78 * Linux compatible names.82 * Linux compatible names.
79 */83 */
80#if __BSD_VISIBLE84#if __BSD_VISIBLE
81#define CLOCK_BOOTTIME CLOCK_UPTIME85#define CLOCK_BOOTTIME CLOCK_MONOTONIC
82#define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST86#define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST
83#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST87#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
84#endif88#endif
lib/libc/include/generic-freebsd/sys/_cpuset.h+2
...@@ -35,6 +35,8 @@...@@ -35,6 +35,8 @@
35#include <sys/_bitset.h>35#include <sys/_bitset.h>
3636
37#ifdef _KERNEL37#ifdef _KERNEL
38#include <machine/param.h>
39
38#define CPU_SETSIZE MAXCPU40#define CPU_SETSIZE MAXCPU
39#endif41#endif
4042
lib/libc/include/generic-freebsd/sys/_domainset.h+2
...@@ -32,6 +32,8 @@...@@ -32,6 +32,8 @@
32#include <sys/_bitset.h>32#include <sys/_bitset.h>
3333
34#ifdef _KERNEL34#ifdef _KERNEL
35#include <machine/param.h>
36
35#define DOMAINSET_SETSIZE MAXMEMDOM37#define DOMAINSET_SETSIZE MAXMEMDOM
36#endif38#endif
3739
lib/libc/include/generic-freebsd/sys/_endian.h+4-2
...@@ -69,8 +69,10 @@...@@ -69,8 +69,10 @@
6969
70/*70/*
71 * POSIX Issue 8 will require these for endian.h. Define them there and in the71 * 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 an72 * traditional BSD compilation environment. PDP_ENDIAN isn't strictly in Issue
73 * assigned date, use strictly greater than issue 7's date.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.
74 */76 */
75#if __BSD_VISIBLE || _POSIX_C_SOURCE > 20080977#if __BSD_VISIBLE || _POSIX_C_SOURCE > 200809
76#define LITTLE_ENDIAN _LITTLE_ENDIAN78#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)uio.h 8.5 (Berkeley) 2/22/94
32 */30 */
3331
34#ifndef _SYS__IOVEC_H_32#ifndef _SYS__IOVEC_H_
...@@ -46,4 +44,28 @@ struct iovec {...@@ -46,4 +44,28 @@ struct iovec {
46 size_t iov_len; /* Length. */44 size_t iov_len; /* Length. */
47};45};
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
49#endif /* !_SYS__IOVEC_H_ */71#endif /* !_SYS__IOVEC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_lock.h+2-2
...@@ -33,8 +33,8 @@...@@ -33,8 +33,8 @@
3333
34struct lock_object {34struct lock_object {
35 const char *lo_name; /* Individual lock name. */35 const char *lo_name; /* Individual lock name. */
36 u_int lo_flags;36 unsigned int lo_flags;
37 u_int lo_data; /* General class specific data. */37 unsigned int lo_data; /* General class specific data. */
38 struct witness *lo_witness; /* Data for witness. */38 struct witness *lo_witness; /* Data for witness. */
39};39};
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 @@...@@ -31,6 +31,8 @@
31#ifndef _SYS__MUTEX_H_31#ifndef _SYS__MUTEX_H_
32#define _SYS__MUTEX_H_32#define _SYS__MUTEX_H_
3333
34#include <sys/_types.h>
35#include <sys/_lock.h>
34#include <machine/param.h>36#include <machine/param.h>
3537
36/*38/*
...@@ -44,7 +46,7 @@...@@ -44,7 +46,7 @@
44 */46 */
45struct mtx {47struct mtx {
46 struct lock_object lock_object; /* Common lock properties. */48 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. */
48};50};
4951
50/*52/*
...@@ -58,7 +60,7 @@ struct mtx {...@@ -58,7 +60,7 @@ struct mtx {
58 */60 */
59struct mtx_padalign {61struct mtx_padalign {
60 struct lock_object lock_object; /* Common lock properties. */62 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. */
62} __aligned(CACHE_LINE_SIZE);64} __aligned(CACHE_LINE_SIZE);
6365
64#endif /* !_SYS__MUTEX_H_ */66#endif /* !_SYS__MUTEX_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_null.h+1-3
...@@ -31,9 +31,7 @@...@@ -31,9 +31,7 @@
31#if !defined(__cplusplus)31#if !defined(__cplusplus)
32#define NULL ((void *)0)32#define NULL ((void *)0)
33#else33#else
34#if __cplusplus >= 201103L34#if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
35#define NULL nullptr
36#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
37#define NULL __null35#define NULL __null
38#else36#else
39#if defined(__LP64__)37#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 @@...@@ -32,6 +32,14 @@
32#ifndef _SYS__RMLOCK_H_32#ifndef _SYS__RMLOCK_H_
33#define _SYS__RMLOCK_H_33#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
35/*43/*
36 * Mostly reader/occasional writer lock.44 * Mostly reader/occasional writer lock.
37 */45 */
...@@ -66,8 +74,6 @@ struct rm_priotracker {...@@ -66,8 +74,6 @@ struct rm_priotracker {
66 LIST_ENTRY(rm_priotracker) rmp_qentry;74 LIST_ENTRY(rm_priotracker) rmp_qentry;
67};75};
6876
69#include <sys/_mutex.h>
70
71struct rmslock_pcpu;77struct rmslock_pcpu;
7278
73struct rmslock {79struct rmslock {
lib/libc/include/generic-freebsd/sys/_rwlock.h+4-2
...@@ -28,6 +28,8 @@...@@ -28,6 +28,8 @@
28#ifndef _SYS__RWLOCK_H_28#ifndef _SYS__RWLOCK_H_
29#define _SYS__RWLOCK_H_29#define _SYS__RWLOCK_H_
3030
31#include <sys/_types.h>
32#include <sys/_lock.h>
31#include <machine/param.h>33#include <machine/param.h>
3234
33/*35/*
...@@ -41,7 +43,7 @@...@@ -41,7 +43,7 @@
41 */43 */
42struct rwlock {44struct rwlock {
43 struct lock_object lock_object;45 struct lock_object lock_object;
44 volatile uintptr_t rw_lock;46 volatile __uintptr_t rw_lock;
45};47};
4648
47/*49/*
...@@ -55,7 +57,7 @@ struct rwlock {...@@ -55,7 +57,7 @@ struct rwlock {
55 */57 */
56struct rwlock_padalign {58struct rwlock_padalign {
57 struct lock_object lock_object;59 struct lock_object lock_object;
58 volatile uintptr_t rw_lock;60 volatile __uintptr_t rw_lock;
59} __aligned(CACHE_LINE_SIZE);61} __aligned(CACHE_LINE_SIZE);
6062
61#endif /* !_SYS__RWLOCK_H_ */63#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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)signal.h 8.4 (Berkeley) 5/4/95
37 */35 */
3836
39#ifndef _SYS__SIGSET_H_37#ifndef _SYS__SIGSET_H_
lib/libc/include/generic-freebsd/sys/_sockaddr_storage.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)socket.h 8.4 (Berkeley) 2/21/94
32 */30 */
3331
34#ifndef _SYS__SOCKADDR_STORAGE_H_32#ifndef _SYS__SOCKADDR_STORAGE_H_
lib/libc/include/generic-freebsd/sys/_stdarg.h+3-4
...@@ -31,12 +31,11 @@...@@ -31,12 +31,11 @@
31#ifndef _SYS__STDARG_H_31#ifndef _SYS__STDARG_H_
32#define _SYS__STDARG_H_32#define _SYS__STDARG_H_
3333
34#include <sys/cdefs.h>34#include <sys/_visible.h>
35#include <sys/_types.h>
3635
37#ifndef _VA_LIST_DECLARED36#ifndef _VA_LIST_DECLARED
38 #define _VA_LIST_DECLARED37#define _VA_LIST_DECLARED
39 typedef __va_list va_list;38typedef __builtin_va_list va_list;
40#endif39#endif
4140
42#define va_start(ap, last) __builtin_va_start((ap), (last))41#define va_start(ap, last) __builtin_va_start((ap), (last))
lib/libc/include/generic-freebsd/sys/_sx.h+4-1
...@@ -31,12 +31,15 @@...@@ -31,12 +31,15 @@
31#ifndef _SYS__SX_H_31#ifndef _SYS__SX_H_
32#define _SYS__SX_H_32#define _SYS__SX_H_
3333
34#include <sys/_types.h>
35#include <sys/_lock.h>
36
34/*37/*
35 * Shared/exclusive lock main structure definition.38 * Shared/exclusive lock main structure definition.
36 */39 */
37struct sx {40struct sx {
38 struct lock_object lock_object;41 struct lock_object lock_object;
39 volatile uintptr_t sx_lock;42 volatile __uintptr_t sx_lock;
40};43};
4144
42#endif /* !_SYS__SX_H_ */45#endif /* !_SYS__SX_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/_termios.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)termios.h 8.3 (Berkeley) 3/28/94
32 */30 */
3331
34#ifndef _SYS__TERMIOS_H_32#ifndef _SYS__TERMIOS_H_
lib/libc/include/generic-freebsd/sys/_timespec.h-3
...@@ -27,9 +27,6 @@...@@ -27,9 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * 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
33 */30 */
3431
35#ifndef _SYS__TIMESPEC_H_32#ifndef _SYS__TIMESPEC_H_
lib/libc/include/generic-freebsd/sys/_tls_variant_i.h+11-1
...@@ -37,8 +37,18 @@...@@ -37,8 +37,18 @@
3737
38struct pthread;38struct 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
40struct tcb {50struct tcb {
41 uintptr_t *tcb_dtv; /* required by rtld */51 struct dtv *tcb_dtv; /* required by rtld */
42 struct pthread *tcb_thread;52 struct pthread *tcb_thread;
43};53};
4454
lib/libc/include/generic-freebsd/sys/_types.h+13-4
...@@ -29,8 +29,6 @@...@@ -29,8 +29,6 @@
29#ifndef _SYS__TYPES_H_29#ifndef _SYS__TYPES_H_
30#define _SYS__TYPES_H_30#define _SYS__TYPES_H_
3131
32#include <sys/cdefs.h>
33
34/*32/*
35 * Basic types upon which most other types are built.33 * Basic types upon which most other types are built.
36 *34 *
...@@ -181,12 +179,23 @@ typedef __uint_least32_t __char32_t;...@@ -181,12 +179,23 @@ typedef __uint_least32_t __char32_t;
181#endif179#endif
182180
183typedef struct {181typedef struct {
184 long long __max_align1 __aligned(_Alignof(long long));182 long long __max_align1
183 __attribute__((__aligned__(__alignof__(long long))));
185#ifndef _STANDALONE184#ifndef _STANDALONE
186 long double __max_align2 __aligned(_Alignof(long double));185 long double __max_align2
186 __attribute__((__aligned__(__alignof__(long long))));
187#endif187#endif
188} __max_align_t;188} __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
190typedef __uint64_t __dev_t; /* device number */199typedef __uint64_t __dev_t; /* device number */
191200
192typedef __uint32_t __fixpt_t; /* fixed point number */201typedef __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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)uio.h 8.5 (Berkeley) 2/22/94
32 */30 */
3331
34#ifndef _SYS__UIO_H_32#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ttycom.h 8.1 (Berkeley) 3/28/94
32 */30 */
3331
34#ifndef _SYS__WINSIZE_H_32#ifndef _SYS__WINSIZE_H_
lib/libc/include/generic-freebsd/sys/acct.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)acct.h 8.4 (Berkeley) 1/9/95
37 */35 */
3836
39#ifndef _SYS_ACCT_H_37#ifndef _SYS_ACCT_H_
lib/libc/include/generic-freebsd/sys/acl.h+12-10
...@@ -36,21 +36,23 @@...@@ -36,21 +36,23 @@
36#ifndef _SYS_ACL_H_36#ifndef _SYS_ACL_H_
37#define _SYS_ACL_H_37#define _SYS_ACL_H_
3838
39#include <sys/param.h>39#include <sys/types.h>
40#include <sys/queue.h>40#include <sys/_null.h>
41#include <vm/uma.h>41#ifdef _KERNEL
42#include <sys/malloc.h>
43#endif
4244
43/*45/*
44 * POSIX.1e and NFSv4 ACL types and related constants.46 * POSIX.1e and NFSv4 ACL types and related constants.
45 */47 */
4648
47typedef uint32_t acl_tag_t;49typedef __acl_tag_t acl_tag_t;
48typedef uint32_t acl_perm_t;50typedef __acl_perm_t acl_perm_t;
49typedef uint16_t acl_entry_type_t;51typedef __acl_entry_type_t acl_entry_type_t;
50typedef uint16_t acl_flag_t;52typedef __acl_flag_t acl_flag_t;
51typedef int acl_type_t;53typedef __acl_type_t acl_type_t;
52typedef int *acl_permset_t;54typedef __acl_permset_t acl_permset_t;
53typedef uint16_t *acl_flagset_t;55typedef __acl_flagset_t acl_flagset_t;
5456
55/*57/*
56 * With 254 entries, "struct acl_t_struct" is exactly one 4kB page big.58 * 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 @@...@@ -97,7 +97,7 @@
97struct __aiocb_private {97struct __aiocb_private {
98 long status;98 long status;
99 long error;99 long error;
100 void *kernelinfo;100 void *spare;
101};101};
102102
103/*103/*
lib/libc/include/generic-freebsd/sys/asan.h+4
...@@ -53,14 +53,18 @@...@@ -53,14 +53,18 @@
53#define KASAN_KSTACK_FREED 0xFE53#define KASAN_KSTACK_FREED 0xFE
54#define KASAN_EXEC_ARGS_FREED 0xFF54#define KASAN_EXEC_ARGS_FREED 0xFF
5555
56struct thread;
57
56void kasan_init(void);58void kasan_init(void);
57void kasan_init_early(vm_offset_t, size_t);59void kasan_init_early(vm_offset_t, size_t);
58void kasan_shadow_map(vm_offset_t, size_t);60void kasan_shadow_map(vm_offset_t, size_t);
59void kasan_mark(const void *, size_t, size_t, uint8_t);61void kasan_mark(const void *, size_t, size_t, uint8_t);
62void kasan_thread_alloc(struct thread *);
60#else /* KASAN */63#else /* KASAN */
61#define kasan_init()64#define kasan_init()
62#define kasan_shadow_map(a, s)65#define kasan_shadow_map(a, s)
63#define kasan_mark(p, s, l, c)66#define kasan_mark(p, s, l, c)
67#define kasan_thread_alloc(t)
64#endif /* !KASAN */68#endif /* !KASAN */
6569
66#endif /* !_SYS_ASAN_H_ */70#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 @@...@@ -36,18 +36,18 @@
3636
37#include <sys/types.h>37#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))
40#define __atomic_store_bool_relaxed(p, v) \40#define __atomic_store_bool_relaxed(p, v) \
41 (*(volatile _Bool *)(p) = (_Bool)(v))41 (*(volatile _Bool *)(p) = (_Bool)(v))
4242
43#define __atomic_load_char_relaxed(p) (*(volatile u_char *)(p))43#define __atomic_load_char_relaxed(p) (*(const volatile u_char *)(p))
44#define __atomic_load_short_relaxed(p) (*(volatile u_short *)(p))44#define __atomic_load_short_relaxed(p) (*(const volatile u_short *)(p))
45#define __atomic_load_int_relaxed(p) (*(volatile u_int *)(p))45#define __atomic_load_int_relaxed(p) (*(const volatile u_int *)(p))
46#define __atomic_load_long_relaxed(p) (*(volatile u_long *)(p))46#define __atomic_load_long_relaxed(p) (*(const volatile u_long *)(p))
47#define __atomic_load_8_relaxed(p) (*(volatile uint8_t *)(p))47#define __atomic_load_8_relaxed(p) (*(const volatile uint8_t *)(p))
48#define __atomic_load_16_relaxed(p) (*(volatile uint16_t *)(p))48#define __atomic_load_16_relaxed(p) (*(const volatile uint16_t *)(p))
49#define __atomic_load_32_relaxed(p) (*(volatile uint32_t *)(p))49#define __atomic_load_32_relaxed(p) (*(const volatile uint32_t *)(p))
50#define __atomic_load_64_relaxed(p) (*(volatile uint64_t *)(p))50#define __atomic_load_64_relaxed(p) (*(const volatile uint64_t *)(p))
5151
52#define __atomic_store_char_relaxed(p, v) \52#define __atomic_store_char_relaxed(p, v) \
53 (*(volatile u_char *)(p) = (u_char)(v))53 (*(volatile u_char *)(p) = (u_char)(v))
...@@ -124,7 +124,7 @@...@@ -124,7 +124,7 @@
124 __atomic_store_generic(p, v, int64_t, uint64_t, 64)124 __atomic_store_generic(p, v, int64_t, uint64_t, 64)
125#endif125#endif
126126
127#define atomic_load_ptr(p) (*(volatile __typeof(*p) *)(p))127#define atomic_load_ptr(p) (*(const volatile __typeof(*p) *)(p))
128#define atomic_store_ptr(p, v) (*(volatile __typeof(*p) *)(p) = (v))128#define atomic_store_ptr(p, v) (*(volatile __typeof(*p) *)(p) = (v))
129129
130/*130/*
...@@ -133,7 +133,7 @@...@@ -133,7 +133,7 @@
133 * openly resorting to the stronger acquire fence, to be sorted out.133 * openly resorting to the stronger acquire fence, to be sorted out.
134 */134 */
135#define atomic_load_consume_ptr(p) \135#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
138#define atomic_interrupt_fence() __compiler_membar()138#define atomic_interrupt_fence() __compiler_membar()
139139
lib/libc/include/generic-freebsd/sys/atomic_san.h+4-5
...@@ -65,10 +65,10 @@...@@ -65,10 +65,10 @@
65 type sp##_atomic_readandclear_##name(volatile type *)65 type sp##_atomic_readandclear_##name(volatile type *)
6666
67#define ATOMIC_SAN_LOAD(sp, name, type) \67#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
70#define ATOMIC_SAN_LOAD_ACQ(sp, name, type) \70#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
73#define ATOMIC_SAN_STORE(sp, name, type) \73#define ATOMIC_SAN_STORE(sp, name, type) \
74 void sp##_atomic_store_##name(volatile type *, type)74 void sp##_atomic_store_##name(volatile type *, type)
...@@ -266,11 +266,10 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);...@@ -266,11 +266,10 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
266#define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr)266#define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr)
267#define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr)267#define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr)
268#define atomic_load_ptr(x) \268#define atomic_load_ptr(x) \
269 ((__typeof(*x))ATOMIC_SAN(load_ptr)( \269 ((__typeof(*x))ATOMIC_SAN(load_ptr)((const volatile uintptr_t *)(x)))
270 __DECONST(volatile uintptr_t *, (x))))
271#define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr)270#define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr)
272#define atomic_load_consume_ptr(x) \271#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)))
274#define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr)273#define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr)
275#define atomic_set_ptr ATOMIC_SAN(set_ptr)274#define atomic_set_ptr ATOMIC_SAN(set_ptr)
276#define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr)275#define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr)
lib/libc/include/generic-freebsd/sys/bio.h-4
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)buf.h 8.9 (Berkeley) 3/30/95
37 */35 */
3836
39#ifndef _SYS_BIO_H_37#ifndef _SYS_BIO_H_
...@@ -77,7 +75,6 @@...@@ -77,7 +75,6 @@
77#ifdef _KERNEL75#ifdef _KERNEL
78struct disk;76struct disk;
79struct bio;77struct bio;
80struct vm_map;
8178
82typedef void bio_task_t(void *);79typedef void bio_task_t(void *);
8380
...@@ -146,7 +143,6 @@ struct bio_queue_head {...@@ -146,7 +143,6 @@ struct bio_queue_head {
146 int batched;143 int batched;
147};144};
148145
149extern struct vm_map *bio_transient_map;
150extern int bio_transient_maxcnt;146extern int bio_transient_maxcnt;
151147
152void biodone(struct bio *bp);148void biodone(struct bio *bp);
lib/libc/include/generic-freebsd/sys/bitcount.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)types.h 8.6 (Berkeley) 2/19/95
37 */35 */
3836
39#ifndef _SYS_BITCOUNT_H_37#ifndef _SYS_BITCOUNT_H_
lib/libc/include/generic-freebsd/sys/buf.h+11-6
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)buf.h 8.9 (Berkeley) 3/30/95
37 */35 */
3836
39#ifndef _SYS_BUF_H_37#ifndef _SYS_BUF_H_
...@@ -298,7 +296,7 @@ struct buf {...@@ -298,7 +296,7 @@ struct buf {
298 * Initialize a lock.296 * Initialize a lock.
299 */297 */
300#define BUF_LOCKINIT(bp, wmesg) \298#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)
302/*300/*
303 *301 *
304 * Get a lock sleeping non-interruptably until it becomes available.302 * Get a lock sleeping non-interruptably until it becomes available.
...@@ -313,7 +311,7 @@ struct buf {...@@ -313,7 +311,7 @@ struct buf {
313 */311 */
314#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \312#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \
315 _lockmgr_args_rw(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \313 _lockmgr_args_rw(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \
316 (interlock), (wmesg), (PRIBIO + 4) | (catch), (timo), \314 (interlock), (wmesg), PVFS | (catch), (timo), \
317 LOCK_FILE, LOCK_LINE)315 LOCK_FILE, LOCK_LINE)
318316
319/*317/*
...@@ -343,6 +341,13 @@ struct buf {...@@ -343,6 +341,13 @@ struct buf {
343 */341 */
344#define BUF_ISLOCKED(bp) \342#define BUF_ISLOCKED(bp) \
345 lockstatus(&(bp)->b_lock)343 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
346/*351/*
347 * Free a buffer lock.352 * Free a buffer lock.
348 */353 */
...@@ -514,7 +519,6 @@ extern int nbuf; /* The number of buffer headers */...@@ -514,7 +519,6 @@ extern int nbuf; /* The number of buffer headers */
514extern u_long maxswzone; /* Max KVA for swap structures */519extern u_long maxswzone; /* Max KVA for swap structures */
515extern u_long maxbcache; /* Max KVA for buffer cache */520extern u_long maxbcache; /* Max KVA for buffer cache */
516extern int maxbcachebuf; /* Max buffer cache block size */521extern int maxbcachebuf; /* Max buffer cache block size */
517extern long runningbufspace;
518extern long hibufspace;522extern long hibufspace;
519extern int dirtybufthresh;523extern int dirtybufthresh;
520extern int bdwriteskip;524extern int bdwriteskip;
...@@ -531,6 +535,7 @@ buf_mapped(struct buf *bp)...@@ -531,6 +535,7 @@ buf_mapped(struct buf *bp)
531 return (bp->b_data != unmapped_buf);535 return (bp->b_data != unmapped_buf);
532}536}
533537
538long runningbufclaim(struct buf *, int);
534void runningbufwakeup(struct buf *);539void runningbufwakeup(struct buf *);
535void waitrunningbufspace(void);540void waitrunningbufspace(void);
536caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est);541caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est);
...@@ -598,7 +603,7 @@ void vfs_unbusy_pages(struct buf *);...@@ -598,7 +603,7 @@ void vfs_unbusy_pages(struct buf *);
598int vmapbuf(struct buf *, void *, size_t, int);603int vmapbuf(struct buf *, void *, size_t, int);
599void vunmapbuf(struct buf *);604void vunmapbuf(struct buf *);
600void brelvp(struct buf *);605void brelvp(struct buf *);
601void bgetvp(struct vnode *, struct buf *);606int bgetvp(struct vnode *, struct buf *) __result_use_check;
602void pbgetbo(struct bufobj *bo, struct buf *bp);607void pbgetbo(struct bufobj *bo, struct buf *bp);
603void pbgetvp(struct vnode *, struct buf *);608void pbgetvp(struct vnode *, struct buf *);
604void pbrelbo(struct buf *);609void pbrelbo(struct buf *);
lib/libc/include/generic-freebsd/sys/buf_ring.h+35-29
...@@ -51,13 +51,13 @@...@@ -51,13 +51,13 @@
51 *51 *
52 */52 */
53struct buf_ring {53struct buf_ring {
54 volatile uint32_t br_prod_head;54 uint32_t br_prod_head;
55 volatile uint32_t br_prod_tail; 55 uint32_t br_prod_tail;
56 int br_prod_size;56 int br_prod_size;
57 int br_prod_mask;57 int br_prod_mask;
58 uint64_t br_drops;58 uint64_t br_drops;
59 volatile uint32_t br_cons_head __aligned(CACHE_LINE_SIZE);59 uint32_t br_cons_head __aligned(CACHE_LINE_SIZE);
60 volatile uint32_t br_cons_tail;60 uint32_t br_cons_tail;
61 int br_cons_size;61 int br_cons_size;
62 int br_cons_mask;62 int br_cons_mask;
63#if defined(DEBUG_BUFRING) && defined(_KERNEL)63#if defined(DEBUG_BUFRING) && defined(_KERNEL)
...@@ -83,10 +83,12 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)...@@ -83,10 +83,12 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
83 * via drbr_peek(), and then re-added via drbr_putback() and83 * via drbr_peek(), and then re-added via drbr_putback() and
84 * trigger a spurious panic.84 * trigger a spurious panic.
85 */85 */
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++)
87 if (br->br_ring[i & mask] == buf)88 if (br->br_ring[i & mask] == buf)
88 panic("buf=%p already enqueue at %d prod=%d cons=%d",89 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));
90#endif 92#endif
91 critical_enter();93 critical_enter();
92 do {94 do {
...@@ -105,16 +107,15 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)...@@ -105,16 +107,15 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
105 cons_tail = atomic_load_acq_32(&br->br_cons_tail);107 cons_tail = atomic_load_acq_32(&br->br_cons_tail);
106108
107 if ((int32_t)(cons_tail + br->br_prod_size - prod_next) < 1) {109 if ((int32_t)(cons_tail + br->br_prod_size - prod_next) < 1) {
108 rmb();110 if (prod_head == atomic_load_32(&br->br_prod_head) &&
109 if (prod_head == br->br_prod_head &&111 cons_tail == atomic_load_32(&br->br_cons_tail)) {
110 cons_tail == br->br_cons_tail) {
111 br->br_drops++;112 br->br_drops++;
112 critical_exit();113 critical_exit();
113 return (ENOBUFS);114 return (ENOBUFS);
114 }115 }
115 continue;116 continue;
116 }117 }
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));
118 prod_idx = prod_head & mask;119 prod_idx = prod_head & mask;
119#ifdef DEBUG_BUFRING120#ifdef DEBUG_BUFRING
120 if (br->br_ring[prod_idx] != NULL)121 if (br->br_ring[prod_idx] != NULL)
...@@ -127,7 +128,7 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)...@@ -127,7 +128,7 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
127 * that preceded us, we need to wait for them128 * that preceded us, we need to wait for them
128 * to complete 129 * to complete
129 */ 130 */
130 while (br->br_prod_tail != prod_head)131 while (atomic_load_32(&br->br_prod_tail) != prod_head)
131 cpu_spinwait();132 cpu_spinwait();
132 atomic_store_rel_32(&br->br_prod_tail, prod_next);133 atomic_store_rel_32(&br->br_prod_tail, prod_next);
133 critical_exit();134 critical_exit();
...@@ -161,7 +162,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)...@@ -161,7 +162,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)
161 critical_exit();162 critical_exit();
162 return (NULL);163 return (NULL);
163 }164 }
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));
165 cons_idx = cons_head & mask;166 cons_idx = cons_head & mask;
166167
167 buf = br->br_ring[cons_idx];168 buf = br->br_ring[cons_idx];
...@@ -173,7 +174,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)...@@ -173,7 +174,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)
173 * that preceded us, we need to wait for them174 * that preceded us, we need to wait for them
174 * to complete 175 * to complete
175 */ 176 */
176 while (br->br_cons_tail != cons_head)177 while (atomic_load_32(&br->br_cons_tail) != cons_head)
177 cpu_spinwait();178 cpu_spinwait();
178179
179 atomic_store_rel_32(&br->br_cons_tail, cons_next);180 atomic_store_rel_32(&br->br_cons_tail, cons_next);
...@@ -195,7 +196,7 @@ buf_ring_dequeue_sc(struct buf_ring *br)...@@ -195,7 +196,7 @@ buf_ring_dequeue_sc(struct buf_ring *br)
195 void *buf;196 void *buf;
196197
197 mask = br->br_cons_mask;198 mask = br->br_cons_mask;
198 cons_head = br->br_cons_head;199 cons_head = atomic_load_32(&br->br_cons_head);
199 prod_tail = atomic_load_acq_32(&br->br_prod_tail);200 prod_tail = atomic_load_acq_32(&br->br_prod_tail);
200201
201 cons_next = cons_head + 1;202 cons_next = cons_head + 1;
...@@ -204,7 +205,7 @@ buf_ring_dequeue_sc(struct buf_ring *br)...@@ -204,7 +205,7 @@ buf_ring_dequeue_sc(struct buf_ring *br)
204 return (NULL);205 return (NULL);
205206
206 cons_idx = cons_head & mask;207 cons_idx = cons_head & mask;
207 br->br_cons_head = cons_next;208 atomic_store_32(&br->br_cons_head, cons_next);
208 buf = br->br_ring[cons_idx];209 buf = br->br_ring[cons_idx];
209210
210#ifdef DEBUG_BUFRING211#ifdef DEBUG_BUFRING
...@@ -213,9 +214,9 @@ buf_ring_dequeue_sc(struct buf_ring *br)...@@ -213,9 +214,9 @@ buf_ring_dequeue_sc(struct buf_ring *br)
213 if (!mtx_owned(br->br_lock))214 if (!mtx_owned(br->br_lock))
214 panic("lock not held on single consumer dequeue");215 panic("lock not held on single consumer dequeue");
215#endif216#endif
216 if (br->br_cons_tail != cons_head)217 if (atomic_load_32(&br->br_cons_tail) != cons_head)
217 panic("inconsistent list cons_tail=%d cons_head=%d",218 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);
219#endif220#endif
220 atomic_store_rel_32(&br->br_cons_tail, cons_next);221 atomic_store_rel_32(&br->br_cons_tail, cons_next);
221 return (buf);222 return (buf);
...@@ -235,13 +236,13 @@ buf_ring_advance_sc(struct buf_ring *br)...@@ -235,13 +236,13 @@ buf_ring_advance_sc(struct buf_ring *br)
235236
236 mask = br->br_cons_mask;237 mask = br->br_cons_mask;
237#endif238#endif
238 cons_head = br->br_cons_head;239 cons_head = atomic_load_32(&br->br_cons_head);
239 prod_tail = br->br_prod_tail;240 prod_tail = atomic_load_32(&br->br_prod_tail);
240241
241 cons_next = cons_head + 1;242 cons_next = cons_head + 1;
242 if (cons_head == prod_tail)243 if (cons_head == prod_tail)
243 return;244 return;
244 br->br_cons_head = cons_next;245 atomic_store_32(&br->br_cons_head, cons_next);
245#ifdef DEBUG_BUFRING246#ifdef DEBUG_BUFRING
246 br->br_ring[cons_head & mask] = NULL;247 br->br_ring[cons_head & mask] = NULL;
247#endif248#endif
...@@ -267,12 +268,13 @@ buf_ring_advance_sc(struct buf_ring *br)...@@ -267,12 +268,13 @@ buf_ring_advance_sc(struct buf_ring *br)
267static __inline void268static __inline void
268buf_ring_putback_sc(struct buf_ring *br, void *new)269buf_ring_putback_sc(struct buf_ring *br, void *new)
269{270{
270 uint32_t mask;271 uint32_t cons_idx, mask;
271272
272 mask = br->br_cons_mask;273 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),
274 ("Buf-Ring has none in putback")) ;276 ("Buf-Ring has none in putback")) ;
275 br->br_ring[br->br_cons_head & mask] = new;277 br->br_ring[cons_idx] = new;
276}278}
277279
278/*280/*
...@@ -291,7 +293,7 @@ buf_ring_peek(struct buf_ring *br)...@@ -291,7 +293,7 @@ buf_ring_peek(struct buf_ring *br)
291#endif 293#endif
292 mask = br->br_cons_mask;294 mask = br->br_cons_mask;
293 prod_tail = atomic_load_acq_32(&br->br_prod_tail);295 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
296 if (cons_head == prod_tail)298 if (cons_head == prod_tail)
297 return (NULL);299 return (NULL);
...@@ -312,7 +314,7 @@ buf_ring_peek_clear_sc(struct buf_ring *br)...@@ -312,7 +314,7 @@ buf_ring_peek_clear_sc(struct buf_ring *br)
312314
313 mask = br->br_cons_mask;315 mask = br->br_cons_mask;
314 prod_tail = atomic_load_acq_32(&br->br_prod_tail);316 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
317 if (cons_head == prod_tail)319 if (cons_head == prod_tail)
318 return (NULL);320 return (NULL);
...@@ -332,22 +334,26 @@ static __inline int...@@ -332,22 +334,26 @@ static __inline int
332buf_ring_full(struct buf_ring *br)334buf_ring_full(struct buf_ring *br)
333{335{
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);
336}339}
337340
338static __inline int341static __inline int
339buf_ring_empty(struct buf_ring *br)342buf_ring_empty(struct buf_ring *br)
340{343{
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));
343}347}
344348
345static __inline int349static __inline int
346buf_ring_count(struct buf_ring *br)350buf_ring_count(struct buf_ring *br)
347{351{
352 uint32_t cons_tail, prod_tail;
348353
349 return ((br->br_prod_size + br->br_prod_tail - br->br_cons_tail)354 cons_tail = atomic_load_32(&br->br_cons_tail);
350 & br->br_prod_mask);355 prod_tail = atomic_load_32(&br->br_prod_tail);
356 return ((br->br_prod_size + prod_tail - cons_tail) & br->br_prod_mask);
351}357}
352358
353#ifdef _KERNEL359#ifdef _KERNEL
lib/libc/include/generic-freebsd/sys/bufobj.h+2-1
...@@ -33,7 +33,7 @@...@@ -33,7 +33,7 @@
33 * cache.33 * cache.
34 *34 *
35 * This used to be vnodes, but we need non-vnode code to be able35 * 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
37 * raid3 and raid5.37 * raid3 and raid5.
38 *38 *
39 * All vnodes will contain a bufobj initially, but down the road we may39 * All vnodes will contain a bufobj initially, but down the road we may
...@@ -116,6 +116,7 @@ struct bufobj {...@@ -116,6 +116,7 @@ struct bufobj {
116#define BO_WWAIT (1 << 1) /* Wait for output to complete */116#define BO_WWAIT (1 << 1) /* Wait for output to complete */
117#define BO_DEAD (1 << 2) /* Dead; only with INVARIANTS */117#define BO_DEAD (1 << 2) /* Dead; only with INVARIANTS */
118#define BO_NOBUFS (1 << 3) /* No bufs allowed */118#define BO_NOBUFS (1 << 3) /* No bufs allowed */
119#define BO_NONSTERILE (1 << 4) /* Ever called reassignbuf() */
119120
120#define BO_LOCKPTR(bo) (&(bo)->bo_lock)121#define BO_LOCKPTR(bo) (&(bo)->bo_lock)
121#define BO_LOCK(bo) rw_wlock(BO_LOCKPTR((bo)))122#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 {...@@ -159,6 +159,7 @@ struct devreq {
159/* Flags for DEV_RESET */159/* Flags for DEV_RESET */
160#define DEVF_RESET_DETACH 0x0000001 /* Detach drivers vs suspend160#define DEVF_RESET_DETACH 0x0000001 /* Detach drivers vs suspend
161 device */161 device */
162#define DEVICE_UNIT_ANY (-1)
162163
163#ifdef _KERNEL164#ifdef _KERNEL
164165
...@@ -276,6 +277,7 @@ enum intr_type {...@@ -276,6 +277,7 @@ enum intr_type {
276 INTR_EXCL = 256, /* exclusive interrupt */277 INTR_EXCL = 256, /* exclusive interrupt */
277 INTR_MPSAFE = 512, /* this interrupt is SMP safe */278 INTR_MPSAFE = 512, /* this interrupt is SMP safe */
278 INTR_ENTROPY = 1024, /* this interrupt provides entropy */279 INTR_ENTROPY = 1024, /* this interrupt provides entropy */
280 INTR_SLEEPABLE = 2048, /* this interrupt handler can sleep */
279 INTR_MD1 = 4096, /* flag reserved for MD use */281 INTR_MD1 = 4096, /* flag reserved for MD use */
280 INTR_MD2 = 8192, /* flag reserved for MD use */282 INTR_MD2 = 8192, /* flag reserved for MD use */
281 INTR_MD3 = 16384, /* flag reserved for MD use */283 INTR_MD3 = 16384, /* flag reserved for MD use */
...@@ -305,18 +307,6 @@ enum cpu_sets {...@@ -305,18 +307,6 @@ enum cpu_sets {
305 INTR_CPUS307 INTR_CPUS
306};308};
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
320struct resource;310struct resource;
321311
322/**312/**
...@@ -396,7 +386,7 @@ struct resource *...@@ -396,7 +386,7 @@ struct resource *
396 rman_res_t count, u_int flags);386 rman_res_t count, u_int flags);
397int resource_list_release(struct resource_list *rl,387int resource_list_release(struct resource_list *rl,
398 device_t bus, device_t child,388 device_t bus, device_t child,
399 int type, int rid, struct resource *res);389 struct resource *res);
400int resource_list_release_active(struct resource_list *rl,390int resource_list_release_active(struct resource_list *rl,
401 device_t bus, device_t child,391 device_t bus, device_t child,
402 int type);392 int type);
...@@ -427,12 +417,12 @@ void root_bus_configure(void);...@@ -427,12 +417,12 @@ void root_bus_configure(void);
427417
428struct _cpuset;418struct _cpuset;
429419
430int bus_generic_activate_resource(device_t dev, device_t child, int type,420int bus_generic_activate_resource(device_t dev, device_t child,
431 int rid, struct resource *r);421 struct resource *r);
432device_t422device_t
433 bus_generic_add_child(device_t dev, u_int order, const char *name,423 bus_generic_add_child(device_t dev, u_int order, const char *name,
434 int unit);424 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,
436 struct resource *r, rman_res_t start,426 struct resource *r, rman_res_t start,
437 rman_res_t end);427 rman_res_t end);
438struct resource *428struct resource *
...@@ -441,7 +431,8 @@ struct resource *...@@ -441,7 +431,8 @@ struct resource *
441 rman_res_t count, u_int flags);431 rman_res_t count, u_int flags);
442int bus_generic_translate_resource(device_t dev, int type, rman_res_t start,432int bus_generic_translate_resource(device_t dev, int type, rman_res_t start,
443 rman_res_t *newstart);433 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");
445int bus_generic_bind_intr(device_t dev, device_t child,436int bus_generic_bind_intr(device_t dev, device_t child,
446 struct resource *irq, int cpu);437 struct resource *irq, int cpu);
447int bus_generic_child_location(device_t dev, device_t child, struct sbuf *sb);438int 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,...@@ -452,8 +443,8 @@ int bus_generic_config_intr(device_t, int, enum intr_trigger,
452int bus_generic_describe_intr(device_t dev, device_t child,443int bus_generic_describe_intr(device_t dev, device_t child,
453 struct resource *irq, void *cookie,444 struct resource *irq, void *cookie,
454 const char *descr);445 const char *descr);
455int bus_generic_deactivate_resource(device_t dev, device_t child, int type,446int bus_generic_deactivate_resource(device_t dev, device_t child,
456 int rid, struct resource *r);447 struct resource *r);
457int bus_generic_detach(device_t dev);448int bus_generic_detach(device_t dev);
458void bus_generic_driver_added(device_t dev, driver_t *driver);449void bus_generic_driver_added(device_t dev, driver_t *driver);
459int bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op,450int 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);...@@ -466,9 +457,7 @@ int bus_generic_get_domain(device_t dev, device_t child, int *domain);
466ssize_t bus_generic_get_property(device_t dev, device_t child,457ssize_t bus_generic_get_property(device_t dev, device_t child,
467 const char *propname, void *propvalue,458 const char *propname, void *propvalue,
468 size_t size, device_property_type_t type);459 size_t size, device_property_type_t type);
469struct resource_list *460int bus_generic_map_resource(device_t dev, device_t child,
470 bus_generic_get_resource_list(device_t, device_t);
471int bus_generic_map_resource(device_t dev, device_t child, int type,
472 struct resource *r,461 struct resource *r,
473 struct resource_map_request *args,462 struct resource_map_request *args,
474 struct resource_map *map);463 struct resource_map *map);
...@@ -477,11 +466,12 @@ int bus_print_child_header(device_t dev, device_t child);...@@ -477,11 +466,12 @@ int bus_print_child_header(device_t dev, device_t child);
477int bus_print_child_domain(device_t dev, device_t child);466int bus_print_child_domain(device_t dev, device_t child);
478int bus_print_child_footer(device_t dev, device_t child);467int bus_print_child_footer(device_t dev, device_t child);
479int bus_generic_print_child(device_t dev, device_t child);468int 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");
481int bus_generic_read_ivar(device_t dev, device_t child, int which,471int bus_generic_read_ivar(device_t dev, device_t child, int which,
482 uintptr_t *result);472 uintptr_t *result);
483int bus_generic_release_resource(device_t bus, device_t child,473int bus_generic_release_resource(device_t bus, device_t child,
484 int type, int rid, struct resource *r);474 struct resource *r);
485int bus_generic_resume(device_t dev);475int bus_generic_resume(device_t dev);
486int bus_generic_resume_child(device_t dev, device_t child);476int bus_generic_resume_child(device_t dev, device_t child);
487int bus_generic_setup_intr(device_t dev, device_t child,477int 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 *,...@@ -497,24 +487,20 @@ int bus_generic_rl_get_resource (device_t, device_t, int, int, rman_res_t *,
497 rman_res_t *);487 rman_res_t *);
498int bus_generic_rl_set_resource (device_t, device_t, int, int, rman_res_t,488int bus_generic_rl_set_resource (device_t, device_t, int, int, rman_res_t,
499 rman_res_t);489 rman_res_t);
500int bus_generic_rl_release_resource (device_t, device_t, int, int,490int bus_generic_rl_release_resource (device_t, device_t, struct resource *);
501 struct resource *);
502struct resource *491struct resource *
503 bus_generic_rman_alloc_resource(device_t dev, device_t child, int type,492 bus_generic_rman_alloc_resource(device_t dev, device_t child, int type,
504 int *rid, rman_res_t start,493 int *rid, rman_res_t start,
505 rman_res_t end, rman_res_t count,494 rman_res_t end, rman_res_t count,
506 u_int flags);495 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,
508 struct resource *r, rman_res_t start,497 struct resource *r, rman_res_t start,
509 rman_res_t end);498 rman_res_t end);
510int bus_generic_rman_release_resource(device_t dev, device_t child,499int bus_generic_rman_release_resource(device_t dev, device_t child,
511 int type, int rid,
512 struct resource *r);500 struct resource *r);
513int bus_generic_rman_activate_resource(device_t dev, device_t child,501int bus_generic_rman_activate_resource(device_t dev, device_t child,
514 int type, int rid,
515 struct resource *r);502 struct resource *r);
516int bus_generic_rman_deactivate_resource(device_t dev, device_t child,503int bus_generic_rman_deactivate_resource(device_t dev, device_t child,
517 int type, int rid,
518 struct resource *r);504 struct resource *r);
519505
520int bus_generic_shutdown(device_t dev);506int bus_generic_shutdown(device_t dev);
...@@ -526,7 +512,7 @@ int bus_generic_suspend_intr(device_t dev, device_t child,...@@ -526,7 +512,7 @@ int bus_generic_suspend_intr(device_t dev, device_t child,
526 struct resource *irq);512 struct resource *irq);
527int bus_generic_resume_intr(device_t dev, device_t child,513int bus_generic_resume_intr(device_t dev, device_t child,
528 struct resource *irq);514 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,
530 struct resource *r,516 struct resource *r,
531 struct resource_map *map);517 struct resource_map *map);
532int bus_generic_write_ivar(device_t dev, device_t child, int which,518int 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,...@@ -554,29 +540,26 @@ int bus_alloc_resources(device_t dev, struct resource_spec *rs,
554void bus_release_resources(device_t dev, const struct resource_spec *rs,540void bus_release_resources(device_t dev, const struct resource_spec *rs,
555 struct resource **res);541 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,
558 rman_res_t start, rman_res_t end);544 rman_res_t start, rman_res_t end);
559int bus_translate_resource(device_t child, int type, rman_res_t start,545int bus_translate_resource(device_t child, int type, rman_res_t start,
560 rman_res_t *newstart);546 rman_res_t *newstart);
561struct resource *bus_alloc_resource(device_t dev, int type, int *rid,547struct resource *bus_alloc_resource(device_t dev, int type, int *rid,
562 rman_res_t start, rman_res_t end,548 rman_res_t start, rman_res_t end,
563 rman_res_t count, u_int flags);549 rman_res_t count, u_int flags);
564int bus_activate_resource(device_t dev, int type, int rid,550int bus_activate_resource(device_t dev, struct resource *r);
565 struct resource *r);551int bus_deactivate_resource(device_t dev, struct resource *r);
566int bus_deactivate_resource(device_t dev, int type, int rid,552int bus_map_resource(device_t dev, struct resource *r,
567 struct resource *r);
568int bus_map_resource(device_t dev, int type, struct resource *r,
569 struct resource_map_request *args,553 struct resource_map_request *args,
570 struct resource_map *map);554 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,
572 struct resource_map *map);556 struct resource_map *map);
573int bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize,557int bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize,
574 struct _cpuset *cpuset);558 struct _cpuset *cpuset);
575bus_dma_tag_t bus_get_dma_tag(device_t dev);559bus_dma_tag_t bus_get_dma_tag(device_t dev);
576bus_space_tag_t bus_get_bus_tag(device_t dev);560bus_space_tag_t bus_get_bus_tag(device_t dev);
577int bus_get_domain(device_t dev, int *domain);561int bus_get_domain(device_t dev, int *domain);
578int bus_release_resource(device_t dev, int type, int rid,562int bus_release_resource(device_t dev, struct resource *r);
579 struct resource *r);
580int bus_free_resource(device_t dev, int type, struct resource *r);563int bus_free_resource(device_t dev, int type, struct resource *r);
581int bus_setup_intr(device_t dev, struct resource *r, int flags,564int bus_setup_intr(device_t dev, struct resource *r, int flags,
582 driver_filter_t filter, driver_intr_t handler, 565 driver_filter_t filter, driver_intr_t handler,
...@@ -597,8 +580,12 @@ void bus_delete_resource(device_t dev, int type, int rid);...@@ -597,8 +580,12 @@ void bus_delete_resource(device_t dev, int type, int rid);
597int bus_child_present(device_t child);580int bus_child_present(device_t child);
598int bus_child_pnpinfo(device_t child, struct sbuf *sb);581int bus_child_pnpinfo(device_t child, struct sbuf *sb);
599int bus_child_location(device_t child, struct sbuf *sb);582int 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);
600void bus_enumerate_hinted_children(device_t bus);587void bus_enumerate_hinted_children(device_t bus);
601int bus_delayed_attach_children(device_t bus);588void bus_identify_children(device_t dev);
602589
603static __inline struct resource *590static __inline struct resource *
604bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)591bus_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,...@@ -613,6 +600,47 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
613 return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags));600 return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags));
614}601}
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
616/*644/*
617 * Access functions for device.645 * Access functions for device.
618 */646 */
...@@ -783,9 +811,7 @@ void bus_data_generation_update(void);...@@ -783,9 +811,7 @@ void bus_data_generation_update(void);
783#define BUS_LOCATOR_UEFI "UEFI"811#define BUS_LOCATOR_UEFI "UEFI"
784#define BUS_LOCATOR_OFW "OFW"812#define BUS_LOCATOR_OFW "OFW"
785813
786extern int bus_current_pass;814int bus_get_pass(void);
787
788void bus_set_pass(int pass);
789815
790/**816/**
791 * Routines to lock / unlock the newbus lock.817 * Routines to lock / unlock the newbus lock.
...@@ -824,24 +850,25 @@ struct driver_module_data {...@@ -824,24 +850,25 @@ struct driver_module_data {
824 int dmd_pass;850 int dmd_pass;
825};851};
826852
827#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \853#define EARLY_DRIVER_MODULE_ORDERED(_name, busname, driver, evh, arg, \
828 order, pass) \854 order, pass) \
829 \855 \
830static struct driver_module_data name##_##busname##_driver_mod = { \856static struct driver_module_data _name##_##busname##_driver_mod = { \
831 evh, arg, \857 .dmd_chainevh = evh, \
832 #busname, \858 .dmd_chainarg = arg, \
833 (kobj_class_t) &driver, \859 .dmd_busname = #busname, \
834 NULL, \860 .dmd_driver = (kobj_class_t)&driver, \
835 pass \861 .dmd_devclass = NULL, \
862 .dmd_pass = pass, \
836}; \863}; \
837 \864 \
838static moduledata_t name##_##busname##_mod = { \865static moduledata_t _name##_##busname##_mod = { \
839 #busname "/" #name, \866 .name = #busname "/" #_name , \
840 driver_module_handler, \867 .evhand = driver_module_handler, \
841 &name##_##busname##_driver_mod \868 .priv = &_name##_##busname##_driver_mod, \
842}; \869}; \
843DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \870DECLARE_MODULE(_name##_##busname, _name##_##busname##_mod, \
844 SI_SUB_DRIVERS, order)871 SI_SUB_DRIVERS, order)
845872
846#define EARLY_DRIVER_MODULE(name, busname, driver, evh, arg, pass) \873#define EARLY_DRIVER_MODULE(name, busname, driver, evh, arg, pass) \
847 EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \874 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);...@@ -161,11 +161,8 @@ void _busdma_dflt_lock(void *arg, bus_dma_lock_op_t op);
161 * boundary: Boundary that segments cannot cross.161 * boundary: Boundary that segments cannot cross.
162 * lowaddr: Low restricted address that cannot appear in a mapping.162 * lowaddr: Low restricted address that cannot appear in a mapping.
163 * highaddr: High restricted address that cannot appear in a mapping.163 * highaddr: High restricted address that cannot appear in a mapping.
164 * filtfunc: An optional function to further test if an address164 * filtfunc: (deprecated, must be NULL)
165 * within the range of lowaddr and highaddr cannot appear165 * filtfuncarg: (deprecated, must be NULL)
166 * in a mapping.
167 * filtfuncarg: An argument that will be passed to filtfunc in addition
168 * to the address to test.
169 * maxsize: Maximum mapping size supported by this tag.166 * maxsize: Maximum mapping size supported by this tag.
170 * nsegments: Number of discontinuities allowed in maps.167 * nsegments: Number of discontinuities allowed in maps.
171 * maxsegsz: Maximum size of a segment in the map.168 * maxsegsz: Maximum size of a segment in the map.
lib/libc/include/generic-freebsd/sys/callout.h+7-14
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)callout.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_CALLOUT_H_37#ifndef _SYS_CALLOUT_H_
...@@ -41,7 +39,7 @@...@@ -41,7 +39,7 @@
4139
42#include <sys/_callout.h>40#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 */
45#define CALLOUT_ACTIVE 0x0002 /* callout is currently active */43#define CALLOUT_ACTIVE 0x0002 /* callout is currently active */
46#define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */44#define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */
47#define CALLOUT_MPSAFE 0x0008 /* deprecated */45#define CALLOUT_MPSAFE 0x0008 /* deprecated */
...@@ -83,18 +81,15 @@...@@ -83,18 +81,15 @@
83 */81 */
84#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE)82#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE)
85#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE)83#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)
87void callout_init(struct callout *, int);85void callout_init(struct callout *, int);
88void _callout_init_lock(struct callout *, struct lock_object *, int);86void _callout_init_lock(struct callout *, struct lock_object *, int);
89#define callout_init_mtx(c, mtx, flags) \87#define callout_init_mtx(c, mtx, flags) \
90 _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \88 _callout_init_lock((c), &(mtx)->lock_object, (flags))
91 NULL, (flags))
92#define callout_init_rm(c, rm, flags) \89#define callout_init_rm(c, rm, flags) \
93 _callout_init_lock((c), ((rm) != NULL) ? &(rm)->lock_object : \90 _callout_init_lock((c), &(rm)->lock_object, (flags))
94 NULL, (flags))
95#define callout_init_rw(c, rw, flags) \91#define callout_init_rw(c, rw, flags) \
96 _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \92 _callout_init_lock((c), &(rw)->lock_object, (flags))
97 NULL, (flags))
98#define callout_pending(c) ((c)->c_iflags & CALLOUT_PENDING)93#define callout_pending(c) ((c)->c_iflags & CALLOUT_PENDING)
99int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t,94int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t,
100 void (*)(void *), void *, int, int);95 void (*)(void *), void *, int, int);
...@@ -121,11 +116,9 @@ int callout_schedule(struct callout *, int);...@@ -121,11 +116,9 @@ int callout_schedule(struct callout *, int);
121int callout_schedule_on(struct callout *, int, int);116int callout_schedule_on(struct callout *, int, int);
122#define callout_schedule_curcpu(c, on_tick) \117#define callout_schedule_curcpu(c, on_tick) \
123 callout_schedule_on((c), (on_tick), PCPU_GET(cpuid))118 callout_schedule_on((c), (on_tick), PCPU_GET(cpuid))
124#define callout_stop(c) _callout_stop_safe(c, 0, NULL)119#define callout_stop(c) _callout_stop_safe(c, 0)
125int _callout_stop_safe(struct callout *, int, void (*)(void *));120int _callout_stop_safe(struct callout *, int);
126void callout_process(sbintime_t now);121void callout_process(sbintime_t now);
127#define callout_async_drain(c, d) \
128 _callout_stop_safe(c, 0, d)
129void callout_when(sbintime_t sbt, sbintime_t precision, int flags,122void callout_when(sbintime_t sbt, sbintime_t precision, int flags,
130 sbintime_t *sbt_res, sbintime_t *prec_res);123 sbintime_t *sbt_res, sbintime_t *prec_res);
131#endif124#endif
lib/libc/include/generic-freebsd/sys/caprights.h+48-45
...@@ -58,51 +58,54 @@ typedef struct cap_rights cap_rights_t;...@@ -58,51 +58,54 @@ typedef struct cap_rights cap_rights_t;
58#endif58#endif
5959
60#ifdef _KERNEL60#ifdef _KERNEL
61extern cap_rights_t cap_accept_rights;61extern const cap_rights_t cap_accept_rights;
62extern cap_rights_t cap_bind_rights;62extern const cap_rights_t cap_bind_rights;
63extern cap_rights_t cap_connect_rights;63extern const cap_rights_t cap_connect_rights;
64extern cap_rights_t cap_event_rights;64extern const cap_rights_t cap_event_rights;
65extern cap_rights_t cap_fchdir_rights;65extern const cap_rights_t cap_fchdir_rights;
66extern cap_rights_t cap_fchflags_rights;66extern const cap_rights_t cap_fchflags_rights;
67extern cap_rights_t cap_fchmod_rights;67extern const cap_rights_t cap_fchmod_rights;
68extern cap_rights_t cap_fchown_rights;68extern const cap_rights_t cap_fchown_rights;
69extern cap_rights_t cap_fcntl_rights;69extern const cap_rights_t cap_fchroot_rights;
70extern cap_rights_t cap_fexecve_rights;70extern const cap_rights_t cap_fcntl_rights;
71extern cap_rights_t cap_flock_rights;71extern const cap_rights_t cap_fexecve_rights;
72extern cap_rights_t cap_fpathconf_rights;72extern const cap_rights_t cap_flock_rights;
73extern cap_rights_t cap_fstat_rights;73extern const cap_rights_t cap_fpathconf_rights;
74extern cap_rights_t cap_fstatfs_rights;74extern const cap_rights_t cap_fstat_rights;
75extern cap_rights_t cap_fsync_rights;75extern const cap_rights_t cap_fstatfs_rights;
76extern cap_rights_t cap_ftruncate_rights;76extern const cap_rights_t cap_fsync_rights;
77extern cap_rights_t cap_futimes_rights;77extern const cap_rights_t cap_ftruncate_rights;
78extern cap_rights_t cap_getpeername_rights;78extern const cap_rights_t cap_futimes_rights;
79extern cap_rights_t cap_getsockopt_rights;79extern const cap_rights_t cap_getpeername_rights;
80extern cap_rights_t cap_getsockname_rights;80extern const cap_rights_t cap_getsockopt_rights;
81extern cap_rights_t cap_ioctl_rights;81extern const cap_rights_t cap_getsockname_rights;
82extern cap_rights_t cap_linkat_source_rights;82extern const cap_rights_t cap_inotify_add_rights;
83extern cap_rights_t cap_linkat_target_rights;83extern const cap_rights_t cap_inotify_rm_rights;
84extern cap_rights_t cap_listen_rights;84extern const cap_rights_t cap_ioctl_rights;
85extern cap_rights_t cap_mkdirat_rights;85extern const cap_rights_t cap_linkat_source_rights;
86extern cap_rights_t cap_mkfifoat_rights;86extern const cap_rights_t cap_linkat_target_rights;
87extern cap_rights_t cap_mknodat_rights;87extern const cap_rights_t cap_listen_rights;
88extern cap_rights_t cap_mmap_rights;88extern const cap_rights_t cap_mkdirat_rights;
89extern cap_rights_t cap_no_rights;89extern const cap_rights_t cap_mkfifoat_rights;
90extern cap_rights_t cap_pdgetpid_rights;90extern const cap_rights_t cap_mknodat_rights;
91extern cap_rights_t cap_pdkill_rights;91extern const cap_rights_t cap_mmap_rights;
92extern cap_rights_t cap_pread_rights;92extern const cap_rights_t cap_no_rights;
93extern cap_rights_t cap_pwrite_rights;93extern const cap_rights_t cap_pdgetpid_rights;
94extern cap_rights_t cap_read_rights;94extern const cap_rights_t cap_pdkill_rights;
95extern cap_rights_t cap_recv_rights;95extern const cap_rights_t cap_pread_rights;
96extern cap_rights_t cap_renameat_source_rights;96extern const cap_rights_t cap_pwrite_rights;
97extern cap_rights_t cap_renameat_target_rights;97extern const cap_rights_t cap_read_rights;
98extern cap_rights_t cap_seek_rights;98extern const cap_rights_t cap_recv_rights;
99extern cap_rights_t cap_send_rights;99extern const cap_rights_t cap_renameat_source_rights;
100extern cap_rights_t cap_send_connect_rights;100extern const cap_rights_t cap_renameat_target_rights;
101extern cap_rights_t cap_setsockopt_rights;101extern const cap_rights_t cap_seek_rights;
102extern cap_rights_t cap_shutdown_rights;102extern const cap_rights_t cap_send_rights;
103extern cap_rights_t cap_symlinkat_rights;103extern const cap_rights_t cap_send_connect_rights;
104extern cap_rights_t cap_unlinkat_rights;104extern const cap_rights_t cap_setsockopt_rights;
105extern cap_rights_t cap_write_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;
106#endif109#endif
107110
108#endif /* !_SYS_CAPRIGHTS_H_ */111#endif /* !_SYS_CAPRIGHTS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/capsicum.h+28-6
...@@ -39,7 +39,6 @@...@@ -39,7 +39,6 @@
39#ifndef _SYS_CAPSICUM_H_39#ifndef _SYS_CAPSICUM_H_
40#define _SYS_CAPSICUM_H_40#define _SYS_CAPSICUM_H_
4141
42#include <sys/cdefs.h>
43#include <sys/param.h>42#include <sys/param.h>
4443
45#include <sys/caprights.h>44#include <sys/caprights.h>
...@@ -202,6 +201,9 @@...@@ -202,6 +201,9 @@
202/* Allows for renameat(2) (target directory descriptor). */201/* Allows for renameat(2) (target directory descriptor). */
203#define CAP_RENAMEAT_TARGET (CAP_LOOKUP | 0x0000040000000000ULL)202#define CAP_RENAMEAT_TARGET (CAP_LOOKUP | 0x0000040000000000ULL)
204203
204/* Allows for fchroot(2). */
205#define CAP_FCHROOT CAPRIGHT(0, 0x0000080000000000ULL)
206
205#define CAP_SOCK_CLIENT \207#define CAP_SOCK_CLIENT \
206 (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \208 (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
207 CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)209 CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
...@@ -211,11 +213,9 @@...@@ -211,11 +213,9 @@
211 CAP_SETSOCKOPT | CAP_SHUTDOWN)213 CAP_SETSOCKOPT | CAP_SHUTDOWN)
212214
213/* All used bits for index 0. */215/* All used bits for index 0. */
214#define CAP_ALL0 CAPRIGHT(0, 0x000007FFFFFFFFFFULL)216#define CAP_ALL0 CAPRIGHT(0, 0x00000FFFFFFFFFFFULL)
215217
216/* Available bits for index 0. */218/* Available bits for index 0. */
217#define CAP_UNUSED0_44 CAPRIGHT(0, 0x0000080000000000ULL)
218/* ... */
219#define CAP_UNUSED0_57 CAPRIGHT(0, 0x0100000000000000ULL)219#define CAP_UNUSED0_57 CAPRIGHT(0, 0x0100000000000000ULL)
220220
221/* INDEX 1 */221/* INDEX 1 */
...@@ -279,11 +279,15 @@...@@ -279,11 +279,15 @@
279279
280#define CAP_KQUEUE (CAP_KQUEUE_EVENT | CAP_KQUEUE_CHANGE)280#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
282/* All used bits for index 1. */286/* All used bits for index 1. */
283#define CAP_ALL1 CAPRIGHT(1, 0x00000000001FFFFFULL)287#define CAP_ALL1 CAPRIGHT(1, 0x00000000007FFFFFULL)
284288
285/* Available bits for index 1. */289/* Available bits for index 1. */
286#define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000200000ULL)290#define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000800000ULL)
287/* ... */291/* ... */
288#define CAP_UNUSED1_57 CAPRIGHT(1, 0x0100000000000000ULL)292#define CAP_UNUSED1_57 CAPRIGHT(1, 0x0100000000000000ULL)
289293
...@@ -371,6 +375,24 @@ _Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00,...@@ -371,6 +375,24 @@ _Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00,
371 _r; \375 _r; \
372})376})
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
374/*396/*
375 * Allow checking caps which are possibly getting modified at the same time.397 * Allow checking caps which are possibly getting modified at the same time.
376 * The caller is expected to determine whether the result is legitimate via398 * 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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
35 */33 */
3634
37#ifndef _SYS_CDEFS_H_35#ifndef _SYS_CDEFS_H_
...@@ -42,7 +40,10 @@...@@ -42,7 +40,10 @@
42#endif40#endif
4341
44/*42/*
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.
46 */47 */
47#ifndef __has_attribute48#ifndef __has_attribute
48#define __has_attribute(x) 049#define __has_attribute(x) 0
...@@ -74,61 +75,34 @@...@@ -74,61 +75,34 @@
74 * having a compiler-agnostic source tree.75 * having a compiler-agnostic source tree.
75 */76 */
7677
78/*
79 * Macro to test if we're using a specific version of gcc or later.
80 */
77#if defined(__GNUC__)81#if defined(__GNUC__)
7882#define __GNUC_PREREQ__(ma, mi) \
79#if __GNUC__ >= 383 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
80#define __GNUCLIKE_ASM 3
81#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
82#else84#else
83#define __GNUCLIKE_ASM 285#define __GNUC_PREREQ__(ma, mi) 0
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
96#endif86#endif
9787
98#define __GNUC_VA_LIST_COMPATIBILITY 188#if defined(__GNUC__)
9989
100/*90/*
101 * Compiler memory barriers, specific to gcc and clang.91 * Compiler memory barriers, specific to gcc and clang.
102 */92 */
103#define __compiler_membar() __asm __volatile(" " : : : "memory")93#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
112#define __CC_SUPPORTS___INLINE 195#define __CC_SUPPORTS___INLINE 1
113#define __CC_SUPPORTS___INLINE__ 196#define __CC_SUPPORTS_SYMVER 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
12197
122#endif /* __GNUC__ */98#endif /* __GNUC__ */
12399
124/*100/*
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.
126 */103 */
127#if defined(__GNUC__)104#ifdef __TINYC__
128#define __GNUC_PREREQ__(ma, mi) \105#undef __CC_SUPPORTS_SYMVER
129 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
130#else
131#define __GNUC_PREREQ__(ma, mi) 0
132#endif106#endif
133107
134/*108/*
...@@ -150,8 +124,6 @@...@@ -150,8 +124,6 @@
150#define __STRING(x) #x /* stringify without expanding x */124#define __STRING(x) #x /* stringify without expanding x */
151#define __XSTRING(x) __STRING(x) /* expand x, then stringify */125#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
152126
153#define __const const /* define reserved names to standard */
154#define __signed signed
155#define __volatile volatile127#define __volatile volatile
156#if defined(__cplusplus)128#if defined(__cplusplus)
157#define __inline inline /* convert to C++ keyword */129#define __inline inline /* convert to C++ keyword */
...@@ -165,76 +137,32 @@...@@ -165,76 +137,32 @@
165#define __P(protos) () /* traditional C preprocessor */137#define __P(protos) () /* traditional C preprocessor */
166#define __CONCAT(x,y) x/**/y138#define __CONCAT(x,y) x/**/y
167#define __STRING(x) "x"139#define __STRING(x) "x"
168
169#if !defined(__CC_SUPPORTS___INLINE)140#if !defined(__CC_SUPPORTS___INLINE)
170#define __const /* delete pseudo-ANSI C keywords */141/* Just delete these in a K&R environment */
171#define __inline142#define __inline
172#define __signed
173#define __volatile143#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 */
188#endif /* !__CC_SUPPORTS___INLINE */144#endif /* !__CC_SUPPORTS___INLINE */
189#endif /* !(__STDC__ || __cplusplus) */145#endif /* !(__STDC__ || __cplusplus) */
190146
191/*147/*
192 * Compiler-dependent macros to help declare dead (non-returning) and148 * Compiler-dependent macros to help declare dead (non-returning) and pure (no
193 * pure (no side effects) functions, and unused variables. They are149 * side effects) functions, and unused variables. These attributes are supported
194 * null except for versions of gcc that are known to support the features150 * by all current compilers, even pcc.
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.
199 */151 */
200#define __weak_symbol __attribute__((__weak__))152#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)
213#define __dead2 __attribute__((__noreturn__))153#define __dead2 __attribute__((__noreturn__))
214#define __pure2 __attribute__((__const__))154#define __pure2 __attribute__((__const__))
215#define __unused __attribute__((__unused__))155#define __unused __attribute__((__unused__))
216#define __used __attribute__((__used__))156#define __used __attribute__((__used__))
157#define __deprecated __attribute__((__deprecated__))
158#define __deprecated1(msg) __attribute__((__deprecated__(msg)))
217#define __packed __attribute__((__packed__))159#define __packed __attribute__((__packed__))
218#define __aligned(x) __attribute__((__aligned__(x)))160#define __aligned(x) __attribute__((__aligned__(x)))
219#define __section(x) __attribute__((__section__(x)))161#define __section(x) __attribute__((__section__(x)))
220#endif
221#define __writeonly __unused162#define __writeonly __unused
222#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
223#define __alloc_size(x) __attribute__((__alloc_size__(x)))163#define __alloc_size(x) __attribute__((__alloc_size__(x)))
224#define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x)))164#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__)
230#define __alloc_align(x) __attribute__((__alloc_align__(x)))165#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
239/*167/*
240 * Keywords added in C11.168 * Keywords added in C11.
...@@ -258,15 +186,6 @@...@@ -258,15 +186,6 @@
258#define _Alignof(x) __alignof(x)186#define _Alignof(x) __alignof(x)
259#endif187#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
270#if defined(__cplusplus) && __cplusplus >= 201103L189#if defined(__cplusplus) && __cplusplus >= 201103L
271#define _Noreturn [[noreturn]]190#define _Noreturn [[noreturn]]
272#else191#else
...@@ -281,12 +200,7 @@...@@ -281,12 +200,7 @@
281#endif200#endif
282201
283#if !__has_extension(c_thread_local)202#if !__has_extension(c_thread_local)
284/*203#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
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) || */ \
290 __has_extension(cxx_thread_local)204 __has_extension(cxx_thread_local)
291#define _Thread_local thread_local205#define _Thread_local thread_local
292#else206#else
...@@ -312,10 +226,10 @@...@@ -312,10 +226,10 @@
312 __has_extension(c_generic_selections)226 __has_extension(c_generic_selections)
313#define __generic(expr, t, yes, no) \227#define __generic(expr, t, yes, no) \
314 _Generic(expr, t: yes, default: no)228 _Generic(expr, t: yes, default: no)
315#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)229#elif !defined(__cplusplus)
316#define __generic(expr, t, yes, no) \230#define __generic(expr, t, yes, no) \
317 __builtin_choose_expr( \231 __builtin_choose_expr(__builtin_types_compatible_p( \
318 __builtin_types_compatible_p(__typeof((0, (expr))), t), yes, no)232 __typeof(((void)0, (expr))), t), yes, no)
319#endif233#endif
320234
321/*235/*
...@@ -326,59 +240,24 @@...@@ -326,59 +240,24 @@
326 * void bar(int myArray[__min_size(10)]);240 * void bar(int myArray[__min_size(10)]);
327 */241 */
328#if !defined(__cplusplus) && \242#if !defined(__cplusplus) && \
329 (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
330 (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))243 (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
331#define __min_size(x) static (x)244#define __min_size(x) static (x)
332#else245#else
333#define __min_size(x) (x)246#define __min_size(x) (x)
334#endif247#endif
335248
336#if __GNUC_PREREQ__(2, 96)
337#define __malloc_like __attribute__((__malloc__))249#define __malloc_like __attribute__((__malloc__))
338#define __pure __attribute__((__pure__))250#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__))
351#define __noinline __attribute__ ((__noinline__))253#define __noinline __attribute__ ((__noinline__))
352#else
353#define __noinline
354#endif
355
356#if __GNUC_PREREQ__(3, 4)
357#define __fastcall __attribute__((__fastcall__))254#define __fastcall __attribute__((__fastcall__))
358#define __result_use_check __attribute__((__warn_unused_result__))255#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)
365#define __returns_twice __attribute__((__returns_twice__))256#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)
371#define __unreachable() __builtin_unreachable()258#define __unreachable() __builtin_unreachable()
372#else
373#define __unreachable() ((void)0)
374#endif
375259
376/* XXX: should use `#if __STDC_VERSION__ < 199901'. */260#if !defined(__STRICT_ANSI__) || __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
382#define __LONG_LONG_SUPPORTED261#define __LONG_LONG_SUPPORTED
383#endif262#endif
384263
...@@ -393,6 +272,55 @@...@@ -393,6 +272,55 @@
393#endif272#endif
394#endif273#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
396/*324/*
397 * We use `__restrict' as a way to define the `restrict' type qualifier325 * We use `__restrict' as a way to define the `restrict' type qualifier
398 * without disturbing older software that is unaware of C99 keywords.326 * without disturbing older software that is unaware of C99 keywords.
...@@ -401,73 +329,27 @@...@@ -401,73 +329,27 @@
401 */329 */
402#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901330#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901
403#define __restrict restrict331#define __restrict restrict
404#elif !__GNUC_PREREQ__(2, 95)
405#define __restrict
406#endif332#endif
407333
408/*334/*
409 * GNU C version 2.96 adds explicit branch prediction so that335 * All modern compilers have explicit branch prediction so that the CPU back-end
410 * the CPU back-end can hint the processor and also so that336 * can hint to the processor and also so that code blocks can be reordered such
411 * code blocks can be reordered such that the predicted path337 * that the predicted path sees a more linear flow, thus improving cache
412 * sees a more linear flow, thus improving cache behavior, etc.338 * behavior, etc. Use sparingly, except in performance critical code where
413 *339 * they make things measurably faster.
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.
435 */340 */
436#if __GNUC_PREREQ__(2, 96)
437#define __predict_true(exp) __builtin_expect((exp), 1)341#define __predict_true(exp) __builtin_expect((exp), 1)
438#define __predict_false(exp) __builtin_expect((exp), 0)342#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)
445#define __null_sentinel __attribute__((__sentinel__))344#define __null_sentinel __attribute__((__sentinel__))
446#define __exported __attribute__((__visibility__("default")))345#define __exported __attribute__((__visibility__("default")))
447#define __hidden __attribute__((__visibility__("hidden")))346#define __hidden __attribute__((__visibility__("hidden")))
448#else
449#define __null_sentinel
450#define __exported
451#define __hidden
452#endif
453347
454/*348/*
455 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>349 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
456 * require it.350 * require it.
457 */351 */
458#if __GNUC_PREREQ__(4, 1)
459#define __offsetof(type, field) __builtin_offsetof(type, field)352#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
471#define __rangeof(type, start, end) \353#define __rangeof(type, start, end) \
472 (__offsetof(type, end) - __offsetof(type, start))354 (__offsetof(type, end) - __offsetof(type, start))
473355
...@@ -477,29 +359,15 @@...@@ -477,29 +359,15 @@
477 * assign pointer x to a local variable, to check that its type is359 * assign pointer x to a local variable, to check that its type is
478 * compatible with member m.360 * compatible with member m.
479 */361 */
480#if __GNUC_PREREQ__(3, 1)
481#define __containerof(x, s, m) ({ \362#define __containerof(x, s, m) ({ \
482 const volatile __typeof(((s *)0)->m) *__x = (x); \363 const volatile __typeof(((s *)0)->m) *__x = (x); \
483 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\364 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
484})365})
485#else
486#define __containerof(x, s, m) \
487 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
488#endif
489366
490/*367/*
491 * Compiler-dependent macros to declare that functions take printf-like368 * Compiler-dependent macros to declare that functions take printf-like
492 * or scanf-like arguments. They are null except for versions of gcc369 * or scanf-like arguments.
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).
495 */370 */
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
503#define __printflike(fmtarg, firstvararg) \371#define __printflike(fmtarg, firstvararg) \
504 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))372 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
505#define __scanflike(fmtarg, firstvararg) \373#define __scanflike(fmtarg, firstvararg) \
...@@ -509,18 +377,23 @@...@@ -509,18 +377,23 @@
509 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))377 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
510#define __strftimelike(fmtarg, firstvararg) \378#define __strftimelike(fmtarg, firstvararg) \
511 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))379 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
512#endif
513380
514/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */381/*
515#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \382 * Like __printflike, but allows fmtarg to be NULL. FreeBSD invented 'printf0'
516 defined(__GNUC__)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))
517#define __printf0like(fmtarg, firstvararg) \391#define __printf0like(fmtarg, firstvararg) \
518 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))392 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
519#else393#else
520#define __printf0like(fmtarg, firstvararg)394#define __printf0like(fmtarg, firstvararg)
521#endif395#endif
522396
523#if defined(__GNUC__)
524#define __strong_reference(sym,aliassym) \397#define __strong_reference(sym,aliassym) \
525 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))398 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
526#ifdef __STDC__399#ifdef __STDC__
...@@ -531,10 +404,12 @@...@@ -531,10 +404,12 @@
531 __asm__(".section .gnu.warning." #sym); \404 __asm__(".section .gnu.warning." #sym); \
532 __asm__(".asciz \"" msg "\""); \405 __asm__(".asciz \"" msg "\""); \
533 __asm__(".previous")406 __asm__(".previous")
407#ifdef __CC_SUPPORTS_SYMVER
534#define __sym_compat(sym,impl,verid) \408#define __sym_compat(sym,impl,verid) \
535 __asm__(".symver " #impl ", " #sym "@" #verid)409 __asm__(".symver " #impl ", " #sym "@" #verid)
536#define __sym_default(sym,impl,verid) \410#define __sym_default(sym,impl,verid) \
537 __asm__(".symver " #impl ", " #sym "@@@" #verid)411 __asm__(".symver " #impl ", " #sym "@@@" #verid)
412#endif
538#else413#else
539#define __weak_reference(sym,alias) \414#define __weak_reference(sym,alias) \
540 __asm__(".weak alias"); \415 __asm__(".weak alias"); \
...@@ -543,27 +418,18 @@...@@ -543,27 +418,18 @@
543 __asm__(".section .gnu.warning.sym"); \418 __asm__(".section .gnu.warning.sym"); \
544 __asm__(".asciz \"msg\""); \419 __asm__(".asciz \"msg\""); \
545 __asm__(".previous")420 __asm__(".previous")
421#ifdef __CC_SUPPORTS_SYMVER
546#define __sym_compat(sym,impl,verid) \422#define __sym_compat(sym,impl,verid) \
547 __asm__(".symver impl, sym@verid")423 __asm__(".symver impl, sym@verid")
548#define __sym_default(impl,sym,verid) \424#define __sym_default(impl,sym,verid) \
549 __asm__(".symver impl, sym@@@verid")425 __asm__(".symver impl, sym@@@verid")
426#endif
550#endif /* __STDC__ */427#endif /* __STDC__ */
551#endif /* __GNUC__ */
552428
553#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))429#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))
554#define __WEAK(sym) __asm__(".weak " __XSTRING(sym))430#define __WEAK(sym) __asm__(".weak " __XSTRING(sym))
555431
556#if defined(__GNUC__)
557#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")432#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
568/*434/*
569 * Embed the rcs id of a source file in the resulting library. Note that in435 * Embed the rcs id of a source file in the resulting library. Note that in
...@@ -622,164 +488,13 @@...@@ -622,164 +488,13 @@
622#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))488#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
623#endif489#endif
624490
625/*-491#if !defined(_STANDALONE) && !defined(_KERNEL)
626 * The following definitions are an extension of the behavior originally492#define __RENAME(x) __asm(__STRING(x))
627 * implemented in <sys/_posix.h>, but with a different level of granularity.493#else /* _STANDALONE || _KERNEL */
628 * POSIX.1 requires that the macros we test be defined before any standard494#define __RENAME(x) no renaming in kernel/standalone environment
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
683#endif495#endif
684496
685/*497#include <sys/_visible.h>
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
783498
784/*499/*
785 * Nullability qualifiers: currently only supported by Clang.500 * Nullability qualifiers: currently only supported by Clang.
lib/libc/include/generic-freebsd/sys/cnv.h+1-7
...@@ -30,6 +30,7 @@...@@ -30,6 +30,7 @@
30#define _CNV_H_30#define _CNV_H_
3131
32#include <sys/cdefs.h>32#include <sys/cdefs.h>
33#include <sys/_nv.h>
3334
34#ifndef _KERNEL35#ifndef _KERNEL
35#include <stdarg.h>36#include <stdarg.h>
...@@ -39,13 +40,6 @@...@@ -39,13 +40,6 @@
39#include <sys/nv_namespace.h>40#include <sys/nv_namespace.h>
40#endif41#endif
4142
42#ifndef _NVLIST_T_DECLARED
43#define _NVLIST_T_DECLARED
44struct nvlist;
45
46typedef struct nvlist nvlist_t;
47#endif
48
49__BEGIN_DECLS43__BEGIN_DECLS
5044
51/*45/*
lib/libc/include/generic-freebsd/sys/compressor.h+1
...@@ -42,6 +42,7 @@ struct compressor;...@@ -42,6 +42,7 @@ struct compressor;
42bool compressor_avail(int format);42bool compressor_avail(int format);
43struct compressor *compressor_init(compressor_cb_t cb, int format,43struct compressor *compressor_init(compressor_cb_t cb, int format,
44 size_t maxiosize, int level, void *arg);44 size_t maxiosize, int level, void *arg);
45int compressor_format(const struct compressor *stream);
45void compressor_reset(struct compressor *stream);46void compressor_reset(struct compressor *stream);
46int compressor_write(struct compressor *stream, void *data,47int compressor_write(struct compressor *stream, void *data,
47 size_t len);48 size_t len);
lib/libc/include/generic-freebsd/sys/conf.h+4-2
...@@ -34,8 +34,6 @@...@@ -34,8 +34,6 @@
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.36 * SUCH DAMAGE.
37 *
38 * @(#)conf.h 8.5 (Berkeley) 1/9/95
39 */37 */
4038
41#ifndef _SYS_CONF_H_39#ifndef _SYS_CONF_H_
...@@ -46,6 +44,7 @@...@@ -46,6 +44,7 @@
46#else44#else
47#include <sys/queue.h>45#include <sys/queue.h>
48#endif46#endif
47#include <sys/_timespec.h>
4948
50struct snapdata;49struct snapdata;
51struct devfs_dirent;50struct devfs_dirent;
...@@ -160,6 +159,7 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh);...@@ -160,6 +159,7 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh);
160#define GID_RT_PRIO 47159#define GID_RT_PRIO 47
161#define GID_ID_PRIO 48160#define GID_ID_PRIO 48
162#define GID_DIALER 68161#define GID_DIALER 68
162#define GID_U2F 116
163#define GID_NOGROUP 65533163#define GID_NOGROUP 65533
164#define GID_NOBODY 65534164#define GID_NOBODY 65534
165165
...@@ -278,6 +278,7 @@ void destroy_dev(struct cdev *_dev);...@@ -278,6 +278,7 @@ void destroy_dev(struct cdev *_dev);
278int destroy_dev_sched(struct cdev *dev);278int destroy_dev_sched(struct cdev *dev);
279int destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg);279int destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg);
280void destroy_dev_drain(struct cdevsw *csw);280void destroy_dev_drain(struct cdevsw *csw);
281void dev_copyname(struct cdev *dev, char *path, size_t len);
281struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref);282struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref);
282struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref);283struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref);
283void dev_relthread(struct cdev *_dev, int _ref);284void dev_relthread(struct cdev *_dev, int _ref);
...@@ -360,6 +361,7 @@ struct dumperinfo {...@@ -360,6 +361,7 @@ struct dumperinfo {
360};361};
361362
362extern int dumping; /* system is dumping */363extern int dumping; /* system is dumping */
364extern bool dumped_core; /* system successfully dumped kernel core */
363365
364/*366/*
365 * Save registers for later extraction from a kernel dump.367 * Save registers for later extraction from a kernel dump.
lib/libc/include/generic-freebsd/sys/cons.h+2-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)cons.h 7.2 (Berkeley) 5/9/91
37 */35 */
3836
39#ifndef _MACHINE_CONS_H_37#ifndef _MACHINE_CONS_H_
...@@ -96,6 +94,8 @@ struct consdev {...@@ -96,6 +94,8 @@ struct consdev {
9694
97#ifdef _KERNEL95#ifdef _KERNEL
9896
97extern int cn_mute;
98
99extern struct msgbuf consmsgbuf; /* Message buffer for constty. */99extern struct msgbuf consmsgbuf; /* Message buffer for constty. */
100extern struct tty *constty; /* Temporary virtual console. */100extern struct tty *constty; /* Temporary virtual console. */
101101
lib/libc/include/generic-freebsd/sys/copyright.h+2-2
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * SPDX-License-Identifier: BSD-2-Clause
3 *3 *
4 * Copyright (C) 1992-2023 The FreeBSD Project. All rights reserved.4 * Copyright (C) 1992-2025 The FreeBSD Project. All rights reserved.
5 *5 *
6 * Redistribution and use in source and binary forms, with or without6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions7 * modification, are permitted provided that the following conditions
...@@ -35,7 +35,7 @@...@@ -35,7 +35,7 @@
3535
36/* FreeBSD */36/* FreeBSD */
37#define COPYRIGHT_FreeBSD \37#define COPYRIGHT_FreeBSD \
38 "Copyright (c) 1992-2023 The FreeBSD Project.\n"38 "Copyright (c) 1992-2025 The FreeBSD Project.\n"
3939
40/* Foundation */40/* Foundation */
41#define TRADEMARK_Foundation \41#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);...@@ -60,17 +60,12 @@ uint64_t counter_u64_fetch(counter_u64_t);
60 counter_u64_zero((a)[_i]); \60 counter_u64_zero((a)[_i]); \
61} while (0)61} while (0)
6262
63/*63struct counter_rate;
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};
7264
65struct counter_rate *counter_rate_alloc(int flags, int period);
66void counter_rate_free(struct counter_rate *);
73int64_t counter_ratecheck(struct counter_rate *, int64_t);67int64_t counter_ratecheck(struct counter_rate *, int64_t);
68uint64_t counter_rate_get(struct counter_rate *);
7469
75#define COUNTER_U64_SYSINIT(c) \70#define COUNTER_U64_SYSINIT(c) \
76 SYSINIT(c##_counter_sysinit, SI_SUB_COUNTER, \71 SYSINIT(c##_counter_sysinit, SI_SUB_COUNTER, \
lib/libc/include/generic-freebsd/sys/cpuset.h+2
...@@ -61,8 +61,10 @@...@@ -61,8 +61,10 @@
61#define CPU_ANDNOT(d, s1, s2) __BIT_ANDNOT2(CPU_SETSIZE, d, s1, s2)61#define CPU_ANDNOT(d, s1, s2) __BIT_ANDNOT2(CPU_SETSIZE, d, s1, s2)
62#define CPU_XOR(d, s1, s2) __BIT_XOR2(CPU_SETSIZE, d, s1, s2)62#define CPU_XOR(d, s1, s2) __BIT_XOR2(CPU_SETSIZE, d, s1, s2)
63#define CPU_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(CPU_SETSIZE, n, p)63#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)
64#define CPU_SET_ATOMIC(n, p) __BIT_SET_ATOMIC(CPU_SETSIZE, n, p)65#define CPU_SET_ATOMIC(n, p) __BIT_SET_ATOMIC(CPU_SETSIZE, n, p)
65#define CPU_SET_ATOMIC_ACQ(n, p) __BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p)66#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)
66#define CPU_AND_ATOMIC(n, p) __BIT_AND_ATOMIC(CPU_SETSIZE, n, p)68#define CPU_AND_ATOMIC(n, p) __BIT_AND_ATOMIC(CPU_SETSIZE, n, p)
67#define CPU_OR_ATOMIC(d, s) __BIT_OR_ATOMIC(CPU_SETSIZE, d, s)69#define CPU_OR_ATOMIC(d, s) __BIT_OR_ATOMIC(CPU_SETSIZE, d, s)
68#define CPU_COPY_STORE_REL(f, t) __BIT_COPY_STORE_REL(CPU_SETSIZE, f, t)70#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 {...@@ -125,6 +125,7 @@ typedef enum {
125 DEVSTAT_TYPE_IF_SCSI = 0x010,125 DEVSTAT_TYPE_IF_SCSI = 0x010,
126 DEVSTAT_TYPE_IF_IDE = 0x020,126 DEVSTAT_TYPE_IF_IDE = 0x020,
127 DEVSTAT_TYPE_IF_OTHER = 0x030,127 DEVSTAT_TYPE_IF_OTHER = 0x030,
128 DEVSTAT_TYPE_IF_NVME = 0x040,
128 DEVSTAT_TYPE_IF_MASK = 0x0f0,129 DEVSTAT_TYPE_IF_MASK = 0x0f0,
129 DEVSTAT_TYPE_PASS = 0x100130 DEVSTAT_TYPE_PASS = 0x100
130} devstat_type_flags;131} devstat_type_flags;
lib/libc/include/generic-freebsd/sys/devmap.h+5-18
...@@ -33,6 +33,7 @@...@@ -33,6 +33,7 @@
33#error "no user-serviceable parts inside"33#error "no user-serviceable parts inside"
34#endif34#endif
3535
36#ifdef __HAVE_STATIC_DEVMAP
36/*37/*
37 * This structure is used by MD code to describe static mappings of devices38 * This structure is used by MD code to describe static mappings of devices
38 * which are established as part of bringing up the MMU early in the boot.39 * 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);...@@ -71,27 +72,13 @@ void devmap_register_table(const struct devmap_entry * _table);
71 * Establish mappings for all the entries in the table. This is called72 * Establish mappings for all the entries in the table. This is called
72 * automatically from the common platform-specific init function in73 * automatically from the common platform-specific init function in
73 * <ARCH>/machdep.c, and also from the custom platform-specific init routines74 * <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 table75 * in older code. This function only has an effect when a table was installed
75 * installed previously by devmap_register_table().76 * previously by devmap_register_table().
76 */77 */
77void devmap_bootstrap(vm_offset_t _l1pt,78void devmap_bootstrap(void);
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);
9379
94/* Print the static mapping table; used for bootverbose output. */80/* Print the static mapping table; used for bootverbose output. */
95void devmap_print_table(void);81void devmap_print_table(void);
82#endif
9683
97#endif /* !_SYS_DEVMAP_H_ */84#endif /* !_SYS_DEVMAP_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/dirent.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)dirent.h 8.3 (Berkeley) 8/10/94
32 */30 */
3331
34#ifndef _SYS_DIRENT_H_32#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);...@@ -78,7 +78,7 @@ void disk_err(struct bio *bp, const char *what, int blkdone, int nl);
78 * only if they point at exactly the same physical storage, this is78 * only if they point at exactly the same physical storage, this is
79 * the case for multipathing for example,79 * the case for multipathing for example,
80 * - GEOM classes that consumes single providers and provide single80 * - GEOM classes that consumes single providers and provide single
81 * providers, like geli, gbde, should just attach class name to the81 * providers, like geli, should just attach class name to the
82 * ident of the underlying provider,82 * ident of the underlying provider,
83 * - ident is an ASCII string (is printable),83 * - ident is an ASCII string (is printable),
84 * - ident is optional and applications can't relay on its presence.84 * - 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 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
30 */28 */
3129
32#ifndef _SYS_DISK_BSD_H_30#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);...@@ -259,6 +259,9 @@ CTASSERT(sizeof(struct gpt_ent) == 128);
259#define GPT_ENT_TYPE_HIFIVE_BBL \259#define GPT_ENT_TYPE_HIFIVE_BBL \
260 {0x2e54b353,0x1271,0x4842,0x80,0x6f,{0xe4,0x36,0xd6,0xaf,0x69,0x85}}260 {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
262/*265/*
263 * Boot partition used by GRUB 2.266 * Boot partition used by GRUB 2.
264 */267 */
lib/libc/include/generic-freebsd/sys/disk/mbr.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
30 */28 */
3129
32#ifndef _SYS_DISK_MBR_H_30#ifndef _SYS_DISK_MBR_H_
lib/libc/include/generic-freebsd/sys/disklabel.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
32 */30 */
3331
34#ifndef _SYS_DISKLABEL_H_32#ifndef _SYS_DISKLABEL_H_
lib/libc/include/generic-freebsd/sys/diskmbr.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
32 */30 */
3331
34#ifndef _SYS_DISKMBR_H_32#ifndef _SYS_DISKMBR_H_
lib/libc/include/generic-freebsd/sys/dkstat.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)dkstat.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_DKSTAT_H_37#ifndef _SYS_DKSTAT_H_
lib/libc/include/generic-freebsd/sys/dnv.h+1-7
...@@ -32,6 +32,7 @@...@@ -32,6 +32,7 @@
32#define _DNV_H_32#define _DNV_H_
3333
34#include <sys/cdefs.h>34#include <sys/cdefs.h>
35#include <sys/_nv.h>
3536
36#ifndef _KERNEL37#ifndef _KERNEL
37#include <stdarg.h>38#include <stdarg.h>
...@@ -41,13 +42,6 @@...@@ -41,13 +42,6 @@
41#include <sys/nv_namespace.h>42#include <sys/nv_namespace.h>
42#endif43#endif
4344
44#ifndef _NVLIST_T_DECLARED
45#define _NVLIST_T_DECLARED
46struct nvlist;
47
48typedef struct nvlist nvlist_t;
49#endif
50
51__BEGIN_DECLS45__BEGIN_DECLS
5246
53/*47/*
lib/libc/include/generic-freebsd/sys/domain.h-6
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)domain.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_DOMAIN_H_32#ifndef _SYS_DOMAIN_H_
...@@ -54,10 +52,6 @@ struct domain {...@@ -54,10 +52,6 @@ struct domain {
54 char *dom_name;52 char *dom_name;
55 int dom_flags;53 int dom_flags;
56 int (*dom_probe)(void); /* check for support (optional) */54 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 *);
61 struct rib_head *(*dom_rtattach) /* initialize routing table */55 struct rib_head *(*dom_rtattach) /* initialize routing table */
62 (uint32_t);56 (uint32_t);
63 void (*dom_rtdetach) /* clean up routing table */57 void (*dom_rtdetach) /* clean up routing table */
lib/libc/include/generic-freebsd/sys/domainset.h+14
...@@ -113,6 +113,20 @@ void domainset_zero(void);...@@ -113,6 +113,20 @@ void domainset_zero(void);
113 * returned value will not match the key pointer.113 * returned value will not match the key pointer.
114 */114 */
115struct domainset *domainset_create(const struct domainset *);115struct 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
116#ifdef _SYS_SYSCTL_H_130#ifdef _SYS_SYSCTL_H_
117int sysctl_handle_domainset(SYSCTL_HANDLER_ARGS);131int sysctl_handle_domainset(SYSCTL_HANDLER_ARGS);
118#endif132#endif
lib/libc/include/generic-freebsd/sys/efi.h+52-22
...@@ -35,15 +35,17 @@...@@ -35,15 +35,17 @@
35#define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1)35#define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1)
3636
37#define EFI_TABLE_SMBIOS \37#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}}
39#define EFI_TABLE_SMBIOS3 \39#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}}
41#define EFI_TABLE_ESRT \41#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}}
43#define EFI_PROPERTIES_TABLE \43#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}}
45#define LINUX_EFI_MEMRESERVE_TABLE \47#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
48enum efi_reset {50enum efi_reset {
49 EFI_RESET_COLD = 0,51 EFI_RESET_COLD = 0,
...@@ -54,8 +56,20 @@ enum efi_reset {...@@ -54,8 +56,20 @@ enum efi_reset {
54typedef uint16_t efi_char;56typedef uint16_t efi_char;
55typedef unsigned long efi_status;57typedef 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
57struct efi_cfgtbl {71struct efi_cfgtbl {
58 struct uuid ct_uuid;72 efi_guid_t ct_guid;
59 void *ct_data;73 void *ct_data;
60};74};
6175
...@@ -139,7 +153,7 @@ struct efi_esrt_table {...@@ -139,7 +153,7 @@ struct efi_esrt_table {
139};153};
140154
141struct efi_esrt_entry_v1 {155struct efi_esrt_entry_v1 {
142 struct uuid fw_class;156 efi_guid_t fw_class;
143 uint32_t fw_type;157 uint32_t fw_type;
144 uint32_t fw_version;158 uint32_t fw_version;
145 uint32_t lowest_supported_fw_version;159 uint32_t lowest_supported_fw_version;
...@@ -154,6 +168,22 @@ struct efi_prop_table {...@@ -154,6 +168,22 @@ struct efi_prop_table {
154 uint64_t memory_protection_attribute;168 uint64_t memory_protection_attribute;
155};169};
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
157#ifdef _KERNEL187#ifdef _KERNEL
158188
159#ifdef EFIABI_ATTR189#ifdef EFIABI_ATTR
...@@ -169,11 +199,11 @@ struct efi_rt {...@@ -169,11 +199,11 @@ struct efi_rt {
169 efi_status (*rt_setvirtual)(u_long, u_long, uint32_t,199 efi_status (*rt_setvirtual)(u_long, u_long, uint32_t,
170 struct efi_md *) EFIABI_ATTR;200 struct efi_md *) EFIABI_ATTR;
171 efi_status (*rt_cvtptr)(u_long, void **) EFIABI_ATTR;201 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 *,
173 u_long *, void *) EFIABI_ATTR;203 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 *)
175 EFIABI_ATTR;205 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,
177 u_long, void *) EFIABI_ATTR;207 u_long, void *) EFIABI_ATTR;
178 efi_status (*rt_gethicnt)(uint32_t *) EFIABI_ATTR;208 efi_status (*rt_gethicnt)(uint32_t *) EFIABI_ATTR;
179 efi_status (*rt_reset)(enum efi_reset, efi_status, u_long,209 efi_status (*rt_reset)(enum efi_reset, efi_status, u_long,
...@@ -246,8 +276,8 @@ struct efi_ops {...@@ -246,8 +276,8 @@ struct efi_ops {
246 * access them.276 * access them.
247 */277 */
248 int (*rt_ok)(void);278 int (*rt_ok)(void);
249 int (*get_table)(struct uuid *, void **);279 int (*get_table)(efi_guid_t *, void **);
250 int (*copy_table)(struct uuid *, void **, size_t, size_t *);280 int (*copy_table)(efi_guid_t *, void **, size_t, size_t *);
251 int (*get_time)(struct efi_tm *);281 int (*get_time)(struct efi_tm *);
252 int (*get_time_capabilities)(struct efi_tmcap *);282 int (*get_time_capabilities)(struct efi_tmcap *);
253 int (*reset_system)(enum efi_reset);283 int (*reset_system)(enum efi_reset);
...@@ -255,10 +285,10 @@ struct efi_ops {...@@ -255,10 +285,10 @@ struct efi_ops {
255 int (*get_waketime)(uint8_t *enabled, uint8_t *pending,285 int (*get_waketime)(uint8_t *enabled, uint8_t *pending,
256 struct efi_tm *tm);286 struct efi_tm *tm);
257 int (*set_waketime)(uint8_t enable, struct efi_tm *tm);287 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 *,
259 void *);289 void *);
260 int (*var_nextname)(size_t *, uint16_t *, struct uuid *);290 int (*var_nextname)(size_t *, uint16_t *, efi_guid_t *);
261 int (*var_set)(uint16_t *, struct uuid *, uint32_t, size_t, void *);291 int (*var_set)(uint16_t *, efi_guid_t *, uint32_t, size_t, void *);
262};292};
263extern const struct efi_ops *active_efi_ops;293extern const struct efi_ops *active_efi_ops;
264294
...@@ -271,21 +301,21 @@ static inline int efi_rt_ok(void)...@@ -271,21 +301,21 @@ static inline int efi_rt_ok(void)
271 return (active_efi_ops->rt_ok());301 return (active_efi_ops->rt_ok());
272}302}
273303
274static inline int efi_get_table(struct uuid *uuid, void **ptr)304static inline int efi_get_table(efi_guid_t *guid, void **ptr)
275{305{
276306
277 if (active_efi_ops->get_table == NULL)307 if (active_efi_ops->get_table == NULL)
278 return (ENXIO);308 return (ENXIO);
279 return (active_efi_ops->get_table(uuid, ptr));309 return (active_efi_ops->get_table(guid, ptr));
280}310}
281311
282static inline int efi_copy_table(struct uuid *uuid, void **buf,312static inline int efi_copy_table(efi_guid_t *guid, void **buf,
283 size_t buf_len, size_t *table_len)313 size_t buf_len, size_t *table_len)
284{314{
285315
286 if (active_efi_ops->copy_table == NULL)316 if (active_efi_ops->copy_table == NULL)
287 return (ENXIO);317 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));
289}319}
290320
291static inline int efi_get_time(struct efi_tm *tm)321static 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)...@@ -335,7 +365,7 @@ static inline int efi_set_waketime(uint8_t enable, struct efi_tm *tm)
335 return (active_efi_ops->set_waketime(enable, tm));365 return (active_efi_ops->set_waketime(enable, tm));
336}366}
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,
339 uint32_t *attrib, size_t *datasize, void *data)369 uint32_t *attrib, size_t *datasize, void *data)
340{370{
341371
...@@ -345,7 +375,7 @@ static inline int efi_var_get(uint16_t *name, struct uuid *vendor,...@@ -345,7 +375,7 @@ static inline int efi_var_get(uint16_t *name, struct uuid *vendor,
345}375}
346376
347static inline int efi_var_nextname(size_t *namesize, uint16_t *name,377static inline int efi_var_nextname(size_t *namesize, uint16_t *name,
348 struct uuid *vendor)378 efi_guid_t *vendor)
349{379{
350380
351 if (active_efi_ops->var_nextname == NULL)381 if (active_efi_ops->var_nextname == NULL)
...@@ -353,7 +383,7 @@ static inline int efi_var_nextname(size_t *namesize, uint16_t *name,...@@ -353,7 +383,7 @@ static inline int efi_var_nextname(size_t *namesize, uint16_t *name,
353 return (active_efi_ops->var_nextname(namesize, name, vendor));383 return (active_efi_ops->var_nextname(namesize, name, vendor));
354}384}
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,
357 uint32_t attrib, size_t datasize, void *data)387 uint32_t attrib, size_t datasize, void *data)
358{388{
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 @@...@@ -30,38 +30,79 @@
30#include <sys/uuid.h>30#include <sys/uuid.h>
31#include <sys/efi.h>31#include <sys/efi.h>
3232
33struct efi_get_table_ioc33/*
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
34{49{
35 void *buf; /* Pointer to userspace buffer */50 void *buf; /* Pointer to userspace buffer */
36 struct uuid uuid; /* UUID to look up */51 efi_guid_t guid; /* GUID to look up */
37 size_t table_len; /* Table size */52 size_t table_len; /* Table size */
38 size_t buf_len; /* Size of the buffer */53 size_t buf_len; /* Size of the buffer */
39};54};
4055
41struct efi_var_ioc56struct efi_var_ioctl
42{57{
43 efi_char *name; /* User pointer to name, in wide chars */58 efi_char *name; /* User pointer to name, in wide chars */
44 size_t namesize; /* Number of wide characters in name */59 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 */
46 uint32_t attrib; /* Attributes */61 uint32_t attrib; /* Attributes */
47 void *data; /* User pointer to the data */62 void *data; /* User pointer to the data */
48 size_t datasize; /* Number of *bytes* in the data */63 size_t datasize; /* Number of *bytes* in the data */
49};64};
5065
51struct efi_waketime_ioc66struct efi_waketime_ioctl
52{67{
53 struct efi_tm waketime;68 struct efi_tm waketime;
54 uint8_t enabled;69 uint8_t enabled;
55 uint8_t pending;70 uint8_t pending;
56};71};
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)
59#define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm)74#define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm)
60#define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm)75#define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm)
61#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioc)76#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioctl)
62#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioc)77#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioctl)
63#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioc)78#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioctl)
64#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioc)79#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioctl)
65#define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioc)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
67#endif /* _SYS_EFIIO_H_ */108#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 {...@@ -306,6 +306,7 @@ typedef struct {
306 and MPRC of Peking University */306 and MPRC of Peking University */
307#define EM_AARCH64 183 /* AArch64 (64-bit ARM) */307#define EM_AARCH64 183 /* AArch64 (64-bit ARM) */
308#define EM_RISCV 243 /* RISC-V */308#define EM_RISCV 243 /* RISC-V */
309#define EM_LOONGARCH 258 /* Loongson LoongArch */
309310
310/* Non-standard or deprecated. */311/* Non-standard or deprecated. */
311#define EM_486 6 /* Intel i486. */312#define EM_486 6 /* Intel i486. */
...@@ -382,6 +383,25 @@ typedef struct {...@@ -382,6 +383,25 @@ typedef struct {
382#define EF_RISCV_RVE 0x00000008383#define EF_RISCV_RVE 0x00000008
383#define EF_RISCV_TSO 0x00000010384#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
385#define EF_SPARC_EXT_MASK 0x00ffff00405#define EF_SPARC_EXT_MASK 0x00ffff00
386#define EF_SPARC_32PLUS 0x00000100406#define EF_SPARC_32PLUS 0x00000100
387#define EF_SPARC_SUN_US1 0x00000200407#define EF_SPARC_SUN_US1 0x00000200
...@@ -450,12 +470,12 @@ typedef struct {...@@ -450,12 +470,12 @@ typedef struct {
450#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */470#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */
451#define SHT_LOPROC 0x70000000 /* reserved range for processor */471#define SHT_LOPROC 0x70000000 /* reserved range for processor */
452#define SHT_X86_64_UNWIND 0x70000001 /* unwind information */472#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
455#define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */475#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
457 pre-emption map. */477 pre-emption map. */
458#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility 478#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility
459 attributes. */479 attributes. */
460#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */480#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */
461#define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */481#define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */
...@@ -534,8 +554,8 @@ typedef struct {...@@ -534,8 +554,8 @@ typedef struct {
534#define PT_GNU_EH_FRAME 0x6474e550554#define PT_GNU_EH_FRAME 0x6474e550
535#define PT_GNU_STACK 0x6474e551555#define PT_GNU_STACK 0x6474e551
536#define PT_GNU_RELRO 0x6474e552556#define PT_GNU_RELRO 0x6474e552
537#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for kernel dumps557#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for arm and amd64 kernel
538 (currently arm). */558 dumps */
539#define PT_LOSUNW 0x6ffffffa559#define PT_LOSUNW 0x6ffffffa
540#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */560#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
541#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */561#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */
...@@ -770,7 +790,8 @@ typedef struct {...@@ -770,7 +790,8 @@ typedef struct {
770#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */790#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */
771#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */791#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */
772#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */792#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() */
774#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */795#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */
775#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */796#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */
776#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */797#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */
...@@ -804,6 +825,7 @@ typedef struct {...@@ -804,6 +825,7 @@ typedef struct {
804#define NT_FREEBSD_FCTL_WXNEEDED 0x00000008825#define NT_FREEBSD_FCTL_WXNEEDED 0x00000008
805#define NT_FREEBSD_FCTL_LA48 0x00000010826#define NT_FREEBSD_FCTL_LA48 0x00000010
806/* was ASG_DISABLE, do not reuse 0x00000020 */827/* was ASG_DISABLE, do not reuse 0x00000020 */
828#define NT_FREEBSD_FCTL_LA57 0x00000040
807829
808/* Values for n_type. Used in core files. */830/* Values for n_type. Used in core files. */
809#define NT_PRSTATUS 1 /* Process status. */831#define NT_PRSTATUS 1 /* Process status. */
...@@ -820,6 +842,7 @@ typedef struct {...@@ -820,6 +842,7 @@ typedef struct {
820#define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */842#define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */
821#define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */843#define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */
822#define NT_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */844#define NT_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */
845#define NT_PROCSTAT_KQUEUES 18 /* Procstat kqueues events. */
823#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */846#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
824#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */847#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
825#define NT_X86_SEGBASES 0x200 /* x86 FS/GS base addresses. */848#define NT_X86_SEGBASES 0x200 /* x86 FS/GS base addresses. */
...@@ -885,7 +908,7 @@ typedef struct {...@@ -885,7 +908,7 @@ typedef struct {
885#define STV_ELIMINATE 0x6908#define STV_ELIMINATE 0x6
886909
887/* Architecture specific data - st_other */910/* Architecture specific data - st_other */
888#define STO_AARCH64_VARIANT_PCS 0x80911#define STO_AARCH64_VARIANT_PCS 0x80
889912
890/* Special symbol table indexes. */913/* Special symbol table indexes. */
891#define STN_UNDEF 0 /* Undefined symbol index. */914#define STN_UNDEF 0 /* Undefined symbol index. */
...@@ -991,8 +1014,11 @@ typedef struct {...@@ -991,8 +1014,11 @@ typedef struct {
991#define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */1014#define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */
992#define AT_USRSTACKBASE 35 /* Top of user stack */1015#define AT_USRSTACKBASE 35 /* Top of user stack */
993#define AT_USRSTACKLIM 36 /* Grow limit of user stack */1016#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
997/*1023/*
998 * Relocation types.1024 * Relocation types.
...@@ -1058,11 +1084,11 @@ typedef struct {...@@ -1058,11 +1084,11 @@ typedef struct {
1058#define R_AARCH64_COPY 1024 /* Copy data from shared object */1084#define R_AARCH64_COPY 1024 /* Copy data from shared object */
1059#define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */1085#define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */
1060#define R_AARCH64_JUMP_SLOT 1026 /* Set GOT entry to code address */1086#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 */
1062#define R_AARCH64_TLS_DTPREL64 10281088#define R_AARCH64_TLS_DTPREL64 1028
1063#define R_AARCH64_TLS_DTPMOD64 10291089#define R_AARCH64_TLS_DTPMOD64 1029
1064#define R_AARCH64_TLS_TPREL64 10301090#define R_AARCH64_TLS_TPREL64 1030
1065#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */1091#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */
1066#define R_AARCH64_IRELATIVE 10321092#define R_AARCH64_IRELATIVE 1032
10671093
1068#define R_ARM_NONE 0 /* No relocation. */1094#define R_ARM_NONE 0 /* No relocation. */
...@@ -1205,8 +1231,8 @@ typedef struct {...@@ -1205,8 +1231,8 @@ typedef struct {
1205#define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */1231#define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */
1206#define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */1232#define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */
1207#define R_MIPS_SUB 241233#define R_MIPS_SUB 24
1208#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */1234#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 */1235#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */
1210#define R_MIPS_JALR 371236#define R_MIPS_JALR 37
1211#define R_MIPS_TLS_GD 421237#define R_MIPS_TLS_GD 42
1212#define R_MIPS_COPY 1261238#define R_MIPS_COPY 126
...@@ -1326,7 +1352,6 @@ typedef struct {...@@ -1326,7 +1352,6 @@ typedef struct {
1326 * RISC-V relocation types.1352 * RISC-V relocation types.
1327 */1353 */
13281354
1329/* Relocation types used by the dynamic linker. */
1330#define R_RISCV_NONE 01355#define R_RISCV_NONE 0
1331#define R_RISCV_32 11356#define R_RISCV_32 1
1332#define R_RISCV_64 21357#define R_RISCV_64 2
...@@ -1339,8 +1364,7 @@ typedef struct {...@@ -1339,8 +1364,7 @@ typedef struct {
1339#define R_RISCV_TLS_DTPREL64 91364#define R_RISCV_TLS_DTPREL64 9
1340#define R_RISCV_TLS_TPREL32 101365#define R_RISCV_TLS_TPREL32 10
1341#define R_RISCV_TLS_TPREL64 111366#define R_RISCV_TLS_TPREL64 11
13421367#define R_RISCV_TLSDESC 12
1343/* Relocation types not used by the dynamic linker. */
1344#define R_RISCV_BRANCH 161368#define R_RISCV_BRANCH 16
1345#define R_RISCV_JAL 171369#define R_RISCV_JAL 17
1346#define R_RISCV_CALL 181370#define R_RISCV_CALL 18
...@@ -1366,10 +1390,10 @@ typedef struct {...@@ -1366,10 +1390,10 @@ typedef struct {
1366#define R_RISCV_SUB16 381390#define R_RISCV_SUB16 38
1367#define R_RISCV_SUB32 391391#define R_RISCV_SUB32 39
1368#define R_RISCV_SUB64 401392#define R_RISCV_SUB64 40
1393#define R_RISCV_GOT32_PCREL 41
1369#define R_RISCV_ALIGN 431394#define R_RISCV_ALIGN 43
1370#define R_RISCV_RVC_BRANCH 441395#define R_RISCV_RVC_BRANCH 44
1371#define R_RISCV_RVC_JUMP 451396#define R_RISCV_RVC_JUMP 45
1372#define R_RISCV_RVC_LUI 46
1373#define R_RISCV_RELAX 511397#define R_RISCV_RELAX 51
1374#define R_RISCV_SUB6 521398#define R_RISCV_SUB6 52
1375#define R_RISCV_SET6 531399#define R_RISCV_SET6 53
...@@ -1378,6 +1402,170 @@ typedef struct {...@@ -1378,6 +1402,170 @@ typedef struct {
1378#define R_RISCV_SET32 561402#define R_RISCV_SET32 56
1379#define R_RISCV_32_PCREL 571403#define R_RISCV_32_PCREL 57
1380#define R_RISCV_IRELATIVE 581404#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
1382#define R_SPARC_NONE 01570#define R_SPARC_NONE 0
1383#define R_SPARC_8 11571#define R_SPARC_8 1
lib/libc/include/generic-freebsd/sys/endian.h+3-1
...@@ -56,7 +56,9 @@ typedef __uint64_t uint64_t;...@@ -56,7 +56,9 @@ typedef __uint64_t uint64_t;
56/*56/*
57 * Note: While tempting to try to avoid namespace pollution from this file,57 * Note: While tempting to try to avoid namespace pollution from this file,
58 * several software packages assume these marcos are defined, even when it58 * 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.
60 */62 */
6163
62/*64/*
lib/libc/include/generic-freebsd/sys/errno.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)errno.h 8.5 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_ERRNO_H_37#ifndef _SYS_ERRNO_H_
lib/libc/include/generic-freebsd/sys/event.h+19-3
...@@ -45,7 +45,9 @@...@@ -45,7 +45,9 @@
45#define EVFILT_USER (-11) /* User events */45#define EVFILT_USER (-11) /* User events */
46#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */46#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */
47#define EVFILT_EMPTY (-13) /* empty send socket buf */47#define EVFILT_EMPTY (-13) /* empty send socket buf */
48#define EVFILT_SYSCOUNT 1348#define EVFILT_JAIL (-14) /* attached to struct prison */
49#define EVFILT_JAILDESC (-15) /* attached to jail descriptors */
50#define EVFILT_SYSCOUNT 15
4951
50#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L52#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
51#define EV_SET(kevp_, a, b, c, d, e, f) do { \53#define EV_SET(kevp_, a, b, c, d, e, f) do { \
...@@ -101,7 +103,7 @@ struct freebsd11_kevent {...@@ -101,7 +103,7 @@ struct freebsd11_kevent {
101};103};
102#endif104#endif
103105
104#if defined(_WANT_KEVENT32) || (defined(_KERNEL) && defined(__LP64__))106#if defined(_WANT_KEVENT32) || defined(_KERNEL)
105struct kevent32 {107struct kevent32 {
106 __uint32_t ident; /* identifier for this event */108 __uint32_t ident; /* identifier for this event */
107 short filter; /* filter for event */109 short filter; /* filter for event */
...@@ -205,10 +207,18 @@ struct freebsd11_kevent32 {...@@ -205,10 +207,18 @@ struct freebsd11_kevent32 {
205#define NOTE_PDATAMASK 0x000fffff /* mask for pid */207#define NOTE_PDATAMASK 0x000fffff /* mask for pid */
206208
207/* additional flags for EVFILT_PROC */209/* additional flags for EVFILT_PROC */
208#define NOTE_TRACK 0x00000001 /* follow across forks */210#define NOTE_TRACK 0x00000001 /* follow across fork/create */
209#define NOTE_TRACKERR 0x00000002 /* could not track child */211#define NOTE_TRACKERR 0x00000002 /* could not track child */
210#define NOTE_CHILD 0x00000004 /* am a child process */212#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
212/* additional flags for EVFILT_TIMER */222/* additional flags for EVFILT_TIMER */
213#define NOTE_SECONDS 0x00000001 /* data is seconds */223#define NOTE_SECONDS 0x00000001 /* data is seconds */
214#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */224#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */
...@@ -262,12 +272,17 @@ struct knlist {...@@ -262,12 +272,17 @@ struct knlist {
262#define EVENT_REGISTER 1272#define EVENT_REGISTER 1
263#define EVENT_PROCESS 2273#define EVENT_PROCESS 2
264274
275struct kinfo_knote;
276struct proc;
277
265struct filterops {278struct filterops {
266 int f_isfd; /* true if ident == filedescriptor */279 int f_isfd; /* true if ident == filedescriptor */
267 int (*f_attach)(struct knote *kn);280 int (*f_attach)(struct knote *kn);
268 void (*f_detach)(struct knote *kn);281 void (*f_detach)(struct knote *kn);
269 int (*f_event)(struct knote *kn, long hint);282 int (*f_event)(struct knote *kn, long hint);
270 void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type);283 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);
271};286};
272287
273/*288/*
...@@ -304,6 +319,7 @@ struct knote {...@@ -304,6 +319,7 @@ struct knote {
304 struct proc *p_proc; /* proc pointer */319 struct proc *p_proc; /* proc pointer */
305 struct kaiocb *p_aio; /* AIO job pointer */320 struct kaiocb *p_aio; /* AIO job pointer */
306 struct aioliojob *p_lio; /* LIO job pointer */321 struct aioliojob *p_lio; /* LIO job pointer */
322 struct prison *p_prison; /* prison pointer */
307 void *p_v; /* generic other pointer */323 void *p_v; /* generic other pointer */
308 } kn_ptr;324 } kn_ptr;
309 const struct filterops *kn_fop;325 const struct filterops *kn_fop;
lib/libc/include/generic-freebsd/sys/eventhandler.h+5
...@@ -326,4 +326,9 @@ struct ifaddr;...@@ -326,4 +326,9 @@ struct ifaddr;
326typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int);326typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int);
327EVENTHANDLER_DECLARE(rt_addrmsg, rt_addrmsg_fn);327EVENTHANDLER_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
329#endif /* _SYS_EVENTHANDLER_H_ */334#endif /* _SYS_EVENTHANDLER_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/exec.h-22
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)exec.h 8.3 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_EXEC_H_37#ifndef _SYS_EXEC_H_
...@@ -59,16 +57,6 @@ struct ps_strings {...@@ -59,16 +57,6 @@ struct ps_strings {
59 unsigned int ps_nenvstr; /* the number of environment strings */57 unsigned int ps_nenvstr; /* the number of environment strings */
60};58};
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
72struct image_params;60struct image_params;
7361
74struct execsw {62struct execsw {
...@@ -107,16 +95,6 @@ int exec_unregister(const struct execsw *);...@@ -107,16 +95,6 @@ int exec_unregister(const struct execsw *);
10795
108enum uio_seg;96enum 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
120/*98/*
121 * note: name##_mod cannot be const storage because the99 * note: name##_mod cannot be const storage because the
122 * linker_file_sysinit() function modifies _file in the100 * 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 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * @(#)fbio.h 8.2 (Berkeley) 10/30/93
36 */34 */
3735
38#ifndef _SYS_FBIO_H_36#ifndef _SYS_FBIO_H_
lib/libc/include/generic-freebsd/sys/fcntl.h+31-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_FCNTL_H_37#ifndef _SYS_FCNTL_H_
...@@ -142,8 +140,24 @@ typedef __pid_t pid_t;...@@ -142,8 +140,24 @@ typedef __pid_t pid_t;
142#define O_DSYNC 0x01000000 /* POSIX data sync */140#define O_DSYNC 0x01000000 /* POSIX data sync */
143#if __BSD_VISIBLE141#if __BSD_VISIBLE
144#define O_EMPTY_PATH 0x02000000142#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
145#endif149#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
147/*161/*
148 * XXX missing O_RSYNC.162 * XXX missing O_RSYNC.
149 */163 */
...@@ -270,6 +284,16 @@ typedef __pid_t pid_t;...@@ -270,6 +284,16 @@ typedef __pid_t pid_t;
270#define F_GET_SEALS 20284#define F_GET_SEALS 20
271#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */285#define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */
272#define F_KINFO 22 /* Return kinfo_file for this fd */286#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
274/* Seals (F_ADD_SEALS, F_GET_SEALS). */298/* Seals (F_ADD_SEALS, F_GET_SEALS). */
275#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */299#define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */
...@@ -280,6 +304,11 @@ typedef __pid_t pid_t;...@@ -280,6 +304,11 @@ typedef __pid_t pid_t;
280304
281/* file descriptor flags (F_GETFD, F_SETFD) */305/* file descriptor flags (F_GETFD, F_SETFD) */
282#define FD_CLOEXEC 1 /* close-on-exec flag */306#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
284/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */313/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
285#define F_RDLCK 1 /* shared or read lock */314#define F_RDLCK 1 /* shared or read lock */
lib/libc/include/generic-freebsd/sys/file.h+34-26
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)file.h 8.3 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_FILE_H_32#ifndef _SYS_FILE_H_
...@@ -39,13 +37,16 @@...@@ -39,13 +37,16 @@
39#include <sys/fcntl.h>37#include <sys/fcntl.h>
40#include <sys/unistd.h>38#include <sys/unistd.h>
41#else39#else
42#include <sys/queue.h>40#include <sys/errno.h>
43#include <sys/refcount.h>
44#include <sys/_lock.h>41#include <sys/_lock.h>
45#include <sys/_mutex.h>42#include <sys/_mutex.h>
43#include <sys/_null.h>
44#include <sys/queue.h>
45#include <sys/refcount.h>
46#include <vm/vm.h>46#include <vm/vm.h>
4747
48struct filedesc;48struct filedesc;
49struct proc;
49struct stat;50struct stat;
50struct thread;51struct thread;
51struct uio;52struct uio;
...@@ -70,6 +71,8 @@ struct nameidata;...@@ -70,6 +71,8 @@ struct nameidata;
70#define DTYPE_PROCDESC 12 /* process descriptor */71#define DTYPE_PROCDESC 12 /* process descriptor */
71#define DTYPE_EVENTFD 13 /* eventfd */72#define DTYPE_EVENTFD 13 /* eventfd */
72#define DTYPE_TIMERFD 14 /* timerfd */73#define DTYPE_TIMERFD 14 /* timerfd */
74#define DTYPE_INOTIFY 15 /* inotify descriptor */
75#define DTYPE_JAILDESC 16 /* jail descriptor */
7376
74#ifdef _KERNEL77#ifdef _KERNEL
7578
...@@ -85,6 +88,8 @@ struct ucred;...@@ -85,6 +88,8 @@ struct ucred;
85#define FOF_NEXTOFF_W 0x08 /* Also update f_nextoff[UIO_WRITE] */88#define FOF_NEXTOFF_W 0x08 /* Also update f_nextoff[UIO_WRITE] */
86#define FOF_NOUPDATE 0x10 /* Do not update f_offset */89#define FOF_NOUPDATE 0x10 /* Do not update f_offset */
87off_t foffset_lock(struct file *fp, int flags);90off_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);
88void foffset_lock_uio(struct file *fp, struct uio *uio, int flags);93void foffset_lock_uio(struct file *fp, struct uio *uio, int flags);
89void foffset_unlock(struct file *fp, off_t val, int flags);94void foffset_unlock(struct file *fp, off_t val, int flags);
90void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags);95void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags);
...@@ -156,7 +161,7 @@ struct fileops {...@@ -156,7 +161,7 @@ struct fileops {
156 fo_fallocate_t *fo_fallocate;161 fo_fallocate_t *fo_fallocate;
157 fo_fspacectl_t *fo_fspacectl;162 fo_fspacectl_t *fo_fspacectl;
158 fo_cmp_t *fo_cmp;163 fo_cmp_t *fo_cmp;
159 fo_spare_t *fo_spares[7]; /* Spare slots */164 fo_spare_t *fo_spares[8]; /* Spare slots */
160 fo_flags_t fo_flags; /* DFLAG_* below */165 fo_flags_t fo_flags; /* DFLAG_* below */
161};166};
162167
...@@ -188,11 +193,11 @@ struct file {...@@ -188,11 +193,11 @@ struct file {
188 volatile u_int f_flag; /* see fcntl.h */193 volatile u_int f_flag; /* see fcntl.h */
189 volatile u_int f_count; /* reference count */194 volatile u_int f_count; /* reference count */
190 void *f_data; /* file descriptor specific data */195 void *f_data; /* file descriptor specific data */
191 struct fileops *f_ops; /* File operations */196 const struct fileops *f_ops; /* File operations */
192 struct vnode *f_vnode; /* NULL or applicable vnode */197 struct vnode *f_vnode; /* NULL or applicable vnode */
193 struct ucred *f_cred; /* associated credentials. */198 struct ucred *f_cred; /* associated credentials. */
194 short f_type; /* descriptor type */199 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 */
196 /*201 /*
197 * DTYPE_VNODE specific fields.202 * DTYPE_VNODE specific fields.
198 */203 */
...@@ -215,8 +220,8 @@ struct file {...@@ -215,8 +220,8 @@ struct file {
215#define f_cdevpriv f_vnun.fvn_cdevpriv220#define f_cdevpriv f_vnun.fvn_cdevpriv
216#define f_advice f_vnun.fvn_advice221#define f_advice f_vnun.fvn_advice
217222
218#define FOFFSET_LOCKED 0x1223#define FILE_V_FOFFSET_LOCKED 0x0001
219#define FOFFSET_LOCK_WAITING 0x2224#define FILE_V_FOFFSET_LOCK_WAITING 0x0002
220#endif /* __BSD_VISIBLE */225#endif /* __BSD_VISIBLE */
221226
222#endif /* _KERNEL || _WANT_FILE */227#endif /* _KERNEL || _WANT_FILE */
...@@ -248,24 +253,27 @@ struct xfile {...@@ -248,24 +253,27 @@ struct xfile {
248253
249#ifdef _KERNEL254#ifdef _KERNEL
250255
251extern struct fileops vnops;256extern const struct fileops vnops;
252extern struct fileops badfileops;257extern const struct fileops badfileops;
253extern struct fileops path_fileops;258extern const struct fileops path_fileops;
254extern struct fileops socketops;259extern const struct fileops socketops;
255extern int maxfiles; /* kernel limit on number of open files */260extern int maxfiles; /* kernel limit on number of open files */
256extern int maxfilesperproc; /* per process limit on number of open files */261extern 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);263int fget(struct thread *td, int fd, const cap_rights_t *rightsp,
259int fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp,264 struct file **fpp);
265int fget_mmap(struct thread *td, int fd, const cap_rights_t *rightsp,
260 vm_prot_t *maxprotp, struct file **fpp);266 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,
262 struct file **fpp);268 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,
264 struct file **fpp);270 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,
266 int needfcntl, struct file **fpp);272 int needfcntl, struct file **fpp);
267int _fdrop(struct file *fp, struct thread *td);273int _fdrop(struct file *fp, struct thread *td);
268int fget_remote(struct thread *td, struct proc *p, int fd, struct file **fpp);274int 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
270fo_rdwr_t invfo_rdwr;278fo_rdwr_t invfo_rdwr;
271fo_truncate_t invfo_truncate;279fo_truncate_t invfo_truncate;
...@@ -283,19 +291,19 @@ fo_kqfilter_t vn_kqfilter_opath;...@@ -283,19 +291,19 @@ fo_kqfilter_t vn_kqfilter_opath;
283int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif);291int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif);
284int file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td);292int file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td);
285293
286void finit(struct file *, u_int, short, void *, struct fileops *);294void finit(struct file *, u_int, short, void *, const struct fileops *);
287void finit_vnode(struct file *, u_int, void *, struct fileops *);295void finit_vnode(struct file *, u_int, void *, const struct fileops *);
288int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp,296int fgetvp(struct thread *td, int fd, const cap_rights_t *rightsp,
289 struct vnode **vpp);297 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,
291 struct vnode **vpp);299 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,
293 struct filecaps *havecaps, struct vnode **vpp);301 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,
295 struct vnode **vpp);303 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,
297 struct vnode **vpp);305 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);
299int fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp);307int fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp);
300308
301static __inline __result_use_check bool309static __inline __result_use_check bool
lib/libc/include/generic-freebsd/sys/filedesc.h+17-12
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_FILEDESC_H_32#ifndef _SYS_FILEDESC_H_
...@@ -150,6 +148,8 @@ struct filedesc_to_leader {...@@ -150,6 +148,8 @@ struct filedesc_to_leader {
150 * Per-process open flags.148 * Per-process open flags.
151 */149 */
152#define UF_EXCLOSE 0x01 /* auto-close on exec */150#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
154#ifdef _KERNEL154#ifdef _KERNEL
155155
...@@ -222,6 +222,7 @@ enum {...@@ -222,6 +222,7 @@ enum {
222222
223/* Flags for kern_dup(). */223/* Flags for kern_dup(). */
224#define FDDUP_FLAG_CLOEXEC 0x1 /* Atomically set UF_EXCLOSE. */224#define FDDUP_FLAG_CLOEXEC 0x1 /* Atomically set UF_EXCLOSE. */
225#define FDDUP_FLAG_CLOFORK 0x2 /* Atomically set UF_FOCLOSE. */
225226
226/* For backward compatibility. */227/* For backward compatibility. */
227#define falloc(td, resultfp, resultfd, flags) \228#define falloc(td, resultfp, resultfd, flags) \
...@@ -277,22 +278,26 @@ struct filedesc_to_leader *...@@ -277,22 +278,26 @@ struct filedesc_to_leader *
277struct filedesc_to_leader *278struct filedesc_to_leader *
278 filedesc_to_leader_share(struct filedesc_to_leader *fdtol,279 filedesc_to_leader_share(struct filedesc_to_leader *fdtol,
279 struct filedesc *fdp);280 struct filedesc *fdp);
280int getvnode(struct thread *td, int fd, cap_rights_t *rightsp,281int getvnode(struct thread *td, int fd, const cap_rights_t *rightsp,
281 struct file **fpp);
282int getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp,
283 struct file **fpp);282 struct file **fpp);
283int getvnode_path(struct thread *td, int fd, const cap_rights_t *rightsp,
284 uint8_t *flagsp, struct file **fpp);
284void mountcheckdirs(struct vnode *olddp, struct vnode *newdp);285void mountcheckdirs(struct vnode *olddp, struct vnode *newdp);
285286
286int fget_cap_noref(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,287int fget_cap_noref(struct filedesc *fdp, int fd,
287 struct file **fpp, struct filecaps *havecapsp);288 const cap_rights_t *needrightsp, struct file **fpp,
288int fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,289 struct filecaps *havecapsp);
289 struct file **fpp, 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);
290/* Return a referenced file from an unlocked descriptor. */292/* 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,
292 struct file **fpp);297 struct file **fpp);
293/* Return a file pointer without a ref. FILEDESC_IS_ONLY_USER must be true. */298/* 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,299int fget_only_user(struct filedesc *fdp, int fd,
295 struct file **fpp);300 const cap_rights_t *needrightsp, struct file **fpp);
296#define fput_only_user(fdp, fp) ({ \301#define fput_only_user(fdp, fp) ({ \
297 MPASS(FILEDESC_IS_ONLY_USER(fdp)); \302 MPASS(FILEDESC_IS_ONLY_USER(fdp)); \
298 MPASS(refcount_load(&fp->f_count) > 0); \303 MPASS(refcount_load(&fp->f_count) > 0); \
lib/libc/include/generic-freebsd/sys/filio.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)filio.h 8.1 (Berkeley) 3/28/94
37 */35 */
3836
39#ifndef _SYS_FILIO_H_37#ifndef _SYS_FILIO_H_
lib/libc/include/generic-freebsd/sys/gmon.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)gmon.h 8.2 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _SYS_GMON_H_32#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 *);...@@ -119,8 +119,7 @@ int exec_map_stack(struct image_params *);
119int exec_new_vmspace(struct image_params *, struct sysentvec *);119int exec_new_vmspace(struct image_params *, struct sysentvec *);
120void exec_setregs(struct thread *, struct image_params *, uintptr_t);120void exec_setregs(struct thread *, struct image_params *, uintptr_t);
121int exec_shell_imgact(struct image_params *);121int exec_shell_imgact(struct image_params *);
122int exec_copyin_args(struct image_args *, const char *, enum uio_seg,122int exec_copyin_args(struct image_args *, const char *, char **, char **);
123 char **, char **);
124int pre_execve(struct thread *td, struct vmspace **oldvmspace);123int pre_execve(struct thread *td, struct vmspace **oldvmspace);
125void post_execve(struct thread *td, int error, struct vmspace *oldvmspace);124void post_execve(struct thread *td, int error, struct vmspace *oldvmspace);
126#endif125#endif
lib/libc/include/generic-freebsd/sys/imgact_aout.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)exec.h 8.1 (Berkeley) 6/11/93
32 */30 */
3331
34#ifndef _IMGACT_AOUT_H_32#ifndef _IMGACT_AOUT_H_
lib/libc/include/generic-freebsd/sys/imgact_elf.h+7-6
...@@ -45,6 +45,7 @@...@@ -45,6 +45,7 @@
45 {(pos)->a_type = (id); (pos)->a_un.a_ptr = (ptr); (pos)++;}45 {(pos)->a_type = (id); (pos)->a_un.a_ptr = (ptr); (pos)++;}
46#endif46#endif
4747
48struct coredump_writer;
48struct image_params;49struct image_params;
49struct thread;50struct thread;
50struct vnode;51struct vnode;
...@@ -86,8 +87,8 @@ typedef struct {...@@ -86,8 +87,8 @@ typedef struct {
86 const char *interp_newpath;87 const char *interp_newpath;
87 int flags;88 int flags;
88 Elf_Brandnote *brand_note;89 Elf_Brandnote *brand_note;
89 bool (*header_supported)(struct image_params *,90 bool (*header_supported)(const struct image_params *,
90 int32_t *, uint32_t *);91 const int32_t *, const uint32_t *);
91 /* High 8 bits of flags is private to the ABI */92 /* High 8 bits of flags is private to the ABI */
92#define BI_CAN_EXEC_DYN 0x000193#define BI_CAN_EXEC_DYN 0x0001
93#define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */94#define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */
...@@ -114,7 +115,7 @@ bool __elfN(brand_inuse)(Elf_Brandinfo *entry);...@@ -114,7 +115,7 @@ bool __elfN(brand_inuse)(Elf_Brandinfo *entry);
114int __elfN(insert_brand_entry)(Elf_Brandinfo *entry);115int __elfN(insert_brand_entry)(Elf_Brandinfo *entry);
115int __elfN(remove_brand_entry)(Elf_Brandinfo *entry);116int __elfN(remove_brand_entry)(Elf_Brandinfo *entry);
116int __elfN(freebsd_fixup)(uintptr_t *, struct image_params *);117int __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);
118size_t __elfN(populate_note)(int, void *, void *, size_t, void **);119size_t __elfN(populate_note)(int, void *, void *, size_t, void **);
119int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t);120int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t);
120void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int);121void __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 *,...@@ -123,9 +124,9 @@ void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
123void __elfN(size_segments)(struct thread *, struct sseg_closure *, int);124void __elfN(size_segments)(struct thread *, struct sseg_closure *, int);
124size_t __elfN(register_note)(struct thread *, struct note_info_list *,125size_t __elfN(register_note)(struct thread *, struct note_info_list *,
125 int, outfunc_t, void *);126 int, outfunc_t, void *);
126bool __elfN(parse_notes)(struct image_params *, Elf_Note *, const char *,127bool __elfN(parse_notes)(const struct image_params *, const Elf_Note *,
127 const Elf_Phdr *, bool (*)(const Elf_Note *, void *, bool *),128 const char *, const Elf_Phdr *,
128 void *);129 bool (*)(const Elf_Note *, void *, bool *), void *);
129130
130/* Machine specific function to dump per-thread information. */131/* Machine specific function to dump per-thread information. */
131void __elfN(dump_thread)(struct thread *, void *, size_t *);132void __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 {...@@ -121,7 +121,7 @@ struct intr_event {
121 int ie_count; /* Loop counter. */121 int ie_count; /* Loop counter. */
122 int ie_warncnt; /* Rate-check interrupt storm warns. */122 int ie_warncnt; /* Rate-check interrupt storm warns. */
123 struct timeval ie_warntm;123 struct timeval ie_warntm;
124 int ie_irq; /* Physical irq number if !SOFT. */124 u_int ie_irq; /* Physical irq number if !SOFT. */
125 int ie_cpu; /* CPU this event is bound to. */125 int ie_cpu; /* CPU this event is bound to. */
126 volatile int ie_phase; /* Switched to establish a barrier. */126 volatile int ie_phase; /* Switched to establish a barrier. */
127 volatile int ie_active[2]; /* Filters in ISR context. */127 volatile int ie_active[2]; /* Filters in ISR context. */
...@@ -129,6 +129,7 @@ struct intr_event {...@@ -129,6 +129,7 @@ struct intr_event {
129129
130/* Interrupt event flags kept in ie_flags. */130/* Interrupt event flags kept in ie_flags. */
131#define IE_SOFT 0x000001 /* Software interrupt. */131#define IE_SOFT 0x000001 /* Software interrupt. */
132#define IE_SLEEPABLE 0x000002 /* Sleepable ithread */
132#define IE_ADDING_THREAD 0x000004 /* Currently building an ithread. */133#define IE_ADDING_THREAD 0x000004 /* Currently building an ithread. */
133134
134/* Flags to pass to swi_sched. */135/* Flags to pass to swi_sched. */
...@@ -175,7 +176,7 @@ struct _cpuset;...@@ -175,7 +176,7 @@ struct _cpuset;
175int intr_event_bind_ithread_cpuset(struct intr_event *ie,176int intr_event_bind_ithread_cpuset(struct intr_event *ie,
176 struct _cpuset *mask);177 struct _cpuset *mask);
177int intr_event_create(struct intr_event **event, void *source,178int 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 *),
179 void (*post_ithread)(void *), void (*post_filter)(void *),180 void (*post_ithread)(void *), void (*post_filter)(void *),
180 int (*assign_cpu)(void *, int), const char *fmt, ...)181 int (*assign_cpu)(void *, int), const char *fmt, ...)
181 __printflike(9, 10);182 __printflike(9, 10);
...@@ -188,7 +189,7 @@ int intr_event_suspend_handler(void *cookie);...@@ -188,7 +189,7 @@ int intr_event_suspend_handler(void *cookie);
188int intr_event_resume_handler(void *cookie);189int intr_event_resume_handler(void *cookie);
189int intr_getaffinity(int irq, int mode, void *mask);190int intr_getaffinity(int irq, int mode, void *mask);
190void *intr_handler_source(void *cookie);191void *intr_handler_source(void *cookie);
191int intr_setaffinity(int irq, int mode, void *mask);192int intr_setaffinity(int irq, int mode, const void *mask);
192void _intr_drain(int irq); /* LinuxKPI only. */193void _intr_drain(int irq); /* LinuxKPI only. */
193int swi_add(struct intr_event **eventp, const char *name,194int swi_add(struct intr_event **eventp, const char *name,
194 driver_intr_t handler, void *arg, int pri, enum intr_type flags,195 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 @@...@@ -33,10 +33,12 @@
33#error Need INTRNG for this file33#error Need INTRNG for this file
34#endif34#endif
3535
36#include <sys/systm.h>36#include <machine/intr.h>
3737
38#define INTR_IRQ_INVALID 0xFFFFFFFF38#define INTR_IRQ_INVALID 0xFFFFFFFF
3939
40#ifndef LOCORE
41
40enum intr_map_data_type {42enum intr_map_data_type {
41 INTR_MAP_DATA_ACPI = 0,43 INTR_MAP_DATA_ACPI = 0,
42 INTR_MAP_DATA_FDT,44 INTR_MAP_DATA_FDT,
...@@ -110,12 +112,13 @@ u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask);...@@ -110,12 +112,13 @@ u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask);
110112
111struct intr_pic *intr_pic_register(device_t, intptr_t);113struct intr_pic *intr_pic_register(device_t, intptr_t);
112int intr_pic_deregister(device_t, intptr_t);114int 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);
114int intr_pic_add_handler(device_t, struct intr_pic *,117int intr_pic_add_handler(device_t, struct intr_pic *,
115 intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t);118 intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t);
116bool intr_is_per_cpu(struct resource *);119bool intr_is_per_cpu(struct resource *);
117120
118extern device_t intr_irq_root_dev;121device_t intr_irq_root_device(uint32_t);
119122
120/* Intr interface for BUS. */123/* Intr interface for BUS. */
121124
...@@ -163,4 +166,9 @@ void intr_ipi_send(cpuset_t cpus, u_int ipi);...@@ -163,4 +166,9 @@ void intr_ipi_send(cpuset_t cpus, u_int ipi);
163void intr_ipi_dispatch(u_int ipi);166void intr_ipi_dispatch(u_int ipi);
164#endif167#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
166#endif /* _SYS_INTR_H */174#endif /* _SYS_INTR_H */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ioccom.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ioccom.h 8.3 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_IOCCOM_H_32#ifndef _SYS_IOCCOM_H_
lib/libc/include/generic-freebsd/sys/ioctl.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)ioctl.h 8.6 (Berkeley) 3/28/94
37 */35 */
3836
39#ifndef _SYS_IOCTL_H_37#ifndef _SYS_IOCTL_H_
lib/libc/include/generic-freebsd/sys/ioctl_compat.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)ioctl_compat.h 8.4 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_IOCTL_COMPAT_H_37#ifndef _SYS_IOCTL_COMPAT_H_
lib/libc/include/generic-freebsd/sys/ipc.h-2
...@@ -37,8 +37,6 @@...@@ -37,8 +37,6 @@
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.39 * SUCH DAMAGE.
40 *
41 * @(#)ipc.h 8.4 (Berkeley) 2/19/95
42 */40 */
4341
44/*42/*
lib/libc/include/generic-freebsd/sys/jail.h+61-23
...@@ -99,8 +99,12 @@ enum prison_state {...@@ -99,8 +99,12 @@ enum prison_state {
99#define JAIL_UPDATE 0x02 /* Update parameters of existing jail */99#define JAIL_UPDATE 0x02 /* Update parameters of existing jail */
100#define JAIL_ATTACH 0x04 /* Attach to jail upon creation */100#define JAIL_ATTACH 0x04 /* Attach to jail upon creation */
101#define JAIL_DYING 0x08 /* Allow getting a dying jail */101#define JAIL_DYING 0x08 /* Allow getting a dying jail */
102#define JAIL_SET_MASK 0x0f102#define JAIL_USE_DESC 0x10 /* Get/set jail in descriptor */
103#define JAIL_GET_MASK 0x08103#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
105#define JAIL_SYS_DISABLE 0109#define JAIL_SYS_DISABLE 0
106#define JAIL_SYS_NEW 1110#define JAIL_SYS_NEW 1
...@@ -115,7 +119,9 @@ int jail(struct jail *);...@@ -115,7 +119,9 @@ int jail(struct jail *);
115int jail_set(struct iovec *, unsigned int, int);119int jail_set(struct iovec *, unsigned int, int);
116int jail_get(struct iovec *, unsigned int, int);120int jail_get(struct iovec *, unsigned int, int);
117int jail_attach(int);121int jail_attach(int);
122int jail_attach_jd(int);
118int jail_remove(int);123int jail_remove(int);
124int jail_remove_jd(int);
119__END_DECLS125__END_DECLS
120126
121#else /* _KERNEL */127#else /* _KERNEL */
...@@ -141,6 +147,11 @@ MALLOC_DECLARE(M_PRISON);...@@ -141,6 +147,11 @@ MALLOC_DECLARE(M_PRISON);
141#define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000"147#define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000"
142#define OSRELEASELEN 32148#define OSRELEASELEN 32
143149
150#define JAIL_META_PRIVATE "meta"
151#define JAIL_META_SHARED "env"
152
153struct jaildesc;
154struct knlist;
144struct racct;155struct racct;
145struct prison_racct;156struct prison_racct;
146157
...@@ -186,7 +197,9 @@ struct prison {...@@ -186,7 +197,9 @@ struct prison {
186 struct vnode *pr_root; /* (c) vnode to rdir */197 struct vnode *pr_root; /* (c) vnode to rdir */
187 struct prison_ip *pr_addrs[PR_FAMILY_MAX]; /* (p,n) IPs of jail */198 struct prison_ip *pr_addrs[PR_FAMILY_MAX]; /* (p,n) IPs of jail */
188 struct prison_racct *pr_prison_racct; /* (c) racct jail proxy */199 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;
190 int pr_childcount; /* (a) number of child jails */203 int pr_childcount; /* (a) number of child jails */
191 int pr_childmax; /* (p) maximum child jails */204 int pr_childmax; /* (p) maximum child jails */
192 unsigned pr_allow; /* (p) PR_ALLOW_* flags */205 unsigned pr_allow; /* (p) PR_ALLOW_* flags */
...@@ -253,13 +266,29 @@ struct prison_racct {...@@ -253,13 +266,29 @@ struct prison_racct {
253#define PR_ALLOW_RESERVED_PORTS 0x00008000266#define PR_ALLOW_RESERVED_PORTS 0x00008000
254#define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */267#define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */
255#define PR_ALLOW_NFSD 0x00020000268#define PR_ALLOW_NFSD 0x00020000
256#define PR_ALLOW_ALL_STATIC 0x000387ff269#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
258/*286/*
259 * PR_ALLOW_DIFFERENCES determines which flags are able to be287 * PR_ALLOW_DIFFERENCES determines which flags are able to be
260 * different between the parent and child jail upon creation.288 * different between the parent and child jail upon creation.
261 */289 */
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
264/*293/*
265 * OSD methods294 * OSD methods
...@@ -373,37 +402,45 @@ extern struct sx allprison_lock;...@@ -373,37 +402,45 @@ extern struct sx allprison_lock;
373/*402/*
374 * Sysctls to describe jail parameters.403 * Sysctls to describe jail parameters.
375 */404 */
405SYSCTL_DECL(_security_jail);
376SYSCTL_DECL(_security_jail_param);406SYSCTL_DECL(_security_jail_param);
377407
408#define SYSCTL_JAIL_PARAM_DECL(name) \
409 SYSCTL_DECL(_security_jail_param_##name)
378#define SYSCTL_JAIL_PARAM(module, param, type, fmt, descr) \410#define SYSCTL_JAIL_PARAM(module, param, type, fmt, descr) \
379 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \411 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
380 (type) | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_param, fmt, descr)412 (type) | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_param, fmt, descr)
381#define SYSCTL_JAIL_PARAM_STRING(module, param, access, len, descr) \413#define SYSCTL_JAIL_PARAM_STRING(module, param, access, len, descr) \
382 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \414 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
383 CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), NULL, len, \415 CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), NULL, len, \
384 sysctl_jail_param, "A", descr)416 sysctl_jail_param, "A", descr)
385#define SYSCTL_JAIL_PARAM_STRUCT(module, param, access, len, fmt, descr)\417#define SYSCTL_JAIL_PARAM_STRUCT(module, param, access, len, fmt, descr) \
386 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \418 SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \
387 CTLTYPE_STRUCT | CTLFLAG_MPSAFE | (access), NULL, len, \419 CTLTYPE_STRUCT | CTLFLAG_MPSAFE | (access), NULL, len, \
388 sysctl_jail_param, fmt, descr)420 sysctl_jail_param, fmt, descr)
389#define SYSCTL_JAIL_PARAM_NODE(module, descr) \421#define SYSCTL_JAIL_PARAM_NODE(module, descr) \
390 SYSCTL_NODE(_security_jail_param, OID_AUTO, module, CTLFLAG_MPSAFE, \422 SYSCTL_NODE(_security_jail_param, OID_AUTO, module, CTLFLAG_MPSAFE, \
391 0, descr)423 0, descr)
392#define SYSCTL_JAIL_PARAM_SUBNODE(parent, module, descr) \424#define SYSCTL_JAIL_PARAM_SUBNODE(parent, module, descr) \
393 SYSCTL_NODE(_security_jail_param_##parent, OID_AUTO, module, \425 SYSCTL_NODE(_security_jail_param_##parent, OID_AUTO, module, \
394 CTLFLAG_MPSAFE, 0, descr)426 CTLFLAG_MPSAFE, 0, descr)
395#define SYSCTL_JAIL_PARAM_SYS_NODE(module, access, descr) \427#define SYSCTL_JAIL_PARAM_SYS_NODE(module, access, descr) \
396 SYSCTL_JAIL_PARAM_NODE(module, descr); \428 SYSCTL_JAIL_PARAM_NODE(module, descr); \
397 SYSCTL_JAIL_PARAM(_##module, , CTLTYPE_INT | (access), "E,jailsys", \429 SYSCTL_JAIL_PARAM(_##module, , CTLTYPE_INT | (access), "E,jailsys", \
398 descr)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
400/*436/*
401 * Kernel support functions for jail().437 * Kernel support functions for jail().
402 */438 */
403struct ucred;439struct knote;
404struct mount;440struct mount;
405struct sockaddr;441struct sockaddr;
406struct statfs;442struct statfs;
443struct ucred;
407struct vfsconf;444struct vfsconf;
408445
409/*446/*
...@@ -421,7 +458,7 @@ void prison0_init(void);...@@ -421,7 +458,7 @@ void prison0_init(void);
421bool prison_allow(struct ucred *, unsigned);458bool prison_allow(struct ucred *, unsigned);
422int prison_check(struct ucred *cred1, struct ucred *cred2);459int prison_check(struct ucred *cred1, struct ucred *cred2);
423bool prison_check_nfsd(struct ucred *cred);460bool prison_check_nfsd(struct ucred *cred);
424bool prison_owns_vnet(struct ucred *);461bool prison_owns_vnet(struct prison *pr);
425int prison_canseemount(struct ucred *cred, struct mount *mp);462int prison_canseemount(struct ucred *cred, struct mount *mp);
426void prison_enforce_statfs(struct ucred *cred, struct mount *mp,463void prison_enforce_statfs(struct ucred *cred, struct mount *mp,
427 struct statfs *sp);464 struct statfs *sp);
...@@ -438,6 +475,7 @@ void prison_proc_free(struct prison *);...@@ -438,6 +475,7 @@ void prison_proc_free(struct prison *);
438void prison_proc_link(struct prison *, struct proc *);475void prison_proc_link(struct prison *, struct proc *);
439void prison_proc_unlink(struct prison *, struct proc *);476void prison_proc_unlink(struct prison *, struct proc *);
440void prison_proc_iterate(struct prison *, void (*)(struct proc *, void *), void *);477void prison_proc_iterate(struct prison *, void (*)(struct proc *, void *), void *);
478void prison_remove(struct prison *);
441void prison_set_allow(struct ucred *cred, unsigned flag, int enable);479void prison_set_allow(struct ucred *cred, unsigned flag, int enable);
442bool prison_ischild(struct prison *, struct prison *);480bool prison_ischild(struct prison *, struct prison *);
443bool prison_isalive(const struct prison *);481bool 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 @@...@@ -31,12 +31,37 @@
31#ifndef _SYS_KASSERT_H_31#ifndef _SYS_KASSERT_H_
32#define _SYS_KASSERT_H_32#define _SYS_KASSERT_H_
3333
34#include <sys/_types.h>
34#include <sys/cdefs.h>35#include <sys/cdefs.h>
3536
36#ifdef _KERNEL37#ifdef _KERNEL
37extern const char *panicstr; /* panic message */38extern const char *panicstr; /* panic message */
38extern bool panicked;39#define KERNEL_PANICKED() __predict_false(panicstr != NULL)
39#define KERNEL_PANICKED() __predict_false(panicked)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
41#ifdef INVARIANTS /* The option is always available */66#ifdef INVARIANTS /* The option is always available */
42#define VNASSERT(exp, vp, msg) do { \67#define VNASSERT(exp, vp, msg) do { \
lib/libc/include/generic-freebsd/sys/kernel.h+66-67
...@@ -39,8 +39,6 @@...@@ -39,8 +39,6 @@
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * SUCH DAMAGE.41 * SUCH DAMAGE.
42 *
43 * @(#)kernel.h 8.3 (Berkeley) 1/21/94
44 */42 */
4543
46#ifndef _SYS_KERNEL_H_44#ifndef _SYS_KERNEL_H_
...@@ -67,7 +65,16 @@ extern int psratio; /* ratio: prof / stat */...@@ -67,7 +65,16 @@ extern int psratio; /* ratio: prof / stat */
67extern int stathz; /* statistics clock's frequency */65extern int stathz; /* statistics clock's frequency */
68extern int profhz; /* profiling clock's frequency */66extern int profhz; /* profiling clock's frequency */
69extern int profprocs; /* number of process's profiling */67extern 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 */
70extern volatile int ticks;76extern volatile int ticks;
77extern volatile long ticksl;
7178
72#endif /* _KERNEL */79#endif /* _KERNEL */
7380
...@@ -86,16 +93,15 @@ extern volatile int ticks;...@@ -86,16 +93,15 @@ extern volatile int ticks;
86 * The SI_SUB_LAST value must have the highest lexical value.93 * The SI_SUB_LAST value must have the highest lexical value.
87 */94 */
88enum sysinit_sub_id {95enum sysinit_sub_id {
89 SI_SUB_DUMMY = 0x0000000, /* not executed; for linker*/96 SI_SUB_DUMMY = 0x0000000, /* not executed; for linker */
90 SI_SUB_DONE = 0x0000001, /* processed*/
91 SI_SUB_TUNABLES = 0x0700000, /* establish tunable values */97 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 */
93 SI_SUB_VM = 0x1000000, /* virtual memory system init */99 SI_SUB_VM = 0x1000000, /* virtual memory system init */
94 SI_SUB_COUNTER = 0x1100000, /* counter(9) is initialized */100 SI_SUB_COUNTER = 0x1100000, /* counter(9) is initialized */
95 SI_SUB_KMEM = 0x1800000, /* kernel memory*/101 SI_SUB_KMEM = 0x1800000, /* kernel memory */
96 SI_SUB_HYPERVISOR = 0x1A40000, /*102 SI_SUB_HYPERVISOR = 0x1A40000, /*
97 * Hypervisor detection and103 * Hypervisor detection and
98 * virtualization support 104 * virtualization support
99 * setup.105 * setup.
100 */106 */
101 SI_SUB_WITNESS = 0x1A80000, /* witness initialization */107 SI_SUB_WITNESS = 0x1A80000, /* witness initialization */
...@@ -105,7 +111,7 @@ enum sysinit_sub_id {...@@ -105,7 +111,7 @@ enum sysinit_sub_id {
105 SI_SUB_VNET_PRELINK = 0x1E00000, /* vnet init before modules */111 SI_SUB_VNET_PRELINK = 0x1E00000, /* vnet init before modules */
106 SI_SUB_KLD = 0x2000000, /* KLD and module setup */112 SI_SUB_KLD = 0x2000000, /* KLD and module setup */
107 SI_SUB_KHELP = 0x2080000, /* khelp modules */113 SI_SUB_KHELP = 0x2080000, /* khelp modules */
108 SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/114 SI_SUB_CPU = 0x2100000, /* CPU resource(s) */
109 SI_SUB_RACCT = 0x2110000, /* resource accounting */115 SI_SUB_RACCT = 0x2110000, /* resource accounting */
110 SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */116 SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */
111 SI_SUB_RANDOM = 0x2160000, /* random number generator */117 SI_SUB_RANDOM = 0x2160000, /* random number generator */
...@@ -113,21 +119,21 @@ enum sysinit_sub_id {...@@ -113,21 +119,21 @@ enum sysinit_sub_id {
113 SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */119 SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */
114 SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */120 SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */
115 SI_SUB_VNET = 0x21E0000, /* vnet 0 */121 SI_SUB_VNET = 0x21E0000, /* vnet 0 */
116 SI_SUB_INTRINSIC = 0x2200000, /* proc 0*/122 SI_SUB_INTRINSIC = 0x2200000, /* proc 0 */
117 SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits*/123 SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits */
118 SI_SUB_DDB_SERVICES = 0x2380000, /* capture, scripting, etc. */124 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 */
120 SI_SUB_KTRACE = 0x2480000, /* ktrace */126 SI_SUB_KTRACE = 0x2480000, /* ktrace */
121 SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */127 SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */
122 SI_SUB_AUDIT = 0x24C0000, /* audit */128 SI_SUB_AUDIT = 0x24C0000, /* audit */
123 SI_SUB_CREATE_INIT = 0x2500000, /* create init process*/129 SI_SUB_CREATE_INIT = 0x2500000, /* create init process */
124 SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */130 SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */
125 SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */131 SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */
126 SI_SUB_INTR = 0x2800000, /* interrupt threads */132 SI_SUB_INTR = 0x2800000, /* interrupt threads */
127 SI_SUB_TASKQ = 0x2880000, /* task queues */133 SI_SUB_TASKQ = 0x2880000, /* task queues */
128 SI_SUB_EPOCH = 0x2888000, /* epoch subsystem */134 SI_SUB_EPOCH = 0x2888000, /* epoch subsystem */
129#ifdef EARLY_AP_STARTUP135#ifdef EARLY_AP_STARTUP
130 SI_SUB_SMP = 0x2900000, /* start the APs*/136 SI_SUB_SMP = 0x2900000, /* start the APs */
131#endif137#endif
132 SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */138 SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */
133 SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */139 SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */
...@@ -138,40 +144,40 @@ enum sysinit_sub_id {...@@ -138,40 +144,40 @@ enum sysinit_sub_id {
138 SI_SUB_DTRACE_ANON = 0x308C000, /* DTrace anon enabling */144 SI_SUB_DTRACE_ANON = 0x308C000, /* DTrace anon enabling */
139 SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */145 SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */
140 SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */146 SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */
141 SI_SUB_VFS = 0x4000000, /* virtual filesystem*/147 SI_SUB_VFS = 0x4000000, /* virtual filesystem */
142 SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks*/148 SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks */
143 SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory*/149 SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory */
144 SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores*/150 SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores */
145 SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues*/151 SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues */
146 SI_SUB_P1003_1B = 0x6E00000, /* P1003.1B realtime */152 SI_SUB_P1003_1B = 0x6E00000, /* P1003.1B realtime */
147 SI_SUB_PSEUDO = 0x7000000, /* pseudo devices*/153 SI_SUB_PSEUDO = 0x7000000, /* pseudo devices */
148 SI_SUB_EXEC = 0x7400000, /* execve() handlers */154 SI_SUB_EXEC = 0x7400000, /* execve() handlers */
149 SI_SUB_PROTO_BEGIN = 0x8000000, /* VNET initialization */155 SI_SUB_PROTO_BEGIN = 0x8000000, /* VNET initialization */
150 SI_SUB_PROTO_PFIL = 0x8100000, /* Initialize pfil before FWs */156 SI_SUB_PROTO_PFIL = 0x8100000, /* Initialize pfil before FWs */
151 SI_SUB_PROTO_IF = 0x8400000, /* interfaces*/157 SI_SUB_PROTO_IF = 0x8400000, /* interfaces */
152 SI_SUB_PROTO_DOMAININIT = 0x8600000, /* domain registration system */158 SI_SUB_PROTO_DOMAININIT = 0x8600000, /* domain registration system */
153 SI_SUB_PROTO_MC = 0x8700000, /* Multicast */159 SI_SUB_PROTO_MC = 0x8700000, /* Multicast */
154 SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?)*/160 SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?) */
155 SI_SUB_PROTO_FIREWALL = 0x8806000, /* Firewalls */161 SI_SUB_PROTO_FIREWALL = 0x8806000, /* Firewalls */
156 SI_SUB_PROTO_IFATTACHDOMAIN = 0x8808000,/* domain dependent data init */162 SI_SUB_PROTO_IFATTACHDOMAIN = 0x8808000,/* domain dependent data init */
157 SI_SUB_PROTO_END = 0x8ffffff, /* VNET helper functions */163 SI_SUB_PROTO_END = 0x8ffffff, /* VNET helper functions */
158 SI_SUB_KPROF = 0x9000000, /* kernel profiling*/164 SI_SUB_KPROF = 0x9000000, /* kernel profiling */
159 SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events*/165 SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events */
160 SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */166 SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */
161 SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */167 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 */
163 SI_SUB_SYSCALLS = 0xd800000, /* register system calls */169 SI_SUB_SYSCALLS = 0xd800000, /* register system calls */
164 SI_SUB_VNET_DONE = 0xdc00000, /* vnet registration complete */170 SI_SUB_VNET_DONE = 0xdc00000, /* vnet registration complete */
165 SI_SUB_KTHREAD_INIT = 0xe000000, /* init process*/171 SI_SUB_KTHREAD_INIT = 0xe000000, /* init process */
166 SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon*/172 SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon */
167 SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon*/173 SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon */
168 SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon*/174 SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon */
169 SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon*/175 SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon */
170 SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/176 SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs */
171#ifndef EARLY_AP_STARTUP177#ifndef EARLY_AP_STARTUP
172 SI_SUB_SMP = 0xf000000, /* start the APs*/178 SI_SUB_SMP = 0xf000000, /* start the APs */
173#endif 179#endif
174 SI_SUB_RACCTD = 0xf100000, /* start racctd*/180 SI_SUB_RACCTD = 0xf100000, /* start racctd */
175 SI_SUB_LAST = 0xfffffff /* final initialization */181 SI_SUB_LAST = 0xfffffff /* final initialization */
176};182};
177183
...@@ -179,16 +185,16 @@ enum sysinit_sub_id {...@@ -179,16 +185,16 @@ enum sysinit_sub_id {
179 * Some enumerated orders; "ANY" sorts last.185 * Some enumerated orders; "ANY" sorts last.
180 */186 */
181enum sysinit_elem_order {187enum sysinit_elem_order {
182 SI_ORDER_FIRST = 0x0000000, /* first*/188 SI_ORDER_FIRST = 0x0000000, /* first */
183 SI_ORDER_SECOND = 0x0000001, /* second*/189 SI_ORDER_SECOND = 0x0000001, /* second */
184 SI_ORDER_THIRD = 0x0000002, /* third*/190 SI_ORDER_THIRD = 0x0000002, /* third */
185 SI_ORDER_FOURTH = 0x0000003, /* fourth*/191 SI_ORDER_FOURTH = 0x0000003, /* fourth */
186 SI_ORDER_FIFTH = 0x0000004, /* fifth*/192 SI_ORDER_FIFTH = 0x0000004, /* fifth */
187 SI_ORDER_SIXTH = 0x0000005, /* sixth*/193 SI_ORDER_SIXTH = 0x0000005, /* sixth */
188 SI_ORDER_SEVENTH = 0x0000006, /* seventh*/194 SI_ORDER_SEVENTH = 0x0000006, /* seventh */
189 SI_ORDER_EIGHTH = 0x0000007, /* eighth*/195 SI_ORDER_EIGHTH = 0x0000007, /* eighth */
190 SI_ORDER_MIDDLE = 0x1000000, /* somewhere in the middle */196 SI_ORDER_MIDDLE = 0x1000000, /* somewhere in the middle */
191 SI_ORDER_ANY = 0xfffffff /* last*/197 SI_ORDER_ANY = 0xfffffff /* last */
192};198};
193199
194/*200/*
...@@ -218,10 +224,10 @@ typedef void (*sysinit_nfunc_t)(void *);...@@ -218,10 +224,10 @@ typedef void (*sysinit_nfunc_t)(void *);
218typedef void (*sysinit_cfunc_t)(const void *);224typedef void (*sysinit_cfunc_t)(const void *);
219225
220struct sysinit {226struct sysinit {
221 enum sysinit_sub_id subsystem; /* subsystem identifier*/227 enum sysinit_sub_id subsystem; /* subsystem identifier */
222 enum sysinit_elem_order order; /* init order within subsystem*/228 enum sysinit_elem_order order; /* init order within subsystem */
223 STAILQ_ENTRY(sysinit) next; /* singly-linked list */229 STAILQ_ENTRY(sysinit) next; /* singly-linked list */
224 sysinit_cfunc_t func; /* function */230 sysinit_cfunc_t func; /* function */
225 const void *udata; /* multiplexer/argument */231 const void *udata; /* multiplexer/argument */
226};232};
227233
...@@ -240,18 +246,11 @@ struct sysinit {...@@ -240,18 +246,11 @@ struct sysinit {
240#ifdef TSLOG246#ifdef TSLOG
241struct sysinit_tslog {247struct sysinit_tslog {
242 sysinit_cfunc_t func;248 sysinit_cfunc_t func;
243 const void * data;249 const void *data;
244 const char * name;250 const char *name;
245};251};
246static inline void252void sysinit_tslog_shim(const void *);
247sysinit_tslog_shim(const void * data)253
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}
255#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \254#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \
256 static struct sysinit_tslog uniquifier ## _sys_init_tslog = { \255 static struct sysinit_tslog uniquifier ## _sys_init_tslog = { \
257 func, \256 func, \
...@@ -265,7 +264,7 @@ sysinit_tslog_shim(const void * data)...@@ -265,7 +264,7 @@ sysinit_tslog_shim(const void * data)
265 sysinit_tslog_shim, \264 sysinit_tslog_shim, \
266 &uniquifier ## _sys_init_tslog \265 &uniquifier ## _sys_init_tslog \
267 }; \266 }; \
268 DATA_WSET(sysinit_set,uniquifier ## _sys_init)267 DATA_WSET(sysinit_set, uniquifier ## _sys_init)
269#else268#else
270#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \269#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \
271 static struct sysinit uniquifier ## _sys_init = { \270 static struct sysinit uniquifier ## _sys_init = { \
...@@ -275,7 +274,7 @@ sysinit_tslog_shim(const void * data)...@@ -275,7 +274,7 @@ sysinit_tslog_shim(const void * data)
275 func, \274 func, \
276 (ident) \275 (ident) \
277 }; \276 }; \
278 DATA_WSET(sysinit_set,uniquifier ## _sys_init)277 DATA_WSET(sysinit_set, uniquifier ## _sys_init)
279#endif278#endif
280279
281#define SYSINIT(uniquifier, subsystem, order, func, ident) \280#define SYSINIT(uniquifier, subsystem, order, func, ident) \
...@@ -293,7 +292,7 @@ sysinit_tslog_shim(const void * data)...@@ -293,7 +292,7 @@ sysinit_tslog_shim(const void * data)
293 func, \292 func, \
294 (ident) \293 (ident) \
295 }; \294 }; \
296 DATA_WSET(sysuninit_set,uniquifier ## _sys_uninit)295 DATA_WSET(sysuninit_set, uniquifier ## _sys_uninit)
297296
298#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \297#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
299 C_SYSUNINIT(uniquifier, subsystem, order, \298 C_SYSUNINIT(uniquifier, subsystem, order, \
...@@ -316,7 +315,7 @@ void sysinit_add(struct sysinit **set, struct sysinit **set_end);...@@ -316,7 +315,7 @@ void sysinit_add(struct sysinit **set, struct sysinit **set_end);
316 * int315 * int
317 * please avoid using for new tunables!316 * please avoid using for new tunables!
318 */317 */
319extern void tunable_int_init(void *);318extern void tunable_int_init(const void *);
320struct tunable_int {319struct tunable_int {
321 const char *path;320 const char *path;
322 int *var;321 int *var;
...@@ -335,7 +334,7 @@ struct tunable_int {...@@ -335,7 +334,7 @@ struct tunable_int {
335/*334/*
336 * long335 * long
337 */336 */
338extern void tunable_long_init(void *);337extern void tunable_long_init(const void *);
339struct tunable_long {338struct tunable_long {
340 const char *path;339 const char *path;
341 long *var;340 long *var;
...@@ -354,7 +353,7 @@ struct tunable_long {...@@ -354,7 +353,7 @@ struct tunable_long {
354/*353/*
355 * unsigned long354 * unsigned long
356 */355 */
357extern void tunable_ulong_init(void *);356extern void tunable_ulong_init(const void *);
358struct tunable_ulong {357struct tunable_ulong {
359 const char *path;358 const char *path;
360 unsigned long *var;359 unsigned long *var;
...@@ -373,7 +372,7 @@ struct tunable_ulong {...@@ -373,7 +372,7 @@ struct tunable_ulong {
373/*372/*
374 * int64_t373 * int64_t
375 */374 */
376extern void tunable_int64_init(void *);375extern void tunable_int64_init(const void *);
377struct tunable_int64 {376struct tunable_int64 {
378 const char *path;377 const char *path;
379 int64_t *var;378 int64_t *var;
...@@ -392,7 +391,7 @@ struct tunable_int64 {...@@ -392,7 +391,7 @@ struct tunable_int64 {
392/*391/*
393 * uint64_t392 * uint64_t
394 */393 */
395extern void tunable_uint64_init(void *);394extern void tunable_uint64_init(const void *);
396struct tunable_uint64 {395struct tunable_uint64 {
397 const char *path;396 const char *path;
398 uint64_t *var;397 uint64_t *var;
...@@ -411,7 +410,7 @@ struct tunable_uint64 {...@@ -411,7 +410,7 @@ struct tunable_uint64 {
411/*410/*
412 * quad411 * quad
413 */412 */
414extern void tunable_quad_init(void *);413extern void tunable_quad_init(const void *);
415struct tunable_quad {414struct tunable_quad {
416 const char *path;415 const char *path;
417 quad_t *var;416 quad_t *var;
...@@ -430,7 +429,7 @@ struct tunable_quad {...@@ -430,7 +429,7 @@ struct tunable_quad {
430/*429/*
431 * bool430 * bool
432 */431 */
433extern void tunable_bool_init(void *);432extern void tunable_bool_init(const void *);
434struct tunable_bool {433struct tunable_bool {
435 const char *path;434 const char *path;
436 bool *var;435 bool *var;
...@@ -446,7 +445,7 @@ struct tunable_bool {...@@ -446,7 +445,7 @@ struct tunable_bool {
446445
447#define TUNABLE_BOOL_FETCH(path, var) getenv_bool((path), (var))446#define TUNABLE_BOOL_FETCH(path, var) getenv_bool((path), (var))
448447
449extern void tunable_str_init(void *);448extern void tunable_str_init(const void *);
450struct tunable_str {449struct tunable_str {
451 const char *path;450 const char *path;
452 char *var;451 char *var;
lib/libc/include/generic-freebsd/sys/kerneldump.h+1
...@@ -161,6 +161,7 @@ void dumpsys_pb_progress(size_t);...@@ -161,6 +161,7 @@ void dumpsys_pb_progress(size_t);
161extern int do_minidump;161extern int do_minidump;
162162
163int livedump_start(int, int, uint8_t);163int livedump_start(int, int, uint8_t);
164int livedump_start_vnode(struct vnode *, int, uint8_t);
164165
165/* Live minidump events */166/* Live minidump events */
166typedef void (*livedump_start_fn)(void *arg, int *errorp);167typedef void (*livedump_start_fn)(void *arg, int *errorp);
lib/libc/include/generic-freebsd/sys/ktls.h+42-7
...@@ -28,8 +28,11 @@...@@ -28,8 +28,11 @@
28#define _SYS_KTLS_H_28#define _SYS_KTLS_H_
2929
30#ifdef _KERNEL30#ifdef _KERNEL
31#include <sys/_null.h>
31#include <sys/refcount.h>32#include <sys/refcount.h>
32#include <sys/_task.h>33#include <sys/_task.h>
34
35#include <machine/param.h>
33#endif36#endif
3437
35struct tls_record_layer {38struct tls_record_layer {
...@@ -142,6 +145,28 @@ struct tls_get_record {...@@ -142,6 +145,28 @@ struct tls_get_record {
142 uint16_t tls_length;145 uint16_t tls_length;
143};146};
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
145#ifdef _KERNEL170#ifdef _KERNEL
146171
147struct tls_session_params {172struct tls_session_params {
...@@ -174,6 +199,7 @@ struct m_snd_tag;...@@ -174,6 +199,7 @@ struct m_snd_tag;
174struct mbuf;199struct mbuf;
175struct sockbuf;200struct sockbuf;
176struct socket;201struct socket;
202struct sockopt;
177203
178struct ktls_session {204struct ktls_session {
179 struct ktls_ocf_session *ocf_session;205 struct ktls_ocf_session *ocf_session;
...@@ -202,6 +228,8 @@ struct ktls_session {...@@ -202,6 +228,8 @@ struct ktls_session {
202228
203 /* Used to destroy any kTLS session */229 /* Used to destroy any kTLS session */
204 struct task destroy_task;230 struct task destroy_task;
231
232 uint64_t gen;
205} __aligned(CACHE_LINE_SIZE);233} __aligned(CACHE_LINE_SIZE);
206234
207extern unsigned int ktls_ifnet_max_rexmit_pct;235extern unsigned int ktls_ifnet_max_rexmit_pct;
...@@ -213,27 +241,29 @@ typedef enum {...@@ -213,27 +241,29 @@ typedef enum {
213} ktls_mbuf_crypto_st_t;241} ktls_mbuf_crypto_st_t;
214242
215void ktls_check_rx(struct sockbuf *sb);243void 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);
217void ktls_disable_ifnet(void *arg);246void ktls_disable_ifnet(void *arg);
218int ktls_enable_rx(struct socket *so, struct tls_enable *en);247int ktls_enable_rx(struct socket *so, struct tls_enable *en);
219int ktls_enable_tx(struct socket *so, struct tls_enable *en);248int 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);
220void ktls_destroy(struct ktls_session *tls);251void ktls_destroy(struct ktls_session *tls);
221void ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,252void ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,
222 uint8_t record_type);253 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);
227int ktls_get_rx_mode(struct socket *so, int *modep);254int ktls_get_rx_mode(struct socket *so, int *modep);
228int ktls_set_tx_mode(struct socket *so, int mode);
229int ktls_get_tx_mode(struct socket *so, int *modep);255int ktls_get_tx_mode(struct socket *so, int *modep);
230int ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq);256int ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq);
231void ktls_input_ifp_mismatch(struct sockbuf *sb, struct ifnet *ifp);257void 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);
233#ifdef RATELIMIT259#ifdef RATELIMIT
234int ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate);260int ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate);
235#endif261#endif
262int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls);
236bool ktls_pending_rx_info(struct sockbuf *sb, uint64_t *seqnop, size_t *residp);263bool 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
238static inline struct ktls_session *268static inline struct ktls_session *
239ktls_hold(struct ktls_session *tls)269ktls_hold(struct ktls_session *tls)
...@@ -252,5 +282,10 @@ ktls_free(struct ktls_session *tls)...@@ -252,5 +282,10 @@ ktls_free(struct ktls_session *tls)
252 ktls_destroy(tls);282 ktls_destroy(tls);
253}283}
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
255#endif /* !_KERNEL */290#endif /* !_KERNEL */
256#endif /* !_SYS_KTLS_H_ */291#endif /* !_SYS_KTLS_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ktrace.h+27-5
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ktrace.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_KTRACE_H_32#ifndef _SYS_KTRACE_H_
...@@ -38,6 +36,7 @@...@@ -38,6 +36,7 @@
38#include <sys/caprights.h>36#include <sys/caprights.h>
39#include <sys/signal.h>37#include <sys/signal.h>
40#include <sys/socket.h>38#include <sys/socket.h>
39#include <sys/_uexterror.h>
41#include <sys/_uio.h>40#include <sys/_uio.h>
4241
43/*42/*
...@@ -89,10 +88,9 @@ struct ktr_header {...@@ -89,10 +88,9 @@ struct ktr_header {
89 * is the public interface.88 * is the public interface.
90 */89 */
91#define KTRCHECK(td, type) ((td)->td_proc->p_traceflag & (1 << type))90#define KTRCHECK(td, type) ((td)->td_proc->p_traceflag & (1 << type))
92#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type))))91#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type))))
93#define KTRCHECKDRAIN(td) (!(STAILQ_EMPTY(&(td)->td_proc->p_ktr)))
94#define KTRUSERRET(td) do { \92#define KTRUSERRET(td) do { \
95 if (__predict_false(KTRCHECKDRAIN(td))) \93 if (__predict_false(!STAILQ_EMPTY_ATOMIC(&(td)->td_proc->p_ktr))) \
96 ktruserret(td); \94 ktruserret(td); \
97} while (0)95} while (0)
9896
...@@ -265,6 +263,24 @@ struct ktr_struct_array {...@@ -265,6 +263,24 @@ struct ktr_struct_array {
265 */263 */
266};264};
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
268/*284/*
269 * KTR_DROP - If this bit is set in ktr_type, then at least one event285 * KTR_DROP - If this bit is set in ktr_type, then at least one event
270 * between the previous record and this record was dropped.286 * between the previous record and this record was dropped.
...@@ -297,6 +313,9 @@ struct ktr_struct_array {...@@ -297,6 +313,9 @@ struct ktr_struct_array {
297#define KTRFAC_FAULT (1<<KTR_FAULT)313#define KTRFAC_FAULT (1<<KTR_FAULT)
298#define KTRFAC_FAULTEND (1<<KTR_FAULTEND)314#define KTRFAC_FAULTEND (1<<KTR_FAULTEND)
299#define KTRFAC_STRUCT_ARRAY (1<<KTR_STRUCT_ARRAY)315#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
301/*320/*
302 * trace flags (also in p_traceflags)321 * trace flags (also in p_traceflags)
...@@ -337,6 +356,7 @@ void ktrstruct(const char *, const void *, size_t);...@@ -337,6 +356,7 @@ void ktrstruct(const char *, const void *, size_t);
337void ktrstruct_error(const char *, const void *, size_t, int);356void ktrstruct_error(const char *, const void *, size_t, int);
338void ktrstructarray(const char *, enum uio_seg, const void *, int, size_t);357void ktrstructarray(const char *, enum uio_seg, const void *, int, size_t);
339void ktrcapfail(enum ktr_cap_violation, const void *);358void ktrcapfail(enum ktr_cap_violation, const void *);
359void ktrdata(int, const void *, size_t);
340#define ktrcaprights(s) \360#define ktrcaprights(s) \
341 ktrstruct("caprights", (s), sizeof(cap_rights_t))361 ktrstruct("caprights", (s), sizeof(cap_rights_t))
342#define ktritimerval(s) \362#define ktritimerval(s) \
...@@ -351,6 +371,8 @@ void ktrcapfail(enum ktr_cap_violation, const void *);...@@ -351,6 +371,8 @@ void ktrcapfail(enum ktr_cap_violation, const void *);
351 ktrstruct("cpuset_t", (s), l)371 ktrstruct("cpuset_t", (s), l)
352#define ktrsplice(s) \372#define ktrsplice(s) \
353 ktrstruct("splice", (s), sizeof(struct splice))373 ktrstruct("splice", (s), sizeof(struct splice))
374#define ktrthrparam(s) \
375 ktrstruct("thrparam", (s), sizeof(struct thr_param))
354extern u_int ktr_geniosize;376extern u_int ktr_geniosize;
355#ifdef KTRACE377#ifdef KTRACE
356extern int ktr_filesize_limit_signal;378extern int ktr_filesize_limit_signal;
lib/libc/include/generic-freebsd/sys/libkern.h+50-3
...@@ -27,18 +27,16 @@...@@ -27,18 +27,16 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)libkern.h 8.1 (Berkeley) 6/10/93
32 */30 */
3331
34#ifndef _SYS_LIBKERN_H_32#ifndef _SYS_LIBKERN_H_
35#define _SYS_LIBKERN_H_33#define _SYS_LIBKERN_H_
3634
37#include <sys/cdefs.h>
38#include <sys/types.h>35#include <sys/types.h>
39#ifdef _KERNEL36#ifdef _KERNEL
40#include <sys/systm.h>37#include <sys/systm.h>
41#endif38#endif
39#include <sys/kassert.h>
4240
43#ifndef LIBKERN_INLINE41#ifndef LIBKERN_INLINE
44#define LIBKERN_INLINE static __inline42#define LIBKERN_INLINE static __inline
...@@ -189,6 +187,49 @@ flsll(long long mask)...@@ -189,6 +187,49 @@ flsll(long long mask)
189 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));187 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
190}188}
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
192#define bitcount64(x) __bitcount64((uint64_t)(x))233#define bitcount64(x) __bitcount64((uint64_t)(x))
193#define bitcount32(x) __bitcount32((uint32_t)(x))234#define bitcount32(x) __bitcount32((uint32_t)(x))
194#define bitcount16(x) __bitcount16((uint16_t)(x))235#define bitcount16(x) __bitcount16((uint16_t)(x))
...@@ -293,4 +334,10 @@ signed_extend32(uint32_t bitmap, int lsb, int width)...@@ -293,4 +334,10 @@ signed_extend32(uint32_t bitmap, int lsb, int width)
293#define FNM_IGNORECASE FNM_CASEFOLD334#define FNM_IGNORECASE FNM_CASEFOLD
294#define FNM_FILE_NAME FNM_PATHNAME335#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
296#endif /* !_SYS_LIBKERN_H_ */343#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...@@ -93,10 +93,12 @@ struct dl_phdr_info
93__BEGIN_DECLS93__BEGIN_DECLS
9494
95typedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *);95typedef 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 *);
97int _rtld_addr_phdr(const void *, struct dl_phdr_info *);97int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
98int _rtld_get_stack_prot(void);98int _rtld_get_stack_prot(void);
99int _rtld_is_dlopened(void *);99int _rtld_is_dlopened(void *);
100const char *rtld_get_var(const char *name);
101int rtld_set_var(const char *name, const char *val);
100102
101#ifdef __ARM_EABI__103#ifdef __ARM_EABI__
102void * dl_unwind_find_exidx(const void *, int *);104void * dl_unwind_find_exidx(const void *, int *);
lib/libc/include/generic-freebsd/sys/linker.h+25-2
...@@ -29,6 +29,8 @@...@@ -29,6 +29,8 @@
29#ifndef _SYS_LINKER_H_29#ifndef _SYS_LINKER_H_
30#define _SYS_LINKER_H_30#define _SYS_LINKER_H_
3131
32#include <sys/param.h>
33
32#ifdef _KERNEL34#ifdef _KERNEL
3335
34#include <machine/elf.h>36#include <machine/elf.h>
...@@ -130,6 +132,12 @@ typedef int linker_predicate_t(linker_file_t, void *);...@@ -130,6 +132,12 @@ typedef int linker_predicate_t(linker_file_t, void *);
130 */132 */
131extern linker_file_t linker_kernel_file;133extern 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
133/*141/*
134 * Obtain a reference to a module, loading it if required.142 * Obtain a reference to a module, loading it if required.
135 */143 */
...@@ -212,6 +220,14 @@ void linker_kldload_unbusy(int flags);...@@ -212,6 +220,14 @@ void linker_kldload_unbusy(int flags);
212220
213#endif /* _KERNEL */221#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
215/*231/*
216 * Module information subtypes232 * Module information subtypes
217 */233 */
...@@ -264,7 +280,10 @@ void linker_kldload_unbusy(int flags);...@@ -264,7 +280,10 @@ void linker_kldload_unbusy(int flags);
264 * Module lookup280 * Module lookup
265 */281 */
266extern vm_offset_t preload_addr_relocate;282extern 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
269extern void * preload_fetch_addr(caddr_t _mod);288extern void * preload_fetch_addr(caddr_t _mod);
270extern size_t preload_fetch_size(caddr_t _mod);289extern size_t preload_fetch_size(caddr_t _mod);
...@@ -272,6 +291,7 @@ extern caddr_t preload_search_by_name(const char *_name);...@@ -272,6 +291,7 @@ extern caddr_t preload_search_by_name(const char *_name);
272extern caddr_t preload_search_by_type(const char *_type);291extern caddr_t preload_search_by_type(const char *_type);
273extern caddr_t preload_search_next_name(caddr_t _base);292extern caddr_t preload_search_next_name(caddr_t _base);
274extern caddr_t preload_search_info(caddr_t _mod, int _inf);293extern caddr_t preload_search_info(caddr_t _mod, int _inf);
294extern void preload_initkmdp(bool _fatal);
275extern void preload_delete_name(const char *_name);295extern void preload_delete_name(const char *_name);
276extern void preload_bootstrap_relocate(vm_offset_t _offset);296extern void preload_bootstrap_relocate(vm_offset_t _offset);
277extern void preload_dump(void);297extern void preload_dump(void);
...@@ -304,7 +324,7 @@ int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel,...@@ -304,7 +324,7 @@ int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel,
304Elf_Addr elf_relocaddr(linker_file_t _lf, Elf_Addr addr);324Elf_Addr elf_relocaddr(linker_file_t _lf, Elf_Addr addr);
305const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Size _symidx);325const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Size _symidx);
306const char *elf_get_symname(linker_file_t _lf, Elf_Size _symidx);326const char *elf_get_symname(linker_file_t _lf, Elf_Size _symidx);
307void link_elf_ireloc(caddr_t kmdp);327void link_elf_ireloc(void);
308328
309#if defined(__aarch64__) || defined(__amd64__)329#if defined(__aarch64__) || defined(__amd64__)
310int elf_reloc_late(linker_file_t _lf, Elf_Addr base, const void *_rel,330int elf_reloc_late(linker_file_t _lf, Elf_Addr base, const void *_rel,
...@@ -325,6 +345,9 @@ typedef struct linker_ctf {...@@ -325,6 +345,9 @@ typedef struct linker_ctf {
325} linker_ctf_t;345} linker_ctf_t;
326346
327int linker_ctf_get(linker_file_t, linker_ctf_t *);347int 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
329int elf_cpu_load_file(linker_file_t);352int elf_cpu_load_file(linker_file_t);
330int elf_cpu_unload_file(linker_file_t);353int elf_cpu_unload_file(linker_file_t);
lib/libc/include/generic-freebsd/sys/lock.h+1
...@@ -66,6 +66,7 @@ struct lock_class {...@@ -66,6 +66,7 @@ struct lock_class {
66 int (*lc_owner)(const struct lock_object *lock,66 int (*lc_owner)(const struct lock_object *lock,
67 struct thread **owner);67 struct thread **owner);
68 uintptr_t (*lc_unlock)(struct lock_object *lock);68 uintptr_t (*lc_unlock)(struct lock_object *lock);
69 int (*lc_trylock)(struct lock_object *lock, uintptr_t how);
69};70};
7071
71#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */72#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */
lib/libc/include/generic-freebsd/sys/lockf.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)lockf.h 8.1 (Berkeley) 6/11/93
35 */33 */
3634
37#ifndef _SYS_LOCKF_H_35#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,...@@ -130,6 +130,10 @@ _lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk,
130 LOCK_FILE, LOCK_LINE)130 LOCK_FILE, LOCK_LINE)
131#define lockmgr_disown(lk) \131#define lockmgr_disown(lk) \
132 _lockmgr_disown((lk), LOCK_FILE, LOCK_LINE)132 _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)))
133#define lockmgr_recursed_v(v) \137#define lockmgr_recursed_v(v) \
134 (v & LK_WRITER_RECURSED)138 (v & LK_WRITER_RECURSED)
135#define lockmgr_recursed(lk) \139#define lockmgr_recursed(lk) \
lib/libc/include/generic-freebsd/sys/mac.h+14
...@@ -47,6 +47,13 @@...@@ -47,6 +47,13 @@
47#ifndef _SYS_MAC_H_47#ifndef _SYS_MAC_H_
48#define _SYS_MAC_H_48#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
50#ifndef _POSIX_MAC57#ifndef _POSIX_MAC
51#define _POSIX_MAC58#define _POSIX_MAC
52#endif59#endif
...@@ -72,6 +79,13 @@ typedef struct mac *mac_t;...@@ -72,6 +79,13 @@ typedef struct mac *mac_t;
7279
73#ifndef _KERNEL80#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
75/*89/*
76 * Location of the userland MAC framework configuration file. mac.conf90 * Location of the userland MAC framework configuration file. mac.conf
77 * set defaults for MAC-aware applications.91 * set defaults for MAC-aware applications.
lib/libc/include/generic-freebsd/sys/malloc.h+7-4
...@@ -29,8 +29,6 @@...@@ -29,8 +29,6 @@
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29 * 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 OF30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.31 * SUCH DAMAGE.
32 *
33 * @(#)malloc.h 8.5 (Berkeley) 5/3/95
34 */32 */
3533
36#ifndef _SYS_MALLOC_H_34#ifndef _SYS_MALLOC_H_
...@@ -62,8 +60,9 @@...@@ -62,8 +60,9 @@
62#define M_BESTFIT 0x2000 /* only for vmem, low fragmentation */60#define M_BESTFIT 0x2000 /* only for vmem, low fragmentation */
63#define M_EXEC 0x4000 /* allocate executable space */61#define M_EXEC 0x4000 /* allocate executable space */
64#define M_NEXTFIT 0x8000 /* only for vmem, follow cursor */62#define M_NEXTFIT 0x8000 /* only for vmem, follow cursor */
63#define M_NEVERFREED 0x10000 /* chunk will never get freed */
6564
66#define M_VERSION 202011050165#define M_VERSION 2024073001
6766
68/*67/*
69 * Two malloc type structures are present: malloc_type, which is used by a68 * Two malloc type structures are present: malloc_type, which is used by a
...@@ -159,6 +158,9 @@ struct malloc_type_header {...@@ -159,6 +158,9 @@ struct malloc_type_header {
159158
160MALLOC_DECLARE(M_CACHE);159MALLOC_DECLARE(M_CACHE);
161MALLOC_DECLARE(M_DEVBUF);160MALLOC_DECLARE(M_DEVBUF);
161MALLOC_DECLARE(M_PARGS);
162MALLOC_DECLARE(M_SESSION);
163MALLOC_DECLARE(M_SUBPROC);
162MALLOC_DECLARE(M_TEMP);164MALLOC_DECLARE(M_TEMP);
163165
164/*166/*
...@@ -176,7 +178,8 @@ extern struct mtx malloc_mtx;...@@ -176,7 +178,8 @@ extern struct mtx malloc_mtx;
176 */178 */
177typedef void malloc_type_list_func_t(struct malloc_type *, void *);179typedef 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);
180void *contigmalloc(unsigned long size, struct malloc_type *type, int flags,183void *contigmalloc(unsigned long size, struct malloc_type *type, int flags,
181 vm_paddr_t low, vm_paddr_t high, unsigned long alignment,184 vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
182 vm_paddr_t boundary) __malloc_like __result_use_check185 vm_paddr_t boundary) __malloc_like __result_use_check
lib/libc/include/generic-freebsd/sys/mbuf.h+161-28
...@@ -28,8 +28,6 @@...@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
33 */31 */
3432
35#ifndef _SYS_MBUF_H_33#ifndef _SYS_MBUF_H_
...@@ -596,6 +594,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)...@@ -596,6 +594,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
596#define EXT_PACKET 6 /* mbuf+cluster from packet zone */594#define EXT_PACKET 6 /* mbuf+cluster from packet zone */
597#define EXT_MBUF 7 /* external mbuf reference */595#define EXT_MBUF 7 /* external mbuf reference */
598#define EXT_RXRING 8 /* data in NIC receive ring */596#define EXT_RXRING 8 /* data in NIC receive ring */
597#define EXT_CTL 9 /* buffer from a ctl(4) backend */
599598
600#define EXT_VENDOR1 224 /* for vendor-internal use */599#define EXT_VENDOR1 224 /* for vendor-internal use */
601#define EXT_VENDOR2 225 /* for vendor-internal use */600#define EXT_VENDOR2 225 /* for vendor-internal use */
...@@ -642,16 +641,15 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)...@@ -642,16 +641,15 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
642641
643/*642/*
644 * Flags indicating checksum, segmentation and other offload work to be643 * Flags indicating checksum, segmentation and other offload work to be
645 * done, or already done, by hardware or lower layers. It is split into644 * done, or already done, by hardware or lower layers.
646 * separate inbound and outbound flags.
647 *645 *
648 * Outbound flags that are set by upper protocol layers requesting lower646 * Flags that are set by upper protocol layers requesting lower
649 * layers, or ideally the hardware, to perform these offloading tasks.647 * layers, or ideally the hardware, to perform these offloading tasks.
650 * For outbound packets this field and its flags can be directly tested648 * Before passing packets to a network interface this field and its flags can
651 * against ifnet if_hwassist. Note that the outbound and the inbound flags do649 * be directly tested against ifnet if_hwassist. Note that the flags
652 * not collide right now but they could be allowed to (as long as the flags are650 * CSUM_IP_SCTP, CSUM_IP_TCP, and CSUM_IP_UDP can appear on input processing
653 * scrubbed appropriately when the direction of an mbuf changes). CSUM_BITS651 * of SCTP, TCP, and UDP. In such a case the checksum will not be computed or
654 * would also have to split into CSUM_BITS_TX and CSUM_BITS_RX.652 * validated by SCTP, TCP, or TCP, since the packet has not been on the wire.
655 *653 *
656 * CSUM_INNER_<x> is the same as CSUM_<x> but it applies to the inner frame.654 * CSUM_INNER_<x> is the same as CSUM_<x> but it applies to the inner frame.
657 * The CSUM_ENCAP_<x> bits identify the outer encapsulation.655 * The CSUM_ENCAP_<x> bits identify the outer encapsulation.
...@@ -680,7 +678,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)...@@ -680,7 +678,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
680#define CSUM_ENCAP_VXLAN 0x00040000 /* VXLAN outer encapsulation */678#define CSUM_ENCAP_VXLAN 0x00040000 /* VXLAN outer encapsulation */
681#define CSUM_ENCAP_RSVD1 0x00080000679#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. */
684#define CSUM_INNER_L3_CALC 0x00100000682#define CSUM_INNER_L3_CALC 0x00100000
685#define CSUM_INNER_L3_VALID 0x00200000683#define CSUM_INNER_L3_VALID 0x00200000
686#define CSUM_INNER_L4_CALC 0x00400000684#define CSUM_INNER_L4_CALC 0x00400000
...@@ -809,12 +807,12 @@ void mb_dupcl(struct mbuf *, struct mbuf *);...@@ -809,12 +807,12 @@ void mb_dupcl(struct mbuf *, struct mbuf *);
809void mb_free_ext(struct mbuf *);807void mb_free_ext(struct mbuf *);
810void mb_free_extpg(struct mbuf *);808void mb_free_extpg(struct mbuf *);
811void mb_free_mext_pgs(struct mbuf *);809void 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);
813struct mbuf *mb_alloc_ext_plus_pages(int, int);811struct mbuf *mb_alloc_ext_plus_pages(int, int);
814struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int,812struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int,
815 struct mbuf **);813 struct mbuf **);
816int mb_unmapped_compress(struct mbuf *m);814int 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);
818void mb_free_notready(struct mbuf *m, int count);816void mb_free_notready(struct mbuf *m, int count);
819void m_adj(struct mbuf *, int);817void m_adj(struct mbuf *, int);
820void m_adj_decap(struct mbuf *, int);818void m_adj_decap(struct mbuf *, int);
...@@ -886,9 +884,11 @@ m_gettype(int size)...@@ -886,9 +884,11 @@ m_gettype(int size)
886 case MCLBYTES:884 case MCLBYTES:
887 type = EXT_CLUSTER;885 type = EXT_CLUSTER;
888 break;886 break;
887#if MJUMPAGESIZE != MCLBYTES
889 case MJUMPAGESIZE:888 case MJUMPAGESIZE:
890 type = EXT_JUMBOP;889 type = EXT_JUMBOP;
891 break;890 break;
891#endif
892 case MJUM9BYTES:892 case MJUM9BYTES:
893 type = EXT_JUMBO9;893 type = EXT_JUMBO9;
894 break;894 break;
...@@ -934,9 +934,11 @@ m_getzone(int size)...@@ -934,9 +934,11 @@ m_getzone(int size)
934 case MCLBYTES:934 case MCLBYTES:
935 zone = zone_clust;935 zone = zone_clust;
936 break;936 break;
937#if MJUMPAGESIZE != MCLBYTES
937 case MJUMPAGESIZE:938 case MJUMPAGESIZE:
938 zone = zone_jumbop;939 zone = zone_jumbop;
939 break;940 break;
941#endif
940 case MJUM9BYTES:942 case MJUM9BYTES:
941 zone = zone_jumbo9;943 zone = zone_jumbo9;
942 break;944 break;
...@@ -1056,9 +1058,11 @@ m_cljset(struct mbuf *m, void *cl, int type)...@@ -1056,9 +1058,11 @@ m_cljset(struct mbuf *m, void *cl, int type)
1056 case EXT_CLUSTER:1058 case EXT_CLUSTER:
1057 size = MCLBYTES;1059 size = MCLBYTES;
1058 break;1060 break;
1061#if MJUMPAGESIZE != MCLBYTES
1059 case EXT_JUMBOP:1062 case EXT_JUMBOP:
1060 size = MJUMPAGESIZE;1063 size = MJUMPAGESIZE;
1061 break;1064 break;
1065#endif
1062 case EXT_JUMBO9:1066 case EXT_JUMBO9:
1063 size = MJUM9BYTES;1067 size = MJUM9BYTES;
1064 break;1068 break;
...@@ -1110,7 +1114,7 @@ static inline u_int...@@ -1110,7 +1114,7 @@ static inline u_int
1110m_extrefcnt(struct mbuf *m)1114m_extrefcnt(struct mbuf *m)
1111{1115{
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
1115 return ((m->m_ext.ext_flags & EXT_FLAG_EMBREF) ? m->m_ext.ext_count :1119 return ((m->m_ext.ext_flags & EXT_FLAG_EMBREF) ? m->m_ext.ext_count :
1116 *m->m_ext.ext_cnt);1120 *m->m_ext.ext_cnt);
...@@ -1142,13 +1146,13 @@ m_extrefcnt(struct mbuf *m)...@@ -1142,13 +1146,13 @@ m_extrefcnt(struct mbuf *m)
1142/* Check if the supplied mbuf has a packet header, or else panic. */1146/* Check if the supplied mbuf has a packet header, or else panic. */
1143#define M_ASSERTPKTHDR(m) \1147#define M_ASSERTPKTHDR(m) \
1144 KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \1148 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
1147/* Check if the supplied mbuf has no send tag, or else panic. */1151/* Check if the supplied mbuf has no send tag, or else panic. */
1148#define M_ASSERT_NO_SND_TAG(m) \1152#define M_ASSERT_NO_SND_TAG(m) \
1149 KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR && \1153 KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR && \
1150 ((m)->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0, \1154 ((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
1153/* Check if mbuf is multipage. */1157/* Check if mbuf is multipage. */
1154#define M_ASSERTEXTPG(m) \1158#define M_ASSERTEXTPG(m) \
...@@ -1162,7 +1166,7 @@ m_extrefcnt(struct mbuf *m)...@@ -1162,7 +1166,7 @@ m_extrefcnt(struct mbuf *m)
1162 */1166 */
1163#define M_ASSERTVALID(m) \1167#define M_ASSERTVALID(m) \
1164 KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \1168 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
1167/* Check whether any mbuf in the chain is unmapped. */1171/* Check whether any mbuf in the chain is unmapped. */
1168#ifdef INVARIANTS1172#ifdef INVARIANTS
...@@ -1207,12 +1211,9 @@ m_extrefcnt(struct mbuf *m)...@@ -1207,12 +1211,9 @@ m_extrefcnt(struct mbuf *m)
1207static __inline void1211static __inline void
1208m_align(struct mbuf *m, int len)1212m_align(struct mbuf *m, int len)
1209{1213{
1210#ifdef INVARIANTS
1211 const char *msg = "%s: not a virgin mbuf";
1212#endif
1213 int adjust;1214 int adjust;
12141215 KASSERT(m->m_data == M_START(m),
1215 KASSERT(m->m_data == M_START(m), (msg, __func__));1216 ("%s: not a virgin mbuf %p", __func__, m));
12161217
1217 adjust = M_SIZE(m) - len;1218 adjust = M_SIZE(m) - len;
1218 m->m_data += adjust &~ (sizeof(long)-1);1219 m->m_data += adjust &~ (sizeof(long)-1);
...@@ -1387,6 +1388,9 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */...@@ -1387,6 +1388,9 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */
1387#define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */1388#define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */
1388#define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */1389#define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */
1389#define PACKET_TAG_PF_REASSEMBLED 311390#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
1391/* Specific cookies and tags. */1395/* Specific cookies and tags. */
13921396
...@@ -1530,14 +1534,16 @@ m_free(struct mbuf *m)...@@ -1530,14 +1534,16 @@ m_free(struct mbuf *m)
1530static __inline int1534static __inline int
1531rt_m_getfib(struct mbuf *m)1535rt_m_getfib(struct mbuf *m)
1532{1536{
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));
1534 return (m->m_pkthdr.fibnum);1539 return (m->m_pkthdr.fibnum);
1535}1540}
15361541
1537#define M_GETFIB(_m) rt_m_getfib(_m)1542#define M_GETFIB(_m) rt_m_getfib(_m)
15381543
1539#define M_SETFIB(_m, _fib) do { \1544#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))); \
1541 ((_m)->m_pkthdr.fibnum) = (_fib); \1547 ((_m)->m_pkthdr.fibnum) = (_fib); \
1542} while (0)1548} while (0)
15431549
...@@ -1559,6 +1565,10 @@ uint32_t m_infiniband_tcpip_hash(const uint32_t, const struct mbuf *, uint32_t);...@@ -1559,6 +1565,10 @@ uint32_t m_infiniband_tcpip_hash(const uint32_t, const struct mbuf *, uint32_t);
1559 #define M_PROFILE(m)1565 #define M_PROFILE(m)
1560#endif1566#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 */
1562struct mbufq {1572struct mbufq {
1563 STAILQ_HEAD(, mbuf) mq_head;1573 STAILQ_HEAD(, mbuf) mq_head;
1564 int mq_len;1574 int mq_len;
...@@ -1676,14 +1686,137 @@ mbufq_concat(struct mbufq *mq_dst, struct mbufq *mq_src)...@@ -1676,14 +1686,137 @@ mbufq_concat(struct mbufq *mq_dst, struct mbufq *mq_src)
1676 mq_src->mq_len = 0;1686 mq_src->mq_len = 0;
1677}1687}
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
1679#ifdef _SYS_TIMESPEC_H_1812#ifdef _SYS_TIMESPEC_H_
1680static inline void1813static inline void
1681mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts)1814mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts)
1682{1815{
16831816
1684 KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m));1817 M_ASSERTPKTHDR(m);
1685 KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0,1818 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));
1687 ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;1820 ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
1688 ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000;1821 ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000;
1689}1822}
...@@ -1693,9 +1826,9 @@ static inline void...@@ -1693,9 +1826,9 @@ static inline void
1693mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv)1826mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv)
1694{1827{
16951828
1696 KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m));1829 M_ASSERTPKTHDR(m);
1697 KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0,1830 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));
1699 tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;1832 tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
1700 tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000;1833 tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000;
1701}1834}
lib/libc/include/generic-freebsd/sys/md4.h+44-4
...@@ -25,8 +25,8 @@...@@ -25,8 +25,8 @@
25 documentation and/or software.25 documentation and/or software.
26 */26 */
2727
28#ifndef _MD4_H_28#ifndef _SYS_MD4_H_
29#define _MD4_H_29#define _SYS_MD4_H_
30/* MD4 context. */30/* MD4 context. */
31typedef struct MD4Context {31typedef struct MD4Context {
32 u_int32_t state[4]; /* state (ABCD) */32 u_int32_t state[4]; /* state (ABCD) */
...@@ -36,6 +36,43 @@ typedef struct MD4Context {...@@ -36,6 +36,43 @@ typedef struct MD4Context {
3636
37#include <sys/cdefs.h>37#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
39__BEGIN_DECLS76__BEGIN_DECLS
40void MD4Init(MD4_CTX *);77void MD4Init(MD4_CTX *);
41void MD4Update(MD4_CTX *, const unsigned char *, unsigned int);78void MD4Update(MD4_CTX *, const unsigned char *, unsigned int);
...@@ -43,9 +80,12 @@ void MD4Pad(MD4_CTX *);...@@ -43,9 +80,12 @@ void MD4Pad(MD4_CTX *);
43void MD4Final(unsigned char [__min_size(16)], MD4_CTX *);80void MD4Final(unsigned char [__min_size(16)], MD4_CTX *);
44#ifndef _KERNEL81#ifndef _KERNEL
45char * MD4End(MD4_CTX *, char *);82char * MD4End(MD4_CTX *, char *);
83char * MD4Fd(int, char *);
84char * MD4FdChunk(int, char *, off_t, off_t);
46char * MD4File(const char *, char *);85char * 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 *);
48#endif88#endif
49__END_DECLS89__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....@@ -29,6 +29,8 @@ documentation and/or software.
29#ifndef _SYS_MD5_H_29#ifndef _SYS_MD5_H_
30#define _SYS_MD5_H_30#define _SYS_MD5_H_
3131
32#include <sys/types.h>
33
32#define MD5_BLOCK_LENGTH 6434#define MD5_BLOCK_LENGTH 64
33#define MD5_DIGEST_LENGTH 1635#define MD5_DIGEST_LENGTH 16
34#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)36#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
...@@ -40,6 +42,46 @@ typedef struct MD5Context {...@@ -40,6 +42,46 @@ typedef struct MD5Context {
40 unsigned char buffer[64]; /* input buffer */42 unsigned char buffer[64]; /* input buffer */
41} MD5_CTX;43} 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
43#include <sys/cdefs.h>85#include <sys/cdefs.h>
4486
45__BEGIN_DECLS87__BEGIN_DECLS
lib/libc/include/generic-freebsd/sys/mdioctl.h-4
...@@ -34,10 +34,6 @@...@@ -34,10 +34,6 @@
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *35 *
36 * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$36 * 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
41 */37 */
4238
43#ifndef _SYS_MDIOCTL_H_39#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,...@@ -163,4 +163,40 @@ void memdesc_copyback(struct memdesc *mem, int off, int size,
163 const void *src);163 const void *src);
164void memdesc_copydata(struct memdesc *mem, int off, int size, void *dst);164void 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
166#endif /* _SYS_MEMDESC_H_ */202#endif /* _SYS_MEMDESC_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/mman.h+18-16
...@@ -27,12 +27,10 @@...@@ -27,12 +27,10 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)mman.h 8.2 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_MMAN_H_32#ifndef _SYS_MMAN_H_
35#define _SYS_MMAN_H_33#define _SYS_MMAN_H_
3634
37#include <sys/cdefs.h>35#include <sys/cdefs.h>
38#include <sys/_types.h>36#include <sys/_types.h>
...@@ -41,10 +39,10 @@...@@ -41,10 +39,10 @@
41/*39/*
42 * Inheritance for minherit()40 * Inheritance for minherit()
43 */41 */
44#define INHERIT_SHARE 042#define INHERIT_SHARE 0
45#define INHERIT_COPY 143#define INHERIT_COPY 1
46#define INHERIT_NONE 244#define INHERIT_NONE 2
47#define INHERIT_ZERO 345#define INHERIT_ZERO 3
48#endif46#endif
4947
50/*48/*
...@@ -55,6 +53,8 @@...@@ -55,6 +53,8 @@
55#define PROT_WRITE 0x02 /* pages can be written */53#define PROT_WRITE 0x02 /* pages can be written */
56#define PROT_EXEC 0x04 /* pages can be executed */54#define PROT_EXEC 0x04 /* pages can be executed */
57#if __BSD_VISIBLE55#if __BSD_VISIBLE
56#define PROT_CHERI0 0x08
57#define PROT_CHERI1 0x10
58#define _PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)58#define _PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
59#define PROT_EXTRACT(prot) ((prot) & _PROT_ALL)59#define PROT_EXTRACT(prot) ((prot) & _PROT_ALL)
6060
...@@ -120,9 +120,9 @@...@@ -120,9 +120,9 @@
120 * Flags provided to shm_rename120 * Flags provided to shm_rename
121 */121 */
122/* Don't overwrite dest, if it exists */122/* Don't overwrite dest, if it exists */
123#define SHM_RENAME_NOREPLACE (1 << 0)123#define SHM_RENAME_NOREPLACE (1 << 0)
124/* Atomically swap src and dest */124/* Atomically swap src and dest */
125#define SHM_RENAME_EXCHANGE (1 << 1)125#define SHM_RENAME_EXCHANGE (1 << 1)
126126
127#endif /* __BSD_VISIBLE */127#endif /* __BSD_VISIBLE */
128128
...@@ -130,21 +130,21 @@...@@ -130,21 +130,21 @@
130/*130/*
131 * Process memory locking131 * Process memory locking
132 */132 */
133#define MCL_CURRENT 0x0001 /* Lock only current memory */133#define MCL_CURRENT 0x0001 /* Lock only current memory */
134#define MCL_FUTURE 0x0002 /* Lock all future memory as well */134#define MCL_FUTURE 0x0002 /* Lock all future memory as well */
135#endif135#endif
136136
137/*137/*
138 * Error return from mmap()138 * Error return from mmap()
139 */139 */
140#define MAP_FAILED ((void *)-1)140#define MAP_FAILED ((void *)-1)
141141
142/*142/*
143 * msync() flags143 * msync() flags
144 */144 */
145#define MS_SYNC 0x0000 /* msync synchronously */145#define MS_SYNC 0x0000 /* msync synchronously */
146#define MS_ASYNC 0x0001 /* return immediately */146#define MS_ASYNC 0x0001 /* return immediately */
147#define MS_INVALIDATE 0x0002 /* invalidate all cached data */147#define MS_INVALIDATE 0x0002 /* invalidate all cached data */
148148
149/*149/*
150 * Advice to madvise150 * Advice to madvise
...@@ -177,7 +177,9 @@...@@ -177,7 +177,9 @@
177#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */177#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
178#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */178#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */
179#define MINCORE_SUPER 0x60 /* Page is a "super" page */179#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
182/*184/*
183 * Anonymous object constant for shm_open().185 * Anonymous object constant for shm_open().
...@@ -312,7 +314,7 @@ bool shm_largepage(struct shmfd *shmfd);...@@ -312,7 +314,7 @@ bool shm_largepage(struct shmfd *shmfd);
312void shm_remove_prison(struct prison *pr);314void shm_remove_prison(struct prison *pr);
313int shm_get_path(struct vm_object *obj, char *path, size_t sz);315int 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
317#define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31)319#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 @@...@@ -27,22 +27,24 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)mount.h 8.21 (Berkeley) 5/20/95
32 */30 */
3331
34#ifndef _SYS_MOUNT_H_32#ifndef _SYS_MOUNT_H_
35#define _SYS_MOUNT_H_33#define _SYS_MOUNT_H_
3634
35#include <sys/types.h>
37#include <sys/ucred.h>36#include <sys/ucred.h>
38#include <sys/queue.h>37#include <sys/queue.h>
39#ifdef _KERNEL38#ifdef _KERNEL
40#include <sys/types.h>
41#include <sys/lock.h>39#include <sys/lock.h>
42#include <sys/lockmgr.h>40#include <sys/lockmgr.h>
43#include <sys/tslog.h>41#include <sys/tslog.h>
44#include <sys/_mutex.h>42#include <sys/_mutex.h>
45#include <sys/_sx.h>43#include <sys/_sx.h>
44#elif defined(_WANT_MOUNT)
45#include <sys/_lock.h>
46#include <sys/_lockmgr.h>
47#include <sys/_mutex.h>
46#endif48#endif
4749
48/*50/*
...@@ -265,6 +267,7 @@ struct mount {...@@ -265,6 +267,7 @@ struct mount {
265 int mnt_lazyvnodelistsize; /* (l) # of lazy vnodes */267 int mnt_lazyvnodelistsize; /* (l) # of lazy vnodes */
266 int mnt_upper_pending; /* (i) # of pending ops on mnt_uppers */268 int mnt_upper_pending; /* (i) # of pending ops on mnt_uppers */
267 struct lock mnt_explock; /* vfs_export walkers lock */269 struct lock mnt_explock; /* vfs_export walkers lock */
270 struct lock mnt_renamelock; /* renames and O_RESOLVE_BENEATH */
268 TAILQ_HEAD(, mount_upper_node) mnt_uppers; /* (i) upper mounts over us */271 TAILQ_HEAD(, mount_upper_node) mnt_uppers; /* (i) upper mounts over us */
269 TAILQ_HEAD(, mount_upper_node) mnt_notify; /* (i) upper mounts for notification */272 TAILQ_HEAD(, mount_upper_node) mnt_notify; /* (i) upper mounts for notification */
270 STAILQ_ENTRY(mount) mnt_taskqueue_link; /* (d) our place in deferred unmount list */273 STAILQ_ENTRY(mount) mnt_taskqueue_link; /* (d) our place in deferred unmount list */
...@@ -367,6 +370,7 @@ struct mntoptnames {...@@ -367,6 +370,7 @@ struct mntoptnames {
367 { MNT_RELOAD, "reload" }, \370 { MNT_RELOAD, "reload" }, \
368 { MNT_FORCE, "force" }, \371 { MNT_FORCE, "force" }, \
369 { MNT_SNAPSHOT, "snapshot" }, \372 { MNT_SNAPSHOT, "snapshot" }, \
373 { MNT_NAMEDATTR, "named attributes" }, \
370 { 0, NULL }374 { 0, NULL }
371#endif375#endif
372376
...@@ -392,6 +396,7 @@ struct mntoptnames {...@@ -392,6 +396,7 @@ struct mntoptnames {
392#define MNT_SUJ 0x0000000100000000ULL /* using journaled soft updates */396#define MNT_SUJ 0x0000000100000000ULL /* using journaled soft updates */
393#define MNT_AUTOMOUNTED 0x0000000200000000ULL /* mounted by automountd(8) */397#define MNT_AUTOMOUNTED 0x0000000200000000ULL /* mounted by automountd(8) */
394#define MNT_UNTRUSTED 0x0000000800000000ULL /* filesys metadata untrusted */398#define MNT_UNTRUSTED 0x0000000800000000ULL /* filesys metadata untrusted */
399#define MNT_NAMEDATTR 0x0000020000000000ULL /* named attributes enabled */
395400
396/*401/*
397 * NFS export related mount flags.402 * NFS export related mount flags.
...@@ -431,7 +436,7 @@ struct mntoptnames {...@@ -431,7 +436,7 @@ struct mntoptnames {
431 MNT_IGNORE | MNT_EXPUBLIC | MNT_NOSYMFOLLOW | \436 MNT_IGNORE | MNT_EXPUBLIC | MNT_NOSYMFOLLOW | \
432 MNT_GJOURNAL | MNT_MULTILABEL | MNT_ACLS | \437 MNT_GJOURNAL | MNT_MULTILABEL | MNT_ACLS | \
433 MNT_NFS4ACLS | MNT_AUTOMOUNTED | MNT_VERIFIED | \438 MNT_NFS4ACLS | MNT_AUTOMOUNTED | MNT_VERIFIED | \
434 MNT_UNTRUSTED)439 MNT_UNTRUSTED | MNT_NAMEDATTR)
435440
436/* Mask of flags that can be updated. */441/* Mask of flags that can be updated. */
437#define MNT_UPDATEMASK (MNT_NOSUID | MNT_NOEXEC | \442#define MNT_UPDATEMASK (MNT_NOSUID | MNT_NOEXEC | \
...@@ -687,6 +692,8 @@ struct ovfsconf {...@@ -687,6 +692,8 @@ struct ovfsconf {
687#define VFCF_SBDRY 0x01000000 /* Stop at Boundary: defer stop requests692#define VFCF_SBDRY 0x01000000 /* Stop at Boundary: defer stop requests
688 to kernel->user (AST) transition */693 to kernel->user (AST) transition */
689#define VFCF_FILEMOUNT 0x02000000 /* allow mounting files */694#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
691typedef uint32_t fsctlop_t;698typedef uint32_t fsctlop_t;
692699
...@@ -1000,6 +1007,7 @@ struct mntarg *mount_argsu(struct mntarg *ma, const char *name, const void *val,...@@ -1000,6 +1007,7 @@ struct mntarg *mount_argsu(struct mntarg *ma, const char *name, const void *val,
1000void statfs_scale_blocks(struct statfs *sf, long max_size);1007void statfs_scale_blocks(struct statfs *sf, long max_size);
1001struct vfsconf *vfs_byname(const char *);1008struct vfsconf *vfs_byname(const char *);
1002struct vfsconf *vfs_byname_kld(const char *, struct thread *td, int *);1009struct vfsconf *vfs_byname_kld(const char *, struct thread *td, int *);
1010void vfs_unref_vfsconf(struct vfsconf *vfsp);
1003void vfs_mount_destroy(struct mount *);1011void vfs_mount_destroy(struct mount *);
1004void vfs_event_signal(fsid_t *, u_int32_t, intptr_t);1012void vfs_event_signal(fsid_t *, u_int32_t, intptr_t);
1005void vfs_freeopts(struct vfsoptlist *opts);1013void 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 *);...@@ -162,9 +162,6 @@ int msgctl(int, int, struct msqid_ds *);
162int msgget(key_t, int);162int msgget(key_t, int);
163ssize_t msgrcv(int, void *, size_t, long, int);163ssize_t msgrcv(int, void *, size_t, long, int);
164int msgsnd(int, const void *, size_t, int);164int msgsnd(int, const void *, size_t, int);
165#if __BSD_VISIBLE
166int msgsys(int, ...);
167#endif
168__END_DECLS165__END_DECLS
169#endif /* !_KERNEL */166#endif /* !_KERNEL */
170167
lib/libc/include/generic-freebsd/sys/msgbuf.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_MSGBUF_H_32#ifndef _SYS_MSGBUF_H_
lib/libc/include/generic-freebsd/sys/mtio.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)mtio.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_MTIO_H_32#ifndef _SYS_MTIO_H_
lib/libc/include/generic-freebsd/sys/mutex.h+1-1
...@@ -91,7 +91,7 @@...@@ -91,7 +91,7 @@
91void _mtx_init(volatile uintptr_t *c, const char *name, const char *type,91void _mtx_init(volatile uintptr_t *c, const char *name, const char *type,
92 int opts);92 int opts);
93void _mtx_destroy(volatile uintptr_t *c);93void _mtx_destroy(volatile uintptr_t *c);
94void mtx_sysinit(void *arg);94void mtx_sysinit(const void *arg);
95int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF);95int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF);
96int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file,96int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file,
97 int line);97 int line);
lib/libc/include/generic-freebsd/sys/namei.h+26-8
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)namei.h 8.5 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_NAMEI_H_32#ifndef _SYS_NAMEI_H_
...@@ -40,6 +38,8 @@...@@ -40,6 +38,8 @@
40#include <sys/_seqc.h>38#include <sys/_seqc.h>
41#include <sys/_uio.h>39#include <sys/_uio.h>
4240
41#include <vm/uma.h>
42
43enum nameiop { LOOKUP, CREATE, DELETE, RENAME };43enum nameiop { LOOKUP, CREATE, DELETE, RENAME };
4444
45struct componentname {45struct componentname {
...@@ -70,7 +70,7 @@ struct nameidata {...@@ -70,7 +70,7 @@ struct nameidata {
70 */70 */
71 const char *ni_dirp; /* pathname pointer */71 const char *ni_dirp; /* pathname pointer */
72 enum uio_seg ni_segflg; /* location of pathname */72 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 */
74 /*74 /*
75 * Arguments to lookup.75 * Arguments to lookup.
76 */76 */
...@@ -108,7 +108,12 @@ struct nameidata {...@@ -108,7 +108,12 @@ struct nameidata {
108 * through the VOP interface.108 * through the VOP interface.
109 */109 */
110 struct componentname ni_cnd;110 struct componentname ni_cnd;
111
112 /* Serving RBENEATH. */
111 struct nameicap_tracker_head ni_cap_tracker;113 struct nameicap_tracker_head ni_cap_tracker;
114 struct vnode *ni_rbeneath_dpp;
115 struct mount *ni_nctrack_mnt;
116
112 /*117 /*
113 * Private helper data for UFS, must be at the end. See118 * Private helper data for UFS, must be at the end. See
114 * NDINIT_PREFILL().119 * NDINIT_PREFILL().
...@@ -152,6 +157,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,...@@ -152,6 +157,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
152#define LOCKSHARED 0x0100 /* Shared lock leaf */157#define LOCKSHARED 0x0100 /* Shared lock leaf */
153#define NOFOLLOW 0x0000 /* do not follow symbolic links (pseudo) */158#define NOFOLLOW 0x0000 /* do not follow symbolic links (pseudo) */
154#define RBENEATH 0x100000000ULL /* No escape, even tmp, from start dir */159#define RBENEATH 0x100000000ULL /* No escape, even tmp, from start dir */
160#define NAMEILOOKUP 0x200000000ULL /* cnp is embedded in nameidata */
155#define MODMASK 0xf000001ffULL /* mask of operational modifiers */161#define MODMASK 0xf000001ffULL /* mask of operational modifiers */
156162
157/*163/*
...@@ -159,7 +165,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,...@@ -159,7 +165,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
159 */165 */
160#define RDONLY 0x00000200 /* lookup with read-only semantics */166#define RDONLY 0x00000200 /* lookup with read-only semantics */
161#define ISRESTARTED 0x00000400 /* restarted namei */167#define ISRESTARTED 0x00000400 /* restarted namei */
162/* UNUSED 0x00000800 */168#define IGNOREWHITEOUT 0x00000800 /* ignore whiteouts, e.g. when checking if a dir is empty */
163#define ISWHITEOUT 0x00001000 /* found whiteout */169#define ISWHITEOUT 0x00001000 /* found whiteout */
164#define DOWHITEOUT 0x00002000 /* do whiteouts */170#define DOWHITEOUT 0x00002000 /* do whiteouts */
165#define WILLBEDIR 0x00004000 /* new files will be dirs; allow trailing / */171#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,...@@ -172,14 +178,15 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
172#define OPENREAD 0x00200000 /* open for reading */178#define OPENREAD 0x00200000 /* open for reading */
173#define OPENWRITE 0x00400000 /* open for writing */179#define OPENWRITE 0x00400000 /* open for writing */
174#define WANTIOCTLCAPS 0x00800000 /* leave ioctl caps for the caller */180#define WANTIOCTLCAPS 0x00800000 /* leave ioctl caps for the caller */
175/* UNUSED 0x01000000 */181#define OPENNAMED 0x01000000 /* opening a named attribute (dir) */
176#define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */182#define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */
177#define MAKEENTRY 0x04000000 /* entry is to be added to name cache */183#define MAKEENTRY 0x04000000 /* entry is to be added to name cache */
178#define ISSYMLINK 0x08000000 /* symlink needs interpretation */184#define ISSYMLINK 0x08000000 /* symlink needs interpretation */
179#define ISLASTCN 0x10000000 /* this is last component of pathname */185#define ISLASTCN 0x10000000 /* this is last component of pathname */
180#define ISDOTDOT 0x20000000 /* current component name is .. */186#define ISDOTDOT 0x20000000 /* current component name is .. */
181#define TRAILINGSLASH 0x40000000 /* path ended in a slash */187#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
184/*191/*
185 * Flags which must not be passed in by callers.192 * Flags which must not be passed in by callers.
...@@ -194,6 +201,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,...@@ -194,6 +201,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
194#define NIRES_ABS 0x00000001 /* Path was absolute */201#define NIRES_ABS 0x00000001 /* Path was absolute */
195#define NIRES_STRICTREL 0x00000002 /* Restricted lookup result */202#define NIRES_STRICTREL 0x00000002 /* Restricted lookup result */
196#define NIRES_EMPTYPATH 0x00000004 /* EMPTYPATH used */203#define NIRES_EMPTYPATH 0x00000004 /* EMPTYPATH used */
204#define NIRES_BENEATH 0x00000008 /* O_RESOLVE_BENEATH is to be inherited */
197205
198/*206/*
199 * Flags in ni_lcf, valid for the duration of the namei call.207 * 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,...@@ -232,6 +240,10 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
232 panic("namei data not inited"); \240 panic("namei data not inited"); \
233 if (((arg)->ni_debugflags & NAMEI_DBG_HADSTARTDIR) != 0) \241 if (((arg)->ni_debugflags & NAMEI_DBG_HADSTARTDIR) != 0) \
234 panic("NDREINIT on namei data with NAMEI_DBG_HADSTARTDIR"); \242 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"); \
235 (arg)->ni_debugflags = NAMEI_DBG_INITED; \247 (arg)->ni_debugflags = NAMEI_DBG_INITED; \
236}248}
237#else249#else
...@@ -243,12 +255,12 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,...@@ -243,12 +255,12 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
243#define NDINIT_ALL(ndp, op, flags, segflg, namep, dirfd, startdir, rightsp) \255#define NDINIT_ALL(ndp, op, flags, segflg, namep, dirfd, startdir, rightsp) \
244do { \256do { \
245 struct nameidata *_ndp = (ndp); \257 struct nameidata *_ndp = (ndp); \
246 cap_rights_t *_rightsp = (rightsp); \258 const cap_rights_t *_rightsp = (rightsp); \
247 MPASS(_rightsp != NULL); \259 MPASS(_rightsp != NULL); \
248 NDINIT_PREFILL(_ndp); \260 NDINIT_PREFILL(_ndp); \
249 NDINIT_DBG(_ndp); \261 NDINIT_DBG(_ndp); \
250 _ndp->ni_cnd.cn_nameiop = op; \262 _ndp->ni_cnd.cn_nameiop = op; \
251 _ndp->ni_cnd.cn_flags = flags; \263 _ndp->ni_cnd.cn_flags = (flags) | NAMEILOOKUP; \
252 _ndp->ni_segflg = segflg; \264 _ndp->ni_segflg = segflg; \
253 _ndp->ni_dirp = namep; \265 _ndp->ni_dirp = namep; \
254 _ndp->ni_dirfd = dirfd; \266 _ndp->ni_dirfd = dirfd; \
...@@ -256,6 +268,9 @@ do { \...@@ -256,6 +268,9 @@ do { \
256 _ndp->ni_resflags = 0; \268 _ndp->ni_resflags = 0; \
257 filecaps_init(&_ndp->ni_filecaps); \269 filecaps_init(&_ndp->ni_filecaps); \
258 _ndp->ni_rightsneeded = _rightsp; \270 _ndp->ni_rightsneeded = _rightsp; \
271 _ndp->ni_rbeneath_dpp = NULL; \
272 _ndp->ni_nctrack_mnt = NULL; \
273 TAILQ_INIT(&_ndp->ni_cap_tracker); \
259} while (0)274} while (0)
260275
261#define NDREINIT(ndp) do { \276#define NDREINIT(ndp) do { \
...@@ -264,6 +279,7 @@ do { \...@@ -264,6 +279,7 @@ do { \
264 filecaps_free(&_ndp->ni_filecaps); \279 filecaps_free(&_ndp->ni_filecaps); \
265 _ndp->ni_resflags = 0; \280 _ndp->ni_resflags = 0; \
266 _ndp->ni_startdir = NULL; \281 _ndp->ni_startdir = NULL; \
282 _ndp->ni_cnd.cn_flags &= ~NAMEI_INTERNAL_FLAGS; \
267} while (0)283} while (0)
268284
269#define NDPREINIT(ndp) do { \285#define NDPREINIT(ndp) do { \
...@@ -285,6 +301,8 @@ do { \...@@ -285,6 +301,8 @@ do { \
285301
286int namei(struct nameidata *ndp);302int namei(struct nameidata *ndp);
287int vfs_lookup(struct nameidata *ndp);303int vfs_lookup(struct nameidata *ndp);
304bool vfs_lookup_isroot(struct nameidata *ndp, struct vnode *dvp);
305struct nameidata *vfs_lookup_nameidata(struct componentname *cnp);
288int vfs_relookup(struct vnode *dvp, struct vnode **vpp,306int vfs_relookup(struct vnode *dvp, struct vnode **vpp,
289 struct componentname *cnp, bool refstart);307 struct componentname *cnp, bool refstart);
290308
lib/libc/include/generic-freebsd/sys/nlist_aout.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)nlist.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_NLIST_AOUT_H_37#ifndef _SYS_NLIST_AOUT_H_
lib/libc/include/generic-freebsd/sys/nv.h+1-7
...@@ -34,6 +34,7 @@...@@ -34,6 +34,7 @@
34#define _NV_H_34#define _NV_H_
3535
36#include <sys/cdefs.h>36#include <sys/cdefs.h>
37#include <sys/_nv.h>
3738
38#ifndef _KERNEL39#ifndef _KERNEL
39#include <stdarg.h>40#include <stdarg.h>
...@@ -43,13 +44,6 @@...@@ -43,13 +44,6 @@
43#include <sys/nv_namespace.h>44#include <sys/nv_namespace.h>
44#endif45#endif
4546
46#ifndef _NVLIST_T_DECLARED
47#define _NVLIST_T_DECLARED
48struct nvlist;
49
50typedef struct nvlist nvlist_t;
51#endif
52
53#define NV_NAME_MAX 204847#define NV_NAME_MAX 2048
5448
55#define NV_TYPE_NONE 049#define NV_TYPE_NONE 0
lib/libc/include/generic-freebsd/sys/nvpair.h+3
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: CDDL-1.0
1/*2/*
2 * CDDL HEADER START3 * CDDL HEADER START
3 *4 *
...@@ -266,6 +267,8 @@ _SYS_NVPAIR_H int nvlist_lookup_double(const nvlist_t *, const char *,...@@ -266,6 +267,8 @@ _SYS_NVPAIR_H int nvlist_lookup_double(const nvlist_t *, const char *,
266 double *);267 double *);
267#endif268#endif
268269
270_SYS_NVPAIR_H int nvlist_snprintf(char *, size_t, nvlist_t *, int);
271
269_SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);272_SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);
270_SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *,273_SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *,
271 nvpair_t **, int *, const char **);274 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);...@@ -55,7 +55,7 @@ typedef void (*osd_destructor_t)(void *value);
55typedef int (*osd_method_t)(void *obj, void *data);55typedef int (*osd_method_t)(void *obj, void *data);
5656
57int osd_register(u_int type, osd_destructor_t destructor,57int osd_register(u_int type, osd_destructor_t destructor,
58 osd_method_t *methods);58 const osd_method_t *methods);
59void osd_deregister(u_int type, u_int slot);59void osd_deregister(u_int type, u_int slot);
6060
61int osd_set(u_int type, struct osd *osd, u_int slot, void *value);61int 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,...@@ -64,6 +64,7 @@ int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv,
64 void *value);64 void *value);
65void osd_free_reserved(void **rsv);65void osd_free_reserved(void **rsv);
66void *osd_get(u_int type, struct osd *osd, u_int slot);66void *osd_get(u_int type, struct osd *osd, u_int slot);
67void *osd_get_unlocked(u_int type, struct osd *osd, u_int slot);
67void osd_del(u_int type, struct osd *osd, u_int slot);68void osd_del(u_int type, struct osd *osd, u_int slot);
68int osd_call(u_int type, u_int method, void *obj, void *data);69int 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);...@@ -79,6 +80,8 @@ void osd_exit(u_int type, struct osd *osd);
79 osd_set_reserved(OSD_THREAD, &(td)->td_osd, (slot), (rsv), (value))80 osd_set_reserved(OSD_THREAD, &(td)->td_osd, (slot), (rsv), (value))
80#define osd_thread_get(td, slot) \81#define osd_thread_get(td, slot) \
81 osd_get(OSD_THREAD, &(td)->td_osd, (slot))82 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))
82#define osd_thread_del(td, slot) do { \85#define osd_thread_del(td, slot) do { \
83 KASSERT((td) == curthread, ("Not curthread.")); \86 KASSERT((td) == curthread, ("Not curthread.")); \
84 osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \87 osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \
...@@ -98,6 +101,8 @@ void osd_exit(u_int type, struct osd *osd);...@@ -98,6 +101,8 @@ void osd_exit(u_int type, struct osd *osd);
98 osd_set_reserved(OSD_JAIL, &(pr)->pr_osd, (slot), (rsv), (value))101 osd_set_reserved(OSD_JAIL, &(pr)->pr_osd, (slot), (rsv), (value))
99#define osd_jail_get(pr, slot) \102#define osd_jail_get(pr, slot) \
100 osd_get(OSD_JAIL, &(pr)->pr_osd, (slot))103 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))
101#define osd_jail_del(pr, slot) \106#define osd_jail_del(pr, slot) \
102 osd_del(OSD_JAIL, &(pr)->pr_osd, (slot))107 osd_del(OSD_JAIL, &(pr)->pr_osd, (slot))
103#define osd_jail_call(pr, method, data) \108#define osd_jail_call(pr, method, data) \
lib/libc/include/generic-freebsd/sys/param.h+18-26
...@@ -32,14 +32,13 @@...@@ -32,14 +32,13 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)param.h 8.3 (Berkeley) 4/4/95
37 */35 */
3836
39#ifndef _SYS_PARAM_H_37#ifndef _SYS_PARAM_H_
40#define _SYS_PARAM_H_38#define _SYS_PARAM_H_
4139
42#include <sys/_null.h>40#include <sys/_null.h>
41#include <sys/_param.h>
4342
44#define BSD 199506 /* System version (year & month). */43#define BSD 199506 /* System version (year & month). */
45#define BSD4_3 144#define BSD4_3 1
...@@ -107,6 +106,8 @@...@@ -107,6 +106,8 @@
107#define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070106#define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070
108#define P_OSREL_TIDPID 1400079107#define P_OSREL_TIDPID 1400079
109#define P_OSREL_ARM64_SPSR 1400084108#define P_OSREL_ARM64_SPSR 1400084
109#define P_OSREL_TLSBASE 1500044
110#define P_OSREL_EXTERRCTL 1500045
110111
111#define P_OSREL_MAJOR(x) ((x) / 100000)112#define P_OSREL_MAJOR(x) ((x) / 100000)
112#endif113#endif
...@@ -151,17 +152,16 @@...@@ -151,17 +152,16 @@
151#endif152#endif
152#endif153#endif
153154
154#ifndef _KERNEL155#if !defined(_KERNEL) && !defined(_STANDALONE) && !defined(LOCORE)
155#ifndef LOCORE
156/* Signals. */156/* Signals. */
157#include <sys/signal.h>157#include <sys/signal.h>
158#endif158#endif
159#endif
160159
161/* Machine type dependent parameters. */160/* Machine type dependent parameters. */
162#include <machine/param.h>161#include <machine/param.h>
163#ifndef _KERNEL162#ifndef _KERNEL
164#include <sys/limits.h>163#include <sys/limits.h>
164#include <sys/_maxphys.h>
165#endif165#endif
166166
167#ifndef DEV_BSHIFT167#ifndef DEV_BSHIFT
...@@ -175,13 +175,6 @@...@@ -175,13 +175,6 @@
175#ifndef DFLTPHYS175#ifndef DFLTPHYS
176#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */176#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */
177#endif177#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
185#ifndef MAXDUMPPGS178#ifndef MAXDUMPPGS
186#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)179#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
187#endif180#endif
...@@ -209,6 +202,17 @@...@@ -209,6 +202,17 @@
209#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */202#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */
210#define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */203#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
212/*216/*
213 * Some macros for units conversion217 * Some macros for units conversion
214 */218 */
...@@ -249,9 +253,6 @@...@@ -249,9 +253,6 @@
249253
250#define NZERO 0 /* default "nice" */254#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
255#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */256#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
256257
257#define NODEV (dev_t)(-1) /* non-existent device */258#define NODEV (dev_t)(-1) /* non-existent device */
...@@ -315,16 +316,7 @@...@@ -315,16 +316,7 @@
315#define isclr(a,i) \316#define isclr(a,i) \
316 ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)317 ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
317318
318/* Macros for counting and rounding. */319/* Macros for counting and rounding provided by <sys/_param.h>. */
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)
328320
329/* Macros for min/max. */321/* Macros for min/max. */
330#define MIN(a,b) (((a)<(b))?(a):(b))322#define MIN(a,b) (((a)<(b))?(a):(b))
...@@ -387,4 +379,4 @@ __END_DECLS...@@ -387,4 +379,4 @@ __END_DECLS
387 */379 */
388#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])380#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 {...@@ -66,10 +66,10 @@ struct pci_conf {
66 struct pcisel pc_sel; /* domain+bus+slot+function */66 struct pcisel pc_sel; /* domain+bus+slot+function */
67 u_int8_t pc_hdr; /* PCI header type */67 u_int8_t pc_hdr; /* PCI header type */
68 u_int16_t pc_subvendor; /* card vendor ID */68 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
70 card vendor */70 card vendor */
71 u_int16_t pc_vendor; /* chip vendor ID */71 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
73 chip vendor */73 chip vendor */
74 u_int8_t pc_class; /* chip PCI class */74 u_int8_t pc_class; /* chip PCI class */
75 u_int8_t pc_subclass; /* chip PCI subclass */75 u_int8_t pc_subclass; /* chip PCI subclass */
...@@ -77,6 +77,9 @@ struct pci_conf {...@@ -77,6 +77,9 @@ struct pci_conf {
77 u_int8_t pc_revid; /* chip revision ID */77 u_int8_t pc_revid; /* chip revision ID */
78 char pd_name[PCI_MAXNAMELEN + 1]; /* device name */78 char pd_name[PCI_MAXNAMELEN + 1]; /* device name */
79 u_long pd_unit; /* device unit number */79 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 */
80};83};
8184
82struct pci_match_conf {85struct pci_match_conf {
...@@ -165,7 +168,6 @@ struct pci_bar_ioreq {...@@ -165,7 +168,6 @@ struct pci_bar_ioreq {
165#define PCIIO_BAR_MMAP_RW 0x04168#define PCIIO_BAR_MMAP_RW 0x04
166#define PCIIO_BAR_MMAP_ACTIVATE 0x08169#define PCIIO_BAR_MMAP_ACTIVATE 0x08
167170
168#define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io)
169#define PCIOCREAD _IOWR('p', 2, struct pci_io)171#define PCIOCREAD _IOWR('p', 2, struct pci_io)
170#define PCIOCWRITE _IOWR('p', 3, struct pci_io)172#define PCIOCWRITE _IOWR('p', 3, struct pci_io)
171#define PCIOCATTACHED _IOWR('p', 4, struct pci_io)173#define PCIOCATTACHED _IOWR('p', 4, struct pci_io)
...@@ -173,5 +175,6 @@ struct pci_bar_ioreq {...@@ -173,5 +175,6 @@ struct pci_bar_ioreq {
173#define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io)175#define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io)
174#define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap)176#define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap)
175#define PCIOCBARIO _IOWR('p', 9, struct pci_bar_ioreq)177#define PCIOCBARIO _IOWR('p', 9, struct pci_bar_ioreq)
178#define PCIOCGETCONF _IOWR('p', 10, struct pci_conf_io)
176179
177#endif /* !_SYS_PCIIO_H_ */180#endif /* !_SYS_PCIIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/pctrie.h+293-20
...@@ -34,8 +34,45 @@...@@ -34,8 +34,45 @@
34#include <sys/_pctrie.h>34#include <sys/_pctrie.h>
35#include <sys/_smr.h>35#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
37#ifdef _KERNEL72#ifdef _KERNEL
3873
74typedef void (*pctrie_cb_t)(void *ptr, void *arg);
75
39#define PCTRIE_DEFINE_SMR(name, type, field, allocfn, freefn, smr) \76#define PCTRIE_DEFINE_SMR(name, type, field, allocfn, freefn, smr) \
40 PCTRIE_DEFINE(name, type, field, allocfn, freefn) \77 PCTRIE_DEFINE(name, type, field, allocfn, freefn) \
41 \78 \
...@@ -46,6 +83,19 @@ name##_PCTRIE_LOOKUP_UNLOCKED(struct pctrie *ptree, uint64_t key) \...@@ -46,6 +83,19 @@ name##_PCTRIE_LOOKUP_UNLOCKED(struct pctrie *ptree, uint64_t key) \
46 return name##_PCTRIE_VAL2PTR(pctrie_lookup_unlocked(ptree, \83 return name##_PCTRIE_VAL2PTR(pctrie_lookup_unlocked(ptree, \
47 key, (smr))); \84 key, (smr))); \
48} \85} \
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
50#define PCTRIE_DEFINE(name, type, field, allocfn, freefn) \100#define PCTRIE_DEFINE(name, type, field, allocfn, freefn) \
51 \101 \
...@@ -57,13 +107,18 @@ CTASSERT(sizeof(((struct type *)0)->field) == sizeof(uint64_t)); \...@@ -57,13 +107,18 @@ CTASSERT(sizeof(((struct type *)0)->field) == sizeof(uint64_t)); \
57CTASSERT((__offsetof(struct type, field) & (sizeof(uint32_t) - 1)) == 0); \107CTASSERT((__offsetof(struct type, field) & (sizeof(uint32_t) - 1)) == 0); \
58 \108 \
59static __inline struct type * \109static __inline struct type * \
60name##_PCTRIE_VAL2PTR(uint64_t *val) \110name##_PCTRIE_NZVAL2PTR(uint64_t *val) \
61{ \111{ \
112 return (struct type *) \
113 ((uintptr_t)val - __offsetof(struct type, field)); \
114} \
62 \115 \
116static __inline struct type * \
117name##_PCTRIE_VAL2PTR(uint64_t *val) \
118{ \
63 if (val == NULL) \119 if (val == NULL) \
64 return (NULL); \120 return (NULL); \
65 return (struct type *) \121 return (name##_PCTRIE_NZVAL2PTR(val)); \
66 ((uintptr_t)val - __offsetof(struct type, field)); \
67} \122} \
68 \123 \
69static __inline uint64_t * \124static __inline uint64_t * \
...@@ -73,23 +128,87 @@ name##_PCTRIE_PTR2VAL(struct type *ptr) \...@@ -73,23 +128,87 @@ name##_PCTRIE_PTR2VAL(struct type *ptr) \
73 return &ptr->field; \128 return &ptr->field; \
74} \129} \
75 \130 \
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 \
77name##_PCTRIE_INSERT(struct pctrie *ptree, struct type *ptr) \156name##_PCTRIE_INSERT(struct pctrie *ptree, struct type *ptr) \
78{ \157{ \
158 void *parentp; \
79 struct pctrie_node *parent; \159 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{ \
80 void *parentp; \171 void *parentp; \
172 struct pctrie_node *parent; \
81 uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \173 uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \
174 uint64_t *found; \
82 \175 \
83 parentp = pctrie_insert_lookup(ptree, val); \176 parentp = pctrie_insert_lookup(ptree, val, &parent, &found); \
84 if (parentp == NULL) \177 return (name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \
85 return (0); \178 found, found_out_opt)); \
86 parent = allocfn(ptree); \179} \
87 if (parent == NULL) \180 \
88 return (ENOMEM); \181static __inline __unused int \
89 pctrie_insert_node(parentp, parent, val); \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); \
90 return (0); \198 return (0); \
91} \199} \
92 \200 \
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 \
93static __inline __unused struct type * \212static __inline __unused struct type * \
94name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \213name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \
95{ \214{ \
...@@ -97,6 +216,30 @@ name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \...@@ -97,6 +216,30 @@ name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \
97 return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \216 return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \
98} \217} \
99 \218 \
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 \
100static __inline __unused struct type * \243static __inline __unused struct type * \
101name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \244name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \
102{ \245{ \
...@@ -122,6 +265,108 @@ name##_PCTRIE_RECLAIM(struct pctrie *ptree) \...@@ -122,6 +265,108 @@ name##_PCTRIE_RECLAIM(struct pctrie *ptree) \
122 freefn(ptree, freenode); \265 freefn(ptree, freenode); \
123} \266} \
124 \267 \
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 \
125static __inline __unused struct type * \370static __inline __unused struct type * \
126name##_PCTRIE_REPLACE(struct pctrie *ptree, struct type *ptr) \371name##_PCTRIE_REPLACE(struct pctrie *ptree, struct type *ptr) \
127{ \372{ \
...@@ -139,8 +384,7 @@ name##_PCTRIE_REMOVE(struct pctrie *ptree, uint64_t key) \...@@ -139,8 +384,7 @@ name##_PCTRIE_REMOVE(struct pctrie *ptree, uint64_t key) \
139 val = pctrie_remove_lookup(ptree, key, &freenode); \384 val = pctrie_remove_lookup(ptree, key, &freenode); \
140 if (val == NULL) \385 if (val == NULL) \
141 panic("%s: key not found", __func__); \386 panic("%s: key not found", __func__); \
142 if (freenode != NULL) \387 name##_PCTRIE_REMOVE_BASE(ptree, freenode); \
143 freefn(ptree, freenode); \
144} \388} \
145 \389 \
146static __inline __unused struct type * \390static __inline __unused struct type * \
...@@ -150,24 +394,53 @@ name##_PCTRIE_REMOVE_LOOKUP(struct pctrie *ptree, uint64_t key) \...@@ -150,24 +394,53 @@ name##_PCTRIE_REMOVE_LOOKUP(struct pctrie *ptree, uint64_t key) \
150 struct pctrie_node *freenode; \394 struct pctrie_node *freenode; \
151 \395 \
152 val = pctrie_remove_lookup(ptree, key, &freenode); \396 val = pctrie_remove_lookup(ptree, key, &freenode); \
153 if (freenode != NULL) \397 name##_PCTRIE_REMOVE_BASE(ptree, freenode); \
154 freefn(ptree, freenode); \
155 return name##_PCTRIE_VAL2PTR(val); \398 return name##_PCTRIE_VAL2PTR(val); \
156}399}
157400
158void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val);401struct pctrie_iter;
159void pctrie_insert_node(void *parentp,402void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val,
160 struct pctrie_node *parent, 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);
161uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key);408uint64_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);
164uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key,409uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key,
165 smr_t smr);410 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);
166struct pctrie_node *pctrie_reclaim_begin(struct pctrie_node **pnode,431struct pctrie_node *pctrie_reclaim_begin(struct pctrie_node **pnode,
167 struct pctrie *ptree);432 struct pctrie *ptree);
168struct pctrie_node *pctrie_reclaim_resume(struct pctrie_node **pnode);433struct 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);
169uint64_t *pctrie_remove_lookup(struct pctrie *ptree, uint64_t index,439uint64_t *pctrie_remove_lookup(struct pctrie *ptree, uint64_t index,
170 struct pctrie_node **killnode);440 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);
171uint64_t *pctrie_replace(struct pctrie *ptree, uint64_t *newval);444uint64_t *pctrie_replace(struct pctrie *ptree, uint64_t *newval);
172size_t pctrie_node_size(void);445size_t pctrie_node_size(void);
173int pctrie_zone_init(void *mem, int size, int flags);446int pctrie_zone_init(void *mem, int size, int flags);
lib/libc/include/generic-freebsd/sys/pipe.h+1-1
...@@ -52,7 +52,7 @@...@@ -52,7 +52,7 @@
52 * See sys_pipe.c for info on what these limits mean. 52 * See sys_pipe.c for info on what these limits mean.
53 */53 */
54extern long maxpipekva;54extern long maxpipekva;
55extern struct fileops pipeops;55extern const struct fileops pipeops;
56#endif56#endif
5757
58/*58/*
lib/libc/include/generic-freebsd/sys/pmc.h+1-3
...@@ -81,7 +81,6 @@ extern char pmc_cpuid[PMC_CPUID_LEN];...@@ -81,7 +81,6 @@ extern char pmc_cpuid[PMC_CPUID_LEN];
81 * Please keep the pmc(3) manual page in sync with this list.81 * Please keep the pmc(3) manual page in sync with this list.
82 */82 */
83#define __PMC_CPUS() \83#define __PMC_CPUS() \
84 __PMC_CPU(AMD_K7, 0x00, "AMD K7") \
85 __PMC_CPU(AMD_K8, 0x01, "AMD K8") \84 __PMC_CPU(AMD_K8, 0x01, "AMD K8") \
86 __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \85 __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \
87 __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \86 __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \
...@@ -130,7 +129,7 @@ enum pmc_cputype {...@@ -130,7 +129,7 @@ enum pmc_cputype {
130 __PMC_CPUS()129 __PMC_CPUS()
131};130};
132131
133#define PMC_CPU_FIRST PMC_CPU_AMD_K7132#define PMC_CPU_FIRST PMC_CPU_AMD_K8
134#define PMC_CPU_LAST PMC_CPU_ARMV8_CORTEX_A76133#define PMC_CPU_LAST PMC_CPU_ARMV8_CORTEX_A76
135134
136/*135/*
...@@ -138,7 +137,6 @@ enum pmc_cputype {...@@ -138,7 +137,6 @@ enum pmc_cputype {
138 */137 */
139#define __PMC_CLASSES() \138#define __PMC_CLASSES() \
140 __PMC_CLASS(TSC, 0x00, "CPU Timestamp counter") \139 __PMC_CLASS(TSC, 0x00, "CPU Timestamp counter") \
141 __PMC_CLASS(K7, 0x01, "AMD K7 performance counters") \
142 __PMC_CLASS(K8, 0x02, "AMD K8 performance counters") \140 __PMC_CLASS(K8, 0x02, "AMD K8 performance counters") \
143 __PMC_CLASS(IAF, 0x06, "Intel Core2/Atom, fixed function") \141 __PMC_CLASS(IAF, 0x06, "Intel Core2/Atom, fixed function") \
144 __PMC_CLASS(IAP, 0x07, "Intel Core...Atom, programmable") \142 __PMC_CLASS(IAP, 0x07, "Intel Core...Atom, programmable") \
lib/libc/include/generic-freebsd/sys/poll.h+6-2
...@@ -96,7 +96,7 @@ struct pollfd {...@@ -96,7 +96,7 @@ struct pollfd {
9696
97#ifndef _KERNEL97#ifndef _KERNEL
9898
99#if __BSD_VISIBLE99#if __POSIX_VISIBLE >= 202405
100#include <sys/_types.h>100#include <sys/_types.h>
101101
102#include <sys/_sigset.h>102#include <sys/_sigset.h>
...@@ -109,9 +109,13 @@ typedef __sigset_t sigset_t;...@@ -109,9 +109,13 @@ typedef __sigset_t sigset_t;
109109
110#endif110#endif
111111
112#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
113#include <ssp/poll.h>
114#endif
115
112__BEGIN_DECLS116__BEGIN_DECLS
113int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);117int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
114#if __BSD_VISIBLE118#if __POSIX_VISIBLE >= 202405
115int ppoll(struct pollfd _pfd[], nfds_t _nfds,119int ppoll(struct pollfd _pfd[], nfds_t _nfds,
116 const struct timespec *__restrict _timeout,120 const struct timespec *__restrict _timeout,
117 const sigset_t *__restrict _newsigmask);121 const sigset_t *__restrict _newsigmask);
lib/libc/include/generic-freebsd/sys/priority.h+29-23
...@@ -64,17 +64,23 @@...@@ -64,17 +64,23 @@
64 */64 */
6565
66/*66/*
67 * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ)67 * Priorities range from 0 to 255. Ranges are as follows:
68 * are insignificant. Ranges are as follows:
69 *68 *
70 * Interrupt threads: 0 - 1569 * Interrupt threads: 0 - 7
71 * Realtime user threads: 16 - 4770 * Realtime user threads: 8 - 39
72 * Top half kernel threads: 48 - 8771 * Top half kernel threads: 40 - 55
73 * Time sharing user threads: 88 - 22372 * Time sharing user threads: 56 - 223
74 * Idle user threads: 224 - 25573 * Idle user threads: 224 - 255
75 *74 *
76 * XXX If/When the specific interrupt thread and top half thread ranges75 * Priority levels of rtprio(2)'s RTP_PRIO_FIFO and RTP_PRIO_REALTIME and
77 * disappear, a larger range can be used for user processes.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.
78 */84 */
7985
80#define PRI_MIN (0) /* Highest priority. */86#define PRI_MIN (0) /* Highest priority. */
...@@ -88,34 +94,34 @@...@@ -88,34 +94,34 @@
88 * decay to lower priorities if they run for full time slices.94 * decay to lower priorities if they run for full time slices.
89 */95 */
90#define PI_REALTIME (PRI_MIN_ITHD + 0)96#define PI_REALTIME (PRI_MIN_ITHD + 0)
91#define PI_INTR (PRI_MIN_ITHD + 4)97#define PI_INTR (PRI_MIN_ITHD + 1)
92#define PI_AV PI_INTR98#define PI_AV PI_INTR
93#define PI_NET PI_INTR99#define PI_NET PI_INTR
94#define PI_DISK PI_INTR100#define PI_DISK PI_INTR
95#define PI_TTY PI_INTR101#define PI_TTY PI_INTR
96#define PI_DULL PI_INTR102#define PI_DULL PI_INTR
97#define PI_SOFT (PRI_MIN_ITHD + 8)103#define PI_SOFT (PRI_MIN_ITHD + 2)
98#define PI_SOFTCLOCK PI_SOFT104#define PI_SOFTCLOCK PI_SOFT
99#define PI_SWI(x) PI_SOFT105#define PI_SWI(x) PI_SOFT
100106
101#define PRI_MIN_REALTIME (16)107#define PRI_MIN_REALTIME (8)
102#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1)108#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1)
103109
104#define PRI_MIN_KERN (48)110#define PRI_MIN_KERN (40)
105#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1)111#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1)
106112
107#define PSWP (PRI_MIN_KERN + 0)113#define PSWP (PRI_MIN_KERN + 0)
108#define PVM (PRI_MIN_KERN + 4)114#define PVM (PRI_MIN_KERN + 1)
109#define PINOD (PRI_MIN_KERN + 8)115#define PINOD (PRI_MIN_KERN + 2)
110#define PRIBIO (PRI_MIN_KERN + 12)116#define PRIBIO (PRI_MIN_KERN + 3)
111#define PVFS (PRI_MIN_KERN + 16)117#define PVFS (PRI_MIN_KERN + 4)
112#define PZERO (PRI_MIN_KERN + 20)118#define PZERO (PRI_MIN_KERN + 5)
113#define PSOCK (PRI_MIN_KERN + 24)119#define PSOCK (PRI_MIN_KERN + 6)
114#define PWAIT (PRI_MIN_KERN + 28)120#define PWAIT (PRI_MIN_KERN + 7)
115#define PLOCK (PRI_MIN_KERN + 32)121#define PLOCK (PRI_MIN_KERN + 8)
116#define PPAUSE (PRI_MIN_KERN + 36)122#define PPAUSE (PRI_MIN_KERN + 9)
117123
118#define PRI_MIN_TIMESHARE (88)124#define PRI_MIN_TIMESHARE (56)
119#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1)125#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1)
120126
121#define PUSER (PRI_MIN_TIMESHARE)127#define PUSER (PRI_MIN_TIMESHARE)
lib/libc/include/generic-freebsd/sys/priv.h+8-1
...@@ -105,7 +105,8 @@...@@ -105,7 +105,8 @@
105#define PRIV_CRED_SETRESGID 58 /* setresgid. */105#define PRIV_CRED_SETRESGID 58 /* setresgid. */
106#define PRIV_SEEOTHERGIDS 59 /* Exempt bsd.seeothergids. */106#define PRIV_SEEOTHERGIDS 59 /* Exempt bsd.seeothergids. */
107#define PRIV_SEEOTHERUIDS 60 /* Exempt bsd.seeotheruids. */107#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
110/*111/*
111 * Debugging privileges.112 * Debugging privileges.
...@@ -114,6 +115,7 @@...@@ -114,6 +115,7 @@
114#define PRIV_DEBUG_SUGID 81 /* Exempt debugging setuid proc. */115#define PRIV_DEBUG_SUGID 81 /* Exempt debugging setuid proc. */
115#define PRIV_DEBUG_UNPRIV 82 /* Exempt unprivileged debug limit. */116#define PRIV_DEBUG_UNPRIV 82 /* Exempt unprivileged debug limit. */
116#define PRIV_DEBUG_DENIED 83 /* Exempt P2_NOTRACE. */117#define PRIV_DEBUG_DENIED 83 /* Exempt P2_NOTRACE. */
118#define PRIV_DEBUG_DIFFJAIL 84 /* Exempt debugging other jails. */
117119
118/*120/*
119 * Dtrace privileges.121 * Dtrace privileges.
...@@ -192,6 +194,7 @@...@@ -192,6 +194,7 @@
192#define PRIV_SCHED_CPUSET 206 /* Can manipulate cpusets. */194#define PRIV_SCHED_CPUSET 206 /* Can manipulate cpusets. */
193#define PRIV_SCHED_CPUSET_INTR 207 /* Can adjust IRQ to CPU binding. */195#define PRIV_SCHED_CPUSET_INTR 207 /* Can adjust IRQ to CPU binding. */
194#define PRIV_SCHED_IDPRIO 208 /* Can set idle time scheduling. */196#define PRIV_SCHED_IDPRIO 208 /* Can set idle time scheduling. */
197#define PRIV_SCHED_DIFFJAIL 209 /* Exempt scheduling other jails. */
195198
196/*199/*
197 * POSIX semaphore privileges.200 * POSIX semaphore privileges.
...@@ -203,6 +206,7 @@...@@ -203,6 +206,7 @@
203 */206 */
204#define PRIV_SIGNAL_DIFFCRED 230 /* Exempt signalling other users. */207#define PRIV_SIGNAL_DIFFCRED 230 /* Exempt signalling other users. */
205#define PRIV_SIGNAL_SUGID 231 /* Non-conserv signal setuid proc. */208#define PRIV_SIGNAL_SUGID 231 /* Non-conserv signal setuid proc. */
209#define PRIV_SIGNAL_DIFFJAIL 232 /* Exempt signalling other jails. */
206210
207/*211/*
208 * Sysctl privileges.212 * Sysctl privileges.
...@@ -210,6 +214,7 @@...@@ -210,6 +214,7 @@
210#define PRIV_SYSCTL_DEBUG 240 /* Can invoke sysctl.debug. */214#define PRIV_SYSCTL_DEBUG 240 /* Can invoke sysctl.debug. */
211#define PRIV_SYSCTL_WRITE 241 /* Can write sysctls. */215#define PRIV_SYSCTL_WRITE 241 /* Can write sysctls. */
212#define PRIV_SYSCTL_WRITEJAIL 242 /* Can write sysctls, jail permitted. */216#define PRIV_SYSCTL_WRITEJAIL 242 /* Can write sysctls, jail permitted. */
217#define PRIV_SYSCTL_MEMLOCK 243 /* Large requests are not serialized. */
213218
214/*219/*
215 * TTY privileges.220 * TTY privileges.
...@@ -404,6 +409,7 @@...@@ -404,6 +409,7 @@
404#define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */409#define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */
405#define PRIV_NETINET_BINDANY 506 /* Allow bind to any address. */410#define PRIV_NETINET_BINDANY 506 /* Allow bind to any address. */
406#define PRIV_NETINET_HASHKEY 507 /* Get and set hash keys for IPv4/6. */411#define PRIV_NETINET_HASHKEY 507 /* Get and set hash keys for IPv4/6. */
412#define PRIV_NETINET_KTLSKEYS 508 /* Read ktls session keys. */
407413
408/*414/*
409 * Placeholders for IPX/SPX privileges, not supported any more.415 * Placeholders for IPX/SPX privileges, not supported any more.
...@@ -515,6 +521,7 @@...@@ -515,6 +521,7 @@
515 */521 */
516#define PRIV_KMEM_READ 680 /* Open mem/kmem for reading. */522#define PRIV_KMEM_READ 680 /* Open mem/kmem for reading. */
517#define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */523#define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */
524#define PRIV_PROC_MEM_WRITE 682 /* Writes via proc_rwmem */
518525
519/*526/*
520 * Kernel debugger privileges.527 * Kernel debugger privileges.
lib/libc/include/generic-freebsd/sys/proc.h+52-63
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)proc.h 8.15 (Berkeley) 5/19/95
37 */35 */
3836
39#ifndef _SYS_PROC_H_37#ifndef _SYS_PROC_H_
...@@ -44,6 +42,7 @@...@@ -44,6 +42,7 @@
44#ifdef _KERNEL42#ifdef _KERNEL
45#include <sys/_eventhandler.h>43#include <sys/_eventhandler.h>
46#endif44#endif
45#include <sys/_exterr.h>
47#include <sys/condvar.h>46#include <sys/condvar.h>
48#ifndef _KERNEL47#ifndef _KERNEL
49#include <sys/filedesc.h>48#include <sys/filedesc.h>
...@@ -55,7 +54,6 @@...@@ -55,7 +54,6 @@
55#include <sys/osd.h>54#include <sys/osd.h>
56#include <sys/priority.h>55#include <sys/priority.h>
57#include <sys/rtprio.h> /* XXX. */56#include <sys/rtprio.h> /* XXX. */
58#include <sys/runq.h>
59#include <sys/resource.h>57#include <sys/resource.h>
60#include <sys/sigio.h>58#include <sys/sigio.h>
61#include <sys/signal.h>59#include <sys/signal.h>
...@@ -249,7 +247,7 @@ struct thread {...@@ -249,7 +247,7 @@ struct thread {
249 struct seltd *td_sel; /* Select queue/channel. */247 struct seltd *td_sel; /* Select queue/channel. */
250 struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */248 struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */
251 struct turnstile *td_turnstile; /* (k) Associated turnstile. */249 struct turnstile *td_turnstile; /* (k) Associated turnstile. */
252 struct rl_q_entry *td_rlqe; /* (k) Associated range lock entry. */250 void *td_pad1; /* Available */
253 struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */251 struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */
254 lwpid_t td_tid; /* (b) Thread ID. */252 lwpid_t td_tid; /* (b) Thread ID. */
255 sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */253 sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */
...@@ -272,11 +270,12 @@ struct thread {...@@ -272,11 +270,12 @@ struct thread {
272 const char *td_wmesg; /* (t) Reason for sleep. */270 const char *td_wmesg; /* (t) Reason for sleep. */
273 volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */271 volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */
274 u_char td_tsqueue; /* (t) Turnstile queue blocked on. */272 u_char td_tsqueue; /* (t) Turnstile queue blocked on. */
275 u_char td_stopsched; /* (k) Scheduler stopped. */273 u_char _td_pad0[2]; /* Available. */
276 int td_locks; /* (k) Debug: count of non-spin locks */274 int td_locks; /* (k) Debug: count of non-spin locks */
277 int td_rw_rlocks; /* (k) Count of rwlock read locks. */275 int td_rw_rlocks; /* (k) Count of rwlock read locks. */
278 int td_sx_slocks; /* (k) Count of sx shared locks. */276 int td_sx_slocks; /* (k) Count of sx shared locks. */
279 int td_lk_slocks; /* (k) Count of lockmgr shared locks. */277 int td_lk_slocks; /* (k) Count of lockmgr shared locks. */
278 struct lock_object *td_wantedlock; /* (k) Lock we are contending on */
280 struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */279 struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */
281 const char *td_lockname; /* (t) Name of lock blocked on. */280 const char *td_lockname; /* (t) Name of lock blocked on. */
282 LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */281 LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */
...@@ -314,8 +313,8 @@ struct thread {...@@ -314,8 +313,8 @@ struct thread {
314 struct osd td_osd; /* (k) Object specific data. */313 struct osd td_osd; /* (k) Object specific data. */
315 struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */314 struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */
316 pid_t td_dbg_forked; /* (c) Child pid for debugger. */315 pid_t td_dbg_forked; /* (c) Child pid for debugger. */
317 struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */
318 u_int td_no_sleeping; /* (k) Sleeping disabled count. */316 u_int td_no_sleeping; /* (k) Sleeping disabled count. */
317 struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */
319 void *td_su; /* (k) FFS SU private */318 void *td_su; /* (k) FFS SU private */
320 sbintime_t td_sleeptimo; /* (t) Sleep timeout. */319 sbintime_t td_sleeptimo; /* (t) Sleep timeout. */
321 int td_rtcgen; /* (s) rtc_generation of abs. sleep */320 int td_rtcgen; /* (s) rtc_generation of abs. sleep */
...@@ -323,6 +322,7 @@ struct thread {...@@ -323,6 +322,7 @@ struct thread {
323 size_t td_vslock_sz; /* (k) amount of vslock-ed space */322 size_t td_vslock_sz; /* (k) amount of vslock-ed space */
324 struct kcov_info *td_kcov_info; /* (*) Kernel code coverage data */323 struct kcov_info *td_kcov_info; /* (*) Kernel code coverage data */
325 long td_ucredref; /* (k) references on td_realucred */324 long td_ucredref; /* (k) references on td_realucred */
325 struct kexterr td_kexterr;
326#define td_endzero td_sigmask326#define td_endzero td_sigmask
327327
328/* Copied during fork1(), thread_create(), or kthread_add(). */328/* Copied during fork1(), thread_create(), or kthread_add(). */
...@@ -342,6 +342,7 @@ struct thread {...@@ -342,6 +342,7 @@ struct thread {
342 void *td_sigblock_ptr; /* (k) uptr for fast sigblock. */342 void *td_sigblock_ptr; /* (k) uptr for fast sigblock. */
343 uint32_t td_sigblock_val; /* (k) fast sigblock value read at343 uint32_t td_sigblock_val; /* (k) fast sigblock value read at
344 td_sigblock_ptr on kern entry */344 td_sigblock_ptr on kern entry */
345 void *td_exterr_ptr;
345#define td_endcopy td_pcb346#define td_endcopy td_pcb
346347
347/*348/*
...@@ -367,7 +368,8 @@ struct thread {...@@ -367,7 +368,8 @@ struct thread {
367 struct callout td_slpcallout; /* (h) Callout for sleep. */368 struct callout td_slpcallout; /* (h) Callout for sleep. */
368 struct trapframe *td_frame; /* (k) */369 struct trapframe *td_frame; /* (k) */
369 vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */370 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. */
371 volatile u_int td_critnest; /* (k*) Critical section nest level. */373 volatile u_int td_critnest; /* (k*) Critical section nest level. */
372 struct mdthread td_md; /* (k) Any machine-dependent fields. */374 struct mdthread td_md; /* (k) Any machine-dependent fields. */
373 struct kaudit_record *td_ar; /* (k) Active audit record, if any. */375 struct kaudit_record *td_ar; /* (k) Active audit record, if any. */
...@@ -430,7 +432,7 @@ do { \...@@ -430,7 +432,7 @@ do { \
430432
431#define TD_LOCKS_INC(td) ((td)->td_locks++)433#define TD_LOCKS_INC(td) ((td)->td_locks++)
432#define TD_LOCKS_DEC(td) do { \434#define TD_LOCKS_DEC(td) do { \
433 KASSERT(SCHEDULER_STOPPED_TD(td) || (td)->td_locks > 0, \435 KASSERT(SCHEDULER_STOPPED() || (td)->td_locks > 0, \
434 ("Thread %p owns no locks", (td))); \436 ("Thread %p owns no locks", (td))); \
435 (td)->td_locks--; \437 (td)->td_locks--; \
436} while (0)438} while (0)
...@@ -452,7 +454,7 @@ do { \...@@ -452,7 +454,7 @@ do { \
452#define TDF_SINTR 0x00000008 /* Sleep is interruptible. */454#define TDF_SINTR 0x00000008 /* Sleep is interruptible. */
453#define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */455#define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */
454#define TDF_IDLETD 0x00000020 /* This is a per-CPU idle thread. */456#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 */
456#define TDF_SIGWAIT 0x00000080 /* Ignore ignored signals */458#define TDF_SIGWAIT 0x00000080 /* Ignore ignored signals */
457#define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */459#define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */
458#define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */460#define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */
...@@ -468,7 +470,7 @@ do { \...@@ -468,7 +470,7 @@ do { \
468#define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */470#define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */
469#define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */471#define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */
470#define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */472#define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */
471#define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */473#define TDF_UNUSED12 0x00400000 /* Available */
472#define TDF_UNUSED6 0x00800000 /* Available */474#define TDF_UNUSED6 0x00800000 /* Available */
473#define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */475#define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */
474#define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */476#define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */
...@@ -493,13 +495,14 @@ enum {...@@ -493,13 +495,14 @@ enum {
493 TDA_KQUEUE,495 TDA_KQUEUE,
494 TDA_RACCT,496 TDA_RACCT,
495 TDA_MOD1, /* For third party use, before signals are */497 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 */
497 TDA_SIG,500 TDA_SIG,
498 TDA_KTRACE,501 TDA_KTRACE,
499 TDA_SUSPEND,502 TDA_SUSPEND,
500 TDA_SIGSUSPEND,503 TDA_SIGSUSPEND,
501 TDA_MOD3, /* .. and after */504 TDA_MOD3, /* .. and after */
502 TAD_MOD4,505 TDA_MOD4,
503 TDA_MAX,506 TDA_MAX,
504};507};
505#define TDAI(tda) (1U << (tda))508#define TDAI(tda) (1U << (tda))
...@@ -560,13 +563,16 @@ enum {...@@ -560,13 +563,16 @@ enum {
560#define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */563#define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */
561#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */564#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */
562#define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */565#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 */
564#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */567#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */
565#define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */568#define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */
566569
567#define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */570#define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */
568#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */571#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */
569#define TDP2_ACCT 0x00000004 /* Doing accounting */572#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
571/*577/*
572 * Reasons that the current thread can not be run yet.578 * Reasons that the current thread can not be run yet.
...@@ -574,14 +580,12 @@ enum {...@@ -574,14 +580,12 @@ enum {
574 */580 */
575#define TDI_SUSPENDED 0x0001 /* On suspension queue. */581#define TDI_SUSPENDED 0x0001 /* On suspension queue. */
576#define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */582#define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */
577#define TDI_SWAPPED 0x0004 /* Stack not in mem. Bad juju if run. */
578#define TDI_LOCK 0x0008 /* Stopped on a lock. */583#define TDI_LOCK 0x0008 /* Stopped on a lock. */
579#define TDI_IWAIT 0x0010 /* Awaiting interrupt. */584#define TDI_IWAIT 0x0010 /* Awaiting interrupt. */
580585
581#define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING)586#define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING)
582#define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL)587#define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL)
583#define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED)588#define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED)
584#define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED)
585#define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK)589#define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK)
586#define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT)590#define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT)
587#ifdef _KERNEL591#ifdef _KERNEL
...@@ -602,7 +606,6 @@ enum {...@@ -602,7 +606,6 @@ enum {
602#define KTDSTATE(td) \606#define KTDSTATE(td) \
603 (((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \607 (((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \
604 ((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \608 ((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \
605 ((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \
606 ((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \609 ((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \
607 ((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding")610 ((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding")
608611
...@@ -618,14 +621,12 @@ enum {...@@ -618,14 +621,12 @@ enum {
618} while (0)621} while (0)
619622
620#define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING)623#define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING)
621#define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED)
622#define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK)624#define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK)
623#define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED)625#define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED)
624#define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT)626#define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT)
625#define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING)627#define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING)
626628
627#define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING)629#define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING)
628#define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED)
629#define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK)630#define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK)
630#define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED)631#define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED)
631#define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT)632#define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT)
...@@ -704,7 +705,7 @@ struct proc {...@@ -704,7 +705,7 @@ struct proc {
704 struct vnode *p_textvp; /* (b) Vnode of executable. */705 struct vnode *p_textvp; /* (b) Vnode of executable. */
705 struct vnode *p_textdvp; /* (b) Dir containing textvp. */706 struct vnode *p_textdvp; /* (b) Dir containing textvp. */
706 char *p_binname; /* (b) Binary hardlink name. */707 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. */
708 struct sigiolst p_sigiolst; /* (c) List of sigio sources. */709 struct sigiolst p_sigiolst; /* (c) List of sigio sources. */
709 int p_sigparent; /* (c) Signal to parent on exit. */710 int p_sigparent; /* (c) Signal to parent on exit. */
710 int p_sig; /* (n) For core dump/debugger XXX. */711 int p_sig; /* (n) For core dump/debugger XXX. */
...@@ -714,7 +715,7 @@ struct proc {...@@ -714,7 +715,7 @@ struct proc {
714 int p_suspcount; /* (j) Num threads in suspended mode. */715 int p_suspcount; /* (j) Num threads in suspended mode. */
715 struct thread *p_xthread; /* (c) Trap thread */716 struct thread *p_xthread; /* (c) Trap thread */
716 int p_boundary_count;/* (j) Num threads at user boundary */717 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 */
718 struct itimers *p_itimers; /* (c) POSIX interval timers. */719 struct itimers *p_itimers; /* (c) POSIX interval timers. */
719 struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */720 struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */
720 u_int p_treeflag; /* (e) P_TREE flags */721 u_int p_treeflag; /* (e) P_TREE flags */
...@@ -762,7 +763,6 @@ struct proc {...@@ -762,7 +763,6 @@ struct proc {
762 LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/763 LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/
763 struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */764 struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */
764 struct cv p_pwait; /* (*) wait cv for exit/exec. */765 struct cv p_pwait; /* (*) wait cv for exit/exec. */
765 uint64_t p_prev_runtime; /* (c) Resource usage accounting. */
766 struct racct *p_racct; /* (b) Resource accounting. */766 struct racct *p_racct; /* (b) Resource accounting. */
767 int p_throttled; /* (c) Flag for racct pcpu throttling */767 int p_throttled; /* (c) Flag for racct pcpu throttling */
768 /*768 /*
...@@ -806,7 +806,7 @@ struct proc {...@@ -806,7 +806,7 @@ struct proc {
806 lock. */806 lock. */
807#define P_CONTROLT 0x00000002 /* Has a controlling terminal. */807#define P_CONTROLT 0x00000002 /* Has a controlling terminal. */
808#define P_KPROC 0x00000004 /* Kernel process. */808#define P_KPROC 0x00000004 /* Kernel process. */
809#define P_UNUSED3 0x00000008 /* --available-- */809#define P_IDLEPROC 0x00000008 /* Container for system idle threads. */
810#define P_PPWAIT 0x00000010 /* Parent is waiting for child to810#define P_PPWAIT 0x00000010 /* Parent is waiting for child to
811 exec/exit. */811 exec/exit. */
812#define P_PROFIL 0x00000020 /* Has started profiling. */812#define P_PROFIL 0x00000020 /* Has started profiling. */
...@@ -816,8 +816,7 @@ struct proc {...@@ -816,8 +816,7 @@ struct proc {
816 shortcuts) */816 shortcuts) */
817#define P_SUGID 0x00000100 /* Had set id privileges since last817#define P_SUGID 0x00000100 /* Had set id privileges since last
818 exec. */818 exec. */
819#define P_SYSTEM 0x00000200 /* System proc: no sigs, stats or819#define P_SYSTEM 0x00000200 /* System proc: no sigs or stats. */
820 swapping. */
821#define P_SINGLE_EXIT 0x00000400 /* Threads suspending should exit,820#define P_SINGLE_EXIT 0x00000400 /* Threads suspending should exit,
822 not wait. */821 not wait. */
823#define P_TRACED 0x00000800 /* Debugged process being traced. */822#define P_TRACED 0x00000800 /* Debugged process being traced. */
...@@ -841,9 +840,9 @@ struct proc {...@@ -841,9 +840,9 @@ struct proc {
841#define P_TOTAL_STOP 0x02000000 /* Stopped in stop_all_proc. */840#define P_TOTAL_STOP 0x02000000 /* Stopped in stop_all_proc. */
842#define P_INEXEC 0x04000000 /* Process is in execve(). */841#define P_INEXEC 0x04000000 /* Process is in execve(). */
843#define P_STATCHILD 0x08000000 /* Child process stopped or exited. */842#define P_STATCHILD 0x08000000 /* Child process stopped or exited. */
844#define P_INMEM 0x10000000 /* Loaded into memory. */843#define P_INMEM 0x10000000 /* Loaded into memory, always set. */
845#define P_SWAPPINGOUT 0x20000000 /* Process is being swapped out. */844#define P_UNUSED1 0x20000000 /* --available-- */
846#define P_SWAPPINGIN 0x40000000 /* Process is being swapped in. */845#define P_UNUSED2 0x40000000 /* --available-- */
847#define P_PPTRACE 0x80000000 /* PT_TRACEME by vforked child. */846#define P_PPTRACE 0x80000000 /* PT_TRACEME by vforked child. */
848847
849#define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE)848#define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE)
...@@ -874,7 +873,7 @@ struct proc {...@@ -874,7 +873,7 @@ struct proc {
874 MAP_STACK */873 MAP_STACK */
875#define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled874#define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled
876 after exec */875 after exec */
877#define P2_ITSTOPPED 0x00002000876#define P2_ITSTOPPED 0x00002000 /* itimers stopped */
878#define P2_PTRACEREQ 0x00004000 /* Active ptrace req */877#define P2_PTRACEREQ 0x00004000 /* Active ptrace req */
879#define P2_NO_NEW_PRIVS 0x00008000 /* Ignore setuid */878#define P2_NO_NEW_PRIVS 0x00008000 /* Ignore setuid */
880#define P2_WXORX_DISABLE 0x00010000 /* WX mappings enabled */879#define P2_WXORX_DISABLE 0x00010000 /* WX mappings enabled */
...@@ -882,7 +881,7 @@ struct proc {...@@ -882,7 +881,7 @@ struct proc {
882#define P2_WEXIT 0x00040000 /* exit just started, no881#define P2_WEXIT 0x00040000 /* exit just started, no
883 external thread_single() is882 external thread_single() is
884 permitted */883 permitted */
885#define P2_REAPKILLED 0x00080000884#define P2_REAPKILLED 0x00080000 /* REAP_KILL pass touched me */
886#define P2_MEMBAR_PRIVE 0x00100000 /* membar private expedited885#define P2_MEMBAR_PRIVE 0x00100000 /* membar private expedited
887 registered */886 registered */
888#define P2_MEMBAR_PRIVE_SYNCORE 0x00200000 /* membar private expedited887#define P2_MEMBAR_PRIVE_SYNCORE 0x00200000 /* membar private expedited
...@@ -890,6 +889,11 @@ struct proc {...@@ -890,6 +889,11 @@ struct proc {
890#define P2_MEMBAR_GLOBE 0x00400000 /* membar global expedited889#define P2_MEMBAR_GLOBE 0x00400000 /* membar global expedited
891 registered */890 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
893/* Flags protected by proctree_lock, kept in p_treeflags. */897/* Flags protected by proctree_lock, kept in p_treeflags. */
894#define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */898#define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */
895#define P_TREE_FIRST_ORPHAN 0x00000002 /* First element of orphan899#define P_TREE_FIRST_ORPHAN 0x00000002 /* First element of orphan
...@@ -938,12 +942,6 @@ struct proc {...@@ -938,12 +942,6 @@ struct proc {
938#define SINGLE_BOUNDARY 2942#define SINGLE_BOUNDARY 2
939#define SINGLE_ALLPROC 3943#define SINGLE_ALLPROC 3
940944
941#ifdef MALLOC_DECLARE
942MALLOC_DECLARE(M_PARGS);
943MALLOC_DECLARE(M_SESSION);
944MALLOC_DECLARE(M_SUBPROC);
945#endif
946
947#define FOREACH_PROC_IN_SYSTEM(p) \945#define FOREACH_PROC_IN_SYSTEM(p) \
948 LIST_FOREACH((p), &allproc, p_list)946 LIST_FOREACH((p), &allproc, p_list)
949#define FOREACH_THREAD_IN_PROC(p, td) \947#define FOREACH_THREAD_IN_PROC(p, td) \
...@@ -956,7 +954,7 @@ MALLOC_DECLARE(M_SUBPROC);...@@ -956,7 +954,7 @@ MALLOC_DECLARE(M_SUBPROC);
956 * in a pid_t, as it is used to represent "no process group".954 * in a pid_t, as it is used to represent "no process group".
957 */955 */
958#define PID_MAX 99999956#define PID_MAX 99999
959#define NO_PID 100000957#define NO_PID (PID_MAX + 1)
960#define THREAD0_TID NO_PID958#define THREAD0_TID NO_PID
961extern pid_t pid_max;959extern pid_t pid_max;
962960
...@@ -992,18 +990,12 @@ extern pid_t pid_max;...@@ -992,18 +990,12 @@ extern pid_t pid_max;
992#define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type))990#define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type))
993991
994/*992/*
995 * Non-zero p_lock ensures that:993 * A non-zero p_lock prevents the process from exiting; it will sleep in exit1()
996 * - exit1() is not performed until p_lock reaches zero;994 * until the count reaches zero.
997 * - the process' threads stack are not swapped out if they are currently
998 * not (P_INMEM).
999 *995 *
1000 * PHOLD() asserts that the process (except the current process) is996 * PHOLD() asserts that the process (except the current process) is
1001 * not exiting, increments p_lock and swaps threads stacks into memory,997 * not exiting and increments p_lock.
1002 * if needed.
1003 * _PHOLD() is same as PHOLD(), it takes the process locked.998 * _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.
1007 */999 */
1008#define PHOLD(p) do { \1000#define PHOLD(p) do { \
1009 PROC_LOCK(p); \1001 PROC_LOCK(p); \
...@@ -1015,14 +1007,6 @@ extern pid_t pid_max;...@@ -1015,14 +1007,6 @@ extern pid_t pid_max;
1015 KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \1007 KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \
1016 ("PHOLD of exiting process %p", p)); \1008 ("PHOLD of exiting process %p", p)); \
1017 (p)->p_lock++; \1009 (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++; \
1026} while (0)1010} while (0)
1027#define PROC_ASSERT_HELD(p) do { \1011#define PROC_ASSERT_HELD(p) do { \
1028 KASSERT((p)->p_lock > 0, ("process %p not held", p)); \1012 KASSERT((p)->p_lock > 0, ("process %p not held", p)); \
...@@ -1058,9 +1042,6 @@ extern pid_t pid_max;...@@ -1058,9 +1042,6 @@ extern pid_t pid_max;
1058 _p->p_cowgen - _td->td_cowgen; \1042 _p->p_cowgen - _td->td_cowgen; \
1059})1043})
10601044
1061/* Check whether a thread is safe to be swapped out. */
1062#define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP)
1063
1064/* Control whether or not it is safe for curthread to sleep. */1045/* Control whether or not it is safe for curthread to sleep. */
1065#define THREAD_NO_SLEEPING() do { \1046#define THREAD_NO_SLEEPING() do { \
1066 curthread->td_no_sleeping++; \1047 curthread->td_no_sleeping++; \
...@@ -1074,6 +1055,16 @@ extern pid_t pid_max;...@@ -1074,6 +1055,16 @@ extern pid_t pid_max;
10741055
1075#define THREAD_CAN_SLEEP() ((curthread)->td_no_sleeping == 0)1056#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
1077#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])1068#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
1078#define PIDHASHLOCK(pid) (&pidhashtbl_lock[((pid) & pidhashlock)])1069#define PIDHASHLOCK(pid) (&pidhashtbl_lock[((pid) & pidhashlock)])
1079extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;1070extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
...@@ -1170,7 +1161,6 @@ int cr_cansignal(struct ucred *cred, struct proc *proc, int signum);...@@ -1170,7 +1161,6 @@ int cr_cansignal(struct ucred *cred, struct proc *proc, int signum);
1170int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp,1161int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp,
1171 struct session *sess);1162 struct session *sess);
1172int enterthispgrp(struct proc *p, struct pgrp *pgrp);1163int enterthispgrp(struct proc *p, struct pgrp *pgrp);
1173void faultin(struct proc *p);
1174int fork1(struct thread *, struct fork_req *);1164int fork1(struct thread *, struct fork_req *);
1175void fork_exit(void (*)(void *, struct trapframe *), void *,1165void fork_exit(void (*)(void *, struct trapframe *), void *,
1176 struct trapframe *);1166 struct trapframe *);
...@@ -1181,7 +1171,6 @@ void kqtimer_proc_continue(struct proc *p);...@@ -1181,7 +1171,6 @@ void kqtimer_proc_continue(struct proc *p);
1181void kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry,1171void kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry,
1182 int *resident_count, bool *super);1172 int *resident_count, bool *super);
1183void kern_yield(int);1173void kern_yield(int);
1184void kick_proc0(void);
1185void killjobc(void);1174void killjobc(void);
1186int leavepgrp(struct proc *p);1175int leavepgrp(struct proc *p);
1187int maybe_preempt(struct thread *td);1176int maybe_preempt(struct thread *td);
...@@ -1195,6 +1184,7 @@ int p_canwait(struct thread *td, struct proc *p);...@@ -1195,6 +1184,7 @@ int p_canwait(struct thread *td, struct proc *p);
1195struct pargs *pargs_alloc(int len);1184struct pargs *pargs_alloc(int len);
1196void pargs_drop(struct pargs *pa);1185void pargs_drop(struct pargs *pa);
1197void pargs_hold(struct pargs *pa);1186void pargs_hold(struct pargs *pa);
1187int pgrp_calc_jobc(struct pgrp *pgrp);
1198void proc_add_orphan(struct proc *child, struct proc *parent);1188void proc_add_orphan(struct proc *child, struct proc *parent);
1199int proc_get_binpath(struct proc *p, char *binname, char **fullpath,1189int proc_get_binpath(struct proc *p, char *binname, char **fullpath,
1200 char **freepath);1190 char **freepath);
...@@ -1220,7 +1210,7 @@ int securelevel_ge(struct ucred *cr, int level);...@@ -1220,7 +1210,7 @@ int securelevel_ge(struct ucred *cr, int level);
1220int securelevel_gt(struct ucred *cr, int level);1210int securelevel_gt(struct ucred *cr, int level);
1221void sess_hold(struct session *);1211void sess_hold(struct session *);
1222void sess_release(struct session *);1212void sess_release(struct session *);
1223int setrunnable(struct thread *, int);1213void setrunnable(struct thread *, int);
1224void setsugid(struct proc *p);1214void setsugid(struct proc *p);
1225bool should_yield(void);1215bool should_yield(void);
1226int sigonstack(size_t sp);1216int sigonstack(size_t sp);
...@@ -1235,6 +1225,7 @@ extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */...@@ -1235,6 +1225,7 @@ extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */
1235void cpu_switch(struct thread *, struct thread *, struct mtx *);1225void cpu_switch(struct thread *, struct thread *, struct mtx *);
1236void cpu_sync_core(void);1226void cpu_sync_core(void);
1237void cpu_throw(struct thread *, struct thread *) __dead2;1227void cpu_throw(struct thread *, struct thread *) __dead2;
1228void cpu_update_pcb(struct thread *);
1238bool curproc_sigkilled(void);1229bool curproc_sigkilled(void);
1239void userret(struct thread *, struct trapframe *);1230void userret(struct thread *, struct trapframe *);
12401231
...@@ -1250,15 +1241,12 @@ int cpu_procctl(struct thread *td, int idtype, id_t id, int com,...@@ -1250,15 +1241,12 @@ int cpu_procctl(struct thread *td, int idtype, id_t id, int com,
1250void cpu_set_syscall_retval(struct thread *, int);1241void cpu_set_syscall_retval(struct thread *, int);
1251int cpu_set_upcall(struct thread *, void (*)(void *), void *,1242int cpu_set_upcall(struct thread *, void (*)(void *), void *,
1252 stack_t *);1243 stack_t *);
1253int cpu_set_user_tls(struct thread *, void *tls_base);1244int cpu_set_user_tls(struct thread *, void *tls_base, int flags);
1254void cpu_thread_alloc(struct thread *);1245void cpu_thread_alloc(struct thread *);
1255void cpu_thread_clean(struct thread *);1246void cpu_thread_clean(struct thread *);
1256void cpu_thread_exit(struct thread *);1247void cpu_thread_exit(struct thread *);
1257void cpu_thread_free(struct thread *);1248void cpu_thread_free(struct thread *);
1258void cpu_thread_swapin(struct thread *);
1259void cpu_thread_swapout(struct thread *);
1260struct thread *thread_alloc(int pages);1249struct thread *thread_alloc(int pages);
1261int thread_alloc_stack(struct thread *, int pages);
1262int thread_check_susp(struct thread *td, bool sleep);1250int thread_check_susp(struct thread *td, bool sleep);
1263void thread_cow_get_proc(struct thread *newtd, struct proc *p);1251void thread_cow_get_proc(struct thread *newtd, struct proc *p);
1264void thread_cow_get(struct thread *newtd, struct thread *td);1252void thread_cow_get(struct thread *newtd, struct thread *td);
...@@ -1271,6 +1259,7 @@ void thread_exit(void) __dead2;...@@ -1271,6 +1259,7 @@ void thread_exit(void) __dead2;
1271void thread_free(struct thread *td);1259void thread_free(struct thread *td);
1272void thread_link(struct thread *td, struct proc *p);1260void thread_link(struct thread *td, struct proc *p);
1273void thread_reap_barrier(void);1261void thread_reap_barrier(void);
1262int thread_recycle(struct thread *, int pages);
1274int thread_single(struct proc *p, int how);1263int thread_single(struct proc *p, int how);
1275void thread_single_end(struct proc *p, int how);1264void thread_single_end(struct proc *p, int how);
1276void thread_stash(struct thread *td);1265void thread_stash(struct thread *td);
lib/libc/include/generic-freebsd/sys/procctl.h+6
...@@ -65,6 +65,8 @@...@@ -65,6 +65,8 @@
65#define PROC_NO_NEW_PRIVS_STATUS 20 /* query suid/sgid disabled status */65#define PROC_NO_NEW_PRIVS_STATUS 20 /* query suid/sgid disabled status */
66#define PROC_WXMAP_CTL 21 /* control W^X */66#define PROC_WXMAP_CTL 21 /* control W^X */
67#define PROC_WXMAP_STATUS 22 /* query W^X */67#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
69/* Operations for PROC_SPROTECT (passed in integer arg). */71/* Operations for PROC_SPROTECT (passed in integer arg). */
70#define PPROT_OP(x) ((x) & 0xf)72#define PPROT_OP(x) ((x) & 0xf)
...@@ -153,6 +155,10 @@ struct procctl_reaper_kill {...@@ -153,6 +155,10 @@ struct procctl_reaper_kill {
153#define PROC_WX_MAPPINGS_DISALLOW_EXEC 0x0002155#define PROC_WX_MAPPINGS_DISALLOW_EXEC 0x0002
154#define PROC_WXORX_ENFORCE 0x80000000156#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
156#ifndef _KERNEL162#ifndef _KERNEL
157__BEGIN_DECLS163__BEGIN_DECLS
158int procctl(idtype_t, id_t, int, void *);164int procctl(idtype_t, id_t, int, void *);
lib/libc/include/generic-freebsd/sys/procdesc.h+5-2
...@@ -94,8 +94,10 @@ struct procdesc {...@@ -94,8 +94,10 @@ struct procdesc {
94 * In-kernel interfaces to process descriptors.94 * In-kernel interfaces to process descriptors.
95 */95 */
96int procdesc_exit(struct proc *);96int procdesc_exit(struct proc *);
97int procdesc_find(struct thread *, int fd, cap_rights_t *, struct proc **);97int procdesc_find(struct thread *, int fd, const cap_rights_t *,
98int kern_pdgetpid(struct thread *, int fd, cap_rights_t *, pid_t *pidp);98 struct proc **);
99int kern_pdgetpid(struct thread *, int fd, const cap_rights_t *,
100 pid_t *pidp);
99void procdesc_new(struct proc *, int);101void procdesc_new(struct proc *, int);
100void procdesc_finit(struct procdesc *, struct file *);102void procdesc_finit(struct procdesc *, struct file *);
101pid_t procdesc_pid(struct file *);103pid_t procdesc_pid(struct file *);
...@@ -106,6 +108,7 @@ int procdesc_falloc(struct thread *, struct file **, int *, int,...@@ -106,6 +108,7 @@ int procdesc_falloc(struct thread *, struct file **, int *, int,
106108
107#else /* !_KERNEL */109#else /* !_KERNEL */
108110
111#include <sys/cdefs.h>
109#include <sys/_types.h>112#include <sys/_types.h>
110113
111#ifndef _PID_T_DECLARED114#ifndef _PID_T_DECLARED
lib/libc/include/generic-freebsd/sys/protosw.h+26-52
...@@ -27,24 +27,11 @@...@@ -27,24 +27,11 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)protosw.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_PROTOSW_H_32#ifndef _SYS_PROTOSW_H_
35#define _SYS_PROTOSW_H_33#define _SYS_PROTOSW_H_
3634#if defined(_KERNEL) || defined(_WANT_PROTOSW)
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*/
48/*35/*
49 * Protocol switch table.36 * Protocol switch table.
50 *37 *
...@@ -54,16 +41,24 @@ struct sockopt;...@@ -54,16 +41,24 @@ struct sockopt;
54 * In retrospect, it would be a lot nicer to use an interface41 * In retrospect, it would be a lot nicer to use an interface
55 * similar to the vnode VOP interface.42 * similar to the vnode VOP interface.
56 */43 */
44struct socket;
45struct sockopt;
46struct thread;
47struct sockaddr;
57struct ifnet;48struct ifnet;
49struct mbuf;
58struct stat;50struct stat;
59struct ucred;51struct ucred;
60struct uio;52struct uio;
53struct kaiocb;
54struct knote;
55enum shutdown_how;
6156
62/* USE THESE FOR YOUR PROTOTYPES ! */57/* USE THESE FOR YOUR PROTOTYPES ! */
63typedef int pr_ctloutput_t(struct socket *, struct sockopt *);58typedef int pr_ctloutput_t(struct socket *, struct sockopt *);
64typedef int pr_setsbopt_t(struct socket *, struct sockopt *);59typedef int pr_setsbopt_t(struct socket *, struct sockopt *);
65typedef void pr_abort_t(struct socket *);60typedef void pr_abort_t(struct socket *);
66typedef int pr_accept_t(struct socket *, struct sockaddr **);61typedef int pr_accept_t(struct socket *, struct sockaddr *);
67typedef int pr_attach_t(struct socket *, int, struct thread *);62typedef int pr_attach_t(struct socket *, int, struct thread *);
68typedef int pr_bind_t(struct socket *, struct sockaddr *, struct thread *);63typedef int pr_bind_t(struct socket *, struct sockaddr *, struct thread *);
69typedef int pr_connect_t(struct socket *, struct sockaddr *,64typedef int pr_connect_t(struct socket *, struct sockaddr *,
...@@ -74,7 +69,7 @@ typedef int pr_control_t(struct socket *, unsigned long, void *,...@@ -74,7 +69,7 @@ typedef int pr_control_t(struct socket *, unsigned long, void *,
74typedef void pr_detach_t(struct socket *);69typedef void pr_detach_t(struct socket *);
75typedef int pr_disconnect_t(struct socket *);70typedef int pr_disconnect_t(struct socket *);
76typedef int pr_listen_t(struct socket *, int, struct thread *);71typedef 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 *);
78typedef int pr_rcvd_t(struct socket *, int);73typedef int pr_rcvd_t(struct socket *, int);
79typedef int pr_rcvoob_t(struct socket *, struct mbuf *, int);74typedef int pr_rcvoob_t(struct socket *, struct mbuf *, int);
80typedef enum {75typedef enum {
...@@ -86,17 +81,17 @@ typedef enum {...@@ -86,17 +81,17 @@ typedef enum {
86} pr_send_flags_t;81} pr_send_flags_t;
87typedef int pr_send_t(struct socket *, int, struct mbuf *,82typedef int pr_send_t(struct socket *, int, struct mbuf *,
88 struct sockaddr *, struct mbuf *, struct thread *);83 struct sockaddr *, struct mbuf *, struct thread *);
84typedef int pr_sendfile_wait_t(struct socket *, off_t, int *);
89typedef int pr_ready_t(struct socket *, struct mbuf *, int);85typedef int pr_ready_t(struct socket *, struct mbuf *, int);
90typedef int pr_sense_t(struct socket *, struct stat *);86typedef int pr_sense_t(struct socket *, struct stat *);
91typedef int pr_shutdown_t(struct socket *);87typedef int pr_shutdown_t(struct socket *, enum shutdown_how);
92typedef int pr_flush_t(struct socket *, int);88typedef int pr_sockaddr_t(struct socket *, struct sockaddr *);
93typedef int pr_sockaddr_t(struct socket *, struct sockaddr **);
94typedef int pr_sosend_t(struct socket *, struct sockaddr *, struct uio *,89typedef int pr_sosend_t(struct socket *, struct sockaddr *, struct uio *,
95 struct mbuf *, struct mbuf *, int, struct thread *);90 struct mbuf *, struct mbuf *, int, struct thread *);
96typedef int pr_soreceive_t(struct socket *, struct sockaddr **,91typedef int pr_soreceive_t(struct socket *, struct sockaddr **,
97 struct uio *, struct mbuf **, struct mbuf **, int *);92 struct uio *, struct mbuf **, struct mbuf **, int *);
98typedef int pr_sopoll_t(struct socket *, int, struct ucred *,93typedef int pr_sopoll_t(struct socket *, int, struct thread *);
99 struct thread *);94typedef int pr_kqfilter_t(struct socket *, struct knote *);
100typedef void pr_sosetlabel_t(struct socket *);95typedef void pr_sosetlabel_t(struct socket *);
101typedef void pr_close_t(struct socket *);96typedef void pr_close_t(struct socket *);
102typedef int pr_bindat_t(int, struct socket *, struct sockaddr *,97typedef int pr_bindat_t(int, struct socket *, struct sockaddr *,
...@@ -104,6 +99,8 @@ typedef int pr_bindat_t(int, struct socket *, struct sockaddr *,...@@ -104,6 +99,8 @@ typedef int pr_bindat_t(int, struct socket *, struct sockaddr *,
104typedef int pr_connectat_t(int, struct socket *, struct sockaddr *,99typedef int pr_connectat_t(int, struct socket *, struct sockaddr *,
105 struct thread *);100 struct thread *);
106typedef int pr_aio_queue_t(struct socket *, struct kaiocb *);101typedef int pr_aio_queue_t(struct socket *, struct kaiocb *);
102typedef int pr_chmod_t(struct socket *, __mode_t, struct ucred *,
103 struct thread *);
107104
108struct protosw {105struct protosw {
109 short pr_type; /* socket type used for */106 short pr_type; /* socket type used for */
...@@ -113,9 +110,9 @@ struct protosw {...@@ -113,9 +110,9 @@ struct protosw {
113 struct domain *pr_domain; /* domain protocol a member of */110 struct domain *pr_domain; /* domain protocol a member of */
114111
115 pr_soreceive_t *pr_soreceive; /* recv(2) */112 pr_soreceive_t *pr_soreceive; /* recv(2) */
116 pr_rcvd_t *pr_rcvd; /* soreceive_generic() if PR_WANTRCVD */
117 pr_sosend_t *pr_sosend; /* send(2) */113 pr_sosend_t *pr_sosend; /* send(2) */
118 pr_send_t *pr_send; /* send(2) via sosend_generic() */114 pr_send_t *pr_send; /* send(2) via sosend_generic() */
115 pr_sendfile_wait_t *pr_sendfile_wait; /* sendfile helper */
119 pr_ready_t *pr_ready; /* sendfile/ktls readyness */116 pr_ready_t *pr_ready; /* sendfile/ktls readyness */
120 pr_sopoll_t *pr_sopoll; /* poll(2) */117 pr_sopoll_t *pr_sopoll; /* poll(2) */
121/* Cache line #2 */118/* Cache line #2 */
...@@ -125,7 +122,7 @@ struct protosw {...@@ -125,7 +122,7 @@ struct protosw {
125 pr_disconnect_t *pr_disconnect; /* sodisconnect() */122 pr_disconnect_t *pr_disconnect; /* sodisconnect() */
126 pr_close_t *pr_close; /* close(2) */123 pr_close_t *pr_close; /* close(2) */
127 pr_shutdown_t *pr_shutdown; /* shutdown(2) */124 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 */
129 pr_aio_queue_t *pr_aio_queue; /* aio(9) */126 pr_aio_queue_t *pr_aio_queue; /* aio(9) */
130/* Cache line #3 */127/* Cache line #3 */
131 pr_bind_t *pr_bind; /* bind(2) */128 pr_bind_t *pr_bind; /* bind(2) */
...@@ -137,15 +134,18 @@ struct protosw {...@@ -137,15 +134,18 @@ struct protosw {
137 pr_control_t *pr_control; /* ioctl(2) */134 pr_control_t *pr_control; /* ioctl(2) */
138 pr_rcvoob_t *pr_rcvoob; /* soreceive_rcvoob() */135 pr_rcvoob_t *pr_rcvoob; /* soreceive_rcvoob() */
139/* Cache line #4 */136/* Cache line #4 */
137 pr_abort_t *pr_abort; /* abrupt tear down: soabort() */
140 pr_ctloutput_t *pr_ctloutput; /* control output (from above) */138 pr_ctloutput_t *pr_ctloutput; /* control output (from above) */
141 pr_peeraddr_t *pr_peeraddr; /* getpeername(2) */139 pr_peeraddr_t *pr_peeraddr; /* getpeername(2) */
142 pr_sockaddr_t *pr_sockaddr; /* getsockname(2) */140 pr_sockaddr_t *pr_sockaddr; /* getsockname(2) */
143 pr_sense_t *pr_sense; /* stat(2) */141 pr_sense_t *pr_sense; /* stat(2) */
144 pr_flush_t *pr_flush; /* XXXGL: merge with pr_shutdown_t! */
145 pr_sosetlabel_t *pr_sosetlabel; /* MAC, XXXGL: remove */142 pr_sosetlabel_t *pr_sosetlabel; /* MAC, XXXGL: remove */
146 pr_setsbopt_t *pr_setsbopt; /* Socket buffer ioctls */143 pr_setsbopt_t *pr_setsbopt; /* Socket buffer ioctls */
144 pr_chmod_t *pr_chmod; /* fchmod(2) */
145 pr_kqfilter_t *pr_kqfilter; /* kevent(2) */
147};146};
148/*#endif*/147#endif /* defined(_KERNEL) || defined(_WANT_PROTOSW) */
148#ifdef _KERNEL
149149
150/*150/*
151 * Values for pr_flags.151 * Values for pr_flags.
...@@ -162,37 +162,12 @@ struct protosw {...@@ -162,37 +162,12 @@ struct protosw {
162#define PR_ADDR 0x02 /* addresses given with messages */162#define PR_ADDR 0x02 /* addresses given with messages */
163#define PR_CONNREQUIRED 0x04 /* connection required by protocol */163#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
164#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */164#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
165#define PR_RIGHTS 0x10 /* passes capabilities */165/* was PR_RIGHTS 0x10 passes capabilities */
166#define PR_IMPLOPCL 0x20 /* implied open/close */166#define PR_IMPLOPCL 0x20 /* implied open/close */
167/* was PR_LASTHDR 0x40 enforce ipsec policy; last header */167/* was PR_LASTHDR 0x40 enforce ipsec policy; last header */
168#define PR_CAPATTACH 0x80 /* socket can attach in cap mode */168#define PR_CAPATTACH 0x80 /* socket can attach in cap mode */
169#define PR_SOCKBUF 0x100 /* private implementation of buffers */169#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
196struct domain *pffinddomain(int family);171struct domain *pffinddomain(int family);
197struct protosw *pffindproto(int family, int type, int proto);172struct protosw *pffindproto(int family, int type, int proto);
198int protosw_register(struct domain *, struct protosw *);173int protosw_register(struct domain *, struct protosw *);
...@@ -202,5 +177,4 @@ int protosw_unregister(struct protosw *);...@@ -202,5 +177,4 @@ int protosw_unregister(struct protosw *);
202extern struct domain inetdomain;177extern struct domain inetdomain;
203extern struct domain inet6domain;178extern struct domain inet6domain;
204#endif179#endif
205
206#endif180#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/ptrace.h+9-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ptrace.h 8.2 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _SYS_PTRACE_H_32#ifndef _SYS_PTRACE_H_
...@@ -89,8 +87,16 @@...@@ -89,8 +87,16 @@
89#define PT_SC_REMOTE 44 /* Execute a syscall */87#define PT_SC_REMOTE 44 /* Execute a syscall */
9088
91#define PT_FIRSTMACH 64 /* for machine-specific requests */89#define PT_FIRSTMACH 64 /* for machine-specific requests */
90#define PT_LASTMACH 127
92#include <machine/ptrace.h> /* machine-specific requests, if any */91#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
94/* Events used with PT_GET_EVENT_MASK and PT_SET_EVENT_MASK */100/* Events used with PT_GET_EVENT_MASK and PT_SET_EVENT_MASK */
95#define PTRACE_EXEC 0x0001101#define PTRACE_EXEC 0x0001
96#define PTRACE_SCE 0x0002102#define PTRACE_SCE 0x0002
...@@ -152,7 +158,7 @@ struct ptrace_lwpinfo32 {...@@ -152,7 +158,7 @@ struct ptrace_lwpinfo32 {
152 int pl_flags; /* LWP flags. */158 int pl_flags; /* LWP flags. */
153 sigset_t pl_sigmask; /* LWP signal mask */159 sigset_t pl_sigmask; /* LWP signal mask */
154 sigset_t pl_siglist; /* LWP pending signal */160 sigset_t pl_siglist; /* LWP pending signal */
155 struct siginfo32 pl_siginfo; /* siginfo for signal */161 struct __siginfo32 pl_siginfo; /* siginfo for signal */
156 char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */162 char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */
157 pid_t pl_child_pid; /* New child pid */163 pid_t pl_child_pid; /* New child pid */
158 u_int pl_syscall_code;164 u_int pl_syscall_code;
lib/libc/include/generic-freebsd/sys/qmath.h+12-9
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/*-1/*-
2 * Copyright (c) 2018 Netflix, Inc.2 * Copyright (c) 2018-2024 Netflix, Inc.
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * Redistribution and use in source and binary forms, with or without5 * Redistribution and use in source and binary forms, with or without
...@@ -378,15 +378,18 @@ typedef u64q_t umaxq_t;...@@ -378,15 +378,18 @@ typedef u64q_t umaxq_t;
378#define Q_QMINQ(a, b) (Q_LT(a, b) ? (a) : (b))378#define Q_QMINQ(a, b) (Q_LT(a, b) ? (a) : (b))
379379
380/*380/*
381 * Test if 'a' can be represented by 'b' with full accuracy (T) or not (F).381 * Test if 'a' can be represented by 'b' with full accuracy (0) or not
382 * The type casting has to be done to a's type so that any truncation caused by382 * (EOVERFLOW). If 'b' has fewer integer and/or fractional bits than 'a',
383 * the casts will not affect the logic.383 * the integer and fractional values stored in 'a' must fit in the available
384 * number of integer and fractional bits in 'b'.
384 */385 */
385#define Q_QCANREPQ(a, b) \386#define Q_QCANREPQ(a, b) (( \
386 ((((Q_LTZ(a) && Q_SIGNED(b)) || !Q_LTZ(a)) && \387 (!Q_LTZ(a) || Q_SIGNED(b)) \
387 Q_GIABSVAL(a) <= Q_TC(a, Q_IMAXVAL(b)) && \388 && ( Q_NIBITS(a) <= Q_NIBITS(b) \
388 Q_GFABSVAL(a) <= Q_TC(a, Q_FMAXVAL(b))) ? \389 || 0 == (Q_GIABSVAL(a) & (~Q_TC(a, 0) << Q_NIBITS(b)))) \
389 0 : EOVERFLOW)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
391/* Test if raw integer value 'i' can be represented by 'q' (T) or not (F). */394/* Test if raw integer value 'i' can be represented by 'q' (T) or not (F). */
392#define Q_QCANREPI(q, i) \395#define Q_QCANREPI(q, i) \
lib/libc/include/generic-freebsd/sys/queue.h+393-218
...@@ -27,12 +27,10 @@...@@ -27,12 +27,10 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)queue.h 8.5 (Berkeley) 8/20/94
32 */30 */
3331
34#ifndef _SYS_QUEUE_H_32#ifndef _SYS_QUEUE_H_
35#define _SYS_QUEUE_H_33#define _SYS_QUEUE_H_
3634
37#include <sys/cdefs.h>35#include <sys/cdefs.h>
3836
...@@ -113,15 +111,15 @@...@@ -113,15 +111,15 @@
113 * _REMOVE_HEAD + + + +111 * _REMOVE_HEAD + + + +
114 * _REMOVE s + s +112 * _REMOVE s + s +
115 * _REPLACE - + - +113 * _REPLACE - + - +
114 * _SPLIT_AFTER + + + +
116 * _SWAP + + + +115 * _SWAP + + + +
117 *116 *
118 */117 */
119#ifdef QUEUE_MACRO_DEBUG118#ifdef QUEUE_MACRO_DEBUG
120#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH119#warn Use QUEUE_MACRO_DEBUG_xxx instead (TRACE, TRASH and/or ASSERTIONS)
121#define QUEUE_MACRO_DEBUG_TRACE120#define QUEUE_MACRO_DEBUG_TRACE
122#define QUEUE_MACRO_DEBUG_TRASH121#define QUEUE_MACRO_DEBUG_TRASH
123#endif122#endif
124
125#ifdef QUEUE_MACRO_DEBUG_TRACE123#ifdef QUEUE_MACRO_DEBUG_TRACE
126/* Store the last 2 places the queue element or head was altered */124/* Store the last 2 places the queue element or head was altered */
127struct qm_trace {125struct qm_trace {
...@@ -131,17 +129,17 @@ struct qm_trace {...@@ -131,17 +129,17 @@ struct qm_trace {
131 const char *prevfile;129 const char *prevfile;
132};130};
133131
134#define TRACEBUF struct qm_trace trace;132#define TRACEBUF struct qm_trace trace;
135#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,133#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
136134
137#define QMD_TRACE_HEAD(head) do { \135#define QMD_TRACE_HEAD(head) do { \
138 (head)->trace.prevline = (head)->trace.lastline; \136 (head)->trace.prevline = (head)->trace.lastline; \
139 (head)->trace.prevfile = (head)->trace.lastfile; \137 (head)->trace.prevfile = (head)->trace.lastfile; \
140 (head)->trace.lastline = __LINE__; \138 (head)->trace.lastline = __LINE__; \
141 (head)->trace.lastfile = __FILE__; \139 (head)->trace.lastfile = __FILE__; \
142} while (0)140} while (0)
143141
144#define QMD_TRACE_ELEM(elem) do { \142#define QMD_TRACE_ELEM(elem) do { \
145 (elem)->trace.prevline = (elem)->trace.lastline; \143 (elem)->trace.prevline = (elem)->trace.lastline; \
146 (elem)->trace.prevfile = (elem)->trace.lastfile; \144 (elem)->trace.prevfile = (elem)->trace.lastfile; \
147 (elem)->trace.lastline = __LINE__; \145 (elem)->trace.lastline = __LINE__; \
...@@ -149,53 +147,110 @@ struct qm_trace {...@@ -149,53 +147,110 @@ struct qm_trace {
149} while (0)147} while (0)
150148
151#else /* !QUEUE_MACRO_DEBUG_TRACE */149#else /* !QUEUE_MACRO_DEBUG_TRACE */
152#define QMD_TRACE_ELEM(elem)150#define QMD_TRACE_ELEM(elem)
153#define QMD_TRACE_HEAD(head)151#define QMD_TRACE_HEAD(head)
154#define TRACEBUF152#define TRACEBUF
155#define TRACEBUF_INITIALIZER153#define TRACEBUF_INITIALIZER
156#endif /* QUEUE_MACRO_DEBUG_TRACE */154#endif /* QUEUE_MACRO_DEBUG_TRACE */
157155
158#ifdef QUEUE_MACRO_DEBUG_TRASH156#ifdef QUEUE_MACRO_DEBUG_TRASH
159#define QMD_SAVELINK(name, link) void **name = (void *)&(link)157#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
160#define TRASHIT(x) do {(x) = (void *)-1;} while (0)158#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
161#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)159#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)
162#else /* !QUEUE_MACRO_DEBUG_TRASH */160#else /* !QUEUE_MACRO_DEBUG_TRASH */
163#define QMD_SAVELINK(name, link)161#define QMD_SAVELINK(name, link)
164#define TRASHIT(x)162#define TRASHIT(x)
165#define QMD_IS_TRASHED(x) 0163#define QMD_IS_TRASHED(x) 0
166#endif /* QUEUE_MACRO_DEBUG_TRASH */164#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
168#ifdef __cplusplus222#ifdef __cplusplus
169/*223/*
170 * In C++ there can be structure lists and class lists:224 * In C++ there can be structure lists and class lists:
171 */225 */
172#define QUEUE_TYPEOF(type) type226#define QUEUE_TYPEOF(type) type
173#else227#else
174#define QUEUE_TYPEOF(type) struct type228#define QUEUE_TYPEOF(type) struct type
175#endif229#endif
176230
177/*231/*
178 * Singly-linked List declarations.232 * Singly-linked List declarations.
179 */233 */
180#define SLIST_HEAD(name, type) \234
235#define SLIST_HEAD(name, type) \
181struct name { \236struct name { \
182 struct type *slh_first; /* first element */ \237 struct type *slh_first; /* first element */ \
183}238}
184239
185#define SLIST_CLASS_HEAD(name, type) \240#define SLIST_CLASS_HEAD(name, type) \
186struct name { \241struct name { \
187 class type *slh_first; /* first element */ \242 class type *slh_first; /* first element */ \
188}243}
189244
190#define SLIST_HEAD_INITIALIZER(head) \245#define SLIST_HEAD_INITIALIZER(head) \
191 { NULL }246 { NULL }
192247
193#define SLIST_ENTRY(type) \248#define SLIST_ENTRY(type) \
194struct { \249struct { \
195 struct type *sle_next; /* next element */ \250 struct type *sle_next; /* next element */ \
196}251}
197252
198#define SLIST_CLASS_ENTRY(type) \253#define SLIST_CLASS_ENTRY(type) \
199struct { \254struct { \
200 class type *sle_next; /* next element */ \255 class type *sle_next; /* next element */ \
201}256}
...@@ -203,137 +258,151 @@ struct { \...@@ -203,137 +258,151 @@ struct { \
203/*258/*
204 * Singly-linked List functions.259 * Singly-linked List functions.
205 */260 */
206#if (defined(_KERNEL) && defined(INVARIANTS))261
207#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) do { \262#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) \
208 if (*(prevp) != (elm)) \263 QMD_ASSERT(*(prevp) == (elm), \
209 panic("Bad prevptr *(%p) == %p != %p", \264 "Bad prevptr *(%p) == %p != %p", \
210 (prevp), *(prevp), (elm)); \265 (prevp), *(prevp), (elm))
211} while (0)266
212#else267#define SLIST_ASSERT_EMPTY(head) \
213#define QMD_SLIST_CHECK_PREVPTR(prevp, elm)268 QMD_ASSERT(SLIST_EMPTY((head)), \
214#endif269 "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
216#define SLIST_CONCAT(head1, head2, type, field) do { \275#define SLIST_CONCAT(head1, head2, type, field) do { \
217 QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \276 QUEUE_TYPEOF(type) *_Curelm = SLIST_FIRST(head1); \
218 if (curelm == NULL) { \277 if (_Curelm == NULL) { \
219 if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \278 if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \
220 SLIST_INIT(head2); \279 SLIST_INIT(head2); \
221 } else if (SLIST_FIRST(head2) != NULL) { \280 } else if (SLIST_FIRST(head2) != NULL) { \
222 while (SLIST_NEXT(curelm, field) != NULL) \281 while (SLIST_NEXT(_Curelm, field) != NULL) \
223 curelm = SLIST_NEXT(curelm, field); \282 _Curelm = SLIST_NEXT(_Curelm, field); \
224 SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \283 SLIST_NEXT(_Curelm, field) = SLIST_FIRST(head2); \
225 SLIST_INIT(head2); \284 SLIST_INIT(head2); \
226 } \285 } \
227} while (0)286} 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) \
234 for ((var) = SLIST_FIRST((head)); \296 for ((var) = SLIST_FIRST((head)); \
235 (var); \297 (var); \
236 (var) = SLIST_NEXT((var), field))298 (var) = SLIST_NEXT((var), field))
237299
238#define SLIST_FOREACH_FROM(var, head, field) \300#define SLIST_FOREACH_FROM(var, head, field) \
239 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \301 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
240 (var); \302 (var); \
241 (var) = SLIST_NEXT((var), field))303 (var) = SLIST_NEXT((var), field))
242304
243#define SLIST_FOREACH_SAFE(var, head, field, tvar) \305#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
244 for ((var) = SLIST_FIRST((head)); \306 for ((var) = SLIST_FIRST((head)); \
245 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \307 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
246 (var) = (tvar))308 (var) = (tvar))
247309
248#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \310#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
249 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \311 for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
250 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \312 (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
251 (var) = (tvar))313 (var) = (tvar))
252314
253#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \315#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
254 for ((varp) = &SLIST_FIRST((head)); \316 for ((varp) = &SLIST_FIRST((head)); \
255 ((var) = *(varp)) != NULL; \317 ((var) = *(varp)) != NULL; \
256 (varp) = &SLIST_NEXT((var), field))318 (varp) = &SLIST_NEXT((var), field))
257319
258#define SLIST_INIT(head) do { \320#define SLIST_INIT(head) do { \
259 SLIST_FIRST((head)) = NULL; \321 SLIST_FIRST((head)) = NULL; \
260} while (0)322} while (0)
261323
262#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \324#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
263 SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \325 SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
264 SLIST_NEXT((slistelm), field) = (elm); \326 SLIST_NEXT((slistelm), field) = (elm); \
265} while (0)327} while (0)
266328
267#define SLIST_INSERT_HEAD(head, elm, field) do { \329#define SLIST_INSERT_HEAD(head, elm, field) do { \
268 SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \330 SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
269 SLIST_FIRST((head)) = (elm); \331 SLIST_FIRST((head)) = (elm); \
270} while (0)332} 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 { \
275 if (SLIST_FIRST((head)) == (elm)) { \337 if (SLIST_FIRST((head)) == (elm)) { \
276 SLIST_REMOVE_HEAD((head), field); \338 SLIST_REMOVE_HEAD((head), field); \
277 } \339 } \
278 else { \340 else { \
279 QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \341 QUEUE_TYPEOF(type) *_Curelm = SLIST_FIRST(head); \
280 while (SLIST_NEXT(curelm, field) != (elm)) \342 while (SLIST_NEXT(_Curelm, field) != (elm)) \
281 curelm = SLIST_NEXT(curelm, field); \343 _Curelm = SLIST_NEXT(_Curelm, field); \
282 SLIST_REMOVE_AFTER(curelm, field); \344 SLIST_REMOVE_AFTER(_Curelm, field); \
283 } \345 } \
284} while (0)346} while (0)
285347
286#define SLIST_REMOVE_AFTER(elm, field) do { \348#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); \
288 SLIST_NEXT(elm, field) = \350 SLIST_NEXT(elm, field) = \
289 SLIST_NEXT(SLIST_NEXT(elm, field), field); \351 SLIST_NEXT(SLIST_NEXT(elm, field), field); \
290 TRASHIT(*oldnext); \352 TRASHIT(*_Oldnext); \
291} while (0)353} while (0)
292354
293#define SLIST_REMOVE_HEAD(head, field) do { \355#define SLIST_REMOVE_HEAD(head, field) do { \
294 QMD_SAVELINK(oldnext, SLIST_FIRST(head)->field.sle_next); \356 QMD_SAVELINK(_Oldnext, SLIST_FIRST(head)->field.sle_next); \
295 SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \357 SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
296 TRASHIT(*oldnext); \358 TRASHIT(*_Oldnext); \
297} while (0)359} while (0)
298360
299#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \361#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \
300 QMD_SLIST_CHECK_PREVPTR(prevp, elm); \362 QMD_SLIST_CHECK_PREVPTR(prevp, elm); \
301 *(prevp) = SLIST_NEXT(elm, field); \363 *(prevp) = SLIST_NEXT(elm, field); \
302 TRASHIT((elm)->field.sle_next); \364 TRASHIT((elm)->field.sle_next); \
303} while (0)365} 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
305#define SLIST_SWAP(head1, head2, type) do { \373#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); \
307 SLIST_FIRST(head1) = SLIST_FIRST(head2); \375 SLIST_FIRST(head1) = SLIST_FIRST(head2); \
308 SLIST_FIRST(head2) = swap_first; \376 SLIST_FIRST(head2) = _Swap_first; \
309} while (0)377} while (0)
310378
311#define SLIST_END(head) NULL379#define SLIST_END(head) NULL
312380
313/*381/*
314 * Singly-linked Tail queue declarations.382 * Singly-linked Tail queue declarations.
315 */383 */
316#define STAILQ_HEAD(name, type) \384
385#define STAILQ_HEAD(name, type) \
317struct name { \386struct name { \
318 struct type *stqh_first;/* first element */ \387 struct type *stqh_first;/* first element */ \
319 struct type **stqh_last;/* addr of last next element */ \388 struct type **stqh_last;/* addr of last next element */ \
320}389}
321390
322#define STAILQ_CLASS_HEAD(name, type) \391#define STAILQ_CLASS_HEAD(name, type) \
323struct name { \392struct name { \
324 class type *stqh_first; /* first element */ \393 class type *stqh_first; /* first element */ \
325 class type **stqh_last; /* addr of last next element */ \394 class type **stqh_last; /* addr of last next element */ \
326}395}
327396
328#define STAILQ_HEAD_INITIALIZER(head) \397#define STAILQ_HEAD_INITIALIZER(head) \
329 { NULL, &(head).stqh_first }398 { NULL, &(head).stqh_first }
330399
331#define STAILQ_ENTRY(type) \400#define STAILQ_ENTRY(type) \
332struct { \401struct { \
333 struct type *stqe_next; /* next element */ \402 struct type *stqe_next; /* next element */ \
334}403}
335404
336#define STAILQ_CLASS_ENTRY(type) \405#define STAILQ_CLASS_ENTRY(type) \
337struct { \406struct { \
338 class type *stqe_next; /* next element */ \407 class type *stqe_next; /* next element */ \
339}408}
...@@ -341,7 +410,38 @@ struct { \...@@ -341,7 +410,38 @@ struct { \
341/*410/*
342 * Singly-linked Tail queue functions.411 * Singly-linked Tail queue functions.
343 */412 */
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 { \
345 if (!STAILQ_EMPTY((head2))) { \445 if (!STAILQ_EMPTY((head2))) { \
346 *(head1)->stqh_last = (head2)->stqh_first; \446 *(head1)->stqh_last = (head2)->stqh_first; \
347 (head1)->stqh_last = (head2)->stqh_last; \447 (head1)->stqh_last = (head2)->stqh_last; \
...@@ -349,72 +449,80 @@ struct { \...@@ -349,72 +449,80 @@ struct { \
349 } \449 } \
350} while (0)450} 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) \
357 for((var) = STAILQ_FIRST((head)); \464 for((var) = STAILQ_FIRST((head)); \
358 (var); \465 (var); \
359 (var) = STAILQ_NEXT((var), field))466 (var) = STAILQ_NEXT((var), field))
360467
361#define STAILQ_FOREACH_FROM(var, head, field) \468#define STAILQ_FOREACH_FROM(var, head, field) \
362 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \469 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
363 (var); \470 (var); \
364 (var) = STAILQ_NEXT((var), field))471 (var) = STAILQ_NEXT((var), field))
365472
366#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \473#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
367 for ((var) = STAILQ_FIRST((head)); \474 for ((var) = STAILQ_FIRST((head)); \
368 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \475 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
369 (var) = (tvar))476 (var) = (tvar))
370477
371#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \478#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
372 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \479 for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
373 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \480 (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
374 (var) = (tvar))481 (var) = (tvar))
375482
376#define STAILQ_INIT(head) do { \483#define STAILQ_INIT(head) do { \
377 STAILQ_FIRST((head)) = NULL; \484 STAILQ_FIRST((head)) = NULL; \
378 (head)->stqh_last = &STAILQ_FIRST((head)); \485 (head)->stqh_last = &STAILQ_FIRST((head)); \
379} while (0)486} while (0)
380487
381#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \488#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
382 if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\489 if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
383 (head)->stqh_last = &STAILQ_NEXT((elm), field); \490 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
384 STAILQ_NEXT((tqelm), field) = (elm); \491 STAILQ_NEXT((tqelm), field) = (elm); \
385} while (0)492} while (0)
386493
387#define STAILQ_INSERT_HEAD(head, elm, field) do { \494#define STAILQ_INSERT_HEAD(head, elm, field) do { \
388 if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \495 if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
389 (head)->stqh_last = &STAILQ_NEXT((elm), field); \496 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
390 STAILQ_FIRST((head)) = (elm); \497 STAILQ_FIRST((head)) = (elm); \
391} while (0)498} 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); \
394 STAILQ_NEXT((elm), field) = NULL; \502 STAILQ_NEXT((elm), field) = NULL; \
395 *(head)->stqh_last = (elm); \503 *(head)->stqh_last = (elm); \
396 (head)->stqh_last = &STAILQ_NEXT((elm), field); \504 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
397} while (0)505} while (0)
398506
399#define STAILQ_LAST(head, type, field) \507#define STAILQ_LAST(head, type, field) \
400 (STAILQ_EMPTY((head)) ? NULL : \508 (STAILQ_EMPTY((head)) ? NULL : \
401 __containerof((head)->stqh_last, \509 __containerof((head)->stqh_last, \
402 QUEUE_TYPEOF(type), field.stqe_next))510 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 { \514#define STAILQ_REMOVE(head, elm, type, field) do { \
407 QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \515 QMD_SAVELINK(_Oldnext, (elm)->field.stqe_next); \
408 if (STAILQ_FIRST((head)) == (elm)) { \516 if (STAILQ_FIRST((head)) == (elm)) { \
409 STAILQ_REMOVE_HEAD((head), field); \517 STAILQ_REMOVE_HEAD((head), field); \
410 } \518 } \
411 else { \519 else { \
412 QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \520 QUEUE_TYPEOF(type) *_Curelm = STAILQ_FIRST(head); \
413 while (STAILQ_NEXT(curelm, field) != (elm)) \521 while (STAILQ_NEXT(_Curelm, field) != (elm)) \
414 curelm = STAILQ_NEXT(curelm, field); \522 _Curelm = STAILQ_NEXT(_Curelm, field); \
415 STAILQ_REMOVE_AFTER(head, curelm, field); \523 STAILQ_REMOVE_AFTER(head, _Curelm, field); \
416 } \524 } \
417 TRASHIT(*oldnext); \525 TRASHIT(*_Oldnext); \
418} while (0)526} while (0)
419527
420#define STAILQ_REMOVE_AFTER(head, elm, field) do { \528#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
...@@ -423,51 +531,81 @@ struct { \...@@ -423,51 +531,81 @@ struct { \
423 (head)->stqh_last = &STAILQ_NEXT((elm), field); \531 (head)->stqh_last = &STAILQ_NEXT((elm), field); \
424} while (0)532} while (0)
425533
426#define STAILQ_REMOVE_HEAD(head, field) do { \534#define STAILQ_REMOVE_HEAD(head, field) do { \
427 if ((STAILQ_FIRST((head)) = \535 if ((STAILQ_FIRST((head)) = \
428 STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \536 STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
429 (head)->stqh_last = &STAILQ_FIRST((head)); \537 (head)->stqh_last = &STAILQ_FIRST((head)); \
430} while (0)538} 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
432#define STAILQ_SWAP(head1, head2, type) do { \554#define STAILQ_SWAP(head1, head2, type) do { \
433 QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \555 QUEUE_TYPEOF(type) *_Swap_first = STAILQ_FIRST(head1); \
434 QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \556 QUEUE_TYPEOF(type) **_Swap_last = (head1)->stqh_last; \
435 STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \557 STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
436 (head1)->stqh_last = (head2)->stqh_last; \558 (head1)->stqh_last = (head2)->stqh_last; \
437 STAILQ_FIRST(head2) = swap_first; \559 STAILQ_FIRST(head2) = _Swap_first; \
438 (head2)->stqh_last = swap_last; \560 (head2)->stqh_last = _Swap_last; \
439 if (STAILQ_EMPTY(head1)) \561 if (STAILQ_FIRST(head1) == NULL) \
440 (head1)->stqh_last = &STAILQ_FIRST(head1); \562 (head1)->stqh_last = &STAILQ_FIRST(head1); \
441 if (STAILQ_EMPTY(head2)) \563 if (STAILQ_FIRST(head2) == NULL) \
442 (head2)->stqh_last = &STAILQ_FIRST(head2); \564 (head2)->stqh_last = &STAILQ_FIRST(head2); \
443} while (0)565} while (0)
444566
445#define STAILQ_END(head) NULL567#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
448/*585/*
449 * List declarations.586 * List declarations.
450 */587 */
451#define LIST_HEAD(name, type) \588
589#define LIST_HEAD(name, type) \
452struct name { \590struct name { \
453 struct type *lh_first; /* first element */ \591 struct type *lh_first; /* first element */ \
454}592}
455593
456#define LIST_CLASS_HEAD(name, type) \594#define LIST_CLASS_HEAD(name, type) \
457struct name { \595struct name { \
458 class type *lh_first; /* first element */ \596 class type *lh_first; /* first element */ \
459}597}
460598
461#define LIST_HEAD_INITIALIZER(head) \599#define LIST_HEAD_INITIALIZER(head) \
462 { NULL }600 { NULL }
463601
464#define LIST_ENTRY(type) \602#define LIST_ENTRY(type) \
465struct { \603struct { \
466 struct type *le_next; /* next element */ \604 struct type *le_next; /* next element */ \
467 struct type **le_prev; /* address of previous next element */ \605 struct type **le_prev; /* address of previous next element */ \
468}606}
469607
470#define LIST_CLASS_ENTRY(type) \608#define LIST_CLASS_ENTRY(type) \
471struct { \609struct { \
472 class type *le_next; /* next element */ \610 class type *le_next; /* next element */ \
473 class type **le_prev; /* address of previous next element */ \611 class type **le_prev; /* address of previous next element */ \
...@@ -477,19 +615,18 @@ struct { \...@@ -477,19 +615,18 @@ struct { \
477 * List functions.615 * List functions.
478 */616 */
479617
480#if (defined(_KERNEL) && defined(INVARIANTS))
481/*618/*
482 * QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME)619 * QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME)
483 *620 *
484 * If the list is non-empty, validates that the first element of the list621 * If the list is non-empty, validates that the first element of the list
485 * points back at 'head.'622 * points back at 'head.'
486 */623 */
487#define QMD_LIST_CHECK_HEAD(head, field) do { \624#define QMD_LIST_CHECK_HEAD(head, field) \
488 if (LIST_FIRST((head)) != NULL && \625 QMD_ASSERT(LIST_FIRST((head)) == NULL || \
489 LIST_FIRST((head))->field.le_prev != \626 LIST_FIRST((head))->field.le_prev == \
490 &LIST_FIRST((head))) \627 &LIST_FIRST((head)), \
491 panic("Bad list head %p first->prev != head", (head)); \628 "Bad list head %p first->prev != head", \
492} while (0)629 (head))
493630
494/*631/*
495 * QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME)632 * QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME)
...@@ -497,74 +634,78 @@ struct { \...@@ -497,74 +634,78 @@ struct { \
497 * If an element follows 'elm' in the list, validates that the next element634 * If an element follows 'elm' in the list, validates that the next element
498 * points back at 'elm.'635 * points back at 'elm.'
499 */636 */
500#define QMD_LIST_CHECK_NEXT(elm, field) do { \637#define QMD_LIST_CHECK_NEXT(elm, field) \
501 if (LIST_NEXT((elm), field) != NULL && \638 QMD_ASSERT(LIST_NEXT((elm), field) == NULL || \
502 LIST_NEXT((elm), field)->field.le_prev != \639 LIST_NEXT((elm), field)->field.le_prev == \
503 &((elm)->field.le_next)) \640 &((elm)->field.le_next), \
504 panic("Bad link elm %p next->prev != elm", (elm)); \641 "Bad link elm %p next->prev != elm", (elm))
505} while (0)
506642
507/*643/*
508 * QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME)644 * QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME)
509 *645 *
510 * Validates that the previous element (or head of the list) points to 'elm.'646 * Validates that the previous element (or head of the list) points to 'elm.'
511 */647 */
512#define QMD_LIST_CHECK_PREV(elm, field) do { \648#define QMD_LIST_CHECK_PREV(elm, field) \
513 if (*(elm)->field.le_prev != (elm)) \649 QMD_ASSERT(*(elm)->field.le_prev == (elm), \
514 panic("Bad link elm %p prev->next != elm", (elm)); \650 "Bad link elm %p prev->next != elm", (elm))
515} while (0)651
516#else652#define LIST_ASSERT_EMPTY(head) \
517#define QMD_LIST_CHECK_HEAD(head, field)653 QMD_ASSERT(LIST_EMPTY((head)), \
518#define QMD_LIST_CHECK_NEXT(elm, field)654 "list %p is not empty", (head))
519#define QMD_LIST_CHECK_PREV(elm, field)655
520#endif /* (_KERNEL && INVARIANTS) */656#define LIST_ASSERT_NONEMPTY(head) \
657 QMD_ASSERT(!LIST_EMPTY((head)), \
658 "list %p is empty", (head))
521659
522#define LIST_CONCAT(head1, head2, type, field) do { \660#define LIST_CONCAT(head1, head2, type, field) do { \
523 QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \661 QUEUE_TYPEOF(type) *_Curelm = LIST_FIRST(head1); \
524 if (curelm == NULL) { \662 if (_Curelm == NULL) { \
525 if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \663 if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \
526 LIST_FIRST(head2)->field.le_prev = \664 LIST_FIRST(head2)->field.le_prev = \
527 &LIST_FIRST((head1)); \665 &LIST_FIRST((head1)); \
528 LIST_INIT(head2); \666 LIST_INIT(head2); \
529 } \667 } \
530 } else if (LIST_FIRST(head2) != NULL) { \668 } else if (LIST_FIRST(head2) != NULL) { \
531 while (LIST_NEXT(curelm, field) != NULL) \669 while (LIST_NEXT(_Curelm, field) != NULL) \
532 curelm = LIST_NEXT(curelm, field); \670 _Curelm = LIST_NEXT(_Curelm, field); \
533 LIST_NEXT(curelm, field) = LIST_FIRST(head2); \671 LIST_NEXT(_Curelm, field) = LIST_FIRST(head2); \
534 LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field);\672 LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(_Curelm, field);\
535 LIST_INIT(head2); \673 LIST_INIT(head2); \
536 } \674 } \
537} while (0)675} 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) \
544 for ((var) = LIST_FIRST((head)); \685 for ((var) = LIST_FIRST((head)); \
545 (var); \686 (var); \
546 (var) = LIST_NEXT((var), field))687 (var) = LIST_NEXT((var), field))
547688
548#define LIST_FOREACH_FROM(var, head, field) \689#define LIST_FOREACH_FROM(var, head, field) \
549 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \690 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
550 (var); \691 (var); \
551 (var) = LIST_NEXT((var), field))692 (var) = LIST_NEXT((var), field))
552693
553#define LIST_FOREACH_SAFE(var, head, field, tvar) \694#define LIST_FOREACH_SAFE(var, head, field, tvar) \
554 for ((var) = LIST_FIRST((head)); \695 for ((var) = LIST_FIRST((head)); \
555 (var) && ((tvar) = LIST_NEXT((var), field), 1); \696 (var) && ((tvar) = LIST_NEXT((var), field), 1); \
556 (var) = (tvar))697 (var) = (tvar))
557698
558#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \699#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
559 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \700 for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
560 (var) && ((tvar) = LIST_NEXT((var), field), 1); \701 (var) && ((tvar) = LIST_NEXT((var), field), 1); \
561 (var) = (tvar))702 (var) = (tvar))
562703
563#define LIST_INIT(head) do { \704#define LIST_INIT(head) do { \
564 LIST_FIRST((head)) = NULL; \705 LIST_FIRST((head)) = NULL; \
565} while (0)706} while (0)
566707
567#define LIST_INSERT_AFTER(listelm, elm, field) do { \708#define LIST_INSERT_AFTER(listelm, elm, field) do { \
568 QMD_LIST_CHECK_NEXT(listelm, field); \709 QMD_LIST_CHECK_NEXT(listelm, field); \
569 if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\710 if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
570 LIST_NEXT((listelm), field)->field.le_prev = \711 LIST_NEXT((listelm), field)->field.le_prev = \
...@@ -573,7 +714,7 @@ struct { \...@@ -573,7 +714,7 @@ struct { \
573 (elm)->field.le_prev = &LIST_NEXT((listelm), field); \714 (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
574} while (0)715} while (0)
575716
576#define LIST_INSERT_BEFORE(listelm, elm, field) do { \717#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
577 QMD_LIST_CHECK_PREV(listelm, field); \718 QMD_LIST_CHECK_PREV(listelm, field); \
578 (elm)->field.le_prev = (listelm)->field.le_prev; \719 (elm)->field.le_prev = (listelm)->field.le_prev; \
579 LIST_NEXT((elm), field) = (listelm); \720 LIST_NEXT((elm), field) = (listelm); \
...@@ -581,7 +722,7 @@ struct { \...@@ -581,7 +722,7 @@ struct { \
581 (listelm)->field.le_prev = &LIST_NEXT((elm), field); \722 (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
582} while (0)723} while (0)
583724
584#define LIST_INSERT_HEAD(head, elm, field) do { \725#define LIST_INSERT_HEAD(head, elm, field) do { \
585 QMD_LIST_CHECK_HEAD((head), field); \726 QMD_LIST_CHECK_HEAD((head), field); \
586 if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \727 if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
587 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\728 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
...@@ -589,9 +730,9 @@ struct { \...@@ -589,9 +730,9 @@ struct { \
589 (elm)->field.le_prev = &LIST_FIRST((head)); \730 (elm)->field.le_prev = &LIST_FIRST((head)); \
590} while (0)731} 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) \
595 ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \736 ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
596 __containerof((elm)->field.le_prev, \737 __containerof((elm)->field.le_prev, \
597 QUEUE_TYPEOF(type), field.le_next))738 QUEUE_TYPEOF(type), field.le_next))
...@@ -599,22 +740,22 @@ struct { \...@@ -599,22 +740,22 @@ struct { \
599#define LIST_REMOVE_HEAD(head, field) \740#define LIST_REMOVE_HEAD(head, field) \
600 LIST_REMOVE(LIST_FIRST(head), field)741 LIST_REMOVE(LIST_FIRST(head), field)
601742
602#define LIST_REMOVE(elm, field) do { \743#define LIST_REMOVE(elm, field) do { \
603 QMD_SAVELINK(oldnext, (elm)->field.le_next); \744 QMD_SAVELINK(_Oldnext, (elm)->field.le_next); \
604 QMD_SAVELINK(oldprev, (elm)->field.le_prev); \745 QMD_SAVELINK(_Oldprev, (elm)->field.le_prev); \
605 QMD_LIST_CHECK_NEXT(elm, field); \746 QMD_LIST_CHECK_NEXT(elm, field); \
606 QMD_LIST_CHECK_PREV(elm, field); \747 QMD_LIST_CHECK_PREV(elm, field); \
607 if (LIST_NEXT((elm), field) != NULL) \748 if (LIST_NEXT((elm), field) != NULL) \
608 LIST_NEXT((elm), field)->field.le_prev = \749 LIST_NEXT((elm), field)->field.le_prev = \
609 (elm)->field.le_prev; \750 (elm)->field.le_prev; \
610 *(elm)->field.le_prev = LIST_NEXT((elm), field); \751 *(elm)->field.le_prev = LIST_NEXT((elm), field); \
611 TRASHIT(*oldnext); \752 TRASHIT(*_Oldnext); \
612 TRASHIT(*oldprev); \753 TRASHIT(*_Oldprev); \
613} while (0)754} while (0)
614755
615#define LIST_REPLACE(elm, elm2, field) do { \756#define LIST_REPLACE(elm, elm2, field) do { \
616 QMD_SAVELINK(oldnext, (elm)->field.le_next); \757 QMD_SAVELINK(_Oldnext, (elm)->field.le_next); \
617 QMD_SAVELINK(oldprev, (elm)->field.le_prev); \758 QMD_SAVELINK(_Oldprev, (elm)->field.le_prev); \
618 QMD_LIST_CHECK_NEXT(elm, field); \759 QMD_LIST_CHECK_NEXT(elm, field); \
619 QMD_LIST_CHECK_PREV(elm, field); \760 QMD_LIST_CHECK_PREV(elm, field); \
620 LIST_NEXT((elm2), field) = LIST_NEXT((elm), field); \761 LIST_NEXT((elm2), field) = LIST_NEXT((elm), field); \
...@@ -623,8 +764,21 @@ struct { \...@@ -623,8 +764,21 @@ struct { \
623 &(elm2)->field.le_next; \764 &(elm2)->field.le_next; \
624 (elm2)->field.le_prev = (elm)->field.le_prev; \765 (elm2)->field.le_prev = (elm)->field.le_prev; \
625 *(elm2)->field.le_prev = (elm2); \766 *(elm2)->field.le_prev = (elm2); \
626 TRASHIT(*oldnext); \767 TRASHIT(*_Oldnext); \
627 TRASHIT(*oldprev); \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 } \
628} while (0)782} while (0)
629783
630#define LIST_SWAP(head1, head2, type, field) do { \784#define LIST_SWAP(head1, head2, type, field) do { \
...@@ -637,36 +791,37 @@ struct { \...@@ -637,36 +791,37 @@ struct { \
637 swap_tmp->field.le_prev = &LIST_FIRST((head2)); \791 swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
638} while (0)792} while (0)
639793
640#define LIST_END(head) NULL794#define LIST_END(head) NULL
641795
642/*796/*
643 * Tail queue declarations.797 * Tail queue declarations.
644 */798 */
645#define TAILQ_HEAD(name, type) \799
800#define TAILQ_HEAD(name, type) \
646struct name { \801struct name { \
647 struct type *tqh_first; /* first element */ \802 struct type *tqh_first; /* first element */ \
648 struct type **tqh_last; /* addr of last next element */ \803 struct type **tqh_last; /* addr of last next element */ \
649 TRACEBUF \804 TRACEBUF \
650}805}
651806
652#define TAILQ_CLASS_HEAD(name, type) \807#define TAILQ_CLASS_HEAD(name, type) \
653struct name { \808struct name { \
654 class type *tqh_first; /* first element */ \809 class type *tqh_first; /* first element */ \
655 class type **tqh_last; /* addr of last next element */ \810 class type **tqh_last; /* addr of last next element */ \
656 TRACEBUF \811 TRACEBUF \
657}812}
658813
659#define TAILQ_HEAD_INITIALIZER(head) \814#define TAILQ_HEAD_INITIALIZER(head) \
660 { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }815 { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
661816
662#define TAILQ_ENTRY(type) \817#define TAILQ_ENTRY(type) \
663struct { \818struct { \
664 struct type *tqe_next; /* next element */ \819 struct type *tqe_next; /* next element */ \
665 struct type **tqe_prev; /* address of previous next element */ \820 struct type **tqe_prev; /* address of previous next element */ \
666 TRACEBUF \821 TRACEBUF \
667}822}
668823
669#define TAILQ_CLASS_ENTRY(type) \824#define TAILQ_CLASS_ENTRY(type) \
670struct { \825struct { \
671 class type *tqe_next; /* next element */ \826 class type *tqe_next; /* next element */ \
672 class type **tqe_prev; /* address of previous next element */ \827 class type **tqe_prev; /* address of previous next element */ \
...@@ -676,29 +831,29 @@ struct { \...@@ -676,29 +831,29 @@ struct { \
676/*831/*
677 * Tail queue functions.832 * Tail queue functions.
678 */833 */
679#if (defined(_KERNEL) && defined(INVARIANTS))834
680/*835/*
681 * QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME)836 * QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
682 *837 *
683 * If the tailq is non-empty, validates that the first element of the tailq838 * If the tailq is non-empty, validates that the first element of the tailq
684 * points back at 'head.'839 * points back at 'head.'
685 */840 */
686#define QMD_TAILQ_CHECK_HEAD(head, field) do { \841#define QMD_TAILQ_CHECK_HEAD(head, field) \
687 if (!TAILQ_EMPTY(head) && \842 QMD_ASSERT(TAILQ_EMPTY(head) || \
688 TAILQ_FIRST((head))->field.tqe_prev != \843 TAILQ_FIRST((head))->field.tqe_prev == \
689 &TAILQ_FIRST((head))) \844 &TAILQ_FIRST((head)), \
690 panic("Bad tailq head %p first->prev != head", (head)); \845 "Bad tailq head %p first->prev != head", \
691} while (0)846 (head))
692847
693/*848/*
694 * QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME)849 * QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
695 *850 *
696 * Validates that the tail of the tailq is a pointer to pointer to NULL.851 * Validates that the tail of the tailq is a pointer to pointer to NULL.
697 */852 */
698#define QMD_TAILQ_CHECK_TAIL(head, field) do { \853#define QMD_TAILQ_CHECK_TAIL(head, field) \
699 if (*(head)->tqh_last != NULL) \854 QMD_ASSERT(*(head)->tqh_last == NULL, \
700 panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \855 "Bad tailq NEXT(%p->tqh_last) != NULL", \
701} while (0)856 (head))
702857
703/*858/*
704 * QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME)859 * QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME)
...@@ -706,30 +861,30 @@ struct { \...@@ -706,30 +861,30 @@ struct { \
706 * If an element follows 'elm' in the tailq, validates that the next element861 * If an element follows 'elm' in the tailq, validates that the next element
707 * points back at 'elm.'862 * points back at 'elm.'
708 */863 */
709#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \864#define QMD_TAILQ_CHECK_NEXT(elm, field) \
710 if (TAILQ_NEXT((elm), field) != NULL && \865 QMD_ASSERT(TAILQ_NEXT((elm), field) == NULL || \
711 TAILQ_NEXT((elm), field)->field.tqe_prev != \866 TAILQ_NEXT((elm), field)->field.tqe_prev == \
712 &((elm)->field.tqe_next)) \867 &((elm)->field.tqe_next), \
713 panic("Bad link elm %p next->prev != elm", (elm)); \868 "Bad link elm %p next->prev != elm", (elm))
714} while (0)
715869
716/*870/*
717 * QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME)871 * QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME)
718 *872 *
719 * Validates that the previous element (or head of the tailq) points to 'elm.'873 * Validates that the previous element (or head of the tailq) points to 'elm.'
720 */874 */
721#define QMD_TAILQ_CHECK_PREV(elm, field) do { \875#define QMD_TAILQ_CHECK_PREV(elm, field) \
722 if (*(elm)->field.tqe_prev != (elm)) \876 QMD_ASSERT(*(elm)->field.tqe_prev == (elm), \
723 panic("Bad link elm %p prev->next != elm", (elm)); \877 "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) */
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 { \
733 if (!TAILQ_EMPTY(head2)) { \888 if (!TAILQ_EMPTY(head2)) { \
734 *(head1)->tqh_last = (head2)->tqh_first; \889 *(head1)->tqh_last = (head2)->tqh_first; \
735 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \890 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
...@@ -740,57 +895,60 @@ struct { \...@@ -740,57 +895,60 @@ struct { \
740 } \895 } \
741} while (0)896} 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) \
748 for ((var) = TAILQ_FIRST((head)); \906 for ((var) = TAILQ_FIRST((head)); \
749 (var); \907 (var); \
750 (var) = TAILQ_NEXT((var), field))908 (var) = TAILQ_NEXT((var), field))
751909
752#define TAILQ_FOREACH_FROM(var, head, field) \910#define TAILQ_FOREACH_FROM(var, head, field) \
753 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \911 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
754 (var); \912 (var); \
755 (var) = TAILQ_NEXT((var), field))913 (var) = TAILQ_NEXT((var), field))
756914
757#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \915#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
758 for ((var) = TAILQ_FIRST((head)); \916 for ((var) = TAILQ_FIRST((head)); \
759 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \917 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
760 (var) = (tvar))918 (var) = (tvar))
761919
762#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \920#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
763 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \921 for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
764 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \922 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
765 (var) = (tvar))923 (var) = (tvar))
766924
767#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \925#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
768 for ((var) = TAILQ_LAST((head), headname); \926 for ((var) = TAILQ_LAST((head), headname); \
769 (var); \927 (var); \
770 (var) = TAILQ_PREV((var), headname, field))928 (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) \
773 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \931 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
774 (var); \932 (var); \
775 (var) = TAILQ_PREV((var), headname, field))933 (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) \
778 for ((var) = TAILQ_LAST((head), headname); \936 for ((var) = TAILQ_LAST((head), headname); \
779 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \937 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
780 (var) = (tvar))938 (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)\
783 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \941 for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
784 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \942 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
785 (var) = (tvar))943 (var) = (tvar))
786944
787#define TAILQ_INIT(head) do { \945#define TAILQ_INIT(head) do { \
788 TAILQ_FIRST((head)) = NULL; \946 TAILQ_FIRST((head)) = NULL; \
789 (head)->tqh_last = &TAILQ_FIRST((head)); \947 (head)->tqh_last = &TAILQ_FIRST((head)); \
790 QMD_TRACE_HEAD(head); \948 QMD_TRACE_HEAD(head); \
791} while (0)949} while (0)
792950
793#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \951#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
794 QMD_TAILQ_CHECK_NEXT(listelm, field); \952 QMD_TAILQ_CHECK_NEXT(listelm, field); \
795 if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\953 if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
796 TAILQ_NEXT((elm), field)->field.tqe_prev = \954 TAILQ_NEXT((elm), field)->field.tqe_prev = \
...@@ -805,7 +963,7 @@ struct { \...@@ -805,7 +963,7 @@ struct { \
805 QMD_TRACE_ELEM(&(listelm)->field); \963 QMD_TRACE_ELEM(&(listelm)->field); \
806} while (0)964} while (0)
807965
808#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \966#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
809 QMD_TAILQ_CHECK_PREV(listelm, field); \967 QMD_TAILQ_CHECK_PREV(listelm, field); \
810 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \968 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
811 TAILQ_NEXT((elm), field) = (listelm); \969 TAILQ_NEXT((elm), field) = (listelm); \
...@@ -815,7 +973,7 @@ struct { \...@@ -815,7 +973,7 @@ struct { \
815 QMD_TRACE_ELEM(&(listelm)->field); \973 QMD_TRACE_ELEM(&(listelm)->field); \
816} while (0)974} while (0)
817975
818#define TAILQ_INSERT_HEAD(head, elm, field) do { \976#define TAILQ_INSERT_HEAD(head, elm, field) do { \
819 QMD_TAILQ_CHECK_HEAD(head, field); \977 QMD_TAILQ_CHECK_HEAD(head, field); \
820 if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \978 if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
821 TAILQ_FIRST((head))->field.tqe_prev = \979 TAILQ_FIRST((head))->field.tqe_prev = \
...@@ -828,7 +986,7 @@ struct { \...@@ -828,7 +986,7 @@ struct { \
828 QMD_TRACE_ELEM(&(elm)->field); \986 QMD_TRACE_ELEM(&(elm)->field); \
829} while (0)987} while (0)
830988
831#define TAILQ_INSERT_TAIL(head, elm, field) do { \989#define TAILQ_INSERT_TAIL(head, elm, field) do { \
832 QMD_TAILQ_CHECK_TAIL(head, field); \990 QMD_TAILQ_CHECK_TAIL(head, field); \
833 TAILQ_NEXT((elm), field) = NULL; \991 TAILQ_NEXT((elm), field) = NULL; \
834 (elm)->field.tqe_prev = (head)->tqh_last; \992 (elm)->field.tqe_prev = (head)->tqh_last; \
...@@ -838,7 +996,7 @@ struct { \...@@ -838,7 +996,7 @@ struct { \
838 QMD_TRACE_ELEM(&(elm)->field); \996 QMD_TRACE_ELEM(&(elm)->field); \
839} while (0)997} while (0)
840998
841#define TAILQ_LAST(head, headname) \999#define TAILQ_LAST(head, headname) \
842 (*(((struct headname *)((head)->tqh_last))->tqh_last))1000 (*(((struct headname *)((head)->tqh_last))->tqh_last))
8431001
844/*1002/*
...@@ -848,24 +1006,24 @@ struct { \...@@ -848,24 +1006,24 @@ struct { \
848 * the previous element. FAST is very useful for instances when1006 * the previous element. FAST is very useful for instances when
849 * you may want to prefetch the last data element.1007 * you may want to prefetch the last data element.
850 */1008 */
851#define TAILQ_LAST_FAST(head, type, field) \1009#define TAILQ_LAST_FAST(head, type, field) \
852 (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next))1010 (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) \
857 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))1015 (*(((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) \
860 ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \1018 ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \
861 __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next))1019 __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next))
8621020
863#define TAILQ_REMOVE_HEAD(head, field) \1021#define TAILQ_REMOVE_HEAD(head, field) \
864 TAILQ_REMOVE(head, TAILQ_FIRST(head), field)1022 TAILQ_REMOVE(head, TAILQ_FIRST(head), field)
8651023
866#define TAILQ_REMOVE(head, elm, field) do { \1024#define TAILQ_REMOVE(head, elm, field) do { \
867 QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \1025 QMD_SAVELINK(_Oldnext, (elm)->field.tqe_next); \
868 QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \1026 QMD_SAVELINK(_Oldprev, (elm)->field.tqe_prev); \
869 QMD_TAILQ_CHECK_NEXT(elm, field); \1027 QMD_TAILQ_CHECK_NEXT(elm, field); \
870 QMD_TAILQ_CHECK_PREV(elm, field); \1028 QMD_TAILQ_CHECK_PREV(elm, field); \
871 if ((TAILQ_NEXT((elm), field)) != NULL) \1029 if ((TAILQ_NEXT((elm), field)) != NULL) \
...@@ -876,14 +1034,14 @@ struct { \...@@ -876,14 +1034,14 @@ struct { \
876 QMD_TRACE_HEAD(head); \1034 QMD_TRACE_HEAD(head); \
877 } \1035 } \
878 *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \1036 *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
879 TRASHIT(*oldnext); \1037 TRASHIT(*_Oldnext); \
880 TRASHIT(*oldprev); \1038 TRASHIT(*_Oldprev); \
881 QMD_TRACE_ELEM(&(elm)->field); \1039 QMD_TRACE_ELEM(&(elm)->field); \
882} while (0)1040} while (0)
8831041
884#define TAILQ_REPLACE(head, elm, elm2, field) do { \1042#define TAILQ_REPLACE(head, elm, elm2, field) do { \
885 QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \1043 QMD_SAVELINK(_Oldnext, (elm)->field.tqe_next); \
886 QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \1044 QMD_SAVELINK(_Oldprev, (elm)->field.tqe_prev); \
887 QMD_TAILQ_CHECK_NEXT(elm, field); \1045 QMD_TAILQ_CHECK_NEXT(elm, field); \
888 QMD_TAILQ_CHECK_PREV(elm, field); \1046 QMD_TAILQ_CHECK_PREV(elm, field); \
889 TAILQ_NEXT((elm2), field) = TAILQ_NEXT((elm), field); \1047 TAILQ_NEXT((elm2), field) = TAILQ_NEXT((elm), field); \
...@@ -894,11 +1052,28 @@ struct { \...@@ -894,11 +1052,28 @@ struct { \
894 (head)->tqh_last = &(elm2)->field.tqe_next; \1052 (head)->tqh_last = &(elm2)->field.tqe_next; \
895 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \1053 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
896 *(elm2)->field.tqe_prev = (elm2); \1054 *(elm2)->field.tqe_prev = (elm2); \
897 TRASHIT(*oldnext); \1055 TRASHIT(*_Oldnext); \
898 TRASHIT(*oldprev); \1056 TRASHIT(*_Oldprev); \
899 QMD_TRACE_ELEM(&(elm)->field); \1057 QMD_TRACE_ELEM(&(elm)->field); \
900} while (0)1058} 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
902#define TAILQ_SWAP(head1, head2, type, field) do { \1077#define TAILQ_SWAP(head1, head2, type, field) do { \
903 QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \1078 QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \
904 QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \1079 QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \
...@@ -916,6 +1091,6 @@ struct { \...@@ -916,6 +1091,6 @@ struct { \
916 (head2)->tqh_last = &(head2)->tqh_first; \1091 (head2)->tqh_last = &(head2)->tqh_first; \
917} while (0)1092} while (0)
9181093
919#define TAILQ_END(head) NULL1094#define TAILQ_END(head) NULL
9201095
921#endif /* !_SYS_QUEUE_H_ */1096#endif /* !_SYS_QUEUE_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/racct.h+5-2
...@@ -35,7 +35,6 @@...@@ -35,7 +35,6 @@
35#ifndef _RACCT_H_35#ifndef _RACCT_H_
36#define _RACCT_H_36#define _RACCT_H_
3737
38#include <sys/cdefs.h>
39#include <sys/types.h>38#include <sys/types.h>
40#include <sys/queue.h>39#include <sys/queue.h>
41#include <sys/stdint.h>40#include <sys/stdint.h>
...@@ -142,13 +141,17 @@ extern bool racct_enable;...@@ -142,13 +141,17 @@ extern bool racct_enable;
142141
143/*142/*
144 * The 'racct' structure defines resource consumption for a particular143 * 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.
146 *147 *
147 * This structure must be filled with zeroes initially.148 * This structure must be filled with zeroes initially.
148 */149 */
149struct racct {150struct racct {
150 int64_t r_resources[RACCT_MAX + 1];151 int64_t r_resources[RACCT_MAX + 1];
151 LIST_HEAD(, rctl_rule_link) r_rule_links;152 LIST_HEAD(, rctl_rule_link) r_rule_links;
153 uint64_t r_runtime;
154 struct timeval r_time;
152};155};
153156
154SYSCTL_DECL(_kern_racct);157SYSCTL_DECL(_kern_racct);
lib/libc/include/generic-freebsd/sys/random.h+14-9
...@@ -85,24 +85,26 @@ enum random_entropy_source {...@@ -85,24 +85,26 @@ enum random_entropy_source {
85 RANDOM_FS_ATIME,85 RANDOM_FS_ATIME,
86 RANDOM_UMA, /* Special!! UMA/SLAB Allocator */86 RANDOM_UMA, /* Special!! UMA/SLAB Allocator */
87 RANDOM_CALLOUT,87 RANDOM_CALLOUT,
88 RANDOM_ENVIRONMENTAL_END = RANDOM_CALLOUT,88 RANDOM_RANDOMDEV,
89 RANDOM_ENVIRONMENTAL_END = RANDOM_RANDOMDEV,
89 /* Fast hardware random-number sources from here on. */90 /* Fast hardware random-number sources from here on. */
90 RANDOM_PURE_START,91 RANDOM_PURE_START,
91 RANDOM_PURE_OCTEON = RANDOM_PURE_START,92 RANDOM_PURE_TPM = RANDOM_PURE_START,
92 RANDOM_PURE_SAFE,
93 RANDOM_PURE_GLXSB,
94 RANDOM_PURE_HIFN,
95 RANDOM_PURE_RDRAND,93 RANDOM_PURE_RDRAND,
94 RANDOM_PURE_RDSEED,
96 RANDOM_PURE_NEHEMIAH,95 RANDOM_PURE_NEHEMIAH,
97 RANDOM_PURE_RNDTEST,96 RANDOM_PURE_RNDTEST,
98 RANDOM_PURE_VIRTIO,97 RANDOM_PURE_VIRTIO,
99 RANDOM_PURE_BROADCOM,98 RANDOM_PURE_BROADCOM,
100 RANDOM_PURE_CCP,99 RANDOM_PURE_CCP,
101 RANDOM_PURE_DARN,100 RANDOM_PURE_DARN,
102 RANDOM_PURE_TPM,
103 RANDOM_PURE_VMGENID,101 RANDOM_PURE_VMGENID,
104 RANDOM_PURE_QUALCOMM,102 RANDOM_PURE_QUALCOMM,
105 RANDOM_PURE_ARMV8,103 RANDOM_PURE_ARMV8,
104 RANDOM_PURE_ARM_TRNG,
105 RANDOM_PURE_SAFE,
106 RANDOM_PURE_GLXSB,
107 RANDOM_PURE_HIFN,
106 ENTROPYSOURCE108 ENTROPYSOURCE
107};109};
108_Static_assert(ENTROPYSOURCE <= 32,110_Static_assert(ENTROPYSOURCE <= 32,
...@@ -140,9 +142,6 @@ random_harvest_direct(const void *entropy, u_int size, enum random_entropy_sourc...@@ -140,9 +142,6 @@ random_harvest_direct(const void *entropy, u_int size, enum random_entropy_sourc
140 random_harvest_direct_(entropy, size, origin);142 random_harvest_direct_(entropy, size, origin);
141}143}
142144
143void random_harvest_register_source(enum random_entropy_source);
144void random_harvest_deregister_source(enum random_entropy_source);
145
146#if defined(RANDOM_ENABLE_UMA)145#if defined(RANDOM_ENABLE_UMA)
147#define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c)146#define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c)
148#else /* !defined(RANDOM_ENABLE_UMA) */147#else /* !defined(RANDOM_ENABLE_UMA) */
...@@ -155,6 +154,12 @@ void random_harvest_deregister_source(enum random_entropy_source);...@@ -155,6 +154,12 @@ void random_harvest_deregister_source(enum random_entropy_source);
155#define random_harvest_queue_ether(a, b) do {} while (0)154#define random_harvest_queue_ether(a, b) do {} while (0)
156#endif /* defined(RANDOM_ENABLE_ETHER) */155#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
158#endif /* _KERNEL */163#endif /* _KERNEL */
159164
160#define GRND_NONBLOCK 0x1165#define GRND_NONBLOCK 0x1
lib/libc/include/generic-freebsd/sys/rangelock.h+16-30
...@@ -29,12 +29,14 @@...@@ -29,12 +29,14 @@
29#ifndef _SYS_RANGELOCK_H29#ifndef _SYS_RANGELOCK_H
30#define _SYS_RANGELOCK_H30#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
34#define RL_LOCK_READ 0x000137#define RL_LOCK_READ 0x0001
35#define RL_LOCK_WRITE 0x000238#define RL_LOCK_WRITE 0x0002
36#define RL_LOCK_TYPE_MASK 0x000339#define RL_LOCK_TYPE_MASK 0x0003
37#define RL_LOCK_GRANTED 0x0004
3840
39struct rl_q_entry;41struct rl_q_entry;
4042
...@@ -44,42 +46,26 @@ struct rl_q_entry;...@@ -44,42 +46,26 @@ struct rl_q_entry;
44 * all existing lock owners are compatible with the request. Two lock46 * all existing lock owners are compatible with the request. Two lock
45 * owners are compatible if their ranges do not overlap, or both47 * owners are compatible if their ranges do not overlap, or both
46 * owners are for read.48 * 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).
58 */49 */
59struct rangelock {50struct rangelock {
60 TAILQ_HEAD(, rl_q_entry) rl_waiters;51 uintptr_t head;
61 struct rl_q_entry *rl_currdep;52 bool sleepers;
62};53};
6354
64#ifdef _KERNEL55#ifdef _KERNEL
6556
66struct mtx;
67
68void rangelock_init(struct rangelock *lock);57void rangelock_init(struct rangelock *lock);
69void rangelock_destroy(struct rangelock *lock);58void rangelock_destroy(struct rangelock *lock);
70void rangelock_unlock(struct rangelock *lock, void *cookie,59void rangelock_unlock(struct rangelock *lock, void *cookie);
71 struct mtx *ilk);60void *rangelock_rlock(struct rangelock *lock, vm_ooffset_t start,
72void *rangelock_unlock_range(struct rangelock *lock, void *cookie,61 vm_ooffset_t end);
73 off_t start, off_t end, struct mtx *ilk);62void *rangelock_tryrlock(struct rangelock *lock, vm_ooffset_t start,
74void *rangelock_rlock(struct rangelock *lock, off_t start, off_t end,63 vm_ooffset_t end);
75 struct mtx *ilk);64void *rangelock_wlock(struct rangelock *lock, vm_ooffset_t start,
76void *rangelock_tryrlock(struct rangelock *lock, off_t start, off_t end,65 vm_ooffset_t end);
77 struct mtx *ilk);66void *rangelock_trywlock(struct rangelock *lock, vm_ooffset_t start,
78void *rangelock_wlock(struct rangelock *lock, off_t start, off_t end,67 vm_ooffset_t end);
79 struct mtx *ilk);68void rangelock_may_recurse(struct rangelock *lock);
80void *rangelock_trywlock(struct rangelock *lock, off_t start, off_t end,
81 struct mtx *ilk);
82void rlqentry_free(struct rl_q_entry *rlqe);
83#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)69#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
84void _rangelock_cookie_assert(void *cookie, int what, const char *file,70void _rangelock_cookie_assert(void *cookie, int what, const char *file,
85 int line);71 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,...@@ -69,10 +69,19 @@ int rangeset_remove_pred(struct rangeset *rs, uint64_t start,
69 uint64_t end, rs_pred_t pred);69 uint64_t end, rs_pred_t pred);
7070
71/*71/*
72 * Really returns the pointer to the data with struct rs_el embedded72 * Finds the range that contains place, if any.
73 * at the beginning.
74 */73 */
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
77/*86/*
78 * Copies src_rs entries into dst_rs. dst_rs must be empty.87 * 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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)reboot.h 8.3 (Berkeley) 12/13/94
32 */30 */
3331
34#ifndef _SYS_REBOOT_H_32#ifndef _SYS_REBOOT_H_
...@@ -62,6 +60,7 @@...@@ -62,6 +60,7 @@
62#define RB_PAUSE 0x100000 /* pause after each output line during probe */60#define RB_PAUSE 0x100000 /* pause after each output line during probe */
63#define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */61#define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */
64#define RB_POWERCYCLE 0x400000 /* Power cycle if possible */62#define RB_POWERCYCLE 0x400000 /* Power cycle if possible */
63#define RB_MUTEMSGS 0x800000 /* start up with console muted after banner */
65#define RB_PROBE 0x10000000 /* Probe multiple consoles */64#define RB_PROBE 0x10000000 /* Probe multiple consoles */
66#define RB_MULTIPLE 0x20000000 /* use multiple consoles */65#define RB_MULTIPLE 0x20000000 /* use multiple consoles */
6766
lib/libc/include/generic-freebsd/sys/refcount.h+6-7
...@@ -28,15 +28,14 @@...@@ -28,15 +28,14 @@
28#ifndef __SYS_REFCOUNT_H__28#ifndef __SYS_REFCOUNT_H__
29#define __SYS_REFCOUNT_H__29#define __SYS_REFCOUNT_H__
3030
31#include <machine/atomic.h>31#include <sys/types.h>
3232#include <sys/kassert.h>
33#if defined(_KERNEL) || defined(_STANDALONE)33#if !defined(_KERNEL) && !defined(_STANDALONE)
34#include <sys/systm.h>
35#else
36#include <stdbool.h>34#include <stdbool.h>
37#define KASSERT(exp, msg) /* */
38#endif35#endif
3936
37#include <machine/atomic.h>
38
40#define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0)39#define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0)
41#define REFCOUNT_SATURATION_VALUE (3U << 30)40#define REFCOUNT_SATURATION_VALUE (3U << 30)
4241
...@@ -65,7 +64,7 @@ refcount_init(volatile u_int *count, u_int value)...@@ -65,7 +64,7 @@ refcount_init(volatile u_int *count, u_int value)
65}64}
6665
67static __inline u_int66static __inline u_int
68refcount_load(volatile u_int *count)67refcount_load(volatile const u_int *count)
69{68{
70 return (atomic_load_int(count));69 return (atomic_load_int(count));
71}70}
lib/libc/include/generic-freebsd/sys/resource.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)resource.h 8.4 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_RESOURCE_H_32#ifndef _SYS_RESOURCE_H_
lib/libc/include/generic-freebsd/sys/resourcevar.h+4-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_RESOURCEVAR_H_32#ifndef _SYS_RESOURCEVAR_H_
...@@ -124,6 +122,8 @@ struct uidinfo {...@@ -124,6 +122,8 @@ struct uidinfo {
124 long ui_kqcnt; /* (b) number of kqueues */122 long ui_kqcnt; /* (b) number of kqueues */
125 long ui_umtxcnt; /* (b) number of shared umtxs */123 long ui_umtxcnt; /* (b) number of shared umtxs */
126 long ui_pipecnt; /* (b) consumption of pipe buffers */124 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 */
127 uid_t ui_uid; /* (a) uid */127 uid_t ui_uid; /* (a) uid */
128 u_int ui_ref; /* (b) reference count */128 u_int ui_ref; /* (b) reference count */
129#ifdef RACCT129#ifdef RACCT
...@@ -146,6 +146,8 @@ int chgsbsize(struct uidinfo *uip, u_int *hiwat, u_int to,...@@ -146,6 +146,8 @@ int chgsbsize(struct uidinfo *uip, u_int *hiwat, u_int to,
146int chgptscnt(struct uidinfo *uip, int diff, rlim_t maxval);146int chgptscnt(struct uidinfo *uip, int diff, rlim_t maxval);
147int chgumtxcnt(struct uidinfo *uip, int diff, rlim_t maxval);147int chgumtxcnt(struct uidinfo *uip, int diff, rlim_t maxval);
148int chgpipecnt(struct uidinfo *uip, int diff, rlim_t max);148int 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);
149int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,151int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
150 struct rlimit *limp);152 struct rlimit *limp);
151struct plimit153struct plimit
lib/libc/include/generic-freebsd/sys/rman.h+14-17
...@@ -124,17 +124,18 @@ TAILQ_HEAD(rman_head, rman);...@@ -124,17 +124,18 @@ TAILQ_HEAD(rman_head, rman);
124int rman_activate_resource(struct resource *r);124int rman_activate_resource(struct resource *r);
125int rman_adjust_resource(struct resource *r, rman_res_t start, rman_res_t end);125int rman_adjust_resource(struct resource *r, rman_res_t start, rman_res_t end);
126int rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);126int rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);
127bus_space_handle_t rman_get_bushandle(struct resource *);127bus_space_handle_t rman_get_bushandle(const struct resource *);
128bus_space_tag_t rman_get_bustag(struct resource *);128bus_space_tag_t rman_get_bustag(const struct resource *);
129rman_res_t rman_get_end(struct resource *);129rman_res_t rman_get_end(const struct resource *);
130device_t rman_get_device(struct resource *);130device_t rman_get_device(const struct resource *);
131u_int rman_get_flags(struct resource *);131u_int rman_get_flags(const struct resource *);
132void *rman_get_irq_cookie(struct resource *);132void *rman_get_irq_cookie(const struct resource *);
133void rman_get_mapping(struct resource *, struct resource_map *);133void rman_get_mapping(const struct resource *, struct resource_map *);
134int rman_get_rid(struct resource *);134int rman_get_rid(const struct resource *);
135rman_res_t rman_get_size(struct resource *);135rman_res_t rman_get_size(const struct resource *);
136rman_res_t rman_get_start(struct resource *);136rman_res_t rman_get_start(const struct resource *);
137void *rman_get_virtual(struct resource *);137int rman_get_type(const struct resource *);
138void *rman_get_virtual(const struct resource *);
138int rman_deactivate_resource(struct resource *r);139int rman_deactivate_resource(struct resource *r);
139int rman_fini(struct rman *rm);140int rman_fini(struct rman *rm);
140int rman_init(struct rman *rm);141int rman_init(struct rman *rm);
...@@ -142,22 +143,18 @@ int rman_init_from_resource(struct rman *rm, struct resource *r);...@@ -142,22 +143,18 @@ int rman_init_from_resource(struct rman *rm, struct resource *r);
142int rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);143int rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);
143uint32_t rman_make_alignment_flags(uint32_t size);144uint32_t rman_make_alignment_flags(uint32_t size);
144int rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end);145int 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);
146int rman_release_resource(struct resource *r);147int rman_release_resource(struct resource *r);
147struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start,148struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start,
148 rman_res_t end, rman_res_t count,149 rman_res_t end, rman_res_t count,
149 u_int flags, device_t dev);150 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);
153void rman_set_bushandle(struct resource *_r, bus_space_handle_t _h);151void rman_set_bushandle(struct resource *_r, bus_space_handle_t _h);
154void rman_set_bustag(struct resource *_r, bus_space_tag_t _t);152void rman_set_bustag(struct resource *_r, bus_space_tag_t _t);
155void rman_set_device(struct resource *_r, device_t _dev);153void rman_set_device(struct resource *_r, device_t _dev);
156void rman_set_end(struct resource *_r, rman_res_t _end);
157void rman_set_irq_cookie(struct resource *_r, void *_c);154void rman_set_irq_cookie(struct resource *_r, void *_c);
158void rman_set_mapping(struct resource *, struct resource_map *);155void rman_set_mapping(struct resource *, struct resource_map *);
159void rman_set_rid(struct resource *_r, int _rid);156void 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);
161void rman_set_virtual(struct resource *_r, void *_v);158void rman_set_virtual(struct resource *_r, void *_v);
162159
163extern struct rman_head rman_head;160extern 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);...@@ -52,7 +52,7 @@ void rm_init(struct rmlock *rm, const char *name);
52void rm_init_flags(struct rmlock *rm, const char *name, int opts);52void rm_init_flags(struct rmlock *rm, const char *name, int opts);
53void rm_destroy(struct rmlock *rm);53void rm_destroy(struct rmlock *rm);
54int rm_wowned(const struct rmlock *rm);54int rm_wowned(const struct rmlock *rm);
55void rm_sysinit(void *arg);55void rm_sysinit(const void *arg);
5656
57void _rm_wlock_debug(struct rmlock *rm, const char *file, int line);57void _rm_wlock_debug(struct rmlock *rm, const char *file, int line);
58void _rm_wunlock_debug(struct rmlock *rm, const char *file, int line);58void _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 @@...@@ -3,6 +3,11 @@
3 *3 *
4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>4 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5 * All rights reserved.5 * 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.
6 *11 *
7 * Redistribution and use in source and binary forms, with or without12 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions13 * modification, are permitted provided that the following conditions
...@@ -29,7 +34,14 @@...@@ -29,7 +34,14 @@
29#ifndef _RUNQ_H_34#ifndef _RUNQ_H_
30#define _RUNQ_H_35#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
34struct thread;46struct thread;
3547
...@@ -37,20 +49,46 @@ struct thread;...@@ -37,20 +49,46 @@ struct thread;
37 * Run queue parameters.49 * Run queue parameters.
38 */50 */
3951
40#define RQ_NQS (64) /* Number of run queues. */52#define RQ_MAX_PRIO (255) /* Maximum priority (minimum is 0). */
41#define RQ_PPQ (4) /* Priorities per queue. */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
43/*81/*
44 * Head of run queues.82 * The queue for a given index as a list of threads.
45 */83 */
46TAILQ_HEAD(rqhead, thread);84TAILQ_HEAD(rq_queue, thread);
4785
48/*86/*
49 * Bit array which maintains the status of a run queue. When a queue is87 * Bit array which maintains the status of a run queue. When a queue is
50 * non-empty the bit corresponding to the queue number will be set.88 * non-empty the bit corresponding to the queue number will be set.
51 */89 */
52struct rqbits {90struct rq_status {
53 rqb_word_t rqb_bits[RQB_LEN];91 rqsw_t rq_sw[RQSW_NB];
54};92};
5593
56/*94/*
...@@ -58,18 +96,29 @@ struct rqbits {...@@ -58,18 +96,29 @@ struct rqbits {
58 * are placed, and a structure to maintain the status of each queue.96 * are placed, and a structure to maintain the status of each queue.
59 */97 */
60struct runq {98struct runq {
61 struct rqbits rq_status;99 struct rq_status rq_status;
62 struct rqhead rq_queues[RQ_NQS];100 struct rq_queue rq_queues[RQ_NQS];
63};101};
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);
71void runq_init(struct runq *);103void runq_init(struct runq *);
72void runq_remove(struct runq *, struct thread *);104bool runq_is_queue_empty(struct runq *, int _idx);
73void runq_remove_idx(struct runq *, struct thread *, u_char *);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
75#endif124#endif
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/rwlock.h+1-1
...@@ -128,7 +128,7 @@...@@ -128,7 +128,7 @@
128 */128 */
129void _rw_init_flags(volatile uintptr_t *c, const char *name, int opts);129void _rw_init_flags(volatile uintptr_t *c, const char *name, int opts);
130void _rw_destroy(volatile uintptr_t *c);130void _rw_destroy(volatile uintptr_t *c);
131void rw_sysinit(void *arg);131void rw_sysinit(const void *arg);
132int _rw_wowned(const volatile uintptr_t *c);132int _rw_wowned(const volatile uintptr_t *c);
133void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line);133void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line);
134int __rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF);134int __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 @@...@@ -63,6 +63,15 @@
63#define _SCHED_H_63#define _SCHED_H_
6464
65#ifdef _KERNEL65#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
66/*75/*
67 * General scheduling info.76 * General scheduling info.
68 *77 *
...@@ -74,7 +83,7 @@...@@ -74,7 +83,7 @@
74 */83 */
75int sched_load(void);84int sched_load(void);
76int sched_rr_interval(void);85int sched_rr_interval(void);
77int sched_runnable(void);86bool sched_runnable(void);
7887
79/* 88/*
80 * Proc related scheduling hooks.89 * Proc related scheduling hooks.
...@@ -214,7 +223,7 @@ SYSINIT(name, SI_SUB_LAST, SI_ORDER_MIDDLE, name ## _add_proc, NULL);...@@ -214,7 +223,7 @@ SYSINIT(name, SI_SUB_LAST, SI_ORDER_MIDDLE, name ## _add_proc, NULL);
214 SCHED_STAT_DEFINE_VAR(name, &DPCPU_NAME(name), descr)223 SCHED_STAT_DEFINE_VAR(name, &DPCPU_NAME(name), descr)
215/*224/*
216 * Sched stats are always incremented in critical sections so no atomic225 * Sched stats are always incremented in critical sections so no atomic
217 * is necesssary to increment them.226 * is necessary to increment them.
218 */227 */
219#define SCHED_STAT_INC(var) DPCPU_GET(var)++;228#define SCHED_STAT_INC(var) DPCPU_GET(var)++;
220#else229#else
lib/libc/include/generic-freebsd/sys/sdt.h+94-75
...@@ -77,8 +77,8 @@...@@ -77,8 +77,8 @@
7777
78#else /* _KERNEL */78#else /* _KERNEL */
7979
80#include <sys/cdefs.h>
81#include <sys/linker_set.h>80#include <sys/linker_set.h>
81#include <machine/sdt_machdep.h>
8282
83extern volatile bool sdt_probes_enabled;83extern volatile bool sdt_probes_enabled;
8484
...@@ -102,8 +102,6 @@ extern volatile bool sdt_probes_enabled;...@@ -102,8 +102,6 @@ extern volatile bool sdt_probes_enabled;
102#define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)102#define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
103#define SDT_PROBE_DEFINE6(prov, mod, func, name, arg0, arg1, arg2, \103#define SDT_PROBE_DEFINE6(prov, mod, func, name, arg0, arg1, arg2, \
104 arg3, arg4, arg5)104 arg3, arg4, arg5)
105#define SDT_PROBE_DEFINE7(prov, mod, func, name, arg0, arg1, arg2, \
106 arg3, arg4, arg5, arg6)
107105
108#define SDT_PROBE0(prov, mod, func, name)106#define SDT_PROBE0(prov, mod, func, name)
109#define SDT_PROBE1(prov, mod, func, name, arg0)107#define SDT_PROBE1(prov, mod, func, name, arg0)
...@@ -112,8 +110,9 @@ extern volatile bool sdt_probes_enabled;...@@ -112,8 +110,9 @@ extern volatile bool sdt_probes_enabled;
112#define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3)110#define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3)
113#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)111#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
114#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5)112#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, \113
116 arg6)114#define MIB_SDT_PROBE1(...)
115#define MIB_SDT_PROBE2(...)
117116
118#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name)117#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name)
119#define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0)118#define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0)
...@@ -127,9 +126,6 @@ extern volatile bool sdt_probes_enabled;...@@ -127,9 +126,6 @@ extern volatile bool sdt_probes_enabled;
127 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4)126 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4)
128#define SDT_PROBE_DEFINE6_XLATE(prov, mod, func, name, arg0, xarg0, \127#define SDT_PROBE_DEFINE6_XLATE(prov, mod, func, name, arg0, xarg0, \
129 arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5)128 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
134#define DTRACE_PROBE(name)130#define DTRACE_PROBE(name)
135#define DTRACE_PROBE1(name, type0, arg0)131#define DTRACE_PROBE1(name, type0, arg0)
...@@ -141,6 +137,18 @@ extern volatile bool sdt_probes_enabled;...@@ -141,6 +137,18 @@ extern volatile bool sdt_probes_enabled;
141137
142#else138#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
144#define __sdt_used152#define __sdt_used
145153
146SET_DECLARE(sdt_providers_set, struct sdt_provider);154SET_DECLARE(sdt_providers_set, struct sdt_provider);
...@@ -153,39 +161,81 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);...@@ -153,39 +161,81 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
153 sdt_provider_##prov161 sdt_provider_##prov
154162
155#define SDT_PROVIDER_DEFINE(_prov) \163#define SDT_PROVIDER_DEFINE(_prov) \
156 struct sdt_provider _SDT_PROVIDER_NAME(_prov)[1] = { \164 struct sdt_provider _SDT_PROVIDER_NAME(_prov) = { \
157 [0] = { .name = #_prov }, \165 .name = #_prov, \
158 }; \166 }; \
159 DATA_SET(sdt_providers_set, _SDT_PROVIDER_NAME(_prov))167 DATA_SET(sdt_providers_set, _SDT_PROVIDER_NAME(_prov))
160168
161#define SDT_PROVIDER_DECLARE(prov) \169#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
164#define SDT_PROBE_DEFINE(_prov, _mod, _func, _name) \172#define SDT_PROBE_DEFINE(_prov, _mod, _func, _name) \
165 struct sdt_probe _SDT_PROBE_NAME(_prov, _mod, _func, _name)[1] = { \173 struct sdt_probe _SDT_PROBE_NAME(_prov, _mod, _func, _name) = { \
166 [0] = { \174 .version = sizeof(struct sdt_probe), \
167 .version = sizeof(struct sdt_probe), \175 .prov = &_SDT_PROVIDER_NAME(_prov), \
168 .prov = _SDT_PROVIDER_NAME(_prov), \176 .mod = #_mod, \
169 .mod = #_mod, \177 .func = #_func, \
170 .func = #_func, \178 .name = #_name, \
171 .name = #_name, \
172 }, \
173 }; \179 }; \
174 DATA_SET(sdt_probes_set, _SDT_PROBE_NAME(_prov, _mod, _func, _name))180 DATA_SET(sdt_probes_set, _SDT_PROBE_NAME(_prov, _mod, _func, _name))
175181
176#define SDT_PROBE_DECLARE(prov, mod, func, name) \182#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
179#define SDT_PROBES_ENABLED() __predict_false(sdt_probes_enabled)185#define SDT_PROBES_ENABLED() __predict_false(sdt_probes_enabled)
180186
181#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \187#ifdef _ILP32
182 if (SDT_PROBES_ENABLED()) { \188#define _SDT_ASM_WORD ".long"
183 if (__predict_false(_SDT_PROBE_NAME(prov, mod, func, name)->id)) \189#else
184 (*sdt_probe_func)(_SDT_PROBE_NAME(prov, mod, func, name)->id, \190#define _SDT_ASM_WORD ".quad"
185 (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \191#endif
186 (uintptr_t) arg3, (uintptr_t) arg4); \192
187 } \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 } \
188} while (0)232} 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
190#define SDT_PROBE_ARGTYPE(_prov, _mod, _func, _name, _num, _type, _xtype) \240#define SDT_PROBE_ARGTYPE(_prov, _mod, _func, _name, _num, _type, _xtype) \
191 static struct sdt_argtype \241 static struct sdt_argtype \
...@@ -194,7 +244,7 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);...@@ -194,7 +244,7 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
194 .ndx = _num, \244 .ndx = _num, \
195 .type = _type, \245 .type = _type, \
196 .xtype = _xtype, \246 .xtype = _xtype, \
197 .probe = _SDT_PROBE_NAME(_prov, _mod, _func, _name), \247 .probe = &_SDT_PROBE_NAME(_prov, _mod, _func, _name), \
198 }, \248 }, \
199 }; \249 }; \
200 DATA_SET(sdt_argtypes_set, \250 DATA_SET(sdt_argtypes_set, \
...@@ -243,17 +293,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);...@@ -243,17 +293,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
243 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, NULL); \293 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, NULL); \
244 SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, NULL)294 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
257#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) \296#define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) \
258 SDT_PROBE_DEFINE(prov, mod, func, name)297 SDT_PROBE_DEFINE(prov, mod, func, name)
259298
...@@ -301,18 +340,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);...@@ -301,18 +340,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
301 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, xarg4); \340 SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, xarg4); \
302 SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, xarg5)341 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
316#define SDT_PROBE0(prov, mod, func, name) \343#define SDT_PROBE0(prov, mod, func, name) \
317 SDT_PROBE(prov, mod, func, name, 0, 0, 0, 0, 0)344 SDT_PROBE(prov, mod, func, name, 0, 0, 0, 0, 0)
318#define SDT_PROBE1(prov, mod, func, name, arg0) \345#define SDT_PROBE1(prov, mod, func, name, arg0) \
...@@ -325,27 +352,18 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);...@@ -325,27 +352,18 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
325 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, 0)352 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, 0)
326#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \353#define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
327 SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)354 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) \355#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \
329 do { \356 _SDT_PROBE(prov, mod, func, name, __COUNTER__, sdt_probe6, \
330 if (_SDT_PROBE_NAME(prov, mod, func, name)->id) \357 (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
331 (*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \358 (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5)
332 uintptr_t, uintptr_t, uintptr_t))sdt_probe_func)( \359
333 _SDT_PROBE_NAME(prov, mod, func, name)->id, \360#ifdef KDTRACE_MIB_SDT
334 (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \361#define MIB_SDT_PROBE1(...) SDT_PROBE1(mib, __VA_ARGS__)
335 (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5);\362#define MIB_SDT_PROBE2(...) SDT_PROBE2(mib, __VA_ARGS__)
336 } while (0)363#else
337#define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \364#define MIB_SDT_PROBE1(...)
338 arg6) \365#define MIB_SDT_PROBE2(...)
339 do { \366#endif
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)
349367
350#define DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \368#define DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \
351 static SDT_PROBE_DEFINE(sdt, , , name); \369 static SDT_PROBE_DEFINE(sdt, , , name); \
...@@ -399,12 +417,12 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);...@@ -399,12 +417,12 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
399 * way to avoid having to rely on CDDL code.417 * way to avoid having to rely on CDDL code.
400 */418 */
401typedef void (*sdt_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1,419typedef 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
404/*422/*
405 * The 'sdt' provider will set it to dtrace_probe when it loads.423 * The 'sdt' provider will set it to dtrace_probe when it loads.
406 */424 */
407extern sdt_probe_func_t sdt_probe_func;425extern sdt_probe_func_t sdt_probe_func;
408426
409struct sdt_probe;427struct sdt_probe;
410struct sdt_provider;428struct sdt_provider;
...@@ -425,6 +443,7 @@ struct sdt_probe {...@@ -425,6 +443,7 @@ struct sdt_probe {
425 TAILQ_ENTRY(sdt_probe)443 TAILQ_ENTRY(sdt_probe)
426 probe_entry; /* SDT probe list entry. */444 probe_entry; /* SDT probe list entry. */
427 TAILQ_HEAD(, sdt_argtype) argtype_list;445 TAILQ_HEAD(, sdt_argtype) argtype_list;
446 STAILQ_HEAD(, sdt_tracepoint) tracepoint_list;
428 const char *mod;447 const char *mod;
429 const char *func;448 const char *func;
430 const char *name;449 const char *name;
...@@ -442,7 +461,7 @@ struct sdt_provider {...@@ -442,7 +461,7 @@ struct sdt_provider {
442};461};
443462
444void sdt_probe_stub(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,463void sdt_probe_stub(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
445 uintptr_t);464 uintptr_t, uintptr_t);
446465
447SDT_PROVIDER_DECLARE(sdt);466SDT_PROVIDER_DECLARE(sdt);
448467
lib/libc/include/generic-freebsd/sys/select.h+29-3
...@@ -49,6 +49,12 @@ typedef __fd_mask fd_mask;...@@ -49,6 +49,12 @@ typedef __fd_mask fd_mask;
49typedef __sigset_t sigset_t;49typedef __sigset_t sigset_t;
50#endif50#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
52/*58/*
53 * Select uses bit masks of file descriptors in longs. These macros59 * Select uses bit masks of file descriptors in longs. These macros
54 * manipulate such bit fields (the filesystem macros use chars).60 * manipulate such bit fields (the filesystem macros use chars).
...@@ -75,13 +81,33 @@ typedef struct fd_set {...@@ -75,13 +81,33 @@ typedef struct fd_set {
75#define fds_bits __fds_bits81#define fds_bits __fds_bits
76#endif82#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
78#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))103#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))
80#if __BSD_VISIBLE105#if __BSD_VISIBLE
81#define FD_COPY(f, t) (void)(*(t) = *(f))106#define FD_COPY(f, t) (void)(*(t) = *(f))
82#endif107#endif
83#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)108#define FD_ISSET(n, p) \
84#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))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))
85#define FD_ZERO(p) do { \111#define FD_ZERO(p) do { \
86 fd_set *_p; \112 fd_set *_p; \
87 __size_t _n; \113 __size_t _n; \
lib/libc/include/generic-freebsd/sys/selinfo.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)select.h 8.2 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _SYS_SELINFO_H_32#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,...@@ -148,9 +148,6 @@ int kern_get_sema(struct thread *td, struct semid_kernel **res,
148#else /* !_KERNEL */148#else /* !_KERNEL */
149149
150__BEGIN_DECLS150__BEGIN_DECLS
151#if __BSD_VISIBLE
152int semsys(int, ...);
153#endif
154int semctl(int, int, int, ...);151int semctl(int, int, int, ...);
155int semget(key_t, int, int);152int semget(key_t, int, int);
156int semop(int, struct sembuf *, size_t);153int semop(int, struct sembuf *, size_t);
lib/libc/include/generic-freebsd/sys/seqc.h+2-2
...@@ -78,14 +78,14 @@ static __inline seqc_t...@@ -78,14 +78,14 @@ static __inline seqc_t
78seqc_read_any(const seqc_t *seqcp)78seqc_read_any(const seqc_t *seqcp)
79{79{
8080
81 return (atomic_load_acq_int(__DECONST(seqc_t *, seqcp)));81 return (atomic_load_acq_int(seqcp));
82}82}
8383
84static __inline seqc_t84static __inline seqc_t
85seqc_read_notmodify(const seqc_t *seqcp)85seqc_read_notmodify(const seqc_t *seqcp)
86{86{
8787
88 return (atomic_load_acq_int(__DECONST(seqc_t *, seqcp)) & ~SEQC_MOD);88 return (atomic_load_acq_int(seqcp) & ~SEQC_MOD);
89}89}
9090
91static __inline seqc_t91static __inline seqc_t
lib/libc/include/generic-freebsd/sys/sglist.h+1
...@@ -55,6 +55,7 @@ struct sglist {...@@ -55,6 +55,7 @@ struct sglist {
5555
56struct bio;56struct bio;
57struct mbuf;57struct mbuf;
58struct thread;
58struct uio;59struct uio;
5960
60static __inline void61static __inline void
lib/libc/include/generic-freebsd/sys/shm.h+1-4
...@@ -51,7 +51,7 @@...@@ -51,7 +51,7 @@
5151
52#define SHM_RDONLY 010000 /* Attach read-only (else read-write) */52#define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
53#define SHM_RND 020000 /* Round attach address to SHMLBA */53#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 */
55#define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */55#define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */
5656
57/* "official" access mode definitions; somewhat braindead since you have57/* "official" access mode definitions; somewhat braindead since you have
...@@ -173,9 +173,6 @@ typedef __size_t size_t;...@@ -173,9 +173,6 @@ typedef __size_t size_t;
173#endif173#endif
174174
175__BEGIN_DECLS175__BEGIN_DECLS
176#if __BSD_VISIBLE
177int shmsys(int, ...);
178#endif
179void *shmat(int, const void *, int);176void *shmat(int, const void *, int);
180int shmget(key_t, size_t, int);177int shmget(key_t, size_t, int);
181int shmctl(int, int, struct shmid_ds *);178int shmctl(int, int, struct shmid_ds *);
lib/libc/include/generic-freebsd/sys/sigio.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_SIGIO_H_32#ifndef _SYS_SIGIO_H_
lib/libc/include/generic-freebsd/sys/signal.h+3-27
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)signal.h 8.4 (Berkeley) 5/4/95
37 */35 */
3836
39#ifndef _SYS_SIGNAL_H_37#ifndef _SYS_SIGNAL_H_
...@@ -42,6 +40,7 @@...@@ -42,6 +40,7 @@
42#include <sys/cdefs.h>40#include <sys/cdefs.h>
43#include <sys/_types.h>41#include <sys/_types.h>
44#include <sys/_sigset.h>42#include <sys/_sigset.h>
43#include <sys/_sigaltstack.h>
45#include <sys/_sigval.h>44#include <sys/_sigval.h>
4645
47#include <machine/_limits.h> /* __MINSIGSTKSZ */46#include <machine/_limits.h> /* __MINSIGSTKSZ */
...@@ -255,7 +254,7 @@ typedef struct __siginfo {...@@ -255,7 +254,7 @@ typedef struct __siginfo {
255#define si_syscall _reason._capsicum._syscall254#define si_syscall _reason._capsicum._syscall
256255
257#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__))256#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__))
258struct siginfo32 {257struct __siginfo32 {
259 int si_signo; /* signal number */258 int si_signo; /* signal number */
260 int si_errno; /* errno association */259 int si_errno; /* errno association */
261 int si_code; /* signal code */260 int si_code; /* signal code */
...@@ -373,7 +372,7 @@ struct sigaction {...@@ -373,7 +372,7 @@ struct sigaction {
373#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */372#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
374#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */373#endif /* __POSIX_VISIBLE || __XSI_VISIBLE */
375374
376#if __XSI_VISIBLE375#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
377#define SA_ONSTACK 0x0001 /* take signal on signal stack */376#define SA_ONSTACK 0x0001 /* take signal on signal stack */
378#define SA_RESTART 0x0002 /* restart system call on signal return */377#define SA_RESTART 0x0002 /* restart system call on signal return */
379#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */378#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 */...@@ -408,29 +407,6 @@ typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
408typedef void __siginfohandler_t(int, struct __siginfo *, void *);407typedef void __siginfohandler_t(int, struct __siginfo *, void *);
409#endif408#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
434#if __BSD_VISIBLE410#if __BSD_VISIBLE
435/*411/*
436 * 4.3 compatibility:412 * 4.3 compatibility:
lib/libc/include/generic-freebsd/sys/signalvar.h+2-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)signalvar.h 8.6 (Berkeley) 2/19/95
32 */30 */
3331
34#ifndef _SYS_SIGNALVAR_H_32#ifndef _SYS_SIGNALVAR_H_
...@@ -272,6 +270,7 @@ int __sys_sigfastblock(int cmd, void *ptr);...@@ -272,6 +270,7 @@ int __sys_sigfastblock(int cmd, void *ptr);
272270
273#ifdef _KERNEL271#ifdef _KERNEL
274extern bool sigfastblock_fetch_always;272extern bool sigfastblock_fetch_always;
273extern bool pt_attach_transparent;
275274
276/* Return nonzero if process p has an unmasked pending signal. */275/* Return nonzero if process p has an unmasked pending signal. */
277#define SIGPENDING(td) \276#define SIGPENDING(td) \
...@@ -404,6 +403,7 @@ int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **);...@@ -404,6 +403,7 @@ int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **);
404void sigfastblock_clear(struct thread *td);403void sigfastblock_clear(struct thread *td);
405void sigfastblock_fetch(struct thread *td);404void sigfastblock_fetch(struct thread *td);
406int sig_intr(void);405int sig_intr(void);
406bool sig_do_core(int);
407void siginit(struct proc *p);407void siginit(struct proc *p);
408void signotify(struct thread *td);408void signotify(struct thread *td);
409void sigqueue_delete(struct sigqueue *queue, int sig);409void sigqueue_delete(struct sigqueue *queue, int sig);
lib/libc/include/generic-freebsd/sys/sleepqueue.h+4-4
...@@ -86,21 +86,21 @@ struct thread;...@@ -86,21 +86,21 @@ struct thread;
86#define SLEEPQ_DROP 0x400 /* Return without lock held. */86#define SLEEPQ_DROP 0x400 /* Return without lock held. */
8787
88void init_sleepqueues(void);88void init_sleepqueues(void);
89int sleepq_abort(struct thread *td, int intrval);89void sleepq_abort(struct thread *td, int intrval);
90void sleepq_add(const void *wchan, struct lock_object *lock,90void sleepq_add(const void *wchan, struct lock_object *lock,
91 const char *wmesg, int flags, int queue);91 const char *wmesg, int flags, int queue);
92struct sleepqueue *sleepq_alloc(void);92struct 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);
94void sleepq_chains_remove_matching(bool (*matches)(struct thread *));94void sleepq_chains_remove_matching(bool (*matches)(struct thread *));
95void sleepq_free(struct sleepqueue *sq);95void sleepq_free(struct sleepqueue *sq);
96void sleepq_lock(const void *wchan);96void sleepq_lock(const void *wchan);
97struct sleepqueue *sleepq_lookup(const void *wchan);97struct sleepqueue *sleepq_lookup(const void *wchan);
98void sleepq_release(const void *wchan);98void sleepq_release(const void *wchan);
99void sleepq_remove(struct thread *td, const void *wchan);99void 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,
101 bool (*matches)(struct thread *), int pri);101 bool (*matches)(struct thread *), int pri);
102void sleepq_remove_nested(struct thread *td);102void 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);
104void sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt,104void sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt,
105 sbintime_t pr, int flags);105 sbintime_t pr, int flags);
106#define sleepq_set_timeout(wchan, timo) \106#define sleepq_set_timeout(wchan, timo) \
lib/libc/include/generic-freebsd/sys/smr_types.h+4-2
...@@ -60,7 +60,8 @@ struct { \...@@ -60,7 +60,8 @@ struct { \
60 */60 */
61#define smr_entered_load(p, smr) ({ \61#define smr_entered_load(p, smr) ({ \
62 SMR_ASSERT(SMR_ENTERED((smr)), "smr_entered_load"); \62 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); \
64})65})
6566
66/*67/*
...@@ -70,7 +71,8 @@ struct { \...@@ -70,7 +71,8 @@ struct { \
70 */71 */
71#define smr_serialized_load(p, ex) ({ \72#define smr_serialized_load(p, ex) ({ \
72 SMR_ASSERT(ex, "smr_serialized_load"); \73 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); \
74})76})
7577
76/*78/*
lib/libc/include/generic-freebsd/sys/sndstat.h+2
...@@ -94,12 +94,14 @@ struct sndstioc_nv_arg {...@@ -94,12 +94,14 @@ struct sndstioc_nv_arg {
94#define SNDST_DSPS_SOUND4_CHAN_LEFTVOL "left_volume"94#define SNDST_DSPS_SOUND4_CHAN_LEFTVOL "left_volume"
95#define SNDST_DSPS_SOUND4_CHAN_RIGHTVOL "right_volume"95#define SNDST_DSPS_SOUND4_CHAN_RIGHTVOL "right_volume"
96#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT "hwbuf_format"96#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT "hwbuf_format"
97#define SNDST_DSPS_SOUND4_CHAN_HWBUF_RATE "hwbuf_rate"
97#define SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE "hwbuf_size"98#define SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE "hwbuf_size"
98#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ "hwbuf_blksz"99#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ "hwbuf_blksz"
99#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT "hwbuf_blkcnt"100#define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT "hwbuf_blkcnt"
100#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE "hwbuf_free"101#define SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE "hwbuf_free"
101#define SNDST_DSPS_SOUND4_CHAN_HWBUF_READY "hwbuf_ready"102#define SNDST_DSPS_SOUND4_CHAN_HWBUF_READY "hwbuf_ready"
102#define SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT "swbuf_format"103#define SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT "swbuf_format"
104#define SNDST_DSPS_SOUND4_CHAN_SWBUF_RATE "swbuf_rate"
103#define SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE "swbuf_size"105#define SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE "swbuf_size"
104#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ "swbuf_blksz"106#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ "swbuf_blksz"
105#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT "swbuf_blkcnt"107#define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT "swbuf_blkcnt"
lib/libc/include/generic-freebsd/sys/sockbuf.h+21-10
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
32 */30 */
33#ifndef _SYS_SOCKBUF_H_31#ifndef _SYS_SOCKBUF_H_
34#define _SYS_SOCKBUF_H_32#define _SYS_SOCKBUF_H_
...@@ -42,13 +40,13 @@...@@ -42,13 +40,13 @@
42#define SB_SEL 0x08 /* someone is selecting */40#define SB_SEL 0x08 /* someone is selecting */
43#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */41#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
44#define SB_UPCALL 0x20 /* someone wants an upcall */42#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 */
46#define SB_AIO 0x80 /* AIO operations queued */44#define SB_AIO 0x80 /* AIO operations queued */
47#define SB_KNOTE 0x100 /* kernel note attached */45#define SB_KNOTE 0x100 /* kernel note attached */
48#define SB_NOCOALESCE 0x200 /* don't coalesce new data into existing mbufs */46#define SB_NOCOALESCE 0x200 /* don't coalesce new data into existing mbufs */
49#define SB_IN_TOE 0x400 /* socket buffer is in the middle of an operation */47#define SB_IN_TOE 0x400 /* socket buffer is in the middle of an operation */
50#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */48#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */
51#define SB_STOP 0x1000 /* backpressure indicator */49/* was SB_STOP 0x1000 */
52#define SB_AIO_RUNNING 0x2000 /* AIO operation running */50#define SB_AIO_RUNNING 0x2000 /* AIO operation running */
53#define SB_SPLICED 0x4000 /* socket buffer is spliced;51#define SB_SPLICED 0x4000 /* socket buffer is spliced;
54 previously used for SB_TLS_IFNET */52 previously used for SB_TLS_IFNET */
...@@ -64,7 +62,7 @@...@@ -64,7 +62,7 @@
64#include <sys/_sx.h>62#include <sys/_sx.h>
65#include <sys/_task.h>63#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
69struct ktls_session;67struct ktls_session;
70struct mbuf;68struct mbuf;
...@@ -134,6 +132,18 @@ struct sockbuf {...@@ -134,6 +132,18 @@ struct sockbuf {
134 /* TLS state, locked by sockbuf and sock I/O mutexes. */132 /* TLS state, locked by sockbuf and sock I/O mutexes. */
135 struct ktls_session *sb_tls_info;133 struct ktls_session *sb_tls_info;
136 };134 };
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 };
137 /*147 /*
138 * PF_UNIX/SOCK_DGRAM148 * PF_UNIX/SOCK_DGRAM
139 *149 *
...@@ -167,6 +177,12 @@ struct sockbuf {...@@ -167,6 +177,12 @@ struct sockbuf {
167 u_int uxdg_ctl;177 u_int uxdg_ctl;
168 u_int uxdg_mbcnt;178 u_int uxdg_mbcnt;
169 };179 };
180 /*
181 * Netlink socket.
182 */
183 struct {
184 TAILQ_HEAD(, nl_buf) nl_queue;
185 };
170 };186 };
171};187};
172188
...@@ -194,8 +210,6 @@ typedef enum { SO_RCV, SO_SND } sb_which;...@@ -194,8 +210,6 @@ typedef enum { SO_RCV, SO_SND } sb_which;
194 * Socket buffer private mbuf(9) flags.210 * Socket buffer private mbuf(9) flags.
195 */211 */
196#define M_NOTREADY M_PROTO1 /* m_data not populated yet */212#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
200void sbappend(struct sockbuf *sb, struct mbuf *m, int flags);214void sbappend(struct sockbuf *sb, struct mbuf *m, int flags);
201void sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags);215void sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags);
...@@ -287,9 +301,6 @@ sbspace(struct sockbuf *sb)...@@ -287,9 +301,6 @@ sbspace(struct sockbuf *sb)
287 SOCKBUF_LOCK_ASSERT(sb);301 SOCKBUF_LOCK_ASSERT(sb);
288#endif302#endif
289303
290 if (sb->sb_flags & SB_STOP)
291 return(0);
292
293 bleft = sb->sb_hiwat - sb->sb_ccc;304 bleft = sb->sb_hiwat - sb->sb_ccc;
294 mleft = sb->sb_mbmax - sb->sb_mbcnt;305 mleft = sb->sb_mbmax - sb->sb_mbcnt;
295306
lib/libc/include/generic-freebsd/sys/socket.h+23-40
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)socket.h 8.4 (Berkeley) 2/21/94
32 */30 */
3331
34#ifndef _SYS_SOCKET_H_32#ifndef _SYS_SOCKET_H_
...@@ -113,10 +111,11 @@ typedef __uintptr_t uintptr_t;...@@ -113,10 +111,11 @@ typedef __uintptr_t uintptr_t;
113 */111 */
114#define SOCK_CLOEXEC 0x10000000112#define SOCK_CLOEXEC 0x10000000
115#define SOCK_NONBLOCK 0x20000000113#define SOCK_NONBLOCK 0x20000000
114#define SOCK_CLOFORK 0x40000000
116#ifdef _KERNEL115#ifdef _KERNEL
117/*116/*
118 * Flags for accept1(), kern_accept4() and solisten_dequeue, in addition117 * 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.
120 */119 */
121#define ACCEPT4_INHERIT 0x1120#define ACCEPT4_INHERIT 0x1
122#define ACCEPT4_COMPAT 0x2121#define ACCEPT4_COMPAT 0x2
...@@ -166,17 +165,18 @@ typedef __uintptr_t uintptr_t;...@@ -166,17 +165,18 @@ typedef __uintptr_t uintptr_t;
166#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */165#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */
167#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */166#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */
168#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */167#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 */
170#define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */170#define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */
171#define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */171#define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */
172#define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */172#define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */
173#define SO_TS_CLOCK 0x1017 /* clock type used for SO_TIMESTAMP */173#define SO_TS_CLOCK 0x1017 /* clock type used for SO_TIMESTAMP */
174#define SO_MAX_PACING_RATE 0x1018 /* socket's max TX pacing rate (Linux name) */174#define SO_MAX_PACING_RATE 0x1018 /* socket's max TX pacing rate (Linux name) */
175#define SO_DOMAIN 0x1019 /* get socket domain */175#define SO_DOMAIN 0x1019 /* get socket domain */
176#define SO_SPLICE 0x1023 /* splice data to other socket */
176#endif177#endif
177178
178#if __BSD_VISIBLE179#if __BSD_VISIBLE
179#define SO_SPLICE 0x1023 /* splice data to other socket */
180#define SO_TS_REALTIME_MICRO 0 /* microsecond resolution, realtime */180#define SO_TS_REALTIME_MICRO 0 /* microsecond resolution, realtime */
181#define SO_TS_BINTIME 1 /* sub-nanosecond resolution, realtime */181#define SO_TS_BINTIME 1 /* sub-nanosecond resolution, realtime */
182#define SO_TS_REALTIME 2 /* nanosecond resolution, realtime */182#define SO_TS_REALTIME 2 /* nanosecond resolution, realtime */
...@@ -270,7 +270,8 @@ struct accept_filter_arg {...@@ -270,7 +270,8 @@ struct accept_filter_arg {
270#define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */270#define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */
271#define AF_HYPERV 43 /* HyperV sockets */271#define AF_HYPERV 43 /* HyperV sockets */
272#define AF_DIVERT 44 /* divert(4) */272#define AF_DIVERT 44 /* divert(4) */
273#define AF_MAX 44273#define AF_IPFWLOG 46
274#define AF_MAX 46
274/*275/*
275 * When allocating a new AF_ constant, please only allocate276 * When allocating a new AF_ constant, please only allocate
276 * even numbered constants for FreeBSD until 134 as odd numbered AF_277 * even numbered constants for FreeBSD until 134 as odd numbered AF_
...@@ -396,6 +397,7 @@ struct sockproto {...@@ -396,6 +397,7 @@ struct sockproto {
396#define PF_INET_SDP AF_INET_SDP397#define PF_INET_SDP AF_INET_SDP
397#define PF_INET6_SDP AF_INET6_SDP398#define PF_INET6_SDP AF_INET6_SDP
398#define PF_DIVERT AF_DIVERT399#define PF_DIVERT AF_DIVERT
400#define PF_IPFWLOG AF_IPFWLOG
399401
400#define PF_MAX AF_MAX402#define PF_MAX AF_MAX
401403
...@@ -477,6 +479,9 @@ struct msghdr {...@@ -477,6 +479,9 @@ struct msghdr {
477#define MSG_MORETOCOME 0x00100000 /* additional data pending */479#define MSG_MORETOCOME 0x00100000 /* additional data pending */
478#define MSG_TLSAPPDATA 0x00200000 /* do not soreceive() alert rec. (TLS) */480#define MSG_TLSAPPDATA 0x00200000 /* do not soreceive() alert rec. (TLS) */
479#endif481#endif
482#if __BSD_VISIBLE
483#define MSG_CMSG_CLOFORK 0x00400000 /* make received fds close-on-fork */
484#endif
480485
481/*486/*
482 * Header for ancillary data objects in msg_control buffer.487 * Header for ancillary data objects in msg_control buffer.
...@@ -631,17 +636,14 @@ struct omsghdr {...@@ -631,17 +636,14 @@ struct omsghdr {
631/*636/*
632 * howto arguments for shutdown(2), specified by Posix.1g.637 * howto arguments for shutdown(2), specified by Posix.1g.
633 */638 */
634#define SHUT_RD 0 /* shut down the reading side */639enum shutdown_how {
635#define SHUT_WR 1 /* shut down the writing side */640 SHUT_RD = 0, /* shut down the reading side */
636#define SHUT_RDWR 2 /* shut down both sides */641#define SHUT_RD SHUT_RD
637642 SHUT_WR, /* shut down the writing side */
638#if __BSD_VISIBLE643#define SHUT_WR SHUT_WR
639/* for SCTP */644 SHUT_RDWR /* shut down both sides */
640/* we cheat and use the SHUT_XX defines for these */645#define SHUT_RDWR SHUT_RDWR
641#define PRU_FLUSH_RD SHUT_RD646};
642#define PRU_FLUSH_WR SHUT_WR
643#define PRU_FLUSH_RDWR SHUT_RDWR
644#endif
645647
646#if __BSD_VISIBLE648#if __BSD_VISIBLE
647/*649/*
...@@ -689,6 +691,10 @@ struct splice {...@@ -689,6 +691,10 @@ struct splice {
689691
690#ifndef _KERNEL692#ifndef _KERNEL
691693
694#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
695#include <ssp/socket.h>
696#endif
697
692#include <sys/cdefs.h>698#include <sys/cdefs.h>
693699
694__BEGIN_DECLS700__BEGIN_DECLS
...@@ -733,33 +739,10 @@ __END_DECLS...@@ -733,33 +739,10 @@ __END_DECLS
733#ifdef _KERNEL739#ifdef _KERNEL
734struct socket;740struct 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
743int so_options_get(const struct socket *);742int so_options_get(const struct socket *);
744void so_options_set(struct socket *, int);743void so_options_set(struct socket *, int);
745744
746int so_error_get(const struct socket *);745int so_error_get(const struct socket *);
747void so_error_set(struct socket *, int);746void 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
764#endif /* _KERNEL */747#endif /* _KERNEL */
765#endif /* !_SYS_SOCKET_H_ */748#endif /* !_SYS_SOCKET_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/socketvar.h+22-17
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
32 */30 */
3331
34#ifndef _SYS_SOCKETVAR_H_32#ifndef _SYS_SOCKETVAR_H_
...@@ -82,6 +80,7 @@ struct so_splice {...@@ -82,6 +80,7 @@ struct so_splice {
82 struct mtx mtx;80 struct mtx mtx;
83 unsigned int wq_index;81 unsigned int wq_index;
84 enum so_splice_state {82 enum so_splice_state {
83 SPLICE_INIT, /* embryonic state, don't queue work yet */
85 SPLICE_IDLE, /* waiting for work to arrive */84 SPLICE_IDLE, /* waiting for work to arrive */
86 SPLICE_QUEUED, /* a wakeup has queued some work */85 SPLICE_QUEUED, /* a wakeup has queued some work */
87 SPLICE_RUNNING, /* currently transferring data */86 SPLICE_RUNNING, /* currently transferring data */
...@@ -239,7 +238,7 @@ struct socket {...@@ -239,7 +238,7 @@ struct socket {
239#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */238#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
240#define SS_NBIO 0x0100 /* non-blocking ops */239#define SS_NBIO 0x0100 /* non-blocking ops */
241#define SS_ASYNC 0x0200 /* async i/o notify */240#define SS_ASYNC 0x0200 /* async i/o notify */
242#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */241/* was SS_ISCONFIRMING 0x0400 */
243#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */242#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
244243
245#ifdef _KERNEL244#ifdef _KERNEL
...@@ -343,16 +342,14 @@ soeventmtx(struct socket *so, const sb_which which)...@@ -343,16 +342,14 @@ soeventmtx(struct socket *so, const sb_which which)
343 soiolock((so), &(so)->so_snd_sx, (flags))342 soiolock((so), &(so)->so_snd_sx, (flags))
344#define SOCK_IO_SEND_UNLOCK(so) \343#define SOCK_IO_SEND_UNLOCK(so) \
345 soiounlock(&(so)->so_snd_sx)344 soiounlock(&(so)->so_snd_sx)
346#define SOCK_IO_SEND_OWNED(so) sx_xlocked(&(so)->so_snd_sx)
347#define SOCK_IO_SEND_ASSERT_LOCKED(so) \345#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)
349#define SOCK_IO_RECV_LOCK(so, flags) \347#define SOCK_IO_RECV_LOCK(so, flags) \
350 soiolock((so), &(so)->so_rcv_sx, (flags))348 soiolock((so), &(so)->so_rcv_sx, (flags))
351#define SOCK_IO_RECV_UNLOCK(so) \349#define SOCK_IO_RECV_UNLOCK(so) \
352 soiounlock(&(so)->so_rcv_sx)350 soiounlock(&(so)->so_rcv_sx)
353#define SOCK_IO_RECV_OWNED(so) sx_xlocked(&(so)->so_rcv_sx)
354#define SOCK_IO_RECV_ASSERT_LOCKED(so) \351#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
357/* do we have to send all at once on a socket? */354/* do we have to send all at once on a socket? */
358#define sosendallatonce(so) \355#define sosendallatonce(so) \
...@@ -459,7 +456,8 @@ MALLOC_DECLARE(M_SONAME);...@@ -459,7 +456,8 @@ MALLOC_DECLARE(M_SONAME);
459#define HHOOK_FILT_SOREAD 4456#define HHOOK_FILT_SOREAD 4
460#define HHOOK_FILT_SOWRITE 5457#define HHOOK_FILT_SOWRITE 5
461#define HHOOK_SOCKET_CLOSE 6458#define HHOOK_SOCKET_CLOSE 6
462#define HHOOK_SOCKET_LAST HHOOK_SOCKET_CLOSE459#define HHOOK_SOCKET_NEWCONN 7
460#define HHOOK_SOCKET_LAST HHOOK_SOCKET_NEWCONN
463461
464struct socket_hhook_data {462struct socket_hhook_data {
465 struct socket *so;463 struct socket *so;
...@@ -479,6 +477,7 @@ struct mbuf;...@@ -479,6 +477,7 @@ struct mbuf;
479struct sockaddr;477struct sockaddr;
480struct ucred;478struct ucred;
481struct uio;479struct uio;
480enum shutdown_how;
482481
483/* Return values for socket upcalls. */482/* Return values for socket upcalls. */
484#define SU_OK 0483#define SU_OK 0
...@@ -489,12 +488,14 @@ struct uio;...@@ -489,12 +488,14 @@ struct uio;
489 */488 */
490int getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr,489int getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr,
491 size_t len);490 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,
493 struct file **fpp, struct filecaps *havecaps);492 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,
495 struct file **fpp);494 struct file **fpp);
496void soabort(struct socket *so);495void 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);
498void soaio_enqueue(struct task *task);499void soaio_enqueue(struct task *task);
499void soaio_rcv(void *context, int pending);500void soaio_rcv(void *context, int pending);
500void soaio_snd(void *context, int pending);501void soaio_snd(void *context, int pending);
...@@ -525,10 +526,9 @@ struct socket *...@@ -525,10 +526,9 @@ struct socket *
525 sonewconn(struct socket *head, int connstatus);526 sonewconn(struct socket *head, int connstatus);
526struct socket *527struct socket *
527 sopeeloff(struct socket *);528 sopeeloff(struct socket *);
528int sopoll(struct socket *so, int events, struct ucred *active_cred,529int sopoll_generic(struct socket *so, int events, struct thread *td);
529 struct thread *td);530int sokqfilter_generic(struct socket *so, struct knote *kn);
530int sopoll_generic(struct socket *so, int events,531int soaio_queue_generic(struct socket *so, struct kaiocb *job);
531 struct ucred *active_cred, struct thread *td);
532int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,532int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
533 struct mbuf **mp0, struct mbuf **controlp, int *flagsp);533 struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
534int soreceive_stream(struct socket *so, struct sockaddr **paddr,534int soreceive_stream(struct socket *so, struct sockaddr **paddr,
...@@ -555,7 +555,9 @@ int sosend_dgram(struct socket *so, struct sockaddr *addr,...@@ -555,7 +555,9 @@ int sosend_dgram(struct socket *so, struct sockaddr *addr,
555int sosend_generic(struct socket *so, struct sockaddr *addr,555int sosend_generic(struct socket *so, struct sockaddr *addr,
556 struct uio *uio, struct mbuf *top, struct mbuf *control,556 struct uio *uio, struct mbuf *top, struct mbuf *control,
557 int flags, struct thread *td);557 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);
559void soupcall_clear(struct socket *, sb_which);561void soupcall_clear(struct socket *, sb_which);
560void soupcall_set(struct socket *, sb_which, so_upcall_t, void *);562void soupcall_set(struct socket *, sb_which, so_upcall_t, void *);
561void solisten_upcall_set(struct socket *, so_upcall_t, void *);563void solisten_upcall_set(struct socket *, so_upcall_t, void *);
...@@ -596,6 +598,8 @@ SYSCTL_DECL(_net_inet_accf);...@@ -596,6 +598,8 @@ SYSCTL_DECL(_net_inet_accf);
596int accept_filt_generic_mod_event(module_t mod, int event, void *data);598int accept_filt_generic_mod_event(module_t mod, int event, void *data);
597#endif599#endif
598600
601int pr_listen_notsupp(struct socket *so, int backlog, struct thread *td);
602
599#endif /* _KERNEL */603#endif /* _KERNEL */
600604
601/*605/*
...@@ -615,7 +619,8 @@ struct xsocket {...@@ -615,7 +619,8 @@ struct xsocket {
615 uint32_t so_qlimit;619 uint32_t so_qlimit;
616 pid_t so_pgid;620 pid_t so_pgid;
617 uid_t so_uid;621 uid_t so_uid;
618 int32_t so_spare32[8];622 int32_t so_fibnum;
623 int32_t so_spare32[7];
619 int16_t so_type;624 int16_t so_type;
620 int16_t so_options;625 int16_t so_options;
621 int16_t so_linger;626 int16_t so_linger;
lib/libc/include/generic-freebsd/sys/sockio.h+4-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)sockio.h 8.1 (Berkeley) 3/28/94
32 */30 */
3331
34#ifndef _SYS_SOCKIO_H_32#ifndef _SYS_SOCKIO_H_
...@@ -149,4 +147,8 @@...@@ -149,4 +147,8 @@
149#define SIOCSIFCAPNV _IOW('i', 155, struct ifreq) /* set IF features */147#define SIOCSIFCAPNV _IOW('i', 155, struct ifreq) /* set IF features */
150#define SIOCGIFCAPNV _IOWR('i', 156, struct ifreq) /* get IF features */148#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
152#endif /* !_SYS_SOCKIO_H_ */154#endif /* !_SYS_SOCKIO_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/sockopt.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
32 */30 */
33#ifndef _SYS_SOCKOPT_H_31#ifndef _SYS_SOCKOPT_H_
34#define _SYS_SOCKOPT_H_32#define _SYS_SOCKOPT_H_
lib/libc/include/generic-freebsd/sys/soundcard.h+11-2
...@@ -184,6 +184,8 @@ struct snd_size {...@@ -184,6 +184,8 @@ struct snd_size {
184#define AFMT_S24_BE 0x00020000 /* Big endian signed 24-bit */184#define AFMT_S24_BE 0x00020000 /* Big endian signed 24-bit */
185#define AFMT_U24_LE 0x00040000 /* Little endian unsigned 24-bit */185#define AFMT_U24_LE 0x00040000 /* Little endian unsigned 24-bit */
186#define AFMT_U24_BE 0x00080000 /* Big endian unsigned 24-bit */186#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
188/* Machine dependent AFMT_* definitions. */190/* Machine dependent AFMT_* definitions. */
189#if BYTE_ORDER == LITTLE_ENDIAN191#if BYTE_ORDER == LITTLE_ENDIAN
...@@ -199,6 +201,8 @@ struct snd_size {...@@ -199,6 +201,8 @@ struct snd_size {
199#define AFMT_U16_OE AFMT_U16_BE201#define AFMT_U16_OE AFMT_U16_BE
200#define AFMT_U24_OE AFMT_U24_BE202#define AFMT_U24_OE AFMT_U24_BE
201#define AFMT_U32_OE AFMT_U32_BE203#define AFMT_U32_OE AFMT_U32_BE
204#define AFMT_F32_NE AFMT_F32_LE
205#define AFMT_F32_OE AFMT_F32_BE
202#else206#else
203#define AFMT_S16_OE AFMT_S16_LE207#define AFMT_S16_OE AFMT_S16_LE
204#define AFMT_S24_OE AFMT_S24_LE208#define AFMT_S24_OE AFMT_S24_LE
...@@ -212,8 +216,12 @@ struct snd_size {...@@ -212,8 +216,12 @@ struct snd_size {
212#define AFMT_U16_NE AFMT_U16_BE216#define AFMT_U16_NE AFMT_U16_BE
213#define AFMT_U24_NE AFMT_U24_BE217#define AFMT_U24_NE AFMT_U24_BE
214#define AFMT_U32_NE AFMT_U32_BE218#define AFMT_U32_NE AFMT_U32_BE
219#define AFMT_F32_NE AFMT_F32_BE
220#define AFMT_F32_OE AFMT_F32_LE
215#endif221#endif
216222
223#define AFMT_FLOAT AFMT_F32_NE /* compatibility alias */
224
217#define AFMT_STEREO 0x10000000 /* can do/want stereo */225#define AFMT_STEREO 0x10000000 /* can do/want stereo */
218226
219/*227/*
...@@ -1400,8 +1408,9 @@ void seqbuf_dump(void); /* This function must be provided by programs */...@@ -1400,8 +1408,9 @@ void seqbuf_dump(void); /* This function must be provided by programs */
1400 int i, l=(len); if (l>6)l=6;\1408 int i, l=(len); if (l>6)l=6;\
1401 _SEQ_NEEDBUF(8);\1409 _SEQ_NEEDBUF(8);\
1402 _seqbuf[_seqbufptr] = EV_SYSEX;\1410 _seqbuf[_seqbufptr] = EV_SYSEX;\
1403 for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\1411 _seqbuf[_seqbufptr+1] = (dev);\
1404 for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\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;\
1405 _SEQ_ADVBUF(8);}1414 _SEQ_ADVBUF(8);}
14061415
1407#define SEQ_CHN_PRESSURE(dev, chn, pressure) \1416#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
lib/libc/include/generic-freebsd/sys/specialfd.h+5
...@@ -30,6 +30,7 @@...@@ -30,6 +30,7 @@
3030
31enum specialfd_type {31enum specialfd_type {
32 SPECIALFD_EVENTFD = 1,32 SPECIALFD_EVENTFD = 1,
33 SPECIALFD_INOTIFY = 2,
33};34};
3435
35struct specialfd_eventfd {36struct specialfd_eventfd {
...@@ -37,4 +38,8 @@ struct specialfd_eventfd {...@@ -37,4 +38,8 @@ struct specialfd_eventfd {
37 int flags;38 int flags;
38};39};
3940
41struct specialfd_inotify {
42 int flags;
43};
44
40#endif /* !_SYS_SPECIALFD_H_ */45#endif /* !_SYS_SPECIALFD_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/stat.h+6-4
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)stat.h 8.12 (Berkeley) 6/16/95
37 */35 */
3836
39#ifndef _SYS_STAT_H_37#ifndef _SYS_STAT_H_
...@@ -161,7 +159,7 @@ struct stat {...@@ -161,7 +159,7 @@ struct stat {
161 ino_t st_ino; /* inode's number */159 ino_t st_ino; /* inode's number */
162 nlink_t st_nlink; /* number of hard links */160 nlink_t st_nlink; /* number of hard links */
163 mode_t st_mode; /* inode protection mode */161 mode_t st_mode; /* inode protection mode */
164 __int16_t st_padding0;162 __int16_t st_bsdflags; /* misc system flags */
165 uid_t st_uid; /* user ID of the file's owner */163 uid_t st_uid; /* user ID of the file's owner */
166 gid_t st_gid; /* group ID of the file's group */164 gid_t st_gid; /* group ID of the file's group */
167 __int32_t st_padding1;165 __int32_t st_padding1;
...@@ -187,7 +185,8 @@ struct stat {...@@ -187,7 +185,8 @@ struct stat {
187 blksize_t st_blksize; /* optimal blocksize for I/O */185 blksize_t st_blksize; /* optimal blocksize for I/O */
188 fflags_t st_flags; /* user defined flags for file */186 fflags_t st_flags; /* user defined flags for file */
189 __uint64_t st_gen; /* file generation number */187 __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];
191};190};
192191
193#ifdef _KERNEL192#ifdef _KERNEL
...@@ -341,6 +340,9 @@ struct nstat {...@@ -341,6 +340,9 @@ struct nstat {
341#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */340#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
342#define SF_SNAPSHOT 0x00200000 /* snapshot inode */341#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
343342
343/* st_bsdflags */
344#define SFBSD_NAMEDATTR 0x0001 /* file is named attribute or dir */
345
344#ifdef _KERNEL346#ifdef _KERNEL
345/*347/*
346 * Shorthand abbreviations of above.348 * 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 @@...@@ -33,7 +33,8 @@
33#include <sys/cdefs.h>33#include <sys/cdefs.h>
34#include <sys/_types.h>34#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__)
37#define __CLANG_ATOMICS38#define __CLANG_ATOMICS
38#elif __GNUC_PREREQ__(4, 7)39#elif __GNUC_PREREQ__(4, 7)
39#define __GNUC_ATOMICS40#define __GNUC_ATOMICS
lib/libc/include/generic-freebsd/sys/sx.h+7-7
...@@ -99,7 +99,7 @@...@@ -99,7 +99,7 @@
99 * Function prototipes. Routines that start with an underscore are not part99 * Function prototipes. Routines that start with an underscore are not part
100 * of the public interface and are wrappered with a macro.100 * of the public interface and are wrappered with a macro.
101 */101 */
102void sx_sysinit(void *arg);102void sx_sysinit(const void *arg);
103#define sx_init(sx, desc) sx_init_flags((sx), (desc), 0)103#define sx_init(sx, desc) sx_init_flags((sx), (desc), 0)
104void sx_init_flags(struct sx *sx, const char *description, int opts);104void sx_init_flags(struct sx *sx, const char *description, int opts);
105void sx_destroy(struct sx *sx);105void sx_destroy(struct sx *sx);
...@@ -301,12 +301,12 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line)...@@ -301,12 +301,12 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line)
301301
302#ifdef _STANDALONE302#ifdef _STANDALONE
303/* since we have no threads in the boot loader, trivially implement no-op version */303/* since we have no threads in the boot loader, trivially implement no-op version */
304#define sx_xlock(s) (1)304#define sx_xlock(s) do {} while (0)
305#define sx_try_xlock(s) (1)305#define sx_try_xlock(s) (1)
306#define sx_xunlock(s) (1)306#define sx_xunlock(s) do {} while (0)
307#define SX_DUPOK 0307#define SX_DUPOK 0
308#define SX_NEW 0308#define SX_NEW 0
309#define SX_NOWITNESS 0309#define SX_NOWITNESS 0
310310
311static __inline void311static __inline void
312sx_init_flags(struct sx *sx, const char *description, int opts)312sx_init_flags(struct sx *sx, const char *description, int opts)
lib/libc/include/generic-freebsd/sys/syscall.h+18-7
...@@ -4,8 +4,10 @@...@@ -4,8 +4,10 @@
4 * DO NOT EDIT-- this file is automatically @generated.4 * DO NOT EDIT-- this file is automatically @generated.
5 */5 */
66
7#define SYS_exit SYS__exit
8
7#define SYS_syscall 09#define SYS_syscall 0
8#define SYS_exit 110#define SYS__exit 1
9#define SYS_fork 211#define SYS_fork 2
10#define SYS_read 312#define SYS_read 3
11#define SYS_write 413#define SYS_write 4
...@@ -73,8 +75,8 @@...@@ -73,8 +75,8 @@
73#define SYS_vfork 6675#define SYS_vfork 66
74 /* 67 is obsolete vread */76 /* 67 is obsolete vread */
75 /* 68 is obsolete vwrite */77 /* 68 is obsolete vwrite */
76#define SYS_sbrk 6978 /* 69 is obsolete sbrk */
77#define SYS_sstk 7079 /* 70 is obsolete sstk */
78 /* 71 is old mmap */80 /* 71 is old mmap */
79#define SYS_freebsd11_vadvise 7281#define SYS_freebsd11_vadvise 72
80#define SYS_munmap 7382#define SYS_munmap 73
...@@ -83,8 +85,8 @@...@@ -83,8 +85,8 @@
83 /* 76 is obsolete vhangup */85 /* 76 is obsolete vhangup */
84 /* 77 is obsolete vlimit */86 /* 77 is obsolete vlimit */
85#define SYS_mincore 7887#define SYS_mincore 78
86#define SYS_getgroups 7988#define SYS_freebsd14_getgroups 79
87#define SYS_setgroups 8089#define SYS_freebsd14_setgroups 80
88#define SYS_getpgrp 8190#define SYS_getpgrp 81
89#define SYS_setpgid 8291#define SYS_setpgid 82
90#define SYS_setitimer 8392#define SYS_setitimer 83
...@@ -442,7 +444,7 @@...@@ -442,7 +444,7 @@
442#define SYS_symlinkat 502444#define SYS_symlinkat 502
443#define SYS_unlinkat 503445#define SYS_unlinkat 503
444#define SYS_posix_openpt 504446#define SYS_posix_openpt 504
445#define SYS_gssd_syscall 505447 /* 505 is obsolete kgssapi */
446#define SYS_jail_get 506448#define SYS_jail_get 506
447#define SYS_jail_set 507449#define SYS_jail_set 507
448#define SYS_jail_remove 508450#define SYS_jail_remove 508
...@@ -526,4 +528,13 @@...@@ -526,4 +528,13 @@
526#define SYS_timerfd_settime 587528#define SYS_timerfd_settime 587
527#define SYS_kcmp 588529#define SYS_kcmp 588
528#define SYS_getrlimitusage 589530#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 @@...@@ -28,13 +28,14 @@
28#ifndef _SYS_SYSCALLSUBR_H_28#ifndef _SYS_SYSCALLSUBR_H_
29#define _SYS_SYSCALLSUBR_H_29#define _SYS_SYSCALLSUBR_H_
3030
31#include <sys/signal.h>31#include <sys/types.h>
32#include <sys/socket.h>
33#include <sys/mac.h>
34#include <sys/mount.h>
35#include <sys/_cpuset.h>32#include <sys/_cpuset.h>
36#include <sys/_domainset.h>33#include <sys/_domainset.h>
37#include <sys/_uio.h>34#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
39struct __wrusage;40struct __wrusage;
40struct cpuset_copy_cb;41struct cpuset_copy_cb;
...@@ -49,6 +50,7 @@ struct kevent_copyops;...@@ -49,6 +50,7 @@ struct kevent_copyops;
49struct kld_file_stat;50struct kld_file_stat;
50struct ksiginfo;51struct ksiginfo;
51struct mbuf;52struct mbuf;
53struct mq_attr;
52struct msghdr;54struct msghdr;
53struct msqid_ds;55struct msqid_ds;
54struct pollfd;56struct pollfd;
...@@ -58,6 +60,7 @@ struct rusage;...@@ -58,6 +60,7 @@ struct rusage;
58struct sched_param;60struct sched_param;
59struct sembuf;61struct sembuf;
60union semun;62union semun;
63struct shmfd;
61struct sockaddr;64struct sockaddr;
62struct spacectl_range;65struct spacectl_range;
63struct stat;66struct stat;
...@@ -84,10 +87,10 @@ int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,...@@ -84,10 +87,10 @@ int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,
84 size_t buflen, size_t path_max);87 size_t buflen, size_t path_max);
85int kern_abort2(struct thread *td, const char *why, int nargs,88int kern_abort2(struct thread *td, const char *why, int nargs,
86 void **uargs);89 void **uargs);
87int kern_accept(struct thread *td, int s, struct sockaddr **name,90int kern_accept(struct thread *td, int s, struct sockaddr *sa,
88 socklen_t *namelen, struct file **fp);91 struct file **fp);
89int kern_accept4(struct thread *td, int s, struct sockaddr **name,92int kern_accept4(struct thread *td, int s, struct sockaddr *sa,
90 socklen_t *namelen, int flags, struct file **fp);93 int flags, struct file **fp);
91int kern_accessat(struct thread *td, int fd, const char *path,94int kern_accessat(struct thread *td, int fd, const char *path,
92 enum uio_seg pathseg, int flags, int mode);95 enum uio_seg pathseg, int flags, int mode);
93int kern_adjtime(struct thread *td, struct timeval *delta,96int kern_adjtime(struct thread *td, struct timeval *delta,
...@@ -164,7 +167,7 @@ int kern_fchmodat(struct thread *td, int fd, const char *path,...@@ -164,7 +167,7 @@ int kern_fchmodat(struct thread *td, int fd, const char *path,
164int kern_fchownat(struct thread *td, int fd, const char *path,167int kern_fchownat(struct thread *td, int fd, const char *path,
165 enum uio_seg pathseg, int uid, int gid, int flag);168 enum uio_seg pathseg, int uid, int gid, int flag);
166int kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg);169int 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);
168int kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags);171int kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags);
169int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);172int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);
170int kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf);173int 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,...@@ -187,13 +190,11 @@ int kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
187 size_t *countp, enum uio_seg bufseg, int mode);190 size_t *countp, enum uio_seg bufseg, int mode);
188int kern_getitimer(struct thread *, u_int, struct itimerval *);191int kern_getitimer(struct thread *, u_int, struct itimerval *);
189int kern_getppid(struct thread *);192int kern_getppid(struct thread *);
190int kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,193int kern_getpeername(struct thread *td, int fd, struct sockaddr *sa);
191 socklen_t *alen);
192int kern_getpriority(struct thread *td, int which, int who);194int kern_getpriority(struct thread *td, int which, int who);
193int kern_getrusage(struct thread *td, int who, struct rusage *rup);195int kern_getrusage(struct thread *td, int who, struct rusage *rup);
194int kern_getsid(struct thread *td, pid_t pid);196int kern_getsid(struct thread *td, pid_t pid);
195int kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,197int kern_getsockname(struct thread *td, int fd, struct sockaddr *sa);
196 socklen_t *alen);
197int kern_getsockopt(struct thread *td, int s, int level, int name,198int kern_getsockopt(struct thread *td, int s, int level, int name,
198 void *optval, enum uio_seg valseg, socklen_t *valsize);199 void *optval, enum uio_seg valseg, socklen_t *valsize);
199int kern_ioctl(struct thread *td, int fd, u_long com, caddr_t data);200int 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);...@@ -214,6 +215,15 @@ int kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps);
214int kern_kldload(struct thread *td, const char *file, int *fileid);215int kern_kldload(struct thread *td, const char *file, int *fileid);
215int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat);216int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat);
216int kern_kldunload(struct thread *td, int fileid, int flags);217int 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 *);
217int kern_linkat(struct thread *td, int fd1, int fd2, const char *path1,227int kern_linkat(struct thread *td, int fd1, int fd2, const char *path1,
218 const char *path2, enum uio_seg segflg, int flag);228 const char *path2, enum uio_seg segflg, int flag);
219int kern_listen(struct thread *td, int s, int backlog);229int 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);...@@ -248,6 +258,7 @@ int kern_munlock(struct thread *td, uintptr_t addr, size_t size);
248int kern_munmap(struct thread *td, uintptr_t addr, size_t size);258int kern_munmap(struct thread *td, uintptr_t addr, size_t size);
249int kern_nanosleep(struct thread *td, struct timespec *rqt,259int kern_nanosleep(struct thread *td, struct timespec *rqt,
250 struct timespec *rmt);260 struct timespec *rmt);
261int kern_nosys(struct thread *td, int dummy);
251int kern_ntp_adjtime(struct thread *td, struct timex *ntv, int *retvalp);262int kern_ntp_adjtime(struct thread *td, struct timex *ntv, int *retvalp);
252int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,263int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
253 long *ploff);264 long *ploff);
...@@ -312,7 +323,9 @@ int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,...@@ -312,7 +323,9 @@ int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
312 fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits);323 fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits);
313int kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,324int kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags,
314 struct mbuf *control, enum uio_seg segflg);325 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);
316int kern_setitimer(struct thread *, u_int, struct itimerval *,329int kern_setitimer(struct thread *, u_int, struct itimerval *,
317 struct itimerval *);330 struct itimerval *);
318int kern_setpriority(struct thread *td, int which, int who, int prio);331int 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,...@@ -325,7 +338,7 @@ int kern_shm_open(struct thread *td, const char *userpath, int flags,
325 mode_t mode, struct filecaps *fcaps);338 mode_t mode, struct filecaps *fcaps);
326int kern_shm_open2(struct thread *td, const char *path, int flags,339int kern_shm_open2(struct thread *td, const char *path, int flags,
327 mode_t mode, int shmflags, struct filecaps *fcaps,340 mode_t mode, int shmflags, struct filecaps *fcaps,
328 const char *name);341 const char *name, struct shmfd *shmfd);
329int kern_shmat(struct thread *td, int shmid, const void *shmaddr,342int kern_shmat(struct thread *td, int shmid, const void *shmaddr,
330 int shmflg);343 int shmflg);
331int kern_shmctl(struct thread *td, int shmid, int cmd, void *buf,344int 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 @@...@@ -30,14 +30,13 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93
35 */33 */
3634
37#ifndef _SYS_SYSCTL_H_35#ifndef _SYS_SYSCTL_H_
38#define _SYS_SYSCTL_H_36#define _SYS_SYSCTL_H_
3937
40#ifdef _KERNEL38#ifdef _KERNEL
39#include <sys/cdefs.h>
41#include <sys/queue.h>40#include <sys/queue.h>
42#include <sys/tree.h>41#include <sys/tree.h>
43#endif42#endif
...@@ -866,7 +865,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);...@@ -866,7 +865,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
866/* OID expressing a sbintime_t as microseconds */865/* OID expressing a sbintime_t as microseconds */
867#define SYSCTL_SBINTIME_USEC(parent, nbr, name, access, ptr, descr) \866#define SYSCTL_SBINTIME_USEC(parent, nbr, name, access, ptr, descr) \
868 SYSCTL_OID(parent, nbr, name, \867 SYSCTL_OID(parent, nbr, name, \
869 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \868 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
870 (ptr), 0, sysctl_usec_to_sbintime, "Q", descr); \869 (ptr), 0, sysctl_usec_to_sbintime, "Q", descr); \
871 CTASSERT(((access) & CTLTYPE) == 0 || \870 CTASSERT(((access) & CTLTYPE) == 0 || \
872 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)871 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)
...@@ -876,7 +875,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);...@@ -876,7 +875,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
876 CTASSERT(((access) & CTLTYPE) == 0 || \875 CTASSERT(((access) & CTLTYPE) == 0 || \
877 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \876 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
878 sysctl_add_oid(ctx, parent, nbr, name, \877 sysctl_add_oid(ctx, parent, nbr, name, \
879 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \878 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
880 __ptr, 0, sysctl_usec_to_sbintime, "Q", __DESCR(descr), \879 __ptr, 0, sysctl_usec_to_sbintime, "Q", __DESCR(descr), \
881 NULL); \880 NULL); \
882})881})
...@@ -884,7 +883,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);...@@ -884,7 +883,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
884/* OID expressing a sbintime_t as milliseconds */883/* OID expressing a sbintime_t as milliseconds */
885#define SYSCTL_SBINTIME_MSEC(parent, nbr, name, access, ptr, descr) \884#define SYSCTL_SBINTIME_MSEC(parent, nbr, name, access, ptr, descr) \
886 SYSCTL_OID(parent, nbr, name, \885 SYSCTL_OID(parent, nbr, name, \
887 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \886 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
888 (ptr), 0, sysctl_msec_to_sbintime, "Q", descr); \887 (ptr), 0, sysctl_msec_to_sbintime, "Q", descr); \
889 CTASSERT(((access) & CTLTYPE) == 0 || \888 CTASSERT(((access) & CTLTYPE) == 0 || \
890 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)889 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)
...@@ -894,7 +893,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);...@@ -894,7 +893,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
894 CTASSERT(((access) & CTLTYPE) == 0 || \893 CTASSERT(((access) & CTLTYPE) == 0 || \
895 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \894 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
896 sysctl_add_oid(ctx, parent, nbr, name, \895 sysctl_add_oid(ctx, parent, nbr, name, \
897 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \896 CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
898 __ptr, 0, sysctl_msec_to_sbintime, "Q", __DESCR(descr), \897 __ptr, 0, sysctl_msec_to_sbintime, "Q", __DESCR(descr), \
899 NULL); \898 NULL); \
900})899})
...@@ -934,6 +933,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);...@@ -934,6 +933,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
934 CTLFLAG_RD | CTLFLAG_CAPRD | CTLTYPE_INT | CTLFLAG_MPSAFE, \933 CTLFLAG_RD | CTLFLAG_CAPRD | CTLTYPE_INT | CTLFLAG_MPSAFE, \
935 NULL, 1, sysctl_handle_int, "I", desc, "feature");934 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
937#endif /* _KERNEL */956#endif /* _KERNEL */
938957
939/*958/*
...@@ -1043,6 +1062,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);...@@ -1043,6 +1062,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
1043#define KERN_PROC_SIGFASTBLK 44 /* address of fastsigblk magic word */1062#define KERN_PROC_SIGFASTBLK 44 /* address of fastsigblk magic word */
1044#define KERN_PROC_VM_LAYOUT 45 /* virtual address space layout info */1063#define KERN_PROC_VM_LAYOUT 45 /* virtual address space layout info */
1045#define KERN_PROC_RLIMIT_USAGE 46 /* array of rlim_t */1064#define KERN_PROC_RLIMIT_USAGE 46 /* array of rlim_t */
1065#define KERN_PROC_KQUEUE 47 /* array of struct kinfo_knote */
10461066
1047/*1067/*
1048 * KERN_IPC identifiers1068 * KERN_IPC identifiers
lib/libc/include/generic-freebsd/sys/sysent.h+15-7
...@@ -79,11 +79,10 @@ struct sysent { /* system call table */...@@ -79,11 +79,10 @@ struct sysent { /* system call table */
79 */79 */
80#define SYF_CAPENABLED 0x0000000180#define SYF_CAPENABLED 0x00000001
8181
82#define SY_THR_FLAGMASK 0x782#define SY_THR_STATIC 0x01
83#define SY_THR_STATIC 0x183#define SY_THR_DRAINING 0x02
84#define SY_THR_DRAINING 0x284#define SY_THR_ABSENT 0x04
85#define SY_THR_ABSENT 0x485#define SY_THR_INCR 0x08
86#define SY_THR_INCR 0x8
8786
88#ifdef KLD_MODULE87#ifdef KLD_MODULE
89#define SY_THR_STATIC_KLD 088#define SY_THR_STATIC_KLD 0
...@@ -91,6 +90,7 @@ struct sysent { /* system call table */...@@ -91,6 +90,7 @@ struct sysent { /* system call table */
91#define SY_THR_STATIC_KLD SY_THR_STATIC90#define SY_THR_STATIC_KLD SY_THR_STATIC
92#endif91#endif
9392
93struct coredump_writer;
94struct image_params;94struct image_params;
95struct proc;95struct proc;
96struct __sigset;96struct __sigset;
...@@ -109,7 +109,8 @@ struct sysentvec {...@@ -109,7 +109,8 @@ struct sysentvec {
109 int *sv_szsigcode; /* size of sigtramp code */109 int *sv_szsigcode; /* size of sigtramp code */
110 int sv_sigcodeoff;110 int sv_sigcodeoff;
111 char *sv_name; /* name of binary type */111 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);
113 /* function to dump core, or NULL */114 /* function to dump core, or NULL */
114 int sv_elf_core_osabi;115 int sv_elf_core_osabi;
115 const char *sv_elf_core_abi_vendor;116 const char *sv_elf_core_abi_vendor;
...@@ -145,10 +146,13 @@ struct sysentvec {...@@ -145,10 +146,13 @@ struct sysentvec {
145 int (*sv_trap)(struct thread *);146 int (*sv_trap)(struct thread *);
146 u_long *sv_hwcap; /* Value passed in AT_HWCAP. */147 u_long *sv_hwcap; /* Value passed in AT_HWCAP. */
147 u_long *sv_hwcap2; /* Value passed in AT_HWCAP2. */148 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. */
148 const char *(*sv_machine_arch)(struct proc *);151 const char *(*sv_machine_arch)(struct proc *);
149 vm_offset_t sv_fxrng_gen_offset;152 vm_offset_t sv_fxrng_gen_offset;
150 void (*sv_onexec_old)(struct thread *td);153 void (*sv_onexec_old)(struct thread *td);
151 int (*sv_onexec)(struct proc *, struct image_params *);154 int (*sv_onexec)(struct proc *, struct image_params *);
155 void (*sv_protect)(struct image_params *, int);
152 void (*sv_onexit)(struct proc *);156 void (*sv_onexit)(struct proc *);
153 void (*sv_ontdexit)(struct thread *td);157 void (*sv_ontdexit)(struct thread *td);
154 int (*sv_setid_allowed)(struct thread *td,158 int (*sv_setid_allowed)(struct thread *td,
...@@ -161,7 +165,7 @@ struct sysentvec {...@@ -161,7 +165,7 @@ struct sysentvec {
161165
162#define SV_ILP32 0x000100 /* 32-bit executable. */166#define SV_ILP32 0x000100 /* 32-bit executable. */
163#define SV_LP64 0x000200 /* 64-bit executable. */167#define SV_LP64 0x000200 /* 64-bit executable. */
164#define SV_IA32 0x004000 /* Intel 32-bit executable. */168#define SV_RESERVED0 0x004000 /* Formerly SV_IA32 */
165#define SV_AOUT 0x008000 /* a.out executable. */169#define SV_AOUT 0x008000 /* a.out executable. */
166#define SV_SHP 0x010000 /* Shared page. */170#define SV_SHP 0x010000 /* Shared page. */
167#define SV_SIGSYS 0x020000 /* SIGSYS for non-existing syscall */171#define SV_SIGSYS 0x020000 /* SIGSYS for non-existing syscall */
...@@ -187,6 +191,10 @@ struct sysentvec {...@@ -187,6 +191,10 @@ struct sysentvec {
187#define SVC_NOCOMPRESS 0x00000002 /* disable compression. */191#define SVC_NOCOMPRESS 0x00000002 /* disable compression. */
188#define SVC_ALL 0x00000004 /* dump everything */192#define SVC_ALL 0x00000004 /* dump everything */
189193
194/* sv_protect flags */
195#define SVP_IMAGE 0x00000001
196#define SVP_INTERP 0x00000002
197
190#ifdef _KERNEL198#ifdef _KERNEL
191extern struct sysentvec aout_sysvec;199extern struct sysentvec aout_sysvec;
192extern struct sysent sysent[];200extern struct sysent sysent[];
lib/libc/include/generic-freebsd/sys/syslimits.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)syslimits.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_SYSLIMITS_H_32#ifndef _SYS_SYSLIMITS_H_
lib/libc/include/generic-freebsd/sys/syslog.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)syslog.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_SYSLOG_H_32#ifndef _SYS_SYSLOG_H_
lib/libc/include/generic-freebsd/sys/sysproto.h+99-54
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7#ifndef _SYS_SYSPROTO_H_7#ifndef _SYS_SYSPROTO_H_
8#define _SYS_SYSPROTO_H_8#define _SYS_SYSPROTO_H_
99
10#include <sys/types.h>
10#include <sys/signal.h>11#include <sys/signal.h>
11#include <sys/acl.h>
12#include <sys/cpuset.h>12#include <sys/cpuset.h>
13#include <sys/domainset.h>13#include <sys/domainset.h>
14#include <sys/_ffcounter.h>14#include <sys/_ffcounter.h>
...@@ -33,7 +33,7 @@ struct thread;...@@ -33,7 +33,7 @@ struct thread;
33#define PADR_(t) 033#define PADR_(t) 0
34#endif34#endif
3535
36struct exit_args {36struct _exit_args {
37 char rval_l_[PADL_(int)]; int rval; char rval_r_[PADR_(int)];37 char rval_l_[PADL_(int)]; int rval; char rval_r_[PADR_(int)];
38};38};
39struct fork_args {39struct fork_args {
...@@ -254,12 +254,6 @@ struct msync_args {...@@ -254,12 +254,6 @@ struct msync_args {
254struct vfork_args {254struct vfork_args {
255 syscallarg_t dummy;255 syscallarg_t dummy;
256};256};
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};
263struct munmap_args {257struct munmap_args {
264 char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];258 char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
265 char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];259 char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
...@@ -279,14 +273,6 @@ struct mincore_args {...@@ -279,14 +273,6 @@ struct mincore_args {
279 char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];273 char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
280 char vec_l_[PADL_(char *)]; char * vec; char vec_r_[PADR_(char *)];274 char vec_l_[PADL_(char *)]; char * vec; char vec_r_[PADR_(char *)];
281};275};
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};
290struct getpgrp_args {276struct getpgrp_args {
291 syscallarg_t dummy;277 syscallarg_t dummy;
292};278};
...@@ -319,7 +305,7 @@ struct dup2_args {...@@ -319,7 +305,7 @@ struct dup2_args {
319struct fcntl_args {305struct fcntl_args {
320 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];306 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
321 char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];307 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)];
323};309};
324struct select_args {310struct select_args {
325 char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];311 char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)];
...@@ -383,12 +369,12 @@ struct getsockopt_args {...@@ -383,12 +369,12 @@ struct getsockopt_args {
383};369};
384struct readv_args {370struct readv_args {
385 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];371 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 *)];
387 char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];373 char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];
388};374};
389struct writev_args {375struct writev_args {
390 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];376 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 *)];
392 char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];378 char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)];
393};379};
394struct settimeofday_args {380struct settimeofday_args {
...@@ -552,7 +538,7 @@ struct setrlimit_args {...@@ -552,7 +538,7 @@ struct setrlimit_args {
552 char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];538 char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)];
553};539};
554struct __sysctl_args {540struct __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 *)];
556 char namelen_l_[PADL_(u_int)]; u_int namelen; char namelen_r_[PADR_(u_int)];542 char namelen_l_[PADL_(u_int)]; u_int namelen; char namelen_r_[PADR_(u_int)];
557 char old_l_[PADL_(void *)]; void * old; char old_r_[PADR_(void *)];543 char old_l_[PADL_(void *)]; void * old; char old_r_[PADR_(void *)];
558 char oldlenp_l_[PADL_(size_t *)]; size_t * oldlenp; char oldlenp_r_[PADR_(size_t *)];544 char oldlenp_l_[PADL_(size_t *)]; size_t * oldlenp; char oldlenp_r_[PADR_(size_t *)];
...@@ -783,7 +769,7 @@ struct aio_return_args {...@@ -783,7 +769,7 @@ struct aio_return_args {
783 char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];769 char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)];
784};770};
785struct aio_suspend_args {771struct 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 *)];
787 char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)];773 char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)];
788 char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)];774 char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)];
789};775};
...@@ -868,49 +854,49 @@ struct sigpending_args {...@@ -868,49 +854,49 @@ struct sigpending_args {
868};854};
869struct sigtimedwait_args {855struct sigtimedwait_args {
870 char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];856 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 *)];
872 char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)];858 char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)];
873};859};
874struct sigwaitinfo_args {860struct sigwaitinfo_args {
875 char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)];861 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 *)];
877};863};
878struct __acl_get_file_args {864struct __acl_get_file_args {
879 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];865 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)];
881 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];867 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
882};868};
883struct __acl_set_file_args {869struct __acl_set_file_args {
884 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];870 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)];
886 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];872 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
887};873};
888struct __acl_get_fd_args {874struct __acl_get_fd_args {
889 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];875 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)];
891 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];877 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
892};878};
893struct __acl_set_fd_args {879struct __acl_set_fd_args {
894 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];880 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)];
896 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];882 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
897};883};
898struct __acl_delete_file_args {884struct __acl_delete_file_args {
899 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];885 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)];
901};887};
902struct __acl_delete_fd_args {888struct __acl_delete_fd_args {
903 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];889 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)];
905};891};
906struct __acl_aclcheck_file_args {892struct __acl_aclcheck_file_args {
907 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];893 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)];
909 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];895 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
910};896};
911struct __acl_aclcheck_fd_args {897struct __acl_aclcheck_fd_args {
912 char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)];898 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)];
914 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];900 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
915};901};
916struct extattrctl_args {902struct extattrctl_args {
...@@ -1136,21 +1122,21 @@ struct swapcontext_args {...@@ -1136,21 +1122,21 @@ struct swapcontext_args {
1136};1122};
1137struct __acl_get_link_args {1123struct __acl_get_link_args {
1138 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];1124 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)];
1140 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];1126 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
1141};1127};
1142struct __acl_set_link_args {1128struct __acl_set_link_args {
1143 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];1129 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)];
1145 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];1131 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
1146};1132};
1147struct __acl_delete_link_args {1133struct __acl_delete_link_args {
1148 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];1134 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)];
1150};1136};
1151struct __acl_aclcheck_link_args {1137struct __acl_aclcheck_link_args {
1152 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];1138 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)];
1154 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];1140 char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)];
1155};1141};
1156struct sigwait_args {1142struct sigwait_args {
...@@ -1482,9 +1468,6 @@ struct unlinkat_args {...@@ -1482,9 +1468,6 @@ struct unlinkat_args {
1482struct posix_openpt_args {1468struct posix_openpt_args {
1483 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];1469 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
1484};1470};
1485struct gssd_syscall_args {
1486 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1487};
1488struct jail_get_args {1471struct jail_get_args {
1489 char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];1472 char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)];
1490 char iovcnt_l_[PADL_(unsigned int)]; unsigned int iovcnt; char iovcnt_r_[PADR_(unsigned int)];1473 char iovcnt_l_[PADL_(unsigned int)]; unsigned int iovcnt; char iovcnt_r_[PADR_(unsigned int)];
...@@ -1603,7 +1586,7 @@ struct wait6_args {...@@ -1603,7 +1586,7 @@ struct wait6_args {
1603 char status_l_[PADL_(int *)]; int * status; char status_r_[PADR_(int *)];1586 char status_l_[PADL_(int *)]; int * status; char status_r_[PADR_(int *)];
1604 char options_l_[PADL_(int)]; int options; char options_r_[PADR_(int)];1587 char options_l_[PADL_(int)]; int options; char options_r_[PADR_(int)];
1605 char wrusage_l_[PADL_(struct __wrusage *)]; struct __wrusage * wrusage; char wrusage_r_[PADR_(struct __wrusage *)];1588 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 *)];
1607};1590};
1608struct cap_rights_limit_args {1591struct cap_rights_limit_args {
1609 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];1592 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
...@@ -1811,7 +1794,7 @@ struct shm_rename_args {...@@ -1811,7 +1794,7 @@ struct shm_rename_args {
1811};1794};
1812struct sigfastblock_args {1795struct sigfastblock_args {
1813 char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];1796 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 *)];
1815};1798};
1816struct __realpathat_args {1799struct __realpathat_args {
1817 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];1800 char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
...@@ -1826,8 +1809,7 @@ struct close_range_args {...@@ -1826,8 +1809,7 @@ struct close_range_args {
1826 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];1809 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
1827};1810};
1828struct rpctls_syscall_args {1811struct rpctls_syscall_args {
1829 char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];1812 char socookie_l_[PADL_(uint64_t)]; uint64_t socookie; char socookie_r_[PADR_(uint64_t)];
1830 char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
1831};1813};
1832struct __specialfd_args {1814struct __specialfd_args {
1833 char type_l_[PADL_(int)]; int type; char type_r_[PADR_(int)];1815 char type_l_[PADL_(int)]; int type; char type_r_[PADR_(int)];
...@@ -1888,7 +1870,44 @@ struct getrlimitusage_args {...@@ -1888,7 +1870,44 @@ struct getrlimitusage_args {
1888 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];1870 char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
1889 char res_l_[PADL_(rlim_t *)]; rlim_t * res; char res_r_[PADR_(rlim_t *)];1871 char res_l_[PADL_(rlim_t *)]; rlim_t * res; char res_r_[PADR_(rlim_t *)];
1890};1872};
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 *);
1892int sys_fork(struct thread *, struct fork_args *);1911int sys_fork(struct thread *, struct fork_args *);
1893int sys_read(struct thread *, struct read_args *);1912int sys_read(struct thread *, struct read_args *);
1894int sys_write(struct thread *, struct write_args *);1913int sys_write(struct thread *, struct write_args *);
...@@ -1940,14 +1959,10 @@ int sys_umask(struct thread *, struct umask_args *);...@@ -1940,14 +1959,10 @@ int sys_umask(struct thread *, struct umask_args *);
1940int sys_chroot(struct thread *, struct chroot_args *);1959int sys_chroot(struct thread *, struct chroot_args *);
1941int sys_msync(struct thread *, struct msync_args *);1960int sys_msync(struct thread *, struct msync_args *);
1942int sys_vfork(struct thread *, struct vfork_args *);1961int sys_vfork(struct thread *, struct vfork_args *);
1943int sys_sbrk(struct thread *, struct sbrk_args *);
1944int sys_sstk(struct thread *, struct sstk_args *);
1945int sys_munmap(struct thread *, struct munmap_args *);1962int sys_munmap(struct thread *, struct munmap_args *);
1946int sys_mprotect(struct thread *, struct mprotect_args *);1963int sys_mprotect(struct thread *, struct mprotect_args *);
1947int sys_madvise(struct thread *, struct madvise_args *);1964int sys_madvise(struct thread *, struct madvise_args *);
1948int sys_mincore(struct thread *, struct mincore_args *);1965int sys_mincore(struct thread *, struct mincore_args *);
1949int sys_getgroups(struct thread *, struct getgroups_args *);
1950int sys_setgroups(struct thread *, struct setgroups_args *);
1951int sys_getpgrp(struct thread *, struct getpgrp_args *);1966int sys_getpgrp(struct thread *, struct getpgrp_args *);
1952int sys_setpgid(struct thread *, struct setpgid_args *);1967int sys_setpgid(struct thread *, struct setpgid_args *);
1953int sys_setitimer(struct thread *, struct setitimer_args *);1968int sys_setitimer(struct thread *, struct setitimer_args *);
...@@ -2210,7 +2225,6 @@ int sys_renameat(struct thread *, struct renameat_args *);...@@ -2210,7 +2225,6 @@ int sys_renameat(struct thread *, struct renameat_args *);
2210int sys_symlinkat(struct thread *, struct symlinkat_args *);2225int sys_symlinkat(struct thread *, struct symlinkat_args *);
2211int sys_unlinkat(struct thread *, struct unlinkat_args *);2226int sys_unlinkat(struct thread *, struct unlinkat_args *);
2212int sys_posix_openpt(struct thread *, struct posix_openpt_args *);2227int sys_posix_openpt(struct thread *, struct posix_openpt_args *);
2213int sys_gssd_syscall(struct thread *, struct gssd_syscall_args *);
2214int sys_jail_get(struct thread *, struct jail_get_args *);2228int sys_jail_get(struct thread *, struct jail_get_args *);
2215int sys_jail_set(struct thread *, struct jail_set_args *);2229int sys_jail_set(struct thread *, struct jail_set_args *);
2216int sys_jail_remove(struct thread *, struct jail_remove_args *);2230int sys_jail_remove(struct thread *, struct jail_remove_args *);
...@@ -2290,6 +2304,15 @@ int sys_timerfd_gettime(struct thread *, struct timerfd_gettime_args *);...@@ -2290,6 +2304,15 @@ int sys_timerfd_gettime(struct thread *, struct timerfd_gettime_args *);
2290int sys_timerfd_settime(struct thread *, struct timerfd_settime_args *);2304int sys_timerfd_settime(struct thread *, struct timerfd_settime_args *);
2291int sys_kcmp(struct thread *, struct kcmp_args *);2305int sys_kcmp(struct thread *, struct kcmp_args *);
2292int sys_getrlimitusage(struct thread *, struct getrlimitusage_args *);2306int 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
2294#ifdef COMPAT_432317#ifdef COMPAT_43
22952318
...@@ -2781,7 +2804,23 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);...@@ -2781,7 +2804,23 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
27812804
2782#endif /* COMPAT_FREEBSD13 */2805#endif /* COMPAT_FREEBSD13 */
27832806
2784#define SYS_AUE_exit AUE_EXIT2807
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
2785#define SYS_AUE_fork AUE_FORK2824#define SYS_AUE_fork AUE_FORK
2786#define SYS_AUE_read AUE_READ2825#define SYS_AUE_read AUE_READ
2787#define SYS_AUE_write AUE_WRITE2826#define SYS_AUE_write AUE_WRITE
...@@ -2846,16 +2885,14 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);...@@ -2846,16 +2885,14 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
2846#define SYS_AUE_ogetpagesize AUE_NULL2885#define SYS_AUE_ogetpagesize AUE_NULL
2847#define SYS_AUE_msync AUE_MSYNC2886#define SYS_AUE_msync AUE_MSYNC
2848#define SYS_AUE_vfork AUE_VFORK2887#define SYS_AUE_vfork AUE_VFORK
2849#define SYS_AUE_sbrk AUE_SBRK
2850#define SYS_AUE_sstk AUE_SSTK
2851#define SYS_AUE_ommap AUE_MMAP2888#define SYS_AUE_ommap AUE_MMAP
2852#define SYS_AUE_freebsd11_vadvise AUE_O_VADVISE2889#define SYS_AUE_freebsd11_vadvise AUE_O_VADVISE
2853#define SYS_AUE_munmap AUE_MUNMAP2890#define SYS_AUE_munmap AUE_MUNMAP
2854#define SYS_AUE_mprotect AUE_MPROTECT2891#define SYS_AUE_mprotect AUE_MPROTECT
2855#define SYS_AUE_madvise AUE_MADVISE2892#define SYS_AUE_madvise AUE_MADVISE
2856#define SYS_AUE_mincore AUE_MINCORE2893#define SYS_AUE_mincore AUE_MINCORE
2857#define SYS_AUE_getgroups AUE_GETGROUPS2894#define SYS_AUE_freebsd14_getgroups AUE_GETGROUPS
2858#define SYS_AUE_setgroups AUE_SETGROUPS2895#define SYS_AUE_freebsd14_setgroups AUE_SETGROUPS
2859#define SYS_AUE_getpgrp AUE_GETPGRP2896#define SYS_AUE_getpgrp AUE_GETPGRP
2860#define SYS_AUE_setpgid AUE_SETPGRP2897#define SYS_AUE_setpgid AUE_SETPGRP
2861#define SYS_AUE_setitimer AUE_SETITIMER2898#define SYS_AUE_setitimer AUE_SETITIMER
...@@ -3185,7 +3222,6 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);...@@ -3185,7 +3222,6 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
3185#define SYS_AUE_symlinkat AUE_SYMLINKAT3222#define SYS_AUE_symlinkat AUE_SYMLINKAT
3186#define SYS_AUE_unlinkat AUE_UNLINKAT3223#define SYS_AUE_unlinkat AUE_UNLINKAT
3187#define SYS_AUE_posix_openpt AUE_POSIX_OPENPT3224#define SYS_AUE_posix_openpt AUE_POSIX_OPENPT
3188#define SYS_AUE_gssd_syscall AUE_NULL
3189#define SYS_AUE_jail_get AUE_JAIL_GET3225#define SYS_AUE_jail_get AUE_JAIL_GET
3190#define SYS_AUE_jail_set AUE_JAIL_SET3226#define SYS_AUE_jail_set AUE_JAIL_SET
3191#define SYS_AUE_jail_remove AUE_JAIL_REMOVE3227#define SYS_AUE_jail_remove AUE_JAIL_REMOVE
...@@ -3266,6 +3302,15 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);...@@ -3266,6 +3302,15 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *);
3266#define SYS_AUE_timerfd_settime AUE_TIMERFD3302#define SYS_AUE_timerfd_settime AUE_TIMERFD
3267#define SYS_AUE_kcmp AUE_NULL3303#define SYS_AUE_kcmp AUE_NULL
3268#define SYS_AUE_getrlimitusage AUE_NULL3304#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
3270#undef PAD_3315#undef PAD_
3271#undef PADL_3316#undef PADL_
lib/libc/include/generic-freebsd/sys/systm.h+54-32
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)systm.h 8.7 (Berkeley) 3/29/95
37 */35 */
3836
39#ifndef _SYS_SYSTM_H_37#ifndef _SYS_SYSTM_H_
...@@ -81,7 +79,7 @@ extern u_long maxphys; /* max raw I/O transfer size */...@@ -81,7 +79,7 @@ extern u_long maxphys; /* max raw I/O transfer size */
81 */79 */
82enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,80enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
83 VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_BHYVE, VM_GUEST_VBOX,81 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
86#endif /* KERNEL */84#endif /* KERNEL */
8785
...@@ -101,17 +99,15 @@ struct ucred;...@@ -101,17 +99,15 @@ struct ucred;
101#include <sys/pcpu.h> /* curthread */99#include <sys/pcpu.h> /* curthread */
102#include <sys/kpilite.h>100#include <sys/kpilite.h>
103101
102extern bool scheduler_stopped;
103
104/*104/*
105 * If we have already panic'd and this is the thread that called105 * If we have already panic'd and this is the thread that called
106 * panic(), then don't block on any mutexes but silently succeed.106 * panic(), then don't block on any mutexes but silently succeed.
107 * Otherwise, the kernel will deadlock since the scheduler isn't107 * Otherwise, the kernel will deadlock since the scheduler isn't
108 * going to run the thread that holds any lock we need.108 * going to run the thread that holds any lock we need.
109 */109 */
110#define SCHEDULER_STOPPED_TD(td) ({ \110#define SCHEDULER_STOPPED() __predict_false(scheduler_stopped)
111 MPASS((td) == curthread); \
112 __predict_false((td)->td_stopsched); \
113})
114#define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread)
115111
116extern const int osreldate;112extern const int osreldate;
117113
...@@ -212,6 +208,16 @@ critical_exit(void)...@@ -212,6 +208,16 @@ critical_exit(void)
212#ifdef EARLY_PRINTF208#ifdef EARLY_PRINTF
213typedef void early_putc_t(int ch);209typedef void early_putc_t(int ch);
214extern early_putc_t *early_putc;210extern 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
215#endif221#endif
216int kvprintf(char const *, void (*)(int, void*), void *, int,222int kvprintf(char const *, void (*)(int, void*), void *, int,
217 __va_list) __printflike(1, 0);223 __va_list) __printflike(1, 0);
...@@ -296,17 +302,18 @@ void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n);...@@ -296,17 +302,18 @@ void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n);
296 ((__r >= __len) ? ENAMETOOLONG : 0); \302 ((__r >= __len) ? ENAMETOOLONG : 0); \
297})303})
298304
299int copyinstr(const void * __restrict udaddr,305int __result_use_check copyinstr(const void * __restrict udaddr,
300 void * _Nonnull __restrict kaddr, size_t len,306 void * _Nonnull __restrict kaddr, size_t len,
301 size_t * __restrict lencopied);307 size_t * __restrict lencopied);
302int copyin(const void * __restrict udaddr,308int __result_use_check copyin(const void * __restrict udaddr,
303 void * _Nonnull __restrict kaddr, size_t len);309 void * _Nonnull __restrict kaddr, size_t len);
304int copyin_nofault(const void * __restrict udaddr,310int __result_use_check copyin_nofault(const void * __restrict udaddr,
305 void * _Nonnull __restrict kaddr, size_t len);311 void * _Nonnull __restrict kaddr, size_t len);
306int copyout(const void * _Nonnull __restrict kaddr,312__nodiscard int copyout(const void * _Nonnull __restrict kaddr,
307 void * __restrict udaddr, size_t len);313 void * __restrict udaddr, size_t len);
308int copyout_nofault(const void * _Nonnull __restrict kaddr,314__nodiscard int copyout_nofault(
309 void * __restrict udaddr, size_t len);315 const void * _Nonnull __restrict kaddr, void * __restrict udaddr,
316 size_t len);
310317
311#ifdef SAN_NEEDS_INTERCEPTORS318#ifdef SAN_NEEDS_INTERCEPTORS
312int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t);319int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t);
...@@ -324,14 +331,14 @@ long fuword(volatile const void *base);...@@ -324,14 +331,14 @@ long fuword(volatile const void *base);
324int fuword16(volatile const void *base);331int fuword16(volatile const void *base);
325int32_t fuword32(volatile const void *base);332int32_t fuword32(volatile const void *base);
326int64_t fuword64(volatile const void *base);333int64_t fuword64(volatile const void *base);
327int fueword(volatile const void *base, long *val);334int __result_use_check fueword(volatile const void *base, long *val);
328int fueword32(volatile const void *base, int32_t *val);335int __result_use_check fueword32(volatile const void *base, int32_t *val);
329int fueword64(volatile const void *base, int64_t *val);336int __result_use_check fueword64(volatile const void *base, int64_t *val);
330int subyte(volatile void *base, int byte);337__nodiscard int subyte(volatile void *base, int byte);
331int suword(volatile void *base, long word);338__nodiscard int suword(volatile void *base, long word);
332int suword16(volatile void *base, int word);339__nodiscard int suword16(volatile void *base, int word);
333int suword32(volatile void *base, int32_t word);340__nodiscard int suword32(volatile void *base, int32_t word);
334int suword64(volatile void *base, int64_t word);341__nodiscard int suword64(volatile void *base, int64_t word);
335uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);342uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);
336u_long casuword(volatile u_long *p, u_long oldval, u_long newval);343u_long casuword(volatile u_long *p, u_long oldval, u_long newval);
337int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,344int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,
...@@ -559,17 +566,32 @@ void counted_warning(unsigned *counter, const char *msg);...@@ -559,17 +566,32 @@ void counted_warning(unsigned *counter, const char *msg);
559/*566/*
560 * APIs to manage deprecation and obsolescence.567 * APIs to manage deprecation and obsolescence.
561 */568 */
562void _gone_in(int major, const char *msg);569void _gone_in(int major, const char *msg, ...) __printflike(2, 3);
563void _gone_in_dev(device_t dev, int major, const char *msg);570void _gone_in_dev(device_t dev, int major, const char *msg, ...)
571 __printflike(3, 4);
564#ifdef NO_OBSOLETE_CODE572#ifdef NO_OBSOLETE_CODE
565#define __gone_ok(m, msg) \573#define __gone_ok(m, msg) \
566 _Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)), \574 _Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)), \
567 "Obsolete code: " msg);575 "Obsolete code: " msg)
568#else576#else
569#define __gone_ok(m, msg)577#define __gone_ok(m, msg)
570#endif578#endif
571#define gone_in(major, msg) __gone_ok(major, msg) _gone_in(major, msg)579#define gone_in(major, msg, ...) do { \
572#define gone_in_dev(dev, major, msg) __gone_ok(major, msg) _gone_in_dev(dev, major, msg)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
574#ifdef INVARIANTS596#ifdef INVARIANTS
575#define __diagused597#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,...@@ -215,4 +215,10 @@ struct taskqueue *taskqueue_create_fast(const char *name, int mflags,
215 taskqueue_enqueue_fn enqueue,215 taskqueue_enqueue_fn enqueue,
216 void *context);216 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
218#endif /* !_SYS_TASKQUEUE_H_ */224#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;...@@ -43,6 +43,7 @@ typedef __size_t size_t;
43#define THR_SUSPENDED 0x000143#define THR_SUSPENDED 0x0001
44/* Create the system scope thread. */44/* Create the system scope thread. */
45#define THR_SYSTEM_SCOPE 0x000245#define THR_SYSTEM_SCOPE 0x0002
46#define THR_C_RUNTIME 0x0004
4647
47struct thr_param {48struct thr_param {
48 void (*start_func)(void *); /* thread entry function. */49 void (*start_func)(void *); /* thread entry function. */
lib/libc/include/generic-freebsd/sys/time.h+2-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)time.h 8.5 (Berkeley) 5/4/95
32 */30 */
3331
34#ifndef _SYS_TIME_H_32#ifndef _SYS_TIME_H_
...@@ -613,7 +611,9 @@ int tvtohz(struct timeval *tv);...@@ -613,7 +611,9 @@ int tvtohz(struct timeval *tv);
613#include <time.h>611#include <time.h>
614612
615#include <sys/cdefs.h>613#include <sys/cdefs.h>
614#ifndef _STANDALONE
616#include <sys/select.h>615#include <sys/select.h>
616#endif
617617
618__BEGIN_DECLS618__BEGIN_DECLS
619int setitimer(int, const struct itimerval *, struct itimerval *);619int setitimer(int, const struct itimerval *, struct itimerval *);
lib/libc/include/generic-freebsd/sys/timeb.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)timeb.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_TIMEB_H_37#ifndef _SYS_TIMEB_H_
lib/libc/include/generic-freebsd/sys/timeffc.h+3-1
...@@ -89,7 +89,7 @@ extern int sysclock_active;...@@ -89,7 +89,7 @@ extern int sysclock_active;
89 * of the kernel tick timer (1/hz [s]).89 * of the kernel tick timer (1/hz [s]).
90 * FFCLOCK_LERP: Linear interpolation of ffclock time to guarantee90 * FFCLOCK_LERP: Linear interpolation of ffclock time to guarantee
91 * monotonic time.91 * monotonic time.
92 * FFCLOCK_LEAPSEC: Include leap seconds.92 * {FB|FF}CLOCK_LEAPSEC: Include leap seconds.
93 * {FB|FF}CLOCK_UPTIME: Time stamp should be relative to system boot, not epoch.93 * {FB|FF}CLOCK_UPTIME: Time stamp should be relative to system boot, not epoch.
94 */94 */
95#define FFCLOCK_FAST 0x0000000195#define FFCLOCK_FAST 0x00000001
...@@ -100,6 +100,7 @@ extern int sysclock_active;...@@ -100,6 +100,7 @@ extern int sysclock_active;
100100
101#define FBCLOCK_FAST 0x00010000 /* Currently unused. */101#define FBCLOCK_FAST 0x00010000 /* Currently unused. */
102#define FBCLOCK_UPTIME 0x00020000102#define FBCLOCK_UPTIME 0x00020000
103#define FBCLOCK_LEAPSEC 0x00040000
103#define FBCLOCK_MASK 0xffff0000104#define FBCLOCK_MASK 0xffff0000
104105
105/*106/*
...@@ -111,6 +112,7 @@ struct fbclock_info {...@@ -111,6 +112,7 @@ struct fbclock_info {
111 struct bintime error;112 struct bintime error;
112 struct bintime tick_time;113 struct bintime tick_time;
113 uint64_t th_scale;114 uint64_t th_scale;
115 long th_tai_offset;
114 int status;116 int status;
115};117};
116118
lib/libc/include/generic-freebsd/sys/times.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)times.h 8.4 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _SYS_TIMES_H_37#ifndef _SYS_TIMES_H_
lib/libc/include/generic-freebsd/sys/timespec.h-3
...@@ -27,9 +27,6 @@...@@ -27,9 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * 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
33 */30 */
3431
35#ifndef _SYS_TIMESPEC_H_32#ifndef _SYS_TIMESPEC_H_
lib/libc/include/generic-freebsd/sys/timetc.h+2-2
...@@ -49,7 +49,7 @@ struct timecounter {...@@ -49,7 +49,7 @@ struct timecounter {
49 * This function is optional. It will be called whenever the49 * This function is optional. It will be called whenever the
50 * timecounter is rewound, and is intended to check for PPS50 * timecounter is rewound, and is intended to check for PPS
51 * events. Normal hardware does not need it but timecounters51 * 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.
53 */53 */
54 u_int tc_counter_mask;54 u_int tc_counter_mask;
55 /* This mask should mask off any unimplemented bits. */55 /* This mask should mask off any unimplemented bits. */
...@@ -87,7 +87,7 @@ extern int tc_min_ticktock_freq; /*...@@ -87,7 +87,7 @@ extern int tc_min_ticktock_freq; /*
87u_int64_t tc_getfrequency(void);87u_int64_t tc_getfrequency(void);
88void tc_init(struct timecounter *tc);88void tc_init(struct timecounter *tc);
89void tc_setclock(struct timespec *ts);89void tc_setclock(struct timespec *ts);
90void tc_ticktock(int cnt);90void tc_ticktock(long cnt);
91void cpu_tick_calibration(void);91void cpu_tick_calibration(void);
9292
93#ifdef SYSCTL_DECL93#ifdef SYSCTL_DECL
lib/libc/include/generic-freebsd/sys/timex.h+1-1
...@@ -154,7 +154,7 @@ struct timex {...@@ -154,7 +154,7 @@ struct timex {
154#ifdef __FreeBSD__154#ifdef __FreeBSD__
155155
156#ifdef _KERNEL156#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);
158#else /* !_KERNEL */158#else /* !_KERNEL */
159#include <sys/cdefs.h>159#include <sys/cdefs.h>
160160
lib/libc/include/generic-freebsd/sys/ttycom.h+2-4
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)ttycom.h 8.1 (Berkeley) 3/28/94
37 */35 */
3836
39#ifndef _SYS_TTYCOM_H_37#ifndef _SYS_TTYCOM_H_
...@@ -71,8 +69,8 @@...@@ -71,8 +69,8 @@
71 /* 89-91 conflicts: tun and tap */69 /* 89-91 conflicts: tun and tap */
72#define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* enable/get timestamp70#define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* enable/get timestamp
73 * of last input event */71 * of last input event */
74#define TIOCMGDTRWAIT _IOR('t', 90, int) /* modem: get wait on close */72/* TIOCMGDTRWAIT _IOR('t', 90, int) * was modem: get wait on close */
75#define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */73/* TIOCMSDTRWAIT _IOW('t', 91, int) * was modem: set wait on close */
76 /* 92-93 tun and tap */74 /* 92-93 tun and tap */
77 /* 94-97 conflicts: tun and tap */75 /* 94-97 conflicts: tun and tap */
78#define TIOCDRAIN _IO('t', 94) /* wait till output drained */76#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
lib/libc/include/generic-freebsd/sys/ttydefaults.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
37 */35 */
3836
39/*37/*
lib/libc/include/generic-freebsd/sys/types.h+4-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)types.h 8.6 (Berkeley) 2/19/95
37 */35 */
3836
39#ifndef _SYS_TYPES_H_37#ifndef _SYS_TYPES_H_
...@@ -299,9 +297,11 @@ typedef struct vm_page *vm_page_t;...@@ -299,9 +297,11 @@ typedef struct vm_page *vm_page_t;
299#if defined(_KERNEL) || defined(_STANDALONE)297#if defined(_KERNEL) || defined(_STANDALONE)
300#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)298#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
301#define __bool_true_false_are_defined 1299#define __bool_true_false_are_defined 1
300#if __STDC_VERSION__ < 202311L
302#define false 0301#define false 0
303#define true 1302#define true 1
304typedef _Bool bool;303typedef _Bool bool;
304#endif /* __STDC_VERSION__ < 202311L */
305#endif /* !__bool_true_false_are_defined && !__cplusplus */305#endif /* !__bool_true_false_are_defined && !__cplusplus */
306#endif /* KERNEL || _STANDALONE */306#endif /* KERNEL || _STANDALONE */
307307
...@@ -313,7 +313,9 @@ typedef _Bool bool;...@@ -313,7 +313,9 @@ typedef _Bool bool;
313313
314#if __BSD_VISIBLE314#if __BSD_VISIBLE
315315
316#ifndef _STANDALONE
316#include <sys/select.h>317#include <sys/select.h>
318#endif
317319
318/*320/*
319 * The major and minor numbers are encoded in dev_t as MMMmmmMm (where321 * 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 @@...@@ -27,22 +27,36 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ucred.h 8.4 (Berkeley) 1/9/95
32 */30 */
3331
34#ifndef _SYS_UCRED_H_32#ifndef _SYS_UCRED_H_
35#define _SYS_UCRED_H_33#define _SYS_UCRED_H_
3634
35#include <sys/types.h>
37#if defined(_KERNEL) || defined(_WANT_UCRED)36#if defined(_KERNEL) || defined(_WANT_UCRED)
38#include <sys/_lock.h>37#include <sys/_lock.h>
39#include <sys/_mutex.h>38#include <sys/_mutex.h>
40#endif39#endif
41#include <bsm/audit.h>40#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 1649/*
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
47/*61/*
48 * Credentials.62 * Credentials.
...@@ -57,39 +71,37 @@ struct loginclass;...@@ -57,39 +71,37 @@ struct loginclass;
57 *71 *
58 * See "Credential management" comment in kern_prot.c for more information.72 * See "Credential management" comment in kern_prot.c for more information.
59 */73 */
60#if defined(_KERNEL) || defined(_WANT_UCRED)
61struct ucred {74struct ucred {
62 struct mtx cr_mtx;75 struct mtx cr_mtx;
63 long cr_ref; /* (c) reference count */76 long cr_ref; /* (c) reference count */
64 u_int cr_users; /* (c) proc + thread using this cred */77 u_int cr_users; /* (c) proc + thread using this cred */
65 u_int cr_flags; /* credential flags */78 u_int cr_flags; /* credential flags */
66 struct auditinfo_addr cr_audit; /* Audit properties. */79 struct auditinfo_addr cr_audit; /* Audit properties. */
80 int cr_ngroups; /* number of supplementary groups */
67#define cr_startcopy cr_uid81#define cr_startcopy cr_uid
68 uid_t cr_uid; /* effective user id */82 uid_t cr_uid; /* effective user id */
69 uid_t cr_ruid; /* real user id */83 uid_t cr_ruid; /* real user id */
70 uid_t cr_svuid; /* saved user id */84 uid_t cr_svuid; /* saved user id */
71 int cr_ngroups; /* number of groups */85 gid_t cr_gid; /* effective group id */
72 gid_t cr_rgid; /* real group id */86 gid_t cr_rgid; /* real group id */
73 gid_t cr_svgid; /* saved group id */87 gid_t cr_svgid; /* saved group id */
74 struct uidinfo *cr_uidinfo; /* per euid resource consumption */88 struct uidinfo *cr_uidinfo; /* per euid resource consumption */
75 struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */89 struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
76 struct prison *cr_prison; /* jail(2) */90 struct prison *cr_prison; /* jail(2) */
77 struct loginclass *cr_loginclass; /* login class */91 struct loginclass *cr_loginclass; /* login class */
78 void *cr_pspare2[2]; /* general use 2 */92 void *cr_pspare2[2]; /* general use 2 */
79#define cr_endcopy cr_label93#define cr_endcopy cr_label
80 struct label *cr_label; /* MAC label */94 struct label *cr_label; /* MAC label */
81 gid_t *cr_groups; /* groups */95 gid_t *cr_groups; /* groups */
82 int cr_agroups; /* Available groups */96 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];
84};99};
85#define NOCRED ((struct ucred *)0) /* no credential available */100#define NOCRED ((struct ucred *)0) /* no credential available */
86#define FSCRED ((struct ucred *)-1) /* filesystem credential */101#define FSCRED ((struct ucred *)-1) /* filesystem credential */
87#endif /* _KERNEL || _WANT_UCRED */102#endif /* _KERNEL || _WANT_UCRED */
88103
89/*104#define XU_NGROUPS 16
90 * Flags for cr_flags.
91 */
92#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */
93105
94/*106/*
95 * This is the external representation of struct ucred.107 * This is the external representation of struct ucred.
...@@ -97,8 +109,26 @@ struct ucred {...@@ -97,8 +109,26 @@ struct ucred {
97struct xucred {109struct xucred {
98 u_int cr_version; /* structure layout version */110 u_int cr_version; /* structure layout version */
99 uid_t cr_uid; /* effective user id */111 uid_t cr_uid; /* effective user id */
100 short cr_ngroups; /* number of groups */112 short cr_ngroups; /* number of groups (incl. cr_gid). */
101 gid_t cr_groups[XU_NGROUPS]; /* groups */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 };
102 union {132 union {
103 void *_cr_unused1; /* compatibility with old ucred */133 void *_cr_unused1; /* compatibility with old ucred */
104 pid_t cr_pid;134 pid_t cr_pid;
...@@ -106,17 +136,77 @@ struct xucred {...@@ -106,17 +136,77 @@ struct xucred {
106};136};
107#define XUCRED_VERSION 0137#define XUCRED_VERSION 0
108138
109/* This can be used for both ucred and xucred structures. */139struct mac;
110#define cr_gid cr_groups[0]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
112#ifdef _KERNEL172#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
114struct thread;198struct 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
116struct credbatch {206struct credbatch {
117 struct ucred *cred;207 struct ucred *cred;
118 int users;208 u_int users;
119 int ref;209 long ref;
120};210};
121211
122static inline void212static inline void
...@@ -146,9 +236,9 @@ void crcopy(struct ucred *dest, struct ucred *src);...@@ -146,9 +236,9 @@ void crcopy(struct ucred *dest, struct ucred *src);
146struct ucred *crcopysafe(struct proc *p, struct ucred *cr);236struct ucred *crcopysafe(struct proc *p, struct ucred *cr);
147struct ucred *crdup(struct ucred *cr);237struct ucred *crdup(struct ucred *cr);
148void crextend(struct ucred *cr, int n);238void crextend(struct ucred *cr, int n);
149void proc_set_cred_init(struct proc *p, struct ucred *cr);239void proc_set_cred(struct proc *p, struct ucred *newcred);
150void proc_set_cred(struct proc *p, struct ucred *cr);240bool proc_set_cred_enforce_proc_lim(struct proc *p, struct ucred *newcred);
151void proc_unset_cred(struct proc *p);241void proc_unset_cred(struct proc *p, bool decrement_proc_count);
152void crfree(struct ucred *cr);242void crfree(struct ucred *cr);
153struct ucred *crcowsync(void);243struct ucred *crcowsync(void);
154struct ucred *crget(void);244struct ucred *crget(void);
...@@ -157,9 +247,30 @@ struct ucred *crcowget(struct ucred *cr);...@@ -157,9 +247,30 @@ struct ucred *crcowget(struct ucred *cr);
157void crcowfree(struct thread *td);247void crcowfree(struct thread *td);
158void cru2x(struct ucred *cr, struct xucred *xcr);248void cru2x(struct ucred *cr, struct xucred *xcr);
159void cru2xt(struct thread *td, struct xucred *xcr);249void cru2xt(struct thread *td, struct xucred *xcr);
160void crsetgroups(struct ucred *cr, int n, gid_t *groups);250void crsetgroups(struct ucred *cr, int ngrp, const gid_t *groups);
161bool groupmember(gid_t gid, struct ucred *cred);251void crsetgroups_and_egid(struct ucred *cr, int ngrp, const gid_t *groups,
162bool realgroupmember(gid_t gid, struct ucred *cred);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
163#endif /* _KERNEL */274#endif /* _KERNEL */
164275
165#endif /* !_SYS_UCRED_H_ */276#endif /* !_SYS_UCRED_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/sys/uio.h+6-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)uio.h 8.5 (Berkeley) 2/22/94
32 */30 */
3331
34#ifndef _SYS_UIO_H_32#ifndef _SYS_UIO_H_
...@@ -86,12 +84,14 @@ int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov,...@@ -86,12 +84,14 @@ int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov,
86int copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop);84int copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop);
87int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz);85int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz);
88int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz);86int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz);
87void exterr_copyout(struct thread *td);
89int physcopyin(void *src, vm_paddr_t dst, size_t len);88int physcopyin(void *src, vm_paddr_t dst, size_t len);
90int physcopyout(vm_paddr_t src, void *dst, size_t len);89int physcopyout(vm_paddr_t src, void *dst, size_t len);
91int physcopyin_vlist(struct bus_dma_segment *src, off_t offset,90int physcopyin_vlist(struct bus_dma_segment *src, off_t offset,
92 vm_paddr_t dst, size_t len);91 vm_paddr_t dst, size_t len);
93int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst,92int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst,
94 off_t offset, size_t len);93 off_t offset, size_t len);
94void uioadvance(struct uio *, size_t);
95int uiomove(void *cp, int n, struct uio *uio);95int uiomove(void *cp, int n, struct uio *uio);
96int uiomove_frombuf(void *buf, int buflen, struct uio *uio);96int uiomove_frombuf(void *buf, int buflen, struct uio *uio);
97int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,97int 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);...@@ -101,6 +101,10 @@ int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio);
101101
102#else /* !_KERNEL */102#else /* !_KERNEL */
103103
104#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
105#include <ssp/uio.h>
106#endif
107
104__BEGIN_DECLS108__BEGIN_DECLS
105ssize_t readv(int, const struct iovec *, int);109ssize_t readv(int, const struct iovec *, int);
106ssize_t writev(int, const struct iovec *, int);110ssize_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 {...@@ -135,6 +135,7 @@ struct umtx_robust_lists_params {
135__BEGIN_DECLS135__BEGIN_DECLS
136136
137int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2);137int _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
139__END_DECLS140__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 *);...@@ -206,6 +206,7 @@ int umtx_key_get(const void *, int, int, struct umtx_key *);
206void umtx_key_release(struct umtx_key *);206void umtx_key_release(struct umtx_key *);
207struct umtx_q *umtxq_alloc(void);207struct umtx_q *umtxq_alloc(void);
208void umtxq_busy(struct umtx_key *);208void umtxq_busy(struct umtx_key *);
209void umtxq_busy_unlocked(struct umtx_key *);
209int umtxq_count(struct umtx_key *);210int umtxq_count(struct umtx_key *);
210void umtxq_free(struct umtx_q *);211void umtxq_free(struct umtx_q *);
211struct umtxq_chain *umtxq_getchain(struct umtx_key *);212struct umtxq_chain *umtxq_getchain(struct umtx_key *);
lib/libc/include/generic-freebsd/sys/un.h-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)un.h 8.3 (Berkeley) 2/19/95
32 */30 */
3331
34#ifndef _SYS_UN_H_32#ifndef _SYS_UN_H_
...@@ -67,7 +65,6 @@ struct sockaddr_un {...@@ -67,7 +65,6 @@ struct sockaddr_un {
67#define LOCAL_PEERCRED 1 /* retrieve peer credentials */65#define LOCAL_PEERCRED 1 /* retrieve peer credentials */
68#define LOCAL_CREDS 2 /* pass credentials to receiver */66#define LOCAL_CREDS 2 /* pass credentials to receiver */
69#define LOCAL_CREDS_PERSISTENT 3 /* pass credentials to receiver */67#define LOCAL_CREDS_PERSISTENT 3 /* pass credentials to receiver */
70#define LOCAL_CONNWAIT 4 /* connects block until accepted */
7168
72/* Start of reserved space for third-party socket options. */69/* Start of reserved space for third-party socket options. */
73#define LOCAL_VENDOR SO_VENDOR70#define LOCAL_VENDOR SO_VENDOR
lib/libc/include/generic-freebsd/sys/unistd.h+17-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)unistd.h 8.2 (Berkeley) 1/7/94
32 */30 */
3331
34#ifndef _SYS_UNISTD_H_32#ifndef _SYS_UNISTD_H_
...@@ -95,7 +93,7 @@...@@ -95,7 +93,7 @@
95#endif93#endif
9694
97/* Define the POSIX.1 version we target for compliance. */95/* Define the POSIX.1 version we target for compliance. */
98#define _POSIX_VERSION 200112L96#define _POSIX_VERSION 200809L
9997
100/* access function */98/* access function */
101#define F_OK 0 /* test for existence of file */99#define F_OK 0 /* test for existence of file */
...@@ -156,6 +154,12 @@...@@ -156,6 +154,12 @@
156#define _PC_MAC_PRESENT 63154#define _PC_MAC_PRESENT 63
157#define _PC_ACL_NFS4 64155#define _PC_ACL_NFS4 64
158#define _PC_DEALLOC_PRESENT 65156#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
159#endif163#endif
160164
161/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */165/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
...@@ -210,6 +214,16 @@...@@ -210,6 +214,16 @@
210 * close_range() options.214 * close_range() options.
211 */215 */
212#define CLOSE_RANGE_CLOEXEC (1<<2)216#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
214#endif /* __BSD_VISIBLE */228#endif /* __BSD_VISIBLE */
215229
lib/libc/include/generic-freebsd/sys/unpcb.h+1-4
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)unpcb.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_UNPCB_H_32#ifndef _SYS_UNPCB_H_
...@@ -95,6 +93,7 @@ struct unpcb {...@@ -95,6 +93,7 @@ struct unpcb {
95 u_int unp_msgcount; /* (g) references from message queue */93 u_int unp_msgcount; /* (g) references from message queue */
96 u_int unp_gcrefs; /* (g) garbage collector refcount */94 u_int unp_gcrefs; /* (g) garbage collector refcount */
97 ino_t unp_ino; /* (g) fake inode number */95 ino_t unp_ino; /* (g) fake inode number */
96 mode_t unp_mode; /* (g) initial pre-bind() mode */
98 LIST_ENTRY(unpcb) unp_dead; /* (g) link in dead list */97 LIST_ENTRY(unpcb) unp_dead; /* (g) link in dead list */
99} __aligned(CACHE_LINE_SIZE);98} __aligned(CACHE_LINE_SIZE);
10099
...@@ -109,8 +108,6 @@ struct unpcb {...@@ -109,8 +108,6 @@ struct unpcb {
109#define UNP_HAVEPC 0x001108#define UNP_HAVEPC 0x001
110#define UNP_WANTCRED_ALWAYS 0x002 /* credentials wanted always */109#define UNP_WANTCRED_ALWAYS 0x002 /* credentials wanted always */
111#define UNP_WANTCRED_ONESHOT 0x004 /* credentials wanted once */110#define UNP_WANTCRED_ONESHOT 0x004 /* credentials wanted once */
112#define UNP_CONNWAIT 0x008 /* connect blocks until accepted */
113
114#define UNP_WANTCRED_MASK (UNP_WANTCRED_ONESHOT | UNP_WANTCRED_ALWAYS)111#define UNP_WANTCRED_MASK (UNP_WANTCRED_ONESHOT | UNP_WANTCRED_ALWAYS)
115112
116/*113/*
lib/libc/include/generic-freebsd/sys/user.h+48-7
...@@ -29,8 +29,6 @@...@@ -29,8 +29,6 @@
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29 * 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 OF30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.31 * SUCH DAMAGE.
32 *
33 * @(#)user.h 8.2 (Berkeley) 9/23/93
34 */32 */
3533
36#ifndef _SYS_USER_H_34#ifndef _SYS_USER_H_
...@@ -40,6 +38,7 @@...@@ -40,6 +38,7 @@
40#ifndef _KERNEL38#ifndef _KERNEL
41/* stuff that *used* to be included by user.h, or is now needed */39/* stuff that *used* to be included by user.h, or is now needed */
42#include <sys/errno.h>40#include <sys/errno.h>
41#include <sys/event.h>
43#include <sys/time.h>42#include <sys/time.h>
44#include <sys/resource.h>43#include <sys/resource.h>
45#include <sys/ucred.h>44#include <sys/ucred.h>
...@@ -87,7 +86,7 @@...@@ -87,7 +86,7 @@
87 */86 */
88#define KI_NSPARE_INT 287#define KI_NSPARE_INT 2
89#define KI_NSPARE_LONG 1288#define KI_NSPARE_LONG 12
90#define KI_NSPARE_PTR 589#define KI_NSPARE_PTR 4
9190
92#ifndef _KERNEL91#ifndef _KERNEL
93#ifndef KINFO_PROC_SIZE92#ifndef KINFO_PROC_SIZE
...@@ -213,6 +212,7 @@ struct kinfo_proc {...@@ -213,6 +212,7 @@ struct kinfo_proc {
213 * That way the spare room from both arrays will remain contiguous.212 * That way the spare room from both arrays will remain contiguous.
214 */213 */
215 struct pwddesc *ki_pd; /* pointer to process paths info */214 struct pwddesc *ki_pd; /* pointer to process paths info */
215 void *ki_uerrmsg; /* address of the ext err msg place */
216 void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */216 void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */
217 long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */217 long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */
218 long ki_sflag; /* PS_* flags */218 long ki_sflag; /* PS_* flags */
...@@ -227,7 +227,7 @@ void fill_kinfo_proc(struct proc *, struct kinfo_proc *);...@@ -227,7 +227,7 @@ void fill_kinfo_proc(struct proc *, struct kinfo_proc *);
227 * Legacy PS_ flag. This moved to p_flag but is maintained for227 * Legacy PS_ flag. This moved to p_flag but is maintained for
228 * compatibility.228 * compatibility.
229 */229 */
230#define PS_INMEM 0x00001 /* Loaded into memory. */230#define PS_INMEM 0x00001 /* Loaded into memory, always true. */
231231
232/* ki_sessflag values */232/* ki_sessflag values */
233#define KI_CTTY 0x00000001 /* controlling tty vnode active */233#define KI_CTTY 0x00000001 /* controlling tty vnode active */
...@@ -265,6 +265,8 @@ struct user {...@@ -265,6 +265,8 @@ struct user {
265#define KF_TYPE_DEV 12265#define KF_TYPE_DEV 12
266#define KF_TYPE_EVENTFD 13266#define KF_TYPE_EVENTFD 13
267#define KF_TYPE_TIMERFD 14267#define KF_TYPE_TIMERFD 14
268#define KF_TYPE_INOTIFY 15
269#define KF_TYPE_JAILDESC 16
268#define KF_TYPE_UNKNOWN 255270#define KF_TYPE_UNKNOWN 255
269271
270#define KF_VTYPE_VNON 0272#define KF_VTYPE_VNON 0
...@@ -373,7 +375,7 @@ struct kinfo_file {...@@ -373,7 +375,7 @@ struct kinfo_file {
373 struct sockaddr_storage kf_sa_peer;375 struct sockaddr_storage kf_sa_peer;
374 /* Address of so_pcb. */376 /* Address of so_pcb. */
375 uint64_t kf_sock_pcb;377 uint64_t kf_sock_pcb;
376 /* Address of inp_ppcb. */378 /* Obsolete! May be reused as a spare. */
377 uint64_t kf_sock_inpcb;379 uint64_t kf_sock_inpcb;
378 /* Address of unp_conn. */380 /* Address of unp_conn. */
379 uint64_t kf_sock_unpconn;381 uint64_t kf_sock_unpconn;
...@@ -451,11 +453,18 @@ struct kinfo_file {...@@ -451,11 +453,18 @@ struct kinfo_file {
451 uint32_t kf_timerfd_flags;453 uint32_t kf_timerfd_flags;
452 uint64_t kf_timerfd_addr;454 uint64_t kf_timerfd_addr;
453 } kf_timerfd;455 } kf_timerfd;
456 struct {
457 int32_t kf_jid;
458 } kf_jail;
454 struct {459 struct {
455 uint64_t kf_kqueue_addr;460 uint64_t kf_kqueue_addr;
456 int32_t kf_kqueue_count;461 int32_t kf_kqueue_count;
457 int32_t kf_kqueue_state;462 int32_t kf_kqueue_state;
458 } kf_kqueue;463 } kf_kqueue;
464 struct {
465 uint64_t kf_inotify_npending;
466 uint64_t kf_inotify_nbpending;
467 } kf_inotify;
459 } kf_un;468 } kf_un;
460 };469 };
461 uint16_t kf_status; /* Status flags. */470 uint16_t kf_status; /* Status flags. */
...@@ -608,7 +617,8 @@ struct kinfo_vmobject {...@@ -608,7 +617,8 @@ struct kinfo_vmobject {
608 } kvo_type_spec; /* Type-specific union */617 } kvo_type_spec; /* Type-specific union */
609 uint64_t kvo_me; /* Uniq handle for anon obj */618 uint64_t kvo_me; /* Uniq handle for anon obj */
610 uint64_t kvo_laundry; /* Number of laundry pages. */619 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];
612 uint32_t kvo_swapped; /* Number of swapped pages */622 uint32_t kvo_swapped; /* Number of swapped pages */
613 uint32_t kvo_flags;623 uint32_t kvo_flags;
614 uint32_t _kvo_ispare[6];624 uint32_t _kvo_ispare[6];
...@@ -625,7 +635,7 @@ struct kinfo_vmobject {...@@ -625,7 +635,7 @@ struct kinfo_vmobject {
625#define KKST_MAXLEN 1024635#define KKST_MAXLEN 1024
626636
627#define KKST_STATE_STACKOK 0 /* Stack is valid. */637#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. */
629#define KKST_STATE_RUNNING 2 /* Stack ephemeral. */639#define KKST_STATE_RUNNING 2 /* Stack ephemeral. */
630640
631#if defined(__amd64__) || defined(__i386__)641#if defined(__amd64__) || defined(__i386__)
...@@ -667,6 +677,35 @@ struct kinfo_vm_layout {...@@ -667,6 +677,35 @@ struct kinfo_vm_layout {
667 uintptr_t kvm_spare[12];677 uintptr_t kvm_spare[12];
668};678};
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
670#ifdef _KERNEL709#ifdef _KERNEL
671/* Flags for kern_proc_out function. */710/* Flags for kern_proc_out function. */
672#define KERN_PROC_NOTHREADS 0x1711#define KERN_PROC_NOTHREADS 0x1
...@@ -694,6 +733,8 @@ int kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen);...@@ -694,6 +733,8 @@ int kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen);
694int kern_proc_out(struct proc *p, struct sbuf *sb, int flags);733int kern_proc_out(struct proc *p, struct sbuf *sb, int flags);
695int kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen,734int kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen,
696 int flags);735 int flags);
736int kern_proc_kqueues_out(struct proc *p, struct sbuf *s, size_t maxlen,
737 bool compat32);
697738
698int vntype_to_kinfo(int vtype);739int vntype_to_kinfo(int vtype);
699void pack_kinfo(struct kinfo_file *kif);740void pack_kinfo(struct kinfo_file *kif);
lib/libc/include/generic-freebsd/sys/utsname.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)utsname.h 8.1 (Berkeley) 1/4/94
35 */33 */
3634
37#ifndef _SYS_UTSNAME_H35#ifndef _SYS_UTSNAME_H
lib/libc/include/generic-freebsd/sys/vmmeter.h+8-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94
32 */30 */
3331
34#ifndef _SYS_VMMETER_H_32#ifndef _SYS_VMMETER_H_
...@@ -122,6 +120,7 @@ struct vmmeter {...@@ -122,6 +120,7 @@ struct vmmeter {
122 counter_u64_t v_rforkpages; /* (p) pages affected by rfork() */120 counter_u64_t v_rforkpages; /* (p) pages affected by rfork() */
123 counter_u64_t v_kthreadpages; /* (p) ... and by kernel fork() */121 counter_u64_t v_kthreadpages; /* (p) ... and by kernel fork() */
124 counter_u64_t v_wire_count; /* (p) pages wired down */122 counter_u64_t v_wire_count; /* (p) pages wired down */
123 counter_u64_t v_nofree_count; /* (p) permanently allocated pages */
125#define VM_METER_NCOUNTERS \124#define VM_METER_NCOUNTERS \
126 (offsetof(struct vmmeter, v_page_size) / sizeof(counter_u64_t))125 (offsetof(struct vmmeter, v_page_size) / sizeof(counter_u64_t))
127 /*126 /*
...@@ -176,6 +175,13 @@ vm_wire_count(void)...@@ -176,6 +175,13 @@ vm_wire_count(void)
176 return (VM_CNT_FETCH(v_wire_count));175 return (VM_CNT_FETCH(v_wire_count));
177}176}
178177
178static inline u_int
179vm_nofree_count(void)
180{
181
182 return (VM_CNT_FETCH(v_nofree_count));
183}
184
179/*185/*
180 * Return TRUE if we are under our severe low-free-pages threshold186 * Return TRUE if we are under our severe low-free-pages threshold
181 *187 *
lib/libc/include/generic-freebsd/sys/vnode.h+83-25
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)vnode.h 8.7 (Berkeley) 2/4/94
32 */30 */
3331
34#ifndef _SYS_VNODE_H_32#ifndef _SYS_VNODE_H_
...@@ -69,6 +67,11 @@ __enum_uint8_decl(vtype) {...@@ -69,6 +67,11 @@ __enum_uint8_decl(vtype) {
69 VLASTTYPE = VMARKER,67 VLASTTYPE = VMARKER,
70};68};
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
72__enum_uint8_decl(vstate) {75__enum_uint8_decl(vstate) {
73 VSTATE_UNINITIALIZED,76 VSTATE_UNINITIALIZED,
74 VSTATE_CONSTRUCTED,77 VSTATE_CONSTRUCTED,
...@@ -88,11 +91,13 @@ enum vgetstate {...@@ -88,11 +91,13 @@ enum vgetstate {
88 * it from v_data. If non-null, this area is freed in getnewvnode().91 * it from v_data. If non-null, this area is freed in getnewvnode().
89 */92 */
9093
91struct namecache;
92struct cache_fpl;94struct cache_fpl;
95struct inotify_watch;
96struct namecache;
9397
94struct vpollinfo {98struct vpollinfo {
95 struct mtx vpi_lock; /* lock to protect below */99 struct mtx vpi_lock; /* lock to protect below */
100 TAILQ_HEAD(, inotify_watch) vpi_inotify; /* list of inotify watchers */
96 struct selinfo vpi_selinfo; /* identity of poller(s) */101 struct selinfo vpi_selinfo; /* identity of poller(s) */
97 short vpi_events; /* what they are looking for */102 short vpi_events; /* what they are looking for */
98 short vpi_revents; /* what has happened */103 short vpi_revents; /* what has happened */
...@@ -134,7 +139,7 @@ struct vnode {...@@ -134,7 +139,7 @@ struct vnode {
134 seqc_t v_seqc; /* i modification count */139 seqc_t v_seqc; /* i modification count */
135 uint32_t v_nchash; /* u namecache hash */140 uint32_t v_nchash; /* u namecache hash */
136 u_int v_hash;141 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 */
138 void *v_data; /* u private data for fs */143 void *v_data; /* u private data for fs */
139144
140 /*145 /*
...@@ -199,6 +204,8 @@ struct vnode {...@@ -199,6 +204,8 @@ struct vnode {
199 int v_seqc_users; /* i modifications pending */204 int v_seqc_users; /* i modifications pending */
200};205};
201206
207#define VN_ISDEV(vp) VTYPE_ISDEV((vp)->v_type)
208
202#ifndef DEBUG_LOCKS209#ifndef DEBUG_LOCKS
203#ifdef _LP64210#ifdef _LP64
204/*211/*
...@@ -248,6 +255,11 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");...@@ -248,6 +255,11 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");
248#define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */255#define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */
249#define VIRF_TEXT_REF 0x0008 /* Executable mappings ref the vnode */256#define VIRF_TEXT_REF 0x0008 /* Executable mappings ref the vnode */
250#define VIRF_CROSSMP 0x0010 /* Cross-mp vnode, no locking */257#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
252#define VI_UNUSED0 0x0001 /* unused */264#define VI_UNUSED0 0x0001 /* unused */
253#define VI_MOUNT 0x0002 /* Mount in progress */265#define VI_MOUNT 0x0002 /* Mount in progress */
...@@ -283,7 +295,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");...@@ -283,7 +295,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");
283struct vattr {295struct vattr {
284 __enum_uint8(vtype) va_type; /* vnode type (for create) */296 __enum_uint8(vtype) va_type; /* vnode type (for create) */
285 u_short va_mode; /* files access mode and type */297 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) */
287 uid_t va_uid; /* owner user id */299 uid_t va_uid; /* owner user id */
288 gid_t va_gid; /* owner group id */300 gid_t va_gid; /* owner group id */
289 nlink_t va_nlink; /* number of references to file */301 nlink_t va_nlink; /* number of references to file */
...@@ -304,6 +316,8 @@ struct vattr {...@@ -304,6 +316,8 @@ struct vattr {
304 long va_spare; /* remain quad aligned */316 long va_spare; /* remain quad aligned */
305};317};
306318
319#define VATTR_ISDEV(vap) VTYPE_ISDEV((vap)->va_type)
320
307/*321/*
308 * Flags for va_vaflags.322 * Flags for va_vaflags.
309 */323 */
...@@ -533,7 +547,7 @@ extern struct vnodeop_desc *vnodeop_descs[];...@@ -533,7 +547,7 @@ extern struct vnodeop_desc *vnodeop_descs[];
533#define VOPARG_OFFSETTO(s_type, s_offset, struct_p) \547#define VOPARG_OFFSETTO(s_type, s_offset, struct_p) \
534 ((s_type)(((char*)(struct_p)) + (s_offset)))548 ((s_type)(((char*)(struct_p)) + (s_offset)))
535549
536#ifdef DEBUG_VFS_LOCKS550#ifdef INVARIANTS
537/*551/*
538 * Support code to aid in debugging VFS locking problems. Not totally552 * Support code to aid in debugging VFS locking problems. Not totally
539 * reliable since if the thread sleeps between changing the lock553 * reliable since if the thread sleeps between changing the lock
...@@ -567,7 +581,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str);...@@ -567,7 +581,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str);
567 VNPASS(!seqc_in_modify(_vp->v_seqc), _vp); \581 VNPASS(!seqc_in_modify(_vp->v_seqc), _vp); \
568} while (0)582} while (0)
569583
570#else /* !DEBUG_VFS_LOCKS */584#else /* !INVARIANTS */
571585
572#define ASSERT_VI_LOCKED(vp, str) ((void)0)586#define ASSERT_VI_LOCKED(vp, str) ((void)0)
573#define ASSERT_VI_UNLOCKED(vp, str) ((void)0)587#define ASSERT_VI_UNLOCKED(vp, str) ((void)0)
...@@ -578,7 +592,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str);...@@ -578,7 +592,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str);
578#define ASSERT_VOP_IN_SEQC(vp) ((void)0)592#define ASSERT_VOP_IN_SEQC(vp) ((void)0)
579#define ASSERT_VOP_NOT_IN_SEQC(vp) ((void)0)593#define ASSERT_VOP_NOT_IN_SEQC(vp) ((void)0)
580594
581#endif /* DEBUG_VFS_LOCKS */595#endif /* INVARIANTS */
582596
583/*597/*
584 * This call works for vnodes in the kernel.598 * This call works for vnodes in the kernel.
...@@ -667,6 +681,7 @@ char *cache_symlink_alloc(size_t size, int flags);...@@ -667,6 +681,7 @@ char *cache_symlink_alloc(size_t size, int flags);
667void cache_symlink_free(char *string, size_t size);681void cache_symlink_free(char *string, size_t size);
668int cache_symlink_resolve(struct cache_fpl *fpl, const char *string,682int cache_symlink_resolve(struct cache_fpl *fpl, const char *string,
669 size_t len);683 size_t len);
684void cache_vop_inotify(struct vnode *vp, int event, uint32_t cookie);
670void cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,685void cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,
671 struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp);686 struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp);
672void cache_vop_rmdir(struct vnode *dvp, struct vnode *vp);687void cache_vop_rmdir(struct vnode *dvp, struct vnode *vp);
...@@ -708,6 +723,7 @@ int speedup_syncer(void);...@@ -708,6 +723,7 @@ int speedup_syncer(void);
708int vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen);723int vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen);
709int vn_getcwd(char *buf, char **retbuf, size_t *buflen);724int vn_getcwd(char *buf, char **retbuf, size_t *buflen);
710int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf);725int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf);
726int vn_fullpath_jail(struct vnode *vp, char **retbuf, char **freebuf);
711int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf);727int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf);
712int vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp,728int vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp,
713 const char *hdrl_name, size_t hrdl_name_length, char **retbuf,729 const char *hdrl_name, size_t hrdl_name_length, char **retbuf,
...@@ -836,18 +852,15 @@ void vn_seqc_write_end(struct vnode *vp);...@@ -836,18 +852,15 @@ void vn_seqc_write_end(struct vnode *vp);
836#define vn_seqc_consistent(vp, seq) seqc_consistent(&(vp)->v_seqc, seq)852#define vn_seqc_consistent(vp, seq) seqc_consistent(&(vp)->v_seqc, seq)
837853
838#define vn_rangelock_unlock(vp, cookie) \854#define vn_rangelock_unlock(vp, cookie) \
839 rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp))855 rangelock_unlock(&(vp)->v_rl, (cookie))
840#define vn_rangelock_unlock_range(vp, cookie, start, end) \
841 rangelock_unlock_range(&(vp)->v_rl, (cookie), (start), (end), \
842 VI_MTX(vp))
843#define vn_rangelock_rlock(vp, start, end) \856#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))
845#define vn_rangelock_tryrlock(vp, start, end) \858#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))
847#define vn_rangelock_wlock(vp, start, end) \860#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))
849#define vn_rangelock_trywlock(vp, start, end) \862#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
852#define vn_irflag_read(vp) atomic_load_short(&(vp)->v_irflag)865#define vn_irflag_read(vp) atomic_load_short(&(vp)->v_irflag)
853void vn_irflag_set_locked(struct vnode *vp, short toset);866void vn_irflag_set_locked(struct vnode *vp, short toset);
...@@ -872,8 +885,10 @@ int vop_stdfsync(struct vop_fsync_args *);...@@ -872,8 +885,10 @@ int vop_stdfsync(struct vop_fsync_args *);
872int vop_stdgetwritemount(struct vop_getwritemount_args *);885int vop_stdgetwritemount(struct vop_getwritemount_args *);
873int vop_stdgetpages(struct vop_getpages_args *);886int vop_stdgetpages(struct vop_getpages_args *);
874int vop_stdinactive(struct vop_inactive_args *);887int vop_stdinactive(struct vop_inactive_args *);
875int vop_stdioctl(struct vop_ioctl_args *);
876int vop_stdneed_inactive(struct vop_need_inactive_args *);888int 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 *);
877int vop_stdkqfilter(struct vop_kqfilter_args *);892int vop_stdkqfilter(struct vop_kqfilter_args *);
878int vop_stdlock(struct vop_lock1_args *);893int vop_stdlock(struct vop_lock1_args *);
879int vop_stdunlock(struct vop_unlock_args *);894int vop_stdunlock(struct vop_unlock_args *);
...@@ -913,9 +928,12 @@ int dead_read(struct vop_read_args *ap);...@@ -913,9 +928,12 @@ int dead_read(struct vop_read_args *ap);
913int dead_write(struct vop_write_args *ap);928int dead_write(struct vop_write_args *ap);
914929
915/* These are called from within the actual VOPS. */930/* 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);
916void vop_close_post(void *a, int rc);933void vop_close_post(void *a, int rc);
917void vop_create_pre(void *a);934void vop_create_pre(void *a);
918void vop_create_post(void *a, int rc);935void vop_create_post(void *a, int rc);
936void vop_deallocate_post(void *a, int rc);
919void vop_whiteout_pre(void *a);937void vop_whiteout_pre(void *a);
920void vop_whiteout_post(void *a, int rc);938void vop_whiteout_post(void *a, int rc);
921void vop_deleteextattr_pre(void *a);939void vop_deleteextattr_pre(void *a);
...@@ -931,7 +949,6 @@ void vop_mknod_post(void *a, int rc);...@@ -931,7 +949,6 @@ void vop_mknod_post(void *a, int rc);
931void vop_open_post(void *a, int rc);949void vop_open_post(void *a, int rc);
932void vop_read_post(void *a, int rc);950void vop_read_post(void *a, int rc);
933void vop_read_pgcache_post(void *ap, int rc);951void vop_read_pgcache_post(void *ap, int rc);
934void vop_readdir_post(void *a, int rc);
935void vop_reclaim_post(void *a, int rc);952void vop_reclaim_post(void *a, int rc);
936void vop_remove_pre(void *a);953void vop_remove_pre(void *a);
937void vop_remove_post(void *a, int rc);954void vop_remove_post(void *a, int rc);
...@@ -949,7 +966,7 @@ void vop_symlink_pre(void *a);...@@ -949,7 +966,7 @@ void vop_symlink_pre(void *a);
949void vop_symlink_post(void *a, int rc);966void vop_symlink_post(void *a, int rc);
950int vop_sigdefer(struct vop_vector *vop, struct vop_generic_args *a);967int vop_sigdefer(struct vop_vector *vop, struct vop_generic_args *a);
951968
952#ifdef DEBUG_VFS_LOCKS969#ifdef INVARIANTS
953void vop_fdatasync_debugpre(void *a);970void vop_fdatasync_debugpre(void *a);
954void vop_fdatasync_debugpost(void *a, int rc);971void vop_fdatasync_debugpost(void *a, int rc);
955void vop_fplookup_vexec_debugpre(void *a);972void vop_fplookup_vexec_debugpre(void *a);
...@@ -991,9 +1008,10 @@ void vop_rename_fail(struct vop_rename_args *ap);...@@ -991,9 +1008,10 @@ void vop_rename_fail(struct vop_rename_args *ap);
991 AUDIT_ARG_VNODE1(ap->a_vp); \1008 AUDIT_ARG_VNODE1(ap->a_vp); \
992 _error = mac_vnode_check_stat(_ap->a_active_cred, _ap->a_file_cred, _ap->a_vp);\1009 _error = mac_vnode_check_stat(_ap->a_active_cred, _ap->a_file_cred, _ap->a_vp);\
993 if (__predict_true(_error == 0)) { \1010 if (__predict_true(_error == 0)) { \
994 ap->a_sb->st_padding0 = 0; \
995 ap->a_sb->st_padding1 = 0; \1011 ap->a_sb->st_padding1 = 0; \
996 bzero(_ap->a_sb->st_spare, sizeof(_ap->a_sb->st_spare)); \1012 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; \
997 } \1015 } \
998 _error; \1016 _error; \
999})1017})
...@@ -1006,7 +1024,36 @@ void vop_rename_fail(struct vop_rename_args *ap);...@@ -1006,7 +1024,36 @@ void vop_rename_fail(struct vop_rename_args *ap);
1006 _error; \1024 _error; \
1007})1025})
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) \
1010 struct vattr va; \1057 struct vattr va; \
1011 int error; \1058 int error; \
1012 off_t osize, ooffset, noffset; \1059 off_t osize, ooffset, noffset; \
...@@ -1020,11 +1067,14 @@ void vop_rename_fail(struct vop_rename_args *ap);...@@ -1020,11 +1067,14 @@ void vop_rename_fail(struct vop_rename_args *ap);
1020 osize = (off_t)va.va_size; \1067 osize = (off_t)va.va_size; \
1021 }1068 }
10221069
1023#define VOP_WRITE_POST(ap, ret) \1070#define vop_write_post(ap, ret) \
1024 noffset = (ap)->a_uio->uio_offset; \1071 noffset = (ap)->a_uio->uio_offset; \
1025 if (noffset > ooffset && !VN_KNLIST_EMPTY((ap)->a_vp)) { \1072 if (noffset > ooffset) { \
1026 VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE \1073 if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \
1027 | (noffset > osize ? NOTE_EXTEND : 0)); \1074 VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \
1075 (noffset > osize ? NOTE_EXTEND : 0)); \
1076 } \
1077 INOTIFY((ap)->a_vp, IN_MODIFY); \
1028 }1078 }
10291079
1030#define VOP_LOCK(vp, flags) VOP_LOCK1(vp, flags, __FILE__, __LINE__)1080#define VOP_LOCK(vp, flags) VOP_LOCK1(vp, flags, __FILE__, __LINE__)
...@@ -1084,7 +1134,14 @@ vrefcnt(struct vnode *vp)...@@ -1084,7 +1134,14 @@ vrefcnt(struct vnode *vp)
1084 vref(vp); \1134 vref(vp); \
1085} while (0)1135} 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
1087int vnode_create_vobject(struct vnode *vp, off_t size, struct thread *td);1143int 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);
1088void vnode_destroy_vobject(struct vnode *vp);1145void vnode_destroy_vobject(struct vnode *vp);
10891146
1090extern struct vop_vector fifo_specops;1147extern struct vop_vector fifo_specops;
...@@ -1190,6 +1247,7 @@ vn_get_state(struct vnode *vp)...@@ -1190,6 +1247,7 @@ vn_get_state(struct vnode *vp)
1190#define vfs_smr_exit() smr_exit(VFS_SMR())1247#define vfs_smr_exit() smr_exit(VFS_SMR())
1191#define vfs_smr_synchronize() smr_synchronize(VFS_SMR())1248#define vfs_smr_synchronize() smr_synchronize(VFS_SMR())
1192#define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR())1249#define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR())
1250#define VFS_SMR_ENTERED() SMR_ENTERED(VFS_SMR())
1193#define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR())1251#define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR())
1194#define VFS_SMR_ASSERT_NOT_ENTERED() SMR_ASSERT_NOT_ENTERED(VFS_SMR())1252#define VFS_SMR_ASSERT_NOT_ENTERED() SMR_ASSERT_NOT_ENTERED(VFS_SMR())
1195#define VFS_SMR_ZONE_SET(zone) uma_zone_set_smr((zone), VFS_SMR())1253#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)wait.h 8.2 (Berkeley) 7/10/94
32 */30 */
3331
34#ifndef _SYS_WAIT_H_32#ifndef _SYS_WAIT_H_
lib/libc/include/generic-freebsd/sys/watchdog.h+19-6
...@@ -32,15 +32,16 @@...@@ -32,15 +32,16 @@
32#define _SYS_WATCHDOG_H32#define _SYS_WATCHDOG_H
3333
34#include <sys/ioccom.h>34#include <sys/ioccom.h>
35#include <sys/_types.h>
3536
36#define _PATH_WATCHDOG "fido"37#define _PATH_WATCHDOG "fido"
3738
38#define WDIOCPATPAT _IOW('W', 42, u_int) /* pat the watchdog */39#define WDIOC_PATPAT _IOW('W', 52, sbintime_t) /* pat the watchdog */
39#define WDIOC_SETTIMEOUT _IOW('W', 43, int) /* set/reset the timer */40#define WDIOC_SETTIMEOUT _IOW('W', 53, sbintime_t) /* set/reset the timer */
40#define WDIOC_GETTIMEOUT _IOR('W', 44, int) /* get total timeout */41#define WDIOC_GETTIMEOUT _IOR('W', 54, sbintime_t) /* get total timeout */
41#define WDIOC_GETTIMELEFT _IOR('W', 45, int) /* get time left */42#define WDIOC_GETTIMELEFT _IOR('W', 55, sbintime_t) /* get time left */
42#define WDIOC_GETPRETIMEOUT _IOR('W', 46, int) /* get the pre-timeout */43#define WDIOC_GETPRETIMEOUT _IOR('W', 56, sbintime_t) /* get the pre-timeout */
43#define WDIOC_SETPRETIMEOUT _IOW('W', 47, int) /* set the pre-timeout */44#define WDIOC_SETPRETIMEOUT _IOW('W', 57, sbintime_t) /* set the pre-timeout */
44/* set the action when a pre-timeout occurs see: WD_SOFT_* */45/* set the action when a pre-timeout occurs see: WD_SOFT_* */
45#define WDIOC_SETPRETIMEOUTACT _IOW('W', 48, int)46#define WDIOC_SETPRETIMEOUTACT _IOW('W', 48, int)
4647
...@@ -48,6 +49,8 @@...@@ -48,6 +49,8 @@
48#define WDIOC_SETSOFT _IOW('W', 49, int)49#define WDIOC_SETSOFT _IOW('W', 49, int)
49#define WDIOC_SETSOFTTIMEOUTACT _IOW('W', 50, int)50#define WDIOC_SETSOFTTIMEOUTACT _IOW('W', 50, int)
5051
52#define WDIOC_CONTROL _IOW('W', 51, int) /* configure watchdog */
53
51#define WD_ACTIVE 0x800000054#define WD_ACTIVE 0x8000000
52 /* 55 /*
53 * Watchdog reset, timeout set to value in WD_INTERVAL field.56 * Watchdog reset, timeout set to value in WD_INTERVAL field.
...@@ -93,6 +96,11 @@...@@ -93,6 +96,11 @@
93#define WD_TO_64SEC 3696#define WD_TO_64SEC 36
94#define WD_TO_128SEC 3797#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
96/* action on pre-timeout trigger */104/* action on pre-timeout trigger */
97#define WD_SOFT_PANIC 0x01 /* panic */105#define WD_SOFT_PANIC 0x01 /* panic */
98#define WD_SOFT_DDB 0x02 /* enter debugger */106#define WD_SOFT_DDB 0x02 /* enter debugger */
...@@ -105,11 +113,16 @@...@@ -105,11 +113,16 @@
105#include <sys/_eventhandler.h>113#include <sys/_eventhandler.h>
106114
107typedef void (*watchdog_fn)(void *, u_int, int *);115typedef void (*watchdog_fn)(void *, u_int, int *);
116typedef void (*watchdog_sbt_fn)(void *, sbintime_t, sbintime_t *, int *);
108117
109EVENTHANDLER_DECLARE(watchdog_list, watchdog_fn);118EVENTHANDLER_DECLARE(watchdog_list, watchdog_fn);
119EVENTHANDLER_DECLARE(watchdog_sbt_list, watchdog_sbt_fn);
110120
111u_int wdog_kern_last_timeout(void);121u_int wdog_kern_last_timeout(void);
112int wdog_kern_pat(u_int utim);122int 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
114/*127/*
115 * The following function pointer is used to attach a software watchdog128 * The following function pointer is used to attach a software watchdog
lib/libc/include/generic-freebsd/sysexits.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)sysexits.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYSEXITS_H_32#ifndef _SYSEXITS_H_
lib/libc/include/generic-freebsd/syslog.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)syslog.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _SYS_SYSLOG_H_32#ifndef _SYS_SYSLOG_H_
lib/libc/include/generic-freebsd/tar.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)tar.h 8.2 (Berkeley) 1/4/94
35 */33 */
3634
37#ifndef _TAR_H35#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)termios.h 8.3 (Berkeley) 3/28/94
32 */30 */
3331
34#ifndef _TERMIOS_H_32#ifndef _TERMIOS_H_
lib/libc/include/generic-freebsd/time.h+6-3
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
37 */35 */
3836
39/*37/*
...@@ -157,6 +155,8 @@ int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);...@@ -157,6 +155,8 @@ int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
157#if __POSIX_VISIBLE >= 199506155#if __POSIX_VISIBLE >= 199506
158char *asctime_r(const struct tm *, char *);156char *asctime_r(const struct tm *, char *);
159char *ctime_r(const time_t *, char *);157char *ctime_r(const time_t *, char *);
158#endif
159#if __POSIX_VISIBLE >= 199506 || __ISO_C_VISIBLE >= 2023
160struct tm *gmtime_r(const time_t *, struct tm *);160struct tm *gmtime_r(const time_t *, struct tm *);
161struct tm *localtime_r(const time_t *, struct tm *);161struct tm *localtime_r(const time_t *, struct tm *);
162#endif162#endif
...@@ -164,15 +164,18 @@ struct tm *localtime_r(const time_t *, struct tm *);...@@ -164,15 +164,18 @@ struct tm *localtime_r(const time_t *, struct tm *);
164#if __XSI_VISIBLE164#if __XSI_VISIBLE
165char *strptime(const char * __restrict, const char * __restrict,165char *strptime(const char * __restrict, const char * __restrict,
166 struct tm * __restrict);166 struct tm * __restrict);
167extern long timezone;
168extern int daylight;
167#endif169#endif
168170
169#if __BSD_VISIBLE171#if __BSD_VISIBLE
170char *timezone(int, int); /* XXX XSI conflict */
171time_t timelocal(struct tm * const);172time_t timelocal(struct tm * const);
172time_t timegm(struct tm * const);173time_t timegm(struct tm * const);
173int timer_oshandle_np(timer_t timerid);174int timer_oshandle_np(timer_t timerid);
174time_t time2posix(time_t t);175time_t time2posix(time_t t);
175time_t posix2time(time_t t);176time_t posix2time(time_t t);
177struct tm *offtime(const time_t *, long);
178struct tm *offtime_r(const time_t *__restrict, long, struct tm *__restrict);
176#endif /* __BSD_VISIBLE */179#endif /* __BSD_VISIBLE */
177180
178#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)181#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
lib/libc/include/generic-freebsd/timeconv.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
37 */35 */
3836
39/*37/*
lib/libc/include/generic-freebsd/ttyent.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ttyent.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _TTYENT_H_32#ifndef _TTYENT_H_
lib/libc/include/generic-freebsd/ufs/ffs/ffs_extern.h+2-3
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95
32 */30 */
3331
34#ifndef _UFS_FFS_EXTERN_H32#ifndef _UFS_FFS_EXTERN_H
...@@ -84,7 +82,8 @@ int ffs_inotovp(struct mount *, ino_t, uint64_t, int, struct vnode **,...@@ -84,7 +82,8 @@ int ffs_inotovp(struct mount *, ino_t, uint64_t, int, struct vnode **,
84 int);82 int);
85int ffs_isblock(struct fs *, uint8_t *, ufs1_daddr_t);83int ffs_isblock(struct fs *, uint8_t *, ufs1_daddr_t);
86int ffs_isfreeblock(struct fs *, uint8_t *, ufs1_daddr_t);84int 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);
88int ffs_own_mount(const struct mount *mp);87int ffs_own_mount(const struct mount *mp);
89int ffs_sbsearch(void *, struct fs **, int, struct malloc_type *,88int ffs_sbsearch(void *, struct fs **, int, struct malloc_type *,
90 int (*)(void *, off_t, void **, int));89 int (*)(void *, off_t, void **, int));
lib/libc/include/generic-freebsd/ufs/ffs/fs.h+3-4
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)fs.h 8.13 (Berkeley) 3/21/95
32 */30 */
3331
34#ifndef _UFS_FFS_FS_H_32#ifndef _UFS_FFS_FS_H_
...@@ -413,7 +411,8 @@ struct fs {...@@ -413,7 +411,8 @@ struct fs {
413 int64_t fs_unrefs; /* number of unreferenced inodes */411 int64_t fs_unrefs; /* number of unreferenced inodes */
414 int64_t fs_providersize; /* size of underlying GEOM provider */412 int64_t fs_providersize; /* size of underlying GEOM provider */
415 int64_t fs_metaspace; /* size of area reserved for metadata */413 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 */
417 int64_t fs_sblockactualloc; /* byte offset of this superblock */416 int64_t fs_sblockactualloc; /* byte offset of this superblock */
418 int64_t fs_sblockloc; /* byte offset of standard superblock */417 int64_t fs_sblockloc; /* byte offset of standard superblock */
419 struct csum_total fs_cstotal; /* (u) cylinder summary information */418 struct csum_total fs_cstotal; /* (u) cylinder summary information */
...@@ -426,7 +425,7 @@ struct fs {...@@ -426,7 +425,7 @@ struct fs {
426 uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */425 uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
427 uint32_t fs_avgfilesize; /* expected average file size */426 uint32_t fs_avgfilesize; /* expected average file size */
428 uint32_t fs_avgfpdir; /* expected # of files per directory */427 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 */
430 ufs_time_t fs_mtime; /* Last mount or fsck time. */429 ufs_time_t fs_mtime; /* Last mount or fsck time. */
431 int32_t fs_sujfree; /* SUJ free list */430 int32_t fs_sujfree; /* SUJ free list */
432 int32_t fs_sparecon32[21]; /* reserved for future constants */431 int32_t fs_sparecon32[21]; /* reserved for future constants */
lib/libc/include/generic-freebsd/ufs/ffs/softdep.h-2
...@@ -36,8 +36,6 @@...@@ -36,8 +36,6 @@
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY36 * 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 OF37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.38 * SUCH DAMAGE.
39 *
40 * @(#)softdep.h 9.7 (McKusick) 6/21/00
41 */39 */
4240
43#include <sys/queue.h>41#include <sys/queue.h>
lib/libc/include/generic-freebsd/ufs/ufs/dinode.h+20-8
...@@ -62,8 +62,6 @@...@@ -62,8 +62,6 @@
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.64 * SUCH DAMAGE.
65 *
66 * @(#)dinode.h 8.3 (Berkeley) 1/21/94
67 */65 */
6866
69#ifndef _UFS_UFS_DINODE_H_67#ifndef _UFS_UFS_DINODE_H_
...@@ -113,12 +111,13 @@ typedef int64_t ufs_time_t;...@@ -113,12 +111,13 @@ typedef int64_t ufs_time_t;
113#define IFWHT 0160000 /* Whiteout. */111#define IFWHT 0160000 /* Whiteout. */
114112
115/*113/*
116 * A dinode contains all the meta-data associated with a UFS2 file.114 * Each UFS filesystem version defines the on-disk format of its dinode.
117 * This structure defines the on-disk format of a dinode. Since115 *
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
118 * this structure describes an on-disk structure, all its fields118 * this structure describes an on-disk structure, all its fields
119 * are defined by types with precise widths.119 * are defined by types with precise widths.
120 */120 */
121
122#define UFS_NXADDR 2 /* External addresses in inode. */121#define UFS_NXADDR 2 /* External addresses in inode. */
123#define UFS_NDADDR 12 /* Direct addresses in inode. */122#define UFS_NDADDR 12 /* Direct addresses in inode. */
124#define UFS_NIADDR 3 /* Indirect addresses in inode. */123#define UFS_NIADDR 3 /* Indirect addresses in inode. */
...@@ -186,11 +185,11 @@ struct ufs1_dinode {...@@ -186,11 +185,11 @@ struct ufs1_dinode {
186 uint32_t di_dirdepth; /* 4: IFDIR: depth from root dir */185 uint32_t di_dirdepth; /* 4: IFDIR: depth from root dir */
187 };186 };
188 uint64_t di_size; /* 8: File byte count. */187 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. */
190 int32_t di_atimensec; /* 20: Last access time. */189 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. */
192 int32_t di_mtimensec; /* 28: Last modified time. */191 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. */
194 int32_t di_ctimensec; /* 36: Last inode change time. */193 int32_t di_ctimensec; /* 36: Last inode change time. */
195 union {194 union {
196 struct {195 struct {
...@@ -212,4 +211,17 @@ struct ufs1_dinode {...@@ -212,4 +211,17 @@ struct ufs1_dinode {
212211
213#define UFS_LINK_MAX 65500 /* leave a few spare for special values */212#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
215#endif /* _UFS_UFS_DINODE_H_ */227#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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)dir.h 8.2 (Berkeley) 1/21/94
37 */35 */
3836
39#ifndef _UFS_UFS_DIR_H_37#ifndef _UFS_UFS_DIR_H_
lib/libc/include/generic-freebsd/ufs/ufs/inode.h+3-8
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)inode.h 8.9 (Berkeley) 5/14/95
37 */35 */
3836
39#ifndef _UFS_UFS_INODE_H_37#ifndef _UFS_UFS_INODE_H_
...@@ -90,10 +88,7 @@ struct inode {...@@ -90,10 +88,7 @@ struct inode {
90 /*88 /*
91 * The real copy of the on-disk inode.89 * The real copy of the on-disk inode.
92 */90 */
93 union {91 union dinodep i_dp; /* On-disk dinode */
94 struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */
95 struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */
96 } dinode_u;
9792
98 ino_t i_number; /* The identity of the inode. */93 ino_t i_number; /* The identity of the inode. */
99 uint32_t i_flag; /* flags, see below */94 uint32_t i_flag; /* flags, see below */
...@@ -206,8 +201,8 @@ struct inode {...@@ -206,8 +201,8 @@ struct inode {
206201
207#define i_dirhash i_un.dirhash202#define i_dirhash i_un.dirhash
208#define i_snapblklist i_un.snapblklist203#define i_snapblklist i_un.snapblklist
209#define i_din1 dinode_u.din1204#define i_din1 i_dp.dp1
210#define i_din2 dinode_u.din2205#define i_din2 i_dp.dp2
211206
212#define ITOUMP(ip) ((ip)->i_ump)207#define ITOUMP(ip) ((ip)->i_ump)
213#define ITODEV(ip) (ITOUMP(ip)->um_dev)208#define ITODEV(ip) (ITOUMP(ip)->um_dev)
lib/libc/include/generic-freebsd/ufs/ufs/quota.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * @(#)quota.h 8.3 (Berkeley) 8/19/94
35 */33 */
3634
37#ifndef _UFS_UFS_QUOTA_H_35#ifndef _UFS_UFS_QUOTA_H_
lib/libc/include/generic-freebsd/ufs/ufs/ufs_extern.h+5-7
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95
32 */30 */
3331
34#ifndef _UFS_UFS_EXTERN_H_32#ifndef _UFS_UFS_EXTERN_H_
...@@ -61,15 +59,15 @@ int ufs_bmap_seekdata(struct vnode *, off_t *);...@@ -61,15 +59,15 @@ int ufs_bmap_seekdata(struct vnode *, off_t *);
61int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *);59int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *);
62void ufs_dirbad(struct inode *, doff_t, char *);60void ufs_dirbad(struct inode *, doff_t, char *);
63int ufs_dirbadentry(struct vnode *, struct direct *, int);61int 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);
65int ufs_extread(struct vop_read_args *);63int ufs_extread(struct vop_read_args *);
66int ufs_extwrite(struct vop_write_args *);64int ufs_extwrite(struct vop_write_args *);
67void ufs_makedirentry(struct inode *, struct componentname *,65void ufs_makedirentry(struct inode *, struct componentname *,
68 struct direct *);66 struct direct *);
69int ufs_direnter(struct vnode *, struct vnode *, struct direct *,67int ufs_direnter(struct vnode *, struct vnode *, struct direct *,
70 struct componentname *, struct buf *);68 struct componentname *, struct buf *);
71int ufs_dirremove(struct vnode *, struct inode *, int, int);69int ufs_dirremove(struct vnode *, struct inode *, int, bool);
72int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, int);70int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, u_int);
73int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *,71int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *,
74 ino_t *);72 ino_t *);
75int ufs_getlbns(struct vnode *, ufs2_daddr_t, struct indir *, int *);73int 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,...@@ -95,9 +93,9 @@ int softdep_setup_directory_add(struct buf *, struct inode *, off_t,
95 ino_t, struct buf *, int);93 ino_t, struct buf *, int);
96void softdep_change_directoryentry_offset(struct buf *, struct inode *,94void softdep_change_directoryentry_offset(struct buf *, struct inode *,
97 caddr_t, caddr_t, caddr_t, int);95 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);
99void softdep_setup_directory_change(struct buf *, struct inode *,97void softdep_setup_directory_change(struct buf *, struct inode *,
100 struct inode *, ino_t, int);98 struct inode *, ino_t, u_int);
101void softdep_change_linkcnt(struct inode *);99void softdep_change_linkcnt(struct inode *);
102int softdep_slowdown(struct vnode *);100int softdep_slowdown(struct vnode *);
103void softdep_setup_create(struct inode *, struct inode *);101void softdep_setup_create(struct inode *, struct inode *);
lib/libc/include/generic-freebsd/ufs/ufs/ufsmount.h-4
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95
32 */30 */
3331
34#ifndef _UFS_UFS_UFSMOUNT_H_32#ifndef _UFS_UFS_UFSMOUNT_H_
...@@ -99,8 +97,6 @@ struct ufsmount {...@@ -99,8 +97,6 @@ struct ufsmount {
99 uint64_t um_maxsymlinklen; /* (c) max size of short97 uint64_t um_maxsymlinklen; /* (c) max size of short
100 symlink */98 symlink */
101 struct mtx um_lock; /* (c) Protects ufsmount & fs */99 struct mtx um_lock; /* (c) Protects ufsmount & fs */
102 struct sx um_checkpath_lock; /* (c) Protects ufs_checkpath()
103 result */
104 struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */100 struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */
105 struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */101 struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */
106 struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */102 struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */
lib/libc/include/generic-freebsd/unistd.h+10-3
...@@ -27,19 +27,20 @@...@@ -27,19 +27,20 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
32 */30 */
3331
34#ifndef _UNISTD_H_32#ifndef _UNISTD_H_
35#define _UNISTD_H_33#define _UNISTD_H_
3634
37#include <sys/cdefs.h>
38#include <sys/types.h> /* XXX adds too much pollution. */35#include <sys/types.h> /* XXX adds too much pollution. */
39#include <sys/unistd.h>36#include <sys/unistd.h>
40#include <sys/_null.h>37#include <sys/_null.h>
41#include <sys/_types.h>38#include <sys/_types.h>
4239
40#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0
41#include <ssp/unistd.h>
42#endif
43
43#ifndef _GID_T_DECLARED44#ifndef _GID_T_DECLARED
44typedef __gid_t gid_t;45typedef __gid_t gid_t;
45#define _GID_T_DECLARED46#define _GID_T_DECLARED
...@@ -291,6 +292,11 @@ typedef __useconds_t useconds_t;...@@ -291,6 +292,11 @@ typedef __useconds_t useconds_t;
291#define _SC_NPROCESSORS_CONF 57292#define _SC_NPROCESSORS_CONF 57
292#define _SC_NPROCESSORS_ONLN 58293#define _SC_NPROCESSORS_ONLN 58
293#define _SC_CPUSET_SIZE 122294#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
294#endif300#endif
295301
296/* Extensions found in Solaris and Linux. */302/* Extensions found in Solaris and Linux. */
...@@ -506,6 +512,7 @@ int exect(const char *, char * const *, char * const *);...@@ -506,6 +512,7 @@ int exect(const char *, char * const *, char * const *);
506int execvP(const char *, const char *, char * const *);512int execvP(const char *, const char *, char * const *);
507int execvpe(const char *, char * const *, char * const *);513int execvpe(const char *, char * const *, char * const *);
508int feature_present(const char *);514int feature_present(const char *);
515int fchroot(int);
509char *fflagstostr(u_long);516char *fflagstostr(u_long);
510int getdomainname(char *, int);517int getdomainname(char *, int);
511int getentropy(void *, size_t);518int getentropy(void *, size_t);
lib/libc/include/generic-freebsd/utime.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)utime.h 8.1 (Berkeley) 6/2/93
32 */30 */
3331
34#ifndef _UTIME_H_32#ifndef _UTIME_H_
lib/libc/include/generic-freebsd/vm/_vm_radix.h+3-6
...@@ -31,16 +31,13 @@...@@ -31,16 +31,13 @@
31#ifndef __VM_RADIX_H_31#ifndef __VM_RADIX_H_
32#define __VM_RADIX_H_32#define __VM_RADIX_H_
3333
34/*34#include <sys/_pctrie.h>
35 * Radix tree node.
36 */
37struct vm_radix_node;
3835
39/*36/*
40 * Radix tree root.37 * Radix tree
41 */38 */
42struct vm_radix {39struct vm_radix {
43 struct vm_radix_node *rt_root;40 struct pctrie rt_trie;
44};41};
4542
46#endif /* !__VM_RADIX_H_ */43#endif /* !__VM_RADIX_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/vm/pmap.h+8-10
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)pmap.h 8.1 (Berkeley) 6/11/93
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -83,8 +81,8 @@ typedef struct pmap_statistics *pmap_statistics_t;...@@ -83,8 +81,8 @@ typedef struct pmap_statistics *pmap_statistics_t;
83 * Each machine-dependent implementation is required to provide:81 * Each machine-dependent implementation is required to provide:
84 *82 *
85 * vm_memattr_t pmap_page_get_memattr(vm_page_t);83 * vm_memattr_t pmap_page_get_memattr(vm_page_t);
86 * boolean_t pmap_page_is_mapped(vm_page_t);84 * bool pmap_page_is_mapped(vm_page_t);
87 * boolean_t pmap_page_is_write_mapped(vm_page_t);85 * bool pmap_page_is_write_mapped(vm_page_t);
88 * void pmap_page_set_memattr(vm_page_t, vm_memattr_t);86 * void pmap_page_set_memattr(vm_page_t, vm_memattr_t);
89 */87 */
90#include <machine/pmap.h>88#include <machine/pmap.h>
...@@ -138,17 +136,17 @@ void pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m,...@@ -138,17 +136,17 @@ void pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m,
138vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va);136vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va);
139vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va,137vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va,
140 vm_prot_t prot);138 vm_prot_t prot);
141void pmap_growkernel(vm_offset_t);139int pmap_growkernel(vm_offset_t);
142void pmap_init(void);140void pmap_init(void);
143boolean_t pmap_is_modified(vm_page_t m);141bool pmap_is_modified(vm_page_t m);
144boolean_t pmap_is_prefaultable(pmap_t pmap, vm_offset_t va);142bool pmap_is_prefaultable(pmap_t pmap, vm_offset_t va);
145boolean_t pmap_is_referenced(vm_page_t m);143bool pmap_is_referenced(vm_page_t m);
146boolean_t pmap_is_valid_memattr(pmap_t, vm_memattr_t);144bool pmap_is_valid_memattr(pmap_t, vm_memattr_t);
147vm_offset_t pmap_map(vm_offset_t *, vm_paddr_t, vm_paddr_t, int);145vm_offset_t pmap_map(vm_offset_t *, vm_paddr_t, vm_paddr_t, int);
148int pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *pap);146int pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *pap);
149void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr,147void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr,
150 vm_object_t object, vm_pindex_t pindex, vm_size_t size);148 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);
152void pmap_page_init(vm_page_t m);150void pmap_page_init(vm_page_t m);
153int pmap_page_wired_mappings(vm_page_t m);151int pmap_page_wired_mappings(vm_page_t m);
154int pmap_pinit(pmap_t);152int pmap_pinit(pmap_t);
lib/libc/include/generic-freebsd/vm/swap_pager.h+4-3
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)swap_pager.h 7.1 (Berkeley) 12/5/90
37 */35 */
3836
39#ifndef _VM_SWAP_PAGER_H_37#ifndef _VM_SWAP_PAGER_H_
...@@ -70,13 +68,16 @@ struct swdevt {...@@ -70,13 +68,16 @@ struct swdevt {
7068
71#ifdef _KERNEL69#ifdef _KERNEL
7270
71extern bool swap_pager_almost_full;
73extern int swap_pager_avail;72extern int swap_pager_avail;
74extern int nsw_cluster_max;73extern int nsw_cluster_max;
7574
76struct xswdev;75struct xswdev;
77int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len);76int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len);
78void swap_pager_copy(vm_object_t, vm_object_t, vm_pindex_t, int);77void 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);
80void swap_pager_freespace(vm_object_t object, vm_pindex_t start,81void swap_pager_freespace(vm_object_t object, vm_pindex_t start,
81 vm_size_t size, vm_size_t *freed);82 vm_size_t size, vm_size_t *freed);
82void swap_pager_swap_init(void);83void 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,...@@ -252,6 +252,7 @@ uma_zone_t uma_zcache_create(const char *name, int size, uma_ctor ctor,
252#define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */252#define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */
253#define UMA_ZONE_NOBUCKET 0x0400 /* Do not use buckets. */253#define UMA_ZONE_NOBUCKET 0x0400 /* Do not use buckets. */
254#define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets. */254#define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets. */
255#define UMA_ZONE_NOTRIM 0x1000 /* Don't trim this zone */
255#define UMA_ZONE_CACHESPREAD 0x2000 /*256#define UMA_ZONE_CACHESPREAD 0x2000 /*
256 * Spread memory start locations across257 * Spread memory start locations across
257 * all possible cache lines. May258 * all possible cache lines. May
lib/libc/include/generic-freebsd/vm/vm.h+7-5
...@@ -28,10 +28,6 @@...@@ -28,10 +28,6 @@
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *30 *
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 *
35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.31 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
36 * All rights reserved.32 * All rights reserved.
37 *33 *
...@@ -80,6 +76,7 @@ typedef u_char vm_prot_t; /* protection codes */...@@ -80,6 +76,7 @@ typedef u_char vm_prot_t; /* protection codes */
80#define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */76#define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */
81#define VM_PROT_PRIV_FLAG ((vm_prot_t) 0x10)77#define VM_PROT_PRIV_FLAG ((vm_prot_t) 0x10)
82#define VM_PROT_FAULT_LOOKUP VM_PROT_PRIV_FLAG78#define VM_PROT_FAULT_LOOKUP VM_PROT_PRIV_FLAG
79#define VM_PROT_NO_PROMOTE VM_PROT_PRIV_FLAG
83#define VM_PROT_QUICK_NOFAULT VM_PROT_PRIV_FLAG /* same to save bits */80#define VM_PROT_QUICK_NOFAULT VM_PROT_PRIV_FLAG /* same to save bits */
8481
85#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)82#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
...@@ -158,6 +155,12 @@ struct kva_md_info {...@@ -158,6 +155,12 @@ struct kva_md_info {
158#define SWAP_RESERVE_RLIMIT_ON (1 << 1)155#define SWAP_RESERVE_RLIMIT_ON (1 << 1)
159#define SWAP_RESERVE_ALLOW_NONWIRED (1 << 2)156#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
161#ifdef _KERNEL164#ifdef _KERNEL
162struct ucred;165struct ucred;
163166
...@@ -167,7 +170,6 @@ bool swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred);...@@ -167,7 +170,6 @@ bool swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred);
167void swap_reserve_force(vm_ooffset_t incr);170void swap_reserve_force(vm_ooffset_t incr);
168void swap_release(vm_ooffset_t decr);171void swap_release(vm_ooffset_t decr);
169void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);172void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);
170void swapper(void);
171173
172extern struct kva_md_info kmi;174extern struct kva_md_info kmi;
173#define VA_IS_CLEANMAP(va) \175#define VA_IS_CLEANMAP(va) \
lib/libc/include/generic-freebsd/vm/vm_domainset.h+13-5
...@@ -28,25 +28,33 @@...@@ -28,25 +28,33 @@
28#ifndef __VM_DOMAINSET_H__28#ifndef __VM_DOMAINSET_H__
29#define __VM_DOMAINSET_H__29#define __VM_DOMAINSET_H__
3030
31struct pctrie_iter;
32
31struct vm_domainset_iter {33struct vm_domainset_iter {
32 struct domainset *di_domain;34 struct domainset *di_domain;
33 unsigned int *di_iter;35 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;
34 vm_pindex_t di_offset;42 vm_pindex_t di_offset;
35 int di_flags;43 int di_flags;
36 uint16_t di_policy;44 uint16_t di_policy;
37 domainid_t di_n;
38 bool di_minskip;45 bool di_minskip;
39};46};
4047
41int vm_domainset_iter_page(struct vm_domainset_iter *, struct vm_object *,48int vm_domainset_iter_page(struct vm_domainset_iter *, struct vm_object *,
42 int *);49 int *, struct pctrie_iter *);
43void vm_domainset_iter_page_init(struct vm_domainset_iter *,50int vm_domainset_iter_page_init(struct vm_domainset_iter *,
44 struct vm_object *, vm_pindex_t, int *, int *);51 struct vm_object *, vm_pindex_t, int *, int *);
45int vm_domainset_iter_policy(struct vm_domainset_iter *, int *);52int 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 *,
47 struct domainset *, int *, int *);54 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 *,
49 struct domainset_ref *, int *, int *);56 struct domainset_ref *, int *, int *);
57void vm_domainset_iter_ignore(struct vm_domainset_iter *, int);
5058
51int vm_wait_doms(const domainset_t *, int mflags);59int vm_wait_doms(const domainset_t *, int mflags);
5260
lib/libc/include/generic-freebsd/vm/vm_extern.h+4-6
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94
32 */30 */
3331
34#ifndef _VM_EXTERN_H_32#ifndef _VM_EXTERN_H_
...@@ -85,14 +83,16 @@ void kmem_init(vm_offset_t, vm_offset_t);...@@ -85,14 +83,16 @@ void kmem_init(vm_offset_t, vm_offset_t);
85void kmem_init_zero_region(void);83void kmem_init_zero_region(void);
86void kmeminit(void);84void kmeminit(void);
8785
88int kernacc(void *, int, int);86bool kernacc(void *, int, int);
89int useracc(void *, int, int);87bool useracc(void *, int, int);
90int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,88int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
91 int fault_flags, vm_page_t *m_hold);89 int fault_flags, vm_page_t *m_hold);
92void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,90void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,
93 vm_ooffset_t *);91 vm_ooffset_t *);
94int vm_fault_disable_pagefaults(void);92int vm_fault_disable_pagefaults(void);
95void vm_fault_enable_pagefaults(int save);93void 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);
96int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,96int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
97 vm_prot_t prot, vm_page_t *ma, int max_count);97 vm_prot_t prot, vm_page_t *ma, int max_count);
98int vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,98int 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);...@@ -129,8 +129,6 @@ struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset);
129void vm_imgact_unmap_page(struct sf_buf *sf);129void vm_imgact_unmap_page(struct sf_buf *sf);
130void vm_thread_dispose(struct thread *td);130void vm_thread_dispose(struct thread *td);
131int vm_thread_new(struct thread *td, int pages);131int 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);
134u_int vm_active_count(void);132u_int vm_active_count(void);
135u_int vm_inactive_count(void);133u_int vm_inactive_count(void);
136u_int vm_laundry_count(void);134u_int vm_laundry_count(void);
lib/libc/include/generic-freebsd/vm/vm_kern.h-5
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)vm_kern.h 8.1 (Berkeley) 6/11/93
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -71,13 +69,10 @@ extern struct vm_map exec_map_store;...@@ -71,13 +69,10 @@ extern struct vm_map exec_map_store;
71extern struct vm_map pipe_map_store;69extern struct vm_map pipe_map_store;
72#define pipe_map (&pipe_map_store)70#define pipe_map (&pipe_map_store)
73extern struct vmem *kernel_arena;71extern struct vmem *kernel_arena;
74extern struct vmem *kmem_arena;
75extern struct vmem *buffer_arena;72extern struct vmem *buffer_arena;
76extern struct vmem *transient_arena;73extern struct vmem *transient_arena;
77extern struct vmem *memguard_arena;74extern struct vmem *memguard_arena;
78extern u_long vm_kmem_size;75extern u_long vm_kmem_size;
79extern u_int exec_map_entries;76extern u_int exec_map_entries;
80extern u_int exec_map_entry_size;77extern u_int exec_map_entry_size;
81extern vm_object_t kstack_object;
82
83#endif /* _VM_VM_KERN_H_ */78#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 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * @(#)vm_map.h 8.9 (Berkeley) 5/17/95
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -77,7 +75,6 @@...@@ -77,7 +75,6 @@
77 * vm_map_entry_t an entry in an address map.75 * vm_map_entry_t an entry in an address map.
78 */76 */
7977
80typedef u_char vm_flags_t;
81typedef u_int vm_eflags_t;78typedef u_int vm_eflags_t;
8279
83/*80/*
...@@ -96,9 +93,9 @@ union vm_map_object {...@@ -96,9 +93,9 @@ union vm_map_object {
96 * and user-exported inheritance and protection information.93 * and user-exported inheritance and protection information.
97 * Also included is control information for virtual copy operations.94 * Also included is control information for virtual copy operations.
98 *95 *
99 * For stack gap map entries (MAP_ENTRY_GUARD | MAP_ENTRY_GROWS_DOWN96 * For stack gap map entries (MAP_ENTRY_GUARD | MAP_ENTRY_STACK_GAP),
100 * or UP), the next_read member is reused as the stack_guard_page97 * the next_read member is reused as the stack_guard_page storage, and
101 * storage, and offset is the stack protection.98 * offset is the stack protection.
102 */99 */
103struct vm_map_entry {100struct vm_map_entry {
104 struct vm_map_entry *left; /* left child or previous entry */101 struct vm_map_entry *left; /* left child or previous entry */
...@@ -141,14 +138,14 @@ struct vm_map_entry {...@@ -141,14 +138,14 @@ struct vm_map_entry {
141 a core */138 a core */
142#define MAP_ENTRY_VN_EXEC 0x00000800 /* text vnode mapping */139#define MAP_ENTRY_VN_EXEC 0x00000800 /* text vnode mapping */
143#define MAP_ENTRY_GROWS_DOWN 0x00001000 /* top-down stacks */140#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
146#define MAP_ENTRY_WIRE_SKIPPED 0x00004000143#define MAP_ENTRY_WIRE_SKIPPED 0x00004000
147#define MAP_ENTRY_WRITECNT 0x00008000 /* tracked writeable144#define MAP_ENTRY_WRITECNT 0x00008000 /* tracked writeable
148 mapping */145 mapping */
149#define MAP_ENTRY_GUARD 0x00010000146#define MAP_ENTRY_GUARD 0x00010000
150#define MAP_ENTRY_STACK_GAP_DN 0x00020000147#define MAP_ENTRY_STACK_GAP 0x00020000
151#define MAP_ENTRY_STACK_GAP_UP 0x00040000148#define MAP_ENTRY_UNUSED1 0x00040000
152#define MAP_ENTRY_HEADER 0x00080000149#define MAP_ENTRY_HEADER 0x00080000
153150
154#define MAP_ENTRY_SPLIT_BOUNDARY_MASK 0x00300000151#define MAP_ENTRY_SPLIT_BOUNDARY_MASK 0x00300000
...@@ -205,14 +202,14 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry)...@@ -205,14 +202,14 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry)
205 */202 */
206struct vm_map {203struct vm_map {
207 struct vm_map_entry header; /* List of entries */204 struct vm_map_entry header; /* List of entries */
208 struct sx lock; /* Lock for map data */205 union {
209 struct mtx system_mtx;206 struct sx lock; /* Lock for map data */
207 struct mtx system_mtx;
208 };
210 int nentries; /* Number of entries */209 int nentries; /* Number of entries */
211 vm_size_t size; /* virtual size */210 vm_size_t size; /* virtual size */
212 u_int timestamp; /* Version number */211 u_int timestamp; /* Version number */
213 u_char needs_wakeup;212 u_int flags; /* flags for this vm_map */
214 u_char system_map; /* (c) Am I a system map? */
215 vm_flags_t flags; /* flags for this vm_map */
216 vm_map_entry_t root; /* Root of a binary search tree */213 vm_map_entry_t root; /* Root of a binary search tree */
217 pmap_t pmap; /* (c) Physical map */214 pmap_t pmap; /* (c) Physical map */
218 vm_offset_t anon_loc;215 vm_offset_t anon_loc;
...@@ -223,16 +220,21 @@ struct vm_map {...@@ -223,16 +220,21 @@ struct vm_map {
223};220};
224221
225/*222/*
226 * vm_flags_t values223 * vm_map flags values
227 */224 */
228#define MAP_WIREFUTURE 0x01 /* wire all future pages */225#define MAP_WIREFUTURE 0x00000001 /* wire all future pages */
229#define MAP_BUSY_WAKEUP 0x02 /* thread(s) waiting on busy state */226#define MAP_BUSY_WAKEUP 0x00000002 /* thread(s) waiting on busy
230#define MAP_IS_SUB_MAP 0x04 /* has parent */227 state */
231#define MAP_ASLR 0x08 /* enabled ASLR */228#define MAP_IS_SUB_MAP 0x00000004 /* has parent */
232#define MAP_ASLR_IGNSTART 0x10 /* ASLR ignores data segment */229#define MAP_ASLR 0x00000008 /* enabled ASLR */
233#define MAP_REPLENISH 0x20 /* kmapent zone needs to be refilled */230#define MAP_ASLR_IGNSTART 0x00000010 /* ASLR ignores data segment */
234#define MAP_WXORX 0x40 /* enforce W^X */231#define MAP_REPLENISH 0x00000020 /* kmapent zone needs to be
235#define MAP_ASLR_STACK 0x80 /* stack location is randomized */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
237#ifdef _KERNEL239#ifdef _KERNEL
238#if defined(KLD_MODULE) && !defined(KLD_TIED)240#if defined(KLD_MODULE) && !defined(KLD_TIED)
...@@ -263,7 +265,7 @@ vm_map_pmap(vm_map_t map)...@@ -263,7 +265,7 @@ vm_map_pmap(vm_map_t map)
263}265}
264266
265static __inline void267static __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)
267{269{
268 map->flags = (map->flags | set) & ~clear;270 map->flags = (map->flags | set) & ~clear;
269}271}
...@@ -278,6 +280,12 @@ vm_map_range_valid(vm_map_t map, vm_offset_t start, vm_offset_t end)...@@ -278,6 +280,12 @@ vm_map_range_valid(vm_map_t map, vm_offset_t start, vm_offset_t end)
278 return (true);280 return (true);
279}281}
280282
283static inline bool
284vm_map_is_system(vm_map_t map)
285{
286 return ((map->flags & MAP_SYSTEM_MAP) != 0);
287}
288
281#endif /* KLD_MODULE */289#endif /* KLD_MODULE */
282#endif /* _KERNEL */290#endif /* _KERNEL */
283291
...@@ -378,12 +386,12 @@ long vmspace_resident_count(struct vmspace *vmspace);...@@ -378,12 +386,12 @@ long vmspace_resident_count(struct vmspace *vmspace);
378#define MAP_PREFAULT_MADVISE 0x00000200 /* from (user) madvise request */386#define MAP_PREFAULT_MADVISE 0x00000200 /* from (user) madvise request */
379#define MAP_WRITECOUNT 0x00000400387#define MAP_WRITECOUNT 0x00000400
380#define MAP_REMAP 0x00000800388#define MAP_REMAP 0x00000800
381#define MAP_STACK_GROWS_DOWN 0x00001000389#define MAP_STACK_AREA 0x00001000
382#define MAP_STACK_GROWS_UP 0x00002000390#define MAP_COW_UNUSED0 0x00002000
383#define MAP_ACC_CHARGED 0x00004000391#define MAP_ACC_CHARGED 0x00004000
384#define MAP_ACC_NO_CHARGE 0x00008000392#define MAP_ACC_NO_CHARGE 0x00008000
385#define MAP_CREATE_STACK_GAP_UP 0x00010000393#define MAP_COW_UNUSED1 0x00010000
386#define MAP_CREATE_STACK_GAP_DN 0x00020000394#define MAP_CREATE_STACK_GAP 0x00020000
387#define MAP_VN_EXEC 0x00040000395#define MAP_VN_EXEC 0x00040000
388#define MAP_SPLIT_BOUNDARY_MASK 0x00180000396#define MAP_SPLIT_BOUNDARY_MASK 0x00180000
389#define MAP_NO_HINT 0x00200000397#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,...@@ -486,6 +494,7 @@ int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t,
486vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t);494vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t);
487int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t);495int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t);
488void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t);496void 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);
489int 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);498int 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);
490int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,499int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
491 vm_pindex_t *, vm_prot_t *, boolean_t *);500 vm_pindex_t *, vm_prot_t *, boolean_t *);
lib/libc/include/generic-freebsd/vm/vm_object.h+2-4
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)vm_object.h 8.3 (Berkeley) 1/12/94
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -100,7 +98,6 @@ struct vm_object {...@@ -100,7 +98,6 @@ struct vm_object {
100 TAILQ_ENTRY(vm_object) object_list; /* list of all objects */98 TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
101 LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */99 LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
102 LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */100 LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
103 struct pglist memq; /* list of resident pages */
104 struct vm_radix rtree; /* root of the resident page radix trie*/101 struct vm_radix rtree; /* root of the resident page radix trie*/
105 vm_pindex_t size; /* Object size */102 vm_pindex_t size; /* Object size */
106 struct domainset_ref domain; /* NUMA policy. */103 struct domainset_ref domain; /* NUMA policy. */
...@@ -206,7 +203,6 @@ struct vm_object {...@@ -206,7 +203,6 @@ struct vm_object {
206#define OBJ_PAGERPRIV2 0x00008000 /* Pager private */203#define OBJ_PAGERPRIV2 0x00008000 /* Pager private */
207#define OBJ_SYSVSHM 0x00010000 /* SysV SHM */204#define OBJ_SYSVSHM 0x00010000 /* SysV SHM */
208#define OBJ_POSIXSHM 0x00020000 /* Posix SHM */205#define OBJ_POSIXSHM 0x00020000 /* Posix SHM */
209#define OBJ_CDEVH 0x00040000 /* OBJT_DEVICE handle is cdev */
210206
211/*207/*
212 * Helpers to perform conversion between vm_object page indexes and offsets.208 * 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,...@@ -379,6 +375,8 @@ void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start,
379void vm_object_page_remove(vm_object_t object, vm_pindex_t start,375void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
380 vm_pindex_t end, int options);376 vm_pindex_t end, int options);
381boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t);377boolean_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);
382void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);380void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);
383void vm_object_reference (vm_object_t);381void vm_object_reference (vm_object_t);
384void vm_object_reference_locked(vm_object_t);382void vm_object_reference_locked(vm_object_t);
lib/libc/include/generic-freebsd/vm/vm_page.h+67-112
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -80,10 +78,6 @@...@@ -80,10 +78,6 @@
80 * A radix tree used to quickly78 * A radix tree used to quickly
81 * perform object/offset lookups79 * perform object/offset lookups
82 *80 *
83 * A list of all pages for a given object,
84 * so they can be quickly deactivated at
85 * time of deallocation.
86 *
87 * An ordered list of pages due for pageout.81 * An ordered list of pages due for pageout.
88 *82 *
89 * In addition, the structure contains the object83 * In addition, the structure contains the object
...@@ -235,7 +229,6 @@ struct vm_page {...@@ -235,7 +229,6 @@ struct vm_page {
235 void *zone;229 void *zone;
236 } uma;230 } uma;
237 } plinks;231 } plinks;
238 TAILQ_ENTRY(vm_page) listq; /* pages in same object (O) */
239 vm_object_t object; /* which object am I in (O) */232 vm_object_t object; /* which object am I in (O) */
240 vm_pindex_t pindex; /* offset into object (O,P) */233 vm_pindex_t pindex; /* offset into object (O,P) */
241 vm_paddr_t phys_addr; /* physical address of page (C) */234 vm_paddr_t phys_addr; /* physical address of page (C) */
...@@ -343,50 +336,6 @@ SLIST_HEAD(spglist, vm_page);...@@ -343,50 +336,6 @@ SLIST_HEAD(spglist, vm_page);
343extern vm_page_t bogus_page;336extern vm_page_t bogus_page;
344#endif /* _KERNEL */337#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
390/*339/*
391 * The vm_page's aflags are updated using atomic operations. To set or clear340 * The vm_page's aflags are updated using atomic operations. To set or clear
392 * these flags, the functions vm_page_aflag_set() and vm_page_aflag_clear()341 * these flags, the functions vm_page_aflag_set() and vm_page_aflag_clear()
...@@ -459,6 +408,7 @@ extern struct mtx_padalign pa_lock[];...@@ -459,6 +408,7 @@ extern struct mtx_padalign pa_lock[];
459#define PG_ZERO 0x04 /* page is zeroed */408#define PG_ZERO 0x04 /* page is zeroed */
460#define PG_MARKER 0x08 /* special queue marker page */409#define PG_MARKER 0x08 /* special queue marker page */
461#define PG_NODUMP 0x10 /* don't include this page in a dump */410#define PG_NODUMP 0x10 /* don't include this page in a dump */
411#define PG_NOFREE 0x20 /* page should never be freed. */
462412
463/*413/*
464 * Misc constants.414 * Misc constants.
...@@ -472,6 +422,7 @@ extern struct mtx_padalign pa_lock[];...@@ -472,6 +422,7 @@ extern struct mtx_padalign pa_lock[];
472422
473#include <sys/kassert.h>423#include <sys/kassert.h>
474#include <machine/atomic.h>424#include <machine/atomic.h>
425struct pctrie_iter;
475426
476/*427/*
477 * Each pageable resident page falls into one of five lists:428 * Each pageable resident page falls into one of five lists:
...@@ -511,13 +462,15 @@ extern long first_page; /* first physical page number */...@@ -511,13 +462,15 @@ extern long first_page; /* first physical page number */
511vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);462vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
512463
513/*464/*
514 * Page allocation parameters for vm_page for the functions465 * vm_page allocation arguments for the functions vm_page_alloc(),
515 * vm_page_alloc(), vm_page_grab(), vm_page_alloc_contig() and466 * vm_page_alloc_contig(), vm_page_alloc_noobj(), vm_page_grab(), and
516 * vm_page_alloc_freelist(). Some functions support only a subset467 * vm_page_grab_pages(). Each function supports only a subset of the flags.
517 * of the flags, and ignore others, see the flags legend.468 * See the flags legend.
518 *469 *
519 * The meaning of VM_ALLOC_ZERO differs slightly between the vm_page_alloc*()470 * The meaning of VM_ALLOC_ZERO varies: vm_page_alloc_noobj(), vm_page_grab(),
520 * and the vm_page_grab*() functions. See these functions for details.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.
521 *474 *
522 * Bits 0 - 1 define class.475 * Bits 0 - 1 define class.
523 * Bits 2 - 15 dedicated for flags.476 * Bits 2 - 15 dedicated for flags.
...@@ -525,7 +478,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);...@@ -525,7 +478,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
525 * (a) - vm_page_alloc() supports the flag.478 * (a) - vm_page_alloc() supports the flag.
526 * (c) - vm_page_alloc_contig() supports the flag.479 * (c) - vm_page_alloc_contig() supports the flag.
527 * (g) - vm_page_grab() supports the flag.480 * (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.
529 * (p) - vm_page_grab_pages() supports the flag.482 * (p) - vm_page_grab_pages() supports the flag.
530 * Bits above 15 define the count of additional pages that the caller483 * Bits above 15 define the count of additional pages that the caller
531 * intends to allocate.484 * intends to allocate.
...@@ -534,26 +487,26 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);...@@ -534,26 +487,26 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
534#define VM_ALLOC_INTERRUPT 1487#define VM_ALLOC_INTERRUPT 1
535#define VM_ALLOC_SYSTEM 2488#define VM_ALLOC_SYSTEM 2
536#define VM_ALLOC_CLASS_MASK 3489#define VM_ALLOC_CLASS_MASK 3
537#define VM_ALLOC_WAITOK 0x0008 /* (acn) Sleep and retry */490#define VM_ALLOC_WAITOK 0x0008 /* (gnp) Sleep and retry */
538#define VM_ALLOC_WAITFAIL 0x0010 /* (acn) Sleep and return error */491#define VM_ALLOC_WAITFAIL 0x0010 /* (acgnp) Sleep and return error */
539#define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */492#define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */
540#define VM_ALLOC_ZERO 0x0040 /* (acgnp) Allocate a zeroed page */493#define VM_ALLOC_ZERO 0x0040 /* (acgnp) Allocate a zeroed page */
541#define VM_ALLOC_NORECLAIM 0x0080 /* (c) Do not reclaim after failure */494#define VM_ALLOC_NORECLAIM 0x0080 /* (c) Do not reclaim after failure */
542#define VM_ALLOC_AVAIL0 0x0100495#define VM_ALLOC_NOFREE 0x0100 /* (agnp) Page will never be freed */
543#define VM_ALLOC_NOBUSY 0x0200 /* (acgp) Do not excl busy the page */496#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 */
545#define VM_ALLOC_AVAIL1 0x0800498#define VM_ALLOC_AVAIL1 0x0800
546#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy flag */499#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy state */
547#define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */500#define VM_ALLOC_NODUMP 0x2000 /* (acgnp) Do not include in dump */
548#define VM_ALLOC_SBUSY 0x4000 /* (acgp) Shared busy the page */501#define VM_ALLOC_SBUSY 0x4000 /* (acgp) Shared busy the page */
549#define VM_ALLOC_NOWAIT 0x8000 /* (acgnp) Do not sleep */502#define VM_ALLOC_NOWAIT 0x8000 /* (acgnp) Do not sleep */
550#define VM_ALLOC_COUNT_MAX 0xffff503#define VM_ALLOC_COUNT_MAX 0xffff
551#define VM_ALLOC_COUNT_SHIFT 16504#define VM_ALLOC_COUNT_SHIFT 16
552#define VM_ALLOC_COUNT_MASK (VM_ALLOC_COUNT(VM_ALLOC_COUNT_MAX))505#define VM_ALLOC_COUNT_MASK (VM_ALLOC_COUNT(VM_ALLOC_COUNT_MAX))
553#define VM_ALLOC_COUNT(count) ({ \506#define VM_ALLOC_COUNT(count) ({ /* (acgn) Additional pages */ \
554 KASSERT((count) <= VM_ALLOC_COUNT_MAX, \507 KASSERT((count) <= VM_ALLOC_COUNT_MAX, \
555 ("%s: invalid VM_ALLOC_COUNT value", __func__)); \508 ("%s: invalid VM_ALLOC_COUNT value", __func__)); \
556 (count) << VM_ALLOC_COUNT_SHIFT; \509 (count) << VM_ALLOC_COUNT_SHIFT; \
557})510})
558511
559#ifdef M_NOWAIT512#ifdef M_NOWAIT
...@@ -577,6 +530,8 @@ malloc2vm_flags(int malloc_flags)...@@ -577,6 +530,8 @@ malloc2vm_flags(int malloc_flags)
577 pflags |= VM_ALLOC_WAITOK;530 pflags |= VM_ALLOC_WAITOK;
578 if ((malloc_flags & M_NORECLAIM))531 if ((malloc_flags & M_NORECLAIM))
579 pflags |= VM_ALLOC_NORECLAIM;532 pflags |= VM_ALLOC_NORECLAIM;
533 if ((malloc_flags & M_NEVERFREED))
534 pflags |= VM_ALLOC_NOFREE;
580 return (pflags);535 return (pflags);
581}536}
582#endif537#endif
...@@ -593,22 +548,9 @@ malloc2vm_flags(int malloc_flags)...@@ -593,22 +548,9 @@ malloc2vm_flags(int malloc_flags)
593#define PS_ALL_VALID 0x2548#define PS_ALL_VALID 0x2
594#define PS_NONE_BUSY 0x4549#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
605void vm_page_activate (vm_page_t);551void vm_page_activate (vm_page_t);
606void vm_page_advise(vm_page_t m, int advice);552void vm_page_advise(vm_page_t m, int advice);
607vm_page_t vm_page_alloc(vm_object_t, vm_pindex_t, int);553vm_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);
612vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,554vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
613 u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment,555 u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment,
614 vm_paddr_t boundary, vm_memattr_t memattr);556 vm_paddr_t boundary, vm_memattr_t memattr);
...@@ -616,8 +558,10 @@ vm_page_t vm_page_alloc_contig_domain(vm_object_t object,...@@ -616,8 +558,10 @@ vm_page_t vm_page_alloc_contig_domain(vm_object_t object,
616 vm_pindex_t pindex, int domain, int req, u_long npages, vm_paddr_t low,558 vm_pindex_t pindex, int domain, int req, u_long npages, vm_paddr_t low,
617 vm_paddr_t high, u_long alignment, vm_paddr_t boundary,559 vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
618 vm_memattr_t memattr);560 vm_memattr_t memattr);
619vm_page_t vm_page_alloc_freelist(int, int);561vm_page_t vm_page_alloc_domain_iter(vm_object_t object, vm_pindex_t pindex,
620vm_page_t vm_page_alloc_freelist_domain(int, int, int);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);
621vm_page_t vm_page_alloc_noobj(int);565vm_page_t vm_page_alloc_noobj(int);
622vm_page_t vm_page_alloc_noobj_domain(int, int);566vm_page_t vm_page_alloc_noobj_domain(int, int);
623vm_page_t vm_page_alloc_noobj_contig(int req, u_long npages, vm_paddr_t low,567vm_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,...@@ -628,7 +572,26 @@ vm_page_t vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages,
628 vm_memattr_t memattr);572 vm_memattr_t memattr);
629void vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set);573void vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set);
630bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose);574bool 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);
631vm_page_t vm_page_grab(vm_object_t, vm_pindex_t, int);592vm_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);
632vm_page_t vm_page_grab_unlocked(vm_object_t, vm_pindex_t, int);595vm_page_t vm_page_grab_unlocked(vm_object_t, vm_pindex_t, int);
633int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,596int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
634 vm_page_t *ma, int count);597 vm_page_t *ma, int count);
...@@ -636,37 +599,38 @@ int vm_page_grab_pages_unlocked(vm_object_t object, vm_pindex_t pindex,...@@ -636,37 +599,38 @@ int vm_page_grab_pages_unlocked(vm_object_t object, vm_pindex_t pindex,
636 int allocflags, vm_page_t *ma, int count);599 int allocflags, vm_page_t *ma, int count);
637int vm_page_grab_valid(vm_page_t *mp, vm_object_t object, vm_pindex_t pindex,600int vm_page_grab_valid(vm_page_t *mp, vm_object_t object, vm_pindex_t pindex,
638 int allocflags);601 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);
639int vm_page_grab_valid_unlocked(vm_page_t *mp, vm_object_t object,604int vm_page_grab_valid_unlocked(vm_page_t *mp, vm_object_t object,
640 vm_pindex_t pindex, int allocflags);605 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);
648void vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr);606void vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr);
649void vm_page_init_marker(vm_page_t marker, int queue, uint16_t aflags);607void 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);
651int vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);609int vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
652void vm_page_invalid(vm_page_t m);610void 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);
653void vm_page_launder(vm_page_t m);619void vm_page_launder(vm_page_t m);
654vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t);620vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t);
655vm_page_t vm_page_lookup_unlocked(vm_object_t, vm_pindex_t);621vm_page_t vm_page_lookup_unlocked(vm_object_t, vm_pindex_t);
656vm_page_t vm_page_next(vm_page_t m);
657void vm_page_pqbatch_drain(void);622void vm_page_pqbatch_drain(void);
658void vm_page_pqbatch_submit(vm_page_t m, uint8_t queue);623void vm_page_pqbatch_submit(vm_page_t m, uint8_t queue);
659bool vm_page_pqstate_commit(vm_page_t m, vm_page_astate_t *old,624bool vm_page_pqstate_commit(vm_page_t m, vm_page_astate_t *old,
660 vm_page_astate_t new);625 vm_page_astate_t new);
661vm_page_t vm_page_prev(vm_page_t m);626bool vm_page_ps_test(vm_page_t m, int psind, int flags, vm_page_t skip_m);
662bool vm_page_ps_test(vm_page_t m, int flags, vm_page_t skip_m);
663void vm_page_putfake(vm_page_t m);627void vm_page_putfake(vm_page_t m);
664void vm_page_readahead_finish(vm_page_t m);628void 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,
666 vm_paddr_t high, u_long alignment, vm_paddr_t boundary);630 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,
668 vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary);632 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,
670 vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,634 vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
671 int desired_runs);635 int desired_runs);
672void vm_page_reference(vm_page_t m);636void vm_page_reference(vm_page_t m);
...@@ -677,7 +641,6 @@ void vm_page_release_locked(vm_page_t m, int flags);...@@ -677,7 +641,6 @@ void vm_page_release_locked(vm_page_t m, int flags);
677vm_page_t vm_page_relookup(vm_object_t, vm_pindex_t);641vm_page_t vm_page_relookup(vm_object_t, vm_pindex_t);
678bool vm_page_remove(vm_page_t);642bool vm_page_remove(vm_page_t);
679bool vm_page_remove_xbusy(vm_page_t);643bool vm_page_remove_xbusy(vm_page_t);
680int vm_page_rename(vm_page_t, vm_object_t, vm_pindex_t);
681void vm_page_replace(vm_page_t mnew, vm_object_t object,644void vm_page_replace(vm_page_t mnew, vm_object_t object,
682 vm_pindex_t pindex, vm_page_t mold);645 vm_pindex_t pindex, vm_page_t mold);
683int vm_page_sbusied(vm_page_t m);646int vm_page_sbusied(vm_page_t m);
...@@ -706,16 +669,8 @@ int vm_page_is_valid(vm_page_t, int, int);...@@ -706,16 +669,8 @@ int vm_page_is_valid(vm_page_t, int, int);
706void vm_page_test_dirty(vm_page_t);669void vm_page_test_dirty(vm_page_t);
707vm_page_bits_t vm_page_bits(int base, int size);670vm_page_bits_t vm_page_bits(int base, int size);
708void vm_page_zero_invalid(vm_page_t m, boolean_t setvalid);671void 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
711void vm_page_dirty_KBI(vm_page_t m);673void 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
720#define vm_page_busy_fetch(m) atomic_load_int(&(m)->busy_lock)675#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);...@@ -732,9 +687,9 @@ void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line);
732#define vm_page_assert_unbusied(m) \687#define vm_page_assert_unbusied(m) \
733 KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) != \688 KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) != \
734 VPB_CURTHREAD_EXCLUSIVE, \689 VPB_CURTHREAD_EXCLUSIVE, \
735 ("vm_page_assert_xbusied: page %p busy_lock %#x owned" \690 ("vm_page_assert_unbusied: page %p busy_lock %#x owned" \
736 " by me @ %s:%d", \691 " by me (%p) @ %s:%d", \
737 (m), (m)->busy_lock, __FILE__, __LINE__)); \692 (m), (m)->busy_lock, curthread, __FILE__, __LINE__)); \
738693
739#define vm_page_assert_xbusied_unchecked(m) do { \694#define vm_page_assert_xbusied_unchecked(m) do { \
740 KASSERT(vm_page_xbusied(m), \695 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);...@@ -746,8 +701,8 @@ void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line);
746 KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) == \701 KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) == \
747 VPB_CURTHREAD_EXCLUSIVE, \702 VPB_CURTHREAD_EXCLUSIVE, \
748 ("vm_page_assert_xbusied: page %p busy_lock %#x not owned" \703 ("vm_page_assert_xbusied: page %p busy_lock %#x not owned" \
749 " by me @ %s:%d", \704 " by me (%p) @ %s:%d", \
750 (m), (m)->busy_lock, __FILE__, __LINE__)); \705 (m), (m)->busy_lock, curthread, __FILE__, __LINE__)); \
751} while (0)706} while (0)
752707
753#define vm_page_busied(m) \708#define vm_page_busied(m) \
...@@ -1018,7 +973,7 @@ vm_page_none_valid(vm_page_t m)...@@ -1018,7 +973,7 @@ vm_page_none_valid(vm_page_t m)
1018}973}
1019974
1020static inline int975static inline int
1021vm_page_domain(vm_page_t m)976vm_page_domain(vm_page_t m __numa_used)
1022{977{
1023#ifdef NUMA978#ifdef NUMA
1024 int domn, segind;979 int domn, segind;
lib/libc/include/generic-freebsd/vm/vm_pageout.h+1-6
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)vm_pageout.h 8.2 (Berkeley) 1/12/94
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -102,11 +100,8 @@ void vm_wait_domain(int domain);...@@ -102,11 +100,8 @@ void vm_wait_domain(int domain);
102void vm_wait_min(void);100void vm_wait_min(void);
103void vm_wait_severe(void);101void 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);
106void vm_pageout_oom(int shortage);104void vm_pageout_oom(int shortage);
107105
108void vm_swapout_run(void);
109void vm_swapout_run_idle(void);
110
111#endif /* _KERNEL */106#endif /* _KERNEL */
112#endif /* _VM_VM_PAGEOUT_H_ */107#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 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -245,23 +243,26 @@ struct vm_domain {...@@ -245,23 +243,26 @@ struct vm_domain {
245 } vmd_pgcache[VM_NFREEPOOL];243 } vmd_pgcache[VM_NFREEPOOL];
246 struct vmem *vmd_kernel_arena; /* (c) per-domain kva R/W arena. */244 struct vmem *vmd_kernel_arena; /* (c) per-domain kva R/W arena. */
247 struct vmem *vmd_kernel_rwx_arena; /* (c) per-domain kva R/W/X arena. */245 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. */
248 u_int vmd_domain; /* (c) Domain number. */247 u_int vmd_domain; /* (c) Domain number. */
249 u_int vmd_page_count; /* (c) Total page count. */248 u_int vmd_page_count; /* (c) Total page count. */
250 long vmd_segs; /* (c) bitmask of the segments */249 long vmd_segs; /* (c) bitmask of the segments */
250 struct pglist vmd_nofreeq; /* (f) NOFREE page bump allocator. */
251 u_int __aligned(CACHE_LINE_SIZE) vmd_free_count; /* (a,f) free page count */251 u_int __aligned(CACHE_LINE_SIZE) vmd_free_count; /* (a,f) free page count */
252 u_int vmd_pageout_deficit; /* (a) Estimated number of pages deficit */252 u_int vmd_pageout_deficit; /* (a) Estimated number of pages deficit */
253 uint8_t vmd_pad[CACHE_LINE_SIZE - (sizeof(u_int) * 2)];253 uint8_t vmd_pad[CACHE_LINE_SIZE - (sizeof(u_int) * 2)];
254254
255 /* Paging control variables, used within single threaded page daemon. */255 /* Paging control variables, used within single threaded page daemon. */
256 struct pidctrl vmd_pid; /* Pageout controller. */256 struct pidctrl vmd_pid; /* Pageout controller. */
257 boolean_t vmd_oom;257 bool vmd_oom; /* An OOM kill was requested. */
258 u_int vmd_inactive_threads;258 bool vmd_helper_threads_enabled;/* Use multiple threads to scan. */
259 u_int vmd_inactive_threads; /* Number of extra helper threads. */
259 u_int vmd_inactive_shortage; /* Per-thread shortage. */260 u_int vmd_inactive_shortage; /* Per-thread shortage. */
260 blockcount_t vmd_inactive_running; /* Number of inactive threads. */261 blockcount_t vmd_inactive_running; /* Number of inactive threads. */
261 blockcount_t vmd_inactive_starting; /* Number of threads started. */262 blockcount_t vmd_inactive_starting; /* Number of threads started. */
262 volatile u_int vmd_addl_shortage; /* Shortage accumulator. */263 u_int vmd_addl_shortage; /* (a) Shortage accumulator. */
263 volatile u_int vmd_inactive_freed; /* Successful inactive frees. */264 u_int vmd_inactive_freed; /* (a) Successful inactive frees. */
264 volatile u_int vmd_inactive_us; /* Microseconds for above. */265 u_int vmd_inactive_us; /* (a) Microseconds for above. */
265 u_int vmd_inactive_pps; /* Exponential decay frees/second. */266 u_int vmd_inactive_pps; /* Exponential decay frees/second. */
266 int vmd_oom_seq;267 int vmd_oom_seq;
267 int vmd_last_active_scan;268 int vmd_last_active_scan;
...@@ -356,6 +357,12 @@ vm_batchqueue_init(struct vm_batchqueue *bq)...@@ -356,6 +357,12 @@ vm_batchqueue_init(struct vm_batchqueue *bq)
356 bq->bq_cnt = 0;357 bq->bq_cnt = 0;
357}358}
358359
360static inline bool
361vm_batchqueue_empty(const struct vm_batchqueue *bq)
362{
363 return (bq->bq_cnt == 0);
364}
365
359static inline int366static inline int
360vm_batchqueue_insert(struct vm_batchqueue *bq, vm_page_t m)367vm_batchqueue_insert(struct vm_batchqueue *bq, vm_page_t m)
361{368{
lib/libc/include/generic-freebsd/vm/vm_pager.h+4-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)vm_pager.h 8.4 (Berkeley) 1/12/94
37 */35 */
3836
39/*37/*
...@@ -295,6 +293,7 @@ struct cdev_pager_ops {...@@ -295,6 +293,7 @@ struct cdev_pager_ops {
295 int (*cdev_pg_ctor)(void *handle, vm_ooffset_t size, vm_prot_t prot,293 int (*cdev_pg_ctor)(void *handle, vm_ooffset_t size, vm_prot_t prot,
296 vm_ooffset_t foff, struct ucred *cred, u_short *color);294 vm_ooffset_t foff, struct ucred *cred, u_short *color);
297 void (*cdev_pg_dtor)(void *handle);295 void (*cdev_pg_dtor)(void *handle);
296 void (*cdev_pg_path)(void *handle, char *path, size_t len);
298};297};
299298
300vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp,299vm_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,...@@ -302,6 +301,9 @@ vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp,
302 vm_ooffset_t foff, struct ucred *cred);301 vm_ooffset_t foff, struct ucred *cred);
303vm_object_t cdev_pager_lookup(void *handle);302vm_object_t cdev_pager_lookup(void *handle);
304void cdev_pager_free_page(vm_object_t object, vm_page_t m);303void 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
306struct phys_pager_ops {308struct phys_pager_ops {
307 int (*phys_pg_getpages)(vm_object_t vm_obj, vm_page_t *m, int count,309 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 @@...@@ -31,8 +31,6 @@
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *33 *
34 * from: @(#)vm_param.h 8.1 (Berkeley) 6/11/93
35 *
36 *34 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.35 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved.36 * All rights reserved.
...@@ -114,14 +112,6 @@ struct xswdev {...@@ -114,14 +112,6 @@ struct xswdev {
114#define KERN_OUT_OF_BOUNDS 9112#define KERN_OUT_OF_BOUNDS 9
115#define KERN_RESTART 10113#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
125#ifndef KSTACK_MAX_PAGES115#ifndef KSTACK_MAX_PAGES
126#define KSTACK_MAX_PAGES 32116#define KSTACK_MAX_PAGES 32
127#endif117#endif
lib/libc/include/generic-freebsd/vm/vm_phys.h+6-7
...@@ -61,25 +61,24 @@ extern int *mem_locality;...@@ -61,25 +61,24 @@ extern int *mem_locality;
61void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end);61void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end);
62vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low,62vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low,
63 vm_paddr_t high, u_long alignment, vm_paddr_t boundary);63 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);
66int vm_phys_alloc_npages(int domain, int pool, int npages, vm_page_t ma[]);64int vm_phys_alloc_npages(int domain, int pool, int npages, vm_page_t ma[]);
67vm_page_t vm_phys_alloc_pages(int domain, int pool, int order);65vm_page_t vm_phys_alloc_pages(int domain, int pool, int order);
68int vm_phys_domain_match(int prefer, vm_paddr_t low, vm_paddr_t high);66int 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);
70int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end,68int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end,
71 vm_memattr_t memattr);69 vm_memattr_t memattr);
72void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end);70void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end);
73vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa);71vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa);
74int vm_phys_find_range(vm_page_t bounds[], int segind, int domain,72int vm_phys_find_range(vm_page_t bounds[], int segind, int domain,
75 u_long npages, vm_paddr_t low, vm_paddr_t high);73 u_long npages, vm_paddr_t low, vm_paddr_t high);
76void vm_phys_free_contig(vm_page_t m, u_long npages);74void vm_phys_free_contig(vm_page_t m, int pool, u_long npages);
77void vm_phys_free_pages(vm_page_t m, int order);75void vm_phys_free_pages(vm_page_t m, int pool, int order);
78void vm_phys_init(void);76void vm_phys_init(void);
79vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa);77vm_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);
80void vm_phys_register_domains(int ndomains, struct mem_affinity *affinity,79void vm_phys_register_domains(int ndomains, struct mem_affinity *affinity,
81 int *locality);80 int *locality);
82bool vm_phys_unfree_page(vm_page_t m);81bool vm_phys_unfree_page(vm_paddr_t pa);
83int vm_phys_mem_affinity(int f, int t);82int vm_phys_mem_affinity(int f, int t);
84void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end);83void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end);
85vm_paddr_t vm_phys_early_alloc(int domain, size_t alloc_size);84vm_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);...@@ -89,7 +88,7 @@ vm_paddr_t vm_phys_avail_size(int i);
89bool vm_phys_is_dumpable(vm_paddr_t pa);88bool vm_phys_is_dumpable(vm_paddr_t pa);
9089
91static inline int90static inline int
92vm_phys_domain(vm_paddr_t pa)91vm_phys_domain(vm_paddr_t pa __numa_used)
93{92{
94#ifdef NUMA93#ifdef NUMA
95 int i;94 int i;
lib/libc/include/generic-freebsd/vm/vm_radix.h+309-18
...@@ -34,36 +34,327 @@...@@ -34,36 +34,327 @@
34#include <vm/_vm_radix.h>34#include <vm/_vm_radix.h>
3535
36#ifdef _KERNEL36#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);
39void vm_radix_wait(void);41void 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);
47void vm_radix_zinit(void);42void vm_radix_zinit(void);
4843void *vm_radix_node_alloc(struct pctrie *ptree);
49/*44void vm_radix_node_free(struct pctrie *ptree, void *node);
50 * Each search path in the trie terminates at a leaf, which is a pointer to a45extern smr_t vm_radix_smr;
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
5646
57static __inline void47static __inline void
58vm_radix_init(struct vm_radix *rtree)48vm_radix_init(struct vm_radix *rtree)
59{49{
60 rtree->rt_root = VM_RADIX_NULL;50 pctrie_init(&rtree->rt_trie);
61}51}
6252
63static __inline bool53static __inline bool
64vm_radix_is_empty(struct vm_radix *rtree)54vm_radix_is_empty(struct vm_radix *rtree)
65{55{
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));
67}358}
68359
69#endif /* _KERNEL */360#endif /* _KERNEL */
lib/libc/include/generic-freebsd/vm/vm_reserv.h+5-4
...@@ -46,15 +46,16 @@...@@ -46,15 +46,16 @@
46 * The following functions are only to be used by the virtual memory system.46 * The following functions are only to be used by the virtual memory system.
47 */47 */
48vm_page_t vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex,48vm_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,49 int domain, int req, u_long npages, vm_paddr_t low,
50 vm_paddr_t low, vm_paddr_t high, u_long alignment,50 vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
51 vm_paddr_t boundary);51 struct pctrie_iter *pages);
52vm_page_t vm_reserv_alloc_page(vm_object_t object, vm_pindex_t pindex,52vm_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);
54void vm_reserv_break_all(vm_object_t object);54void vm_reserv_break_all(vm_object_t object);
55boolean_t vm_reserv_free_page(vm_page_t m);55boolean_t vm_reserv_free_page(vm_page_t m);
56void vm_reserv_init(void);56void vm_reserv_init(void);
57bool vm_reserv_is_page_free(vm_page_t m);57bool vm_reserv_is_page_free(vm_page_t m);
58bool vm_reserv_is_populated(vm_page_t m, int npages);
58int vm_reserv_level(vm_page_t m);59int vm_reserv_level(vm_page_t m);
59int vm_reserv_level_iffullpop(vm_page_t m);60int vm_reserv_level_iffullpop(vm_page_t m);
60vm_page_t vm_reserv_reclaim_contig(int domain, u_long npages,61vm_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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * @(#)vnode_pager.h 8.1 (Berkeley) 6/11/93
37 */35 */
3836
39#ifndef _VNODE_PAGER_37#ifndef _VNODE_PAGER_
lib/libc/include/generic-freebsd/wchar.h+9-2
...@@ -78,7 +78,7 @@ typedef __size_t size_t;...@@ -78,7 +78,7 @@ typedef __size_t size_t;
7878
79#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE79#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
80#ifndef _VA_LIST_DECLARED80#ifndef _VA_LIST_DECLARED
81typedef __va_list va_list;81typedef __builtin_va_list va_list;
82#define _VA_LIST_DECLARED82#define _VA_LIST_DECLARED
83#endif83#endif
84#endif84#endif
...@@ -108,6 +108,14 @@ typedef struct __sFILE FILE;...@@ -108,6 +108,14 @@ typedef struct __sFILE FILE;
108#endif108#endif
109struct tm;109struct 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
111__BEGIN_DECLS119__BEGIN_DECLS
112wint_t btowc(int);120wint_t btowc(int);
113wint_t fgetwc(FILE *);121wint_t fgetwc(FILE *);
...@@ -146,7 +154,6 @@ wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict);...@@ -146,7 +154,6 @@ wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict);
146size_t wcscspn(const wchar_t *, const wchar_t *) __pure;154size_t wcscspn(const wchar_t *, const wchar_t *) __pure;
147size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict,155size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict,
148 const struct tm * __restrict);156 const struct tm * __restrict);
149size_t wcslen(const wchar_t *) __pure;
150wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict,157wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict,
151 size_t);158 size_t);
152int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure;159int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure;
lib/libc/include/generic-freebsd/x86/_align.h-2
...@@ -35,8 +35,6 @@...@@ -35,8 +35,6 @@
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY35 * 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 OF36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.37 * SUCH DAMAGE.
38 *
39 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
40 */38 */
4139
42#ifndef _X86_INCLUDE__ALIGN_H_40#ifndef _X86_INCLUDE__ALIGN_H_
lib/libc/include/generic-freebsd/x86/_limits.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)limits.h 8.3 (Berkeley) 1/4/94
32 */30 */
3331
34#ifndef _MACHINE__LIMITS_H_32#ifndef _MACHINE__LIMITS_H_
lib/libc/include/generic-freebsd/x86/_types.h-3
...@@ -32,9 +32,6 @@...@@ -32,9 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
37 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
38 */35 */
3936
40#ifndef _MACHINE__TYPES_H_37#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,...@@ -84,6 +84,8 @@ void madt_parse_interrupt_values(void *entry,
84extern int madt_found_sci_override;84extern int madt_found_sci_override;
85extern int (*apei_nmi)(void);85extern int (*apei_nmi)(void);
8686
87void acpi_set_root(vm_paddr_t addr);
88
87#endif /* _KERNEL */89#endif /* _KERNEL */
8890
89#endif /* __ACPICA_MACHDEP_H__ */91#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;...@@ -296,6 +296,8 @@ typedef struct IOAPIC ioapic_t;
296/* constants relating to APIC ID registers */296/* constants relating to APIC ID registers */
297#define APIC_ID_MASK 0xff000000297#define APIC_ID_MASK 0xff000000
298#define APIC_ID_SHIFT 24298#define APIC_ID_SHIFT 24
299#define APIC_EXT_ID_MASK 0x00fe0000
300#define APIC_EXT_ID_SHIFT 17
299#define APIC_ID_CLUSTER 0xf0301#define APIC_ID_CLUSTER 0xf0
300#define APIC_ID_CLUSTER_ID 0x0f302#define APIC_ID_CLUSTER_ID 0x0f
301#define APIC_MAX_CLUSTER 0xe303#define APIC_MAX_CLUSTER 0xe
lib/libc/include/generic-freebsd/x86/apicvar.h+16-14
...@@ -196,19 +196,21 @@ extern int *apic_cpuids;...@@ -196,19 +196,21 @@ extern int *apic_cpuids;
196/* Allow to replace the lapic_ipi_vectored implementation. */196/* Allow to replace the lapic_ipi_vectored implementation. */
197extern void (*ipi_vectored)(u_int, int);197extern void (*ipi_vectored)(u_int, int);
198198
199typedef struct ioapic *ioapic_drv_t;
200
199void apic_register_enumerator(struct apic_enumerator *enumerator);201void apic_register_enumerator(struct apic_enumerator *enumerator);
200void *ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase);202ioapic_drv_t ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase);
201int ioapic_disable_pin(void *cookie, u_int pin);203int ioapic_disable_pin(ioapic_drv_t cookie, u_int pin);
202int ioapic_get_vector(void *cookie, u_int pin);204int ioapic_get_vector(ioapic_drv_t cookie, u_int pin);
203void ioapic_register(void *cookie);205void ioapic_register(ioapic_drv_t cookie);
204int ioapic_remap_vector(void *cookie, u_int pin, int vector);206int ioapic_remap_vector(ioapic_drv_t cookie, u_int pin, int vector);
205int ioapic_set_bus(void *cookie, u_int pin, int bus_type);207int ioapic_set_bus(ioapic_drv_t cookie, u_int pin, int bus_type);
206int ioapic_set_extint(void *cookie, u_int pin);208int ioapic_set_extint(ioapic_drv_t cookie, u_int pin);
207int ioapic_set_nmi(void *cookie, u_int pin);209int ioapic_set_nmi(ioapic_drv_t cookie, u_int pin);
208int ioapic_set_polarity(void *cookie, u_int pin, enum intr_polarity pol);210int ioapic_set_polarity(ioapic_drv_t cookie, u_int pin, enum intr_polarity pol);
209int ioapic_set_triggermode(void *cookie, u_int pin,211int ioapic_set_triggermode(ioapic_drv_t cookie, u_int pin,
210 enum intr_trigger trigger);212 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
213void lapic_create(u_int apic_id, int boot_cpu);215void lapic_create(u_int apic_id, int boot_cpu);
214void lapic_init(vm_paddr_t addr);216void lapic_init(vm_paddr_t addr);
...@@ -229,9 +231,9 @@ void apic_enable_vector(u_int apic_id, u_int vector);...@@ -229,9 +231,9 @@ void apic_enable_vector(u_int apic_id, u_int vector);
229void apic_disable_vector(u_int apic_id, u_int vector);231void apic_disable_vector(u_int apic_id, u_int vector);
230void apic_free_vector(u_int apic_id, u_int vector, u_int irq);232void apic_free_vector(u_int apic_id, u_int vector, u_int irq);
231void lapic_calibrate_timer(void);233void lapic_calibrate_timer(void);
232int lapic_enable_pmc(void);234int lapic_enable_pcint(void);
233void lapic_disable_pmc(void);235void lapic_disable_pcint(void);
234void lapic_reenable_pmc(void);236void lapic_reenable_pcint(void);
235void lapic_enable_cmc(void);237void lapic_enable_cmc(void);
236int lapic_enable_mca_elvt(void);238int lapic_enable_mca_elvt(void);
237void lapic_ipi_raw(register_t icrlo, u_int dest);239void lapic_ipi_raw(register_t icrlo, u_int dest);
lib/libc/include/generic-freebsd/x86/bus.h+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-ClauseE2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause
3 *3 *
4 * Copyright (c) KATO Takenori, 1999.4 * Copyright (c) KATO Takenori, 1999.
5 *5 *
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,...@@ -88,7 +88,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
8888
89/*89/*
90 * Free a piece of memory and it's allociated dmamap, that was allocated90 * 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.
92 */92 */
93static inline void93static inline void
94bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)94bus_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 @@...@@ -33,28 +33,23 @@
3333
34struct bus_dma_tag_common {34struct bus_dma_tag_common {
35 struct bus_dma_impl *impl;35 struct bus_dma_impl *impl;
36 struct bus_dma_tag_common *parent;
37 bus_size_t alignment;36 bus_size_t alignment;
38 bus_addr_t boundary;37 bus_addr_t boundary;
39 bus_addr_t lowaddr;38 bus_addr_t lowaddr;
40 bus_addr_t highaddr;39 bus_addr_t highaddr;
41 bus_dma_filter_t *filter;
42 void *filterarg;
43 bus_size_t maxsize;40 bus_size_t maxsize;
44 u_int nsegments;41 u_int nsegments;
45 bus_size_t maxsegsz;42 bus_size_t maxsegsz;
46 int flags;43 int flags;
47 bus_dma_lock_t *lockfunc;44 bus_dma_lock_t *lockfunc;
48 void *lockfuncarg;45 void *lockfuncarg;
49 int ref_count;
50 int domain;46 int domain;
51};47};
5248
53struct bus_dma_impl {49struct bus_dma_impl {
54 int (*tag_create)(bus_dma_tag_t parent,50 int (*tag_create)(bus_dma_tag_t parent,
55 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,51 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
56 bus_addr_t highaddr, bus_dma_filter_t *filter,52 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
57 void *filterarg, bus_size_t maxsize, int nsegments,
58 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,53 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
59 void *lockfuncarg, bus_dma_tag_t *dmat);54 void *lockfuncarg, bus_dma_tag_t *dmat);
60 int (*tag_destroy)(bus_dma_tag_t dmat);55 int (*tag_destroy)(bus_dma_tag_t dmat);
...@@ -87,13 +82,11 @@ struct bus_dma_impl {...@@ -87,13 +82,11 @@ struct bus_dma_impl {
87#endif82#endif
88};83};
8984
90int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr);
91int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,85int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
92 bus_size_t alignment,86 bus_size_t alignment,
93 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,87 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
94 bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,88 bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags,
95 int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,89 bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat);
96 void *lockfuncarg, size_t sz, void **dmat);
9790
98extern struct bus_dma_impl bus_dma_bounce_impl;91extern struct bus_dma_impl bus_dma_bounce_impl;
9992
lib/libc/include/generic-freebsd/x86/dump.h+8
...@@ -38,7 +38,11 @@...@@ -38,7 +38,11 @@
3838
39/* 20 phys_avail entry pairs correspond to 10 pa's */39/* 20 phys_avail entry pairs correspond to 10 pa's */
40#define DUMPSYS_MD_PA_NPAIRS 1040#define DUMPSYS_MD_PA_NPAIRS 10
41#ifdef __amd64__
42#define DUMPSYS_NUM_AUX_HDRS 1
43#else
41#define DUMPSYS_NUM_AUX_HDRS 044#define DUMPSYS_NUM_AUX_HDRS 0
45#endif
4246
43/* How often to check the dump progress bar? */47/* How often to check the dump progress bar? */
44#define DUMPSYS_PB_CHECK_BITS 24 /* Every 16MB */48#define DUMPSYS_PB_CHECK_BITS 24 /* Every 16MB */
...@@ -71,12 +75,16 @@ dumpsys_unmap_chunk(vm_paddr_t pa, size_t s, void *va)...@@ -71,12 +75,16 @@ dumpsys_unmap_chunk(vm_paddr_t pa, size_t s, void *va)
71 dumpsys_gen_unmap_chunk(pa, s, va);75 dumpsys_gen_unmap_chunk(pa, s, va);
72}76}
7377
78#ifdef __amd64__
79int dumpsys_write_aux_headers(struct dumperinfo *di);
80#else
74static inline int81static inline int
75dumpsys_write_aux_headers(struct dumperinfo *di)82dumpsys_write_aux_headers(struct dumperinfo *di)
76{83{
7784
78 return (dumpsys_gen_write_aux_headers(di));85 return (dumpsys_gen_write_aux_headers(di));
79}86}
87#endif
8088
81static inline int89static inline int
82dumpsys(struct dumperinfo *di)90dumpsys(struct dumperinfo *di)
lib/libc/include/generic-freebsd/x86/endian.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)endian.h 7.8 (Berkeley) 4/3/91
32 */30 */
3331
34#ifndef _MACHINE_ENDIAN_H_32#ifndef _MACHINE_ENDIAN_H_
lib/libc/include/generic-freebsd/x86/float.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
32 */30 */
3331
34#ifndef _MACHINE_FLOAT_H_32#ifndef _MACHINE_FLOAT_H_
lib/libc/include/generic-freebsd/x86/fpu.h+7-2
...@@ -28,8 +28,6 @@...@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
33 */31 */
3432
35/*33/*
...@@ -220,6 +218,13 @@ struct savefpu_ymm {...@@ -220,6 +218,13 @@ struct savefpu_ymm {
220 */218 */
221#define fpu_enable() clts()219#define fpu_enable() clts()
222#define fpu_disable() load_cr0(rcr0() | CR0_TS)220#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);
223#endif228#endif
224229
225#endif /* !_X86_FPU_H_ */230#endif /* !_X86_FPU_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/frame.h+1-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)frame.h 5.2 (Berkeley) 1/18/91
36 */34 */
3735
38#ifndef _MACHINE_FRAME_H_36#ifndef _MACHINE_FRAME_H_
...@@ -154,6 +152,7 @@ struct trapframe {...@@ -154,6 +152,7 @@ struct trapframe {
154#define TF_HASSEGS 0x1152#define TF_HASSEGS 0x1
155#define TF_HASBASES 0x2153#define TF_HASBASES 0x2
156#define TF_HASFPXSTATE 0x4154#define TF_HASFPXSTATE 0x4
155#define TF_RESERV0 0x8 /* no tlsbase in the trapframe */
157#endif /* __amd64__ */156#endif /* __amd64__ */
158157
159#endif /* _MACHINE_FRAME_H_ */158#endif /* _MACHINE_FRAME_H_ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/init.h+2-2
...@@ -35,10 +35,10 @@...@@ -35,10 +35,10 @@
35 * hypervisor environment.35 * hypervisor environment.
36 */36 */
37struct init_ops {37struct init_ops {
38 caddr_t (*parse_preload_data)(u_int64_t);38 void (*parse_preload_data)(u_int64_t);
39 void (*early_clock_source_init)(void);39 void (*early_clock_source_init)(void);
40 void (*early_delay)(int);40 void (*early_delay)(int);
41 void (*parse_memmap)(caddr_t, vm_paddr_t *, int *);41 void (*parse_memmap)(vm_paddr_t *, int *);
42};42};
4343
44extern struct init_ops init_ops;44extern 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;...@@ -62,8 +62,6 @@ extern u_int num_msi_irqs;
62 */62 */
63#define MSI_INTEL_ADDR_BASE 0xfee0000063#define MSI_INTEL_ADDR_BASE 0xfee00000
6464
65#ifndef LOCORE
66
67typedef void inthand_t(void);65typedef void inthand_t(void);
6866
69#define IDTVEC(name) __CONCAT(X,name)67#define IDTVEC(name) __CONCAT(X,name)
...@@ -138,12 +136,12 @@ void elcr_write_trigger(u_int irq, enum intr_trigger trigger);...@@ -138,12 +136,12 @@ void elcr_write_trigger(u_int irq, enum intr_trigger trigger);
138#ifdef SMP136#ifdef SMP
139void intr_add_cpu(u_int cpu);137void intr_add_cpu(u_int cpu);
140#endif138#endif
141int intr_add_handler(const char *name, int vector, driver_filter_t filter,139int intr_add_handler(struct intsrc *isrc, const char *name,
142 driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep,140 driver_filter_t filter, driver_intr_t handler, void *arg,
143 int domain);141 enum intr_type flags, void **cookiep, int domain);
144int intr_config_intr(int vector, enum intr_trigger trig,142int intr_config_intr(struct intsrc *isrc, enum intr_trigger trig,
145 enum intr_polarity pol);143 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);
147void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);145void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
148u_int intr_next_cpu(int domain);146u_int intr_next_cpu(int domain);
149struct intsrc *intr_lookup_source(int vector);147struct intsrc *intr_lookup_source(int vector);
...@@ -165,6 +163,5 @@ int msix_release(int irq);...@@ -165,6 +163,5 @@ int msix_release(int irq);
165void xen_intr_alloc_irqs(void);163void xen_intr_alloc_irqs(void);
166#endif164#endif
167165
168#endif /* !LOCORE */
169#endif /* _KERNEL */166#endif /* _KERNEL */
170#endif /* !__X86_INTR_MACHDEP_H__ */167#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,...@@ -58,10 +58,14 @@ int legacy_pcib_write_ivar(device_t dev, device_t child, int which,
58struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child,58struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child,
59 int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,59 int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count,
60 u_int flags);60 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,
62 struct resource *r, rman_res_t start, rman_res_t end);62 struct resource *r, rman_res_t start, rman_res_t end);
63int legacy_pcib_release_resource(device_t dev, device_t child, int type,63int legacy_pcib_release_resource(device_t dev, device_t child,
64 int rid, struct resource *r);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);
65int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count,69int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count,
66 int maxcount, int *irqs);70 int maxcount, int *irqs);
67int legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq);71int 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 {...@@ -44,6 +44,31 @@ struct mca_record {
44 int mr_cpu;44 int mr_cpu;
45};45};
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
47#ifdef _KERNEL72#ifdef _KERNEL
4873
49void cmc_intr(void);74void cmc_intr(void);
lib/libc/include/generic-freebsd/x86/metadata.h+9-3
...@@ -34,11 +34,17 @@...@@ -34,11 +34,17 @@
34#define MODINFOMD_EFI_FB 0x100534#define MODINFOMD_EFI_FB 0x1005
35#define MODINFOMD_MODULEP 0x100635#define MODINFOMD_MODULEP 0x1006
36#define MODINFOMD_VBE_FB 0x100736#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 */
38struct efi_map_header {44struct efi_map_header {
39 uint64_t memory_size;45 uint64_t memory_size; /* Numnber of bytes that follow */
40 uint64_t descriptor_size;46 uint64_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
41 uint32_t descriptor_version;47 uint32_t descriptor_version; /* Currently '1' */
42};48};
4349
44struct efi_fb {50struct efi_fb {
lib/libc/include/generic-freebsd/x86/mptable.h-4
...@@ -188,16 +188,12 @@ typedef struct CBASMENTRY {...@@ -188,16 +188,12 @@ typedef struct CBASMENTRY {
188188
189#ifdef _KERNEL189#ifdef _KERNEL
190struct mptable_hostb_softc {190struct mptable_hostb_softc {
191#ifdef NEW_PCIB
192 struct pcib_host_resources sc_host_res;191 struct pcib_host_resources sc_host_res;
193 int sc_decodes_vga_io;192 int sc_decodes_vga_io;
194 int sc_decodes_isa_io;193 int sc_decodes_isa_io;
195#endif
196};194};
197195
198#ifdef NEW_PCIB
199void mptable_pci_host_res_init(device_t pcib);196void mptable_pci_host_res_init(device_t pcib);
200#endif
201int mptable_pci_probe_table(int bus);197int mptable_pci_probe_table(int bus);
202int mptable_pci_route_interrupt(device_t pcib, device_t dev, int pin);198int mptable_pci_route_interrupt(device_t pcib, device_t dev, int pin);
203#endif199#endif
lib/libc/include/generic-freebsd/x86/pci_cfgreg.h+2-5
...@@ -58,15 +58,12 @@ extern int cfgmech;...@@ -58,15 +58,12 @@ extern int cfgmech;
58rman_res_t hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count);58rman_res_t hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count);
59int pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus);59int pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus);
60int pci_cfgregopen(void);60int pci_cfgregopen(void);
61u_int32_t pci_cfgregread_domain(int domain, int bus, int slot, int func, int reg, int bytes);61u_int32_t pci_cfgregread(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);62void pci_cfgregwrite(int domain, int bus, int slot, int func, int reg, u_int32_t data, int bytes);
63#ifdef __HAVE_PIR63#ifdef __HAVE_PIR
64void pci_pir_open(void);64void pci_pir_open(void);
65int pci_pir_probe(int bus, int require_parse);65int pci_pir_probe(int bus, int require_parse);
66int pci_pir_route_interrupt(int bus, int device, int func, int pin);66int pci_pir_route_interrupt(int bus, int device, int func, int pin);
67#endif67#endif
6868
69#define pci_cfgregread pci_cfgregread_domain
70#define pci_cfgregwrite pci_cfgregwrite_domain
71
72#endif /* !__X86_PCI_CFGREG_H__ */69#endif /* !__X86_PCI_CFGREG_H__ */
\ No newline at end of file
lib/libc/include/generic-freebsd/x86/psl.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)psl.h 5.2 (Berkeley) 1/18/91
35 */33 */
3634
37#ifndef _MACHINE_PSL_H_35#ifndef _MACHINE_PSL_H_
lib/libc/include/generic-freebsd/x86/ptrace.h+2-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)ptrace.h 8.1 (Berkeley) 6/11/93
32 */30 */
3331
34#ifndef _MACHINE_PTRACE_H_32#ifndef _MACHINE_PTRACE_H_
...@@ -56,6 +54,8 @@...@@ -56,6 +54,8 @@
56#define PT_SETFSBASE (PT_FIRSTMACH + 8)54#define PT_SETFSBASE (PT_FIRSTMACH + 8)
57#define PT_GETGSBASE (PT_FIRSTMACH + 9)55#define PT_GETGSBASE (PT_FIRSTMACH + 9)
58#define PT_SETGSBASE (PT_FIRSTMACH + 10)56#define PT_SETGSBASE (PT_FIRSTMACH + 10)
57#define PT_GETTLSBASE (PT_FIRSTMACH + 11)
58#define PT_SETTLSBASE (PT_FIRSTMACH + 12)
5959
60/* Argument structure for PT_GETXSTATE_INFO. */60/* Argument structure for PT_GETXSTATE_INFO. */
61struct ptrace_xstate_info {61struct ptrace_xstate_info {
lib/libc/include/generic-freebsd/x86/reg.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)reg.h 5.5 (Berkeley) 1/18/91
36 */34 */
3735
38#ifndef _MACHINE_REG_H_36#ifndef _MACHINE_REG_H_
lib/libc/include/generic-freebsd/x86/segments.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
36 */34 */
3735
38#ifndef _X86_SEGMENTS_H_36#ifndef _X86_SEGMENTS_H_
lib/libc/include/generic-freebsd/x86/signal.h-2
...@@ -28,8 +28,6 @@...@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28 * 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 OF29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.30 * SUCH DAMAGE.
31 *
32 * @(#)signal.h 8.1 (Berkeley) 6/11/93
33 */31 */
3432
35#ifndef _X86_SIGNAL_H33#ifndef _X86_SIGNAL_H
lib/libc/include/generic-freebsd/x86/specialreg.h+20-5
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)specialreg.h 7.1 (Berkeley) 5/9/91
32 */30 */
3331
34#ifndef _MACHINE_SPECIALREG_H_32#ifndef _MACHINE_SPECIALREG_H_
...@@ -125,6 +123,7 @@...@@ -125,6 +123,7 @@
125#define XFEATURE_ENABLED_OPMASK 0x00000020123#define XFEATURE_ENABLED_OPMASK 0x00000020
126#define XFEATURE_ENABLED_ZMM_HI256 0x00000040124#define XFEATURE_ENABLED_ZMM_HI256 0x00000040
127#define XFEATURE_ENABLED_HI16_ZMM 0x00000080125#define XFEATURE_ENABLED_HI16_ZMM 0x00000080
126#define XFEATURE_ENABLED_PT 0x00000100
128#define XFEATURE_ENABLED_PKRU 0x00000200127#define XFEATURE_ENABLED_PKRU 0x00000200
129#define XFEATURE_ENABLED_TILECONFIG 0x00020000128#define XFEATURE_ENABLED_TILECONFIG 0x00020000
130#define XFEATURE_ENABLED_TILEDATA 0x00040000129#define XFEATURE_ENABLED_TILEDATA 0x00040000
...@@ -215,6 +214,7 @@...@@ -215,6 +214,7 @@
215#define CPUPT_MTC (1 << 3) /* MTC Supported */214#define CPUPT_MTC (1 << 3) /* MTC Supported */
216#define CPUPT_PRW (1 << 4) /* PTWRITE Supported */215#define CPUPT_PRW (1 << 4) /* PTWRITE Supported */
217#define CPUPT_PWR (1 << 5) /* Power Event Trace Supported */216#define CPUPT_PWR (1 << 5) /* Power Event Trace Supported */
217#define CPUPT_DIS_TNT (1 << 8) /* TNT disable supported */
218218
219/* Leaf 0 ecx. */219/* Leaf 0 ecx. */
220#define CPUPT_TOPA (1 << 0) /* ToPA Output Supported */220#define CPUPT_TOPA (1 << 0) /* ToPA Output Supported */
...@@ -388,6 +388,14 @@...@@ -388,6 +388,14 @@
388#define CPUID_EXTSTATE_XINUSE 0x00000004388#define CPUID_EXTSTATE_XINUSE 0x00000004
389#define CPUID_EXTSTATE_XSAVES 0x00000008389#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
391/*399/*
392 * AMD extended function 8000_0007h ebx info400 * AMD extended function 8000_0007h ebx info
393 */401 */
...@@ -648,6 +656,12 @@...@@ -648,6 +656,12 @@
648#define MSR_PAT 0x277656#define MSR_PAT 0x277
649#define MSR_MC0_CTL2 0x280657#define MSR_MC0_CTL2 0x280
650#define MSR_MTRRdefType 0x2ff658#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)
651#define MSR_MC0_CTL 0x400665#define MSR_MC0_CTL 0x400
652#define MSR_MC0_STATUS 0x401666#define MSR_MC0_STATUS 0x401
653#define MSR_MC0_ADDR 0x402667#define MSR_MC0_ADDR 0x402
...@@ -775,6 +789,7 @@...@@ -775,6 +789,7 @@
775#define RTIT_CTL_ADDR2_CFG_M (0xfULL << RTIT_CTL_ADDR2_CFG_S)789#define RTIT_CTL_ADDR2_CFG_M (0xfULL << RTIT_CTL_ADDR2_CFG_S)
776#define RTIT_CTL_ADDR3_CFG_S 44790#define RTIT_CTL_ADDR3_CFG_S 44
777#define RTIT_CTL_ADDR3_CFG_M (0xfULL << RTIT_CTL_ADDR3_CFG_S)791#define RTIT_CTL_ADDR3_CFG_M (0xfULL << RTIT_CTL_ADDR3_CFG_S)
792#define RTIT_CTL_DIS_TNT (1ULL << 55)
778#define MSR_IA32_RTIT_STATUS 0x571 /* Tracing Status Register (R/W) */793#define MSR_IA32_RTIT_STATUS 0x571 /* Tracing Status Register (R/W) */
779#define RTIT_STATUS_FILTEREN (1 << 0)794#define RTIT_STATUS_FILTEREN (1 << 0)
780#define RTIT_STATUS_CONTEXTEN (1 << 1)795#define RTIT_STATUS_CONTEXTEN (1 << 1)
...@@ -991,7 +1006,7 @@...@@ -991,7 +1006,7 @@
9911006
992#define CCR4 0xe81007#define CCR4 0xe8
993#define CCR4_IOMASK 0x071008#define CCR4_IOMASK 0x07
994#define CCR4_MEM 0x08 /* Enables momory bypassing */1009#define CCR4_MEM 0x08 /* Enables memory bypassing */
995#define CCR4_DTE 0x10 /* Enables directory table entry cache */1010#define CCR4_DTE 0x10 /* Enables directory table entry cache */
996#define CCR4_FASTFPE 0x20 /* Fast FPU exception */1011#define CCR4_FASTFPE 0x20 /* Fast FPU exception */
997#define CCR4_CPUID 0x80 /* Enables CPUID instruction */1012#define CCR4_CPUID 0x80 /* Enables CPUID instruction */
...@@ -1011,7 +1026,7 @@...@@ -1011,7 +1026,7 @@
1011#define PCR0_RSTK 0x01 /* Enables return stack */1026#define PCR0_RSTK 0x01 /* Enables return stack */
1012#define PCR0_BTB 0x02 /* Enables branch target buffer */1027#define PCR0_BTB 0x02 /* Enables branch target buffer */
1013#define PCR0_LOOP 0x04 /* Enables loop */1028#define PCR0_LOOP 0x04 /* Enables loop */
1014#define PCR0_AIS 0x08 /* Enables all instrcutions stalled to1029#define PCR0_AIS 0x08 /* Enables all instructions stalled to
1015 serialize pipe. */1030 serialize pipe. */
1016#define PCR0_MLR 0x10 /* Enables reordering of misaligned loads */1031#define PCR0_MLR 0x10 /* Enables reordering of misaligned loads */
1017#define PCR0_BTBRT 0x40 /* Enables BTB test register. */1032#define PCR0_BTBRT 0x40 /* Enables BTB test register. */
...@@ -1165,7 +1180,7 @@...@@ -1165,7 +1180,7 @@
11651180
1166/*1181/*
1167 * The region control registers specify the attributes associated with1182 * The region control registers specify the attributes associated with
1168 * the ARRx addres regions.1183 * the ARRx address regions.
1169 */1184 */
1170#define RCR0 0xdc1185#define RCR0 0xdc
1171#define RCR1 0xdd1186#define RCR1 0xdd
lib/libc/include/generic-freebsd/x86/sysarch.h+4
...@@ -61,6 +61,9 @@...@@ -61,6 +61,9 @@
61#define AMD64_GET_XFPUSTATE 13261#define AMD64_GET_XFPUSTATE 132
62#define AMD64_SET_PKRU 13362#define AMD64_SET_PKRU 133
63#define AMD64_CLEAR_PKRU 13463#define AMD64_CLEAR_PKRU 134
64#define AMD64_GET_TLSBASE 135
65#define AMD64_SET_TLSBASE 136
66#define AMD64_DISABLE_TLSBASE 137
6467
65/* Flags for AMD64_SET_PKRU */68/* Flags for AMD64_SET_PKRU */
66#define AMD64_PKRU_EXCL 0x000169#define AMD64_PKRU_EXCL 0x0001
...@@ -140,6 +143,7 @@ int amd64_get_fsbase(void **);...@@ -140,6 +143,7 @@ int amd64_get_fsbase(void **);
140int amd64_get_gsbase(void **);143int amd64_get_gsbase(void **);
141int amd64_set_fsbase(void *);144int amd64_set_fsbase(void *);
142int amd64_set_gsbase(void *);145int amd64_set_gsbase(void *);
146int amd64_set_tlsbase(void *);
143int x86_pkru_get_perm(unsigned int keyidx, int *access, int *modify);147int x86_pkru_get_perm(unsigned int keyidx, int *access, int *modify);
144int x86_pkru_set_perm(unsigned int keyidx, int access, int modify);148int x86_pkru_set_perm(unsigned int keyidx, int access, int modify);
145int x86_pkru_protect_range(void *addr, unsigned long len, unsigned int keyidx,149int 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 @@...@@ -36,13 +36,23 @@
3636
37struct pthread;37struct 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
39/*49/*
40 * Variant II tcb, first two members are required by rtld,50 * Variant II tcb, first two members are required by rtld,
41 * %fs (amd64) / %gs (i386) points to the structure.51 * %fs (amd64) / %gs (i386) points to the structure.
42 */52 */
43struct tcb {53struct tcb {
44 struct tcb *tcb_self; /* required by rtld */54 struct tcb *tcb_self; /* required by rtld */
45 uintptr_t *tcb_dtv; /* required by rtld */55 struct dtv *tcb_dtv; /* required by rtld */
46 struct pthread *tcb_thread;56 struct pthread *tcb_thread;
47};57};
4858
...@@ -59,7 +69,7 @@ static __inline void...@@ -59,7 +69,7 @@ static __inline void
59_tcb_set(struct tcb *tcb)69_tcb_set(struct tcb *tcb)
60{70{
61#ifdef __amd64__71#ifdef __amd64__
62 amd64_set_fsbase(tcb);72 amd64_set_tlsbase(tcb);
63#else73#else
64 i386_set_gsbase(tcb);74 i386_set_gsbase(tcb);
65#endif75#endif
lib/libc/include/generic-freebsd/x86/trap.h-2
...@@ -30,8 +30,6 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)trap.h 5.4 (Berkeley) 5/9/91
35 */33 */
3634
37#ifndef _MACHINE_TRAP_H_35#ifndef _MACHINE_TRAP_H_
lib/libc/include/generic-freebsd/x86/ucode.h+14-1
...@@ -31,6 +31,12 @@...@@ -31,6 +31,12 @@
31#ifndef _MACHINE_UCODE_H_31#ifndef _MACHINE_UCODE_H_
32#define _MACHINE_UCODE_H_32#define _MACHINE_UCODE_H_
3333
34#ifdef _KERNEL
35#include <sys/types.h>
36#else
37#include <stdbool.h>
38#endif
39
34struct ucode_intel_header {40struct ucode_intel_header {
35 uint32_t header_version;41 uint32_t header_version;
36 int32_t update_revision;42 int32_t update_revision;
...@@ -56,7 +62,14 @@ struct ucode_intel_extsig_table {...@@ -56,7 +62,14 @@ struct ucode_intel_extsig_table {
56 } entries[0];62 } entries[0];
57};63};
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,
60 uint64_t *nrevp, uint64_t *orevp);73 uint64_t *nrevp, uint64_t *orevp);
61size_t ucode_load_bsp(uintptr_t free);74size_t ucode_load_bsp(uintptr_t free);
62void ucode_load_ap(int cpu);75void ucode_load_ap(int cpu);
lib/libc/include/generic-freebsd/x86/ucontext.h+6-2
...@@ -99,7 +99,9 @@ typedef struct __mcontext {...@@ -99,7 +99,9 @@ typedef struct __mcontext {
99#define _MC_HASSEGS 0x199#define _MC_HASSEGS 0x1
100#define _MC_HASBASES 0x2100#define _MC_HASBASES 0x2
101#define _MC_HASFPXSTATE 0x4101#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
104typedef struct __mcontext {106typedef struct __mcontext {
105 /*107 /*
...@@ -158,7 +160,9 @@ typedef struct __mcontext {...@@ -158,7 +160,9 @@ typedef struct __mcontext {
158 __register_t mc_xfpustate;160 __register_t mc_xfpustate;
159 __register_t mc_xfpustate_len;161 __register_t mc_xfpustate_len;
160162
161 long mc_spare[4];163 __register_t mc_tlsbase;
164
165 long mc_spare[3];
162} mcontext_t;166} mcontext_t;
163#endif /* __amd64__ */167#endif /* __amd64__ */
164168
lib/libc/include/generic-freebsd/x86/vmware.h+6-2
...@@ -31,19 +31,23 @@...@@ -31,19 +31,23 @@
31#define VMW_HVPORT 0x565831#define VMW_HVPORT 0x5658
3232
33#define VMW_HVCMD_GETVERSION 1033#define VMW_HVCMD_GETVERSION 10
34#define VMW_HVCMD_GUESTRPC 30
34#define VMW_HVCMD_GETHZ 4535#define VMW_HVCMD_GETHZ 45
35#define VMW_HVCMD_GETVCPU_INFO 6836#define VMW_HVCMD_GETVCPU_INFO 68
3637
38#define VMW_HVCMD_DEFAULT_PARAM UINT_MAX
39
37#define VMW_VCPUINFO_LEGACY_X2APIC (1 << 3)40#define VMW_VCPUINFO_LEGACY_X2APIC (1 << 3)
38#define VMW_VCPUINFO_VCPU_RESERVED (1 << 31)41#define VMW_VCPUINFO_VCPU_RESERVED (1 << 31)
3942
40static __inline void43static __inline void
41vmware_hvcall(u_int cmd, u_int *p)44vmware_hvcall(int chan, u_int cmd, u_int param, u_int *p)
42{45{
4346
44 __asm __volatile("inl %w3, %0"47 __asm __volatile("inl %w3, %0"
45 : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])48 : "=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))
47 : "memory");51 : "memory");
48}52}
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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
37 */35 */
3836
39#ifndef _X86_X86_IEEEFP_H_37#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;...@@ -50,6 +50,7 @@ extern u_int cpu_clflush_line_size;
50extern u_int cpu_stdext_feature;50extern u_int cpu_stdext_feature;
51extern u_int cpu_stdext_feature2;51extern u_int cpu_stdext_feature2;
52extern u_int cpu_stdext_feature3;52extern u_int cpu_stdext_feature3;
53extern u_int cpu_stdext_feature4;
53extern uint64_t cpu_ia32_arch_caps;54extern uint64_t cpu_ia32_arch_caps;
54extern u_int cpu_high;55extern u_int cpu_high;
55extern u_int cpu_id;56extern u_int cpu_id;
...@@ -62,6 +63,7 @@ extern char cpu_vendor[];...@@ -62,6 +63,7 @@ extern char cpu_vendor[];
62extern char cpu_model[];63extern char cpu_model[];
63extern u_int cpu_vendor_id;64extern u_int cpu_vendor_id;
64extern u_int cpu_mon_mwait_flags;65extern u_int cpu_mon_mwait_flags;
66extern u_int cpu_mon_mwait_edx;
65extern u_int cpu_mon_min_size;67extern u_int cpu_mon_min_size;
66extern u_int cpu_mon_max_size;68extern u_int cpu_mon_max_size;
67extern u_int cpu_maxphyaddr;69extern u_int cpu_maxphyaddr;
...@@ -147,7 +149,9 @@ void zenbleed_sanitize_enable(void);...@@ -147,7 +149,9 @@ void zenbleed_sanitize_enable(void);
147void zenbleed_check_and_apply(bool all_cpus);149void zenbleed_check_and_apply(bool all_cpus);
148void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame);150void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame);
149void nmi_call_kdb_smp(u_int type, struct trapframe *frame);151void 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);
151void pagecopy(void *from, void *to);155void pagecopy(void *from, void *to);
152void printcpuinfo(void);156void printcpuinfo(void);
153int pti_get_default(void);157int 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 @@...@@ -36,6 +36,7 @@
36#ifndef _FENV_H_36#ifndef _FENV_H_
37#define _FENV_H_37#define _FENV_H_
3838
39#include <sys/cdefs.h>
39#include <sys/_types.h>40#include <sys/_types.h>
4041
41#ifndef __fenv_static42#ifndef __fenv_static
...@@ -71,32 +72,13 @@ __BEGIN_DECLS...@@ -71,32 +72,13 @@ __BEGIN_DECLS
71extern const fenv_t __fe_dfl_env;72extern const fenv_t __fe_dfl_env;
72#define FE_DFL_ENV (&__fe_dfl_env)73#define FE_DFL_ENV (&__fe_dfl_env)
7374
74#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double)75#ifndef __riscv_float_abi_double
75#if defined(__riscv_float_abi_single)76#error only double hard float ABI supported
76#error single precision floating point ABI not supported
77#else
78#error compiler did not set soft/hard float macros
79#endif
80#endif77#endif
8178
82#ifndef __riscv_float_abi_soft
83#define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr))79#define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr))
84#define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr))80#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
100__fenv_static inline int82__fenv_static inline int
101feclearexcept(int __excepts)83feclearexcept(int __excepts)
102{84{
...@@ -212,15 +194,9 @@ feupdateenv(const fenv_t *__envp)...@@ -212,15 +194,9 @@ feupdateenv(const fenv_t *__envp)
212194
213 return (0);195 return (0);
214}196}
215#endif /* !__riscv_float_abi_soft */
216197
217#if __BSD_VISIBLE198#if __BSD_VISIBLE
218199
219#ifdef __riscv_float_abi_soft
220int feenableexcept(int __mask);
221int fedisableexcept(int __mask);
222int fegetexcept(void);
223#else
224__fenv_static inline int200__fenv_static inline int
225feenableexcept(int __mask __unused)201feenableexcept(int __mask __unused)
226{202{
...@@ -248,7 +224,6 @@ fegetexcept(void)...@@ -248,7 +224,6 @@ fegetexcept(void)
248224
249 return (0);225 return (0);
250}226}
251#endif /* !__riscv_float_abi_soft */
252227
253#endif /* __BSD_VISIBLE */228#endif /* __BSD_VISIBLE */
254229
lib/libc/include/riscv64-freebsd-none/float.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
30 */28 */
3129
32#ifndef _MACHINE_FLOAT_H_30#ifndef _MACHINE_FLOAT_H_
lib/libc/include/riscv64-freebsd-none/machine/_align.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
30 */28 */
3129
32#ifndef _MACHINE__ALIGN_H_30#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 @@...@@ -22,8 +22,6 @@
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22 * 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 OF23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.24 * SUCH DAMAGE.
25 *
26 * @(#)limits.h 8.3 (Berkeley) 1/4/94
27 */25 */
2826
29#ifndef _MACHINE__LIMITS_H_27#ifndef _MACHINE__LIMITS_H_
lib/libc/include/riscv64-freebsd-none/machine/_types.h-3
...@@ -26,9 +26,6 @@...@@ -26,9 +26,6 @@
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26 * 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 OF27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.28 * SUCH DAMAGE.
29 *
30 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
31 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
32 */29 */
3330
34#ifndef _MACHINE__TYPES_H_31#ifndef _MACHINE__TYPES_H_
lib/libc/include/riscv64-freebsd-none/machine/asm.h+5
...@@ -69,4 +69,9 @@...@@ -69,4 +69,9 @@
69 li tmp, SSTATUS_SUM; \69 li tmp, SSTATUS_SUM; \
70 csrc sstatus, tmp70 csrc sstatus, tmp
7171
72#define SBI_CALL(ext, func) \
73 li a7, ext; \
74 li a6, func; \
75 ecall
76
72#endif /* _MACHINE_ASM_H_ */77#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 @@...@@ -1,5 +1,5 @@
1/*-1/*-
2 * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>2 * Copyright (c) 2015-2024 Ruslan Bukin <br@bsdpad.com>
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * Portions of this software were developed by SRI International and the5 * Portions of this software were developed by SRI International and the
...@@ -105,8 +105,6 @@ atomic_fcmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \...@@ -105,8 +105,6 @@ atomic_fcmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \
105105
106ATOMIC_CMPSET_ACQ_REL(8);106ATOMIC_CMPSET_ACQ_REL(8);
107ATOMIC_FCMPSET_ACQ_REL(8);107ATOMIC_FCMPSET_ACQ_REL(8);
108ATOMIC_CMPSET_ACQ_REL(16);
109ATOMIC_FCMPSET_ACQ_REL(16);
110108
111#define atomic_cmpset_char atomic_cmpset_8109#define atomic_cmpset_char atomic_cmpset_8
112#define atomic_cmpset_acq_char atomic_cmpset_acq_8110#define atomic_cmpset_acq_char atomic_cmpset_acq_8
...@@ -116,11 +114,40 @@ ATOMIC_FCMPSET_ACQ_REL(16);...@@ -116,11 +114,40 @@ ATOMIC_FCMPSET_ACQ_REL(16);
116#define atomic_fcmpset_rel_char atomic_fcmpset_rel_8114#define atomic_fcmpset_rel_char atomic_fcmpset_rel_8
117115
118#define atomic_cmpset_short atomic_cmpset_16116#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
121#define atomic_fcmpset_short atomic_fcmpset_16117#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
122#define atomic_fcmpset_acq_short atomic_fcmpset_acq_16145#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
123#define atomic_fcmpset_rel_short atomic_fcmpset_rel_16149#define atomic_fcmpset_rel_short atomic_fcmpset_rel_16
150#define atomic_store_rel_short atomic_store_rel_16
124151
125static __inline void152static __inline void
126atomic_add_32(volatile uint32_t *p, uint32_t val)153atomic_add_32(volatile uint32_t *p, uint32_t val)
...@@ -239,6 +266,34 @@ atomic_readandclear_32(volatile uint32_t *p)...@@ -239,6 +266,34 @@ atomic_readandclear_32(volatile uint32_t *p)
239 return (ret);266 return (ret);
240}267}
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
242#define atomic_add_int atomic_add_32297#define atomic_add_int atomic_add_32
243#define atomic_clear_int atomic_clear_32298#define atomic_clear_int atomic_clear_32
244#define atomic_cmpset_int atomic_cmpset_32299#define atomic_cmpset_int atomic_cmpset_32
...@@ -257,7 +312,7 @@ ATOMIC_CMPSET_ACQ_REL(32);...@@ -257,7 +312,7 @@ ATOMIC_CMPSET_ACQ_REL(32);
257ATOMIC_FCMPSET_ACQ_REL(32);312ATOMIC_FCMPSET_ACQ_REL(32);
258313
259static __inline uint32_t314static __inline uint32_t
260atomic_load_acq_32(volatile uint32_t *p)315atomic_load_acq_32(const volatile uint32_t *p)
261{316{
262 uint32_t ret;317 uint32_t ret;
263318
...@@ -410,6 +465,48 @@ atomic_readandclear_64(volatile uint64_t *p)...@@ -410,6 +465,48 @@ atomic_readandclear_64(volatile uint64_t *p)
410 return (ret);465 return (ret);
411}466}
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
413static __inline uint32_t510static __inline uint32_t
414atomic_swap_32(volatile uint32_t *p, uint32_t val)511atomic_swap_32(volatile uint32_t *p, uint32_t val)
415{512{
...@@ -447,6 +544,9 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)...@@ -447,6 +544,9 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
447#define atomic_set_long atomic_set_64544#define atomic_set_long atomic_set_64
448#define atomic_subtract_long atomic_subtract_64545#define atomic_subtract_long atomic_subtract_64
449#define atomic_swap_long atomic_swap_64546#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
451#define atomic_add_ptr atomic_add_64551#define atomic_add_ptr atomic_add_64
452#define atomic_clear_ptr atomic_clear_64552#define atomic_clear_ptr atomic_clear_64
...@@ -457,6 +557,8 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)...@@ -457,6 +557,8 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
457#define atomic_set_ptr atomic_set_64557#define atomic_set_ptr atomic_set_64
458#define atomic_subtract_ptr atomic_subtract_64558#define atomic_subtract_ptr atomic_subtract_64
459#define atomic_swap_ptr atomic_swap_64559#define atomic_swap_ptr atomic_swap_64
560#define atomic_testandclear_ptr atomic_testandclear_64
561#define atomic_testandset_ptr atomic_testandset_64
460562
461ATOMIC_ACQ_REL(set, 64)563ATOMIC_ACQ_REL(set, 64)
462ATOMIC_ACQ_REL(clear, 64)564ATOMIC_ACQ_REL(clear, 64)
...@@ -467,7 +569,7 @@ ATOMIC_CMPSET_ACQ_REL(64);...@@ -467,7 +569,7 @@ ATOMIC_CMPSET_ACQ_REL(64);
467ATOMIC_FCMPSET_ACQ_REL(64);569ATOMIC_FCMPSET_ACQ_REL(64);
468570
469static __inline uint64_t571static __inline uint64_t
470atomic_load_acq_64(volatile uint64_t *p)572atomic_load_acq_64(const volatile uint64_t *p)
471{573{
472 uint64_t ret;574 uint64_t ret;
473575
...@@ -554,4 +656,7 @@ atomic_thread_fence_seq_cst(void)...@@ -554,4 +656,7 @@ atomic_thread_fence_seq_cst(void)
554656
555#include <sys/_atomic_subword.h>657#include <sys/_atomic_subword.h>
556658
659#define atomic_set_short atomic_set_16
660#define atomic_clear_short atomic_clear_16
661
557#endif /* _MACHINE_ATOMIC_H_ */662#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,...@@ -49,7 +49,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
4949
50/*50/*
51 * Free a piece of memory and it's allociated dmamap, that was allocated51 * 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.
53 */53 */
54static inline void54static inline void
55bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)55bus_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 @@...@@ -31,27 +31,22 @@
3131
32struct bus_dma_tag_common {32struct bus_dma_tag_common {
33 struct bus_dma_impl *impl;33 struct bus_dma_impl *impl;
34 struct bus_dma_tag_common *parent;
35 bus_size_t alignment;34 bus_size_t alignment;
36 bus_addr_t boundary;35 bus_addr_t boundary;
37 bus_addr_t lowaddr;36 bus_addr_t lowaddr;
38 bus_addr_t highaddr;37 bus_addr_t highaddr;
39 bus_dma_filter_t *filter;
40 void *filterarg;
41 bus_size_t maxsize;38 bus_size_t maxsize;
42 u_int nsegments;39 u_int nsegments;
43 bus_size_t maxsegsz;40 bus_size_t maxsegsz;
44 int flags;41 int flags;
45 bus_dma_lock_t *lockfunc;42 bus_dma_lock_t *lockfunc;
46 void *lockfuncarg;43 void *lockfuncarg;
47 int ref_count;
48};44};
4945
50struct bus_dma_impl {46struct bus_dma_impl {
51 int (*tag_create)(bus_dma_tag_t parent,47 int (*tag_create)(bus_dma_tag_t parent,
52 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,48 bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr,
53 bus_addr_t highaddr, bus_dma_filter_t *filter,49 bus_addr_t highaddr, bus_size_t maxsize, int nsegments,
54 void *filterarg, bus_size_t maxsize, int nsegments,
55 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,50 bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
56 void *lockfuncarg, bus_dma_tag_t *dmat);51 void *lockfuncarg, bus_dma_tag_t *dmat);
57 int (*tag_destroy)(bus_dma_tag_t dmat);52 int (*tag_destroy)(bus_dma_tag_t dmat);
...@@ -79,13 +74,11 @@ struct bus_dma_impl {...@@ -79,13 +74,11 @@ struct bus_dma_impl {
79 bus_dmasync_op_t op);74 bus_dmasync_op_t op);
80};75};
8176
82int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
83int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,77int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
84 bus_size_t alignment,78 bus_size_t alignment,
85 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,79 bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
86 bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,80 bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags,
87 int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,81 bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat);
88 void *lockfuncarg, size_t sz, void **dmat);
8982
90extern struct bus_dma_impl bus_dma_bounce_impl;83extern 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 @@...@@ -35,9 +35,11 @@
35#ifndef _MACHINE_CPU_H_35#ifndef _MACHINE_CPU_H_
36#define _MACHINE_CPU_H_36#define _MACHINE_CPU_H_
3737
38#ifndef LOCORE
38#include <machine/atomic.h>39#include <machine/atomic.h>
39#include <machine/cpufunc.h>40#include <machine/cpufunc.h>
40#include <machine/frame.h>41#include <machine/frame.h>
42#endif
4143
42#define TRAPF_PC(tfp) ((tfp)->tf_sepc)44#define TRAPF_PC(tfp) ((tfp)->tf_sepc)
43#define TRAPF_USERMODE(tfp) (((tfp)->tf_sstatus & SSTATUS_SPP) == 0)45#define TRAPF_USERMODE(tfp) (((tfp)->tf_sstatus & SSTATUS_SPP) == 0)
...@@ -47,8 +49,6 @@...@@ -47,8 +49,6 @@
47#define cpu_spinwait() /* nothing */49#define cpu_spinwait() /* nothing */
48#define cpu_lock_delay() DELAY(1)50#define cpu_lock_delay() DELAY(1)
4951
50#ifdef _KERNEL
51
52/*52/*
53 * Core manufacturer IDs, as reported by the mvendorid CSR.53 * Core manufacturer IDs, as reported by the mvendorid CSR.
54 */54 */
...@@ -80,6 +80,7 @@...@@ -80,6 +80,7 @@
8080
81/* SiFive marchid values */81/* SiFive marchid values */
82#define MARCHID_SIFIVE_U7 MARCHID_COMMERCIAL(7)82#define MARCHID_SIFIVE_U7 MARCHID_COMMERCIAL(7)
83#define MARCHID_SIFIVE_P5 MARCHID_COMMERCIAL(8)
8384
84/*85/*
85 * MMU virtual-addressing modes. Support for each level implies the previous,86 * MMU virtual-addressing modes. Support for each level implies the previous,
...@@ -89,6 +90,9 @@...@@ -89,6 +90,9 @@
89#define MMU_SV48 0x2 /* 4-level paging */90#define MMU_SV48 0x2 /* 4-level paging */
90#define MMU_SV57 0x4 /* 5-level paging */91#define MMU_SV57 0x4 /* 5-level paging */
9192
93#ifdef _KERNEL
94#ifndef LOCORE
95
92extern char btext[];96extern char btext[];
93extern char etext[];97extern char etext[];
9498
...@@ -105,6 +109,7 @@ get_cyclecount(void)...@@ -105,6 +109,7 @@ get_cyclecount(void)
105 return (rdcycle());109 return (rdcycle());
106}110}
107111
108#endif112#endif /* !LOCORE */
113#endif /* _KERNEL */
109114
110#endif /* !_MACHINE_CPU_H_ */115#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)...@@ -44,6 +44,8 @@ breakpoint(void)
4444
45#ifdef _KERNEL45#ifdef _KERNEL
4646
47#include <sys/_null.h>
48
47#include <machine/riscvreg.h>49#include <machine/riscvreg.h>
4850
49static __inline register_t51static __inline register_t
...@@ -102,21 +104,62 @@ sfence_vma_page(uintptr_t addr)...@@ -102,21 +104,62 @@ sfence_vma_page(uintptr_t addr)
102 __asm __volatile("sfence.vma %0" :: "r" (addr) : "memory");104 __asm __volatile("sfence.vma %0" :: "r" (addr) : "memory");
103}105}
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
105#define rdcycle() csr_read64(cycle)122#define rdcycle() csr_read64(cycle)
106#define rdtime() csr_read64(time)123#define rdtime() csr_read64(time)
107#define rdinstret() csr_read64(instret)124#define rdinstret() csr_read64(instret)
108#define rdhpmcounter(n) csr_read64(hpmcounter##n)125#define rdhpmcounter(n) csr_read64(hpmcounter##n)
109126
127/* Cache hooks. */
128
110extern int64_t dcache_line_size;129extern int64_t dcache_line_size;
111extern int64_t icache_line_size;
112130
113#define cpu_dcache_wbinv_range(a, s)131typedef void (*cache_op_t)(vm_offset_t start, vm_size_t size);
114#define cpu_dcache_inv_range(a, s)132
115#define cpu_dcache_wb_range(a, s)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)162void riscv_cache_install_hooks(struct riscv_cache_ops *, u_int);
118#define cpu_icache_sync_range(a, s)
119#define cpu_icache_sync_range_checked(a, s)
120163
121#define cpufunc_nullop() riscv_nullop()164#define cpufunc_nullop() riscv_nullop()
122165
lib/libc/include/riscv64-freebsd-none/machine/elf.h+2
...@@ -80,7 +80,9 @@ __ElfType(Auxinfo);...@@ -80,7 +80,9 @@ __ElfType(Auxinfo);
80#define HWCAP_ISA_F HWCAP_ISA_BIT('f')80#define HWCAP_ISA_F HWCAP_ISA_BIT('f')
81#define HWCAP_ISA_D HWCAP_ISA_BIT('d')81#define HWCAP_ISA_D HWCAP_ISA_BIT('d')
82#define HWCAP_ISA_C HWCAP_ISA_BIT('c')82#define HWCAP_ISA_C HWCAP_ISA_BIT('c')
83#define HWCAP_ISA_H HWCAP_ISA_BIT('h')
83#define HWCAP_ISA_G \84#define HWCAP_ISA_G \
84 (HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F | HWCAP_ISA_D)85 (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
86#endif /* !_MACHINE_ELF_H_ */88#endif /* !_MACHINE_ELF_H_ */
\ No newline at end of file
lib/libc/include/riscv64-freebsd-none/machine/endian.h-2
...@@ -24,8 +24,6 @@...@@ -24,8 +24,6 @@
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24 * 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 OF25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.26 * SUCH DAMAGE.
27 *
28 * @(#)endian.h 8.1 (Berkeley) 6/10/93
29 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $27 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
30 */28 */
3129
lib/libc/include/riscv64-freebsd-none/machine/float.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)float.h 7.1 (Berkeley) 5/8/90
30 */28 */
3129
32#ifndef _MACHINE_FLOAT_H_30#ifndef _MACHINE_FLOAT_H_
lib/libc/include/riscv64-freebsd-none/machine/fpe.h+11-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1/*-1/*-
2 * Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com>2 * Copyright (c) 2016-2024 Ruslan Bukin <br@bsdpad.com>
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * This software was developed by SRI International and the University of5 * This software was developed by SRI International and the University of
...@@ -34,4 +34,14 @@...@@ -34,4 +34,14 @@
34void fpe_state_save(struct thread *td);34void fpe_state_save(struct thread *td);
35void fpe_state_clear(void);35void 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
37#endif /* !_MACHINE_FPE_H_ */47#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 {...@@ -57,6 +57,10 @@ struct trapframe {
57 uint64_t tf_scause;57 uint64_t tf_scause;
58};58};
5959
60#ifdef _KERNEL
61#define TF_SIZE (roundup2(sizeof(struct trapframe), STACKALIGNBYTES + 1))
62#endif
63
60/*64/*
61 * Signal frame. Pushed onto user stack before calling sigcode.65 * Signal frame. Pushed onto user stack before calling sigcode.
62 */66 */
...@@ -65,6 +69,16 @@ struct sigframe {...@@ -65,6 +69,16 @@ struct sigframe {
65 ucontext_t sf_uc; /* actual saved ucontext */69 ucontext_t sf_uc; /* actual saved ucontext */
66};70};
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
68#endif /* !LOCORE */82#endif /* !LOCORE */
6983
70/* Definitions for syscalls */84/* 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 @@...@@ -27,7 +27,6 @@
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *28 *
29 * from tahoe: in_cksum.c 1.2 86/01/0529 * from tahoe: in_cksum.c 1.2 86/01/05
30 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
31 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp30 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
32 */31 */
3332
lib/libc/include/riscv64-freebsd-none/machine/intr.h+5-2
...@@ -39,8 +39,7 @@...@@ -39,8 +39,7 @@
39#define NIRQ 102439#define NIRQ 1024
40#endif40#endif
4141
42#include <sys/intr.h>42#ifndef LOCORE
43
44enum {43enum {
45 IRQ_SOFTWARE_USER,44 IRQ_SOFTWARE_USER,
46 IRQ_SOFTWARE_SUPERVISOR,45 IRQ_SOFTWARE_SUPERVISOR,
...@@ -55,5 +54,9 @@ enum {...@@ -55,5 +54,9 @@ enum {
55 IRQ_EXTERNAL_HYPERVISOR,54 IRQ_EXTERNAL_HYPERVISOR,
56 IRQ_EXTERNAL_MACHINE,55 IRQ_EXTERNAL_MACHINE,
57};56};
57#endif /* !LOCORE */
58
59#define INTR_ROOT_IRQ 0
60#define INTR_ROOT_COUNT 1
5861
59#endif /* !_MACHINE_INTR_MACHDEP_H_ */62#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 @@...@@ -36,10 +36,8 @@
36#define _MACHINE_MACHDEP_H_36#define _MACHINE_MACHDEP_H_
3737
38struct riscv_bootparams {38struct riscv_bootparams {
39 vm_offset_t kern_l1pt; /* Kernel L1 base */
40 vm_offset_t kern_phys; /* Kernel base (physical) addr */39 vm_offset_t kern_phys; /* Kernel base (physical) addr */
41 vm_offset_t kern_stack;40 vm_offset_t kern_stack;
42 vm_offset_t dtbp_virt; /* Device tree blob virtual addr */
43 vm_offset_t dtbp_phys; /* Device tree blob physical addr */41 vm_offset_t dtbp_phys; /* Device tree blob physical addr */
44 vm_offset_t modulep; /* loader(8) metadata */42 vm_offset_t modulep; /* loader(8) metadata */
45};43};
lib/libc/include/riscv64-freebsd-none/machine/md_var.h+2
...@@ -42,8 +42,10 @@ extern register_t mimpid;...@@ -42,8 +42,10 @@ extern register_t mimpid;
42extern u_int mmu_caps;42extern u_int mmu_caps;
4343
44/* Supervisor-mode extension support */44/* Supervisor-mode extension support */
45extern bool has_hyp;
45extern bool has_sstc;46extern bool has_sstc;
46extern bool has_sscofpmf;47extern bool has_sscofpmf;
48extern bool has_svpbmt;
4749
48struct dumperinfo;50struct dumperinfo;
49struct minidumpstate;51struct minidumpstate;
lib/libc/include/riscv64-freebsd-none/machine/metadata.h+10-3
...@@ -30,11 +30,18 @@...@@ -30,11 +30,18 @@
3030
31#define MODINFOMD_DTBP 0x100131#define MODINFOMD_DTBP 0x1001
32#define MODINFOMD_EFI_MAP 0x100232#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 */
34struct efi_map_header {41struct efi_map_header {
35 size_t memory_size;42 size_t memory_size; /* Numnber of bytes that follow */
36 size_t descriptor_size;43 size_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */
37 uint32_t descriptor_version;44 uint32_t descriptor_version; /* Currently '1' */
38};45};
3946
40/*47/*
lib/libc/include/riscv64-freebsd-none/machine/param.h-12
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
30 */28 */
3129
32#ifndef _MACHINE_PARAM_H_30#ifndef _MACHINE_PARAM_H_
...@@ -41,8 +39,6 @@...@@ -41,8 +39,6 @@
41#define STACKALIGNBYTES (16 - 1)39#define STACKALIGNBYTES (16 - 1)
42#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)40#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
4341
44#define __PCI_REROUTE_INTERRUPT
45
46#ifndef MACHINE42#ifndef MACHINE
47#define MACHINE "riscv"43#define MACHINE "riscv"
48#endif44#endif
...@@ -95,15 +91,7 @@...@@ -95,15 +91,7 @@
95/*91/*
96 * Mach derived conversion macros92 * Mach derived conversion macros
97 */93 */
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
104#define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)94#define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
105#define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)95#define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
10696
107#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
108
109#endif /* !_MACHINE_PARAM_H_ */97#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 @@...@@ -46,7 +46,8 @@
46 struct pmap *pc_curpmap; /* Currently active pmap */ \46 struct pmap *pc_curpmap; /* Currently active pmap */ \
47 uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \47 uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \
48 uint32_t pc_hart; /* Hart ID */ \48 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
51#ifdef _KERNEL52#ifdef _KERNEL
5253
lib/libc/include/riscv64-freebsd-none/machine/pmap.h+9-1
...@@ -67,6 +67,12 @@ struct md_page {...@@ -67,6 +67,12 @@ struct md_page {
67 vm_memattr_t pv_memattr;67 vm_memattr_t pv_memattr;
68};68};
6969
70enum pmap_stage {
71 PM_INVALID,
72 PM_STAGE1,
73 PM_STAGE2,
74};
75
70struct pmap {76struct pmap {
71 struct mtx pm_mtx;77 struct mtx pm_mtx;
72 struct pmap_statistics pm_stats; /* pmap statictics */78 struct pmap_statistics pm_stats; /* pmap statictics */
...@@ -76,6 +82,7 @@ struct pmap {...@@ -76,6 +82,7 @@ struct pmap {
76 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */82 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
77 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */83 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */
78 struct vm_radix pm_root;84 struct vm_radix pm_root;
85 enum pmap_stage pm_stage;
79};86};
8087
81typedef struct pmap *pmap_t;88typedef struct pmap *pmap_t;
...@@ -126,7 +133,7 @@ struct thread;...@@ -126,7 +133,7 @@ struct thread;
126133
127void pmap_activate_boot(pmap_t);134void pmap_activate_boot(pmap_t);
128void pmap_activate_sw(struct thread *);135void 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);
130int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);137int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);
131void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);138void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);
132void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);139void 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);...@@ -134,6 +141,7 @@ vm_paddr_t pmap_kextract(vm_offset_t va);
134void pmap_kremove(vm_offset_t);141void pmap_kremove(vm_offset_t);
135void pmap_kremove_device(vm_offset_t, vm_size_t);142void pmap_kremove_device(vm_offset_t, vm_size_t);
136void *pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma);143void *pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma);
144int pmap_pinit_stage(pmap_t, enum pmap_stage);
137bool pmap_page_is_mapped(vm_page_t m);145bool pmap_page_is_mapped(vm_page_t m);
138bool pmap_ps_enabled(pmap_t);146bool pmap_ps_enabled(pmap_t);
139147
lib/libc/include/riscv64-freebsd-none/machine/proc.h-2
...@@ -25,8 +25,6 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
30 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/2928 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29
31 */29 */
3230
lib/libc/include/riscv64-freebsd-none/machine/pte.h+46-3
...@@ -83,6 +83,51 @@ typedef uint64_t pn_t; /* page number */...@@ -83,6 +83,51 @@ typedef uint64_t pn_t; /* page number */
83#define PTE_PROMOTE (PTE_V | PTE_RWX | PTE_D | PTE_G | PTE_U | \83#define PTE_PROMOTE (PTE_V | PTE_RWX | PTE_D | PTE_G | PTE_U | \
84 PTE_SW_MANAGED | PTE_SW_WIRED)84 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
86/* Bits 63 - 54 are reserved for future use. */131/* Bits 63 - 54 are reserved for future use. */
87#define PTE_HI_MASK 0xFFC0000000000000ULL132#define PTE_HI_MASK 0xFFC0000000000000ULL
88133
...@@ -92,6 +137,4 @@ typedef uint64_t pn_t; /* page number */...@@ -92,6 +137,4 @@ typedef uint64_t pn_t; /* page number */
92#define PTE_PPN3_S 37137#define PTE_PPN3_S 37
93#define PTE_SIZE 8138#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 @@...@@ -40,8 +40,6 @@
40#define SYS_RES_MEMORY 3 /* i/o memory */40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */41#define SYS_RES_IOPORT 4 /* i/o ports */
42#define SYS_RES_GPIO 5 /* general purpose i/o */42#define SYS_RES_GPIO 5 /* general purpose i/o */
43#ifdef NEW_PCIB
44#define PCI_RES_BUS 6 /* PCI bus numbers */43#define PCI_RES_BUS 6 /* PCI bus numbers */
45#endif
4644
47#endif /* !_MACHINE_RESOURCE_H_ */45#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 @@...@@ -1,5 +1,5 @@
1/*-1/*-
2 * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>2 * Copyright (c) 2015-2024 Ruslan Bukin <br@bsdpad.com>
3 * All rights reserved.3 * All rights reserved.
4 *4 *
5 * Portions of this software were developed by SRI International and the5 * Portions of this software were developed by SRI International and the
...@@ -47,9 +47,15 @@...@@ -47,9 +47,15 @@
47#define SCAUSE_STORE_ACCESS_FAULT 747#define SCAUSE_STORE_ACCESS_FAULT 7
48#define SCAUSE_ECALL_USER 848#define SCAUSE_ECALL_USER 8
49#define SCAUSE_ECALL_SUPERVISOR 949#define SCAUSE_ECALL_SUPERVISOR 9
50#define SCAUSE_VIRTUAL_SUPERVISOR_ECALL 10
51#define SCAUSE_MACHINE_ECALL 11
50#define SCAUSE_INST_PAGE_FAULT 1252#define SCAUSE_INST_PAGE_FAULT 12
51#define SCAUSE_LOAD_PAGE_FAULT 1353#define SCAUSE_LOAD_PAGE_FAULT 13
52#define SCAUSE_STORE_PAGE_FAULT 1554#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
54#define SSTATUS_UIE (1 << 0)60#define SSTATUS_UIE (1 << 0)
55#define SSTATUS_SIE (1 << 1)61#define SSTATUS_SIE (1 << 1)
...@@ -116,6 +122,17 @@...@@ -116,6 +122,17 @@
116#define MSTATUS_PRV_H 2 /* hypervisor */122#define MSTATUS_PRV_H 2 /* hypervisor */
117#define MSTATUS_PRV_M 3 /* machine */123#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
119#define MIE_USIE (1 << 0)136#define MIE_USIE (1 << 0)
120#define MIE_SSIE (1 << 1)137#define MIE_SSIE (1 << 1)
121#define MIE_HSIE (1 << 2)138#define MIE_HSIE (1 << 2)
...@@ -143,10 +160,31 @@...@@ -143,10 +160,31 @@
143160
144#define MIP_SEIP (1 << 9)161#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
146/* Note: sip register has no SIP_STIP bit in Spike simulator */172/* Note: sip register has no SIP_STIP bit in Spike simulator */
147#define SIP_SSIP (1 << 1)173#define SIP_SSIP (1 << 1)
148#define SIP_STIP (1 << 5)174#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
150#define SATP_PPN_S 0188#define SATP_PPN_S 0
151#define SATP_PPN_M (0xfffffffffffUL << SATP_PPN_S)189#define SATP_PPN_M (0xfffffffffffUL << SATP_PPN_S)
152#define SATP_ASID_S 44190#define SATP_ASID_S 44
...@@ -189,13 +227,14 @@...@@ -189,13 +227,14 @@
189 (__builtin_constant_p(val) && ((u_long)(val) < 32))227 (__builtin_constant_p(val) && ((u_long)(val) < 32))
190228
191#define csr_swap(csr, val) \229#define csr_swap(csr, val) \
192({ if (CSR_ZIMM(val)) \230({ u_long ret; \
231 if (CSR_ZIMM(val)) \
193 __asm __volatile("csrrwi %0, " #csr ", %1" \232 __asm __volatile("csrrwi %0, " #csr ", %1" \
194 : "=r" (val) : "i" (val)); \233 : "=r" (ret) : "i" (val)); \
195 else \234 else \
196 __asm __volatile("csrrw %0, " #csr ", %1" \235 __asm __volatile("csrrw %0, " #csr ", %1" \
197 : "=r" (val) : "r" (val)); \236 : "=r" (ret) : "r" (val)); \
198 val; \237 ret; \
199})238})
200239
201#define csr_write(csr, val) \240#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 @@...@@ -49,6 +49,12 @@
49#define SBI_IMPL_ID_KVM 349#define SBI_IMPL_ID_KVM 3
50#define SBI_IMPL_ID_RUSTSBI 450#define SBI_IMPL_ID_RUSTSBI 4
51#define SBI_IMPL_ID_DIOSIX 551#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
53/* SBI Error Codes */59/* SBI Error Codes */
54#define SBI_SUCCESS 060#define SBI_SUCCESS 0
...@@ -117,6 +123,8 @@...@@ -117,6 +123,8 @@
117#define SBI_REMOTE_SFENCE_VMA_ASID 7123#define SBI_REMOTE_SFENCE_VMA_ASID 7
118#define SBI_SHUTDOWN 8124#define SBI_SHUTDOWN 8
119125
126#ifndef LOCORE
127
120#define SBI_CALL0(e, f) SBI_CALL5(e, f, 0, 0, 0, 0, 0)128#define SBI_CALL0(e, f) SBI_CALL5(e, f, 0, 0, 0, 0, 0)
121#define SBI_CALL1(e, f, p1) SBI_CALL5(e, f, p1, 0, 0, 0, 0)129#define SBI_CALL1(e, f, p1) SBI_CALL5(e, f, p1, 0, 0, 0, 0)
122#define SBI_CALL2(e, f, p1, p2) SBI_CALL5(e, f, p1, p2, 0, 0, 0)130#define SBI_CALL2(e, f, p1, p2) SBI_CALL5(e, f, p1, p2, 0, 0, 0)
...@@ -236,4 +244,5 @@ sbi_console_getchar(void)...@@ -236,4 +244,5 @@ sbi_console_getchar(void)
236void sbi_print_version(void);244void sbi_print_version(void);
237void sbi_init(void);245void sbi_init(void);
238246
247#endif /* !LOCORE */
239#endif /* !_MACHINE_SBI_H_ */248#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 @@...@@ -25,8 +25,6 @@
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25 * 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 OF26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.27 * SUCH DAMAGE.
28 *
29 * @(#)signal.h 8.1 (Berkeley) 6/11/93
30 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/0928 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09
31 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:1729 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17
32 */30 */
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 @@...@@ -28,10 +28,14 @@
28#define _MACHINE_VM_H_28#define _MACHINE_VM_H_
2929
30/* Memory attribute configuration. */30/* Memory attribute configuration. */
31#define VM_MEMATTR_DEVICE 031#define VM_MEMATTR_PMA 0
32#define VM_MEMATTR_UNCACHEABLE 132#define VM_MEMATTR_UNCACHEABLE 1
33#define VM_MEMATTR_WRITE_BACK 233#define VM_MEMATTR_DEVICE 2
3434
35#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK35#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
37#endif /* !_MACHINE_VM_H_ */41#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
35 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/3033 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30
36 */34 */
3735
...@@ -211,8 +209,6 @@...@@ -211,8 +209,6 @@
211#define PS_STRINGS_SV39 (USRSTACK_SV39 - sizeof(struct ps_strings))209#define PS_STRINGS_SV39 (USRSTACK_SV39 - sizeof(struct ps_strings))
212#define PS_STRINGS_SV48 (USRSTACK_SV48 - sizeof(struct ps_strings))210#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
216/*212/*
217 * How many physical pages per kmem arena virtual page.213 * How many physical pages per kmem arena virtual page.
218 */214 */
...@@ -236,19 +232,22 @@...@@ -236,19 +232,22 @@
236#define VM_INITIAL_PAGEIN 16232#define VM_INITIAL_PAGEIN 16
237#endif233#endif
238234
239#define UMA_MD_SMALL_ALLOC235#define UMA_USE_DMAP
240236
241#ifndef LOCORE237#ifndef LOCORE
242extern vm_paddr_t dmap_phys_base;238extern vm_paddr_t dmap_phys_base;
243extern vm_paddr_t dmap_phys_max;239extern vm_paddr_t dmap_phys_max;
244extern vm_offset_t dmap_max_addr;240extern vm_offset_t dmap_max_addr;
245extern vm_offset_t init_pt_va;
246#endif241#endif
247242
248#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */243#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
249244
245/*
246 * The top of KVA is reserved for early device mappings.
247 */
250#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS248#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS
251#define PMAP_MAPDEV_EARLY_SIZE L2_SIZE249#define DEVMAP_MIN_VADDR (DEVMAP_MAX_VADDR - PMAP_MAPDEV_EARLY_SIZE)
250#define PMAP_MAPDEV_EARLY_SIZE (4 * L2_SIZE)
252251
253/*252/*
254 * No non-transparent large page support in the pmap.253 * No non-transparent large page support in the pmap.
...@@ -259,5 +258,6 @@ extern vm_offset_t init_pt_va;...@@ -259,5 +258,6 @@ extern vm_offset_t init_pt_va;
259 * Need a page dump array for minidump.258 * Need a page dump array for minidump.
260 */259 */
261#define MINIDUMP_PAGE_TRACKING 1260#define MINIDUMP_PAGE_TRACKING 1
261#define MINIDUMP_STARTUP_PAGE_TRACKING 1
262262
263#endif /* !_MACHINE_VMPARAM_H_ */263#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 @@...@@ -1,30 +1,13 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * Copyright (c) 2005 The FreeBSD Foundation.
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
5 *3 *
6 * Redistribution and use in source and binary forms, with or without4 * SPDX-License-Identifier: BSD-2-Clause
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.
16 *5 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND6 * Derived in part from NetBSD's bus.h files by (alphabetically):
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE7 * Christopher G. Demetriou
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE8 * Charles M. Hannum
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR9 * Jason Thorpe
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL10 * The NetBSD Foundation.
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 */11 */
2912
30#ifndef I386_INCLUDE__BUS_H13#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
35 */33 */
3634
37#ifndef _MACHINE_ASM_H_35#ifndef _MACHINE_ASM_H_
lib/libc/include/x86-freebsd-none/machine/atomic.h+20-27
...@@ -49,8 +49,8 @@ static __inline void...@@ -49,8 +49,8 @@ static __inline void
49__mbk(void)49__mbk(void)
50{50{
5151
52 __asm __volatile("lock; addl $0,%%fs:%0"52 __asm __volatile("lock; addl $0,%%fs:%c0"
53 : "+m" (*(u_int *)__OFFSETOF_MONITORBUF) : : "memory", "cc");53 : : "i" (__OFFSETOF_MONITORBUF) : "memory", "cc");
54}54}
5555
56static __inline void56static __inline void
...@@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)...@@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)
249249
250#define ATOMIC_LOAD(TYPE) \250#define ATOMIC_LOAD(TYPE) \
251static __inline u_##TYPE \251static __inline u_##TYPE \
252atomic_load_acq_##TYPE(volatile u_##TYPE *p) \252atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
253{ \253{ \
254 u_##TYPE res; \254 u_##TYPE res; \
255 \255 \
...@@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void)...@@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void)
299299
300#ifdef _KERNEL300#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
313/* I486 does not support SMP or CMPXCHG8B. */302/* I486 does not support SMP or CMPXCHG8B. */
314static __inline int303static __inline int
315atomic_cmpset_64_i386(volatile uint64_t *dst, uint64_t expect, uint64_t src)304atomic_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)...@@ -353,12 +342,12 @@ atomic_fcmpset_64_i386(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
353}342}
354343
355static __inline uint64_t344static __inline uint64_t
356atomic_load_acq_64_i386(volatile uint64_t *p)345atomic_load_acq_64_i386(const volatile uint64_t *p)
357{346{
358 volatile uint32_t *q;347 const volatile uint32_t *q;
359 uint64_t res;348 uint64_t res;
360349
361 q = (volatile uint32_t *)p;350 q = (const volatile uint32_t *)p;
362 __asm __volatile(351 __asm __volatile(
363 " pushfl ; "352 " pushfl ; "
364 " cli ; "353 " cli ; "
...@@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src)...@@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
447 return (res);436 return (res);
448}437}
449438
439/*
440 * Architecturally always writes back some value to '*p' so will trigger
441 * a #GP(0) on read-only mappings.
442 */
450static __inline uint64_t443static __inline uint64_t
451atomic_load_acq_64_i586(volatile uint64_t *p)444atomic_load_acq_64_i586(const volatile uint64_t *p)
452{445{
453 uint64_t res;446 uint64_t res;
454447
...@@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p)...@@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p)
456 " movl %%ebx,%%eax ; "449 " movl %%ebx,%%eax ; "
457 " movl %%ecx,%%edx ; "450 " movl %%ecx,%%edx ; "
458 " lock; cmpxchg8b %1"451 " lock; cmpxchg8b %1"
459 : "=&A" (res), /* 0 */452 : "=&A" (res) /* 0 */
460 "+m" (*p) /* 1 */453 : "m" (*p) /* 1 */
461 : : "memory", "cc");454 : "memory", "cc");
462 return (res);455 return (res);
463}456}
464457
...@@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src)...@@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
514}507}
515508
516static __inline uint64_t509static __inline uint64_t
517atomic_load_acq_64(volatile uint64_t *p)510atomic_load_acq_64(const volatile uint64_t *p)
518{511{
519512
520 if ((cpu_feature & CPUID_CX8) == 0)513 if ((cpu_feature & CPUID_CX8) == 0)
...@@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long);...@@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long);
614#undef ATOMIC_STORE607#undef ATOMIC_STORE
615#undef ATOMIC_LOADSTORE608#undef ATOMIC_LOADSTORE
616609
617#ifndef WANT_FUNCTIONS
618
619static __inline int610static __inline int
620atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)611atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
621{612{
...@@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v)...@@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v)
842#define atomic_subtract_rel_ptr(p, v) \833#define atomic_subtract_rel_ptr(p, v) \
843 atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v))834 atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v))
844#define atomic_load_acq_ptr(p) \835#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))
846#define atomic_store_rel_ptr(p, v) \837#define atomic_store_rel_ptr(p, v) \
847 atomic_store_rel_int((volatile u_int *)(p), (v))838 atomic_store_rel_int((volatile u_int *)(p), (v))
848#define atomic_cmpset_ptr(dst, old, new) \839#define atomic_cmpset_ptr(dst, old, new) \
...@@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v)...@@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v)
865 atomic_swap_int((volatile u_int *)(p), (u_int)(v))856 atomic_swap_int((volatile u_int *)(p), (u_int)(v))
866#define atomic_readandclear_ptr(p) \857#define atomic_readandclear_ptr(p) \
867 atomic_readandclear_int((volatile u_int *)(p))858 atomic_readandclear_int((volatile u_int *)(p))
868859#define atomic_testandclear_ptr(p, val) \
869#endif /* !WANT_FUNCTIONS */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
871#if defined(_KERNEL)864#if defined(_KERNEL)
872#define mb() __mbk()865#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
35 */33 */
3634
37#ifndef _MACHINE_CPU_H_35#ifndef _MACHINE_CPU_H_
lib/libc/include/x86-freebsd-none/machine/cpufunc.h+1-10
...@@ -63,15 +63,6 @@ bsfl(u_int mask)...@@ -63,15 +63,6 @@ bsfl(u_int mask)
63 return (result);63 return (result);
64}64}
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
75static __inline void66static __inline void
76clflush(u_long addr)67clflush(u_long addr)
77{68{
...@@ -83,7 +74,7 @@ static __inline void...@@ -83,7 +74,7 @@ static __inline void
83clflushopt(u_long addr)74clflushopt(u_long addr)
84{75{
8576
86 __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr));77 __asm __volatile("clflushopt %0" : : "m" (*(char *)addr));
87}78}
8879
89static __inline void80static __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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
37 */35 */
3836
39#ifndef _MACHINE_IEEEFP_H_37#ifndef _MACHINE_IEEEFP_H_
lib/libc/include/x86-freebsd-none/machine/in_cksum.h-1
...@@ -29,7 +29,6 @@...@@ -29,7 +29,6 @@
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *30 *
31 * from tahoe: in_cksum.c 1.2 86/01/0531 * from tahoe: in_cksum.c 1.2 86/01/05
32 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
33 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp32 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
34 */33 */
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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
35 */33 */
3634
37/*35/*
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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)param.h 5.8 (Berkeley) 6/28/91
35 */33 */
3634
37#ifndef _I386_INCLUDE_PARAM_H_35#ifndef _I386_INCLUDE_PARAM_H_
...@@ -43,9 +41,7 @@...@@ -43,9 +41,7 @@
43 * Machine dependent constants for Intel 386.41 * Machine dependent constants for Intel 386.
44 */42 */
4543
46#define __HAVE_ACPI
47#define __HAVE_PIR44#define __HAVE_PIR
48#define __PCI_REROUTE_INTERRUPT
4945
50#ifndef MACHINE46#ifndef MACHINE
51#define MACHINE "i386"47#define MACHINE "i386"
...@@ -146,19 +142,12 @@...@@ -146,19 +142,12 @@
146/*142/*
147 * Mach derived conversion macros143 * Mach derived conversion macros
148 */144 */
149#define trunc_page(x) ((x) & ~PAGE_MASK)
150#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
151#define trunc_4mpage(x) ((x) & ~PDRMASK)145#define trunc_4mpage(x) ((x) & ~PDRMASK)
152#define round_4mpage(x) ((((x)) + PDRMASK) & ~PDRMASK)146#define round_4mpage(x) ((((x)) + PDRMASK) & ~PDRMASK)
153147
154#define atop(x) ((x) >> PAGE_SHIFT)
155#define ptoa(x) ((x) << PAGE_SHIFT)
156
157#define i386_btop(x) ((x) >> PAGE_SHIFT)148#define i386_btop(x) ((x) >> PAGE_SHIFT)
158#define i386_ptob(x) ((x) << PAGE_SHIFT)149#define i386_ptob(x) ((x) << PAGE_SHIFT)
159150
160#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
161
162#define INKERNEL(va) (TRUE)151#define INKERNEL(va) (TRUE)
163152
164#endif /* !_I386_INCLUDE_PARAM_H_ */153#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
35 */33 */
3634
37#ifndef _I386_PCB_H_35#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");...@@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
108/*108/*
109 * Evaluates to the address of the per-cpu variable name.109 * Evaluates to the address of the per-cpu variable name.
110 */110 */
111#define __PCPU_PTR(name) __extension__ ({ \111#define __PCPU_PTR(name) \
112 __pcpu_type(name) *__p; \112 (&get_pcpu()->name)
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})
121113
122/*114/*
123 * Evaluates to the value of the per-cpu variable name.115 * Evaluates to the value of the per-cpu variable name.
...@@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
126 __pcpu_type(name) __res; \118 __pcpu_type(name) __res; \
127 struct __s { \119 struct __s { \
128 u_char __b[MIN(sizeof(__res), 4)]; \120 u_char __b[MIN(sizeof(__res), 4)]; \
129 } __s; \121 }; \
130 \122 \
131 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \123 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \
132 sizeof(__res) == 4) { \124 sizeof(__res) == 4) { \
133 __asm __volatile("mov %%fs:%1,%0" \125 __asm __volatile("mov %%fs:%c1,%0" \
134 : "=r" (__s) \126 : "=r" (*(struct __s *)(void *)&__res) \
135 : "m" (*(struct __s *)(__pcpu_offset(name)))); \127 : "i" (__pcpu_offset(name))); \
136 *(struct __s *)(void *)&__res = __s; \
137 } else { \128 } else { \
138 __res = *__PCPU_PTR(name); \129 __res = *__PCPU_PTR(name); \
139 } \130 } \
...@@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
148 __pcpu_type(name) __val; \139 __pcpu_type(name) __val; \
149 struct __s { \140 struct __s { \
150 u_char __b[MIN(sizeof(__val), 4)]; \141 u_char __b[MIN(sizeof(__val), 4)]; \
151 } __s; \142 }; \
152 \143 \
153 __val = (val); \144 __val = (val); \
154 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \145 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
155 sizeof(__val) == 4) { \146 sizeof(__val) == 4) { \
156 __s = *(struct __s *)(void *)&__val; \147 __asm __volatile("add %1,%%fs:%c0" \
157 __asm __volatile("add %1,%%fs:%0" \148 : \
158 : "=m" (*(struct __s *)(__pcpu_offset(name))) \149 : "i" (__pcpu_offset(name)), \
159 : "r" (__s)); \150 "r" (*(struct __s *)(void *)&__val) \
151 : "cc", "memory"); \
160 } else \152 } else \
161 *__PCPU_PTR(name) += __val; \153 *__PCPU_PTR(name) += __val; \
162} while (0)154} while (0)
...@@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
168 __pcpu_type(name) __val; \160 __pcpu_type(name) __val; \
169 struct __s { \161 struct __s { \
170 u_char __b[MIN(sizeof(__val), 4)]; \162 u_char __b[MIN(sizeof(__val), 4)]; \
171 } __s; \163 }; \
172 \164 \
173 __val = (val); \165 __val = (val); \
174 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \166 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
175 sizeof(__val) == 4) { \167 sizeof(__val) == 4) { \
176 __s = *(struct __s *)(void *)&__val; \168 __asm __volatile("mov %1,%%fs:%c0" \
177 __asm __volatile("mov %1,%%fs:%0" \169 : \
178 : "=m" (*(struct __s *)(__pcpu_offset(name))) \170 : "i" (__pcpu_offset(name)), \
179 : "r" (__s)); \171 "r" (*(struct __s *)(void *)&__val) \
172 : "memory"); \
180 } else { \173 } else { \
181 *__PCPU_PTR(name) = __val; \174 *__PCPU_PTR(name) = __val; \
182 } \175 } \
...@@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
185#define get_pcpu() __extension__ ({ \178#define get_pcpu() __extension__ ({ \
186 struct pcpu *__pc; \179 struct pcpu *__pc; \
187 \180 \
188 __asm __volatile("movl %%fs:%1,%0" \181 __asm __volatile("movl %%fs:%c1,%0" \
189 : "=r" (__pc) \182 : "=r" (__pc) \
190 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \183 : "i" (__pcpu_offset(pc_prvspace))); \
191 __pc; \184 __pc; \
192})185})
193186
lib/libc/include/x86-freebsd-none/machine/pcpu_aux.h+4-4
...@@ -49,8 +49,8 @@ __curthread(void)...@@ -49,8 +49,8 @@ __curthread(void)
49{49{
50 struct thread *td;50 struct thread *td;
5151
52 __asm("movl %%fs:%1,%0" : "=r" (td)52 __asm("movl %%fs:%c1,%0" : "=r" (td)
53 : "m" (*(char *)offsetof(struct pcpu, pc_curthread)));53 : "i" (offsetof(struct pcpu, pc_curthread)));
54 return (td);54 return (td);
55}55}
56#define curthread (__curthread())56#define curthread (__curthread())
...@@ -60,8 +60,8 @@ __curpcb(void)...@@ -60,8 +60,8 @@ __curpcb(void)
60{60{
61 struct pcb *pcb;61 struct pcb *pcb;
6262
63 __asm("movl %%fs:%1,%0" : "=r" (pcb)63 __asm("movl %%fs:%c1,%0" : "=r" (pcb)
64 : "m" (*(char *)offsetof(struct pcpu, pc_curpcb)));64 : "i" (offsetof(struct pcpu, pc_curpcb)));
65 return (pcb);65 return (pcb);
66}66}
67#define curpcb (__curpcb())67#define curpcb (__curpcb())
lib/libc/include/x86-freebsd-none/machine/pmap.h+3-6
...@@ -37,9 +37,6 @@...@@ -37,9 +37,6 @@
37 * map the page tables using the pagetables themselves. This is done to37 * map the page tables using the pagetables themselves. This is done to
38 * reduce the impact on kernel virtual memory for lots of sparse address38 * reduce the impact on kernel virtual memory for lots of sparse address
39 * space, and to reduce the cost of memory to each process.39 * 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
43 */40 */
4441
45#ifndef _MACHINE_PMAP_H_42#ifndef _MACHINE_PMAP_H_
...@@ -83,7 +80,7 @@...@@ -83,7 +80,7 @@
83 * 4KB (PTE) page mappings have identical settings for the following fields:80 * 4KB (PTE) page mappings have identical settings for the following fields:
84 */81 */
85#define PG_PTE_PROMOTE (PG_MANAGED | PG_W | PG_G | PG_PTE_PAT | \82#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
88/*85/*
89 * Page Protection Exception bits86 * Page Protection Exception bits
...@@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem);...@@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem);
221void *pmap_bios16_enter(void);218void *pmap_bios16_enter(void);
222void pmap_bios16_leave(void *handle);219void pmap_bios16_leave(void *handle);
223void pmap_bootstrap(vm_paddr_t);220void 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);
225int pmap_change_attr(vm_offset_t, vm_size_t, int);222int pmap_change_attr(vm_offset_t, vm_size_t, int);
226caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits);223caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits);
227void pmap_cp_slow0_map(vm_offset_t kaddr, int plen, vm_page_t *ma);224void 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);...@@ -239,7 +236,7 @@ void pmap_ksetrw(vm_offset_t va);
239void *pmap_mapbios(vm_paddr_t, vm_size_t);236void *pmap_mapbios(vm_paddr_t, vm_size_t);
240void *pmap_mapdev(vm_paddr_t, vm_size_t);237void *pmap_mapdev(vm_paddr_t, vm_size_t);
241void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);238void *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);
243void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);240void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
244vm_paddr_t pmap_pg_frame(vm_paddr_t pa);241vm_paddr_t pmap_pg_frame(vm_paddr_t pa);
245bool pmap_ps_enabled(pmap_t pmap);242bool 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 {...@@ -58,8 +58,8 @@ struct pmap_methods {
58 void *(*pm_bios16_enter)(void);58 void *(*pm_bios16_enter)(void);
59 void (*pm_bios16_leave)(void *handle);59 void (*pm_bios16_leave)(void *handle);
60 void (*pm_bootstrap)(vm_paddr_t firstaddr);60 void (*pm_bootstrap)(vm_paddr_t firstaddr);
61 boolean_t (*pm_is_valid_memattr)(pmap_t, vm_memattr_t);61 bool (*pm_is_valid_memattr)(pmap_t, vm_memattr_t);
62 int (*pm_cache_bits)(pmap_t, int, boolean_t);62 int (*pm_cache_bits)(pmap_t, int, bool);
63 bool (*pm_ps_enabled)(pmap_t);63 bool (*pm_ps_enabled)(pmap_t);
64 void (*pm_pinit0)(pmap_t);64 void (*pm_pinit0)(pmap_t);
65 int (*pm_pinit)(pmap_t);65 int (*pm_pinit)(pmap_t);
...@@ -84,13 +84,13 @@ struct pmap_methods {...@@ -84,13 +84,13 @@ struct pmap_methods {
84 void (*pm_object_init_pt)(pmap_t, vm_offset_t, vm_object_t,84 void (*pm_object_init_pt)(pmap_t, vm_offset_t, vm_object_t,
85 vm_pindex_t, vm_size_t);85 vm_pindex_t, vm_size_t);
86 void (*pm_unwire)(pmap_t, vm_offset_t, vm_offset_t);86 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);
88 int (*pm_page_wired_mappings)(vm_page_t);88 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);
90 void (*pm_remove_pages)(pmap_t);90 void (*pm_remove_pages)(pmap_t);
91 boolean_t (*pm_is_modified)(vm_page_t);91 bool (*pm_is_modified)(vm_page_t);
92 boolean_t (*pm_is_prefaultable)(pmap_t, vm_offset_t);92 bool (*pm_is_prefaultable)(pmap_t, vm_offset_t);
93 boolean_t (*pm_is_referenced)(vm_page_t);93 bool (*pm_is_referenced)(vm_page_t);
94 void (*pm_remove_write)(vm_page_t);94 void (*pm_remove_write)(vm_page_t);
95 int (*pm_ts_referenced)(vm_page_t);95 int (*pm_ts_referenced)(vm_page_t);
96 void *(*pm_mapdev_attr)(vm_paddr_t, vm_size_t, int, int);96 void *(*pm_mapdev_attr)(vm_paddr_t, vm_size_t, int, int);
...@@ -107,7 +107,7 @@ struct pmap_methods {...@@ -107,7 +107,7 @@ struct pmap_methods {
107 void (*pm_remove_all)(vm_page_t);107 void (*pm_remove_all)(vm_page_t);
108 void (*pm_init)(void);108 void (*pm_init)(void);
109 void (*pm_init_pat)(void);109 void (*pm_init_pat)(void);
110 void (*pm_growkernel)(vm_offset_t);110 int (*pm_growkernel)(vm_offset_t);
111 void (*pm_invalidate_page)(pmap_t, vm_offset_t);111 void (*pm_invalidate_page)(pmap_t, vm_offset_t);
112 void (*pm_invalidate_range)(pmap_t, vm_offset_t, vm_offset_t);112 void (*pm_invalidate_range)(pmap_t, vm_offset_t, vm_offset_t);
113 void (*pm_invalidate_all)(pmap_t);113 void (*pm_invalidate_all)(pmap_t);
lib/libc/include/x86-freebsd-none/machine/pmap_nopae.h-3
...@@ -44,9 +44,6 @@...@@ -44,9 +44,6 @@
44 * map the page tables using the pagetables themselves. This is done to44 * map the page tables using the pagetables themselves. This is done to
45 * reduce the impact on kernel virtual memory for lots of sparse address45 * reduce the impact on kernel virtual memory for lots of sparse address
46 * space, and to reduce the cost of memory to each process.46 * 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
50 */47 */
5148
52#ifndef _MACHINE_PMAP_NOPAE_H49#ifndef _MACHINE_PMAP_NOPAE_H
lib/libc/include/x86-freebsd-none/machine/pmap_pae.h-3
...@@ -44,9 +44,6 @@...@@ -44,9 +44,6 @@
44 * map the page tables using the pagetables themselves. This is done to44 * map the page tables using the pagetables themselves. This is done to
45 * reduce the impact on kernel virtual memory for lots of sparse address45 * reduce the impact on kernel virtual memory for lots of sparse address
46 * space, and to reduce the cost of memory to each process.46 * 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
50 */47 */
5148
52#ifndef _MACHINE_PMAP_PAE_H49#ifndef _MACHINE_PMAP_PAE_H
lib/libc/include/x86-freebsd-none/machine/proc.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
32 */30 */
3331
34#ifndef _MACHINE_PROC_H_32#ifndef _MACHINE_PROC_H_
lib/libc/include/x86-freebsd-none/machine/profile.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
32 */30 */
3331
34#ifndef _MACHINE_PROFILE_H_32#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 @@...@@ -39,8 +39,6 @@
39#define SYS_RES_DRQ 2 /* isa dma lines */39#define SYS_RES_DRQ 2 /* isa dma lines */
40#define SYS_RES_MEMORY 3 /* i/o memory */40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */41#define SYS_RES_IOPORT 4 /* i/o ports */
42#ifdef NEW_PCIB
43#define PCI_RES_BUS 5 /* PCI bus numbers */42#define PCI_RES_BUS 5 /* PCI bus numbers */
44#endif
4543
46#endif /* !_MACHINE_RESOURCE_H_ */44#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 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
36 */34 */
3735
38#ifndef _MACHINE_SEGMENTS_H_36#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 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)signal.h 8.1 (Berkeley) 6/11/93
32 */30 */
3331
34#ifndef _MACHINE_SIGNAL_H_32#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)tss.h 5.4 (Berkeley) 1/18/91
35 */33 */
3634
37#ifndef _MACHINE_TSS_H_35#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 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
37 */35 */
3836
39#ifndef _MACHINE_VMPARAM_H_37#ifndef _MACHINE_VMPARAM_H_
...@@ -248,5 +246,6 @@...@@ -248,5 +246,6 @@
248 * Need a page dump array for minidump.246 * Need a page dump array for minidump.
249 */247 */
250#define MINIDUMP_PAGE_TRACKING 1248#define MINIDUMP_PAGE_TRACKING 1
249#define MINIDUMP_STARTUP_PAGE_TRACKING 0
251250
252#endif /* _MACHINE_VMPARAM_H_ */251#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
35 */33 */
3634
37#ifndef _MACHINE_ASM_H_35#ifndef _MACHINE_ASM_H_
lib/libc/include/x86_64-freebsd-none/i386/atomic.h+20-27
...@@ -49,8 +49,8 @@ static __inline void...@@ -49,8 +49,8 @@ static __inline void
49__mbk(void)49__mbk(void)
50{50{
5151
52 __asm __volatile("lock; addl $0,%%fs:%0"52 __asm __volatile("lock; addl $0,%%fs:%c0"
53 : "+m" (*(u_int *)__OFFSETOF_MONITORBUF) : : "memory", "cc");53 : : "i" (__OFFSETOF_MONITORBUF) : "memory", "cc");
54}54}
5555
56static __inline void56static __inline void
...@@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)...@@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v)
249249
250#define ATOMIC_LOAD(TYPE) \250#define ATOMIC_LOAD(TYPE) \
251static __inline u_##TYPE \251static __inline u_##TYPE \
252atomic_load_acq_##TYPE(volatile u_##TYPE *p) \252atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
253{ \253{ \
254 u_##TYPE res; \254 u_##TYPE res; \
255 \255 \
...@@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void)...@@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void)
299299
300#ifdef _KERNEL300#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
313/* I486 does not support SMP or CMPXCHG8B. */302/* I486 does not support SMP or CMPXCHG8B. */
314static __inline int303static __inline int
315atomic_cmpset_64_i386(volatile uint64_t *dst, uint64_t expect, uint64_t src)304atomic_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)...@@ -353,12 +342,12 @@ atomic_fcmpset_64_i386(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
353}342}
354343
355static __inline uint64_t344static __inline uint64_t
356atomic_load_acq_64_i386(volatile uint64_t *p)345atomic_load_acq_64_i386(const volatile uint64_t *p)
357{346{
358 volatile uint32_t *q;347 const volatile uint32_t *q;
359 uint64_t res;348 uint64_t res;
360349
361 q = (volatile uint32_t *)p;350 q = (const volatile uint32_t *)p;
362 __asm __volatile(351 __asm __volatile(
363 " pushfl ; "352 " pushfl ; "
364 " cli ; "353 " cli ; "
...@@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src)...@@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
447 return (res);436 return (res);
448}437}
449438
439/*
440 * Architecturally always writes back some value to '*p' so will trigger
441 * a #GP(0) on read-only mappings.
442 */
450static __inline uint64_t443static __inline uint64_t
451atomic_load_acq_64_i586(volatile uint64_t *p)444atomic_load_acq_64_i586(const volatile uint64_t *p)
452{445{
453 uint64_t res;446 uint64_t res;
454447
...@@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p)...@@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p)
456 " movl %%ebx,%%eax ; "449 " movl %%ebx,%%eax ; "
457 " movl %%ecx,%%edx ; "450 " movl %%ecx,%%edx ; "
458 " lock; cmpxchg8b %1"451 " lock; cmpxchg8b %1"
459 : "=&A" (res), /* 0 */452 : "=&A" (res) /* 0 */
460 "+m" (*p) /* 1 */453 : "m" (*p) /* 1 */
461 : : "memory", "cc");454 : "memory", "cc");
462 return (res);455 return (res);
463}456}
464457
...@@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src)...@@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src)
514}507}
515508
516static __inline uint64_t509static __inline uint64_t
517atomic_load_acq_64(volatile uint64_t *p)510atomic_load_acq_64(const volatile uint64_t *p)
518{511{
519512
520 if ((cpu_feature & CPUID_CX8) == 0)513 if ((cpu_feature & CPUID_CX8) == 0)
...@@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long);...@@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long);
614#undef ATOMIC_STORE607#undef ATOMIC_STORE
615#undef ATOMIC_LOADSTORE608#undef ATOMIC_LOADSTORE
616609
617#ifndef WANT_FUNCTIONS
618
619static __inline int610static __inline int
620atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)611atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
621{612{
...@@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v)...@@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v)
842#define atomic_subtract_rel_ptr(p, v) \833#define atomic_subtract_rel_ptr(p, v) \
843 atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v))834 atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v))
844#define atomic_load_acq_ptr(p) \835#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))
846#define atomic_store_rel_ptr(p, v) \837#define atomic_store_rel_ptr(p, v) \
847 atomic_store_rel_int((volatile u_int *)(p), (v))838 atomic_store_rel_int((volatile u_int *)(p), (v))
848#define atomic_cmpset_ptr(dst, old, new) \839#define atomic_cmpset_ptr(dst, old, new) \
...@@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v)...@@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v)
865 atomic_swap_int((volatile u_int *)(p), (u_int)(v))856 atomic_swap_int((volatile u_int *)(p), (u_int)(v))
866#define atomic_readandclear_ptr(p) \857#define atomic_readandclear_ptr(p) \
867 atomic_readandclear_int((volatile u_int *)(p))858 atomic_readandclear_int((volatile u_int *)(p))
868859#define atomic_testandclear_ptr(p, val) \
869#endif /* !WANT_FUNCTIONS */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
871#if defined(_KERNEL)864#if defined(_KERNEL)
872#define mb() __mbk()865#define mb() __mbk()
lib/libc/include/x86_64-freebsd-none/i386/cpufunc.h+1-10
...@@ -63,15 +63,6 @@ bsfl(u_int mask)...@@ -63,15 +63,6 @@ bsfl(u_int mask)
63 return (result);63 return (result);
64}64}
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
75static __inline void66static __inline void
76clflush(u_long addr)67clflush(u_long addr)
77{68{
...@@ -83,7 +74,7 @@ static __inline void...@@ -83,7 +74,7 @@ static __inline void
83clflushopt(u_long addr)74clflushopt(u_long addr)
84{75{
8576
86 __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr));77 __asm __volatile("clflushopt %0" : : "m" (*(char *)addr));
87}78}
8879
89static __inline void80static __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");...@@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
108/*108/*
109 * Evaluates to the address of the per-cpu variable name.109 * Evaluates to the address of the per-cpu variable name.
110 */110 */
111#define __PCPU_PTR(name) __extension__ ({ \111#define __PCPU_PTR(name) \
112 __pcpu_type(name) *__p; \112 (&get_pcpu()->name)
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})
121113
122/*114/*
123 * Evaluates to the value of the per-cpu variable name.115 * Evaluates to the value of the per-cpu variable name.
...@@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
126 __pcpu_type(name) __res; \118 __pcpu_type(name) __res; \
127 struct __s { \119 struct __s { \
128 u_char __b[MIN(sizeof(__res), 4)]; \120 u_char __b[MIN(sizeof(__res), 4)]; \
129 } __s; \121 }; \
130 \122 \
131 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \123 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \
132 sizeof(__res) == 4) { \124 sizeof(__res) == 4) { \
133 __asm __volatile("mov %%fs:%1,%0" \125 __asm __volatile("mov %%fs:%c1,%0" \
134 : "=r" (__s) \126 : "=r" (*(struct __s *)(void *)&__res) \
135 : "m" (*(struct __s *)(__pcpu_offset(name)))); \127 : "i" (__pcpu_offset(name))); \
136 *(struct __s *)(void *)&__res = __s; \
137 } else { \128 } else { \
138 __res = *__PCPU_PTR(name); \129 __res = *__PCPU_PTR(name); \
139 } \130 } \
...@@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
148 __pcpu_type(name) __val; \139 __pcpu_type(name) __val; \
149 struct __s { \140 struct __s { \
150 u_char __b[MIN(sizeof(__val), 4)]; \141 u_char __b[MIN(sizeof(__val), 4)]; \
151 } __s; \142 }; \
152 \143 \
153 __val = (val); \144 __val = (val); \
154 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \145 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
155 sizeof(__val) == 4) { \146 sizeof(__val) == 4) { \
156 __s = *(struct __s *)(void *)&__val; \147 __asm __volatile("add %1,%%fs:%c0" \
157 __asm __volatile("add %1,%%fs:%0" \148 : \
158 : "=m" (*(struct __s *)(__pcpu_offset(name))) \149 : "i" (__pcpu_offset(name)), \
159 : "r" (__s)); \150 "r" (*(struct __s *)(void *)&__val) \
151 : "cc", "memory"); \
160 } else \152 } else \
161 *__PCPU_PTR(name) += __val; \153 *__PCPU_PTR(name) += __val; \
162} while (0)154} while (0)
...@@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
168 __pcpu_type(name) __val; \160 __pcpu_type(name) __val; \
169 struct __s { \161 struct __s { \
170 u_char __b[MIN(sizeof(__val), 4)]; \162 u_char __b[MIN(sizeof(__val), 4)]; \
171 } __s; \163 }; \
172 \164 \
173 __val = (val); \165 __val = (val); \
174 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \166 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
175 sizeof(__val) == 4) { \167 sizeof(__val) == 4) { \
176 __s = *(struct __s *)(void *)&__val; \168 __asm __volatile("mov %1,%%fs:%c0" \
177 __asm __volatile("mov %1,%%fs:%0" \169 : \
178 : "=m" (*(struct __s *)(__pcpu_offset(name))) \170 : "i" (__pcpu_offset(name)), \
179 : "r" (__s)); \171 "r" (*(struct __s *)(void *)&__val) \
172 : "memory"); \
180 } else { \173 } else { \
181 *__PCPU_PTR(name) = __val; \174 *__PCPU_PTR(name) = __val; \
182 } \175 } \
...@@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
185#define get_pcpu() __extension__ ({ \178#define get_pcpu() __extension__ ({ \
186 struct pcpu *__pc; \179 struct pcpu *__pc; \
187 \180 \
188 __asm __volatile("movl %%fs:%1,%0" \181 __asm __volatile("movl %%fs:%c1,%0" \
189 : "=r" (__pc) \182 : "=r" (__pc) \
190 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \183 : "i" (__pcpu_offset(pc_prvspace))); \
191 __pc; \184 __pc; \
192})185})
193186
lib/libc/include/x86_64-freebsd-none/i386/pcpu_aux.h+4-4
...@@ -49,8 +49,8 @@ __curthread(void)...@@ -49,8 +49,8 @@ __curthread(void)
49{49{
50 struct thread *td;50 struct thread *td;
5151
52 __asm("movl %%fs:%1,%0" : "=r" (td)52 __asm("movl %%fs:%c1,%0" : "=r" (td)
53 : "m" (*(char *)offsetof(struct pcpu, pc_curthread)));53 : "i" (offsetof(struct pcpu, pc_curthread)));
54 return (td);54 return (td);
55}55}
56#define curthread (__curthread())56#define curthread (__curthread())
...@@ -60,8 +60,8 @@ __curpcb(void)...@@ -60,8 +60,8 @@ __curpcb(void)
60{60{
61 struct pcb *pcb;61 struct pcb *pcb;
6262
63 __asm("movl %%fs:%1,%0" : "=r" (pcb)63 __asm("movl %%fs:%c1,%0" : "=r" (pcb)
64 : "m" (*(char *)offsetof(struct pcpu, pc_curpcb)));64 : "i" (offsetof(struct pcpu, pc_curpcb)));
65 return (pcb);65 return (pcb);
66}66}
67#define curpcb (__curpcb())67#define curpcb (__curpcb())
lib/libc/include/x86_64-freebsd-none/i386/pmap.h+3-6
...@@ -37,9 +37,6 @@...@@ -37,9 +37,6 @@
37 * map the page tables using the pagetables themselves. This is done to37 * map the page tables using the pagetables themselves. This is done to
38 * reduce the impact on kernel virtual memory for lots of sparse address38 * reduce the impact on kernel virtual memory for lots of sparse address
39 * space, and to reduce the cost of memory to each process.39 * 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
43 */40 */
4441
45#ifndef _MACHINE_PMAP_H_42#ifndef _MACHINE_PMAP_H_
...@@ -83,7 +80,7 @@...@@ -83,7 +80,7 @@
83 * 4KB (PTE) page mappings have identical settings for the following fields:80 * 4KB (PTE) page mappings have identical settings for the following fields:
84 */81 */
85#define PG_PTE_PROMOTE (PG_MANAGED | PG_W | PG_G | PG_PTE_PAT | \82#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
88/*85/*
89 * Page Protection Exception bits86 * Page Protection Exception bits
...@@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem);...@@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem);
221void *pmap_bios16_enter(void);218void *pmap_bios16_enter(void);
222void pmap_bios16_leave(void *handle);219void pmap_bios16_leave(void *handle);
223void pmap_bootstrap(vm_paddr_t);220void 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);
225int pmap_change_attr(vm_offset_t, vm_size_t, int);222int pmap_change_attr(vm_offset_t, vm_size_t, int);
226caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits);223caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits);
227void pmap_cp_slow0_map(vm_offset_t kaddr, int plen, vm_page_t *ma);224void 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);...@@ -239,7 +236,7 @@ void pmap_ksetrw(vm_offset_t va);
239void *pmap_mapbios(vm_paddr_t, vm_size_t);236void *pmap_mapbios(vm_paddr_t, vm_size_t);
240void *pmap_mapdev(vm_paddr_t, vm_size_t);237void *pmap_mapdev(vm_paddr_t, vm_size_t);
241void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);238void *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);
243void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);240void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
244vm_paddr_t pmap_pg_frame(vm_paddr_t pa);241vm_paddr_t pmap_pg_frame(vm_paddr_t pa);
245bool pmap_ps_enabled(pmap_t pmap);242bool pmap_ps_enabled(pmap_t pmap);
lib/libc/include/x86_64-freebsd-none/i386/proc.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
32 */30 */
3331
34#ifndef _MACHINE_PROC_H_32#ifndef _MACHINE_PROC_H_
lib/libc/include/x86_64-freebsd-none/i386/profile.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
32 */30 */
3331
34#ifndef _MACHINE_PROFILE_H_32#ifndef _MACHINE_PROFILE_H_
lib/libc/include/x86_64-freebsd-none/i386/segments.h-2
...@@ -31,8 +31,6 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
36 */34 */
3735
38#ifndef _MACHINE_SEGMENTS_H_36#ifndef _MACHINE_SEGMENTS_H_
lib/libc/include/x86_64-freebsd-none/i386/vmparam.h+1-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
37 */35 */
3836
39#ifndef _MACHINE_VMPARAM_H_37#ifndef _MACHINE_VMPARAM_H_
...@@ -248,5 +246,6 @@...@@ -248,5 +246,6 @@
248 * Need a page dump array for minidump.246 * Need a page dump array for minidump.
249 */247 */
250#define MINIDUMP_PAGE_TRACKING 1248#define MINIDUMP_PAGE_TRACKING 1
249#define MINIDUMP_STARTUP_PAGE_TRACKING 0
251250
252#endif /* _MACHINE_VMPARAM_H_ */251#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 @@...@@ -1,30 +1,13 @@
1/*-1/*-
2 * SPDX-License-Identifier: BSD-2-Clause2 * Copyright (c) 2005 The FreeBSD Foundation.
3 *
4 * Copyright (c) 2005 M. Warner Losh <imp@FreeBSD.org>
5 *3 *
6 * Redistribution and use in source and binary forms, with or without4 * SPDX-License-Identifier: BSD-2-Clause
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.
16 *5 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND6 * Derived in part from NetBSD's bus.h files by (alphabetically):
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE7 * Christopher G. Demetriou
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE8 * Charles M. Hannum
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR9 * Jason Thorpe
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL10 * The NetBSD Foundation.
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 */11 */
2912
30#ifndef AMD64_INCLUDE__BUS_H13#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
35 */33 */
3634
37#ifdef __i386__35#ifdef __i386__
...@@ -94,7 +92,7 @@...@@ -94,7 +92,7 @@
9492
95#define END(x) .size x, . - x; .cfi_endproc93#define END(x) .size x, . - x; .cfi_endproc
96/*94/*
97 * WEAK_REFERENCE(): create a weak reference alias from sym. 95 * WEAK_REFERENCE(): create a weak reference alias from sym.
98 * The macro is not a general asm macro that takes arbitrary names,96 * The macro is not a general asm macro that takes arbitrary names,
99 * but one that takes only C names. It does the non-null name97 * but one that takes only C names. It does the non-null name
100 * translation inside the macro.98 * translation inside the macro.
lib/libc/include/x86_64-freebsd-none/machine/atomic.h+6-7
...@@ -102,7 +102,7 @@...@@ -102,7 +102,7 @@
102 */102 */
103103
104/*104/*
105 * Always use lock prefixes. The result is slighly less optimal for105 * Always use lock prefixes. The result is slightly less optimal for
106 * UP systems, but it matters less now, and sometimes UP is emulated106 * UP systems, but it matters less now, and sometimes UP is emulated
107 * over SMP.107 * over SMP.
108 *108 *
...@@ -295,8 +295,8 @@ static __inline void...@@ -295,8 +295,8 @@ static __inline void
295__storeload_barrier(void)295__storeload_barrier(void)
296{296{
297#if defined(_KERNEL)297#if defined(_KERNEL)
298 __asm __volatile("lock; addl $0,%%gs:%0"298 __asm __volatile("lock; addl $0,%%gs:%c0"
299 : "+m" (*(u_int *)OFFSETOF_MONITORBUF) : : "memory", "cc");299 : : "i" (OFFSETOF_MONITORBUF) : "memory", "cc");
300#else /* !_KERNEL */300#else /* !_KERNEL */
301 __asm __volatile("lock; addl $0,-8(%%rsp)" : : : "memory", "cc");301 __asm __volatile("lock; addl $0,-8(%%rsp)" : : : "memory", "cc");
302#endif /* _KERNEL*/302#endif /* _KERNEL*/
...@@ -304,7 +304,7 @@ __storeload_barrier(void)...@@ -304,7 +304,7 @@ __storeload_barrier(void)
304304
305#define ATOMIC_LOAD(TYPE) \305#define ATOMIC_LOAD(TYPE) \
306static __inline u_##TYPE \306static __inline u_##TYPE \
307atomic_load_acq_##TYPE(volatile u_##TYPE *p) \307atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \
308{ \308{ \
309 u_##TYPE res; \309 u_##TYPE res; \
310 \310 \
...@@ -385,7 +385,6 @@ ATOMIC_LOADSTORE(long);...@@ -385,7 +385,6 @@ ATOMIC_LOADSTORE(long);
385#undef ATOMIC_LOAD385#undef ATOMIC_LOAD
386#undef ATOMIC_STORE386#undef ATOMIC_STORE
387#undef ATOMIC_LOADSTORE387#undef ATOMIC_LOADSTORE
388#ifndef WANT_FUNCTIONS
389388
390/* Read the current value and store a new value in the destination. */389/* Read the current value and store a new value in the destination. */
391static __inline u_int390static __inline u_int
...@@ -589,8 +588,8 @@ atomic_swap_long(volatile u_long *p, u_long v)...@@ -589,8 +588,8 @@ atomic_swap_long(volatile u_long *p, u_long v)
589#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long588#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long
590#define atomic_swap_ptr atomic_swap_long589#define atomic_swap_ptr atomic_swap_long
591#define atomic_readandclear_ptr atomic_readandclear_long590#define atomic_readandclear_ptr atomic_readandclear_long
592591#define atomic_testandset_ptr atomic_testandset_long
593#endif /* !WANT_FUNCTIONS */592#define atomic_testandclear_ptr atomic_testandclear_long
594593
595#endif /* !SAN_NEEDS_INTERCEPTORS || SAN_RUNTIME */594#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 @@...@@ -29,6 +29,6 @@
29#ifndef _AMD64_BUS_DMA_H_29#ifndef _AMD64_BUS_DMA_H_
30#define _AMD64_BUS_DMA_H_30#define _AMD64_BUS_DMA_H_
3131
32#include <x86/bus_dma.h> 32#include <x86/bus_dma.h>
3333
34#endif /* _AMD64_BUS_DMA_H_ */34#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91
35 */33 */
3634
37#ifndef _MACHINE_CPU_H_35#ifndef _MACHINE_CPU_H_
...@@ -72,7 +70,8 @@ extern char btext[];...@@ -72,7 +70,8 @@ extern char btext[];
72extern char _end[];70extern char _end[];
73extern char etext[];71extern char etext[];
7472
75/* Resume hook for VMM. */73/* Suspend and resume hook for VMM. */
74extern void (*vmm_suspend_p)(void);
76extern void (*vmm_resume_p)(void);75extern void (*vmm_resume_p)(void);
7776
78void cpu_halt(void);77void cpu_halt(void);
lib/libc/include/x86_64-freebsd-none/machine/cpufunc.h+33-5
...@@ -65,10 +65,6 @@ breakpoint(void)...@@ -65,10 +65,6 @@ breakpoint(void)
6565
66#define bsfq(mask) __builtin_ctzl(mask)66#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
72static __inline void68static __inline void
73clflush(u_long addr)69clflush(u_long addr)
74{70{
...@@ -80,7 +76,7 @@ static __inline void...@@ -80,7 +76,7 @@ static __inline void
80clflushopt(u_long addr)76clflushopt(u_long addr)
81{77{
8278
83 __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr));79 __asm __volatile("clflushopt %0" : : "m" (*(char *)addr));
84}80}
8581
86static __inline void82static __inline void
...@@ -576,6 +572,15 @@ rss(void)...@@ -576,6 +572,15 @@ rss(void)
576 return (sel);572 return (sel);
577}573}
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
579static __inline void584static __inline void
580load_ds(u_short sel)585load_ds(u_short sel)
581{586{
...@@ -946,6 +951,29 @@ sgx_eremove(void *epc)...@@ -946,6 +951,29 @@ sgx_eremove(void *epc)
946 return (sgx_encls(SGX_EREMOVE, 0, (uint64_t)epc, 0));951 return (sgx_encls(SGX_EREMOVE, 0, (uint64_t)epc, 0));
947}952}
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
949void reset_dbregs(void);977void reset_dbregs(void);
950978
951#ifdef _KERNEL979#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 @@...@@ -29,6 +29,8 @@
29#ifndef __AMD64_INCLUDE_EFI_H_29#ifndef __AMD64_INCLUDE_EFI_H_
30#define __AMD64_INCLUDE_EFI_H_30#define __AMD64_INCLUDE_EFI_H_
3131
32#include <sys/types.h>
33
32/*34/*
33 * XXX: from gcc 6.2 manual:35 * XXX: from gcc 6.2 manual:
34 * Note, the ms_abi attribute for Microsoft Windows 64-bit targets36 * Note, the ms_abi attribute for Microsoft Windows 64-bit targets
...@@ -51,6 +53,10 @@...@@ -51,6 +53,10 @@
51#define EFI_TIME_OWNED() mtx_assert(&atrtc_time_lock, MA_OWNED)53#define EFI_TIME_OWNED() mtx_assert(&atrtc_time_lock, MA_OWNED)
5254
53#define EFI_RT_HANDLE_FAULTS_DEFAULT 155#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;
54#endif60#endif
5561
56struct efirt_callinfo {62struct 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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
35 */33 */
3634
37/*35/*
lib/libc/include/x86_64-freebsd-none/machine/ieeefp.h-2
...@@ -32,8 +32,6 @@...@@ -32,8 +32,6 @@
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32 * 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 OF33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.34 * SUCH DAMAGE.
35 *
36 * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
37 */35 */
3836
39#ifndef _MACHINE_IEEEFP_H_37#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;...@@ -50,6 +50,7 @@ extern vm_paddr_t intel_graphics_stolen_base;
50extern vm_paddr_t intel_graphics_stolen_size;50extern vm_paddr_t intel_graphics_stolen_size;
5151
52extern int la57;52extern int la57;
53extern int prefer_uva_la48;
5354
54extern vm_paddr_t kernphys;55extern vm_paddr_t kernphys;
55extern vm_paddr_t KERNend;56extern vm_paddr_t KERNend;
...@@ -98,6 +99,10 @@ void get_fpcontext(struct thread *td, struct __mcontext *mcp,...@@ -98,6 +99,10 @@ void get_fpcontext(struct thread *td, struct __mcontext *mcp,
98int set_fpcontext(struct thread *td, struct __mcontext *mcp,99int set_fpcontext(struct thread *td, struct __mcontext *mcp,
99 char *xfpustate, size_t xfpustate_len);100 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
101#endif /* !_MACHINE_MD_VAR_H_ */106#endif /* !_MACHINE_MD_VAR_H_ */
102107
103#endif /* __i386__ */108#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)...@@ -81,7 +81,7 @@ kmsan_md_unsupported(vm_offset_t addr)
81 * The kernel itself isn't shadowed: for most purposes global variables81 * The kernel itself isn't shadowed: for most purposes global variables
82 * are always initialized, and because KMSAN kernels are large82 * are always initialized, and because KMSAN kernels are large
83 * (GENERIC-KMSAN is ~80MB at the time of writing), shadowing would83 * (GENERIC-KMSAN is ~80MB at the time of writing), shadowing would
84 * incur signficant memory usage.84 * incur significant memory usage.
85 */85 */
86 return (addr < VM_MIN_KERNEL_ADDRESS || addr >= KERNBASE);86 return (addr < VM_MIN_KERNEL_ADDRESS || addr >= KERNBASE);
87}87}
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 @@...@@ -36,8 +36,6 @@
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY36 * 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 OF37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.38 * SUCH DAMAGE.
39 *
40 * @(#)param.h 8.1 (Berkeley) 6/10/93
41 */39 */
4240
43#ifndef _AMD64_INCLUDE_PARAM_H_41#ifndef _AMD64_INCLUDE_PARAM_H_
...@@ -49,9 +47,6 @@...@@ -49,9 +47,6 @@
49 * Machine dependent constants for AMD64.47 * Machine dependent constants for AMD64.
50 */48 */
5149
52#define __HAVE_ACPI
53#define __PCI_REROUTE_INTERRUPT
54
55#ifndef MACHINE50#ifndef MACHINE
56#define MACHINE "amd64"51#define MACHINE "amd64"
57#endif52#endif
...@@ -80,7 +75,7 @@...@@ -80,7 +75,7 @@
80 * ALIGNED_POINTER is a boolean macro that checks whether an address75 * ALIGNED_POINTER is a boolean macro that checks whether an address
81 * is valid to fetch data elements of type t from on this architecture.76 * is valid to fetch data elements of type t from on this architecture.
82 * This does not reflect the optimal alignment, just the possibility77 * This does not reflect the optimal alignment, just the possibility
83 * (within reasonable limits). 78 * (within reasonable limits).
84 */79 */
85#define ALIGNED_POINTER(p, t) 180#define ALIGNED_POINTER(p, t) 1
8681
...@@ -144,25 +139,17 @@...@@ -144,25 +139,17 @@
144/*139/*
145 * Mach derived conversion macros140 * Mach derived conversion macros
146 */141 */
147#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
148#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK))
149#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK)142#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK)
150#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK)143#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK)
151#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK)144#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
156#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)146#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
157#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)147#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
165#define SC_TABLESIZE 1024 /* Must be power of 2. */153#define SC_TABLESIZE 1024 /* Must be power of 2. */
166#endif
167154
168#endif /* !_AMD64_INCLUDE_PARAM_H_ */155#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 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
36 */34 */
3735
38#ifndef _AMD64_PCB_H_36#ifndef _AMD64_PCB_H_
...@@ -86,6 +84,7 @@ struct pcb {...@@ -86,6 +84,7 @@ struct pcb {
86#define PCB_KERNFPU_THR 0x0020 /* fpu_kern_thread() */84#define PCB_KERNFPU_THR 0x0020 /* fpu_kern_thread() */
87#define PCB_32BIT 0x0040 /* process has 32 bit context (segs etc) */85#define PCB_32BIT 0x0040 /* process has 32 bit context (segs etc) */
88#define PCB_FPUNOSAVE 0x0080 /* no save area for current FPU ctx */86#define PCB_FPUNOSAVE 0x0080 /* no save area for current FPU ctx */
87#define PCB_TLSBASE 0x0100 /* tlsbase was set */
8988
90 uint16_t pcb_initial_fpucw;89 uint16_t pcb_initial_fpucw;
9190
...@@ -106,7 +105,8 @@ struct pcb {...@@ -106,7 +105,8 @@ struct pcb {
106105
107 struct savefpu *pcb_save;106 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];
110};110};
111111
112/* Per-CPU state saved during suspend and resume. */112/* 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");...@@ -182,16 +182,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
182/*182/*
183 * Evaluates to the address of the per-cpu variable name.183 * Evaluates to the address of the per-cpu variable name.
184 */184 */
185#define __PCPU_PTR(name) __extension__ ({ \185#define __PCPU_PTR(name) \
186 __pcpu_type(name) *__p; \186 (&get_pcpu()->name)
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})
195187
196/*188/*
197 * Evaluates to the value of the per-cpu variable name.189 * Evaluates to the value of the per-cpu variable name.
...@@ -200,14 +192,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -200,14 +192,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
200 __pcpu_type(name) __res; \192 __pcpu_type(name) __res; \
201 struct __s { \193 struct __s { \
202 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \194 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
203 } __s; \195 }; \
204 \196 \
205 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \197 if (sizeof(__res) == 1 || sizeof(__res) == 2 || \
206 sizeof(__res) == 4 || sizeof(__res) == 8) { \198 sizeof(__res) == 4 || sizeof(__res) == 8) { \
207 __asm __volatile("mov %%gs:%1,%0" \199 __asm __volatile("mov %%gs:%c1,%0" \
208 : "=r" (__s) \200 : "=r" (*(struct __s *)(void *)&__res) \
209 : "m" (*(struct __s *)(__pcpu_offset(name)))); \201 : "i" (__pcpu_offset(name))); \
210 *(struct __s *)(void *)&__res = __s; \
211 } else { \202 } else { \
212 __res = *__PCPU_PTR(name); \203 __res = *__PCPU_PTR(name); \
213 } \204 } \
...@@ -222,15 +213,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -222,15 +213,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
222 __pcpu_type(name) __val; \213 __pcpu_type(name) __val; \
223 struct __s { \214 struct __s { \
224 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \215 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
225 } __s; \216 }; \
226 \217 \
227 __val = (val); \218 __val = (val); \
228 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \219 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
229 sizeof(__val) == 4 || sizeof(__val) == 8) { \220 sizeof(__val) == 4 || sizeof(__val) == 8) { \
230 __s = *(struct __s *)(void *)&__val; \221 __asm __volatile("add %1,%%gs:%c0" \
231 __asm __volatile("add %1,%%gs:%0" \222 : \
232 : "=m" (*(struct __s *)(__pcpu_offset(name))) \223 : "i" (__pcpu_offset(name)), \
233 : "r" (__s)); \224 "r" (*(struct __s *)(void *)&__val) \
225 : "cc", "memory"); \
234 } else \226 } else \
235 *__PCPU_PTR(name) += __val; \227 *__PCPU_PTR(name) += __val; \
236} while (0)228} while (0)
...@@ -238,30 +230,31 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");...@@ -238,30 +230,31 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
238/*230/*
239 * Sets the value of the per-cpu variable name to value val.231 * Sets the value of the per-cpu variable name to value val.
240 */232 */
241#define __PCPU_SET(name, val) { \233#define __PCPU_SET(name, val) do { \
242 __pcpu_type(name) __val; \234 __pcpu_type(name) __val; \
243 struct __s { \235 struct __s { \
244 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \236 u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \
245 } __s; \237 }; \
246 \238 \
247 __val = (val); \239 __val = (val); \
248 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \240 if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
249 sizeof(__val) == 4 || sizeof(__val) == 8) { \241 sizeof(__val) == 4 || sizeof(__val) == 8) { \
250 __s = *(struct __s *)(void *)&__val; \242 __asm __volatile("mov %1,%%gs:%c0" \
251 __asm __volatile("mov %1,%%gs:%0" \243 : \
252 : "=m" (*(struct __s *)(__pcpu_offset(name))) \244 : "i" (__pcpu_offset(name)), \
253 : "r" (__s)); \245 "r" (*(struct __s *)(void *)&__val) \
246 : "memory"); \
254 } else { \247 } else { \
255 *__PCPU_PTR(name) = __val; \248 *__PCPU_PTR(name) = __val; \
256 } \249 } \
257}250} while (0)
258251
259#define get_pcpu() __extension__ ({ \252#define get_pcpu() __extension__ ({ \
260 struct pcpu *__pc; \253 struct pcpu *__pc; \
261 \254 \
262 __asm __volatile("movq %%gs:%1,%0" \255 __asm __volatile("movq %%gs:%c1,%0" \
263 : "=r" (__pc) \256 : "=r" (__pc) \
264 : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \257 : "i" (__pcpu_offset(pc_prvspace))); \
265 __pc; \258 __pc; \
266})259})
267#endif /* !__SEG_GS */260#endif /* !__SEG_GS */
lib/libc/include/x86_64-freebsd-none/machine/pcpu_aux.h+2-2
...@@ -54,8 +54,8 @@ __curthread(void)...@@ -54,8 +54,8 @@ __curthread(void)
54{54{
55 struct thread *td;55 struct thread *td;
5656
57 __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu,57 __asm("movq %%gs:%c1,%0" : "=r" (td)
58 pc_curthread)));58 : "i" (offsetof(struct pcpu, pc_curthread)));
59 return (td);59 return (td);
60}60}
61#define curthread (__curthread())61#define curthread (__curthread())
lib/libc/include/x86_64-freebsd-none/machine/pmap.h+35-73
...@@ -38,9 +38,6 @@...@@ -38,9 +38,6 @@
38 * map the page tables using the pagetables themselves. This is done to38 * map the page tables using the pagetables themselves. This is done to
39 * reduce the impact on kernel virtual memory for lots of sparse address39 * reduce the impact on kernel virtual memory for lots of sparse address
40 * space, and to reduce the cost of memory to each process.40 * 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
44 */41 */
4542
46#ifdef __i386__43#ifdef __i386__
...@@ -50,48 +47,7 @@...@@ -50,48 +47,7 @@
50#ifndef _MACHINE_PMAP_H_47#ifndef _MACHINE_PMAP_H_
51#define _MACHINE_PMAP_H_48#define _MACHINE_PMAP_H_
5249
53/*50#include <machine/pte.h>
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 */
9551
96/*52/*
97 * Define the PG_xx macros in terms of the bits on x86 PTEs.53 * Define the PG_xx macros in terms of the bits on x86 PTEs.
...@@ -120,9 +76,6 @@...@@ -120,9 +76,6 @@
120#define EPT_PG_EMUL_V X86_PG_AVAIL(52)76#define EPT_PG_EMUL_V X86_PG_AVAIL(52)
121#define EPT_PG_EMUL_RW X86_PG_AVAIL(53)77#define EPT_PG_EMUL_RW X86_PG_AVAIL(53)
122#define PG_PROMOTED X86_PG_AVAIL(54) /* PDE only */78#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
127/*80/*
128 * Promotion to a 2MB (PDE) page mapping requires that the corresponding 4KB81 * Promotion to a 2MB (PDE) page mapping requires that the corresponding 4KB
...@@ -132,18 +85,6 @@...@@ -132,18 +85,6 @@
132 PG_M | PG_U | PG_RW | PG_V | PG_PKU_MASK)85 PG_M | PG_U | PG_RW | PG_V | PG_PKU_MASK)
13386
134/*87/*
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/*
147 * undef the PG_xx macros that define bits in the regular x86 PTEs that88 * undef the PG_xx macros that define bits in the regular x86 PTEs that
148 * have a different position in nested PTEs. This is done when compiling89 * have a different position in nested PTEs. This is done when compiling
149 * code that needs to be aware of the differences between regular x86 and90 * code that needs to be aware of the differences between regular x86 and
...@@ -169,12 +110,7 @@...@@ -169,12 +110,7 @@
169 * Pte related macros. This is complicated by having to deal with110 * Pte related macros. This is complicated by having to deal with
170 * the sign extension of the 48th bit.111 * the sign extension of the 48th bit.
171 */112 */
172#define KV4ADDR(l4, l3, l2, l1) ( \113#define KV4ADDR(l4, l3, l2, l1) KV5ADDR(-1, 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))
178#define KV5ADDR(l5, l4, l3, l2, l1) ( \114#define KV5ADDR(l5, l4, l3, l2, l1) ( \
179 ((unsigned long)-1 << 56) | \115 ((unsigned long)-1 << 56) | \
180 ((unsigned long)(l5) << PML5SHIFT) | \116 ((unsigned long)(l5) << PML5SHIFT) | \
...@@ -233,11 +169,12 @@...@@ -233,11 +169,12 @@
233 * the recursive page table map.169 * the recursive page table map.
234 */170 */
235#define NDMPML4E 8171#define NDMPML4E 8
172#define NDMPML5E 32
236173
237/*174/*
238 * These values control the layout of virtual memory. The starting address175 * These values control the layout of virtual memory. The starting
239 * of the direct map, which is controlled by DMPML4I, must be a multiple of176 * address of the direct map is controlled by DMPML4I on LA48 and
240 * its size. (See the PHYS_TO_DMAP() and DMAP_TO_PHYS() macros.)177 * DMPML5I on LA57.
241 *178 *
242 * Note: KPML4I is the index of the (single) level 4 page that maps179 * Note: KPML4I is the index of the (single) level 4 page that maps
243 * the KVA that holds KERNBASE, while KPML4BASE is the index of the180 * the KVA that holds KERNBASE, while KPML4BASE is the index of the
...@@ -255,6 +192,7 @@...@@ -255,6 +192,7 @@
255192
256#define KPML4BASE (NPML4EPG-NKPML4E) /* KVM at highest addresses */193#define KPML4BASE (NPML4EPG-NKPML4E) /* KVM at highest addresses */
257#define DMPML4I rounddown(KPML4BASE-NDMPML4E, NDMPML4E) /* Below KVM */194#define DMPML4I rounddown(KPML4BASE-NDMPML4E, NDMPML4E) /* Below KVM */
195#define DMPML5I (NPML5EPG / 2 + 1)
258196
259#define KPML4I (NPML4EPG-1)197#define KPML4I (NPML4EPG-1)
260#define KPDPI (NPDPEPG-2) /* kernbase at -2GB */198#define KPDPI (NPDPEPG-2) /* kernbase at -2GB */
...@@ -264,9 +202,14 @@...@@ -264,9 +202,14 @@
264#define KMSANSHADPML4I (KPML4BASE - NKMSANSHADPML4E)202#define KMSANSHADPML4I (KPML4BASE - NKMSANSHADPML4E)
265#define KMSANORIGPML4I (DMPML4I - NKMSANORIGPML4E)203#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 */
268#define LMSPML4I (PML4PML4I + 1)209#define LMSPML4I (PML4PML4I + 1)
269#define LMEPML4I (KASANPML4I - 1)210#define LMEPML4I (KASANPML4I - 1)
211#define LMSPML5I (DMPML5I + NDMPML5E)
212#define LMEPML5I (LMSPML5I + 32 - 1) /* 32 slots for large map */
270213
271/*214/*
272 * XXX doesn't really belong here I guess...215 * XXX doesn't really belong here I guess...
...@@ -448,10 +391,10 @@ void pmap_activate_boot(pmap_t pmap);...@@ -448,10 +391,10 @@ void pmap_activate_boot(pmap_t pmap);
448void pmap_activate_sw(struct thread *);391void pmap_activate_sw(struct thread *);
449void pmap_allow_2m_x_ept_recalculate(void);392void pmap_allow_2m_x_ept_recalculate(void);
450void pmap_bootstrap(vm_paddr_t *);393void 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);
452int pmap_change_attr(vm_offset_t, vm_size_t, int);395int pmap_change_attr(vm_offset_t, vm_size_t, int);
453int pmap_change_prot(vm_offset_t, vm_size_t, vm_prot_t);396int 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);
455void pmap_flush_cache_range(vm_offset_t, vm_offset_t);398void pmap_flush_cache_range(vm_offset_t, vm_offset_t);
456void pmap_flush_cache_phys_range(vm_paddr_t, vm_paddr_t, vm_memattr_t);399void pmap_flush_cache_phys_range(vm_paddr_t, vm_paddr_t, vm_memattr_t);
457void pmap_init_pat(void);400void pmap_init_pat(void);
...@@ -467,7 +410,7 @@ void *pmap_mapdev(vm_paddr_t, vm_size_t);...@@ -467,7 +410,7 @@ void *pmap_mapdev(vm_paddr_t, vm_size_t);
467void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);410void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int);
468void *pmap_mapdev_pciecfg(vm_paddr_t pa, vm_size_t size);411void *pmap_mapdev_pciecfg(vm_paddr_t pa, vm_size_t size);
469bool pmap_not_in_di(void);412bool pmap_not_in_di(void);
470boolean_t pmap_page_is_mapped(vm_page_t m);413bool pmap_page_is_mapped(vm_page_t m);
471void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);414void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma);
472void pmap_page_set_memattr_noflush(vm_page_t m, vm_memattr_t ma);415void pmap_page_set_memattr_noflush(vm_page_t m, vm_memattr_t ma);
473void pmap_pinit_pml4(vm_page_t);416void pmap_pinit_pml4(vm_page_t);
...@@ -612,6 +555,25 @@ pmap_pml5e_index(vm_offset_t va)...@@ -612,6 +555,25 @@ pmap_pml5e_index(vm_offset_t va)
612 return ((va >> PML5SHIFT) & ((1ul << NPML5EPGSHIFT) - 1));555 return ((va >> PML5SHIFT) & ((1ul << NPML5EPGSHIFT) - 1));
613}556}
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
615#endif /* !LOCORE */577#endif /* !LOCORE */
616578
617#endif /* !_MACHINE_PMAP_H_ */579#endif /* !_MACHINE_PMAP_H_ */
lib/libc/include/x86_64-freebsd-none/machine/proc.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * from: @(#)proc.h 7.1 (Berkeley) 5/15/91
32 */30 */
3331
34#ifdef __i386__32#ifdef __i386__
lib/libc/include/x86_64-freebsd-none/machine/profile.h-2
...@@ -27,8 +27,6 @@...@@ -27,8 +27,6 @@
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27 * 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 OF28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.29 * SUCH DAMAGE.
30 *
31 * @(#)profile.h 8.1 (Berkeley) 6/11/93
32 */30 */
3331
34#ifdef __i386__32#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 @@...@@ -12,7 +12,7 @@
12 * no representations about the suitability of this software for any12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied13 * purpose. It is provided "as is" without express or implied
14 * warranty.14 * warranty.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS16 * 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,17 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
...@@ -39,8 +39,6 @@...@@ -39,8 +39,6 @@
39#define SYS_RES_DRQ 2 /* isa dma lines */39#define SYS_RES_DRQ 2 /* isa dma lines */
40#define SYS_RES_MEMORY 3 /* i/o memory */40#define SYS_RES_MEMORY 3 /* i/o memory */
41#define SYS_RES_IOPORT 4 /* i/o ports */41#define SYS_RES_IOPORT 4 /* i/o ports */
42#ifdef NEW_PCIB
43#define PCI_RES_BUS 5 /* PCI bus numbers */42#define PCI_RES_BUS 5 /* PCI bus numbers */
44#endif
4543
46#endif /* !_MACHINE_RESOURCE_H_ */44#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 @@...@@ -31,8 +31,6 @@
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY31 * 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 OF32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.33 * SUCH DAMAGE.
34 *
35 * from: @(#)segments.h 7.1 (Berkeley) 5/9/91
36 */34 */
3735
38#ifdef __i386__36#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 @@...@@ -34,7 +34,7 @@
34 * On this machine, the only purpose for which sf_buf is used is to implement34 * On this machine, the only purpose for which sf_buf is used is to implement
35 * an opaque pointer required by the machine-independent parts of the kernel.35 * an opaque pointer required by the machine-independent parts of the kernel.
36 * That pointer references the vm_page that is "mapped" by the sf_buf. The36 * 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.
38 */38 */
39static inline vm_offset_t39static inline vm_offset_t
40sf_buf_kva(struct sf_buf *sf)40sf_buf_kva(struct sf_buf *sf)
lib/libc/include/x86_64-freebsd-none/machine/smp.h-3
...@@ -13,8 +13,6 @@...@@ -13,8 +13,6 @@
1313
14#ifdef _KERNEL14#ifdef _KERNEL
1515
16#ifdef SMP
17
18#ifndef LOCORE16#ifndef LOCORE
1917
20#include <x86/x86_smp.h>18#include <x86/x86_smp.h>
...@@ -39,7 +37,6 @@ void invlop_handler(void);...@@ -39,7 +37,6 @@ void invlop_handler(void);
39int start_all_aps(void);37int start_all_aps(void);
4038
41#endif /* !LOCORE */39#endif /* !LOCORE */
42#endif /* SMP */
4340
44#endif /* _KERNEL */41#endif /* _KERNEL */
45#endif /* _MACHINE_SMP_H_ */42#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 @@...@@ -30,8 +30,6 @@
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * 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 OF31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.32 * SUCH DAMAGE.
33 *
34 * from: @(#)tss.h 5.4 (Berkeley) 1/18/91
35 */33 */
3634
37#ifndef _MACHINE_TSS_H_35#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 {...@@ -46,6 +46,7 @@ enum vm_suspend_how {
46 VM_SUSPEND_POWEROFF,46 VM_SUSPEND_POWEROFF,
47 VM_SUSPEND_HALT,47 VM_SUSPEND_HALT,
48 VM_SUSPEND_TRIPLEFAULT,48 VM_SUSPEND_TRIPLEFAULT,
49 VM_SUSPEND_DESTROY,
49 VM_SUSPEND_LAST50 VM_SUSPEND_LAST
50};51};
5152
...@@ -124,7 +125,7 @@ enum x2apic_state {...@@ -124,7 +125,7 @@ enum x2apic_state {
124/*125/*
125 * The VM name has to fit into the pathname length constraints of devfs,126 * The VM name has to fit into the pathname length constraints of devfs,
126 * governed primarily by SPECNAMELEN. The length is the total number of127 * 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
128 * including any leading '/' characters.129 * including any leading '/' characters.
129 * A prefix and a suffix are added to the name specified by the user.130 * A prefix and a suffix are added to the name specified by the user.
130 * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters131 * 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);...@@ -150,6 +151,7 @@ CTASSERT(VM_MAX_NAMELEN >= VM_MIN_NAMELEN);
150151
151struct vm;152struct vm;
152struct vm_exception;153struct vm_exception;
154struct vm_mem;
153struct seg_desc;155struct seg_desc;
154struct vm_exit;156struct vm_exit;
155struct vm_run;157struct vm_run;
...@@ -170,6 +172,7 @@ struct vm_eventinfo {...@@ -170,6 +172,7 @@ struct vm_eventinfo {
170172
171typedef int (*vmm_init_func_t)(int ipinum);173typedef int (*vmm_init_func_t)(int ipinum);
172typedef int (*vmm_cleanup_func_t)(void);174typedef int (*vmm_cleanup_func_t)(void);
175typedef void (*vmm_suspend_func_t)(void);
173typedef void (*vmm_resume_func_t)(void);176typedef void (*vmm_resume_func_t)(void);
174typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);177typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);
175typedef int (*vmi_run_func_t)(void *vcpui, register_t rip,178typedef 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);...@@ -194,6 +197,7 @@ typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now);
194struct vmm_ops {197struct vmm_ops {
195 vmm_init_func_t modinit; /* module wide initialization */198 vmm_init_func_t modinit; /* module wide initialization */
196 vmm_cleanup_func_t modcleanup;199 vmm_cleanup_func_t modcleanup;
200 vmm_resume_func_t modsuspend;
197 vmm_resume_func_t modresume;201 vmm_resume_func_t modresume;
198202
199 vmi_init_func_t init; /* vm-specific initialization */203 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,...@@ -236,39 +240,11 @@ void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores,
236int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,240int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
237 uint16_t threads, uint16_t maxcpus);241 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);
250int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa);243int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
251int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len);244int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len);
252int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);245int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
253int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func);246int 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
272int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);248int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
273int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);249int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
274int vm_get_seg_desc(struct vcpu *vcpu, int reg,250int vm_get_seg_desc(struct vcpu *vcpu, int reg,
...@@ -399,7 +375,8 @@ vcpu_should_yield(struct vcpu *vcpu)...@@ -399,7 +375,8 @@ vcpu_should_yield(struct vcpu *vcpu)
399375
400void *vcpu_stats(struct vcpu *vcpu);376void *vcpu_stats(struct vcpu *vcpu);
401void vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr);377void 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);
403struct vatpic *vm_atpic(struct vm *vm);380struct vatpic *vm_atpic(struct vm *vm);
404struct vatpit *vm_atpit(struct vm *vm);381struct vatpit *vm_atpit(struct vm *vm);
405struct vpmtmr *vm_pmtmr(struct vm *vm);382struct vpmtmr *vm_pmtmr(struct vm *vm);
...@@ -448,7 +425,7 @@ int vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2);...@@ -448,7 +425,7 @@ int vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2);
448425
449/*426/*
450 * Function used to keep track of the guest's TSC offset. The427 * Function used to keep track of the guest's TSC offset. The
451 * offset is used by the virutalization extensions to provide a consistent428 * offset is used by the virtualization extensions to provide a consistent
452 * value for the Time Stamp Counter to the guest.429 * value for the Time Stamp Counter to the guest.
453 */430 */
454void vm_set_tsc_offset(struct vcpu *vcpu, uint64_t offset);431void vm_set_tsc_offset(struct vcpu *vcpu, uint64_t offset);
...@@ -465,7 +442,7 @@ struct vm_copyinfo {...@@ -465,7 +442,7 @@ struct vm_copyinfo {
465/*442/*
466 * Set up 'copyinfo[]' to copy to/from guest linear address space starting443 * Set up 'copyinfo[]' to copy to/from guest linear address space starting
467 * at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for444 * 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.
469 *446 *
470 * retval is_fault Interpretation447 * retval is_fault Interpretation
471 * 0 0 Success448 * 0 0 Success
...@@ -673,6 +650,8 @@ struct vm_inout_str {...@@ -673,6 +650,8 @@ struct vm_inout_str {
673 int addrsize;650 int addrsize;
674 enum vm_reg_name seg_name;651 enum vm_reg_name seg_name;
675 struct seg_desc seg_desc;652 struct seg_desc seg_desc;
653 int cs_d;
654 uint64_t cs_base;
676};655};
677656
678enum task_switch_reason {657enum task_switch_reason {
lib/libc/include/x86_64-freebsd-none/machine/vmm_dev.h+8-18
...@@ -29,12 +29,10 @@...@@ -29,12 +29,10 @@
29#ifndef _VMM_DEV_H_29#ifndef _VMM_DEV_H_
30#define _VMM_DEV_H_30#define _VMM_DEV_H_
3131
32struct vm_snapshot_meta;32#include <sys/domainset.h>
3333
34#ifdef _KERNEL34#include <machine/vmm.h>
35void vmmdev_init(void);35#include <machine/vmm_snapshot.h>
36int vmmdev_cleanup(void);
37#endif
3836
39struct vm_memmap {37struct vm_memmap {
40 vm_paddr_t gpa;38 vm_paddr_t gpa;
...@@ -56,16 +54,12 @@ struct vm_munmap {...@@ -56,16 +54,12 @@ struct vm_munmap {
56struct vm_memseg {54struct vm_memseg {
57 int segid;55 int segid;
58 size_t len;56 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;
60};61};
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
69struct vm_register {63struct vm_register {
70 int cpuid;64 int cpuid;
71 int regnum; /* enum vm_reg_name */65 int regnum; /* enum vm_reg_name */
...@@ -312,7 +306,7 @@ enum {...@@ -312,7 +306,7 @@ enum {
312 IOCNUM_UNMAP_PPTDEV_MMIO = 46,306 IOCNUM_UNMAP_PPTDEV_MMIO = 46,
313307
314 /* statistics */308 /* statistics */
315 IOCNUM_VM_STATS = 50, 309 IOCNUM_VM_STATS = 50,
316 IOCNUM_VM_STAT_DESC = 51,310 IOCNUM_VM_STAT_DESC = 51,
317311
318 /* kernel device state */312 /* kernel device state */
...@@ -354,12 +348,8 @@ enum {...@@ -354,12 +348,8 @@ enum {
354 _IOW('v', IOCNUM_SUSPEND, struct vm_suspend)348 _IOW('v', IOCNUM_SUSPEND, struct vm_suspend)
355#define VM_REINIT \349#define VM_REINIT \
356 _IO('v', IOCNUM_REINIT)350 _IO('v', IOCNUM_REINIT)
357#define VM_ALLOC_MEMSEG_FBSD12 \
358 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg_fbsd12)
359#define VM_ALLOC_MEMSEG \351#define VM_ALLOC_MEMSEG \
360 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg)352 _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg)
361#define VM_GET_MEMSEG_FBSD12 \
362 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg_fbsd12)
363#define VM_GET_MEMSEG \353#define VM_GET_MEMSEG \
364 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg)354 _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg)
365#define VM_MMAP_MEMSEG \355#define VM_MMAP_MEMSEG \
lib/libc/include/x86_64-freebsd-none/machine/vmm_instruction_emul.h+26-1
...@@ -31,6 +31,31 @@...@@ -31,6 +31,31 @@
3131
32#include <sys/mman.h>32#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
34/*59/*
35 * Callback functions to read and write memory regions.60 * Callback functions to read and write memory regions.
36 */61 */
...@@ -112,7 +137,7 @@ void vie_init(struct vie *vie, const char *inst_bytes, int inst_length);...@@ -112,7 +137,7 @@ void vie_init(struct vie *vie, const char *inst_bytes, int inst_length);
112 * 'gla' is the guest linear address provided by the hardware assist137 * 'gla' is the guest linear address provided by the hardware assist
113 * that caused the nested page table fault. It is used to verify that138 * that caused the nested page table fault. It is used to verify that
114 * the software instruction decoding is in agreement with the hardware.139 * the software instruction decoding is in agreement with the hardware.
115 * 140 *
116 * Some hardware assists do not provide the 'gla' to the hypervisor.141 * Some hardware assists do not provide the 'gla' to the hypervisor.
117 * To skip the 'gla' verification for this or any other reason pass142 * To skip the 'gla' verification for this or any other reason pass
118 * in VIE_INVALID_GLA instead.143 * in VIE_INVALID_GLA instead.
lib/libc/include/x86_64-freebsd-none/machine/vmparam.h+46-42
...@@ -38,8 +38,6 @@...@@ -38,8 +38,6 @@
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.40 * SUCH DAMAGE.
41 *
42 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
43 */41 */
4442
45#ifdef __i386__43#ifdef __i386__
...@@ -74,12 +72,12 @@...@@ -74,12 +72,12 @@
74#endif72#endif
7573
76/*74/*
77 * We provide a machine specific single page allocator through the use75 * We provide a single page allocator through the use of the
78 * of the direct mapped segment. This uses 2MB pages for reduced76 * direct mapped segment. This uses 2MB pages for reduced
79 * TLB pressure.77 * TLB pressure.
80 */78 */
81#if !defined(KASAN) && !defined(KMSAN)79#if !defined(KASAN) && !defined(KMSAN)
82#define UMA_MD_SMALL_ALLOC80#define UMA_USE_DMAP
83#endif81#endif
8482
85/*83/*
...@@ -91,19 +89,21 @@...@@ -91,19 +89,21 @@
91 * The number of PHYSSEG entries must be one greater than the number89 * The number of PHYSSEG entries must be one greater than the number
92 * of phys_avail entries because the phys_avail entry that spans the90 * of phys_avail entries because the phys_avail entry that spans the
93 * largest physical address that is accessible by ISA DMA is split91 * largest physical address that is accessible by ISA DMA is split
94 * into two PHYSSEG entries. 92 * into two PHYSSEG entries.
95 */93 */
96#define VM_PHYSSEG_MAX 6394#define VM_PHYSSEG_MAX 63
9795
98/*96/*
99 * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool97 * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool from
100 * from which physical pages are allocated and VM_FREEPOOL_DIRECT is98 * which physical pages are allocated and VM_FREEPOOL_DIRECT is the pool from
101 * the pool from which physical pages for page tables and small UMA99 * which physical pages for page tables and small UMA objects are allocated.
102 * 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.
103 */102 */
104#define VM_NFREEPOOL 2103#define VM_NFREEPOOL 3
105#define VM_FREEPOOL_DEFAULT 0104#define VM_FREEPOOL_LAZYINIT 0
106#define VM_FREEPOOL_DIRECT 1105#define VM_FREEPOOL_DEFAULT 1
106#define VM_FREEPOOL_DIRECT 2
107107
108/*108/*
109 * Create up to three free page lists: VM_FREELIST_DMA32 is for physical pages109 * Create up to three free page lists: VM_FREELIST_DMA32 is for physical pages
...@@ -149,10 +149,6 @@...@@ -149,10 +149,6 @@
149#define VM_LEVEL_0_ORDER 9149#define VM_LEVEL_0_ORDER 9
150#endif150#endif
151151
152#ifdef SMP
153#define PA_LOCK_COUNT 256
154#endif
155
156/*152/*
157 * Kernel physical load address for non-UEFI boot and for legacy UEFI loader.153 * Kernel physical load address for non-UEFI boot and for legacy UEFI loader.
158 * Newer UEFI loader loads kernel anywhere below 4G, with memory allocated154 * Newer UEFI loader loads kernel anywhere below 4G, with memory allocated
...@@ -167,6 +163,7 @@...@@ -167,6 +163,7 @@
167 * Virtual addresses of things. Derived from the page directory and163 * Virtual addresses of things. Derived from the page directory and
168 * page table indexes from pmap.h for precision.164 * page table indexes from pmap.h for precision.
169 *165 *
166 * LA48:
170 * 0x0000000000000000 - 0x00007fffffffffff user map167 * 0x0000000000000000 - 0x00007fffffffffff user map
171 * 0x0000800000000000 - 0xffff7fffffffffff does not exist (hole)168 * 0x0000800000000000 - 0xffff7fffffffffff does not exist (hole)
172 * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot)169 * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot)
...@@ -179,32 +176,38 @@...@@ -179,32 +176,38 @@
179 * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional176 * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional
180 * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map177 * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map
181 *178 *
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 *
182 * Within the kernel map:193 * Within the kernel map:
183 *194 *
184 * 0xfffffe0000000000 vm_page_array195 * 0xfffffe0000000000 vm_page_array
185 * 0xffffffff80000000 KERNBASE196 * 0xffffffff80000000 KERNBASE
186 */197 */
187198
188#define VM_MIN_KERNEL_ADDRESS KV4ADDR(KPML4BASE, 0, 0, 0)199#define VM_MIN_KERNEL_ADDRESS_LA48 KV4ADDR(KPML4BASE, 0, 0, 0)
189#define VM_MAX_KERNEL_ADDRESS KV4ADDR(KPML4BASE + NKPML4E - 1, \200#define VM_MIN_KERNEL_ADDRESS kva_layout.km_low
190 NPDPEPG-1, NPDEPG-1, NPTEPG-1)201#define VM_MAX_KERNEL_ADDRESS kva_layout.km_high
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)
197202
198#define KMSAN_SHAD_MIN_ADDRESS KV4ADDR(KMSANSHADPML4I, 0, 0, 0)203#define KASAN_MIN_ADDRESS (kva_layout.kasan_shadow_low)
199#define KMSAN_SHAD_MAX_ADDRESS KV4ADDR(KMSANSHADPML4I + NKMSANSHADPML4E, \204#define KASAN_MAX_ADDRESS (kva_layout.kasan_shadow_high)
200 0, 0, 0)
201205
202#define KMSAN_ORIG_MIN_ADDRESS KV4ADDR(KMSANORIGPML4I, 0, 0, 0)206#define KMSAN_SHAD_MIN_ADDRESS (kva_layout.kmsan_shadow_low)
203#define KMSAN_ORIG_MAX_ADDRESS KV4ADDR(KMSANORIGPML4I + NKMSANORIGPML4E, \207#define KMSAN_SHAD_MAX_ADDRESS (kva_layout.kmsan_shadow_high)
204 0, 0, 0)
205208
206#define LARGEMAP_MIN_ADDRESS KV4ADDR(LMSPML4I, 0, 0, 0)209#define KMSAN_ORIG_MIN_ADDRESS (kva_layout.kmsan_origin_low)
207#define LARGEMAP_MAX_ADDRESS KV4ADDR(LMEPML4I + 1, 0, 0, 0)210#define KMSAN_ORIG_MAX_ADDRESS (kva_layout.kmsan_origin_high)
208211
209/*212/*
210 * Formally kernel mapping starts at KERNBASE, but kernel linker213 * Formally kernel mapping starts at KERNBASE, but kernel linker
...@@ -243,21 +246,21 @@...@@ -243,21 +246,21 @@
243 * vt fb startup needs to be reworked.246 * vt fb startup needs to be reworked.
244 */247 */
245#define PHYS_IN_DMAP(pa) (dmaplimit == 0 || (pa) < dmaplimit)248#define PHYS_IN_DMAP(pa) (dmaplimit == 0 || (pa) < dmaplimit)
246#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \249#define VIRT_IN_DMAP(va) \
247 (va) < (DMAP_MIN_ADDRESS + dmaplimit))250 ((va) >= kva_layout.dmap_low && (va) < kva_layout.dmap_low + dmaplimit)
248251
249#define PMAP_HAS_DMAP 1252#define PMAP_HAS_DMAP 1
250#define PHYS_TO_DMAP(x) ({ \253#define PHYS_TO_DMAP(x) __extension__ ({ \
251 KASSERT(PHYS_IN_DMAP(x), \254 KASSERT(PHYS_IN_DMAP(x), \
252 ("physical address %#jx not covered by the DMAP", \255 ("physical address %#jx not covered by the DMAP", \
253 (uintmax_t)x)); \256 (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__ ({ \
257 KASSERT(VIRT_IN_DMAP(x), \260 KASSERT(VIRT_IN_DMAP(x), \
258 ("virtual address %#jx not covered by the DMAP", \261 ("virtual address %#jx not covered by the DMAP", \
259 (uintmax_t)x)); \262 (uintmax_t)x)); \
260 (x) & ~DMAP_MIN_ADDRESS; })263 (x) - kva_layout.dmap_low; })
261264
262/*265/*
263 * amd64 maps the page array into KVA so that it can be more easily266 * amd64 maps the page array into KVA so that it can be more easily
...@@ -278,7 +281,7 @@...@@ -278,7 +281,7 @@
278 */281 */
279#ifndef VM_KMEM_SIZE_MAX282#ifndef VM_KMEM_SIZE_MAX
280#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \283#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)
282#endif285#endif
283286
284/* initial pagein size of beginning of executable file */287/* initial pagein size of beginning of executable file */
...@@ -296,7 +299,8 @@...@@ -296,7 +299,8 @@
296/*299/*
297 * Need a page dump array for minidump.300 * Need a page dump array for minidump.
298 */301 */
299#define MINIDUMP_PAGE_TRACKING 1302#define MINIDUMP_PAGE_TRACKING 1
303#define MINIDUMP_STARTUP_PAGE_TRACKING 1
300304
301#endif /* _MACHINE_VMPARAM_H_ */305#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 {...@@ -510,7 +510,7 @@ pub const Os = struct {
510510
511 break :blk default_min;511 break :blk default_min;
512 },512 },
513 .max = .{ .major = 14, .minor = 3, .patch = 0 },513 .max = .{ .major = 15, .minor = 0, .patch = 0 },
514 },514 },
515 },515 },
516 .netbsd => .{516 .netbsd => .{
...@@ -865,7 +865,6 @@ pub const Abi = enum {...@@ -865,7 +865,6 @@ pub const Abi = enum {
865 },865 },
866 .freebsd => switch (arch) {866 .freebsd => switch (arch) {
867 .arm,867 .arm,
868 .powerpc,
869 => .eabihf,868 => .eabihf,
870 else => .none,869 else => .none,
871 },870 },
lib/std/zig/target.zig-1
...@@ -71,7 +71,6 @@ pub const available_libcs = [_]ArchOsAbi{...@@ -71,7 +71,6 @@ pub const available_libcs = [_]ArchOsAbi{
71 .{ .arch = .mips64el, .os = .linux, .abi = .gnuabin32, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 }, .glibc_triple = "mips64el-linux-gnu-n32" },71 .{ .arch = .mips64el, .os = .linux, .abi = .gnuabin32, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 }, .glibc_triple = "mips64el-linux-gnu-n32" },
72 .{ .arch = .mips64el, .os = .linux, .abi = .muslabi64, .os_ver = .{ .major = 2, .minor = 3, .patch = 48 } },72 .{ .arch = .mips64el, .os = .linux, .abi = .muslabi64, .os_ver = .{ .major = 2, .minor = 3, .patch = 48 } },
73 .{ .arch = .mips64el, .os = .linux, .abi = .muslabin32, .os_ver = .{ .major = 2, .minor = 6, .patch = 0 } },73 .{ .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 } },
75 .{ .arch = .powerpc, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu-soft" },74 .{ .arch = .powerpc, .os = .linux, .abi = .gnueabi, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu-soft" },
76 .{ .arch = .powerpc, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu" },75 .{ .arch = .powerpc, .os = .linux, .abi = .gnueabihf, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 }, .glibc_triple = "powerpc-linux-gnu" },
77 .{ .arch = .powerpc, .os = .linux, .abi = .musleabi, .os_ver = .{ .major = 1, .minor = 3, .patch = 45 } },76 .{ .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...@@ -139,10 +139,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
139 .path = "common" ++ path.sep_str ++ "crtbrand.S",139 .path = "common" ++ path.sep_str ++ "crtbrand.S",
140 .flags = acflags.items,140 .flags = acflags.items,
141 },141 },
142 .{
143 .path = "common" ++ path.sep_str ++ "crtend.c",
144 .flags = cflags.items,
145 },
146 .{142 .{
147 .path = "common" ++ path.sep_str ++ "feature_note.S",143 .path = "common" ++ path.sep_str ++ "feature_note.S",
148 .flags = acflags.items,144 .flags = acflags.items,
...@@ -257,6 +253,12 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -257,6 +253,12 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
257pub const Lib = struct {253pub const Lib = struct {
258 name: []const u8,254 name: []const u8,
259 sover: u8,255 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 }
260};262};
261263
262pub const libs = [_]Lib{264pub const libs = [_]Lib{
...@@ -269,6 +271,7 @@ pub const libs = [_]Lib{...@@ -269,6 +271,7 @@ pub const libs = [_]Lib{
269 .{ .name = "ld", .sover = 1 },271 .{ .name = "ld", .sover = 1 },
270 .{ .name = "util", .sover = 9 },272 .{ .name = "util", .sover = 9 },
271 .{ .name = "execinfo", .sover = 1 },273 .{ .name = "execinfo", .sover = 1 },
274 .{ .name = "sys", .sover = 7, .added_in = .{ .major = 15, .minor = 0, .patch = 0 } },
272};275};
273276
274pub const ABI = struct {277pub const ABI = struct {
...@@ -434,7 +437,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -434,7 +437,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
434437
435 const target = comp.getTarget();438 const target = comp.getTarget();
436 // FreeBSD 7 == FBSD_1.0, ..., FreeBSD 14 == FBSD_1.7439 // 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
439 // Use the global cache directory.443 // Use the global cache directory.
440 var cache: Cache = .{444 var cache: Cache = .{
...@@ -452,7 +456,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -452,7 +456,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
452 man.hash.addBytes(build_options.version);456 man.hash.addBytes(build_options.version);
453 man.hash.add(target.cpu.arch);457 man.hash.add(target.cpu.arch);
454 man.hash.add(target.abi);458 man.hash.add(target.abi);
455 man.hash.add(target_version);459 man.hash.add(target_os_version);
456460
457 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});461 const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});
458 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);462 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...@@ -494,19 +498,19 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
494 };498 };
495499
496 const target_ver_index = for (metadata.all_versions, 0..) |ver, i| {500 const target_ver_index = for (metadata.all_versions, 0..) |ver, i| {
497 switch (ver.order(target_version)) {501 switch (ver.order(target_libc_version)) {
498 .eq => break i,502 .eq => break i,
499 .lt => continue,503 .lt => continue,
500 .gt => {504 .gt => {
501 // TODO Expose via compile error mechanism instead of log.505 // 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});
503 return error.InvalidTargetLibCVersion;507 return error.InvalidTargetLibCVersion;
504 },508 },
505 }509 }
506 } else blk: {510 } else blk: {
507 const latest_index = metadata.all_versions.len - 1;511 const latest_index = metadata.all_versions.len - 1;
508 log.warn("zig cannot build new FreeBSD libc version {f}; providing instead {f}", .{512 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],
510 });514 });
511 break :blk latest_index;515 break :blk latest_index;
512 };516 };
...@@ -524,6 +528,11 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -524,6 +528,11 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
524 defer stubs_asm.deinit();528 defer stubs_asm.deinit();
525529
526 for (libs, 0..) |lib, lib_i| {530 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
527 stubs_asm.shrinkRetainingCapacity(0);536 stubs_asm.shrinkRetainingCapacity(0);
528537
529 try stubs_asm.appendSlice(".text\n");538 try stubs_asm.appendSlice(".text\n");
...@@ -983,6 +992,9 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -983,6 +992,9 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
983}992}
984993
985fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {994fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
995 const target = comp.getTarget();
996 const target_os_version = target.os.version_range.semver.min;
997
986 assert(comp.freebsd_so_files == null);998 assert(comp.freebsd_so_files == null);
987 comp.freebsd_so_files = so_files;999 comp.freebsd_so_files = so_files;
9881000
...@@ -994,10 +1006,14 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {...@@ -994,10 +1006,14 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
994 defer comp.mutex.unlock();1006 defer comp.mutex.unlock();
9951007
996 for (libs) |lib| {1008 for (libs) |lib| {
1009 if (lib.added_in) |add_in| {
1010 if (target_os_version.order(add_in) == .lt) continue;
1011 }
1012
997 const so_path: Path = .{1013 const so_path: Path = .{
998 .root_dir = so_files.dir_path.root_dir,1014 .root_dir = so_files.dir_path.root_dir,
999 .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{1015 .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),
1001 }) catch return comp.setAllocFailure(),1017 }) catch return comp.setAllocFailure(),
1002 };1018 };
1003 task_buffer[task_buffer_i] = .{ .load_dso = so_path };1019 task_buffer[task_buffer_i] = .{ .load_dso = so_path };
...@@ -1019,10 +1035,13 @@ fn buildSharedLib(...@@ -1019,10 +1035,13 @@ fn buildSharedLib(
1019 const tracy = trace(@src());1035 const tracy = trace(@src());
1020 defer tracy.end();1036 defer tracy.end();
10211037
1038 const target = comp.getTarget();
1039
1022 const io = comp.io;1040 const io = comp.io;
1023 const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, lib.sover });1041 const sover = lib.getSoVersion(&target.os);
1024 const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };1042 const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, sover });
1025 const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);1043 const version: Version = .{ .major = sover, .minor = 0, .patch = 0 };
1044 const ld_basename = path.basename(target.standardDynamicLinkerPath().get().?);
1026 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;1045 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
1027 const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });1046 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 {...@@ -1190,8 +1190,12 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
1190 }));1190 }));
1191 } else if (target.isFreeBSDLibC()) {1191 } else if (target.isFreeBSDLibC()) {
1192 for (freebsd.libs) |lib| {1192 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
1193 const lib_path = try std.fmt.allocPrint(arena, "{f}{c}lib{s}.so.{d}", .{1197 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),
1195 });1199 });
1196 try argv.append(lib_path);1200 try argv.append(lib_path);
1197 }1201 }
tools/process_headers.zig-1
...@@ -81,7 +81,6 @@ const musl_targets = [_]LibCTarget{...@@ -81,7 +81,6 @@ const musl_targets = [_]LibCTarget{
81const freebsd_targets = [_]LibCTarget{81const freebsd_targets = [_]LibCTarget{
82 .{ .arch = .arm, .abi = .eabihf },82 .{ .arch = .arm, .abi = .eabihf },
83 .{ .arch = .aarch64, .abi = .none },83 .{ .arch = .aarch64, .abi = .none },
84 .{ .arch = .powerpc, .abi = .eabihf },
85 .{ .arch = .powerpc64, .abi = .none },84 .{ .arch = .powerpc64, .abi = .none },
86 .{ .arch = .riscv64, .abi = .none },85 .{ .arch = .riscv64, .abi = .none },
87 .{ .arch = .x86, .abi = .none },86 .{ .arch = .x86, .abi = .none },