diff options
Diffstat (limited to 'freebsd/sys/sys')
35 files changed, 715 insertions, 125 deletions
diff --git a/freebsd/sys/sys/ata.h b/freebsd/sys/sys/ata.h index cacb1ea0..efa5b246 100644 --- a/freebsd/sys/sys/ata.h +++ b/freebsd/sys/sys/ata.h @@ -135,6 +135,7 @@ struct ata_params { #define ATA_SUPPORT_AUTOACTIVATE 0x0004 #define ATA_SUPPORT_IFPWRMNGT 0x0008 #define ATA_SUPPORT_INORDERDATA 0x0010 +#define ATA_SUPPORT_ASYNCNOTIF 0x0020 #define ATA_SUPPORT_SOFTSETPRESERVE 0x0040 /*79*/ u_int16_t sataenabled; #define ATA_ENABLED_DAPST 0x0080 @@ -260,6 +261,20 @@ struct ata_params { /*255*/ u_int16_t integrity; } __packed; +/* + * ATA Device Register + * + * bit 7 Obsolete (was 1 in early ATA specs) + * bit 6 Sets LBA/CHS mode. 1=LBA, 0=CHS + * bit 5 Obsolete (was 1 in early ATA specs) + * bit 4 1 = Slave Drive, 0 = Master Drive + * bit 3-0 In LBA mode, 27-24 of address. In CHS mode, head number +*/ + +#define ATA_DEV_MASTER 0x00 +#define ATA_DEV_SLAVE 0x10 +#define ATA_DEV_LBA 0x40 + /* ATA transfer modes */ #define ATA_MODE_MASK 0x0f diff --git a/freebsd/sys/sys/buf.h b/freebsd/sys/sys/buf.h index 6cc68ee9..e182c7cc 100644 --- a/freebsd/sys/sys/buf.h +++ b/freebsd/sys/sys/buf.h @@ -311,6 +311,12 @@ extern const char *buf_wmesg; /* Default buffer lock message */ lockdestroy(&(bp)->b_lock) /* + * Print informations on a buffer lock. + */ +#define BUF_LOCKPRINTINFO(bp) \ + lockmgr_printinfo(&(bp)->b_lock) + +/* * Buffer lock assertions. */ #if defined(INVARIANTS) && defined(INVARIANT_SUPPORT) diff --git a/freebsd/sys/sys/bus.h b/freebsd/sys/sys/bus.h index 6c1128e3..7259981e 100644 --- a/freebsd/sys/sys/bus.h +++ b/freebsd/sys/sys/bus.h @@ -52,6 +52,7 @@ struct u_businfo { typedef enum device_state { DS_NOTPRESENT = 10, /**< @brief not probed or probe failed */ DS_ALIVE = 20, /**< @brief probe succeeded */ + DS_ATTACHING = 25, /**< @brief currently attaching */ DS_ATTACHED = 30, /**< @brief attach method called */ DS_BUSY = 40 /**< @brief device is open */ } device_state_t; @@ -194,7 +195,11 @@ enum intr_type { INTR_FAST = 128, INTR_EXCL = 256, /* exclusive interrupt */ INTR_MPSAFE = 512, /* this interrupt is SMP safe */ - INTR_ENTROPY = 1024 /* this interrupt provides entropy */ + INTR_ENTROPY = 1024, /* this interrupt provides entropy */ + INTR_MD1 = 4096, /* flag reserved for MD use */ + INTR_MD2 = 8192, /* flag reserved for MD use */ + INTR_MD3 = 16384, /* flag reserved for MD use */ + INTR_MD4 = 32768 /* flag reserved for MD use */ }; enum intr_trigger { @@ -285,6 +290,9 @@ int bus_generic_activate_resource(device_t dev, device_t child, int type, device_t bus_generic_add_child(device_t dev, u_int order, const char *name, int unit); +int bus_generic_adjust_resource(device_t bus, device_t child, int type, + struct resource *r, u_long start, + u_long end); struct resource * bus_generic_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, @@ -353,6 +361,8 @@ struct resource_spec { int bus_alloc_resources(device_t dev, struct resource_spec *rs, struct resource **res); void bus_release_resources(device_t dev, const struct resource_spec *rs, struct resource **res); +int bus_adjust_resource(device_t child, int type, struct resource *r, + u_long start, u_long end); struct resource *bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); @@ -397,6 +407,7 @@ device_t device_add_child_ordered(device_t dev, u_int order, const char *name, int unit); void device_busy(device_t dev); int device_delete_child(device_t dev, device_t child); +int device_delete_children(device_t dev); int device_attach(device_t dev); int device_detach(device_t dev); void device_disable(device_t dev); @@ -540,9 +551,10 @@ extern int bus_current_pass; void bus_set_pass(int pass); /** - * Shorthand for constructing method tables. + * Shorthands for constructing method tables. */ #define DEVMETHOD KOBJMETHOD +#define DEVMETHOD_END KOBJMETHOD_END /* * Some common device interfaces. @@ -566,7 +578,8 @@ struct driver_module_data { int dmd_pass; }; -#define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ +#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ + evh, arg, order, pass) \ \ static struct driver_module_data name##_##busname##_driver_mod = { \ evh, arg, \ @@ -582,7 +595,16 @@ static moduledata_t name##_##busname##_mod = { \ &name##_##busname##_driver_mod \ }; \ DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ - SI_SUB_DRIVERS, SI_ORDER_MIDDLE) + SI_SUB_DRIVERS, order) + +#define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ + EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ + evh, arg, SI_ORDER_MIDDLE, pass) + +#define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg,\ + order) \ + EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ + evh, arg, order, BUS_PASS_DEFAULT) #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, \ diff --git a/freebsd/sys/sys/callout.h b/freebsd/sys/sys/callout.h index 2d43d149..370cec7a 100644 --- a/freebsd/sys/sys/callout.h +++ b/freebsd/sys/sys/callout.h @@ -64,6 +64,7 @@ struct callout { #define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */ #define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */ #define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */ +#define CALLOUT_DFRMIGRATION 0x0040 /* callout in deferred migration mode */ struct callout_handle { struct callout *callout; diff --git a/freebsd/sys/sys/eventhandler.h b/freebsd/sys/sys/eventhandler.h index 0da999d0..61d05bff 100644 --- a/freebsd/sys/sys/eventhandler.h +++ b/freebsd/sys/sys/eventhandler.h @@ -178,6 +178,11 @@ EVENTHANDLER_DECLARE(shutdown_pre_sync, shutdown_fn); /* before fs sync */ EVENTHANDLER_DECLARE(shutdown_post_sync, shutdown_fn); /* after fs sync */ EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn); +/* Power state change events */ +typedef void (*power_change_fn)(void *); +EVENTHANDLER_DECLARE(power_resume, power_change_fn); +EVENTHANDLER_DECLARE(power_suspend, power_change_fn); + /* Low memory event */ typedef void (*vm_lowmem_handler_t)(void *, int); #define LOWMEM_PRI_DEFAULT EVENTHANDLER_PRI_FIRST @@ -237,6 +242,4 @@ typedef void (*uma_zone_chfn)(void *); EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn); EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn); -typedef void(*schedtail_fn)(void *, struct proc *); -EVENTHANDLER_DECLARE(schedtail, schedtail_fn); #endif /* SYS_EVENTHANDLER_H */ diff --git a/freebsd/sys/sys/file.h b/freebsd/sys/sys/file.h index 60339b81..f563f75c 100644 --- a/freebsd/sys/sys/file.h +++ b/freebsd/sys/sys/file.h @@ -117,6 +117,14 @@ struct fileops { * none not locked */ +struct fadvise_info { + int fa_advice; /* (f) FADV_* type. */ + off_t fa_start; /* (f) Region start. */ + off_t fa_end; /* (f) Region end. */ + off_t fa_prevstart; /* (f) Previous NOREUSE start. */ + off_t fa_prevend; /* (f) Previous NOREUSE end. */ +}; + struct file { #ifndef __rtems__ void *f_data; /* file descriptor specific data */ @@ -132,7 +140,11 @@ struct file { */ int f_seqcount; /* Count of sequential accesses. */ off_t f_nextoff; /* next expected read/write offset. */ - struct cdev_privdata *f_cdevpriv; /* (d) Private data for the cdev. */ + union { + struct cdev_privdata *fvn_cdevpriv; + /* (d) Private data for the cdev. */ + struct fadvise_info *fvn_advice; + } f_vnun; /* * DFLAG_SEEKABLE specific fields */ @@ -223,6 +235,9 @@ rtems_bsd_error_to_status_and_errno(int error) } #endif /* __rtems__ */ +#define f_cdevpriv f_vnun.fvn_cdevpriv +#define f_advice f_vnun.fvn_advice + #define FOFFSET_LOCKED 0x1 #define FOFFSET_LOCK_WAITING 0x2 diff --git a/freebsd/sys/sys/filedesc.h b/freebsd/sys/sys/filedesc.h index 62bbc6f2..0b48d849 100644 --- a/freebsd/sys/sys/filedesc.h +++ b/freebsd/sys/sys/filedesc.h @@ -153,6 +153,8 @@ falloc(struct thread *td, struct file **resultfp, int *resultfd) } } #endif /* __rtems__ */ +int fallocf(struct thread *td, struct file **resultfp, int *resultfd, + int flags); int fdalloc(struct thread *td, int minfd, int *result); int fdavail(struct thread *td, int n); int fdcheckstd(struct thread *td); diff --git a/freebsd/sys/sys/hhook.h b/freebsd/sys/sys/hhook.h new file mode 100644 index 00000000..51eda1fd --- /dev/null +++ b/freebsd/sys/sys/hhook.h @@ -0,0 +1,156 @@ +/*- + * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Lawrence Stewart while studying at the Centre + * for Advanced Internet Architectures, Swinburne University of Technology, made + * possible in part by grants from the FreeBSD Foundation and Cisco University + * Research Program Fund at Community Foundation Silicon Valley. + * + * Portions of this software were developed at the Centre for Advanced + * Internet Architectures, Swinburne University of Technology, Melbourne, + * Australia by Lawrence Stewart under sponsorship from the FreeBSD Foundation. + * + * 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. + * + * 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 KPI modelled on the pfil framework for instantiating helper hook points + * within the kernel for use by Khelp modules. Originally released as part of + * the NewTCP research project at Swinburne University of Technology's Centre + * for Advanced Internet Architectures, Melbourne, Australia, which was made + * possible in part by a grant from the Cisco University Research Program Fund + * at Community Foundation Silicon Valley. More details are available at: + * http://caia.swin.edu.au/urp/newtcp/ + */ + +#ifndef _SYS_HHOOK_H_ +#define _SYS_HHOOK_H_ + +/* XXXLAS: Is there a way around this? */ +#include <rtems/bsd/sys/lock.h> +#include <sys/rmlock.h> + +/* hhook_head flags. */ +#define HHH_ISINVNET 0x00000001 /* Is the hook point in a vnet? */ + +/* Flags common to all register functions. */ +#define HHOOK_WAITOK 0x00000001 /* Sleeping allowed. */ +#define HHOOK_NOWAIT 0x00000002 /* Sleeping disallowed. */ +/* Flags only relevant to hhook_head_register() and hhook_head_is_virtual(). */ +#define HHOOK_HEADISINVNET 0x00000100 /* Public proxy for HHH_ISINVNET. */ + +/* Helper hook types. */ +#define HHOOK_TYPE_TCP 1 + +struct helper; +struct osd; + +/* Signature for helper hook functions. */ +typedef int (*hhook_func_t)(int32_t hhook_type, int32_t hhook_id, void *udata, + void *ctx_data, void *hdata, struct osd *hosd); + +/* + * Information required to add/remove a helper hook function to/from a helper + * hook point. + */ +struct hookinfo { + hhook_func_t hook_func; + struct helper *hook_helper; + void *hook_udata; + int32_t hook_id; + int32_t hook_type; +}; + +/* + * Ideally this would be private but we need access to the hhh_nhooks member + * variable in order to make the HHOOKS_RUN_IF() macro low impact. + */ +struct hhook_head { + STAILQ_HEAD(hhook_list, hhook) hhh_hooks; + struct rmlock hhh_lock; + int32_t hhh_id; + int32_t hhh_nhooks; + int32_t hhh_type; + uint32_t hhh_flags; + volatile uint32_t hhh_refcount; + LIST_ENTRY(hhook_head) hhh_next; +}; + +/* Public KPI functions. */ +void hhook_run_hooks(struct hhook_head *hhh, void *ctx_data, struct osd *hosd); + +int hhook_add_hook(struct hhook_head *hhh, struct hookinfo *hki, + uint32_t flags); + +int hhook_add_hook_lookup(struct hookinfo *hki, uint32_t flags); + +int hhook_remove_hook(struct hhook_head *hhh, struct hookinfo *hki); + +int hhook_remove_hook_lookup(struct hookinfo *hki); + +int hhook_head_register(int32_t hhook_type, int32_t hhook_id, + struct hhook_head **hhh, uint32_t flags); + +int hhook_head_deregister(struct hhook_head *hhh); + +int hhook_head_deregister_lookup(int32_t hhook_type, int32_t hhook_id); + +struct hhook_head * hhook_head_get(int32_t hhook_type, int32_t hhook_id); + +void hhook_head_release(struct hhook_head *hhh); + +uint32_t hhook_head_is_virtualised(struct hhook_head *hhh); + +uint32_t hhook_head_is_virtualised_lookup(int32_t hook_type, int32_t hook_id); + +/* + * A wrapper around hhook_run_hooks() that only calls the function if at least + * one helper hook function is registered for the specified helper hook point. + */ +#define HHOOKS_RUN_IF(hhh, ctx_data, hosd) do { \ + if (hhh != NULL && hhh->hhh_nhooks > 0) \ + hhook_run_hooks(hhh, ctx_data, hosd); \ +} while (0) + +/* + * WARNING: This macro should only be used in code paths that execute + * infrequently, otherwise the refcounting overhead would be excessive. + * + * A similar wrapper to HHOOKS_RUN_IF() for situations where the caller prefers + * not to lookup and store the appropriate hhook_head pointer themselves. + */ +#define HHOOKS_RUN_LOOKUP_IF(hhook_type, hhook_id, ctx_data, hosd) do { \ + struct hhook_head *_hhh; \ + \ + _hhh = hhook_head_get(hhook_type, hhook_id); \ + if (_hhh != NULL) { \ + if (_hhh->hhh_nhooks > 0) \ + hhook_run_hooks(_hhh, ctx_data, hosd); \ + hhook_head_release(_hhh); \ + } \ +} while (0) + +#endif /* _SYS_HHOOK_H_ */ diff --git a/freebsd/sys/sys/kernel.h b/freebsd/sys/sys/kernel.h index 9b5aa856..83122c99 100644 --- a/freebsd/sys/sys/kernel.h +++ b/freebsd/sys/sys/kernel.h @@ -66,7 +66,7 @@ extern int stathz; /* statistics clock's frequency */ extern int profhz; /* profiling clock's frequency */ extern int profprocs; /* number of process's profiling */ #ifndef __rtems__ -extern int ticks; +extern volatile int ticks; #else /* __rtems__ */ #include <rtems/score/watchdogimpl.h> #define ticks _Watchdog_Ticks_since_boot diff --git a/freebsd/sys/sys/khelp.h b/freebsd/sys/sys/khelp.h new file mode 100644 index 00000000..db12d6bb --- /dev/null +++ b/freebsd/sys/sys/khelp.h @@ -0,0 +1,76 @@ +/*- + * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Lawrence Stewart while studying at the Centre + * for Advanced Internet Architectures, Swinburne University of Technology, made + * possible in part by grants from the FreeBSD Foundation and Cisco University + * Research Program Fund at Community Foundation Silicon Valley. + * + * Portions of this software were developed at the Centre for Advanced + * Internet Architectures, Swinburne University of Technology, Melbourne, + * Australia by Lawrence Stewart under sponsorship from the FreeBSD Foundation. + * + * 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. + * + * 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 KPI for managing kernel helper modules which perform useful functionality + * within the kernel. Originally released as part of the NewTCP research project + * at Swinburne University of Technology's Centre for Advanced Internet + * Architectures, Melbourne, Australia, which was made possible in part by a + * grant from the Cisco University Research Program Fund at Community Foundation + * Silicon Valley. More details are available at: + * http://caia.swin.edu.au/urp/newtcp/ + */ + +#ifndef _SYS_KHELP_H_ +#define _SYS_KHELP_H_ + +struct helper; +struct hookinfo; +struct osd; + +/* Helper classes. */ +#define HELPER_CLASS_TCP 0x00000001 + +/* Public KPI functions. */ +int khelp_register_helper(struct helper *h); + +int khelp_deregister_helper(struct helper *h); + +int khelp_init_osd(uint32_t classes, struct osd *hosd); + +int khelp_destroy_osd(struct osd *hosd); + +void * khelp_get_osd(struct osd *hosd, int32_t id); + +int32_t khelp_get_id(char *hname); + +int khelp_add_hhook(struct hookinfo *hki, uint32_t flags); + +int khelp_remove_hhook(struct hookinfo *hki); + +#endif /* _SYS_KHELP_H_ */ diff --git a/freebsd/sys/sys/kobj.h b/freebsd/sys/sys/kobj.h index 3143bea4..5df5dccc 100644 --- a/freebsd/sys/sys/kobj.h +++ b/freebsd/sys/sys/kobj.h @@ -201,6 +201,7 @@ kobj_t kobj_create(kobj_class_t cls, * Initialise a pre-allocated object. */ void kobj_init(kobj_t obj, kobj_class_t cls); +void kobj_init_static(kobj_t obj, kobj_class_t cls); /* * Delete an object. If mtype is non-zero, free the memory. diff --git a/freebsd/sys/sys/libkern.h b/freebsd/sys/sys/libkern.h index a09517cc..942c21f5 100644 --- a/freebsd/sys/sys/libkern.h +++ b/freebsd/sys/sys/libkern.h @@ -127,6 +127,7 @@ size_t strlen(const char *); int strncasecmp(const char *, const char *, size_t); int strncmp(const char *, const char *, size_t); char *strncpy(char * __restrict, const char * __restrict, size_t); +size_t strnlen(const char *, size_t); char *strsep(char **, const char *delim); size_t strspn(const char *, const char *); char *strstr(const char *, const char *); diff --git a/freebsd/sys/sys/limits.h b/freebsd/sys/sys/limits.h index 633a7f70..edb21d8d 100644 --- a/freebsd/sys/sys/limits.h +++ b/freebsd/sys/sys/limits.h @@ -91,7 +91,7 @@ #endif #ifndef __rtems__ -#if __XSI_VISIBLE +#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809 #define LONG_BIT __LONG_BIT #define WORD_BIT __WORD_BIT #endif diff --git a/freebsd/sys/sys/mman.h b/freebsd/sys/sys/mman.h index 4872d631..5ed9cdd6 100644 --- a/freebsd/sys/sys/mman.h +++ b/freebsd/sys/sys/mman.h @@ -82,11 +82,15 @@ */ #define MAP_FILE 0x0000 /* map from file (default) */ #define MAP_ANON 0x1000 /* allocated from memory, swap space */ +#ifndef _KERNEL +#define MAP_ANONYMOUS MAP_ANON /* For compatibility. */ +#endif /* !_KERNEL */ /* * Extended flags */ #define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ +#define MAP_PREFAULT_READ 0x00040000 /* prefault mapping for reading */ #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 199309 @@ -174,9 +178,11 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_WANT_FILE) #include <vm/vm.h> +struct file; + struct shmfd { size_t shm_size; vm_object_t shm_object; @@ -184,6 +190,7 @@ struct shmfd { uid_t shm_uid; gid_t shm_gid; mode_t shm_mode; + int shm_kmappings; /* * Values maintained solely to make this a better-behaved file @@ -195,10 +202,16 @@ struct shmfd { struct timespec shm_birthtime; struct label *shm_label; /* MAC label */ + const char *shm_path; }; +#endif +#ifdef _KERNEL int shm_mmap(struct shmfd *shmfd, vm_size_t objsize, vm_ooffset_t foff, vm_object_t *obj); +int shm_map(struct file *fp, size_t size, off_t offset, void **memp); +int shm_unmap(struct file *fp, void *mem, size_t size); +void shm_path(struct shmfd *shmfd, char *path, size_t size); #else /* !_KERNEL */ diff --git a/freebsd/sys/sys/module_khelp.h b/freebsd/sys/sys/module_khelp.h new file mode 100644 index 00000000..9a7f507d --- /dev/null +++ b/freebsd/sys/sys/module_khelp.h @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Lawrence Stewart while studying at the Centre + * for Advanced Internet Architectures, Swinburne University of Technology, made + * possible in part by grants from the FreeBSD Foundation and Cisco University + * Research Program Fund at Community Foundation Silicon Valley. + * + * Portions of this software were developed at the Centre for Advanced + * Internet Architectures, Swinburne University of Technology, Melbourne, + * Australia by Lawrence Stewart under sponsorship from the FreeBSD Foundation. + * + * 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. + * + * 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$ + */ + +#ifndef _SYS_MODULE_KHELP_H_ +#define _SYS_MODULE_KHELP_H_ + +/* XXXLAS: Needed for uma related typedefs. */ +#include <vm/uma.h> + +/* Helper flags. */ +#define HELPER_NEEDS_OSD 0x0001 + +struct helper { + int (*mod_init) (void); + int (*mod_destroy) (void); +#define HELPER_NAME_MAXLEN 16 + char h_name[HELPER_NAME_MAXLEN]; + uma_zone_t h_zone; + struct hookinfo *h_hooks; + uint32_t h_nhooks; + uint32_t h_classes; + int32_t h_id; + volatile uint32_t h_refcount; + uint16_t h_flags; + TAILQ_ENTRY(helper) h_next; +}; + +struct khelp_modevent_data { + char name[HELPER_NAME_MAXLEN]; + struct helper *helper; + struct hookinfo *hooks; + int nhooks; + int uma_zsize; + uma_ctor umactor; + uma_dtor umadtor; +}; + +#define KHELP_DECLARE_MOD(hname, hdata, hhooks, version) \ + static struct khelp_modevent_data kmd_##hname = { \ + .name = #hname, \ + .helper = hdata \ + .hooks = hhooks, \ + .nhooks = sizeof(hhooks) / sizeof(hhooks[0]), \ + }; \ + static moduledata_t h_##hname = { \ + .name = #hname, \ + .evhand = khelp_modevent, \ + .priv = &kmd_##hname \ + }; \ + DECLARE_MODULE(hname, h_##hname, SI_SUB_PROTO_IFATTACHDOMAIN, \ + SI_ORDER_ANY); \ + MODULE_VERSION(hname, version) + +#define KHELP_DECLARE_MOD_UMA(hname, hdata, hhooks, version, size, ctor, dtor) \ + static struct khelp_modevent_data kmd_##hname = { \ + .name = #hname, \ + .helper = hdata, \ + .hooks = hhooks, \ + .nhooks = sizeof(hhooks) / sizeof(hhooks[0]), \ + .uma_zsize = size, \ + .umactor = ctor, \ + .umadtor = dtor \ + }; \ + static moduledata_t h_##hname = { \ + .name = #hname, \ + .evhand = khelp_modevent, \ + .priv = &kmd_##hname \ + }; \ + DECLARE_MODULE(hname, h_##hname, SI_SUB_PROTO_IFATTACHDOMAIN, \ + SI_ORDER_ANY); \ + MODULE_VERSION(hname, version) + +int khelp_modevent(module_t mod, int type, void *data); + +#endif /* _SYS_MODULE_KHELP_H_ */ diff --git a/freebsd/sys/sys/mount.h b/freebsd/sys/sys/mount.h index fcf80bd5..efa17492 100644 --- a/freebsd/sys/sys/mount.h +++ b/freebsd/sys/sys/mount.h @@ -201,10 +201,10 @@ void __mnt_vnode_markerfree(struct vnode **mvp, struct mount *mp); __mnt_vnode_markerfree(&(mvp), (mp)) #define MNT_VNODE_FOREACH_ABORT(mp, mvp) \ - do { \ - MNT_ILOCK(mp); \ - MNT_VNODE_FOREACH_ABORT_ILOCKED(mp, mvp); \ - MNT_IUNLOCK(mp); \ + do { \ + MNT_ILOCK(mp); \ + MNT_VNODE_FOREACH_ABORT_ILOCKED(mp, mvp); \ + MNT_IUNLOCK(mp); \ } while (0) #define MNT_ILOCK(mp) mtx_lock(&(mp)->mnt_mtx) @@ -213,7 +213,7 @@ void __mnt_vnode_markerfree(struct vnode **mvp, struct mount *mp); #define MNT_MTX(mp) (&(mp)->mnt_mtx) #define MNT_REF(mp) (mp)->mnt_ref++ #define MNT_REL(mp) do { \ - KASSERT((mp)->mnt_ref > 0, ("negative mnt_ref")); \ + KASSERT((mp)->mnt_ref > 0, ("negative mnt_ref")); \ (mp)->mnt_ref--; \ if ((mp)->mnt_ref == 0) \ wakeup((mp)); \ diff --git a/freebsd/sys/sys/mutex.h b/freebsd/sys/sys/mutex.h index 3e4a1701..e7649d8f 100644 --- a/freebsd/sys/sys/mutex.h +++ b/freebsd/sys/sys/mutex.h @@ -399,7 +399,8 @@ do { \ \ if (mtx_owned(&Giant)) { \ WITNESS_SAVE(&Giant.lock_object, Giant); \ - for (_giantcnt = 0; mtx_owned(&Giant); _giantcnt++) \ + for (_giantcnt = 0; mtx_owned(&Giant) && \ + !SCHEDULER_STOPPED(); _giantcnt++) \ mtx_unlock(&Giant); \ } diff --git a/freebsd/sys/sys/osd.h b/freebsd/sys/sys/osd.h index 63d536fa..14316ae3 100644 --- a/freebsd/sys/sys/osd.h +++ b/freebsd/sys/sys/osd.h @@ -46,9 +46,10 @@ struct osd { #define OSD_THREAD 0 #define OSD_JAIL 1 +#define OSD_KHELP 2 #define OSD_FIRST OSD_THREAD -#define OSD_LAST OSD_JAIL +#define OSD_LAST OSD_KHELP typedef void (*osd_destructor_t)(void *value); typedef int (*osd_method_t)(void *obj, void *data); diff --git a/freebsd/sys/sys/priority.h b/freebsd/sys/sys/priority.h index 9bbd2de8..a3493715 100644 --- a/freebsd/sys/sys/priority.h +++ b/freebsd/sys/sys/priority.h @@ -85,14 +85,12 @@ #define PI_REALTIME (PRI_MIN_ITHD + 0) #define PI_AV (PRI_MIN_ITHD + 4) -#define PI_TTYHIGH (PRI_MIN_ITHD + 8) -#define PI_TAPE (PRI_MIN_ITHD + 12) #define PI_NET (PRI_MIN_ITHD + 16) #define PI_DISK (PRI_MIN_ITHD + 20) -#define PI_TTYLOW (PRI_MIN_ITHD + 24) -#define PI_DISKLOW (PRI_MIN_ITHD + 28) +#define PI_TTY (PRI_MIN_ITHD + 24) #define PI_DULL (PRI_MIN_ITHD + 32) #define PI_SOFT (PRI_MIN_ITHD + 36) +#define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) #define PRI_MIN_KERN (64) #define PRI_MAX_KERN (PRI_MIN_REALTIME - 1) @@ -105,7 +103,6 @@ #define PZERO (PRI_MIN_KERN + 20) #define PSOCK (PRI_MIN_KERN + 24) #define PWAIT (PRI_MIN_KERN + 28) -#define PCONFIG (PRI_MIN_KERN + 32) #define PLOCK (PRI_MIN_KERN + 36) #define PPAUSE (PRI_MIN_KERN + 40) @@ -120,6 +117,12 @@ #define PRI_MIN_IDLE (224) #define PRI_MAX_IDLE (PRI_MAX) +#ifdef _KERNEL +/* Other arguments for kern_yield(9). */ +#define PRI_USER -2 /* Change to current user priority. */ +#define PRI_UNCHANGED -1 /* Do not change priority. */ +#endif + struct priority { u_char pri_class; /* Scheduling class. */ u_char pri_level; /* Normal priority level. */ diff --git a/freebsd/sys/sys/priv.h b/freebsd/sys/sys/priv.h index 6939e144..a9b9bdb6 100644 --- a/freebsd/sys/sys/priv.h +++ b/freebsd/sys/sys/priv.h @@ -336,6 +336,7 @@ #define PRIV_NET_GIF 416 /* Administer gif interface. */ #define PRIV_NET_SETIFVNET 417 /* Move interface to vnet. */ #define PRIV_NET_SETIFDESCR 418 /* Set interface description. */ +#define PRIV_NET_SETIFFIB 419 /* Set interface fib. */ /* * 802.11-related privileges. @@ -497,7 +498,7 @@ #ifdef _KERNEL /* - * Privilege check interfaces, modeled after historic suser() interfacs, but + * Privilege check interfaces, modeled after historic suser() interfaces, but * with the addition of a specific privilege name. No flags are currently * defined for the API. Historically, flags specified using the real uid * instead of the effective uid, and whether or not the check should be diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h index ba40e259..d75dd7de 100644 --- a/freebsd/sys/sys/proc.h +++ b/freebsd/sys/sys/proc.h @@ -238,6 +238,7 @@ struct thread { short td_locks; /* (k) Count of non-spin locks. */ short td_rw_rlocks; /* (k) Count of rwlock read locks. */ short td_lk_slocks; /* (k) Count of lockmgr shared locks. */ + short td_stopsched; /* (k) Scheduler stopped. */ struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */ const char *td_lockname; /* (t) Name of lock blocked on. */ LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */ @@ -250,6 +251,7 @@ struct thread { u_int td_estcpu; /* (t) estimated cpu utilization */ int td_slptick; /* (t) Time at sleep. */ int td_blktick; /* (t) Time spent blocked. */ + u_int td_cow; /* (*) Number of copy-on-write faults */ struct rusage td_ru; /* (t) rusage information. */ uint64_t td_incruntime; /* (t) Cpu ticks to transfer to proc. */ uint64_t td_runtime; /* (t) How many cpu ticks we've run. */ @@ -271,7 +273,7 @@ struct thread { struct ksiginfo td_dbgksi; /* (c) ksi reflected to debugger. */ int td_ng_outbound; /* (k) Thread entered ng from above. */ struct osd td_osd; /* (k) Object specific data. */ -#define td_endzero td_base_pri +#define td_endzero td_rqindex /* Copied during fork1() or thread_sched_upcall(). */ #define td_startcopy td_endzero @@ -318,6 +320,8 @@ struct thread { const char *td_vnet_lpush; /* (k) Debugging vnet push / pop. */ struct rusage_ext td_rux; /* (t) Internal rusage information. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ + pid_t td_dbg_forked; /* (c) Child pid for debugger. */ + u_int td_vp_reserv; /* (k) Count of reserved vnodes. */ #endif /* __rtems__ */ }; @@ -367,7 +371,7 @@ do { \ #define TDF_NEEDSUSPCHK 0x00008000 /* Thread may need to suspend. */ #define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */ #define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */ -#define TDF_UNUSED18 0x00040000 /* --available-- */ +#define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */ #define TDF_UNUSED19 0x00080000 /* Thread is sleeping on a umtx. */ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ #define TDF_UNUSED21 0x00200000 /* --available-- */ @@ -388,6 +392,10 @@ do { \ #define TDB_SCE 0x00000008 /* Thread performs syscall enter */ #define TDB_SCX 0x00000010 /* Thread performs syscall exit */ #define TDB_EXEC 0x00000020 /* TDB_SCX from exec(2) family */ +#define TDB_FORK 0x00000040 /* TDB_SCX from fork(2) that created new + process */ +#define TDB_STOPATFORK 0x00000080 /* Stop at the return from fork (child + only) */ /* * "Private" flags kept in td_pflags: @@ -400,11 +408,11 @@ do { \ #define TDP_COWINPROGRESS 0x00000010 /* Snapshot copy-on-write in progress. */ #define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */ #define TDP_DEADLKTREAT 0x00000040 /* Lock aquisition - deadlock treatment. */ -#define TDP_UNUSED80 0x00000080 /* available. */ +#define TDP_NOFAULTING 0x00000080 /* Do not handle page faults. */ #define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */ #define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */ #define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */ -#define TDP_UNUSED800 0x00000800 /* available. */ +#define TDP_SYNCIO 0x00000800 /* Local override, disable async i/o. */ #define TDP_SCHED1 0x00001000 /* Reserved for scheduler private use */ #define TDP_SCHED2 0x00002000 /* Reserved for scheduler private use */ #define TDP_SCHED3 0x00004000 /* Reserved for scheduler private use */ @@ -418,6 +426,8 @@ do { \ #define TDP_CALLCHAIN 0x00400000 /* Capture thread's callchain */ #define TDP_IGNSUSP 0x00800000 /* Permission to ignore the MNTK_SUSPEND* */ #define TDP_AUDITREC 0x01000000 /* Audit record pending on thread */ +#define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */ +#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */ /* * Reasons that the current thread can not be run yet. @@ -537,7 +547,7 @@ struct proc { struct thread *p_singlethread;/* (c + j) If single threading this is it */ int p_suspcount; /* (j) Num threads in suspended mode. */ struct thread *p_xthread; /* (c) Trap thread */ - int p_boundary_count;/* (c) Num threads at user boundary */ + int p_boundary_count;/* (j) Num threads at user boundary */ int p_pendingcnt; /* how many signals are pending */ struct itimers *p_itimers; /* (c) POSIX interval timers. */ /* End area that is zeroed on creation. */ @@ -572,7 +582,9 @@ struct proc { STAILQ_HEAD(, ktr_request) p_ktr; /* (o) KTR event queue. */ 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_pwait; /* (*) wait cv for exit/exec. */ + struct cv p_dbgwait; /* (*) wait cv for debugger attach + after fork. */ #endif /* __rtems__ */ }; @@ -589,7 +601,7 @@ struct proc { #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */ #define P_CONTROLT 0x00002 /* Has a controlling terminal. */ #define P_KTHREAD 0x00004 /* Kernel thread (*). */ -#define P_NOLOAD 0x00008 /* Ignore during load avg calculations. */ +#define P_FOLLOWFORK 0x00008 /* Attach parent debugger to children. */ #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */ #define P_PROFIL 0x00020 /* Has started profiling. */ #define P_STOPPROF 0x00040 /* Has thread requesting to stop profiling. */ @@ -610,7 +622,6 @@ struct proc { #define P_SIGEVENT 0x200000 /* Process pending signals changed. */ #define P_SINGLE_BOUNDARY 0x400000 /* Threads should suspend at user boundary. */ #define P_HWPMC 0x800000 /* Process is using HWPMCs */ - #define P_JAILED 0x1000000 /* Process is in jail. */ #define P_INEXEC 0x4000000 /* Process is in execve(). */ #define P_STATCHILD 0x8000000 /* Child process stopped or exited. */ @@ -669,7 +680,6 @@ MALLOC_DECLARE(M_PARGS); MALLOC_DECLARE(M_PGRP); MALLOC_DECLARE(M_SESSION); MALLOC_DECLARE(M_SUBPROC); -MALLOC_DECLARE(M_ZOMBIE); #endif #define FOREACH_PROC_IN_SYSTEM(p) \ @@ -757,6 +767,7 @@ MALLOC_DECLARE(M_ZOMBIE); } while (0) #define _PRELE(p) do { \ PROC_LOCK_ASSERT((p), MA_OWNED); \ + PROC_ASSERT_HELD(p); \ (--(p)->p_lock); \ if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0) \ wakeup(&(p)->p_lock); \ @@ -814,6 +825,21 @@ struct proc *pfind(pid_t); /* Find process by id. */ struct pgrp *pgfind(pid_t); /* Find process group by id. */ struct proc *zpfind(pid_t); /* Find zombie process by id. */ +/* + * pget() flags. + */ +#define PGET_HOLD 0x00001 /* Hold the process. */ +#define PGET_CANSEE 0x00002 /* Check against p_cansee(). */ +#define PGET_CANDEBUG 0x00004 /* Check against p_candebug(). */ +#define PGET_ISCURRENT 0x00008 /* Check that the found process is current. */ +#define PGET_NOTWEXIT 0x00010 /* Check that the process is not in P_WEXIT. */ +#define PGET_NOTINEXEC 0x00020 /* Check that the process is not in P_INEXEC. */ +#define PGET_NOTID 0x00040 /* Do not assume tid if pid > PID_MAX. */ + +#define PGET_WANTREAD (PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT) + +int pget(pid_t pid, int flags, struct proc **pp); + void ast(struct trapframe *framep); struct thread *choosethread(void); int cr_cansignal(struct ucred *cred, struct proc *proc, int signum); @@ -827,9 +853,11 @@ void fork_exit(void (*)(void *, struct trapframe *), void *, struct trapframe *); void fork_return(struct thread *, struct trapframe *); int inferior(struct proc *p); +void kern_yield(int); void kick_proc0(void); int leavepgrp(struct proc *p); int maybe_preempt(struct thread *td); +void maybe_yield(void); void mi_switch(int flags, struct thread *newtd); int p_candebug(struct thread *td, struct proc *p); int p_cansee(struct thread *td, struct proc *p); @@ -852,6 +880,7 @@ void sess_hold(struct session *); void sess_release(struct session *); int setrunnable(struct thread *); void setsugid(struct proc *p); +int should_yield(void); int sigonstack(size_t sp); void sleepinit(void); void stopevent(struct proc *, u_int, u_int); @@ -863,9 +892,6 @@ void cpu_switch(struct thread *, struct thread *, struct mtx *); void cpu_throw(struct thread *, struct thread *) __dead2; void unsleep(struct thread *); void userret(struct thread *, struct trapframe *); -struct syscall_args; -int syscallenter(struct thread *, struct syscall_args *); -void syscallret(struct thread *, int, struct syscall_args *); void cpu_exit(struct thread *); void exit1(struct thread *, int) __dead2; @@ -908,7 +934,27 @@ int thread_unsuspend_one(struct thread *td); void thread_unthread(struct thread *td); void thread_wait(struct proc *p); struct thread *thread_find(struct proc *p, lwpid_t tid); -void thr_exit1(void); + +#ifndef __rtems__ +static __inline int +curthread_pflags_set(int flags) +{ + struct thread *td; + int save; + + td = curthread; + save = ~flags | (td->td_pflags & flags); + td->td_pflags |= flags; + return (save); +} + +static __inline void +curthread_pflags_restore(int save) +{ + + curthread->td_pflags &= save; +} +#endif /* __rtems__ */ #endif /* _KERNEL */ diff --git a/freebsd/sys/sys/queue.h b/freebsd/sys/sys/queue.h index f0bae8d9..274e636c 100644 --- a/freebsd/sys/sys/queue.h +++ b/freebsd/sys/sys/queue.h @@ -99,6 +99,7 @@ * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - * _REMOVE + + + + + * _SWAP + + + + * */ #ifdef QUEUE_MACRO_DEBUG @@ -307,18 +308,18 @@ struct { \ TRASHIT(*oldnext); \ } while (0) -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - #define STAILQ_REMOVE_AFTER(head, elm, field) do { \ if ((STAILQ_NEXT(elm, field) = \ STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if ((STAILQ_FIRST((head)) = \ + STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + #define STAILQ_SWAP(head1, head2, type) do { \ struct type *swap_first = STAILQ_FIRST(head1); \ struct type **swap_last = (head1)->stqh_last; \ diff --git a/freebsd/sys/sys/refcount.h b/freebsd/sys/sys/refcount.h index 7cf4d47b..572a64e1 100644 --- a/freebsd/sys/sys/refcount.h +++ b/freebsd/sys/sys/refcount.h @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#ifndef __SYS_REFCOUNT_HH__ -#define __SYS_REFCOUNT_HH__ +#ifndef __SYS_REFCOUNT_H__ +#define __SYS_REFCOUNT_H__ #include <machine/atomic.h> @@ -73,4 +73,4 @@ refcount_release(volatile u_int *count) return (old == 1); } -#endif /* ! __SYS_REFCOUNT_HH__ */ +#endif /* ! __SYS_REFCOUNT_H__ */ diff --git a/freebsd/sys/sys/rman.h b/freebsd/sys/sys/rman.h index ba06cc04..b34ef37d 100644 --- a/freebsd/sys/sys/rman.h +++ b/freebsd/sys/sys/rman.h @@ -116,7 +116,9 @@ struct rman { TAILQ_HEAD(rman_head, rman); int rman_activate_resource(struct resource *r); +int rman_adjust_resource(struct resource *r, u_long start, u_long end); int rman_await_resource(struct resource *r, int pri, int timo); +int rman_first_free_region(struct rman *rm, u_long *start, u_long *end); bus_space_handle_t rman_get_bushandle(struct resource *); bus_space_tag_t rman_get_bustag(struct resource *); u_long rman_get_end(struct resource *); @@ -130,6 +132,7 @@ int rman_deactivate_resource(struct resource *r); int rman_fini(struct rman *rm); int rman_init(struct rman *rm); int rman_init_from_resource(struct rman *rm, struct resource *r); +int rman_last_free_region(struct rman *rm, u_long *start, u_long *end); uint32_t rman_make_alignment_flags(uint32_t size); int rman_manage_region(struct rman *rm, u_long start, u_long end); int rman_is_region_manager(struct resource *r, struct rman *rm); diff --git a/freebsd/sys/sys/sbuf.h b/freebsd/sys/sys/sbuf.h index ee74ce5b..6f923378 100644 --- a/freebsd/sys/sys/sbuf.h +++ b/freebsd/sys/sys/sbuf.h @@ -33,12 +33,16 @@ #include <rtems/bsd/sys/_types.h> +struct sbuf; +struct sbuf_drain_data; +typedef int (sbuf_drain_func)(void *, const char *, int); + /* * Structure definition */ struct sbuf { char *s_buf; /* storage buffer */ - void *s_unused; /* binary compatibility. */ + struct sbuf_drain *s_drain; /* drain function and data */ int s_size; /* size of storage buffer */ int s_len; /* current length of string */ #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ @@ -69,9 +73,10 @@ int sbuf_printf(struct sbuf *, const char *, ...) int sbuf_vprintf(struct sbuf *, const char *, __va_list) __printflike(2, 0); int sbuf_putc(struct sbuf *, int); +void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *); int sbuf_trim(struct sbuf *); int sbuf_overflowed(struct sbuf *); -void sbuf_finish(struct sbuf *); +int sbuf_finish(struct sbuf *); char *sbuf_data(struct sbuf *); int sbuf_len(struct sbuf *); int sbuf_done(struct sbuf *); diff --git a/freebsd/sys/sys/sdt.h b/freebsd/sys/sys/sdt.h index eeae665c..7d1286b8 100644 --- a/freebsd/sys/sys/sdt.h +++ b/freebsd/sys/sys/sdt.h @@ -31,34 +31,68 @@ #ifndef _SYS_SDT_H #define _SYS_SDT_H -/* Stub these for the time being. */ -#define DTRACE_PROBE(name) -#define DTRACE_PROBE1(name, type1, arg1) -#define DTRACE_PROBE2(name, type1, arg1, type2, arg2) -#define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) -#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) - #ifndef _KERNEL -/* The promise of things to come. Worlds to explore. People to meet. Things to do. */ - -#else +#define _DTRACE_VERSION 1 + +#define DTRACE_PROBE(prov, name) { \ + extern void __dtrace_##prov##___##name(void); \ + __dtrace_##prov##___##name(); \ +} + +#define DTRACE_PROBE1(prov, name, arg1) { \ + extern void __dtrace_##prov##___##name(unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1); \ +} + +#define DTRACE_PROBE2(prov, name, arg1, arg2) { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2); \ +} + +#define DTRACE_PROBE3(prov, name, arg1, arg2, arg3) { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long, unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3); \ +} + +#define DTRACE_PROBE4(prov, name, arg1, arg2, arg3, arg4) { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long, unsigned long, unsigned long); \ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3, \ + (unsigned long)arg4); \ +} + +#define DTRACE_PROBE5(prov, name, arg1, arg2, arg3, arg4, arg5) { \ + extern void __dtrace_##prov##___##name(unsigned long, \ + unsigned long, unsigned long, unsigned long, unsigned long);\ + __dtrace_##prov##___##name((unsigned long)arg1, \ + (unsigned long)arg2, (unsigned long)arg3, \ + (unsigned long)arg4, (unsigned long)arg5); \ +} + +#else /* _KERNEL */ #ifndef KDTRACE_HOOKS #define SDT_PROVIDER_DEFINE(prov) #define SDT_PROVIDER_DECLARE(prov) -#define SDT_PROBE_DEFINE(prov, mod, func, name) +#define SDT_PROBE_DEFINE(prov, mod, func, name, sname) #define SDT_PROBE_DECLARE(prov, mod, func, name) #define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type) -#define SDT_PROBE_DEFINE1(prov, mod, func, name, arg0) -#define SDT_PROBE_DEFINE2(prov, mod, func, name, arg0, arg1) -#define SDT_PROBE_DEFINE3(prov, mod, func, name, arg0, arg1, arg2) -#define SDT_PROBE_DEFINE4(prov, mod, func, name, arg0, arg1, arg2, arg3) -#define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) +#define SDT_PROBE_DEFINE1(prov, mod, func, name, sname, arg0) +#define SDT_PROBE_DEFINE2(prov, mod, func, name, sname, arg0, arg1) +#define SDT_PROBE_DEFINE3(prov, mod, func, name, sname, arg0, arg1, arg2) +#define SDT_PROBE_DEFINE4(prov, mod, func, name, sname, arg0, arg1, arg2, arg3) +#define SDT_PROBE_DEFINE5(prov, mod, func, name, sname, arg0, arg1, arg2, arg3, arg4) +#define SDT_PROBE0(prov, mod, func, name) #define SDT_PROBE1(prov, mod, func, name, arg0) #define SDT_PROBE2(prov, mod, func, name, arg0, arg1) #define SDT_PROBE3(prov, mod, func, name, arg0, arg1, arg2) @@ -135,10 +169,10 @@ struct sdt_provider { #define SDT_PROVIDER_DECLARE(prov) \ extern struct sdt_provider sdt_provider_##prov[1] -#define SDT_PROBE_DEFINE(prov, mod, func, name) \ +#define SDT_PROBE_DEFINE(prov, mod, func, name, sname) \ struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] = { \ { sizeof(struct sdt_probe), 0, sdt_provider_##prov, \ - { NULL, NULL }, { NULL, NULL }, #mod, #func, #name, 0, 0 } \ + { NULL, NULL }, { NULL, NULL }, #mod, #func, #sname, 0, 0 } \ }; \ SYSINIT(sdt_##prov##_##mod##_##func##_##name##_init, SI_SUB_KDTRACE, \ SI_ORDER_SECOND + 1, sdt_probe_register, \ @@ -168,36 +202,38 @@ struct sdt_provider { SI_SUB_KDTRACE, SI_ORDER_SECOND + 2, sdt_argtype_deregister, \ sdt_##prov##_##mod##_##func##_##name##num ) -#define SDT_PROBE_DEFINE1(prov, mod, func, name, arg0) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ +#define SDT_PROBE_DEFINE1(prov, mod, func, name, sname, arg0) \ + SDT_PROBE_DEFINE(prov, mod, func, name, sname); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0) -#define SDT_PROBE_DEFINE2(prov, mod, func, name, arg0, arg1) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ +#define SDT_PROBE_DEFINE2(prov, mod, func, name, sname, arg0, arg1) \ + SDT_PROBE_DEFINE(prov, mod, func, name, sname); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1) -#define SDT_PROBE_DEFINE3(prov, mod, func, name, arg0, arg1, arg2) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ +#define SDT_PROBE_DEFINE3(prov, mod, func, name, sname, arg0, arg1, arg2)\ + SDT_PROBE_DEFINE(prov, mod, func, name, sname); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2) -#define SDT_PROBE_DEFINE4(prov, mod, func, name, arg0, arg1, arg2, arg3) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ +#define SDT_PROBE_DEFINE4(prov, mod, func, name, sname, arg0, arg1, arg2, arg3) \ + SDT_PROBE_DEFINE(prov, mod, func, name, sname); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3) -#define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ +#define SDT_PROBE_DEFINE5(prov, mod, func, name, sname, arg0, arg1, arg2, arg3, arg4) \ + SDT_PROBE_DEFINE(prov, mod, func, name, sname); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4) +#define SDT_PROBE0(prov, mod, func, name) \ + SDT_PROBE(prov, mod, func, name, 0, 0, 0, 0, 0) #define SDT_PROBE1(prov, mod, func, name, arg0) \ SDT_PROBE(prov, mod, func, name, arg0, 0, 0, 0, 0) #define SDT_PROBE2(prov, mod, func, name, arg0, arg1) \ @@ -225,6 +261,10 @@ int sdt_argtype_listall(struct sdt_probe *, sdt_argtype_listall_func_t, void *); int sdt_probe_listall(struct sdt_provider *, sdt_probe_listall_func_t, void *); int sdt_provider_listall(sdt_provider_listall_func_t,void *); +void sdt_register_callbacks(sdt_provider_listall_func_t, void *, + sdt_provider_listall_func_t, void *, sdt_probe_listall_func_t, void *); +void sdt_deregister_callbacks(void); + #endif /* KDTRACE_HOOKS */ #endif /* _KERNEL */ diff --git a/freebsd/sys/sys/selinfo.h b/freebsd/sys/sys/selinfo.h index 39e540f7..bfa445c6 100644 --- a/freebsd/sys/sys/selinfo.h +++ b/freebsd/sys/sys/selinfo.h @@ -55,6 +55,7 @@ struct selinfo { #define SEL_WAITING(si) (!TAILQ_EMPTY(&(si)->si_tdlist)) #ifdef _KERNEL +void seldrain(struct selinfo *sip); void selrecord(struct thread *selector, struct selinfo *sip); void selwakeup(struct selinfo *sip); void selwakeuppri(struct selinfo *sip, int pri); diff --git a/freebsd/sys/sys/socket.h b/freebsd/sys/sys/socket.h index 9481e5c4..2f016b27 100644 --- a/freebsd/sys/sys/socket.h +++ b/freebsd/sys/sys/socket.h @@ -139,6 +139,17 @@ typedef __uid_t uid_t; #define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ #define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ #define SO_SETFIB 0x1014 /* use this FIB to route */ +#define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */ +#define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */ +#endif + +/* + * Space reserved for new socket options added by third-party vendors. + * This range applies to all socket option levels. New socket options + * in FreeBSD should always use an option value less than SO_VENDOR. + */ +#if __BSD_VISIBLE +#define SO_VENDOR 0x80000000 #endif /* @@ -416,7 +427,9 @@ struct sockaddr_storage { #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ #define NET_RT_IFLIST 3 /* survey interface list */ #define NET_RT_IFMALIST 4 /* return multicast address list */ -#define NET_RT_MAXID 5 +#define NET_RT_IFLISTL 5 /* Survey interface list, using 'l'en + * versions of msghdr structs. */ +#define NET_RT_MAXID 6 #define CTL_NET_RT_NAMES { \ { 0, 0 }, \ @@ -424,6 +437,7 @@ struct sockaddr_storage { { "flags", CTLTYPE_STRUCT }, \ { "iflist", CTLTYPE_STRUCT }, \ { "ifmalist", CTLTYPE_STRUCT }, \ + { "iflistl", CTLTYPE_STRUCT }, \ } #endif /* __BSD_VISIBLE */ diff --git a/freebsd/sys/sys/sockio.h b/freebsd/sys/sys/sockio.h index 4c1c4839..89226990 100644 --- a/freebsd/sys/sys/sockio.h +++ b/freebsd/sys/sys/sockio.h @@ -110,6 +110,9 @@ #define SIOCSIFVNET _IOWR('i', 90, struct ifreq) /* move IF jail/vnet */ #define SIOCSIFRVNET _IOWR('i', 91, struct ifreq) /* reclaim vnet IF */ +#define SIOCGIFFIB _IOWR('i', 92, struct ifreq) /* get IF fib */ +#define SIOCSIFFIB _IOW('i', 93, struct ifreq) /* set IF fib */ + #define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific parameters */ #define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific diff --git a/freebsd/sys/sys/sysctl.h b/freebsd/sys/sys/sysctl.h index 16d4d2db..d4f44e64 100644 --- a/freebsd/sys/sys/sysctl.h +++ b/freebsd/sys/sys/sysctl.h @@ -87,6 +87,7 @@ struct ctlname { #define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ #define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) +#define CTLFLAG_DYING 0x00010000 /* oid is being removed */ /* * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. @@ -114,6 +115,8 @@ struct ctlname { #define CTL_AUTO_START 0x100 #ifdef _KERNEL +#include <sys/linker_set.h> + #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \ struct sysctl_req *req @@ -166,7 +169,8 @@ struct sysctl_oid { const char *oid_name; int (*oid_handler)(SYSCTL_HANDLER_ARGS); const char *oid_fmt; - int oid_refcnt; + int16_t oid_refcnt; + uint16_t oid_running; const char *oid_descr; }; @@ -242,13 +246,13 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ static struct sysctl_oid sysctl__##parent##_##name = { \ &sysctl_##parent##_children, { NULL }, nbr, kind, \ - a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ + a1, a2, #name, handler, fmt, 0, 0, __DESCR(descr) }; \ DATA_SET(sysctl_set, sysctl__##parent##_##name) #else /* __rtems__ */ #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ static struct sysctl_oid sysctl__##parent##_##name = { \ &_bsd_sysctl_##parent##_children, { NULL }, nbr, kind, \ - a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ + a1, a2, #name, handler, fmt, 0, 0, __DESCR(descr) }; \ DATA_SET(sysctl_set, sysctl__##parent##_##name) #endif /* __rtems__ */ @@ -516,6 +520,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define KERN_PROC_VMMAP 32 /* VM map entries for process */ #define KERN_PROC_FILEDESC 33 /* File descriptors for process */ #define KERN_PROC_GROUPS 34 /* process groups */ +#define KERN_PROC_OSREL 40 /* osreldate for process binary */ /* * KERN_IPC identifiers @@ -747,6 +752,9 @@ void sysctl_lock(void); void sysctl_unlock(void); int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); +struct sbuf; +struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int, + struct sysctl_req *); #else /* !_KERNEL */ #include <sys/cdefs.h> diff --git a/freebsd/sys/sys/sysproto.h b/freebsd/sys/sys/sysproto.h index a3d54238..c94df43d 100644 --- a/freebsd/sys/sys/sysproto.h +++ b/freebsd/sys/sys/sysproto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/8/sys/kern/syscalls.master 212545 2010-09-13 08:49:08Z kib + * created from FreeBSD: stable/8/sys/kern/syscalls.master 229725 2012-01-06 19:32:39Z jhb */ #ifndef _SYS_SYSPROTO_H_ @@ -1711,6 +1711,17 @@ struct pselect_args { char ts_l_[PADL_(const struct timespec *)]; const struct timespec * ts; char ts_r_[PADR_(const struct timespec *)]; char sm_l_[PADL_(const sigset_t *)]; const sigset_t * sm; char sm_r_[PADR_(const sigset_t *)]; }; +struct posix_fallocate_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; + char len_l_[PADL_(off_t)]; off_t len; char len_r_[PADR_(off_t)]; +}; +struct posix_fadvise_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; + char len_l_[PADL_(off_t)]; off_t len; char len_r_[PADR_(off_t)]; + char advice_l_[PADL_(int)]; int advice; char advice_r_[PADR_(int)]; +}; int nosys(struct thread *, struct nosys_args *); void sys_exit(struct thread *, struct sys_exit_args *); int fork(struct thread *, struct fork_args *); @@ -2072,6 +2083,8 @@ int msgctl(struct thread *, struct msgctl_args *); int shmctl(struct thread *, struct shmctl_args *); int lpathconf(struct thread *, struct lpathconf_args *); int pselect(struct thread *, struct pselect_args *); +int posix_fallocate(struct thread *, struct posix_fallocate_args *); +int posix_fadvise(struct thread *, struct posix_fadvise_args *); #ifdef COMPAT_43 @@ -2747,6 +2760,8 @@ int freebsd7_shmctl(struct thread *, struct freebsd7_shmctl_args *); #define SYS_AUE_shmctl AUE_SHMCTL #define SYS_AUE_lpathconf AUE_LPATHCONF #define SYS_AUE_pselect AUE_SELECT +#define SYS_AUE_posix_fallocate AUE_NULL +#define SYS_AUE_posix_fadvise AUE_NULL #endif /* __rtems__ */ #undef PAD_ diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h index 4d922392..b689998c 100644 --- a/freebsd/sys/sys/systm.h +++ b/freebsd/sys/sys/systm.h @@ -54,6 +54,7 @@ extern int cold; /* nonzero if we are doing a cold boot */ extern int rebooting; /* boot() has been called. */ extern const char *panicstr; /* panic message */ extern char version[]; /* system version */ +extern char compiler_version[]; /* compiler version */ extern char copyright[]; /* system copyright */ extern int kstack_pages; /* number of kernel stack pages */ @@ -125,6 +126,18 @@ enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN }; ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg) /* + * If we have already panic'd and this is the thread that called + * panic(), then don't block on any mutexes but silently succeed. + * Otherwise, the kernel will deadlock since the scheduler isn't + * going to run the thread that holds any lock we need. + */ +#ifndef __rtems__ +#define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched) +#else /* __rtems__ */ +#define SCHEDULER_STOPPED() 0 +#endif /* __rtems__ */ + +/* * XXX the hints declarations are even more misplaced than most declarations * in this file, since they are needed in one file (per arch) and only used * in two files. @@ -166,7 +179,7 @@ int nullop(void); int eopnotsupp(void); int ureadc(int, struct uio *); void hashdestroy(void *, struct malloc_type *, u_long); -void *hashinit(int count, struct malloc_type *type, u_long *hashmark); +void *hashinit(int count, struct malloc_type *type, u_long *hashmask); void *hashinit_flags(int count, struct malloc_type *type, u_long *hashmask, int flags); #define HASH_NOWAIT 0x00000001 @@ -233,8 +246,12 @@ int copyinstr(const void * __restrict udaddr, void * __restrict kaddr, __nonnull(1) __nonnull(2); int copyin(const void * __restrict udaddr, void * __restrict kaddr, size_t len) __nonnull(1) __nonnull(2); +int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, + size_t len) __nonnull(1) __nonnull(2); int copyout(const void * __restrict kaddr, void * __restrict udaddr, size_t len) __nonnull(1) __nonnull(2); +int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, + size_t len) __nonnull(1) __nonnull(2); #else /* __rtems__ */ static inline int __nonnull(1) __nonnull(2) copyinstr(const void * __restrict udaddr, void * __restrict kaddr, @@ -259,6 +276,13 @@ copyin(const void * __restrict udaddr, void * __restrict kaddr, } static inline int __nonnull(1) __nonnull(2) +copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, + size_t len) +{ + return copyin(udaddr, kaddr, len); +} + +static inline int __nonnull(1) __nonnull(2) copyout(const void * __restrict kaddr, void * __restrict udaddr, size_t len) { @@ -266,9 +290,26 @@ copyout(const void * __restrict kaddr, void * __restrict udaddr, return (0); } + +static inline int __nonnull(1) __nonnull(2) +copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, + size_t len) +{ + return copyout(kaddr, udaddr, len); +} #endif /* __rtems__ */ +#ifndef __rtems__ int fubyte(const void *base); +#else /* __rtems__ */ +static inline int +fubyte(const void *base) +{ + const unsigned char *byte_base = base; + + return byte_base[0]; +} +#endif /* __rtems__ */ long fuword(const void *base); int fuword16(void *base); int32_t fuword32(const void *base); @@ -426,48 +467,13 @@ void delete_unrhdr(struct unrhdr *uh); void clean_unrhdr(struct unrhdr *uh); void clean_unrhdrl(struct unrhdr *uh); int alloc_unr(struct unrhdr *uh); +int alloc_unr_specific(struct unrhdr *uh, u_int item); int alloc_unrl(struct unrhdr *uh); void free_unr(struct unrhdr *uh, u_int item); /* - * This is about as magic as it gets. fortune(1) has got similar code - * for reversing bits in a word. Who thinks up this stuff?? - * - * Yes, it does appear to be consistently faster than: - * while (i = ffs(m)) { - * m >>= i; - * bits++; - * } - * and - * while (lsb = (m & -m)) { // This is magic too - * m &= ~lsb; // or: m ^= lsb - * bits++; - * } - * Both of these latter forms do some very strange things on gcc-3.1 with - * -mcpu=pentiumpro and/or -march=pentiumpro and/or -O or -O2. - * There is probably an SSE or MMX popcnt instruction. - * - * I wonder if this should be in libkern? - * - * XXX Stop the presses! Another one: - * static __inline u_int32_t - * popcnt1(u_int32_t v) - * { - * v -= ((v >> 1) & 0x55555555); - * v = (v & 0x33333333) + ((v >> 2) & 0x33333333); - * v = (v + (v >> 4)) & 0x0F0F0F0F; - * return (v * 0x01010101) >> 24; - * } - * The downside is that it has a multiply. With a pentium3 with - * -mcpu=pentiumpro and -march=pentiumpro then gcc-3.1 will use - * an imull, and in that case it is faster. In most other cases - * it appears slightly slower. - * - * Another variant (also from fortune): - * #define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255) - * #define BX_(x) ((x) - (((x)>>1)&0x77777777) \ - * - (((x)>>2)&0x33333333) \ - * - (((x)>>3)&0x11111111)) + * Population count algorithm using SWAR approach + * - "SIMD Within A Register". */ static __inline uint32_t bitcount32(uint32_t x) @@ -481,4 +487,15 @@ bitcount32(uint32_t x) return (x); } +static __inline uint16_t +bitcount16(uint32_t x) +{ + + x = (x & 0x5555) + ((x & 0xaaaa) >> 1); + x = (x & 0x3333) + ((x & 0xcccc) >> 2); + x = (x + (x >> 4)) & 0x0f0f; + x = (x + (x >> 8)) & 0x00ff; + return (x); +} + #endif /* !_SYS_SYSTM_H_ */ diff --git a/freebsd/sys/sys/taskqueue.h b/freebsd/sys/sys/taskqueue.h index bf2e4ee3..6ac22e06 100644 --- a/freebsd/sys/sys/taskqueue.h +++ b/freebsd/sys/sys/taskqueue.h @@ -61,6 +61,12 @@ void taskqueue_block(struct taskqueue *queue); void taskqueue_unblock(struct taskqueue *queue); int taskqueue_member(struct taskqueue *queue, struct thread *td); +#define TASK_INITIALIZER(priority, func, context) \ + { .ta_pending = 0, \ + .ta_priority = (priority), \ + .ta_func = (func), \ + .ta_context = (context) } + /* * Functions for dedicated thread taskqueues */ @@ -94,7 +100,7 @@ static void \ taskqueue_define_##name(void *arg) \ { \ taskqueue_##name = \ - taskqueue_create(#name, M_NOWAIT, (enqueue), (context)); \ + taskqueue_create(#name, M_WAITOK, (enqueue), (context)); \ init; \ } \ \ @@ -118,7 +124,7 @@ static void \ taskqueue_define_##name(void *arg) \ { \ taskqueue_##name = \ - taskqueue_create_fast(#name, M_NOWAIT, (enqueue), \ + taskqueue_create_fast(#name, M_WAITOK, (enqueue), \ (context)); \ init; \ } \ diff --git a/freebsd/sys/sys/un.h b/freebsd/sys/sys/un.h index a858abf4..9db3c6d9 100644 --- a/freebsd/sys/sys/un.h +++ b/freebsd/sys/sys/un.h @@ -53,9 +53,12 @@ struct sockaddr_un { #if __BSD_VISIBLE /* Socket options. */ -#define LOCAL_PEERCRED 0x001 /* retrieve peer credentials */ -#define LOCAL_CREDS 0x002 /* pass credentials to receiver */ -#define LOCAL_CONNWAIT 0x004 /* connects block until accepted */ +#define LOCAL_PEERCRED 1 /* retrieve peer credentials */ +#define LOCAL_CREDS 2 /* pass credentials to receiver */ +#define LOCAL_CONNWAIT 4 /* connects block until accepted */ + +/* Start of reserved space for third-party socket options. */ +#define LOCAL_VENDOR SO_VENDOR #ifndef _KERNEL diff --git a/freebsd/sys/sys/user.h b/freebsd/sys/sys/user.h index 7ca16ad0..01a8e73a 100644 --- a/freebsd/sys/sys/user.h +++ b/freebsd/sys/sys/user.h @@ -151,7 +151,7 @@ struct kinfo_proc { u_int ki_estcpu; /* Time averaged value of ki_cpticks */ u_int ki_slptime; /* Time since last blocked */ u_int ki_swtime; /* Time swapped in or out */ - int ki_spareint1; /* unused (just here for alignment) */ + u_int ki_cow; /* number of copy-on-write faults */ u_int64_t ki_runtime; /* Real time in microsec */ struct timeval ki_start; /* starting time */ struct timeval ki_childtime; /* time used by process children */ @@ -338,6 +338,7 @@ struct kinfo_file { #define KVME_FLAG_COW 0x00000001 #define KVME_FLAG_NEEDS_COPY 0x00000002 #define KVME_FLAG_NOCOREDUMP 0x00000004 +#define KVME_FLAG_SUPER 0x00000008 #if defined(__amd64__) #define KINFO_OVMENTRY_SIZE 1168 |