Merge ../linus
[linux-2.6] / drivers / acpi / tables / tbconvrt.c
1 /******************************************************************************
2  *
3  * Module Name: tbconvrt - ACPI Table conversion utilities
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2006, R. Byron Moore
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #include <acpi/acpi.h>
45 #include <acpi/actables.h>
46
47 #define _COMPONENT          ACPI_TABLES
48 ACPI_MODULE_NAME("tbconvrt")
49
50 /* Local prototypes */
51 static void
52 acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
53                              u8 register_bit_width,
54                              acpi_physical_address address);
55
56 static void
57 acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
58                       struct fadt_descriptor_rev1 *original_fadt);
59
60 static void
61 acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
62                       struct fadt_descriptor *original_fadt);
63
64 u8 acpi_fadt_is_v1;
65 ACPI_EXPORT_SYMBOL(acpi_fadt_is_v1)
66
67 /*******************************************************************************
68  *
69  * FUNCTION:    acpi_tb_get_table_count
70  *
71  * PARAMETERS:  RSDP            - Pointer to the RSDP
72  *              RSDT            - Pointer to the RSDT/XSDT
73  *
74  * RETURN:      The number of tables pointed to by the RSDT or XSDT.
75  *
76  * DESCRIPTION: Calculate the number of tables.  Automatically handles either
77  *              an RSDT or XSDT.
78  *
79  ******************************************************************************/
80
81 u32
82 acpi_tb_get_table_count(struct rsdp_descriptor *RSDP,
83                         struct acpi_table_header *RSDT)
84 {
85         u32 pointer_size;
86
87         ACPI_FUNCTION_ENTRY();
88
89         /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
90
91         if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
92                 pointer_size = sizeof(u32);
93         } else {
94                 pointer_size = sizeof(u64);
95         }
96
97         /*
98          * Determine the number of tables pointed to by the RSDT/XSDT.
99          * This is defined by the ACPI Specification to be the number of
100          * pointers contained within the RSDT/XSDT.  The size of the pointers
101          * is architecture-dependent.
102          */
103         return ((RSDT->length -
104                  sizeof(struct acpi_table_header)) / pointer_size);
105 }
106
107 /*******************************************************************************
108  *
109  * FUNCTION:    acpi_tb_convert_to_xsdt
110  *
111  * PARAMETERS:  table_info      - Info about the RSDT
112  *
113  * RETURN:      Status
114  *
115  * DESCRIPTION: Convert an RSDT to an XSDT (internal common format)
116  *
117  ******************************************************************************/
118
119 acpi_status acpi_tb_convert_to_xsdt(struct acpi_table_desc *table_info)
120 {
121         acpi_size table_size;
122         u32 i;
123         struct xsdt_descriptor *new_table;
124
125         ACPI_FUNCTION_ENTRY();
126
127         /* Compute size of the converted XSDT */
128
129         table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof(u64)) +
130             sizeof(struct acpi_table_header);
131
132         /* Allocate an XSDT */
133
134         new_table = ACPI_ALLOCATE_ZEROED(table_size);
135         if (!new_table) {
136                 return (AE_NO_MEMORY);
137         }
138
139         /* Copy the header and set the length */
140
141         ACPI_MEMCPY(new_table, table_info->pointer,
142                     sizeof(struct acpi_table_header));
143         new_table->length = (u32) table_size;
144
145         /* Copy the table pointers */
146
147         for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
148
149                 /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
150
151                 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
152                         ACPI_STORE_ADDRESS(new_table->table_offset_entry[i],
153                                            (ACPI_CAST_PTR
154                                             (struct rsdt_descriptor,
155                                              table_info->pointer))->
156                                            table_offset_entry[i]);
157                 } else {
158                         new_table->table_offset_entry[i] =
159                             (ACPI_CAST_PTR(struct xsdt_descriptor,
160                                            table_info->pointer))->
161                             table_offset_entry[i];
162                 }
163         }
164
165         /* Delete the original table (either mapped or in a buffer) */
166
167         acpi_tb_delete_single_table(table_info);
168
169         /* Point the table descriptor to the new table */
170
171         table_info->pointer =
172             ACPI_CAST_PTR(struct acpi_table_header, new_table);
173         table_info->length = table_size;
174         table_info->allocation = ACPI_MEM_ALLOCATED;
175
176         return (AE_OK);
177 }
178
179 /*******************************************************************************
180  *
181  * FUNCTION:    acpi_tb_init_generic_address
182  *
183  * PARAMETERS:  new_gas_struct      - GAS struct to be initialized
184  *              register_bit_width  - Width of this register
185  *              Address             - Address of the register
186  *
187  * RETURN:      None
188  *
189  * DESCRIPTION: Initialize a GAS structure.
190  *
191  ******************************************************************************/
192
193 static void
194 acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
195                              u8 register_bit_width,
196                              acpi_physical_address address)
197 {
198
199         ACPI_STORE_ADDRESS(new_gas_struct->address, address);
200
201         new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
202         new_gas_struct->register_bit_width = register_bit_width;
203         new_gas_struct->register_bit_offset = 0;
204         new_gas_struct->access_width = 0;
205 }
206
207 /*******************************************************************************
208  *
209  * FUNCTION:    acpi_tb_convert_fadt1
210  *
211  * PARAMETERS:  local_fadt      - Pointer to new FADT
212  *              original_fadt   - Pointer to old FADT
213  *
214  * RETURN:      None, populates local_fadt
215  *
216  * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format
217  *
218  ******************************************************************************/
219
220 static void
221 acpi_tb_convert_fadt1(struct fadt_descriptor *local_fadt,
222                       struct fadt_descriptor_rev1 *original_fadt)
223 {
224
225         /* ACPI 1.0 FACS */
226         /* The BIOS stored FADT should agree with Revision 1.0 */
227         acpi_fadt_is_v1 = 1;
228
229         /*
230          * Copy the table header and the common part of the tables.
231          *
232          * The 2.0 table is an extension of the 1.0 table, so the entire 1.0
233          * table can be copied first, then expand some fields to 64 bits.
234          */
235         ACPI_MEMCPY(local_fadt, original_fadt,
236                     sizeof(struct fadt_descriptor_rev1));
237
238         /* Convert table pointers to 64-bit fields */
239
240         ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
241                            local_fadt->V1_firmware_ctrl);
242         ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
243
244         /*
245          * System Interrupt Model isn't used in ACPI 2.0
246          * (local_fadt->Reserved1 = 0;)
247          */
248
249         /*
250          * This field is set by the OEM to convey the preferred power management
251          * profile to OSPM. It doesn't have any 1.0 equivalence.  Since we don't
252          * know what kind of 32-bit system this is, we will use "unspecified".
253          */
254         local_fadt->prefer_PM_profile = PM_UNSPECIFIED;
255
256         /*
257          * Processor Performance State Control. This is the value OSPM writes to
258          * the SMI_CMD register to assume processor performance state control
259          * responsibility. There isn't any equivalence in 1.0, but as many 1.x
260          * ACPI tables contain _PCT and _PSS we also keep this value, unless
261          * acpi_strict is set.
262          */
263         if (acpi_strict)
264                 local_fadt->pstate_cnt = 0;
265
266         /*
267          * Support for the _CST object and C States change notification.
268          * This data item hasn't any 1.0 equivalence so leave it zero.
269          */
270         local_fadt->cst_cnt = 0;
271
272         /*
273          * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0.
274          * It primarily adds the FADT reset mechanism.
275          */
276         if ((original_fadt->revision == 2) &&
277             (original_fadt->length ==
278              sizeof(struct fadt_descriptor_rev2_minus))) {
279                 /*
280                  * Grab the entire generic address struct, plus the 1-byte reset value
281                  * that immediately follows.
282                  */
283                 ACPI_MEMCPY(&local_fadt->reset_register,
284                             &(ACPI_CAST_PTR(struct fadt_descriptor_rev2_minus,
285                                             original_fadt))->reset_register,
286                             sizeof(struct acpi_generic_address) + 1);
287         } else {
288                 /*
289                  * Since there isn't any equivalence in 1.0 and since it is highly
290                  * likely that a 1.0 system has legacy support.
291                  */
292                 local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES;
293         }
294
295         /*
296          * Convert the V1.0 block addresses to V2.0 GAS structures
297          */
298         acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
299                                      local_fadt->pm1_evt_len,
300                                      (acpi_physical_address) local_fadt->
301                                      V1_pm1a_evt_blk);
302         acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
303                                      local_fadt->pm1_evt_len,
304                                      (acpi_physical_address) local_fadt->
305                                      V1_pm1b_evt_blk);
306         acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
307                                      local_fadt->pm1_cnt_len,
308                                      (acpi_physical_address) local_fadt->
309                                      V1_pm1a_cnt_blk);
310         acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
311                                      local_fadt->pm1_cnt_len,
312                                      (acpi_physical_address) local_fadt->
313                                      V1_pm1b_cnt_blk);
314         acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
315                                      local_fadt->pm2_cnt_len,
316                                      (acpi_physical_address) local_fadt->
317                                      V1_pm2_cnt_blk);
318         acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
319                                      local_fadt->pm_tm_len,
320                                      (acpi_physical_address) local_fadt->
321                                      V1_pm_tmr_blk);
322         acpi_tb_init_generic_address(&local_fadt->xgpe0_blk, 0,
323                                      (acpi_physical_address) local_fadt->
324                                      V1_gpe0_blk);
325         acpi_tb_init_generic_address(&local_fadt->xgpe1_blk, 0,
326                                      (acpi_physical_address) local_fadt->
327                                      V1_gpe1_blk);
328
329         /* Create separate GAS structs for the PM1 Enable registers */
330
331         acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
332                                      (u8) ACPI_DIV_2(acpi_gbl_FADT->
333                                                      pm1_evt_len),
334                                      (acpi_physical_address)
335                                      (local_fadt->xpm1a_evt_blk.address +
336                                       ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
337
338         /* PM1B is optional; leave null if not present */
339
340         if (local_fadt->xpm1b_evt_blk.address) {
341                 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
342                                              (u8) ACPI_DIV_2(acpi_gbl_FADT->
343                                                              pm1_evt_len),
344                                              (acpi_physical_address)
345                                              (local_fadt->xpm1b_evt_blk.
346                                               address +
347                                               ACPI_DIV_2(acpi_gbl_FADT->
348                                                          pm1_evt_len)));
349         }
350 }
351
352 /*******************************************************************************
353  *
354  * FUNCTION:    acpi_tb_convert_fadt2
355  *
356  * PARAMETERS:  local_fadt      - Pointer to new FADT
357  *              original_fadt   - Pointer to old FADT
358  *
359  * RETURN:      None, populates local_fadt
360  *
361  * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format.
362  *              Handles optional "X" fields.
363  *
364  ******************************************************************************/
365
366 static void
367 acpi_tb_convert_fadt2(struct fadt_descriptor *local_fadt,
368                       struct fadt_descriptor *original_fadt)
369 {
370
371         /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
372
373         ACPI_MEMCPY(local_fadt, original_fadt, sizeof(struct fadt_descriptor));
374
375         /*
376          * "X" fields are optional extensions to the original V1.0 fields, so
377          * we must selectively expand V1.0 fields if the corresponding X field
378          * is zero.
379          */
380         if (!(local_fadt->xfirmware_ctrl)) {
381                 ACPI_STORE_ADDRESS(local_fadt->xfirmware_ctrl,
382                                    local_fadt->V1_firmware_ctrl);
383         }
384
385         if (!(local_fadt->Xdsdt)) {
386                 ACPI_STORE_ADDRESS(local_fadt->Xdsdt, local_fadt->V1_dsdt);
387         }
388
389         if (!(local_fadt->xpm1a_evt_blk.address)) {
390                 acpi_tb_init_generic_address(&local_fadt->xpm1a_evt_blk,
391                                              local_fadt->pm1_evt_len,
392                                              (acpi_physical_address)
393                                              local_fadt->V1_pm1a_evt_blk);
394         }
395
396         if (!(local_fadt->xpm1b_evt_blk.address)) {
397                 acpi_tb_init_generic_address(&local_fadt->xpm1b_evt_blk,
398                                              local_fadt->pm1_evt_len,
399                                              (acpi_physical_address)
400                                              local_fadt->V1_pm1b_evt_blk);
401         }
402
403         if (!(local_fadt->xpm1a_cnt_blk.address)) {
404                 acpi_tb_init_generic_address(&local_fadt->xpm1a_cnt_blk,
405                                              local_fadt->pm1_cnt_len,
406                                              (acpi_physical_address)
407                                              local_fadt->V1_pm1a_cnt_blk);
408         }
409
410         if (!(local_fadt->xpm1b_cnt_blk.address)) {
411                 acpi_tb_init_generic_address(&local_fadt->xpm1b_cnt_blk,
412                                              local_fadt->pm1_cnt_len,
413                                              (acpi_physical_address)
414                                              local_fadt->V1_pm1b_cnt_blk);
415         }
416
417         if (!(local_fadt->xpm2_cnt_blk.address)) {
418                 acpi_tb_init_generic_address(&local_fadt->xpm2_cnt_blk,
419                                              local_fadt->pm2_cnt_len,
420                                              (acpi_physical_address)
421                                              local_fadt->V1_pm2_cnt_blk);
422         }
423
424         if (!(local_fadt->xpm_tmr_blk.address)) {
425                 acpi_tb_init_generic_address(&local_fadt->xpm_tmr_blk,
426                                              local_fadt->pm_tm_len,
427                                              (acpi_physical_address)
428                                              local_fadt->V1_pm_tmr_blk);
429         }
430
431         if (!(local_fadt->xgpe0_blk.address)) {
432                 acpi_tb_init_generic_address(&local_fadt->xgpe0_blk,
433                                              0,
434                                              (acpi_physical_address)
435                                              local_fadt->V1_gpe0_blk);
436         }
437
438         if (!(local_fadt->xgpe1_blk.address)) {
439                 acpi_tb_init_generic_address(&local_fadt->xgpe1_blk,
440                                              0,
441                                              (acpi_physical_address)
442                                              local_fadt->V1_gpe1_blk);
443         }
444
445         /* Create separate GAS structs for the PM1 Enable registers */
446
447         acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
448                                      (u8) ACPI_DIV_2(acpi_gbl_FADT->
449                                                      pm1_evt_len),
450                                      (acpi_physical_address)
451                                      (local_fadt->xpm1a_evt_blk.address +
452                                       ACPI_DIV_2(acpi_gbl_FADT->pm1_evt_len)));
453
454         acpi_gbl_xpm1a_enable.address_space_id =
455             local_fadt->xpm1a_evt_blk.address_space_id;
456
457         /* PM1B is optional; leave null if not present */
458
459         if (local_fadt->xpm1b_evt_blk.address) {
460                 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
461                                              (u8) ACPI_DIV_2(acpi_gbl_FADT->
462                                                              pm1_evt_len),
463                                              (acpi_physical_address)
464                                              (local_fadt->xpm1b_evt_blk.
465                                               address +
466                                               ACPI_DIV_2(acpi_gbl_FADT->
467                                                          pm1_evt_len)));
468
469                 acpi_gbl_xpm1b_enable.address_space_id =
470                     local_fadt->xpm1b_evt_blk.address_space_id;
471         }
472 }
473
474 /*******************************************************************************
475  *
476  * FUNCTION:    acpi_tb_convert_table_fadt
477  *
478  * PARAMETERS:  None
479  *
480  * RETURN:      Status
481  *
482  * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local
483  *              ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
484  *              copied to the local FADT.  The ACPI CA software uses this
485  *              local FADT. Thus a significant amount of special #ifdef
486  *              type codeing is saved.
487  *
488  ******************************************************************************/
489
490 acpi_status acpi_tb_convert_table_fadt(void)
491 {
492         struct fadt_descriptor *local_fadt;
493         struct acpi_table_desc *table_desc;
494
495         ACPI_FUNCTION_TRACE(tb_convert_table_fadt);
496
497         /*
498          * acpi_gbl_FADT is valid. Validate the FADT length. The table must be
499          * at least as long as the version 1.0 FADT
500          */
501         if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
502                 ACPI_ERROR((AE_INFO, "FADT is invalid, too short: 0x%X",
503                             acpi_gbl_FADT->length));
504                 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
505         }
506
507         /* Allocate buffer for the ACPI 2.0(+) FADT */
508
509         local_fadt = ACPI_ALLOCATE_ZEROED(sizeof(struct fadt_descriptor));
510         if (!local_fadt) {
511                 return_ACPI_STATUS(AE_NO_MEMORY);
512         }
513
514         if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) {
515                 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor)) {
516
517                         /* Length is too short to be a V2.0 table */
518
519                         ACPI_WARNING((AE_INFO,
520                                       "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table",
521                                       acpi_gbl_FADT->length,
522                                       acpi_gbl_FADT->revision));
523
524                         acpi_tb_convert_fadt1(local_fadt,
525                                               (void *)acpi_gbl_FADT);
526                 } else {
527                         /* Valid V2.0 table */
528
529                         acpi_tb_convert_fadt2(local_fadt, acpi_gbl_FADT);
530                 }
531         } else {
532                 /* Valid V1.0 table */
533
534                 acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT);
535         }
536
537         /* Global FADT pointer will point to the new common V2.0 FADT */
538
539         acpi_gbl_FADT = local_fadt;
540         acpi_gbl_FADT->length = sizeof(struct fadt_descriptor);
541
542         /* Free the original table */
543
544         table_desc = acpi_gbl_table_lists[ACPI_TABLE_ID_FADT].next;
545         acpi_tb_delete_single_table(table_desc);
546
547         /* Install the new table */
548
549         table_desc->pointer =
550             ACPI_CAST_PTR(struct acpi_table_header, acpi_gbl_FADT);
551         table_desc->allocation = ACPI_MEM_ALLOCATED;
552         table_desc->length = sizeof(struct fadt_descriptor);
553
554         /* Dump the entire FADT */
555
556         ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
557                           "Hex dump of common internal FADT, size %d (%X)\n",
558                           acpi_gbl_FADT->length, acpi_gbl_FADT->length));
559
560         ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT),
561                          acpi_gbl_FADT->length);
562
563         return_ACPI_STATUS(AE_OK);
564 }
565
566 /*******************************************************************************
567  *
568  * FUNCTION:    acpi_tb_build_common_facs
569  *
570  * PARAMETERS:  table_info      - Info for currently installed FACS
571  *
572  * RETURN:      Status
573  *
574  * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal
575  *              table format.
576  *
577  ******************************************************************************/
578
579 acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
580 {
581
582         ACPI_FUNCTION_TRACE(tb_build_common_facs);
583
584         /* Absolute minimum length is 24, but the ACPI spec says 64 */
585
586         if (acpi_gbl_FACS->length < 24) {
587                 ACPI_ERROR((AE_INFO, "Invalid FACS table length: 0x%X",
588                             acpi_gbl_FACS->length));
589                 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
590         }
591
592         if (acpi_gbl_FACS->length < 64) {
593                 ACPI_WARNING((AE_INFO,
594                               "FACS is shorter than the ACPI specification allows: 0x%X, using anyway",
595                               acpi_gbl_FACS->length));
596         }
597
598         /* Copy fields to the new FACS */
599
600         acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock);
601
602         if ((acpi_gbl_RSDP->revision < 2) ||
603             (acpi_gbl_FACS->length < 32) ||
604             (!(acpi_gbl_FACS->xfirmware_waking_vector))) {
605
606                 /* ACPI 1.0 FACS or short table or optional X_ field is zero */
607
608                 acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR(u64,
609                                                                             &
610                                                                             (acpi_gbl_FACS->
611                                                                              firmware_waking_vector));
612                 acpi_gbl_common_fACS.vector_width = 32;
613         } else {
614                 /* ACPI 2.0 FACS with valid X_ field */
615
616                 acpi_gbl_common_fACS.firmware_waking_vector =
617                     &acpi_gbl_FACS->xfirmware_waking_vector;
618                 acpi_gbl_common_fACS.vector_width = 64;
619         }
620
621         return_ACPI_STATUS(AE_OK);
622 }