tbdata.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. /******************************************************************************
  2. *
  3. * Module Name: tbdata - Table manager data structure functions
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, 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("tbdata")
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_tb_init_table_descriptor
  51. *
  52. * PARAMETERS: table_desc - Table descriptor
  53. * address - Physical address of the table
  54. * flags - Allocation flags of the table
  55. * table - Pointer to the table
  56. *
  57. * RETURN: None
  58. *
  59. * DESCRIPTION: Initialize a new table descriptor
  60. *
  61. ******************************************************************************/
  62. void
  63. acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
  64. acpi_physical_address address,
  65. u8 flags, struct acpi_table_header *table)
  66. {
  67. /*
  68. * Initialize the table descriptor. Set the pointer to NULL, since the
  69. * table is not fully mapped at this time.
  70. */
  71. memset(table_desc, 0, sizeof(struct acpi_table_desc));
  72. table_desc->address = address;
  73. table_desc->length = table->length;
  74. table_desc->flags = flags;
  75. ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
  76. }
  77. /*******************************************************************************
  78. *
  79. * FUNCTION: acpi_tb_acquire_table
  80. *
  81. * PARAMETERS: table_desc - Table descriptor
  82. * table_ptr - Where table is returned
  83. * table_length - Where table length is returned
  84. * table_flags - Where table allocation flags are returned
  85. *
  86. * RETURN: Status
  87. *
  88. * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
  89. * maintained in the acpi_gbl_root_table_list.
  90. *
  91. ******************************************************************************/
  92. acpi_status
  93. acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
  94. struct acpi_table_header **table_ptr,
  95. u32 *table_length, u8 *table_flags)
  96. {
  97. struct acpi_table_header *table = NULL;
  98. switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
  99. case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
  100. table =
  101. acpi_os_map_memory(table_desc->address, table_desc->length);
  102. break;
  103. case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
  104. case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
  105. table = ACPI_CAST_PTR(struct acpi_table_header,
  106. ACPI_PHYSADDR_TO_PTR(table_desc->
  107. address));
  108. break;
  109. default:
  110. break;
  111. }
  112. /* Table is not valid yet */
  113. if (!table) {
  114. return (AE_NO_MEMORY);
  115. }
  116. /* Fill the return values */
  117. *table_ptr = table;
  118. *table_length = table_desc->length;
  119. *table_flags = table_desc->flags;
  120. return (AE_OK);
  121. }
  122. /*******************************************************************************
  123. *
  124. * FUNCTION: acpi_tb_release_table
  125. *
  126. * PARAMETERS: table - Pointer for the table
  127. * table_length - Length for the table
  128. * table_flags - Allocation flags for the table
  129. *
  130. * RETURN: None
  131. *
  132. * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table().
  133. *
  134. ******************************************************************************/
  135. void
  136. acpi_tb_release_table(struct acpi_table_header *table,
  137. u32 table_length, u8 table_flags)
  138. {
  139. switch (table_flags & ACPI_TABLE_ORIGIN_MASK) {
  140. case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
  141. acpi_os_unmap_memory(table, table_length);
  142. break;
  143. case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
  144. case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
  145. default:
  146. break;
  147. }
  148. }
  149. /*******************************************************************************
  150. *
  151. * FUNCTION: acpi_tb_acquire_temp_table
  152. *
  153. * PARAMETERS: table_desc - Table descriptor to be acquired
  154. * address - Address of the table
  155. * flags - Allocation flags of the table
  156. *
  157. * RETURN: Status
  158. *
  159. * DESCRIPTION: This function validates the table header to obtain the length
  160. * of a table and fills the table descriptor to make its state as
  161. * "INSTALLED". Such a table descriptor is only used for verified
  162. * installation.
  163. *
  164. ******************************************************************************/
  165. acpi_status
  166. acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
  167. acpi_physical_address address, u8 flags)
  168. {
  169. struct acpi_table_header *table_header;
  170. switch (flags & ACPI_TABLE_ORIGIN_MASK) {
  171. case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
  172. /* Get the length of the full table from the header */
  173. table_header =
  174. acpi_os_map_memory(address,
  175. sizeof(struct acpi_table_header));
  176. if (!table_header) {
  177. return (AE_NO_MEMORY);
  178. }
  179. acpi_tb_init_table_descriptor(table_desc, address, flags,
  180. table_header);
  181. acpi_os_unmap_memory(table_header,
  182. sizeof(struct acpi_table_header));
  183. return (AE_OK);
  184. case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
  185. case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
  186. table_header = ACPI_CAST_PTR(struct acpi_table_header,
  187. ACPI_PHYSADDR_TO_PTR(address));
  188. if (!table_header) {
  189. return (AE_NO_MEMORY);
  190. }
  191. acpi_tb_init_table_descriptor(table_desc, address, flags,
  192. table_header);
  193. return (AE_OK);
  194. default:
  195. break;
  196. }
  197. /* Table is not valid yet */
  198. return (AE_NO_MEMORY);
  199. }
  200. /*******************************************************************************
  201. *
  202. * FUNCTION: acpi_tb_release_temp_table
  203. *
  204. * PARAMETERS: table_desc - Table descriptor to be released
  205. *
  206. * RETURN: Status
  207. *
  208. * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table().
  209. *
  210. *****************************************************************************/
  211. void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc)
  212. {
  213. /*
  214. * Note that the .Address is maintained by the callers of
  215. * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table()
  216. * where .Address will be freed.
  217. */
  218. acpi_tb_invalidate_table(table_desc);
  219. }
  220. /******************************************************************************
  221. *
  222. * FUNCTION: acpi_tb_validate_table
  223. *
  224. * PARAMETERS: table_desc - Table descriptor
  225. *
  226. * RETURN: Status
  227. *
  228. * DESCRIPTION: This function is called to validate the table, the returned
  229. * table descriptor is in "VALIDATED" state.
  230. *
  231. *****************************************************************************/
  232. acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
  233. {
  234. acpi_status status = AE_OK;
  235. ACPI_FUNCTION_TRACE(tb_validate_table);
  236. /* Validate the table if necessary */
  237. if (!table_desc->pointer) {
  238. status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
  239. &table_desc->length,
  240. &table_desc->flags);
  241. if (!table_desc->pointer) {
  242. status = AE_NO_MEMORY;
  243. }
  244. }
  245. return_ACPI_STATUS(status);
  246. }
  247. /*******************************************************************************
  248. *
  249. * FUNCTION: acpi_tb_invalidate_table
  250. *
  251. * PARAMETERS: table_desc - Table descriptor
  252. *
  253. * RETURN: None
  254. *
  255. * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
  256. * acpi_tb_validate_table().
  257. *
  258. ******************************************************************************/
  259. void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
  260. {
  261. ACPI_FUNCTION_TRACE(tb_invalidate_table);
  262. /* Table must be validated */
  263. if (!table_desc->pointer) {
  264. return_VOID;
  265. }
  266. acpi_tb_release_table(table_desc->pointer, table_desc->length,
  267. table_desc->flags);
  268. table_desc->pointer = NULL;
  269. return_VOID;
  270. }
  271. /******************************************************************************
  272. *
  273. * FUNCTION: acpi_tb_validate_temp_table
  274. *
  275. * PARAMETERS: table_desc - Table descriptor
  276. *
  277. * RETURN: Status
  278. *
  279. * DESCRIPTION: This function is called to validate the table, the returned
  280. * table descriptor is in "VALIDATED" state.
  281. *
  282. *****************************************************************************/
  283. acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
  284. {
  285. if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) {
  286. /*
  287. * Only validates the header of the table.
  288. * Note that Length contains the size of the mapping after invoking
  289. * this work around, this value is required by
  290. * acpi_tb_release_temp_table().
  291. * We can do this because in acpi_init_table_descriptor(), the Length
  292. * field of the installed descriptor is filled with the actual
  293. * table length obtaining from the table header.
  294. */
  295. table_desc->length = sizeof(struct acpi_table_header);
  296. }
  297. return (acpi_tb_validate_table(table_desc));
  298. }
  299. /******************************************************************************
  300. *
  301. * FUNCTION: acpi_tb_verify_temp_table
  302. *
  303. * PARAMETERS: table_desc - Table descriptor
  304. * signature - Table signature to verify
  305. *
  306. * RETURN: Status
  307. *
  308. * DESCRIPTION: This function is called to validate and verify the table, the
  309. * returned table descriptor is in "VALIDATED" state.
  310. *
  311. *****************************************************************************/
  312. acpi_status
  313. acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature)
  314. {
  315. acpi_status status = AE_OK;
  316. ACPI_FUNCTION_TRACE(tb_verify_temp_table);
  317. /* Validate the table */
  318. status = acpi_tb_validate_temp_table(table_desc);
  319. if (ACPI_FAILURE(status)) {
  320. return_ACPI_STATUS(AE_NO_MEMORY);
  321. }
  322. /* If a particular signature is expected (DSDT/FACS), it must match */
  323. if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) {
  324. ACPI_BIOS_ERROR((AE_INFO,
  325. "Invalid signature 0x%X for ACPI table, expected [%s]",
  326. table_desc->signature.integer, signature));
  327. status = AE_BAD_SIGNATURE;
  328. goto invalidate_and_exit;
  329. }
  330. /* Verify the checksum */
  331. if (acpi_gbl_verify_table_checksum) {
  332. status =
  333. acpi_tb_verify_checksum(table_desc->pointer,
  334. table_desc->length);
  335. if (ACPI_FAILURE(status)) {
  336. ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
  337. "%4.4s 0x%8.8X%8.8X"
  338. " Attempted table install failed",
  339. acpi_ut_valid_acpi_name(table_desc->
  340. signature.
  341. ascii) ?
  342. table_desc->signature.ascii : "????",
  343. ACPI_FORMAT_UINT64(table_desc->
  344. address)));
  345. goto invalidate_and_exit;
  346. }
  347. }
  348. return_ACPI_STATUS(AE_OK);
  349. invalidate_and_exit:
  350. acpi_tb_invalidate_table(table_desc);
  351. return_ACPI_STATUS(status);
  352. }
  353. /*******************************************************************************
  354. *
  355. * FUNCTION: acpi_tb_resize_root_table_list
  356. *
  357. * PARAMETERS: None
  358. *
  359. * RETURN: Status
  360. *
  361. * DESCRIPTION: Expand the size of global table array
  362. *
  363. ******************************************************************************/
  364. acpi_status acpi_tb_resize_root_table_list(void)
  365. {
  366. struct acpi_table_desc *tables;
  367. u32 table_count;
  368. ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
  369. /* allow_resize flag is a parameter to acpi_initialize_tables */
  370. if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
  371. ACPI_ERROR((AE_INFO,
  372. "Resize of Root Table Array is not allowed"));
  373. return_ACPI_STATUS(AE_SUPPORT);
  374. }
  375. /* Increase the Table Array size */
  376. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  377. table_count = acpi_gbl_root_table_list.max_table_count;
  378. } else {
  379. table_count = acpi_gbl_root_table_list.current_table_count;
  380. }
  381. tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
  382. ACPI_ROOT_TABLE_SIZE_INCREMENT) *
  383. sizeof(struct acpi_table_desc));
  384. if (!tables) {
  385. ACPI_ERROR((AE_INFO,
  386. "Could not allocate new root table array"));
  387. return_ACPI_STATUS(AE_NO_MEMORY);
  388. }
  389. /* Copy and free the previous table array */
  390. if (acpi_gbl_root_table_list.tables) {
  391. memcpy(tables, acpi_gbl_root_table_list.tables,
  392. (acpi_size) table_count *
  393. sizeof(struct acpi_table_desc));
  394. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  395. ACPI_FREE(acpi_gbl_root_table_list.tables);
  396. }
  397. }
  398. acpi_gbl_root_table_list.tables = tables;
  399. acpi_gbl_root_table_list.max_table_count =
  400. table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
  401. acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
  402. return_ACPI_STATUS(AE_OK);
  403. }
  404. /*******************************************************************************
  405. *
  406. * FUNCTION: acpi_tb_get_next_table_descriptor
  407. *
  408. * PARAMETERS: table_index - Where table index is returned
  409. * table_desc - Where table descriptor is returned
  410. *
  411. * RETURN: Status and table index/descriptor.
  412. *
  413. * DESCRIPTION: Allocate a new ACPI table entry to the global table list
  414. *
  415. ******************************************************************************/
  416. acpi_status
  417. acpi_tb_get_next_table_descriptor(u32 *table_index,
  418. struct acpi_table_desc **table_desc)
  419. {
  420. acpi_status status;
  421. u32 i;
  422. /* Ensure that there is room for the table in the Root Table List */
  423. if (acpi_gbl_root_table_list.current_table_count >=
  424. acpi_gbl_root_table_list.max_table_count) {
  425. status = acpi_tb_resize_root_table_list();
  426. if (ACPI_FAILURE(status)) {
  427. return (status);
  428. }
  429. }
  430. i = acpi_gbl_root_table_list.current_table_count;
  431. acpi_gbl_root_table_list.current_table_count++;
  432. if (table_index) {
  433. *table_index = i;
  434. }
  435. if (table_desc) {
  436. *table_desc = &acpi_gbl_root_table_list.tables[i];
  437. }
  438. return (AE_OK);
  439. }
  440. /*******************************************************************************
  441. *
  442. * FUNCTION: acpi_tb_terminate
  443. *
  444. * PARAMETERS: None
  445. *
  446. * RETURN: None
  447. *
  448. * DESCRIPTION: Delete all internal ACPI tables
  449. *
  450. ******************************************************************************/
  451. void acpi_tb_terminate(void)
  452. {
  453. u32 i;
  454. ACPI_FUNCTION_TRACE(tb_terminate);
  455. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  456. /* Delete the individual tables */
  457. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
  458. acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
  459. }
  460. /*
  461. * Delete the root table array if allocated locally. Array cannot be
  462. * mapped, so we don't need to check for that flag.
  463. */
  464. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  465. ACPI_FREE(acpi_gbl_root_table_list.tables);
  466. }
  467. acpi_gbl_root_table_list.tables = NULL;
  468. acpi_gbl_root_table_list.flags = 0;
  469. acpi_gbl_root_table_list.current_table_count = 0;
  470. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
  471. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  472. return_VOID;
  473. }
  474. /*******************************************************************************
  475. *
  476. * FUNCTION: acpi_tb_delete_namespace_by_owner
  477. *
  478. * PARAMETERS: table_index - Table index
  479. *
  480. * RETURN: Status
  481. *
  482. * DESCRIPTION: Delete all namespace objects created when this table was loaded.
  483. *
  484. ******************************************************************************/
  485. acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
  486. {
  487. acpi_owner_id owner_id;
  488. acpi_status status;
  489. ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
  490. status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  491. if (ACPI_FAILURE(status)) {
  492. return_ACPI_STATUS(status);
  493. }
  494. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  495. /* The table index does not exist */
  496. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  497. return_ACPI_STATUS(AE_NOT_EXIST);
  498. }
  499. /* Get the owner ID for this table, used to delete namespace nodes */
  500. owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
  501. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  502. /*
  503. * Need to acquire the namespace writer lock to prevent interference
  504. * with any concurrent namespace walks. The interpreter must be
  505. * released during the deletion since the acquisition of the deletion
  506. * lock may block, and also since the execution of a namespace walk
  507. * must be allowed to use the interpreter.
  508. */
  509. (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
  510. status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
  511. acpi_ns_delete_namespace_by_owner(owner_id);
  512. if (ACPI_FAILURE(status)) {
  513. return_ACPI_STATUS(status);
  514. }
  515. acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
  516. status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
  517. return_ACPI_STATUS(status);
  518. }
  519. /*******************************************************************************
  520. *
  521. * FUNCTION: acpi_tb_allocate_owner_id
  522. *
  523. * PARAMETERS: table_index - Table index
  524. *
  525. * RETURN: Status
  526. *
  527. * DESCRIPTION: Allocates owner_id in table_desc
  528. *
  529. ******************************************************************************/
  530. acpi_status acpi_tb_allocate_owner_id(u32 table_index)
  531. {
  532. acpi_status status = AE_BAD_PARAMETER;
  533. ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
  534. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  535. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  536. status =
  537. acpi_ut_allocate_owner_id(&
  538. (acpi_gbl_root_table_list.
  539. tables[table_index].owner_id));
  540. }
  541. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  542. return_ACPI_STATUS(status);
  543. }
  544. /*******************************************************************************
  545. *
  546. * FUNCTION: acpi_tb_release_owner_id
  547. *
  548. * PARAMETERS: table_index - Table index
  549. *
  550. * RETURN: Status
  551. *
  552. * DESCRIPTION: Releases owner_id in table_desc
  553. *
  554. ******************************************************************************/
  555. acpi_status acpi_tb_release_owner_id(u32 table_index)
  556. {
  557. acpi_status status = AE_BAD_PARAMETER;
  558. ACPI_FUNCTION_TRACE(tb_release_owner_id);
  559. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  560. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  561. acpi_ut_release_owner_id(&
  562. (acpi_gbl_root_table_list.
  563. tables[table_index].owner_id));
  564. status = AE_OK;
  565. }
  566. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  567. return_ACPI_STATUS(status);
  568. }
  569. /*******************************************************************************
  570. *
  571. * FUNCTION: acpi_tb_get_owner_id
  572. *
  573. * PARAMETERS: table_index - Table index
  574. * owner_id - Where the table owner_id is returned
  575. *
  576. * RETURN: Status
  577. *
  578. * DESCRIPTION: returns owner_id for the ACPI table
  579. *
  580. ******************************************************************************/
  581. acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id)
  582. {
  583. acpi_status status = AE_BAD_PARAMETER;
  584. ACPI_FUNCTION_TRACE(tb_get_owner_id);
  585. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  586. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  587. *owner_id =
  588. acpi_gbl_root_table_list.tables[table_index].owner_id;
  589. status = AE_OK;
  590. }
  591. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  592. return_ACPI_STATUS(status);
  593. }
  594. /*******************************************************************************
  595. *
  596. * FUNCTION: acpi_tb_is_table_loaded
  597. *
  598. * PARAMETERS: table_index - Index into the root table
  599. *
  600. * RETURN: Table Loaded Flag
  601. *
  602. ******************************************************************************/
  603. u8 acpi_tb_is_table_loaded(u32 table_index)
  604. {
  605. u8 is_loaded = FALSE;
  606. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  607. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  608. is_loaded = (u8)
  609. (acpi_gbl_root_table_list.tables[table_index].flags &
  610. ACPI_TABLE_IS_LOADED);
  611. }
  612. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  613. return (is_loaded);
  614. }
  615. /*******************************************************************************
  616. *
  617. * FUNCTION: acpi_tb_set_table_loaded_flag
  618. *
  619. * PARAMETERS: table_index - Table index
  620. * is_loaded - TRUE if table is loaded, FALSE otherwise
  621. *
  622. * RETURN: None
  623. *
  624. * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
  625. *
  626. ******************************************************************************/
  627. void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
  628. {
  629. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  630. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  631. if (is_loaded) {
  632. acpi_gbl_root_table_list.tables[table_index].flags |=
  633. ACPI_TABLE_IS_LOADED;
  634. } else {
  635. acpi_gbl_root_table_list.tables[table_index].flags &=
  636. ~ACPI_TABLE_IS_LOADED;
  637. }
  638. }
  639. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  640. }