Skip to content

Commit

Permalink
ACPI 6.0: Update _BIX support for new package element
Browse files Browse the repository at this point in the history
One integer was added at the end of the _BIX method, and the
version number was incremented.
  • Loading branch information
acpibob committed Apr 12, 2016
1 parent b9a8a4f commit 3451e6d
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 5 deletions.
100 changes: 97 additions & 3 deletions source/compiler/aslprepkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

/* Local prototypes */

static void
static ACPI_PARSE_OBJECT *
ApCheckPackageElements (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
Expand Down Expand Up @@ -160,6 +160,11 @@ ApPackageTooLarge (
UINT32 Count,
UINT32 ExpectedCount);

static void
ApCustomPackage (
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Predefined);


/*******************************************************************************
*
Expand Down Expand Up @@ -240,6 +245,11 @@ ApCheckPackage (

switch (Package->RetInfo.Type)
{
case ACPI_PTYPE_CUSTOM:

ApCustomPackage (ParentOp, Predefined);
break;

case ACPI_PTYPE1_FIXED:
/*
* The package count is fixed and there are no subpackages
Expand Down Expand Up @@ -452,6 +462,86 @@ ApCheckPackage (
}


/*******************************************************************************
*
* FUNCTION: ApCustomPackage
*
* PARAMETERS: ParentOp - Parse op for the package
* Predefined - Pointer to package-specific info for
* the method
*
* RETURN: None
*
* DESCRIPTION: Validate packages that don't fit into the standard model and
* require custom code.
*
* NOTE: Currently used for the _BIX method only. When needed for two or more
* methods, probably a detect/dispatch mechanism will be required.
*
******************************************************************************/

static void
ApCustomPackage (
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Predefined)
{
ACPI_PARSE_OBJECT *Op;
UINT32 Count;
UINT32 ExpectedCount;
UINT32 Version;


/* First child is the package length */

Op = ParentOp->Asl.Child;
Count = (UINT32) Op->Asl.Value.Integer;

/* Get the version number, must be Integer */

Op = Op->Asl.Next;
Version = (UINT32) Op->Asl.Value.Integer;
if (Op->Asl.ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer);
return;
}

/* Validate count (# of elements) */

ExpectedCount = 21; /* Version 1 */
if (Version == 0)
{
ExpectedCount = 20; /* Version 0 */
}

if (Count < ExpectedCount)
{
ApPackageTooSmall (Predefined->Info.Name, ParentOp,
Count, ExpectedCount);
return;
}
else if (Count > ExpectedCount)
{
ApPackageTooLarge (Predefined->Info.Name, ParentOp,
Count, ExpectedCount);
}

/* Validate all elements of the package */

Op = ApCheckPackageElements (Predefined->Info.Name, Op,
ACPI_RTYPE_INTEGER, 16,
ACPI_RTYPE_STRING, 4);

/* Version 1 has a single trailing integer */

if (Version > 0)
{
ApCheckPackageElements (Predefined->Info.Name, Op,
ACPI_RTYPE_INTEGER, 1, 0, 0);
}
}


/*******************************************************************************
*
* FUNCTION: ApCheckPackageElements
Expand All @@ -463,15 +553,17 @@ ApCheckPackage (
* Type2 - Object type for second group
* Count2 - Count for second group
*
* RETURN: None
* RETURN: Next Op peer in the parse tree, after all specified elements
* have been validated. Used for multiple validations (calls
* to this function).
*
* DESCRIPTION: Validate all elements of a package. Works with packages that
* are defined to contain up to two groups of different object
* types.
*
******************************************************************************/

static void
static ACPI_PARSE_OBJECT *
ApCheckPackageElements (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
Expand Down Expand Up @@ -503,6 +595,8 @@ ApCheckPackageElements (
ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1));
Op = Op->Asl.Next;
}

return (Op);
}


Expand Down
97 changes: 97 additions & 0 deletions source/components/namespace/nsprepkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ AcpiNsCheckPackageElements (
UINT32 Count2,
UINT32 StartIndex);

static ACPI_STATUS
AcpiNsCustomPackage (
ACPI_EVALUATE_INFO *Info,
ACPI_OPERAND_OBJECT **Elements,
UINT32 Count);


/*******************************************************************************
*
Expand Down Expand Up @@ -220,6 +226,11 @@ AcpiNsCheckPackage (
*/
switch (Package->RetInfo.Type)
{
case ACPI_PTYPE_CUSTOM:

Status = AcpiNsCustomPackage (Info, Elements, Count);
break;

case ACPI_PTYPE1_FIXED:
/*
* The package count is fixed and there are no subpackages
Expand Down Expand Up @@ -696,6 +707,92 @@ AcpiNsCheckPackageList (
}


/*******************************************************************************
*
* FUNCTION: AcpiNsCustomPackage
*
* PARAMETERS: Info - Method execution information block
* Elements - Pointer to the package elements array
* Count - Element count for the package
*
* RETURN: Status
*
* DESCRIPTION: Check a returned package object for the correct count and
* correct type of all sub-objects.
*
* NOTE: Currently used for the _BIX method only. When needed for two or more
* methods, probably a detect/dispatch mechanism will be required.
*
******************************************************************************/

static ACPI_STATUS
AcpiNsCustomPackage (
ACPI_EVALUATE_INFO *Info,
ACPI_OPERAND_OBJECT **Elements,
UINT32 Count)
{
UINT32 ExpectedCount;
UINT32 Version;
ACPI_STATUS Status = AE_OK;


ACPI_FUNCTION_NAME (NsCustomPackage);


/* Get version number, must be Integer */

if ((*Elements)->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
"Return Package has invalid object type for version number"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}

Version = (UINT32) (*Elements)->Integer.Value;
ExpectedCount = 21; /* Version 1 */

if (Version == 0)
{
ExpectedCount = 20; /* Version 0 */
}

if (Count < ExpectedCount)
{
ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
"Return Package is too small - found %u elements, expected %u",
Count, ExpectedCount));
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
}
else if (Count > ExpectedCount)
{
ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
"%s: Return Package is larger than needed - "
"found %u, expected %u\n",
Info->FullPathname, Count, ExpectedCount));
}

/* Validate all elements of the returned package */

Status = AcpiNsCheckPackageElements (Info, Elements,
ACPI_RTYPE_INTEGER, 16,
ACPI_RTYPE_STRING, 4, 0);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}

/* Version 1 has a single trailing integer */

if (Version > 0)
{
Status = AcpiNsCheckPackageElements (Info, Elements + 20,
ACPI_RTYPE_INTEGER, 1, 0, 0, 20);
}

return_ACPI_STATUS (Status);
}


/*******************************************************************************
*
* FUNCTION: AcpiNsCheckPackageElements
Expand Down
5 changes: 3 additions & 2 deletions source/include/acpredef.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ enum AcpiReturnPackageTypes
ACPI_PTYPE2_REV_FIXED = 9,
ACPI_PTYPE2_FIX_VAR = 10,
ACPI_PTYPE2_VAR_VAR = 11,
ACPI_PTYPE2_UUID_PAIR = 12
ACPI_PTYPE2_UUID_PAIR = 12,
ACPI_PTYPE_CUSTOM = 13
};


Expand Down Expand Up @@ -416,7 +417,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =

{{"_BIX", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int),(4 Str) */
PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING, 4,0),
PACKAGE_INFO (ACPI_PTYPE_CUSTOM, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING, 4,0),

{{"_BLT", METHOD_3ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
METHOD_NO_RETURN_VALUE}},
Expand Down

0 comments on commit 3451e6d

Please sign in to comment.