grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / networks / rhine / io.h
blob47c1a69863892044ebd091bc6b3ebc428d328d39
1 /*
3 Copyright (C) 2004-2011 Neil Cafferkey
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA.
22 #ifndef IO_H
23 #define IO_H
26 /* I/O tags */
28 #define IOTAG_ByteIn (TAG_USER + 0)
29 #define IOTAG_WordIn (TAG_USER + 1)
30 #define IOTAG_LongIn (TAG_USER + 2)
31 #define IOTAG_QuadIn (TAG_USER + 3)
32 #define IOTAG_ByteOut (TAG_USER + 4)
33 #define IOTAG_WordOut (TAG_USER + 5)
34 #define IOTAG_LongOut (TAG_USER + 6)
35 #define IOTAG_QuadOut (TAG_USER + 7)
36 #define IOTAG_BytesIn (TAG_USER + 8)
37 #define IOTAG_WordsIn (TAG_USER + 9)
38 #define IOTAG_LongsIn (TAG_USER + 10)
39 #define IOTAG_QuadsIn (TAG_USER + 11)
40 #define IOTAG_BytesOut (TAG_USER + 12)
41 #define IOTAG_WordsOut (TAG_USER + 13)
42 #define IOTAG_LongsOut (TAG_USER + 14)
43 #define IOTAG_QuadsOut (TAG_USER + 15)
44 #define IOTAG_BEWordIn (TAG_USER + 16)
45 #define IOTAG_BELongIn (TAG_USER + 17)
46 #define IOTAG_BEQuadIn (TAG_USER + 18)
47 #define IOTAG_BEWordOut (TAG_USER + 19)
48 #define IOTAG_BELongOut (TAG_USER + 20)
49 #define IOTAG_BEQuadOut (TAG_USER + 21)
50 #define IOTAG_BEWordsIn (TAG_USER + 22)
51 #define IOTAG_BELongsIn (TAG_USER + 23)
52 #define IOTAG_BEQuadsIn (TAG_USER + 24)
53 #define IOTAG_BEWordsOut (TAG_USER + 25)
54 #define IOTAG_BELongsOut (TAG_USER + 26)
55 #define IOTAG_BEQuadsOut (TAG_USER + 27)
56 #define IOTAG_LEWordIn (TAG_USER + 28)
57 #define IOTAG_LELongIn (TAG_USER + 29)
58 #define IOTAG_LEQuadIn (TAG_USER + 30)
59 #define IOTAG_LEWordOut (TAG_USER + 31)
60 #define IOTAG_LELongOut (TAG_USER + 32)
61 #define IOTAG_LEQuadOut (TAG_USER + 33)
62 #define IOTAG_LEWordsIn (TAG_USER + 34)
63 #define IOTAG_LELongsIn (TAG_USER + 35)
64 #define IOTAG_LEQuadsIn (TAG_USER + 36)
65 #define IOTAG_LEWordsOut (TAG_USER + 37)
66 #define IOTAG_LELongsOut (TAG_USER + 38)
67 #define IOTAG_LEQuadsOut (TAG_USER + 39)
68 #define IOTAG_AllocDMAMem (TAG_USER + 40)
69 #define IOTAG_FreeDMAMem (TAG_USER + 41)
70 #define IOTAG_SendFrame (TAG_USER + 42)
71 #define IOTAG_ReceiveFrame (TAG_USER + 43)
74 /* I/O macros */
76 #ifdef __i386__
78 #define BYTEIN(address) \
79 ({ \
80 UBYTE _BYTEIN_value; \
81 __asm volatile ("inb %w1,%0":"=a" (_BYTEIN_value):"Nd" (address)); \
82 _BYTEIN_value; \
85 #define WORDIN(address) \
86 ({ \
87 UWORD _WORDIN_value; \
88 __asm volatile ("inw %w1,%0":"=a" (_WORDIN_value):"Nd" (address)); \
89 _WORDIN_value; \
92 #define LONGIN(address) \
93 ({ \
94 ULONG _LONGIN_value; \
95 __asm volatile ("inl %w1,%0":"=a" (_LONGIN_value):"Nd" (address)); \
96 _LONGIN_value; \
99 #define BYTEOUT(address, value) \
100 ({ \
101 __asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (address)); \
104 #define WORDOUT(address, value) \
105 ({ \
106 __asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (address)); \
109 #define LONGOUT(address, value) \
110 ({ \
111 __asm volatile ("outl %0,%w1": :"a" (value), "Nd" (address)); \
114 #else
116 #define BYTEIN(address) \
117 (*((volatile UBYTE *)(address)))
119 #define WORDIN(address) \
120 (*((volatile UWORD *)(address)))
122 #define LONGIN(address) \
123 (*((volatile ULONG *)(address)))
125 #define BYTEOUT(address, value) \
126 *((volatile UBYTE *)(address)) = (value)
128 #define WORDOUT(address, value) \
129 *((volatile UWORD *)(address)) = (value)
131 #define LONGOUT(address, value) \
132 *((volatile ULONG *)(address)) = (value)
134 #endif
136 #define WORDSIN(address, data, count) \
137 ({ \
138 ULONG _WORDSIN_i = (count); \
139 UWORD *_WORDSIN_p = (data); \
140 while(_WORDSIN_i-- != 0) \
141 *_WORDSIN_p++ = WORDIN(address); \
142 _WORDSIN_p; \
145 #define LONGSIN(address, data, count) \
146 ({ \
147 ULONG _LONGSIN_i = (count); \
148 ULONG *_LONGSIN_p = (data); \
149 while(_LONGSIN_i-- != 0) \
150 *_LONGSIN_p++ = LONGIN(address); \
151 _LONGSIN_p; \
154 #define WORDSOUT(address, data, count) \
155 do \
157 ULONG _WORDSOUT_i = (count); \
158 const UWORD *_WORDSOUT_p = (data); \
159 while(_WORDSOUT_i-- != 0) \
160 WORDOUT(address, *_WORDSOUT_p++); \
162 while(0)
164 #define LONGSOUT(address, data, count) \
165 do \
167 ULONG _LONGSOUT_i = (count); \
168 const ULONG *_LONGSOUT_p = (data); \
169 while(_LONGSOUT_i-- != 0) \
170 LONGOUT(address, *_LONGSOUT_p++); \
172 while(0)
174 #define BEWORDOUT(address, value) \
175 WORDOUT(address, MakeBEWord(value))
177 #define LEWORDIN(address) \
178 LEWord(WORDIN(address))
180 #define LEWORDOUT(address, value) \
181 WORDOUT(address, MakeLEWord(value))
183 #define LELONGIN(address) \
184 LELong(LONGIN(address))
186 #define LELONGOUT(address, value) \
187 LONGOUT(address, MakeLELong(value))
189 #define LEWORDSIN(address, data, count) \
190 ({ \
191 ULONG _LEWORDSIN_i = (count); \
192 UWORD *_LEWORDSIN_p = (data); \
193 while(_LEWORDSIN_i-- != 0) \
194 *_LEWORDSIN_p++ = LEWORDIN(address); \
195 _LEWORDSIN_p; \
199 #endif