coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
memmap.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/romstage.h>
4 #include <cbmem.h>
5 #include <console/console.h>
6 #include <cpu/x86/mtrr.h>
7 #include <cpu/x86/smm.h>
8 #include <intelblocks/fast_spi.h>
10 #include <arch/bert_storage.h>
11 #include <types.h>
12 
13 /*
14  * Expected Host Memory Map (we don't know 100% and not all regions are present on all SoCs):
15  *
16  * +---------------------------+ TOUUD
17  * | |
18  * +---------------------------+ TOM (if mem > 4GB)
19  * | CSME UMA (if mem > 4 GiB) |
20  * +---------------------------+ TOUUD
21  * | |
22  * +---------------------------+ 4GiB
23  * | PCI Address Space |
24  * +---------------------------+ TOM (if mem < 4GB)
25  * | CSME UMA (if mem < 4 GiB) |
26  * +---------------------------+ TOLUD (also maps into MC address space)
27  * | iGD / DSM |
28  * +---------------------------+ BDSM
29  * | GTT / GSM |
30  * +---------------------------+ TOLM
31  * | TSEG |
32  * +---------------------------+ TSEGMB
33  * | DMA Protected Region |
34  * +---------------------------+ DPR
35  * | PRM (C6DRAM/SGX) |
36  * +---------------------------+ PRMRR
37  * | Probeless Trace |
38  * +---------------------------+ ME Stolen
39  * | PTT |
40  * +---------------------------+ TOLUM / top_of_ram / cbmem_top
41  * | CBMEM Root |
42  * +---------------------------+
43  * | FSP Reserved Memory |
44  * +---------------------------+
45  * | various CBMEM entries |
46  * +---------------------------+ top_of_stack (8 byte aligned)
47  * | stack (CBMEM entry) |
48  * +---------------------------+ FSP TOLUM
49  * | |
50  * +---------------------------+ 0
51  */
52 
53 #define BERT_REGION_MAX_SIZE 0x10000
54 
55 void smm_region(uintptr_t *start, size_t *size)
56 {
57  *start = sa_get_tseg_base();
58  *size = sa_get_tseg_size();
59 }
60 
61 void bert_reserved_region(void **start, size_t *size)
62 {
64  *size = BERT_REGION_MAX_SIZE;
65 
66  printk(BIOS_DEBUG, "Reserving BERT start %lx, size %zx\n", (uintptr_t)*start, *size);
67 }
68 
70 {
71  /* FSP does not seem to bother w.r.t. alignment when asked to place cbmem_top() */
72  uintptr_t top_of_ram = ALIGN_UP((uintptr_t)cbmem_top(), 8 * MiB);
73 
74  /*
75  * We need to make sure ramstage will be run cached. At this
76  * point exact location of ramstage in cbmem is not known.
77  * Instruct postcar to cache 16 megs below cbmem top which is
78  * a safe bet to cover ramstage.
79  */
80  printk(BIOS_DEBUG, "top_of_ram = 0x%lx\n", top_of_ram);
81 
82  postcar_frame_add_mtrr(pcf, top_of_ram - 16 * MiB, 16 * MiB, MTRR_TYPE_WRBACK);
83 
84  /* Cache the TSEG region */
86 
87  /* Cache the extended BIOS region if it is supported */
89 }
void postcar_frame_add_mtrr(struct postcar_frame *pcf, uintptr_t addr, size_t size, int type)
void postcar_enable_tseg_cache(struct postcar_frame *pcf)
#define MiB
Definition: helpers.h:76
#define ALIGN_UP(x, a)
Definition: helpers.h:17
void * cbmem_top(void)
Definition: imd_cbmem.c:18
void * cbmem_add(u32 id, u64 size)
Definition: imd_cbmem.c:144
#define CBMEM_ID_ACPI_BERT
Definition: cbmem_id.h:7
uintptr_t sa_get_tseg_base(void)
size_t sa_get_tseg_size(void)
#define printk(level,...)
Definition: stdlib.h:16
void fast_spi_cache_ext_bios_postcar(struct postcar_frame *pcf)
Definition: fast_spi.c:280
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void fill_postcar_frame(struct postcar_frame *pcf)
Definition: memmap.c:63
void smm_region(uintptr_t *start, size_t *size)
Definition: memmap.c:50
void bert_reserved_region(void **start, size_t *size)
Definition: memmap.c:63
#define BERT_REGION_MAX_SIZE
Definition: memmap.c:53
unsigned long uintptr_t
Definition: stdint.h:21
#define MTRR_TYPE_WRBACK
Definition: mtrr.h:14