📄 tbconvrt.c
字号:
/****************************************************************************** * * Module Name: tbconvrt - ACPI Table conversion utilities * $Revision: 28 $ * *****************************************************************************//* * Copyright (C) 2000, 2001 R. Byron Moore * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include "acpi.h"#include "achware.h"#include "actables.h"#include "actbl.h"#define _COMPONENT ACPI_TABLES MODULE_NAME ("tbconvrt")/******************************************************************************* * * FUNCTION: Acpi_tb_get_table_count * * PARAMETERS: * * RETURN: * * DESCRIPTION: Calculate the number of tables * ******************************************************************************/u32acpi_tb_get_table_count ( RSDP_DESCRIPTOR *RSDP, acpi_table_header *RSDT){ u32 pointer_size; FUNCTION_ENTRY ();#ifndef _IA64 if (RSDP->revision < 2) { pointer_size = sizeof (u32); } else#endif { pointer_size = sizeof (u64); } /* * Determine the number of tables pointed to by the RSDT/XSDT. * This is defined by the ACPI Specification to be the number of * pointers contained within the RSDT/XSDT. The size of the pointers * is architecture-dependent. */ return ((RSDT->length - sizeof (acpi_table_header)) / pointer_size);}/******************************************************************************* * * FUNCTION: Acpi_tb_convert_to_xsdt * * PARAMETERS: * * RETURN: * * DESCRIPTION: Convert an RSDT to an XSDT (internal common format) * ******************************************************************************/acpi_statusacpi_tb_convert_to_xsdt ( acpi_table_desc *table_info, u32 *number_of_tables){ u32 table_size; u32 i; xsdt_descriptor *new_table; FUNCTION_ENTRY (); *number_of_tables = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info->pointer); /* Compute size of the converted XSDT */ table_size = (*number_of_tables * sizeof (u64)) + sizeof (acpi_table_header); /* Allocate an XSDT */ new_table = ACPI_MEM_CALLOCATE (table_size); if (!new_table) { return (AE_NO_MEMORY); } /* Copy the header and set the length */ MEMCPY (new_table, table_info->pointer, sizeof (acpi_table_header)); new_table->header.length = table_size; /* Copy the table pointers */ for (i = 0; i < *number_of_tables; i++) { if (acpi_gbl_RSDP->revision < 2) {#ifdef _IA64 new_table->table_offset_entry[i] = ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i];#else ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]);#endif } else { new_table->table_offset_entry[i] = ((xsdt_descriptor *) table_info->pointer)->table_offset_entry[i]; } } /* Delete the original table (either mapped or in a buffer) */ acpi_tb_delete_single_table (table_info); /* Point the table descriptor to the new table */ table_info->pointer = (acpi_table_header *) new_table; table_info->base_pointer = (acpi_table_header *) new_table; table_info->length = table_size; table_info->allocation = ACPI_MEM_ALLOCATED; return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_tb_convert_table_fadt * * PARAMETERS: * * RETURN: * * DESCRIPTION: * Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply * copied to the intermediate FADT. The ACPI CA software uses this * intermediate FADT. Thus a significant amount of special #ifdef * type codeing is saved. This intermediate FADT will need to be * freed at some point. * ******************************************************************************/acpi_statusacpi_tb_convert_table_fadt (void){#ifdef _IA64 fadt_descriptor_rev071 *FADT71; u8 pm1_address_space; u8 pm2_address_space; u8 pm_timer_address_space; u8 gpe0address_space; u8 gpe1_address_space;#else fadt_descriptor_rev1 *FADT1;#endif fadt_descriptor_rev2 *FADT2; acpi_table_desc *table_desc; FUNCTION_TRACE ("Tb_convert_table_fadt"); /* Acpi_gbl_FADT is valid */ /* Allocate and zero the 2.0 buffer */ FADT2 = ACPI_MEM_CALLOCATE (sizeof (fadt_descriptor_rev2)); if (FADT2 == NULL) { return_ACPI_STATUS (AE_NO_MEMORY); } /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */ /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */ if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) { /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ *FADT2 = *((fadt_descriptor_rev2*) acpi_gbl_FADT); } else {#ifdef _IA64 /* * For the 64-bit case only, a revision ID less than V2.0 means the * tables are the 0.71 extensions */ /* The BIOS stored FADT should agree with Revision 0.71 */ FADT71 = (fadt_descriptor_rev071 *) acpi_gbl_FADT; /* Copy the table header*/ FADT2->header = FADT71->header; /* Copy the common fields */ FADT2->sci_int = FADT71->sci_int; FADT2->acpi_enable = FADT71->acpi_enable; FADT2->acpi_disable = FADT71->acpi_disable; FADT2->S4bios_req = FADT71->S4bios_req; FADT2->plvl2_lat = FADT71->plvl2_lat; FADT2->plvl3_lat = FADT71->plvl3_lat; FADT2->day_alrm = FADT71->day_alrm; FADT2->mon_alrm = FADT71->mon_alrm; FADT2->century = FADT71->century; FADT2->gpe1_base = FADT71->gpe1_base; /* * We still use the block length registers even though * the GAS structure should obsolete them. This is because * these registers are byte lengths versus the GAS which * contains a bit width */ FADT2->pm1_evt_len = FADT71->pm1_evt_len; FADT2->pm1_cnt_len = FADT71->pm1_cnt_len; FADT2->pm2_cnt_len = FADT71->pm2_cnt_len; FADT2->pm_tm_len = FADT71->pm_tm_len; FADT2->gpe0blk_len = FADT71->gpe0blk_len; FADT2->gpe1_blk_len = FADT71->gpe1_blk_len; FADT2->gpe1_base = FADT71->gpe1_base; /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/ FADT2->wb_invd = FADT71->flush_cash; FADT2->proc_c1 = FADT71->proc_c1; FADT2->plvl2_up = FADT71->plvl2_up; FADT2->pwr_button = FADT71->pwr_button; FADT2->sleep_button = FADT71->sleep_button; FADT2->fixed_rTC = FADT71->fixed_rTC; FADT2->rtcs4 = FADT71->rtcs4; FADT2->tmr_val_ext = FADT71->tmr_val_ext; FADT2->dock_cap = FADT71->dock_cap; /* We should not use these next two addresses */ /* Since our buffer is pre-zeroed nothing to do for */ /* the next three data items in the structure */ /* FADT2->Firmware_ctrl = 0; */ /* FADT2->Dsdt = 0; */ /* System Interrupt Model isn't used in ACPI 2.0*/ /* FADT2->Reserved1 = 0; */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -