This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / include / linux / ckrm.h
1 /* ckrm.h - Class-based Kernel Resource Management (CKRM)
2  *
3  * Copyright (C) Hubertus Franke, IBM Corp. 2003,2004
4  *           (C) Shailabh Nagar,  IBM Corp. 2003
5  *           (C) Chandra Seetharaman, IBM Corp. 2003
6  * 
7  * 
8  * Provides a base header file including macros and basic data structures.
9  *
10  * Latest version, more details at http://ckrm.sf.net
11  * 
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  */
18
19 /* Changes
20  *
21  * 28 Aug 2003
22  *        Created.
23  * 06 Nov 2003
24  *        Made modifications to suit the new RBCE module.
25  * 10 Nov 2003
26  *        Added callbacks_active and surrounding logic. Added task paramter
27  *        for all CE callbacks.
28  * 19 Nov 2004
29  *        New Event callback structure
30  */
31
32 #ifndef _LINUX_CKRM_H
33 #define _LINUX_CKRM_H
34
35 #ifdef CONFIG_CKRM
36
37 // Data structure and function to get the list of registered 
38 // resource controllers.
39
40 // #include <linux/sched.h>
41
42 /* CKRM defines a set of events at particular points in the kernel
43  * at which callbacks registered by various class types are called
44  */
45
46 enum ckrm_event {
47         /* we distinguish various events types
48          *
49          * (a) CKRM_LATCHABLE_EVENTS
50          *      events can be latched for event callbacks by classtypes
51          *
52          * (b) CKRM_NONLATACHBLE_EVENTS
53          *     events can not be latched but can be used to call classification
54          * 
55          * (c) event that are used for notification purposes
56          *     range: [ CKRM_EVENT_CANNOT_CLASSIFY .. )
57          */
58
59         /* events (a) */
60
61         CKRM_LATCHABLE_EVENTS,
62
63         CKRM_EVENT_NEWTASK = CKRM_LATCHABLE_EVENTS,
64         CKRM_EVENT_FORK,
65         CKRM_EVENT_EXIT,
66         CKRM_EVENT_EXEC,
67         CKRM_EVENT_UID,
68         CKRM_EVENT_GID,
69         CKRM_EVENT_LOGIN,
70         CKRM_EVENT_USERADD,
71         CKRM_EVENT_USERDEL,
72         CKRM_EVENT_LISTEN_START,
73         CKRM_EVENT_LISTEN_STOP,
74         CKRM_EVENT_APPTAG,
75
76         /* events (b) */
77
78         CKRM_NONLATCHABLE_EVENTS,
79
80         CKRM_EVENT_RECLASSIFY = CKRM_NONLATCHABLE_EVENTS,
81
82         /* events (c) */
83         CKRM_NOTCLASSIFY_EVENTS,
84
85         CKRM_EVENT_MANUAL = CKRM_NOTCLASSIFY_EVENTS,
86         
87         CKRM_NUM_EVENTS
88 };
89 #endif
90
91 #ifdef __KERNEL__
92 #ifdef CONFIG_CKRM
93
94 extern void ckrm_invoke_event_cb_chain(enum ckrm_event ev, void *arg);
95
96 typedef void (*ckrm_event_cb)(void *arg);
97
98 struct ckrm_hook_cb {
99         ckrm_event_cb fct;
100         struct ckrm_hook_cb *next;
101 };
102
103 #define CKRM_DEF_CB(EV,fct)                                     \
104 static inline void ckrm_cb_##fct(void)                          \
105 {                                                               \
106          ckrm_invoke_event_cb_chain(CKRM_EVENT_##EV,NULL);      \
107 }
108
109 #define CKRM_DEF_CB_ARG(EV,fct,argtp)                                   \
110 static inline void ckrm_cb_##fct(argtp arg)                             \
111 {                                                                       \
112          ckrm_invoke_event_cb_chain(CKRM_EVENT_##EV,(void*)arg);        \
113 }
114
115 #else // !CONFIG_CKRM
116
117 #define CKRM_DEF_CB(EV,fct)                     \
118 static inline void ckrm_cb_##fct(void)  { }
119
120 #define CKRM_DEF_CB_ARG(EV,fct,argtp)           \
121 static inline void ckrm_cb_##fct(argtp arg) { }
122
123 #define ckrm_cb_newtask(task_struct)
124 #define ckrm_cb_exit(task_struct)
125 #define ckrm_init()
126
127 #endif // CONFIG_CKRM
128
129 /*-----------------------------------------------------------------
130  *   define the CKRM event functions 
131  *               EVENT          FCT           ARG         
132  *-----------------------------------------------------------------*/
133
134 // types we refer at 
135 struct task_struct;
136 struct sock;
137 struct user_struct;
138
139 CKRM_DEF_CB_ARG( FORK         , fork,         struct task_struct *);
140 CKRM_DEF_CB_ARG( EXEC         , exec,         const char*         );
141 CKRM_DEF_CB    ( UID          , uid                               );
142 CKRM_DEF_CB    ( GID          , gid                               );
143 CKRM_DEF_CB    ( APPTAG       , apptag                            );
144 CKRM_DEF_CB    ( LOGIN        , login                             );
145 CKRM_DEF_CB_ARG( USERADD      , useradd,      struct user_struct *);
146 CKRM_DEF_CB_ARG( USERDEL      , userdel,      struct user_struct *);
147 CKRM_DEF_CB_ARG( LISTEN_START , listen_start, struct sock *       );
148 CKRM_DEF_CB_ARG( LISTEN_STOP  , listen_stop,  struct sock *       );
149
150 #ifdef CONFIG_CKRM
151 // and a few special one's
152 void ckrm_cb_newtask(struct task_struct *);
153 void ckrm_cb_exit(struct task_struct *);
154
155 // some other functions required
156 extern void ckrm_init(void);
157 extern int get_exe_path_name(struct task_struct *, char *, int);
158 #endif // CONFIG_CKRM
159
160 #endif // __KERNEL__
161
162 #endif // _LINUX_CKRM_H