tbxface.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /******************************************************************************
  2. *
  3. * Module Name: tbxface - Public interfaces to the ACPI subsystem
  4. * ACPI table oriented interfaces
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2011, 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_status
  384. acpi_get_table(char *signature,
  385. u32 instance, struct acpi_table_header **out_table)
  386. {
  387. acpi_size tbl_size;
  388. return acpi_get_table_with_size(signature,
  389. instance, out_table, &tbl_size);
  390. }
  391. ACPI_EXPORT_SYMBOL(acpi_get_table)
  392. /*******************************************************************************
  393. *
  394. * FUNCTION: acpi_get_table_by_index
  395. *
  396. * PARAMETERS: table_index - Table index
  397. * Table - Where the pointer to the table is returned
  398. *
  399. * RETURN: Status and pointer to the table
  400. *
  401. * DESCRIPTION: Obtain a table by an index into the global table list.
  402. *
  403. ******************************************************************************/
  404. acpi_status
  405. acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table)
  406. {
  407. acpi_status status;
  408. ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
  409. /* Parameter validation */
  410. if (!table) {
  411. return_ACPI_STATUS(AE_BAD_PARAMETER);
  412. }
  413. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  414. /* Validate index */
  415. if (table_index >= acpi_gbl_root_table_list.current_table_count) {
  416. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  417. return_ACPI_STATUS(AE_BAD_PARAMETER);
  418. }
  419. if (!acpi_gbl_root_table_list.tables[table_index].pointer) {
  420. /* Table is not mapped, map it */
  421. status =
  422. acpi_tb_verify_table(&acpi_gbl_root_table_list.
  423. tables[table_index]);
  424. if (ACPI_FAILURE(status)) {
  425. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  426. return_ACPI_STATUS(status);
  427. }
  428. }
  429. *table = acpi_gbl_root_table_list.tables[table_index].pointer;
  430. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  431. return_ACPI_STATUS(AE_OK);
  432. }
  433. ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
  434. /*******************************************************************************
  435. *
  436. * FUNCTION: acpi_tb_load_namespace
  437. *
  438. * PARAMETERS: None
  439. *
  440. * RETURN: Status
  441. *
  442. * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
  443. * the RSDT/XSDT.
  444. *
  445. ******************************************************************************/
  446. static acpi_status acpi_tb_load_namespace(void)
  447. {
  448. acpi_status status;
  449. u32 i;
  450. struct acpi_table_header *new_dsdt;
  451. ACPI_FUNCTION_TRACE(tb_load_namespace);
  452. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  453. /*
  454. * Load the namespace. The DSDT is required, but any SSDT and
  455. * PSDT tables are optional. Verify the DSDT.
  456. */
  457. if (!acpi_gbl_root_table_list.current_table_count ||
  458. !ACPI_COMPARE_NAME(&
  459. (acpi_gbl_root_table_list.
  460. tables[ACPI_TABLE_INDEX_DSDT].signature),
  461. ACPI_SIG_DSDT)
  462. ||
  463. ACPI_FAILURE(acpi_tb_verify_table
  464. (&acpi_gbl_root_table_list.
  465. tables[ACPI_TABLE_INDEX_DSDT]))) {
  466. status = AE_NO_ACPI_TABLES;
  467. goto unlock_and_exit;
  468. }
  469. /*
  470. * Save the DSDT pointer for simple access. This is the mapped memory
  471. * address. We must take care here because the address of the .Tables
  472. * array can change dynamically as tables are loaded at run-time. Note:
  473. * .Pointer field is not validated until after call to acpi_tb_verify_table.
  474. */
  475. acpi_gbl_DSDT =
  476. acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer;
  477. /*
  478. * Optionally copy the entire DSDT to local memory (instead of simply
  479. * mapping it.) There are some BIOSs that corrupt or replace the original
  480. * DSDT, creating the need for this option. Default is FALSE, do not copy
  481. * the DSDT.
  482. */
  483. if (acpi_gbl_copy_dsdt_locally) {
  484. new_dsdt = acpi_tb_copy_dsdt(ACPI_TABLE_INDEX_DSDT);
  485. if (new_dsdt) {
  486. acpi_gbl_DSDT = new_dsdt;
  487. }
  488. }
  489. /*
  490. * Save the original DSDT header for detection of table corruption
  491. * and/or replacement of the DSDT from outside the OS.
  492. */
  493. ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT,
  494. sizeof(struct acpi_table_header));
  495. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  496. /* Load and parse tables */
  497. status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
  498. if (ACPI_FAILURE(status)) {
  499. return_ACPI_STATUS(status);
  500. }
  501. /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
  502. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  503. for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
  504. if ((!ACPI_COMPARE_NAME
  505. (&(acpi_gbl_root_table_list.tables[i].signature),
  506. ACPI_SIG_SSDT)
  507. &&
  508. !ACPI_COMPARE_NAME(&
  509. (acpi_gbl_root_table_list.tables[i].
  510. signature), ACPI_SIG_PSDT))
  511. ||
  512. ACPI_FAILURE(acpi_tb_verify_table
  513. (&acpi_gbl_root_table_list.tables[i]))) {
  514. continue;
  515. }
  516. if (no_auto_ssdt) {
  517. printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n");
  518. continue;
  519. }
  520. /* Ignore errors while loading tables, get as many as possible */
  521. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  522. (void)acpi_ns_load_table(i, acpi_gbl_root_node);
  523. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  524. }
  525. ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
  526. unlock_and_exit:
  527. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  528. return_ACPI_STATUS(status);
  529. }
  530. /*******************************************************************************
  531. *
  532. * FUNCTION: acpi_load_tables
  533. *
  534. * PARAMETERS: None
  535. *
  536. * RETURN: Status
  537. *
  538. * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
  539. *
  540. ******************************************************************************/
  541. acpi_status acpi_load_tables(void)
  542. {
  543. acpi_status status;
  544. ACPI_FUNCTION_TRACE(acpi_load_tables);
  545. /* Load the namespace from the tables */
  546. status = acpi_tb_load_namespace();
  547. if (ACPI_FAILURE(status)) {
  548. ACPI_EXCEPTION((AE_INFO, status,
  549. "While loading namespace from ACPI tables"));
  550. }
  551. return_ACPI_STATUS(status);
  552. }
  553. ACPI_EXPORT_SYMBOL(acpi_load_tables)
  554. /*******************************************************************************
  555. *
  556. * FUNCTION: acpi_install_table_handler
  557. *
  558. * PARAMETERS: Handler - Table event handler
  559. * Context - Value passed to the handler on each event
  560. *
  561. * RETURN: Status
  562. *
  563. * DESCRIPTION: Install table event handler
  564. *
  565. ******************************************************************************/
  566. acpi_status
  567. acpi_install_table_handler(acpi_tbl_handler handler, void *context)
  568. {
  569. acpi_status status;
  570. ACPI_FUNCTION_TRACE(acpi_install_table_handler);
  571. if (!handler) {
  572. return_ACPI_STATUS(AE_BAD_PARAMETER);
  573. }
  574. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  575. if (ACPI_FAILURE(status)) {
  576. return_ACPI_STATUS(status);
  577. }
  578. /* Don't allow more than one handler */
  579. if (acpi_gbl_table_handler) {
  580. status = AE_ALREADY_EXISTS;
  581. goto cleanup;
  582. }
  583. /* Install the handler */
  584. acpi_gbl_table_handler = handler;
  585. acpi_gbl_table_handler_context = context;
  586. cleanup:
  587. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  588. return_ACPI_STATUS(status);
  589. }
  590. ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
  591. /*******************************************************************************
  592. *
  593. * FUNCTION: acpi_remove_table_handler
  594. *
  595. * PARAMETERS: Handler - Table event handler that was installed
  596. * previously.
  597. *
  598. * RETURN: Status
  599. *
  600. * DESCRIPTION: Remove table event handler
  601. *
  602. ******************************************************************************/
  603. acpi_status acpi_remove_table_handler(acpi_tbl_handler handler)
  604. {
  605. acpi_status status;
  606. ACPI_FUNCTION_TRACE(acpi_remove_table_handler);
  607. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  608. if (ACPI_FAILURE(status)) {
  609. return_ACPI_STATUS(status);
  610. }
  611. /* Make sure that the installed handler is the same */
  612. if (!handler || handler != acpi_gbl_table_handler) {
  613. status = AE_BAD_PARAMETER;
  614. goto cleanup;
  615. }
  616. /* Remove the handler */
  617. acpi_gbl_table_handler = NULL;
  618. cleanup:
  619. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  620. return_ACPI_STATUS(status);
  621. }
  622. ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)
  623. static int __init acpi_no_auto_ssdt_setup(char *s) {
  624. printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
  625. no_auto_ssdt = 1;
  626. return 1;
  627. }
  628. __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);