dec21140A ethernet driver for virtualpc, contributed by nicolas tittley.
[minix.git] / drivers / rtl8139 / liveupdate.c
blob19e064132edcd8b708711f02567083a714d3fa11
1 #include "rtl8139.h"
3 /* State management variables. */
4 EXTERN re_t re_table[RE_PORT_NR];
6 /* Custom states definition. */
7 #define RL_STATE_READ_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
8 #define RL_STATE_WRITE_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 1)
9 #define RL_STATE_IS_CUSTOM(s) \
10 ((s) >= RL_STATE_READ_PROTOCOL_FREE && (s) <= RL_STATE_WRITE_PROTOCOL_FREE)
12 /* State management helpers. */
13 PRIVATE int is_reading;
14 PRIVATE int is_writing;
15 PRIVATE void load_state_info(void)
17 int i, found_processing;
18 re_t *rep;
20 /* Check if we are reading or writing. */
21 is_reading = FALSE;
22 is_writing = FALSE;
23 found_processing = FALSE;
24 for (i= 0; i<RE_PORT_NR && !found_processing; i++) {
25 rep = &re_table[i];
27 if (rep->re_flags & REF_READING) {
28 is_reading = TRUE;
31 if (rep->re_flags & REF_SEND_AVAIL) {
32 is_writing = TRUE;
35 found_processing = (is_reading && is_writing);
39 /*===========================================================================*
40 * sef_cb_lu_prepare *
41 *===========================================================================*/
42 PUBLIC void sef_cb_lu_prepare(int state)
44 int is_ready;
46 /* Load state information. */
47 load_state_info();
49 /* Check if we are ready for the target state. */
50 is_ready = FALSE;
51 switch(state) {
52 /* Standard states. */
53 case SEF_LU_STATE_REQUEST_FREE:
54 is_ready = TRUE;
55 break;
57 case SEF_LU_STATE_PROTOCOL_FREE:
58 is_ready = (!is_reading && !is_writing);
59 break;
61 /* Custom states. */
62 case RL_STATE_READ_PROTOCOL_FREE:
63 is_ready = (!is_reading);
64 break;
66 case RL_STATE_WRITE_PROTOCOL_FREE:
67 is_ready = (!is_writing);
68 break;
71 /* Tell SEF if we are ready. */
72 if(is_ready) {
73 sef_lu_ready(OK);
77 /*===========================================================================*
78 * sef_cb_lu_state_isvalid *
79 *===========================================================================*/
80 PUBLIC int sef_cb_lu_state_isvalid(int state)
82 return SEF_LU_STATE_IS_STANDARD(state) || RL_STATE_IS_CUSTOM(state);
85 /*===========================================================================*
86 * sef_cb_lu_state_dump *
87 *===========================================================================*/
88 PUBLIC void sef_cb_lu_state_dump(int state)
90 /* Load state information. */
91 load_state_info();
93 sef_lu_dprint("rtl8139: live update state = %d\n", state);
94 sef_lu_dprint("rtl8139: is_reading = %d\n", is_reading);
95 sef_lu_dprint("rtl8139: is_writing = %d\n", is_writing);
97 sef_lu_dprint("rtl8139: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
98 SEF_LU_STATE_WORK_FREE, TRUE);
99 sef_lu_dprint("rtl8139: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
100 SEF_LU_STATE_REQUEST_FREE, TRUE);
101 sef_lu_dprint("rtl8139: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
102 SEF_LU_STATE_PROTOCOL_FREE, (!is_reading && !is_writing));
103 sef_lu_dprint("rtl8139: RL_STATE_READ_PROTOCOL_FREE(%d) reached = %d\n",
104 RL_STATE_READ_PROTOCOL_FREE, (!is_reading));
105 sef_lu_dprint("rtl8139: RL_STATE_WRITE_PROTOCOL_FREE(%d) reached = %d\n",
106 RL_STATE_WRITE_PROTOCOL_FREE, (!is_writing));