tbfadt.c 20 KB

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