32 #define DBG_PROGNAME "OPENCBM.DLL"
35 #define DBG_IS_DEBUG_C
49 #define OPENCBM_PLUGIN
75 fastschedule_start(
void)
79 if (timeBeginPeriod(1) != TIMERR_NOERROR)
93 fastschedule_stop(
void)
97 if (timeEndPeriod(1) != TIMERR_NOERROR)
131 DllMain(IN HANDLE Module, IN DWORD Reason, IN LPVOID Reserved)
133 static BOOL bIsOpen = FALSE;
134 BOOLEAN Status = TRUE;
140 if (Reason == DLL_PROCESS_ATTACH)
162 case DLL_PROCESS_ATTACH:
190 fastschedule_start();
194 case DLL_PROCESS_DETACH:
326 OVERLAPPED overlapped;
372 DWORD bytesToRead = Count;
375 OVERLAPPED overlapped;
431 returnValue =
cbm_ioctl(HandleDevice,
CBMCTRL(LISTEN), ¶meter,
sizeof(parameter), NULL, 0)
471 returnValue =
cbm_ioctl(HandleDevice,
CBMCTRL(TALK), ¶meter,
sizeof(parameter), NULL, 0)
509 if (
cbm_ioctl(HandleDevice,
CBMCTRL(OPEN), ¶meter,
sizeof(parameter), NULL, 0))
554 cbm_ioctl(HandleDevice,
CBMCTRL(CLOSE), ¶meter,
sizeof(parameter), NULL, 0)
587 returnValue =
cbm_ioctl(HandleDevice,
CBMCTRL(UNLISTEN), NULL, 0, NULL, 0) ? 0 : 1;
619 returnValue =
cbm_ioctl(HandleDevice,
CBMCTRL(UNTALK), NULL, 0, NULL, 0) ? 0 : 1;
652 cbm_ioctl(HandleDevice,
CBMCTRL(GET_EOI), NULL, 0, &result,
sizeof(result));
679 returnValue =
cbm_ioctl(HandleDevice,
CBMCTRL(CLEAR_EOI), NULL, 0, NULL, 0);
717 returnValue =
cbm_ioctl(HandleDevice,
CBMCTRL(RESET), NULL, 0, NULL, 0) ? 0 : 1;
754 cbm_ioctl(HandleDevice,
CBMCTRL(PP_READ), NULL, 0, &result,
sizeof(result));
789 parameter.
Byte = Byte;
791 cbm_ioctl(HandleDevice,
CBMCTRL(PP_WRITE), ¶meter,
sizeof(parameter), NULL, 0);
824 cbm_ioctl(HandleDevice,
CBMCTRL(IEC_POLL), NULL, 0, &result,
sizeof(result));
855 parameter.
Line = (UCHAR) Line;
857 cbm_ioctl(HandleDevice,
CBMCTRL(IEC_SET), ¶meter,
sizeof(parameter), NULL, 0);
887 parameter.
Line = (UCHAR) Line;
889 cbm_ioctl(HandleDevice,
CBMCTRL(IEC_RELEASE), ¶meter,
sizeof(parameter), NULL, 0);
928 parameter.
State = (UCHAR) Set;
929 parameter.
Line = (UCHAR) Release;
931 cbm_ioctl(HandleDevice,
CBMCTRL(IEC_SETRELEASE), ¶meter,
sizeof(parameter), NULL, 0);
970 parameter.
Line = (UCHAR) Line;
971 parameter.
State = (UCHAR) State;
974 ¶meter,
sizeof(parameter),
975 &result,
sizeof(result));
1029 int returnValue = -1;
1033 if (
cbm_ioctl(HandleDevice,
CBMCTRL(IEC_DBG_READ), NULL, 0, &result,
sizeof(result)) ) {
1034 returnValue = result.
Value;
1073 int returnValue = -1;
1077 parameter.
Value = Value;
1079 if (
cbm_ioctl(HandleDevice,
CBMCTRL(IEC_DBG_WRITE), ¶meter,
sizeof(parameter), NULL, 0) ) {
void CBMAPIDECL opencbm_plugin_iec_release(CBM_FILE HandleDevice, int Line)
Deactivate a line on the IEC serial bus.
#define FUNC_LEAVE_UCHAR(_xxx)
void cbm_get_debugging_flags(const char *ModuleName)
Set the debugging flags.
int CBMAPIDECL opencbm_plugin_open(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Open a file on the IEC serial bus.
BOOL WINAPI DllMain(IN HANDLE Module, IN DWORD Reason, IN LPVOID Reserved)
DLL initialization und unloading.
#define FUNC_LEAVE_INT(_xxx)
VOID WaitForIoCompletionCancelAll(VOID)
Cancel any running WaitForIoCompletion()
Define makros for debugging purposes.
int CBMAPIDECL opencbm_plugin_close(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Close a file on the IEC serial bus.
VOID WaitForIoCompletionInit(VOID)
Initialize WaitForIoCompletion()
void CBMAPIDECL opencbm_plugin_iec_set(CBM_FILE HandleDevice, int Line)
Activate a line on the IEC serial bus.
int CBMAPIDECL opencbm_plugin_iec_dbg_write(CBM_FILE HandleDevice, unsigned char Value)
Write a byte to the parallel port output register.
int CBMAPIDECL opencbm_plugin_iec_poll(CBM_FILE HandleDevice)
Read status of all bus lines.
int CBMAPIDECL opencbm_plugin_unlisten(CBM_FILE HandleDevice)
Send an UNLISTEN on the IEC serial bus.
Define the IOCTL codes for the opencbm driver.
int CBMAPIDECL opencbm_plugin_raw_write(CBM_FILE HandleDevice, const void *Buffer, size_t Count)
Write data to the IEC serial bus.
int CBMAPIDECL opencbm_plugin_iec_dbg_read(CBM_FILE HandleDevice)
Read a byte from the parallel port input register.
int CBMAPIDECL opencbm_plugin_listen(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Send a LISTEN on the IEC serial bus.
void CBMAPIDECL opencbm_plugin_unlock(CBM_FILE HandleDevice)
Unlock the parallel port for the driver.
#define FUNC_LEAVE_BOOL(_xxx)
int CBMAPIDECL opencbm_plugin_reset(CBM_FILE HandleDevice)
RESET all devices.
unsigned char CBMAPIDECL opencbm_plugin_pp_read(CBM_FILE HandleDevice)
Read a byte from a XP1541/XP1571 cable.
void CBMAPIDECL opencbm_plugin_iec_setrelease(CBM_FILE HandleDevice, int Set, int Release)
Activate and deactive a line on the IEC serial bus.
int CBMAPIDECL opencbm_plugin_talk(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Send a TALK on the IEC serial bus.
VOID WaitForIoCompletionConstruct(LPOVERLAPPED Overlapped)
Boilerplate code for asynchronous I/O requests.
int CBMAPIDECL opencbm_plugin_untalk(CBM_FILE HandleDevice)
Send an UNTALK on the IEC serial bus.
BOOL cbm_ioctl(IN CBM_FILE HandleDevice, IN DWORD ControlCode, IN char *TextControlCode, IN PVOID InBuffer, IN ULONG InBufferSize, OUT PVOID OutBuffer, IN ULONG OutBufferSize)
Perform an ioctl on the driver.
int CBMAPIDECL opencbm_plugin_clear_eoi(CBM_FILE HandleDevice)
Reset the EOI flag.
int CBMAPIDECL opencbm_plugin_iec_wait(CBM_FILE HandleDevice, int Line, int State)
Wait for a line to have a specific state.
BOOL cbm_driver_stop(VOID)
Stop a device driver.
void CBMAPIDECL opencbm_plugin_lock(CBM_FILE HandleDevice)
Lock the parallel port for the driver.
BOOL cbm_driver_start(VOID)
Start a device driver.
int CBMAPIDECL opencbm_plugin_get_eoi(CBM_FILE HandleDevice)
Get EOI flag after bus read.
Internal API for opencbm installation.
VOID WaitForIoCompletionDeinit(VOID)
Uninitialize WaitForIoCompletion()
int CBMAPIDECL opencbm_plugin_raw_read(CBM_FILE HandleDevice, void *Buffer, size_t Count)
Read data from the IEC serial bus.
int CBMAPIDECL cbm_get_debugging_buffer(CBM_FILE HandleDevice, char *buffer, size_t len)
Output contents of the debugging buffer.
void CBMAPIDECL opencbm_plugin_pp_write(CBM_FILE HandleDevice, unsigned char Byte)
Write a byte to a XP1541/XP1571 cable.
BOOL WaitForIoCompletion(BOOL Result, CBM_FILE HandleDevice, LPOVERLAPPED Overlapped, DWORD *BytesTransferred)
Wait for the completion of an I/O operation.
BOOL IsDriverStartedAutomatically(VOID)
Is the driver started automatically?