1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <cpu/x86/smm.h>
10 void acpi_fill_fadt(acpi_fadt_t
*fadt
)
12 const uint16_t pmbase
= ACPI_BASE_ADDRESS
;
15 fadt
->pm1a_evt_blk
= pmbase
+ PM1_STS
;
16 fadt
->pm1a_cnt_blk
= pmbase
+ PM1_CNT
;
17 fadt
->pm2_cnt_blk
= pmbase
+ PM2A_CNT_BLK
;
18 fadt
->pm_tmr_blk
= pmbase
+ PM1_TMR
;
19 fadt
->gpe0_blk
= pmbase
+ GPE0_STS
;
21 fadt
->pm1_evt_len
= 4;
22 fadt
->pm1_cnt_len
= 2;
23 fadt
->pm2_cnt_len
= 1;
25 fadt
->gpe0_blk_len
= 2 * (GPE0_EN
- GPE0_STS
);
27 fadt
->mon_alrm
= 0x00;
28 fadt
->iapc_boot_arch
= ACPI_FADT_LEGACY_DEVICES
| ACPI_FADT_8042
;
30 fadt
->flags
|= ACPI_FADT_WBINVD
| ACPI_FADT_C1_SUPPORTED
|
31 ACPI_FADT_SLEEP_BUTTON
|
32 ACPI_FADT_SEALED_CASE
| ACPI_FADT_S4_RTC_WAKE
|
33 ACPI_FADT_PLATFORM_CLOCK
;
35 fadt
->x_pm1a_evt_blk
.space_id
= ACPI_ADDRESS_SPACE_IO
;
36 fadt
->x_pm1a_evt_blk
.bit_width
= fadt
->pm1_evt_len
* 8;
37 fadt
->x_pm1a_evt_blk
.bit_offset
= 0;
38 fadt
->x_pm1a_evt_blk
.access_size
= ACPI_ACCESS_SIZE_WORD_ACCESS
;
39 fadt
->x_pm1a_evt_blk
.addrl
= fadt
->pm1a_evt_blk
;
40 fadt
->x_pm1a_evt_blk
.addrh
= 0x0;
42 fadt
->x_pm1a_cnt_blk
.space_id
= ACPI_ADDRESS_SPACE_IO
;
43 fadt
->x_pm1a_cnt_blk
.bit_width
= fadt
->pm1_cnt_len
* 8;
44 fadt
->x_pm1a_cnt_blk
.bit_offset
= 0;
45 fadt
->x_pm1a_cnt_blk
.access_size
= ACPI_ACCESS_SIZE_WORD_ACCESS
;
46 fadt
->x_pm1a_cnt_blk
.addrl
= fadt
->pm1a_cnt_blk
;
47 fadt
->x_pm1a_cnt_blk
.addrh
= 0x0;
49 fadt
->x_pm2_cnt_blk
.space_id
= ACPI_ADDRESS_SPACE_IO
;
50 fadt
->x_pm2_cnt_blk
.bit_width
= fadt
->pm2_cnt_len
* 8;
51 fadt
->x_pm2_cnt_blk
.bit_offset
= 0;
52 fadt
->x_pm2_cnt_blk
.access_size
= ACPI_ACCESS_SIZE_BYTE_ACCESS
;
53 fadt
->x_pm2_cnt_blk
.addrl
= fadt
->pm2_cnt_blk
;
54 fadt
->x_pm2_cnt_blk
.addrh
= 0x0;
56 fadt
->x_pm_tmr_blk
.space_id
= ACPI_ADDRESS_SPACE_IO
;
57 fadt
->x_pm_tmr_blk
.bit_width
= fadt
->pm_tmr_len
* 8;
58 fadt
->x_pm_tmr_blk
.bit_offset
= 0;
59 fadt
->x_pm_tmr_blk
.access_size
= ACPI_ACCESS_SIZE_DWORD_ACCESS
;
60 fadt
->x_pm_tmr_blk
.addrl
= fadt
->pm_tmr_blk
;
61 fadt
->x_pm_tmr_blk
.addrh
= 0x0;
64 * Windows 10 requires x_gpe0_blk to be set starting with FADT revision 5.
65 * The bit_width field intentionally overflows here.
66 * The OSPM can instead use the values in `fadt->gpe0_blk{,_len}`, which
67 * seems to work fine on Linux 5.0 and Windows 10.
69 fadt
->x_gpe0_blk
.space_id
= ACPI_ADDRESS_SPACE_IO
;
70 fadt
->x_gpe0_blk
.bit_width
= fadt
->gpe0_blk_len
* 8;
71 fadt
->x_gpe0_blk
.bit_offset
= 0;
72 fadt
->x_gpe0_blk
.access_size
= ACPI_ACCESS_SIZE_BYTE_ACCESS
;
73 fadt
->x_gpe0_blk
.addrl
= fadt
->gpe0_blk
;
74 fadt
->x_gpe0_blk
.addrh
= 0x0;