Skip to content

Commit

Permalink
update more headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Mar 19, 2020
1 parent 632db3c commit dbb4ff0
Show file tree
Hide file tree
Showing 57 changed files with 625 additions and 213 deletions.
88 changes: 62 additions & 26 deletions sys/sys/eventhandler.h
Expand Up @@ -24,11 +24,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: stable/10/sys/sys/eventhandler.h 307253 2016-10-14 03:11:31Z sephe $
* $FreeBSD: stable/11/sys/sys/eventhandler.h 331727 2018-03-29 04:41:45Z mjoras $
*/

#ifndef SYS_EVENTHANDLER_H
#define SYS_EVENTHANDLER_H
#ifndef _SYS_EVENTHANDLER_H_
#define _SYS_EVENTHANDLER_H_

#include <sys/lock.h>
#include <sys/ktr.h>
Expand All @@ -52,8 +52,7 @@ struct eventhandler_entry_vimage {

struct eventhandler_list {
char *el_name;
int el_flags;
#define EHL_INITTED (1<<0)
int el_flags; /* Unused. */
u_int el_runcount;
struct mtx el_lock;
TAILQ_ENTRY(eventhandler_list) el_link;
Expand All @@ -73,8 +72,6 @@ typedef struct eventhandler_entry *eventhandler_tag;
struct eventhandler_entry *_ep; \
struct eventhandler_entry_ ## name *_t; \
\
KASSERT((list)->el_flags & EHL_INITTED, \
("eventhandler_invoke: running non-inited list")); \
EHL_LOCK_ASSERT((list), MA_OWNED); \
(list)->el_runcount++; \
KASSERT((list)->el_runcount > 0, \
Expand All @@ -99,10 +96,41 @@ typedef struct eventhandler_entry *eventhandler_tag;
} while (0)

/*
* Slow handlers are entirely dynamic; lists are created
* when entries are added to them, and thus have no concept of "owner",
*
* Slow handlers need to be declared, but do not need to be defined. The
* You can optionally use the EVENTHANDLER_LIST and EVENTHANDLER_DIRECT macros
* to pre-define a symbol for the eventhandler list. This symbol can be used by
* EVENTHANDLER_DIRECT_INVOKE, which has the advantage of not needing to do a
* locked search of the global list of eventhandler lists. At least
* EVENTHANDLER_LIST_DEFINE must be be used for EVENTHANDLER_DIRECT_INVOKE to
* work. EVENTHANDLER_LIST_DECLARE is only needed if the call to
* EVENTHANDLER_DIRECT_INVOKE is in a different compilation unit from
* EVENTHANDLER_LIST_DEFINE. If the events are even relatively high frequency
* it is suggested that you directly define a list for them.
*/
#define EVENTHANDLER_LIST_DECLARE(name) \
extern struct eventhandler_list *_eventhandler_list_ ## name \

#define EVENTHANDLER_LIST_DEFINE(name) \
struct eventhandler_list *_eventhandler_list_ ## name ; \
static void _ehl_init_ ## name (void * ctx __unused) \
{ \
_eventhandler_list_ ## name = eventhandler_create_list(#name); \
} \
SYSINIT(name ## _ehl_init, SI_SUB_EVENTHANDLER, SI_ORDER_ANY, \
_ehl_init_ ## name, NULL); \
struct __hack

#define EVENTHANDLER_DIRECT_INVOKE(name, ...) do { \
struct eventhandler_list *_el; \
\
_el = _eventhandler_list_ ## name ; \
if (!TAILQ_EMPTY(&_el->el_entries)) { \
EHL_LOCK(_el); \
_EVENTHANDLER_INVOKE(name, _el , ## __VA_ARGS__); \
} \
} while (0)

/*
* Event handlers need to be declared, but do not need to be defined. The
* declaration must be in scope wherever the handler is to be invoked.
*/
#define EVENTHANDLER_DECLARE(name, type) \
Expand Down Expand Up @@ -142,14 +170,24 @@ do { \
if ((_el = eventhandler_find_list(#name)) != NULL) \
eventhandler_deregister(_el, tag); \
} while(0)


#define EVENTHANDLER_DEREGISTER_NOWAIT(name, tag) \
do { \
struct eventhandler_list *_el; \
\
if ((_el = eventhandler_find_list(#name)) != NULL) \
eventhandler_deregister_nowait(_el, tag); \
} while(0)

eventhandler_tag eventhandler_register(struct eventhandler_list *list,
const char *name, void *func, void *arg, int priority);
void eventhandler_deregister(struct eventhandler_list *list,
eventhandler_tag tag);
void eventhandler_deregister_nowait(struct eventhandler_list *list,
eventhandler_tag tag);
struct eventhandler_list *eventhandler_find_list(const char *name);
void eventhandler_prune_list(struct eventhandler_list *list);
struct eventhandler_list *eventhandler_create_list(const char *name);

#ifdef VIMAGE
typedef void (*vimage_iterator_func_t)(void *, ...);
Expand Down Expand Up @@ -205,19 +243,6 @@ typedef void (*vfs_unmounted_notify_fn)(void *, struct mount *,
EVENTHANDLER_DECLARE(vfs_mounted, vfs_mounted_notify_fn);
EVENTHANDLER_DECLARE(vfs_unmounted, vfs_unmounted_notify_fn);

/* VLAN state change events */
struct ifnet;
typedef void (*vlan_config_fn)(void *, struct ifnet *, uint16_t);
typedef void (*vlan_unconfig_fn)(void *, struct ifnet *, uint16_t);
EVENTHANDLER_DECLARE(vlan_config, vlan_config_fn);
EVENTHANDLER_DECLARE(vlan_unconfig, vlan_unconfig_fn);

/* BPF attach/detach events */
struct ifnet;
typedef void (*bpf_track_fn)(void *, struct ifnet *, int /* dlt */,
int /* 1 =>'s attach */);
EVENTHANDLER_DECLARE(bpf_track, bpf_track_fn);

/*
* Process events
* process_fork and exit handlers are called without Giant.
Expand Down Expand Up @@ -291,4 +316,15 @@ typedef void (*ada_probe_veto_fn)(void *, struct cam_path *,
struct ata_params *, int *);
EVENTHANDLER_DECLARE(ada_probe_veto, ada_probe_veto_fn);

#endif /* SYS_EVENTHANDLER_H */
/* newbus device events */
enum evhdev_detach {
EVHDEV_DETACH_BEGIN, /* Before detach() is called */
EVHDEV_DETACH_COMPLETE, /* After detach() returns 0 */
EVHDEV_DETACH_FAILED /* After detach() returns err */
};
typedef void (*device_attach_fn)(void *, device_t);
typedef void (*device_detach_fn)(void *, device_t, enum evhdev_detach);
EVENTHANDLER_DECLARE(device_attach, device_attach_fn);
EVENTHANDLER_DECLARE(device_detach, device_detach_fn);

#endif /* _SYS_EVENTHANDLER_H_ */
3 changes: 2 additions & 1 deletion sys/sys/eventvar.h
Expand Up @@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: stable/10/sys/sys/eventvar.h 255527 2013-09-13 19:50:50Z kib $
* $FreeBSD: stable/11/sys/sys/eventvar.h 331722 2018-03-29 02:50:57Z eadler $
*/

#ifndef _SYS_EVENTVAR_H_
Expand Down Expand Up @@ -61,6 +61,7 @@ struct kqueue {
u_long kq_knhashmask; /* size of knhash */
struct klist *kq_knhash; /* hash table for knotes */
struct task kq_task;
struct ucred *kq_cred;
};

#endif /* !_SYS_EVENTVAR_H_ */
16 changes: 8 additions & 8 deletions sys/sys/exec.h
Expand Up @@ -33,7 +33,7 @@
* SUCH DAMAGE.
*
* @(#)exec.h 8.3 (Berkeley) 1/21/94
* $FreeBSD: stable/10/sys/sys/exec.h 295454 2016-02-10 00:08:51Z jhb $
* $FreeBSD: stable/11/sys/sys/exec.h 331722 2018-03-29 02:50:57Z eadler $
*/

#ifndef _SYS_EXEC_H_
Expand All @@ -59,13 +59,6 @@ struct ps_strings {
unsigned int ps_nenvstr; /* the number of environment strings */
};

/*
* Address of ps_strings structure (in user space).
* Prefer the kern.ps_strings or kern.proc.ps_strings sysctls to this constant.
*/
#define PS_STRINGS (USRSTACK - sizeof(struct ps_strings))
#define SPARE_USRSPACE 4096

struct image_params;

struct execsw {
Expand All @@ -78,6 +71,13 @@ struct execsw {
#ifdef _KERNEL
#include <sys/cdefs.h>

/*
* Address of ps_strings structure (in user space).
* Prefer the kern.ps_strings or kern.proc.ps_strings sysctls to this constant.
*/
#define PS_STRINGS (USRSTACK - sizeof(struct ps_strings))
#define SPARE_USRSPACE 4096

int exec_map_first_page(struct image_params *);
void exec_unmap_first_page(struct image_params *);

Expand Down
2 changes: 1 addition & 1 deletion sys/sys/extattr.h
Expand Up @@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: stable/10/sys/sys/extattr.h 248995 2013-04-02 05:30:41Z mdf $
* $FreeBSD: stable/11/sys/sys/extattr.h 331722 2018-03-29 02:50:57Z eadler $
*/
/*
* Developed by the TrustedBSD Project.
Expand Down

0 comments on commit dbb4ff0

Please sign in to comment.