home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 September / CHIP_CD_1997_09_PL.iso / software / testsoft / labwind / demo.6 / main / include / busacc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-02  |  10.5 KB  |  257 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*             National Instruments NI-VXI Software Interface           */
  4. /*                   (C) 1996,  National Instruments                    */
  5. /*                                                                      */
  6. /*      High Level, Low Level, and Local Resource Access Functions      */
  7. /*                                                                      */
  8. /************************************************************************/
  9. /*                       DO NOT MODIFY THIS FILE                        */
  10. /************************************************************************/
  11. /* The following file contains all of the necessary include file
  12.  * information for use of the National Instruments NI-VXI High Level
  13.  * VXIbus Access functions, Low Level VXIbus Access functions,
  14.  * and Local Resource Access functions.
  15.  */
  16.  
  17. #if !defined(busacc_h)
  18. #define busacc_h
  19.  
  20. #include "datasize.h"
  21.  
  22. /*************************************************************************
  23.  *   Standard NI-VXI values for space fields in VXIin, VXIout, VXImove,
  24.  * and MapVXIaddrress. 
  25.  */
  26. #define LOC_SPACE             0U
  27. #define A16_SPACE             1U
  28. #define A24_SPACE             2U
  29. #define A32_SPACE             3U
  30.  
  31. /*************************************************************************
  32.  *   Standard NI-VXI values for data width parameters.
  33.  */
  34. #define BYTE_WIDTH            1U
  35. #define WORD_WIDTH            2U
  36. #define LONGWORD_WIDTH        4U
  37.  
  38. /*************************************************************************
  39.  *   Standard NI-VXI values for privilege fields
  40.  */
  41. #define NonPriv_DATA          0U
  42. #define Priv_DATA             1U
  43. #define NonPriv_PROGRAM       2U
  44. #define Priv_PROGRAM          3U
  45. #define NonPriv_BLOCK         4U
  46. #define Priv_BLOCK            5U
  47. #define NonPrivD64_BLOCK      6U
  48. #define PrivD64_BLOCK         7U
  49.  
  50. /*************************************************************************
  51.  *   Standard NI-VXI values for byte order fields
  52.  */
  53. #define MOTOROLA_ORDER        0U
  54. #define INTEL_ORDER           1U
  55. /*************************************************************************
  56.  *   Standard NI-VXI values for transfer method fields
  57.  */
  58. #define XFER_DMA              0U
  59. #define XFER_PIO              1U
  60. /*************************************************************************
  61.  *   Standard NI-VXI values for address increment fields
  62.  */
  63. #define XFER_INCREMENT_ADDR    0U
  64. #define XFER_NO_INCREMENT_ADDR 1U
  65. /*************************************************************************
  66.  *   Standard NI-VXI values for block transfer fields
  67.  */
  68. #define XFER_ENABLE_BLOCK     0U
  69. #define XFER_DISABLE_BLOCK    1U
  70. /*************************************************************************
  71.  *   Standard NI-VXI values for sync block transfer fields
  72.  */
  73. #define XFER_ENABLE_SYNC      0U
  74. #define XFER_DISABLE_SYNC     1U
  75.  
  76. /*************************************************************************
  77.  *    The following function macros can be used to formulate the AccessP
  78.  * parameters to the functions VXIin, VXIout, VXImove, and MapVXIaddress.
  79.  *
  80.  * NOTE:
  81.  * DO NOT WORRY ABOUT THE EXTENSIVE MATH DONE WITHIN THESE MACROS.  IF
  82.  * OTHER DEFINES ARE SUPPLIED AS PARAMETERS TO THESE MACROS, THE ENTIRE
  83.  * MATH OPERATION WILL BE COMPUTED AT PRE-PROCESSOR (PRE COMPILE-TIME).
  84.  * NO CODE WILL BE GENERATED--ONLY A SINGLE MOVE INSTRUCTION.
  85.  *
  86.  *    The AccessP_*() macros are used to set the particular field
  87.  * (address space, privilege, or byte order) within the call to the
  88.  * function.
  89.  *
  90.  *    The SetAccessP_*() macros are used to set the particular field
  91.  * (address space, privilege, or byte order) in a variable to be used
  92.  * as an AccessP parameter.  This is done in a similar manner to the
  93.  * AccessP_* #defines except the 'c' parameter specifies the variable
  94.  * to set the field in.
  95.  *
  96.  *    The GetAccessP_*() macros are used to extract the particular field
  97.  * (address space, privilege, or byte order) from an AccessP parameter.
  98.  *
  99.  * Example:
  100.  *
  101.  *    UINT16 AccessP, value, ret;
  102.  *    UINT32 offset;
  103.  *
  104.  *    offset = 0xC000;     -- logical address 0's ID register --
  105.  *
  106.  *    ret = VXIin(AccessP_Space(A16_SPACE)   |
  107.  *                AccessP_Priv(NonPriv_DATA) |
  108.  *                AccessP_BO(MOTOROLA_ORDER),
  109.  *                offset, WORD_WIDTH, (UINT32 *)&value);
  110.  * OR
  111.  *    SetAccessP_Space(AccessP, A16_SPACE);
  112.  *    SetAccessP_Priv(AccessP, NonPriv_DATA);
  113.  *    SetAccessP_BO(AccessP, MOTOROLA_ORDER);
  114.  *    ret = VXIin(AccessP, offset, WORD_WIDTH, (UINT32 *)&value);
  115.  *
  116.  */
  117. #define AccessP_Space(p)          ( p&3     )
  118. #define AccessP_Priv(p)           ((p&7)<<2 )
  119. #define AccessP_Owner(p)          ((p&1)<<6 )
  120. #define AccessP_BO(p)             ((p&1)<<7 )
  121. #define AccessP_PIO(p)            ((p&1)<<11)
  122. #define AccessP_NoInc(p)          ((p&1)<<12)
  123. #define AccessP_BlkDisable(p)     ((p&1)<<13)
  124. #define AccessP_SyncDisable(p)    ((p&1)<<14)
  125.  
  126. #define SetAccessP_Space(c,s)      (c = (c & 0xfffffffcL) | AccessP_Space(s)      )
  127. #define SetAccessP_Priv(c,p)       (c = (c & 0xffffffe3L) | AccessP_Priv(p)       )
  128. #define SetAccessP_Owner(c,o)      (c = (c & 0xffffffbfL) | AccessP_Owner(o)      )
  129. #define SetAccessP_BO(c,b)         (c = (c & 0xffffff7fL) | AccessP_BO(b)         )
  130. #define SetAccessP_PIO(c,p)        (c = (c & 0xfffff7ffL) | AccessP_PIO(p)        )
  131. #define SetAccessP_NoInc(c,i)      (c = (c & 0xffffefffL) | AccessP_NoInc(i)      )
  132. #define SetAccessP_BlkDisable(c,b) (c = (c & 0xffffdfffL) | AccessP_BlkDisable(b) )
  133. #define SetAccessP_SyncDisable(c,s)(c = (c & 0xffffbfffL) | AccessP_SyncDisable(s))
  134.  
  135. #define GetAccessP_Space(c)       (UINT16)( c      & 0x0003)
  136. #define GetAccessP_Priv(c)        (UINT16)((c>>2)  & 0x0007)
  137. #define GetAccessP_Owner(c)       (UINT16)((c>>6)  & 0x0001)
  138. #define GetAccessP_BO(c)          (UINT16)((c>>7)  & 0x0001)
  139. #define GetAccessP_PIO(c)         (UINT16)((c>>11) & 0x0001)
  140. #define GetAccessP_NoInc(c)       (UINT16)((c>>12) & 0x0001)
  141. #define GetAccessP_BlkDisable(c)  (UINT16)((c>>13) & 0x0001)
  142. #define GetAccessP_SyncDisable(c) (UINT16)((c>>14) & 0x0001)
  143.  
  144. /*************************************************************************
  145.  *   The following structure definition is needed when calling the 
  146.  * functions SaveContext and RestoreContext.
  147.  */
  148. typedef struct ContextStruct {
  149.     UINT32 entries[6];
  150. } ContextStruct;
  151.  
  152. /*************************************************************************
  153.  *   The following structure definition is needed when calling the 
  154.  * functions GetVXIbusStatus and GetVXIbusStatusInd.
  155.  */
  156. typedef struct BusStatus {
  157.     INT16 BusError;
  158.     INT16 Sysfail;
  159.     INT16 ACfail;
  160.     INT16 SignalIn;
  161.     INT16 VXIints;
  162.     INT16 ECLtrigs;
  163.     INT16 TTLtrigs;
  164. } BusStatus;
  165.  
  166. /*************************************************************************
  167.  *   The following are return codes for all of the High Level, Low Level,
  168.  * and Local Resource Access functions.
  169.  */
  170.  
  171. /* General defines for all Bus Access functions */
  172. #define INVALID_WINDOW              (-1)
  173. #define INVALID_ACCESS_PARM         (-2)
  174. #define INVALID_ACCESS_ADDRESS      (-3)
  175. #define INVALID_ACCESS_WIDTH        (-4)
  176. #define UNSUPPORTED_BYTEORDER       (-5)
  177. #define UNSUPPORTED_ADDRESS         (-6)
  178. #define UNSUPPORTED_PRIV            (-7)
  179. #define UNSUPPORTED_WIDTH           (-9)
  180. #define NOT_OWNER_ACCESS            (-9)
  181.  
  182. /* MapVXIaddress */
  183. #define MAP_SUCCESSFUL              NIVXI_OK        /* zero */
  184. #define MAP_INVPARMS                INVALID_ACCESS_PARM
  185. #define MAP_INVADDR                 INVALID_ACCESS_ADDRESS
  186. #define MAP_INVWIDTH                INVALID_ACCESS_WIDTH
  187. #define MAP_UNSUP_BYTEORDER         UNSUPPORTED_BYTEORDER
  188. #define MAP_UNSUP_ADDRESS           UNSUPPORTED_ADDRESS
  189. #define MAP_UNSUP_PRIV              UNSUPPORTED_PRIV
  190. #define MAP_TIMEOUT                 (-8)
  191.  
  192. /* UnmapVXIaddress */
  193. #define UNMAP_OK_UNLOCKED           NIVXI_OK        /* zero */
  194. #define UNMAP_ACCESS_ONLY           (1)
  195. #define UNMAP_INVWIN                INVALID_WINDOW
  196.  
  197. /* GetWindowRange */
  198. #define RANGE_OK                    NIVXI_OK        /* zero */
  199. #define RANGE_INVWIN                INVALID_WINDOW
  200.  
  201. /* SaveContext, RestoreContext, GetContext, SetContext */
  202. #define CONTEXT_OK                  NIVXI_OK        /* zero */
  203. #define CONTEXT_INVWIN              INVALID_WINDOW
  204. #define CONTEXT_INVALID             INVALID_ACCESS_PARM
  205. #define CONTEXT_NOTOWNER            NOT_OWNER_ACCESS
  206.  
  207. /* SetPrivilege, GetPrivilege */
  208. #define PRIV_OK                     NIVXI_OK       /* zero */
  209. #define PRIV_INVWIN                 INVALID_WINDOW
  210. #define PRIV_INVPRIV                INVALID_ACCESS_PARM
  211. #define PRIV_UNSUP                  UNSUPPORTED_PRIV
  212. #define PRIV_NOTOWNER               NOT_OWNER_ACCESS
  213.  
  214. /* SetByteOrdering, GetByteOrdering */
  215. #define BYTEORDER_OK                NIVXI_OK       /* zero */
  216. #define BYTEORDER_OK_SAMEFORALL     (1)
  217. #define BYTEORDER_INVWIN            INVALID_WINDOW
  218. #define BYTEORDER_INVBO             INVALID_ACCESS_PARM
  219. #define BYTEORDER_UNSUP             UNSUPPORTED_PRIV
  220. #define BYTEORDER_NOTOWNER          NOT_OWNER_ACCESS
  221.  
  222. /* GetVXIbusStatus, GetVXIbusStatusInd */
  223. #define BUSSTAT_OK                  NIVXI_OK       /* zero */
  224. #define BUSSTAT_NOTSUP              NO_HARDWARE_SUPPORT
  225. #define BUSSTAT_INVCONT             INVALID_CONTROLLER
  226. #define BUSSTAT_INVFIELD            (-3)
  227.  
  228. /* VXIin, VXIout, VXImove, VXIinLR, VXIoutLR, VXIinReg, VXIoutReg */
  229. #define ACCESS_OK                   NIVXI_OK       /* zero */
  230. #define ACCESS_BERR                 (-1)
  231. #define ACCESS_INVPARM              INVALID_ACCESS_PARM
  232. #define ACCESS_INVADDR              INVALID_ACCESS_ADDRESS
  233. #define ACCESS_INVWIDTH             INVALID_ACCESS_WIDTH
  234. #define ACCESS_UNSUP_BYTEORDER      UNSUPPORTED_BYTEORDER
  235. #define ACCESS_UNSUP_ADDRESS        UNSUPPORTED_ADDRESS
  236. #define ACCESS_UNSUP_PRIV           UNSUPPORTED_PRIV
  237. #define ACCESS_UNSUP_WIDTH          UNSUPPORTED_WIDTH
  238. #define ACCESS_DMA_ERROR            (-8)
  239.  
  240. /* SetMODID, ReadMODID */
  241. #define MODID_OK                    NIVXI_OK       /* zero */
  242. #define MODID_NOTSLOT0              (-1)
  243.  
  244. /* VXImemAlloc, VXImemCopy, VXImemFree */
  245. #define MEM_OK_USE_VXIMEMCOPY       ( 1)
  246. #define MEM_OK                      NIVXI_OK       /* zero */
  247. #define MEM_ALLOC_FAIL              (-1)
  248. #define MEM_A16ONLY                 (-2)
  249.  
  250. #define MEM_COPY_FAIL               (-1)
  251. #define MEM_COPY_INVDIR             (-5)
  252.  
  253. #define MEM_DEALLOC_FAIL            (-1)
  254.  
  255. #endif
  256.  
  257.