summaryrefslogtreecommitdiff
path: root/source/components/namespace
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2016-04-25 22:24:53 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2016-04-25 22:24:53 +0000
commit2331c681155dd7b2f78bd28ca0c183e2f98ff44f (patch)
tree299b4e7602e20d34772a23e4bdda2512f5f1706b /source/components/namespace
parent937fa60dd2f2b6264fb99f22b638190a3fef996b (diff)
Notes
Diffstat (limited to 'source/components/namespace')
-rw-r--r--source/components/namespace/nsinit.c2
-rw-r--r--source/components/namespace/nsprepkg.c97
-rw-r--r--source/components/namespace/nsxfeval.c116
3 files changed, 158 insertions, 57 deletions
diff --git a/source/components/namespace/nsinit.c b/source/components/namespace/nsinit.c
index 067dffe1fd3d..dbe6c7c09f6e 100644
--- a/source/components/namespace/nsinit.c
+++ b/source/components/namespace/nsinit.c
@@ -215,7 +215,7 @@ AcpiNsInitializeDevices (
/*
* Execute \_SB._INI.
- * There appears to be a strict order requirement for \_SB._INI,
+ * There appears to be a strict order requirement for \_SB._INI,
* which should be evaluated before any _REG evaluations.
*/
Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
diff --git a/source/components/namespace/nsprepkg.c b/source/components/namespace/nsprepkg.c
index 141251f8519e..ae75c1a0185d 100644
--- a/source/components/namespace/nsprepkg.c
+++ b/source/components/namespace/nsprepkg.c
@@ -70,6 +70,12 @@ AcpiNsCheckPackageElements (
UINT32 Count2,
UINT32 StartIndex);
+static ACPI_STATUS
+AcpiNsCustomPackage (
+ ACPI_EVALUATE_INFO *Info,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count);
+
/*******************************************************************************
*
@@ -148,6 +154,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
@@ -626,6 +637,92 @@ PackageTooSmall:
/*******************************************************************************
*
+ * 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
*
* PARAMETERS: Info - Method execution information block
diff --git a/source/components/namespace/nsxfeval.c b/source/components/namespace/nsxfeval.c
index 91f8b72b5612..b88ecf507ec2 100644
--- a/source/components/namespace/nsxfeval.c
+++ b/source/components/namespace/nsxfeval.c
@@ -305,13 +305,12 @@ AcpiEvaluateObject (
}
-#if 0
+#ifdef _FUTURE_FEATURE
/*
* Begin incoming argument count analysis. Check for too few args
* and too many args.
*/
-
switch (AcpiNsGetType (Info->Node))
{
case ACPI_TYPE_METHOD:
@@ -399,69 +398,74 @@ AcpiEvaluateObject (
* If we are expecting a return value, and all went well above,
* copy the return value to an external object.
*/
- if (ReturnBuffer)
+ if (!ReturnBuffer)
+ {
+ goto CleanupReturnObject;
+ }
+
+ if (!Info->ReturnObject)
+ {
+ ReturnBuffer->Length = 0;
+ goto Cleanup;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
+ ACPI_DESC_TYPE_NAMED)
{
- if (!Info->ReturnObject)
+ /*
+ * If we received a NS Node as a return object, this means that
+ * the object we are evaluating has nothing interesting to
+ * return (such as a mutex, etc.) We return an error because
+ * these types are essentially unsupported by this interface.
+ * We don't check up front because this makes it easier to add
+ * support for various types at a later date if necessary.
+ */
+ Status = AE_TYPE;
+ Info->ReturnObject = NULL; /* No need to delete a NS Node */
+ ReturnBuffer->Length = 0;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto CleanupReturnObject;
+ }
+
+ /* Dereference Index and RefOf references */
+
+ AcpiNsResolveReferences (Info);
+
+ /* Get the size of the returned object */
+
+ Status = AcpiUtGetObjectSize (Info->ReturnObject,
+ &BufferSpaceNeeded);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (ReturnBuffer,
+ BufferSpaceNeeded);
+ if (ACPI_FAILURE (Status))
{
- ReturnBuffer->Length = 0;
+ /*
+ * Caller's buffer is too small or a new one can't
+ * be allocated
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Needed buffer size %X, %s\n",
+ (UINT32) BufferSpaceNeeded,
+ AcpiFormatException (Status)));
}
else
{
- if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) ==
- ACPI_DESC_TYPE_NAMED)
- {
- /*
- * If we received a NS Node as a return object, this means that
- * the object we are evaluating has nothing interesting to
- * return (such as a mutex, etc.) We return an error because
- * these types are essentially unsupported by this interface.
- * We don't check up front because this makes it easier to add
- * support for various types at a later date if necessary.
- */
- Status = AE_TYPE;
- Info->ReturnObject = NULL; /* No need to delete a NS Node */
- ReturnBuffer->Length = 0;
- }
+ /* We have enough space for the object, build it */
- if (ACPI_SUCCESS (Status))
- {
- /* Dereference Index and RefOf references */
-
- AcpiNsResolveReferences (Info);
-
- /* Get the size of the returned object */
-
- Status = AcpiUtGetObjectSize (Info->ReturnObject,
- &BufferSpaceNeeded);
- if (ACPI_SUCCESS (Status))
- {
- /* Validate/Allocate/Clear caller buffer */
-
- Status = AcpiUtInitializeBuffer (ReturnBuffer,
- BufferSpaceNeeded);
- if (ACPI_FAILURE (Status))
- {
- /*
- * Caller's buffer is too small or a new one can't
- * be allocated
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Needed buffer size %X, %s\n",
- (UINT32) BufferSpaceNeeded,
- AcpiFormatException (Status)));
- }
- else
- {
- /* We have enough space for the object, build it */
-
- Status = AcpiUtCopyIobjectToEobject (
- Info->ReturnObject, ReturnBuffer);
- }
- }
- }
+ Status = AcpiUtCopyIobjectToEobject (
+ Info->ReturnObject, ReturnBuffer);
}
}
+CleanupReturnObject:
+
if (Info->ReturnObject)
{
/*