OpenCBM
|
Internal functions and definitions of the libiec library. More...
#include "iec.h"
Go to the source code of this file.
Data Structures | |
struct | IEC_TIMEOUTS |
Macros | |
#define | PARALLEL_DATA_OFFSET 0 |
#define | PARALLEL_STATUS_OFFSET 1 |
#define | PARALLEL_CONTROL_OFFSET 2 |
#define | PARALLEL_REGISTER_SPAN 3 |
#define | PP_ATN_OUT (Pdx->IecAtnOut) |
The ATN OUT bit. | |
#define | PP_CLK_OUT (Pdx->IecClkOut) |
The CLOCK OUT bit. | |
#define | PP_DATA_OUT (Pdx->IecDataOut) |
The DATA OUT bit. | |
#define | PP_RESET_OUT (Pdx->IecResetOut) |
The RESET OUT bit. | |
#define | PP_LP_IRQ 0x10 |
Bit for allowing interrupts of the LPT. | |
#define | PP_LP_BIDIR 0x20 |
Bit for setting set bidirectional mode of the LPT. | |
#define | PP_ATN_IN (Pdx->IecAtnIn) |
The ATN IN bit. | |
#define | PP_CLK_IN (Pdx->IecClkIn) |
The CLOCK IN bit. | |
#define | PP_DATA_IN (Pdx->IecDataIn) |
The DATA IN bit. | |
#define | PP_RESET_IN (Pdx->IecResetIn) |
The RESET IN bit. | |
#define | PAR_PORT (Pdx->ParPortPortAddress + PARALLEL_DATA_OFFSET) |
#define | IN_PORT (Pdx->ParPortPortAddress + PARALLEL_STATUS_OFFSET) |
#define | OUT_PORT (Pdx->ParPortPortAddress + PARALLEL_CONTROL_OFFSET) |
#define | CBMIEC_SET(_set) do { DBG_ASSERT((_set) != 0); Pdx->IecOutBits|=(_set); WRITE_PORT_UCHAR(OUT_PORT,(UCHAR)(Pdx->IecOutEor ^ Pdx->IecOutBits)); } while (0) |
#define | CBMIEC_RELEASE(_rel) do { DBG_ASSERT((_rel) != 0); Pdx->IecOutBits&=~(_rel); WRITE_PORT_UCHAR(OUT_PORT,(UCHAR)(Pdx->IecOutEor ^ Pdx->IecOutBits)); } while (0) |
#define | CBMIEC_SET_RELEASE(_set, _rel) |
#define | CBMIEC_ARE_OUTPUT_LINES_CORRECT() ( READ_PORT_UCHAR(OUT_PORT) == (UCHAR)(Pdx->IecOutEor ^ Pdx->IecOutBits) ) |
#define | CBMIEC_GET(_line) (((READ_PORT_UCHAR(IN_PORT) ^ Pdx->IecInEor) & _line)==0?1:0) |
#define | READ_PORT_UCHAR(_x_) DbgRp(_x_) |
READ_PORT_UCHAR replacement for debugging. More... | |
#define | WRITE_PORT_UCHAR(_x_, _y_) DbgWp(_x_, _y_) |
WRITE_PORT_UCHAR replacement for debugging. More... | |
Typedefs | |
typedef struct IEC_TIMEOUTS | IEC_TIMEOUTS |
typedef enum cablestate_e | CABLESTATE |
remember in which state the cable is currently | |
Enumerations | |
enum | cablestate_e { CABLESTATE_UNKNOWN, CABLESTATE_ERROR_OCCURRED, CABLESTATE_TESTED, CABLESTATE_SUCCESSFULLY_USED } |
remember in which state the cable is currently More... | |
Functions | |
VOID | DbgWp (IN PUCHAR Port, IN UCHAR Value) |
Write to a port address with debugging output. More... | |
UCHAR | DbgRp (IN PUCHAR Port) |
Read from a port address with debugging output. More... | |
VOID | cbmiec_show_port (UCHAR *s) |
show the value of parallel port lines More... | |
VOID | cbmiec_show_state (IN PDEVICE_EXTENSION Pdx, IN UCHAR *Str) |
Dump the input lines. More... | |
VOID | cbmiec_schedule_timeout (IN ULONG howlong) |
Schedule a timeout. More... | |
VOID | cbmiec_udelay (IN ULONG howlong) |
Wait for a timeout. More... | |
NTSTATUS | cbmiec_i_raw_read (IN PDEVICE_EXTENSION Pdx, OUT UCHAR *buf, ULONG cnt, OUT ULONG *pReceived) |
Read some bytes from the IEC bus. More... | |
NTSTATUS | cbmiec_i_raw_write (PDEVICE_EXTENSION Pdx, const UCHAR *buf, ULONG cnt, ULONG *pSent, BOOLEAN atn, BOOLEAN talk) |
Write some bytes to the IEC bus. More... | |
VOID | cbmiec_block_irq (PDEVICE_EXTENSION Pdx) |
Block all interrupts. More... | |
VOID | cbmiec_release_irq (PDEVICE_EXTENSION Pdx) |
Release the interrupts. More... | |
LONG | cbmiec_i_pp_read_debounced (IN PDEVICE_EXTENSION Pdx) |
Read a byte from the X[M|A]P1541 cable. Make sure to debounce it. More... | |
VOID | cbmiec_setcablestate (PDEVICE_EXTENSION Pdx, CABLESTATE State) |
Set the current state of the cable detection. | |
Variables | |
IEC_TIMEOUTS | libiec_global_timeouts |
#define CBMIEC_ARE_OUTPUT_LINES_CORRECT | ( | ) | ( READ_PORT_UCHAR(OUT_PORT) == (UCHAR)(Pdx->IecOutEor ^ Pdx->IecOutBits) ) |
for the "hibernate workaround": Find out if the status of the control lines is like it should be
Definition at line 72 of file i_iec.h.
Referenced by cbmiec_is_cable_state_wrong().
#define CBMIEC_GET | ( | _line | ) | (((READ_PORT_UCHAR(IN_PORT) ^ Pdx->IecInEor) & _line)==0?1:0) |
get the value of the parallel port
Definition at line 75 of file i_iec.h.
Referenced by cbmiec_check_device(), cbmiec_checkcable(), cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_parallel_burst_read(), cbmiec_parallel_burst_write(), cbmiec_send_byte(), cbmiec_show_state(), and cbmiec_wait_for_listener().
#define CBMIEC_RELEASE | ( | _rel | ) | do { DBG_ASSERT((_rel) != 0); Pdx->IecOutBits&=~(_rel); WRITE_PORT_UCHAR(OUT_PORT,(UCHAR)(Pdx->IecOutEor ^ Pdx->IecOutBits)); } while (0) |
release an output line on the parallel port
Definition at line 66 of file i_iec.h.
Referenced by cbmiec_check_device(), cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_init(), cbmiec_parallel_burst_read(), cbmiec_parallel_burst_write(), cbmiec_pp_write(), cbmiec_release_bus(), cbmiec_reset(), cbmiec_send_byte(), cbmiec_test_irq(), and cbmiec_wait_for_listener().
#define CBMIEC_SET | ( | _set | ) | do { DBG_ASSERT((_set) != 0); Pdx->IecOutBits|=(_set); WRITE_PORT_UCHAR(OUT_PORT,(UCHAR)(Pdx->IecOutEor ^ Pdx->IecOutBits)); } while (0) |
set an output line on the parallel port
Definition at line 64 of file i_iec.h.
Referenced by cbmiec_check_device(), cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_parallel_burst_read(), cbmiec_parallel_burst_write(), cbmiec_pp_read(), cbmiec_reset(), cbmiec_send_byte(), cbmiec_test_irq(), and cbmiec_wait_for_listener().
#define CBMIEC_SET_RELEASE | ( | _set, | |
_rel | |||
) |
set and release an output line on the parallel port (simultaneously)
Definition at line 68 of file i_iec.h.
Referenced by cbmiec_iec_setrelease(), and cbmiec_send_byte().
#define IN_PORT (Pdx->ParPortPortAddress + PARALLEL_STATUS_OFFSET) |
Get the address of the parallel port STATUS register (= the port for input) out of the Pdx info
Definition at line 58 of file i_iec.h.
Referenced by cbmiec_iec_dbg_read(), cbmiec_iec_poll(), cbmiec_iec_wait(), and cbmiec_interrupt().
#define OUT_PORT (Pdx->ParPortPortAddress + PARALLEL_CONTROL_OFFSET) |
Get the address of the parallel port CONTROL register (= the port for output) out of the Pdx info
Definition at line 61 of file i_iec.h.
Referenced by cbmiec_checkcable(), and cbmiec_iec_dbg_write().
#define PAR_PORT (Pdx->ParPortPortAddress + PARALLEL_DATA_OFFSET) |
Get the address of the parallel port DATA register out of the Pdx info
Definition at line 55 of file i_iec.h.
Referenced by cbmiec_i_pp_read_debounced(), cbmiec_pp_read(), and cbmiec_pp_write().
#define PARALLEL_CONTROL_OFFSET 2 |
#define PARALLEL_DATA_OFFSET 0 |
#define PARALLEL_REGISTER_SPAN 3 |
#define PARALLEL_STATUS_OFFSET 1 |
#define READ_PORT_UCHAR | ( | _x_ | ) | DbgRp(_x_) |
READ_PORT_UCHAR replacement for debugging.
<em>x</em> | the port number to read |
Definition at line 211 of file i_iec.h.
Referenced by cbmiec_checkcable(), cbmiec_i_pp_read_debounced(), cbmiec_iec_dbg_read(), cbmiec_iec_poll(), cbmiec_iec_wait(), cbmiec_interrupt(), cbmiec_show_port(), cbmiec_test_irq(), DbgRp(), ParPortSetModeWdm(), and ParPortUnsetModeWdm().
#define WRITE_PORT_UCHAR | ( | _x_, | |
_y_ | |||
) | DbgWp(_x_, _y_) |
WRITE_PORT_UCHAR replacement for debugging.
<em>x</em> | the port number to read |
<em>y</em> | the value to put into that port number |
Definition at line 221 of file i_iec.h.
Referenced by cbmiec_iec_dbg_write(), cbmiec_pp_read(), cbmiec_pp_write(), cbmiec_test_irq(), DbgWp(), and ParPortSetModeNt4().
typedef struct IEC_TIMEOUTS IEC_TIMEOUTS |
The various timeouts of the IEC bus protocol
enum cablestate_e |
VOID cbmiec_block_irq | ( | PDEVICE_EXTENSION | Pdx | ) |
Block all interrupts.
This function blocks all interrupt, thus that we cannot be interrupted while executing some critical things.
This should not be used for big time periods.
Definition at line 94 of file libiec/util.c.
References CLI(), DBG_ASSERT, DBGDO, FUNC_ENTER, and FUNC_LEAVE.
Referenced by cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_send_byte(), and cbmiec_wait_for_listener().
LONG cbmiec_i_pp_read_debounced | ( | IN PDEVICE_EXTENSION | Pdx | ) |
Read a byte from the X[M|A]P1541 cable. Make sure to debounce it.
This function reads a byte from the parallel portion of the X[M|A]P1541 cable. The lines are debounced.
Pdx | Pointer to the device extension. |
Definition at line 39 of file ppread.c.
References DBG_PREFIX, DBG_PRINT, FUNC_ENTER, FUNC_LEAVE_LONG, PAR_PORT, and READ_PORT_UCHAR.
Referenced by cbmiec_pp_read().
NTSTATUS cbmiec_i_raw_read | ( | IN PDEVICE_EXTENSION | Pdx, |
OUT UCHAR * | Buffer, | ||
ULONG | Count, | ||
OUT ULONG * | Received | ||
) |
Read some bytes from the IEC bus.
Pdx | Pointer to the device extension. |
Buffer | Pointer to a buffer where the read bytes are written to. |
Count | Maximum number of characters to read from the bus. |
Received | Pointer to the variable which will hold the read bytes. |
Definition at line 45 of file i_rawread.c.
References CABLESTATE_ERROR_OCCURRED, CABLESTATE_SUCCESSFULLY_USED, cbmiec_block_irq(), cbmiec_checkcable(), CBMIEC_GET, CBMIEC_RELEASE, cbmiec_release_irq(), cbmiec_schedule_timeout(), CBMIEC_SET, cbmiec_setcablestate(), cbmiec_udelay(), DBG_ASSERT, DBG_ERROR, DBG_PREFIX, DBG_SUCCESS, FUNC_ENTER, libiec_global_timeouts, PERF_EVENT_READ_BIT_NO, PERF_EVENT_READ_BYTE, PERF_EVENT_READ_BYTE_NO, PP_CLK_IN, PP_DATA_IN, PP_DATA_OUT, QueueShouldCancelCurrentIrp(), IEC_TIMEOUTS::T_1_RECV_WAIT_CLK_LOW_DATA_READY_GRANU, IEC_TIMEOUTS::T_2_RECV_WAIT_CLK_HIGH_T_NE, IEC_TIMEOUTS::T_2_Times, IEC_TIMEOUTS::T_3_RECV_EOI_RECOGNIZED, IEC_TIMEOUTS::T_4_RECV_WAIT_CLK_HIGH_AFTER_EOI_GRANU, IEC_TIMEOUTS::T_4_Times, IEC_TIMEOUTS::T_5_RECV_BIT_WAIT_CLK_HIGH, IEC_TIMEOUTS::T_5_Times, IEC_TIMEOUTS::T_6_RECV_BIT_WAIT_CLK_LOW, IEC_TIMEOUTS::T_6_Times, and IEC_TIMEOUTS::T_7_RECV_INTER_BYTE_DELAY.
Referenced by cbmiec_raw_read().
NTSTATUS cbmiec_i_raw_write | ( | PDEVICE_EXTENSION | Pdx, |
const UCHAR * | Buffer, | ||
ULONG | Count, | ||
ULONG * | Sent, | ||
BOOLEAN | Atn, | ||
BOOLEAN | Talk | ||
) |
Write some bytes to the IEC bus.
Pdx | Pointer to the device extension. |
Buffer | Pointer to a buffer where the read bytes are written to. |
Count | Maximum number of characters to read from the bus. |
Sent | Pointer to the variable which will hold the number of written bytes. |
Atn | If true: Sent the bytes with set ATN; else, with released ATN |
Talk | If true: A talk command is to be sent (some special care has to be taken at the end of the transmission). |
ATN is released on return of this routine
Definition at line 54 of file i_rawwrite.c.
References CABLESTATE_ERROR_OCCURRED, CABLESTATE_SUCCESSFULLY_USED, cbmiec_block_irq(), cbmiec_checkcable(), CBMIEC_GET, CBMIEC_RELEASE, cbmiec_release_irq(), cbmiec_schedule_timeout(), cbmiec_send_byte(), CBMIEC_SET, cbmiec_setcablestate(), cbmiec_udelay(), cbmiec_wait_for_listener(), DBG_ASSERT, DBG_ERROR, DBG_PREFIX, DBG_SUCCESS, DebugNtStatus(), FUNC_ENTER, libiec_global_timeouts, PERF_EVENT_WRITE_BYTE, PERF_EVENT_WRITE_BYTE_NO, PP_ATN_OUT, PP_CLK_IN, PP_CLK_OUT, PP_DATA_IN, PP_DATA_OUT, QueueShouldCancelCurrentIrp(), IEC_TIMEOUTS::T_10_SEND_BEFORE_1ST_BYTE, IEC_TIMEOUTS::T_11_SEND_BEFORE_BYTE_DELAY, IEC_TIMEOUTS::T_12_SEND_AFTER_BYTE_DELAY, IEC_TIMEOUTS::T_14_SEND_AT_END_DELAY, IEC_TIMEOUTS::T_9_SEND_WAIT_DEVICES_T_AT, and IEC_TIMEOUTS::T_9_Times.
Referenced by cbmiec_close(), cbmiec_listen(), cbmiec_open(), cbmiec_raw_write(), cbmiec_talk(), cbmiec_unlisten(), and cbmiec_untalk().
VOID cbmiec_release_irq | ( | PDEVICE_EXTENSION | Pdx | ) |
Release the interrupts.
This function releases all interrupt, undoing a previous cbmiec_block_irq() call.
Definition at line 118 of file libiec/util.c.
References DBG_ASSERT, DBGDO, FUNC_ENTER, FUNC_LEAVE, and STI().
Referenced by cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_send_byte(), and cbmiec_wait_for_listener().
VOID cbmiec_schedule_timeout | ( | IN ULONG | Howlong | ) |
Schedule a timeout.
This function schedules a timeout. Scheduling means that other threads have the opportunity to use the processor while we're waiting.
Howlong | How long to wait (in us) |
Definition at line 34 of file libiec/util.c.
References FUNC_ENTER, and FUNC_LEAVE.
Referenced by cbmiec_check_device(), cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_iec_wait(), cbmiec_reset(), cbmiec_wait_for_drives_ready(), and cbmiec_wait_for_listener().
VOID cbmiec_show_port | ( | UCHAR * | s | ) |
show the value of parallel port lines
cbmiec_show_port() is used to show the value of the parallel port lines if needed for debugging
s | @@\xrefitem todo 162. |
VOID cbmiec_show_state | ( | IN PDEVICE_EXTENSION | Pdx, |
IN UCHAR * | Str | ||
) |
Dump the input lines.
Pdx | Pointer to the device extension of the driver. |
Str | Caller-supplied pointer to a string to output before the values. |
Definition at line 111 of file sys/libiec/debug.c.
References CBMIEC_GET, DBG_ASSERT, DBG_PREFIX, DBG_SUCCESS, FUNC_DEF, PP_ATN_IN, PP_CLK_IN, and PP_DATA_IN.
VOID cbmiec_udelay | ( | IN ULONG | Howlong | ) |
Wait for a timeout.
This function waits for a timeout. Waiting means that we want to have an exact timing, so don't give away the processor.
Howlong | How long to wait (in us) |
Definition at line 66 of file libiec/util.c.
Referenced by cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_iec_wait(), cbmiec_parallel_burst_read(), cbmiec_parallel_burst_write(), cbmiec_send_byte(), and cbmiec_test_irq().
UCHAR DbgRp | ( | IN PUCHAR | Port | ) |
Read from a port address with debugging output.
Port | The port address to be written. |
Definition at line 85 of file sys/libiec/debug.c.
References cbmiec_show_port(), DBG_PREFIX, FUNC_DEF, and READ_PORT_UCHAR.
VOID DbgWp | ( | IN PUCHAR | Port, |
IN UCHAR | Value | ||
) |
Write to a port address with debugging output.
Port | The port address to be written. |
Value | The value to be written. |
Definition at line 63 of file sys/libiec/debug.c.
References cbmiec_show_port(), DBG_PREFIX, FUNC_DEF, and WRITE_PORT_UCHAR.
IEC_TIMEOUTS libiec_global_timeouts |
timeout values
Definition at line 28 of file libiec/init.c.
Referenced by cbmiec_i_raw_read(), cbmiec_i_raw_write(), cbmiec_iec_wait(), cbmiec_reset(), cbmiec_send_byte(), and cbmiec_wait_for_listener().