{
UINT8 ResourceType;
UINT8ResourceIndex;
ACPI_RS_LENGTH ResourceLength;
ACPI_RS_LENGTH MinimumResourceLength;
ACPI_FUNCTION_ENTRY ();
/* * 1) Validate the ResourceType field (Byte 0) */
ResourceType = ACPI_GET8 (Aml);
/* * Byte 0 contains the descriptor name (Resource Type) * Examine the large/small bit in the resource header */if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
{
/* Verify the large resource type (name) against the max */if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
{
return (AE_AML_INVALID_RESOURCE_TYPE);
}
/* * Large Resource Type -- bits 6:0 contain the name * Translate range 0x80-0x8B to index range 0x10-0x1B */
ResourceIndex = (UINT8) (ResourceType - 0x70);
}
else
{
/* * Small Resource Type -- bits 6:3 contain the name * Shift range to index range 0x00-0x0F */
ResourceIndex = (UINT8)
((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
}
/* Check validity of the resource type, zero indicates name is invalid */if (!AcpiGbl_ResourceTypes[ResourceIndex])
{
return (AE_AML_INVALID_RESOURCE_TYPE);
}
/* * 2) Validate the ResourceLength field. This ensures that the length * is at least reasonable, and guarantees that it is non-zero. */
ResourceLength = AcpiUtGetResourceLength (Aml);
MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
/* Validate based upon the type of resource - fixed length or variable */switch (AcpiGbl_ResourceTypes[ResourceIndex])
{
caseACPI_FIXED_LENGTH:
/* Fixed length resource, length must match exactly */if (ResourceLength != MinimumResourceLength)
{
return (AE_AML_BAD_RESOURCE_LENGTH);
}
break;
caseACPI_VARIABLE_LENGTH:
/* Variable length resource, length must be at least the minimum */if (ResourceLength < MinimumResourceLength)
{
return (AE_AML_BAD_RESOURCE_LENGTH);
}
break;
caseACPI_SMALL_VARIABLE_LENGTH:
/* Small variable length resource, length can be (Min) or (Min-1) */if ((ResourceLength > MinimumResourceLength) ||
(ResourceLength < (MinimumResourceLength - 1)))
{
return (AE_AML_BAD_RESOURCE_LENGTH);
}
break;
default:
/* Shouldn't happen (because of validation earlier), but be sure */return (AE_AML_INVALID_RESOURCE_TYPE);
}
/* Optionally return the resource table index */if (ReturnIndex)
{
*ReturnIndex = ResourceIndex;
}
return (AE_OK);
}
Generated on Thu May 24 2012 05:22:41 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.