ReactOS  0.4.15-dev-326-g1c504f4
exregion.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
Include dependency graph for exregion.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 

Functions

ACPI_STATUS AcpiExSystemMemorySpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExSystemIoSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExPciConfigSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExCmosSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExPciBarSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
ACPI_STATUS AcpiExDataTableSpaceHandler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 49 of file exregion.c.

Function Documentation

◆ AcpiExCmosSpaceHandler()

ACPI_STATUS AcpiExCmosSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 469 of file exregion.c.

476 {
478 
479 
480  ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
481 
482 
484 }
UINT32 ACPI_STATUS
Definition: actypes.h:460
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExDataTableSpaceHandler()

ACPI_STATUS AcpiExDataTableSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 543 of file exregion.c.

550 {
551  ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
552 
553 
554  /*
555  * Perform the memory read or write. The BitWidth was already
556  * validated.
557  */
558  switch (Function)
559  {
560  case ACPI_READ:
561 
563  ACPI_DIV_8 (BitWidth));
564  break;
565 
566  case ACPI_WRITE:
567 
569  ACPI_DIV_8 (BitWidth));
570  break;
571 
572  default:
573 
575  }
576 
578 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
#define ACPI_READ
Definition: actypes.h:743
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:681
static WCHAR Address[46]
Definition: ping.c:68
#define ACPI_PHYSADDR_TO_PTR(i)
Definition: actypes.h:555
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ACPI_DIV_8(a)
Definition: acmacros.h:214
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define AE_OK
Definition: acexcep.h:97
#define ACPI_WRITE
Definition: actypes.h:744

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExPciBarSpaceHandler()

ACPI_STATUS AcpiExPciBarSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 506 of file exregion.c.

513 {
515 
516 
517  ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
518 
519 
521 }
UINT32 ACPI_STATUS
Definition: actypes.h:460
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExPciConfigSpaceHandler()

ACPI_STATUS AcpiExPciConfigSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 388 of file exregion.c.

395 {
397  ACPI_PCI_ID *PciId;
398  UINT16 PciRegister;
399 
400 
401  ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
402 
403 
404  /*
405  * The arguments to AcpiOs(Read|Write)PciConfiguration are:
406  *
407  * PciSegment is the PCI bus segment range 0-31
408  * PciBus is the PCI bus number range 0-255
409  * PciDevice is the PCI device number range 0-31
410  * PciFunction is the PCI device function number
411  * PciRegister is the Config space register range 0-255 bytes
412  *
413  * Value - input value for write, output address for read
414  *
415  */
416  PciId = (ACPI_PCI_ID *) RegionContext;
417  PciRegister = (UINT16) (UINT32) Address;
418 
420  "Pci-Config %u (%u) Seg(%04x) Bus(%04x) "
421  "Dev(%04x) Func(%04x) Reg(%04x)\n",
422  Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
423  PciId->Function, PciRegister));
424 
425  switch (Function)
426  {
427  case ACPI_READ:
428 
429  *Value = 0;
431  PciId, PciRegister, Value, BitWidth);
432  break;
433 
434  case ACPI_WRITE:
435 
437  PciId, PciRegister, *Value, BitWidth);
438  break;
439 
440  default:
441 
443  break;
444  }
445 
447 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
ACPI_STATUS AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Reg, UINT64 *Value, UINT32 Width)
Definition: osl.c:793
#define ACPI_READ
Definition: actypes.h:743
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
UINT16 Bus
Definition: actypes.h:1328
UINT16 Device
Definition: actypes.h:1329
UINT32 ACPI_STATUS
Definition: actypes.h:460
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:681
unsigned int UINT32
static WCHAR Address[46]
Definition: ping.c:68
UINT16 Segment
Definition: actypes.h:1327
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_STATUS AcpiOsWritePciConfiguration(ACPI_PCI_ID *PciId, UINT32 Reg, UINT64 Value, UINT32 Width)
Definition: osl.c:822
Status
Definition: gdiplustypes.h:24
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
unsigned short UINT16
UINT16 Function
Definition: actypes.h:1330
#define AE_OK
Definition: acexcep.h:97
#define ACPI_WRITE
Definition: actypes.h:744

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExSystemIoSpaceHandler()

ACPI_STATUS AcpiExSystemIoSpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 323 of file exregion.c.

330 {
332  UINT32 Value32;
333 
334 
335  ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
336 
337 
339  "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
340  BitWidth, Function, ACPI_FORMAT_UINT64 (Address)));
341 
342  /* Decode the function parameter */
343 
344  switch (Function)
345  {
346  case ACPI_READ:
347 
348  Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
349  &Value32, BitWidth);
350  *Value = Value32;
351  break;
352 
353  case ACPI_WRITE:
354 
355  Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
356  (UINT32) *Value, BitWidth);
357  break;
358 
359  default:
360 
362  break;
363  }
364 
366 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
#define ACPI_READ
Definition: actypes.h:743
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiHwReadPort(ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width)
Definition: hwvalid.c:237
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:681
unsigned int UINT32
ACPI_STATUS AcpiHwWritePort(ACPI_IO_ADDRESS Address, UINT32 Value, UINT32 Width)
Definition: hwvalid.c:312
static WCHAR Address[46]
Definition: ping.c:68
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
Status
Definition: gdiplustypes.h:24
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define AE_OK
Definition: acexcep.h:97
#define ACPI_WRITE
Definition: actypes.h:744

Referenced by AcpiEvInstallSpaceHandler().

◆ AcpiExSystemMemorySpaceHandler()

ACPI_STATUS AcpiExSystemMemorySpaceHandler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 Value,
void HandlerContext,
void RegionContext 
)

Definition at line 72 of file exregion.c.

79 {
81  void *LogicalAddrPtr = NULL;
82  ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
83  UINT32 Length;
84  ACPI_SIZE MapLength;
85  ACPI_SIZE PageBoundaryMapLength;
86 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
88 #endif
89 
90 
91  ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
92 
93 
94  /* Validate and translate the bit width */
95 
96  switch (BitWidth)
97  {
98  case 8:
99 
100  Length = 1;
101  break;
102 
103  case 16:
104 
105  Length = 2;
106  break;
107 
108  case 32:
109 
110  Length = 4;
111  break;
112 
113  case 64:
114 
115  Length = 8;
116  break;
117 
118  default:
119 
120  ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
121  BitWidth));
123  }
124 
125 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
126  /*
127  * Hardware does not support non-aligned data transfers, we must verify
128  * the request.
129  */
131  if (Remainder != 0)
132  {
134  }
135 #endif
136 
137  /*
138  * Does the request fit into the cached memory mapping?
139  * Is 1) Address below the current mapping? OR
140  * 2) Address beyond the current mapping?
141  */
142  if ((Address < MemInfo->MappedPhysicalAddress) ||
143  (((UINT64) Address + Length) >
144  ((UINT64)
145  MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
146  {
147  /*
148  * The request cannot be resolved by the current memory mapping;
149  * Delete the existing mapping and create a new one.
150  */
151  if (MemInfo->MappedLength)
152  {
153  /* Valid mapping, delete it */
154 
156  MemInfo->MappedLength);
157  }
158 
159  /*
160  * October 2009: Attempt to map from the requested address to the
161  * end of the region. However, we will never map more than one
162  * page, nor will we cross a page boundary.
163  */
164  MapLength = (ACPI_SIZE)
165  ((MemInfo->Address + MemInfo->Length) - Address);
166 
167  /*
168  * If mapping the entire remaining portion of the region will cross
169  * a page boundary, just map up to the page boundary, do not cross.
170  * On some systems, crossing a page boundary while mapping regions
171  * can cause warnings if the pages have different attributes
172  * due to resource management.
173  *
174  * This has the added benefit of constraining a single mapping to
175  * one page, which is similar to the original code that used a 4k
176  * maximum window.
177  */
178  PageBoundaryMapLength = (ACPI_SIZE)
180  if (PageBoundaryMapLength == 0)
181  {
182  PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
183  }
184 
185  if (MapLength > PageBoundaryMapLength)
186  {
187  MapLength = PageBoundaryMapLength;
188  }
189 
190  /* Create a new mapping starting at the address given */
191 
192  MemInfo->MappedLogicalAddress = AcpiOsMapMemory (Address, MapLength);
193  if (!MemInfo->MappedLogicalAddress)
194  {
196  "Could not map memory at 0x%8.8X%8.8X, size %u",
197  ACPI_FORMAT_UINT64 (Address), (UINT32) MapLength));
198  MemInfo->MappedLength = 0;
200  }
201 
202  /* Save the physical address and mapping size */
203 
204  MemInfo->MappedPhysicalAddress = Address;
205  MemInfo->MappedLength = MapLength;
206  }
207 
208  /*
209  * Generate a logical pointer corresponding to the address we want to
210  * access
211  */
212  LogicalAddrPtr = MemInfo->MappedLogicalAddress +
213  ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress);
214 
216  "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
217  BitWidth, Function, ACPI_FORMAT_UINT64 (Address)));
218 
219  /*
220  * Perform the memory read or write
221  *
222  * Note: For machines that do not support non-aligned transfers, the target
223  * address was checked for alignment above. We do not attempt to break the
224  * transfer up into smaller (byte-size) chunks because the AML specifically
225  * asked for a transfer width that the hardware may require.
226  */
227  switch (Function)
228  {
229  case ACPI_READ:
230 
231  *Value = 0;
232  switch (BitWidth)
233  {
234  case 8:
235 
236  *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
237  break;
238 
239  case 16:
240 
241  *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
242  break;
243 
244  case 32:
245 
246  *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
247  break;
248 
249  case 64:
250 
251  *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
252  break;
253 
254  default:
255 
256  /* BitWidth was already validated */
257 
258  break;
259  }
260  break;
261 
262  case ACPI_WRITE:
263 
264  switch (BitWidth)
265  {
266  case 8:
267 
268  ACPI_SET8 (LogicalAddrPtr, *Value);
269  break;
270 
271  case 16:
272 
273  ACPI_SET16 (LogicalAddrPtr, *Value);
274  break;
275 
276  case 32:
277 
278  ACPI_SET32 (LogicalAddrPtr, *Value);
279  break;
280 
281  case 64:
282 
283  ACPI_SET64 (LogicalAddrPtr, *Value);
284  break;
285 
286  default:
287 
288  /* BitWidth was already validated */
289 
290  break;
291  }
292  break;
293 
294  default:
295 
297  break;
298  }
299 
301 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ACPI_READ
Definition: actypes.h:743
#define ACPI_GET16(ptr)
Definition: acmacros.h:58
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
void * AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
Definition: osl.c:108
#define AE_AML_OPERAND_VALUE
Definition: acexcep.h:183
#define ACPI_GET8(ptr)
Definition: acmacros.h:57
UINT32 ACPI_STATUS
Definition: actypes.h:460
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:681
unsigned int UINT32
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
ACPI_SIZE MappedLength
Definition: actypes.h:1340
#define ACPI_DEFAULT_PAGE_SIZE
Definition: acconfig.h:132
ACPI_STATUS AcpiUtShortDivide(UINT64 InDividend, UINT32 Divisor, UINT64 *OutQuotient, UINT32 *OutRemainder)
Definition: utmath.c:337
#define ACPI_ROUND_UP(value, boundary)
Definition: acmacros.h:242
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_PHYSICAL_ADDRESS Address
Definition: actypes.h:1337
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ACPI_SET32(ptr, val)
Definition: acmacros.h:63
#define ACPI_SET8(ptr, val)
Definition: acmacros.h:61
Status
Definition: gdiplustypes.h:24
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_SET64(ptr, val)
Definition: acmacros.h:64
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_GET32(ptr)
Definition: acmacros.h:59
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_AML_ALIGNMENT
Definition: acexcep.h:206
ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress
Definition: actypes.h:1338
UINT8 * MappedLogicalAddress
Definition: actypes.h:1339
#define ACPI_GET64(ptr)
Definition: acmacros.h:60
unsigned long long UINT64
#define ACPI_SET16(ptr, val)
Definition: acmacros.h:62
#define AE_OK
Definition: acexcep.h:97
void AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Size)
Definition: osl.c:128
_In_ LARGE_INTEGER _Out_opt_ PLARGE_INTEGER Remainder
Definition: rtlfuncs.h:3046
#define ACPI_WRITE
Definition: actypes.h:744

Referenced by AcpiEvInstallSpaceHandler().