tbxface.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /******************************************************************************
  2. *
  3. * Module Name: tbxface - Public interfaces to the ACPI subsystem
  4. * ACPI table oriented interfaces
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2012, Intel Corp.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18. * substantially similar to the "NO WARRANTY" disclaimer below
  19. * ("Disclaimer") and any redistribution must be conditioned upon
  20. * including a substantially similar Disclaimer requirement for further
  21. * binary redistribution.
  22. * 3. Neither the names of the above-listed copyright holders nor the names
  23. * of any contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * Alternatively, this software may be distributed under the terms of the
  27. * GNU General Public License ("GPL") version 2 as published by the Free
  28. * Software Foundation.
  29. *
  30. * NO WARRANTY
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGES.
  42. */
  43. #include <linux/export.h>
  44. #include <acpi/acpi.h>
  45. #include "accommon.h"
  46. #include "acnamesp.h"
  47. #include "actables.h"
  48. #define _COMPONENT ACPI_TABLES
  49. ACPI_MODULE_NAME("tbxface")
  50. /* Local prototypes */
  51. static acpi_status acpi_tb_load_namespace(void);
  52. static int no_auto_ssdt;
  53. /*******************************************************************************
  54. *
  55. * FUNCTION: acpi_allocate_root_table
  56. *
  57. * PARAMETERS: initial_table_count - Size of initial_table_array, in number of
  58. * struct acpi_table_desc structures
  59. *
  60. * RETURN: Status
  61. *
  62. * DESCRIPTION: Allocate a root table array. Used by i_aSL compiler and
  63. * acpi_initialize_tables.
  64. *
  65. ******************************************************************************/
  66. acpi_status acpi_allocate_root_table(u32 initial_table_count)
  67. {
  68. acpi_gbl_root_table_list.max_table_count = initial_table_count;
  69. acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
  70. return (acpi_tb_resize_root_table_list());
  71. }
  72. /*******************************************************************************
  73. *
  74. * FUNCTION: acpi_initialize_tables
  75. *
  76. * PARAMETERS: initial_table_array - Pointer to an array of pre-allocated
  77. * struct acpi_table_desc structures. If NULL, the
  78. * array is dynamically allocated.
  79. * initial_table_count - Size of initial_table_array, in number of
  80. * struct acpi_table_desc structures
  81. * allow_realloc - Flag to tell Table Manager if resize of
  82. * pre-allocated array is allowed. Ignored
  83. * if initial_table_array is NULL.
  84. *
  85. * RETURN: Status
  86. *
  87. * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
  88. *
  89. * NOTE: Allows static allocation of the initial table array in order
  90. * to avoid the use of dynamic memory in confined environments
  91. * such as the kernel boot sequence where it may not be available.
  92. *
  93. * If the host OS memory managers are initialized, use NULL for
  94. * initial_table_array, and the table will be dynamically allocated.
  95. *
  96. ******************************************************************************/
  97. acpi_status __init
  98. acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
  99. u32 initial_table_count, u8 allow_resize)
  100. {
  101. acpi_physical_address rsdp_address;
  102. acpi_status status;
  103. ACPI_FUNCTION_TRACE(acpi_initialize_tables);
  104. /*
  105. * Set up the Root Table Array
  106. * Allocate the table array if requested
  107. */
  108. if (!initial_table_array) {
  109. status = acpi_allocate_root_table(initial_table_count);
  110. if (ACPI_FAILURE(status)) {
  111. return_ACPI_STATUS(status);
  112. }
  113. } else {
  114. /* Root Table Array has been statically allocated by the host */
  115. ACPI_MEMSET(initial_table_array, 0,
  116. (acpi_size) initial_table_count *
  117. sizeof(struct acpi_table_desc));
  118. acpi_gbl_root_table_list.tables = initial_table_array;
  119. acpi_gbl_root_table_list.max_table_count = initial_table_count;
  120. acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
  121. if (allow_resize) {
  122. acpi_gbl_root_table_list.flags |=
  123. ACPI_ROOT_ALLOW_RESIZE;
  124. }
  125. }
  126. /* Get the address of the RSDP */
  127. rsdp_address = acpi_os_get_root_pointer();
  128. if (!rsdp_address) {
  129. return_ACPI_STATUS(AE_NOT_FOUND);
  130. }
  131. /*
  132. * Get the root table (RSDT or XSDT) and extract all entries to the local
  133. * Root Table Array. This array contains the information of the RSDT/XSDT
  134. * in a common, more useable format.
  135. */
  136. status = acpi_tb_parse_root_table(rsdp_address);
  137. return_ACPI_STATUS(status);
  138. }
  139. /*******************************************************************************
  140. *
  141. * FUNCTION: acpi_reallocate_root_table
  142. *
  143. * PARAMETERS: None
  144. *
  145. * RETURN: Status
  146. *
  147. * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
  148. * root list from the previously provided scratch area. Should
  149. * be called once dynamic memory allocation is available in the
  150. * kernel
  151. *
  152. ******************************************************************************/
  153. acpi_status acpi_reallocate_root_table(void)
  154. {
  155. struct acpi_table_desc *tables;
  156. acpi_size new_size;
  157. acpi_size current_size;
  158. ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
  159. /*
  160. * Only reallocate the root table if the host provided a static buffer
  161. * for the table array in the call to acpi_initialize_tables.
  162. */
  163. if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
  164. return_ACPI_STATUS(AE_SUPPORT);
  165. }
  166. /*
  167. * Get the current size of the root table and add the default
  168. * increment to create the new table size.
  169. */
  170. current_size = (acpi_size)
  171. acpi_gbl_root_table_list.current_table_count *
  172. sizeof(struct acpi_table_desc);
  173. new_size = current_size +
  174. (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc));
  175. /* Create new array and copy the old array */
  176. tables = ACPI_ALLOCATE_ZEROED(new_size);
  177. if (!tables) {
  178. return_ACPI_STATUS(AE_NO_MEMORY);
  179. }
  180. ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size);
  181. /*
  182. * Update the root table descriptor. The new size will be the current
  183. * number of tables plus the increment, independent of the reserved
  184. * size of the original table list.
  185. */
  186. acpi_gbl_root_table_list.tables = tables;
  187. acpi_gbl_root_table_list.max_table_count =
  188. acpi_gbl_root_table_list.current_table_count +
  189. ACPI_ROOT_TABLE_SIZE_INCREMENT;
  190. acpi_gbl_root_table_list.flags =
  191. ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
  192. return_ACPI_STATUS(AE_OK);
  193. }
  194. /*******************************************************************************
  195. *
  196. * FUNCTION: acpi_load_table
  197. *
  198. * PARAMETERS: table_ptr - pointer to a buffer containing the entire
  199. * table to be loaded
  200. *
  201. * RETURN: Status
  202. *
  203. * DESCRIPTION: This function is called to load a table from the caller's
  204. * buffer. The buffer must contain an entire ACPI Table including
  205. * a valid header. The header fields will be verified, and if it
  206. * is determined that the table is invalid, the call will fail.
  207. *
  208. ******************************************************************************/
  209. acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
  210. {
  211. acpi_status status;
  212. u32 table_index;
  213. struct acpi_table_desc table_desc;
  214. if (!table_ptr)
  215. return AE_BAD_PARAMETER;
  216. ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
  217. table_desc.pointer = table_ptr;
  218. table_desc.length = table_ptr->length;
  219. table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN;
  220. /*
  221. * Install the new table into the local data structures
  222. */
  223. status = acpi_tb_add_table(&table_desc, &table_index);
  224. if (ACPI_FAILURE(status)) {
  225. return status;
  226. }
  227. status = acpi_ns_load_table(table_index, acpi_gbl_root_node);
  228. return status;
  229. }
  230. ACPI_EXPORT_SYMBOL(acpi_load_table)
  231. /*******************************************************************************
  232. *
  233. * FUNCTION: acpi_get_table_header
  234. *
  235. * PARAMETERS: Signature - ACPI signature of needed table
  236. * Instance - Which instance (for SSDTs)
  237. * out_table_header - The pointer to the table header to fill
  238. *
  239. * RETURN: Status and pointer to mapped table header
  240. *
  241. * DESCRIPTION: Finds an ACPI table header.
  242. *
  243. * NOTE: Caller is responsible in unmapping the header with
  244. * acpi_os_unmap_memory
  245. *
  246. ******************************************************************************/
  247. acpi_status
  248. acpi_get_table_header(char *signature,
  249. u32 instance, struct acpi_table_header *out_table_header)
  250. {
  251. u32 i;
  252. u32 j;
  253. struct acpi_table_header *header;
  254. /* Parameter validation */
  255. if (!signature || !out_table_header) {
  256. return (AE_BAD_PARAMETER);
  257. }
  258. /* Walk the root table list */
  259. for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
  260. i++) {
  261. if (!ACPI_COMPARE_NAME
  262. (&(acpi_gbl_root_table_list.tables[i].signature),
  263. signature)) {
  264. continue;
  265. }
  266. if (++j < instance) {
  267. continue;
  268. }
  269. if (!acpi_gbl_root_table_list.tables[i].pointer) {
  270. if ((acpi_gbl_root_table_list.tables[i].flags &
  271. ACPI_TABLE_ORIGIN_MASK) ==
  272. ACPI_TABLE_ORIGIN_MAPPED) {
  273. header =
  274. acpi_os_map_memory(acpi_gbl_root_table_list.
  275. tables[i].address,
  276. sizeof(struct
  277. acpi_table_header));
  278. if (!header) {
  279. return AE_NO_MEMORY;
  280. }
  281. ACPI_MEMCPY(out_table_header, header,
  282. sizeof(struct acpi_table_header));
  283. acpi_os_unmap_memory(header,
  284. sizeof(struct
  285. acpi_table_header));
  286. } else {
  287. return AE_NOT_FOUND;
  288. }
  289. } else {
  290. ACPI_MEMCPY(out_table_header,
  291. acpi_gbl_root_table_list.tables[i].pointer,
  292. sizeof(struct acpi_table_header));
  293. }
  294. return (AE_OK);
  295. }
  296. return (AE_NOT_FOUND);
  297. }
  298. ACPI_EXPORT_SYMBOL(acpi_get_table_header)
  299. /*******************************************************************************
  300. *
  301. * FUNCTION: acpi_unload_table_id
  302. *
  303. * PARAMETERS: id - Owner ID of the table to be removed.
  304. *
  305. * RETURN: Status
  306. *
  307. * DESCRIPTION: This routine is used to force the unload of a table (by id)
  308. *
  309. ******************************************************************************/
  310. acpi_status acpi_unload_table_id(acpi_owner_id id)
  311. {
  312. int i;
  313. acpi_status status = AE_NOT_EXIST;
  314. ACPI_FUNCTION_TRACE(acpi_unload_table_id);
  315. /* Find table in the global table list */
  316. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
  317. if (id != acpi_gbl_root_table_list.tables[i].owner_id) {
  318. continue;
  319. }
  320. /*
  321. * Delete all namespace objects owned by this table. Note that these
  322. * objects can appear anywhere in the namespace by virtue of the AML
  323. * "Scope" operator. Thus, we need to track ownership by an ID, not
  324. * simply a position within the hierarchy
  325. */
  326. acpi_tb_delete_namespace_by_owner(i);
  327. status = acpi_tb_release_owner_id(i);
  328. acpi_tb_set_table_loaded_flag(i, FALSE);
  329. break;
  330. }
  331. return_ACPI_STATUS(status);
  332. }
  333. ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
  334. /*******************************************************************************
  335. *
  336. * FUNCTION: acpi_get_table_with_size
  337. *
  338. * PARAMETERS: Signature - ACPI signature of needed table
  339. * Instance - Which instance (for SSDTs)
  340. * out_table - Where the pointer to the table is returned
  341. *
  342. * RETURN: Status and pointer to table
  343. *
  344. * DESCRIPTION: Finds and verifies an ACPI table.
  345. *
  346. ******************************************************************************/
  347. acpi_status
  348. acpi_get_table_with_size(char *signature,
  349. u32 instance, struct acpi_table_header **out_table,
  350. acpi_size *tbl_size)
  351. {
  352. u32 i;
  353. u32 j;
  354. acpi_status status;
  355. /* Parameter validation */
  356. if (!signature || !out_table) {
  357. return (AE_BAD_PARAMETER);
  358. }
  359. /* Walk the root table list */
  360. for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
  361. i++) {
  362. if (!ACPI_COMPARE_NAME
  363. (&(acpi_gbl_root_table_list.tables[i].signature),
  364. signature)) {
  365. continue;
  366. }
  367. if (++j < instance) {
  368. continue;
  369. }
  370. status =
  371. acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
  372. if (ACPI_SUCCESS(status)) {
  373. *out_table = acpi_gbl_root_table_list.tables[i].pointer;
  374. *tbl_size = acpi_gbl_root_table_list.tables[i].length;
  375. }
  376. if (!acpi_gbl_permanent_mmap) {
  377. acpi_gbl_root_table_list.tables[i].pointer = NULL;
  378. }
  379. return (status);
  380. }
  381. return (AE_NOT_FOUND);
  382. }
  383. ACPI_EXPORT_SYMBOL(acpi_get_table_with_size)
  384. acpi_status
  385. acpi_get_table(char *signature,
  386. u32 instance, struct acpi_table_header **out_table)
  387. {
  388. acpi_size tbl_size;
  389. return acpi_get_table_with_size(signature,
  390. instance, out_table, &tbl_size);
  391. }
  392. ACPI_EXPORT_SYMBOL(acpi_get_table)
  393. /*******************************************************************************
  394. *
  395. * FUNCTION: acpi_get_table_by_index
  396. *
  397. * PARAMETERS: table_index - Table index
  398. * Table - Where the pointer to the table is returned
  399. *
  400. * RETURN: Status and pointer to the table
  401. *
  402. * DESCRIPTION: Obtain a table by an index into the global table list.
  403. *
  404. ******************************************************************************/
  405. acpi_status
  406. acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table)
  407. {
  408. acpi_status status;
  409. ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
  410. /* Parameter validation */
  411. if (!table) {
  412. return_ACPI_STATUS(AE_BAD_PARAMETER);
  413. }
  414. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  415. /* Validate index */
  416. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  417. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  418. return_ACPI_STATUS(AE_BAD_PARAMETER);
  419. }
  420. if (!acpi_gbl_root_table_list.tables[table_index].pointer) {
  421. /* Table is not mapped, map it */
  422. status =
  423. acpi_tb_verify_table(&acpi_gbl_root_table_list.
  424. tables[table_index]);
  425. if (ACPI_FAILURE(status)) {
  426. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  427. return_ACPI_STATUS(status);
  428. }
  429. }
  430. *table = acpi_gbl_root_table_list.tables[table_index].pointer;
  431. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  432. return_ACPI_STATUS(AE_OK);
  433. }
  434. ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
  435. /*******************************************************************************
  436. *
  437. * FUNCTION: acpi_tb_load_namespace
  438. *
  439. * PARAMETERS: None
  440. *
  441. * RETURN: Status
  442. *
  443. * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
  444. * the RSDT/XSDT.
  445. *
  446. ******************************************************************************/
  447. static acpi_status acpi_tb_load_namespace(void)
  448. {
  449. acpi_status status;
  450. u32 i;
  451. struct acpi_table_header *new_dsdt;
  452. ACPI_FUNCTION_TRACE(tb_load_namespace);
  453. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  454. /*
  455. * Load the namespace. The DSDT is required, but any SSDT and
  456. * PSDT tables are optional. Verify the DSDT.
  457. */
  458. if (!acpi_gbl_root_table_list.current_table_count ||
  459. !ACPI_COMPARE_NAME(&
  460. (acpi_gbl_root_table_list.
  461. tables[ACPI_TABLE_INDEX_DSDT].signature),
  462. ACPI_SIG_DSDT)
  463. ||
  464. ACPI_FAILURE(acpi_tb_verify_table
  465. (&acpi_gbl_root_table_list.
  466. tables[ACPI_TABLE_INDEX_DSDT]))) {
  467. status = AE_NO_ACPI_TABLES;
  468. goto unlock_and_exit;
  469. }
  470. /*
  471. * Save the DSDT pointer for simple access. This is the mapped memory
  472. * address. We must take care here because the address of the .Tables
  473. * array can change dynamically as tables are loaded at run-time. Note:
  474. * .Pointer field is not validated until after call to acpi_tb_verify_table.
  475. */
  476. acpi_gbl_DSDT =
  477. acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer;
  478. /*
  479. * Optionally copy the entire DSDT to local memory (instead of simply
  480. * mapping it.) There are some BIOSs that corrupt or replace the original
  481. * DSDT, creating the need for this option. Default is FALSE, do not copy
  482. * the DSDT.
  483. */
  484. if (acpi_gbl_copy_dsdt_locally) {
  485. new_dsdt = acpi_tb_copy_dsdt(ACPI_TABLE_INDEX_DSDT);
  486. if (new_dsdt) {
  487. acpi_gbl_DSDT = new_dsdt;
  488. }
  489. }
  490. /*
  491. * Save the original DSDT header for detection of table corruption
  492. * and/or replacement of the DSDT from outside the OS.
  493. */
  494. ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT,
  495. sizeof(struct acpi_table_header));
  496. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  497. /* Load and parse tables */
  498. status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
  499. if (ACPI_FAILURE(status)) {
  500. return_ACPI_STATUS(status);
  501. }
  502. /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
  503. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  504. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
  505. if ((!ACPI_COMPARE_NAME
  506. (&(acpi_gbl_root_table_list.tables[i].signature),
  507. ACPI_SIG_SSDT)
  508. &&
  509. !ACPI_COMPARE_NAME(&
  510. (acpi_gbl_root_table_list.tables[i].
  511. signature), ACPI_SIG_PSDT))
  512. ||
  513. ACPI_FAILURE(acpi_tb_verify_table
  514. (&acpi_gbl_root_table_list.tables[i]))) {
  515. continue;
  516. }
  517. if (no_auto_ssdt) {
  518. printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n");
  519. continue;
  520. }
  521. /* Ignore errors while loading tables, get as many as possible */
  522. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  523. (void)acpi_ns_load_table(i, acpi_gbl_root_node);
  524. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  525. }
  526. ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
  527. unlock_and_exit:
  528. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  529. return_ACPI_STATUS(status);
  530. }
  531. /*******************************************************************************
  532. *
  533. * FUNCTION: acpi_load_tables
  534. *
  535. * PARAMETERS: None
  536. *
  537. * RETURN: Status
  538. *
  539. * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
  540. *
  541. ******************************************************************************/
  542. acpi_status acpi_load_tables(void)
  543. {
  544. acpi_status status;
  545. ACPI_FUNCTION_TRACE(acpi_load_tables);
  546. /* Load the namespace from the tables */
  547. status = acpi_tb_load_namespace();
  548. if (ACPI_FAILURE(status)) {
  549. ACPI_EXCEPTION((AE_INFO, status,
  550. "While loading namespace from ACPI tables"));
  551. }
  552. return_ACPI_STATUS(status);
  553. }
  554. ACPI_EXPORT_SYMBOL(acpi_load_tables)
  555. /*******************************************************************************
  556. *
  557. * FUNCTION: acpi_install_table_handler
  558. *
  559. * PARAMETERS: Handler - Table event handler
  560. * Context - Value passed to the handler on each event
  561. *
  562. * RETURN: Status
  563. *
  564. * DESCRIPTION: Install table event handler
  565. *
  566. ******************************************************************************/
  567. acpi_status
  568. acpi_install_table_handler(acpi_tbl_handler handler, void *context)
  569. {
  570. acpi_status status;
  571. ACPI_FUNCTION_TRACE(acpi_install_table_handler);
  572. if (!handler) {
  573. return_ACPI_STATUS(AE_BAD_PARAMETER);
  574. }
  575. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  576. if (ACPI_FAILURE(status)) {
  577. return_ACPI_STATUS(status);
  578. }
  579. /* Don't allow more than one handler */
  580. if (acpi_gbl_table_handler) {
  581. status = AE_ALREADY_EXISTS;
  582. goto cleanup;
  583. }
  584. /* Install the handler */
  585. acpi_gbl_table_handler = handler;
  586. acpi_gbl_table_handler_context = context;
  587. cleanup:
  588. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  589. return_ACPI_STATUS(status);
  590. }
  591. ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
  592. /*******************************************************************************
  593. *
  594. * FUNCTION: acpi_remove_table_handler
  595. *
  596. * PARAMETERS: Handler - Table event handler that was installed
  597. * previously.
  598. *
  599. * RETURN: Status
  600. *
  601. * DESCRIPTION: Remove table event handler
  602. *
  603. ******************************************************************************/
  604. acpi_status acpi_remove_table_handler(acpi_tbl_handler handler)
  605. {
  606. acpi_status status;
  607. ACPI_FUNCTION_TRACE(acpi_remove_table_handler);
  608. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  609. if (ACPI_FAILURE(status)) {
  610. return_ACPI_STATUS(status);
  611. }
  612. /* Make sure that the installed handler is the same */
  613. if (!handler || handler != acpi_gbl_table_handler) {
  614. status = AE_BAD_PARAMETER;
  615. goto cleanup;
  616. }
  617. /* Remove the handler */
  618. acpi_gbl_table_handler = NULL;
  619. cleanup:
  620. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  621. return_ACPI_STATUS(status);
  622. }
  623. ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)
  624. static int __init acpi_no_auto_ssdt_setup(char *s) {
  625. printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
  626. no_auto_ssdt = 1;
  627. return 1;
  628. }
  629. __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);