- DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Proto...
[reactos.git] / reactos / lib / cmlib / cmlib.h
index f925666..ca289e7 100644 (file)
 #ifndef CMLIB_H
 #define CMLIB_H
 
-#ifdef CMLIB_HOST
-#include <host/typedefs.h>
-#include <stdio.h>
-#include <string.h>
-
-// Definitions copied from <ntstatus.h>
-// We only want to include host headers, so we define them manually
-#define STATUS_SUCCESS                   ((NTSTATUS)0x00000000)
-#define STATUS_NOT_IMPLEMENTED           ((NTSTATUS)0xC0000002)
-#define STATUS_NO_MEMORY                 ((NTSTATUS)0xC0000017)
-#define STATUS_INSUFFICIENT_RESOURCES    ((NTSTATUS)0xC000009A)
-#define STATUS_REGISTRY_CORRUPT          ((NTSTATUS)0xC000014C)
-#define STATUS_NOT_REGISTRY_FILE         ((NTSTATUS)0xC000015C)
-#define STATUS_REGISTRY_RECOVERED        ((NTSTATUS)0x40000009)
+//
+// Debug support switch
+//
+#define _CMLIB_DEBUG_ 1
 
+#ifdef CMLIB_HOST
+    #include <host/typedefs.h>
+    #include <stdio.h>
+    #include <string.h>
+
+    // Definitions copied from <ntstatus.h>
+    // We only want to include host headers, so we define them manually
+    #define STATUS_SUCCESS                   ((NTSTATUS)0x00000000)
+    #define STATUS_NOT_IMPLEMENTED           ((NTSTATUS)0xC0000002)
+    #define STATUS_NO_MEMORY                 ((NTSTATUS)0xC0000017)
+    #define STATUS_INSUFFICIENT_RESOURCES    ((NTSTATUS)0xC000009A)
+    #define STATUS_REGISTRY_CORRUPT          ((NTSTATUS)0xC000014C)
+    #define STATUS_NOT_REGISTRY_FILE         ((NTSTATUS)0xC000015C)
+    #define STATUS_REGISTRY_RECOVERED        ((NTSTATUS)0x40000009)
+
+    #define REG_OPTION_VOLATILE              1
+    #define OBJ_CASE_INSENSITIVE             0x00000040L
+    #define USHORT_MAX                       USHRT_MAX
+
+    VOID NTAPI
+    KeQuerySystemTime(
+        OUT PLARGE_INTEGER CurrentTime);
+
+    VOID NTAPI
+    RtlInitializeBitMap(
+        IN PRTL_BITMAP BitMapHeader,
+        IN PULONG BitMapBuffer,
+        IN ULONG SizeOfBitMap);
+
+    ULONG NTAPI
+    RtlFindSetBits(
+        IN PRTL_BITMAP BitMapHeader,
+        IN ULONG NumberToFind,
+        IN ULONG HintIndex);
+
+    VOID NTAPI
+    RtlSetBits(
+        IN PRTL_BITMAP BitMapHeader,
+        IN ULONG StartingIndex,
+        IN ULONG NumberToSet);
+
+    VOID NTAPI
+    RtlClearAllBits(
+        IN PRTL_BITMAP BitMapHeader);
+
+    #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1)
+    #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
+
+    #define PKTHREAD PVOID
+    #define PKGUARDED_MUTEX PVOID
+    #define PERESOURCE PVOID
+    #define PFILE_OBJECT PVOID
+    #define PKEVENT PVOID
+    #define PWORK_QUEUE_ITEM PVOID
+    #define EX_PUSH_LOCK PULONG_PTR
+
+    /* For <host/wcsfuncs.h> */
+    #define USE_HOST_WCSFUNCS
+
+    #define CMLTRACE(x, ...)
+#else
+    //
+    // Debug/Tracing support
+    //
+    #if _CMLIB_DEBUG_
+    #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
+    #define CMLTRACE DbgPrintEx
+    #else
+    #define CMLTRACE(x, ...)                                 \
+    if (x & CmlibTraceLevel) DbgPrint(__VA_ARGS__)
+    #endif
+    #else
+    #define CMLTRACE(x, ...) DPRINT(__VA_ARGS__)
+    #endif
+
+    #include <ntdef.h>
+    #undef DECLSPEC_IMPORT
+    #define DECLSPEC_IMPORT
+    #include <ntddk.h>
 #endif
 
-#ifndef _TYPEDEFS_HOST_H
- #include <ntddk.h>
-
-#else
- #define REG_OPTION_VOLATILE 1
- #define OBJ_CASE_INSENSITIVE 0x00000040L
- #define USHORT_MAX USHRT_MAX
-
-VOID NTAPI
-KeQuerySystemTime(
-    OUT PLARGE_INTEGER CurrentTime);
-
-VOID NTAPI
-RtlInitializeBitMap(
-    IN PRTL_BITMAP BitMapHeader,
-    IN PULONG BitMapBuffer,
-    IN ULONG SizeOfBitMap);
-
-ULONG NTAPI
-RtlFindSetBits(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG NumberToFind,
-    IN ULONG HintIndex);
-
-VOID NTAPI
-RtlSetBits(
-    IN PRTL_BITMAP BitMapHeader,
-    IN ULONG StartingIndex,
-    IN ULONG NumberToSet);
-
-VOID NTAPI
-RtlClearAllBits(
-    IN PRTL_BITMAP BitMapHeader);
-
-#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1)
-
-#define PKTHREAD PVOID
-#define PKGUARDED_MUTEX PVOID
-#define PERESOURCE PVOID
-#define PFILE_OBJECT PVOID
-#define PKEVENT PVOID
-#define PWORK_QUEUE_ITEM PVOID
-#define EX_PUSH_LOCK PULONG_PTR
+#include <host/wcsfuncs.h>
 
-#endif
+//
+// These define the Debug Masks Supported
+//
+#define CMLIB_HCELL_DEBUG                                 0x01
 
 #ifndef ROUND_UP
 #define ROUND_UP(a,b)        ((((a)+(b)-1)/(b))*(b))
 #define ROUND_DOWN(a,b)      (((a)/(b))*(b))
 #endif
 
+//
+// PAGE_SIZE definition
+//
+#ifndef PAGE_SIZE
+#if defined(TARGET_i386) || defined(TARGET_amd64) || defined(TARGET_arm)
+#define PAGE_SIZE 0x1000
+#else
+#error Local PAGE_SIZE definition required when built as host
+#endif
+#endif
+
 #define TAG_CM 0x68742020
 
 #define CMAPI NTAPI
@@ -158,6 +199,7 @@ typedef struct _CMHIVE
 
 #endif
 
+extern ULONG CmlibTraceLevel;
 
 /*
  * Public functions.