📄 upc.h
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
* File: upc.h
*
* Purpose: Macros to access device
*
* Author: Tevin Chen
*
* Date: Mar 17, 1997
*
*/
#ifndef __UPC_H__
#define __UPC_H__
#if !defined(DEVICE_H)
#include "device.h"
#endif
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions -------------------------*/
//
// For IO mapped
//
#ifdef IO_MAP
#define VNSvInPortB(dwIOAddress, pbyData) { \
*(pbyData) = inb(dwIOAddress); \
}
#define VNSvInPortW(dwIOAddress, pwData) { \
*(pwData) = inw(dwIOAddress); \
}
#define VNSvInPortD(dwIOAddress, pdwData) { \
*(pdwData) = inl(dwIOAddress); \
}
#define VNSvOutPortB(dwIOAddress, byData) { \
outb(byData, dwIOAddress); \
}
#define VNSvOutPortW(dwIOAddress, wData) { \
outw(wData, dwIOAddress); \
}
#define VNSvOutPortD(dwIOAddress, dwData) { \
outl(dwData, dwIOAddress); \
}
#else
//
// For memory mapped IO
//
#define VNSvInPortB(dwIOAddress, pbyData) { \
volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
*(pbyData) = readb(pbyAddr); \
}
#define VNSvInPortW(dwIOAddress, pwData) { \
volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
*(pwData) = readw(pwAddr); \
}
#define VNSvInPortD(dwIOAddress, pdwData) { \
volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
*(pdwData) = readl(pdwAddr); \
}
#define VNSvOutPortB(dwIOAddress, byData) { \
volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \
writeb((BYTE)byData, pbyAddr); \
}
#define VNSvOutPortW(dwIOAddress, wData) { \
volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \
writew((WORD)wData, pwAddr); \
}
#define VNSvOutPortD(dwIOAddress, dwData) { \
volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \
writel((DWORD)dwData, pdwAddr); \
}
#endif
//
// ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
//
#define PCBvInPortB(dwIOAddress, pbyData) { \
*(pbyData) = inb(dwIOAddress); \
}
#define PCBvInPortW(dwIOAddress, pwData) { \
*(pwData) = inw(dwIOAddress); \
}
#define PCBvInPortD(dwIOAddress, pdwData) { \
*(pdwData) = inl(dwIOAddress); \
}
#define PCBvOutPortB(dwIOAddress, byData) { \
outb(byData, dwIOAddress); \
}
#define PCBvOutPortW(dwIOAddress, wData) { \
outw(wData, dwIOAddress); \
}
#define PCBvOutPortD(dwIOAddress, dwData) { \
outl(dwData, dwIOAddress); \
}
#define PCAvDelayByIO(uDelayUnit) { \
BYTE byData; \
ULONG ii; \
\
if (uDelayUnit <= 50) { \
udelay(uDelayUnit); \
} \
else { \
for (ii = 0; ii < (uDelayUnit); ii++) \
byData = inb(0x61); \
} \
}
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
#endif // __UPC_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -