Watt-32 tcp/ip  2.2 dev-rel.10
ioport.h
Go to the documentation of this file.
1 
3 #ifndef _w32_IOPORT_H
4 #define _w32_IOPORT_H
5 
6 /*
7  * Make sure <conio.h> (or <pc.h> for djgpp) gets included
8  */
9 #if !defined(_w32_TARGET_H)
10 #error You must include IOPORT.H after TARGET.H
11 #endif
12 
13 /*
14  * Macros necessary to bypass the limitation of Borland's BCC32 not
15  * to allow inline port functions. Assignements should be volatile,
16  * check the .asm output.
17  * NB! macro-args must be TASM/MASM compatible
18  */
19 
20 #if defined(__BORLANDC__) && defined(__FLAT__)
21  #define VOLATILE volatile
22  #define __in(p,t,z) ( _DX = (unsigned short)(p),__emit__(0xEC+z),(unsigned t)_AX )
23  #define __out(p,x,z) { _AX = (unsigned short)(x); _DX = (unsigned short)(p);__emit__(0xEE+z); }
24  #define _inportb(p) __in(p,char,0)
25  #define _inportw(p) __in(p,short,1)
26  #define _outportb(p,x) __out(p,x,0)
27  #define _outportw(p,x) __out(p,x,1)
28 
29 #elif defined(__HIGHC__)
30  #define _inportb(p) _inb(p)
31  #define _inportw(p) _inw(p)
32  #define _outportb(p,x) _outb(p,x)
33  #define _outportw(p,x) _outpw(p,x)
34  #define VOLATILE
35 
36 #elif defined(__DJGPP__) || defined(__EMX__)
37  #define _inportb(p) inportb(p)
38  #define _inport(p) inportw(p)
39  #define _outportb(p,x) outportb(p,x)
40  #define _outportw(p,x) outportw(p,x)
41  #define VOLATILE
42 
43 #elif defined(_MSC_VER) && (_MSC_VER >= 800)
44  #include <conio.h>
45  #pragma intrinsic (_inp, _inpw, _outp, _outpw)
46  #define _inportb(p) _inp(p)
47  #define _inportw(p) _inpw(p)
48  #define _outportb(p,x) _outp(p,x)
49  #define _outportw(p,x) _outpw(p,x)
50  #define VOLATILE
51 
52 #else
53  #define _inportb(p) inp(p)
54  #define _inportw(p) inpw(p)
55  #define _outportb(p,x) outp(p,x)
56  #define _outportw(p,x) outpw(p,x)
57  #define VOLATILE
58 #endif
59 
60 #if defined(__EMX__)
61 
62 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
63 
64 extern __inline__ unsigned char inportb (unsigned short port)
65 {
66  unsigned char rc;
67  __asm__ __volatile__ (
68  "inb %1, %0"
69  : "=a" (rc)
70  : "dN" (port));
71  return (rc);
72 }
73 
74 extern __inline__ unsigned short inportw (unsigned short port)
75 {
76  unsigned short rc;
77  __asm__ __volatile__ (
78  "inw %1, %0"
79  : "=a" (rc)
80  : "dN" (port));
81  return (rc);
82 }
83 
84 extern __inline__ void outportb (unsigned short port, unsigned char data)
85 {
86  __asm__ __volatile__ (
87  "outb %1, %0"
88  :: "dN" (port),
89  "a" (data));
90 }
91 
92 extern __inline__ void outportw (unsigned short port, unsigned short data)
93 {
94  __asm__ __volatile__ (
95  "outw %1, %0"
96  :: "dN" (port),
97  "a" (data));
98 }
99 #endif /* __EMX__ */
100 #endif /* _w32_IOPORT_H */
101