Commit | Line | Data |
---|---|---|
2eae6bdc AS |
1 | /**************************************************************************** |
2 | ** use1401.h | |
3 | ** Copyright (C) Cambridge Electronic Design Ltd, 1992-2010 | |
4 | ** Authors: Paul Cox, Tim Bergel, Greg Smith | |
5 | ** See CVS for revisions. | |
6 | ** | |
7 | ** Because the size of a long is different between 32-bit and 64-bit on some | |
8 | ** systems, we avoid this in this interface. | |
9 | ****************************************************************************/ | |
10 | #ifndef __USE1401_H__ | |
11 | #define __USE1401_H__ | |
12 | #include "machine.h" | |
13 | ||
e4837704 EU |
14 | /* Some definitions to make things compatible. If you want to use Use1401 directly */ |
15 | /* from a Windows program you should define U14_NOT_DLL, in which case you also */ | |
16 | /* MUST make sure that your application startup code calls U14InitLib(). */ | |
17 | /* DLL_USE1401 is defined when you are building the Use1401 dll, not otherwise. */ | |
2eae6bdc AS |
18 | #ifdef _IS_WINDOWS_ |
19 | #ifndef U14_NOT_DLL | |
20 | #ifdef DLL_USE1401 | |
c33033db | 21 | #define U14API(retType) (retType DllExport __stdcall) |
2eae6bdc | 22 | #else |
c33033db | 23 | #define U14API(retType) (retType DllImport __stdcall) |
2eae6bdc AS |
24 | #endif |
25 | #endif | |
26 | ||
27 | #define U14ERRBASE -500 | |
28 | #define U14LONG long | |
29 | #endif | |
30 | ||
31 | #ifdef LINUX | |
32 | #define U14ERRBASE -1000 | |
33 | #define U14LONG int | |
34 | #endif | |
35 | ||
36 | #ifdef _QT | |
37 | #ifndef U14_NOT_DLL | |
38 | #undef U14API | |
c33033db | 39 | #define U14API(retType) (retType __declspec(dllimport) __stdcall) |
2eae6bdc AS |
40 | #endif |
41 | #undef U14LONG | |
42 | #define U14LONG int | |
43 | #endif | |
44 | ||
45 | #ifndef U14API | |
46 | #define U14API(retType) retType | |
47 | #endif | |
48 | ||
49 | #ifndef U14LONG | |
50 | #define U14LONG long | |
51 | #endif | |
52 | ||
e4837704 EU |
53 | /* Error codes: We need them here as user space can see them. */ |
54 | #define U14ERR_NOERROR 0 /* no problems */ | |
2eae6bdc | 55 | |
e4837704 EU |
56 | /* Device error codes, but these don't need to be extended - a succession is assumed */ |
57 | #define U14ERR_STD 4 /* standard 1401 connected */ | |
58 | #define U14ERR_U1401 5 /* u1401 connected */ | |
59 | #define U14ERR_PLUS 6 /* 1401 plus connected */ | |
60 | #define U14ERR_POWER 7 /* Power1401 connected */ | |
61 | #define U14ERR_U14012 8 /* u1401 mkII connected */ | |
2eae6bdc AS |
62 | #define U14ERR_POWER2 9 |
63 | #define U14ERR_U14013 10 | |
64 | #define U14ERR_POWER3 11 | |
65 | ||
e4837704 | 66 | /* NBNB Error numbers need shifting as some linux error codes start at 512 */ |
2eae6bdc AS |
67 | #define U14ERR(n) (n+U14ERRBASE) |
68 | #define U14ERR_OFF U14ERR(0) /* 1401 there but switched off */ | |
69 | #define U14ERR_NC U14ERR(-1) /* 1401 not connected */ | |
70 | #define U14ERR_ILL U14ERR(-2) /* if present it is ill */ | |
71 | #define U14ERR_NOIF U14ERR(-3) /* I/F card missing */ | |
72 | #define U14ERR_TIME U14ERR(-4) /* 1401 failed to come ready */ | |
73 | #define U14ERR_BADSW U14ERR(-5) /* I/F card bad switches */ | |
74 | #define U14ERR_PTIME U14ERR(-6) /* 1401plus failed to come ready */ | |
75 | #define U14ERR_NOINT U14ERR(-7) /* couldn't grab the int vector */ | |
76 | #define U14ERR_INUSE U14ERR(-8) /* 1401 is already in use */ | |
77 | #define U14ERR_NODMA U14ERR(-9) /* couldn't get DMA channel */ | |
78 | #define U14ERR_BADHAND U14ERR(-10) /* handle provided was bad */ | |
79 | #define U14ERR_BAD1401NUM U14ERR(-11) /* 1401 number provided was bad */ | |
80 | ||
81 | #define U14ERR_NO_SUCH_FN U14ERR(-20) /* no such function */ | |
82 | #define U14ERR_NO_SUCH_SUBFN U14ERR(-21) /* no such sub function */ | |
83 | #define U14ERR_NOOUT U14ERR(-22) /* no room in output buffer */ | |
84 | #define U14ERR_NOIN U14ERR(-23) /* no input in buffer */ | |
85 | #define U14ERR_STRLEN U14ERR(-24) /* string longer than buffer */ | |
86 | #define U14ERR_ERR_STRLEN U14ERR(-24) /* string longer than buffer */ | |
87 | #define U14ERR_LOCKFAIL U14ERR(-25) /* failed to lock memory */ | |
88 | #define U14ERR_UNLOCKFAIL U14ERR(-26) /* failed to unlock memory */ | |
89 | #define U14ERR_ALREADYSET U14ERR(-27) /* area already set up */ | |
90 | #define U14ERR_NOTSET U14ERR(-28) /* area not set up */ | |
91 | #define U14ERR_BADAREA U14ERR(-29) /* illegal area number */ | |
92 | #define U14ERR_FAIL U14ERR(-30) /* we failed for some other reason*/ | |
93 | ||
94 | #define U14ERR_NOFILE U14ERR(-40) /* command file not found */ | |
95 | #define U14ERR_READERR U14ERR(-41) /* error reading command file */ | |
96 | #define U14ERR_UNKNOWN U14ERR(-42) /* unknown command */ | |
97 | #define U14ERR_HOSTSPACE U14ERR(-43) /* not enough host space to load */ | |
98 | #define U14ERR_LOCKERR U14ERR(-44) /* could not lock resource/command*/ | |
99 | #define U14ERR_CLOADERR U14ERR(-45) /* CLOAD command failed */ | |
100 | ||
101 | #define U14ERR_TOXXXERR U14ERR(-60) /* tohost/1401 failed */ | |
102 | #define U14ERR_NO386ENH U14ERR(-80) /* not 386 enhanced mode */ | |
103 | #define U14ERR_NO1401DRIV U14ERR(-81) /* no device driver */ | |
104 | #define U14ERR_DRIVTOOOLD U14ERR(-82) /* device driver too old */ | |
105 | ||
106 | #define U14ERR_TIMEOUT U14ERR(-90) /* timeout occurred */ | |
107 | ||
108 | #define U14ERR_BUFF_SMALL U14ERR(-100) /* buffer for getstring too small */ | |
109 | #define U14ERR_CBALREADY U14ERR(-101) /* there is already a callback */ | |
110 | #define U14ERR_BADDEREG U14ERR(-102) /* bad parameter to deregcallback */ | |
111 | #define U14ERR_NOMEMORY U14ERR(-103) /* no memory for allocation */ | |
112 | ||
113 | #define U14ERR_DRIVCOMMS U14ERR(-110) /* failed talking to driver */ | |
114 | #define U14ERR_OUTOFMEMORY U14ERR(-111) /* needed memory and couldnt get it*/ | |
115 | ||
e4837704 | 116 | /* / 1401 type codes. */ |
2eae6bdc AS |
117 | #define U14TYPE1401 0 /* standard 1401 */ |
118 | #define U14TYPEPLUS 1 /* 1401 plus */ | |
119 | #define U14TYPEU1401 2 /* u1401 */ | |
120 | #define U14TYPEPOWER 3 /* power1401 */ | |
121 | #define U14TYPEU14012 4 /* u1401 mk II */ | |
122 | #define U14TYPEPOWER2 5 /* power1401 mk II */ | |
123 | #define U14TYPEU14013 6 /* u1401-3 */ | |
124 | #define U14TYPEPOWER3 7 /* power1401-3 */ | |
125 | #define U14TYPEUNKNOWN -1 /* dont know */ | |
126 | ||
e4837704 | 127 | /* Transfer flags to allow driver capabilities to be interrogated */ |
2eae6bdc | 128 | |
e4837704 | 129 | /* Constants for transfer flags */ |
2eae6bdc AS |
130 | #define U14TF_USEDMA 1 /* Transfer flag for use DMA */ |
131 | #define U14TF_MULTIA 2 /* Transfer flag for multi areas */ | |
132 | #define U14TF_FIFO 4 /* for FIFO interface card */ | |
133 | #define U14TF_USB2 8 /* for USB2 interface and 1401 */ | |
134 | #define U14TF_NOTIFY 16 /* for event notifications */ | |
135 | #define U14TF_SHORT 32 /* for PCI can short cycle */ | |
136 | #define U14TF_PCI2 64 /* for new PCI card 1401-70 */ | |
137 | #define U14TF_CIRCTH 128 /* Circular-mode to host */ | |
138 | #define U14TF_DIAG 256 /* Diagnostics/debug functions */ | |
139 | #define U14TF_CIRC14 512 /* Circular-mode to 1401 */ | |
140 | ||
e4837704 | 141 | /* Definitions of element sizes for DMA transfers - to allow byte-swapping */ |
2eae6bdc | 142 | #define ESZBYTES 0 /* BYTE element size value */ |
4e0825fd | 143 | #define ESZWORDS 1 /* unsigned short element size value */ |
2eae6bdc AS |
144 | #define ESZLONGS 2 /* long element size value */ |
145 | #define ESZUNKNOWN 0 /* unknown element size value */ | |
146 | ||
e4837704 | 147 | /* These define required access types for the debug/diagnostics function */ |
2eae6bdc AS |
148 | #define BYTE_SIZE 1 /* 8-bit access */ |
149 | #define WORD_SIZE 2 /* 16-bit access */ | |
150 | #define LONG_SIZE 3 /* 32-bit access */ | |
151 | ||
e4837704 | 152 | /* Stuff used by U14_GetTransfer */ |
2eae6bdc AS |
153 | #define GET_TX_MAXENTRIES 257 /* (max length / page size + 1) */ |
154 | ||
155 | #ifdef _IS_WINDOWS_ | |
156 | #pragma pack(1) | |
157 | ||
158 | typedef struct /* used for U14_GetTransfer results */ | |
159 | { /* Info on a single mapped block */ | |
d9f8374b EU |
160 | U14LONG physical; |
161 | U14LONG size; | |
2eae6bdc AS |
162 | } TXENTRY; |
163 | ||
164 | typedef struct TGetTxBlock /* used for U14_GetTransfer results */ | |
165 | { /* matches structure in VXD */ | |
d9f8374b EU |
166 | U14LONG size; |
167 | U14LONG linear; | |
168 | short seg; | |
169 | short reserved; | |
170 | short avail; /* number of available entries */ | |
171 | short used; /* number of used entries */ | |
172 | TXENTRY entries[GET_TX_MAXENTRIES]; /* Array of mapped block info */ | |
2eae6bdc AS |
173 | } TGET_TX_BLOCK; |
174 | ||
175 | typedef TGET_TX_BLOCK *LPGET_TX_BLOCK; | |
176 | ||
177 | #pragma pack() | |
178 | #endif | |
179 | ||
180 | #ifdef LINUX | |
181 | typedef struct /* used for U14_GetTransfer results */ | |
182 | { /* Info on a single mapped block */ | |
d9f8374b EU |
183 | long long physical; |
184 | long size; | |
2eae6bdc AS |
185 | } TXENTRY; |
186 | ||
187 | typedef struct TGetTxBlock /* used for U14_GetTransfer results */ | |
188 | { /* matches structure in VXD */ | |
d9f8374b EU |
189 | long long linear; /* linear address */ |
190 | long size; /* total size of the mapped area, holds id when called */ | |
191 | short seg; /* segment of the address for Win16 */ | |
192 | short reserved; | |
193 | short avail; /* number of available entries */ | |
194 | short used; /* number of used entries */ | |
195 | TXENTRY entries[GET_TX_MAXENTRIES]; /* Array of mapped block info */ | |
2eae6bdc AS |
196 | } TGET_TX_BLOCK; |
197 | #endif | |
198 | ||
199 | #ifdef __cplusplus | |
200 | extern "C" { | |
201 | #endif | |
202 | ||
e4837704 | 203 | U14API(int) U14WhenToTimeOut(short hand); /* when to timeout in ms */ |
d9f8374b | 204 | U14API(short) U14PassedTime(int iTime); /* non-zero if iTime passed */ |
2eae6bdc | 205 | |
d9f8374b | 206 | U14API(short) U14LastErrCode(short hand); |
2eae6bdc | 207 | |
d9f8374b EU |
208 | U14API(short) U14Open1401(short n1401); |
209 | U14API(short) U14Close1401(short hand); | |
210 | U14API(short) U14Reset1401(short hand); | |
211 | U14API(short) U14ForceReset(short hand); | |
212 | U14API(short) U14TypeOf1401(short hand); | |
4e0825fd | 213 | U14API(short) U14NameOf1401(short hand, char *pBuf, unsigned short wMax); |
2eae6bdc | 214 | |
d9f8374b EU |
215 | U14API(short) U14Stat1401(short hand); |
216 | U14API(short) U14CharCount(short hand); | |
217 | U14API(short) U14LineCount(short hand); | |
2eae6bdc | 218 | |
d9f8374b | 219 | U14API(short) U14SendString(short hand, const char *pString); |
4e0825fd | 220 | U14API(short) U14GetString(short hand, char *pBuffer, unsigned short wMaxLen); |
d9f8374b EU |
221 | U14API(short) U14SendChar(short hand, char cChar); |
222 | U14API(short) U14GetChar(short hand, char *pcChar); | |
2eae6bdc | 223 | |
d9f8374b | 224 | U14API(short) U14LdCmd(short hand, const char *command); |
8c79caa8 | 225 | U14API(unsigned int) U14Ld(short hand, const char *vl, const char *str); |
2eae6bdc | 226 | |
4e0825fd | 227 | U14API(short) U14SetTransArea(short hand, unsigned short wArea, void *pvBuff, |
8c79caa8 | 228 | unsigned int dwLength, short eSz); |
4e0825fd EU |
229 | U14API(short) U14UnSetTransfer(short hand, unsigned short wArea); |
230 | U14API(short) U14SetTransferEvent(short hand, unsigned short wArea, BOOL bEvent, | |
8c79caa8 | 231 | BOOL bToHost, unsigned int dwStart, unsigned int dwLength); |
4e0825fd EU |
232 | U14API(int) U14TestTransferEvent(short hand, unsigned short wArea); |
233 | U14API(int) U14WaitTransferEvent(short hand, unsigned short wArea, int msTimeOut); | |
d9f8374b | 234 | U14API(short) U14GetTransfer(short hand, TGET_TX_BLOCK *pTransBlock); |
2eae6bdc | 235 | |
8c79caa8 | 236 | U14API(short) U14ToHost(short hand, char *pAddrHost, unsigned int dwSize, unsigned int dw1401, |
d9f8374b | 237 | short eSz); |
8c79caa8 | 238 | U14API(short) U14To1401(short hand, const char *pAddrHost, unsigned int dwSize, unsigned int dw1401, |
d9f8374b | 239 | short eSz); |
2eae6bdc | 240 | |
4e0825fd | 241 | U14API(short) U14SetCircular(short hand, unsigned short wArea, BOOL bToHost, void *pvBuff, |
8c79caa8 | 242 | unsigned int dwLength); |
2eae6bdc | 243 | |
8c79caa8 EU |
244 | U14API(int) U14GetCircBlk(short hand, unsigned short wArea, unsigned int *pdwOffs); |
245 | U14API(int) U14FreeCircBlk(short hand, unsigned short wArea, unsigned int dwOffs, unsigned int dwSize, | |
246 | unsigned int *pdwOffs); | |
2eae6bdc | 247 | |
d9f8374b EU |
248 | U14API(short) U14StrToLongs(const char *pszBuff, U14LONG *palNums, short sMaxLongs); |
249 | U14API(short) U14LongsFrom1401(short hand, U14LONG *palBuff, short sMaxLongs); | |
2eae6bdc AS |
250 | |
251 | U14API(void) U14SetTimeout(short hand, int lTimeout); | |
252 | U14API(int) U14GetTimeout(short hand); | |
d9f8374b | 253 | U14API(short) U14OutBufSpace(short hand); |
2eae6bdc AS |
254 | U14API(int) U14BaseAddr1401(short hand); |
255 | U14API(int) U14DriverVersion(short hand); | |
256 | U14API(int) U14DriverType(short hand); | |
4e0825fd | 257 | U14API(short) U14DriverName(short hand, char *pBuf, unsigned short wMax); |
8c79caa8 | 258 | U14API(short) U14GetUserMemorySize(short hand, unsigned int *pMemorySize); |
d9f8374b EU |
259 | U14API(short) U14KillIO1401(short hand); |
260 | ||
261 | U14API(short) U14BlkTransState(short hand); | |
262 | U14API(short) U14StateOf1401(short hand); | |
263 | ||
264 | U14API(short) U14Grab1401(short hand); | |
265 | U14API(short) U14Free1401(short hand); | |
8c79caa8 EU |
266 | U14API(short) U14Peek1401(short hand, unsigned int dwAddr, int nSize, int nRepeats); |
267 | U14API(short) U14Poke1401(short hand, unsigned int dwAddr, unsigned int dwValue, int nSize, int nRepeats); | |
268 | U14API(short) U14Ramp1401(short hand, unsigned int dwAddr, unsigned int dwDef, unsigned int dwEnable, int nSize, int nRepeats); | |
269 | U14API(short) U14RampAddr(short hand, unsigned int dwDef, unsigned int dwEnable, int nSize, int nRepeats); | |
d9f8374b EU |
270 | U14API(short) U14StopDebugLoop(short hand); |
271 | U14API(short) U14GetDebugData(short hand, U14LONG *plValue); | |
272 | ||
273 | U14API(short) U14StartSelfTest(short hand); | |
274 | U14API(short) U14CheckSelfTest(short hand, U14LONG *pData); | |
275 | U14API(short) U14TransferFlags(short hand); | |
4e0825fd | 276 | U14API(void) U14GetErrorString(short nErr, char *pStr, unsigned short wMax); |
2eae6bdc AS |
277 | U14API(int) U14MonitorRev(short hand); |
278 | U14API(void) U14CloseAll(void); | |
279 | ||
8c79caa8 | 280 | U14API(short) U14WorkingSet(unsigned int dwMinKb, unsigned int dwMaxKb); |
2eae6bdc AS |
281 | U14API(int) U14InitLib(void); |
282 | ||
283 | #ifdef __cplusplus | |
284 | } | |
285 | #endif | |
286 | ||
287 | #endif /* End of ifndef __USE1401_H__ */ | |
d1cc1b86 | 288 |