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 #define __SIMPLE_DEVICE__
4 
5 #include <arch/romstage.h>
6 #include <device/pci_ops.h>
7 #include <cbmem.h>
8 #include <cpu/x86/mtrr.h>
9 #include <cpu/x86/smm.h>
10 #include <types.h>
11 
12 #include "ironlake.h"
13 
15 {
16  /* Base of TSEG is top of usable DRAM */
17  return pci_read_config32(PCI_DEV(0, 0, 0), TSEG);
18 }
19 
20 static size_t northbridge_get_tseg_size(void)
21 {
22  return CONFIG_SMM_TSEG_SIZE;
23 }
24 
25 void *cbmem_top_chipset(void)
26 {
27  return (void *)northbridge_get_tseg_base();
28 }
29 
30 void smm_region(uintptr_t *start, size_t *size)
31 {
32  *start = northbridge_get_tseg_base();
33  *size = northbridge_get_tseg_size();
34 }
35 
37 {
38  uintptr_t top_of_ram;
39 
40  /* Cache at least 8 MiB below the top of ram, and at most 8 MiB
41  * above top of the ram. This satisfies MTRR alignment requirement
42  * with different TSEG size configurations.
43  */
44  top_of_ram = ALIGN_DOWN((uintptr_t)cbmem_top(), 8*MiB);
45  postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 8*MiB, MTRR_TYPE_WRBACK);
46  postcar_frame_add_mtrr(pcf, top_of_ram, 8*MiB, MTRR_TYPE_WRBACK);
47 }
void postcar_frame_add_mtrr(struct postcar_frame *pcf, uintptr_t addr, size_t size, int type)
#define ALIGN_DOWN(x, a)
Definition: helpers.h:18
#define MiB
Definition: helpers.h:76
void * cbmem_top(void)
Definition: imd_cbmem.c:18
#define TSEG
Definition: host_bridge.h:60
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
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 size_t northbridge_get_tseg_size(void)
Definition: memmap.c:20
static uintptr_t northbridge_get_tseg_base(void)
Definition: memmap.c:14
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
unsigned long uintptr_t
Definition: stdint.h:21
#define MTRR_TYPE_WRBACK
Definition: mtrr.h:14