tbdata.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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 =
  106. ACPI_CAST_PTR(struct acpi_table_header,
  107. table_desc->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, address);
  187. if (!table_header) {
  188. return (AE_NO_MEMORY);
  189. }
  190. acpi_tb_init_table_descriptor(table_desc, address, flags,
  191. table_header);
  192. return (AE_OK);
  193. default:
  194. break;
  195. }
  196. /* Table is not valid yet */
  197. return (AE_NO_MEMORY);
  198. }
  199. /*******************************************************************************
  200. *
  201. * FUNCTION: acpi_tb_release_temp_table
  202. *
  203. * PARAMETERS: table_desc - Table descriptor to be released
  204. *
  205. * RETURN: Status
  206. *
  207. * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table().
  208. *
  209. *****************************************************************************/
  210. void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc)
  211. {
  212. /*
  213. * Note that the .Address is maintained by the callers of
  214. * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table()
  215. * where .Address will be freed.
  216. */
  217. acpi_tb_invalidate_table(table_desc);
  218. }
  219. /******************************************************************************
  220. *
  221. * FUNCTION: acpi_tb_validate_table
  222. *
  223. * PARAMETERS: table_desc - Table descriptor
  224. *
  225. * RETURN: Status
  226. *
  227. * DESCRIPTION: This function is called to validate the table, the returned
  228. * table descriptor is in "VALIDATED" state.
  229. *
  230. *****************************************************************************/
  231. acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
  232. {
  233. acpi_status status = AE_OK;
  234. ACPI_FUNCTION_TRACE(tb_validate_table);
  235. /* Validate the table if necessary */
  236. if (!table_desc->pointer) {
  237. status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
  238. &table_desc->length,
  239. &table_desc->flags);
  240. if (!table_desc->pointer) {
  241. status = AE_NO_MEMORY;
  242. }
  243. }
  244. return_ACPI_STATUS(status);
  245. }
  246. /*******************************************************************************
  247. *
  248. * FUNCTION: acpi_tb_invalidate_table
  249. *
  250. * PARAMETERS: table_desc - Table descriptor
  251. *
  252. * RETURN: None
  253. *
  254. * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
  255. * acpi_tb_validate_table().
  256. *
  257. ******************************************************************************/
  258. void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
  259. {
  260. ACPI_FUNCTION_TRACE(tb_invalidate_table);
  261. /* Table must be validated */
  262. if (!table_desc->pointer) {
  263. return_VOID;
  264. }
  265. acpi_tb_release_table(table_desc->pointer, table_desc->length,
  266. table_desc->flags);
  267. table_desc->pointer = NULL;
  268. return_VOID;
  269. }
  270. /******************************************************************************
  271. *
  272. * FUNCTION: acpi_tb_validate_temp_table
  273. *
  274. * PARAMETERS: table_desc - Table descriptor
  275. *
  276. * RETURN: Status
  277. *
  278. * DESCRIPTION: This function is called to validate the table, the returned
  279. * table descriptor is in "VALIDATED" state.
  280. *
  281. *****************************************************************************/
  282. acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
  283. {
  284. if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) {
  285. /*
  286. * Only validates the header of the table.
  287. * Note that Length contains the size of the mapping after invoking
  288. * this work around, this value is required by
  289. * acpi_tb_release_temp_table().
  290. * We can do this because in acpi_init_table_descriptor(), the Length
  291. * field of the installed descriptor is filled with the actual
  292. * table length obtaining from the table header.
  293. */
  294. table_desc->length = sizeof(struct acpi_table_header);
  295. }
  296. return (acpi_tb_validate_table(table_desc));
  297. }
  298. /******************************************************************************
  299. *
  300. * FUNCTION: acpi_tb_verify_temp_table
  301. *
  302. * PARAMETERS: table_desc - Table descriptor
  303. * signature - Table signature to verify
  304. *
  305. * RETURN: Status
  306. *
  307. * DESCRIPTION: This function is called to validate and verify the table, the
  308. * returned table descriptor is in "VALIDATED" state.
  309. *
  310. *****************************************************************************/
  311. acpi_status
  312. acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature)
  313. {
  314. acpi_status status = AE_OK;
  315. ACPI_FUNCTION_TRACE(tb_verify_temp_table);
  316. /* Validate the table */
  317. status = acpi_tb_validate_temp_table(table_desc);
  318. if (ACPI_FAILURE(status)) {
  319. return_ACPI_STATUS(AE_NO_MEMORY);
  320. }
  321. /* If a particular signature is expected (DSDT/FACS), it must match */
  322. if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) {
  323. ACPI_BIOS_ERROR((AE_INFO,
  324. "Invalid signature 0x%X for ACPI table, expected [%s]",
  325. table_desc->signature.integer, signature));
  326. status = AE_BAD_SIGNATURE;
  327. goto invalidate_and_exit;
  328. }
  329. /* Verify the checksum */
  330. if (acpi_gbl_verify_table_checksum) {
  331. status =
  332. acpi_tb_verify_checksum(table_desc->pointer,
  333. table_desc->length);
  334. if (ACPI_FAILURE(status)) {
  335. ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
  336. "%4.4s " ACPI_PRINTF_UINT
  337. " Attempted table install failed",
  338. acpi_ut_valid_acpi_name(table_desc->
  339. signature.
  340. ascii) ?
  341. table_desc->signature.ascii : "????",
  342. ACPI_FORMAT_TO_UINT(table_desc->
  343. address)));
  344. goto invalidate_and_exit;
  345. }
  346. }
  347. return_ACPI_STATUS(AE_OK);
  348. invalidate_and_exit:
  349. acpi_tb_invalidate_table(table_desc);
  350. return_ACPI_STATUS(status);
  351. }
  352. /*******************************************************************************
  353. *
  354. * FUNCTION: acpi_tb_resize_root_table_list
  355. *
  356. * PARAMETERS: None
  357. *
  358. * RETURN: Status
  359. *
  360. * DESCRIPTION: Expand the size of global table array
  361. *
  362. ******************************************************************************/
  363. acpi_status acpi_tb_resize_root_table_list(void)
  364. {
  365. struct acpi_table_desc *tables;
  366. u32 table_count;
  367. ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
  368. /* allow_resize flag is a parameter to acpi_initialize_tables */
  369. if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
  370. ACPI_ERROR((AE_INFO,
  371. "Resize of Root Table Array is not allowed"));
  372. return_ACPI_STATUS(AE_SUPPORT);
  373. }
  374. /* Increase the Table Array size */
  375. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  376. table_count = acpi_gbl_root_table_list.max_table_count;
  377. } else {
  378. table_count = acpi_gbl_root_table_list.current_table_count;
  379. }
  380. tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
  381. ACPI_ROOT_TABLE_SIZE_INCREMENT) *
  382. sizeof(struct acpi_table_desc));
  383. if (!tables) {
  384. ACPI_ERROR((AE_INFO,
  385. "Could not allocate new root table array"));
  386. return_ACPI_STATUS(AE_NO_MEMORY);
  387. }
  388. /* Copy and free the previous table array */
  389. if (acpi_gbl_root_table_list.tables) {
  390. ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
  391. (acpi_size) table_count *
  392. 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_root_index
  406. *
  407. * PARAMETERS: table_index - Where table index is returned
  408. *
  409. * RETURN: Status and table index.
  410. *
  411. * DESCRIPTION: Allocate a new ACPI table entry to the global table list
  412. *
  413. ******************************************************************************/
  414. acpi_status acpi_tb_get_next_root_index(u32 *table_index)
  415. {
  416. acpi_status status;
  417. /* Ensure that there is room for the table in the Root Table List */
  418. if (acpi_gbl_root_table_list.current_table_count >=
  419. acpi_gbl_root_table_list.max_table_count) {
  420. status = acpi_tb_resize_root_table_list();
  421. if (ACPI_FAILURE(status)) {
  422. return (status);
  423. }
  424. }
  425. *table_index = acpi_gbl_root_table_list.current_table_count;
  426. acpi_gbl_root_table_list.current_table_count++;
  427. return (AE_OK);
  428. }
  429. /*******************************************************************************
  430. *
  431. * FUNCTION: acpi_tb_terminate
  432. *
  433. * PARAMETERS: None
  434. *
  435. * RETURN: None
  436. *
  437. * DESCRIPTION: Delete all internal ACPI tables
  438. *
  439. ******************************************************************************/
  440. void acpi_tb_terminate(void)
  441. {
  442. u32 i;
  443. ACPI_FUNCTION_TRACE(tb_terminate);
  444. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  445. /* Delete the individual tables */
  446. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
  447. acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
  448. }
  449. /*
  450. * Delete the root table array if allocated locally. Array cannot be
  451. * mapped, so we don't need to check for that flag.
  452. */
  453. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  454. ACPI_FREE(acpi_gbl_root_table_list.tables);
  455. }
  456. acpi_gbl_root_table_list.tables = NULL;
  457. acpi_gbl_root_table_list.flags = 0;
  458. acpi_gbl_root_table_list.current_table_count = 0;
  459. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
  460. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  461. return_VOID;
  462. }
  463. /*******************************************************************************
  464. *
  465. * FUNCTION: acpi_tb_delete_namespace_by_owner
  466. *
  467. * PARAMETERS: table_index - Table index
  468. *
  469. * RETURN: Status
  470. *
  471. * DESCRIPTION: Delete all namespace objects created when this table was loaded.
  472. *
  473. ******************************************************************************/
  474. acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
  475. {
  476. acpi_owner_id owner_id;
  477. acpi_status status;
  478. ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
  479. status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  480. if (ACPI_FAILURE(status)) {
  481. return_ACPI_STATUS(status);
  482. }
  483. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  484. /* The table index does not exist */
  485. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  486. return_ACPI_STATUS(AE_NOT_EXIST);
  487. }
  488. /* Get the owner ID for this table, used to delete namespace nodes */
  489. owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
  490. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  491. /*
  492. * Need to acquire the namespace writer lock to prevent interference
  493. * with any concurrent namespace walks. The interpreter must be
  494. * released during the deletion since the acquisition of the deletion
  495. * lock may block, and also since the execution of a namespace walk
  496. * must be allowed to use the interpreter.
  497. */
  498. (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
  499. status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
  500. acpi_ns_delete_namespace_by_owner(owner_id);
  501. if (ACPI_FAILURE(status)) {
  502. return_ACPI_STATUS(status);
  503. }
  504. acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
  505. status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
  506. return_ACPI_STATUS(status);
  507. }
  508. /*******************************************************************************
  509. *
  510. * FUNCTION: acpi_tb_allocate_owner_id
  511. *
  512. * PARAMETERS: table_index - Table index
  513. *
  514. * RETURN: Status
  515. *
  516. * DESCRIPTION: Allocates owner_id in table_desc
  517. *
  518. ******************************************************************************/
  519. acpi_status acpi_tb_allocate_owner_id(u32 table_index)
  520. {
  521. acpi_status status = AE_BAD_PARAMETER;
  522. ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
  523. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  524. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  525. status =
  526. acpi_ut_allocate_owner_id(&
  527. (acpi_gbl_root_table_list.
  528. tables[table_index].owner_id));
  529. }
  530. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  531. return_ACPI_STATUS(status);
  532. }
  533. /*******************************************************************************
  534. *
  535. * FUNCTION: acpi_tb_release_owner_id
  536. *
  537. * PARAMETERS: table_index - Table index
  538. *
  539. * RETURN: Status
  540. *
  541. * DESCRIPTION: Releases owner_id in table_desc
  542. *
  543. ******************************************************************************/
  544. acpi_status acpi_tb_release_owner_id(u32 table_index)
  545. {
  546. acpi_status status = AE_BAD_PARAMETER;
  547. ACPI_FUNCTION_TRACE(tb_release_owner_id);
  548. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  549. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  550. acpi_ut_release_owner_id(&
  551. (acpi_gbl_root_table_list.
  552. tables[table_index].owner_id));
  553. status = AE_OK;
  554. }
  555. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  556. return_ACPI_STATUS(status);
  557. }
  558. /*******************************************************************************
  559. *
  560. * FUNCTION: acpi_tb_get_owner_id
  561. *
  562. * PARAMETERS: table_index - Table index
  563. * owner_id - Where the table owner_id is returned
  564. *
  565. * RETURN: Status
  566. *
  567. * DESCRIPTION: returns owner_id for the ACPI table
  568. *
  569. ******************************************************************************/
  570. acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id)
  571. {
  572. acpi_status status = AE_BAD_PARAMETER;
  573. ACPI_FUNCTION_TRACE(tb_get_owner_id);
  574. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  575. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  576. *owner_id =
  577. acpi_gbl_root_table_list.tables[table_index].owner_id;
  578. status = AE_OK;
  579. }
  580. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  581. return_ACPI_STATUS(status);
  582. }
  583. /*******************************************************************************
  584. *
  585. * FUNCTION: acpi_tb_is_table_loaded
  586. *
  587. * PARAMETERS: table_index - Index into the root table
  588. *
  589. * RETURN: Table Loaded Flag
  590. *
  591. ******************************************************************************/
  592. u8 acpi_tb_is_table_loaded(u32 table_index)
  593. {
  594. u8 is_loaded = FALSE;
  595. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  596. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  597. is_loaded = (u8)
  598. (acpi_gbl_root_table_list.tables[table_index].flags &
  599. ACPI_TABLE_IS_LOADED);
  600. }
  601. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  602. return (is_loaded);
  603. }
  604. /*******************************************************************************
  605. *
  606. * FUNCTION: acpi_tb_set_table_loaded_flag
  607. *
  608. * PARAMETERS: table_index - Table index
  609. * is_loaded - TRUE if table is loaded, FALSE otherwise
  610. *
  611. * RETURN: None
  612. *
  613. * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
  614. *
  615. ******************************************************************************/
  616. void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
  617. {
  618. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  619. if (table_index < acpi_gbl_root_table_list.current_table_count) {
  620. if (is_loaded) {
  621. acpi_gbl_root_table_list.tables[table_index].flags |=
  622. ACPI_TABLE_IS_LOADED;
  623. } else {
  624. acpi_gbl_root_table_list.tables[table_index].flags &=
  625. ~ACPI_TABLE_IS_LOADED;
  626. }
  627. }
  628. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  629. }