ReactOS 0.4.15-dev-8100-g1887773
HalSystemInfo.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for HalSystemInfo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static void TestAMLIllegalIOPortAddresses (void)
 
 START_TEST (HalSystemInfo)
 

Variables

static HAL_AMLI_BAD_IO_ADDRESS_LIST ExpectedList []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file HalSystemInfo.c.

Function Documentation

◆ START_TEST()

START_TEST ( HalSystemInfo  )

Definition at line 151 of file HalSystemInfo.c.

152{
154}
static void TestAMLIllegalIOPortAddresses(void)
Definition: HalSystemInfo.c:39

◆ TestAMLIllegalIOPortAddresses()

static void TestAMLIllegalIOPortAddresses ( void  )
static

Definition at line 39 of file HalSystemInfo.c.

40{
43 ULONG AddressListLength;
45
46 /* Query required size and check that it's valid */
47 ReturnedLength = 0x55555555;
49 0,
50 NULL,
53 ok(ReturnedLength % sizeof(*AddressList) == 0, "List size %lu is not a multiple of %Iu\n", ReturnedLength, sizeof(*AddressList));
54 if (skip(ReturnedLength > 0 && ReturnedLength < 0x10000000, "Invalid length\n"))
55 {
56 return;
57 }
58 AddressListLength = ReturnedLength;
60 AddressListLength,
61 'OImK');
62 if (skip(AddressList != NULL, "Failed to alloc %lu bytes\n", AddressListLength))
63 {
64 return;
65 }
66
67 if (ReturnedLength != sizeof(*AddressList))
68 {
69 /* Try with space for exactly one entry and make sure we get
70 * the same return code
71 */
72 RtlFillMemory(AddressList, AddressListLength, 0x55);
73 ReturnedLength = 0x55555555;
75 sizeof(*AddressList),
76 AddressList,
79 ok_eq_ulong(ReturnedLength, AddressListLength);
80 ok_eq_hex(AddressList[0].BadAddrBegin, 0x55555555UL);
81 }
82
83 /* One byte less than required should still return no data */
84 RtlFillMemory(AddressList, AddressListLength, 0x55);
85 ReturnedLength = 0x55555555;
87 AddressListLength - 1,
88 AddressList,
91 ok_eq_ulong(ReturnedLength, AddressListLength);
92 ok_eq_hex(AddressList[0].BadAddrBegin, 0x55555555UL);
93
94 /* Specify required size */
95 RtlFillMemory(AddressList, AddressListLength, 0x55);
96 ReturnedLength = 0x55555555;
98 AddressListLength,
99 AddressList,
102 ok_eq_ulong(ReturnedLength, AddressListLength);
103
104 /* Validate the table against our expectations */
106 for (ULONG i = 0;
107 i < min(ReturnedLength, sizeof(ExpectedList)) / sizeof(*AddressList);
108 i++)
109 {
110 ok(AddressList[i].BadAddrBegin == ExpectedList[i].BadAddrBegin,
111 "[%lu] BadAddrBegin 0x%lx, expected 0x%lx\n",
112 i, AddressList[i].BadAddrBegin, ExpectedList[i].BadAddrBegin);
113 ok(AddressList[i].BadAddrSize == ExpectedList[i].BadAddrSize,
114 "[%lu] BadAddrSize 0x%lx, expected 0x%lx\n",
115 i, AddressList[i].BadAddrSize, ExpectedList[i].BadAddrSize);
116 ok(AddressList[i].OSVersionTrigger == ExpectedList[i].OSVersionTrigger,
117 "[%lu] OSVersionTrigger 0x%lx, expected 0x%lx\n",
118 i, AddressList[i].OSVersionTrigger, ExpectedList[i].OSVersionTrigger);
119 if (ExpectedList[i].IOHandler != NULL)
120 {
121 ok(AddressList[i].IOHandler != NULL,
122 "[%lu] IOHandler = %p\n", i, AddressList[i].IOHandler);
123 }
124 else
125 {
126 ok(AddressList[i].IOHandler == NULL,
127 "[%lu] IOHandler = %p\n", i, AddressList[i].IOHandler);
128 }
129
130 /* If we got an I/O handler, try to call it */
131 if (AddressList[i].IOHandler != NULL)
132 {
133 ULONG Data = 0x55555555;
134
135 /* We don't want to break devices, so call it with an address
136 * outside of its range, and it should return failure
137 */
138 Status = AddressList[i].IOHandler(TRUE,
139 AddressList[i].BadAddrBegin - 1,
140 1,
141 &Data);
143 "[%lu] IOHandler returned 0x%lx\n", i, Status);
144 ok(Data == 0x55555555,
145 "[%lu] IOHandler returned Data 0x%lx\n", i, Data);
146 }
147 }
148 ExFreePoolWithTag(AddressList, 'OImK');
149}
static HAL_AMLI_BAD_IO_ADDRESS_LIST ExpectedList[]
Definition: HalSystemInfo.c:13
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
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
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define min(a, b)
Definition: monoChain.cc:55
#define STATUS_SUCCESS
Definition: shellext.h:65
PHALIOREADWRITEHANDLER IOHandler
Definition: haltypes.h:382
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define HalQuerySystemInformation
Definition: haltypes.h:294
@ HalQueryAMLIIllegalIOPortAddresses
Definition: haltypes.h:35

Referenced by START_TEST().

Variable Documentation

◆ ExpectedList

HAL_AMLI_BAD_IO_ADDRESS_LIST ExpectedList[]
static
Initial value:
=
{
{ 0x0000, 0x10, 1, NULL },
{ 0x0020, 0x02, 0, NULL },
{ 0x0040, 0x04, 1, NULL },
{ 0x0048, 0x04, 1, NULL },
{ 0x0070, 0x02, 1, NULL },
{ 0x0074, 0x03, 1, NULL },
{ 0x0081, 0x03, 1, NULL },
{ 0x0087, 0x01, 1, NULL },
{ 0x0089, 0x01, 1, NULL },
{ 0x008A, 0x02, 1, NULL },
{ 0x008F, 0x01, 1, NULL },
{ 0x0090, 0x02, 1, NULL },
{ 0x0093, 0x02, 1, NULL },
{ 0x0096, 0x02, 1, NULL },
{ 0x00A0, 0x02, 0, NULL },
{ 0x00C0, 0x20, 1, NULL },
{ 0x04D0, 0x02, 0, NULL },
{ 0x0CF8, 0x08, 1, (PVOID)1 },
{ 0x0000, 0x00, 0, NULL },
}
void * PVOID
Definition: typedefs.h:50

Definition at line 13 of file HalSystemInfo.c.

Referenced by TestAMLIllegalIOPortAddresses().