1
2
3
4
5
6
7
8
9
10#ifndef __USE1401_H__
11#define __USE1401_H__
12#include "machine.h"
13
14
15
16
17
18#ifdef _IS_WINDOWS_
19#ifndef U14_NOT_DLL
20#ifdef DLL_USE1401
21#define U14API(retType) (retType DllExport __stdcall)
22#else
23#define U14API(retType) (retType DllImport __stdcall)
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
39#define U14API(retType) (retType __declspec(dllimport) __stdcall)
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
53
54#define U14ERR_NOERROR 0
55
56
57#define U14ERR_STD 4
58#define U14ERR_U1401 5
59#define U14ERR_PLUS 6
60#define U14ERR_POWER 7
61#define U14ERR_U14012 8
62#define U14ERR_POWER2 9
63#define U14ERR_U14013 10
64#define U14ERR_POWER3 11
65
66
67#define U14ERR(n) (n+U14ERRBASE)
68#define U14ERR_OFF U14ERR(0)
69#define U14ERR_NC U14ERR(-1)
70#define U14ERR_ILL U14ERR(-2)
71#define U14ERR_NOIF U14ERR(-3)
72#define U14ERR_TIME U14ERR(-4)
73#define U14ERR_BADSW U14ERR(-5)
74#define U14ERR_PTIME U14ERR(-6)
75#define U14ERR_NOINT U14ERR(-7)
76#define U14ERR_INUSE U14ERR(-8)
77#define U14ERR_NODMA U14ERR(-9)
78#define U14ERR_BADHAND U14ERR(-10)
79#define U14ERR_BAD1401NUM U14ERR(-11)
80
81#define U14ERR_NO_SUCH_FN U14ERR(-20)
82#define U14ERR_NO_SUCH_SUBFN U14ERR(-21)
83#define U14ERR_NOOUT U14ERR(-22)
84#define U14ERR_NOIN U14ERR(-23)
85#define U14ERR_STRLEN U14ERR(-24)
86#define U14ERR_ERR_STRLEN U14ERR(-24)
87#define U14ERR_LOCKFAIL U14ERR(-25)
88#define U14ERR_UNLOCKFAIL U14ERR(-26)
89#define U14ERR_ALREADYSET U14ERR(-27)
90#define U14ERR_NOTSET U14ERR(-28)
91#define U14ERR_BADAREA U14ERR(-29)
92#define U14ERR_FAIL U14ERR(-30)
93
94#define U14ERR_NOFILE U14ERR(-40)
95#define U14ERR_READERR U14ERR(-41)
96#define U14ERR_UNKNOWN U14ERR(-42)
97#define U14ERR_HOSTSPACE U14ERR(-43)
98#define U14ERR_LOCKERR U14ERR(-44)
99#define U14ERR_CLOADERR U14ERR(-45)
100
101#define U14ERR_TOXXXERR U14ERR(-60)
102#define U14ERR_NO386ENH U14ERR(-80)
103#define U14ERR_NO1401DRIV U14ERR(-81)
104#define U14ERR_DRIVTOOOLD U14ERR(-82)
105
106#define U14ERR_TIMEOUT U14ERR(-90)
107
108#define U14ERR_BUFF_SMALL U14ERR(-100)
109#define U14ERR_CBALREADY U14ERR(-101)
110#define U14ERR_BADDEREG U14ERR(-102)
111#define U14ERR_NOMEMORY U14ERR(-103)
112
113#define U14ERR_DRIVCOMMS U14ERR(-110)
114#define U14ERR_OUTOFMEMORY U14ERR(-111)
115
116
117#define U14TYPE1401 0
118#define U14TYPEPLUS 1
119#define U14TYPEU1401 2
120#define U14TYPEPOWER 3
121#define U14TYPEU14012 4
122#define U14TYPEPOWER2 5
123#define U14TYPEU14013 6
124#define U14TYPEPOWER3 7
125#define U14TYPEUNKNOWN -1
126
127
128
129
130#define U14TF_USEDMA 1
131#define U14TF_MULTIA 2
132#define U14TF_FIFO 4
133#define U14TF_USB2 8
134#define U14TF_NOTIFY 16
135#define U14TF_SHORT 32
136#define U14TF_PCI2 64
137#define U14TF_CIRCTH 128
138#define U14TF_DIAG 256
139#define U14TF_CIRC14 512
140
141
142#define ESZBYTES 0
143#define ESZWORDS 1
144#define ESZLONGS 2
145#define ESZUNKNOWN 0
146
147
148#define BYTE_SIZE 1
149#define WORD_SIZE 2
150#define LONG_SIZE 3
151
152
153#define GET_TX_MAXENTRIES 257
154
155#ifdef _IS_WINDOWS_
156#pragma pack(1)
157
158typedef struct
159{
160 U14LONG physical;
161 U14LONG size;
162} TXENTRY;
163
164typedef struct TGetTxBlock
165{
166 U14LONG size;
167 U14LONG linear;
168 short seg;
169 short reserved;
170 short avail;
171 short used;
172 TXENTRY entries[GET_TX_MAXENTRIES];
173} TGET_TX_BLOCK;
174
175typedef TGET_TX_BLOCK *LPGET_TX_BLOCK;
176
177#pragma pack()
178#endif
179
180#ifdef LINUX
181typedef struct
182{
183 long long physical;
184 long size;
185} TXENTRY;
186
187typedef struct TGetTxBlock
188{
189 long long linear;
190 long size;
191 short seg;
192 short reserved;
193 short avail;
194 short used;
195 TXENTRY entries[GET_TX_MAXENTRIES];
196} TGET_TX_BLOCK;
197#endif
198
199#ifdef __cplusplus
200extern "C" {
201#endif
202
203U14API(int) U14WhenToTimeOut(short hand);
204U14API(short) U14PassedTime(int iTime);
205
206U14API(short) U14LastErrCode(short hand);
207
208U14API(short) U14Open1401(short n1401);
209U14API(short) U14Close1401(short hand);
210U14API(short) U14Reset1401(short hand);
211U14API(short) U14ForceReset(short hand);
212U14API(short) U14TypeOf1401(short hand);
213U14API(short) U14NameOf1401(short hand, char *pBuf, unsigned short wMax);
214
215U14API(short) U14Stat1401(short hand);
216U14API(short) U14CharCount(short hand);
217U14API(short) U14LineCount(short hand);
218
219U14API(short) U14SendString(short hand, const char *pString);
220U14API(short) U14GetString(short hand, char *pBuffer, unsigned short wMaxLen);
221U14API(short) U14SendChar(short hand, char cChar);
222U14API(short) U14GetChar(short hand, char *pcChar);
223
224U14API(short) U14LdCmd(short hand, const char *command);
225U14API(unsigned int) U14Ld(short hand, const char *vl, const char *str);
226
227U14API(short) U14SetTransArea(short hand, unsigned short wArea, void *pvBuff,
228 unsigned int dwLength, short eSz);
229U14API(short) U14UnSetTransfer(short hand, unsigned short wArea);
230U14API(short) U14SetTransferEvent(short hand, unsigned short wArea, BOOL bEvent,
231 BOOL bToHost, unsigned int dwStart, unsigned int dwLength);
232U14API(int) U14TestTransferEvent(short hand, unsigned short wArea);
233U14API(int) U14WaitTransferEvent(short hand, unsigned short wArea, int msTimeOut);
234U14API(short) U14GetTransfer(short hand, TGET_TX_BLOCK *pTransBlock);
235
236U14API(short) U14ToHost(short hand, char *pAddrHost, unsigned int dwSize, unsigned int dw1401,
237 short eSz);
238U14API(short) U14To1401(short hand, const char *pAddrHost, unsigned int dwSize, unsigned int dw1401,
239 short eSz);
240
241U14API(short) U14SetCircular(short hand, unsigned short wArea, BOOL bToHost, void *pvBuff,
242 unsigned int dwLength);
243
244U14API(int) U14GetCircBlk(short hand, unsigned short wArea, unsigned int *pdwOffs);
245U14API(int) U14FreeCircBlk(short hand, unsigned short wArea, unsigned int dwOffs, unsigned int dwSize,
246 unsigned int *pdwOffs);
247
248U14API(short) U14StrToLongs(const char *pszBuff, U14LONG *palNums, short sMaxLongs);
249U14API(short) U14LongsFrom1401(short hand, U14LONG *palBuff, short sMaxLongs);
250
251U14API(void) U14SetTimeout(short hand, int lTimeout);
252U14API(int) U14GetTimeout(short hand);
253U14API(short) U14OutBufSpace(short hand);
254U14API(int) U14BaseAddr1401(short hand);
255U14API(int) U14DriverVersion(short hand);
256U14API(int) U14DriverType(short hand);
257U14API(short) U14DriverName(short hand, char *pBuf, unsigned short wMax);
258U14API(short) U14GetUserMemorySize(short hand, unsigned int *pMemorySize);
259U14API(short) U14KillIO1401(short hand);
260
261U14API(short) U14BlkTransState(short hand);
262U14API(short) U14StateOf1401(short hand);
263
264U14API(short) U14Grab1401(short hand);
265U14API(short) U14Free1401(short hand);
266U14API(short) U14Peek1401(short hand, unsigned int dwAddr, int nSize, int nRepeats);
267U14API(short) U14Poke1401(short hand, unsigned int dwAddr, unsigned int dwValue, int nSize, int nRepeats);
268U14API(short) U14Ramp1401(short hand, unsigned int dwAddr, unsigned int dwDef, unsigned int dwEnable, int nSize, int nRepeats);
269U14API(short) U14RampAddr(short hand, unsigned int dwDef, unsigned int dwEnable, int nSize, int nRepeats);
270U14API(short) U14StopDebugLoop(short hand);
271U14API(short) U14GetDebugData(short hand, U14LONG *plValue);
272
273U14API(short) U14StartSelfTest(short hand);
274U14API(short) U14CheckSelfTest(short hand, U14LONG *pData);
275U14API(short) U14TransferFlags(short hand);
276U14API(void) U14GetErrorString(short nErr, char *pStr, unsigned short wMax);
277U14API(int) U14MonitorRev(short hand);
278U14API(void) U14CloseAll(void);
279
280U14API(short) U14WorkingSet(unsigned int dwMinKb, unsigned int dwMaxKb);
281U14API(int) U14InitLib(void);
282
283#ifdef __cplusplus
284}
285#endif
286
287#endif
288
289