ReactOS Fundraising Campaign 2012
 
€ 3,303 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

static ACPI_STATUS AcpiNsCheckPackage ( ACPI_PREDEFINED_DATA Data,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
) [static]

Definition at line 539 of file nspredef.c.

Referenced by AcpiNsCheckPredefinedNames().

00542 {
00543     ACPI_OPERAND_OBJECT         *ReturnObject = *ReturnObjectPtr;
00544     const ACPI_PREDEFINED_INFO  *Package;
00545     ACPI_OPERAND_OBJECT         **Elements;
00546     ACPI_STATUS                 Status = AE_OK;
00547     UINT32                      ExpectedCount;
00548     UINT32                      Count;
00549     UINT32                      i;
00550 
00551 
00552     ACPI_FUNCTION_NAME (NsCheckPackage);
00553 
00554 
00555     /* The package info for this name is in the next table entry */
00556 
00557     Package = Data->Predefined + 1;
00558 
00559     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
00560         "%s Validating return Package of Type %X, Count %X\n",
00561         Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count));
00562 
00563     /*
00564      * For variable-length Packages, we can safely remove all embedded
00565      * and trailing NULL package elements
00566      */
00567     AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject);
00568 
00569     /* Extract package count and elements array */
00570 
00571     Elements = ReturnObject->Package.Elements;
00572     Count = ReturnObject->Package.Count;
00573 
00574     /* The package must have at least one element, else invalid */
00575 
00576     if (!Count)
00577     {
00578         ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
00579             "Return Package has no elements (empty)"));
00580 
00581         return (AE_AML_OPERAND_VALUE);
00582     }
00583 
00584     /*
00585      * Decode the type of the expected package contents
00586      *
00587      * PTYPE1 packages contain no subpackages
00588      * PTYPE2 packages contain sub-packages
00589      */
00590     switch (Package->RetInfo.Type)
00591     {
00592     case ACPI_PTYPE1_FIXED:
00593 
00594         /*
00595          * The package count is fixed and there are no sub-packages
00596          *
00597          * If package is too small, exit.
00598          * If package is larger than expected, issue warning but continue
00599          */
00600         ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
00601         if (Count < ExpectedCount)
00602         {
00603             goto PackageTooSmall;
00604         }
00605         else if (Count > ExpectedCount)
00606         {
00607             ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
00608                 "%s: Return Package is larger than needed - "
00609                 "found %u, expected %u\n",
00610                 Data->Pathname, Count, ExpectedCount));
00611         }
00612 
00613         /* Validate all elements of the returned package */
00614 
00615         Status = AcpiNsCheckPackageElements (Data, Elements,
00616                     Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
00617                     Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0);
00618         break;
00619 
00620 
00621     case ACPI_PTYPE1_VAR:
00622 
00623         /*
00624          * The package count is variable, there are no sub-packages, and all
00625          * elements must be of the same type
00626          */
00627         for (i = 0; i < Count; i++)
00628         {
00629             Status = AcpiNsCheckObjectType (Data, Elements,
00630                         Package->RetInfo.ObjectType1, i);
00631             if (ACPI_FAILURE (Status))
00632             {
00633                 return (Status);
00634             }
00635             Elements++;
00636         }
00637         break;
00638 
00639 
00640     case ACPI_PTYPE1_OPTION:
00641 
00642         /*
00643          * The package count is variable, there are no sub-packages. There are
00644          * a fixed number of required elements, and a variable number of
00645          * optional elements.
00646          *
00647          * Check if package is at least as large as the minimum required
00648          */
00649         ExpectedCount = Package->RetInfo3.Count;
00650         if (Count < ExpectedCount)
00651         {
00652             goto PackageTooSmall;
00653         }
00654 
00655         /* Variable number of sub-objects */
00656 
00657         for (i = 0; i < Count; i++)
00658         {
00659             if (i < Package->RetInfo3.Count)
00660             {
00661                 /* These are the required package elements (0, 1, or 2) */
00662 
00663                 Status = AcpiNsCheckObjectType (Data, Elements,
00664                             Package->RetInfo3.ObjectType[i], i);
00665                 if (ACPI_FAILURE (Status))
00666                 {
00667                     return (Status);
00668                 }
00669             }
00670             else
00671             {
00672                 /* These are the optional package elements */
00673 
00674                 Status = AcpiNsCheckObjectType (Data, Elements,
00675                             Package->RetInfo3.TailObjectType, i);
00676                 if (ACPI_FAILURE (Status))
00677                 {
00678                     return (Status);
00679                 }
00680             }
00681             Elements++;
00682         }
00683         break;
00684 
00685 
00686     case ACPI_PTYPE2_REV_FIXED:
00687 
00688         /* First element is the (Integer) revision */
00689 
00690         Status = AcpiNsCheckObjectType (Data, Elements,
00691                     ACPI_RTYPE_INTEGER, 0);
00692         if (ACPI_FAILURE (Status))
00693         {
00694             return (Status);
00695         }
00696 
00697         Elements++;
00698         Count--;
00699 
00700         /* Examine the sub-packages */
00701 
00702         Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
00703         break;
00704 
00705 
00706     case ACPI_PTYPE2_PKG_COUNT:
00707 
00708         /* First element is the (Integer) count of sub-packages to follow */
00709 
00710         Status = AcpiNsCheckObjectType (Data, Elements,
00711                     ACPI_RTYPE_INTEGER, 0);
00712         if (ACPI_FAILURE (Status))
00713         {
00714             return (Status);
00715         }
00716 
00717         /*
00718          * Count cannot be larger than the parent package length, but allow it
00719          * to be smaller. The >= accounts for the Integer above.
00720          */
00721         ExpectedCount = (UINT32) (*Elements)->Integer.Value;
00722         if (ExpectedCount >= Count)
00723         {
00724             goto PackageTooSmall;
00725         }
00726 
00727         Count = ExpectedCount;
00728         Elements++;
00729 
00730         /* Examine the sub-packages */
00731 
00732         Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
00733         break;
00734 
00735 
00736     case ACPI_PTYPE2:
00737     case ACPI_PTYPE2_FIXED:
00738     case ACPI_PTYPE2_MIN:
00739     case ACPI_PTYPE2_COUNT:
00740 
00741         /*
00742          * These types all return a single Package that consists of a
00743          * variable number of sub-Packages.
00744          *
00745          * First, ensure that the first element is a sub-Package. If not,
00746          * the BIOS may have incorrectly returned the object as a single
00747          * package instead of a Package of Packages (a common error if
00748          * there is only one entry). We may be able to repair this by
00749          * wrapping the returned Package with a new outer Package.
00750          */
00751         if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE))
00752         {
00753             /* Create the new outer package and populate it */
00754 
00755             Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr);
00756             if (ACPI_FAILURE (Status))
00757             {
00758                 return (Status);
00759             }
00760 
00761             /* Update locals to point to the new package (of 1 element) */
00762 
00763             ReturnObject = *ReturnObjectPtr;
00764             Elements = ReturnObject->Package.Elements;
00765             Count = 1;
00766         }
00767 
00768         /* Examine the sub-packages */
00769 
00770         Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
00771         break;
00772 
00773 
00774     default:
00775 
00776         /* Should not get here if predefined info table is correct */
00777 
00778         ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
00779             "Invalid internal return type in table entry: %X",
00780             Package->RetInfo.Type));
00781 
00782         return (AE_AML_INTERNAL);
00783     }
00784 
00785     return (Status);
00786 
00787 
00788 PackageTooSmall:
00789 
00790     /* Error exit for the case with an incorrect package count */
00791 
00792     ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
00793         "Return Package is too small - found %u elements, expected %u",
00794         Count, ExpectedCount));
00795 
00796     return (AE_AML_OPERAND_VALUE);
00797 }


Generated on Tue May 15 05:39:16 2012 for ReactOS by doxygen 1.6.3

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.