tbxface.c 21 KB

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