reactos/sdk/include/ddk/ioaccess.h

74 lines
2.4 KiB
C
Raw Normal View History

/*
* 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
#ifdef __cplusplus
extern "C" {
#endif
#define H2I(p) PtrToUshort(p)
#ifndef NO_PORT_MACROS
Merge 34739 - 34769, 34796 - 34905, 34916 - 34967, 34970 - 35135, 35167, 35325, 35326, 35443 - 35506, 35510 - 35546, 35587, 35616, 35644 from ros-amd64-bringup branch: - Update AMD64 intrinsic Interlocked functions - Add _InterlockedExchange64 to intin_x86.h -Fix definitions of IsBadHugeReadPtr, IsBadHugeWritePtr, IsBadReadPtr, IsBadStringPtrA, IsBadStringPtrW, IsBadWritePtr and SetProcessWorkingSetSize - Define CONTEXT and XMM_SAVE_AREA32, taken from WINE - Include _M_AMD64 for defintitions in ioaccess.h - Add Interlocked intrinisc definitions for AMD64 platform - Add KI_USER_SHARED_DATA and KeGetCurrentIrql() prototype to winddh - Fix prototypes for KfAcquireSpinLock, KfReleaseSpinLock, KeAcquireInStackQueuedSpinLock and KeReleaseInStackQueuedSpinLock on amd64 - Fix rotl declaration, add mysteriously missing rotr. winnt.h: - Fix CONTEXT_AMD64 and friends, add various constants. - Define RUNTIME_FUNCTION, RtlCaptureContext, RtlRestoreContext, RtlAddFunctionTable, RtlInstallFunctionTableCallback, RtlDeleteFunctionTable. - Fix definitions for EXCEPTION_RECORD and friends to support amd64. - Define IMAGE_THUNK_DATA64 and related constants. - Define IMAGE_TLS_DIRECTORY64 and related constants. - Remove WINEisms - Remove multiple declarations and minor fixes. - Fix KESEG0_BASE for amd64 - Fix definition for NdisCopyLookaheadData on amd64 - Only add function prototypes if NO_INTERLOCKED_INTRINSICS is defined - Move the inlined InterlockedAnd/Or from rtl to winbase.h and rename it to InterlockedAnd/Or_Inline - Fix TreeView_EnsureVisible macro. - Add missing 64 bit intrinsic Interlocked functions - Fix _InterlockedDecrement64 - Fix InterlockedExchangeAddSizeT - Fix __writecrx instrinsics - Fix ExQueryPoolBlockSize prototype - Make KI_USER_SHARED_DATA and IMAGE_ORDINAL_FLAG64 a ULONGLONG - Fix definition if IMAGE_OPTIONAL_HEADER64 - Add KPCR structure - Add __readcrx intrinsics - Ad some definitions to winddk.h - Add a field for a DbgPrint function pointer to the ROS_LOADER_PARAMETER_BLOCK for early debug prints in ntoskrnl - Update KPCR and KIPCR - Add KeGetPcr() and update KeGetCurrentProcessorNumber - Fix SECURITY_DESCRIPTOR_RELATIVE and KDPC_DATA - Implement byteswap intrinsics - Add macro definitions for KeQuerySystemTime, KeQueryTickCount and KeQueryInterruptTime to ddk - Add NtCurrentTeb inline function - Update amd64 prototypes for KeGetCurrentIrql, KfRaiseIrql, KfLowerIrql, KeRaiseIrqlToDpcLevel, KeRaiseIrqlToSynchLevel, KeLowerIrql, KeRaiseIrql - Implement __readcr8, __writecr8, __lidt and __sidt intrinsics. - Implement KeGetCurrentIrql as intrinsic. - Make KeGetCurrentIrql, KeLowerIrql, KfRaiseIrql, KeRaiseIrql, KeRaiseIrqlToDpcLevel and KeRaiseIrqlToSynchLevel intrinsics as in the WDK 2008. - Fix _interlockedbittest intrinsics - Fix __readmsr and __writemsr on amd64 - Fix __readgsqword, it was using a long internally. Add volatile keyword to segment addressing intrinsics. Add "memory" to clobber list on all those that do write. - Merge __readcr and __writecr x86 / x64 definitions, because they are the same. Implement __readdr and __writedr for x64. - __readcr3() returns an unsigned __int64, fix x86 MmGetPageDirectory accordingly. svn path=/trunk/; revision=35646
2008-08-25 21:57:13 +00:00
#if defined(_X86_) || defined(_M_AMD64)
#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))
#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)))
#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))
#define MEMORY_BARRIER()
#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 */
#ifdef __cplusplus
}
#endif
#endif /* __IOACCESS_H */