1 #include <minix/drivers.h> 2 3 /* State management variables. */ 4 EXTERN int writing; 5 6 /* Custom states definition. */ 7 #define PR_STATE_WRITE_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 0) 8 #define PR_STATE_IS_CUSTOM(s) ((s) == PR_STATE_WRITE_PROTOCOL_FREE) 9 10 /*===========================================================================* 11 * sef_cb_lu_prepare * 12 *===========================================================================*/ 13 int sef_cb_lu_prepare(int state) 14 { 15 int is_ready; 16 17 /* Check if we are ready for the target state. */ 18 is_ready = FALSE; 19 switch(state) { 20 /* Standard states. */ 21 case SEF_LU_STATE_REQUEST_FREE: 22 is_ready = TRUE; 23 break; 24 25 case SEF_LU_STATE_PROTOCOL_FREE: 26 is_ready = (!writing); 27 break; 28 29 /* Custom states. */ 30 case PR_STATE_WRITE_PROTOCOL_FREE: 31 is_ready = (!writing); 32 break; 33 } 34 35 /* Tell SEF if we are ready. */ 36 return is_ready ? OK : ENOTREADY; 37 } 38 39 /*===========================================================================* 40 * sef_cb_lu_state_isvalid * 41 *===========================================================================*/ 42 int sef_cb_lu_state_isvalid(int state, int UNUSED(flags)) 43 { 44 return SEF_LU_STATE_IS_STANDARD(state) || PR_STATE_IS_CUSTOM(state); 45 } 46 47 /*===========================================================================* 48 * sef_cb_lu_state_dump * 49 *===========================================================================*/ 50 void sef_cb_lu_state_dump(int state) 51 { 52 sef_lu_dprint("printer: live update state = %d\n", state); 53 sef_lu_dprint("printer: writing = %d\n", writing); 54 55 sef_lu_dprint("printer: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n", 56 SEF_LU_STATE_WORK_FREE, TRUE); 57 sef_lu_dprint("printer: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n", 58 SEF_LU_STATE_REQUEST_FREE, TRUE); 59 sef_lu_dprint("printer: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n", 60 SEF_LU_STATE_PROTOCOL_FREE, (!writing)); 61 sef_lu_dprint("printer: PR_STATE_WRITE_PROTOCOL_FREE(%d) reached = %d\n", 62 PR_STATE_WRITE_PROTOCOL_FREE, (!writing)); 63 } 64 65