tbxface.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. /******************************************************************************
  2. *
  3. * Module Name: tbxface - Public interfaces to the ACPI subsystem
  4. * ACPI table oriented interfaces
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2010, 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.size = 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.size = 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.count * sizeof(struct acpi_table_desc);
  171. new_size = current_size +
  172. (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc));
  173. /* Create new array and copy the old array */
  174. tables = ACPI_ALLOCATE_ZEROED(new_size);
  175. if (!tables) {
  176. return_ACPI_STATUS(AE_NO_MEMORY);
  177. }
  178. ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size);
  179. /*
  180. * Update the root table descriptor. The new size will be the current
  181. * number of tables plus the increment, independent of the reserved
  182. * size of the original table list.
  183. */
  184. acpi_gbl_root_table_list.tables = tables;
  185. acpi_gbl_root_table_list.size =
  186. acpi_gbl_root_table_list.count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
  187. acpi_gbl_root_table_list.flags =
  188. ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
  189. return_ACPI_STATUS(AE_OK);
  190. }
  191. /*******************************************************************************
  192. *
  193. * FUNCTION: acpi_load_table
  194. *
  195. * PARAMETERS: table_ptr - pointer to a buffer containing the entire
  196. * table to be loaded
  197. *
  198. * RETURN: Status
  199. *
  200. * DESCRIPTION: This function is called to load a table from the caller's
  201. * buffer. The buffer must contain an entire ACPI Table including
  202. * a valid header. The header fields will be verified, and if it
  203. * is determined that the table is invalid, the call will fail.
  204. *
  205. ******************************************************************************/
  206. acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
  207. {
  208. acpi_status status;
  209. u32 table_index;
  210. struct acpi_table_desc table_desc;
  211. if (!table_ptr)
  212. return AE_BAD_PARAMETER;
  213. ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
  214. table_desc.pointer = table_ptr;
  215. table_desc.length = table_ptr->length;
  216. table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN;
  217. /*
  218. * Install the new table into the local data structures
  219. */
  220. status = acpi_tb_add_table(&table_desc, &table_index);
  221. if (ACPI_FAILURE(status)) {
  222. return status;
  223. }
  224. status = acpi_ns_load_table(table_index, acpi_gbl_root_node);
  225. return status;
  226. }
  227. ACPI_EXPORT_SYMBOL(acpi_load_table)
  228. /*******************************************************************************
  229. *
  230. * FUNCTION: acpi_get_table_header
  231. *
  232. * PARAMETERS: Signature - ACPI signature of needed table
  233. * Instance - Which instance (for SSDTs)
  234. * out_table_header - The pointer to the table header to fill
  235. *
  236. * RETURN: Status and pointer to mapped table header
  237. *
  238. * DESCRIPTION: Finds an ACPI table header.
  239. *
  240. * NOTE: Caller is responsible in unmapping the header with
  241. * acpi_os_unmap_memory
  242. *
  243. ******************************************************************************/
  244. acpi_status
  245. acpi_get_table_header(char *signature,
  246. u32 instance, struct acpi_table_header *out_table_header)
  247. {
  248. u32 i;
  249. u32 j;
  250. struct acpi_table_header *header;
  251. /* Parameter validation */
  252. if (!signature || !out_table_header) {
  253. return (AE_BAD_PARAMETER);
  254. }
  255. /* Walk the root table list */
  256. for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
  257. if (!ACPI_COMPARE_NAME
  258. (&(acpi_gbl_root_table_list.tables[i].signature),
  259. signature)) {
  260. continue;
  261. }
  262. if (++j < instance) {
  263. continue;
  264. }
  265. if (!acpi_gbl_root_table_list.tables[i].pointer) {
  266. if ((acpi_gbl_root_table_list.tables[i].flags &
  267. ACPI_TABLE_ORIGIN_MASK) ==
  268. ACPI_TABLE_ORIGIN_MAPPED) {
  269. header =
  270. acpi_os_map_memory(acpi_gbl_root_table_list.
  271. tables[i].address,
  272. sizeof(struct
  273. acpi_table_header));
  274. if (!header) {
  275. return AE_NO_MEMORY;
  276. }
  277. ACPI_MEMCPY(out_table_header, header,
  278. sizeof(struct acpi_table_header));
  279. acpi_os_unmap_memory(header,
  280. sizeof(struct
  281. acpi_table_header));
  282. } else {
  283. return AE_NOT_FOUND;
  284. }
  285. } else {
  286. ACPI_MEMCPY(out_table_header,
  287. acpi_gbl_root_table_list.tables[i].pointer,
  288. sizeof(struct acpi_table_header));
  289. }
  290. return (AE_OK);
  291. }
  292. return (AE_NOT_FOUND);
  293. }
  294. ACPI_EXPORT_SYMBOL(acpi_get_table_header)
  295. /*******************************************************************************
  296. *
  297. * FUNCTION: acpi_unload_table_id
  298. *
  299. * PARAMETERS: id - Owner ID of the table to be removed.
  300. *
  301. * RETURN: Status
  302. *
  303. * DESCRIPTION: This routine is used to force the unload of a table (by id)
  304. *
  305. ******************************************************************************/
  306. acpi_status acpi_unload_table_id(acpi_owner_id id)
  307. {
  308. int i;
  309. acpi_status status = AE_NOT_EXIST;
  310. ACPI_FUNCTION_TRACE(acpi_unload_table_id);
  311. /* Find table in the global table list */
  312. for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
  313. if (id != acpi_gbl_root_table_list.tables[i].owner_id) {
  314. continue;
  315. }
  316. /*
  317. * Delete all namespace objects owned by this table. Note that these
  318. * objects can appear anywhere in the namespace by virtue of the AML
  319. * "Scope" operator. Thus, we need to track ownership by an ID, not
  320. * simply a position within the hierarchy
  321. */
  322. acpi_tb_delete_namespace_by_owner(i);
  323. status = acpi_tb_release_owner_id(i);
  324. acpi_tb_set_table_loaded_flag(i, FALSE);
  325. break;
  326. }
  327. return_ACPI_STATUS(status);
  328. }
  329. ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
  330. /*******************************************************************************
  331. *
  332. * FUNCTION: acpi_get_table_with_size
  333. *
  334. * PARAMETERS: Signature - ACPI signature of needed table
  335. * Instance - Which instance (for SSDTs)
  336. * out_table - Where the pointer to the table is returned
  337. *
  338. * RETURN: Status and pointer to table
  339. *
  340. * DESCRIPTION: Finds and verifies an ACPI table.
  341. *
  342. ******************************************************************************/
  343. acpi_status
  344. acpi_get_table_with_size(char *signature,
  345. u32 instance, struct acpi_table_header **out_table,
  346. acpi_size *tbl_size)
  347. {
  348. u32 i;
  349. u32 j;
  350. acpi_status status;
  351. /* Parameter validation */
  352. if (!signature || !out_table) {
  353. return (AE_BAD_PARAMETER);
  354. }
  355. /* Walk the root table list */
  356. for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
  357. if (!ACPI_COMPARE_NAME
  358. (&(acpi_gbl_root_table_list.tables[i].signature),
  359. signature)) {
  360. continue;
  361. }
  362. if (++j < instance) {
  363. continue;
  364. }
  365. status =
  366. acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
  367. if (ACPI_SUCCESS(status)) {
  368. *out_table = acpi_gbl_root_table_list.tables[i].pointer;
  369. *tbl_size = acpi_gbl_root_table_list.tables[i].length;
  370. }
  371. if (!acpi_gbl_permanent_mmap) {
  372. acpi_gbl_root_table_list.tables[i].pointer = NULL;
  373. }
  374. return (status);
  375. }
  376. return (AE_NOT_FOUND);
  377. }
  378. acpi_status
  379. acpi_get_table(char *signature,
  380. u32 instance, struct acpi_table_header **out_table)
  381. {
  382. acpi_size tbl_size;
  383. return acpi_get_table_with_size(signature,
  384. instance, out_table, &tbl_size);
  385. }
  386. ACPI_EXPORT_SYMBOL(acpi_get_table)
  387. /*******************************************************************************
  388. *
  389. * FUNCTION: acpi_get_table_by_index
  390. *
  391. * PARAMETERS: table_index - Table index
  392. * Table - Where the pointer to the table is returned
  393. *
  394. * RETURN: Status and pointer to the table
  395. *
  396. * DESCRIPTION: Obtain a table by an index into the global table list.
  397. *
  398. ******************************************************************************/
  399. acpi_status
  400. acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table)
  401. {
  402. acpi_status status;
  403. ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
  404. /* Parameter validation */
  405. if (!table) {
  406. return_ACPI_STATUS(AE_BAD_PARAMETER);
  407. }
  408. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  409. /* Validate index */
  410. if (table_index >= acpi_gbl_root_table_list.count) {
  411. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  412. return_ACPI_STATUS(AE_BAD_PARAMETER);
  413. }
  414. if (!acpi_gbl_root_table_list.tables[table_index].pointer) {
  415. /* Table is not mapped, map it */
  416. status =
  417. acpi_tb_verify_table(&acpi_gbl_root_table_list.
  418. tables[table_index]);
  419. if (ACPI_FAILURE(status)) {
  420. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  421. return_ACPI_STATUS(status);
  422. }
  423. }
  424. *table = acpi_gbl_root_table_list.tables[table_index].pointer;
  425. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  426. return_ACPI_STATUS(AE_OK);
  427. }
  428. ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
  429. /*******************************************************************************
  430. *
  431. * FUNCTION: acpi_tb_load_namespace
  432. *
  433. * PARAMETERS: None
  434. *
  435. * RETURN: Status
  436. *
  437. * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
  438. * the RSDT/XSDT.
  439. *
  440. ******************************************************************************/
  441. static acpi_status acpi_tb_load_namespace(void)
  442. {
  443. acpi_status status;
  444. u32 i;
  445. ACPI_FUNCTION_TRACE(tb_load_namespace);
  446. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  447. acpi_gbl_DSDT = &acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT];
  448. /*
  449. * Load the namespace. The DSDT is required, but any SSDT and
  450. * PSDT tables are optional. Verify the DSDT.
  451. */
  452. if (!acpi_gbl_root_table_list.count ||
  453. !ACPI_COMPARE_NAME(&acpi_gbl_DSDT->signature, ACPI_SIG_DSDT) ||
  454. ACPI_FAILURE(acpi_tb_verify_table(acpi_gbl_DSDT))) {
  455. status = AE_NO_ACPI_TABLES;
  456. goto unlock_and_exit;
  457. }
  458. /*
  459. * Optionally copy the entire DSDT to local memory (instead of simply
  460. * mapping it.) There are some BIOSs that corrupt or replace the original
  461. * DSDT, creating the need for this option. Default is FALSE, do not copy
  462. * the DSDT.
  463. */
  464. if (acpi_gbl_copy_dsdt_locally) {
  465. acpi_tb_copy_dsdt(acpi_gbl_DSDT);
  466. }
  467. /*
  468. * Save the original DSDT header for detection of table corruption
  469. * and/or replacement of the DSDT from outside the OS.
  470. */
  471. ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT->pointer,
  472. sizeof(struct acpi_table_header));
  473. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  474. /* Load and parse tables */
  475. status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
  476. if (ACPI_FAILURE(status)) {
  477. return_ACPI_STATUS(status);
  478. }
  479. /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
  480. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  481. for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
  482. if ((!ACPI_COMPARE_NAME
  483. (&(acpi_gbl_root_table_list.tables[i].signature),
  484. ACPI_SIG_SSDT)
  485. &&
  486. !ACPI_COMPARE_NAME(&
  487. (acpi_gbl_root_table_list.tables[i].
  488. signature), ACPI_SIG_PSDT))
  489. ||
  490. ACPI_FAILURE(acpi_tb_verify_table
  491. (&acpi_gbl_root_table_list.tables[i]))) {
  492. continue;
  493. }
  494. if (no_auto_ssdt) {
  495. printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n");
  496. continue;
  497. }
  498. /* Ignore errors while loading tables, get as many as possible */
  499. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  500. (void)acpi_ns_load_table(i, acpi_gbl_root_node);
  501. (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
  502. }
  503. ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
  504. unlock_and_exit:
  505. (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  506. return_ACPI_STATUS(status);
  507. }
  508. /*******************************************************************************
  509. *
  510. * FUNCTION: acpi_load_tables
  511. *
  512. * PARAMETERS: None
  513. *
  514. * RETURN: Status
  515. *
  516. * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
  517. *
  518. ******************************************************************************/
  519. acpi_status acpi_load_tables(void)
  520. {
  521. acpi_status status;
  522. ACPI_FUNCTION_TRACE(acpi_load_tables);
  523. /* Load the namespace from the tables */
  524. status = acpi_tb_load_namespace();
  525. if (ACPI_FAILURE(status)) {
  526. ACPI_EXCEPTION((AE_INFO, status,
  527. "While loading namespace from ACPI tables"));
  528. }
  529. return_ACPI_STATUS(status);
  530. }
  531. ACPI_EXPORT_SYMBOL(acpi_load_tables)
  532. /*******************************************************************************
  533. *
  534. * FUNCTION: acpi_install_table_handler
  535. *
  536. * PARAMETERS: Handler - Table event handler
  537. * Context - Value passed to the handler on each event
  538. *
  539. * RETURN: Status
  540. *
  541. * DESCRIPTION: Install table event handler
  542. *
  543. ******************************************************************************/
  544. acpi_status
  545. acpi_install_table_handler(acpi_tbl_handler handler, void *context)
  546. {
  547. acpi_status status;
  548. ACPI_FUNCTION_TRACE(acpi_install_table_handler);
  549. if (!handler) {
  550. return_ACPI_STATUS(AE_BAD_PARAMETER);
  551. }
  552. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  553. if (ACPI_FAILURE(status)) {
  554. return_ACPI_STATUS(status);
  555. }
  556. /* Don't allow more than one handler */
  557. if (acpi_gbl_table_handler) {
  558. status = AE_ALREADY_EXISTS;
  559. goto cleanup;
  560. }
  561. /* Install the handler */
  562. acpi_gbl_table_handler = handler;
  563. acpi_gbl_table_handler_context = context;
  564. cleanup:
  565. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  566. return_ACPI_STATUS(status);
  567. }
  568. ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
  569. /*******************************************************************************
  570. *
  571. * FUNCTION: acpi_remove_table_handler
  572. *
  573. * PARAMETERS: Handler - Table event handler that was installed
  574. * previously.
  575. *
  576. * RETURN: Status
  577. *
  578. * DESCRIPTION: Remove table event handler
  579. *
  580. ******************************************************************************/
  581. acpi_status acpi_remove_table_handler(acpi_tbl_handler handler)
  582. {
  583. acpi_status status;
  584. ACPI_FUNCTION_TRACE(acpi_remove_table_handler);
  585. status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
  586. if (ACPI_FAILURE(status)) {
  587. return_ACPI_STATUS(status);
  588. }
  589. /* Make sure that the installed handler is the same */
  590. if (!handler || handler != acpi_gbl_table_handler) {
  591. status = AE_BAD_PARAMETER;
  592. goto cleanup;
  593. }
  594. /* Remove the handler */
  595. acpi_gbl_table_handler = NULL;
  596. cleanup:
  597. (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
  598. return_ACPI_STATUS(status);
  599. }
  600. ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)
  601. static int __init acpi_no_auto_ssdt_setup(char *s) {
  602. printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
  603. no_auto_ssdt = 1;
  604. return 1;
  605. }
  606. __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);