ReactOS  0.4.14-dev-552-g2fad488
rscalc.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
#include "acnamesp.h"
Include dependency graph for rscalc.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_RESOURCES
 

Functions

static UINT8 AcpiRsCountSetBits (UINT16 BitField)
 
static ACPI_RS_LENGTH AcpiRsStructOptionLength (ACPI_RESOURCE_SOURCE *ResourceSource)
 
static UINT32 AcpiRsStreamOptionLength (UINT32 ResourceLength, UINT32 MinimumTotalLength)
 
ACPI_STATUS AcpiRsGetAmlLength (ACPI_RESOURCE *Resource, ACPI_SIZE ResourceListSize, ACPI_SIZE *SizeNeeded)
 
ACPI_STATUS AcpiRsGetListLength (UINT8 *AmlBuffer, UINT32 AmlBufferLength, ACPI_SIZE *SizeNeeded)
 
ACPI_STATUS AcpiRsGetPciRoutingTableLength (ACPI_OPERAND_OBJECT *PackageObject, ACPI_SIZE *BufferSizeNeeded)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_RESOURCES

Definition at line 50 of file rscalc.c.

Function Documentation

◆ AcpiRsCountSetBits()

static UINT8 AcpiRsCountSetBits ( UINT16  BitField)
static

Definition at line 84 of file rscalc.c.

86 {
87  UINT8 BitsSet;
88 
89 
91 
92 
93  for (BitsSet = 0; BitField; BitsSet++)
94  {
95  /* Zero the least significant bit that is set */
96 
97  BitField &= (UINT16) (BitField - 1);
98  }
99 
100  return (BitsSet);
101 }
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
unsigned short UINT16
unsigned char UINT8

Referenced by AcpiRsGetListLength().

◆ AcpiRsGetAmlLength()

ACPI_STATUS AcpiRsGetAmlLength ( ACPI_RESOURCE Resource,
ACPI_SIZE  ResourceListSize,
ACPI_SIZE *  SizeNeeded 
)

Definition at line 211 of file rscalc.c.

215 {
216  ACPI_SIZE AmlSizeNeeded = 0;
217  ACPI_RESOURCE *ResourceEnd;
218  ACPI_RS_LENGTH TotalSize;
219 
220 
221  ACPI_FUNCTION_TRACE (RsGetAmlLength);
222 
223 
224  /* Traverse entire list of internal resource descriptors */
225 
226  ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, ResourceListSize);
227  while (Resource < ResourceEnd)
228  {
229  /* Validate the descriptor type */
230 
231  if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
232  {
234  }
235 
236  /* Sanity check the length. It must not be zero, or we loop forever */
237 
238  if (!Resource->Length)
239  {
241  }
242 
243  /* Get the base size of the (external stream) resource descriptor */
244 
245  TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
246 
247  /*
248  * Augment the base size for descriptors with optional and/or
249  * variable-length fields
250  */
251  switch (Resource->Type)
252  {
254 
255  /* Length can be 3 or 2 */
256 
257  if (Resource->Data.Irq.DescriptorLength == 2)
258  {
259  TotalSize--;
260  }
261  break;
262 
263 
265 
266  /* Length can be 1 or 0 */
267 
268  if (Resource->Data.Irq.DescriptorLength == 0)
269  {
270  TotalSize--;
271  }
272  break;
273 
274 
276  /*
277  * Vendor Defined Resource:
278  * For a Vendor Specific resource, if the Length is between 1 and 7
279  * it will be created as a Small Resource data type, otherwise it
280  * is a Large Resource data type.
281  */
282  if (Resource->Data.Vendor.ByteLength > 7)
283  {
284  /* Base size of a Large resource descriptor */
285 
286  TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
287  }
288 
289  /* Add the size of the vendor-specific data */
290 
291  TotalSize = (ACPI_RS_LENGTH)
292  (TotalSize + Resource->Data.Vendor.ByteLength);
293  break;
294 
295 
297  /*
298  * End Tag:
299  * We are done -- return the accumulated total size.
300  */
301  *SizeNeeded = AmlSizeNeeded + TotalSize;
302 
303  /* Normal exit */
304 
306 
307 
309  /*
310  * 16-Bit Address Resource:
311  * Add the size of the optional ResourceSource info
312  */
313  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
315  &Resource->Data.Address16.ResourceSource));
316  break;
317 
318 
320  /*
321  * 32-Bit Address Resource:
322  * Add the size of the optional ResourceSource info
323  */
324  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
326  &Resource->Data.Address32.ResourceSource));
327  break;
328 
329 
331  /*
332  * 64-Bit Address Resource:
333  * Add the size of the optional ResourceSource info
334  */
335  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
337  &Resource->Data.Address64.ResourceSource));
338  break;
339 
340 
342  /*
343  * Extended IRQ Resource:
344  * Add the size of each additional optional interrupt beyond the
345  * required 1 (4 bytes for each UINT32 interrupt number)
346  */
347  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
348  ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
349 
350  /* Add the size of the optional ResourceSource info */
351 
353  &Resource->Data.ExtendedIrq.ResourceSource));
354  break;
355 
356 
358 
359  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
360  (Resource->Data.Gpio.PinTableLength * 2) +
361  Resource->Data.Gpio.ResourceSource.StringLength +
362  Resource->Data.Gpio.VendorLength);
363 
364  break;
365 
367 
368  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
369  (Resource->Data.PinFunction.PinTableLength * 2) +
370  Resource->Data.PinFunction.ResourceSource.StringLength +
371  Resource->Data.PinFunction.VendorLength);
372 
373  break;
374 
375 
377 
379  Resource->Data.CommonSerialBus.Type];
380 
381  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
382  Resource->Data.I2cSerialBus.ResourceSource.StringLength +
383  Resource->Data.I2cSerialBus.VendorLength);
384 
385  break;
386 
388 
389  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
390  (Resource->Data.PinConfig.PinTableLength * 2) +
391  Resource->Data.PinConfig.ResourceSource.StringLength +
392  Resource->Data.PinConfig.VendorLength);
393 
394  break;
395 
397 
398  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
399  (Resource->Data.PinGroup.PinTableLength * 2) +
400  Resource->Data.PinGroup.ResourceLabel.StringLength +
401  Resource->Data.PinGroup.VendorLength);
402 
403  break;
404 
406 
407  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
408  Resource->Data.PinGroupFunction.ResourceSource.StringLength +
409  Resource->Data.PinGroupFunction.ResourceSourceLabel.StringLength +
410  Resource->Data.PinGroupFunction.VendorLength);
411 
412  break;
413 
415 
416  TotalSize = (ACPI_RS_LENGTH) (TotalSize +
417  Resource->Data.PinGroupConfig.ResourceSource.StringLength +
418  Resource->Data.PinGroupConfig.ResourceSourceLabel.StringLength +
419  Resource->Data.PinGroupConfig.VendorLength);
420 
421  break;
422 
423  default:
424 
425  break;
426  }
427 
428  /* Update the total */
429 
430  AmlSizeNeeded += TotalSize;
431 
432  /* Point to the next object */
433 
435  }
436 
437  /* Did not find an EndTag resource descriptor */
438 
440 }
#define AE_AML_BAD_RESOURCE_LENGTH
Definition: acexcep.h:210
#define ACPI_RESOURCE_TYPE_PIN_FUNCTION
Definition: acrestyp.h:734
#define ACPI_RESOURCE_TYPE_START_DEPENDENT
Definition: acrestyp.h:716
#define ACPI_RESOURCE_TYPE_SERIAL_BUS
Definition: acrestyp.h:733
const UINT8 AcpiGbl_AmlResourceSerialBusSizes[]
Definition: rsinfo.c:273
#define ACPI_RESOURCE_TYPE_IRQ
Definition: acrestyp.h:714
struct aml_resource_large_header AML_RESOURCE_LARGE_HEADER
#define ACPI_RESOURCE_TYPE_END_TAG
Definition: acrestyp.h:721
#define ACPI_RESOURCE_TYPE_GPIO
Definition: acrestyp.h:731
#define ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG
Definition: acrestyp.h:738
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:848
#define ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION
Definition: acrestyp.h:737
#define ACPI_RESOURCE_TYPE_PIN_CONFIG
Definition: acrestyp.h:735
#define ACPI_RESOURCE_TYPE_ADDRESS32
Definition: acrestyp.h:726
#define ACPI_RESOURCE_TYPE_VENDOR
Definition: acrestyp.h:720
#define ACPI_RESOURCE_TYPE_ADDRESS64
Definition: acrestyp.h:727
const UINT8 AcpiGbl_AmlResourceSizes[]
Definition: rsinfo.c:199
#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ
Definition: acrestyp.h:729
#define ACPI_RESOURCE_TYPE_MAX
Definition: acrestyp.h:739
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_AML_NO_RESOURCE_END_TAG
Definition: acexcep.h:207
UINT16 ACPI_RS_LENGTH
Definition: acrestyp.h:51
#define ACPI_RESOURCE_TYPE_PIN_GROUP
Definition: acrestyp.h:736
#define ACPI_RESOURCE_TYPE_ADDRESS16
Definition: acrestyp.h:725
#define ACPI_ADD_PTR(t, a, b)
Definition: actypes.h:546
static ACPI_RS_LENGTH AcpiRsStructOptionLength(ACPI_RESOURCE_SOURCE *ResourceSource)
Definition: rscalc.c:119
#define AE_OK
Definition: acexcep.h:97
#define AE_AML_INVALID_RESOURCE_TYPE
Definition: acexcep.h:202

Referenced by AcpiRsCreateAmlResources().

◆ AcpiRsGetListLength()

ACPI_STATUS AcpiRsGetListLength ( UINT8 AmlBuffer,
UINT32  AmlBufferLength,
ACPI_SIZE *  SizeNeeded 
)

Definition at line 460 of file rscalc.c.

464 {
466  UINT8 *EndAml;
467  UINT8 *Buffer;
469  UINT16 Temp16;
470  UINT16 ResourceLength;
471  UINT32 ExtraStructBytes;
472  UINT8 ResourceIndex;
473  UINT8 MinimumAmlResourceLength;
474  AML_RESOURCE *AmlResource;
475 
476 
477  ACPI_FUNCTION_TRACE (RsGetListLength);
478 
479 
480  *SizeNeeded = ACPI_RS_SIZE_MIN; /* Minimum size is one EndTag */
481  EndAml = AmlBuffer + AmlBufferLength;
482 
483  /* Walk the list of AML resource descriptors */
484 
485  while (AmlBuffer < EndAml)
486  {
487  /* Validate the Resource Type and Resource Length */
488 
489  Status = AcpiUtValidateResource (NULL, AmlBuffer, &ResourceIndex);
490  if (ACPI_FAILURE (Status))
491  {
492  /*
493  * Exit on failure. Cannot continue because the descriptor length
494  * may be bogus also.
495  */
497  }
498 
499  AmlResource = (void *) AmlBuffer;
500 
501  /* Get the resource length and base (minimum) AML size */
502 
503  ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
504  MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
505 
506  /*
507  * Augment the size for descriptors with optional
508  * and/or variable length fields
509  */
510  ExtraStructBytes = 0;
511  Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
512 
513  switch (AcpiUtGetResourceType (AmlBuffer))
514  {
516  /*
517  * IRQ Resource:
518  * Get the number of bits set in the 16-bit IRQ mask
519  */
520  ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
521  ExtraStructBytes = AcpiRsCountSetBits (Temp16);
522  break;
523 
524 
526  /*
527  * DMA Resource:
528  * Get the number of bits set in the 8-bit DMA mask
529  */
530  ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
531  break;
532 
533 
536  /*
537  * Vendor Resource:
538  * Get the number of vendor data bytes
539  */
540  ExtraStructBytes = ResourceLength;
541 
542  /*
543  * There is already one byte included in the minimum
544  * descriptor size. If there are extra struct bytes,
545  * subtract one from the count.
546  */
547  if (ExtraStructBytes)
548  {
549  ExtraStructBytes--;
550  }
551  break;
552 
553 
555  /*
556  * End Tag: This is the normal exit
557  */
559 
560 
564  /*
565  * Address Resource:
566  * Add the size of the optional ResourceSource
567  */
568  ExtraStructBytes = AcpiRsStreamOptionLength (
569  ResourceLength, MinimumAmlResourceLength);
570  break;
571 
572 
574  /*
575  * Extended IRQ Resource:
576  * Using the InterruptTableLength, add 4 bytes for each additional
577  * interrupt. Note: at least one interrupt is required and is
578  * included in the minimum descriptor size (reason for the -1)
579  */
580  ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
581 
582  /* Add the size of the optional ResourceSource */
583 
584  ExtraStructBytes += AcpiRsStreamOptionLength (
585  ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
586  break;
587 
589 
590  /* Vendor data is optional */
591 
592  if (AmlResource->Gpio.VendorLength)
593  {
594  ExtraStructBytes +=
595  AmlResource->Gpio.VendorOffset -
596  AmlResource->Gpio.PinTableOffset +
597  AmlResource->Gpio.VendorLength;
598  }
599  else
600  {
601  ExtraStructBytes +=
602  AmlResource->LargeHeader.ResourceLength +
603  sizeof (AML_RESOURCE_LARGE_HEADER) -
604  AmlResource->Gpio.PinTableOffset;
605  }
606  break;
607 
609 
610  /* Vendor data is optional */
611 
612  if (AmlResource->PinFunction.VendorLength)
613  {
614  ExtraStructBytes +=
615  AmlResource->PinFunction.VendorOffset -
616  AmlResource->PinFunction.PinTableOffset +
617  AmlResource->PinFunction.VendorLength;
618  }
619  else
620  {
621  ExtraStructBytes +=
622  AmlResource->LargeHeader.ResourceLength +
623  sizeof (AML_RESOURCE_LARGE_HEADER) -
624  AmlResource->PinFunction.PinTableOffset;
625  }
626  break;
627 
629 
630  MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
631  AmlResource->CommonSerialBus.Type];
632  ExtraStructBytes +=
633  AmlResource->CommonSerialBus.ResourceLength -
634  MinimumAmlResourceLength;
635  break;
636 
638 
639  /* Vendor data is optional */
640 
641  if (AmlResource->PinConfig.VendorLength)
642  {
643  ExtraStructBytes +=
644  AmlResource->PinConfig.VendorOffset -
645  AmlResource->PinConfig.PinTableOffset +
646  AmlResource->PinConfig.VendorLength;
647  }
648  else
649  {
650  ExtraStructBytes +=
651  AmlResource->LargeHeader.ResourceLength +
652  sizeof (AML_RESOURCE_LARGE_HEADER) -
653  AmlResource->PinConfig.PinTableOffset;
654  }
655  break;
656 
658 
659  ExtraStructBytes +=
660  AmlResource->PinGroup.VendorOffset -
661  AmlResource->PinGroup.PinTableOffset +
662  AmlResource->PinGroup.VendorLength;
663 
664  break;
665 
667 
668  ExtraStructBytes +=
669  AmlResource->PinGroupFunction.VendorOffset -
670  AmlResource->PinGroupFunction.ResSourceOffset +
671  AmlResource->PinGroupFunction.VendorLength;
672 
673  break;
674 
676 
677  ExtraStructBytes +=
678  AmlResource->PinGroupConfig.VendorOffset -
679  AmlResource->PinGroupConfig.ResSourceOffset +
680  AmlResource->PinGroupConfig.VendorLength;
681 
682  break;
683 
684  default:
685 
686  break;
687  }
688 
689  /*
690  * Update the required buffer size for the internal descriptor structs
691  *
692  * Important: Round the size up for the appropriate alignment. This
693  * is a requirement on IA64.
694  */
695  if (AcpiUtGetResourceType (AmlBuffer) ==
697  {
699  AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
700  }
701  else
702  {
703  BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
704  ExtraStructBytes;
705  }
706 
708  *SizeNeeded += BufferSize;
709 
711  "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
712  AcpiUtGetResourceType (AmlBuffer),
713  AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));
714 
715  /*
716  * Point to the next resource within the AML stream using the length
717  * contained in the resource descriptor header
718  */
719  AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
720  }
721 
722  /* Did not find an EndTag resource descriptor */
723 
725 }
#define ACPI_MOVE_16_TO_16(d, s)
Definition: acmacros.h:141
#define ACPI_RESOURCE_NAME_END_TAG
Definition: aclocal.h:1323
#define ACPI_RESOURCE_NAME_DMA
Definition: aclocal.h:1313
ACPI_STATUS AcpiUtValidateResource(ACPI_WALK_STATE *WalkState, void *Aml, UINT8 *ReturnIndex)
Definition: utresrc.c:313
#define ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION
Definition: aclocal.h:1345
#define ACPI_RESOURCE_NAME_EXTENDED_IRQ
Definition: aclocal.h:1337
AML_RESOURCE_PIN_GROUP PinGroup
Definition: amlresrc.h:690
#define ACPI_RESOURCE_NAME_VENDOR_LARGE
Definition: aclocal.h:1332
UINT16 AcpiUtGetResourceLength(void *Aml)
Definition: utresrc.c:526
AML_RESOURCE_PIN_FUNCTION PinFunction
Definition: amlresrc.h:688
struct aml_resource_large_header AML_RESOURCE_LARGE_HEADER
AML_RESOURCE_PIN_GROUP_FUNCTION PinGroupFunction
Definition: amlresrc.h:691
UINT32 ACPI_STATUS
Definition: actypes.h:460
static UINT32 AcpiRsStreamOptionLength(UINT32 ResourceLength, UINT32 MinimumTotalLength)
Definition: rscalc.c:156
const UINT8 AcpiGbl_ResourceStructSizes[]
Definition: rsinfo.c:229
#define ACPI_RESOURCE_NAME_ADDRESS16
Definition: aclocal.h:1336
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
static UINT8 AcpiRsCountSetBits(UINT16 BitField)
Definition: rscalc.c:84
#define ACPI_RESOURCE_NAME_ADDRESS32
Definition: aclocal.h:1335
unsigned int UINT32
#define ACPI_RESOURCE_NAME_ADDRESS64
Definition: aclocal.h:1338
AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus
Definition: amlresrc.h:687
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
UINT16 PinTableOffset
Definition: amlresrc.h:424
const UINT8 AcpiGbl_ResourceStructSerialBusSizes[]
Definition: rsinfo.c:281
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 AmlBufferLength
Definition: acpixf.h:1095
UINT8 AcpiUtGetResourceHeaderLength(void *Aml)
Definition: utresrc.c:571
const UINT8 AcpiGbl_ResourceAmlSizes[]
Definition: utresrc.c:57
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254
AML_RESOURCE_LARGE_HEADER LargeHeader
Definition: amlresrc.h:657
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_RESOURCE_NAME_IRQ
Definition: aclocal.h:1312
#define BufferSize
Definition: classpnp.h:419
UINT32 AcpiUtGetDescriptorLength(void *Aml)
Definition: utresrc.c:605
AML_RESOURCE_PIN_GROUP_CONFIG PinGroupConfig
Definition: amlresrc.h:692
Status
Definition: gdiplustypes.h:24
AML_RESOURCE_PIN_CONFIG PinConfig
Definition: amlresrc.h:689
UINT16 VendorLength
Definition: amlresrc.h:428
#define ACPI_RESOURCE_NAME_PIN_GROUP
Definition: aclocal.h:1344
#define ACPI_DB_RESOURCES
Definition: acoutput.h:176
#define ACPI_RESOURCE_NAME_PIN_FUNCTION
Definition: aclocal.h:1341
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
unsigned short UINT16
#define AE_AML_NO_RESOURCE_END_TAG
Definition: acexcep.h:207
#define ACPI_RESOURCE_NAME_SERIAL_BUS
Definition: aclocal.h:1342
UINT8 AcpiUtGetResourceType(void *Aml)
Definition: utresrc.c:486
#define ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG
Definition: aclocal.h:1346
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
UINT16 VendorOffset
Definition: amlresrc.h:427
unsigned char UINT8
#define ACPI_RS_SIZE_MIN
Definition: acrestyp.h:797
#define ACPI_RESOURCE_NAME_GPIO
Definition: aclocal.h:1340
#define AE_OK
Definition: acexcep.h:97
#define ACPI_RESOURCE_NAME_VENDOR_SMALL
Definition: aclocal.h:1322
const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[]
Definition: utresrc.c:101
#define ACPI_RESOURCE_NAME_PIN_CONFIG
Definition: aclocal.h:1343
AML_RESOURCE_GPIO Gpio
Definition: amlresrc.h:683

Referenced by AcpiBufferToResource(), and AcpiRsCreateResourceList().

◆ AcpiRsGetPciRoutingTableLength()

ACPI_STATUS AcpiRsGetPciRoutingTableLength ( ACPI_OPERAND_OBJECT PackageObject,
ACPI_SIZE *  BufferSizeNeeded 
)

Definition at line 746 of file rscalc.c.

749 {
750  UINT32 NumberOfElements;
751  ACPI_SIZE TempSizeNeeded = 0;
752  ACPI_OPERAND_OBJECT **TopObjectList;
753  UINT32 Index;
754  ACPI_OPERAND_OBJECT *PackageElement;
755  ACPI_OPERAND_OBJECT **SubObjectList;
756  BOOLEAN NameFound;
757  UINT32 TableIndex;
758 
759 
760  ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
761 
762 
763  NumberOfElements = PackageObject->Package.Count;
764 
765  /*
766  * Calculate the size of the return buffer.
767  * The base size is the number of elements * the sizes of the
768  * structures. Additional space for the strings is added below.
769  * The minus one is to subtract the size of the UINT8 Source[1]
770  * member because it is added below.
771  *
772  * But each PRT_ENTRY structure has a pointer to a string and
773  * the size of that string must be found.
774  */
775  TopObjectList = PackageObject->Package.Elements;
776 
777  for (Index = 0; Index < NumberOfElements; Index++)
778  {
779  /* Dereference the subpackage */
780 
781  PackageElement = *TopObjectList;
782 
783  /* We must have a valid Package object */
784 
785  if (!PackageElement ||
786  (PackageElement->Common.Type != ACPI_TYPE_PACKAGE))
787  {
789  }
790 
791  /*
792  * The SubObjectList will now point to an array of the
793  * four IRQ elements: Address, Pin, Source and SourceIndex
794  */
795  SubObjectList = PackageElement->Package.Elements;
796 
797  /* Scan the IrqTableElements for the Source Name String */
798 
799  NameFound = FALSE;
800 
801  for (TableIndex = 0;
802  TableIndex < PackageElement->Package.Count && !NameFound;
803  TableIndex++)
804  {
805  if (*SubObjectList && /* Null object allowed */
806 
807  ((ACPI_TYPE_STRING ==
808  (*SubObjectList)->Common.Type) ||
809 
811  (*SubObjectList)->Common.Type) &&
812 
813  ((*SubObjectList)->Reference.Class ==
815  {
816  NameFound = TRUE;
817  }
818  else
819  {
820  /* Look at the next element */
821 
822  SubObjectList++;
823  }
824  }
825 
826  TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
827 
828  /* Was a String type found? */
829 
830  if (NameFound)
831  {
832  if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING)
833  {
834  /*
835  * The length String.Length field does not include the
836  * terminating NULL, add 1
837  */
838  TempSizeNeeded += ((ACPI_SIZE)
839  (*SubObjectList)->String.Length + 1);
840  }
841  else
842  {
843  TempSizeNeeded += AcpiNsGetPathnameLength (
844  (*SubObjectList)->Reference.Node);
845  }
846  }
847  else
848  {
849  /*
850  * If no name was found, then this is a NULL, which is
851  * translated as a UINT32 zero.
852  */
853  TempSizeNeeded += sizeof (UINT32);
854  }
855 
856  /* Round up the size since each element must be aligned */
857 
858  TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
859 
860  /* Point to the next ACPI_OPERAND_OBJECT */
861 
862  TopObjectList++;
863  }
864 
865  /*
866  * Add an extra element to the end of the list, essentially a
867  * NULL terminator
868  */
869  *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
871 }
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING _Out_opt_ PULONG BufferSizeNeeded
Definition: fltkernel.h:1117
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:520
#define ACPI_ROUND_UP_TO_64BIT(a)
Definition: acmacros.h:253
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:710
ACPI_SIZE AcpiNsGetPathnameLength(ACPI_NAMESPACE_NODE *Node)
Definition: nsnames.c:103
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
struct acpi_pci_routing_table ACPI_PCI_ROUTING_TABLE
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:682
unsigned int UINT32
unsigned char BOOLEAN
static const UCHAR Index[8]
Definition: usbohci.c:18
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:516
#define ACPI_TYPE_STRING
Definition: actypes.h:680
#define AE_OK
Definition: acexcep.h:97
union acpi_operand_object ** Elements
Definition: acobject.h:161

Referenced by AcpiRsCreatePciRoutingTable().

◆ AcpiRsStreamOptionLength()

static UINT32 AcpiRsStreamOptionLength ( UINT32  ResourceLength,
UINT32  MinimumTotalLength 
)
static

Definition at line 156 of file rscalc.c.

159 {
160  UINT32 StringLength = 0;
161 
162 
164 
165 
166  /*
167  * The ResourceSourceIndex and ResourceSource are optional elements of
168  * some Large-type resource descriptors.
169  */
170 
171  /*
172  * If the length of the actual resource descriptor is greater than the
173  * ACPI spec-defined minimum length, it means that a ResourceSourceIndex
174  * exists and is followed by a (required) null terminated string. The
175  * string length (including the null terminator) is the resource length
176  * minus the minimum length, minus one byte for the ResourceSourceIndex
177  * itself.
178  */
179  if (ResourceLength > MinimumAmlResourceLength)
180  {
181  /* Compute the length of the optional string */
182 
183  StringLength = ResourceLength - MinimumAmlResourceLength - 1;
184  }
185 
186  /*
187  * Round the length up to a multiple of the native word in order to
188  * guarantee that the entire resource descriptor is native word aligned
189  */
190  return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength));
191 }
unsigned int UINT32
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254

Referenced by AcpiRsGetListLength().

◆ AcpiRsStructOptionLength()

static ACPI_RS_LENGTH AcpiRsStructOptionLength ( ACPI_RESOURCE_SOURCE ResourceSource)
static

Definition at line 119 of file rscalc.c.

121 {
123 
124 
125  /*
126  * If the ResourceSource string is valid, return the size of the string
127  * (StringLength includes the NULL terminator) plus the size of the
128  * ResourceSourceIndex (1).
129  */
130  if (ResourceSource->StringPtr)
131  {
132  return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1));
133  }
134 
135  return (0);
136 }
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
UINT16 ACPI_RS_LENGTH
Definition: acrestyp.h:51

Referenced by AcpiRsGetAmlLength().