tbconvrt.c 19 KB

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