| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
uintptr_t dpr = pci_read_config32(HOST_BRIDGE, DPR); |
| 23 |
uintptr_t tom = ALIGN_DOWN(dpr, 1 * MiB); |
| 24 |
|
| 25 |
|
| 26 |
if (dpr & DPR_EPM) |
| 27 |
tom -= (dpr & DPR_SIZE_MASK) << 16; |
| 28 |
|
| 29 |
return tom; |
| 30 |
} |
| 31 |
|
| 32 |
uintptr_t cbmem_top_chipset(void) |
| 33 |
{ |
| 34 |
return 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 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
const uintptr_t top_of_ram = ALIGN_DOWN(cbmem_top(), 8 * MiB); |
| 55 |
postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 16*MiB, |
| 56 |
MTRR_TYPE_WRBACK); |
| 57 |
} |