ReactOS 0.4.16-dev-297-gc569aee
tests.c File Reference
Include dependency graph for tests.c:

Go to the source code of this file.

Macros

#define TEST_RDP_IO_BASE   ((PUCHAR)(0x2F4 | 3))
 
#define RDP_INDEX   4
 

Functions

static VOID DrvFlushDeviceConfig (_In_ PISAPNP_CARD_LOGICAL_DEVICE LogDev)
 
static BOOLEAN DrvCreateCards (VOID)
 
static BOOLEAN DrvTestIsolation (VOID)
 
static VOID DrvTestResources (VOID)
 
static VOID DrvTestReadDataPortQueryResources (VOID)
 
static VOID DrvTestReadDataPortQueryResourcesRequirementsForEnum (VOID)
 
static VOID DrvTestReadDataPortQueryResourcesRequirementsForRebalance (VOID)
 
 START_TEST (Resources)
 

Variables

static const ULONG DrvpIsaBusPorts [] = { 0xA79, 0x279 }
 
static const ULONG DrvpIsaBusReadDataPorts [] = { 0x274, 0x3E4, 0x204, 0x2E4, 0x354, 0x2F4 }
 
PISAPNP_CARD IsapCard
 

Macro Definition Documentation

◆ RDP_INDEX

#define RDP_INDEX   4

◆ TEST_RDP_IO_BASE

#define TEST_RDP_IO_BASE   ((PUCHAR)(0x2F4 | 3))

Definition at line 22 of file tests.c.

Function Documentation

◆ DrvCreateCards()

static BOOLEAN DrvCreateCards ( VOID  )
static

Definition at line 62 of file tests.c.

63{
65
66 /* Create 2 cards */
68 if (!IsapCard)
69 return FALSE;
70
71 Card = IsapCard;
74
75 return TRUE;
76}
Definition: card.h:28
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
VOID DrvCreateCard2(_In_ PISAPNP_CARD Card)
Definition: empty_card.c:44
VOID DrvCreateCard1(_In_ PISAPNP_CARD Card)
Definition: res_card.c:226
PISAPNP_CARD IsapCard
Definition: isabus.c:14

Referenced by DrvTestIsolation().

◆ DrvFlushDeviceConfig()

static VOID DrvFlushDeviceConfig ( _In_ PISAPNP_CARD_LOGICAL_DEVICE  LogDev)
static

Definition at line 28 of file tests.c.

30{
31 UCHAR MemControl[8];
32
33 /*
34 * Save the memory control registers
35 * since we would need the correct values for the configuration process.
36 */
37 MemControl[0] = LogDev->Registers[0x42];
38 MemControl[1] = LogDev->Registers[0x4A];
39 MemControl[2] = LogDev->Registers[0x52];
40 MemControl[3] = LogDev->Registers[0x5A];
41 MemControl[4] = LogDev->Registers[0x7A];
42 MemControl[5] = LogDev->Registers[0x84];
43 MemControl[6] = LogDev->Registers[0x94];
44 MemControl[7] = LogDev->Registers[0xA4];
45
46 /* Fill the whole configuration area with 0xCC for testing purposes */
47 RtlFillMemory(&LogDev->Registers[0x40], sizeof(LogDev->Registers) - 0x40, 0xCC);
48
49 /* Restore saved registers */
50 LogDev->Registers[0x42] = MemControl[0];
51 LogDev->Registers[0x4A] = MemControl[1];
52 LogDev->Registers[0x52] = MemControl[2];
53 LogDev->Registers[0x5A] = MemControl[3];
54 LogDev->Registers[0x7A] = MemControl[4];
55 LogDev->Registers[0x84] = MemControl[5];
56 LogDev->Registers[0x94] = MemControl[6];
57 LogDev->Registers[0xA4] = MemControl[7];
58}
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrvTestResources().

◆ DrvTestIsolation()

static BOOLEAN DrvTestIsolation ( VOID  )
static

Definition at line 80 of file tests.c.

81{
82 UCHAR Cards;
83
84 /* Run the isolation protocol on an empty bus */
86 ok_eq_int(Cards, 0);
88
89 if (!DrvCreateCards())
90 {
91 skip("No memory\n");
92 return FALSE;
93 }
94
95 /* Another bus that contains 2 cards */
97 ok_eq_int(Cards, 2);
98
99 return TRUE;
100}
#define ok_eq_int(value, expected)
Definition: apitest.h:60
#define skip(...)
Definition: atltest.h:64
VOID IsaHwWaitForKey(VOID)
Definition: hardware.c:1684
UCHAR IsaHwTryReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:1259
#define TEST_RDP_IO_BASE
Definition: tests.c:22
static BOOLEAN DrvCreateCards(VOID)
Definition: tests.c:62

Referenced by START_TEST().

◆ DrvTestReadDataPortQueryResources()

static VOID DrvTestReadDataPortQueryResources ( VOID  )
static

Definition at line 253 of file tests.c.

254{
257 ULONG i;
258
260
261 ok(ResourceList != NULL, "ResourceList is NULL\n");
262 if (ResourceList == NULL)
263 {
264 skip("No ResourceList\n");
265 return;
266 }
268
269 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[0];
270
271 for (i = 0; i < RTL_NUMBER_OF(DrvpIsaBusPorts); ++i)
272 {
276 1ul,
278 Descriptor++;
279 }
280
281 /*********************************************************/
282
284}
static SIZE_T GetPoolAllocSize(PVOID MemPtr)
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define ok_eq_size(value, expected)
Definition: apitest.h:69
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
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
@ Internal
Definition: hwresource.cpp:137
PCM_RESOURCE_LIST IsaPnpCreateReadPortDOResources(VOID)
Definition: isapnp.c:967
unsigned __int64 ULONG64
Definition: imports.h:198
#define expect_resource_list_header(ResourceList, ExpectedIface, ExpectedCount)
Definition: precomp.h:201
#define expect_port_res(Desc, ExpectedFlags, ExpectedShare, ExpectedLength, ExpectedStart)
Definition: precomp.h:340
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
static const ULONG DrvpIsaBusPorts[]
Definition: tests.c:17
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by START_TEST().

◆ DrvTestReadDataPortQueryResourcesRequirementsForEnum()

static VOID DrvTestReadDataPortQueryResourcesRequirementsForEnum ( VOID  )
static

Definition at line 309 of file tests.c.

310{
313 ULONG i;
314
316
317 ok(ReqList != NULL, "ReqList is NULL\n");
318 if (ReqList == NULL)
319 {
320 skip("No ReqList\n");
321 return;
322 }
324 expect_alt_list_header(&ReqList->List[0], 16UL);
325
326 Descriptor = &ReqList->List[0].Descriptors[0];
327
328 for (i = 0; i < RTL_NUMBER_OF(DrvpIsaBusPorts) * 2; ++i)
329 {
330 if ((i % 2) == 0)
331 {
333 0,
336 1ul,
337 1ul,
340 }
341 else
342 {
347 0ul,
348 1ul,
349 0ull,
350 0ull);
351 }
352
353 Descriptor++;
354 }
355
356 for (i = 0; i < RTL_NUMBER_OF(DrvpIsaBusReadDataPorts) * 2; ++i)
357 {
358 if ((i % 2) == 0)
359 {
361 0,
364 4ul,
365 1ul,
367 (ULONG64)(DrvpIsaBusReadDataPorts[i / 2]) + 4 - 1);
368 }
369 else
370 {
375 0ul,
376 1ul,
377 0ull,
378 0ull);
379 }
380
381 Descriptor++;
382 }
383
384 /*********************************************************/
385
386 ok_int(ReqList->ListSize, GetPoolAllocSize(ReqList));
387 ok_int(ReqList->ListSize, (ULONG_PTR)Descriptor - (ULONG_PTR)ReqList);
388}
#define ok_int(expression, result)
Definition: atltest.h:134
PIO_RESOURCE_REQUIREMENTS_LIST IsaPnpCreateReadPortDORequirements(_In_opt_ ULONG SelectedReadPort)
Definition: isapnp.c:821
#define expect_alt_list_header(AltList, ExpectedCount)
Definition: precomp.h:218
#define expect_requirements_list_header(ReqList, ExpectedIface, ExpectedCount)
Definition: precomp.h:210
#define expect_port_req(Desc, ExpectedOption, ExpectedFlags, ExpectedShare, ExpectedLength, ExpectedAlign, ExpectedMin, ExpectedMax)
Definition: precomp.h:225
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: iotypes.h:2737
IO_RESOURCE_LIST List[1]
Definition: iotypes.h:2747
static const ULONG DrvpIsaBusReadDataPorts[]
Definition: tests.c:18
#define IO_RESOURCE_ALTERNATIVE

Referenced by START_TEST().

◆ DrvTestReadDataPortQueryResourcesRequirementsForRebalance()

static VOID DrvTestReadDataPortQueryResourcesRequirementsForRebalance ( VOID  )
static

Definition at line 407 of file tests.c.

408{
411 ULONG i;
412
413 /* Select the 4th I/O range in the list */
414#define RDP_INDEX 4
416
417 ok(ReqList != NULL, "ReqList is NULL\n");
418 if (ReqList == NULL)
419 {
420 skip("No ReqList\n");
421 return;
422 }
424 expect_alt_list_header(&ReqList->List[0], 10UL);
425
426 Descriptor = &ReqList->List[0].Descriptors[0];
427
428 for (i = 0; i < RTL_NUMBER_OF(DrvpIsaBusPorts) * 2; ++i)
429 {
430 if ((i % 2) == 0)
431 {
433 0,
436 1ul,
437 1ul,
440 }
441 else
442 {
447 0ul,
448 1ul,
449 0ull,
450 0ull);
451 }
452
453 Descriptor++;
454 }
455
456 for (i = 0; i < RTL_NUMBER_OF(DrvpIsaBusReadDataPorts); ++i)
457 {
462 4ul,
463 1ul,
465 (ULONG64)(DrvpIsaBusReadDataPorts[i]) + 4 - 1);
466
467 Descriptor++;
468 }
469
470 /*********************************************************/
471
472 ok_int(ReqList->ListSize, GetPoolAllocSize(ReqList));
473 ok_int(ReqList->ListSize, (ULONG_PTR)Descriptor - (ULONG_PTR)ReqList);
474}
#define RDP_INDEX

Referenced by START_TEST().

◆ DrvTestResources()

static VOID DrvTestResources ( VOID  )
static

Definition at line 104 of file tests.c.

105{
106 ISAPNP_FDO_EXTENSION FdoExt = { 0 };
109 ULONG i;
110
111 /* Our cards were isolated via DrvTestIsolation() */
112 FdoExt.Cards = 2;
115
116 /* Enumerate all logical devices on the bus */
117 IsaHwFillDeviceList(&FdoExt);
119
120 for (Entry = FdoExt.DeviceListHead.Flink, i = 0;
121 Entry != &FdoExt.DeviceListHead;
122 Entry = Entry->Flink)
123 {
127
128 PdoExt.IsaPnpDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
129
130 /* Create the resource lists */
133
134 ReqList = PdoExt.RequirementsList;
135 ResourceList = PdoExt.ResourceList;
136
137 /* Process each discovered logical device */
138 switch (i++)
139 {
140 case 0:
141 {
143
144 LogDev = &IsapCard[0].LogDev[0];
145 ok_eq_int(LogDev->Registers[0x30], 0x00);
146 break;
147 }
148 case 1:
149 {
151
152 LogDev = &IsapCard[0].LogDev[1];
153 ok_eq_int(LogDev->Registers[0x30], 0x00);
154 break;
155 }
156 case 2:
157 {
159
160 LogDev = &IsapCard[0].LogDev[2];
161 ok_eq_int(LogDev->Registers[0x30], 0x00);
162 break;
163 }
164 case 3:
165 {
167
168 LogDev = &IsapCard[0].LogDev[3];
169 ok_eq_int(LogDev->Registers[0x30], 0x00);
170 break;
171 }
172 case 4:
173 {
175
176 LogDev = &IsapCard[0].LogDev[4];
177 ok_eq_int(LogDev->Registers[0x30], 0x00);
178 break;
179 }
180 case 5:
181 {
183
184 /* Card 1, logical device 6 */
185 LogDev = &IsapCard[0].LogDev[5];
186
187 /* Should be activated only after configuration */
188 ok_eq_int(LogDev->Registers[0x30], 0x00);
189
190 /* I/O configuration test */
191 {
193
194 DrvFlushDeviceConfig(LogDev);
195
196 /* Assume that this device comes up with I/O range check logic enabled */
197 LogDev->Registers[0x31] = 0x02;
198
199 /* Create new resources */
201 if (ResourceList == NULL)
202 {
203 skip("No ResourceList\n");
204 break;
205 }
206
207 /* Assign resources to the device */
208 {
209 IsaHwWakeDevice(PdoExt.IsaPnpDevice);
210
211 Status = IsaHwConfigureDevice(&FdoExt, PdoExt.IsaPnpDevice, ResourceList);
213
214 IsaHwActivateDevice(&FdoExt, PdoExt.IsaPnpDevice);
216 }
217
219
220 /* I/O range check must be disabled */
221 ok_eq_int(LogDev->Registers[0x31], 0x00);
222
223 /* Verify device activation */
224 ok_eq_int(LogDev->Registers[0x30], 0x01);
225 }
226 break;
227 }
228 case 6:
229 {
231
232 LogDev = &IsapCard[0].LogDev[6];
233 ok_eq_int(LogDev->Registers[0x30], 0x00);
234 break;
235 }
236
237 default:
238 break;
239 }
240 }
241
242 ok(i == 7, "Some devices not tested\n");
243}
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
LONG NTSTATUS
Definition: precomp.h:26
VOID IsaHwWakeDevice(_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
Definition: hardware.c:1650
NTSTATUS IsaHwConfigureDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice, _In_ PCM_RESOURCE_LIST Resources)
Definition: hardware.c:1517
VOID IsaHwActivateDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
Definition: hardware.c:1661
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Status
Definition: gdiplustypes.h:25
static NTSTATUS IsaPnpCreateLogicalDeviceRequirements(_In_ PISAPNP_PDO_EXTENSION PdoExt)
Definition: isapnp.c:189
static NTSTATUS IsaPnpCreateLogicalDeviceResources(_In_ PISAPNP_PDO_EXTENSION PdoExt)
Definition: isapnp.c:625
VOID DrvTestCard1Dev2Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:660
PCM_RESOURCE_LIST DrvTestCard1Dev6CreateConfigurationResources(VOID)
Definition: res_card.c:1260
VOID DrvTestCard1Dev6Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:1162
VOID DrvTestCard1Dev7Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:1331
VOID DrvTestCard1Dev5Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:970
VOID DrvTestCard1Dev6ConfigurationResult(_In_ PISAPNP_CARD_LOGICAL_DEVICE LogDev)
Definition: res_card.c:1171
VOID DrvTestCard1Dev1Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:560
VOID DrvTestCard1Dev3Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:760
VOID DrvTestCard1Dev4Resources(_In_ PCM_RESOURCE_LIST ResourceList, _In_ PIO_RESOURCE_REQUIREMENTS_LIST ReqList)
Definition: res_card.c:838
#define STATUS_SUCCESS
Definition: shellext.h:65
base of all file and directory entries
Definition: entries.h:83
ISAPNP_CARD_LOGICAL_DEVICE LogDev[TEST_MAX_SUPPORTED_DEVICES]
Definition: precomp.h:130
PUCHAR ReadDataPort
Definition: isapnp.h:64
LIST_ENTRY DeviceListHead
Definition: precomp.h:82
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
static VOID DrvFlushDeviceConfig(_In_ PISAPNP_CARD_LOGICAL_DEVICE LogDev)
Definition: tests.c:28
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( Resources  )

Definition at line 476 of file tests.c.

477{
481
482 if (DrvTestIsolation())
483 {
485 }
486}
static VOID DrvTestReadDataPortQueryResourcesRequirementsForRebalance(VOID)
Definition: tests.c:407
static VOID DrvTestReadDataPortQueryResources(VOID)
Definition: tests.c:253
static VOID DrvTestReadDataPortQueryResourcesRequirementsForEnum(VOID)
Definition: tests.c:309
static VOID DrvTestResources(VOID)
Definition: tests.c:104
static BOOLEAN DrvTestIsolation(VOID)
Definition: tests.c:80

Variable Documentation

◆ DrvpIsaBusPorts

◆ DrvpIsaBusReadDataPorts

const ULONG DrvpIsaBusReadDataPorts[] = { 0x274, 0x3E4, 0x204, 0x2E4, 0x354, 0x2F4 }
static

◆ IsapCard