xref: /linux/tools/power/acpi/tools/acpidump/acpidump.h (revision 908fc4c2)
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /******************************************************************************
3  *
4  * Module Name: acpidump.h - Include file for acpi_dump utility
5  *
6  * Copyright (C) 2000 - 2022, Intel Corp.
7  *
8  *****************************************************************************/
9 
10 /*
11  * Global variables. Defined in main.c only, externed in all other files
12  */
13 #ifdef _DECLARE_GLOBALS
14 #define EXTERN
15 #define INIT_GLOBAL(a,b)        a=b
16 #else
17 #define EXTERN                  extern
18 #define INIT_GLOBAL(a,b)        a
19 #endif
20 
21 #include <acpi/acpi.h>
22 #include "accommon.h"
23 #include "actables.h"
24 #include "acapps.h"
25 
26 /* Globals */
27 
28 EXTERN u8 INIT_GLOBAL(gbl_summary_mode, FALSE);
29 EXTERN u8 INIT_GLOBAL(gbl_verbose_mode, FALSE);
30 EXTERN u8 INIT_GLOBAL(gbl_binary_mode, FALSE);
31 EXTERN u8 INIT_GLOBAL(gbl_dump_customized_tables, TRUE);
32 EXTERN u8 INIT_GLOBAL(gbl_do_not_dump_xsdt, FALSE);
33 EXTERN ACPI_FILE INIT_GLOBAL(gbl_output_file, NULL);
34 EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL);
35 EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0);
36 
37 /* Action table used to defer requested options */
38 
39 struct ap_dump_action {
40 	char *argument;
41 	u32 to_be_done;
42 };
43 
44 #define AP_MAX_ACTIONS              32
45 
46 #define AP_DUMP_ALL_TABLES          0
47 #define AP_DUMP_TABLE_BY_ADDRESS    1
48 #define AP_DUMP_TABLE_BY_NAME       2
49 #define AP_DUMP_TABLE_BY_FILE       3
50 
51 #define AP_MAX_ACPI_FILES           256	/* Prevent infinite loops */
52 
53 /* Minimum FADT sizes for various table addresses */
54 
55 #define MIN_FADT_FOR_DSDT           (ACPI_FADT_OFFSET (dsdt) + sizeof (u32))
56 #define MIN_FADT_FOR_FACS           (ACPI_FADT_OFFSET (facs) + sizeof (u32))
57 #define MIN_FADT_FOR_XDSDT          (ACPI_FADT_OFFSET (Xdsdt) + sizeof (u64))
58 #define MIN_FADT_FOR_XFACS          (ACPI_FADT_OFFSET (Xfacs) + sizeof (u64))
59 
60 /*
61  * apdump - Table get/dump routines
62  */
63 int ap_dump_table_from_file(char *pathname);
64 
65 int ap_dump_table_by_name(char *signature);
66 
67 int ap_dump_table_by_address(char *ascii_address);
68 
69 int ap_dump_all_tables(void);
70 
71 u8 ap_is_valid_header(struct acpi_table_header *table);
72 
73 u8 ap_is_valid_checksum(struct acpi_table_header *table);
74 
75 u32 ap_get_table_length(struct acpi_table_header *table);
76 
77 /*
78  * apfiles - File I/O utilities
79  */
80 int ap_open_output_file(char *pathname);
81 
82 int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance);
83 
84 struct acpi_table_header *ap_get_table_from_file(char *pathname,
85 						 u32 *file_size);
86