0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <acpi/acpi.h>
0011 #include "accommon.h"
0012 #include "actables.h"
0013
0014 #define _COMPONENT ACPI_TABLES
0015 ACPI_MODULE_NAME("tbinstal")
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 void
0034 acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
0035 u8 override, u32 *table_index)
0036 {
0037 u32 i;
0038 acpi_status status;
0039
0040 status = acpi_tb_get_next_table_descriptor(&i, NULL);
0041 if (ACPI_FAILURE(status)) {
0042 return;
0043 }
0044
0045
0046
0047
0048
0049
0050
0051
0052 if (override) {
0053 acpi_tb_override_table(new_table_desc);
0054 }
0055
0056 acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[i],
0057 new_table_desc->address,
0058 new_table_desc->flags,
0059 new_table_desc->pointer);
0060
0061 acpi_tb_print_table_header(new_table_desc->address,
0062 new_table_desc->pointer);
0063
0064
0065
0066 *table_index = i;
0067
0068
0069
0070 if (i == acpi_gbl_dsdt_index) {
0071 acpi_ut_set_integer_width(new_table_desc->pointer->revision);
0072 }
0073 }
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 acpi_status
0099 acpi_tb_install_standard_table(acpi_physical_address address,
0100 u8 flags,
0101 struct acpi_table_header *table,
0102 u8 reload, u8 override, u32 *table_index)
0103 {
0104 u32 i;
0105 acpi_status status = AE_OK;
0106 struct acpi_table_desc new_table_desc;
0107
0108 ACPI_FUNCTION_TRACE(tb_install_standard_table);
0109
0110
0111
0112 status =
0113 acpi_tb_acquire_temp_table(&new_table_desc, address, flags, table);
0114 if (ACPI_FAILURE(status)) {
0115 ACPI_ERROR((AE_INFO,
0116 "Could not acquire table length at %8.8X%8.8X",
0117 ACPI_FORMAT_UINT64(address)));
0118 return_ACPI_STATUS(status);
0119 }
0120
0121
0122
0123
0124
0125 if (!reload &&
0126 acpi_gbl_disable_ssdt_table_install &&
0127 ACPI_COMPARE_NAMESEG(&new_table_desc.signature, ACPI_SIG_SSDT)) {
0128 ACPI_INFO(("Ignoring installation of %4.4s at %8.8X%8.8X",
0129 new_table_desc.signature.ascii,
0130 ACPI_FORMAT_UINT64(address)));
0131 goto release_and_exit;
0132 }
0133
0134
0135
0136 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
0137
0138
0139
0140 status = acpi_tb_verify_temp_table(&new_table_desc, NULL, &i);
0141 if (ACPI_FAILURE(status)) {
0142 if (status == AE_CTRL_TERMINATE) {
0143
0144
0145
0146
0147
0148
0149
0150
0151 acpi_tb_uninstall_table(&new_table_desc);
0152 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
0153 *table_index = i;
0154 return_ACPI_STATUS(AE_OK);
0155 }
0156 goto unlock_and_exit;
0157 }
0158
0159
0160
0161 acpi_tb_install_table_with_override(&new_table_desc, override,
0162 table_index);
0163
0164
0165
0166 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
0167 acpi_tb_notify_table(ACPI_TABLE_EVENT_INSTALL, new_table_desc.pointer);
0168 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
0169
0170 unlock_and_exit:
0171
0172
0173
0174 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
0175
0176 release_and_exit:
0177
0178
0179
0180 acpi_tb_release_temp_table(&new_table_desc);
0181 return_ACPI_STATUS(status);
0182 }
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
0202 {
0203 acpi_status status;
0204 struct acpi_table_desc new_table_desc;
0205 struct acpi_table_header *table;
0206 acpi_physical_address address;
0207 u32 length;
0208 ACPI_ERROR_ONLY(char *override_type);
0209
0210
0211
0212 status = acpi_os_table_override(old_table_desc->pointer, &table);
0213 if (ACPI_SUCCESS(status) && table) {
0214 acpi_tb_acquire_temp_table(&new_table_desc,
0215 ACPI_PTR_TO_PHYSADDR(table),
0216 ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL,
0217 table);
0218 ACPI_ERROR_ONLY(override_type = "Logical");
0219 goto finish_override;
0220 }
0221
0222
0223
0224 status = acpi_os_physical_table_override(old_table_desc->pointer,
0225 &address, &length);
0226 if (ACPI_SUCCESS(status) && address && length) {
0227 acpi_tb_acquire_temp_table(&new_table_desc, address,
0228 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
0229 NULL);
0230 ACPI_ERROR_ONLY(override_type = "Physical");
0231 goto finish_override;
0232 }
0233
0234 return;
0235
0236 finish_override:
0237
0238
0239
0240
0241
0242 status = acpi_tb_verify_temp_table(&new_table_desc, NULL, NULL);
0243 if (ACPI_FAILURE(status)) {
0244 return;
0245 }
0246
0247 ACPI_INFO(("%4.4s 0x%8.8X%8.8X"
0248 " %s table override, new table: 0x%8.8X%8.8X",
0249 old_table_desc->signature.ascii,
0250 ACPI_FORMAT_UINT64(old_table_desc->address),
0251 override_type, ACPI_FORMAT_UINT64(new_table_desc.address)));
0252
0253
0254
0255 acpi_tb_uninstall_table(old_table_desc);
0256
0257
0258
0259
0260
0261 acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
0262 new_table_desc.flags,
0263 new_table_desc.pointer);
0264 acpi_tb_validate_temp_table(old_table_desc);
0265
0266
0267
0268 acpi_tb_release_temp_table(&new_table_desc);
0269 }
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283 void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
0284 {
0285
0286 ACPI_FUNCTION_TRACE(tb_uninstall_table);
0287
0288
0289
0290 if (!table_desc->address) {
0291 return_VOID;
0292 }
0293
0294 acpi_tb_invalidate_table(table_desc);
0295
0296 if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
0297 ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
0298 ACPI_FREE(table_desc->pointer);
0299 table_desc->pointer = NULL;
0300 }
0301
0302 table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
0303 return_VOID;
0304 }