xref: /freebsd/tools/tools/ncpus/acpidump.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
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 
28 #ifndef _ACPIDUMP_H_
29 #define _ACPIDUMP_H_
30 
31 /* Root System Description Pointer */
32 struct ACPIrsdp {
33 	u_char		signature[8];
34 	u_char		sum;
35 	u_char		oem[6];
36 	u_char		revision;
37 	u_int32_t	rsdt_addr;
38 	u_int32_t	length;
39 	u_int64_t	xsdt_addr;
40 	u_char		xsum;
41 	u_char		_reserved_[3];
42 } __packed;
43 
44 /* System Description Table */
45 struct ACPIsdt {
46 	u_char		signature[4];
47 	u_int32_t	len;
48 	u_char		rev;
49 	u_char		check;
50 	u_char		oemid[6];
51 	u_char		oemtblid[8];
52 	u_int32_t	oemrev;
53 	u_char		creator[4];
54 	u_int32_t	crerev;
55 #define SIZEOF_SDT_HDR 36	/* struct size except body */
56 	u_int32_t	body[1];/* This member should be casted */
57 } __packed;
58 
59 struct MADT_local_apic {
60 	u_char		cpu_id;
61 	u_char		apic_id;
62 	u_int32_t	flags;
63 #define	ACPI_MADT_APIC_LOCAL_FLAG_ENABLED	1
64 } __packed;
65 
66 struct MADT_io_apic {
67 	u_char		apic_id;
68 	u_char		reserved;
69 	u_int32_t	apic_addr;
70 	u_int32_t	int_base;
71 } __packed;
72 
73 struct MADT_int_override {
74 	u_char		bus;
75 	u_char		source;
76 	u_int32_t	intr;
77 	u_int16_t	mps_flags;
78 #define	MPS_INT_FLAG_POLARITY_MASK	0x3
79 #define	MPS_INT_FLAG_POLARITY_CONFORM	0x0
80 #define	MPS_INT_FLAG_POLARITY_HIGH	0x1
81 #define	MPS_INT_FLAG_POLARITY_LOW	0x3
82 #define	MPS_INT_FLAG_TRIGGER_MASK	0xc
83 #define	MPS_INT_FLAG_TRIGGER_CONFORM	0x0
84 #define	MPS_INT_FLAG_TRIGGER_EDGE	0x4
85 #define	MPS_INT_FLAG_TRIGGER_LEVEL	0xc
86 } __packed;
87 
88 struct MADT_nmi {
89 	u_int16_t	mps_flags;
90 	u_int32_t	intr;
91 } __packed;
92 
93 struct MADT_local_nmi {
94 	u_char		cpu_id;
95 	u_int16_t	mps_flags;
96 	u_char		lintpin;
97 } __packed;
98 
99 struct MADT_local_apic_override {
100 	u_char		reserved[2];
101 	u_int64_t	apic_addr;
102 } __packed;
103 
104 struct MADT_io_sapic {
105 	u_char		apic_id;
106 	u_char		reserved;
107 	u_int32_t	int_base;
108 	u_int64_t	apic_addr;
109 } __packed;
110 
111 struct MADT_local_sapic {
112 	u_char		cpu_id;
113 	u_char		apic_id;
114 	u_char		apic_eid;
115 	u_char		reserved[3];
116 	u_int32_t	flags;
117 } __packed;
118 
119 struct MADT_int_src {
120 	u_int16_t	mps_flags;
121 	u_char		type;
122 #define	ACPI_MADT_APIC_INT_SOURCE_PMI	1
123 #define	ACPI_MADT_APIC_INT_SOURCE_INIT	2
124 #define	ACPI_MADT_APIC_INT_SOURCE_CPEI	3	/* Corrected Platform Error */
125 	u_char		cpu_id;
126 	u_char		cpu_eid;
127 	u_char		sapic_vector;
128 	u_int32_t	intr;
129 	u_char		reserved[4];
130 } __packed;
131 
132 struct MADT_APIC {
133 	u_char		type;
134 #define	ACPI_MADT_APIC_TYPE_LOCAL_APIC	0
135 #define	ACPI_MADT_APIC_TYPE_IO_APIC	1
136 #define	ACPI_MADT_APIC_TYPE_INT_OVERRIDE 2
137 #define	ACPI_MADT_APIC_TYPE_NMI		3
138 #define	ACPI_MADT_APIC_TYPE_LOCAL_NMI	4
139 #define	ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE 5
140 #define	ACPI_MADT_APIC_TYPE_IO_SAPIC	6
141 #define	ACPI_MADT_APIC_TYPE_LOCAL_SAPIC	7
142 #define	ACPI_MADT_APIC_TYPE_INT_SRC	8
143 	u_char		len;
144 	union {
145 		struct MADT_local_apic local_apic;
146 		struct MADT_io_apic io_apic;
147 		struct MADT_int_override int_override;
148 		struct MADT_nmi nmi;
149 		struct MADT_local_nmi local_nmi;
150 		struct MADT_local_apic_override local_apic_override;
151 		struct MADT_io_sapic io_sapic;
152 		struct MADT_local_sapic local_sapic;
153 		struct MADT_int_src int_src;
154 	} body;
155 } __packed;
156 
157 struct MADTbody {
158 	u_int32_t	lapic_addr;
159 	u_int32_t	flags;
160 #define	ACPI_APIC_FLAG_PCAT_COMPAT 1	/* System has dual-8259 setup. */
161 	u_char		body[1];
162 } __packed;
163 
164 /*
165  * Addresses to scan on ia32 for the RSD PTR.  According to section 5.2.2
166  * of the ACPI spec, we only consider two regions for the base address:
167  * 1. EBDA (1 KB area addressed to by 16 bit pointer at 0x40E)
168  * 2. High memory (0xE0000 - 0xFFFFF)
169  */
170 #define RSDP_EBDA_PTR	0x40E
171 #define RSDP_EBDA_SIZE	0x400
172 #define RSDP_HI_START	0xE0000
173 #define RSDP_HI_SIZE	0x20000
174 
175 #endif	/* !_ACPIDUMP_H_ */
176