coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
acpi_bert.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <acpi/acpi.h>
4 #include <acpi/acpigen.h>
5 #include <arch/bert_storage.h>
6 #include <console/console.h>
7 #include <intelblocks/acpi.h>
8 #include <intelblocks/crashlog.h>
9 
10 static bool boot_error_src_present(void)
11 {
12  if (!CONFIG(SOC_INTEL_CRASHLOG)) {
13  printk(BIOS_DEBUG, "Crashlog disabled.\n");
14  return false;
15  }
16 
17  if (!discover_crashlog()) {
18  printk(BIOS_SPEW, "Crashlog discovery result: crashlog not found\n");
19  return false;
20  }
21 
23 
24  /* Discovery tables sizes can be larger than the actual valid collected data */
25  u32 crashlog_size = cl_get_total_data_size();
26 
27  return (crashlog_size > 0);
28 }
29 
30 enum cb_err acpi_soc_get_bert_region(void **region, size_t *length)
31 {
33  size_t cpu_record_size, pmc_record_size;
34  size_t gesb_header_size;
35  void *cl_data = NULL;
36 
37  if (!boot_error_src_present()) {
38  return CB_ERR;
39  }
40 
41  if (!cl_get_total_data_size()) {
42  printk(BIOS_ERR, "No crashlog record present\n");
43  return CB_ERR;
44  }
45 
47  gesb_header_size = sizeof(*status);
48 
49  if (!status) {
50  printk(BIOS_ERR, "unable to allocate GSB\n");
51  return CB_ERR;
52  }
53 
55  printk(BIOS_ERR, "Crashlog entry would exceed "
56  "available region\n");
57  return CB_ERR;
58  }
59 
60  cpu_record_size = cl_get_cpu_record_size();
61  if (cpu_record_size) {
62  cl_data = new_cper_fw_error_crashlog(status, cpu_record_size);
63  if (!cl_data) {
64  printk(BIOS_ERR, "Crashlog CPU entry(size %lu) "
65  "would exceed available region\n",
66  cpu_record_size);
67  return CB_ERR;
68  }
69  printk(BIOS_DEBUG, "cl_data %p, cpu_record_size %lu\n",
70  cl_data, cpu_record_size);
71  cl_fill_cpu_records(cl_data);
72  }
73 
74  pmc_record_size = cl_get_pmc_record_size();
75  if (pmc_record_size) {
76  /* Allocate new FW ERR structure in case CPU crashlog is present */
77  if (cpu_record_size && !bert_append_fw_err(status)) {
78  printk(BIOS_ERR, "Crashlog PMC entry would "
79  "exceed available region\n");
80  return CB_ERR;
81  }
82 
83  cl_data = new_cper_fw_error_crashlog(status, pmc_record_size);
84  if (!cl_data) {
85  printk(BIOS_ERR, "Crashlog PMC entry(size %lu) "
86  "would exceed available region\n",
87  pmc_record_size);
88  return CB_ERR;
89  }
90  printk(BIOS_DEBUG, "cl_data %p, pmc_record_size %lu\n",
91  cl_data, pmc_record_size);
92  cl_fill_pmc_records(cl_data);
93  }
94 
95  *length = status->data_length + gesb_header_size;
96  *region = (void *)status;
97 
98  return CB_SUCCESS;
99 }
enum cb_err acpi_soc_get_bert_region(void **region, size_t *length)
Definition: acpi_bert.c:30
static bool boot_error_src_present(void)
Definition: acpi_bert.c:10
size_t bert_storage_remaining(void)
acpi_hest_generic_data_v300_t * bert_append_fw_err(acpi_generic_error_status_t *status)
acpi_generic_error_status_t * bert_new_event(guid_t *guid)
void * new_cper_fw_error_crashlog(acpi_generic_error_status_t *status, size_t cl_size)
int cl_get_total_data_size(void)
Definition: crashlog.c:230
int cl_get_pmc_record_size(void)
Definition: crashlog.c:245
int cl_get_cpu_record_size(void)
Definition: crashlog.c:250
cb_err
coreboot error codes
Definition: cb_err.h:15
@ CB_ERR
Generic error code.
Definition: cb_err.h:17
@ CB_SUCCESS
Call completed successfully.
Definition: cb_err.h:16
bool cl_fill_pmc_records(void *cl_record)
Definition: crashlog.c:487
void collect_pmc_and_cpu_crashlog_from_srams(void)
Definition: crashlog.c:445
bool discover_crashlog(void)
Definition: crashlog.c:239
bool cl_fill_cpu_records(void *cl_record)
Definition: crashlog.c:469
#define printk(level,...)
Definition: stdlib.h:16
#define CPER_SEC_FW_ERR_REC_REF_GUID
Definition: cper.h:63
@ CONFIG
Definition: dsi_common.h:201
uint64_t length
Definition: fw_cfg_if.h:1
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
Definition: loglevel.h:142
#define NULL
Definition: stddef.h:19
uint32_t u32
Definition: stdint.h:51
Definition: region.h:76