2 * ckrm_events.h - Class-based Kernel Resource Management (CKRM)
5 * Copyright (C) Hubertus Franke, IBM Corp. 2003,2004
6 * (C) Shailabh Nagar, IBM Corp. 2003
7 * (C) Chandra Seetharaman, IBM Corp. 2003
10 * Provides a base header file including macros and basic data structures.
12 * Latest version, more details at http://ckrm.sf.net
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of version 2.1 of the GNU Lesser General Public License
16 * as published by the Free Software Foundation.
18 * This program is distributed in the hope that it would be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30 * Made modifications to suit the new RBCE module.
32 * Added callbacks_active and surrounding logic. Added task paramter
33 * for all CE callbacks.
35 * New Event callback structure
38 #ifndef _LINUX_CKRM_EVENTS_H
39 #define _LINUX_CKRM_EVENTS_H
44 * Data structure and function to get the list of registered
45 * resource controllers.
49 * CKRM defines a set of events at particular points in the kernel
50 * at which callbacks registered by various class types are called
55 * we distinguish these events types:
57 * (a) CKRM_LATCHABLE_EVENTS
58 * events can be latched for event callbacks by classtypes
60 * (b) CKRM_NONLATACHBLE_EVENTS
61 * events can not be latched but can be used to call classification
63 * (c) event that are used for notification purposes
64 * range: [ CKRM_EVENT_CANNOT_CLASSIFY .. )
69 CKRM_LATCHABLE_EVENTS,
71 CKRM_EVENT_NEWTASK = CKRM_LATCHABLE_EVENTS,
81 CKRM_EVENT_LISTEN_START,
82 CKRM_EVENT_LISTEN_STOP,
87 CKRM_NONLATCHABLE_EVENTS,
89 CKRM_EVENT_RECLASSIFY = CKRM_NONLATCHABLE_EVENTS,
93 CKRM_NOTCLASSIFY_EVENTS,
95 CKRM_EVENT_MANUAL = CKRM_NOTCLASSIFY_EVENTS,
105 * CKRM event callback specification for the classtypes or resource controllers
106 * typically an array is specified using CKRM_EVENT_SPEC terminated with
107 * CKRM_EVENT_SPEC_LAST and then that array is registered using
108 * ckrm_register_event_set.
109 * Individual registration of event_cb is also possible
112 typedef void (*ckrm_event_cb) (void *arg);
114 struct ckrm_hook_cb {
116 struct ckrm_hook_cb *next;
119 struct ckrm_event_spec {
121 struct ckrm_hook_cb cb;
124 #define CKRM_EVENT_SPEC(EV,FCT) { CKRM_EVENT_##EV, \
125 { (ckrm_event_cb)FCT, NULL } }
127 int ckrm_register_event_set(struct ckrm_event_spec especs[]);
128 int ckrm_unregister_event_set(struct ckrm_event_spec especs[]);
129 int ckrm_register_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb);
130 int ckrm_unregister_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb);
132 extern void ckrm_invoke_event_cb_chain(enum ckrm_event ev, void *arg);
134 #define CKRM_DEF_CB(EV,fct) \
135 static inline void ckrm_cb_##fct(void) \
137 ckrm_invoke_event_cb_chain(CKRM_EVENT_##EV,NULL); \
140 #define CKRM_DEF_CB_ARG(EV,fct,argtp) \
141 static inline void ckrm_cb_##fct(argtp arg) \
143 ckrm_invoke_event_cb_chain(CKRM_EVENT_##EV,(void*)arg); \
146 #else /* !CONFIG_CKRM */
148 #define CKRM_DEF_CB(EV,fct) \
149 static inline void ckrm_cb_##fct(void) { }
151 #define CKRM_DEF_CB_ARG(EV,fct,argtp) \
152 static inline void ckrm_cb_##fct(argtp arg) { }
154 #endif /* CONFIG_CKRM */
157 * define the CKRM event functions
161 /* forward declarations for function arguments */
166 CKRM_DEF_CB_ARG(FORK, fork, struct task_struct *);
167 CKRM_DEF_CB_ARG(EXEC, exec, const char *);
168 CKRM_DEF_CB(UID, uid);
169 CKRM_DEF_CB(GID, gid);
170 CKRM_DEF_CB_ARG(XID, xid, struct task_struct *);
171 CKRM_DEF_CB(APPTAG, apptag);
172 CKRM_DEF_CB(LOGIN, login);
173 CKRM_DEF_CB_ARG(USERADD, useradd, struct user_struct *);
174 CKRM_DEF_CB_ARG(USERDEL, userdel, struct user_struct *);
175 CKRM_DEF_CB_ARG(LISTEN_START, listen_start, struct sock *);
176 CKRM_DEF_CB_ARG(LISTEN_STOP, listen_stop, struct sock *);
178 /* some other functions required */
180 extern void ckrm_init(void);
181 extern void ckrm_cb_newtask(struct task_struct *);
182 extern void ckrm_cb_exit(struct task_struct *);
184 #define ckrm_init() do { } while (0)
185 #define ckrm_cb_newtask(x) do { } while (0)
186 #define ckrm_cb_exit(x) do { } while (0)
189 extern int get_exe_path_name(struct task_struct *, char *, int);
191 #endif /* __KERNEL__ */
192 #endif /* _LINUX_CKRM_EVENTS_H */