OpenCBM
reset.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 1999-2004 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8  * Copyright 2001-2004 Spiro Trikaliotis
9  *
10  */
11 
22 #include <wdm.h>
23 #include "cbm_driver.h"
24 #include "i_iec.h"
25 
38 NTSTATUS
39 cbmiec_wait_for_drives_ready(IN PDEVICE_EXTENSION Pdx)
40 {
41  int i=1;
42  NTSTATUS ntStatus = STATUS_TIMEOUT;
43 
44  FUNC_ENTER();
45 
46  while (1) {
47  IEC_CHECKDEVICE check_device;
48 
49  cbmiec_check_device(Pdx, &check_device);
50 
51 #if 0
52  switch (check_device)
53  {
55  DBG_PRINT((DBG_PREFIX "%u: Bus is free!", i));
56  break;
57 
59  DBG_PRINT((DBG_PREFIX "%u: Bus is busy.", i));
60  break;
61 
63  DBG_PRINT((DBG_PREFIX "%u: No device.", i));
64  break;
65 
66  default:
67  DBG_PRINT((DBG_PREFIX "%u: UNKNOWN", i));
68  break;
69  }
70 #endif
71 
72  if (check_device == IEC_CHECKDEVICE_BUSFREE)
73  {
74  ntStatus = STATUS_SUCCESS;
75  break;
76  }
77 
78  ++i;
79 
80  if (i == 1000)
81  {
82  DBG_PRINT((DBG_PREFIX "Quiting because i has reached %u", i));
83  break;
84  }
86  }
87 
88  FUNC_LEAVE_NTSTATUS(ntStatus);
89 }
90 
102 NTSTATUS
103 cbmiec_reset(IN PDEVICE_EXTENSION Pdx)
104 {
105  FUNC_ENTER();
106 
108 
112 
113  DBG_SUCCESS((DBG_PREFIX "sleeping after RESET..."));
114 
115 /*
116  cbmiec_schedule_timeout(libiec_global_timeouts.T_afterreset);
117  CBMIEC_SET(PP_CLK_OUT);
118 */
119  FUNC_LEAVE_NTSTATUS(cbmiec_wait_for_drives_ready(Pdx));
120 }
IEC_TIMEOUTS libiec_global_timeouts
Definition: libiec/init.c:28
#define PP_ATN_OUT
The ATN OUT bit.
Definition: i_iec.h:39
NTSTATUS cbmiec_reset(IN PDEVICE_EXTENSION Pdx)
Send a RESET to the IEC bus.
Definition: reset.c:103
#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
ULONG T_holdreset
= 100 us: How long is a RESET being held?
Definition: i_iec.h:83
NTSTATUS cbmiec_check_device(IN PDEVICE_EXTENSION Pdx, OUT IEC_CHECKDEVICE *CheckDevice)
Fast IEC drive detection.
Definition: checkdevice.c:49
#define CBMIEC_SET(_set)
Definition: i_iec.h:64
Internal functions and definitions of the libiec library.
#define PP_LP_BIDIR
Bit for setting set bidirectional mode of the LPT.
Definition: i_iec.h:46
#define PP_LP_IRQ
Bit for allowing interrupts of the LPT.
Definition: i_iec.h:45
VOID cbmiec_schedule_timeout(IN ULONG howlong)
Schedule a timeout.
Definition: libiec/util.c:34
enum iec_checkdevice IEC_CHECKDEVICE
#define DBG_SUCCESS(_xxx)
Definition: debug.h:393
#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.
#define DBG_PREFIX
Definition: debug.h:320
NTSTATUS cbmiec_wait_for_drives_ready(IN PDEVICE_EXTENSION Pdx)
Wait for the drives to become ready after a RESET.
Definition: reset.c:39
#define DBG_PRINT(_xxx)
Definition: debug.h:403