tbdata.c 22 KB

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