tbconvrt.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /******************************************************************************
  2. *
  3. * Module Name: tbconvrt - ACPI Table conversion utilities
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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 <linux/module.h>
  43. #include <acpi/acpi.h>
  44. #include <acpi/actables.h>
  45. #define _COMPONENT ACPI_TABLES
  46. ACPI_MODULE_NAME ("tbconvrt")
  47. /* Local prototypes */
  48. static void
  49. acpi_tb_init_generic_address (
  50. struct acpi_generic_address *new_gas_struct,
  51. u8 register_bit_width,
  52. acpi_physical_address address);
  53. static void
  54. acpi_tb_convert_fadt1 (
  55. struct fadt_descriptor_rev2 *local_fadt,
  56. struct fadt_descriptor_rev1 *original_fadt);
  57. static void
  58. acpi_tb_convert_fadt2 (
  59. struct fadt_descriptor_rev2 *local_fadt,
  60. struct fadt_descriptor_rev2 *original_fadt);
  61. u8 acpi_fadt_is_v1;
  62. EXPORT_SYMBOL(acpi_fadt_is_v1);
  63. /*******************************************************************************
  64. *
  65. * FUNCTION: acpi_tb_get_table_count
  66. *
  67. * PARAMETERS: RSDP - Pointer to the RSDP
  68. * RSDT - Pointer to the RSDT/XSDT
  69. *
  70. * RETURN: The number of tables pointed to by the RSDT or XSDT.
  71. *
  72. * DESCRIPTION: Calculate the number of tables. Automatically handles either
  73. * an RSDT or XSDT.
  74. *
  75. ******************************************************************************/
  76. u32
  77. acpi_tb_get_table_count (
  78. struct rsdp_descriptor *RSDP,
  79. struct acpi_table_header *RSDT)
  80. {
  81. u32 pointer_size;
  82. ACPI_FUNCTION_ENTRY ();
  83. if (RSDP->revision < 2) {
  84. pointer_size = sizeof (u32);
  85. }
  86. else {
  87. pointer_size = sizeof (u64);
  88. }
  89. /*
  90. * Determine the number of tables pointed to by the RSDT/XSDT.
  91. * This is defined by the ACPI Specification to be the number of
  92. * pointers contained within the RSDT/XSDT. The size of the pointers
  93. * is architecture-dependent.
  94. */
  95. return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size);
  96. }
  97. /*******************************************************************************
  98. *
  99. * FUNCTION: acpi_tb_convert_to_xsdt
  100. *
  101. * PARAMETERS: table_info - Info about the RSDT
  102. *
  103. * RETURN: Status
  104. *
  105. * DESCRIPTION: Convert an RSDT to an XSDT (internal common format)
  106. *
  107. ******************************************************************************/
  108. acpi_status
  109. acpi_tb_convert_to_xsdt (
  110. struct acpi_table_desc *table_info)
  111. {
  112. acpi_size table_size;
  113. u32 i;
  114. XSDT_DESCRIPTOR *new_table;
  115. ACPI_FUNCTION_ENTRY ();
  116. /* Compute size of the converted XSDT */
  117. table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) +
  118. sizeof (struct acpi_table_header);
  119. /* Allocate an XSDT */
  120. new_table = ACPI_MEM_CALLOCATE (table_size);
  121. if (!new_table) {
  122. return (AE_NO_MEMORY);
  123. }
  124. /* Copy the header and set the length */
  125. ACPI_MEMCPY (new_table, table_info->pointer, sizeof (struct acpi_table_header));
  126. new_table->length = (u32) table_size;
  127. /* Copy the table pointers */
  128. for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
  129. if (acpi_gbl_RSDP->revision < 2) {
  130. ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
  131. (ACPI_CAST_PTR (struct rsdt_descriptor_rev1,
  132. table_info->pointer))->table_offset_entry[i]);
  133. }
  134. else {
  135. new_table->table_offset_entry[i] =
  136. (ACPI_CAST_PTR (XSDT_DESCRIPTOR,
  137. table_info->pointer))->table_offset_entry[i];
  138. }
  139. }
  140. /* Delete the original table (either mapped or in a buffer) */
  141. acpi_tb_delete_single_table (table_info);
  142. /* Point the table descriptor to the new table */
  143. table_info->pointer = ACPI_CAST_PTR (struct acpi_table_header, new_table);
  144. table_info->length = table_size;
  145. table_info->allocation = ACPI_MEM_ALLOCATED;
  146. return (AE_OK);
  147. }
  148. /*******************************************************************************
  149. *
  150. * FUNCTION: acpi_tb_init_generic_address
  151. *
  152. * PARAMETERS: new_gas_struct - GAS struct to be initialized
  153. * register_bit_width - Width of this register
  154. * Address - Address of the register
  155. *
  156. * RETURN: None
  157. *
  158. * DESCRIPTION: Initialize a GAS structure.
  159. *
  160. ******************************************************************************/
  161. static void
  162. acpi_tb_init_generic_address (
  163. struct acpi_generic_address *new_gas_struct,
  164. u8 register_bit_width,
  165. acpi_physical_address address)
  166. {
  167. ACPI_STORE_ADDRESS (new_gas_struct->address, address);
  168. new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
  169. new_gas_struct->register_bit_width = register_bit_width;
  170. new_gas_struct->register_bit_offset = 0;
  171. new_gas_struct->access_width = 0;
  172. }
  173. /*******************************************************************************
  174. *
  175. * FUNCTION: acpi_tb_convert_fadt1
  176. *
  177. * PARAMETERS: local_fadt - Pointer to new FADT
  178. * original_fadt - Pointer to old FADT
  179. *
  180. * RETURN: None, populates local_fadt
  181. *
  182. * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format
  183. *
  184. ******************************************************************************/
  185. static void
  186. acpi_tb_convert_fadt1 (
  187. struct fadt_descriptor_rev2 *local_fadt,
  188. struct fadt_descriptor_rev1 *original_fadt)
  189. {
  190. /* ACPI 1.0 FACS */
  191. /* The BIOS stored FADT should agree with Revision 1.0 */
  192. acpi_fadt_is_v1 = 1;
  193. /*
  194. * Copy the table header and the common part of the tables.
  195. *
  196. * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
  197. * table can be copied first, then expand some fields to 64 bits.
  198. */
  199. ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1));
  200. /* Convert table pointers to 64-bit fields */
  201. ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl);
  202. ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt);
  203. /*
  204. * System Interrupt Model isn't used in ACPI 2.0
  205. * (local_fadt->Reserved1 = 0;)
  206. */
  207. /*
  208. * This field is set by the OEM to convey the preferred power management
  209. * profile to OSPM. It doesn't have any 1.0 equivalence. Since we don't
  210. * know what kind of 32-bit system this is, we will use "unspecified".
  211. */
  212. local_fadt->prefer_PM_profile = PM_UNSPECIFIED;
  213. /*
  214. * Processor Performance State Control. This is the value OSPM writes to
  215. * the SMI_CMD register to assume processor performance state control
  216. * responsibility. There isn't any equivalence in 1.0, but as many 1.x
  217. * ACPI tables contain _PCT and _PSS we also keep this value, unless
  218. * acpi_strict is set.
  219. */
  220. if (acpi_strict)
  221. local_fadt->pstate_cnt = 0;
  222. /*
  223. * Support for the _CST object and C States change notification.
  224. * This data item hasn't any 1.0 equivalence so leave it zero.
  225. */
  226. local_fadt->cst_cnt = 0;
  227. /*
  228. * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0.
  229. * It primarily adds the FADT reset mechanism.
  230. */
  231. if ((original_fadt->revision == 2) &&
  232. (original_fadt->length == 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. }
  242. else {
  243. /*
  244. * Since there isn't any equivalence in 1.0 and since it is highly
  245. * likely that a 1.0 system has legacy support.
  246. */
  247. local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES;
  248. }
  249. /*
  250. * Convert the V1.0 block addresses to V2.0 GAS structures
  251. */
  252. acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, local_fadt->pm1_evt_len,
  253. (acpi_physical_address) local_fadt->V1_pm1a_evt_blk);
  254. acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len,
  255. (acpi_physical_address) local_fadt->V1_pm1b_evt_blk);
  256. acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, local_fadt->pm1_cnt_len,
  257. (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk);
  258. acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len,
  259. (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk);
  260. acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, local_fadt->pm2_cnt_len,
  261. (acpi_physical_address) local_fadt->V1_pm2_cnt_blk);
  262. acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len,
  263. (acpi_physical_address) local_fadt->V1_pm_tmr_blk);
  264. acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0,
  265. (acpi_physical_address) local_fadt->V1_gpe0_blk);
  266. acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0,
  267. (acpi_physical_address) local_fadt->V1_gpe1_blk);
  268. /* Create separate GAS structs for the PM1 Enable registers */
  269. acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
  270. (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
  271. (acpi_physical_address)
  272. (local_fadt->xpm1a_evt_blk.address +
  273. ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
  274. /* PM1B is optional; leave null if not present */
  275. if (local_fadt->xpm1b_evt_blk.address) {
  276. acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
  277. (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
  278. (acpi_physical_address)
  279. (local_fadt->xpm1b_evt_blk.address +
  280. ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
  281. }
  282. }
  283. /*******************************************************************************
  284. *
  285. * FUNCTION: acpi_tb_convert_fadt2
  286. *
  287. * PARAMETERS: local_fadt - Pointer to new FADT
  288. * original_fadt - Pointer to old FADT
  289. *
  290. * RETURN: None, populates local_fadt
  291. *
  292. * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format.
  293. * Handles optional "X" fields.
  294. *
  295. ******************************************************************************/
  296. static void
  297. acpi_tb_convert_fadt2 (
  298. struct fadt_descriptor_rev2 *local_fadt,
  299. struct fadt_descriptor_rev2 *original_fadt)
  300. {
  301. /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
  302. ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2));
  303. /*
  304. * "X" fields are optional extensions to the original V1.0 fields, so
  305. * we must selectively expand V1.0 fields if the corresponding X field
  306. * is zero.
  307. */
  308. if (!(local_fadt->xfirmware_ctrl)) {
  309. ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl,
  310. local_fadt->V1_firmware_ctrl);
  311. }
  312. if (!(local_fadt->Xdsdt)) {
  313. ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt);
  314. }
  315. if (!(local_fadt->xpm1a_evt_blk.address)) {
  316. acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk,
  317. local_fadt->pm1_evt_len,
  318. (acpi_physical_address) local_fadt->V1_pm1a_evt_blk);
  319. }
  320. if (!(local_fadt->xpm1b_evt_blk.address)) {
  321. acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk,
  322. local_fadt->pm1_evt_len,
  323. (acpi_physical_address) local_fadt->V1_pm1b_evt_blk);
  324. }
  325. if (!(local_fadt->xpm1a_cnt_blk.address)) {
  326. acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk,
  327. local_fadt->pm1_cnt_len,
  328. (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk);
  329. }
  330. if (!(local_fadt->xpm1b_cnt_blk.address)) {
  331. acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk,
  332. local_fadt->pm1_cnt_len,
  333. (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk);
  334. }
  335. if (!(local_fadt->xpm2_cnt_blk.address)) {
  336. acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk,
  337. local_fadt->pm2_cnt_len,
  338. (acpi_physical_address) local_fadt->V1_pm2_cnt_blk);
  339. }
  340. if (!(local_fadt->xpm_tmr_blk.address)) {
  341. acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk,
  342. local_fadt->pm_tm_len,
  343. (acpi_physical_address) local_fadt->V1_pm_tmr_blk);
  344. }
  345. if (!(local_fadt->xgpe0_blk.address)) {
  346. acpi_tb_init_generic_address (&local_fadt->xgpe0_blk,
  347. 0, (acpi_physical_address) local_fadt->V1_gpe0_blk);
  348. }
  349. if (!(local_fadt->xgpe1_blk.address)) {
  350. acpi_tb_init_generic_address (&local_fadt->xgpe1_blk,
  351. 0, (acpi_physical_address) local_fadt->V1_gpe1_blk);
  352. }
  353. /* Create separate GAS structs for the PM1 Enable registers */
  354. acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
  355. (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
  356. (acpi_physical_address)
  357. (local_fadt->xpm1a_evt_blk.address +
  358. ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
  359. acpi_gbl_xpm1a_enable.address_space_id =
  360. local_fadt->xpm1a_evt_blk.address_space_id;
  361. /* PM1B is optional; leave null if not present */
  362. if (local_fadt->xpm1b_evt_blk.address) {
  363. acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
  364. (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
  365. (acpi_physical_address)
  366. (local_fadt->xpm1b_evt_blk.address +
  367. ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
  368. acpi_gbl_xpm1b_enable.address_space_id =
  369. local_fadt->xpm1b_evt_blk.address_space_id;
  370. }
  371. }
  372. /*******************************************************************************
  373. *
  374. * FUNCTION: acpi_tb_convert_table_fadt
  375. *
  376. * PARAMETERS: None
  377. *
  378. * RETURN: Status
  379. *
  380. * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local
  381. * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
  382. * copied to the local FADT. The ACPI CA software uses this
  383. * local FADT. Thus a significant amount of special #ifdef
  384. * type codeing is saved.
  385. *
  386. ******************************************************************************/
  387. acpi_status
  388. acpi_tb_convert_table_fadt (
  389. void)
  390. {
  391. struct fadt_descriptor_rev2 *local_fadt;
  392. struct acpi_table_desc *table_desc;
  393. ACPI_FUNCTION_TRACE ("tb_convert_table_fadt");
  394. /*
  395. * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
  396. * at least as long as the version 1.0 FADT
  397. */
  398. if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) {
  399. ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n",
  400. acpi_gbl_FADT->length));
  401. return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
  402. }
  403. /* Allocate buffer for the ACPI 2.0(+) FADT */
  404. local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2));
  405. if (!local_fadt) {
  406. return_ACPI_STATUS (AE_NO_MEMORY);
  407. }
  408. if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
  409. if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) {
  410. /* Length is too short to be a V2.0 table */
  411. ACPI_REPORT_WARNING ((
  412. "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
  413. acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
  414. acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
  415. }
  416. else {
  417. /* Valid V2.0 table */
  418. acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT);
  419. }
  420. }
  421. else {
  422. /* Valid V1.0 table */
  423. acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
  424. }
  425. /* Global FADT pointer will point to the new common V2.0 FADT */
  426. acpi_gbl_FADT = local_fadt;
  427. acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR);
  428. /* Free the original table */
  429. table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next;
  430. acpi_tb_delete_single_table (table_desc);
  431. /* Install the new table */
  432. table_desc->pointer = ACPI_CAST_PTR (struct acpi_table_header, acpi_gbl_FADT);
  433. table_desc->allocation = ACPI_MEM_ALLOCATED;
  434. table_desc->length = sizeof (struct fadt_descriptor_rev2);
  435. /* Dump the entire FADT */
  436. ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
  437. "Hex dump of common internal FADT, size %d (%X)\n",
  438. acpi_gbl_FADT->length, acpi_gbl_FADT->length));
  439. ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length);
  440. return_ACPI_STATUS (AE_OK);
  441. }
  442. /*******************************************************************************
  443. *
  444. * FUNCTION: acpi_tb_build_common_facs
  445. *
  446. * PARAMETERS: table_info - Info for currently installed FACS
  447. *
  448. * RETURN: Status
  449. *
  450. * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal
  451. * table format.
  452. *
  453. ******************************************************************************/
  454. acpi_status
  455. acpi_tb_build_common_facs (
  456. struct acpi_table_desc *table_info)
  457. {
  458. ACPI_FUNCTION_TRACE ("tb_build_common_facs");
  459. /* Absolute minimum length is 24, but the ACPI spec says 64 */
  460. if (acpi_gbl_FACS->length < 24) {
  461. ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n",
  462. acpi_gbl_FACS->length));
  463. return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
  464. }
  465. if (acpi_gbl_FACS->length < 64) {
  466. ACPI_REPORT_WARNING ((
  467. "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
  468. acpi_gbl_FACS->length));
  469. }
  470. /* Copy fields to the new FACS */
  471. acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
  472. if ((acpi_gbl_RSDP->revision < 2) ||
  473. (acpi_gbl_FACS->length < 32) ||
  474. (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
  475. /* ACPI 1.0 FACS or short table or optional X_ field is zero */
  476. acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64,
  477. &(acpi_gbl_FACS->firmware_waking_vector));
  478. acpi_gbl_common_fACS.vector_width = 32;
  479. }
  480. else {
  481. /* ACPI 2.0 FACS with valid X_ field */
  482. acpi_gbl_common_fACS.firmware_waking_vector = &acpi_gbl_FACS->xfirmware_waking_vector;
  483. acpi_gbl_common_fACS.vector_width = 64;
  484. }
  485. return_ACPI_STATUS (AE_OK);
  486. }