/*! \brief Write some bytes to the IEC bus \param Pdx Pointer to the device extension. \param Buffer Pointer to a buffer where the read bytes are written to. \param Size Maximum number of characters to read from the bus. \param Written Pointer to the variable which will hold the number of written bytes. \return If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values. ATN is released on return of this routine */ NTSTATUS cbmiec_raw_write(IN PDEVICE_EXTENSION Pdx, IN const PUCHAR Buffer, IN ULONG Size, OUT ULONG *Written) { NTSTATUS ntStatus; #if DBG unsigned i; #endif FUNC_ENTER(); PERF_EVENT_VERBOSE(0x1000, 0); FUNC_PARAM((DBG_PREFIX "Buffer = 0x%p, Size = 0x%04x", Buffer, Size)); #if DBG for (i=0;i<Size;i++) { FUNC_PARAM((DBG_PREFIX " output %2u: 0x%02x '%c'", i, (unsigned int) Buffer[i], (UCHAR) Buffer[i])); } #endif PERF_EVENT_VERBOSE(0x1001, 0); ntStatus = cbmiec_i_raw_write(Pdx, Buffer, Size, Written, 0, 0); PERF_EVENT_VERBOSE(0x1002, 0); FUNC_LEAVE_NTSTATUS(ntStatus); }
/*! \brief Send an UNLISTEN over the IEC bus This function sends an UNLISTEN to the IEC bus. \param Pdx Pointer to the device extension. \return If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values. */ NTSTATUS cbmiec_unlisten(IN PDEVICE_EXTENSION Pdx) { NTSTATUS ntStatus; ULONG sent; UCHAR buffer; FUNC_ENTER(); // send a 0x3F (unlisten) under control of ATN buffer = 0x3f; ntStatus = cbmiec_i_raw_write(Pdx, &buffer, 1, &sent, 1, 0); Pdx->DoNotReleaseBus = FALSE; FUNC_LEAVE_NTSTATUS(ntStatus); }
/*! \brief Send a TALK over the IEC bus This function sends a TALK to the IEC bus. \param Pdx Pointer to the device extension. \param Device Device (primary) address \param Secaddr Secondary address \return If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it returns one of the error status values. */ NTSTATUS cbmiec_talk(IN PDEVICE_EXTENSION Pdx, IN UCHAR Device, IN UCHAR Secaddr) { NTSTATUS ntStatus; ULONG sent; UCHAR buffer[2]; FUNC_ENTER(); FUNC_PARAM((DBG_PREFIX "Device = 0x%02x, Secaddr = 0x%02x", (int)Device, (int)Secaddr)); // send a 0x4x / 0x6y (talk device x, secaddr y) under control of ATN buffer[0] = 0x40 | Device; buffer[1] = 0x60 | Secaddr; ntStatus = cbmiec_i_raw_write(Pdx, buffer, 2, &sent, 1, 1); Pdx->DoNotReleaseBus = TRUE; FUNC_LEAVE_NTSTATUS(ntStatus); }