ReactOS  0.4.15-dev-1200-gc3b3fcd
IoInterrupt.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for IoInterrupt.c:

Go to the source code of this file.

Classes

struct  TEST_CONTEXT
 

Macros

#define NDEBUG
 
#define CheckSpinLock(Lock, Locked)
 

Typedefs

typedef struct TEST_CONTEXTPTEST_CONTEXT
 

Functions

static BOOLEAN NTAPI SynchronizeRoutine (IN PVOID Context)
 
static VOID TestSynchronizeExecution (VOID)
 
 START_TEST (IoInterrupt)
 

Variables

static KSYNCHRONIZE_ROUTINE SynchronizeRoutine
 

Macro Definition Documentation

◆ CheckSpinLock

#define CheckSpinLock (   Lock,
  Locked 
)
Value:
do \
{ \
ok_eq_ulongptr(*(Lock), (Locked) != 0); \
} while (0)
#define ok_eq_ulongptr(value, expected)
Definition: kmt_test.h:249
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:260
BOOLEAN KmtIsMultiProcessorBuild
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75

Definition at line 13 of file IoInterrupt.c.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file IoInterrupt.c.

Typedef Documentation

◆ PTEST_CONTEXT

Function Documentation

◆ START_TEST()

START_TEST ( IoInterrupt  )

Definition at line 92 of file IoInterrupt.c.

93 {
95 }
static VOID TestSynchronizeExecution(VOID)
Definition: IoInterrupt.c:47

◆ SynchronizeRoutine()

static BOOLEAN NTAPI SynchronizeRoutine ( IN PVOID  Context)
static

Definition at line 33 of file IoInterrupt.c.

35 {
36  PTEST_CONTEXT TestContext = Context;
37 
38  ok_irql(TestContext->ExpectedIrql);
39 
40  CheckSpinLock(TestContext->Interrupt->ActualLock, TRUE);
41 
42  return TestContext->ReturnValue;
43 }
#define TRUE
Definition: types.h:120
#define CheckSpinLock(Lock, Locked)
Definition: IoInterrupt.c:13
struct tagContext Context
Definition: acpixf.h:1034

◆ TestSynchronizeExecution()

static VOID TestSynchronizeExecution ( VOID  )
static

Definition at line 47 of file IoInterrupt.c.

48 {
49  KINTERRUPT Interrupt;
50  TEST_CONTEXT TestContext;
51  KIRQL SynchIrql;
52  KIRQL OriginalIrql;
53  KIRQL Irql;
54  KSPIN_LOCK ActualLock;
55  BOOLEAN Ret;
56 
57  RtlFillMemory(&Interrupt, sizeof Interrupt, 0x55);
58  Interrupt.ActualLock = &ActualLock;
60  CheckSpinLock(Interrupt.ActualLock, FALSE);
61 
62  TestContext.Interrupt = &Interrupt;
63  TestContext.ReturnValue = TRUE;
64 
65  for (TestContext.ReturnValue = 0; TestContext.ReturnValue <= 2; ++TestContext.ReturnValue)
66  {
67  for (OriginalIrql = PASSIVE_LEVEL; OriginalIrql <= HIGH_LEVEL; ++OriginalIrql)
68  {
69  /* TODO: don't hardcode this :| */
70  if (OriginalIrql == 3 || (OriginalIrql >= 11 && OriginalIrql <= 26) || OriginalIrql == 30)
71  continue;
72  KeRaiseIrql(OriginalIrql, &Irql);
73  for (SynchIrql = max(DISPATCH_LEVEL, OriginalIrql); SynchIrql <= HIGH_LEVEL; ++SynchIrql)
74  {
75  if (SynchIrql == 3 || (SynchIrql >= 11 && SynchIrql <= 26) || SynchIrql == 30)
76  continue;
77  Interrupt.SynchronizeIrql = SynchIrql;
78  ok_irql(OriginalIrql);
79  CheckSpinLock(Interrupt.ActualLock, FALSE);
80  TestContext.ExpectedIrql = SynchIrql;
81  Ret = KeSynchronizeExecution(&Interrupt, SynchronizeRoutine, &TestContext);
82  ok_eq_int(Ret, TestContext.ReturnValue);
83  ok_irql(OriginalIrql);
84  CheckSpinLock(Interrupt.ActualLock, FALSE);
85  /* TODO: Check that all other fields of the interrupt are untouched */
86  }
88  }
89  }
90 }
PKINTERRUPT Interrupt
Definition: IoInterrupt.c:25
#define max(a, b)
Definition: svc.c:63
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define TRUE
Definition: types.h:120
#define ok_eq_int(value, expected)
Definition: kmt_test.h:238
BOOLEAN ReturnValue
Definition: IoInterrupt.c:23
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
unsigned char BOOLEAN
#define CheckSpinLock(Lock, Locked)
Definition: IoInterrupt.c:13
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
PKSPIN_LOCK ActualLock
Definition: ketypes.h:836
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
KIRQL SynchronizeIrql
Definition: ketypes.h:840
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:142
KIRQL ExpectedIrql
Definition: IoInterrupt.c:24
static KSYNCHRONIZE_ROUTINE SynchronizeRoutine
Definition: IoInterrupt.c:28

Referenced by START_TEST().

Variable Documentation

◆ SynchronizeRoutine

KSYNCHRONIZE_ROUTINE SynchronizeRoutine
static

Definition at line 28 of file IoInterrupt.c.

Referenced by TestSynchronizeExecution().