ULONG Flags;
} ARBITER_INTERFACE, *PARBITER_INTERFACE;
+typedef enum _KPROFILE_SOURCE {
+ ProfileTime,
+ ProfileAlignmentFixup,
+ ProfileTotalIssues,
+ ProfilePipelineDry,
+ ProfileLoadInstructions,
+ ProfilePipelineFrozen,
+ ProfileBranchInstructions,
+ ProfileTotalNonissues,
+ ProfileDcacheMisses,
+ ProfileIcacheMisses,
+ ProfileCacheMisses,
+ ProfileBranchMispredictions,
+ ProfileStoreInstructions,
+ ProfileFpInstructions,
+ ProfileIntegerInstructions,
+ Profile2Issue,
+ Profile3Issue,
+ Profile4Issue,
+ ProfileSpecialInstructions,
+ ProfileTotalCycles,
+ ProfileIcacheIssues,
+ ProfileDcacheAccesses,
+ ProfileMemoryBarrierCycles,
+ ProfileLoadLinkedIssues,
+ ProfileMaximum
+} KPROFILE_SOURCE;
+
typedef enum _HAL_QUERY_INFORMATION_CLASS {
HalInstalledBusInformation,
HalProfileSourceInformation,
HalGenerateCmcInterrupt
} HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
+typedef struct _HAL_PROFILE_SOURCE_INTERVAL
+{
+ KPROFILE_SOURCE Source;
+ ULONG_PTR Interval;
+} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
+
+typedef struct _HAL_PROFILE_SOURCE_INFORMATION
+{
+ KPROFILE_SOURCE Source;
+ BOOLEAN Supported;
+ ULONG Interval;
+} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
+
typedef struct _MAP_REGISTER_ENTRY
{
PVOID MapRegister;
(DDKAPI *PKINTERRUPT_ROUTINE)(
VOID);
-typedef enum _KPROFILE_SOURCE {
- ProfileTime,
- ProfileAlignmentFixup,
- ProfileTotalIssues,
- ProfilePipelineDry,
- ProfileLoadInstructions,
- ProfilePipelineFrozen,
- ProfileBranchInstructions,
- ProfileTotalNonissues,
- ProfileDcacheMisses,
- ProfileIcacheMisses,
- ProfileCacheMisses,
- ProfileBranchMispredictions,
- ProfileStoreInstructions,
- ProfileFpInstructions,
- ProfileIntegerInstructions,
- Profile2Issue,
- Profile3Issue,
- Profile4Issue,
- ProfileSpecialInstructions,
- ProfileTotalCycles,
- ProfileIcacheIssues,
- ProfileDcacheAccesses,
- ProfileMemoryBarrierCycles,
- ProfileLoadLinkedIssues,
- ProfileMaximum
-} KPROFILE_SOURCE;
-
typedef enum _CREATE_FILE_TYPE {
CreateFileTypeNone,
CreateFileTypeNamedPipe,
#elif defined(_M_ARM) // !defined (_X86_)
+ FORCEINLINE
+ VOID
+ KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
+ {
+ /* Clear the lock */
+ *SpinLock = 0;
+ }
+
NTHALAPI
KIRQL
FASTCALL
#define ROUND_TO_PAGES(Size) \
((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
+
+
+#if defined(_X86_) || defined(_AMD64_)
+
+//
+// x86 and x64 performs a 0x2C interrupt
+//
+#define DbgRaiseAssertionFailure __int2c
+
+#elif defined(_ARM_)
+
+//
+// TODO
+//
+
+#else
+#error Unsupported Architecture
+#endif
+
#if DBG
#define ASSERT(exp) \
(VOID)((!(exp)) ? \
- RtlAssert( #exp, __FILE__, __LINE__, NULL ), FALSE : TRUE)
+ RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
#define ASSERTMSG(msg, exp) \
(VOID)((!(exp)) ? \
- RtlAssert( #exp, __FILE__, __LINE__, msg ), FALSE : TRUE)
+ RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
#define RTL_SOFT_ASSERT(exp) \
- (VOID)((!(_exp)) ? \
+ (VOID)((!(exp)) ? \
DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
#define RTL_SOFT_ASSERTMSG(msg, exp) \
#define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
#define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
+#if defined(_MSC_VER)
+
+#define NT_ASSERT(exp) \
+ ((!(exp)) ? \
+ (__annotation(L"Debug", L"AssertFail", L#exp), \
+ DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSG(msg, exp) \
+ ((!(exp)) ? \
+ (__annotation(L"Debug", L"AssertFail", L##msg), \
+ DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSGW(msg, exp) \
+ ((!(exp)) ? \
+ (__annotation(L"Debug", L"AssertFail", msg), \
+ DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#else
+
+//
+// GCC doesn't support __annotation (nor PDB)
+//
+#define NT_ASSERT(exp) \
+ (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSG NT_ASSERT
+#define NT_ASSERTMSGW NT_ASSERT
+
+#endif
+
#else /* !DBG */
#define ASSERT(exp) ((VOID) 0)
#define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
#define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
+#define NT_ASSERT(exp) ((VOID)0)
+#define NT_ASSERTMSG(exp) ((VOID)0)
+#define NT_ASSERTMSGW(exp) ((VOID)0)
+
#endif /* DBG */
/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
KdEnableDebugger(
VOID);
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KdRefreshDebuggerNotPresent(
+ VOID
+);
+
#if (NTDDI_VERSION >= NTDDI_WS03SP1)
NTKERNELAPI
NTSTATUS
vDbgPrintEx(
IN ULONG ComponentId,
IN ULONG Level,
- IN LPCSTR Format,
+ IN PCCH Format,
IN va_list ap);
ULONG
NTAPI
vDbgPrintExWithPrefix(
- IN LPCSTR Prefix,
+ IN PCCH Prefix,
IN ULONG ComponentId,
IN ULONG Level,
- IN LPCSTR Format,
+ IN PCCH Format,
IN va_list ap);
NTKERNELAPI
ULONG
DDKCDECLAPI
DbgPrintReturnControlC(
- IN PCH Format,
+ IN PCCH Format,
IN ...);
ULONG
#endif /* !DBG */
-#if defined(_NTDDK_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
+#if defined(__GNUC__)
+
+extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent;
+extern NTKERNELAPI BOOLEAN KdDebuggerEnabled;
+#define KD_DEBUGGER_ENABLED KdDebuggerEnabled
+#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
+
+#elif defined(_NTDDK_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent;
extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled;