00001 /* 00002 * This program is free software; you can redistribute it and/or 00003 * modify it under the terms of the GNU General Public License 00004 * as published by the Free Software Foundation; either version 00005 * 2 of the License, or (at your option) any later version. 00006 * 00007 * Copyright 1999-2004 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de> 00008 * Copyright 2001-2004 Spiro Trikaliotis 00009 * 00010 */ 00011 00023 #include <wdm.h> 00024 #include "cbm_driver.h" 00025 #include "i_iec.h" 00026 00045 NTSTATUS 00046 cbmiec_iec_wait(IN PDEVICE_EXTENSION Pdx, IN UCHAR Line, IN UCHAR State, OUT PUCHAR Result) 00047 { 00048 NTSTATUS ntStatus; 00049 UCHAR mask; 00050 ULONG i; 00051 00052 FUNC_ENTER(); 00053 00054 FUNC_PARAM((DBG_PREFIX "line = 0x%02x, state = 0x%02x", Line, State)); 00055 00056 // Find the correct mask for the line which has to be tested 00057 00058 switch (Line) 00059 { 00060 case IEC_LINE_DATA: 00061 mask = PP_DATA_IN; 00062 break; 00063 00064 case IEC_LINE_CLOCK: 00065 mask = PP_CLK_IN; 00066 break; 00067 00068 case IEC_LINE_ATN: 00069 mask = PP_ATN_IN; 00070 break; 00071 00072 default: 00073 FUNC_LEAVE_NTSTATUS_CONST(STATUS_INVALID_PARAMETER); 00074 } 00075 00076 // For which state do we have to wait: Set (= mask) or unset 00077 00078 State = State ? mask : 0; 00079 00080 i = 0; 00081 00082 while ((READ_PORT_UCHAR(IN_PORT) & mask) == State) 00083 { 00084 if(i >= 20) 00085 { 00086 cbmiec_schedule_timeout(libiec_global_timeouts.T_8_IEC_WAIT_LONG_DELAY); 00087 00088 if (QueueShouldCancelCurrentIrp(&Pdx->IrpQueue)) 00089 { 00090 FUNC_LEAVE_NTSTATUS_CONST(STATUS_TIMEOUT); 00091 } 00092 } 00093 else 00094 { 00095 i++; 00096 cbmiec_udelay(libiec_global_timeouts.T_8_IEC_WAIT_SHORT_DELAY); 00097 } 00098 } 00099 00100 ntStatus = cbmiec_iec_poll(Pdx, Result); 00101 FUNC_LEAVE_NTSTATUS(ntStatus); 00102 }
1.4.2