tbdata.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. /******************************************************************************
  2. *
  3. * Module Name: tbdata - Table manager data structure functions
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, 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_nameseg(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 * sizeof(struct acpi_table_desc));
  393. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  394. ACPI_FREE(acpi_gbl_root_table_list.tables);
  395. }
  396. }
  397. acpi_gbl_root_table_list.tables = tables;
  398. acpi_gbl_root_table_list.max_table_count =
  399. table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
  400. acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
  401. return_ACPI_STATUS(AE_OK);
  402. }
  403. /*******************************************************************************
  404. *
  405. * FUNCTION: acpi_tb_get_next_table_descriptor
  406. *
  407. * PARAMETERS: table_index - Where table index is returned
  408. * table_desc - Where table descriptor is returned
  409. *
  410. * RETURN: Status and table index/descriptor.
  411. *
  412. * DESCRIPTION: Allocate a new ACPI table entry to the global table list
  413. *
  414. ******************************************************************************/
  415. acpi_status
  416. acpi_tb_get_next_table_descriptor(u32 *table_index,
  417. struct acpi_table_desc **table_desc)
  418. {
  419. acpi_status status;
  420. u32 i;
  421. /* Ensure that there is room for the table in the Root Table List */
  422. if (acpi_gbl_root_table_list.current_table_count >=
  423. acpi_gbl_root_table_list.max_table_count) {
  424. status = acpi_tb_resize_root_table_list();
  425. if (ACPI_FAILURE(status)) {
  426. return (status);
  427. }
  428. }
  429. i = acpi_gbl_root_table_list.current_table_count;
  430. acpi_gbl_root_table_list.current_table_count++;
  431. if (table_index) {
  432. *table_index = i;
  433. }
  434. if (table_desc) {
  435. *table_desc = &acpi_gbl_root_table_list.tables[i];
  436. }
  437. return (AE_OK);
  438. }
  439. /*******************************************************************************
  440. *
  441. * FUNCTION: acpi_tb_terminate
  442. *
  443. * PARAMETERS: None
  444. *
  445. * RETURN: None
  446. *
  447. * DESCRIPTION: Delete all internal ACPI tables
  448. *
  449. ******************************************************************************/
  450. void acpi_tb_terminate(void)
  451. {
  452. u32 i;
  453. ACPI_FUNCTION_TRACE(tb_terminate);
  454. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  455. /* Delete the individual tables */
  456. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
  457. acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
  458. }
  459. /*
  460. * Delete the root table array if allocated locally. Array cannot be
  461. * mapped, so we don't need to check for that flag.
  462. */
  463. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  464. ACPI_FREE(acpi_gbl_root_table_list.tables);
  465. }
  466. acpi_gbl_root_table_list.tables = NULL;
  467. acpi_gbl_root_table_list.flags = 0;
  468. acpi_gbl_root_table_list.current_table_count = 0;
  469. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
  470. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  471. return_VOID;
  472. }
  473. /*******************************************************************************
  474. *
  475. * FUNCTION: acpi_tb_delete_namespace_by_owner
  476. *
  477. * PARAMETERS: table_index - Table index
  478. *
  479. * RETURN: Status
  480. *
  481. * DESCRIPTION: Delete all namespace objects created when this table was loaded.
  482. *
  483. ******************************************************************************/
  484. acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
  485. {
  486. acpi_owner_id owner_id;
  487. acpi_status status;
  488. ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
  489. status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  490. if (ACPI_FAILURE(status)) {
  491. return_ACPI_STATUS(status);
  492. }
  493. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  494. /* The table index does not exist */
  495. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  496. return_ACPI_STATUS(AE_NOT_EXIST);
  497. }
  498. /* Get the owner ID for this table, used to delete namespace nodes */
  499. owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
  500. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  501. /*
  502. * Need to acquire the namespace writer lock to prevent interference
  503. * with any concurrent namespace walks. The interpreter must be
  504. * released during the deletion since the acquisition of the deletion
  505. * lock may block, and also since the execution of a namespace walk
  506. * must be allowed to use the interpreter.
  507. */
  508. (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
  509. status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
  510. acpi_ns_delete_namespace_by_owner(owner_id);
  511. if (ACPI_FAILURE(status)) {
  512. return_ACPI_STATUS(status);
  513. }
  514. acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
  515. status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
  516. return_ACPI_STATUS(status);
  517. }
  518. /*******************************************************************************
  519. *
  520. * FUNCTION: acpi_tb_allocate_owner_id
  521. *
  522. * PARAMETERS: table_index - Table index
  523. *
  524. * RETURN: Status
  525. *
  526. * DESCRIPTION: Allocates owner_id in table_desc
  527. *
  528. ******************************************************************************/
  529. acpi_status acpi_tb_allocate_owner_id(u32 table_index)
  530. {
  531. acpi_status status = AE_BAD_PARAMETER;
  532. ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
  533. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  534. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  535. status =
  536. acpi_ut_allocate_owner_id(&
  537. (acpi_gbl_root_table_list.
  538. tables[table_index].owner_id));
  539. }
  540. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  541. return_ACPI_STATUS(status);
  542. }
  543. /*******************************************************************************
  544. *
  545. * FUNCTION: acpi_tb_release_owner_id
  546. *
  547. * PARAMETERS: table_index - Table index
  548. *
  549. * RETURN: Status
  550. *
  551. * DESCRIPTION: Releases owner_id in table_desc
  552. *
  553. ******************************************************************************/
  554. acpi_status acpi_tb_release_owner_id(u32 table_index)
  555. {
  556. acpi_status status = AE_BAD_PARAMETER;
  557. ACPI_FUNCTION_TRACE(tb_release_owner_id);
  558. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  559. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  560. acpi_ut_release_owner_id(&
  561. (acpi_gbl_root_table_list.
  562. tables[table_index].owner_id));
  563. status = AE_OK;
  564. }
  565. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  566. return_ACPI_STATUS(status);
  567. }
  568. /*******************************************************************************
  569. *
  570. * FUNCTION: acpi_tb_get_owner_id
  571. *
  572. * PARAMETERS: table_index - Table index
  573. * owner_id - Where the table owner_id is returned
  574. *
  575. * RETURN: Status
  576. *
  577. * DESCRIPTION: returns owner_id for the ACPI table
  578. *
  579. ******************************************************************************/
  580. acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
  581. {
  582. acpi_status status = AE_BAD_PARAMETER;
  583. ACPI_FUNCTION_TRACE(tb_get_owner_id);
  584. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  585. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  586. *owner_id =
  587. acpi_gbl_root_table_list.tables[table_index].owner_id;
  588. status = AE_OK;
  589. }
  590. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  591. return_ACPI_STATUS(status);
  592. }
  593. /*******************************************************************************
  594. *
  595. * FUNCTION: acpi_tb_is_table_loaded
  596. *
  597. * PARAMETERS: table_index - Index into the root table
  598. *
  599. * RETURN: Table Loaded Flag
  600. *
  601. ******************************************************************************/
  602. u8 acpi_tb_is_table_loaded(u32 table_index)
  603. {
  604. u8 is_loaded = FALSE;
  605. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  606. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  607. is_loaded = (u8)
  608. (acpi_gbl_root_table_list.tables[table_index].flags &
  609. ACPI_TABLE_IS_LOADED);
  610. }
  611. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  612. return (is_loaded);
  613. }
  614. /*******************************************************************************
  615. *
  616. * FUNCTION: acpi_tb_set_table_loaded_flag
  617. *
  618. * PARAMETERS: table_index - Table index
  619. * is_loaded - TRUE if table is loaded, FALSE otherwise
  620. *
  621. * RETURN: None
  622. *
  623. * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
  624. *
  625. ******************************************************************************/
  626. void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
  627. {
  628. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  629. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  630. if (is_loaded) {
  631. acpi_gbl_root_table_list.tables[table_index].flags |=
  632. ACPI_TABLE_IS_LOADED;
  633. } else {
  634. acpi_gbl_root_table_list.tables[table_index].flags &=
  635. ~ACPI_TABLE_IS_LOADED;
  636. }
  637. }
  638. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  639. }