Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Module Name: tbdata - Table manager data structure functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include "actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #define _COMPONENT          ACPI_TABLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) ACPI_MODULE_NAME("tbdata")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) acpi_tb_check_duplication(struct acpi_table_desc *table_desc, u32 *table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28)  * FUNCTION:    acpi_tb_compare_tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30)  * PARAMETERS:  table_desc          - Table 1 descriptor to be compared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31)  *              table_index         - Index of table 2 to be compared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33)  * RETURN:      TRUE if both tables are identical.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35)  * DESCRIPTION: This function compares a table with another table that has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36)  *              already been installed in the root table list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) static u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 	u8 is_identical;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 	struct acpi_table_header *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 	u32 table_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 	u8 table_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 	    acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 				  &table, &table_length, &table_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 		return (FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	 * Check for a table match on the entire table length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	 * not just the header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	is_identical = (u8)((table_desc->length != table_length ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 			     memcmp(table_desc->pointer, table, table_length)) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 			    FALSE : TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	/* Release the acquired table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 	acpi_tb_release_table(table, table_length, table_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	return (is_identical);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72)  * FUNCTION:    acpi_tb_init_table_descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74)  * PARAMETERS:  table_desc              - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75)  *              address                 - Physical address of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76)  *              flags                   - Allocation flags of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77)  *              table                   - Pointer to the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81)  * DESCRIPTION: Initialize a new table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 			      acpi_physical_address address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 			      u8 flags, struct acpi_table_header *table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	 * Initialize the table descriptor. Set the pointer to NULL, since the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	 * table is not fully mapped at this time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	memset(table_desc, 0, sizeof(struct acpi_table_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	table_desc->address = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	table_desc->length = table->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	table_desc->flags = flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104)  * FUNCTION:    acpi_tb_acquire_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106)  * PARAMETERS:  table_desc          - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107)  *              table_ptr           - Where table is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108)  *              table_length        - Where table length is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109)  *              table_flags         - Where table allocation flags are returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113)  * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114)  *              maintained in the acpi_gbl_root_table_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 		      struct acpi_table_header **table_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 		      u32 *table_length, u8 *table_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	struct acpi_table_header *table = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 		table =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 		    acpi_os_map_memory(table_desc->address, table_desc->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 		table = ACPI_CAST_PTR(struct acpi_table_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 				      ACPI_PHYSADDR_TO_PTR(table_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 							   address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	/* Table is not valid yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	if (!table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 		return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	/* Fill the return values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	*table_ptr = table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	*table_length = table_desc->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	*table_flags = table_desc->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161)  * FUNCTION:    acpi_tb_release_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163)  * PARAMETERS:  table               - Pointer for the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164)  *              table_length        - Length for the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165)  *              table_flags         - Allocation flags for the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169)  * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) acpi_tb_release_table(struct acpi_table_header *table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 		      u32 table_length, u8 table_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	switch (table_flags & ACPI_TABLE_ORIGIN_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 		acpi_os_unmap_memory(table, table_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194)  * FUNCTION:    acpi_tb_acquire_temp_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196)  * PARAMETERS:  table_desc          - Table descriptor to be acquired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197)  *              address             - Address of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198)  *              flags               - Allocation flags of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202)  * DESCRIPTION: This function validates the table header to obtain the length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203)  *              of a table and fills the table descriptor to make its state as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204)  *              "INSTALLED". Such a table descriptor is only used for verified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205)  *              installation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 			   acpi_physical_address address, u8 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	struct acpi_table_header *table_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	switch (flags & ACPI_TABLE_ORIGIN_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 		/* Get the length of the full table from the header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 		table_header =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 		    acpi_os_map_memory(address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 				       sizeof(struct acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 		if (!table_header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 			return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 		acpi_tb_init_table_descriptor(table_desc, address, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 					      table_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 		acpi_os_unmap_memory(table_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 				     sizeof(struct acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		table_header = ACPI_CAST_PTR(struct acpi_table_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 					     ACPI_PHYSADDR_TO_PTR(address));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 		if (!table_header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 			return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		acpi_tb_init_table_descriptor(table_desc, address, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 					      table_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	/* Table is not valid yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258)  * FUNCTION:    acpi_tb_release_temp_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260)  * PARAMETERS:  table_desc          - Table descriptor to be released
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264)  * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	 * Note that the .Address is maintained by the callers of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	 * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	 * where .Address will be freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 	acpi_tb_invalidate_table(table_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281)  * FUNCTION:    acpi_tb_validate_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283)  * PARAMETERS:  table_desc          - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287)  * DESCRIPTION: This function is called to validate the table, the returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288)  *              table descriptor is in "VALIDATED" state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	ACPI_FUNCTION_TRACE(tb_validate_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	/* Validate the table if necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	if (!table_desc->pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 		status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 					       &table_desc->length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 					       &table_desc->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 		if (!table_desc->pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 			status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314)  * FUNCTION:    acpi_tb_invalidate_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316)  * PARAMETERS:  table_desc          - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320)  * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321)  *              acpi_tb_validate_table().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	ACPI_FUNCTION_TRACE(tb_invalidate_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	/* Table must be validated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	if (!table_desc->pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 		return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	acpi_tb_release_table(table_desc->pointer, table_desc->length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 			      table_desc->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	table_desc->pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345)  * FUNCTION:    acpi_tb_validate_temp_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347)  * PARAMETERS:  table_desc          - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351)  * DESCRIPTION: This function is called to validate the table, the returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352)  *              table descriptor is in "VALIDATED" state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	if (!table_desc->pointer && !acpi_gbl_enable_table_validation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		 * Only validates the header of the table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		 * Note that Length contains the size of the mapping after invoking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 		 * this work around, this value is required by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 		 * acpi_tb_release_temp_table().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 		 * We can do this because in acpi_init_table_descriptor(), the Length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		 * field of the installed descriptor is filled with the actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 		 * table length obtaining from the table header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 		table_desc->length = sizeof(struct acpi_table_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	return (acpi_tb_validate_table(table_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377)  * FUNCTION:    acpi_tb_check_duplication
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379)  * PARAMETERS:  table_desc          - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380)  *              table_index         - Where the table index is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384)  * DESCRIPTION: Avoid installing duplicated tables. However table override and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385)  *              user aided dynamic table load is allowed, thus comparing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386)  *              address of the table is not sufficient, and checking the entire
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387)  *              table content is required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) acpi_tb_check_duplication(struct acpi_table_desc *table_desc, u32 *table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	ACPI_FUNCTION_TRACE(tb_check_duplication);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	/* Check if table is already registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 		/* Do not compare with unverified tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 		if (!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 		    (acpi_gbl_root_table_list.tables[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		     flags & ACPI_TABLE_IS_VERIFIED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		 * Check for a table match on the entire table length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		 * not just the header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		if (!acpi_tb_compare_tables(table_desc, i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		 * Note: the current mechanism does not unregister a table if it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		 * dynamically unloaded. The related namespace entries are deleted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 		 * but the table remains in the root table list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		 * The assumption here is that the number of different tables that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		 * will be loaded is actually small, and there is minimal overhead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		 * in just keeping the table in case it is needed again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 		 * If this assumption changes in the future (perhaps on large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		 * machines with many table load/unload operations), tables will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 		 * need to be unregistered when they are unloaded, and slots in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 		 * root table list should be reused when empty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		if (acpi_gbl_root_table_list.tables[i].flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		    ACPI_TABLE_IS_LOADED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 			/* Table is still loaded, this is an error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 			return_ACPI_STATUS(AE_ALREADY_EXISTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 			*table_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 			return_ACPI_STATUS(AE_CTRL_TERMINATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	/* Indicate no duplication to the caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451)  * FUNCTION:    acpi_tb_verify_temp_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453)  * PARAMETERS:  table_desc          - Table descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454)  *              signature           - Table signature to verify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455)  *              table_index         - Where the table index is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459)  * DESCRIPTION: This function is called to validate and verify the table, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460)  *              returned table descriptor is in "VALIDATED" state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461)  *              Note that 'TableIndex' is required to be set to !NULL to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462)  *              enable duplication check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 			  char *signature, u32 *table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	ACPI_FUNCTION_TRACE(tb_verify_temp_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	/* Validate the table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	status = acpi_tb_validate_temp_table(table_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	/* If a particular signature is expected (DSDT/FACS), it must match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	if (signature &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	    !ACPI_COMPARE_NAMESEG(&table_desc->signature, signature)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 		ACPI_BIOS_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 				 "Invalid signature 0x%X for ACPI table, expected [%s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 				 table_desc->signature.integer, signature));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 		status = AE_BAD_SIGNATURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 		goto invalidate_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	if (acpi_gbl_enable_table_validation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 		/* Verify the checksum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 		    acpi_tb_verify_checksum(table_desc->pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 					    table_desc->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 			ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 					"%4.4s 0x%8.8X%8.8X"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 					" Attempted table install failed",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 					acpi_ut_valid_nameseg(table_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 							      signature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 							      ascii) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 					table_desc->signature.ascii : "????",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 					ACPI_FORMAT_UINT64(table_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 							   address)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 			goto invalidate_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 		/* Avoid duplications */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		if (table_index) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 			    acpi_tb_check_duplication(table_desc, table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 				if (status != AE_CTRL_TERMINATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 					ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 							"%4.4s 0x%8.8X%8.8X"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 							" Table is already loaded",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 							acpi_ut_valid_nameseg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 							(table_desc->signature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 							 ascii) ? table_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 							signature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 							ascii : "????",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 							ACPI_FORMAT_UINT64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 							(table_desc->address)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 				goto invalidate_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		table_desc->flags |= ACPI_TABLE_IS_VERIFIED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) invalidate_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	acpi_tb_invalidate_table(table_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548)  * FUNCTION:    acpi_tb_resize_root_table_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554)  * DESCRIPTION: Expand the size of global table array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) acpi_status acpi_tb_resize_root_table_list(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	struct acpi_table_desc *tables;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	u32 table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	u32 current_table_count, max_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	/* allow_resize flag is a parameter to acpi_initialize_tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 			    "Resize of Root Table Array is not allowed"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 		return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	/* Increase the Table Array size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		table_count = acpi_gbl_root_table_list.max_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 		table_count = acpi_gbl_root_table_list.current_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	max_table_count = table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	tables = ACPI_ALLOCATE_ZEROED(((acpi_size)max_table_count) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 				      sizeof(struct acpi_table_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	if (!tables) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 			    "Could not allocate new root table array"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 		return_ACPI_STATUS(AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	/* Copy and free the previous table array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	current_table_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	if (acpi_gbl_root_table_list.tables) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 		for (i = 0; i < table_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 			if (acpi_gbl_root_table_list.tables[i].address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 				memcpy(tables + current_table_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 				       acpi_gbl_root_table_list.tables + i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 				       sizeof(struct acpi_table_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 				current_table_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 			ACPI_FREE(acpi_gbl_root_table_list.tables);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	acpi_gbl_root_table_list.tables = tables;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	acpi_gbl_root_table_list.max_table_count = max_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	acpi_gbl_root_table_list.current_table_count = current_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620)  * FUNCTION:    acpi_tb_get_next_table_descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622)  * PARAMETERS:  table_index         - Where table index is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623)  *              table_desc          - Where table descriptor is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625)  * RETURN:      Status and table index/descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627)  * DESCRIPTION: Allocate a new ACPI table entry to the global table list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) acpi_tb_get_next_table_descriptor(u32 *table_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 				  struct acpi_table_desc **table_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	/* Ensure that there is room for the table in the Root Table List */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 	if (acpi_gbl_root_table_list.current_table_count >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	    acpi_gbl_root_table_list.max_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 		status = acpi_tb_resize_root_table_list();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	i = acpi_gbl_root_table_list.current_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	acpi_gbl_root_table_list.current_table_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	if (table_index) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		*table_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	if (table_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 		*table_desc = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663)  * FUNCTION:    acpi_tb_terminate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669)  * DESCRIPTION: Delete all internal ACPI tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) void acpi_tb_terminate(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	ACPI_FUNCTION_TRACE(tb_terminate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	/* Delete the individual tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 		acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	 * Delete the root table array if allocated locally. Array cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	 * mapped, so we don't need to check for that flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 		ACPI_FREE(acpi_gbl_root_table_list.tables);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	acpi_gbl_root_table_list.tables = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	acpi_gbl_root_table_list.flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	acpi_gbl_root_table_list.current_table_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707)  * FUNCTION:    acpi_tb_delete_namespace_by_owner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709)  * PARAMETERS:  table_index         - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713)  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	acpi_owner_id owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	if (table_index >= acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 		/* The table index does not exist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 		(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		return_ACPI_STATUS(AE_NOT_EXIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	/* Get the owner ID for this table, used to delete namespace nodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	 * Need to acquire the namespace writer lock to prevent interference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	 * with any concurrent namespace walks. The interpreter must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	 * released during the deletion since the acquisition of the deletion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	 * lock may block, and also since the execution of a namespace walk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	 * must be allowed to use the interpreter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	acpi_ns_delete_namespace_by_owner(owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761)  * FUNCTION:    acpi_tb_allocate_owner_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763)  * PARAMETERS:  table_index         - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767)  * DESCRIPTION: Allocates owner_id in table_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) acpi_status acpi_tb_allocate_owner_id(u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	acpi_status status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	if (table_index < acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 		    acpi_ut_allocate_owner_id(&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 					      (acpi_gbl_root_table_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 					       tables[table_index].owner_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791)  * FUNCTION:    acpi_tb_release_owner_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793)  * PARAMETERS:  table_index         - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797)  * DESCRIPTION: Releases owner_id in table_desc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) acpi_status acpi_tb_release_owner_id(u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	acpi_status status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	ACPI_FUNCTION_TRACE(tb_release_owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	if (table_index < acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		acpi_ut_release_owner_id(&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 					 (acpi_gbl_root_table_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 					  tables[table_index].owner_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 		status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821)  * FUNCTION:    acpi_tb_get_owner_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823)  * PARAMETERS:  table_index         - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824)  *              owner_id            - Where the table owner_id is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828)  * DESCRIPTION: returns owner_id for the ACPI table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	acpi_status status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	ACPI_FUNCTION_TRACE(tb_get_owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	if (table_index < acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		*owner_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		    acpi_gbl_root_table_list.tables[table_index].owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 		status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851)  * FUNCTION:    acpi_tb_is_table_loaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853)  * PARAMETERS:  table_index         - Index into the root table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855)  * RETURN:      Table Loaded Flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) u8 acpi_tb_is_table_loaded(u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	u8 is_loaded = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	if (table_index < acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		is_loaded = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		    (acpi_gbl_root_table_list.tables[table_index].flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		     ACPI_TABLE_IS_LOADED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	return (is_loaded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876)  * FUNCTION:    acpi_tb_set_table_loaded_flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878)  * PARAMETERS:  table_index         - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879)  *              is_loaded           - TRUE if table is loaded, FALSE otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883)  * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	if (table_index < acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		if (is_loaded) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 			acpi_gbl_root_table_list.tables[table_index].flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 			    ACPI_TABLE_IS_LOADED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 			acpi_gbl_root_table_list.tables[table_index].flags &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 			    ~ACPI_TABLE_IS_LOADED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906)  * FUNCTION:    acpi_tb_load_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908)  * PARAMETERS:  table_index             - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909)  *              parent_node             - Where table index is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913)  * DESCRIPTION: Load an ACPI table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) acpi_tb_load_table(u32 table_index, struct acpi_namespace_node *parent_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	struct acpi_table_header *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	acpi_owner_id owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	ACPI_FUNCTION_TRACE(tb_load_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	 * Note: Now table is "INSTALLED", it must be validated before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	 * using.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	status = acpi_get_table_by_index(table_index, &table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	status = acpi_ns_load_table(table_index, parent_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	 * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	 * responsible for discovering any new wake GPEs by running _PRW methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	 * that may have been loaded by this table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	status = acpi_tb_get_owner_id(table_index, &owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		acpi_ev_update_gpes(owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	/* Invoke table handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	acpi_tb_notify_table(ACPI_TABLE_EVENT_LOAD, table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958)  * FUNCTION:    acpi_tb_install_and_load_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960)  * PARAMETERS:  address                 - Physical address of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961)  *              flags                   - Allocation flags of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962)  *              override                - Whether override should be performed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963)  *              table_index             - Where table index is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967)  * DESCRIPTION: Install and load an ACPI table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) acpi_tb_install_and_load_table(acpi_physical_address address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 			       u8 flags, u8 override, u32 *table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	ACPI_FUNCTION_TRACE(tb_install_and_load_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	/* Install the table and load it into the namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	status = acpi_tb_install_standard_table(address, flags, TRUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 						override, &i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	status = acpi_tb_load_table(i, acpi_gbl_root_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	*table_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) ACPI_EXPORT_SYMBOL(acpi_tb_install_and_load_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999)  * FUNCTION:    acpi_tb_unload_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)  * PARAMETERS:  table_index             - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005)  * DESCRIPTION: Unload an ACPI table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) acpi_status acpi_tb_unload_table(u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	struct acpi_table_header *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	ACPI_FUNCTION_TRACE(tb_unload_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	/* Ensure the table is still loaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	if (!acpi_tb_is_table_loaded(table_index)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		return_ACPI_STATUS(AE_NOT_EXIST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	/* Invoke table handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	status = acpi_get_table_by_index(table_index, &table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 		acpi_tb_notify_table(ACPI_TABLE_EVENT_UNLOAD, table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	/* Delete the portion of the namespace owned by this table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	status = acpi_tb_delete_namespace_by_owner(table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	(void)acpi_tb_release_owner_id(table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	acpi_tb_set_table_loaded_flag(table_index, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) ACPI_EXPORT_SYMBOL(acpi_tb_unload_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)  * FUNCTION:    acpi_tb_notify_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047)  * PARAMETERS:  event               - Table event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)  *              table               - Validated table pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052)  * DESCRIPTION: Notify a table event to the users.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) void acpi_tb_notify_table(u32 event, void *table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	/* Invoke table handler if present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	if (acpi_gbl_table_handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 		(void)acpi_gbl_table_handler(event, table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 					     acpi_gbl_table_handler_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) }