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
/* Use simple device model for this file even in ramstage */
4
#define __SIMPLE_DEVICE__
5
6
#include <
arch/romstage.h
>
7
#include <
cbmem.h
>
8
#include <
cpu/x86/smm.h
>
9
#include <
device/pci.h
>
10
#include <
device/pci_ops.h
>
11
#include <soc/pci_devs.h>
12
#include <soc/systemagent.h>
13
#include <
stdint.h
>
14
15
static
uintptr_t
dpr_region_start
(
void
)
16
{
17
/*
18
* Base of DPR is top of usable DRAM below 4GiB. The register has
19
* 1 MiB alignment and reports the TOP of the range, the base
20
* must be calculated from the size in MiB in bits 11:4.
21
*/
22
uintptr_t
dpr =
pci_read_config32
(
HOST_BRIDGE
,
DPR
);
23
uintptr_t
tom =
ALIGN_DOWN
(dpr, 1 *
MiB
);
24
25
/* Subtract DMA Protected Range size if enabled */
26
if
(dpr &
DPR_EPM
)
27
tom -= (dpr &
DPR_SIZE_MASK
) << 16;
28
29
return
tom;
30
}
31
32
void
*
cbmem_top_chipset
(
void
)
33
{
34
return
(
void
*)
dpr_region_start
();
35
}
36
37
void
smm_region
(
uintptr_t
*start,
size_t
*size)
38
{
39
uintptr_t
tseg =
pci_read_config32
(
HOST_BRIDGE
,
TSEG
);
40
uintptr_t
bgsm =
pci_read_config32
(
HOST_BRIDGE
,
BGSM
);
41
42
tseg =
ALIGN_DOWN
(tseg, 1 *
MiB
);
43
bgsm =
ALIGN_DOWN
(bgsm, 1 *
MiB
);
44
*start = tseg;
45
*size = bgsm - tseg;
46
}
47
48
void
fill_postcar_frame
(
struct
postcar_frame
*pcf)
49
{
50
uintptr_t
top_of_ram;
51
52
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
53
* above top of the ram. This satisfies MTRR alignment requirement
54
* with different TSEG size configurations.
55
*/
56
top_of_ram =
ALIGN_DOWN
((
uintptr_t
)
cbmem_top
(), 8*
MiB
);
57
postcar_frame_add_mtrr
(pcf, top_of_ram - 8*
MiB
, 16*
MiB
,
58
MTRR_TYPE_WRBACK
);
59
}
romstage.h
postcar_frame_add_mtrr
void postcar_frame_add_mtrr(struct postcar_frame *pcf, uintptr_t addr, size_t size, int type)
Definition:
postcar_loader.c:71
ALIGN_DOWN
#define ALIGN_DOWN(x, a)
Definition:
helpers.h:18
MiB
#define MiB
Definition:
helpers.h:76
cbmem.h
cbmem_top
void * cbmem_top(void)
Definition:
imd_cbmem.c:18
DPR_SIZE_MASK
#define DPR_SIZE_MASK
Definition:
host_bridge.h:30
TSEG
#define TSEG
Definition:
host_bridge.h:60
DPR_EPM
#define DPR_EPM
Definition:
host_bridge.h:28
DPR
#define DPR
Definition:
host_bridge.h:27
BGSM
#define BGSM
Definition:
host_bridge.h:59
smm.h
pci_ops.h
pci_read_config32
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition:
pci_ops.h:58
cbmem_top_chipset
void * cbmem_top_chipset(void)
Definition:
memmap.c:44
fill_postcar_frame
void fill_postcar_frame(struct postcar_frame *pcf)
Definition:
memmap.c:63
smm_region
void smm_region(uintptr_t *start, size_t *size)
Definition:
memmap.c:50
pci.h
dpr_region_start
static uintptr_t dpr_region_start(void)
Definition:
memmap.c:15
HOST_BRIDGE
@ HOST_BRIDGE
Definition:
reg_access.h:23
stdint.h
uintptr_t
unsigned long uintptr_t
Definition:
stdint.h:21
postcar_frame
Definition:
romstage.h:18
MTRR_TYPE_WRBACK
#define MTRR_TYPE_WRBACK
Definition:
mtrr.h:14
src
soc
intel
broadwell
memmap.c
Generated by
1.9.1