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 <cpu/x86/mtrr.h>
6 #include <cpu/x86/smm.h>
7 #include <soc/iosf.h>
8 
10 {
11  return (iosf_bunit_read(BUNIT_SMRRL) << 20);
12 }
13 
14 static size_t smm_region_size(void)
15 {
16  return CONFIG_SMM_TSEG_SIZE;
17 }
18 
19 void *cbmem_top_chipset(void)
20 {
21  return (void *) smm_region_start();
22 }
23 
24 void smm_region(uintptr_t *start, size_t *size)
25 {
26  *start = (iosf_bunit_read(BUNIT_SMRRL) & 0xFFFF) << 20;
27  *size = smm_region_size();
28 }
29 
31 {
32  uintptr_t top_of_ram;
33 
34  /* Cache at least 8 MiB below the top of ram, and at most 8 MiB
35  * above top of the ram. This satisfies MTRR alignment requirement
36  * with different TSEG size configurations.
37  */
38  top_of_ram = ALIGN_DOWN((uintptr_t)cbmem_top(), 8*MiB);
39  postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 16*MiB,
41 }
void postcar_frame_add_mtrr(struct postcar_frame *pcf, uintptr_t addr, size_t size, int type)
#define BUNIT_SMRRL
Definition: iosf.h:190
uint32_t iosf_bunit_read(int reg)
Definition: iosf.c:39
#define ALIGN_DOWN(x, a)
Definition: helpers.h:18
#define MiB
Definition: helpers.h:76
void * cbmem_top(void)
Definition: imd_cbmem.c:18
void * cbmem_top_chipset(void)
Definition: memmap.c:44
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
static uintptr_t smm_region_start(void)
Definition: memmap.c:9
static size_t smm_region_size(void)
Definition: memmap.c:14
unsigned long uintptr_t
Definition: stdint.h:21
#define MTRR_TYPE_WRBACK
Definition: mtrr.h:14