2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: Macros to access device
35 /*--------------------- Export Definitions -------------------------*/
43 #define VNSvInPortB(dwIOAddress, pbyData) \
45 *(pbyData) = inb(dwIOAddress); \
48 #define VNSvInPortW(dwIOAddress, pwData) \
50 *(pwData) = inw(dwIOAddress); \
53 #define VNSvInPortD(dwIOAddress, pdwData) \
55 *(pdwData) = inl(dwIOAddress); \
58 #define VNSvOutPortB(dwIOAddress, byData) \
59 outb(byData, dwIOAddress)
61 #define VNSvOutPortW(dwIOAddress, wData) \
62 outw(wData, dwIOAddress)
64 #define VNSvOutPortD(dwIOAddress, dwData) \
65 outl(dwData, dwIOAddress)
70 // For memory mapped IO
73 #define VNSvInPortB(dwIOAddress, pbyData) \
75 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
76 *(pbyData) = readb(pbyAddr); \
79 #define VNSvInPortW(dwIOAddress, pwData) \
81 volatile unsigned short *pwAddr = (unsigned short *)(dwIOAddress); \
82 *(pwData) = readw(pwAddr); \
85 #define VNSvInPortD(dwIOAddress, pdwData) \
87 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
88 *(pdwData) = readl(pdwAddr); \
91 #define VNSvOutPortB(dwIOAddress, byData) \
93 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
94 writeb((unsigned char)byData, pbyAddr); \
97 #define VNSvOutPortW(dwIOAddress, wData) \
99 volatile unsigned short *pwAddr = ((unsigned short *)(dwIOAddress)); \
100 writew((unsigned short)wData, pwAddr); \
103 #define VNSvOutPortD(dwIOAddress, dwData) \
105 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
106 writel((unsigned long)dwData, pdwAddr); \
112 // ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
114 #define PCBvInPortB(dwIOAddress, pbyData) \
116 *(pbyData) = inb(dwIOAddress); \
119 #define PCBvInPortW(dwIOAddress, pwData) \
121 *(pwData) = inw(dwIOAddress); \
124 #define PCBvInPortD(dwIOAddress, pdwData) \
126 *(pdwData) = inl(dwIOAddress); \
129 #define PCBvOutPortB(dwIOAddress, byData) \
130 outb(byData, dwIOAddress)
132 #define PCBvOutPortW(dwIOAddress, wData) \
133 outw(wData, dwIOAddress)
135 #define PCBvOutPortD(dwIOAddress, dwData) \
136 outl(dwData, dwIOAddress)
138 #define PCAvDelayByIO(uDelayUnit) \
140 unsigned char byData; \
143 if (uDelayUnit <= 50) { \
144 udelay(uDelayUnit); \
146 for (ii = 0; ii < (uDelayUnit); ii++) \
147 byData = inb(0x61); \
151 /*--------------------- Export Classes ----------------------------*/
153 /*--------------------- Export Variables --------------------------*/
155 /*--------------------- Export Functions --------------------------*/