1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: tbprint - Table output utilities
6 * Copyright (C) 2000 - 2023, Intel Corp.
8 *****************************************************************************/
10 #include <acpi/acpi.h>
15 #define _COMPONENT ACPI_TABLES
16 ACPI_MODULE_NAME("tbprint")
18 /* Local prototypes */
19 static void acpi_tb_fix_string(char *string
, acpi_size length
);
22 acpi_tb_cleanup_table_header(struct acpi_table_header
*out_header
,
23 struct acpi_table_header
*header
);
25 /*******************************************************************************
27 * FUNCTION: acpi_tb_fix_string
29 * PARAMETERS: string - String to be repaired
30 * length - Maximum length
34 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
35 * with a question mark '?'.
37 ******************************************************************************/
39 static void acpi_tb_fix_string(char *string
, acpi_size length
)
42 while (length
&& *string
) {
43 if (!isprint((int)(u8
)*string
)) {
52 /*******************************************************************************
54 * FUNCTION: acpi_tb_cleanup_table_header
56 * PARAMETERS: out_header - Where the cleaned header is returned
57 * header - Input ACPI table header
59 * RETURN: Returns the cleaned header in out_header
61 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
62 * the header consist of printable characters.
64 ******************************************************************************/
67 acpi_tb_cleanup_table_header(struct acpi_table_header
*out_header
,
68 struct acpi_table_header
*header
)
71 memcpy(out_header
, header
, sizeof(struct acpi_table_header
));
73 acpi_tb_fix_string(out_header
->signature
, ACPI_NAMESEG_SIZE
);
74 acpi_tb_fix_string(out_header
->oem_id
, ACPI_OEM_ID_SIZE
);
75 acpi_tb_fix_string(out_header
->oem_table_id
, ACPI_OEM_TABLE_ID_SIZE
);
76 acpi_tb_fix_string(out_header
->asl_compiler_id
, ACPI_NAMESEG_SIZE
);
79 /*******************************************************************************
81 * FUNCTION: acpi_tb_print_table_header
83 * PARAMETERS: address - Table physical address
84 * header - Table header
88 * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
90 ******************************************************************************/
93 acpi_tb_print_table_header(acpi_physical_address address
,
94 struct acpi_table_header
*header
)
96 struct acpi_table_header local_header
;
98 if (ACPI_COMPARE_NAMESEG(header
->signature
, ACPI_SIG_FACS
)) {
100 /* FACS only has signature and length fields */
102 ACPI_INFO(("%-4.4s 0x%8.8X%8.8X %06X",
103 header
->signature
, ACPI_FORMAT_UINT64(address
),
105 } else if (ACPI_VALIDATE_RSDP_SIG(ACPI_CAST_PTR(struct acpi_table_rsdp
,
106 header
)->signature
)) {
108 /* RSDP has no common fields */
110 memcpy(local_header
.oem_id
,
111 ACPI_CAST_PTR(struct acpi_table_rsdp
, header
)->oem_id
,
113 acpi_tb_fix_string(local_header
.oem_id
, ACPI_OEM_ID_SIZE
);
115 ACPI_INFO(("RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)",
116 ACPI_FORMAT_UINT64(address
),
117 (ACPI_CAST_PTR(struct acpi_table_rsdp
, header
)->
119 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp
,
120 header
)->length
: 20,
121 ACPI_CAST_PTR(struct acpi_table_rsdp
,
123 local_header
.oem_id
));
125 /* Standard ACPI table with full common header */
127 acpi_tb_cleanup_table_header(&local_header
, header
);
129 ACPI_INFO(("%-4.4s 0x%8.8X%8.8X"
130 " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
131 local_header
.signature
, ACPI_FORMAT_UINT64(address
),
132 local_header
.length
, local_header
.revision
,
133 local_header
.oem_id
, local_header
.oem_table_id
,
134 local_header
.oem_revision
,
135 local_header
.asl_compiler_id
,
136 local_header
.asl_compiler_revision
));