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

VxWorks

开发平台:

C/C++

  1. /* tyLib.h - tty handler support library header */
  2. /* Copyright 1984-1992 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 03c,08may97,db   added numOpen entry to TY_DEV structure(SPR #7637).
  7. 03b,22sep92,rrr  added support for c++
  8. 03a,04jul92,jcf  cleaned up.
  9. 02u,26may92,rrr  the tree shuffle
  10. 02t,04oct91,rrr  passed through the ansification filter
  11.   -changed VOID to void
  12.   -changed copyright notice
  13. 02s,11jul91,jwt  removed divisible bit-field operations in TY_DEV structure.
  14. 02r,05oct90,shl  added ANSI function prototypes.
  15.                  made #endif ANSI style.
  16.                  added copyright notice.
  17. 02q,07aug90,shl  added function declarations comment.
  18. 02p,26jun90,jcf  embedded the TY_DEV semaphores.
  19. 02o,12may90,gae  added IMPORTs of ty{Read,Write,ITx,IRd}.
  20.  removed unused wdog.  changed UTINY to UINT8.
  21. 02n,29mar90,rdc  reworked to lower interrupt latency.
  22. 02m,16mar90,rdc  added select support.
  23. 02l,27jul89,hjb  added protoHook and protoArg to TY_DEV.
  24. 02k,18nov88,dnw  removed NOT_GENERIC stuff.
  25. 02j,04may88,jcf  changed SEMAPHORE to SEM_ID.
  26. 02i,15jun87,ecs  added canceled to rdState & wrtState of TY_DEV.
  27. 02h,24dec86,gae  changed stsLib.h to vwModNum.h.
  28. 02g,07apr86,dnw  removed ST_ERROR status and added rdError flag to smpte mode.
  29. 02f,23mar86,jlf  changed GENERIC to NOT_GENERIC.
  30. 02e,22aug85,dnw  replaced xState with rdState and wrtState structures.
  31.  added rdSmpteState and wrtSmpteState to SMPTE only version.
  32. 02d,16aug84,dnw  removed S_tyLib_SMPTE_READ_ERROR from GENERIC version.
  33.  added lnNBytes and lnBytesLeft members to TY_DEV for
  34.    line-protocol mode.
  35. 02c,15aug84,jlf  changed back to tyLib.h
  36. 02b,13aug84,ecs  got rid of S_tyLib_UNKNOWN_REQUEST.
  37.  changed S_tyLib_READ_ERROR to S_tyLib_SMPTE_READ_ERROR.
  38. 02a,10aug84,jlf  changed to tyLib.hx - new mega-file format.
  39. 01g,08aug84,ecs  added include of stsLib.h, status codes.
  40. 01f,15jun84,dnw  changed TY_DEV to work with new i/o system and ring buffer lib.
  41. 01e,27jan84,ecs  added inclusion test.
  42. 01d,15sep83,dnw  added xon/xoff stuff: xState field in TY_DEV and definitions
  43.    of states XST_...
  44. 01c,29jul83,dnw  added ST_TX_CR and removed txStopped.
  45.  diddled with TY_DEV to make it simpler & more consistent.
  46.  fiddled with device states to put them in order and
  47.    confuse the innocent.
  48. 01b,22jul83,ecs  added options & status, changed expectCk to TBOOL.
  49. 01a,24jun83,ecs  written
  50. */
  51. #ifndef __INCtyLibh
  52. #define __INCtyLibh
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. #include "iosLib.h"
  57. #include "rngLib.h"
  58. #include "selectLib.h"
  59. #include "vwModNum.h"
  60. #include "private/semLibP.h"
  61. /* HIDDEN */
  62. typedef struct /* TY_DEV - tty device descriptor */
  63.     {
  64.     DEV_HDR devHdr; /* I/O device header */
  65.     RING_ID rdBuf; /* ring buffer for read */
  66.     SEMAPHORE rdSyncSem; /* reader synchronization semaphore */
  67.     SEMAPHORE mutexSem; /* mutual exclusion semaphore */
  68.     struct /* current state of the read channel */
  69. {
  70. unsigned char xoff;     /* input has been XOFF'd */
  71. unsigned char pending;  /* XON/XOFF will be sent when xmtr is free*/
  72.         unsigned char canceled; /* read has been canceled */
  73. unsigned char flushingRdBuf; /* critical section marker */
  74. } rdState;
  75.     RING_ID wrtBuf; /* ring buffer for write */
  76.     SEMAPHORE wrtSyncSem; /* writer synchronization semaphore */
  77.     struct /* current state of the write channel */
  78. {
  79. unsigned char busy;     /* transmitter is busy sending character */
  80. unsigned char xoff;     /* output has been XOFF'd */
  81. unsigned char cr;       /* CR should be inserted next (after LF) */
  82.         unsigned char canceled; /* write has been canceled */
  83. unsigned char flushingWrtBuf; /* critical section marker */
  84. unsigned char wrtBufBusy; /* task level writing to buffer */
  85. } wrtState;
  86.     UINT8 lnNBytes; /* number of bytes in unfinished new line */
  87.     UINT8 lnBytesLeft; /* number of bytes left in incompletely
  88.    dequeued line */
  89.     unsigned short options; /* options in effect for this channel */
  90.     FUNCPTR txStartup; /* pointer to routine to start xmitter */
  91.     FUNCPTR protoHook; /* protocol specific hook routine */
  92.     int protoArg; /* protocol specific argument */
  93.     SEL_WAKEUP_LIST selWakeupList;/* tasks that are selected on this dev */
  94.     int numOpen; /* number of open paths to device */
  95.     } TY_DEV;
  96. /* END_HIDDEN */
  97. typedef TY_DEV * TY_DEV_ID;
  98. /* function declarations */
  99. #if defined(__STDC__) || defined(__cplusplus)
  100. extern STATUS  tyDevInit (TY_DEV_ID pTyDev, int rdBufSize, int wrtBufSize,
  101.    FUNCPTR txStartup);
  102. extern STATUS  tyITx (TY_DEV_ID pTyDev, char *pChar);
  103. extern STATUS  tyIRd (TY_DEV_ID pTyDev, char inchar);
  104. extern STATUS  tyIoctl (TY_DEV_ID pTyDev, int request, int arg);
  105. extern int  tyRead (TY_DEV_ID pTyDev, char *buffer, int maxbytes);
  106. extern int  tyWrite (TY_DEV_ID pTyDev, char *buffer, int nbytes);
  107. extern void  tyAbortFuncSet (FUNCPTR func);
  108. extern void  tyAbortSet (char ch);
  109. extern void  tyBackspaceSet (char ch);
  110. extern void  tyDeleteLineSet (char ch);
  111. extern void  tyEOFSet (char ch);
  112. extern void  tyMonitorTrapSet (char ch);
  113. #else /* __STDC__ */
  114. extern STATUS  tyDevInit ();
  115. extern STATUS  tyIRd ();
  116. extern STATUS  tyITx ();
  117. extern STATUS  tyIoctl ();
  118. extern int  tyRead ();
  119. extern int  tyWrite ();
  120. extern void  tyAbortFuncSet ();
  121. extern void  tyAbortSet ();
  122. extern void  tyBackspaceSet ();
  123. extern void  tyDeleteLineSet ();
  124. extern void  tyEOFSet ();
  125. extern void  tyMonitorTrapSet ();
  126. #endif /* __STDC__ */
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif /* __INCtyLibh */