cbioLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* cbioLib.h - cached block I/O device (CBIO) header file */
  2. /* Copyright 1999-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01j,21aug01,jkf  SPR#69031, common code for both AE & 5.x.
  7. 01i,14apr00,jkf  fixed S_cbioLib_INVALID_CBIO_DEV_ID definition
  8. 01h,29feb00,jkf  T3 changes
  9. 01g,31aug99,jkf  overhaul for new CBIO API.
  10. 01f,31jul99,jkf  T2 merge, tidiness & spelling.
  11. 01e,14oct98,lrn  added includes for required types
  12. 01d,07sep98,lrn  added prototype for cbioDevVerify 
  13. 01c,02jul98,lrn  ready for prerelease
  14. 01b,27apr98,lrn  added implementation dependent structure pointer, stats 
  15. 01a,15jan98,lrn  written
  16. */
  17. #ifndef __INCcbioLibh
  18. #define __INCcbioLibh
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* includes */
  23. #include "blkIo.h"  /* for BLK_DEV type */
  24. /* 
  25.  * typedef's and enums 
  26.  */
  27. typedef unsigned long block_t ; /* block number */
  28. typedef unsigned long cookie_t ; /* opaque cookie */
  29. typedef struct cbioDev * CBIO_DEV_ID ;  /* CBIO device handle */
  30. typedef enum                            /* CBIO_RW direction enum */
  31.         {CBIO_READ, CBIO_WRITE}         /* data transfer direction */
  32.         CBIO_RW;
  33. typedef struct cbioParams /* CBIO Device parameters */
  34.     {
  35.     BOOL cbioRemovable; /* removable medium flag */
  36.     block_t  nBlocks; /* number of blocks on device */
  37.     size_t  bytesPerBlk; /* number of bytes per block */
  38.     size_t blockOffset; /* number of blocks from physical 0 */
  39.     short blocksPerTrack; /* number of blocks per track */
  40.     short nHeads; /* number of heads */
  41.     short retryCnt; /* retry count for I/O errors -XXX */
  42.     block_t  lastErrBlk; /* block # where last error occurred */
  43.     int  lastErrno; /* error code of last error */
  44.     } CBIO_PARAMS;
  45. /* 
  46.  * Cached Block I/O (CBIO) API functions 
  47.  */
  48. /* Library init routine */
  49. IMPORT STATUS cbioLibInit
  50.     (
  51.     void
  52.     );
  53. /* transfer n blocks from/to memory */
  54. IMPORT STATUS cbioBlkRW
  55.     (
  56.     CBIO_DEV_ID dev,
  57.     block_t startBlock,
  58.     block_t numBlocks,
  59.     addr_t buffer,
  60.     CBIO_RW rw,
  61.     cookie_t * pCookie
  62.     );
  63. /* transfer n bytes from/to memory */
  64. IMPORT STATUS cbioBytesRW
  65.     (
  66.     CBIO_DEV_ID  dev,
  67.     block_t startBlock,
  68.     off_t offset,
  69.     addr_t buffer,
  70.     size_t nBytes,
  71.     CBIO_RW rw,
  72.     cookie_t * pCookie
  73.     );
  74. /* Copy from block to block */
  75. IMPORT STATUS cbioBlkCopy
  76.     (
  77.     CBIO_DEV_ID  dev,
  78.     block_t srcBlock,
  79.     block_t dstBlock,
  80.     block_t numBlocks
  81.     );
  82. /* I/O control operations */
  83. IMPORT STATUS cbioIoctl
  84.     (
  85.     CBIO_DEV_ID dev,
  86.     int command,
  87.     addr_t arg
  88.     );
  89. /* get mode - O_RDONLY, O_WRONLY, O_RDWR */
  90. IMPORT int cbioModeGet  
  91.     (
  92.     CBIO_DEV_ID dev
  93.     );
  94. /* set mode  - O_RDONLY, O_WRONLY, or O_RDWR */
  95. IMPORT STATUS cbioModeSet  
  96.     (
  97.     CBIO_DEV_ID dev,
  98.     int mode
  99.     );
  100. /* determine device ready status */
  101. IMPORT int cbioRdyChgdGet 
  102.     (
  103.     CBIO_DEV_ID dev
  104.     );
  105. /* Force a change in ready status state */
  106. IMPORT STATUS cbioRdyChgdSet  
  107.     (
  108.     CBIO_DEV_ID dev,
  109.     BOOL status
  110.     );
  111. /* Obtain exclusive ownership of device */
  112. IMPORT STATUS cbioLock  
  113.     (
  114.     CBIO_DEV_ID dev,
  115.     int timeout /* max time to pend (semTake) */
  116.     );
  117. /* Release exclusive ownership of device */
  118. IMPORT STATUS cbioUnlock 
  119.     (
  120.     CBIO_DEV_ID dev
  121.     );
  122. /* fill CBIO_PARAMS structure */
  123. IMPORT STATUS cbioParamsGet
  124.     (
  125.     CBIO_DEV_ID dev,
  126.     CBIO_PARAMS * pCbioParams
  127.     );
  128. /* display cbio information */
  129. IMPORT STATUS cbioShow
  130.     (
  131.     CBIO_DEV_ID dev
  132.     );
  133. /* Verify a CBIO device is valid */             
  134. IMPORT STATUS cbioDevVerify                     
  135.     (                                           
  136.     CBIO_DEV_ID device                          
  137.     );                                          
  138.                                                 
  139. /* create a CBIO wapper atop a BLK_DEV */       
  140. IMPORT CBIO_DEV_ID cbioWrapBlkDev               
  141.     (                                           
  142.     BLK_DEV * pDevice                            
  143.     );                                          
  144. /* 
  145.  * CBIO I/O control codes for cbioIoctl()
  146.  */
  147. #define CBIO_RESET 0xcb100000 /* Reset device */
  148. #define CBIO_STATUS_CHK 0xcb100001 /* check device status */
  149. #define CBIO_DEVICE_LOCK 0xcb100002 /* Prevent disk removal */
  150. #define CBIO_DEVICE_UNLOCK 0xcb100003 /* Allow disk removal */
  151. #define CBIO_DEVICE_EJECT 0xcb100004 /* Dismount device */
  152. #define CBIO_CACHE_FLUSH 0xcb100010 /* Flush dirty caches */
  153. #define CBIO_CACHE_INVAL 0xcb100030 /* Flush & Invalidate all */
  154. #define CBIO_CACHE_NEWBLK 0xcb100050 /* Allocate scratch block */
  155. /*
  156.  * cbioLib errno's 
  157.  */
  158. #define S_cbioLib_INVALID_CBIO_DEV_ID (M_cbioLib | 1)
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif /* __INCcbioLibh */