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