167754Smsmith/******************************************************************************* 267754Smsmith * 377424Smsmith * Module Name: rscalc - Calculate stream and list lengths 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7316303Sjkim/****************************************************************************** 8316303Sjkim * 9316303Sjkim * 1. Copyright Notice 10316303Sjkim * 11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 14316303Sjkim * 2. License 15316303Sjkim * 16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17316303Sjkim * rights. You may have additional license terms from the party that provided 18316303Sjkim * you this software, covering your right to use that party's intellectual 19316303Sjkim * property rights. 20316303Sjkim * 21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 26316303Sjkim * Code in any form, with the right to sublicense such rights; and 27316303Sjkim * 28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29316303Sjkim * license (with the right to sublicense), under only those claims of Intel 30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 33316303Sjkim * license, and in no event shall the patent license extend to any additions 34316303Sjkim * to or modifications of the Original Intel Code. No other license or right 35316303Sjkim * is granted directly or by implication, estoppel or otherwise; 36316303Sjkim * 37316303Sjkim * The above copyright and patent license is granted only if the following 38316303Sjkim * conditions are met: 39316303Sjkim * 40316303Sjkim * 3. Conditions 41316303Sjkim * 42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43316303Sjkim * Redistribution of source code of any substantial portion of the Covered 44316303Sjkim * Code or modification with rights to further distribute source must include 45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 49316303Sjkim * Code and the date of any change. Licensee must include in that file the 50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51316303Sjkim * must include a prominent statement that the modification is derived, 52316303Sjkim * directly or indirectly, from Original Intel Code. 53316303Sjkim * 54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55316303Sjkim * Redistribution of source code of any substantial portion of the Covered 56316303Sjkim * Code or modification without rights to further distribute source must 57316303Sjkim * include the following Disclaimer and Export Compliance provision in the 58316303Sjkim * documentation and/or other materials provided with distribution. In 59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 61316303Sjkim * license from Licensee to its licensee is limited to the intellectual 62316303Sjkim * property embodied in the software Licensee provides to its licensee, and 63316303Sjkim * not to intellectual property embodied in modifications its licensee may 64316303Sjkim * make. 65316303Sjkim * 66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69316303Sjkim * provision in the documentation and/or other materials provided with the 70316303Sjkim * distribution. 71316303Sjkim * 72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73316303Sjkim * Intel Code. 74316303Sjkim * 75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77316303Sjkim * other dealings in products derived from or relating to the Covered Code 78316303Sjkim * without prior written authorization from Intel. 79316303Sjkim * 80316303Sjkim * 4. Disclaimer and Export Compliance 81316303Sjkim * 82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88316303Sjkim * PARTICULAR PURPOSE. 89316303Sjkim * 90316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97316303Sjkim * LIMITED REMEDY. 98316303Sjkim * 99316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100316303Sjkim * software or system incorporating such software without first obtaining any 101316303Sjkim * required license or other approval from the U. S. Department of Commerce or 102316303Sjkim * any other agency or department of the United States Government. In the 103316303Sjkim * event Licensee exports any such software from the United States or 104316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 105316303Sjkim * ensure that the distribution and export/re-export of the software is in 106316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109316303Sjkim * software, or service, directly or indirectly, to any country for which the 110316303Sjkim * United States government or any agency thereof requires an export license, 111316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 112316303Sjkim * such license, approval or letter. 113316303Sjkim * 114316303Sjkim ***************************************************************************** 115316303Sjkim * 116316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 117316303Sjkim * following license: 118316303Sjkim * 119217365Sjkim * Redistribution and use in source and binary forms, with or without 120217365Sjkim * modification, are permitted provided that the following conditions 121217365Sjkim * are met: 122217365Sjkim * 1. Redistributions of source code must retain the above copyright 123217365Sjkim * notice, this list of conditions, and the following disclaimer, 124217365Sjkim * without modification. 125217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 127217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 128217365Sjkim * including a substantially similar Disclaimer requirement for further 129217365Sjkim * binary redistribution. 130217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 131217365Sjkim * of any contributors may be used to endorse or promote products derived 132217365Sjkim * from this software without specific prior written permission. 13367754Smsmith * 134316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145316303Sjkim * 146316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 147217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 148217365Sjkim * Software Foundation. 14967754Smsmith * 150316303Sjkim *****************************************************************************/ 15167754Smsmith 152193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 153193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 154193341Sjkim#include <contrib/dev/acpica/include/acresrc.h> 155193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 15667754Smsmith 157193267Sjkim 15877424Smsmith#define _COMPONENT ACPI_RESOURCES 15991116Smsmith ACPI_MODULE_NAME ("rscalc") 16067754Smsmith 16167754Smsmith 162151937Sjkim/* Local prototypes */ 163151937Sjkim 164151937Sjkimstatic UINT8 165151937SjkimAcpiRsCountSetBits ( 166151937Sjkim UINT16 BitField); 167151937Sjkim 168151937Sjkimstatic ACPI_RS_LENGTH 169151937SjkimAcpiRsStructOptionLength ( 170151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource); 171151937Sjkim 172151937Sjkimstatic UINT32 173151937SjkimAcpiRsStreamOptionLength ( 174151937Sjkim UINT32 ResourceLength, 175151937Sjkim UINT32 MinimumTotalLength); 176151937Sjkim 177151937Sjkim 17867754Smsmith/******************************************************************************* 17967754Smsmith * 180151937Sjkim * FUNCTION: AcpiRsCountSetBits 18167754Smsmith * 182151937Sjkim * PARAMETERS: BitField - Field in which to count bits 18367754Smsmith * 184151937Sjkim * RETURN: Number of bits set within the field 18567754Smsmith * 186151937Sjkim * DESCRIPTION: Count the number of bits set in a resource field. Used for 187151937Sjkim * (Short descriptor) interrupt and DMA lists. 18867754Smsmith * 18967754Smsmith ******************************************************************************/ 19067754Smsmith 191151937Sjkimstatic UINT8 192151937SjkimAcpiRsCountSetBits ( 193151937Sjkim UINT16 BitField) 19467754Smsmith{ 195151937Sjkim UINT8 BitsSet; 19667754Smsmith 19767754Smsmith 198151937Sjkim ACPI_FUNCTION_ENTRY (); 19967754Smsmith 20067754Smsmith 201151937Sjkim for (BitsSet = 0; BitField; BitsSet++) 20267754Smsmith { 203151937Sjkim /* Zero the least significant bit that is set */ 20467754Smsmith 205193267Sjkim BitField &= (UINT16) (BitField - 1); 206151937Sjkim } 20767754Smsmith 208151937Sjkim return (BitsSet); 209151937Sjkim} 21067754Smsmith 21167754Smsmith 212151937Sjkim/******************************************************************************* 213151937Sjkim * 214151937Sjkim * FUNCTION: AcpiRsStructOptionLength 215151937Sjkim * 216151937Sjkim * PARAMETERS: ResourceSource - Pointer to optional descriptor field 217151937Sjkim * 218151937Sjkim * RETURN: Status 219151937Sjkim * 220151937Sjkim * DESCRIPTION: Common code to handle optional ResourceSourceIndex and 221151937Sjkim * ResourceSource fields in some Large descriptors. Used during 222151937Sjkim * list-to-stream conversion 223151937Sjkim * 224151937Sjkim ******************************************************************************/ 22567754Smsmith 226151937Sjkimstatic ACPI_RS_LENGTH 227151937SjkimAcpiRsStructOptionLength ( 228151937Sjkim ACPI_RESOURCE_SOURCE *ResourceSource) 229151937Sjkim{ 230151937Sjkim ACPI_FUNCTION_ENTRY (); 23167754Smsmith 23267754Smsmith 233151937Sjkim /* 234151937Sjkim * If the ResourceSource string is valid, return the size of the string 235151937Sjkim * (StringLength includes the NULL terminator) plus the size of the 236151937Sjkim * ResourceSourceIndex (1). 237151937Sjkim */ 238151937Sjkim if (ResourceSource->StringPtr) 239151937Sjkim { 240151937Sjkim return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1)); 241151937Sjkim } 24267754Smsmith 243151937Sjkim return (0); 244151937Sjkim} 24567754Smsmith 24667754Smsmith 247151937Sjkim/******************************************************************************* 248151937Sjkim * 249151937Sjkim * FUNCTION: AcpiRsStreamOptionLength 250151937Sjkim * 251151937Sjkim * PARAMETERS: ResourceLength - Length from the resource header 252151937Sjkim * MinimumTotalLength - Minimum length of this resource, before 253151937Sjkim * any optional fields. Includes header size 254151937Sjkim * 255151937Sjkim * RETURN: Length of optional string (0 if no string present) 256151937Sjkim * 257151937Sjkim * DESCRIPTION: Common code to handle optional ResourceSourceIndex and 258151937Sjkim * ResourceSource fields in some Large descriptors. Used during 259151937Sjkim * stream-to-list conversion 260151937Sjkim * 261151937Sjkim ******************************************************************************/ 26267754Smsmith 263151937Sjkimstatic UINT32 264151937SjkimAcpiRsStreamOptionLength ( 265151937Sjkim UINT32 ResourceLength, 266151937Sjkim UINT32 MinimumAmlResourceLength) 267151937Sjkim{ 268151937Sjkim UINT32 StringLength = 0; 26967754Smsmith 27067754Smsmith 271151937Sjkim ACPI_FUNCTION_ENTRY (); 27267754Smsmith 27367754Smsmith 274151937Sjkim /* 275298714Sjkim * The ResourceSourceIndex and ResourceSource are optional elements of 276298714Sjkim * some Large-type resource descriptors. 277151937Sjkim */ 27867754Smsmith 279151937Sjkim /* 280298714Sjkim * If the length of the actual resource descriptor is greater than the 281298714Sjkim * ACPI spec-defined minimum length, it means that a ResourceSourceIndex 282298714Sjkim * exists and is followed by a (required) null terminated string. The 283298714Sjkim * string length (including the null terminator) is the resource length 284298714Sjkim * minus the minimum length, minus one byte for the ResourceSourceIndex 285298714Sjkim * itself. 286151937Sjkim */ 287151937Sjkim if (ResourceLength > MinimumAmlResourceLength) 288151937Sjkim { 289151937Sjkim /* Compute the length of the optional string */ 29077424Smsmith 291151937Sjkim StringLength = ResourceLength - MinimumAmlResourceLength - 1; 292151937Sjkim } 29377424Smsmith 294167802Sjkim /* 295167802Sjkim * Round the length up to a multiple of the native word in order to 296167802Sjkim * guarantee that the entire resource descriptor is native word aligned 297167802Sjkim */ 298167802Sjkim return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength)); 29967754Smsmith} 30067754Smsmith 30167754Smsmith 30267754Smsmith/******************************************************************************* 30367754Smsmith * 304151937Sjkim * FUNCTION: AcpiRsGetAmlLength 30567754Smsmith * 306151937Sjkim * PARAMETERS: Resource - Pointer to the resource linked list 307272444Sjkim * ResourceListSize - Size of the resource linked list 308151937Sjkim * SizeNeeded - Where the required size is returned 30967754Smsmith * 31077424Smsmith * RETURN: Status 31167754Smsmith * 312151937Sjkim * DESCRIPTION: Takes a linked list of internal resource descriptors and 313151937Sjkim * calculates the size buffer needed to hold the corresponding 314151937Sjkim * external resource byte stream. 31567754Smsmith * 31667754Smsmith ******************************************************************************/ 31767754Smsmith 31867754SmsmithACPI_STATUS 319151937SjkimAcpiRsGetAmlLength ( 320151937Sjkim ACPI_RESOURCE *Resource, 321272444Sjkim ACPI_SIZE ResourceListSize, 32291116Smsmith ACPI_SIZE *SizeNeeded) 32367754Smsmith{ 324151937Sjkim ACPI_SIZE AmlSizeNeeded = 0; 325272444Sjkim ACPI_RESOURCE *ResourceEnd; 326167802Sjkim ACPI_RS_LENGTH TotalSize; 32767754Smsmith 32867754Smsmith 329167802Sjkim ACPI_FUNCTION_TRACE (RsGetAmlLength); 33067754Smsmith 33167754Smsmith 332151937Sjkim /* Traverse entire list of internal resource descriptors */ 333151937Sjkim 334272444Sjkim ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, ResourceListSize); 335272444Sjkim while (Resource < ResourceEnd) 33667754Smsmith { 337151937Sjkim /* Validate the descriptor type */ 33867754Smsmith 339151937Sjkim if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) 34067754Smsmith { 341151937Sjkim return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); 342151937Sjkim } 34367754Smsmith 344246849Sjkim /* Sanity check the length. It must not be zero, or we loop forever */ 345246849Sjkim 346246849Sjkim if (!Resource->Length) 347246849Sjkim { 348246849Sjkim return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); 349246849Sjkim } 350246849Sjkim 351151937Sjkim /* Get the base size of the (external stream) resource descriptor */ 35267754Smsmith 353151937Sjkim TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type]; 35467754Smsmith 355151937Sjkim /* 356151937Sjkim * Augment the base size for descriptors with optional and/or 357151937Sjkim * variable-length fields 358151937Sjkim */ 359151937Sjkim switch (Resource->Type) 360151937Sjkim { 361193267Sjkim case ACPI_RESOURCE_TYPE_IRQ: 362193267Sjkim 363193267Sjkim /* Length can be 3 or 2 */ 364193267Sjkim 365193267Sjkim if (Resource->Data.Irq.DescriptorLength == 2) 366193267Sjkim { 367193267Sjkim TotalSize--; 368193267Sjkim } 369193267Sjkim break; 370193267Sjkim 371193267Sjkim 372193267Sjkim case ACPI_RESOURCE_TYPE_START_DEPENDENT: 373193267Sjkim 374193267Sjkim /* Length can be 1 or 0 */ 375193267Sjkim 376193267Sjkim if (Resource->Data.Irq.DescriptorLength == 0) 377193267Sjkim { 378193267Sjkim TotalSize--; 379193267Sjkim } 380193267Sjkim break; 381193267Sjkim 382193267Sjkim 383151937Sjkim case ACPI_RESOURCE_TYPE_VENDOR: 38477424Smsmith /* 385151937Sjkim * Vendor Defined Resource: 386151937Sjkim * For a Vendor Specific resource, if the Length is between 1 and 7 387151937Sjkim * it will be created as a Small Resource data type, otherwise it 388151937Sjkim * is a Large Resource data type. 38977424Smsmith */ 390151937Sjkim if (Resource->Data.Vendor.ByteLength > 7) 391151937Sjkim { 392151937Sjkim /* Base size of a Large resource descriptor */ 39367754Smsmith 394151937Sjkim TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER); 395151937Sjkim } 39667754Smsmith 397151937Sjkim /* Add the size of the vendor-specific data */ 39877424Smsmith 399151937Sjkim TotalSize = (ACPI_RS_LENGTH) 400151937Sjkim (TotalSize + Resource->Data.Vendor.ByteLength); 40177424Smsmith break; 40267754Smsmith 40367754Smsmith 404151937Sjkim case ACPI_RESOURCE_TYPE_END_TAG: 40577424Smsmith /* 406151937Sjkim * End Tag: 407151937Sjkim * We are done -- return the accumulated total size. 40877424Smsmith */ 409151937Sjkim *SizeNeeded = AmlSizeNeeded + TotalSize; 41067754Smsmith 411151937Sjkim /* Normal exit */ 41267754Smsmith 413151937Sjkim return_ACPI_STATUS (AE_OK); 41467754Smsmith 415151937Sjkim 416151937Sjkim case ACPI_RESOURCE_TYPE_ADDRESS16: 41777424Smsmith /* 418151937Sjkim * 16-Bit Address Resource: 419151937Sjkim * Add the size of the optional ResourceSource info 42077424Smsmith */ 421298714Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 422298714Sjkim AcpiRsStructOptionLength ( 423298714Sjkim &Resource->Data.Address16.ResourceSource)); 42477424Smsmith break; 42567754Smsmith 42667754Smsmith 427151937Sjkim case ACPI_RESOURCE_TYPE_ADDRESS32: 42877424Smsmith /* 429151937Sjkim * 32-Bit Address Resource: 430151937Sjkim * Add the size of the optional ResourceSource info 43177424Smsmith */ 432298714Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 433298714Sjkim AcpiRsStructOptionLength ( 434298714Sjkim &Resource->Data.Address32.ResourceSource)); 435151937Sjkim break; 43667754Smsmith 43767754Smsmith 438151937Sjkim case ACPI_RESOURCE_TYPE_ADDRESS64: 43977424Smsmith /* 440151937Sjkim * 64-Bit Address Resource: 441151937Sjkim * Add the size of the optional ResourceSource info 44277424Smsmith */ 443298714Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 444298714Sjkim AcpiRsStructOptionLength ( 445298714Sjkim &Resource->Data.Address64.ResourceSource)); 44677424Smsmith break; 44767754Smsmith 44867754Smsmith 449151937Sjkim case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 45077424Smsmith /* 451151937Sjkim * Extended IRQ Resource: 452151937Sjkim * Add the size of each additional optional interrupt beyond the 453151937Sjkim * required 1 (4 bytes for each UINT32 interrupt number) 45477424Smsmith */ 455298714Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 456151937Sjkim ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + 45767754Smsmith 458151937Sjkim /* Add the size of the optional ResourceSource info */ 45967754Smsmith 460151937Sjkim AcpiRsStructOptionLength ( 461151937Sjkim &Resource->Data.ExtendedIrq.ResourceSource)); 462151937Sjkim break; 46367754Smsmith 46467754Smsmith 465228110Sjkim case ACPI_RESOURCE_TYPE_GPIO: 466228110Sjkim 467298714Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 468298714Sjkim (Resource->Data.Gpio.PinTableLength * 2) + 469228110Sjkim Resource->Data.Gpio.ResourceSource.StringLength + 470228110Sjkim Resource->Data.Gpio.VendorLength); 471228110Sjkim 472228110Sjkim break; 473228110Sjkim 474322877Sjkim case ACPI_RESOURCE_TYPE_PIN_FUNCTION: 475228110Sjkim 476322877Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 477322877Sjkim (Resource->Data.PinFunction.PinTableLength * 2) + 478322877Sjkim Resource->Data.PinFunction.ResourceSource.StringLength + 479322877Sjkim Resource->Data.PinFunction.VendorLength); 480322877Sjkim 481322877Sjkim break; 482322877Sjkim 483322877Sjkim 484228110Sjkim case ACPI_RESOURCE_TYPE_SERIAL_BUS: 485228110Sjkim 486298714Sjkim TotalSize = AcpiGbl_AmlResourceSerialBusSizes [ 487298714Sjkim Resource->Data.CommonSerialBus.Type]; 488228110Sjkim 489228110Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 490228110Sjkim Resource->Data.I2cSerialBus.ResourceSource.StringLength + 491228110Sjkim Resource->Data.I2cSerialBus.VendorLength); 492228110Sjkim 493228110Sjkim break; 494228110Sjkim 495322877Sjkim case ACPI_RESOURCE_TYPE_PIN_CONFIG: 496322877Sjkim 497322877Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 498322877Sjkim (Resource->Data.PinConfig.PinTableLength * 2) + 499322877Sjkim Resource->Data.PinConfig.ResourceSource.StringLength + 500322877Sjkim Resource->Data.PinConfig.VendorLength); 501322877Sjkim 502322877Sjkim break; 503322877Sjkim 504322877Sjkim case ACPI_RESOURCE_TYPE_PIN_GROUP: 505322877Sjkim 506322877Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 507322877Sjkim (Resource->Data.PinGroup.PinTableLength * 2) + 508322877Sjkim Resource->Data.PinGroup.ResourceLabel.StringLength + 509322877Sjkim Resource->Data.PinGroup.VendorLength); 510322877Sjkim 511322877Sjkim break; 512322877Sjkim 513322877Sjkim case ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION: 514322877Sjkim 515322877Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 516322877Sjkim Resource->Data.PinGroupFunction.ResourceSource.StringLength + 517322877Sjkim Resource->Data.PinGroupFunction.ResourceSourceLabel.StringLength + 518322877Sjkim Resource->Data.PinGroupFunction.VendorLength); 519322877Sjkim 520322877Sjkim break; 521322877Sjkim 522322877Sjkim case ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG: 523322877Sjkim 524322877Sjkim TotalSize = (ACPI_RS_LENGTH) (TotalSize + 525322877Sjkim Resource->Data.PinGroupConfig.ResourceSource.StringLength + 526322877Sjkim Resource->Data.PinGroupConfig.ResourceSourceLabel.StringLength + 527322877Sjkim Resource->Data.PinGroupConfig.VendorLength); 528322877Sjkim 529322877Sjkim break; 530322877Sjkim 531250838Sjkim default: 532228110Sjkim 53377424Smsmith break; 534151937Sjkim } 53567754Smsmith 536151937Sjkim /* Update the total */ 53767754Smsmith 538151937Sjkim AmlSizeNeeded += TotalSize; 53967754Smsmith 540151937Sjkim /* Point to the next object */ 54167754Smsmith 542167802Sjkim Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); 543151937Sjkim } 54467754Smsmith 545167802Sjkim /* Did not find an EndTag resource descriptor */ 54667754Smsmith 547167802Sjkim return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 548151937Sjkim} 54967754Smsmith 55067754Smsmith 551151937Sjkim/******************************************************************************* 552151937Sjkim * 553151937Sjkim * FUNCTION: AcpiRsGetListLength 554151937Sjkim * 555151937Sjkim * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 556151937Sjkim * AmlBufferLength - Size of AmlBuffer 557151937Sjkim * SizeNeeded - Where the size needed is returned 558151937Sjkim * 559151937Sjkim * RETURN: Status 560151937Sjkim * 561151937Sjkim * DESCRIPTION: Takes an external resource byte stream and calculates the size 562151937Sjkim * buffer needed to hold the corresponding internal resource 563151937Sjkim * descriptor linked list. 564151937Sjkim * 565151937Sjkim ******************************************************************************/ 56667754Smsmith 567151937SjkimACPI_STATUS 568151937SjkimAcpiRsGetListLength ( 569151937Sjkim UINT8 *AmlBuffer, 570151937Sjkim UINT32 AmlBufferLength, 571151937Sjkim ACPI_SIZE *SizeNeeded) 572151937Sjkim{ 573167802Sjkim ACPI_STATUS Status; 574167802Sjkim UINT8 *EndAml; 575151937Sjkim UINT8 *Buffer; 576167802Sjkim UINT32 BufferSize; 577151937Sjkim UINT16 Temp16; 578151937Sjkim UINT16 ResourceLength; 579151937Sjkim UINT32 ExtraStructBytes; 580167802Sjkim UINT8 ResourceIndex; 581167802Sjkim UINT8 MinimumAmlResourceLength; 582228110Sjkim AML_RESOURCE *AmlResource; 58367754Smsmith 58467754Smsmith 585167802Sjkim ACPI_FUNCTION_TRACE (RsGetListLength); 58667754Smsmith 58767754Smsmith 588228110Sjkim *SizeNeeded = ACPI_RS_SIZE_MIN; /* Minimum size is one EndTag */ 589167802Sjkim EndAml = AmlBuffer + AmlBufferLength; 59067754Smsmith 591167802Sjkim /* Walk the list of AML resource descriptors */ 59267754Smsmith 593167802Sjkim while (AmlBuffer < EndAml) 594167802Sjkim { 595167802Sjkim /* Validate the Resource Type and Resource Length */ 59667754Smsmith 597243347Sjkim Status = AcpiUtValidateResource (NULL, AmlBuffer, &ResourceIndex); 598167802Sjkim if (ACPI_FAILURE (Status)) 599151937Sjkim { 600228110Sjkim /* 601228110Sjkim * Exit on failure. Cannot continue because the descriptor length 602228110Sjkim * may be bogus also. 603228110Sjkim */ 604167802Sjkim return_ACPI_STATUS (Status); 605151937Sjkim } 60667754Smsmith 607228110Sjkim AmlResource = (void *) AmlBuffer; 608228110Sjkim 609167802Sjkim /* Get the resource length and base (minimum) AML size */ 61067754Smsmith 611151937Sjkim ResourceLength = AcpiUtGetResourceLength (AmlBuffer); 612167802Sjkim MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; 61367754Smsmith 614167802Sjkim /* 615167802Sjkim * Augment the size for descriptors with optional 616167802Sjkim * and/or variable length fields 617167802Sjkim */ 618151937Sjkim ExtraStructBytes = 0; 619167802Sjkim Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer); 620138287Smarks 621167802Sjkim switch (AcpiUtGetResourceType (AmlBuffer)) 622151937Sjkim { 623167802Sjkim case ACPI_RESOURCE_NAME_IRQ: 62477424Smsmith /* 625167802Sjkim * IRQ Resource: 626167802Sjkim * Get the number of bits set in the 16-bit IRQ mask 62777424Smsmith */ 628167802Sjkim ACPI_MOVE_16_TO_16 (&Temp16, Buffer); 629167802Sjkim ExtraStructBytes = AcpiRsCountSetBits (Temp16); 630167802Sjkim break; 63167754Smsmith 63267754Smsmith 633167802Sjkim case ACPI_RESOURCE_NAME_DMA: 634167802Sjkim /* 635167802Sjkim * DMA Resource: 636167802Sjkim * Get the number of bits set in the 8-bit DMA mask 637167802Sjkim */ 638167802Sjkim ExtraStructBytes = AcpiRsCountSetBits (*Buffer); 639167802Sjkim break; 64067754Smsmith 64167754Smsmith 642167802Sjkim case ACPI_RESOURCE_NAME_VENDOR_SMALL: 643167802Sjkim case ACPI_RESOURCE_NAME_VENDOR_LARGE: 644167802Sjkim /* 645167802Sjkim * Vendor Resource: 646167802Sjkim * Get the number of vendor data bytes 647167802Sjkim */ 648167802Sjkim ExtraStructBytes = ResourceLength; 649241973Sjkim 650241973Sjkim /* 651241973Sjkim * There is already one byte included in the minimum 652241973Sjkim * descriptor size. If there are extra struct bytes, 653241973Sjkim * subtract one from the count. 654241973Sjkim */ 655241973Sjkim if (ExtraStructBytes) 656241973Sjkim { 657241973Sjkim ExtraStructBytes--; 658241973Sjkim } 659167802Sjkim break; 66067754Smsmith 66167754Smsmith 662167802Sjkim case ACPI_RESOURCE_NAME_END_TAG: 663167802Sjkim /* 664228110Sjkim * End Tag: This is the normal exit 665167802Sjkim */ 666167802Sjkim return_ACPI_STATUS (AE_OK); 667138287Smarks 66877424Smsmith 669167802Sjkim case ACPI_RESOURCE_NAME_ADDRESS32: 670167802Sjkim case ACPI_RESOURCE_NAME_ADDRESS16: 671167802Sjkim case ACPI_RESOURCE_NAME_ADDRESS64: 67277424Smsmith /* 673167802Sjkim * Address Resource: 674167802Sjkim * Add the size of the optional ResourceSource 67577424Smsmith */ 676167802Sjkim ExtraStructBytes = AcpiRsStreamOptionLength ( 677167802Sjkim ResourceLength, MinimumAmlResourceLength); 678167802Sjkim break; 67967754Smsmith 68067754Smsmith 681167802Sjkim case ACPI_RESOURCE_NAME_EXTENDED_IRQ: 682167802Sjkim /* 683167802Sjkim * Extended IRQ Resource: 684167802Sjkim * Using the InterruptTableLength, add 4 bytes for each additional 685167802Sjkim * interrupt. Note: at least one interrupt is required and is 686167802Sjkim * included in the minimum descriptor size (reason for the -1) 687167802Sjkim */ 688167802Sjkim ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32); 68967754Smsmith 690167802Sjkim /* Add the size of the optional ResourceSource */ 69167754Smsmith 692167802Sjkim ExtraStructBytes += AcpiRsStreamOptionLength ( 693167802Sjkim ResourceLength - ExtraStructBytes, MinimumAmlResourceLength); 694167802Sjkim break; 69567754Smsmith 696228110Sjkim case ACPI_RESOURCE_NAME_GPIO: 69767754Smsmith 698228110Sjkim /* Vendor data is optional */ 699228110Sjkim 700228110Sjkim if (AmlResource->Gpio.VendorLength) 701228110Sjkim { 702298714Sjkim ExtraStructBytes += 703298714Sjkim AmlResource->Gpio.VendorOffset - 704298714Sjkim AmlResource->Gpio.PinTableOffset + 705298714Sjkim AmlResource->Gpio.VendorLength; 706228110Sjkim } 707228110Sjkim else 708228110Sjkim { 709298714Sjkim ExtraStructBytes += 710298714Sjkim AmlResource->LargeHeader.ResourceLength + 711228110Sjkim sizeof (AML_RESOURCE_LARGE_HEADER) - 712228110Sjkim AmlResource->Gpio.PinTableOffset; 713228110Sjkim } 714228110Sjkim break; 715228110Sjkim 716322877Sjkim case ACPI_RESOURCE_NAME_PIN_FUNCTION: 717322877Sjkim 718322877Sjkim /* Vendor data is optional */ 719322877Sjkim 720322877Sjkim if (AmlResource->PinFunction.VendorLength) 721322877Sjkim { 722322877Sjkim ExtraStructBytes += 723322877Sjkim AmlResource->PinFunction.VendorOffset - 724322877Sjkim AmlResource->PinFunction.PinTableOffset + 725322877Sjkim AmlResource->PinFunction.VendorLength; 726322877Sjkim } 727322877Sjkim else 728322877Sjkim { 729322877Sjkim ExtraStructBytes += 730322877Sjkim AmlResource->LargeHeader.ResourceLength + 731322877Sjkim sizeof (AML_RESOURCE_LARGE_HEADER) - 732322877Sjkim AmlResource->PinFunction.PinTableOffset; 733322877Sjkim } 734322877Sjkim break; 735322877Sjkim 736228110Sjkim case ACPI_RESOURCE_NAME_SERIAL_BUS: 737228110Sjkim 738228110Sjkim MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[ 739228110Sjkim AmlResource->CommonSerialBus.Type]; 740298714Sjkim ExtraStructBytes += 741298714Sjkim AmlResource->CommonSerialBus.ResourceLength - 742228110Sjkim MinimumAmlResourceLength; 743228110Sjkim break; 744228110Sjkim 745322877Sjkim case ACPI_RESOURCE_NAME_PIN_CONFIG: 746322877Sjkim 747322877Sjkim /* Vendor data is optional */ 748322877Sjkim 749322877Sjkim if (AmlResource->PinConfig.VendorLength) 750322877Sjkim { 751322877Sjkim ExtraStructBytes += 752322877Sjkim AmlResource->PinConfig.VendorOffset - 753322877Sjkim AmlResource->PinConfig.PinTableOffset + 754322877Sjkim AmlResource->PinConfig.VendorLength; 755322877Sjkim } 756322877Sjkim else 757322877Sjkim { 758322877Sjkim ExtraStructBytes += 759322877Sjkim AmlResource->LargeHeader.ResourceLength + 760322877Sjkim sizeof (AML_RESOURCE_LARGE_HEADER) - 761322877Sjkim AmlResource->PinConfig.PinTableOffset; 762322877Sjkim } 763322877Sjkim break; 764322877Sjkim 765322877Sjkim case ACPI_RESOURCE_NAME_PIN_GROUP: 766322877Sjkim 767322877Sjkim ExtraStructBytes += 768322877Sjkim AmlResource->PinGroup.VendorOffset - 769322877Sjkim AmlResource->PinGroup.PinTableOffset + 770322877Sjkim AmlResource->PinGroup.VendorLength; 771322877Sjkim 772322877Sjkim break; 773322877Sjkim 774322877Sjkim case ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION: 775322877Sjkim 776322877Sjkim ExtraStructBytes += 777322877Sjkim AmlResource->PinGroupFunction.VendorOffset - 778322877Sjkim AmlResource->PinGroupFunction.ResSourceOffset + 779322877Sjkim AmlResource->PinGroupFunction.VendorLength; 780322877Sjkim 781322877Sjkim break; 782322877Sjkim 783322877Sjkim case ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG: 784322877Sjkim 785322877Sjkim ExtraStructBytes += 786322877Sjkim AmlResource->PinGroupConfig.VendorOffset - 787322877Sjkim AmlResource->PinGroupConfig.ResSourceOffset + 788322877Sjkim AmlResource->PinGroupConfig.VendorLength; 789322877Sjkim 790322877Sjkim break; 791322877Sjkim 792167802Sjkim default: 793250838Sjkim 794167802Sjkim break; 795167802Sjkim } 79667754Smsmith 797167802Sjkim /* 798167802Sjkim * Update the required buffer size for the internal descriptor structs 799167802Sjkim * 800167802Sjkim * Important: Round the size up for the appropriate alignment. This 801167802Sjkim * is a requirement on IA64. 802167802Sjkim */ 803298714Sjkim if (AcpiUtGetResourceType (AmlBuffer) == 804298714Sjkim ACPI_RESOURCE_NAME_SERIAL_BUS) 805228110Sjkim { 806228110Sjkim BufferSize = AcpiGbl_ResourceStructSerialBusSizes[ 807228110Sjkim AmlResource->CommonSerialBus.Type] + ExtraStructBytes; 808228110Sjkim } 809228110Sjkim else 810228110Sjkim { 811228110Sjkim BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + 812298714Sjkim ExtraStructBytes; 813228110Sjkim } 814298714Sjkim 815167802Sjkim BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); 816167802Sjkim *SizeNeeded += BufferSize; 81767754Smsmith 818167802Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, 819167802Sjkim "Type %.2X, AmlLength %.2X InternalLength %.2X\n", 820167802Sjkim AcpiUtGetResourceType (AmlBuffer), 821167802Sjkim AcpiUtGetDescriptorLength (AmlBuffer), BufferSize)); 82267754Smsmith 82367754Smsmith /* 824167802Sjkim * Point to the next resource within the AML stream using the length 825167802Sjkim * contained in the resource descriptor header 82667754Smsmith */ 827167802Sjkim AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); 82867754Smsmith } 82967754Smsmith 830167802Sjkim /* Did not find an EndTag resource descriptor */ 831151937Sjkim 832167802Sjkim return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); 83367754Smsmith} 83467754Smsmith 83567754Smsmith 83667754Smsmith/******************************************************************************* 83767754Smsmith * 83899679Siwasaki * FUNCTION: AcpiRsGetPciRoutingTableLength 83967754Smsmith * 84067754Smsmith * PARAMETERS: PackageObject - Pointer to the package object 84167754Smsmith * BufferSizeNeeded - UINT32 pointer of the size buffer 84277424Smsmith * needed to properly return the 84377424Smsmith * parsed data 84467754Smsmith * 84577424Smsmith * RETURN: Status 84667754Smsmith * 84767754Smsmith * DESCRIPTION: Given a package representing a PCI routing table, this 84877424Smsmith * calculates the size of the corresponding linked list of 84977424Smsmith * descriptions. 85067754Smsmith * 85167754Smsmith ******************************************************************************/ 85267754Smsmith 85367754SmsmithACPI_STATUS 85499679SiwasakiAcpiRsGetPciRoutingTableLength ( 85567754Smsmith ACPI_OPERAND_OBJECT *PackageObject, 85691116Smsmith ACPI_SIZE *BufferSizeNeeded) 85767754Smsmith{ 85867754Smsmith UINT32 NumberOfElements; 85999679Siwasaki ACPI_SIZE TempSizeNeeded = 0; 86067754Smsmith ACPI_OPERAND_OBJECT **TopObjectList; 86167754Smsmith UINT32 Index; 86267754Smsmith ACPI_OPERAND_OBJECT *PackageElement; 86367754Smsmith ACPI_OPERAND_OBJECT **SubObjectList; 86467754Smsmith BOOLEAN NameFound; 86567754Smsmith UINT32 TableIndex; 86667754Smsmith 86767754Smsmith 868167802Sjkim ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength); 86967754Smsmith 87067754Smsmith 87167754Smsmith NumberOfElements = PackageObject->Package.Count; 87267754Smsmith 87367754Smsmith /* 87467754Smsmith * Calculate the size of the return buffer. 87567754Smsmith * The base size is the number of elements * the sizes of the 876241973Sjkim * structures. Additional space for the strings is added below. 87767754Smsmith * The minus one is to subtract the size of the UINT8 Source[1] 87867754Smsmith * member because it is added below. 87967754Smsmith * 88067754Smsmith * But each PRT_ENTRY structure has a pointer to a string and 88167754Smsmith * the size of that string must be found. 88267754Smsmith */ 88367754Smsmith TopObjectList = PackageObject->Package.Elements; 88467754Smsmith 88567754Smsmith for (Index = 0; Index < NumberOfElements; Index++) 88667754Smsmith { 887272444Sjkim /* Dereference the subpackage */ 888151937Sjkim 88967754Smsmith PackageElement = *TopObjectList; 89067754Smsmith 891193267Sjkim /* We must have a valid Package object */ 892193267Sjkim 893193267Sjkim if (!PackageElement || 894193267Sjkim (PackageElement->Common.Type != ACPI_TYPE_PACKAGE)) 895193267Sjkim { 896193267Sjkim return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 897193267Sjkim } 898193267Sjkim 89967754Smsmith /* 90067754Smsmith * The SubObjectList will now point to an array of the 90167754Smsmith * four IRQ elements: Address, Pin, Source and SourceIndex 90267754Smsmith */ 90367754Smsmith SubObjectList = PackageElement->Package.Elements; 90467754Smsmith 905151937Sjkim /* Scan the IrqTableElements for the Source Name String */ 906151937Sjkim 90767754Smsmith NameFound = FALSE; 90867754Smsmith 909250838Sjkim for (TableIndex = 0; 910250838Sjkim TableIndex < PackageElement->Package.Count && !NameFound; 911250838Sjkim TableIndex++) 91267754Smsmith { 913167802Sjkim if (*SubObjectList && /* Null object allowed */ 914167802Sjkim 915167802Sjkim ((ACPI_TYPE_STRING == 916193267Sjkim (*SubObjectList)->Common.Type) || 917151937Sjkim 918151937Sjkim ((ACPI_TYPE_LOCAL_REFERENCE == 919193267Sjkim (*SubObjectList)->Common.Type) && 920151937Sjkim 921193267Sjkim ((*SubObjectList)->Reference.Class == 922193267Sjkim ACPI_REFCLASS_NAME)))) 92367754Smsmith { 92467754Smsmith NameFound = TRUE; 92567754Smsmith } 92667754Smsmith else 92767754Smsmith { 928151937Sjkim /* Look at the next element */ 929151937Sjkim 93067754Smsmith SubObjectList++; 93167754Smsmith } 93267754Smsmith } 93367754Smsmith 93491116Smsmith TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); 93569450Smsmith 936151937Sjkim /* Was a String type found? */ 937151937Sjkim 93899679Siwasaki if (NameFound) 93967754Smsmith { 940193267Sjkim if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING) 94173561Smsmith { 94273561Smsmith /* 943114237Snjl * The length String.Length field does not include the 944114237Snjl * terminating NULL, add 1 94573561Smsmith */ 946151937Sjkim TempSizeNeeded += ((ACPI_SIZE) 947151937Sjkim (*SubObjectList)->String.Length + 1); 94873561Smsmith } 94973561Smsmith else 95073561Smsmith { 95177424Smsmith TempSizeNeeded += AcpiNsGetPathnameLength ( 952298714Sjkim (*SubObjectList)->Reference.Node); 95373561Smsmith } 95467754Smsmith } 95567754Smsmith else 95667754Smsmith { 95767754Smsmith /* 95867754Smsmith * If no name was found, then this is a NULL, which is 95977424Smsmith * translated as a UINT32 zero. 96067754Smsmith */ 96177424Smsmith TempSizeNeeded += sizeof (UINT32); 96267754Smsmith } 96367754Smsmith 96469450Smsmith /* Round up the size since each element must be aligned */ 96569450Smsmith 966167802Sjkim TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded); 96769450Smsmith 968151937Sjkim /* Point to the next ACPI_OPERAND_OBJECT */ 969151937Sjkim 97067754Smsmith TopObjectList++; 97167754Smsmith } 97267754Smsmith 97377424Smsmith /* 974167802Sjkim * Add an extra element to the end of the list, essentially a 975151937Sjkim * NULL terminator 97677424Smsmith */ 97791116Smsmith *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); 97867754Smsmith return_ACPI_STATUS (AE_OK); 97969450Smsmith} 980