utresrc.c

来自「linux 内核源代码」· C语言 代码 · 共 616 行 · 第 1/2 页

C
616
字号
/******************************************************************************* * * Module Name: utresrc - Resource managment utilities * ******************************************************************************//* * Copyright (C) 2000 - 2007, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions, and the following disclaimer, *    without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer *    substantially similar to the "NO WARRANTY" disclaimer below *    ("Disclaimer") and any redistribution must be conditioned upon *    including a substantially similar Disclaimer requirement for further *    binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names *    of any contributors may be used to endorse or promote products derived *    from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. */#include <acpi/acpi.h>#include <acpi/amlresrc.h>#define _COMPONENT          ACPI_UTILITIESACPI_MODULE_NAME("utresrc")#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)/* * Strings used to decode resource descriptors. * Used by both the disasssembler and the debugger resource dump routines */const char *acpi_gbl_bm_decode[] = {	"NotBusMaster",	"BusMaster"};const char *acpi_gbl_config_decode[] = {	"0 - Good Configuration",	"1 - Acceptable Configuration",	"2 - Suboptimal Configuration",	"3 - ***Invalid Configuration***",};const char *acpi_gbl_consume_decode[] = {	"ResourceProducer",	"ResourceConsumer"};const char *acpi_gbl_dec_decode[] = {	"PosDecode",	"SubDecode"};const char *acpi_gbl_he_decode[] = {	"Level",	"Edge"};const char *acpi_gbl_io_decode[] = {	"Decode10",	"Decode16"};const char *acpi_gbl_ll_decode[] = {	"ActiveHigh",	"ActiveLow"};const char *acpi_gbl_max_decode[] = {	"MaxNotFixed",	"MaxFixed"};const char *acpi_gbl_mem_decode[] = {	"NonCacheable",	"Cacheable",	"WriteCombining",	"Prefetchable"};const char *acpi_gbl_min_decode[] = {	"MinNotFixed",	"MinFixed"};const char *acpi_gbl_mtp_decode[] = {	"AddressRangeMemory",	"AddressRangeReserved",	"AddressRangeACPI",	"AddressRangeNVS"};const char *acpi_gbl_rng_decode[] = {	"InvalidRanges",	"NonISAOnlyRanges",	"ISAOnlyRanges",	"EntireRange"};const char *acpi_gbl_rw_decode[] = {	"ReadOnly",	"ReadWrite"};const char *acpi_gbl_shr_decode[] = {	"Exclusive",	"Shared"};const char *acpi_gbl_siz_decode[] = {	"Transfer8",	"Transfer8_16",	"Transfer16",	"InvalidSize"};const char *acpi_gbl_trs_decode[] = {	"DenseTranslation",	"SparseTranslation"};const char *acpi_gbl_ttp_decode[] = {	"TypeStatic",	"TypeTranslation"};const char *acpi_gbl_typ_decode[] = {	"Compatibility",	"TypeA",	"TypeB",	"TypeF"};#endif/* * Base sizes of the raw AML resource descriptors, indexed by resource type. * Zero indicates a reserved (and therefore invalid) resource type. */const u8 acpi_gbl_resource_aml_sizes[] = {	/* Small descriptors */	0,	0,	0,	0,	ACPI_AML_SIZE_SMALL(struct aml_resource_irq),	ACPI_AML_SIZE_SMALL(struct aml_resource_dma),	ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent),	ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),	ACPI_AML_SIZE_SMALL(struct aml_resource_io),	ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),	0,	0,	0,	0,	ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small),	ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag),	/* Large descriptors */	0,	ACPI_AML_SIZE_LARGE(struct aml_resource_memory24),	ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register),	0,	ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large),	ACPI_AML_SIZE_LARGE(struct aml_resource_memory32),	ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32),	ACPI_AML_SIZE_LARGE(struct aml_resource_address32),	ACPI_AML_SIZE_LARGE(struct aml_resource_address16),	ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),	ACPI_AML_SIZE_LARGE(struct aml_resource_address64),	ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)};/* * Resource types, used to validate the resource length field. * The length of fixed-length types must match exactly, variable * lengths must meet the minimum required length, etc. * Zero indicates a reserved (and therefore invalid) resource type. */static const u8 acpi_gbl_resource_types[] = {	/* Small descriptors */	0,	0,	0,	0,	ACPI_SMALL_VARIABLE_LENGTH,	ACPI_FIXED_LENGTH,	ACPI_SMALL_VARIABLE_LENGTH,	ACPI_FIXED_LENGTH,	ACPI_FIXED_LENGTH,	ACPI_FIXED_LENGTH,	0,	0,	0,	0,	ACPI_VARIABLE_LENGTH,	ACPI_FIXED_LENGTH,	/* Large descriptors */	0,	ACPI_FIXED_LENGTH,	ACPI_FIXED_LENGTH,	0,	ACPI_VARIABLE_LENGTH,	ACPI_FIXED_LENGTH,	ACPI_FIXED_LENGTH,	ACPI_VARIABLE_LENGTH,	ACPI_VARIABLE_LENGTH,	ACPI_VARIABLE_LENGTH,	ACPI_VARIABLE_LENGTH,	ACPI_FIXED_LENGTH};/******************************************************************************* * * FUNCTION:    acpi_ut_walk_aml_resources * * PARAMETERS:  Aml             - Pointer to the raw AML resource template *              aml_length      - Length of the entire template *              user_function   - Called once for each descriptor found. If *                                NULL, a pointer to the end_tag is returned *              Context         - Passed to user_function * * RETURN:      Status * * DESCRIPTION: Walk a raw AML resource list(buffer). User function called *              once for each resource found. * ******************************************************************************/acpi_statusacpi_ut_walk_aml_resources(u8 * aml,			   acpi_size aml_length,			   acpi_walk_aml_callback user_function, void **context){	acpi_status status;	u8 *end_aml;	u8 resource_index;	u32 length;	u32 offset = 0;	ACPI_FUNCTION_TRACE(ut_walk_aml_resources);	/* The absolute minimum resource template is one end_tag descriptor */	if (aml_length < sizeof(struct aml_resource_end_tag)) {		return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);	}	/* Point to the end of the resource template buffer */	end_aml = aml + aml_length;	/* Walk the byte list, abort on any invalid descriptor type or length */	while (aml < end_aml) {		/* Validate the Resource Type and Resource Length */		status = acpi_ut_validate_resource(aml, &resource_index);		if (ACPI_FAILURE(status)) {			return_ACPI_STATUS(status);		}		/* Get the length of this descriptor */		length = acpi_ut_get_descriptor_length(aml);		/* Invoke the user function */		if (user_function) {			status =			    user_function(aml, length, offset, resource_index,					  context);			if (ACPI_FAILURE(status)) {				return (status);			}		}		/* An end_tag descriptor terminates this resource template */		if (acpi_ut_get_resource_type(aml) ==

⌨️ 快捷键说明

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