tbinstal.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /******************************************************************************
  2. *
  3. * Module Name: tbinstal - ACPI table installation and removal
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2013, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acnamesp.h"
  45. #include "actables.h"
  46. #define _COMPONENT ACPI_TABLES
  47. ACPI_MODULE_NAME("tbinstal")
  48. /******************************************************************************
  49. *
  50. * FUNCTION: acpi_tb_verify_table
  51. *
  52. * PARAMETERS: table_desc - table
  53. *
  54. * RETURN: Status
  55. *
  56. * DESCRIPTION: this function is called to verify and map table
  57. *
  58. *****************************************************************************/
  59. acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
  60. {
  61. acpi_status status = AE_OK;
  62. ACPI_FUNCTION_TRACE(tb_verify_table);
  63. /* Map the table if necessary */
  64. if (!table_desc->pointer) {
  65. if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
  66. ACPI_TABLE_ORIGIN_MAPPED) {
  67. table_desc->pointer =
  68. acpi_os_map_memory(table_desc->address,
  69. table_desc->length);
  70. }
  71. if (!table_desc->pointer) {
  72. return_ACPI_STATUS(AE_NO_MEMORY);
  73. }
  74. }
  75. /* FACS is the odd table, has no standard ACPI header and no checksum */
  76. if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) {
  77. /* Always calculate checksum, ignore bad checksum if requested */
  78. status =
  79. acpi_tb_verify_checksum(table_desc->pointer,
  80. table_desc->length);
  81. }
  82. return_ACPI_STATUS(status);
  83. }
  84. /*******************************************************************************
  85. *
  86. * FUNCTION: acpi_tb_add_table
  87. *
  88. * PARAMETERS: table_desc - Table descriptor
  89. * table_index - Where the table index is returned
  90. *
  91. * RETURN: Status
  92. *
  93. * DESCRIPTION: This function is called to add an ACPI table. It is used to
  94. * dynamically load tables via the Load and load_table AML
  95. * operators.
  96. *
  97. ******************************************************************************/
  98. acpi_status
  99. acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
  100. {
  101. u32 i;
  102. acpi_status status = AE_OK;
  103. ACPI_FUNCTION_TRACE(tb_add_table);
  104. if (!table_desc->pointer) {
  105. status = acpi_tb_verify_table(table_desc);
  106. if (ACPI_FAILURE(status) || !table_desc->pointer) {
  107. return_ACPI_STATUS(status);
  108. }
  109. }
  110. /*
  111. * Validate the incoming table signature.
  112. *
  113. * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
  114. * 2) We added support for OEMx tables, signature "OEM".
  115. * 3) Valid tables were encountered with a null signature, so we just
  116. * gave up on validating the signature, (05/2008).
  117. * 4) We encountered non-AML tables such as the MADT, which caused
  118. * interpreter errors and kernel faults. So now, we once again allow
  119. * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
  120. */
  121. if ((table_desc->pointer->signature[0] != 0x00) &&
  122. (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT))
  123. && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) {
  124. ACPI_BIOS_ERROR((AE_INFO,
  125. "Table has invalid signature [%4.4s] (0x%8.8X), "
  126. "must be SSDT or OEMx",
  127. acpi_ut_valid_acpi_name(*(u32 *)table_desc->
  128. pointer->
  129. signature) ?
  130. table_desc->pointer->signature : "????",
  131. *(u32 *)table_desc->pointer->signature));
  132. return_ACPI_STATUS(AE_BAD_SIGNATURE);
  133. }
  134. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  135. /* Check if table is already registered */
  136. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
  137. if (!acpi_gbl_root_table_list.tables[i].pointer) {
  138. status =
  139. acpi_tb_verify_table(&acpi_gbl_root_table_list.
  140. tables[i]);
  141. if (ACPI_FAILURE(status)
  142. || !acpi_gbl_root_table_list.tables[i].pointer) {
  143. continue;
  144. }
  145. }
  146. /*
  147. * Check for a table match on the entire table length,
  148. * not just the header.
  149. */
  150. if (table_desc->length !=
  151. acpi_gbl_root_table_list.tables[i].length) {
  152. continue;
  153. }
  154. if (ACPI_MEMCMP(table_desc->pointer,
  155. acpi_gbl_root_table_list.tables[i].pointer,
  156. acpi_gbl_root_table_list.tables[i].length)) {
  157. continue;
  158. }
  159. /*
  160. * Note: the current mechanism does not unregister a table if it is
  161. * dynamically unloaded. The related namespace entries are deleted,
  162. * but the table remains in the root table list.
  163. *
  164. * The assumption here is that the number of different tables that
  165. * will be loaded is actually small, and there is minimal overhead
  166. * in just keeping the table in case it is needed again.
  167. *
  168. * If this assumption changes in the future (perhaps on large
  169. * machines with many table load/unload operations), tables will
  170. * need to be unregistered when they are unloaded, and slots in the
  171. * root table list should be reused when empty.
  172. */
  173. /*
  174. * Table is already registered.
  175. * We can delete the table that was passed as a parameter.
  176. */
  177. acpi_tb_delete_table(table_desc);
  178. *table_index = i;
  179. if (acpi_gbl_root_table_list.tables[i].
  180. flags & ACPI_TABLE_IS_LOADED) {
  181. /* Table is still loaded, this is an error */
  182. status = AE_ALREADY_EXISTS;
  183. goto release;
  184. } else {
  185. /* Table was unloaded, allow it to be reloaded */
  186. table_desc->pointer =
  187. acpi_gbl_root_table_list.tables[i].pointer;
  188. table_desc->address =
  189. acpi_gbl_root_table_list.tables[i].address;
  190. status = AE_OK;
  191. goto print_header;
  192. }
  193. }
  194. /*
  195. * ACPI Table Override:
  196. * Allow the host to override dynamically loaded tables.
  197. * NOTE: the table is fully mapped at this point, and the mapping will
  198. * be deleted by tb_table_override if the table is actually overridden.
  199. */
  200. (void)acpi_tb_table_override(table_desc->pointer, table_desc);
  201. /* Add the table to the global root table list */
  202. status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
  203. table_desc->length, table_desc->flags,
  204. table_index);
  205. if (ACPI_FAILURE(status)) {
  206. goto release;
  207. }
  208. print_header:
  209. acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
  210. release:
  211. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  212. return_ACPI_STATUS(status);
  213. }
  214. /*******************************************************************************
  215. *
  216. * FUNCTION: acpi_tb_table_override
  217. *
  218. * PARAMETERS: table_header - Header for the original table
  219. * table_desc - Table descriptor initialized for the
  220. * original table. May or may not be mapped.
  221. *
  222. * RETURN: Pointer to the entire new table. NULL if table not overridden.
  223. * If overridden, installs the new table within the input table
  224. * descriptor.
  225. *
  226. * DESCRIPTION: Attempt table override by calling the OSL override functions.
  227. * Note: If the table is overridden, then the entire new table
  228. * is mapped and returned by this function.
  229. *
  230. ******************************************************************************/
  231. struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
  232. *table_header,
  233. struct acpi_table_desc
  234. *table_desc)
  235. {
  236. acpi_status status;
  237. struct acpi_table_header *new_table = NULL;
  238. acpi_physical_address new_address = 0;
  239. u32 new_table_length = 0;
  240. u8 new_flags;
  241. char *override_type;
  242. /* (1) Attempt logical override (returns a logical address) */
  243. status = acpi_os_table_override(table_header, &new_table);
  244. if (ACPI_SUCCESS(status) && new_table) {
  245. new_address = ACPI_PTR_TO_PHYSADDR(new_table);
  246. new_table_length = new_table->length;
  247. new_flags = ACPI_TABLE_ORIGIN_OVERRIDE;
  248. override_type = "Logical";
  249. goto finish_override;
  250. }
  251. /* (2) Attempt physical override (returns a physical address) */
  252. status = acpi_os_physical_table_override(table_header,
  253. &new_address,
  254. &new_table_length);
  255. if (ACPI_SUCCESS(status) && new_address && new_table_length) {
  256. /* Map the entire new table */
  257. new_table = acpi_os_map_memory(new_address, new_table_length);
  258. if (!new_table) {
  259. ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
  260. "%4.4s %p Attempted physical table override failed",
  261. table_header->signature,
  262. ACPI_CAST_PTR(void,
  263. table_desc->address)));
  264. return (NULL);
  265. }
  266. override_type = "Physical";
  267. new_flags = ACPI_TABLE_ORIGIN_MAPPED;
  268. goto finish_override;
  269. }
  270. return (NULL); /* There was no override */
  271. finish_override:
  272. ACPI_INFO((AE_INFO,
  273. "%4.4s %p %s table override, new table: %p",
  274. table_header->signature,
  275. ACPI_CAST_PTR(void, table_desc->address),
  276. override_type, new_table));
  277. /* We can now unmap/delete the original table (if fully mapped) */
  278. acpi_tb_delete_table(table_desc);
  279. /* Setup descriptor for the new table */
  280. table_desc->address = new_address;
  281. table_desc->pointer = new_table;
  282. table_desc->length = new_table_length;
  283. table_desc->flags = new_flags;
  284. return (new_table);
  285. }
  286. /*******************************************************************************
  287. *
  288. * FUNCTION: acpi_tb_resize_root_table_list
  289. *
  290. * PARAMETERS: None
  291. *
  292. * RETURN: Status
  293. *
  294. * DESCRIPTION: Expand the size of global table array
  295. *
  296. ******************************************************************************/
  297. acpi_status acpi_tb_resize_root_table_list(void)
  298. {
  299. struct acpi_table_desc *tables;
  300. u32 table_count;
  301. ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
  302. /* allow_resize flag is a parameter to acpi_initialize_tables */
  303. if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
  304. ACPI_ERROR((AE_INFO,
  305. "Resize of Root Table Array is not allowed"));
  306. return_ACPI_STATUS(AE_SUPPORT);
  307. }
  308. /* Increase the Table Array size */
  309. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  310. table_count = acpi_gbl_root_table_list.max_table_count;
  311. } else {
  312. table_count = acpi_gbl_root_table_list.current_table_count;
  313. }
  314. tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
  315. ACPI_ROOT_TABLE_SIZE_INCREMENT) *
  316. sizeof(struct acpi_table_desc));
  317. if (!tables) {
  318. ACPI_ERROR((AE_INFO,
  319. "Could not allocate new root table array"));
  320. return_ACPI_STATUS(AE_NO_MEMORY);
  321. }
  322. /* Copy and free the previous table array */
  323. if (acpi_gbl_root_table_list.tables) {
  324. ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
  325. (acpi_size) table_count *
  326. sizeof(struct acpi_table_desc));
  327. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  328. ACPI_FREE(acpi_gbl_root_table_list.tables);
  329. }
  330. }
  331. acpi_gbl_root_table_list.tables = tables;
  332. acpi_gbl_root_table_list.max_table_count =
  333. table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
  334. acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
  335. return_ACPI_STATUS(AE_OK);
  336. }
  337. /*******************************************************************************
  338. *
  339. * FUNCTION: acpi_tb_store_table
  340. *
  341. * PARAMETERS: address - Table address
  342. * table - Table header
  343. * length - Table length
  344. * flags - flags
  345. *
  346. * RETURN: Status and table index.
  347. *
  348. * DESCRIPTION: Add an ACPI table to the global table list
  349. *
  350. ******************************************************************************/
  351. acpi_status
  352. acpi_tb_store_table(acpi_physical_address address,
  353. struct acpi_table_header *table,
  354. u32 length, u8 flags, u32 *table_index)
  355. {
  356. acpi_status status;
  357. struct acpi_table_desc *new_table;
  358. /* Ensure that there is room for the table in the Root Table List */
  359. if (acpi_gbl_root_table_list.current_table_count >=
  360. acpi_gbl_root_table_list.max_table_count) {
  361. status = acpi_tb_resize_root_table_list();
  362. if (ACPI_FAILURE(status)) {
  363. return (status);
  364. }
  365. }
  366. new_table =
  367. &acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.
  368. current_table_count];
  369. /* Initialize added table */
  370. new_table->address = address;
  371. new_table->pointer = table;
  372. new_table->length = length;
  373. new_table->owner_id = 0;
  374. new_table->flags = flags;
  375. ACPI_MOVE_32_TO_32(&new_table->signature, table->signature);
  376. *table_index = acpi_gbl_root_table_list.current_table_count;
  377. acpi_gbl_root_table_list.current_table_count++;
  378. return (AE_OK);
  379. }
  380. /*******************************************************************************
  381. *
  382. * FUNCTION: acpi_tb_delete_table
  383. *
  384. * PARAMETERS: table_index - Table index
  385. *
  386. * RETURN: None
  387. *
  388. * DESCRIPTION: Delete one internal ACPI table
  389. *
  390. ******************************************************************************/
  391. void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
  392. {
  393. /* Table must be mapped or allocated */
  394. if (!table_desc->pointer) {
  395. return;
  396. }
  397. switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
  398. case ACPI_TABLE_ORIGIN_MAPPED:
  399. acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
  400. break;
  401. case ACPI_TABLE_ORIGIN_ALLOCATED:
  402. ACPI_FREE(table_desc->pointer);
  403. break;
  404. /* Not mapped or allocated, there is nothing we can do */
  405. default:
  406. return;
  407. }
  408. table_desc->pointer = NULL;
  409. }
  410. /*******************************************************************************
  411. *
  412. * FUNCTION: acpi_tb_terminate
  413. *
  414. * PARAMETERS: None
  415. *
  416. * RETURN: None
  417. *
  418. * DESCRIPTION: Delete all internal ACPI tables
  419. *
  420. ******************************************************************************/
  421. void acpi_tb_terminate(void)
  422. {
  423. u32 i;
  424. ACPI_FUNCTION_TRACE(tb_terminate);
  425. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  426. /* Delete the individual tables */
  427. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
  428. acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
  429. }
  430. /*
  431. * Delete the root table array if allocated locally. Array cannot be
  432. * mapped, so we don't need to check for that flag.
  433. */
  434. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  435. ACPI_FREE(acpi_gbl_root_table_list.tables);
  436. }
  437. acpi_gbl_root_table_list.tables = NULL;
  438. acpi_gbl_root_table_list.flags = 0;
  439. acpi_gbl_root_table_list.current_table_count = 0;
  440. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
  441. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  442. return_VOID;
  443. }
  444. /*******************************************************************************
  445. *
  446. * FUNCTION: acpi_tb_delete_namespace_by_owner
  447. *
  448. * PARAMETERS: table_index - Table index
  449. *
  450. * RETURN: Status
  451. *
  452. * DESCRIPTION: Delete all namespace objects created when this table was loaded.
  453. *
  454. ******************************************************************************/
  455. acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
  456. {
  457. acpi_owner_id owner_id;
  458. acpi_status status;
  459. ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
  460. status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  461. if (ACPI_FAILURE(status)) {
  462. return_ACPI_STATUS(status);
  463. }
  464. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  465. /* The table index does not exist */
  466. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  467. return_ACPI_STATUS(AE_NOT_EXIST);
  468. }
  469. /* Get the owner ID for this table, used to delete namespace nodes */
  470. owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
  471. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  472. /*
  473. * Need to acquire the namespace writer lock to prevent interference
  474. * with any concurrent namespace walks. The interpreter must be
  475. * released during the deletion since the acquisition of the deletion
  476. * lock may block, and also since the execution of a namespace walk
  477. * must be allowed to use the interpreter.
  478. */
  479. (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
  480. status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
  481. acpi_ns_delete_namespace_by_owner(owner_id);
  482. if (ACPI_FAILURE(status)) {
  483. return_ACPI_STATUS(status);
  484. }
  485. acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
  486. status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
  487. return_ACPI_STATUS(status);
  488. }
  489. /*******************************************************************************
  490. *
  491. * FUNCTION: acpi_tb_allocate_owner_id
  492. *
  493. * PARAMETERS: table_index - Table index
  494. *
  495. * RETURN: Status
  496. *
  497. * DESCRIPTION: Allocates owner_id in table_desc
  498. *
  499. ******************************************************************************/
  500. acpi_status acpi_tb_allocate_owner_id(u32 table_index)
  501. {
  502. acpi_status status = AE_BAD_PARAMETER;
  503. ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
  504. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  505. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  506. status = acpi_ut_allocate_owner_id
  507. (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
  508. }
  509. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  510. return_ACPI_STATUS(status);
  511. }
  512. /*******************************************************************************
  513. *
  514. * FUNCTION: acpi_tb_release_owner_id
  515. *
  516. * PARAMETERS: table_index - Table index
  517. *
  518. * RETURN: Status
  519. *
  520. * DESCRIPTION: Releases owner_id in table_desc
  521. *
  522. ******************************************************************************/
  523. acpi_status acpi_tb_release_owner_id(u32 table_index)
  524. {
  525. acpi_status status = AE_BAD_PARAMETER;
  526. ACPI_FUNCTION_TRACE(tb_release_owner_id);
  527. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  528. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  529. acpi_ut_release_owner_id(&
  530. (acpi_gbl_root_table_list.
  531. tables[table_index].owner_id));
  532. status = AE_OK;
  533. }
  534. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  535. return_ACPI_STATUS(status);
  536. }
  537. /*******************************************************************************
  538. *
  539. * FUNCTION: acpi_tb_get_owner_id
  540. *
  541. * PARAMETERS: table_index - Table index
  542. * owner_id - Where the table owner_id is returned
  543. *
  544. * RETURN: Status
  545. *
  546. * DESCRIPTION: returns owner_id for the ACPI table
  547. *
  548. ******************************************************************************/
  549. acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
  550. {
  551. acpi_status status = AE_BAD_PARAMETER;
  552. ACPI_FUNCTION_TRACE(tb_get_owner_id);
  553. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  554. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  555. *owner_id =
  556. acpi_gbl_root_table_list.tables[table_index].owner_id;
  557. status = AE_OK;
  558. }
  559. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  560. return_ACPI_STATUS(status);
  561. }
  562. /*******************************************************************************
  563. *
  564. * FUNCTION: acpi_tb_is_table_loaded
  565. *
  566. * PARAMETERS: table_index - Table index
  567. *
  568. * RETURN: Table Loaded Flag
  569. *
  570. ******************************************************************************/
  571. u8 acpi_tb_is_table_loaded(u32 table_index)
  572. {
  573. u8 is_loaded = FALSE;
  574. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  575. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  576. is_loaded = (u8)
  577. (acpi_gbl_root_table_list.tables[table_index].flags &
  578. ACPI_TABLE_IS_LOADED);
  579. }
  580. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  581. return (is_loaded);
  582. }
  583. /*******************************************************************************
  584. *
  585. * FUNCTION: acpi_tb_set_table_loaded_flag
  586. *
  587. * PARAMETERS: table_index - Table index
  588. * is_loaded - TRUE if table is loaded, FALSE otherwise
  589. *
  590. * RETURN: None
  591. *
  592. * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
  593. *
  594. ******************************************************************************/
  595. void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
  596. {
  597. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  598. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  599. if (is_loaded) {
  600. acpi_gbl_root_table_list.tables[table_index].flags |=
  601. ACPI_TABLE_IS_LOADED;
  602. } else {
  603. acpi_gbl_root_table_list.tables[table_index].flags &=
  604. ~ACPI_TABLE_IS_LOADED;
  605. }
  606. }
  607. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  608. }