Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
19 * File: upc.h
20 *
21 * Purpose: Macros to access device
22 *
23 * Author: Tevin Chen
24 *
25 * Date: Mar 17, 1997
26 *
27 */
28
29#ifndef __UPC_H__
30#define __UPC_H__
31
32#include "device.h"
33#include "ttype.h"
34
35/*--------------------- Export Definitions -------------------------*/
36
37//
38// For IO mapped
39//
40
41#ifdef IO_MAP
42
43#define VNSvInPortB(dwIOAddress, pbyData) \
44do { \
45 *(pbyData) = inb(dwIOAddress); \
46} while (0)
47
48#define VNSvInPortW(dwIOAddress, pwData) \
49do { \
50 *(pwData) = inw(dwIOAddress); \
51} while (0)
52
53#define VNSvInPortD(dwIOAddress, pdwData) \
54do { \
55 *(pdwData) = inl(dwIOAddress); \
56} while (0)
57
58#define VNSvOutPortB(dwIOAddress, byData) \
59 outb(byData, dwIOAddress)
60
61#define VNSvOutPortW(dwIOAddress, wData) \
62 outw(wData, dwIOAddress)
63
64#define VNSvOutPortD(dwIOAddress, dwData) \
65 outl(dwData, dwIOAddress)
66
67#else
68
69//
70// For memory mapped IO
71//
72
73#define VNSvInPortB(dwIOAddress, pbyData) \
74do { \
75 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
76 *(pbyData) = readb(pbyAddr); \
77} while (0)
78
79#define VNSvInPortW(dwIOAddress, pwData) \
80do { \
81 volatile unsigned short *pwAddr = (unsigned short *)(dwIOAddress); \
82 *(pwData) = readw(pwAddr); \
83} while (0)
84
85#define VNSvInPortD(dwIOAddress, pdwData) \
86do { \
87 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
88 *(pdwData) = readl(pdwAddr); \
89} while (0)
90
91#define VNSvOutPortB(dwIOAddress, byData) \
92do { \
93 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
94 writeb((unsigned char)byData, pbyAddr); \
95} while (0)
96
97#define VNSvOutPortW(dwIOAddress, wData) \
98do { \
99 volatile unsigned short *pwAddr = ((unsigned short *)(dwIOAddress)); \
100 writew((unsigned short)wData, pwAddr); \
101} while (0)
102
103#define VNSvOutPortD(dwIOAddress, dwData) \
104do { \
105 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
106 writel((unsigned long)dwData, pdwAddr); \
107} while (0)
108
109#endif
110
111//
112// ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
113//
114#define PCBvInPortB(dwIOAddress, pbyData) \
115do { \
116 *(pbyData) = inb(dwIOAddress); \
117} while (0)
118
119#define PCBvInPortW(dwIOAddress, pwData) \
120do { \
121 *(pwData) = inw(dwIOAddress); \
122} while (0)
123
124#define PCBvInPortD(dwIOAddress, pdwData) \
125do { \
126 *(pdwData) = inl(dwIOAddress); \
127} while (0)
128
129#define PCBvOutPortB(dwIOAddress, byData) \
130 outb(byData, dwIOAddress)
131
132#define PCBvOutPortW(dwIOAddress, wData) \
133 outw(wData, dwIOAddress)
134
135#define PCBvOutPortD(dwIOAddress, dwData) \
136 outl(dwData, dwIOAddress)
137
138#define PCAvDelayByIO(uDelayUnit) \
139do { \
140 unsigned char byData; \
141 unsigned long ii; \
142 \
143 if (uDelayUnit <= 50) { \
144 udelay(uDelayUnit); \
145 } else { \
146 for (ii = 0; ii < (uDelayUnit); ii++) \
147 byData = inb(0x61); \
148 } \
149} while (0)
150
151/*--------------------- Export Classes ----------------------------*/
152
153/*--------------------- Export Variables --------------------------*/
154
155/*--------------------- Export Functions --------------------------*/
156
157#endif // __UPC_H__