tbinstal.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /******************************************************************************
  2. *
  3. * Module Name: tbinstal - ACPI table installation and removal
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2012, 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. ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
  301. /* allow_resize flag is a parameter to acpi_initialize_tables */
  302. if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
  303. ACPI_ERROR((AE_INFO,
  304. "Resize of Root Table Array is not allowed"));
  305. return_ACPI_STATUS(AE_SUPPORT);
  306. }
  307. /* Increase the Table Array size */
  308. tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list.
  309. max_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) acpi_gbl_root_table_list.
  321. max_table_count * 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. ACPI_ROOT_TABLE_SIZE_INCREMENT;
  329. acpi_gbl_root_table_list.flags |= (u8)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. }
  438. /*******************************************************************************
  439. *
  440. * FUNCTION: acpi_tb_delete_namespace_by_owner
  441. *
  442. * PARAMETERS: table_index - Table index
  443. *
  444. * RETURN: Status
  445. *
  446. * DESCRIPTION: Delete all namespace objects created when this table was loaded.
  447. *
  448. ******************************************************************************/
  449. acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
  450. {
  451. acpi_owner_id owner_id;
  452. acpi_status status;
  453. ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
  454. status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  455. if (ACPI_FAILURE(status)) {
  456. return_ACPI_STATUS(status);
  457. }
  458. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  459. /* The table index does not exist */
  460. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  461. return_ACPI_STATUS(AE_NOT_EXIST);
  462. }
  463. /* Get the owner ID for this table, used to delete namespace nodes */
  464. owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
  465. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  466. /*
  467. * Need to acquire the namespace writer lock to prevent interference
  468. * with any concurrent namespace walks. The interpreter must be
  469. * released during the deletion since the acquisition of the deletion
  470. * lock may block, and also since the execution of a namespace walk
  471. * must be allowed to use the interpreter.
  472. */
  473. (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
  474. status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
  475. acpi_ns_delete_namespace_by_owner(owner_id);
  476. if (ACPI_FAILURE(status)) {
  477. return_ACPI_STATUS(status);
  478. }
  479. acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
  480. status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
  481. return_ACPI_STATUS(status);
  482. }
  483. /*******************************************************************************
  484. *
  485. * FUNCTION: acpi_tb_allocate_owner_id
  486. *
  487. * PARAMETERS: table_index - Table index
  488. *
  489. * RETURN: Status
  490. *
  491. * DESCRIPTION: Allocates owner_id in table_desc
  492. *
  493. ******************************************************************************/
  494. acpi_status acpi_tb_allocate_owner_id(u32 table_index)
  495. {
  496. acpi_status status = AE_BAD_PARAMETER;
  497. ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
  498. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  499. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  500. status = acpi_ut_allocate_owner_id
  501. (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
  502. }
  503. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  504. return_ACPI_STATUS(status);
  505. }
  506. /*******************************************************************************
  507. *
  508. * FUNCTION: acpi_tb_release_owner_id
  509. *
  510. * PARAMETERS: table_index - Table index
  511. *
  512. * RETURN: Status
  513. *
  514. * DESCRIPTION: Releases owner_id in table_desc
  515. *
  516. ******************************************************************************/
  517. acpi_status acpi_tb_release_owner_id(u32 table_index)
  518. {
  519. acpi_status status = AE_BAD_PARAMETER;
  520. ACPI_FUNCTION_TRACE(tb_release_owner_id);
  521. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  522. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  523. acpi_ut_release_owner_id(&
  524. (acpi_gbl_root_table_list.
  525. tables[table_index].owner_id));
  526. status = AE_OK;
  527. }
  528. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  529. return_ACPI_STATUS(status);
  530. }
  531. /*******************************************************************************
  532. *
  533. * FUNCTION: acpi_tb_get_owner_id
  534. *
  535. * PARAMETERS: table_index - Table index
  536. * owner_id - Where the table owner_id is returned
  537. *
  538. * RETURN: Status
  539. *
  540. * DESCRIPTION: returns owner_id for the ACPI table
  541. *
  542. ******************************************************************************/
  543. acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
  544. {
  545. acpi_status status = AE_BAD_PARAMETER;
  546. ACPI_FUNCTION_TRACE(tb_get_owner_id);
  547. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  548. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  549. *owner_id =
  550. acpi_gbl_root_table_list.tables[table_index].owner_id;
  551. status = AE_OK;
  552. }
  553. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  554. return_ACPI_STATUS(status);
  555. }
  556. /*******************************************************************************
  557. *
  558. * FUNCTION: acpi_tb_is_table_loaded
  559. *
  560. * PARAMETERS: table_index - Table index
  561. *
  562. * RETURN: Table Loaded Flag
  563. *
  564. ******************************************************************************/
  565. u8 acpi_tb_is_table_loaded(u32 table_index)
  566. {
  567. u8 is_loaded = FALSE;
  568. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  569. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  570. is_loaded = (u8)
  571. (acpi_gbl_root_table_list.tables[table_index].flags &
  572. ACPI_TABLE_IS_LOADED);
  573. }
  574. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  575. return (is_loaded);
  576. }
  577. /*******************************************************************************
  578. *
  579. * FUNCTION: acpi_tb_set_table_loaded_flag
  580. *
  581. * PARAMETERS: table_index - Table index
  582. * is_loaded - TRUE if table is loaded, FALSE otherwise
  583. *
  584. * RETURN: None
  585. *
  586. * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
  587. *
  588. ******************************************************************************/
  589. void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
  590. {
  591. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  592. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  593. if (is_loaded) {
  594. acpi_gbl_root_table_list.tables[table_index].flags |=
  595. ACPI_TABLE_IS_LOADED;
  596. } else {
  597. acpi_gbl_root_table_list.tables[table_index].flags &=
  598. ~ACPI_TABLE_IS_LOADED;
  599. }
  600. }
  601. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  602. }