ACPI_STATUS AcpiExConcatTemplate ( ACPI_OPERAND_OBJECT *ObjDesc1, ACPI_OPERAND_OBJECT *ObjDesc2, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; UINT8 *EndTag1; UINT8 *EndTag2; ACPI_SIZE Length1; ACPI_SIZE Length2; ACPI_FUNCTION_TRACE ("ExConcatTemplate"); /* Find the EndTags in each resource template */ EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1); EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2); if (!EndTag1 || !EndTag2) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* Compute the length of each part */ Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer); Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) + 2; /* Size of END_TAG */ /* Create a new buffer object for the result */ ReturnDesc = AcpiUtCreateBufferObject (Length1 + Length2); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the templates to the new descriptor */ NewBuf = ReturnDesc->Buffer.Pointer; ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1); ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2); /* Compute the new checksum */ NewBuf[ReturnDesc->Buffer.Length - 1] = AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer, (ReturnDesc->Buffer.Length - 1)); /* Return the completed template descriptor */ *ActualReturnDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiExConcatTemplate ( ACPI_OPERAND_OBJECT *Operand0, ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; UINT8 *EndTag; ACPI_SIZE Length0; ACPI_SIZE Length1; ACPI_SIZE NewLength; ACPI_FUNCTION_TRACE (ExConcatTemplate); /* * Find the EndTag descriptor in each resource template. * Note1: returned pointers point TO the EndTag, not past it. * Note2: zero-length buffers are allowed; treated like one EndTag */ /* Get the length of the first resource template */ Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); /* Get the length of the second resource template */ Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); /* Combine both lengths, minimum size will be 2 for EndTag */ NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); /* Create a new buffer object for the result (with one EndTag) */ ReturnDesc = AcpiUtCreateBufferObject (NewLength); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* * Copy the templates to the new buffer, 0 first, then 1 follows. One * EndTag descriptor is copied from Operand1. */ NewBuf = ReturnDesc->Buffer.Pointer; memcpy (NewBuf, Operand0->Buffer.Pointer, Length0); memcpy (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ NewBuf[NewLength - 1] = 0; NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; /* Return the completed resource template */ *ActualReturnDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); }