home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / famapi.zip / INCLUDE.ZIP / _PORTINT.H < prev    next >
C/C++ Source or Header  |  1992-12-30  |  4KB  |  115 lines

  1. /*
  2.  *      **************************************************************
  3.  *       JdeBP C++ Library Routines      General Public Licence v1.00
  4.  *          Copyright (c) 1991,1992  Jonathan de Boyne Pollard
  5.  *      **************************************************************
  6.  *
  7.  * PORT I/O and DOS/BIOS INTERRUPTS (MS-DOS)
  8.  *
  9.  */
  10.  
  11. #if !defined(___PORTINT_H_INCLUDED)
  12.  
  13. //
  14. // manifest constants for _hardresume result parameter
  15. //
  16. #define _HARDERR_IGNORE     0   /* Ignore the error */
  17. #define _HARDERR_RETRY      1   /* Retry the operation */
  18. #define _HARDERR_ABORT      2   /* Abort program issuing Interrupt 23h */
  19. #define _HARDERR_FAIL       3   /* Fail the system call in progress */
  20.                     /* _HARDERR_FAIL is not supported on DOS 2.x */
  21.  
  22. //
  23. //  Register packs
  24. //
  25. #ifndef _REGS_DEFINED
  26. struct  WORDREGS {
  27.     unsigned int    ax, bx, cx, dx, si, di, cflag, flags;
  28. };
  29. struct  BYTEREGS {
  30.     unsigned char   al, ah, bl, bh, cl, ch, dl, dh;
  31. };
  32. struct  SREGS   {
  33.     unsigned int    es, cs, ss, ds;
  34. };
  35. union   REGS    {
  36.     struct  WORDREGS x;
  37.     struct  BYTEREGS h;
  38. };
  39. struct  REGPACK {
  40.     unsigned    r_ax, r_bx, r_cx, r_dx;
  41.     unsigned    r_bp, r_si, r_di, r_ds, r_es, r_flags;
  42. };
  43. #define _REGS_DEFINED
  44. #endif
  45.  
  46. extern "C" {
  47.  
  48. int         _CDECL  bdos        (int, unsigned int, unsigned int);
  49. void        _CDECL  (_disable)  (void);
  50. void        _CDECL  (_enable)   (void);
  51. void        _CDECL  _harderr    (void (_far *)());
  52. void        _CDECL  _hardresume (int);
  53. void        _CDECL  _hardretn   (int);
  54. int         _CDECL  intdos      (union REGS *, union REGS *);
  55. int         _CDECL  intdosx     (union REGS *, union REGS *, struct SREGS *);
  56. int         _CDECL  int86       (int, union REGS *, union REGS *);
  57. int         _CDECL  int86x      (int, union REGS *, union REGS *, struct SREGS *);
  58. void        _CDECL  segread     (struct SREGS *);
  59.  
  60. int         _CDECL  (inp)   (unsigned);
  61. unsigned    _CDECL  (inpw)  (unsigned);
  62. int         _CDECL  (outp)  (unsigned, int);
  63. unsigned    _CDECL  (outpw) (unsigned, unsigned);
  64.  
  65. #if __BORLANDC__
  66. unsigned char   _CDECL  inportb (int);
  67. unsigned int    _CDECL  inport  (int);
  68. void            _CDECL  outportb    (int, unsigned char);
  69. void            _CDECL  outport     (int, unsigned int);
  70. #endif
  71.  
  72. #if __BORLANDC__
  73. //
  74. // Borland C uses a system whereby __double_underscore_functions__ are
  75. // expanded to inline code by the compiler.
  76. //
  77. void        _CDECL      __emit__    (unsigned char __byte, ...);
  78. void        _CDECL      __cli__     (void);
  79. void        _CDECL      __sti__     (void);
  80. void        _CDECL      __int__     (int);
  81. unsigned char   _CDECL  __inportb__ (int);
  82. unsigned int    _CDECL  __inportw__ (int);
  83. void        _CDECL      __outportb__(int, unsigned char);
  84. void        _CDECL      __outportw__(int, unsigned int);
  85. #endif
  86.  
  87. }
  88.  
  89. //
  90. //  Macro Overrides
  91. //
  92.  
  93. #if __BORLANDC__
  94. #define inp(p)          __inportb__(p)
  95. #define outp(p,v)      (__outportb__(p,v), (int)_AL)
  96. #define inpw(p)         __inportw__(p)
  97. #define outpw(p,v)     (__outportw__(p,v), (unsigned)_AX)
  98. #define inportb         __inportb__
  99. #define inport          __inportw__
  100. #define outportb        __outportb__
  101. #define outport         __outportw__
  102. #define disable( )      __emit__( (char)( 0xfa ) )
  103. #define enable( )       __emit__( (char)( 0xfb ) )
  104. #define geninterrupt(i) __int__(i)
  105. #endif
  106.  
  107. #if __MSC__
  108. #define _disable( ) __emit__( (char )( 0xfa ) ) /* MSC name */
  109. #define _enable( )  __emit__( (char )( 0xfb ) ) /* MSC name */
  110. #endif
  111.  
  112. #define ___PORTINT_H_INCLUDED
  113. #endif
  114.  
  115.