1 /* Prototypes for System Event Framework (SEF) functions. */
8 /* SEF entry points for system processes. */
9 void sef_startup(void);
10 int sef_receive_status(endpoint_t src
, message
*m_ptr
, int *status_ptr
);
11 endpoint_t
sef_self(void);
12 void sef_cancel(void);
13 void sef_exit(int status
);
14 #define sef_receive(src, m_ptr) sef_receive_status(src, m_ptr, NULL)
18 #define sef_dprint printf
19 #define sef_debug_begin() (void)(NULL)
20 #define sef_debug_end() (void)(NULL)
22 /*===========================================================================*
24 *===========================================================================*/
25 /* What to intercept. */
26 #define INTERCEPT_SEF_INIT_REQUESTS 1
27 #define IS_SEF_INIT_REQUEST(mp) ((mp)->m_type == RS_INIT \
28 && (mp)->m_source == RS_PROC_NR)
30 /* Type definitions. */
32 cp_grant_id_t rproctab_gid
;
34 endpoint_t old_endpoint
;
37 /* Callback type definitions. */
38 typedef int(*sef_cb_init_t
)(int type
, sef_init_info_t
*info
);
39 typedef int(*sef_cb_init_response_t
)(message
*m_ptr
);
41 /* Callback registration helpers. */
42 void sef_setcb_init_fresh(sef_cb_init_t cb
);
43 void sef_setcb_init_lu(sef_cb_init_t cb
);
44 void sef_setcb_init_restart(sef_cb_init_t cb
);
45 void sef_setcb_init_response(sef_cb_init_response_t cb
);
47 /* Predefined callback implementations. */
48 int sef_cb_init_null(int type
, sef_init_info_t
*info
);
49 int sef_cb_init_response_null(message
*m_ptr
);
51 int sef_cb_init_fail(int type
, sef_init_info_t
*info
);
52 int sef_cb_init_reset(int type
, sef_init_info_t
*info
);
53 int sef_cb_init_crash(int type
, sef_init_info_t
*info
);
54 int sef_cb_init_response_rs_reply(message
*m_ptr
);
56 /* Macros for predefined callback implementations. */
57 #define SEF_CB_INIT_FRESH_NULL sef_cb_init_null
58 #define SEF_CB_INIT_LU_NULL sef_cb_init_null
59 #define SEF_CB_INIT_RESTART_NULL sef_cb_init_null
60 #define SEF_CB_INIT_RESPONSE_NULL sef_cb_init_response_null
62 #define SEF_CB_INIT_FRESH_DEFAULT sef_cb_init_null
63 #define SEF_CB_INIT_LU_DEFAULT sef_cb_init_null
64 #define SEF_CB_INIT_RESTART_DEFAULT sef_cb_init_reset
65 #define SEF_CB_INIT_RESPONSE_DEFAULT sef_cb_init_response_rs_reply
68 #define SEF_INIT_FRESH 0 /* init fresh */
69 #define SEF_INIT_LU 1 /* init after live update */
70 #define SEF_INIT_RESTART 2 /* init after restart */
73 #define SEF_INIT_DEBUG_DEFAULT 0
75 #ifndef SEF_INIT_DEBUG
76 #define SEF_INIT_DEBUG SEF_INIT_DEBUG_DEFAULT
79 #define sef_init_dprint sef_dprint
80 #define sef_init_debug_begin sef_debug_begin
81 #define sef_init_debug_end sef_debug_end
83 /*===========================================================================*
85 *===========================================================================*/
86 /* What to intercept. */
87 #define INTERCEPT_SEF_PING_REQUESTS 1
88 #define IS_SEF_PING_REQUEST(mp, status) (is_ipc_notify(status) \
89 && (mp)->m_source == RS_PROC_NR)
91 /* Callback type definitions. */
92 typedef void(*sef_cb_ping_reply_t
)(endpoint_t source
);
94 /* Callback registration helpers. */
95 void sef_setcb_ping_reply(sef_cb_ping_reply_t cb
);
97 /* Predefined callback implementations. */
98 void sef_cb_ping_reply_null(endpoint_t source
);
100 void sef_cb_ping_reply_pong(endpoint_t source
);
102 /* Macros for predefined callback implementations. */
103 #define SEF_CB_PING_REPLY_NULL sef_cb_ping_reply_null
105 #define SEF_CB_PING_REPLY_DEFAULT sef_cb_ping_reply_pong
108 #define SEF_PING_DEBUG_DEFAULT 0
110 #ifndef SEF_PING_DEBUG
111 #define SEF_PING_DEBUG SEF_PING_DEBUG_DEFAULT
114 #define sef_ping_dprint sef_dprint
115 #define sef_ping_debug_begin sef_debug_begin
116 #define sef_ping_debug_end sef_debug_end
118 /*===========================================================================*
120 *===========================================================================*/
121 /* What to intercept. */
122 #define INTERCEPT_SEF_LU_REQUESTS 1
123 #define IS_SEF_LU_REQUEST(mp, status) ((mp)->m_type == RS_LU_PREPARE \
124 && (mp)->m_source == RS_PROC_NR)
126 /* Callback type definitions. */
127 typedef int(*sef_cb_lu_prepare_t
)(int);
128 typedef int(*sef_cb_lu_state_isvalid_t
)(int);
129 typedef void(*sef_cb_lu_state_changed_t
)(int, int);
130 typedef void(*sef_cb_lu_state_dump_t
)(int);
131 typedef int(*sef_cb_lu_state_save_t
)(int);
132 typedef int(*sef_cb_lu_response_t
)(message
*m_ptr
);
134 /* Callback registration helpers. */
135 void sef_setcb_lu_prepare(sef_cb_lu_prepare_t cb
);
136 void sef_setcb_lu_state_isvalid(sef_cb_lu_state_isvalid_t cb
);
137 void sef_setcb_lu_state_changed(sef_cb_lu_state_changed_t cb
);
138 void sef_setcb_lu_state_dump(sef_cb_lu_state_dump_t cb
);
139 void sef_setcb_lu_state_save(sef_cb_lu_state_save_t cb
);
140 void sef_setcb_lu_response(sef_cb_lu_response_t cb
);
142 /* Predefined callback implementations. */
143 int sef_cb_lu_prepare_null(int state
);
144 int sef_cb_lu_state_isvalid_null(int state
);
145 void sef_cb_lu_state_changed_null(int old_state
, int state
);
146 void sef_cb_lu_state_dump_null(int state
);
147 int sef_cb_lu_state_save_null(int state
);
148 int sef_cb_lu_response_null(message
*m_ptr
);
150 int sef_cb_lu_prepare_always_ready(int state
);
151 int sef_cb_lu_prepare_never_ready(int state
);
152 int sef_cb_lu_prepare_crash(int state
);
153 int sef_cb_lu_state_isvalid_standard(int state
);
154 int sef_cb_lu_state_isvalid_workfree(int state
);
155 int sef_cb_lu_response_rs_reply(message
*m_ptr
);
157 /* Macros for predefined callback implementations. */
158 #define SEF_CB_LU_PREPARE_NULL sef_cb_lu_prepare_null
159 #define SEF_CB_LU_STATE_ISVALID_NULL sef_cb_lu_state_isvalid_null
160 #define SEF_CB_LU_STATE_CHANGED_NULL sef_cb_lu_state_changed_null
161 #define SEF_CB_LU_STATE_DUMP_NULL sef_cb_lu_state_dump_null
162 #define SEF_CB_LU_STATE_SAVE_NULL sef_cb_lu_state_save_null
163 #define SEF_CB_LU_RESPONSE_NULL sef_cb_lu_response_null
165 #define SEF_CB_LU_PREPARE_DEFAULT sef_cb_lu_prepare_null
166 #define SEF_CB_LU_STATE_ISVALID_DEFAULT sef_cb_lu_state_isvalid_null
167 #define SEF_CB_LU_STATE_CHANGED_DEFAULT sef_cb_lu_state_changed_null
168 #define SEF_CB_LU_STATE_DUMP_DEFAULT sef_cb_lu_state_dump_null
169 #define SEF_CB_LU_STATE_SAVE_DEFAULT sef_cb_lu_state_save_null
170 #define SEF_CB_LU_RESPONSE_DEFAULT sef_cb_lu_response_rs_reply
172 /* Standard live update states. */
173 #define SEF_LU_STATE_NULL 0 /* null state */
174 #define SEF_LU_STATE_WORK_FREE 1 /* no work in progress */
175 #define SEF_LU_STATE_REQUEST_FREE 2 /* no request in progress */
176 #define SEF_LU_STATE_PROTOCOL_FREE 3 /* no protocol in progress */
177 #define SEF_LU_STATE_CUSTOM_BASE (SEF_LU_STATE_PROTOCOL_FREE+1)
178 #define SEF_LU_STATE_IS_STANDARD(s) ((s) > SEF_LU_STATE_NULL \
179 && (s) < SEF_LU_STATE_CUSTOM_BASE)
182 #define SEF_LU_DEBUG_DEFAULT 1
185 #define SEF_LU_DEBUG SEF_LU_DEBUG_DEFAULT
188 #define sef_lu_dprint sef_dprint
189 #define sef_lu_debug_begin sef_debug_begin
190 #define sef_lu_debug_end sef_debug_end
192 /*===========================================================================*
194 *===========================================================================*/
195 /* What to intercept. */
196 #define INTERCEPT_SEF_SIGNAL_REQUESTS 1
197 #define IS_SEF_SIGNAL_REQUEST(mp, status) \
198 (((mp)->m_type == SIGS_SIGNAL_RECEIVED && (mp)->m_source < INIT_PROC_NR) \
199 || (is_ipc_notify(status) && (mp)->m_source == SYSTEM))
201 /* Callback type definitions. */
202 typedef void(*sef_cb_signal_handler_t
)(int signo
);
203 typedef int(*sef_cb_signal_manager_t
)(endpoint_t target
, int signo
);
204 typedef int(*sef_cb_gcov_t
)(message
*msg
);
206 /* Callback registration helpers. */
207 void sef_setcb_signal_handler(sef_cb_signal_handler_t cb
);
208 void sef_setcb_signal_manager(sef_cb_signal_manager_t cb
);
209 void sef_setcb_gcov(sef_cb_gcov_t cb
);
211 /* Predefined callback implementations. */
212 void sef_cb_signal_handler_null(int signo
);
213 int sef_cb_signal_manager_null(endpoint_t target
, int signo
);
215 void sef_cb_signal_handler_term(int signo
);
216 void sef_cb_signal_handler_posix_default(int signo
);
218 /* Macros for predefined callback implementations. */
219 #define SEF_CB_SIGNAL_HANDLER_NULL sef_cb_signal_handler_null
220 #define SEF_CB_SIGNAL_MANAGER_NULL sef_cb_signal_manager_null
222 #define SEF_CB_SIGNAL_HANDLER_DEFAULT sef_cb_signal_handler_null
223 #define SEF_CB_SIGNAL_MANAGER_DEFAULT sef_cb_signal_manager_null
226 #define SEF_SIGNAL_DEBUG_DEFAULT 0
228 #ifndef SEF_SIGNAL_DEBUG
229 #define SEF_SIGNAL_DEBUG SEF_SIGNAL_DEBUG_DEFAULT
232 #define sef_signal_dprint sef_dprint
233 #define sef_signal_debug_begin sef_debug_begin
234 #define sef_signal_debug_end sef_debug_end
236 /*===========================================================================*
237 * SEF Fault Injection *
238 *===========================================================================*/
239 /* What to intercept. */
240 #define INTERCEPT_SEF_FI_REQUESTS 1
241 #define IS_SEF_FI_REQUEST(mp, status) \
242 (m_ptr->m_type == COMMON_REQ_FI_CTL)
244 /* Fault injection tool support. */
245 #define SEF_FI_ALLOW_EDFI 1
247 #if !defined(USE_LIVEUPDATE)
248 #undef INTERCEPT_SEF_LU_REQUESTS