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