📄 tbget.c
字号:
* ******************************************************************************/acpi_statusacpi_tb_verify_rsdp ( ACPI_PHYSICAL_ADDRESS rsdp_physical_address){ acpi_table_desc table_info; acpi_status status; u8 *table_ptr; FUNCTION_TRACE ("Tb_verify_rsdp"); /* * Obtain access to the RSDP structure */ status = acpi_os_map_memory (rsdp_physical_address, sizeof (RSDP_DESCRIPTOR), (void **) &table_ptr); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* * The signature and checksum must both be correct */ if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ status = AE_BAD_SIGNATURE; goto cleanup; } if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) { /* Nope, BAD Checksum */ status = AE_BAD_CHECKSUM; goto cleanup; } /* TBD: Check extended checksum if table version >= 2 */ /* The RSDP supplied is OK */ table_info.pointer = (acpi_table_header *) table_ptr; table_info.length = sizeof (RSDP_DESCRIPTOR); table_info.allocation = ACPI_MEM_MAPPED; table_info.base_pointer = table_ptr; /* Save the table pointers and allocation info */ status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); if (ACPI_FAILURE (status)) { goto cleanup; } /* Save the RSDP in a global for easy access */ acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer; return_ACPI_STATUS (status); /* Error exit */cleanup: acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR)); return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION: Acpi_tb_get_rsdt_address * * PARAMETERS: None * * RETURN: RSDT physical address * * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the * version of the RSDP * ******************************************************************************/ACPI_PHYSICAL_ADDRESSacpi_tb_get_rsdt_address (void){ ACPI_PHYSICAL_ADDRESS physical_address; FUNCTION_ENTRY (); /* * For RSDP revision 0 or 1, we use the RSDT. * For RSDP revision 2 (and above), we use the XSDT */ if (acpi_gbl_RSDP->revision < 2) {#ifdef _IA64 /* 0.71 RSDP has 64bit Rsdt address field */ physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address;#else physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address;#endif } else { physical_address = (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address); } return (physical_address);}/******************************************************************************* * * FUNCTION: Acpi_tb_validate_rsdt * * PARAMETERS: Table_ptr - Addressable pointer to the RSDT. * * RETURN: Status * * DESCRIPTION: Validate signature for the RSDT or XSDT * ******************************************************************************/acpi_statusacpi_tb_validate_rsdt ( acpi_table_header *table_ptr){ u32 no_match; PROC_NAME ("Tb_validate_rsdt"); /* * For RSDP revision 0 or 1, we use the RSDT. * For RSDP revision 2 (and above), we use the XSDT */ if (acpi_gbl_RSDP->revision < 2) { no_match = STRNCMP ((char *) table_ptr, RSDT_SIG, sizeof (RSDT_SIG) -1); } else { no_match = STRNCMP ((char *) table_ptr, XSDT_SIG, sizeof (XSDT_SIG) -1); } if (no_match) { /* Invalid RSDT or XSDT signature */ REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); DUMP_BUFFER (acpi_gbl_RSDP, 20); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "RSDT/XSDT signature at %X is invalid\n", acpi_gbl_RSDP->rsdt_physical_address)); return (AE_BAD_SIGNATURE); } return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_tb_get_table_pointer * * PARAMETERS: Physical_address - Address from RSDT * Flags - virtual or physical addressing * Table_ptr - Addressable address (output) * * RETURN: Status * * DESCRIPTION: Create an addressable pointer to an ACPI table * ******************************************************************************/acpi_statusacpi_tb_get_table_pointer ( ACPI_PHYSICAL_ADDRESS physical_address, u32 flags, u32 *size, acpi_table_header **table_ptr){ acpi_status status; FUNCTION_ENTRY (); if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { *size = SIZE_IN_HEADER; status = acpi_tb_map_acpi_table (physical_address, size, table_ptr); } else { *size = 0; *table_ptr = (acpi_table_header *) (ACPI_TBLPTR) physical_address; status = AE_OK; } return (status);}/******************************************************************************* * * FUNCTION: Acpi_tb_get_table_rsdt * * PARAMETERS: Number_of_tables - Where the table count is placed * * RETURN: Status * * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) * ******************************************************************************/acpi_statusacpi_tb_get_table_rsdt ( u32 *number_of_tables){ acpi_table_desc table_info; acpi_status status; ACPI_PHYSICAL_ADDRESS physical_address; FUNCTION_TRACE ("Tb_get_table_rsdt"); /* * Get the RSDT from the RSDP */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", acpi_gbl_RSDP, HIDWORD(acpi_gbl_RSDP->rsdt_physical_address), LODWORD(acpi_gbl_RSDP->rsdt_physical_address))); physical_address = acpi_tb_get_rsdt_address (); /* Get the RSDT/XSDT */ status = acpi_tb_get_table (physical_address, NULL, &table_info); if (ACPI_FAILURE (status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT, %s\n", acpi_format_exception (status))); return_ACPI_STATUS (status); } /* Check the RSDT or XSDT signature */ status = acpi_tb_validate_rsdt (table_info.pointer); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* * Valid RSDT signature, verify the checksum. If it fails, just * print a warning and ignore it. */ status = acpi_tb_verify_table_checksum (table_info.pointer); /* Convert and/or copy to an XSDT structure */ status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Save the table pointers and allocation info */ status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } acpi_gbl_XSDT = (xsdt_descriptor *) table_info.pointer; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); return_ACPI_STATUS (status);}/****************************************************************************** * * FUNCTION: Acpi_tb_get_table_facs * * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from * buffer rather than searching memory * *Table_info - Where the table info is returned * * RETURN: Status * * DESCRIPTION: Returns a pointer to the FACS as defined in FADT. This * function assumes the global variable FADT has been * correctly initialized. The value of FADT->Firmware_ctrl * into a far pointer which is returned. * *****************************************************************************/acpi_statusacpi_tb_get_table_facs ( acpi_table_header *buffer_ptr, acpi_table_desc *table_info){ acpi_table_header *table_ptr = NULL; u32 size; u8 allocation; acpi_status status = AE_OK; FUNCTION_TRACE ("Tb_get_table_facs"); /* Must have a valid FADT pointer */ if (!acpi_gbl_FADT) { return_ACPI_STATUS (AE_NO_ACPI_TABLES); } size = sizeof (FACS_DESCRIPTOR); if (buffer_ptr) { /* * Getting table from a file -- allocate a buffer and * read the table. */ table_ptr = ACPI_MEM_ALLOCATE (size); if(!table_ptr) { return_ACPI_STATUS (AE_NO_MEMORY); } MEMCPY (table_ptr, buffer_ptr, size); /* Save allocation type */ allocation = ACPI_MEM_ALLOCATED; } else { /* Just map the physical memory to our address space */ status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl), &size, &table_ptr); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } /* Save allocation type */ allocation = ACPI_MEM_MAPPED; } /* Return values */ table_info->pointer = table_ptr; table_info->length = size; table_info->allocation = allocation; table_info->base_pointer = table_ptr; return_ACPI_STATUS (status);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -