forget difference between big and small commands - obsolete with vm.
[minix.git] / drivers / log / liveupdate.c
blob793b415d776ca1126dd5e2332d83454a23b0a7ec
1 #include "log.h"
3 /* State management variables. */
4 #define NR_DEVS 1 /* number of minor devices */
5 EXTERN struct logdevice logdevices[NR_DEVS];
7 /* State management helpers. */
8 PRIVATE int is_read_pending;
9 PRIVATE int is_select_callback_pending;
10 PRIVATE void load_state_info(void)
12 int i, found_pending;
13 struct logdevice *log;
15 /* Check if reads or select callbacks are pending. */
16 is_read_pending = FALSE;
17 is_select_callback_pending = FALSE;
18 found_pending = FALSE;
19 for (i = 0; i < NR_DEVS && !found_pending; i++) {
20 log = &logdevices[i];
21 if(log->log_proc_nr) {
22 is_read_pending = TRUE;
24 if(log->log_selected) {
25 is_select_callback_pending = TRUE;
28 found_pending = (is_read_pending && is_select_callback_pending);
32 /* Custom states definition. */
33 #define LOG_STATE_SELECT_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
34 #define LOG_STATE_IS_CUSTOM(s) ((s) == LOG_STATE_SELECT_PROTOCOL_FREE)
36 /*===========================================================================*
37 * sef_cb_lu_prepare *
38 *===========================================================================*/
39 PUBLIC void sef_cb_lu_prepare(int state)
41 int is_ready;
43 /* Load state information. */
44 load_state_info();
46 /* Check if we are ready for the target state. */
47 is_ready = FALSE;
48 switch(state) {
49 /* Standard states. */
50 case SEF_LU_STATE_REQUEST_FREE:
51 is_ready = (!is_read_pending);
52 break;
54 case SEF_LU_STATE_PROTOCOL_FREE:
55 is_ready = (!is_read_pending && !is_select_callback_pending);
56 break;
58 /* Custom states. */
59 case LOG_STATE_SELECT_PROTOCOL_FREE:
60 is_ready = (!is_select_callback_pending);
61 break;
64 /* Tell SEF if we are ready. */
65 if(is_ready) {
66 sef_lu_ready(OK);
70 /*===========================================================================*
71 * sef_cb_lu_state_isvalid *
72 *===========================================================================*/
73 PUBLIC int sef_cb_lu_state_isvalid(int state)
75 return SEF_LU_STATE_IS_STANDARD(state) || LOG_STATE_IS_CUSTOM(state);
78 /*===========================================================================*
79 * sef_cb_lu_state_dump *
80 *===========================================================================*/
81 PUBLIC void sef_cb_lu_state_dump(int state)
83 /* Load state information. */
84 load_state_info();
86 sef_lu_dprint("log: live update state = %d\n", state);
87 sef_lu_dprint("log: is_read_pending = %d\n", is_read_pending);
88 sef_lu_dprint("log: is_select_callback_pending = %d\n",
89 is_select_callback_pending);
91 sef_lu_dprint("log: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
92 SEF_LU_STATE_WORK_FREE, TRUE);
93 sef_lu_dprint("log: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
94 SEF_LU_STATE_REQUEST_FREE, (!is_read_pending));
95 sef_lu_dprint("log: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
96 SEF_LU_STATE_PROTOCOL_FREE, (!is_read_pending
97 && !is_select_callback_pending));
98 sef_lu_dprint("log: LOG_STATE_SELECT_PROTOCOL_FREE(%d) reached = %d\n",
99 LOG_STATE_SELECT_PROTOCOL_FREE, (!is_select_callback_pending));