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
33 #if !defined(DEVICE_H)
36 #if !defined(__TTYPE_H__)
40 /*--------------------- Export Definitions -------------------------*/
49 #define VNSvInPortB(dwIOAddress, pbyData) { \
50 *(pbyData) = inb(dwIOAddress); \
54 #define VNSvInPortW(dwIOAddress, pwData) { \
55 *(pwData) = inw(dwIOAddress); \
58 #define VNSvInPortD(dwIOAddress, pdwData) { \
59 *(pdwData) = inl(dwIOAddress); \
63 #define VNSvOutPortB(dwIOAddress, byData) { \
64 outb(byData, dwIOAddress); \
68 #define VNSvOutPortW(dwIOAddress, wData) { \
69 outw(wData, dwIOAddress); \
72 #define VNSvOutPortD(dwIOAddress, dwData) { \
73 outl(dwData, dwIOAddress); \
79 // For memory mapped IO
83 #define VNSvInPortB(dwIOAddress, pbyData) { \
84 volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
85 *(pbyData) = readb(pbyAddr); \
89 #define VNSvInPortW(dwIOAddress, pwData) { \
90 volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
91 *(pwData) = readw(pwAddr); \
94 #define VNSvInPortD(dwIOAddress, pdwData) { \
95 volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
96 *(pdwData) = readl(pdwAddr); \
100 #define VNSvOutPortB(dwIOAddress, byData) { \
101 volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
102 writeb((BYTE)byData, pbyAddr); \
106 #define VNSvOutPortW(dwIOAddress, wData) { \
107 volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
108 writew((WORD)wData, pwAddr); \
111 #define VNSvOutPortD(dwIOAddress, dwData) { \
112 volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
113 writel((DWORD)dwData, pdwAddr); \
120 // ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
122 #define PCBvInPortB(dwIOAddress, pbyData) { \
123 *(pbyData) = inb(dwIOAddress); \
126 #define PCBvInPortW(dwIOAddress, pwData) { \
127 *(pwData) = inw(dwIOAddress); \
130 #define PCBvInPortD(dwIOAddress, pdwData) { \
131 *(pdwData) = inl(dwIOAddress); \
134 #define PCBvOutPortB(dwIOAddress, byData) { \
135 outb(byData, dwIOAddress); \
138 #define PCBvOutPortW(dwIOAddress, wData) { \
139 outw(wData, dwIOAddress); \
142 #define PCBvOutPortD(dwIOAddress, dwData) { \
143 outl(dwData, dwIOAddress); \
147 #define PCAvDelayByIO(uDelayUnit) { \
151 if (uDelayUnit <= 50) { \
152 udelay(uDelayUnit); \
155 for (ii = 0; ii < (uDelayUnit); ii++) \
156 byData = inb(0x61); \
161 /*--------------------- Export Classes ----------------------------*/
163 /*--------------------- Export Variables --------------------------*/
165 /*--------------------- Export Functions --------------------------*/