tbconvrt.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /******************************************************************************
  2. *
  3. * Module Name: tbconvrt - ACPI Table conversion utilities
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, R. Byron Moore
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include <acpi/actables.h>
  44. #define _COMPONENT ACPI_TABLES
  45. ACPI_MODULE_NAME("tbconvrt")
  46. /* Local prototypes */
  47. static void
  48. acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
  49. u8 register_bit_width,
  50. acpi_physical_address address);
  51. static void
  52. acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
  53. struct fadt_descriptor_rev1 *original_fadt);
  54. static void
  55. acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
  56. struct fadt_descriptor *original_fadt);
  57. u8 acpi_fadt_is_v1;
  58. ACPI_EXPORT_SYMBOL(acpi_fadt_is_v1)
  59. /*******************************************************************************
  60. *
  61. * FUNCTION: acpi_tb_get_table_count
  62. *
  63. * PARAMETERS: RSDP - Pointer to the RSDP
  64. * RSDT - Pointer to the RSDT/XSDT
  65. *
  66. * RETURN: The number of tables pointed to by the RSDT or XSDT.
  67. *
  68. * DESCRIPTION: Calculate the number of tables. Automatically handles either
  69. * an RSDT or XSDT.
  70. *
  71. ******************************************************************************/
  72. u32
  73. acpi_tb_get_table_count(struct rsdp_descriptor *RSDP,
  74. struct acpi_table_header *RSDT)
  75. {
  76. u32 pointer_size;
  77. ACPI_FUNCTION_ENTRY();
  78. /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
  79. if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
  80. pointer_size = sizeof(u32);
  81. } else {
  82. pointer_size = sizeof(u64);
  83. }
  84. /*
  85. * Determine the number of tables pointed to by the RSDT/XSDT.
  86. * This is defined by the ACPI Specification to be the number of
  87. * pointers contained within the RSDT/XSDT. The size of the pointers
  88. * is architecture-dependent.
  89. */
  90. return ((RSDT->length -
  91. sizeof(struct acpi_table_header)) / pointer_size);
  92. }
  93. /*******************************************************************************
  94. *
  95. * FUNCTION: acpi_tb_convert_to_xsdt
  96. *
  97. * PARAMETERS: table_info - Info about the RSDT
  98. *
  99. * RETURN: Status
  100. *
  101. * DESCRIPTION: Convert an RSDT to an XSDT (internal common format)
  102. *
  103. ******************************************************************************/
  104. acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
  105. {
  106. acpi_size table_size;
  107. u32 i;
  108. struct xsdt_descriptor *new_table;
  109. ACPI_FUNCTION_ENTRY();
  110. /* Compute size of the converted XSDT */
  111. table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof(u64)) +
  112. sizeof(struct acpi_table_header);
  113. /* Allocate an XSDT */
  114. new_table = ACPI_ALLOCATE_ZEROED(table_size);
  115. if (!new_table) {
  116. return (AE_NO_MEMORY);
  117. }
  118. /* Copy the header and set the length */
  119. ACPI_MEMCPY(new_table, table_info->pointer,
  120. sizeof(struct acpi_table_header));
  121. new_table->length = (u32) table_size;
  122. /* Copy the table pointers */
  123. for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
  124. /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
  125. if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
  126. ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
  127. (ACPI_CAST_PTR
  128. (struct rsdt_descriptor,
  129. table_info->pointer))->
  130. table_offset_entry[i]);
  131. } else {
  132. new_table->table_offset_entry[i] =
  133. (ACPI_CAST_PTR(struct xsdt_descriptor,
  134. table_info->pointer))->
  135. table_offset_entry[i];
  136. }
  137. }
  138. /* Delete the original table (either mapped or in a buffer) */
  139. acpi_tb_delete_single_table(table_info);
  140. /* Point the table descriptor to the new table */
  141. table_info->pointer =
  142. ACPI_CAST_PTR(struct acpi_table_header, new_table);
  143. table_info->length = table_size;
  144. table_info->allocation = ACPI_MEM_ALLOCATED;
  145. return (AE_OK);
  146. }
  147. /*******************************************************************************
  148. *
  149. * FUNCTION: acpi_tb_init_generic_address
  150. *
  151. * PARAMETERS: new_gas_struct - GAS struct to be initialized
  152. * register_bit_width - Width of this register
  153. * Address - Address of the register
  154. *
  155. * RETURN: None
  156. *
  157. * DESCRIPTION: Initialize a GAS structure.
  158. *
  159. ******************************************************************************/
  160. static void
  161. acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
  162. u8 register_bit_width,
  163. acpi_physical_address address)
  164. {
  165. ACPI_STORE_ADDRESS(new_gas_struct->address, address);
  166. new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
  167. new_gas_struct->register_bit_width = register_bit_width;
  168. new_gas_struct->register_bit_offset = 0;
  169. new_gas_struct->access_width = 0;
  170. }
  171. /*******************************************************************************
  172. *
  173. * FUNCTION: acpi_tb_convert_fadt1
  174. *
  175. * PARAMETERS: local_fadt - Pointer to new FADT
  176. * original_fadt - Pointer to old FADT
  177. *
  178. * RETURN: None, populates local_fadt
  179. *
  180. * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format
  181. *
  182. ******************************************************************************/
  183. static void
  184. acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
  185. struct fadt_descriptor_rev1 *original_fadt)
  186. {
  187. /* ACPI 1.0 FACS */
  188. /* The BIOS stored FADT should agree with Revision 1.0 */
  189. acpi_fadt_is_v1 = 1;
  190. /*
  191. * Copy the table header and the common part of the tables.
  192. *
  193. * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
  194. * table can be copied first, then expand some fields to 64 bits.
  195. */
  196. ACPI_MEMCPY(local_fadt, original_fadt,
  197. sizeof(struct fadt_descriptor_rev1));
  198. /* Convert table pointers to 64-bit fields */
  199. ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
  200. local_fadt->V1_firmware_ctrl);
  201. ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
  202. /*
  203. * System Interrupt Model isn't used in ACPI 2.0
  204. * (local_fadt->Reserved1 = 0;)
  205. */
  206. /*
  207. * This field is set by the OEM to convey the preferred power management
  208. * profile to OSPM. It doesn't have any 1.0 equivalence. Since we don't
  209. * know what kind of 32-bit system this is, we will use "unspecified".
  210. */
  211. local_fadt->prefer_PM_profile = PM_UNSPECIFIED;
  212. /*
  213. * Processor Performance State Control. This is the value OSPM writes to
  214. * the SMI_CMD register to assume processor performance state control
  215. * responsibility. There isn't any equivalence in 1.0, but as many 1.x
  216. * ACPI tables contain _PCT and _PSS we also keep this value, unless
  217. * acpi_strict is set.
  218. */
  219. if (acpi_strict)
  220. local_fadt->pstate_cnt = 0;
  221. /*
  222. * Support for the _CST object and C States change notification.
  223. * This data item hasn't any 1.0 equivalence so leave it zero.
  224. */
  225. local_fadt->cst_cnt = 0;
  226. /*
  227. * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0.
  228. * It primarily adds the FADT reset mechanism.
  229. */
  230. if ((original_fadt->revision == 2) &&
  231. (original_fadt->length ==
  232. sizeof(struct fadt_descriptor_rev2_minus))) {
  233. /*
  234. * Grab the entire generic address struct, plus the 1-byte reset value
  235. * that immediately follows.
  236. */
  237. ACPI_MEMCPY(&local_fadt->reset_register,
  238. &(ACPI_CAST_PTR(struct fadt_descriptor_rev2_minus,
  239. original_fadt))->reset_register,
  240. sizeof(struct acpi_generic_address) + 1);
  241. } else {
  242. /*
  243. * Since there isn't any equivalence in 1.0 and since it is highly
  244. * likely that a 1.0 system has legacy support.
  245. */
  246. local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES;
  247. }
  248. /*
  249. * Convert the V1.0 block addresses to V2.0 GAS structures
  250. */
  251. acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
  252. local_fadt->pm1_evt_len,
  253. (acpi_physical_address) local_fadt->
  254. V1_pm1a_evt_blk);
  255. acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
  256. local_fadt->pm1_evt_len,
  257. (acpi_physical_address) local_fadt->
  258. V1_pm1b_evt_blk);
  259. acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
  260. local_fadt->pm1_cnt_len,
  261. (acpi_physical_address) local_fadt->
  262. V1_pm1a_cnt_blk);
  263. acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
  264. local_fadt->pm1_cnt_len,
  265. (acpi_physical_address) local_fadt->
  266. V1_pm1b_cnt_blk);
  267. acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
  268. local_fadt->pm2_cnt_len,
  269. (acpi_physical_address) local_fadt->
  270. V1_pm2_cnt_blk);
  271. acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
  272. local_fadt->pm_tm_len,
  273. (acpi_physical_address) local_fadt->
  274. V1_pm_tmr_blk);
  275. acpi_tb_init_generic_address(&local_fadt->xgpe0_blk, 0,
  276. (acpi_physical_address) local_fadt->
  277. V1_gpe0_blk);
  278. acpi_tb_init_generic_address(&local_fadt->xgpe1_blk, 0,
  279. (acpi_physical_address) local_fadt->
  280. V1_gpe1_blk);
  281. /* Create separate GAS structs for the PM1 Enable registers */
  282. acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
  283. (u8) ACPI_DIV_2(acpi_gbl_FADT->
  284. pm1_evt_len),
  285. (acpi_physical_address)
  286. (local_fadt->xpm1a_evt_blk.address +
  287. ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
  288. /* PM1B is optional; leave null if not present */
  289. if (local_fadt->xpm1b_evt_blk.address) {
  290. acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
  291. (u8) ACPI_DIV_2(acpi_gbl_FADT->
  292. pm1_evt_len),
  293. (acpi_physical_address)
  294. (local_fadt->xpm1b_evt_blk.
  295. address +
  296. ACPI_DIV_2(acpi_gbl_FADT->
  297. pm1_evt_len)));
  298. }
  299. }
  300. /*******************************************************************************
  301. *
  302. * FUNCTION: acpi_tb_convert_fadt2
  303. *
  304. * PARAMETERS: local_fadt - Pointer to new FADT
  305. * original_fadt - Pointer to old FADT
  306. *
  307. * RETURN: None, populates local_fadt
  308. *
  309. * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format.
  310. * Handles optional "X" fields.
  311. *
  312. ******************************************************************************/
  313. static void
  314. acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
  315. struct fadt_descriptor *original_fadt)
  316. {
  317. /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
  318. ACPI_MEMCPY(local_fadt, original_fadt, sizeof(struct fadt_descriptor));
  319. /*
  320. * "X" fields are optional extensions to the original V1.0 fields, so
  321. * we must selectively expand V1.0 fields if the corresponding X field
  322. * is zero.
  323. */
  324. if (!(local_fadt->xfirmware_ctrl)) {
  325. ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
  326. local_fadt->V1_firmware_ctrl);
  327. }
  328. if (!(local_fadt->Xdsdt)) {
  329. ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
  330. }
  331. if (!(local_fadt->xpm1a_evt_blk.address)) {
  332. acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
  333. local_fadt->pm1_evt_len,
  334. (acpi_physical_address)
  335. local_fadt->V1_pm1a_evt_blk);
  336. }
  337. if (!(local_fadt->xpm1b_evt_blk.address)) {
  338. acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
  339. local_fadt->pm1_evt_len,
  340. (acpi_physical_address)
  341. local_fadt->V1_pm1b_evt_blk);
  342. }
  343. if (!(local_fadt->xpm1a_cnt_blk.address)) {
  344. acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
  345. local_fadt->pm1_cnt_len,
  346. (acpi_physical_address)
  347. local_fadt->V1_pm1a_cnt_blk);
  348. }
  349. if (!(local_fadt->xpm1b_cnt_blk.address)) {
  350. acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
  351. local_fadt->pm1_cnt_len,
  352. (acpi_physical_address)
  353. local_fadt->V1_pm1b_cnt_blk);
  354. }
  355. if (!(local_fadt->xpm2_cnt_blk.address)) {
  356. acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
  357. local_fadt->pm2_cnt_len,
  358. (acpi_physical_address)
  359. local_fadt->V1_pm2_cnt_blk);
  360. }
  361. if (!(local_fadt->xpm_tmr_blk.address)) {
  362. acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
  363. local_fadt->pm_tm_len,
  364. (acpi_physical_address)
  365. local_fadt->V1_pm_tmr_blk);
  366. }
  367. if (!(local_fadt->xgpe0_blk.address)) {
  368. acpi_tb_init_generic_address(&local_fadt->xgpe0_blk,
  369. 0,
  370. (acpi_physical_address)
  371. local_fadt->V1_gpe0_blk);
  372. }
  373. if (!(local_fadt->xgpe1_blk.address)) {
  374. acpi_tb_init_generic_address(&local_fadt->xgpe1_blk,
  375. 0,
  376. (acpi_physical_address)
  377. local_fadt->V1_gpe1_blk);
  378. }
  379. /* Create separate GAS structs for the PM1 Enable registers */
  380. acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
  381. (u8) ACPI_DIV_2(acpi_gbl_FADT->
  382. pm1_evt_len),
  383. (acpi_physical_address)
  384. (local_fadt->xpm1a_evt_blk.address +
  385. ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
  386. acpi_gbl_xpm1a_enable.address_space_id =
  387. local_fadt->xpm1a_evt_blk.address_space_id;
  388. /* PM1B is optional; leave null if not present */
  389. if (local_fadt->xpm1b_evt_blk.address) {
  390. acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
  391. (u8) ACPI_DIV_2(acpi_gbl_FADT->
  392. pm1_evt_len),
  393. (acpi_physical_address)
  394. (local_fadt->xpm1b_evt_blk.
  395. address +
  396. ACPI_DIV_2(acpi_gbl_FADT->
  397. pm1_evt_len)));
  398. acpi_gbl_xpm1b_enable.address_space_id =
  399. local_fadt->xpm1b_evt_blk.address_space_id;
  400. }
  401. }
  402. /*******************************************************************************
  403. *
  404. * FUNCTION: acpi_tb_convert_table_fadt
  405. *
  406. * PARAMETERS: None
  407. *
  408. * RETURN: Status
  409. *
  410. * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local
  411. * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
  412. * copied to the local FADT. The ACPI CA software uses this
  413. * local FADT. Thus a significant amount of special #ifdef
  414. * type codeing is saved.
  415. *
  416. ******************************************************************************/
  417. acpi_status acpi_tb_convert_table_fadt(void)
  418. {
  419. struct fadt_descriptor *local_fadt;
  420. struct acpi_table_desc *table_desc;
  421. ACPI_FUNCTION_TRACE(tb_convert_table_fadt);
  422. /*
  423. * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
  424. * at least as long as the version 1.0 FADT
  425. */
  426. if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
  427. ACPI_ERROR((AE_INFO, "FADT is invalid, too short: 0x%X",
  428. acpi_gbl_FADT->length));
  429. return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
  430. }
  431. /* Allocate buffer for the ACPI 2.0(+) FADT */
  432. local_fadt = ACPI_ALLOCATE_ZEROED(sizeof(struct fadt_descriptor));
  433. if (!local_fadt) {
  434. return_ACPI_STATUS(AE_NO_MEMORY);
  435. }
  436. if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
  437. if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor)) {
  438. /* Length is too short to be a V2.0 table */
  439. ACPI_WARNING((AE_INFO,
  440. "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table",
  441. acpi_gbl_FADT->length,
  442. acpi_gbl_FADT->revision));
  443. acpi_tb_convert_fadt1(local_fadt,
  444. (void *)acpi_gbl_FADT);
  445. } else {
  446. /* Valid V2.0 table */
  447. acpi_tb_convert_fadt2(local_fadt, acpi_gbl_FADT);
  448. }
  449. } else {
  450. /* Valid V1.0 table */
  451. acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT);
  452. }
  453. /* Global FADT pointer will point to the new common V2.0 FADT */
  454. acpi_gbl_FADT = local_fadt;
  455. acpi_gbl_FADT->length = sizeof(struct fadt_descriptor);
  456. /* Free the original table */
  457. table_desc = acpi_gbl_table_lists[ACPI_TABLE_ID_FADT].next;
  458. acpi_tb_delete_single_table(table_desc);
  459. /* Install the new table */
  460. table_desc->pointer =
  461. ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT);
  462. table_desc->allocation = ACPI_MEM_ALLOCATED;
  463. table_desc->length = sizeof(struct fadt_descriptor);
  464. /* Dump the entire FADT */
  465. ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
  466. "Hex dump of common internal FADT, size %d (%X)\n",
  467. acpi_gbl_FADT->length, acpi_gbl_FADT->length));
  468. ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT),
  469. acpi_gbl_FADT->length);
  470. return_ACPI_STATUS(AE_OK);
  471. }
  472. /*******************************************************************************
  473. *
  474. * FUNCTION: acpi_tb_build_common_facs
  475. *
  476. * PARAMETERS: table_info - Info for currently installed FACS
  477. *
  478. * RETURN: Status
  479. *
  480. * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal
  481. * table format.
  482. *
  483. ******************************************************************************/
  484. acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
  485. {
  486. ACPI_FUNCTION_TRACE(tb_build_common_facs);
  487. /* Absolute minimum length is 24, but the ACPI spec says 64 */
  488. if (acpi_gbl_FACS->length < 24) {
  489. ACPI_ERROR((AE_INFO, "Invalid FACS table length: 0x%X",
  490. acpi_gbl_FACS->length));
  491. return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
  492. }
  493. if (acpi_gbl_FACS->length < 64) {
  494. ACPI_WARNING((AE_INFO,
  495. "FACS is shorter than the ACPI specification allows: 0x%X, using anyway",
  496. acpi_gbl_FACS->length));
  497. }
  498. /* Copy fields to the new FACS */
  499. acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
  500. if ((acpi_gbl_RSDP->revision < 2) ||
  501. (acpi_gbl_FACS->length < 32) ||
  502. (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
  503. /* ACPI 1.0 FACS or short table or optional X_ field is zero */
  504. acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64,
  505. &
  506. (acpi_gbl_FACS->
  507. firmware_waking_vector));
  508. acpi_gbl_common_fACS.vector_width = 32;
  509. } else {
  510. /* ACPI 2.0 FACS with valid X_ field */
  511. acpi_gbl_common_fACS.firmware_waking_vector =
  512. &acpi_gbl_FACS->xfirmware_waking_vector;
  513. acpi_gbl_common_fACS.vector_width = 64;
  514. }
  515. return_ACPI_STATUS(AE_OK);
  516. }