The Windows headers include a file called ioaccess.h in the ddk folder, which exposes various READ/WRITE_PORT/REGISTER_ routines as inlined macros for various architectures (PPC, MIPS, AMD64, IA64, X86), making use of the MSVC compiler-intrinsics (inp, outp, etc). Since ReactOS already has those intrinscs implemented, we've also created an ioaccess.h w32api header file which makes use of them.
We can now remove the portio.h and portio.c files in FreeLDR, since there's no more need to duplicate this code.
Additionally, this can be also done with the PPC port of FreeLDR or any other architecture, since it doesn't require per-architecture support in FreeLDR anymore -- only the underlying intrinsics in intrin.h must be implemented (note that for PPC, MIPS and ARM, the notion of a port doesn't even exist -- those functions map to register-reading functions, where register basically means memory).
svn path=/trunk/; revision=32130
2008-02-05 02:40:08 +00:00
|
|
|
/*
|
|
|
|
* ioaccess.h
|
|
|
|
*
|
|
|
|
* Windows Device Driver Kit
|
|
|
|
*
|
|
|
|
* This file is part of the w32api package.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
|
|
|
*
|
|
|
|
* This source code is offered for use in the public domain. You may
|
|
|
|
* use, modify or distribute it freely.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful but
|
|
|
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
|
|
|
* DISCLAIMED. This includes but is not limited to warranties of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef __IOACCESS_H
|
|
|
|
#define __IOACCESS_H
|
|
|
|
|
|
|
|
#if __GNUC__ >= 3
|
|
|
|
#pragma GCC system_header
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define H2I(p) PtrToUshort(p)
|
|
|
|
|
|
|
|
#ifndef NO_PORT_MACROS
|
|
|
|
|
|
|
|
#if defined(_X86_)
|
|
|
|
#define READ_REGISTER_UCHAR(r) (*(volatile UCHAR *)(r))
|
|
|
|
#define READ_REGISTER_USHORT(r) (*(volatile USHORT *)(r))
|
|
|
|
#define READ_REGISTER_ULONG(r) (*(volatile ULONG *)(r))
|
|
|
|
#define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR *)(r) = (v))
|
|
|
|
#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v))
|
|
|
|
#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v))
|
2008-07-21 21:53:38 +00:00
|
|
|
#define READ_PORT_UCHAR(p) (UCHAR)(__inbyte (H2I(p)))
|
|
|
|
#define READ_PORT_USHORT(p) (USHORT)(__inword (H2I(p)))
|
|
|
|
#define READ_PORT_ULONG(p) (ULONG)(__indword (H2I(p)))
|
The Windows headers include a file called ioaccess.h in the ddk folder, which exposes various READ/WRITE_PORT/REGISTER_ routines as inlined macros for various architectures (PPC, MIPS, AMD64, IA64, X86), making use of the MSVC compiler-intrinsics (inp, outp, etc). Since ReactOS already has those intrinscs implemented, we've also created an ioaccess.h w32api header file which makes use of them.
We can now remove the portio.h and portio.c files in FreeLDR, since there's no more need to duplicate this code.
Additionally, this can be also done with the PPC port of FreeLDR or any other architecture, since it doesn't require per-architecture support in FreeLDR anymore -- only the underlying intrinsics in intrin.h must be implemented (note that for PPC, MIPS and ARM, the notion of a port doesn't even exist -- those functions map to register-reading functions, where register basically means memory).
svn path=/trunk/; revision=32130
2008-02-05 02:40:08 +00:00
|
|
|
#define WRITE_PORT_UCHAR(p, v) __outbyte (H2I(p), (v))
|
|
|
|
#define WRITE_PORT_USHORT(p, v) __outword (H2I(p), (v))
|
|
|
|
#define WRITE_PORT_ULONG(p, v) __outdword (H2I(p), (v))
|
|
|
|
|
|
|
|
#elif defined(_PPC_) || defined(_MIPS_) || defined(_ARM_)
|
|
|
|
|
|
|
|
#define READ_REGISTER_UCHAR(r) (*(volatile UCHAR * const)(r))
|
|
|
|
#define READ_REGISTER_USHORT(r) (*(volatile USHORT * const)(r))
|
|
|
|
#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r))
|
|
|
|
#define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR * const)(r) = (v))
|
|
|
|
#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT * const)(r) = (v))
|
|
|
|
#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG * const)(r) = (v))
|
|
|
|
#define READ_PORT_UCHAR(r) READ_REGISTER_UCHAR(r)
|
|
|
|
#define READ_PORT_USHORT(r) READ_REGISTER_USHORT(r)
|
|
|
|
#define READ_PORT_ULONG(r) READ_REGISTER_ULONG(r)
|
|
|
|
#define WRITE_PORT_UCHAR(p, v) WRITE_REGISTER_UCHAR(p, (UCHAR) (v))
|
|
|
|
#define WRITE_PORT_USHORT(p, v) WRITE_REGISTER_USHORT(p, (USHORT) (v))
|
|
|
|
#define WRITE_PORT_ULONG(p, v) WRITE_REGISTER_ULONG(p, (ULONG) (v))
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#error Unsupported architecture
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* NO_PORT_MACROS */
|
|
|
|
#endif /* __IOACCESS_H */
|