summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-22 14:59:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:41 +0200
commit3489e3b6396ee9944a6a2e19e675ca54c36993b4 (patch)
treecd55cfac1c96ff4b888a9606fd6a0d8eb65bb446 /freebsd/sys/sys
parentck: Define CK_MD_PPC32_LWSYNC if available (diff)
downloadrtems-libbsd-3489e3b6396ee9944a6a2e19e675ca54c36993b4.tar.bz2
Update to FreeBSD head 2018-09-17
Git mirror commit 6c2192b1ef8c50788c751f878552526800b1e319. Update #3472.
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r--freebsd/sys/sys/bus.h9
-rw-r--r--freebsd/sys/sys/cpu.h2
-rw-r--r--freebsd/sys/sys/file.h13
-rw-r--r--freebsd/sys/sys/interrupt.h13
-rw-r--r--freebsd/sys/sys/jail.h5
-rw-r--r--freebsd/sys/sys/libkern.h23
-rw-r--r--freebsd/sys/sys/linker.h3
-rw-r--r--freebsd/sys/sys/malloc.h76
-rw-r--r--freebsd/sys/sys/mbuf.h7
-rw-r--r--freebsd/sys/sys/module.h5
-rw-r--r--freebsd/sys/sys/mouse.h15
-rw-r--r--freebsd/sys/sys/mutex.h2
-rw-r--r--freebsd/sys/sys/nv.h8
-rw-r--r--freebsd/sys/sys/pciio.h19
-rw-r--r--freebsd/sys/sys/pcpu.h59
-rw-r--r--freebsd/sys/sys/proc.h21
-rw-r--r--freebsd/sys/sys/random.h42
-rw-r--r--freebsd/sys/sys/reboot.h9
-rw-r--r--freebsd/sys/sys/sglist.h113
-rw-r--r--freebsd/sys/sys/sockbuf.h8
-rw-r--r--freebsd/sys/sys/socketvar.h17
-rw-r--r--freebsd/sys/sys/sockopt.h1
-rw-r--r--freebsd/sys/sys/sx.h4
-rw-r--r--freebsd/sys/sys/sysproto.h4
-rw-r--r--freebsd/sys/sys/systm.h121
-rw-r--r--freebsd/sys/sys/unpcb.h23
-rw-r--r--freebsd/sys/sys/vmmeter.h7
27 files changed, 437 insertions, 192 deletions
diff --git a/freebsd/sys/sys/bus.h b/freebsd/sys/sys/bus.h
index f3c54f36..74a48f81 100644
--- a/freebsd/sys/sys/bus.h
+++ b/freebsd/sys/sys/bus.h
@@ -92,7 +92,9 @@ struct u_device {
#define DF_EXTERNALSOFTC 0x40 /* softc not allocated by us */
#define DF_REBID 0x80 /* Can rebid after attach */
#define DF_SUSPENDED 0x100 /* Device is suspended. */
-#define DF_QUIET_CHILDREN 0x200 /* Default to quiet for all my children */
+#define DF_QUIET_CHILDREN 0x200 /* Default to quiet for all my children */
+#define DF_ATTACHED_ONCE 0x400 /* Has been attached at least once */
+#define DF_NEEDNOMATCH 0x800 /* Has a pending NOMATCH event */
/**
* @brief Device request structure used for ioctl's.
@@ -126,6 +128,8 @@ struct devreq {
#define DEV_CLEAR_DRIVER _IOW('D', 8, struct devreq)
#define DEV_RESCAN _IOW('D', 9, struct devreq)
#define DEV_DELETE _IOW('D', 10, struct devreq)
+#define DEV_FREEZE _IOW('D', 11, struct devreq)
+#define DEV_THAW _IOW('D', 12, struct devreq)
/* Flags for DEV_DETACH and DEV_DISABLE. */
#define DEVF_FORCE_DETACH 0x0000001
@@ -156,7 +160,8 @@ void devctl_notify(const char *__system, const char *__subsystem,
const char *__type, const char *__data);
void devctl_queue_data_f(char *__data, int __flags);
void devctl_queue_data(char *__data);
-void devctl_safe_quote(char *__dst, const char *__src, size_t len);
+struct sbuf;
+void devctl_safe_quote_sb(struct sbuf *__sb, const char *__src);
/**
* Device name parsers. Hook to allow device enumerators to map
diff --git a/freebsd/sys/sys/cpu.h b/freebsd/sys/sys/cpu.h
index b3b745ab..8a74e470 100644
--- a/freebsd/sys/sys/cpu.h
+++ b/freebsd/sys/sys/cpu.h
@@ -87,7 +87,7 @@ struct cf_setting {
};
/* Maximum number of settings a given driver can have. */
-#define MAX_SETTINGS 24
+#define MAX_SETTINGS 256
/* A combination of settings is a level. */
struct cf_level {
diff --git a/freebsd/sys/sys/file.h b/freebsd/sys/sys/file.h
index a566e69c..20beac22 100644
--- a/freebsd/sys/sys/file.h
+++ b/freebsd/sys/sys/file.h
@@ -297,18 +297,23 @@ rtems_bsd_error_to_status_and_errno(int error)
* Userland version of struct file, for sysctl
*/
struct xfile {
- size_t xf_size; /* size of struct xfile */
+ ksize_t xf_size; /* size of struct xfile */
pid_t xf_pid; /* owning process */
uid_t xf_uid; /* effective uid of owning process */
int xf_fd; /* descriptor number */
- void *xf_file; /* address of struct file */
+ int _xf_int_pad1;
+ kvaddr_t xf_file; /* address of struct file */
short xf_type; /* descriptor type */
+ short _xf_short_pad1;
int xf_count; /* reference count */
int xf_msgcount; /* references from message queue */
+ int _xf_int_pad2;
off_t xf_offset; /* file offset */
- void *xf_data; /* file descriptor specific data */
- void *xf_vnode; /* vnode pointer */
+ kvaddr_t xf_data; /* file descriptor specific data */
+ kvaddr_t xf_vnode; /* vnode pointer */
u_int xf_flag; /* flags (see fcntl.h) */
+ int _xf_int_pad3;
+ int64_t _xf_int64_pad[6];
};
#ifdef _KERNEL
diff --git a/freebsd/sys/sys/interrupt.h b/freebsd/sys/sys/interrupt.h
index 7c9aad4d..105bb968 100644
--- a/freebsd/sys/sys/interrupt.h
+++ b/freebsd/sys/sys/interrupt.h
@@ -33,6 +33,7 @@
#include <sys/_lock.h>
#include <sys/_mutex.h>
+#include <sys/ck.h>
struct intr_event;
struct intr_thread;
@@ -52,7 +53,7 @@ struct intr_handler {
char ih_name[MAXCOMLEN + 1]; /* Name of handler. */
struct intr_event *ih_event; /* Event we are connected to. */
int ih_need; /* Needs service. */
- TAILQ_ENTRY(intr_handler) ih_next; /* Next handler for this event. */
+ CK_SLIST_ENTRY(intr_handler) ih_next; /* Next handler for this event. */
u_char ih_pri; /* Priority of this handler. */
struct intr_thread *ih_thread; /* Ithread for filtered handler. */
};
@@ -105,7 +106,7 @@ struct intr_handler {
*/
struct intr_event {
TAILQ_ENTRY(intr_event) ie_list;
- TAILQ_HEAD(, intr_handler) ie_handlers; /* Interrupt handlers. */
+ CK_SLIST_HEAD(, intr_handler) ie_handlers; /* Interrupt handlers. */
char ie_name[MAXCOMLEN + 1]; /* Individual event name. */
char ie_fullname[MAXCOMLEN + 1];
struct mtx ie_lock;
@@ -121,6 +122,8 @@ struct intr_event {
struct timeval ie_warntm;
int ie_irq; /* Physical irq number if !SOFT. */
int ie_cpu; /* CPU this event is bound to. */
+ volatile int ie_phase; /* Switched to establish a barrier. */
+ volatile int ie_active[2]; /* Filters in ISR context. */
};
/* Interrupt event flags kept in ie_flags. */
@@ -151,8 +154,13 @@ extern struct intr_event *clk_intr_event;
extern void *vm_ih;
/* Counts and names for statistics (defined in MD code). */
+#if defined(__amd64__) || defined(__i386__)
+extern u_long *intrcnt; /* counts for for each device and stray */
+extern char *intrnames; /* string table containing device names */
+#else
extern u_long intrcnt[]; /* counts for for each device and stray */
extern char intrnames[]; /* string table containing device names */
+#endif
extern size_t sintrcnt; /* size of intrcnt table */
extern size_t sintrnames; /* size of intrnames table */
@@ -174,7 +182,6 @@ int intr_event_create(struct intr_event **event, void *source,
int intr_event_describe_handler(struct intr_event *ie, void *cookie,
const char *descr);
int intr_event_destroy(struct intr_event *ie);
-void intr_event_execute_handlers(struct proc *p, struct intr_event *ie);
int intr_event_handle(struct intr_event *ie, struct trapframe *frame);
int intr_event_remove_handler(void *cookie);
int intr_getaffinity(int irq, int mode, void *mask);
diff --git a/freebsd/sys/sys/jail.h b/freebsd/sys/sys/jail.h
index c42964fe..6f8c9aa5 100644
--- a/freebsd/sys/sys/jail.h
+++ b/freebsd/sys/sys/jail.h
@@ -227,9 +227,10 @@ struct prison_racct {
#define PR_ALLOW_MOUNT 0x00000010
#define PR_ALLOW_QUOTAS 0x00000020
#define PR_ALLOW_SOCKET_AF 0x00000040
+#define PR_ALLOW_MLOCK 0x00000080
#define PR_ALLOW_RESERVED_PORTS 0x00008000
#define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */
-#define PR_ALLOW_ALL_STATIC 0x0001807f
+#define PR_ALLOW_ALL_STATIC 0x000180ff
/*
* OSD methods
@@ -417,6 +418,8 @@ int prison_if(struct ucred *cred, struct sockaddr *sa);
char *prison_name(struct prison *, struct prison *);
int prison_priv_check(struct ucred *cred, int priv);
int sysctl_jail_param(SYSCTL_HANDLER_ARGS);
+unsigned prison_add_allow(const char *prefix, const char *name,
+ const char *prefix_descr, const char *descr);
void prison_add_vfs(struct vfsconf *vfsp);
void prison_racct_foreach(void (*callback)(struct racct *racct,
void *arg2, void *arg3), void (*pre)(void), void (*post)(void),
diff --git a/freebsd/sys/sys/libkern.h b/freebsd/sys/sys/libkern.h
index dc24036b..28da25ca 100644
--- a/freebsd/sys/sys/libkern.h
+++ b/freebsd/sys/sys/libkern.h
@@ -144,11 +144,6 @@ arc4rand(void *ptr, u_int len, int reseed)
arc4random_buf(ptr, len);
}
#endif /* __rtems__ */
-#ifndef __rtems__
-int bcmp(const void *, const void *, size_t);
-#else /* __rtems__ */
-#define bcmp(m1, m2, n) memcmp(m1, m2, n)
-#endif /* __rtems__ */
int timingsafe_bcmp(const void *, const void *, size_t);
void *bsearch(const void *, const void *, size_t,
size_t, int (*)(const void *, const void *));
@@ -210,7 +205,6 @@ int fnmatch(const char *, const char *, int);
int locc(int, char *, u_int);
void *memchr(const void *s, int c, size_t n);
void *memcchr(const void *s, int c, size_t n);
-int memcmp(const void *b1, const void *b2, size_t len);
void *memmem(const void *l, size_t l_len, const void *s, size_t s_len);
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
@@ -290,23 +284,6 @@ uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int);
#endif
#endif
-
-LIBKERN_INLINE void *memset(void *, int, size_t);
-#ifdef LIBKERN_BODY
-LIBKERN_INLINE void *
-memset(void *b, int c, size_t len)
-{
- char *bb;
-
- if (c == 0)
- bzero(b, len);
- else
- for (bb = (char *)b; len--; )
- *bb++ = c;
- return (b);
-}
-#endif
-
#ifndef __rtems__
static __inline char *
index(const char *p, int ch)
diff --git a/freebsd/sys/sys/linker.h b/freebsd/sys/sys/linker.h
index 21c5a41e..8aae31d9 100644
--- a/freebsd/sys/sys/linker.h
+++ b/freebsd/sys/sys/linker.h
@@ -273,10 +273,9 @@ extern int kld_debug;
typedef int elf_lookup_fn(linker_file_t, Elf_Size, int, Elf_Addr *);
/* Support functions */
+bool elf_is_ifunc_reloc(Elf_Size r_info);
int elf_reloc(linker_file_t _lf, Elf_Addr base, const void *_rel,
int _type, elf_lookup_fn _lu);
-int elf_reloc_ifunc(linker_file_t _lf, Elf_Addr base, const void *_rel,
- int _type, elf_lookup_fn _lu);
int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel,
int _type, elf_lookup_fn _lu);
Elf_Addr elf_relocaddr(linker_file_t _lf, Elf_Addr addr);
diff --git a/freebsd/sys/sys/malloc.h b/freebsd/sys/sys/malloc.h
index 8c66fe81..33e1aab9 100644
--- a/freebsd/sys/sys/malloc.h
+++ b/freebsd/sys/sys/malloc.h
@@ -38,6 +38,9 @@
#define _SYS_MALLOC_H_
#include <sys/param.h>
+#ifdef _KERNEL
+#include <sys/systm.h>
+#endif
#include <sys/queue.h>
#include <sys/_lock.h>
#include <sys/_mutex.h>
@@ -46,7 +49,7 @@
#define MINALLOCSIZE UMA_SMALLEST_UNIT
/*
- * flags to malloc.
+ * Flags to memory allocation functions.
*/
#define M_NOWAIT 0x0001 /* do not block */
#define M_WAITOK 0x0002 /* ok to block */
@@ -56,16 +59,10 @@
#define M_NODUMP 0x0800 /* don't dump pages in this allocation */
#define M_FIRSTFIT 0x1000 /* Only for vmem, fast fit. */
#define M_BESTFIT 0x2000 /* Only for vmem, low fragmentation. */
+#define M_EXEC 0x4000 /* allocate executable space. */
#define M_MAGIC 877983977 /* time when first defined :-) */
-#ifdef INVARIANTS
-#define M_ZERO_INVARIANTS M_ZERO
-#else
-#define M_ZERO_INVARIANTS 0
-#endif
-
-
/*
* Two malloc type structures are present: malloc_type, which is used by a
* type owner to declare the type, and malloc_type_internal, which holds
@@ -142,7 +139,6 @@ struct malloc_type_header {
#ifdef _KERNEL
#ifdef __rtems__
#include <stdlib.h>
-#define malloc _bsd_malloc
#define realloc _bsd_realloc
#define reallocf _bsd_reallocf
#define free _bsd_free
@@ -188,8 +184,70 @@ void *contigmalloc_domain(unsigned long size, struct malloc_type *type,
__malloc_like __result_use_check __alloc_size(1) __alloc_align(6);
void free(void *addr, struct malloc_type *type);
void free_domain(void *addr, struct malloc_type *type);
+#ifndef __rtems__
void *malloc(size_t size, struct malloc_type *type, int flags) __malloc_like
__result_use_check __alloc_size(1);
+#else /* __rtems__ */
+void *_bsd_malloc(size_t size, struct malloc_type *type, int flags)
+ __malloc_like __result_use_check __alloc_size(1);
+#endif /* __rtems__ */
+/*
+ * Try to optimize malloc(..., ..., M_ZERO) allocations by doing zeroing in
+ * place if the size is known at compilation time.
+ *
+ * Passing the flag down requires malloc to blindly zero the entire object.
+ * In practice a lot of the zeroing can be avoided if most of the object
+ * gets explicitly initialized after the allocation. Letting the compiler
+ * zero in place gives it the opportunity to take advantage of this state.
+ *
+ * Note that the operation is only applicable if both flags and size are
+ * known at compilation time. If M_ZERO is passed but M_WAITOK is not, the
+ * allocation can fail and a NULL check is needed. However, if M_WAITOK is
+ * passed we know the allocation must succeed and the check can be elided.
+ *
+ * _malloc_item = malloc(_size, type, (flags) &~ M_ZERO);
+ * if (((flags) & M_WAITOK) != 0 || _malloc_item != NULL)
+ * bzero(_malloc_item, _size);
+ *
+ * If the flag is set, the compiler knows the left side is always true,
+ * therefore the entire statement is true and the callsite is:
+ *
+ * _malloc_item = malloc(_size, type, (flags) &~ M_ZERO);
+ * bzero(_malloc_item, _size);
+ *
+ * If the flag is not set, the compiler knows the left size is always false
+ * and the NULL check is needed, therefore the callsite is:
+ *
+ * _malloc_item = malloc(_size, type, (flags) &~ M_ZERO);
+ * if (_malloc_item != NULL)
+ * bzero(_malloc_item, _size);
+ *
+ * The implementation is a macro because of what appears to be a clang 6 bug:
+ * an inline function variant ended up being compiled to a mere malloc call
+ * regardless of argument. gcc generates expected code (like the above).
+ */
+#ifdef __rtems__
+/*
+ * The macro below was modified without the __rtems__ guards. This macro looks
+ * quite brittle and it is better to provoke a merge conflict in case of a
+ * FreeBSD baseline update.
+ */
+#endif /* __rtems__ */
+#define malloc(size, type, flags) ({ \
+ void *_malloc_item; \
+ size_t _size = (size); \
+ if (__builtin_constant_p(size) && __builtin_constant_p(flags) &&\
+ ((flags) & M_ZERO) != 0) { \
+ _malloc_item = _bsd_malloc(_size, type, (flags) &~ M_ZERO); \
+ if (((flags) & M_WAITOK) != 0 || \
+ __predict_true(_malloc_item != NULL)) \
+ bzero(_malloc_item, _size); \
+ } else { \
+ _malloc_item = _bsd_malloc(_size, type, flags); \
+ } \
+ _malloc_item; \
+})
+
void *malloc_domain(size_t size, struct malloc_type *type, int domain,
int flags) __malloc_like __result_use_check __alloc_size(1);
void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type,
diff --git a/freebsd/sys/sys/mbuf.h b/freebsd/sys/sys/mbuf.h
index 4d2a3223..0423b580 100644
--- a/freebsd/sys/sys/mbuf.h
+++ b/freebsd/sys/sys/mbuf.h
@@ -304,7 +304,7 @@ struct mbuf {
#define M_MCAST 0x00000020 /* send/received as link-level multicast */
#define M_PROMISC 0x00000040 /* packet was not for us */
#define M_VLANTAG 0x00000080 /* ether_vtag is valid */
-#define M_UNUSED_8 0x00000100 /* --available-- */
+#define M_NOMAP 0x00000100 /* mbuf data is unmapped (soon from Drew) */
#define M_NOFREE 0x00000200 /* do not free mbuf, embedded in cluster */
#define M_TSTMP 0x00000400 /* rcv_tstmp field is valid */
#define M_TSTMP_HPREC 0x00000800 /* rcv_tstmp is high-prec, typically
@@ -570,8 +570,8 @@ struct mbuf {
#define MT_EXP4 12 /* for experimental use */
#define MT_CONTROL 14 /* extra-data protocol message */
-#define MT_OOBDATA 15 /* expedited data */
-#define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */
+#define MT_EXTCONTROL 15 /* control message with externalized contents */
+#define MT_OOBDATA 16 /* expedited data */
#define MT_NOINIT 255 /* Not a type but a flag to allocate
a non-initialized mbuf */
@@ -636,6 +636,7 @@ void m_demote_pkthdr(struct mbuf *);
void m_demote(struct mbuf *, int, int);
struct mbuf *m_devget(char *, int, int, struct ifnet *,
void (*)(char *, caddr_t, u_int));
+void m_dispose_extcontrolm(struct mbuf *m);
struct mbuf *m_dup(const struct mbuf *, int);
int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int);
void m_extadd(struct mbuf *, char *, u_int, m_ext_free_t,
diff --git a/freebsd/sys/sys/module.h b/freebsd/sys/sys/module.h
index 6799b179..b40870d3 100644
--- a/freebsd/sys/sys/module.h
+++ b/freebsd/sys/sys/module.h
@@ -146,8 +146,13 @@ struct mod_pnp_match_info
SYSINIT(name##module, sub, order, module_register_init, &data); \
struct __hack
+#ifdef KLD_TIED
#define DECLARE_MODULE(name, data, sub, order) \
+ DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version)
+#else
+#define DECLARE_MODULE(name, data, sub, order) \
DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, MODULE_KERNEL_MAXVER)
+#endif
/*
* The module declared with DECLARE_MODULE_TIED can only be loaded
diff --git a/freebsd/sys/sys/mouse.h b/freebsd/sys/sys/mouse.h
index a1f950cf..882d59c9 100644
--- a/freebsd/sys/sys/mouse.h
+++ b/freebsd/sys/sys/mouse.h
@@ -38,8 +38,6 @@
#define MOUSE_SETMODE _IOW('M', 3, mousemode_t)
#define MOUSE_GETLEVEL _IOR('M', 4, int)
#define MOUSE_SETLEVEL _IOW('M', 5, int)
-#define MOUSE_GETVARS _IOR('M', 6, mousevar_t)
-#define MOUSE_SETVARS _IOW('M', 7, mousevar_t)
#define MOUSE_READSTATE _IOWR('M', 8, mousedata_t)
#define MOUSE_READDATA _IOWR('M', 9, mousedata_t)
@@ -228,19 +226,6 @@ typedef struct mousedata {
int buf[16]; /* data buffer */
} mousedata_t;
-#if (defined(MOUSE_GETVARS))
-
-typedef struct mousevar {
- int var[16];
-} mousevar_t;
-
-/* magic numbers in var[0] */
-#define MOUSE_VARS_PS2_SIG 0x00325350 /* 'PS2' */
-#define MOUSE_VARS_BUS_SIG 0x00535542 /* 'BUS' */
-#define MOUSE_VARS_INPORT_SIG 0x00504e49 /* 'INP' */
-
-#endif /* MOUSE_GETVARS */
-
/* Synaptics Touchpad */
#define MOUSE_SYNAPTICS_PACKETSIZE 6 /* '3' works better */
diff --git a/freebsd/sys/sys/mutex.h b/freebsd/sys/sys/mutex.h
index e15de1ae..e9c91f80 100644
--- a/freebsd/sys/sys/mutex.h
+++ b/freebsd/sys/sys/mutex.h
@@ -161,7 +161,7 @@ void _thread_lock(struct thread *td, int opts, const char *file, int line);
void _thread_lock(struct thread *);
#endif
-#if defined(LOCK_PROFILING) || defined(KLD_MODULE)
+#if defined(LOCK_PROFILING) || (defined(KLD_MODULE) && !defined(KLD_TIED))
#define thread_lock(tdp) \
thread_lock_flags_((tdp), 0, __FILE__, __LINE__)
#elif LOCK_DEBUG > 0
diff --git a/freebsd/sys/sys/nv.h b/freebsd/sys/sys/nv.h
index bf40f8f3..80fb8777 100644
--- a/freebsd/sys/sys/nv.h
+++ b/freebsd/sys/sys/nv.h
@@ -162,6 +162,14 @@ void nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value);
void nvlist_add_descriptor_array(nvlist_t *nvl, const char *name, const int *value, size_t nitems);
#endif
+void nvlist_append_bool_array(nvlist_t *nvl, const char *name, const bool value);
+void nvlist_append_number_array(nvlist_t *nvl, const char *name, const uint64_t value);
+void nvlist_append_string_array(nvlist_t *nvl, const char *name, const char * const value);
+void nvlist_append_nvlist_array(nvlist_t *nvl, const char *name, const nvlist_t * const value);
+#ifndef _KERNEL
+void nvlist_append_descriptor_array(nvlist_t *nvl, const char *name, int value);
+#endif
+
/*
* The nvlist_move functions add the given name/value pair.
* The functions consumes provided buffer.
diff --git a/freebsd/sys/sys/pciio.h b/freebsd/sys/sys/pciio.h
index 80d2019b..50e9116d 100644
--- a/freebsd/sys/sys/pciio.h
+++ b/freebsd/sys/sys/pciio.h
@@ -138,11 +138,30 @@ struct pci_list_vpd_io {
struct pci_vpd_element *plvi_data;
};
+struct pci_bar_mmap {
+ void *pbm_map_base; /* (sometimes IN)/OUT mmaped base */
+ size_t pbm_map_length; /* mapped length of the BAR, multiple
+ of pages */
+ uint64_t pbm_bar_length; /* actual length of the BAR */
+ int pbm_bar_off; /* offset from the mapped base to the
+ start of BAR */
+ struct pcisel pbm_sel; /* device to operate on */
+ int pbm_reg; /* starting address of BAR */
+ int pbm_flags;
+ int pbm_memattr;
+};
+
+#define PCIIO_BAR_MMAP_FIXED 0x01
+#define PCIIO_BAR_MMAP_EXCL 0x02
+#define PCIIO_BAR_MMAP_RW 0x04
+#define PCIIO_BAR_MMAP_ACTIVATE 0x08
+
#define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io)
#define PCIOCREAD _IOWR('p', 2, struct pci_io)
#define PCIOCWRITE _IOWR('p', 3, struct pci_io)
#define PCIOCATTACHED _IOWR('p', 4, struct pci_io)
#define PCIOCGETBAR _IOWR('p', 6, struct pci_bar_io)
#define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io)
+#define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap)
#endif /* !_SYS_PCIIO_H_ */
diff --git a/freebsd/sys/sys/pcpu.h b/freebsd/sys/sys/pcpu.h
index bfa7f34d..7aad9f2e 100644
--- a/freebsd/sys/sys/pcpu.h
+++ b/freebsd/sys/sys/pcpu.h
@@ -81,7 +81,31 @@ extern uintptr_t dpcpu_off[];
*/
#define DPCPU_NAME(n) pcpu_entry_##n
#define DPCPU_DECLARE(t, n) extern t DPCPU_NAME(n)
-#define DPCPU_DEFINE(t, n) t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used
+/* struct _hack is to stop this from being used with the static keyword. */
+#define DPCPU_DEFINE(t, n) \
+ struct _hack; t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used
+#if defined(KLD_MODULE) && (defined(__aarch64__) || defined(__riscv))
+/*
+ * On some architectures the compiler will use PC-relative load to
+ * find the address of DPCPU data with the static keyword. We then
+ * use this to find the offset of the data in a per-CPU region.
+ * This works for in the kernel as we can allocate the space ahead
+ * of time, however modules need to allocate a sepatate space and
+ * then use relocations to fix the address of the data. As
+ * PC-relative data doesn't have a relocation there is nothing for
+ * the kernel module linker to fix so data is accessed from the
+ * wrong location.
+ *
+ * This is a workaround until a better solution can be found.
+ *
+ * VNET_DEFINE_STATIC also has the same workaround.
+ */
+#define DPCPU_DEFINE_STATIC(t, n) \
+ t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used
+#else
+#define DPCPU_DEFINE_STATIC(t, n) \
+ static t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used
+#endif
/*
* Accessors with a given base.
@@ -189,14 +213,6 @@ struct pcpu {
#endif /* __rtems__ */
} __aligned(CACHE_LINE_SIZE);
-#ifdef CTASSERT
-/*
- * To minimize memory waste in per-cpu UMA zones, size of struct pcpu
- * should be denominator of PAGE_SIZE.
- */
-CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE);
-#endif
-
#ifdef _KERNEL
STAILQ_HEAD(cpuhead, pcpu);
@@ -211,15 +227,34 @@ extern struct pcpu *cpuid_to_pcpu[];
#endif
#define curvidata PCPU_GET(vidata)
+#ifndef __rtems__
+#define UMA_PCPU_ALLOC_SIZE PAGE_SIZE
+
+#ifdef CTASSERT
+#if defined(__i386__) || defined(__amd64__)
+/* Required for counters(9) to work on x86. */
+CTASSERT(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE);
+#else
+/*
+ * To minimize memory waste in per-cpu UMA zones, size of struct pcpu
+ * should be denominator of PAGE_SIZE.
+ */
+CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE);
+#endif /* UMA_PCPU_ALLOC_SIZE && x86 */
+#endif /* CTASSERT */
+#else /* __rtems__ */
+#define UMA_PCPU_ALLOC_SIZE sizeof(struct pcpu)
+#endif /* __rtems__ */
+
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
static inline void *
zpcpu_get(void *base)
{
#ifndef __rtems__
- return ((char *)(base) + sizeof(struct pcpu) * curcpu);
+ return ((char *)(base) + UMA_PCPU_ALLOC_SIZE * curcpu);
#else /* __rtems__ */
- return ((char *)(base) + sizeof(struct pcpu) * _SMP_Get_current_processor());
+ return ((char *)(base) + UMA_PCPU_ALLOC_SIZE * _SMP_Get_current_processor());
#endif /* __rtems__ */
}
@@ -227,7 +262,7 @@ static inline void *
zpcpu_get_cpu(void *base, int cpu)
{
- return ((char *)(base) + sizeof(struct pcpu) * cpu);
+ return ((char *)(base) + UMA_PCPU_ALLOC_SIZE * cpu);
}
/*
diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h
index 36ed69cc..9372b3a0 100644
--- a/freebsd/sys/sys/proc.h
+++ b/freebsd/sys/sys/proc.h
@@ -74,19 +74,6 @@
#include <machine/cpu.h>
#endif
-
-/*
- * A section object may be passed to every begin-end pair to allow for
- * forward progress guarantees with-in prolonged active sections.
- *
- * We can't include ck_epoch.h so we define our own variant here and
- * then CTASSERT that it's the same size in subr_epoch.c
- */
-struct epoch_section {
- unsigned int bucket;
-};
-typedef struct epoch_section epoch_section_t;
-
/*
* One structure allocated per session.
*
@@ -408,8 +395,7 @@ struct thread {
int td_lastcpu; /* (t) Last cpu we were on. */
int td_oncpu; /* (t) Which cpu we are on. */
void *td_lkpi_task; /* LinuxKPI task struct pointer */
- TAILQ_ENTRY(thread) td_epochq; /* (t) Epoch queue. */
- epoch_section_t td_epoch_section; /* (t) epoch section object */
+ int td_pmcpend;
#endif /* __rtems__ */
};
@@ -677,7 +663,7 @@ struct proc {
u_int p_stype; /* (c) Stop event type. */
char p_step; /* (c) Process is stopped. */
u_char p_pfsflags; /* (c) Procfs flags. */
- u_int p_ptevents; /* (c) ptrace() event mask. */
+ u_int p_ptevents; /* (c + e) ptrace() event mask. */
struct nlminfo *p_nlminfo; /* (?) Only used by/for lockd. */
struct kaioinfo *p_aioinfo; /* (y) ASYNC I/O info. */
struct thread *p_singlethread;/* (c + j) If single threading this is it */
@@ -729,8 +715,6 @@ struct proc {
LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/
struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */
struct cv p_pwait; /* (*) wait cv for exit/exec. */
- struct cv p_dbgwait; /* (*) wait cv for debugger attach
- after fork. */
uint64_t p_prev_runtime; /* (c) Resource usage accounting. */
struct racct *p_racct; /* (b) Resource accounting. */
int p_throttled; /* (c) Flag for racct pcpu throttling */
@@ -1127,6 +1111,7 @@ struct proc *proc_realparent(struct proc *child);
void proc_reap(struct thread *td, struct proc *p, int *status, int options);
void proc_reparent(struct proc *child, struct proc *newparent);
void proc_set_traced(struct proc *p, bool stop);
+void proc_wkilled(struct proc *p);
struct pstats *pstats_alloc(void);
void pstats_fork(struct pstats *src, struct pstats *dst);
void pstats_free(struct pstats *ps);
diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h
index c717a686..f32d3f66 100644
--- a/freebsd/sys/sys/random.h
+++ b/freebsd/sys/sys/random.h
@@ -35,12 +35,6 @@
#ifdef _KERNEL
-#if !defined(KLD_MODULE)
-#if defined(RANDOM_LOADABLE) && defined(RANDOM_YARROW)
-#error "Cannot define both RANDOM_LOADABLE and RANDOM_YARROW"
-#endif
-#endif
-
struct uio;
#if defined(DEV_RANDOM)
@@ -105,6 +99,7 @@ enum random_entropy_source {
RANDOM_PURE_VIRTIO,
RANDOM_PURE_BROADCOM,
RANDOM_PURE_CCP,
+ RANDOM_PURE_DARN,
ENTROPYSOURCE
};
@@ -117,57 +112,54 @@ enum random_entropy_source {
#if defined(DEV_RANDOM)
extern u_int hc_source_mask;
-void random_harvest_queue_(const void *, u_int, u_int, enum random_entropy_source);
-void random_harvest_fast_(const void *, u_int, u_int);
-void random_harvest_direct_(const void *, u_int, u_int, enum random_entropy_source);
+void random_harvest_queue_(const void *, u_int, enum random_entropy_source);
+void random_harvest_fast_(const void *, u_int);
+void random_harvest_direct_(const void *, u_int, enum random_entropy_source);
static __inline void
-random_harvest_queue(const void *entropy, u_int size, u_int bits,
- enum random_entropy_source origin)
+random_harvest_queue(const void *entropy, u_int size, enum random_entropy_source origin)
{
if (hc_source_mask & (1 << origin))
- random_harvest_queue_(entropy, size, bits, origin);
+ random_harvest_queue_(entropy, size, origin);
}
static __inline void
-random_harvest_fast(const void *entropy, u_int size, u_int bits,
- enum random_entropy_source origin)
+random_harvest_fast(const void *entropy, u_int size, enum random_entropy_source origin)
{
if (hc_source_mask & (1 << origin))
- random_harvest_fast_(entropy, size, bits);
+ random_harvest_fast_(entropy, size);
}
static __inline void
-random_harvest_direct(const void *entropy, u_int size, u_int bits,
- enum random_entropy_source origin)
+random_harvest_direct(const void *entropy, u_int size, enum random_entropy_source origin)
{
if (hc_source_mask & (1 << origin))
- random_harvest_direct_(entropy, size, bits, origin);
+ random_harvest_direct_(entropy, size, origin);
}
void random_harvest_register_source(enum random_entropy_source);
void random_harvest_deregister_source(enum random_entropy_source);
#else
-#define random_harvest_queue(a, b, c, d) do {} while (0)
-#define random_harvest_fast(a, b, c, d) do {} while (0)
-#define random_harvest_direct(a, b, c, d) do {} while (0)
+#define random_harvest_queue(a, b, c) do {} while (0)
+#define random_harvest_fast(a, b, c) do {} while (0)
+#define random_harvest_direct(a, b, c) do {} while (0)
#define random_harvest_register_source(a) do {} while (0)
#define random_harvest_deregister_source(a) do {} while (0)
#endif
#if defined(RANDOM_ENABLE_UMA)
-#define random_harvest_fast_uma(a, b, c, d) random_harvest_fast(a, b, c, d)
+#define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c)
#else /* !defined(RANDOM_ENABLE_UMA) */
-#define random_harvest_fast_uma(a, b, c, d) do {} while (0)
+#define random_harvest_fast_uma(a, b, c) do {} while (0)
#endif /* defined(RANDOM_ENABLE_UMA) */
#if defined(RANDOM_ENABLE_ETHER)
-#define random_harvest_queue_ether(a, b, c) random_harvest_queue(a, b, c, RANDOM_NET_ETHER)
+#define random_harvest_queue_ether(a, b) random_harvest_queue(a, b, RANDOM_NET_ETHER)
#else /* !defined(RANDOM_ENABLE_ETHER) */
-#define random_harvest_queue_ether(a, b, c) do {} while (0)
+#define random_harvest_queue_ether(a, b) do {} while (0)
#endif /* defined(RANDOM_ENABLE_ETHER) */
diff --git a/freebsd/sys/sys/reboot.h b/freebsd/sys/sys/reboot.h
index d0dff609..20b91f8e 100644
--- a/freebsd/sys/sys/reboot.h
+++ b/freebsd/sys/sys/reboot.h
@@ -41,28 +41,29 @@
*/
#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
-#define RB_ASKNAME 0x001 /* ask for file name to reboot from */
+#define RB_ASKNAME 0x001 /* force prompt of device of root filesystem */
#define RB_SINGLE 0x002 /* reboot to single user only */
#define RB_NOSYNC 0x004 /* dont sync before reboot */
#define RB_HALT 0x008 /* don't reboot, just halt */
-#define RB_INITNAME 0x010 /* name given for /etc/init (unused) */
+#define RB_INITNAME 0x010 /* Unused placeholder to specify init path */
#define RB_DFLTROOT 0x020 /* use compiled-in rootdev */
#define RB_KDB 0x040 /* give control to kernel debugger */
#define RB_RDONLY 0x080 /* mount root fs read-only */
#define RB_DUMP 0x100 /* dump kernel memory before reboot */
-#define RB_MINIROOT 0x200 /* mini-root present in memory at boot time */
+#define RB_MINIROOT 0x200 /* Unused placeholder */
#define RB_VERBOSE 0x800 /* print all potentially useful info */
#define RB_SERIAL 0x1000 /* use serial port as console */
#define RB_CDROM 0x2000 /* use cdrom as root */
#define RB_POWEROFF 0x4000 /* turn the power off if possible */
#define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */
#define RB_MUTE 0x10000 /* start up with the console muted */
-#define RB_SELFTEST 0x20000 /* don't complete the boot; do selftest */
+#define RB_SELFTEST 0x20000 /* unused placeholder */
#define RB_RESERVED1 0x40000 /* reserved for internal use of boot blocks */
#define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */
#define RB_PAUSE 0x100000 /* pause after each output line during probe */
#define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */
#define RB_POWERCYCLE 0x400000 /* Power cycle if possible */
+#define RB_PROBE 0x10000000 /* Probe multiple consoles */
#define RB_MULTIPLE 0x20000000 /* use multiple consoles */
#define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */
diff --git a/freebsd/sys/sys/sglist.h b/freebsd/sys/sys/sglist.h
new file mode 100644
index 00000000..5674416c
--- /dev/null
+++ b/freebsd/sys/sys/sglist.h
@@ -0,0 +1,113 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2008 Yahoo!, Inc.
+ * All rights reserved.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * A scatter/gather list describes a group of physical address ranges.
+ * Each physical address range consists of a starting address and a
+ * length.
+ */
+
+#ifndef __SGLIST_H__
+#define __SGLIST_H__
+
+#include <sys/refcount.h>
+
+struct sglist_seg {
+ vm_paddr_t ss_paddr;
+ size_t ss_len;
+};
+
+struct sglist {
+ struct sglist_seg *sg_segs;
+ u_int sg_refs;
+ u_short sg_nseg;
+ u_short sg_maxseg;
+};
+
+struct bio;
+struct mbuf;
+struct uio;
+
+static __inline void
+sglist_init(struct sglist *sg, u_short maxsegs, struct sglist_seg *segs)
+{
+
+ sg->sg_segs = segs;
+ sg->sg_nseg = 0;
+ sg->sg_maxseg = maxsegs;
+ refcount_init(&sg->sg_refs, 1);
+}
+
+static __inline void
+sglist_reset(struct sglist *sg)
+{
+
+ sg->sg_nseg = 0;
+}
+
+static __inline struct sglist *
+sglist_hold(struct sglist *sg)
+{
+
+ refcount_acquire(&sg->sg_refs);
+ return (sg);
+}
+
+struct sglist *sglist_alloc(int nsegs, int mflags);
+int sglist_append(struct sglist *sg, void *buf, size_t len);
+int sglist_append_bio(struct sglist *sg, struct bio *bp);
+int sglist_append_mbuf(struct sglist *sg, struct mbuf *m0);
+int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr,
+ size_t len);
+int sglist_append_sglist(struct sglist *sg, struct sglist *source,
+ size_t offset, size_t length);
+int sglist_append_uio(struct sglist *sg, struct uio *uio);
+int sglist_append_user(struct sglist *sg, void *buf, size_t len,
+ struct thread *td);
+int sglist_append_vmpages(struct sglist *sg, vm_page_t *m, size_t pgoff,
+ size_t len);
+struct sglist *sglist_build(void *buf, size_t len, int mflags);
+struct sglist *sglist_clone(struct sglist *sg, int mflags);
+int sglist_consume_uio(struct sglist *sg, struct uio *uio, size_t resid);
+int sglist_count(void *buf, size_t len);
+int sglist_count_vmpages(vm_page_t *m, size_t pgoff, size_t len);
+void sglist_free(struct sglist *sg);
+int sglist_join(struct sglist *first, struct sglist *second);
+size_t sglist_length(struct sglist *sg);
+int sglist_slice(struct sglist *original, struct sglist **slice,
+ size_t offset, size_t length, int mflags);
+int sglist_split(struct sglist *original, struct sglist **head,
+ size_t length, int mflags);
+
+#endif /* !__SGLIST_H__ */
diff --git a/freebsd/sys/sys/sockbuf.h b/freebsd/sys/sys/sockbuf.h
index 91a30b6f..915fee0b 100644
--- a/freebsd/sys/sys/sockbuf.h
+++ b/freebsd/sys/sys/sockbuf.h
@@ -141,9 +141,9 @@ int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
struct mbuf *m0, struct mbuf *control);
int sbappendaddr_nospacecheck_locked(struct sockbuf *sb,
const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control);
-int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
+void sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
struct mbuf *control);
-int sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
+void sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
struct mbuf *control);
void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
void sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);
@@ -168,6 +168,10 @@ int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so,
struct mbuf *
sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff);
struct mbuf *
+ sbsndptr_noadv(struct sockbuf *sb, u_int off, u_int *moff);
+void
+ sbsndptr_adv(struct sockbuf *sb, struct mbuf *mb, u_int len);
+struct mbuf *
sbsndmbuf(struct sockbuf *sb, u_int off, u_int *moff);
int sbwait(struct sockbuf *sb);
int sblock(struct sockbuf *sb, int flags);
diff --git a/freebsd/sys/sys/socketvar.h b/freebsd/sys/sys/socketvar.h
index f877a0df..96ba4a01 100644
--- a/freebsd/sys/sys/socketvar.h
+++ b/freebsd/sys/sys/socketvar.h
@@ -63,6 +63,7 @@ struct vnet;
* private data and error information.
*/
typedef int so_upcall_t(struct socket *, void *, int);
+typedef void so_dtor_t(struct socket *);
struct socket;
@@ -84,7 +85,7 @@ struct socket {
struct selinfo so_rdsel; /* (b/cr) for so_rcv/so_comp */
struct selinfo so_wrsel; /* (b/cs) for so_snd */
short so_type; /* (a) generic type, see socket.h */
- short so_options; /* (b) from socket call, see socket.h */
+ int so_options; /* (b) from socket call, see socket.h */
short so_linger; /* time to linger close(2) */
short so_state; /* (b) internal state flags SS_* */
void *so_pcb; /* protocol control block */
@@ -99,6 +100,7 @@ struct socket {
/* NB: generation count must not be first. */
so_gen_t so_gencnt; /* (h) generation count */
void *so_emuldata; /* (b) private data for emulators */
+ so_dtor_t *so_dtor; /* (b) optional destructor */
struct osd osd; /* Object Specific extensions */
/*
* so_fibnum, so_user_cookie and friends can be used to attach
@@ -399,6 +401,7 @@ int soconnect2(struct socket *so1, struct socket *so2);
int socreate(int dom, struct socket **aso, int type, int proto,
struct ucred *cred, struct thread *td);
int sodisconnect(struct socket *so);
+void sodtor_set(struct socket *, so_dtor_t *);
struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags);
void sofree(struct socket *so);
void sohasoutofband(struct socket *so);
@@ -477,15 +480,9 @@ int accept_filt_generic_mod_event(module_t mod, int event, void *data);
* Structure to export socket from kernel to utilities, via sysctl(3).
*/
struct xsocket {
- size_t xso_len; /* length of this structure */
- union {
- void *xso_so; /* kernel address of struct socket */
- int64_t ph_so;
- };
- union {
- void *so_pcb; /* kernel address of struct inpcb */
- int64_t ph_pcb;
- };
+ ksize_t xso_len; /* length of this structure */
+ kvaddr_t xso_so; /* kernel address of struct socket */
+ kvaddr_t so_pcb; /* kernel address of struct inpcb */
uint64_t so_oobmark;
int64_t so_spare64[8];
int32_t xso_protocol;
diff --git a/freebsd/sys/sys/sockopt.h b/freebsd/sys/sys/sockopt.h
index 7f19ecf8..e7cc6cf0 100644
--- a/freebsd/sys/sys/sockopt.h
+++ b/freebsd/sys/sys/sockopt.h
@@ -62,7 +62,6 @@ int sosetopt(struct socket *so, struct sockopt *sopt);
int sogetopt(struct socket *so, struct sockopt *sopt);
int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
-/* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */
int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
diff --git a/freebsd/sys/sys/sx.h b/freebsd/sys/sys/sx.h
index 566137bd..10cfb10a 100644
--- a/freebsd/sys/sys/sx.h
+++ b/freebsd/sys/sys/sx.h
@@ -76,8 +76,8 @@
#define SX_LOCK_SHARED 0x01
#define SX_LOCK_SHARED_WAITERS 0x02
#define SX_LOCK_EXCLUSIVE_WAITERS 0x04
-#define SX_LOCK_RECURSED 0x08
-#define SX_LOCK_WRITE_SPINNER 0x10
+#define SX_LOCK_WRITE_SPINNER 0x08
+#define SX_LOCK_RECURSED 0x10
#define SX_LOCK_FLAGMASK \
(SX_LOCK_SHARED | SX_LOCK_SHARED_WAITERS | \
SX_LOCK_EXCLUSIVE_WAITERS | SX_LOCK_RECURSED | SX_LOCK_WRITE_SPINNER)
diff --git a/freebsd/sys/sys/sysproto.h b/freebsd/sys/sys/sysproto.h
index b328cb51..89467f3b 100644
--- a/freebsd/sys/sys/sysproto.h
+++ b/freebsd/sys/sys/sysproto.h
@@ -90,7 +90,7 @@ struct chown_args {
char uid_l_[PADL_(int)]; int uid; char uid_r_[PADR_(int)];
char gid_l_[PADL_(int)]; int gid; char gid_r_[PADR_(int)];
};
-struct obreak_args {
+struct break_args {
char nsize_l_[PADL_(char *)]; char * nsize; char nsize_r_[PADR_(char *)];
};
struct getpid_args {
@@ -1831,7 +1831,7 @@ int sys_chdir(struct thread *, struct chdir_args *);
int sys_fchdir(struct thread *, struct fchdir_args *);
int sys_chmod(struct thread *, struct chmod_args *);
int sys_chown(struct thread *, struct chown_args *);
-int sys_obreak(struct thread *, struct obreak_args *);
+int sys_break(struct thread *, struct break_args *);
int sys_getpid(struct thread *, struct getpid_args *);
int sys_mount(struct thread *, struct mount_args *);
int sys_unmount(struct thread *, struct unmount_args *);
diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h
index 9c21f589..4145be2c 100644
--- a/freebsd/sys/sys/systm.h
+++ b/freebsd/sys/sys/systm.h
@@ -48,6 +48,7 @@
#include <sys/stdint.h> /* for people using printf mainly */
#ifdef __rtems__
#include <string.h>
+#include <rtems/score/threaddispatch.h>
#endif /* __rtems__ */
__NULLABILITY_PRAGMA_PUSH
@@ -106,12 +107,21 @@ extern int vm_guest; /* Running as virtual machine guest? */
enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_BHYVE, VM_LAST };
+/*
+ * These functions need to be declared before the KASSERT macro is invoked in
+ * !KASSERT_PANIC_OPTIONAL builds, so their declarations are sort of out of
+ * place compared to other function definitions in this header. On the other
+ * hand, this header is a bit disorganized anyway.
+ */
+void panic(const char *, ...) __dead2 __printflike(1, 2);
+void vpanic(const char *, __va_list) __dead2 __printflike(1, 0);
+
#if defined(WITNESS) || defined(INVARIANT_SUPPORT)
-#ifndef __rtems__
+#ifdef KASSERT_PANIC_OPTIONAL
void kassert_panic(const char *fmt, ...) __printflike(1, 2);
-#else /* __rtems__ */
-#define kassert_panic panic
-#endif /* __rtems__ */
+#else
+#define kassert_panic panic
+#endif
#endif
#ifdef INVARIANTS /* The option is always available */
@@ -137,6 +147,12 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2);
#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
#endif
+#if defined(_KERNEL)
+#include <sys/param.h> /* MAXCPU */
+#include <sys/pcpu.h> /* curthread */
+#include <sys/kpilite.h>
+#endif
+
/*
* Assert that a pointer can be loaded from memory atomically.
*
@@ -184,11 +200,10 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2);
* XXX most of these variables should be const.
*/
extern int osreldate;
-extern int envmode;
-extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */
-extern int dynamic_kenv;
+extern bool dynamic_kenv;
extern struct mtx kenv_lock;
extern char *kern_envp;
+extern char *md_envp;
extern char static_env[];
extern char static_hints[]; /* by config for now */
@@ -244,34 +259,57 @@ void *phashinit_flags(int count, struct malloc_type *type, u_long *nentries,
int flags);
void g_waitidle(void);
-void panic(const char *, ...) __dead2 __printflike(1, 2);
-void vpanic(const char *, __va_list) __dead2 __printflike(1, 0);
-
void cpu_boot(int);
void cpu_flush_dcache(void *, size_t);
void cpu_rootconf(void);
-#ifndef __rtems__
-void critical_enter(void);
-void critical_exit(void);
-#else /* __rtems__ */
-#include <rtems/score/threaddispatch.h>
+void critical_enter_KBI(void);
+void critical_exit_KBI(void);
+void critical_exit_preempt(void);
+void init_param1(void);
+void init_param2(long physpages);
+void init_static_kenv(char *, size_t);
+void tablefull(const char *);
+#if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET)
+#define critical_enter() critical_enter_KBI()
+#define critical_exit() critical_exit_KBI()
+#else
static __inline void
critical_enter(void)
{
+#ifndef __rtems__
+ struct thread_lite *td;
+
+ td = (struct thread_lite *)curthread;
+ td->td_critnest++;
+ __compiler_membar();
+#else /* __rtems__ */
_Thread_Dispatch_disable();
+#endif /* __rtems__ */
}
static __inline void
critical_exit(void)
{
+#ifndef __rtems__
+ struct thread_lite *td;
+
+ td = (struct thread_lite *)curthread;
+ KASSERT(td->td_critnest != 0,
+ ("critical_exit: td_critnest == 0"));
+ __compiler_membar();
+ td->td_critnest--;
+ __compiler_membar();
+ if (__predict_false(td->td_owepreempt))
+ critical_exit_preempt();
+#else /* __rtems__ */
_Thread_Dispatch_enable(_Per_CPU_Get());
-}
#endif /* __rtems__ */
-void init_param1(void);
-void init_param2(long physpages);
-void init_static_kenv(char *, size_t);
-void tablefull(const char *);
+
+}
+#endif
+
+
#ifdef EARLY_PRINTF
typedef void early_putc_t(int ch);
extern early_putc_t *early_putc;
@@ -329,30 +367,22 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags);
#define HD_OMIT_CHARS (1 << 18)
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
-#ifndef __rtems__
void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len);
-#define bcopy(from, to, len) ({ \
- if (__builtin_constant_p(len) && (len) <= 64) \
- __builtin_memmove((to), (from), (len)); \
- else \
- bcopy((from), (to), (len)); \
-})
+#define bcopy(from, to, len) __builtin_memmove((to), (from), (len))
void bzero(void * _Nonnull buf, size_t len);
-#define bzero(buf, len) ({ \
- if (__builtin_constant_p(len) && (len) <= 64) \
- __builtin_memset((buf), 0, (len)); \
- else \
- bzero((buf), (len)); \
-})
-#else /* __rtems__ */
-#define bcopy(src, dst, len) memmove((dst), (src), (len))
-#define bzero(buf, size) memset((buf), 0, (size))
-#endif /* __rtems__ */
+#define bzero(buf, len) __builtin_memset((buf), 0, (len))
void explicit_bzero(void * _Nonnull, size_t);
+int bcmp(const void *b1, const void *b2, size_t len);
+#define bcmp(b1, b2, len) __builtin_memcmp((b1), (b2), (len))
+void *memset(void * _Nonnull buf, int c, size_t len);
+#define memset(buf, c, len) __builtin_memset((buf), (c), (len))
void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
-#define memcpy(to, from, len) __builtin_memcpy(to, from, len)
+#define memcpy(to, from, len) __builtin_memcpy((to), (from), (len))
void *memmove(void * _Nonnull dest, const void * _Nonnull src, size_t n);
+#define memmove(dest, src, n) __builtin_memmove((dest), (src), (n))
+int memcmp(const void *b1, const void *b2, size_t len);
+#define memcmp(b1, b2, len) __builtin_memcmp((b1), (b2), (len))
#ifndef __rtems__
int copystr(const void * _Nonnull __restrict kfaddr,
@@ -451,17 +481,13 @@ void realitexpire(void *);
int sysbeep(int hertz, int period);
-void hardclock(int usermode, uintfptr_t pc);
-void hardclock_cnt(int cnt, int usermode);
-void hardclock_cpu(int usermode);
+void hardclock(int cnt, int usermode);
void hardclock_sync(int cpu);
#ifndef __rtems__
void softclock(void *);
+void statclock(int cnt, int usermode);
+void profclock(int cnt, int usermode, uintfptr_t pc);
#endif /* __rtems__ */
-void statclock(int usermode);
-void statclock_cnt(int cnt, int usermode);
-void profclock(int usermode, uintfptr_t pc);
-void profclock_cnt(int cnt, int usermode, uintfptr_t pc);
int hardclockintr(void);
@@ -492,6 +518,11 @@ int kern_setenv(const char *name, const char *value);
int kern_unsetenv(const char *name);
int testenv(const char *name);
+int getenv_array(const char *name, void *data, int size, int *psize,
+ int type_size, bool allow_signed);
+#define GETENV_UNSIGNED false /* negative numbers not allowed */
+#define GETENV_SIGNED true /* negative numbers allowed */
+
typedef uint64_t (cpu_tick_f)(void);
void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var);
extern cpu_tick_f *cpu_ticks;
diff --git a/freebsd/sys/sys/unpcb.h b/freebsd/sys/sys/unpcb.h
index d80b1384..7d7a20ac 100644
--- a/freebsd/sys/sys/unpcb.h
+++ b/freebsd/sys/sys/unpcb.h
@@ -142,12 +142,12 @@ struct unpcb {
*/
#ifdef _SYS_SOCKETVAR_H_
struct xunpcb {
- size_t xu_len; /* length of this structure */
- void *xu_unpp; /* to help netstat, fstat */
- void *unp_vnode; /* (s) */
- void *unp_conn; /* (s) */
- void *xu_firstref; /* (s) */
- void *xu_nextref; /* (s) */
+ ksize_t xu_len; /* length of this structure */
+ kvaddr_t xu_unpp; /* to help netstat, fstat */
+ kvaddr_t unp_vnode; /* (s) */
+ kvaddr_t unp_conn; /* (s) */
+ kvaddr_t xu_firstref; /* (s) */
+ kvaddr_t xu_nextref; /* (s) */
unp_gen_t unp_gencnt; /* (s) */
int64_t xu_spare64[8];
int32_t xu_spare32[8];
@@ -163,11 +163,20 @@ struct xunpcb {
} __aligned(8);
struct xunpgen {
- size_t xug_len;
+ ksize_t xug_len;
u_int xug_count;
unp_gen_t xug_gen;
so_gen_t xug_sogen;
} __aligned(8);;
#endif /* _SYS_SOCKETVAR_H_ */
+#if defined(_KERNEL)
+struct thread;
+
+/* In uipc_userreq.c */
+void
+unp_copy_peercred(struct thread *td, struct unpcb *client_unp,
+ struct unpcb *server_unp, struct unpcb *listen_unp);
+#endif
+
#endif /* _SYS_UNPCB_H_ */
diff --git a/freebsd/sys/sys/vmmeter.h b/freebsd/sys/sys/vmmeter.h
index 3c570b0a..c41b151f 100644
--- a/freebsd/sys/sys/vmmeter.h
+++ b/freebsd/sys/sys/vmmeter.h
@@ -187,6 +187,13 @@ vm_page_count_severe(void)
return (!DOMAINSET_EMPTY(&vm_severe_domains));
}
+static inline int
+vm_page_count_severe_set(domainset_t *mask)
+{
+
+ return (DOMAINSET_SUBSET(&vm_severe_domains, mask));
+}
+
/*
* Return TRUE if we are under our minimum low-free-pages threshold.
*