xref: /freebsd/usr.sbin/acpi/acpidump/acpidump.h (revision 5521ff5a4d1929056e7ffc982fac3341ca54df7c)
1 /*-
2  * Copyright (c) 1999 Doug Rabson
3  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  *	$Id: acpidump.h,v 1.3 2000/08/09 14:47:52 iwasaki Exp $
28  *	$FreeBSD$
29  */
30 
31 #ifndef _ACPIDUMP_H_
32 #define _ACPIDUMP_H_
33 
34 /* Generic Address structure */
35 struct ACPIgas {
36 	u_int8_t	address_space_id;
37 #define ACPI_GAS_MEMORY		0
38 #define ACPI_GAS_IO		1
39 #define ACPI_GAS_PCI		2
40 #define ACPI_GAS_EMBEDDED	3
41 #define ACPI_GAS_SMBUS		4
42 #define ACPI_GAS_FIXED		0x7f
43 	u_int8_t	register_bit_width;
44 	u_int8_t	register_bit_offset;
45 	u_int8_t	res;
46 	u_int64_t	address;
47 } __attribute__((packed));
48 
49 /* Root System Description Pointer */
50 struct ACPIrsdp {
51 	u_char		signature[8];
52 	u_char		sum;
53 	u_char		oem[6];
54 	u_char		res;
55 	u_int32_t	addr;
56 } __attribute__((packed));
57 
58 /* System Description Table */
59 struct ACPIsdt {
60 	u_char		signature[4];
61 	u_int32_t	len;
62 	u_char		rev;
63 	u_char		check;
64 	u_char		oemid[6];
65 	u_char		oemtblid[8];
66 	u_int32_t	oemrev;
67 	u_char		creator[4];
68 	u_int32_t	crerev;
69 #define SIZEOF_SDT_HDR 36	/* struct size except body */
70 	u_int32_t	body[1];/* This member should be casted */
71 } __attribute__((packed));
72 
73 /* Fixed ACPI Description Table (body) */
74 struct FACPbody {
75 	u_int32_t	facs_ptr;
76 	u_int32_t	dsdt_ptr;
77 	u_int8_t	int_model;
78 #define ACPI_FACP_INTMODEL_PIC	0	/* Standard PC-AT PIC */
79 #define ACPI_FACP_INTMODEL_APIC	1	/* Multiple APIC */
80 	u_char		reserved1;
81 	u_int16_t	sci_int;
82 	u_int32_t	smi_cmd;
83 	u_int8_t	acpi_enable;
84 	u_int8_t	acpi_disable;
85 	u_int8_t	s4biosreq;
86 	u_int8_t	reserved2;
87 	u_int32_t	pm1a_evt_blk;
88 	u_int32_t	pm1b_evt_blk;
89 	u_int32_t	pm1a_cnt_blk;
90 	u_int32_t	pm1b_cnt_blk;
91 	u_int32_t	pm2_cnt_blk;
92 	u_int32_t	pm_tmr_blk;
93 	u_int32_t	gpe0_blk;
94 	u_int32_t	gpe1_blk;
95 	u_int8_t	pm1_evt_len;
96 	u_int8_t	pm1_cnt_len;
97 	u_int8_t	pm2_cnt_len;
98 	u_int8_t	pm_tmr_len;
99 	u_int8_t	gpe0_len;
100 	u_int8_t	gpe1_len;
101 	u_int8_t	gpe1_base;
102 	u_int8_t	reserved3;
103 	u_int16_t	p_lvl2_lat;
104 	u_int16_t	p_lvl3_lat;
105 	u_int16_t	flush_size;
106 	u_int16_t	flush_stride;
107 	u_int8_t	duty_off;
108 	u_int8_t	duty_width;
109 	u_int8_t	day_alrm;
110 	u_int8_t	mon_alrm;
111 	u_int8_t	century;
112 	u_int16_t	iapc_boot_arch;
113 	u_char		reserved4[1];
114 	u_int32_t	flags;
115 #define ACPI_FACP_FLAG_WBINVD	1	/* WBINVD is correctly supported */
116 #define ACPI_FACP_FLAG_WBINVD_FLUSH 2	/* WBINVD flushes caches */
117 #define ACPI_FACP_FLAG_PROC_C1	4	/* C1 power state supported */
118 #define ACPI_FACP_FLAG_P_LVL2_UP 8	/* C2 power state works on SMP */
119 #define ACPI_FACP_FLAG_PWR_BUTTON 16	/* Power button uses control method */
120 #define ACPI_FACP_FLAG_SLP_BUTTON 32	/* Sleep button uses control method */
121 #define ACPI_FACP_FLAG_FIX_RTC	64	/* RTC wakeup not supported */
122 #define ACPI_FACP_FLAG_RTC_S4	128	/* RTC can wakeup from S4 state */
123 #define ACPI_FACP_FLAG_TMR_VAL_EXT 256	/* TMR_VAL is 32bit */
124 #define ACPI_FACP_FLAG_DCK_CAP	512	/* Can support docking */
125 	struct ACPIgas	reset_reg;
126 	u_int8_t	reset_value;
127 	u_int8_t	reserved5[3];
128 	u_int64_t	x_firmware_ctrl;
129 	u_int64_t	x_dsdt;
130 	struct ACPIgas	x_pm1a_evt_blk;
131 	struct ACPIgas	x_pm1b_evt_blk;
132 	struct ACPIgas	x_pm1a_cnt_blk;
133 	struct ACPIgas	x_pm1b_cnt_blk;
134 	struct ACPIgas	x_pm2_cnt_blk;
135 	struct ACPIgas	x_pm_tmr_blk;
136 	struct ACPIgas	x_gpe0_blk;
137 	struct ACPIgas	x_gpe1_blk;
138 } __attribute__((packed));
139 
140 /* Firmware ACPI Control Structure */
141 struct FACS {
142 	u_char		signature[4];
143 	u_int32_t	len;
144 	u_char		hard_sig[4];
145 	/*
146 	 * NOTE This should be filled with physical address below 1MB!!
147 	 * sigh....
148 	 */
149 	u_int32_t	firm_wake_vec;
150 	u_int32_t	g_lock;		/* bit field */
151 	/* 5.2.6.1 Global Lock */
152 #define ACPI_GLOBAL_LOCK_PENDING 1
153 #define ACPI_GLOBAL_LOCK_OWNED 2
154 	u_int32_t	flags;		/* bit field */
155 #define ACPI_FACS_FLAG_S4BIOS_F	1	/* Supports S4BIOS_SEQ */
156 	char		reserved[40];
157 } __attribute__((packed));
158 
159 void		*acpi_map_physical(vm_offset_t, size_t);
160 struct ACPIrsdp	*acpi_find_rsd_ptr(void);
161 int		 acpi_checksum(void *, size_t);
162 struct ACPIsdt	*acpi_map_sdt(vm_offset_t);
163 void		 acpi_print_rsd_ptr(struct ACPIrsdp *);
164 void		 acpi_print_sdt(struct ACPIsdt *);
165 void		 acpi_print_rsdt(struct ACPIsdt *);
166 void		 acpi_print_facp(struct FACPbody *);
167 void		 acpi_print_dsdt(struct ACPIsdt *);
168 
169 void		 asl_dump_termobj(u_int8_t **, int);
170 void		 asl_dump_objectlist(u_int8_t **, u_int8_t *, int);
171 
172 void		 aml_dump(u_int32_t *, int);
173 
174 void    	 acpi_handle_rsdt(struct ACPIsdt *);
175 void		 acpi_load_dsdt(char *, u_int8_t **, u_int8_t **);
176 
177 extern char	*aml_dumpfile;
178 
179 #endif	/* !_ACPIDUMP_H_ */
180