| 1 |
|
| 2 |
|
| 3 |
#include <arch/romstage.h> |
| 4 |
#include <cbmem.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/pci_ops.h> |
| 7 |
#include <device/pci_ids.h> |
| 8 |
#include <cpu/x86/smm.h> |
| 9 |
#include <soc/soc_util.h> |
| 10 |
#include <soc/pci_devs.h> |
| 11 |
#include <soc/util.h> |
| 12 |
#include <security/intel/txt/txt_platform.h> |
| 13 |
|
| 14 |
void smm_region(uintptr_t *start, size_t *size) |
| 15 |
{ |
| 16 |
uintptr_t tseg_base = pci_read_config32(VTD_DEV(0), VTD_TSEG_BASE_CSR); |
| 17 |
uintptr_t tseg_limit = pci_read_config32(VTD_DEV(0), VTD_TSEG_LIMIT_CSR); |
| 18 |
|
| 19 |
tseg_base = ALIGN_DOWN(tseg_base, 1 * MiB); |
| 20 |
tseg_limit = ALIGN_DOWN(tseg_limit, 1 * MiB); |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
tseg_limit += 1 * MiB; |
| 26 |
|
| 27 |
*start = tseg_base; |
| 28 |
*size = tseg_limit - tseg_base; |
| 29 |
} |
| 30 |
|
| 31 |
void fill_postcar_frame(struct postcar_frame *pcf) |
| 32 |
{ |
| 33 |
const uintptr_t top_of_ram = cbmem_top(); |
| 34 |
uintptr_t cbmem_base; |
| 35 |
size_t cbmem_size; |
| 36 |
|
| 37 |
|
| 38 |
if (cbmem_get_region((void **)&cbmem_base, &cbmem_size)) |
| 39 |
die("Could not find cbmem region"); |
| 40 |
printk(BIOS_DEBUG, "top_of_ram = 0x%lx\n", top_of_ram); |
| 41 |
printk(BIOS_DEBUG, "cbmem base_ptr: 0x%lx, size: 0x%zx\n", cbmem_base, cbmem_size); |
| 42 |
|
| 43 |
cbmem_base -= 4 * MiB; |
| 44 |
cbmem_base = ALIGN_DOWN(cbmem_base, 4 * MiB); |
| 45 |
|
| 46 |
|
| 47 |
cbmem_size = ALIGN_UP(top_of_ram - cbmem_base, 4 * MiB); |
| 48 |
|
| 49 |
postcar_frame_add_mtrr(pcf, cbmem_base, cbmem_size, MTRR_TYPE_WRBACK); |
| 50 |
|
| 51 |
if (CONFIG(TSEG_STAGE_CACHE)) |
| 52 |
postcar_enable_tseg_cache(pcf); |
| 53 |
} |
| 54 |
|
| 55 |
#if !defined(__SIMPLE_DEVICE__) |
| 56 |
union dpr_register txt_get_chipset_dpr(void) |
| 57 |
{ |
| 58 |
union dpr_register dpr; |
| 59 |
struct device *dev = VTD_DEV(0); |
| 60 |
|
| 61 |
dpr.raw = 0; |
| 62 |
|
| 63 |
if (!dev) { |
| 64 |
printk(BIOS_ERR, "BUS 0: Unable to find VTD PCI dev"); |
| 65 |
return dpr; |
| 66 |
} |
| 67 |
|
| 68 |
dpr.raw = pci_read_config32(dev, VTD_LTDPR); |
| 69 |
|
| 70 |
dev = NULL; |
| 71 |
|
| 72 |
while ((dev = dev_find_device(PCI_VID_INTEL, MMAP_VTD_STACK_CFG_REG_DEVID, dev))) { |
| 73 |
|
| 74 |
union dpr_register test_dpr = { .raw = pci_read_config32(dev, VTD_LTDPR) }; |
| 75 |
if (dpr.raw != test_dpr.raw) { |
| 76 |
printk(BIOS_ERR, "LTDPR not the same on all IIO's"); |
| 77 |
dpr.raw = 0; |
| 78 |
return dpr; |
| 79 |
} |
| 80 |
} |
| 81 |
return dpr; |
| 82 |
} |
| 83 |
#endif |