ReactOS 0.4.15-dev-5667-ged97270
rsxface.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
#include "acnamesp.h"
Include dependency graph for rsxface.c:

Go to the source code of this file.

Macros

#define EXPORT_ACPI_INTERFACES
 
#define _COMPONENT   ACPI_RESOURCES
 
#define ACPI_COPY_FIELD(Out, In, Field)   ((Out)->Field = (In)->Field)
 
#define ACPI_COPY_ADDRESS(Out, In)
 

Functions

static ACPI_STATUS AcpiRsMatchVendorResource (ACPI_RESOURCE *Resource, void *Context)
 
static ACPI_STATUS AcpiRsValidateParameters (ACPI_HANDLE DeviceHandle, ACPI_BUFFER *Buffer, ACPI_NAMESPACE_NODE **ReturnNode)
 
ACPI_STATUS AcpiGetIrqRoutingTable (ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiGetCurrentResources (ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiGetPossibleResources (ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiSetCurrentResources (ACPI_HANDLE DeviceHandle, ACPI_BUFFER *InBuffer)
 
ACPI_STATUS AcpiGetEventResources (ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiResourceToAddress64 (ACPI_RESOURCE *Resource, ACPI_RESOURCE_ADDRESS64 *Out)
 
ACPI_STATUS AcpiGetVendorResource (ACPI_HANDLE DeviceHandle, char *Name, ACPI_VENDOR_UUID *Uuid, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiWalkResourceBuffer (ACPI_BUFFER *Buffer, ACPI_WALK_RESOURCE_CALLBACK UserFunction, void *Context)
 
ACPI_STATUS AcpiWalkResources (ACPI_HANDLE DeviceHandle, char *Name, ACPI_WALK_RESOURCE_CALLBACK UserFunction, void *Context)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_RESOURCES

Definition at line 51 of file rsxface.c.

◆ ACPI_COPY_ADDRESS

#define ACPI_COPY_ADDRESS (   Out,
  In 
)
Value:
ACPI_COPY_FIELD(Out, In, ResourceType); \
ACPI_COPY_FIELD(Out, In, ProducerConsumer); \
ACPI_COPY_FIELD(Out, In, Decode); \
ACPI_COPY_FIELD(Out, In, MinAddressFixed); \
ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \
ACPI_COPY_FIELD(Out, In, Info); \
ACPI_COPY_FIELD(Out, In, Address.Granularity); \
ACPI_COPY_FIELD(Out, In, Address.Minimum); \
ACPI_COPY_FIELD(Out, In, Address.Maximum); \
ACPI_COPY_FIELD(Out, In, Address.TranslationOffset); \
ACPI_COPY_FIELD(Out, In, Address.AddressLength); \
ACPI_COPY_FIELD(Out, In, ResourceSource);
@ Out
@ In
static WCHAR Address[46]
Definition: ping.c:68
#define ACPI_COPY_FIELD(Out, In, Field)
Definition: rsxface.c:56
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Definition at line 57 of file rsxface.c.

◆ ACPI_COPY_FIELD

#define ACPI_COPY_FIELD (   Out,
  In,
  Field 
)    ((Out)->Field = (In)->Field)

Definition at line 56 of file rsxface.c.

◆ EXPORT_ACPI_INTERFACES

#define EXPORT_ACPI_INTERFACES

Definition at line 44 of file rsxface.c.

Function Documentation

◆ AcpiGetCurrentResources()

ACPI_STATUS AcpiGetCurrentResources ( ACPI_HANDLE  DeviceHandle,
ACPI_BUFFER RetBuffer 
)

Definition at line 225 of file rsxface.c.

228{
231
232
234
235
236 /* Validate parameters then dispatch to internal routine */
237
239 if (ACPI_FAILURE (Status))
240 {
242 }
243
244 Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
246}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_STATUS AcpiRsGetCrsMethodData(ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
Definition: rsutils.c:575
UINT32 ACPI_STATUS
Definition: actypes.h:460
union node Node
Definition: types.h:1255
Status
Definition: gdiplustypes.h:25
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
ACPI_STATUS AcpiGetCurrentResources(ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
Definition: rsxface.c:225
static ACPI_STATUS AcpiRsValidateParameters(ACPI_HANDLE DeviceHandle, ACPI_BUFFER *Buffer, ACPI_NAMESPACE_NODE **ReturnNode)
Definition: rsxface.c:101
Definition: dlist.c:348

Referenced by AcpiGetCurrentResources(), Bus_PDO_QueryResourceRequirements(), and Bus_PDO_QueryResources().

◆ AcpiGetEventResources()

ACPI_STATUS AcpiGetEventResources ( ACPI_HANDLE  DeviceHandle,
ACPI_BUFFER RetBuffer 
)

Definition at line 373 of file rsxface.c.

376{
379
380
382
383
384 /* Validate parameters then dispatch to internal routine */
385
387 if (ACPI_FAILURE (Status))
388 {
390 }
391
392 Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
394}
ACPI_STATUS AcpiRsGetAeiMethodData(ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
Definition: rsutils.c:685
ACPI_STATUS AcpiGetEventResources(ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
Definition: rsxface.c:373

Referenced by AcpiGetEventResources().

◆ AcpiGetIrqRoutingTable()

ACPI_STATUS AcpiGetIrqRoutingTable ( ACPI_HANDLE  DeviceHandle,
ACPI_BUFFER RetBuffer 
)

Definition at line 174 of file rsxface.c.

177{
180
181
183
184
185 /* Validate parameters then dispatch to internal routine */
186
188 if (ACPI_FAILURE (Status))
189 {
191 }
192
193 Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
195}
ACPI_STATUS AcpiRsGetPrtMethodData(ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
Definition: rsutils.c:521
ACPI_STATUS AcpiGetIrqRoutingTable(ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
Definition: rsxface.c:174

Referenced by AcpiGetIrqRoutingTable().

◆ AcpiGetPossibleResources()

ACPI_STATUS AcpiGetPossibleResources ( ACPI_HANDLE  DeviceHandle,
ACPI_BUFFER RetBuffer 
)

Definition at line 273 of file rsxface.c.

276{
279
280
282
283
284 /* Validate parameters then dispatch to internal routine */
285
287 if (ACPI_FAILURE (Status))
288 {
290 }
291
292 Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
294}
ACPI_STATUS AcpiRsGetPrsMethodData(ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
Definition: rsutils.c:630
ACPI_STATUS AcpiGetPossibleResources(ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer)
Definition: rsxface.c:273

Referenced by AcpiGetPossibleResources(), and Bus_PDO_QueryResourceRequirements().

◆ AcpiGetVendorResource()

ACPI_STATUS AcpiGetVendorResource ( ACPI_HANDLE  DeviceHandle,
char Name,
ACPI_VENDOR_UUID Uuid,
ACPI_BUFFER RetBuffer 
)

Definition at line 486 of file rsxface.c.

491{
494
495
496 /* Other parameters are validated by AcpiWalkResources */
497
498 if (!Uuid || !RetBuffer)
499 {
500 return (AE_BAD_PARAMETER);
501 }
502
503 Info.Uuid = Uuid;
504 Info.Buffer = RetBuffer;
505 Info.Status = AE_NOT_EXIST;
506
507 /* Walk the _CRS or _PRS resource list for this device */
508
511 if (ACPI_FAILURE (Status))
512 {
513 return (Status);
514 }
515
516 return (Info.Status);
517}
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_NOT_EXIST
Definition: acexcep.h:114
ACPI_STATUS AcpiWalkResources(ACPI_HANDLE DeviceHandle, char *Name, ACPI_WALK_RESOURCE_CALLBACK UserFunction, void *Context)
Definition: rsxface.c:704
static ACPI_STATUS AcpiRsMatchVendorResource(ACPI_RESOURCE *Resource, void *Context)
Definition: rsxface.c:535

◆ AcpiResourceToAddress64()

ACPI_STATUS AcpiResourceToAddress64 ( ACPI_RESOURCE Resource,
ACPI_RESOURCE_ADDRESS64 Out 
)

Definition at line 417 of file rsxface.c.

420{
421 ACPI_RESOURCE_ADDRESS16 *Address16;
422 ACPI_RESOURCE_ADDRESS32 *Address32;
423
424
425 if (!Resource || !Out)
426 {
427 return (AE_BAD_PARAMETER);
428 }
429
430 /* Convert 16 or 32 address descriptor to 64 */
431
432 switch (Resource->Type)
433 {
435
436 Address16 = ACPI_CAST_PTR (
438 ACPI_COPY_ADDRESS (Out, Address16);
439 break;
440
442
443 Address32 = ACPI_CAST_PTR (
445 ACPI_COPY_ADDRESS (Out, Address32);
446 break;
447
449
450 /* Simple copy for 64 bit source */
451
453 break;
454
455 default:
456
457 return (AE_BAD_PARAMETER);
458 }
459
460 return (AE_OK);
461}
#define AE_OK
Definition: acexcep.h:97
#define ACPI_RESOURCE_TYPE_ADDRESS64
Definition: acrestyp.h:736
#define ACPI_RESOURCE_TYPE_ADDRESS32
Definition: acrestyp.h:735
#define ACPI_RESOURCE_TYPE_ADDRESS16
Definition: acrestyp.h:734
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ACPI_COPY_ADDRESS(Out, In)
Definition: rsxface.c:57
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ AcpiRsMatchVendorResource()

static ACPI_STATUS AcpiRsMatchVendorResource ( ACPI_RESOURCE Resource,
void Context 
)
static

Definition at line 535 of file rsxface.c.

538{
543
544
545 /* Ignore all descriptors except Vendor */
546
548 {
549 return (AE_OK);
550 }
551
552 Vendor = &Resource->Data.VendorTyped;
553
554 /*
555 * For a valid match, these conditions must hold:
556 *
557 * 1) Length of descriptor data must be at least as long as a UUID struct
558 * 2) The UUID subtypes must match
559 * 3) The UUID data must match
560 */
561 if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
562 (Vendor->UuidSubtype != Info->Uuid->Subtype) ||
563 (memcmp (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
564 {
565 return (AE_OK);
566 }
567
568 /* Validate/Allocate/Clear caller buffer */
569
570 Buffer = Info->Buffer;
572 if (ACPI_FAILURE (Status))
573 {
574 return (Status);
575 }
576
577 /* Found the correct resource, copy and return it */
578
579 memcpy (Buffer->Pointer, Resource, Resource->Length);
580 Buffer->Length = Resource->Length;
581
582 /* Found the desired descriptor, terminate resource walk */
583
584 Info->Status = AE_OK;
585 return (AE_CTRL_TERMINATE);
586}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define ACPI_RESOURCE_TYPE_VENDOR
Definition: acrestyp.h:729
#define ACPI_UUID_LENGTH
Definition: actypes.h:1277
ACPI_STATUS AcpiUtInitializeBuffer(ACPI_BUFFER *Buffer, ACPI_SIZE RequiredLength)
Definition: utalloc.c:336
Definition: bufpool.h:45
UINT8 Uuid[ACPI_UUID_LENGTH]
Definition: acrestyp.h:262

Referenced by AcpiGetVendorResource().

◆ AcpiRsValidateParameters()

static ACPI_STATUS AcpiRsValidateParameters ( ACPI_HANDLE  DeviceHandle,
ACPI_BUFFER Buffer,
ACPI_NAMESPACE_NODE **  ReturnNode 
)
static

Definition at line 101 of file rsxface.c.

105{
108
109
110 ACPI_FUNCTION_TRACE (RsValidateParameters);
111
112
113 /*
114 * Must have a valid handle to an ACPI device
115 */
116 if (!DeviceHandle)
117 {
119 }
120
122 if (!Node)
123 {
125 }
126
127 if (Node->Type != ACPI_TYPE_DEVICE)
128 {
130 }
131
132 /*
133 * Validate the user buffer object
134 *
135 * if there is a non-zero buffer length we also need a valid pointer in
136 * the buffer. If it's a zero buffer length, we'll be returning the
137 * needed buffer size (later), so keep going.
138 */
140 if (ACPI_FAILURE (Status))
141 {
143 }
144
145 *ReturnNode = Node;
147}
#define AE_TYPE
Definition: acexcep.h:116
ACPI_NAMESPACE_NODE * AcpiNsValidateHandle(ACPI_HANDLE Handle)
Definition: nsutils.c:655
#define ACPI_TYPE_DEVICE
Definition: actypes.h:693
ACPI_STATUS AcpiUtValidateBuffer(ACPI_BUFFER *Buffer)
Definition: utalloc.c:290

Referenced by AcpiGetCurrentResources(), AcpiGetEventResources(), AcpiGetIrqRoutingTable(), AcpiGetPossibleResources(), and AcpiSetCurrentResources().

◆ AcpiSetCurrentResources()

ACPI_STATUS AcpiSetCurrentResources ( ACPI_HANDLE  DeviceHandle,
ACPI_BUFFER InBuffer 
)

Definition at line 318 of file rsxface.c.

321{
324
325
327
328
329 /* Validate the buffer, don't allow zero length */
330
331 if ((!InBuffer) ||
332 (!InBuffer->Pointer) ||
333 (!InBuffer->Length))
334 {
336 }
337
338 /* Validate parameters then dispatch to internal routine */
339
341 if (ACPI_FAILURE (Status))
342 {
344 }
345
346 Status = AcpiRsSetSrsMethodData (Node, InBuffer);
348}
ACPI_STATUS AcpiRsSetSrsMethodData(ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer)
Definition: rsutils.c:800
ACPI_STATUS AcpiSetCurrentResources(ACPI_HANDLE DeviceHandle, ACPI_BUFFER *InBuffer)
Definition: rsxface.c:318
void * Pointer
Definition: actypes.h:1054
ACPI_SIZE Length
Definition: actypes.h:1053

Referenced by AcpiSetCurrentResources().

◆ AcpiWalkResourceBuffer()

ACPI_STATUS AcpiWalkResourceBuffer ( ACPI_BUFFER Buffer,
ACPI_WALK_RESOURCE_CALLBACK  UserFunction,
void Context 
)

Definition at line 606 of file rsxface.c.

610{
613 ACPI_RESOURCE *ResourceEnd;
614
615
617
618
619 /* Parameter validation */
620
621 if (!Buffer || !Buffer->Pointer || !UserFunction)
622 {
624 }
625
626 /* Buffer contains the resource list and length */
627
629 ResourceEnd = ACPI_ADD_PTR (
630 ACPI_RESOURCE, Buffer->Pointer, Buffer->Length);
631
632 /* Walk the resource list until the EndTag is found (or buffer end) */
633
634 while (Resource < ResourceEnd)
635 {
636 /* Sanity check the resource type */
637
639 {
641 break;
642 }
643
644 /* Sanity check the length. It must not be zero, or we loop forever */
645
646 if (!Resource->Length)
647 {
649 }
650
651 /* Invoke the user function, abort on any error returned */
652
654 if (ACPI_FAILURE (Status))
655 {
657 {
658 /* This is an OK termination by the user function */
659
660 Status = AE_OK;
661 }
662 break;
663 }
664
665 /* EndTag indicates end-of-list */
666
668 {
669 break;
670 }
671
672 /* Get the next resource descriptor */
673
675 }
676
678}
#define AE_AML_INVALID_RESOURCE_TYPE
Definition: acexcep.h:202
#define AE_AML_BAD_RESOURCE_LENGTH
Definition: acexcep.h:210
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK UserFunction
Definition: acpixf.h:1078
#define ACPI_NEXT_RESOURCE(Res)
Definition: acrestyp.h:812
#define ACPI_RESOURCE_TYPE_END_TAG
Definition: acrestyp.h:730
#define ACPI_RESOURCE_TYPE_MAX
Definition: acrestyp.h:748
#define ACPI_ADD_PTR(t, a, b)
Definition: actypes.h:546
ACPI_STATUS AcpiWalkResourceBuffer(ACPI_BUFFER *Buffer, ACPI_WALK_RESOURCE_CALLBACK UserFunction, void *Context)
Definition: rsxface.c:606

Referenced by AcpiWalkResourceBuffer(), and AcpiWalkResources().

◆ AcpiWalkResources()

ACPI_STATUS AcpiWalkResources ( ACPI_HANDLE  DeviceHandle,
char Name,
ACPI_WALK_RESOURCE_CALLBACK  UserFunction,
void Context 
)

Definition at line 704 of file rsxface.c.

709{
712
713
715
716
717 /* Parameter validation */
718
719 if (!DeviceHandle || !UserFunction || !Name ||
724 {
726 }
727
728 /* Get the _CRS/_PRS/_AEI/_DMA resource list */
729
732 if (ACPI_FAILURE (Status))
733 {
735 }
736
737 /* Walk the resource list and cleanup */
738
740 ACPI_FREE (Buffer.Pointer);
742}
#define METHOD_NAME__AEI
Definition: acnames.h:50
#define METHOD_NAME__CRS
Definition: acnames.h:55
#define METHOD_NAME__PRS
Definition: acnames.h:63
#define METHOD_NAME__DMA
Definition: acnames.h:58
ACPI_STATUS AcpiRsGetMethodData(ACPI_HANDLE Handle, const char *Path, ACPI_BUFFER *RetBuffer)
Definition: rsutils.c:741
#define ACPI_COMPARE_NAMESEG(a, b)
Definition: actypes.h:564
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_LOCAL_BUFFER
Definition: actypes.h:1047

Referenced by AcpiGetVendorResource(), and AcpiWalkResources().