tbfadt.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /******************************************************************************
  2. *
  3. * Module Name: tbfadt - FADT table utilities
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, Intel Corp.
  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 "accommon.h"
  44. #include "actables.h"
  45. #define _COMPONENT ACPI_TABLES
  46. ACPI_MODULE_NAME("tbfadt")
  47. /* Local prototypes */
  48. static inline void
  49. acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
  50. u8 space_id, u8 byte_width, u64 address);
  51. static void acpi_tb_convert_fadt(void);
  52. static void acpi_tb_validate_fadt(void);
  53. /* Table for conversion of FADT to common internal format and FADT validation */
  54. typedef struct acpi_fadt_info {
  55. char *name;
  56. u8 address64;
  57. u8 address32;
  58. u8 length;
  59. u8 default_length;
  60. u8 type;
  61. } acpi_fadt_info;
  62. #define ACPI_FADT_REQUIRED 1
  63. #define ACPI_FADT_SEPARATE_LENGTH 2
  64. static struct acpi_fadt_info fadt_info_table[] = {
  65. {"Pm1aEventBlock",
  66. ACPI_FADT_OFFSET(xpm1a_event_block),
  67. ACPI_FADT_OFFSET(pm1a_event_block),
  68. ACPI_FADT_OFFSET(pm1_event_length),
  69. ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
  70. ACPI_FADT_REQUIRED},
  71. {"Pm1bEventBlock",
  72. ACPI_FADT_OFFSET(xpm1b_event_block),
  73. ACPI_FADT_OFFSET(pm1b_event_block),
  74. ACPI_FADT_OFFSET(pm1_event_length),
  75. ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
  76. 0},
  77. {"Pm1aControlBlock",
  78. ACPI_FADT_OFFSET(xpm1a_control_block),
  79. ACPI_FADT_OFFSET(pm1a_control_block),
  80. ACPI_FADT_OFFSET(pm1_control_length),
  81. ACPI_PM1_REGISTER_WIDTH,
  82. ACPI_FADT_REQUIRED},
  83. {"Pm1bControlBlock",
  84. ACPI_FADT_OFFSET(xpm1b_control_block),
  85. ACPI_FADT_OFFSET(pm1b_control_block),
  86. ACPI_FADT_OFFSET(pm1_control_length),
  87. ACPI_PM1_REGISTER_WIDTH,
  88. 0},
  89. {"Pm2ControlBlock",
  90. ACPI_FADT_OFFSET(xpm2_control_block),
  91. ACPI_FADT_OFFSET(pm2_control_block),
  92. ACPI_FADT_OFFSET(pm2_control_length),
  93. ACPI_PM2_REGISTER_WIDTH,
  94. ACPI_FADT_SEPARATE_LENGTH},
  95. {"PmTimerBlock",
  96. ACPI_FADT_OFFSET(xpm_timer_block),
  97. ACPI_FADT_OFFSET(pm_timer_block),
  98. ACPI_FADT_OFFSET(pm_timer_length),
  99. ACPI_PM_TIMER_WIDTH,
  100. ACPI_FADT_REQUIRED},
  101. {"Gpe0Block",
  102. ACPI_FADT_OFFSET(xgpe0_block),
  103. ACPI_FADT_OFFSET(gpe0_block),
  104. ACPI_FADT_OFFSET(gpe0_block_length),
  105. 0,
  106. ACPI_FADT_SEPARATE_LENGTH},
  107. {"Gpe1Block",
  108. ACPI_FADT_OFFSET(xgpe1_block),
  109. ACPI_FADT_OFFSET(gpe1_block),
  110. ACPI_FADT_OFFSET(gpe1_block_length),
  111. 0,
  112. ACPI_FADT_SEPARATE_LENGTH}
  113. };
  114. #define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info))
  115. /*******************************************************************************
  116. *
  117. * FUNCTION: acpi_tb_init_generic_address
  118. *
  119. * PARAMETERS: generic_address - GAS struct to be initialized
  120. * byte_width - Width of this register
  121. * Address - Address of the register
  122. *
  123. * RETURN: None
  124. *
  125. * DESCRIPTION: Initialize a Generic Address Structure (GAS)
  126. * See the ACPI specification for a full description and
  127. * definition of this structure.
  128. *
  129. ******************************************************************************/
  130. static inline void
  131. acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
  132. u8 space_id, u8 byte_width, u64 address)
  133. {
  134. /*
  135. * The 64-bit Address field is non-aligned in the byte packed
  136. * GAS struct.
  137. */
  138. ACPI_MOVE_64_TO_64(&generic_address->address, &address);
  139. /* All other fields are byte-wide */
  140. generic_address->space_id = space_id;
  141. generic_address->bit_width = (u8)ACPI_MUL_8(byte_width);
  142. generic_address->bit_offset = 0;
  143. generic_address->access_width = 0; /* Access width ANY */
  144. }
  145. /*******************************************************************************
  146. *
  147. * FUNCTION: acpi_tb_parse_fadt
  148. *
  149. * PARAMETERS: table_index - Index for the FADT
  150. * Flags - Flags
  151. *
  152. * RETURN: None
  153. *
  154. * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
  155. * (FADT contains the addresses of the DSDT and FACS)
  156. *
  157. ******************************************************************************/
  158. void acpi_tb_parse_fadt(u32 table_index, u8 flags)
  159. {
  160. u32 length;
  161. struct acpi_table_header *table;
  162. /*
  163. * The FADT has multiple versions with different lengths,
  164. * and it contains pointers to both the DSDT and FACS tables.
  165. *
  166. * Get a local copy of the FADT and convert it to a common format
  167. * Map entire FADT, assumed to be smaller than one page.
  168. */
  169. length = acpi_gbl_root_table_list.tables[table_index].length;
  170. table =
  171. acpi_os_map_memory(acpi_gbl_root_table_list.tables[table_index].
  172. address, length);
  173. if (!table) {
  174. return;
  175. }
  176. /*
  177. * Validate the FADT checksum before we copy the table. Ignore
  178. * checksum error as we want to try to get the DSDT and FACS.
  179. */
  180. (void)acpi_tb_verify_checksum(table, length);
  181. /* Obtain a local copy of the FADT in common ACPI 2.0+ format */
  182. acpi_tb_create_local_fadt(table, length);
  183. /* All done with the real FADT, unmap it */
  184. acpi_os_unmap_memory(table, length);
  185. /* Obtain the DSDT and FACS tables via their addresses within the FADT */
  186. acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
  187. flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
  188. acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs,
  189. flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
  190. }
  191. /*******************************************************************************
  192. *
  193. * FUNCTION: acpi_tb_create_local_fadt
  194. *
  195. * PARAMETERS: Table - Pointer to BIOS FADT
  196. * Length - Length of the table
  197. *
  198. * RETURN: None
  199. *
  200. * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
  201. * Performs validation on some important FADT fields.
  202. *
  203. * NOTE: We create a local copy of the FADT regardless of the version.
  204. *
  205. ******************************************************************************/
  206. void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
  207. {
  208. /*
  209. * Check if the FADT is larger than the largest table that we expect
  210. * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
  211. * a warning.
  212. */
  213. if (length > sizeof(struct acpi_table_fadt)) {
  214. ACPI_WARNING((AE_INFO,
  215. "FADT (revision %u) is longer than ACPI 2.0 version, "
  216. "truncating length 0x%X to 0x%zX",
  217. table->revision, (unsigned)length,
  218. sizeof(struct acpi_table_fadt)));
  219. }
  220. /* Clear the entire local FADT */
  221. ACPI_MEMSET(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt));
  222. /* Copy the original FADT, up to sizeof (struct acpi_table_fadt) */
  223. ACPI_MEMCPY(&acpi_gbl_FADT, table,
  224. ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
  225. /*
  226. * 1) Convert the local copy of the FADT to the common internal format
  227. * 2) Validate some of the important values within the FADT
  228. */
  229. acpi_tb_convert_fadt();
  230. }
  231. /*******************************************************************************
  232. *
  233. * FUNCTION: acpi_tb_convert_fadt
  234. *
  235. * PARAMETERS: None, uses acpi_gbl_FADT
  236. *
  237. * RETURN: None
  238. *
  239. * DESCRIPTION: Converts all versions of the FADT to a common internal format.
  240. * Expand all 32-bit addresses to 64-bit.
  241. *
  242. * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt),
  243. * and must contain a copy of the actual FADT.
  244. *
  245. * ACPICA will use the "X" fields of the FADT for all addresses.
  246. *
  247. * "X" fields are optional extensions to the original V1.0 fields. Even if
  248. * they are present in the structure, they can be optionally not used by
  249. * setting them to zero. Therefore, we must selectively expand V1.0 fields
  250. * if the corresponding X field is zero.
  251. *
  252. * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding
  253. * "X" fields.
  254. *
  255. * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by
  256. * expanding the corresponding ACPI 1.0 field.
  257. *
  258. ******************************************************************************/
  259. static void acpi_tb_convert_fadt(void)
  260. {
  261. u8 pm1_register_bit_width;
  262. u8 pm1_register_byte_width;
  263. struct acpi_generic_address *target64;
  264. u32 i;
  265. /* Update the local FADT table header length */
  266. acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
  267. /*
  268. * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
  269. * Later code will always use the X 64-bit field. Also, check for an
  270. * address mismatch between the 32-bit and 64-bit address fields
  271. * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate
  272. * the presence of two FACS or two DSDT tables.
  273. */
  274. if (!acpi_gbl_FADT.Xfacs) {
  275. acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
  276. } else if (acpi_gbl_FADT.facs &&
  277. (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
  278. ACPI_WARNING((AE_INFO,
  279. "32/64 FACS address mismatch in FADT - two FACS tables!"));
  280. }
  281. if (!acpi_gbl_FADT.Xdsdt) {
  282. acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
  283. } else if (acpi_gbl_FADT.dsdt &&
  284. (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
  285. ACPI_WARNING((AE_INFO,
  286. "32/64 DSDT address mismatch in FADT - two DSDT tables!"));
  287. }
  288. /*
  289. * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
  290. * should be zero are indeed zero. This will workaround BIOSs that
  291. * inadvertently place values in these fields.
  292. *
  293. * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at
  294. * offset 45, 55, 95, and the word located at offset 109, 110.
  295. */
  296. if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) {
  297. acpi_gbl_FADT.preferred_profile = 0;
  298. acpi_gbl_FADT.pstate_control = 0;
  299. acpi_gbl_FADT.cst_control = 0;
  300. acpi_gbl_FADT.boot_flags = 0;
  301. }
  302. /*
  303. * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
  304. * generic address structures as necessary. Later code will always use
  305. * the 64-bit address structures.
  306. */
  307. for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
  308. target64 =
  309. ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
  310. fadt_info_table[i].address64);
  311. /* Expand only if the 64-bit X target is null */
  312. if (!target64->address) {
  313. /* The space_id is always I/O for the 32-bit legacy address fields */
  314. acpi_tb_init_generic_address(target64,
  315. ACPI_ADR_SPACE_SYSTEM_IO,
  316. *ACPI_ADD_PTR(u8,
  317. &acpi_gbl_FADT,
  318. fadt_info_table
  319. [i].length),
  320. (u64) * ACPI_ADD_PTR(u32,
  321. &acpi_gbl_FADT,
  322. fadt_info_table
  323. [i].
  324. address32));
  325. }
  326. }
  327. /* Validate FADT values now, before we make any changes */
  328. acpi_tb_validate_fadt();
  329. /*
  330. * Optionally check all register lengths against the default values and
  331. * update them if they are incorrect.
  332. */
  333. if (acpi_gbl_use_default_register_widths) {
  334. for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
  335. target64 =
  336. ACPI_ADD_PTR(struct acpi_generic_address,
  337. &acpi_gbl_FADT,
  338. fadt_info_table[i].address64);
  339. /*
  340. * If a valid register (Address != 0) and the (default_length > 0)
  341. * (Not a GPE register), then check the width against the default.
  342. */
  343. if ((target64->address) &&
  344. (fadt_info_table[i].default_length > 0) &&
  345. (fadt_info_table[i].default_length !=
  346. target64->bit_width)) {
  347. ACPI_WARNING((AE_INFO,
  348. "Invalid length for %s: %d, using default %d",
  349. fadt_info_table[i].name,
  350. target64->bit_width,
  351. fadt_info_table[i].
  352. default_length));
  353. /* Incorrect size, set width to the default */
  354. target64->bit_width =
  355. fadt_info_table[i].default_length;
  356. }
  357. }
  358. }
  359. /*
  360. * Get the length of the individual PM1 registers (enable and status).
  361. * Each register is defined to be (event block length / 2).
  362. */
  363. pm1_register_bit_width =
  364. (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width);
  365. pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width);
  366. /*
  367. * Adjust the lengths of the PM1 Event Blocks so that they can be used to
  368. * access the PM1 status register(s). Use (width / 2)
  369. */
  370. acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width;
  371. acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width;
  372. /*
  373. * Calculate separate GAS structs for the PM1 Enable registers.
  374. * These addresses do not appear (directly) in the FADT, so it is
  375. * useful to calculate them once, here.
  376. *
  377. * The PM event blocks are split into two register blocks, first is the
  378. * PM Status Register block, followed immediately by the PM Enable
  379. * Register block. Each is of length (xpm1x_event_block.bit_width/2).
  380. *
  381. * On various systems the v2 fields (and particularly the bit widths)
  382. * cannot be relied upon, though. Hence resort to using the v1 length
  383. * here (and warn about the inconsistency).
  384. */
  385. if (acpi_gbl_FADT.xpm1a_event_block.bit_width
  386. != acpi_gbl_FADT.pm1_event_length * 8)
  387. printk(KERN_WARNING "FADT: "
  388. "X_PM1a_EVT_BLK.bit_width (%u) does not match"
  389. " PM1_EVT_LEN (%u)\n",
  390. acpi_gbl_FADT.xpm1a_event_block.bit_width,
  391. acpi_gbl_FADT.pm1_event_length);
  392. /* The PM1A register block is required */
  393. acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
  394. acpi_gbl_FADT.xpm1a_event_block.space_id,
  395. pm1_register_byte_width,
  396. (acpi_gbl_FADT.xpm1a_event_block.address +
  397. pm1_register_byte_width));
  398. /* Don't forget to copy space_id of the GAS */
  399. acpi_gbl_xpm1a_enable.space_id =
  400. acpi_gbl_FADT.xpm1a_event_block.space_id;
  401. /* The PM1B register block is optional, ignore if not present */
  402. if (acpi_gbl_FADT.xpm1b_event_block.address) {
  403. if (acpi_gbl_FADT.xpm1b_event_block.bit_width
  404. != acpi_gbl_FADT.pm1_event_length * 8)
  405. printk(KERN_WARNING "FADT: "
  406. "X_PM1b_EVT_BLK.bit_width (%u) does not match"
  407. " PM1_EVT_LEN (%u)\n",
  408. acpi_gbl_FADT.xpm1b_event_block.bit_width,
  409. acpi_gbl_FADT.pm1_event_length);
  410. acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
  411. acpi_gbl_FADT.xpm1b_event_block.space_id,
  412. pm1_register_byte_width,
  413. (acpi_gbl_FADT.xpm1b_event_block.
  414. address + pm1_register_byte_width));
  415. /* Don't forget to copy space_id of the GAS */
  416. acpi_gbl_xpm1b_enable.space_id =
  417. acpi_gbl_FADT.xpm1b_event_block.space_id;
  418. }
  419. }
  420. /******************************************************************************
  421. *
  422. * FUNCTION: acpi_tb_validate_fadt
  423. *
  424. * PARAMETERS: Table - Pointer to the FADT to be validated
  425. *
  426. * RETURN: None
  427. *
  428. * DESCRIPTION: Validate various important fields within the FADT. If a problem
  429. * is found, issue a message, but no status is returned.
  430. * Used by both the table manager and the disassembler.
  431. *
  432. * Possible additional checks:
  433. * (acpi_gbl_FADT.pm1_event_length >= 4)
  434. * (acpi_gbl_FADT.pm1_control_length >= 2)
  435. * (acpi_gbl_FADT.pm_timer_length >= 4)
  436. * Gpe block lengths must be multiple of 2
  437. *
  438. ******************************************************************************/
  439. static void acpi_tb_validate_fadt(void)
  440. {
  441. char *name;
  442. u32 *address32;
  443. struct acpi_generic_address *address64;
  444. u8 length;
  445. u32 i;
  446. /*
  447. * Check for FACS and DSDT address mismatches. An address mismatch between
  448. * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
  449. * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
  450. */
  451. if (acpi_gbl_FADT.facs &&
  452. (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
  453. ACPI_WARNING((AE_INFO,
  454. "32/64X FACS address mismatch in FADT - "
  455. "two FACS tables! %8.8X/%8.8X%8.8X",
  456. acpi_gbl_FADT.facs,
  457. ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
  458. }
  459. if (acpi_gbl_FADT.dsdt &&
  460. (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
  461. ACPI_WARNING((AE_INFO,
  462. "32/64X DSDT address mismatch in FADT - "
  463. "two DSDT tables! %8.8X/%8.8X%8.8X",
  464. acpi_gbl_FADT.dsdt,
  465. ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
  466. }
  467. /* Examine all of the 64-bit extended address fields (X fields) */
  468. for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
  469. /*
  470. * Generate pointers to the 32-bit and 64-bit addresses, get the
  471. * register length (width), and the register name
  472. */
  473. address64 = ACPI_ADD_PTR(struct acpi_generic_address,
  474. &acpi_gbl_FADT,
  475. fadt_info_table[i].address64);
  476. address32 =
  477. ACPI_ADD_PTR(u32, &acpi_gbl_FADT,
  478. fadt_info_table[i].address32);
  479. length =
  480. *ACPI_ADD_PTR(u8, &acpi_gbl_FADT,
  481. fadt_info_table[i].length);
  482. name = fadt_info_table[i].name;
  483. /*
  484. * For each extended field, check for length mismatch between the
  485. * legacy length field and the corresponding 64-bit X length field.
  486. */
  487. if (address64 && (address64->bit_width != ACPI_MUL_8(length))) {
  488. ACPI_WARNING((AE_INFO,
  489. "32/64X length mismatch in %s: %d/%d",
  490. name, ACPI_MUL_8(length),
  491. address64->bit_width));
  492. }
  493. if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) {
  494. /*
  495. * Field is required (Pm1a_event, Pm1a_control, pm_timer).
  496. * Both the address and length must be non-zero.
  497. */
  498. if (!address64->address || !length) {
  499. ACPI_ERROR((AE_INFO,
  500. "Required field %s has zero address and/or length: %8.8X%8.8X/%X",
  501. name,
  502. ACPI_FORMAT_UINT64(address64->
  503. address),
  504. length));
  505. }
  506. } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) {
  507. /*
  508. * Field is optional (PM2Control, GPE0, GPE1) AND has its own
  509. * length field. If present, both the address and length must be valid.
  510. */
  511. if ((address64->address && !length)
  512. || (!address64->address && length)) {
  513. ACPI_WARNING((AE_INFO,
  514. "Optional field %s has zero address or length: %8.8X%8.8X/%X",
  515. name,
  516. ACPI_FORMAT_UINT64(address64->
  517. address),
  518. length));
  519. }
  520. }
  521. /* If both 32- and 64-bit addresses are valid (non-zero), they must match */
  522. if (address64->address && *address32 &&
  523. (address64->address != (u64) * address32)) {
  524. ACPI_ERROR((AE_INFO,
  525. "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X",
  526. name, *address32,
  527. ACPI_FORMAT_UINT64(address64->address)));
  528. }
  529. }
  530. }