ReactOS 0.4.16-dev-306-g647d351
hwvalid.c File Reference
#include "acpi.h"
#include "accommon.h"
Include dependency graph for hwvalid.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_HARDWARE
 
#define ACPI_PORT_INFO_ENTRIES   ACPI_ARRAY_LENGTH (AcpiProtectedPorts)
 

Functions

static ACPI_STATUS AcpiHwValidateIoRequest (ACPI_IO_ADDRESS Address, UINT32 BitWidth)
 
ACPI_STATUS AcpiHwReadPort (ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
 
ACPI_STATUS AcpiHwWritePort (ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
 

Variables

static const ACPI_PORT_INFO AcpiProtectedPorts []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_HARDWARE

Definition at line 47 of file hwvalid.c.

◆ ACPI_PORT_INFO_ENTRIES

#define ACPI_PORT_INFO_ENTRIES   ACPI_ARRAY_LENGTH (AcpiProtectedPorts)

Definition at line 110 of file hwvalid.c.

Function Documentation

◆ AcpiHwReadPort()

ACPI_STATUS AcpiHwReadPort ( ACPI_IO_ADDRESS  Address,
UINT32 Value,
UINT32  Width 
)

Definition at line 237 of file hwvalid.c.

241{
243 UINT32 OneByte;
244 UINT32 i;
245
246
247 /* Truncate address to 16 bits if requested */
248
249 if (AcpiGbl_TruncateIoAddresses)
250 {
252 }
253
254 /* Validate the entire request and perform the I/O */
255
257 if (ACPI_SUCCESS (Status))
258 {
260 return (Status);
261 }
262
264 {
265 return (Status);
266 }
267
268 /*
269 * There has been a protection violation within the request. Fall
270 * back to byte granularity port I/O and ignore the failing bytes.
271 * This provides compatibility with other ACPI implementations.
272 */
273 for (i = 0, *Value = 0; i < Width; i += 8)
274 {
275 /* Validate and read one byte */
276
278 {
279 Status = AcpiOsReadPort (Address, &OneByte, 8);
280 if (ACPI_FAILURE (Status))
281 {
282 return (Status);
283 }
284
285 *Value |= (OneByte << i);
286 }
287
288 Address++;
289 }
290
291 return (AE_OK);
292}
unsigned int UINT32
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_AML_ILLEGAL_ADDRESS
Definition: acexcep.h:211
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_OK
Definition: acexcep.h:97
ACPI_STATUS AcpiOsReadPort(ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
Definition: osl.c:701
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_UINT16_MAX
Definition: actypes.h:65
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
static ACPI_STATUS AcpiHwValidateIoRequest(ACPI_IO_ADDRESS Address, UINT32 BitWidth)
Definition: hwvalid.c:130
static WCHAR Address[46]
Definition: ping.c:68
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by AcpiExSystemIoSpaceHandler(), AcpiHwRead(), and AcpiHwRegisterRead().

◆ AcpiHwValidateIoRequest()

static ACPI_STATUS AcpiHwValidateIoRequest ( ACPI_IO_ADDRESS  Address,
UINT32  BitWidth 
)
static

Definition at line 130 of file hwvalid.c.

133{
134 UINT32 i;
135 UINT32 ByteWidth;
136 ACPI_IO_ADDRESS LastAddress;
137 const ACPI_PORT_INFO *PortInfo;
138
139
140 ACPI_FUNCTION_TRACE (HwValidateIoRequest);
141
142
143 /* Supported widths are 8/16/32 */
144
145 if ((BitWidth != 8) &&
146 (BitWidth != 16) &&
147 (BitWidth != 32))
148 {
150 "Bad BitWidth parameter: %8.8X", BitWidth));
152 }
153
154 PortInfo = AcpiProtectedPorts;
155 ByteWidth = ACPI_DIV_8 (BitWidth);
156 LastAddress = Address + ByteWidth - 1;
157
159 "Address %8.8X%8.8X LastAddress %8.8X%8.8X Length %X",
161 ByteWidth));
162
163 /* Maximum 16-bit address in I/O space */
164
165 if (LastAddress > ACPI_UINT16_MAX)
166 {
168 "Illegal I/O port address/length above 64K: %8.8X%8.8X/0x%X",
169 ACPI_FORMAT_UINT64 (Address), ByteWidth));
171 }
172
173 /* Exit if requested address is not within the protected port table */
174
176 {
178 }
179
180 /* Check request against the list of protected I/O ports */
181
182 for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++)
183 {
184 /*
185 * Check if the requested address range will write to a reserved
186 * port. There are four cases to consider:
187 *
188 * 1) Address range is contained completely in the port address range
189 * 2) Address range overlaps port range at the port range start
190 * 3) Address range overlaps port range at the port range end
191 * 4) Address range completely encompasses the port range
192 */
193 if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start))
194 {
195 /* Port illegality may depend on the _OSI calls made by the BIOS */
196
197 if (AcpiGbl_OsiData >= PortInfo->OsiDependency)
198 {
200 "Denied AML access to port 0x%8.8X%8.8X/%X (%s 0x%.4X-0x%.4X)\n",
201 ACPI_FORMAT_UINT64 (Address), ByteWidth, PortInfo->Name,
202 PortInfo->Start, PortInfo->End));
203
205 }
206 }
207
208 /* Finished if address range ends before the end of this port */
209
210 if (LastAddress <= PortInfo->End)
211 {
212 break;
213 }
214 }
215
217}
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_LIMIT
Definition: acexcep.h:124
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_DIV_8(a)
Definition: acmacros.h:214
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_VALUES
Definition: acoutput.h:173
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DB_IO
Definition: acoutput.h:177
static const ACPI_PORT_INFO AcpiProtectedPorts[]
Definition: hwvalid.c:89
#define ACPI_PORT_INFO_ENTRIES
Definition: hwvalid.c:110
char * Name
Definition: aclocal.h:1278
UINT16 End
Definition: aclocal.h:1280
UINT8 OsiDependency
Definition: aclocal.h:1281
UINT16 Start
Definition: aclocal.h:1279

Referenced by AcpiHwReadPort(), and AcpiHwWritePort().

◆ AcpiHwWritePort()

ACPI_STATUS AcpiHwWritePort ( ACPI_IO_ADDRESS  Address,
UINT32  Value,
UINT32  Width 
)

Definition at line 312 of file hwvalid.c.

316{
318 UINT32 i;
319
320
321 /* Truncate address to 16 bits if requested */
322
323 if (AcpiGbl_TruncateIoAddresses)
324 {
326 }
327
328 /* Validate the entire request and perform the I/O */
329
331 if (ACPI_SUCCESS (Status))
332 {
334 return (Status);
335 }
336
338 {
339 return (Status);
340 }
341
342 /*
343 * There has been a protection violation within the request. Fall
344 * back to byte granularity port I/O and ignore the failing bytes.
345 * This provides compatibility with other ACPI implementations.
346 */
347 for (i = 0; i < Width; i += 8)
348 {
349 /* Validate and write one byte */
350
352 {
353 Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8);
354 if (ACPI_FAILURE (Status))
355 {
356 return (Status);
357 }
358 }
359
360 Address++;
361 }
362
363 return (AE_OK);
364}
ACPI_STATUS AcpiOsWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: osl.c:731

Referenced by AcpiEnterSleepStateS4bios(), AcpiExSystemIoSpaceHandler(), AcpiHwRegisterWrite(), AcpiHwSetMode(), and AcpiHwWrite().

Variable Documentation

◆ AcpiProtectedPorts

const ACPI_PORT_INFO AcpiProtectedPorts[]
static
Initial value:
=
{
{"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP},
{"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL},
{"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP},
{"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP},
{"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP},
{"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP},
{"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP},
{"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP},
{"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP},
{"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP},
{"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP},
{"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP},
{"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP},
{"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL},
{"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP},
{"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL},
{"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP}
}
#define ACPI_ALWAYS_ILLEGAL
Definition: aclocal.h:1259
#define ACPI_OSI_WIN_XP
Definition: actypes.h:1436

Definition at line 89 of file hwvalid.c.

Referenced by AcpiHwValidateIoRequest().