⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rscalc.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
                                &Resource->Data.Address16.ResourceSource));            break;        case ACPI_RESOURCE_TYPE_ADDRESS32:            /*             * 32-Bit Address Resource:             * Add the size of the optional ResourceSource info             */            TotalSize = (ACPI_RS_LENGTH)                (TotalSize + AcpiRsStructOptionLength (                                &Resource->Data.Address32.ResourceSource));            break;        case ACPI_RESOURCE_TYPE_ADDRESS64:            /*             * 64-Bit Address Resource:             * Add the size of the optional ResourceSource info             */            TotalSize = (ACPI_RS_LENGTH)                (TotalSize + AcpiRsStructOptionLength (                                &Resource->Data.Address64.ResourceSource));            break;        case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:            /*             * Extended IRQ Resource:             * Add the size of each additional optional interrupt beyond the             * required 1 (4 bytes for each UINT32 interrupt number)             */            TotalSize = (ACPI_RS_LENGTH)                (TotalSize +                ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +                /* Add the size of the optional ResourceSource info */                AcpiRsStructOptionLength (                    &Resource->Data.ExtendedIrq.ResourceSource));            break;        default:            break;        }        /* Update the total */        AmlSizeNeeded += TotalSize;        /* Point to the next object */        Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);    }    /* Did not find an EndTag resource descriptor */    return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);}/******************************************************************************* * * FUNCTION:    AcpiRsGetListLength * * PARAMETERS:  AmlBuffer           - Pointer to the resource byte stream *              AmlBufferLength     - Size of AmlBuffer *              SizeNeeded          - Where the size needed is returned * * RETURN:      Status * * DESCRIPTION: Takes an external resource byte stream and calculates the size *              buffer needed to hold the corresponding internal resource *              descriptor linked list. * ******************************************************************************/ACPI_STATUSAcpiRsGetListLength (    UINT8                   *AmlBuffer,    UINT32                  AmlBufferLength,    ACPI_SIZE               *SizeNeeded){    ACPI_STATUS             Status;    UINT8                   *EndAml;    UINT8                   *Buffer;    UINT32                  BufferSize;    UINT16                  Temp16;    UINT16                  ResourceLength;    UINT32                  ExtraStructBytes;    UINT8                   ResourceIndex;    UINT8                   MinimumAmlResourceLength;    ACPI_FUNCTION_TRACE (RsGetListLength);    *SizeNeeded = 0;    EndAml = AmlBuffer + AmlBufferLength;    /* Walk the list of AML resource descriptors */    while (AmlBuffer < EndAml)    {        /* Validate the Resource Type and Resource Length */        Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex);        if (ACPI_FAILURE (Status))        {            return_ACPI_STATUS (Status);        }        /* Get the resource length and base (minimum) AML size */        ResourceLength = AcpiUtGetResourceLength (AmlBuffer);        MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];        /*         * Augment the size for descriptors with optional         * and/or variable length fields         */        ExtraStructBytes = 0;        Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);        switch (AcpiUtGetResourceType (AmlBuffer))        {        case ACPI_RESOURCE_NAME_IRQ:            /*             * IRQ Resource:             * Get the number of bits set in the 16-bit IRQ mask             */            ACPI_MOVE_16_TO_16 (&Temp16, Buffer);            ExtraStructBytes = AcpiRsCountSetBits (Temp16);            break;        case ACPI_RESOURCE_NAME_DMA:            /*             * DMA Resource:             * Get the number of bits set in the 8-bit DMA mask             */            ExtraStructBytes = AcpiRsCountSetBits (*Buffer);            break;        case ACPI_RESOURCE_NAME_VENDOR_SMALL:        case ACPI_RESOURCE_NAME_VENDOR_LARGE:            /*             * Vendor Resource:             * Get the number of vendor data bytes             */            ExtraStructBytes = ResourceLength;            break;        case ACPI_RESOURCE_NAME_END_TAG:            /*             * End Tag:             * This is the normal exit, add size of EndTag             */            *SizeNeeded += ACPI_RS_SIZE_MIN;            return_ACPI_STATUS (AE_OK);        case ACPI_RESOURCE_NAME_ADDRESS32:        case ACPI_RESOURCE_NAME_ADDRESS16:        case ACPI_RESOURCE_NAME_ADDRESS64:            /*             * Address Resource:             * Add the size of the optional ResourceSource             */            ExtraStructBytes = AcpiRsStreamOptionLength (                ResourceLength, MinimumAmlResourceLength);            break;        case ACPI_RESOURCE_NAME_EXTENDED_IRQ:            /*             * Extended IRQ Resource:             * Using the InterruptTableLength, add 4 bytes for each additional             * interrupt. Note: at least one interrupt is required and is             * included in the minimum descriptor size (reason for the -1)             */            ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);            /* Add the size of the optional ResourceSource */            ExtraStructBytes += AcpiRsStreamOptionLength (                ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);            break;        default:            break;        }        /*         * Update the required buffer size for the internal descriptor structs         *         * Important: Round the size up for the appropriate alignment. This         * is a requirement on IA64.         */        BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +                        ExtraStructBytes;        BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize);        *SizeNeeded += BufferSize;        ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,            "Type %.2X, AmlLength %.2X InternalLength %.2X\n",            AcpiUtGetResourceType (AmlBuffer),            AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));        /*         * Point to the next resource within the AML stream using the length         * contained in the resource descriptor header         */        AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);    }    /* Did not find an EndTag resource descriptor */    return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);}/******************************************************************************* * * FUNCTION:    AcpiRsGetPciRoutingTableLength * * PARAMETERS:  PackageObject           - Pointer to the package object *              BufferSizeNeeded        - UINT32 pointer of the size buffer *                                        needed to properly return the *                                        parsed data * * RETURN:      Status * * DESCRIPTION: Given a package representing a PCI routing table, this *              calculates the size of the corresponding linked list of *              descriptions. * ******************************************************************************/ACPI_STATUSAcpiRsGetPciRoutingTableLength (    ACPI_OPERAND_OBJECT     *PackageObject,    ACPI_SIZE               *BufferSizeNeeded){    UINT32                  NumberOfElements;    ACPI_SIZE               TempSizeNeeded = 0;    ACPI_OPERAND_OBJECT     **TopObjectList;    UINT32                  Index;    ACPI_OPERAND_OBJECT     *PackageElement;    ACPI_OPERAND_OBJECT     **SubObjectList;    BOOLEAN                 NameFound;    UINT32                  TableIndex;    ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);    NumberOfElements = PackageObject->Package.Count;    /*     * Calculate the size of the return buffer.     * The base size is the number of elements * the sizes of the     * structures.  Additional space for the strings is added below.     * The minus one is to subtract the size of the UINT8 Source[1]     * member because it is added below.     *     * But each PRT_ENTRY structure has a pointer to a string and     * the size of that string must be found.     */    TopObjectList = PackageObject->Package.Elements;    for (Index = 0; Index < NumberOfElements; Index++)    {        /* Dereference the sub-package */        PackageElement = *TopObjectList;        /*         * The SubObjectList will now point to an array of the         * four IRQ elements: Address, Pin, Source and SourceIndex         */        SubObjectList = PackageElement->Package.Elements;        /* Scan the IrqTableElements for the Source Name String */        NameFound = FALSE;        for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++)        {            if (*SubObjectList && /* Null object allowed */                ((ACPI_TYPE_STRING ==                    ACPI_GET_OBJECT_TYPE (*SubObjectList)) ||                ((ACPI_TYPE_LOCAL_REFERENCE ==                    ACPI_GET_OBJECT_TYPE (*SubObjectList)) &&                    ((*SubObjectList)->Reference.Opcode ==                        AML_INT_NAMEPATH_OP))))            {                NameFound = TRUE;            }            else            {                /* Look at the next element */                SubObjectList++;            }        }        TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);        /* Was a String type found? */        if (NameFound)        {            if (ACPI_GET_OBJECT_TYPE (*SubObjectList) == ACPI_TYPE_STRING)            {                /*                 * The length String.Length field does not include the                 * terminating NULL, add 1                 */                TempSizeNeeded += ((ACPI_SIZE)                    (*SubObjectList)->String.Length + 1);            }            else            {                TempSizeNeeded += AcpiNsGetPathnameLength (                                    (*SubObjectList)->Reference.Node);            }        }        else        {            /*             * If no name was found, then this is a NULL, which is             * translated as a UINT32 zero.             */            TempSizeNeeded += sizeof (UINT32);        }        /* Round up the size since each element must be aligned */        TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);        /* Point to the next ACPI_OPERAND_OBJECT */        TopObjectList++;    }    /*     * Add an extra element to the end of the list, essentially a     * NULL terminator     */    *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);    return_ACPI_STATUS (AE_OK);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -