1 /* $NetBSD: acpidump.h,v 1.7 2017/09/07 04:40:56 msaitoh Exp $ */
2 
3 /*-
4  * Copyright (c) 1999 Doug Rabson
5  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *        $FreeBSD$
30  */
31 
32 #ifndef _ACPIDUMP_H_
33 #define   _ACPIDUMP_H_
34 
35 #include <stdlib.h> /* for size_t */
36 #include <acpi_common.h>
37 #include <dev/acpi/acpica.h>
38 
39 /* Subfields in the HPET Id member. */
40 #define   ACPI_HPET_ID_HARDWARE_REV_ID  0x000000ff
41 #define   ACPI_HPET_ID_COMPARATORS      0x00001f00
42 #define   ACPI_HPET_ID_COUNT_SIZE_CAP   0x00002000
43 #define   ACPI_HPET_ID_LEGACY_CAPABLE   0x00008000
44 #define   ACPI_HPET_ID_PCI_VENDOR_ID    0xffff0000
45 
46 /* Find and map the RSD PTR structure and return it for parsing */
47 ACPI_TABLE_HEADER *sdt_load_devmem(void);
48 
49 /* TCPA */
50 struct TCPAbody {
51           ACPI_TABLE_HEADER header;
52           uint16_t  platform_class;
53 #define ACPI_TCPA_BIOS_CLIENT 0x00
54 #define ACPI_TCPA_BIOS_SERVER 0x01
55           union {
56                     struct client_hdr {
57                               uint32_t  log_max_len __packed;
58                               uint64_t  log_start_addr __packed;
59                     } client;
60                     struct server_hdr {
61                               uint16_t  reserved;
62                               uint64_t  log_max_len __packed;
63                               uint64_t  log_start_addr __packed;
64                     } server;
65           };
66 } __packed;
67 
68 struct TCPAevent {
69           u_int32_t pcr_index;
70           u_int32_t event_type;
71           u_int8_t  pcr_value[20];
72           u_int32_t event_size;
73           u_int8_t  event_data[0];
74 };
75 
76 struct TCPApc_event {
77           u_int32_t event_id;
78           u_int32_t event_size;
79           u_int8_t  event_data[0];
80 };
81 
82 enum TCPAevent_types {
83           PREBOOT = 0,
84           POST_CODE,
85           UNUSED,
86           NO_ACTION,
87           SEPARATOR,
88           ACTION,
89           EVENT_TAG,
90           SCRTM_CONTENTS,
91           SCRTM_VERSION,
92           CPU_MICROCODE,
93           PLATFORM_CONFIG_FLAGS,
94           TABLE_OF_DEVICES,
95           COMPACT_HASH,
96           IPL,
97           IPL_PARTITION_DATA,
98           NONHOST_CODE,
99           NONHOST_CONFIG,
100           NONHOST_INFO,
101           EVENT_TYPE_MAX,
102 };
103 
104 enum TCPApcclient_ids {
105           SMBIOS = 1,
106           BIS_CERT,
107           POST_BIOS_ROM,
108           ESCD,
109           CMOS,
110           NVRAM,
111           OPTION_ROM_EXEC,
112           OPTION_ROM_CONFIG,
113           OPTION_ROM_MICROCODE = 10,
114           S_CRTM_VERSION,
115           S_CRTM_CONTENTS,
116           POST_CONTENTS,
117           HOST_TABLE_OF_DEVICES,
118           PCCLIENT_ID_MAX,
119 };
120 
121 /*
122  * Load the DSDT from a previous save file.  Note that other tables are
123  * not saved (i.e. FADT)
124  */
125 ACPI_TABLE_HEADER *dsdt_load_file(char *);
126 
127 /* Save the DSDT to a file */
128 void       dsdt_save_file(char *, ACPI_TABLE_HEADER *, ACPI_TABLE_HEADER *);
129 
130 /* Print out as many fixed tables as possible, given the RSD PTR */
131 void       sdt_print_all(ACPI_TABLE_HEADER *);
132 
133 /* Disassemble the AML in the DSDT */
134 void       aml_disassemble(ACPI_TABLE_HEADER *, ACPI_TABLE_HEADER *);
135 
136 /* Routines for accessing tables in physical memory */
137 ACPI_TABLE_RSDP *acpi_find_rsd_ptr(void);
138 void      *acpi_map_physical(vm_offset_t, size_t);
139 ACPI_TABLE_HEADER *sdt_from_rsdt(ACPI_TABLE_HEADER *, const char *,
140               ACPI_TABLE_HEADER *);
141 ACPI_TABLE_HEADER *dsdt_from_fadt(ACPI_TABLE_FADT *);
142 int        acpi_checksum(void *, size_t);
143 
144 /* Command line flags */
145 extern int          cflag;
146 extern int          dflag;
147 extern int          sflag;
148 extern int          tflag;
149 extern int          vflag;
150 
151 #endif    /* !_ACPIDUMP_H_ */
152