Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

checkdevice.c

Go to the documentation of this file.
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 1997-2005 Joe Forster <sta(at)c64(dot)org>
00008  *  Copyright 1997-2005 Wolfgang Moser <cbm(a)d81(o)de>
00009  *  Copyright      2005 Spiro Trikaliotis
00010  *
00011  */
00012 
00025 #include <wdm.h>
00026 #include "cbm_driver.h"
00027 #include "i_iec.h"
00028 
00049 NTSTATUS
00050 cbmiec_check_device(IN PDEVICE_EXTENSION Pdx, OUT IEC_CHECKDEVICE *CheckDevice)
00051 {
00052     FUNC_ENTER();
00053 
00054     DBG_ASSERT(CheckDevice != NULL);
00055 
00056     do
00057     {
00058         CBMIEC_RELEASE(PP_ATN_OUT | PP_CLK_OUT | PP_DATA_OUT | PP_RESET_OUT);
00059 
00060         // wait for the drive to have time to react
00061         cbmiec_schedule_timeout(100);
00062 
00063         // assert ATN
00064         CBMIEC_SET(PP_ATN_OUT);
00065 
00066         // now, wait for the drive to have time to react
00067         cbmiec_schedule_timeout(100);
00068 
00069         // if DATA is still unset, we have a problem.
00070         if (!CBMIEC_GET(PP_DATA_IN))
00071         {
00072             *CheckDevice = IEC_CHECKDEVICE_NODEVICE;
00073             break;
00074         }
00075 
00076         // ok, at least one drive reacted. Now, test releasing ATN:
00077 
00078         CBMIEC_RELEASE(PP_ATN_OUT);
00079         cbmiec_schedule_timeout(100);
00080 
00081         if (!CBMIEC_GET(PP_DATA_IN))
00082             *CheckDevice = IEC_CHECKDEVICE_BUSFREE;
00083         else
00084             *CheckDevice = IEC_CHECKDEVICE_BUSBUSY;
00085 
00086     } while (FALSE);
00087 
00088     CBMIEC_RELEASE(PP_ATN_OUT | PP_CLK_OUT | PP_DATA_OUT | PP_RESET_OUT);
00089 
00090     FUNC_LEAVE_NTSTATUS_CONST(STATUS_SUCCESS);
00091 }

Generated on Sun Apr 30 18:45:45 2006 for opencbm by  doxygen 1.4.2