tbinstal.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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. /* Always calculate checksum, ignore bad checksum if requested */
  76. status =
  77. acpi_tb_verify_checksum(table_desc->pointer, table_desc->length);
  78. return_ACPI_STATUS(status);
  79. }
  80. /*******************************************************************************
  81. *
  82. * FUNCTION: acpi_tb_add_table
  83. *
  84. * PARAMETERS: table_desc - Table descriptor
  85. * table_index - Where the table index is returned
  86. *
  87. * RETURN: Status
  88. *
  89. * DESCRIPTION: This function is called to add an ACPI table. It is used to
  90. * dynamically load tables via the Load and load_table AML
  91. * operators.
  92. *
  93. ******************************************************************************/
  94. acpi_status
  95. acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
  96. {
  97. u32 i;
  98. acpi_status status = AE_OK;
  99. ACPI_FUNCTION_TRACE(tb_add_table);
  100. if (!table_desc->pointer) {
  101. status = acpi_tb_verify_table(table_desc);
  102. if (ACPI_FAILURE(status) || !table_desc->pointer) {
  103. return_ACPI_STATUS(status);
  104. }
  105. }
  106. /*
  107. * Validate the incoming table signature.
  108. *
  109. * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
  110. * 2) We added support for OEMx tables, signature "OEM".
  111. * 3) Valid tables were encountered with a null signature, so we just
  112. * gave up on validating the signature, (05/2008).
  113. * 4) We encountered non-AML tables such as the MADT, which caused
  114. * interpreter errors and kernel faults. So now, we once again allow
  115. * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
  116. */
  117. if ((table_desc->pointer->signature[0] != 0x00) &&
  118. (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT))
  119. && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) {
  120. ACPI_BIOS_ERROR((AE_INFO,
  121. "Table has invalid signature [%4.4s] (0x%8.8X), "
  122. "must be SSDT or OEMx",
  123. acpi_ut_valid_acpi_name(table_desc->pointer->
  124. signature) ?
  125. table_desc->pointer->signature : "????",
  126. *(u32 *)table_desc->pointer->signature));
  127. return_ACPI_STATUS(AE_BAD_SIGNATURE);
  128. }
  129. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  130. /* Check if table is already registered */
  131. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
  132. if (!acpi_gbl_root_table_list.tables[i].pointer) {
  133. status =
  134. acpi_tb_verify_table(&acpi_gbl_root_table_list.
  135. tables[i]);
  136. if (ACPI_FAILURE(status)
  137. || !acpi_gbl_root_table_list.tables[i].pointer) {
  138. continue;
  139. }
  140. }
  141. /*
  142. * Check for a table match on the entire table length,
  143. * not just the header.
  144. */
  145. if (table_desc->length !=
  146. acpi_gbl_root_table_list.tables[i].length) {
  147. continue;
  148. }
  149. if (ACPI_MEMCMP(table_desc->pointer,
  150. acpi_gbl_root_table_list.tables[i].pointer,
  151. acpi_gbl_root_table_list.tables[i].length)) {
  152. continue;
  153. }
  154. /*
  155. * Note: the current mechanism does not unregister a table if it is
  156. * dynamically unloaded. The related namespace entries are deleted,
  157. * but the table remains in the root table list.
  158. *
  159. * The assumption here is that the number of different tables that
  160. * will be loaded is actually small, and there is minimal overhead
  161. * in just keeping the table in case it is needed again.
  162. *
  163. * If this assumption changes in the future (perhaps on large
  164. * machines with many table load/unload operations), tables will
  165. * need to be unregistered when they are unloaded, and slots in the
  166. * root table list should be reused when empty.
  167. */
  168. /*
  169. * Table is already registered.
  170. * We can delete the table that was passed as a parameter.
  171. */
  172. acpi_tb_delete_table(table_desc);
  173. *table_index = i;
  174. if (acpi_gbl_root_table_list.tables[i].
  175. flags & ACPI_TABLE_IS_LOADED) {
  176. /* Table is still loaded, this is an error */
  177. status = AE_ALREADY_EXISTS;
  178. goto release;
  179. } else {
  180. /* Table was unloaded, allow it to be reloaded */
  181. table_desc->pointer =
  182. acpi_gbl_root_table_list.tables[i].pointer;
  183. table_desc->address =
  184. acpi_gbl_root_table_list.tables[i].address;
  185. status = AE_OK;
  186. goto print_header;
  187. }
  188. }
  189. /*
  190. * ACPI Table Override:
  191. * Allow the host to override dynamically loaded tables.
  192. * NOTE: the table is fully mapped at this point, and the mapping will
  193. * be deleted by tb_table_override if the table is actually overridden.
  194. */
  195. (void)acpi_tb_table_override(table_desc->pointer, table_desc);
  196. /* Add the table to the global root table list */
  197. status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
  198. table_desc->length, table_desc->flags,
  199. table_index);
  200. if (ACPI_FAILURE(status)) {
  201. goto release;
  202. }
  203. print_header:
  204. acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
  205. release:
  206. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  207. return_ACPI_STATUS(status);
  208. }
  209. /*******************************************************************************
  210. *
  211. * FUNCTION: acpi_tb_table_override
  212. *
  213. * PARAMETERS: table_header - Header for the original table
  214. * table_desc - Table descriptor initialized for the
  215. * original table. May or may not be mapped.
  216. *
  217. * RETURN: Pointer to the entire new table. NULL if table not overridden.
  218. * If overridden, installs the new table within the input table
  219. * descriptor.
  220. *
  221. * DESCRIPTION: Attempt table override by calling the OSL override functions.
  222. * Note: If the table is overridden, then the entire new table
  223. * is mapped and returned by this function.
  224. *
  225. ******************************************************************************/
  226. struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
  227. *table_header,
  228. struct acpi_table_desc
  229. *table_desc)
  230. {
  231. acpi_status status;
  232. struct acpi_table_header *new_table = NULL;
  233. acpi_physical_address new_address = 0;
  234. u32 new_table_length = 0;
  235. u8 new_flags;
  236. char *override_type;
  237. /* (1) Attempt logical override (returns a logical address) */
  238. status = acpi_os_table_override(table_header, &new_table);
  239. if (ACPI_SUCCESS(status) && new_table) {
  240. new_address = ACPI_PTR_TO_PHYSADDR(new_table);
  241. new_table_length = new_table->length;
  242. new_flags = ACPI_TABLE_ORIGIN_OVERRIDE;
  243. override_type = "Logical";
  244. goto finish_override;
  245. }
  246. /* (2) Attempt physical override (returns a physical address) */
  247. status = acpi_os_physical_table_override(table_header,
  248. &new_address,
  249. &new_table_length);
  250. if (ACPI_SUCCESS(status) && new_address && new_table_length) {
  251. /* Map the entire new table */
  252. new_table = acpi_os_map_memory(new_address, new_table_length);
  253. if (!new_table) {
  254. ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
  255. "%4.4s %p Attempted physical table override failed",
  256. table_header->signature,
  257. ACPI_CAST_PTR(void,
  258. table_desc->address)));
  259. return (NULL);
  260. }
  261. override_type = "Physical";
  262. new_flags = ACPI_TABLE_ORIGIN_MAPPED;
  263. goto finish_override;
  264. }
  265. return (NULL); /* There was no override */
  266. finish_override:
  267. ACPI_INFO((AE_INFO,
  268. "%4.4s %p %s table override, new table: %p",
  269. table_header->signature,
  270. ACPI_CAST_PTR(void, table_desc->address),
  271. override_type, new_table));
  272. /* We can now unmap/delete the original table (if fully mapped) */
  273. acpi_tb_delete_table(table_desc);
  274. /* Setup descriptor for the new table */
  275. table_desc->address = new_address;
  276. table_desc->pointer = new_table;
  277. table_desc->length = new_table_length;
  278. table_desc->flags = new_flags;
  279. return (new_table);
  280. }
  281. /*******************************************************************************
  282. *
  283. * FUNCTION: acpi_tb_resize_root_table_list
  284. *
  285. * PARAMETERS: None
  286. *
  287. * RETURN: Status
  288. *
  289. * DESCRIPTION: Expand the size of global table array
  290. *
  291. ******************************************************************************/
  292. acpi_status acpi_tb_resize_root_table_list(void)
  293. {
  294. struct acpi_table_desc *tables;
  295. u32 table_count;
  296. ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
  297. /* allow_resize flag is a parameter to acpi_initialize_tables */
  298. if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
  299. ACPI_ERROR((AE_INFO,
  300. "Resize of Root Table Array is not allowed"));
  301. return_ACPI_STATUS(AE_SUPPORT);
  302. }
  303. /* Increase the Table Array size */
  304. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  305. table_count = acpi_gbl_root_table_list.max_table_count;
  306. } else {
  307. table_count = acpi_gbl_root_table_list.current_table_count;
  308. }
  309. tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
  310. ACPI_ROOT_TABLE_SIZE_INCREMENT) *
  311. sizeof(struct acpi_table_desc));
  312. if (!tables) {
  313. ACPI_ERROR((AE_INFO,
  314. "Could not allocate new root table array"));
  315. return_ACPI_STATUS(AE_NO_MEMORY);
  316. }
  317. /* Copy and free the previous table array */
  318. if (acpi_gbl_root_table_list.tables) {
  319. ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
  320. (acpi_size) table_count *
  321. sizeof(struct acpi_table_desc));
  322. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  323. ACPI_FREE(acpi_gbl_root_table_list.tables);
  324. }
  325. }
  326. acpi_gbl_root_table_list.tables = tables;
  327. acpi_gbl_root_table_list.max_table_count =
  328. table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
  329. acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
  330. return_ACPI_STATUS(AE_OK);
  331. }
  332. /*******************************************************************************
  333. *
  334. * FUNCTION: acpi_tb_store_table
  335. *
  336. * PARAMETERS: address - Table address
  337. * table - Table header
  338. * length - Table length
  339. * flags - flags
  340. *
  341. * RETURN: Status and table index.
  342. *
  343. * DESCRIPTION: Add an ACPI table to the global table list
  344. *
  345. ******************************************************************************/
  346. acpi_status
  347. acpi_tb_store_table(acpi_physical_address address,
  348. struct acpi_table_header *table,
  349. u32 length, u8 flags, u32 *table_index)
  350. {
  351. acpi_status status;
  352. struct acpi_table_desc *new_table;
  353. /* Ensure that there is room for the table in the Root Table List */
  354. if (acpi_gbl_root_table_list.current_table_count >=
  355. acpi_gbl_root_table_list.max_table_count) {
  356. status = acpi_tb_resize_root_table_list();
  357. if (ACPI_FAILURE(status)) {
  358. return (status);
  359. }
  360. }
  361. new_table =
  362. &acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.
  363. current_table_count];
  364. /* Initialize added table */
  365. new_table->address = address;
  366. new_table->pointer = table;
  367. new_table->length = length;
  368. new_table->owner_id = 0;
  369. new_table->flags = flags;
  370. ACPI_MOVE_32_TO_32(&new_table->signature, table->signature);
  371. *table_index = acpi_gbl_root_table_list.current_table_count;
  372. acpi_gbl_root_table_list.current_table_count++;
  373. return (AE_OK);
  374. }
  375. /*******************************************************************************
  376. *
  377. * FUNCTION: acpi_tb_delete_table
  378. *
  379. * PARAMETERS: table_index - Table index
  380. *
  381. * RETURN: None
  382. *
  383. * DESCRIPTION: Delete one internal ACPI table
  384. *
  385. ******************************************************************************/
  386. void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
  387. {
  388. /* Table must be mapped or allocated */
  389. if (!table_desc->pointer) {
  390. return;
  391. }
  392. switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
  393. case ACPI_TABLE_ORIGIN_MAPPED:
  394. acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
  395. break;
  396. case ACPI_TABLE_ORIGIN_ALLOCATED:
  397. ACPI_FREE(table_desc->pointer);
  398. break;
  399. /* Not mapped or allocated, there is nothing we can do */
  400. default:
  401. return;
  402. }
  403. table_desc->pointer = NULL;
  404. }
  405. /*******************************************************************************
  406. *
  407. * FUNCTION: acpi_tb_terminate
  408. *
  409. * PARAMETERS: None
  410. *
  411. * RETURN: None
  412. *
  413. * DESCRIPTION: Delete all internal ACPI tables
  414. *
  415. ******************************************************************************/
  416. void acpi_tb_terminate(void)
  417. {
  418. u32 i;
  419. ACPI_FUNCTION_TRACE(tb_terminate);
  420. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  421. /* Delete the individual tables */
  422. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
  423. acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
  424. }
  425. /*
  426. * Delete the root table array if allocated locally. Array cannot be
  427. * mapped, so we don't need to check for that flag.
  428. */
  429. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  430. ACPI_FREE(acpi_gbl_root_table_list.tables);
  431. }
  432. acpi_gbl_root_table_list.tables = NULL;
  433. acpi_gbl_root_table_list.flags = 0;
  434. acpi_gbl_root_table_list.current_table_count = 0;
  435. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
  436. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  437. return_VOID;
  438. }
  439. /*******************************************************************************
  440. *
  441. * FUNCTION: acpi_tb_delete_namespace_by_owner
  442. *
  443. * PARAMETERS: table_index - Table index
  444. *
  445. * RETURN: Status
  446. *
  447. * DESCRIPTION: Delete all namespace objects created when this table was loaded.
  448. *
  449. ******************************************************************************/
  450. acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
  451. {
  452. acpi_owner_id owner_id;
  453. acpi_status status;
  454. ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
  455. status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  456. if (ACPI_FAILURE(status)) {
  457. return_ACPI_STATUS(status);
  458. }
  459. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  460. /* The table index does not exist */
  461. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  462. return_ACPI_STATUS(AE_NOT_EXIST);
  463. }
  464. /* Get the owner ID for this table, used to delete namespace nodes */
  465. owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
  466. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  467. /*
  468. * Need to acquire the namespace writer lock to prevent interference
  469. * with any concurrent namespace walks. The interpreter must be
  470. * released during the deletion since the acquisition of the deletion
  471. * lock may block, and also since the execution of a namespace walk
  472. * must be allowed to use the interpreter.
  473. */
  474. (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
  475. status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
  476. acpi_ns_delete_namespace_by_owner(owner_id);
  477. if (ACPI_FAILURE(status)) {
  478. return_ACPI_STATUS(status);
  479. }
  480. acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
  481. status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
  482. return_ACPI_STATUS(status);
  483. }
  484. /*******************************************************************************
  485. *
  486. * FUNCTION: acpi_tb_allocate_owner_id
  487. *
  488. * PARAMETERS: table_index - Table index
  489. *
  490. * RETURN: Status
  491. *
  492. * DESCRIPTION: Allocates owner_id in table_desc
  493. *
  494. ******************************************************************************/
  495. acpi_status acpi_tb_allocate_owner_id(u32 table_index)
  496. {
  497. acpi_status status = AE_BAD_PARAMETER;
  498. ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
  499. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  500. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  501. status = acpi_ut_allocate_owner_id
  502. (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
  503. }
  504. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  505. return_ACPI_STATUS(status);
  506. }
  507. /*******************************************************************************
  508. *
  509. * FUNCTION: acpi_tb_release_owner_id
  510. *
  511. * PARAMETERS: table_index - Table index
  512. *
  513. * RETURN: Status
  514. *
  515. * DESCRIPTION: Releases owner_id in table_desc
  516. *
  517. ******************************************************************************/
  518. acpi_status acpi_tb_release_owner_id(u32 table_index)
  519. {
  520. acpi_status status = AE_BAD_PARAMETER;
  521. ACPI_FUNCTION_TRACE(tb_release_owner_id);
  522. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  523. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  524. acpi_ut_release_owner_id(&
  525. (acpi_gbl_root_table_list.
  526. tables[table_index].owner_id));
  527. status = AE_OK;
  528. }
  529. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  530. return_ACPI_STATUS(status);
  531. }
  532. /*******************************************************************************
  533. *
  534. * FUNCTION: acpi_tb_get_owner_id
  535. *
  536. * PARAMETERS: table_index - Table index
  537. * owner_id - Where the table owner_id is returned
  538. *
  539. * RETURN: Status
  540. *
  541. * DESCRIPTION: returns owner_id for the ACPI table
  542. *
  543. ******************************************************************************/
  544. acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
  545. {
  546. acpi_status status = AE_BAD_PARAMETER;
  547. ACPI_FUNCTION_TRACE(tb_get_owner_id);
  548. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  549. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  550. *owner_id =
  551. acpi_gbl_root_table_list.tables[table_index].owner_id;
  552. status = AE_OK;
  553. }
  554. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  555. return_ACPI_STATUS(status);
  556. }
  557. /*******************************************************************************
  558. *
  559. * FUNCTION: acpi_tb_is_table_loaded
  560. *
  561. * PARAMETERS: table_index - Table index
  562. *
  563. * RETURN: Table Loaded Flag
  564. *
  565. ******************************************************************************/
  566. u8 acpi_tb_is_table_loaded(u32 table_index)
  567. {
  568. u8 is_loaded = FALSE;
  569. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  570. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  571. is_loaded = (u8)
  572. (acpi_gbl_root_table_list.tables[table_index].flags &
  573. ACPI_TABLE_IS_LOADED);
  574. }
  575. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  576. return (is_loaded);
  577. }
  578. /*******************************************************************************
  579. *
  580. * FUNCTION: acpi_tb_set_table_loaded_flag
  581. *
  582. * PARAMETERS: table_index - Table index
  583. * is_loaded - TRUE if table is loaded, FALSE otherwise
  584. *
  585. * RETURN: None
  586. *
  587. * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
  588. *
  589. ******************************************************************************/
  590. void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
  591. {
  592. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  593. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  594. if (is_loaded) {
  595. acpi_gbl_root_table_list.tables[table_index].flags |=
  596. ACPI_TABLE_IS_LOADED;
  597. } else {
  598. acpi_gbl_root_table_list.tables[table_index].flags &=
  599. ~ACPI_TABLE_IS_LOADED;
  600. }
  601. }
  602. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  603. }