home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / common / ibmIOArch.h < prev    next >
C/C++ Source or Header  |  1991-09-20  |  6KB  |  160 lines

  1. /*
  2.  * Copyright IBM Corporation 1987,1988,1989
  3.  *
  4.  * All Rights Reserved
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted,
  8.  * provided that the above copyright notice appear in all copies and that 
  9.  * both that copyright notice and this permission notice appear in
  10.  * supporting documentation, and that the name of IBM not be
  11.  * used in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20.  * SOFTWARE.
  21.  *
  22. */
  23. /***********************************************************
  24.         Copyright IBM Corporation 1988
  25.  
  26.                       All Rights Reserved
  27.  
  28. Permission to use, copy, modify, and distribute this software and its 
  29. documentation for any purpose and without fee is hereby granted, 
  30. provided that the above copyright notice appear in all copies and that
  31. both that copyright notice and this permission notice appear in 
  32. supporting documentation, and that the name of IBM not be
  33. used in advertising or publicity pertaining to distribution of the
  34. software without specific, written prior permission.  
  35.  
  36. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  37. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  38. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  39. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  40. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  41. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  42. SOFTWARE.
  43.  
  44. ******************************************************************/
  45. #ifndef __HAVE_IO_ARCHITECTURE__
  46. #define __HAVE_IO_ARCHITECTURE__
  47. /* $Header: /x11/R5/mit/server/ddx/ibmps2/common/RCS/ibmIOArch.h,v 1.1 1991/09/20 18:24:03 mtranle Exp $ */
  48. /* $Source: /x11/R5/mit/server/ddx/ibmps2/common/RCS/ibmIOArch.h,v $ */
  49.  
  50. /*
  51.  * --- FOR 6152
  52.  * References to all pc ( i.e. '286 ) memory in the
  53.  * regions used by the X server ( the 128K windows )
  54.  * MUST be long-word ( i.e. 32-bit ) reads or writes.
  55.  * --- FOR RTPC
  56.  * Natural Alignment For Memory-Mapped I/O
  57.  * --- FOR PS2
  58.  * Natural Alignment For Memory-Mapped I/O
  59.  *
  60.  * --- NOTE:
  61.  * These definitions will change for other memory
  62.  * architectures or operating systems ( e.g. AIX-Rt )
  63.  */
  64.  
  65. #if defined(lint) || defined(PCIO) || defined(i386) || defined(iAPX286)
  66.  
  67. #if defined(__GNUC__) && defined(i386)
  68. #define inb( port )                 \
  69. ({ unsigned char  __value;          \
  70.    unsigned short  __addr = (port); \
  71.    __asm volatile ("inb (%1)"       \
  72.            : "=a" (__value) \
  73.            : "d" (__addr)); \
  74.    __value;                         \
  75.  })
  76.  
  77. #define inw( port )                 \
  78. ({ unsigned short __value;          \
  79.    unsigned short __addr = (port);  \
  80.    __asm volatile ("inw (%1)"       \
  81.            : "=a" (__value) \
  82.            : "d" (__addr)); \
  83.    __value;                         \
  84.  })
  85.  
  86. #define outb( port, val8 )                         \
  87. ({ unsigned short __addr = (port);                 \
  88.    unsigned char  __value = (val8);                \
  89.    __asm volatile ("outb (%1)"                     \
  90.            : /* no output */               \
  91.            : "a" (__value), "d" (__addr)); \
  92.  })
  93.  
  94. #define outw( port, val16 )                        \
  95. ({ unsigned short __addr = (port);                 \
  96.    unsigned short __value = (val16);               \
  97.    __asm volatile ("outw (%1)"                     \
  98.            : /* no output */               \
  99.            : "a" (__value), "d" (__addr)); \
  100.  })
  101. #else
  102. extern unsigned char inb( ) ;
  103. extern unsigned char outb( ) ;
  104. extern unsigned short int inw( ) ;
  105. extern unsigned short outw( ) ;
  106. #endif /* __GNUC__ && i386 */
  107.  
  108. extern void INTS_ON() ;
  109. extern void INTS_OFF() ;
  110.  
  111. #else
  112.  
  113. #define INTS_ON() /**/
  114. #define INTS_OFF() /**/
  115.  
  116. #ifdef ATRIO
  117.  
  118. #define inb( pc_io_address ) ( ( *( (volatile unsigned long int *) \
  119.     ( 0xD00F0000 | ( ( pc_io_address ) ) ) ) ) )
  120. #define inw( pc_io_address ) ( ( *( (volatile unsigned long int *) \
  121.     ( 0xD00E0000 | ( ( pc_io_address ) ) ) ) ) )
  122. #define outb( pc_io_address, value ) ( ( *( (volatile unsigned long int *) \
  123.     ( 0xD00F0000 | ( pc_io_address ) ) ) = ( value ) ) )
  124. #define outw( pc_io_address, value ) ( ( *( (volatile unsigned long int *) \
  125.     ( 0xD00E0000 | ( ( pc_io_address ) ) ) ) = ( value ) ) )
  126.  
  127. #else
  128. #ifdef RTIO
  129. /* For Normal RT-PC */
  130.  
  131. #define inb( pc_io_address ) ( ( *( (volatile unsigned char *) \
  132.     ( 0xF0000000 | ( ( pc_io_address ) ) ) ) ) )
  133. #define inw( pc_io_address ) ( ( *( (volatile unsigned short *) \
  134.     ( 0xF0000000 | ( ( pc_io_address ) ) ) ) ) )
  135. #define outb( pc_io_address, value ) ( ( *( (volatile unsigned char *) \
  136.     ( 0xF0000000 | ( pc_io_address ) ) ) = ( value ) ) )
  137. #define outw( pc_io_address, value ) (( *( (volatile unsigned short *) \
  138.      ( 0xF0000000 | ( ( pc_io_address ) ) ) ) = ( value ) ) )
  139. #endif
  140. #endif
  141. #endif
  142.  
  143. /* So that lint doesn't complain about constructs it doesn't understand */
  144. #ifdef lint
  145. #ifdef volatile
  146. #undef volatile
  147. #endif
  148. #define volatile /**/
  149. #ifdef const
  150. #undef const
  151. #endif
  152. #define const    /**/
  153. #ifdef signed
  154. #undef signed
  155. #endif
  156. #define signed   /**/
  157. #endif
  158.  
  159. #endif /* __HAVE_IO_ARCHITECTURE__ */
  160.