coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hest.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <soc/acpi.h>
4 #include <acpi/acpi_gnvs.h>
5 #include <cbmem.h>
6 #include <console/console.h>
7 #include <soc/hest.h>
8 #include <intelblocks/nvs.h>
9 
10 static u64 hest_get_elog_addr(void)
11 {
12  /* The elog address comes from reserved memory */
13  struct global_nvs *gnvs;
14  gnvs = acpi_get_gnvs();
15  if (!gnvs) {
16  printk(BIOS_ERR, "Unable to get gnvs\n");
17  return 0;
18  }
19 
20  /* Runtime logging address */
21  printk(BIOS_DEBUG, "\t status blk start addr = %llx\n", gnvs->hest_log_addr);
22  printk(BIOS_DEBUG, "\t size = %x\n", CONFIG_ERROR_LOG_BUFFER_SIZE);
23  return gnvs->hest_log_addr;
24 }
25 
26 static u32 acpi_hest_add_ghes(void *current)
27 {
28  ghes_record_t *rec = (ghes_record_t *)current;
29  u32 size = sizeof(ghes_record_t);
30 
31  /* Fill GHES error source descriptor */
32  memset(rec, 0, size);
34  rec->esd.source_id = 0; /* 0 for MCE check exception source */
35  rec->esd.enabled = 1;
36  rec->esd.related_src_id = 0xffff;
37  rec->esd.prealloc_erecords = 1;
38  rec->esd.max_section_per_record = 0xf;
40 
41  /* Add error_status_address */
42  rec->sts_addr.space_id = 0;
43  rec->sts_addr.bit_width = 0x40;
44  rec->sts_addr.bit_offset = 0;
46 
47  /* Add notification structure */
49  rec->notify.length = sizeof(acpi_hest_hen_t);
51 
52  /* error status block entries start address */
53  if (CONFIG(SOC_ACPI_HEST))
55 
56  return size;
57 }
58 
59 static unsigned long acpi_fill_hest(acpi_hest_t *hest)
60 {
61  acpi_header_t *header = &(hest->header);
62  void *current;
63  current = (void *)(hest);
64  void *next = current;
65  next = hest + 1;
66  next += acpi_hest_add_ghes(next);
67  hest->error_source_count += 1;
68  header->length += next - current;
69  return header->length;
70 }
71 
72 unsigned long hest_create(unsigned long current, struct acpi_rsdp *rsdp)
73 {
74  struct global_nvs *gnvs;
75  acpi_hest_t *hest;
76 
77  /* Reserve memory for Enhanced error logging */
78  void *mem = cbmem_add(CBMEM_ID_ACPI_HEST, CONFIG_ERROR_LOG_BUFFER_SIZE);
79  if (!mem) {
80  printk(BIOS_ERR, "Unable to allocate HEST memory\n");
81  return current;
82  }
83 
84  printk(BIOS_DEBUG, "HEST memory created: %p\n", mem);
85  gnvs = acpi_get_gnvs();
86  if (!gnvs) {
87  printk(BIOS_ERR, "Unable to get gnvs\n");
88  return current;
89  }
91  printk(BIOS_DEBUG, "elog_addr: %llx, size:%x\n", gnvs->hest_log_addr,
92  CONFIG_ERROR_LOG_BUFFER_SIZE);
93 
94  current = ALIGN(current, 8);
95  hest = (acpi_hest_t *)current;
97  acpi_add_table(rsdp, (void *)current);
98  current += hest->header.length;
99  return current;
100 }
void acpi_add_table(acpi_rsdp_t *rsdp, void *table)
Add an ACPI table to the RSDT (and XSDT) structure, recalculate length and checksum.
Definition: acpi.c:49
void acpi_write_hest(acpi_hest_t *hest, unsigned long(*acpi_fill_hest)(acpi_hest_t *hest))
Definition: acpi.c:1433
void * acpi_get_gnvs(void)
Definition: gnvs.c:40
struct arm64_kernel_header header
Definition: fit_payload.c:30
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
void * cbmem_add(u32 id, u64 size)
Definition: imd_cbmem.c:144
#define CBMEM_ID_ACPI_HEST
Definition: cbmem_id.h:10
#define printk(level,...)
Definition: stdlib.h:16
@ CONFIG
Definition: dsi_common.h:201
static u32 acpi_hest_add_ghes(void *current)
Definition: hest.c:26
unsigned long hest_create(unsigned long current, struct acpi_rsdp *rsdp)
Definition: hest.c:72
static u64 hest_get_elog_addr(void)
Definition: hest.c:10
static unsigned long acpi_fill_hest(acpi_hest_t *hest)
Definition: hest.c:59
#define QWORD_ACCESS
Definition: hest.h:16
#define HEST_GHES_DESC_TYPE
Definition: hest.h:9
struct ghes_record ghes_record_t
#define NOTIFY_TYPE_SCI
Definition: hest.h:17
#define GHEST_ERROR_STATUS_BLOCK_LENGTH
Definition: hest.h:11
#define GHES_MAX_RAW_DATA_LENGTH
Definition: hest.h:10
struct acpi_hest_hen acpi_hest_hen_t
#define ALIGN
Definition: asm.h:22
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
struct global_nvs * gnvs
uint64_t u64
Definition: stdint.h:54
uint32_t u32
Definition: stdint.h:51
unsigned long uintptr_t
Definition: stdint.h:21
u16 type
Definition: hest.h:21
u16 source_id
Definition: hest.h:22
u32 prealloc_erecords
Definition: hest.h:26
u8 enabled
Definition: hest.h:25
u16 related_src_id
Definition: hest.h:23
u32 max_section_per_record
Definition: hest.h:27
u8 length
Definition: acpi.h:898
acpi_header_t header
Definition: acpi.h:877
u32 error_source_count
Definition: acpi.h:878
Definition: acpi.h:82
acpi_ghes_esd_t esd
Definition: hest.h:31
acpi_hest_hen_t notify
Definition: hest.h:34
u32 max_raw_data_length
Definition: hest.h:32
u32 err_sts_blk_len
Definition: hest.h:35
acpi_addr64_t sts_addr
Definition: hest.h:33
Definition: nvs.h:14
u64 hest_log_addr
Definition: nvs.h:29