Move alignment macros to wdm.h
[reactos.git] / include / ddk / winddk.h
index 620a8a1..094efc9 100644 (file)
 #ifndef __WINDDK_H
 #define __WINDDK_H
 
+/* Helper macro to enable gcc's extension.  */
+#ifndef __GNU_EXTENSION
+#ifdef __GNUC__
+#define __GNU_EXTENSION __extension__
+#else
+#define __GNU_EXTENSION
+#endif
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -65,21 +74,6 @@ extern "C" {
 # define _DDK_DUMMYUNION_N_MEMBER(n, name) name
 #endif
 
-/*
- * Alignment Macros
- */
-#define ALIGN_DOWN(s, t) \
-    ((ULONG)(s) & ~(sizeof(t) - 1))
-
-#define ALIGN_UP(s, t) \
-    (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
-
-#define ALIGN_DOWN_POINTER(p, t) \
-    ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
-
-#define ALIGN_UP_POINTER(p, t) \
-    (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
-
 /*
  * GUID Comparison
  */
@@ -556,7 +550,7 @@ typedef struct _KUSER_SHARED_DATA
     ULONG SystemCall;
     ULONG SystemCallReturn;
     ULONGLONG SystemCallPad[3];
-    union {
+    __GNU_EXTENSION union {
         volatile KSYSTEM_TIME TickCount;
         volatile ULONG64 TickCountQuad;
     };
@@ -569,10 +563,10 @@ typedef struct _KUSER_SHARED_DATA
     USHORT UserModeGlobalLogger[8];
     ULONG HeapTracingPid[2];
     ULONG CritSecTracingPid[2];
-    union
+    __GNU_EXTENSION union
     {
         ULONG SharedDataFlags;
-        struct
+        __GNU_EXTENSION struct
         {
             ULONG DbgErrorPortPresent:1;
             ULONG DbgElevationEnabled:1;
@@ -1276,9 +1270,9 @@ typedef struct _KGUARDED_MUTEX
     PKTHREAD Owner;
     ULONG Contention;
     KGATE Gate;
-    union
+    __GNU_EXTENSION union
     {
-        struct
+        __GNU_EXTENSION struct
         {
             SHORT KernelApcDisable;
             SHORT SpecialApcDisable;
@@ -4063,9 +4057,10 @@ typedef struct _PCI_COMMON_CONFIG {
 #define PCI_INVALID_VENDORID   0xFFFF
 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
 
-#define PCI_ADDRESS_IO_SPACE                0x01
-#define PCI_ADDRESS_MEMORY_TYPE_MASK        0x06
-#define PCI_ADDRESS_MEMORY_PREFETCHABLE     0x08
+#define PCI_ADDRESS_MEMORY_SPACE            0x00000000
+#define PCI_ADDRESS_IO_SPACE                0x00000001
+#define PCI_ADDRESS_MEMORY_TYPE_MASK        0x00000006
+#define PCI_ADDRESS_MEMORY_PREFETCHABLE     0x00000008
 #define PCI_ADDRESS_IO_ADDRESS_MASK         0xfffffffc
 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK     0xfffffff0
 #define PCI_ADDRESS_ROM_ADDRESS_MASK        0xfffff800
@@ -4585,6 +4580,32 @@ typedef struct _NT_TIB {
     struct _NT_TIB *Self;
 } NT_TIB, *PNT_TIB;
 
+typedef struct _NT_TIB32 {
+       ULONG ExceptionList;
+       ULONG StackBase;
+       ULONG StackLimit;
+       ULONG SubSystemTib;
+       __GNU_EXTENSION union {
+               ULONG FiberData;
+               ULONG Version;
+       };
+       ULONG ArbitraryUserPointer;
+       ULONG Self;
+} NT_TIB32,*PNT_TIB32;
+
+typedef struct _NT_TIB64 {
+       ULONG64 ExceptionList;
+       ULONG64 StackBase;
+       ULONG64 StackLimit;
+       ULONG64 SubSystemTib;
+       __GNU_EXTENSION union {
+               ULONG64 FiberData;
+               ULONG Version;
+       };
+       ULONG64 ArbitraryUserPointer;
+       ULONG64 Self;
+} NT_TIB64,*PNT_TIB64;
+
 typedef enum _PROCESSINFOCLASS {
   ProcessBasicInformation,
   ProcessQuotaLimits,
@@ -4678,7 +4699,7 @@ typedef struct _PROCESS_WS_WATCH_INFORMATION
 
 typedef struct _PROCESS_DEVICEMAP_INFORMATION
 {
-    union
+    __GNU_EXTENSION union
     {
         struct
         {
@@ -5123,23 +5144,7 @@ FORCEINLINE
 ULONG
 KeGetCurrentProcessorNumber(VOID)
 {
-#if defined(__GNUC__)
-  ULONG ret;
-  __asm__ __volatile__ (
-    "movl %%fs:%c1, %0\n"
-    : "=r" (ret)
-    : "i" (FIELD_OFFSET(KPCR, Number))
-  );
-  return ret;
-#elif defined(_MSC_VER)
-#if _MSC_FULL_VER >= 13012035
-  return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
-#else
-  __asm { movzx eax, fs:[0] KPCR.Number }
-#endif
-#else
-#error Unknown compiler
-#endif
+    return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number));
 }
 
 NTHALAPI
@@ -5236,7 +5241,7 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
     USHORT SegFs;
     USHORT SegGs;
     USHORT SegSs;
-    USHORT EFlags;
+    ULONG EFlags;
 
     /* Debug */
     ULONG64 Dr0;
@@ -5371,10 +5376,10 @@ extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
 
 typedef struct _KPCR
 {
-    union
+    __GNU_EXTENSION union
     {
         NT_TIB NtTib;
-        struct
+        __GNU_EXTENSION struct
         {
             union _KGDTENTRY64 *GdtBase;
             struct _KTSS64 *TssBase;
@@ -8552,6 +8557,21 @@ KeRegisterBugCheckCallback(
   IN ULONG  Length,
   IN PUCHAR  Component);
 
+NTKERNELAPI
+PVOID
+NTAPI
+KeRegisterNmiCallback(
+  IN PNMI_CALLBACK CallbackRoutine,
+  IN PVOID Context
+);
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+KeDeregisterNmiCallback(
+  IN PVOID Handle
+);
+
 NTKERNELAPI
 VOID
 FASTCALL
@@ -8968,6 +8988,19 @@ MmAllocatePagesForMdl(
   IN PHYSICAL_ADDRESS  SkipBytes,
   IN SIZE_T  TotalBytes);
 
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+NTKERNELAPI
+PMDL
+NTAPI
+MmAllocatePagesForMdlEx(
+  IN PHYSICAL_ADDRESS LowAddress,
+  IN PHYSICAL_ADDRESS HighAddress,
+  IN PHYSICAL_ADDRESS SkipBytes,
+  IN SIZE_T TotalBytes,
+  IN MEMORY_CACHING_TYPE CacheType,
+  IN ULONG Flags);
+#endif
+
 NTKERNELAPI
 VOID
 NTAPI
@@ -9351,7 +9384,7 @@ MmSecureVirtualMemory(
   IN ULONG  ProbeMode);
 
 NTKERNELAPI
-ULONG
+SIZE_T
 NTAPI
 MmSizeOfMdl(
   IN PVOID  Base,