Print this page
update to acpica-unix2-20131115
acpica-unix2-20130823
PANKOVs restructure

*** 3,13 **** * Module Name: rscreate - Create resource lists/tables * ******************************************************************************/ /* ! * Copyright (C) 2000 - 2011, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: --- 3,13 ---- * Module Name: rscreate - Create resource lists/tables * ******************************************************************************/ /* ! * Copyright (C) 2000 - 2013, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met:
*** 52,61 **** --- 52,134 ---- ACPI_MODULE_NAME ("rscreate") /******************************************************************************* * + * FUNCTION: AcpiBufferToResource + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * AmlBufferLength - Length of the AmlBuffer + * ResourcePtr - Where the converted resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a raw AML buffer to a resource list + * + ******************************************************************************/ + + ACPI_STATUS + AcpiBufferToResource ( + UINT8 *AmlBuffer, + UINT16 AmlBufferLength, + ACPI_RESOURCE **ResourcePtr) + { + ACPI_STATUS Status; + ACPI_SIZE ListSizeNeeded; + void *Resource; + void *CurrentResourcePtr; + + /* + * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag + * is not required here. + */ + + /* Get the required length for the converted resource */ + + Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength, + &ListSizeNeeded); + if (Status == AE_AML_NO_RESOURCE_END_TAG) + { + Status = AE_OK; + } + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Allocate a buffer for the converted resource */ + + Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded); + CurrentResourcePtr = Resource; + if (!Resource) + { + return (AE_NO_MEMORY); + } + + /* Perform the AML-to-Resource conversion */ + + Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength, + AcpiRsConvertAmlToResources, &CurrentResourcePtr); + if (Status == AE_AML_NO_RESOURCE_END_TAG) + { + Status = AE_OK; + } + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (Resource); + } + else + { + *ResourcePtr = Resource; + } + + return (Status); + } + + + /******************************************************************************* + * * FUNCTION: AcpiRsCreateResourceList * * PARAMETERS: AmlBuffer - Pointer to the resource byte stream * OutputBuffer - Pointer to the user's buffer *
*** 117,127 **** } /* Do the conversion */ Resource = OutputBuffer->Pointer; ! Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, AcpiRsConvertAmlToResources, &Resource); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } --- 190,200 ---- } /* Do the conversion */ Resource = OutputBuffer->Pointer; ! Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength, AcpiRsConvertAmlToResources, &Resource); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); }
*** 134,145 **** /******************************************************************************* * * FUNCTION: AcpiRsCreatePciRoutingTable * ! * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT ! * package * OutputBuffer - Pointer to the user's buffer * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point --- 207,218 ---- /******************************************************************************* * * FUNCTION: AcpiRsCreatePciRoutingTable * ! * PARAMETERS: PackageObject - Pointer to a package containing one ! * of more ACPI_OPERAND_OBJECTs * OutputBuffer - Pointer to the user's buffer * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
*** 222,241 **** * The minus four is to subtract the size of the UINT8 Source[4] member * because it is added below. */ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); - /* Each element of the top-level package must also be a package */ - - if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) - { - ACPI_ERROR ((AE_INFO, - "(PRT[%u]) Need sub-package, found %s", - Index, AcpiUtGetObjectTypeName (*TopObjectList))); - return_ACPI_STATUS (AE_AML_OPERAND_TYPE); - } - /* Each sub-package must be of length 4 */ if ((*TopObjectList)->Package.Count != 4) { ACPI_ERROR ((AE_INFO, --- 295,304 ----
*** 274,300 **** } UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; /* - * If the BIOS has erroneously reversed the _PRT SourceName (index 2) - * and the SourceIndex (index 3), fix it. _PRT is important enough to - * workaround this BIOS error. This also provides compatibility with - * other ACPI implementations. - */ - ObjDesc = SubObjectList[3]; - if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) - { - SubObjectList[3] = SubObjectList[2]; - SubObjectList[2] = ObjDesc; - - ACPI_WARNING ((AE_INFO, - "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", - Index)); - } - - /* * 3) Third subobject: Dereference the PRT.SourceName * The name may be unresolved (slack mode), so allow a null object */ ObjDesc = SubObjectList[2]; if (ObjDesc) --- 337,346 ----
*** 325,335 **** /* +1 to include null terminator */ UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; break; - case ACPI_TYPE_STRING: ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); /* --- 371,380 ----
*** 337,347 **** * (add 1 for terminator) */ UserPrt->Length += ObjDesc->String.Length + 1; break; - case ACPI_TYPE_INTEGER: /* * If this is a number, then the Source Name is NULL, since the * entire buffer was zeroed out, we can leave this alone. * --- 382,391 ----
*** 348,358 **** * Add to the Length field the length of the UINT32 NULL */ UserPrt->Length += sizeof (UINT32); break; - default: ACPI_ERROR ((AE_INFO, "(PRT[%u].Source) Need Ref/String/Integer, found %s", Index, AcpiUtGetObjectTypeName (ObjDesc))); --- 392,401 ----
*** 390,437 **** /******************************************************************************* * * FUNCTION: AcpiRsCreateAmlResources * ! * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list ! * OutputBuffer - Pointer to the user's buffer * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point * to the size buffer needed. * ! * DESCRIPTION: Takes the linked list of device resources and ! * creates a bytestream to be used as input for the ! * _SRS control method. * ******************************************************************************/ ACPI_STATUS AcpiRsCreateAmlResources ( ! ACPI_RESOURCE *LinkedListBuffer, ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; ACPI_SIZE AmlSizeNeeded = 0; ACPI_FUNCTION_TRACE (RsCreateAmlResources); ! ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", ! LinkedListBuffer)); ! /* ! * Params already validated, so we don't re-validate here ! * ! * Pass the LinkedListBuffer into a module that calculates ! * the buffer size needed for the byte stream. ! */ ! Status = AcpiRsGetAmlLength (LinkedListBuffer, ! &AmlSizeNeeded); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); --- 433,477 ---- /******************************************************************************* * * FUNCTION: AcpiRsCreateAmlResources * ! * PARAMETERS: ResourceList - Pointer to the resource list buffer ! * OutputBuffer - Where the AML buffer is returned * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the OutputBuffer is too small, the error will be * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point * to the size buffer needed. * ! * DESCRIPTION: Converts a list of device resources to an AML bytestream ! * to be used as input for the _SRS control method. * ******************************************************************************/ ACPI_STATUS AcpiRsCreateAmlResources ( ! ACPI_BUFFER *ResourceList, ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; ACPI_SIZE AmlSizeNeeded = 0; ACPI_FUNCTION_TRACE (RsCreateAmlResources); ! /* Params already validated, no need to re-validate here */ ! ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n", ! ResourceList->Pointer)); + /* Get the buffer size needed for the AML byte stream */ + + Status = AcpiRsGetAmlLength (ResourceList->Pointer, + ResourceList->Length, &AmlSizeNeeded); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status);
*** 445,461 **** return_ACPI_STATUS (Status); } /* Do the conversion */ ! Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, ! OutputBuffer->Pointer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); } - --- 485,500 ---- return_ACPI_STATUS (Status); } /* Do the conversion */ ! Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer, ! AmlSizeNeeded, OutputBuffer->Pointer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); return_ACPI_STATUS (AE_OK); }