You are on page 1of 2

1 #ifndef _LINUX_ACPI_H

2 #define _LINUX_ACPI_H
3 #include "def/types.h"
4 #include "def/status.h"
5
6 // Root System Description Table Pointer - RSDP
7 #define ACPI_BIOS_ROM_BASE (0x0E0000)
8 #define ACPI_BIOS_ROM_END (0x100000)
9 #define ACPI_RSDP1_SIG 0x20445352 /* 'RSD ' */
10 #define ACPI_RSDP2_SIG 0x20525450 /* 'PTR ' */
11 // https://elixir.bootlin.com/linux/2.3.35/source/include/linux/acpi.h#L267
12 struct acpi_rsdp
13 {
14 b32 signature[2];
15 nat8 checksum;
16 byte oem_id[6];
17 nat8 revision;
18 struct acpi_rsdt *rsdt;
19 } __attribute__((packed));
20
21 // Root System Description Table - https://wiki.osdev.org/RSDT
22 #define ACPI_RSDT_SIG 0x54445352 /* 'RSDT' */
23 // https://elixir.bootlin.com/linux/2.3.35/source/include/linux/acpi.h#L275
24 struct acpi_sdt_header
25 {
26 b32 signature;
27 nat32 length; // Total size of the table, inclusive of the header.
28 nat8 rev;
29 nat8 checksum;
30 byte oem_id[6];
31 byte oem_table_id[8];
32 nat32 oem_revision;
33 nat32 creator_id;
34 nat32 creator_revision;
35 } __attribute__((packed));
36 struct acpi_rsdt
37 {
38 struct acpi_sdt_header header;
39 struct acpi_sdt_header *sdt_ptrs[]; // pointer to other sdt
40 };
41
42 // Fixed ACPI Description Table - https://wiki.osdev.org/FADT
43 #define ACPI_FADT_SIG 0x50434146 // equals to four bytes value of "FACP" encode with
ASCII
44 // https://elixir.bootlin.com/linux/2.3.35/source/include/linux/acpi.h#L287
45 struct acpi_fadt
46 {
47 struct acpi_sdt_header header;
48 nat32 facs;
49 struct acpi_dsdt *dsdt;
50 nat8 int_model;
51 nat8 reserved;
52 nat16 sci_int;
53 nat32 smi_cmd;
54 nat8 acpi_enable;
55 nat8 acpi_disable;
56 nat8 s4bios_req;
57 nat8 reserved2;
58 nat32 pm1a_evt;
59 nat32 pm1b_evt;
60 nat32 pm1a_cnt;
61 nat32 pm1b_cnt;
62 nat32 pm2_cnt;
63 nat32 pm_tmr;
64 nat32 gpe0;
65 nat32 gpe1;
66 nat8 pm1_evt_len;
67 nat8 pm1_cnt_len;
68 nat8 pm2_cnt_len;
69 nat8 pm_tm_len;
70 nat8 gpe0_len;
71 nat8 gpe1_len;
72 nat8 gpe1_base;
73 nat8 reserved3;
74 nat16 p_lvl2_lat;
75 nat16 p_lvl3_lat;
76 nat16 flush_size;
77 nat16 flush_stride;
78 nat8 duty_offset;
79 nat8 duty_width;
80 nat8 day_alarm;
81 nat8 mon_alarm;
82 nat8 century;
83 byte reserved4;
84 byte reserved5;
85 byte reserved6;
86 b32 flags;
87 } __attribute__((packed));
88
89 // Differentiated System Description Table - https://wiki.osdev.org/DSDT
90 #define ACPI_DSDT_SIG 0x54445344 /* 'DSDT' */
91 struct acpi_dsdt
92 {
93 struct acpi_sdt_header header;
94 byte aml_code[];
95 } __attribute__((packed));
96
97 STATUS acpi_init(void);
98 STATUS acpi_power_off(void);
99
100 #endif

You might also like