linux/drivers/staging/ced1401/use1401.h
<<
>>
Prefs
   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
  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. */
  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/* Error codes: We need them here as user space can see them. */
  54#define U14ERR_NOERROR        0             /*  no problems */
  55
  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 */
  62#define U14ERR_POWER2         9
  63#define U14ERR_U14013        10
  64#define U14ERR_POWER3        11
  65
  66/* NBNB Error numbers need shifting as some linux error codes start at 512 */
  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
 116/* / 1401 type codes. */
 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
 127/* Transfer flags to allow driver capabilities to be interrogated */
 128
 129/* Constants for transfer flags */
 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
 141/* Definitions of element sizes for DMA transfers - to allow byte-swapping */
 142#define ESZBYTES              0           /* BYTE element size value        */
 143#define ESZWORDS              1           /* unsigned short element size value        */
 144#define ESZLONGS              2           /* long element size value        */
 145#define ESZUNKNOWN            0           /* unknown element size value     */
 146
 147/* These define required access types for the debug/diagnostics function */
 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
 152/* Stuff used by U14_GetTransfer */
 153#define GET_TX_MAXENTRIES  257          /* (max length / page size + 1) */
 154
 155#ifdef _IS_WINDOWS_
 156#pragma pack(1)
 157
 158typedef struct                          /* used for U14_GetTransfer results */
 159{                                          /* Info on a single mapped block */
 160        U14LONG physical;
 161        U14LONG size;
 162} TXENTRY;
 163
 164typedef struct TGetTxBlock              /* used for U14_GetTransfer results */
 165{                                               /* matches structure in VXD */
 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 */
 173} TGET_TX_BLOCK;
 174
 175typedef TGET_TX_BLOCK *LPGET_TX_BLOCK;
 176
 177#pragma pack()
 178#endif
 179
 180#ifdef LINUX
 181typedef struct                          /* used for U14_GetTransfer results */
 182{                                       /* Info on a single mapped block */
 183        long long physical;
 184        long     size;
 185} TXENTRY;
 186
 187typedef struct TGetTxBlock              /* used for U14_GetTransfer results */
 188{                                       /* matches structure in VXD */
 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 */
 196} TGET_TX_BLOCK;
 197#endif
 198
 199#ifdef __cplusplus
 200extern "C" {
 201#endif
 202
 203U14API(int)   U14WhenToTimeOut(short hand);         /*  when to timeout in ms */
 204U14API(short)   U14PassedTime(int iTime);             /*  non-zero if iTime passed */
 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 /* End of ifndef __USE1401_H__ */
 288
 289