25 #define PP_XA_ATN_OUT 0x01
26 #define PP_XA_CLK_OUT 0x02
27 #define PP_XA_DATA_OUT 0x04
28 #define PP_XA_RESET_OUT 0x08
29 #define PP_XA_EOR_OUT 0xcb
31 #define PP_XA_ATN_IN 0x10
32 #define PP_XA_CLK_IN 0x20
33 #define PP_XA_DATA_IN 0x40
34 #define PP_XA_RESET_IN 0x80
35 #define PP_XA_EOR_IN 0x80
40 #define PP_XM_ATN_OUT PP_XA_ATN_OUT
41 #define PP_XM_CLK_OUT PP_XA_CLK_OUT
42 #define PP_XM_DATA_OUT PP_XA_DATA_OUT
43 #define PP_XM_RESET_OUT PP_XA_RESET_OUT
44 #define PP_XM_EOR_OUT 0xc4
46 #define PP_XM_ATN_IN PP_XA_ATN_IN
47 #define PP_XM_CLK_IN PP_XA_CLK_IN
48 #define PP_XM_DATA_IN PP_XA_DATA_IN
49 #define PP_XM_RESET_IN PP_XA_RESET_IN
50 #define PP_XM_EOR_IN PP_XA_EOR_IN
54 #define PP_XE_ATN_OUT PP_XM_ATN_OUT
55 #define PP_XE_CLK_OUT PP_XM_CLK_OUT
56 #define PP_XE_DATA_OUT PP_XM_RESET_OUT
57 #define PP_XE_RESET_OUT PP_XM_DATA_OUT
58 #define PP_XE_EOR_OUT PP_XM_EOR_OUT
60 #define PP_XE_ATN_IN PP_XM_ATN_IN
61 #define PP_XE_CLK_IN PP_XM_CLK_IN
62 #define PP_XE_DATA_IN PP_XM_RESET_IN
63 #define PP_XE_RESET_IN PP_XM_DATA_IN
64 #define PP_XE_EOR_IN PP_XM_EOR_IN
76 cbmiec_set_cablevalues(IN PDEVICE_EXTENSION Pdx)
80 switch (Pdx->IecCable)
82 case IEC_CABLETYPE_XM:
97 case IEC_CABLETYPE_XA:
112 case IEC_CABLETYPE_XE:
113 DBG_CABLE((
DBG_PREFIX "************ XE1541 ***************"));
129 DBG_CABLE((
DBG_PREFIX "***************************************"));
130 DBG_CABLE((
DBG_PREFIX "******************* DEFAULT? **********"));
131 DBG_CABLE((
DBG_PREFIX "***************************************"));
140 DBG_CABLE((
DBG_PREFIX "IecAtnOut = %02x IecAtnIn = %02x", Pdx->IecAtnOut, Pdx->IecAtnIn));
141 DBG_CABLE((
DBG_PREFIX "IecClkOut = %02x IecClkIn = %02x", Pdx->IecClkOut, Pdx->IecClkIn));
142 DBG_CABLE((
DBG_PREFIX "IecDataOut = %02x IecDataIn = %02x", Pdx->IecDataOut, Pdx->IecDataIn));
143 DBG_CABLE((
DBG_PREFIX "IecResetOut = %02x IecResetIn = %02x", Pdx->IecResetOut, Pdx->IecResetIn));
144 DBG_CABLE((
DBG_PREFIX "EOR Out = %02x EOR In = %02x - outbits = %02x", Pdx->IecOutEor,
145 Pdx->IecInEor, Pdx->IecOutBits));
156 #define READ(_x) ((((READ_PORT_UCHAR(OUT_PORT) ^ Pdx->IecOutEor)) & (_x)) ? 1 : 0)
170 DBG_CABLE((DBG_PREFIX "############ ATN OUT = %u, CLOCK OUT = %u, DATA OUT = %u, RESET OUT = %u", \
171 READ(PP_ATN_OUT), READ(PP_CLK_OUT), READ(PP_DATA_OUT), READ(PP_RESET_OUT) )); \
173 DBG_CABLE((DBG_PREFIX "############ ATN IN = %u, CLOCK IN = %u, DATA IN = %u, RESET IN = %u", \
174 CBMIEC_GET(PP_ATN_IN), CBMIEC_GET(PP_CLK_IN), CBMIEC_GET(PP_DATA_IN), CBMIEC_GET(PP_RESET_IN) ));
192 cbmiec_testcable(PDEVICE_EXTENSION Pdx)
194 NTSTATUS ntStatus = STATUS_PORT_DISCONNECTED;
203 DBG_CABLE((
DBG_PREFIX "############ Status: out: $%02x, in: $%02x ($%02x ^ $%02x)",
215 DBG_CABLE((
DBG_PREFIX "RESET does not follow"));
221 DBG_CABLE((
DBG_PREFIX "ATN does not follow"));
227 DBG_CABLE((
DBG_PREFIX "DATA does not follow"));
233 DBG_CABLE((
DBG_PREFIX "CLOCK does not follow"));
238 if (Pdx->DoNotReleaseBus)
240 DBG_CABLE((
DBG_PREFIX "Pdx->DoNotReleaseBus set, skipping extra tests."));
242 ntStatus = STATUS_SUCCESS;
251 DBG_CABLE((
DBG_PREFIX " --- Release all lines" ));
254 DBG_CABLE((
DBG_PREFIX " --- Release all lines - 1" ));
261 DBG_CABLE((
DBG_PREFIX "RESET is set, but it should not"));
267 DBG_CABLE((
DBG_PREFIX "ATN is set, but it should not"));
273 DBG_CABLE((
DBG_PREFIX "DATA is set, but it should not"));
279 DBG_CABLE((
DBG_PREFIX "CLOCK is set, but it should not"));
292 DBG_CABLE((
DBG_PREFIX "RESET is reacting to ATN - most probably, it is an XE1541 cable!"));
293 Pdx->IecCable = IEC_CABLETYPE_XE;
299 DBG_CABLE((
DBG_PREFIX "DATA does not react to ATN."));
310 ntStatus = STATUS_SUCCESS;
316 FUNC_LEAVE_NTSTATUS(ntStatus);
336 NTSTATUS ntStatus = STATUS_SUCCESS;
337 const wchar_t *msgAuto = L
"";
338 const wchar_t *msgCable;
344 DBG_CABLE((
DBG_PREFIX "IecCableUserSet = %d, IecCable = %d", Pdx->IecCableUserSet, Pdx->IecCable));
356 switch (Pdx->IecCableUserSet)
358 case IEC_CABLETYPE_XE:
361 case IEC_CABLETYPE_XM:
364 case IEC_CABLETYPE_XA:
370 iecCableType = Pdx->IecCableUserSet;
374 cbmiec_set_cablevalues(Pdx);
380 iecCableType = (in != out) ? IEC_CABLETYPE_XA : IEC_CABLETYPE_XM;
381 msgAuto = L
" (auto)";
391 if (iecCableType != Pdx->IecCable)
394 Pdx->DoNotReleaseBus = FALSE;
409 Pdx->IecCable = iecCableType;
412 cbmiec_set_cablevalues(Pdx);
414 switch (Pdx->IecCable)
416 case IEC_CABLETYPE_XE:
421 case IEC_CABLETYPE_XM:
422 msgCable = L
"passive (XM1541)";
425 case IEC_CABLETYPE_XA:
426 msgCable = L
"active (XA1541)";
435 ntStatus = cbmiec_testcable(Pdx);
437 if (NT_SUCCESS(ntStatus))
439 const wchar_t *msgExtra = L
"";
441 if (Pdx->IecCable == IEC_CABLETYPE_XE)
445 msgCable = L
"passive (XE1541)";
447 msgExtra = L
" (THIS IS NOT SUPPORTED YET!)";
449 cbmiec_set_cablevalues(Pdx);
453 msgCable, msgAuto, msgExtra));
456 (Pdx->IecCable == IEC_CABLETYPE_XE) ? CBM_IEC_INIT_XE1541 : CBM_IEC_INIT,
464 "used is really a %ws cable%ws",
483 DBG_CABLE((
DBG_PREFIX "*********************" ));
484 DBG_CABLE((
DBG_PREFIX "end cbmiec_checkcable" ));
485 DBG_CABLE((
DBG_PREFIX "*********************" ));
487 FUNC_LEAVE_NTSTATUS(ntStatus);
498 Pdx->IecCableState = State;
enum cablestate_e CABLESTATE
@@@
#define CBMIEC_GET(_line)
#define PP_XA_RESET_IN
@@@
#define PP_ATN_OUT
The ATN OUT bit.
#define PP_XE_RESET_OUT
@@@
NTSTATUS cbmiec_checkcable(PDEVICE_EXTENSION Pdx)
Determine the type of cable (XA1541/XM1541) on the IEC bus.
#define PP_XM_RESET_OUT
@@@
#define LogErrorString(_Fdo_, _UniqueErrorValue_, _String1_, _String2_)
#define PP_DATA_OUT
The DATA OUT bit.
#define PP_XE_RESET_IN
@@@
#define PP_CLK_IN
The CLOCK IN bit.
enum iec_cabletype IEC_CABLETYPE
#define PP_RESET_OUT
The RESET OUT bit.
#define PP_XM_DATA_OUT
@@@
BOOLEAN cbmiec_is_cable_state_wrong(PDEVICE_EXTENSION Pdx)
@@@
Internal functions and definitions of the libiec library.
VOID cbmiec_schedule_timeout(IN ULONG howlong)
Schedule a timeout.
VOID cbmiec_setcablestate(PDEVICE_EXTENSION Pdx, CABLESTATE State)
Set the current state of the cable detection.
#define CBMIEC_ARE_OUTPUT_LINES_CORRECT()
#define PP_DATA_IN
The DATA IN bit.
#define DBG_SUCCESS(_xxx)
#define CBMIEC_RELEASE(_rel)
#define PP_XE_DATA_OUT
@@@
#define PP_CLK_OUT
The CLOCK OUT bit.
#define PP_XM_RESET_IN
@@@
#define PP_RESET_IN
The RESET IN bit.
#define PP_ATN_IN
The ATN IN bit.
Definitions for the opencbm driver.
#define PP_XA_DATA_OUT
@@@
NTSTATUS cbmiec_wait_for_drives_ready(IN PDEVICE_EXTENSION Pdx)
Wait for the drives to become ready after a RESET.
#define PP_XA_RESET_OUT
@@@
#define READ_PORT_UCHAR(_x_)
READ_PORT_UCHAR replacement for debugging.