1*b36d9bd9SDmitry Borisov /*
2*b36d9bd9SDmitry Borisov  * PROJECT:     ReactOS API Tests
3*b36d9bd9SDmitry Borisov  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4*b36d9bd9SDmitry Borisov  * PURPOSE:     Precompiled header for isapnp_unittest
5*b36d9bd9SDmitry Borisov  * COPYRIGHT:   Copyright 2024 Dmitry Borisov <di.sean@protonmail.com>
6*b36d9bd9SDmitry Borisov  */
7*b36d9bd9SDmitry Borisov 
8*b36d9bd9SDmitry Borisov #pragma once
9*b36d9bd9SDmitry Borisov 
10*b36d9bd9SDmitry Borisov #include <apitest.h>
11*b36d9bd9SDmitry Borisov 
12*b36d9bd9SDmitry Borisov #define WIN32_NO_STATUS
13*b36d9bd9SDmitry Borisov #include <ndk/rtlfuncs.h>
14*b36d9bd9SDmitry Borisov 
15*b36d9bd9SDmitry Borisov typedef PVOID PDEVICE_OBJECT;
16*b36d9bd9SDmitry Borisov 
17*b36d9bd9SDmitry Borisov #define UNIT_TEST
18*b36d9bd9SDmitry Borisov #include <isapnphw.h>
19*b36d9bd9SDmitry Borisov #include <isapnpres.h>
20*b36d9bd9SDmitry Borisov 
21*b36d9bd9SDmitry Borisov /* KERNEL DEFINITIONS (MOCK) **************************************************/
22*b36d9bd9SDmitry Borisov 
23*b36d9bd9SDmitry Borisov #define PAGED_CODE()
24*b36d9bd9SDmitry Borisov #define CODE_SEG(segment)
25*b36d9bd9SDmitry Borisov #define DPRINT(...)  do { if (0) { trace(__VA_ARGS__); } } while (0)
26*b36d9bd9SDmitry Borisov #define DPRINT1(...) do { if (0) { trace(__VA_ARGS__); } } while (0)
27*b36d9bd9SDmitry Borisov #define KeStallExecutionProcessor(MicroSeconds)
28*b36d9bd9SDmitry Borisov 
29*b36d9bd9SDmitry Borisov FORCEINLINE
30*b36d9bd9SDmitry Borisov PVOID
ExAllocatePoolWithTag(ULONG PoolType,SIZE_T NumberOfBytes,ULONG Tag)31*b36d9bd9SDmitry Borisov ExAllocatePoolWithTag(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
32*b36d9bd9SDmitry Borisov {
33*b36d9bd9SDmitry Borisov     PULONG_PTR Mem = HeapAlloc(GetProcessHeap(), 0, NumberOfBytes + 2 * sizeof(PVOID));
34*b36d9bd9SDmitry Borisov     if (Mem == NULL)
35*b36d9bd9SDmitry Borisov         return NULL;
36*b36d9bd9SDmitry Borisov 
37*b36d9bd9SDmitry Borisov     Mem[0] = NumberOfBytes;
38*b36d9bd9SDmitry Borisov     Mem[1] = Tag;
39*b36d9bd9SDmitry Borisov 
40*b36d9bd9SDmitry Borisov     return (PVOID)(Mem + 2);
41*b36d9bd9SDmitry Borisov }
42*b36d9bd9SDmitry Borisov 
43*b36d9bd9SDmitry Borisov FORCEINLINE
44*b36d9bd9SDmitry Borisov PVOID
ExAllocatePoolZero(ULONG PoolType,SIZE_T NumberOfBytes,ULONG Tag)45*b36d9bd9SDmitry Borisov ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
46*b36d9bd9SDmitry Borisov {
47*b36d9bd9SDmitry Borisov     PVOID Result = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
48*b36d9bd9SDmitry Borisov 
49*b36d9bd9SDmitry Borisov     if (Result != NULL)
50*b36d9bd9SDmitry Borisov         RtlZeroMemory(Result, NumberOfBytes);
51*b36d9bd9SDmitry Borisov 
52*b36d9bd9SDmitry Borisov     return Result;
53*b36d9bd9SDmitry Borisov }
54*b36d9bd9SDmitry Borisov 
55*b36d9bd9SDmitry Borisov FORCEINLINE
56*b36d9bd9SDmitry Borisov VOID
ExFreePoolWithTag(PVOID MemPtr,ULONG Tag)57*b36d9bd9SDmitry Borisov ExFreePoolWithTag(PVOID MemPtr, ULONG Tag)
58*b36d9bd9SDmitry Borisov {
59*b36d9bd9SDmitry Borisov     PULONG_PTR Mem = MemPtr;
60*b36d9bd9SDmitry Borisov 
61*b36d9bd9SDmitry Borisov     Mem -= 2;
62*b36d9bd9SDmitry Borisov     ok(Mem[1] == Tag, "Tag is %lx, expected %lx\n", Tag, Mem[1]);
63*b36d9bd9SDmitry Borisov     HeapFree(GetProcessHeap(), 0, Mem);
64*b36d9bd9SDmitry Borisov }
65*b36d9bd9SDmitry Borisov 
66*b36d9bd9SDmitry Borisov FORCEINLINE
67*b36d9bd9SDmitry Borisov SIZE_T
GetPoolAllocSize(PVOID MemPtr)68*b36d9bd9SDmitry Borisov GetPoolAllocSize(PVOID MemPtr)
69*b36d9bd9SDmitry Borisov {
70*b36d9bd9SDmitry Borisov     PVOID* Mem = MemPtr;
71*b36d9bd9SDmitry Borisov 
72*b36d9bd9SDmitry Borisov     Mem -= 2;
73*b36d9bd9SDmitry Borisov     return (SIZE_T)Mem[0];
74*b36d9bd9SDmitry Borisov }
75*b36d9bd9SDmitry Borisov 
76*b36d9bd9SDmitry Borisov /* ISAPNP DRIVER DEFINITIONS (MOCK) *******************************************/
77*b36d9bd9SDmitry Borisov 
78*b36d9bd9SDmitry Borisov #define TAG_ISAPNP 'pasI'
79*b36d9bd9SDmitry Borisov 
80*b36d9bd9SDmitry Borisov typedef struct _ISAPNP_FDO_EXTENSION
81*b36d9bd9SDmitry Borisov {
82*b36d9bd9SDmitry Borisov     LIST_ENTRY DeviceListHead;
83*b36d9bd9SDmitry Borisov     ULONG DeviceCount;
84*b36d9bd9SDmitry Borisov     ULONG Cards;
85*b36d9bd9SDmitry Borisov     PUCHAR ReadDataPort;
86*b36d9bd9SDmitry Borisov } ISAPNP_FDO_EXTENSION, *PISAPNP_FDO_EXTENSION;
87*b36d9bd9SDmitry Borisov 
88*b36d9bd9SDmitry Borisov typedef struct _ISAPNP_PDO_EXTENSION
89*b36d9bd9SDmitry Borisov {
90*b36d9bd9SDmitry Borisov     PISAPNP_LOGICAL_DEVICE IsaPnpDevice;
91*b36d9bd9SDmitry Borisov 
92*b36d9bd9SDmitry Borisov     PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
93*b36d9bd9SDmitry Borisov 
94*b36d9bd9SDmitry Borisov     PCM_RESOURCE_LIST ResourceList;
95*b36d9bd9SDmitry Borisov     ULONG ResourceListSize;
96*b36d9bd9SDmitry Borisov } ISAPNP_PDO_EXTENSION, *PISAPNP_PDO_EXTENSION;
97*b36d9bd9SDmitry Borisov 
98*b36d9bd9SDmitry Borisov /* TEST DEFINITIONS ***********************************************************/
99*b36d9bd9SDmitry Borisov 
100*b36d9bd9SDmitry Borisov typedef enum _ISAPNP_STATE
101*b36d9bd9SDmitry Borisov {
102*b36d9bd9SDmitry Borisov     IsaWaitForKey = 0,
103*b36d9bd9SDmitry Borisov     IsaSleep = 1,
104*b36d9bd9SDmitry Borisov     IsaIsolation = 2,
105*b36d9bd9SDmitry Borisov     IsaConfgure = 3
106*b36d9bd9SDmitry Borisov } ISAPNP_STATE;
107*b36d9bd9SDmitry Borisov 
108*b36d9bd9SDmitry Borisov typedef struct _ISAPNP_CARD_LOGICAL_DEVICE
109*b36d9bd9SDmitry Borisov {
110*b36d9bd9SDmitry Borisov     UCHAR Registers[0xFF];
111*b36d9bd9SDmitry Borisov } ISAPNP_CARD_LOGICAL_DEVICE, *PISAPNP_CARD_LOGICAL_DEVICE;
112*b36d9bd9SDmitry Borisov 
113*b36d9bd9SDmitry Borisov #define TEST_MAX_SUPPORTED_DEVICES     7
114*b36d9bd9SDmitry Borisov 
115*b36d9bd9SDmitry Borisov typedef struct _ISAPNP_CARD
116*b36d9bd9SDmitry Borisov {
117*b36d9bd9SDmitry Borisov     ISAPNP_STATE State;
118*b36d9bd9SDmitry Borisov     UCHAR LfsrCount;
119*b36d9bd9SDmitry Borisov     UCHAR Lfsr;
120*b36d9bd9SDmitry Borisov     UCHAR SelectNumberReg;
121*b36d9bd9SDmitry Borisov     UCHAR DeviceNumberReg;
122*b36d9bd9SDmitry Borisov     UCHAR SerialIsolationIdx;
123*b36d9bd9SDmitry Borisov     UCHAR SerialIdResponse;
124*b36d9bd9SDmitry Borisov     UCHAR IsolationRead;
125*b36d9bd9SDmitry Borisov     PUCHAR PnpRom;
126*b36d9bd9SDmitry Borisov     PUCHAR ReadDataPort;
127*b36d9bd9SDmitry Borisov     ULONG RomIdx;
128*b36d9bd9SDmitry Borisov     ULONG RomSize;
129*b36d9bd9SDmitry Borisov     ULONG LogicalDevices;
130*b36d9bd9SDmitry Borisov     ISAPNP_CARD_LOGICAL_DEVICE LogDev[TEST_MAX_SUPPORTED_DEVICES];
131*b36d9bd9SDmitry Borisov } ISAPNP_CARD, *PISAPNP_CARD;
132*b36d9bd9SDmitry Borisov 
133*b36d9bd9SDmitry Borisov UCHAR
134*b36d9bd9SDmitry Borisov NTAPI
135*b36d9bd9SDmitry Borisov READ_PORT_UCHAR(
136*b36d9bd9SDmitry Borisov     _In_ PUCHAR Port);
137*b36d9bd9SDmitry Borisov 
138*b36d9bd9SDmitry Borisov VOID
139*b36d9bd9SDmitry Borisov NTAPI
140*b36d9bd9SDmitry Borisov WRITE_PORT_UCHAR(
141*b36d9bd9SDmitry Borisov     _In_ PUCHAR Port,
142*b36d9bd9SDmitry Borisov     _In_ UCHAR Value);
143*b36d9bd9SDmitry Borisov 
144*b36d9bd9SDmitry Borisov VOID
145*b36d9bd9SDmitry Borisov IsaBusCreateCard(
146*b36d9bd9SDmitry Borisov     _Inout_ PISAPNP_CARD Card,
147*b36d9bd9SDmitry Borisov     _In_ PVOID PnpRom,
148*b36d9bd9SDmitry Borisov     _In_ ULONG RomSize,
149*b36d9bd9SDmitry Borisov     _In_ ULONG LogicalDevices);
150*b36d9bd9SDmitry Borisov 
151*b36d9bd9SDmitry Borisov VOID
152*b36d9bd9SDmitry Borisov DrvCreateCard1(
153*b36d9bd9SDmitry Borisov     _In_ PISAPNP_CARD Card);
154*b36d9bd9SDmitry Borisov 
155*b36d9bd9SDmitry Borisov VOID
156*b36d9bd9SDmitry Borisov DrvTestCard1Dev1Resources(
157*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
158*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
159*b36d9bd9SDmitry Borisov 
160*b36d9bd9SDmitry Borisov VOID
161*b36d9bd9SDmitry Borisov DrvTestCard1Dev2Resources(
162*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
163*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
164*b36d9bd9SDmitry Borisov 
165*b36d9bd9SDmitry Borisov VOID
166*b36d9bd9SDmitry Borisov DrvTestCard1Dev3Resources(
167*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
168*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
169*b36d9bd9SDmitry Borisov 
170*b36d9bd9SDmitry Borisov VOID
171*b36d9bd9SDmitry Borisov DrvTestCard1Dev4Resources(
172*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
173*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
174*b36d9bd9SDmitry Borisov 
175*b36d9bd9SDmitry Borisov VOID
176*b36d9bd9SDmitry Borisov DrvTestCard1Dev5Resources(
177*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
178*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
179*b36d9bd9SDmitry Borisov 
180*b36d9bd9SDmitry Borisov VOID
181*b36d9bd9SDmitry Borisov DrvTestCard1Dev6Resources(
182*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
183*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
184*b36d9bd9SDmitry Borisov 
185*b36d9bd9SDmitry Borisov VOID
186*b36d9bd9SDmitry Borisov DrvTestCard1Dev7Resources(
187*b36d9bd9SDmitry Borisov     _In_ PCM_RESOURCE_LIST ResourceList,
188*b36d9bd9SDmitry Borisov     _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList);
189*b36d9bd9SDmitry Borisov 
190*b36d9bd9SDmitry Borisov PCM_RESOURCE_LIST
191*b36d9bd9SDmitry Borisov DrvTestCard1Dev6CreateConfigurationResources(VOID);
192*b36d9bd9SDmitry Borisov 
193*b36d9bd9SDmitry Borisov VOID
194*b36d9bd9SDmitry Borisov DrvTestCard1Dev6ConfigurationResult(
195*b36d9bd9SDmitry Borisov     _In_ PISAPNP_CARD_LOGICAL_DEVICE LogDev);
196*b36d9bd9SDmitry Borisov 
197*b36d9bd9SDmitry Borisov VOID
198*b36d9bd9SDmitry Borisov DrvCreateCard2(
199*b36d9bd9SDmitry Borisov     _In_ PISAPNP_CARD Card);
200*b36d9bd9SDmitry Borisov 
201*b36d9bd9SDmitry Borisov #define expect_resource_list_header(ResourceList, ExpectedIface, ExpectedCount)       \
202*b36d9bd9SDmitry Borisov     do {                                                                              \
203*b36d9bd9SDmitry Borisov     ok_eq_int((ResourceList)->List[0].InterfaceType, (ExpectedIface));                \
204*b36d9bd9SDmitry Borisov     ok_eq_ulong((ResourceList)->List[0].BusNumber, 0UL);                              \
205*b36d9bd9SDmitry Borisov     ok_eq_int((ResourceList)->List[0].PartialResourceList.Version, 1); /* 0 */        \
206*b36d9bd9SDmitry Borisov     ok_eq_int((ResourceList)->List[0].PartialResourceList.Revision, 1); /* 0x3000 */  \
207*b36d9bd9SDmitry Borisov     ok_eq_ulong((ResourceList)->List[0].PartialResourceList.Count, (ExpectedCount));  \
208*b36d9bd9SDmitry Borisov     } while (0)
209*b36d9bd9SDmitry Borisov 
210*b36d9bd9SDmitry Borisov #define expect_requirements_list_header(ReqList, ExpectedIface, ExpectedCount)       \
211*b36d9bd9SDmitry Borisov     do {                                                                             \
212*b36d9bd9SDmitry Borisov     ok_eq_int((ReqList)->InterfaceType, (ExpectedIface));                            \
213*b36d9bd9SDmitry Borisov     ok_eq_ulong((ReqList)->BusNumber, 0UL);                                          \
214*b36d9bd9SDmitry Borisov     ok_eq_ulong((ReqList)->SlotNumber, 0UL);                                         \
215*b36d9bd9SDmitry Borisov     ok_eq_ulong((ReqList)->AlternativeLists, (ExpectedCount));                       \
216*b36d9bd9SDmitry Borisov     } while (0)
217*b36d9bd9SDmitry Borisov 
218*b36d9bd9SDmitry Borisov #define expect_alt_list_header(AltList, ExpectedCount)  \
219*b36d9bd9SDmitry Borisov     do {                                                \
220*b36d9bd9SDmitry Borisov     ok_eq_int((AltList)->Version, 1);                   \
221*b36d9bd9SDmitry Borisov     ok_eq_int((AltList)->Revision, 1);                  \
222*b36d9bd9SDmitry Borisov     ok_eq_ulong((AltList)->Count, (ExpectedCount));     \
223*b36d9bd9SDmitry Borisov     } while (0)
224*b36d9bd9SDmitry Borisov 
225*b36d9bd9SDmitry Borisov #define expect_port_req(Desc, ExpectedOption, ExpectedFlags, ExpectedShare,      \
226*b36d9bd9SDmitry Borisov                         ExpectedLength, ExpectedAlign, ExpectedMin, ExpectedMax) \
227*b36d9bd9SDmitry Borisov     do {                                                                         \
228*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypePort,                                       \
229*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypePort);      \
230*b36d9bd9SDmitry Borisov     ok((Desc)->Option == (ExpectedOption),                                       \
231*b36d9bd9SDmitry Borisov        "Desc->Option = %u, expected %u\n", (Desc)->Option, (ExpectedOption));    \
232*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                         \
233*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));       \
234*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                              \
235*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                             \
236*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                               \
237*b36d9bd9SDmitry Borisov     ok((Desc)->u.Port.Length == (ExpectedLength),                                \
238*b36d9bd9SDmitry Borisov        "Desc->u.Port.Length = %lx, expected %lx\n",                              \
239*b36d9bd9SDmitry Borisov        (Desc)->u.Port.Length, (ExpectedLength));                                 \
240*b36d9bd9SDmitry Borisov     ok((Desc)->u.Port.Alignment == (ExpectedAlign),                              \
241*b36d9bd9SDmitry Borisov        "Desc->u.Port.Alignment = %lu, expected %lu\n",                           \
242*b36d9bd9SDmitry Borisov        (Desc)->u.Port.Alignment, (ExpectedAlign));                               \
243*b36d9bd9SDmitry Borisov     ok((Desc)->u.Port.MinimumAddress.QuadPart == (ExpectedMin),                  \
244*b36d9bd9SDmitry Borisov        "Desc->u.Port.MinimumAddress = 0x%I64x, expected 0x%I64x\n",              \
245*b36d9bd9SDmitry Borisov        (Desc)->u.Port.MinimumAddress.QuadPart, (ExpectedMin));                   \
246*b36d9bd9SDmitry Borisov     ok((Desc)->u.Port.MaximumAddress.QuadPart == (ExpectedMax),                  \
247*b36d9bd9SDmitry Borisov        "Desc->u.Port.MaximumAddress = 0x%I64x, expected 0x%I64x\n",              \
248*b36d9bd9SDmitry Borisov        (Desc)->u.Port.MaximumAddress.QuadPart, (ExpectedMax));                   \
249*b36d9bd9SDmitry Borisov     } while (0)
250*b36d9bd9SDmitry Borisov 
251*b36d9bd9SDmitry Borisov #define expect_irq_req(Desc, ExpectedOption, ExpectedFlags, ExpectedShare,       \
252*b36d9bd9SDmitry Borisov                        ExpectedMin, ExpectedMax)                                 \
253*b36d9bd9SDmitry Borisov     do {                                                                         \
254*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeInterrupt,                                  \
255*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeInterrupt); \
256*b36d9bd9SDmitry Borisov     ok((Desc)->Option == (ExpectedOption),                                       \
257*b36d9bd9SDmitry Borisov        "Desc->Option = %u, expected %u\n", (Desc)->Option, (ExpectedOption));    \
258*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                         \
259*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));       \
260*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                              \
261*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                             \
262*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                               \
263*b36d9bd9SDmitry Borisov     ok((Desc)->u.Interrupt.MinimumVector == (ExpectedMin),                       \
264*b36d9bd9SDmitry Borisov        "Desc->u.Interrupt.MinimumVector = %lu, expected %lu\n",                  \
265*b36d9bd9SDmitry Borisov        (Desc)->u.Interrupt.MinimumVector, (ExpectedMin));                        \
266*b36d9bd9SDmitry Borisov     ok((Desc)->u.Interrupt.MaximumVector == (ExpectedMax),                       \
267*b36d9bd9SDmitry Borisov        "Desc->u.Interrupt.MaximumVector = %lu, expected %lu\n",                  \
268*b36d9bd9SDmitry Borisov        (Desc)->u.Interrupt.MaximumVector, (ExpectedMax));                        \
269*b36d9bd9SDmitry Borisov     } while (0)
270*b36d9bd9SDmitry Borisov 
271*b36d9bd9SDmitry Borisov #define expect_dma_req(Desc, ExpectedOption, ExpectedFlags, ExpectedShare,       \
272*b36d9bd9SDmitry Borisov                        ExpectedMin, ExpectedMax)                                 \
273*b36d9bd9SDmitry Borisov     do {                                                                         \
274*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeDma,                                        \
275*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeDma);       \
276*b36d9bd9SDmitry Borisov     ok((Desc)->Option == (ExpectedOption),                                       \
277*b36d9bd9SDmitry Borisov        "Desc->Option = %u, expected %u\n", (Desc)->Option, (ExpectedOption));    \
278*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                         \
279*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));       \
280*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                              \
281*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                             \
282*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                               \
283*b36d9bd9SDmitry Borisov     ok((Desc)->u.Dma.MinimumChannel == (ExpectedMin),                            \
284*b36d9bd9SDmitry Borisov        "Desc->u.Dma.MinimumChannel = %lu, expected %lu\n",                       \
285*b36d9bd9SDmitry Borisov        (Desc)->u.Dma.MinimumChannel, (ExpectedMin));                             \
286*b36d9bd9SDmitry Borisov     ok((Desc)->u.Dma.MaximumChannel == (ExpectedMax),                            \
287*b36d9bd9SDmitry Borisov        "Desc->u.Dma.MaximumChannel = %lu, expected %lu\n",                       \
288*b36d9bd9SDmitry Borisov        (Desc)->u.Dma.MaximumChannel, (ExpectedMax));                             \
289*b36d9bd9SDmitry Borisov     } while (0)
290*b36d9bd9SDmitry Borisov 
291*b36d9bd9SDmitry Borisov #define expect_mem_req(Desc, ExpectedOption, ExpectedFlags, ExpectedShare,       \
292*b36d9bd9SDmitry Borisov                        ExpectedLength, ExpectedAlign, ExpectedMin, ExpectedMax)  \
293*b36d9bd9SDmitry Borisov     do {                                                                         \
294*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeMemory,                                     \
295*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeMemory);    \
296*b36d9bd9SDmitry Borisov     ok((Desc)->Option == (ExpectedOption),                                       \
297*b36d9bd9SDmitry Borisov        "Desc->Option = %u, expected %u\n", (Desc)->Option, (ExpectedOption));    \
298*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                         \
299*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));       \
300*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                              \
301*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                             \
302*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                               \
303*b36d9bd9SDmitry Borisov     ok((Desc)->u.Memory.Length == (ExpectedLength),                              \
304*b36d9bd9SDmitry Borisov        "Desc->u.Memory.Length = %lx, expected %lx\n",                            \
305*b36d9bd9SDmitry Borisov        (Desc)->u.Memory.Length, (ExpectedLength));                               \
306*b36d9bd9SDmitry Borisov     ok((Desc)->u.Memory.Alignment == (ExpectedAlign),                            \
307*b36d9bd9SDmitry Borisov        "Desc->u.Memory.Alignment = %lx, expected %lx\n",                         \
308*b36d9bd9SDmitry Borisov        (Desc)->u.Memory.Alignment, (ExpectedAlign));                             \
309*b36d9bd9SDmitry Borisov     ok((Desc)->u.Memory.MinimumAddress.QuadPart == (ExpectedMin),                \
310*b36d9bd9SDmitry Borisov        "Desc->u.Memory.MinimumAddress = 0x%I64x, expected 0x%I64x\n",            \
311*b36d9bd9SDmitry Borisov        (Desc)->u.Memory.MinimumAddress.QuadPart, (ExpectedMin));                 \
312*b36d9bd9SDmitry Borisov     ok((Desc)->u.Memory.MaximumAddress.QuadPart == (ExpectedMax),                \
313*b36d9bd9SDmitry Borisov        "Desc->u.Memory.MaximumAddress = 0x%I64x, expected 0x%I64x\n",            \
314*b36d9bd9SDmitry Borisov        (Desc)->u.Memory.MaximumAddress.QuadPart, (ExpectedMax));                 \
315*b36d9bd9SDmitry Borisov     } while (0)
316*b36d9bd9SDmitry Borisov 
317*b36d9bd9SDmitry Borisov #define expect_cfg_req(Desc, ExpectedOption, ExpectedFlags, ExpectedShare,        \
318*b36d9bd9SDmitry Borisov                        ExpectedPriority, ExpectedRes1, ExpectedRes2)              \
319*b36d9bd9SDmitry Borisov     do {                                                                          \
320*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeConfigData,                                  \
321*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeConfigData); \
322*b36d9bd9SDmitry Borisov     ok((Desc)->Option == (ExpectedOption),                                        \
323*b36d9bd9SDmitry Borisov        "Desc->Option = %u, expected %u\n", (Desc)->Option, (ExpectedOption));     \
324*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                          \
325*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));        \
326*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                               \
327*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                              \
328*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                                \
329*b36d9bd9SDmitry Borisov     ok((Desc)->u.ConfigData.Priority == (ExpectedPriority),                       \
330*b36d9bd9SDmitry Borisov        "Desc->u.ConfigData.Priority = %lx, expected %lx\n",                       \
331*b36d9bd9SDmitry Borisov        (Desc)->u.ConfigData.Priority, (ExpectedPriority));                        \
332*b36d9bd9SDmitry Borisov     ok((Desc)->u.ConfigData.Reserved1 == (ExpectedRes1),                          \
333*b36d9bd9SDmitry Borisov        "Desc->u.ConfigData.Reserved1 = %lx, expected %lx\n",                      \
334*b36d9bd9SDmitry Borisov        (Desc)->u.ConfigData.Reserved2, (ExpectedRes1));                           \
335*b36d9bd9SDmitry Borisov     ok((Desc)->u.ConfigData.Reserved2 == (ExpectedRes2),                          \
336*b36d9bd9SDmitry Borisov        "Desc->u.ConfigData.Reserved2 = %lx, expected %lx\n",                      \
337*b36d9bd9SDmitry Borisov        (Desc)->u.ConfigData.Reserved2, (ExpectedRes2));                           \
338*b36d9bd9SDmitry Borisov     } while (0)
339*b36d9bd9SDmitry Borisov 
340*b36d9bd9SDmitry Borisov #define expect_port_res(Desc, ExpectedFlags, ExpectedShare, ExpectedLength, ExpectedStart) \
341*b36d9bd9SDmitry Borisov     do {                                                                                   \
342*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypePort,                                                 \
343*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypePort);                \
344*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                                   \
345*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));                 \
346*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                                        \
347*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                                       \
348*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                                         \
349*b36d9bd9SDmitry Borisov     ok((Desc)->u.Port.Length == (ExpectedLength),                                          \
350*b36d9bd9SDmitry Borisov        "Desc->u.Port.Length = %lx, expected %lx\n",                                        \
351*b36d9bd9SDmitry Borisov        (Desc)->u.Port.Length, (ExpectedLength));                                           \
352*b36d9bd9SDmitry Borisov     ok((Desc)->u.Port.Start.QuadPart == (ExpectedStart),                                   \
353*b36d9bd9SDmitry Borisov        "Desc->u.Port.Start = 0x%I64x, expected 0x%I64x\n",                                 \
354*b36d9bd9SDmitry Borisov        (Desc)->u.Port.Start.QuadPart, (ExpectedStart));                                    \
355*b36d9bd9SDmitry Borisov     } while (0)
356*b36d9bd9SDmitry Borisov 
357*b36d9bd9SDmitry Borisov #define expect_irq_res(Desc, ExpectedFlags, ExpectedShare,                                 \
358*b36d9bd9SDmitry Borisov                        ExpectedLevel, ExpectedVector, ExpectedAffinity)                    \
359*b36d9bd9SDmitry Borisov     do {                                                                                   \
360*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeInterrupt,                                            \
361*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeInterrupt);           \
362*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                                   \
363*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));                 \
364*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                                        \
365*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                                       \
366*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                                         \
367*b36d9bd9SDmitry Borisov     ok((Desc)->u.Interrupt.Level == (ExpectedLevel),                                       \
368*b36d9bd9SDmitry Borisov        "Desc->u.Interrupt.Level = %lu\n", (Desc)->u.Interrupt.Level);                      \
369*b36d9bd9SDmitry Borisov     ok((Desc)->u.Interrupt.Vector == (ExpectedVector),                                     \
370*b36d9bd9SDmitry Borisov        "Desc->u.Interrupt.Vector = %lu\n", (Desc)->u.Interrupt.Vector);                    \
371*b36d9bd9SDmitry Borisov     ok((Desc)->u.Interrupt.Affinity == (ExpectedAffinity),                                 \
372*b36d9bd9SDmitry Borisov        "Desc->u.Interrupt.Affinity = %Ix\n", (Desc)->u.Interrupt.Affinity);                \
373*b36d9bd9SDmitry Borisov     } while (0)
374*b36d9bd9SDmitry Borisov 
375*b36d9bd9SDmitry Borisov #define expect_dma_res(Desc, ExpectedFlags, ExpectedShare, ExpectedChannel)                \
376*b36d9bd9SDmitry Borisov     do {                                                                                   \
377*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeDma,                                                  \
378*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeDma);                 \
379*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                                   \
380*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));                 \
381*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                                        \
382*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                                       \
383*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                                         \
384*b36d9bd9SDmitry Borisov     ok((Desc)->u.Dma.Channel == (ExpectedChannel),                                         \
385*b36d9bd9SDmitry Borisov        "Desc->u.Dma.Channel = %lu, expected %lu\n",                                        \
386*b36d9bd9SDmitry Borisov        (Desc)->u.Dma.Channel, (ExpectedChannel));                                          \
387*b36d9bd9SDmitry Borisov     ok((Desc)->u.Dma.Port == 0ul,                                                          \
388*b36d9bd9SDmitry Borisov        "Desc->u.Dma.Port = %lu, expected %lu\n",                                           \
389*b36d9bd9SDmitry Borisov        (Desc)->u.Dma.Port, 0ul);                                                           \
390*b36d9bd9SDmitry Borisov     ok((Desc)->u.Dma.Reserved1 == 0ul,                                                     \
391*b36d9bd9SDmitry Borisov        "Desc->u.Dma.Reserved1 = %lx, expected 0\n", (Desc)->u.Dma.Reserved1);              \
392*b36d9bd9SDmitry Borisov     } while (0)
393*b36d9bd9SDmitry Borisov 
394*b36d9bd9SDmitry Borisov #define expect_mem_res(Desc, ExpectedFlags, ExpectedShare, ExpectedLength, ExpectedStart)  \
395*b36d9bd9SDmitry Borisov     do {                                                                                   \
396*b36d9bd9SDmitry Borisov     ok((Desc)->Type == CmResourceTypeMemory,                                               \
397*b36d9bd9SDmitry Borisov        "Desc->Type = %u, expected %u\n", (Desc)->Type, CmResourceTypeMemory);              \
398*b36d9bd9SDmitry Borisov     ok((Desc)->Flags == (ExpectedFlags),                                                   \
399*b36d9bd9SDmitry Borisov        "Desc->Flags = %x, expected %x\n", (Desc)->Flags, (ExpectedFlags));                 \
400*b36d9bd9SDmitry Borisov     ok((Desc)->ShareDisposition == (ExpectedShare),                                        \
401*b36d9bd9SDmitry Borisov        "Desc->ShareDisposition = %u, expected %u\n",                                       \
402*b36d9bd9SDmitry Borisov        (Desc)->ShareDisposition, (ExpectedShare));                                         \
403*b36d9bd9SDmitry Borisov     ok((Desc)->u.Memory.Length == (ExpectedLength),                                        \
404*b36d9bd9SDmitry Borisov        "Desc->u.Memory.Length = %lx, expected %lx\n",                                      \
405*b36d9bd9SDmitry Borisov        (Desc)->u.Memory.Length, (ExpectedLength));                                         \
406*b36d9bd9SDmitry Borisov     ok((Desc)->u.Memory.Start.QuadPart == (ExpectedStart),                                 \
407*b36d9bd9SDmitry Borisov        "Desc->u.Memory.Start = 0x%I64x, expected 0x%I64x\n",                               \
408*b36d9bd9SDmitry Borisov        (Desc)->u.Memory.Start.QuadPart, (ExpectedStart));                                  \
409*b36d9bd9SDmitry Borisov     } while (0)
410