Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / arossupport / include / io.h
blobbbe8c53ffc54918b637e4a42a4faae0616c634df
1 #ifndef AROS_IO_H
2 #define AROS_IO_H
4 /*
5 Copyright © 2006, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: I/O macros
9 Lang: english
12 #ifndef AROS_MACROS_H
13 # include <aros/macros.h>
14 #endif
17 /* I/O macros */
19 #ifdef __i386__
21 #define BYTEIN(address) \
22 ({ \
23 UBYTE _BYTEIN_value; \
24 __asm volatile ("inb %w1,%0":"=a" (_BYTEIN_value):"Nd" (address)); \
25 _BYTEIN_value; \
28 #define WORDIN(address) \
29 ({ \
30 UWORD _WORDIN_value; \
31 __asm volatile ("inw %w1,%0":"=a" (_WORDIN_value):"Nd" (address)); \
32 _WORDIN_value; \
35 #define LONGIN(address) \
36 ({ \
37 ULONG _LONGIN_value; \
38 __asm volatile ("inl %w1,%0":"=a" (_LONGIN_value):"Nd" (address)); \
39 _LONGIN_value; \
42 #define BYTEOUT(address, value) \
43 ({ \
44 __asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (address)); \
47 #define WORDOUT(address, value) \
48 ({ \
49 __asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (address)); \
52 #define LONGOUT(address, value) \
53 ({ \
54 __asm volatile ("outl %0,%w1": :"a" (value), "Nd" (address)); \
57 #else
59 #define BYTEIN(address) \
60 (*((volatile UBYTE *)(address)))
62 #define WORDIN(address) \
63 (*((volatile UWORD *)(address)))
65 #define LONGIN(address) \
66 (*((volatile ULONG *)(address)))
68 #define BYTEOUT(address, value) \
69 *((volatile UBYTE *)(address)) = (value)
71 #define WORDOUT(address, value) \
72 *((volatile UWORD *)(address)) = (value)
74 #define LONGOUT(address, value) \
75 *((volatile ULONG *)(address)) = (value)
77 #endif
79 #define WORDSIN(address, data, count) \
80 ({ \
81 ULONG _WORDSIN_i = (count); \
82 UWORD *_WORDSIN_p = (data); \
83 while(_WORDSIN_i-- != 0) \
84 *_WORDSIN_p++ = WORDIN(address); \
85 _WORDSIN_p; \
88 #define LONGSIN(address, data, count) \
89 ({ \
90 ULONG _LONGSIN_i = (count); \
91 ULONG *_LONGSIN_p = (data); \
92 while(_LONGSIN_i-- != 0) \
93 *_LONGSIN_p++ = LONGIN(address); \
94 _LONGSIN_p; \
97 #define WORDSOUT(address, data, count) \
98 do \
99 { \
100 ULONG _WORDSOUT_i = (count); \
101 const UWORD *_WORDSOUT_p = (data); \
102 while(_WORDSOUT_i-- != 0) \
103 WORDOUT(address, *_WORDSOUT_p++); \
105 while(0)
107 #define LONGSOUT(address, data, count) \
108 do \
110 ULONG _LONGSOUT_i = (count); \
111 const ULONG *_LONGSOUT_p = (data); \
112 while(_LONGSOUT_i-- != 0) \
113 LONGOUT(address, *_LONGSOUT_p++); \
115 while(0)
117 #define BEWORDOUT(address, value) \
118 WORDOUT(address, AROS_WORD2BE(value))
120 #define LEWORDIN(address) \
121 AROS_LE2WORD(WORDIN(address))
123 #define LEWORDOUT(address, value) \
124 WORDOUT(address, AROS_WORD2LE(value))
126 #define LELONGIN(address) \
127 AROS_LE2LONG(LONGIN(address))
129 #define LELONGOUT(address, value) \
130 LONGOUT(address, AROS_LONG2LE(value))
132 #define LEWORDSIN(address, data, count) \
133 ({ \
134 ULONG _LEWORDSIN_i = (count); \
135 UWORD *_LEWORDSIN_p = (data); \
136 while(_LEWORDSIN_i-- != 0) \
137 *_LEWORDSIN_p++ = LEWORDIN(address); \
138 _LEWORDSIN_p; \
141 #endif /* AROS_IO_H */