Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / networks / rtl8029 / io.h
blob2c36e09d5b74a644b85a5028ecd35ce989845342
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 /* I/O macros */
28 #ifdef __i386__
30 #define BYTEIN(address) \
31 ({ \
32 UBYTE _BYTEIN_value; \
33 __asm volatile ("inb %w1,%0":"=a" (_BYTEIN_value):"Nd" (address)); \
34 _BYTEIN_value; \
37 #define WORDIN(address) \
38 ({ \
39 UWORD _WORDIN_value; \
40 __asm volatile ("inw %w1,%0":"=a" (_WORDIN_value):"Nd" (address)); \
41 _WORDIN_value; \
44 #define LONGIN(address) \
45 ({ \
46 ULONG _LONGIN_value; \
47 __asm volatile ("inl %w1,%0":"=a" (_LONGIN_value):"Nd" (address)); \
48 _LONGIN_value; \
51 #define BYTEOUT(address, value) \
52 ({ \
53 __asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (address)); \
56 #define WORDOUT(address, value) \
57 ({ \
58 __asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (address)); \
61 #define LONGOUT(address, value) \
62 ({ \
63 __asm volatile ("outl %0,%w1": :"a" (value), "Nd" (address)); \
66 #else
68 #define BYTEIN(address) \
69 (*((volatile UBYTE *)(address)))
71 #define WORDIN(address) \
72 (*((volatile UWORD *)(address)))
74 #define LONGIN(address) \
75 (*((volatile ULONG *)(address)))
77 #define BYTEOUT(address, value) \
78 *((volatile UBYTE *)(address)) = (value)
80 #define WORDOUT(address, value) \
81 *((volatile UWORD *)(address)) = (value)
83 #define LONGOUT(address, value) \
84 *((volatile ULONG *)(address)) = (value)
86 #endif
88 #define WORDSIN(address, data, count) \
89 ({ \
90 ULONG _WORDSIN_i = (count); \
91 UWORD *_WORDSIN_p = (data); \
92 while(_WORDSIN_i-- != 0) \
93 *_WORDSIN_p++ = WORDIN(address); \
94 _WORDSIN_p; \
97 #define LONGSIN(address, data, count) \
98 ({ \
99 ULONG _LONGSIN_i = (count); \
100 ULONG *_LONGSIN_p = (data); \
101 while(_LONGSIN_i-- != 0) \
102 *_LONGSIN_p++ = LONGIN(address); \
103 _LONGSIN_p; \
106 #define WORDSOUT(address, data, count) \
107 do \
109 ULONG _WORDSOUT_i = (count); \
110 const UWORD *_WORDSOUT_p = (data); \
111 while(_WORDSOUT_i-- != 0) \
112 WORDOUT(address, *_WORDSOUT_p++); \
114 while(0)
116 #define LONGSOUT(address, data, count) \
117 do \
119 ULONG _LONGSOUT_i = (count); \
120 const ULONG *_LONGSOUT_p = (data); \
121 while(_LONGSOUT_i-- != 0) \
122 LONGOUT(address, *_LONGSOUT_p++); \
124 while(0)
126 #define BEWORDOUT(address, value) \
127 WORDOUT(address, MakeBEWord(value))
129 #define LEWORDIN(address) \
130 LEWord(WORDIN(address))
132 #define LEWORDOUT(address, value) \
133 WORDOUT(address, MakeLEWord(value))
135 #define LELONGIN(address) \
136 LELong(LONGIN(address))
138 #define LELONGOUT(address, value) \
139 LONGOUT(address, MakeLELong(value))
141 #define LEWORDSIN(address, data, count) \
142 ({ \
143 ULONG _LEWORDSIN_i = (count); \
144 UWORD *_LEWORDSIN_p = (data); \
145 while(_LEWORDSIN_i-- != 0) \
146 *_LEWORDSIN_p++ = LEWORDIN(address); \
147 _LEWORDSIN_p; \
151 #endif