ReactOS 0.4.15-dev-8102-g108db8f
KeIrql.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Interrupt Request Level test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#ifndef _M_AMD64
9__declspec(dllimport) void __stdcall KeRaiseIrql(unsigned char, unsigned char *);
10__declspec(dllimport) void __stdcall KeLowerIrql(unsigned char);
11#else
12#define CLOCK1_LEVEL CLOCK_LEVEL
13#define CLOCK2_LEVEL CLOCK_LEVEL
14#endif
15
16#include <kmt_test.h>
17
18#define NDEBUG
19#include <debug.h>
20
21START_TEST(KeIrql)
22{
23 KIRQL Irql, Irql2, PrevIrql, SynchIrql;
24
25 /* we should be called at PASSIVE_LEVEL */
26 ok_irql(PASSIVE_LEVEL);
27
28 PrevIrql = KeGetCurrentIrql();
29
30 /* SYNCH_LEVEL is different for UP/MP */
32 SynchIrql = IPI_LEVEL - 2;
33 else
34 SynchIrql = DISPATCH_LEVEL;
35
36 /* some Irqls MUST work */
37 {
40 PROFILE_LEVEL, IPI_LEVEL, /*POWER_LEVEL,*/ SynchIrql, HIGH_LEVEL };
41 int i;
42 for (i = 0; i < sizeof Irqls / sizeof Irqls[0]; ++i)
43 {
44 KeRaiseIrql(Irqls[i], &Irql2);
45 ok_eq_uint(Irql2, PrevIrql);
46 ok_irql(Irqls[i]);
47 KeLowerIrql(Irql2);
48 ok_irql(PrevIrql);
49 }
50 }
51
52 /* raising/lowering to the current level should have no effect */
53 ok_irql(PASSIVE_LEVEL);
57 ok_irql(PASSIVE_LEVEL);
58
59 /* try to raise to each Irql and back */
61 {
62 DPRINT("Raising to %u\n", Irql);
63 KeRaiseIrql(Irql, &Irql2);
64 ok_eq_uint(Irql2, PrevIrql);
65 KeLowerIrql(Irql2);
66 ok_irql(PrevIrql);
67 }
68
69 /* go through all Irqls in order, skip the ones that the system doesn't accept */
71 {
72 DPRINT("Raising to %u\n", Irql);
73 KeRaiseIrql(Irql, &Irql2);
74 ok_eq_uint(Irql2, PrevIrql);
75 Irql2 = KeGetCurrentIrql();
76 ok(Irql2 <= Irql, "New Irql is %u, expected <= requested value of %u\n", Irql2, Irql);
77 PrevIrql = Irql2;
78 }
79
80 ok_irql(HIGH_LEVEL);
81
82 /* now go back again, skipping the ones that don't work */
84 {
85 DPRINT("Lowering to %u\n", Irql - 1);
86 KeLowerIrql(Irql - 1);
87 Irql2 = KeGetCurrentIrql();
88 ok(Irql2 < Irql, "New Irql is %u, expected <= requested value of %u\n", Irql2, Irql - 1);
89 if (Irql2 < Irql)
90 Irql = Irql2;
91 else
92 --Irql;
93 }
94
95 /* test KeRaiseIrqlToDpcLevel */
96 ok_irql(PASSIVE_LEVEL);
98 ok_irql(DISPATCH_LEVEL);
101 ok_irql(DISPATCH_LEVEL);
104
105 /* test KeRaiseIrqlToSynchLevel */
106 ok_irql(PASSIVE_LEVEL);
108 ok_irql(SynchIrql);
111 ok_irql(SynchIrql);
112 ok_eq_uint(Irql, SynchIrql);
114
115 /* these bugcheck on a checked build but run fine on free! */
117 {
120 ok_irql(APC_LEVEL);
122 ok_irql(HIGH_LEVEL);
124 }
125
126#ifndef _M_AMD64
127 /* try the actual exports, not only the fastcall versions */
128 ok_irql(PASSIVE_LEVEL);
130 ok_irql(HIGH_LEVEL);
132 (KeLowerIrql)(Irql);
133 ok_irql(PASSIVE_LEVEL);
134#endif
135
136 /* make sure we exit gracefully */
137 ok_irql(PASSIVE_LEVEL);
139}
__declspec(dllimport)
Definition: KeIrql.c:9
#define ok_eq_uint(value, expected)
Definition: apitest.h:61
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
_Out_ PKIRQL Irql
Definition: csq.h:179
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define IPI_LEVEL
Definition: env_spec_w32.h:701
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define PROFILE_LEVEL
Definition: env_spec_w32.h:698
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define CLOCK1_LEVEL
Definition: env_spec_w32.h:699
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define LOW_LEVEL
Definition: env_spec_w32.h:694
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment KeRaiseIrqlToDpcLevel
Definition: CrNtStubs.h:68
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
KIRQL NTAPI KeRaiseIrqlToSynchLevel(VOID)
Definition: pic.c:156
BOOLEAN KmtIsCheckedBuild
BOOLEAN KmtIsMultiProcessorBuild
#define CMCI_LEVEL
Definition: ketypes.h:15
#define CLOCK_LEVEL
Definition: ketypes.h:16
#define DPRINT
Definition: sndvol32.h:73
#define __stdcall
Definition: typedefs.h:25