OpenCBM
checkdevice.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 1997-2005 Joe Forster <sta(at)c64(dot)org>
8  * Copyright 1997-2005 Wolfgang Moser (http://d81.de)
9  * Copyright 2005 Spiro Trikaliotis
10  *
11  */
12 
24 #include <wdm.h>
25 #include "cbm_driver.h"
26 #include "i_iec.h"
27 
48 NTSTATUS
49 cbmiec_check_device(IN PDEVICE_EXTENSION Pdx, OUT IEC_CHECKDEVICE *CheckDevice)
50 {
51  FUNC_ENTER();
52 
53  DBG_ASSERT(CheckDevice != NULL);
54 
55  do
56  {
58 
59  // wait for the drive to have time to react
61 
62  // assert ATN
64 
65  // now, wait for the drive to have time to react
67 
68  // if DATA is still unset, we have a problem.
69  if (!CBMIEC_GET(PP_DATA_IN))
70  {
71  *CheckDevice = IEC_CHECKDEVICE_NODEVICE;
72  break;
73  }
74 
75  // ok, at least one drive reacted. Now, test releasing ATN:
76 
79 
80  if (!CBMIEC_GET(PP_DATA_IN))
81  *CheckDevice = IEC_CHECKDEVICE_BUSFREE;
82  else
83  *CheckDevice = IEC_CHECKDEVICE_BUSBUSY;
84 
85  } while (FALSE);
86 
88 
89  FUNC_LEAVE_NTSTATUS_CONST(STATUS_SUCCESS);
90 }
#define CBMIEC_GET(_line)
Definition: i_iec.h:75
#define PP_ATN_OUT
The ATN OUT bit.
Definition: i_iec.h:39
#define PP_DATA_OUT
The DATA OUT bit.
Definition: i_iec.h:41
#define PP_RESET_OUT
The RESET OUT bit.
Definition: i_iec.h:42
#define CBMIEC_SET(_set)
Definition: i_iec.h:64
Internal functions and definitions of the libiec library.
VOID cbmiec_schedule_timeout(IN ULONG howlong)
Schedule a timeout.
Definition: libiec/util.c:34
#define DBG_ASSERT(_xxx)
Definition: debug.h:401
enum iec_checkdevice IEC_CHECKDEVICE
#define PP_DATA_IN
The DATA IN bit.
Definition: i_iec.h:51
#define CBMIEC_RELEASE(_rel)
Definition: i_iec.h:66
#define PP_CLK_OUT
The CLOCK OUT bit.
Definition: i_iec.h:40
#define FUNC_ENTER()
Definition: debug.h:347
Definitions for the opencbm driver.
NTSTATUS cbmiec_check_device(IN PDEVICE_EXTENSION Pdx, OUT IEC_CHECKDEVICE *CheckDevice)
Fast IEC drive detection.
Definition: checkdevice.c:49