Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / networks / etherlink3 / io.h
blob09f41045a7d5456c7169904233b218232bb16608
1 /*
3 Copyright (C) 2004,2005 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 #include <exec/types.h>
27 #include <utility/tagitem.h>
29 #include "endian.h"
32 /* I/O tags */
34 #define IOTAG_ByteIn (TAG_USER + 0)
35 #define IOTAG_WordIn (TAG_USER + 1)
36 #define IOTAG_LongIn (TAG_USER + 2)
37 #define IOTAG_QuadIn (TAG_USER + 3)
38 #define IOTAG_ByteOut (TAG_USER + 4)
39 #define IOTAG_WordOut (TAG_USER + 5)
40 #define IOTAG_LongOut (TAG_USER + 6)
41 #define IOTAG_QuadOut (TAG_USER + 7)
42 #define IOTAG_BytesIn (TAG_USER + 8)
43 #define IOTAG_WordsIn (TAG_USER + 9)
44 #define IOTAG_LongsIn (TAG_USER + 10)
45 #define IOTAG_QuadsIn (TAG_USER + 11)
46 #define IOTAG_BytesOut (TAG_USER + 12)
47 #define IOTAG_WordsOut (TAG_USER + 13)
48 #define IOTAG_LongsOut (TAG_USER + 14)
49 #define IOTAG_QuadsOut (TAG_USER + 15)
50 #define IOTAG_BEWordIn (TAG_USER + 16)
51 #define IOTAG_BELongIn (TAG_USER + 17)
52 #define IOTAG_BEQuadIn (TAG_USER + 18)
53 #define IOTAG_BEWordOut (TAG_USER + 19)
54 #define IOTAG_BELongOut (TAG_USER + 20)
55 #define IOTAG_BEQuadOut (TAG_USER + 21)
56 #define IOTAG_BEWordsIn (TAG_USER + 22)
57 #define IOTAG_BELongsIn (TAG_USER + 23)
58 #define IOTAG_BEQuadsIn (TAG_USER + 24)
59 #define IOTAG_BEWordsOut (TAG_USER + 25)
60 #define IOTAG_BELongsOut (TAG_USER + 26)
61 #define IOTAG_BEQuadsOut (TAG_USER + 27)
62 #define IOTAG_LEWordIn (TAG_USER + 28)
63 #define IOTAG_LELongIn (TAG_USER + 29)
64 #define IOTAG_LEQuadIn (TAG_USER + 30)
65 #define IOTAG_LEWordOut (TAG_USER + 31)
66 #define IOTAG_LELongOut (TAG_USER + 32)
67 #define IOTAG_LEQuadOut (TAG_USER + 33)
68 #define IOTAG_LEWordsIn (TAG_USER + 34)
69 #define IOTAG_LELongsIn (TAG_USER + 35)
70 #define IOTAG_LEQuadsIn (TAG_USER + 36)
71 #define IOTAG_LEWordsOut (TAG_USER + 37)
72 #define IOTAG_LELongsOut (TAG_USER + 38)
73 #define IOTAG_LEQuadsOut (TAG_USER + 39)
74 #define IOTAG_AllocDMAMem (TAG_USER + 40)
75 #define IOTAG_FreeDMAMem (TAG_USER + 41)
78 /* I/O macros */
80 #ifdef __i386__
82 #define BYTEIN(address) \
83 ({ \
84 UBYTE _BYTEIN_value; \
85 __asm volatile ("inb %w1,%0":"=a" (_BYTEIN_value):"Nd" (address)); \
86 _BYTEIN_value; \
89 #define WORDIN(address) \
90 ({ \
91 UWORD _WORDIN_value; \
92 __asm volatile ("inw %w1,%0":"=a" (_WORDIN_value):"Nd" (address)); \
93 _WORDIN_value; \
96 #define LONGIN(address) \
97 ({ \
98 ULONG _LONGIN_value; \
99 __asm volatile ("inl %w1,%0":"=a" (_LONGIN_value):"Nd" (address)); \
100 _LONGIN_value; \
103 #define BYTEOUT(address, value) \
104 ({ \
105 __asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (address)); \
108 #define WORDOUT(address, value) \
109 ({ \
110 __asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (address)); \
113 #define LONGOUT(address, value) \
114 ({ \
115 __asm volatile ("outl %0,%w1": :"a" (value), "Nd" (address)); \
118 #else
120 #define BYTEIN(address) \
121 (*((volatile UBYTE *)(address)))
123 #define WORDIN(address) \
124 (*((volatile UWORD *)(address)))
126 #define LONGIN(address) \
127 (*((volatile ULONG *)(address)))
129 #define BYTEOUT(address, value) \
130 *((volatile UBYTE *)(address)) = (value)
132 #define WORDOUT(address, value) \
133 *((volatile UWORD *)(address)) = (value)
135 #define LONGOUT(address, value) \
136 *((volatile ULONG *)(address)) = (value)
138 #endif
140 #define WORDSIN(address, data, count) \
141 ({ \
142 ULONG _WORDSIN_i = (count); \
143 UWORD *_WORDSIN_p = (data); \
144 while(_WORDSIN_i-- != 0) \
145 *_WORDSIN_p++ = WORDIN(address); \
146 _WORDSIN_p; \
149 #define LONGSIN(address, data, count) \
150 ({ \
151 ULONG _LONGSIN_i = (count); \
152 ULONG *_LONGSIN_p = (data); \
153 while(_LONGSIN_i-- != 0) \
154 *_LONGSIN_p++ = LONGIN(address); \
155 _LONGSIN_p; \
158 #define WORDSOUT(address, data, count) \
159 do \
161 ULONG _WORDSOUT_i = (count); \
162 const UWORD *_WORDSOUT_p = (data); \
163 while(_WORDSOUT_i-- != 0) \
164 WORDOUT(address, *_WORDSOUT_p++); \
166 while(0)
168 #define LONGSOUT(address, data, count) \
169 do \
171 ULONG _LONGSOUT_i = (count); \
172 const ULONG *_LONGSOUT_p = (data); \
173 while(_LONGSOUT_i-- != 0) \
174 LONGOUT(address, *_LONGSOUT_p++); \
176 while(0)
178 #define BEWORDOUT(address, value) \
179 WORDOUT(address, MakeBEWord(value))
181 #define LEWORDIN(address) \
182 LEWord(WORDIN(address))
184 #define LEWORDOUT(address, value) \
185 WORDOUT(address, MakeLEWord(value))
187 #define LELONGIN(address) \
188 LELong(LONGIN(address))
190 #define LELONGOUT(address, value) \
191 LONGOUT(address, MakeLELong(value))
193 #define LEWORDSIN(address, data, count) \
194 ({ \
195 ULONG _LEWORDSIN_i = (count); \
196 UWORD *_LEWORDSIN_p = (data); \
197 while(_LEWORDSIN_i-- != 0) \
198 *_LEWORDSIN_p++ = LEWORDIN(address); \
199 _LEWORDSIN_p; \
203 #endif