1*c2c66affSColin Finck /* 2*c2c66affSColin Finck * ioaccess.h 3*c2c66affSColin Finck * 4*c2c66affSColin Finck * Windows Device Driver Kit 5*c2c66affSColin Finck * 6*c2c66affSColin Finck * This file is part of the w32api package. 7*c2c66affSColin Finck * 8*c2c66affSColin Finck * THIS SOFTWARE IS NOT COPYRIGHTED 9*c2c66affSColin Finck * 10*c2c66affSColin Finck * This source code is offered for use in the public domain. You may 11*c2c66affSColin Finck * use, modify or distribute it freely. 12*c2c66affSColin Finck * 13*c2c66affSColin Finck * This code is distributed in the hope that it will be useful but 14*c2c66affSColin Finck * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 15*c2c66affSColin Finck * DISCLAIMED. This includes but is not limited to warranties of 16*c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17*c2c66affSColin Finck * 18*c2c66affSColin Finck */ 19*c2c66affSColin Finck #ifndef __IOACCESS_H 20*c2c66affSColin Finck #define __IOACCESS_H 21*c2c66affSColin Finck 22*c2c66affSColin Finck #ifdef __cplusplus 23*c2c66affSColin Finck extern "C" { 24*c2c66affSColin Finck #endif 25*c2c66affSColin Finck 26*c2c66affSColin Finck #define H2I(p) PtrToUshort(p) 27*c2c66affSColin Finck 28*c2c66affSColin Finck #ifndef NO_PORT_MACROS 29*c2c66affSColin Finck 30*c2c66affSColin Finck #if defined(_X86_) || defined(_M_AMD64) 31*c2c66affSColin Finck #define READ_REGISTER_UCHAR(r) (*(volatile UCHAR *)(r)) 32*c2c66affSColin Finck #define READ_REGISTER_USHORT(r) (*(volatile USHORT *)(r)) 33*c2c66affSColin Finck #define READ_REGISTER_ULONG(r) (*(volatile ULONG *)(r)) 34*c2c66affSColin Finck #define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR *)(r) = (v)) 35*c2c66affSColin Finck #define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v)) 36*c2c66affSColin Finck #define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v)) 37*c2c66affSColin Finck #define READ_PORT_UCHAR(p) (UCHAR)(__inbyte (H2I(p))) 38*c2c66affSColin Finck #define READ_PORT_USHORT(p) (USHORT)(__inword (H2I(p))) 39*c2c66affSColin Finck #define READ_PORT_ULONG(p) (ULONG)(__indword (H2I(p))) 40*c2c66affSColin Finck #define WRITE_PORT_UCHAR(p, v) __outbyte (H2I(p), (v)) 41*c2c66affSColin Finck #define WRITE_PORT_USHORT(p, v) __outword (H2I(p), (v)) 42*c2c66affSColin Finck #define WRITE_PORT_ULONG(p, v) __outdword (H2I(p), (v)) 43*c2c66affSColin Finck 44*c2c66affSColin Finck #define MEMORY_BARRIER() 45*c2c66affSColin Finck 46*c2c66affSColin Finck #elif defined(_PPC_) || defined(_MIPS_) || defined(_ARM_) 47*c2c66affSColin Finck 48*c2c66affSColin Finck #define READ_REGISTER_UCHAR(r) (*(volatile UCHAR * const)(r)) 49*c2c66affSColin Finck #define READ_REGISTER_USHORT(r) (*(volatile USHORT * const)(r)) 50*c2c66affSColin Finck #define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r)) 51*c2c66affSColin Finck #define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR * const)(r) = (v)) 52*c2c66affSColin Finck #define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT * const)(r) = (v)) 53*c2c66affSColin Finck #define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG * const)(r) = (v)) 54*c2c66affSColin Finck #define READ_PORT_UCHAR(r) READ_REGISTER_UCHAR(r) 55*c2c66affSColin Finck #define READ_PORT_USHORT(r) READ_REGISTER_USHORT(r) 56*c2c66affSColin Finck #define READ_PORT_ULONG(r) READ_REGISTER_ULONG(r) 57*c2c66affSColin Finck #define WRITE_PORT_UCHAR(p, v) WRITE_REGISTER_UCHAR(p, (UCHAR) (v)) 58*c2c66affSColin Finck #define WRITE_PORT_USHORT(p, v) WRITE_REGISTER_USHORT(p, (USHORT) (v)) 59*c2c66affSColin Finck #define WRITE_PORT_ULONG(p, v) WRITE_REGISTER_ULONG(p, (ULONG) (v)) 60*c2c66affSColin Finck 61*c2c66affSColin Finck #else 62*c2c66affSColin Finck 63*c2c66affSColin Finck #error Unsupported architecture 64*c2c66affSColin Finck 65*c2c66affSColin Finck #endif 66*c2c66affSColin Finck 67*c2c66affSColin Finck #endif /* NO_PORT_MACROS */ 68*c2c66affSColin Finck 69*c2c66affSColin Finck #ifdef __cplusplus 70*c2c66affSColin Finck } 71*c2c66affSColin Finck #endif 72*c2c66affSColin Finck 73*c2c66affSColin Finck #endif /* __IOACCESS_H */ 74