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

📄 tbutils.c

📁 xen虚拟机源代码安装包
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * * Module Name: tbutils   - table utilities * *****************************************************************************//* * Copyright (C) 2000 - 2008, 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: * 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 <xen/config.h>#include <xen/init.h>#include <acpi/acpi.h>#include <acpi/actables.h>#define _COMPONENT          ACPI_TABLESACPI_MODULE_NAME("tbutils")/* Local prototypes */static acpi_physical_addressacpi_tb_get_root_table_entry(u8 * table_entry,			     acpi_native_uint table_entry_size);/******************************************************************************* * * FUNCTION:    acpi_tb_check_xsdt * * PARAMETERS:  address                    - Pointer to the XSDT * * RETURN:      status *		AE_OK - XSDT is okay *		AE_NO_MEMORY - can't map XSDT *		AE_INVALID_TABLE_LENGTH - invalid table length *		AE_NULL_ENTRY - XSDT has NULL entry * * DESCRIPTION: validate XSDT******************************************************************************/static acpi_statusacpi_tb_check_xsdt(acpi_physical_address address){	struct acpi_table_header *table;	u32 length;	u64 xsdt_entry_address;	u8 *table_entry;	u32 table_count;	int i;	table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));	if (!table)		return AE_NO_MEMORY;	length = table->length;	acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));	if (length < sizeof(struct acpi_table_header))		return AE_INVALID_TABLE_LENGTH;	table = acpi_os_map_memory(address, length);	if (!table)		return AE_NO_MEMORY;	/* Calculate the number of tables described in XSDT */	table_count =		(u32) ((table->length -		sizeof(struct acpi_table_header)) / sizeof(u64));	table_entry =		ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);	for (i = 0; i < table_count; i++) {		ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry);		if (!xsdt_entry_address) {			/* XSDT has NULL entry */			break;		}		table_entry += sizeof(u64);	}	acpi_os_unmap_memory(table, length);	if (i < table_count)		return AE_NULL_ENTRY;	else		return AE_OK;}/******************************************************************************* * * FUNCTION:    acpi_tb_tables_loaded * * PARAMETERS:  None * * RETURN:      TRUE if required ACPI tables are loaded * * DESCRIPTION: Determine if the minimum required ACPI tables are present *              (FADT, FACS, DSDT) * ******************************************************************************/u8 acpi_tb_tables_loaded(void){	if (acpi_gbl_root_table_list.count >= 3) {		return (TRUE);	}	return (FALSE);}/******************************************************************************* * * FUNCTION:    acpi_tb_print_table_header * * PARAMETERS:  Address             - Table physical address *              Header              - Table header * * RETURN:      None * * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. * ******************************************************************************/voidacpi_tb_print_table_header(acpi_physical_address address,			   struct acpi_table_header *header){	if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {		/* FACS only has signature and length fields of common table header */		ACPI_INFO((AE_INFO, "%4.4s %08lX, %04X",			   header->signature, (unsigned long)address,			   header->length));	} else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {		/* RSDP has no common fields */		ACPI_INFO((AE_INFO, "RSDP %08lX, %04X (r%d %6.6s)",			   (unsigned long)address,			   (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->			    revision >			    0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,					       header)->length : 20,			   ACPI_CAST_PTR(struct acpi_table_rsdp,					 header)->revision,			   ACPI_CAST_PTR(struct acpi_table_rsdp,					 header)->oem_id));	} else {		/* Standard ACPI table with full common header */		ACPI_INFO((AE_INFO,			   "%4.4s %08lX, %04X (r%d %6.6s %8.8s %8X %4.4s %8X)",			   header->signature, (unsigned long)address,			   header->length, header->revision, header->oem_id,			   header->oem_table_id, header->oem_revision,			   header->asl_compiler_id,			   header->asl_compiler_revision));	}}/******************************************************************************* * * FUNCTION:    acpi_tb_validate_checksum * * PARAMETERS:  Table               - ACPI table to verify *              Length              - Length of entire table * * RETURN:      Status * * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns *              exception on bad checksum. * ******************************************************************************/acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length){	u8 checksum;	/* Compute the checksum on the table */	checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);	/* Checksum ok? (should be zero) */	if (checksum) {		ACPI_WARNING((AE_INFO,			      "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X",			      table->signature, table->checksum,			      (u8) (table->checksum - checksum)));#if (ACPI_CHECKSUM_ABORT)		return (AE_BAD_CHECKSUM);#endif	}	return (AE_OK);}/******************************************************************************* * * FUNCTION:    acpi_tb_checksum * * PARAMETERS:  Buffer          - Pointer to memory region to be checked *              Length          - Length of this memory region * * RETURN:      Checksum (u8) * * DESCRIPTION: Calculates circular checksum of memory region. * ******************************************************************************/u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length){	u8 sum = 0;	u8 *end = buffer + length;	while (buffer < end) {		sum = (u8) (sum + *(buffer++));	}	return sum;}/******************************************************************************* * * FUNCTION:    acpi_tb_install_table * * PARAMETERS:  Address                 - Physical address of DSDT or FACS *              Flags                   - Flags *              Signature               - Table signature, NULL if no need to *                                        match *              table_index             - Index into root table array * * RETURN:      None * * DESCRIPTION: Install an ACPI table into the global data structure. * ******************************************************************************/voidacpi_tb_install_table(acpi_physical_address address,		      u8 flags, char *signature, acpi_native_uint table_index){	struct acpi_table_header *table;	if (!address) {		ACPI_ERROR((AE_INFO,			    "Null physical address for ACPI table [%s]",			    signature));		return;

⌨️ 快捷键说明

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