tbfadt.c 19 KB

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