OpenCBM
xa1541/WINDOWS/parburst.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 2005 Tim Schürmann
8  * Copyright 2005,2007,2009 Spiro Trikaliotis
9  * Copyright 2009 Arnd <arnd(at)jonnz(dot)de>
10  *
11 */
12 
21 #include <windows.h>
22 #include <windowsx.h>
23 
24 #include <mmsystem.h>
25 
27 #define DBG_USERMODE
28 
30 #define DBG_PROGNAME "OPENCBM-XA1541.DLL"
31 
32 #include "debug.h"
33 
34 #include <winioctl.h>
35 #include "cbmioctl.h"
36 
37 #include <stdlib.h>
38 
40 
41 #include "i_opencbm.h"
42 
43 #define OPENCBM_PLUGIN
44 #include "archlib.h"
45 
46 
62 unsigned char CBMAPIDECL
64 {
66 
67  FUNC_ENTER();
68 
69  cbm_ioctl(HandleDevice, CBMCTRL(PARBURST_READ), NULL, 0, &result, sizeof(result));
70 
71  FUNC_LEAVE_UCHAR(result.Byte);
72 }
73 
89 void CBMAPIDECL
90 opencbm_plugin_parallel_burst_write(CBM_FILE HandleDevice, unsigned char Value)
91 {
92  CBMT_PARBURST_PWRITE_IN parameter;
93 
94  FUNC_ENTER();
95 
96  parameter.Byte = Value;
97 
98  cbm_ioctl(HandleDevice, CBMCTRL(PARBURST_WRITE), &parameter, sizeof(parameter), NULL, 0);
99 
100  FUNC_LEAVE();
101 }
102 
124 int CBMAPIDECL
125 opencbm_plugin_parallel_burst_read_track(CBM_FILE HandleDevice, unsigned char *Buffer, unsigned int Length)
126 {
127  int retval = 0;
128 
129  FUNC_ENTER();
130 
131  retval = cbm_ioctl(HandleDevice, CBMCTRL(PARBURST_READ_TRACK),
132  NULL, 0,
133  Buffer, Length);
134 
135  if (retval == 0)
136  {
137  DBG_WARN((DBG_PREFIX "opencbm: cbm.c: parallel_burst_read_track: ioctl returned with error %u", retval));
138  }
139 
140  FUNC_LEAVE_INT(retval);
141 }
142 
164 int CBMAPIDECL
165 opencbm_plugin_parallel_burst_read_track_var(CBM_FILE HandleDevice, unsigned char *Buffer, unsigned int Length)
166 {
167  int retval = 0;
168 
169  FUNC_ENTER();
170 
171  retval = cbm_ioctl(HandleDevice, CBMCTRL(PARBURST_READ_TRACK_VAR),
172  NULL, 0,
173  Buffer, Length);
174 
175  if (retval == 0)
176  {
177  DBG_WARN((DBG_PREFIX "opencbm: cbm.c: parallel_burst_read_track_var: ioctl returned with error %u", retval));
178  }
179 
180  FUNC_LEAVE_INT(retval);
181 }
182 
204 int CBMAPIDECL
205 opencbm_plugin_parallel_burst_write_track(CBM_FILE HandleDevice, unsigned char *Buffer, unsigned int Length)
206 {
207  int retval = 0;
208 
209  FUNC_ENTER();
210 
211  retval = cbm_ioctl(HandleDevice, CBMCTRL(PARBURST_WRITE_TRACK),
212  Buffer, Length,
213  NULL, 0);
214 
215  if (retval == 0)
216  {
217  DBG_WARN((DBG_PREFIX "opencbm: cbm.c: parallel_burst_write_track: ioctl returned with error %u", retval));
218  }
219 
220  FUNC_LEAVE_INT(retval);
221 }
#define FUNC_LEAVE_UCHAR(_xxx)
Definition: debug.h:364
#define DBG_WARN(_xxx)
Definition: debug.h:395
void CBMAPIDECL opencbm_plugin_parallel_burst_write(CBM_FILE HandleDevice, unsigned char Value)
PARBURST: Write to the parallel port.
#define FUNC_LEAVE_INT(_xxx)
Definition: debug.h:358
Define makros for debugging purposes.
#define CBMAPIDECL
Definition: opencbm.h:85
unsigned char CBMAPIDECL opencbm_plugin_parallel_burst_read(CBM_FILE HandleDevice)
PARBURST: Read from the parallel port.
#define CBMCTRL(_x_)
Definition: i_opencbm.h:37
Define the IOCTL codes for the opencbm driver.
#define FUNC_LEAVE()
Definition: debug.h:349
#define CBM_FILE
Definition: opencbm.h:87
int CBMAPIDECL opencbm_plugin_parallel_burst_read_track(CBM_FILE HandleDevice, unsigned char *Buffer, unsigned int Length)
PARBURST: Read a complete track.
int CBMAPIDECL opencbm_plugin_parallel_burst_read_track_var(CBM_FILE HandleDevice, unsigned char *Buffer, unsigned int Length)
PARBURST: Read a variable length track.
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.
Definition: i_opencbm.c:506
#define FUNC_ENTER()
Definition: debug.h:347
#define DBG_PREFIX
Definition: debug.h:320
int CBMAPIDECL opencbm_plugin_parallel_burst_write_track(CBM_FILE HandleDevice, unsigned char *Buffer, unsigned int Length)
PARBURST: Write a complete track.
Internal API for opencbm installation.