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

VxWorks

开发平台:

C/C++

  1. /* aioPxLibP.h - asynchronous I/O header file */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01g,18jul96,dbt  moved aioPxLibInit() and aioShow() prototypes to aio.h 
  7.  (SPR #3227).
  8.  Updated copyright.
  9. 01f,15apr94,kdl  changed FD_NODE_TO_SYS macro to use offsetof().
  10. 01e,08apr94,kdl  changed aio_show() to aioShow().
  11. 01d,26jan94,kdl  changed include of ioQPxLib.h to ioQLib.h.
  12. 01c,12jan94,kdl  changed aioInit() to aioPxLibInit(); general cleanup.
  13. 01b,06dec93,dvs  changed M_aioLib to M_aioPxLib
  14.                  changed S_aioLib* to S_aioPxLib*
  15. 01a,04apr93,elh  written.
  16. */
  17. #ifndef __INCaioPxLibh
  18. #define __INCaioPxLibh
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* includes */
  23. #include "private/semLibP.h"
  24. #include "iosLibP.h"
  25. #include "qPriNode.h"
  26. #include "lstLib.h"
  27. #include "sigLib.h"
  28. #include "semLib.h"
  29. #include "ioQLib.h"
  30. #include "dllLib.h"
  31. #include "private/mutexPxLibP.h"
  32. #include "stddef.h"
  33. /* defines */
  34. /* error codes */
  35. #define S_aioPxLib_DRV_NUM_INVALID (M_aioPxLib | 1)
  36. #define S_aioPxLib_AIO_NOT_DEFINED (M_aioPxLib | 2)
  37. #define S_aioPxLib_IOS_NOT_INITIALIZED (M_aioPxLib | 3)
  38. #define S_aioPxLib_NO_AIO_DEVICE  (M_aioPxLib | 4)
  39. /* aio driver ioctl functions */
  40. #define  FAIO_PUSH 1 /* push request to head */
  41. #define  FAIO_CANCEL 2 /* cancel a request */
  42. /* aio control block states */
  43. #define AIO_FREE 0 /* not submitted */
  44. #define AIO_COMPLETED 1 /* completed */
  45. #define AIO_READY 2 /* ready to be submitted */
  46. #define AIO_QUEUED 3 /* queued */
  47. #define AIO_WAIT    4 /* waiting */
  48. #define AIO_RUNNING 5 /* running */
  49. #define AIO_CLUST_MAX           100             /* default max clusters */
  50. /* easy access to aio_sys */
  51. #define aio_state aio_sys.state
  52. #define aio_retVal  aio_sys.ioNode.retVal
  53. #define aio_errorVal aio_sys.ioNode.errorVal
  54. /* easy access to fd_entry */ 
  55. #define drv_value pFdEntry->value
  56. #define drv_num pFdEntry->pDevHdr->drvNum
  57. /* mark request done */
  58. #define AIO_DONE_SET(pAiocb, _ret, _err) 
  59.     {
  60.     (pAiocb)->aio_sys.state    = AIO_COMPLETED;
  61.     (pAiocb)->aio_sys.ioNode.retVal   = (_ret);
  62.     (pAiocb)->aio_sys.ioNode.errorVal = (_err);
  63.     }
  64. #define FD_NODE_TO_SYS(pNode)
  65. ((AIO_SYS *)(void *)((char *)(pNode) - offsetof(AIO_SYS, fdNode)))
  66. /* typedefs */
  67. typedef struct aio_clust /* aio cluster */
  68.     {
  69.     BOOL inuse; /* cluster in use */
  70.     int refCnt; /* reference count */
  71.     struct sigpend sigpend; /* signal */
  72.     mutex_t lock; /* lock cluster */
  73.     cond_t wake; /* cluster cond var */
  74.     } AIO_CLUST;
  75. typedef struct aio_sys /* aio system info */
  76.     {
  77.     IO_NODE ioNode; /* I/O queue node */
  78.     int state; /* state */
  79.     AIO_CLUST * pClust; /* lio cluster */
  80.     struct aiocb * pAiocb; /* A-I/O control block */
  81.     struct sigpend      sigpend; /* signal */
  82.     LIST wait;  /* wait list */
  83.     mutex_t lock; /* aiocb lock */
  84.     cond_t wake; /* aiocb cond var */
  85.     DL_NODE fdNode; /* node for fd list */
  86.     } AIO_SYS;
  87. typedef struct aio_wait_id /* wait structure */
  88.     {
  89.     NODE node; /* wait list node */
  90.     BOOL done; /* completed */
  91.     mutex_t lock; /* wait id lock */
  92.     cond_t wake; /* wait id cond var */
  93.     } AIO_WAIT_ID;
  94. typedef struct aio_dev /* driver A-I/O struct */
  95.     {
  96.     IO_Q ioQ; /* I/O queues */
  97.     } AIO_DEV;
  98. typedef struct aio_drv_entry /* A-I/O driver table entry */
  99.     {
  100.     BOOL inuse; /* entry in use */ 
  101.     FUNCPTR insert; /* insert routine */
  102.     FUNCPTR ioctl; /* ioctl routine */
  103.     int flags; /* driver specific flags */
  104.     } AIO_DRV_ENTRY;
  105. typedef struct aio_fd_entry /* A-I/O fd table entry */
  106.     {
  107.     FD_ENTRY * pFdEntry; /* fd entry */
  108.     DL_LIST  ioQ; /* I/O queue */
  109.     SEMAPHORE    ioQSem; /* semaphore for I/O queue */
  110.     BOOL ioQActive; /* I/O queue active */
  111.     } AIO_FD_ENTRY;
  112. extern FUNCPTR aioPrintRtn; /* for aioShow */
  113. /* forward declarations */
  114. #if defined(__STDC__) || defined(__cplusplus)
  115. extern STATUS aioDrvInstall (int drvnum, FUNCPTR pInsert, FUNCPTR pIoctl, 
  116.       int flags);
  117. extern STATUS  aioCancel (AIO_DEV * pDev, struct aiocb * pAiocb);
  118. extern STATUS  aioPush (AIO_DEV * pDev, struct aiocb * pAiocb);
  119. extern STATUS  aioSync (AIO_DEV * pDev, struct aiocb * pAiocb, 
  120.                  FUNCPTR syncReqRtn);
  121. extern void  aioDone (AIO_SYS * pReq);
  122. extern STATUS  aioDrvFlagsGet (int fd, int * pFlags);
  123. extern STATUS  aioDrvFlagsSet ( int fd, int flags);
  124. extern AIO_SYS *  aioNext (AIO_DEV * pDev);
  125. extern AIO_FD_ENTRY * aioEntryFind (int fd);
  126. #else /* __STDC__ */
  127. extern STATUS aioDrvInstall ();
  128. extern STATUS  aioCancel ();
  129. extern STATUS  aioPush ();
  130. extern STATUS  aioSync ();
  131. extern void  aioDone ();
  132. extern STATUS  aioDrvFlagsGet ();
  133. extern STATUS  aioDrvFlagsSet ();
  134. extern AIO_SYS *  aioNext ();
  135. extern AIO_FD_ENTRY * aioEntryFind ();
  136. #endif /* __STDC__ */
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif /* __INCaioPxLibh */