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,
30 #define BYTEIN(address) \
32 UBYTE _BYTEIN_value; \
33 __asm volatile ("inb %w1,%0":"=a" (_BYTEIN_value):"Nd" (address)); \
37 #define WORDIN(address) \
39 UWORD _WORDIN_value; \
40 __asm volatile ("inw %w1,%0":"=a" (_WORDIN_value):"Nd" (address)); \
44 #define LONGIN(address) \
46 ULONG _LONGIN_value; \
47 __asm volatile ("inl %w1,%0":"=a" (_LONGIN_value):"Nd" (address)); \
51 #define BYTEOUT(address, value) \
53 __asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (address)); \
56 #define WORDOUT(address, value) \
58 __asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (address)); \
61 #define LONGOUT(address, value) \
63 __asm volatile ("outl %0,%w1": :"a" (value), "Nd" (address)); \
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)
88 #define WORDSIN(address, data, count) \
90 ULONG _WORDSIN_i = (count); \
91 UWORD *_WORDSIN_p = (data); \
92 while(_WORDSIN_i-- != 0) \
93 *_WORDSIN_p++ = WORDIN(address); \
97 #define LONGSIN(address, data, count) \
99 ULONG _LONGSIN_i = (count); \
100 ULONG *_LONGSIN_p = (data); \
101 while(_LONGSIN_i-- != 0) \
102 *_LONGSIN_p++ = LONGIN(address); \
106 #define WORDSOUT(address, data, count) \
109 ULONG _WORDSOUT_i = (count); \
110 const UWORD *_WORDSOUT_p = (data); \
111 while(_WORDSOUT_i-- != 0) \
112 WORDOUT(address, *_WORDSOUT_p++); \
116 #define LONGSOUT(address, data, count) \
119 ULONG _LONGSOUT_i = (count); \
120 const ULONG *_LONGSOUT_p = (data); \
121 while(_LONGSOUT_i-- != 0) \
122 LONGOUT(address, *_LONGSOUT_p++); \
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) \
143 ULONG _LEWORDSIN_i = (count); \
144 UWORD *_LEWORDSIN_p = (data); \
145 while(_LEWORDSIN_i-- != 0) \
146 *_LEWORDSIN_p++ = LEWORDIN(address); \