coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
systemagent.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <cpu/cpu.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci_ops.h>
7 #include <fsp/util.h>
9 #include <soc/iomap.h>
10 #include <soc/systemagent.h>
11 
12 /*
13  * SoC implementation
14  *
15  * Add all known fixed memory ranges for Host Controller/Memory
16  * controller.
17  */
18 void soc_add_fixed_mmio_resources(struct device *dev, int *index)
19 {
20  static const struct sa_mmio_descriptor soc_fixed_resources[] = {
21  { PCIEXBAR, CONFIG_ECAM_MMCONF_BASE_ADDRESS, CONFIG_ECAM_MMCONF_LENGTH,
22  "PCIEXBAR" },
23  { MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" },
24  };
25 
26  sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources,
27  ARRAY_SIZE(soc_fixed_resources));
28 
29  /* Add VTd resources if VTd is enabled. These resources were
30  set up by the FSP-S call. */
32  return;
33 
35  mmio_resource(dev, *index,
37  VTBAR_SIZE / KiB);
38  (*index)++;
39  }
41  mmio_resource(dev, *index,
43  VTBAR_SIZE / KiB);
44  (*index)++;
45  }
46 }
47 
49  uint64_t *prmrr_mask)
50 {
51  const void *hob;
52  size_t hob_size, prmrr_size;
53  uint64_t phys_address_mask;
54  const uint8_t prmrr_phys_base_guid[16] = {
55  0x38, 0x3a, 0x81, 0x9f, 0xb0, 0x6f, 0xa7, 0x4f,
56  0xaf, 0x79, 0x8a, 0x4e, 0x74, 0xdd, 0x48, 0x33
57  };
58  const uint8_t prmrr_size_guid[16] = {
59  0x44, 0xed, 0x0b, 0x99, 0x4e, 0x9b, 0x26, 0x42,
60  0xa5, 0x97, 0x28, 0x36, 0x76, 0x6b, 0x5c, 0x41
61  };
62 
63  hob = fsp_find_extension_hob_by_guid(prmrr_phys_base_guid,
64  &hob_size);
65  if (!hob) {
66  printk(BIOS_ERR, "Failed to locate PRMRR base hob\n");
67  return -1;
68  }
69  if (hob_size != sizeof(uint64_t)) {
70  printk(BIOS_ERR, "Incorrect PRMRR base hob size\n");
71  return -1;
72  }
73  *prmrr_base = *(uint64_t *) hob;
74 
75  hob = fsp_find_extension_hob_by_guid(prmrr_size_guid,
76  &hob_size);
77  if (!hob) {
78  printk(BIOS_ERR, "Failed to locate PRMRR size hob\n");
79  return -1;
80  }
81  if (hob_size != sizeof(uint64_t)) {
82  printk(BIOS_ERR, "Incorrect PRMRR base hob size\n");
83  return -1;
84  }
85  prmrr_size = *(uint64_t *) hob;
86  phys_address_mask = (1ULL << cpu_phys_address_size()) - 1;
87  *prmrr_mask = phys_address_mask & ~(uint64_t)(prmrr_size - 1);
88 
89  return 0;
90 }
91 
93 {
94  /* Max 4GiB per rank, 2 ranks per channel. Intel Document: 332092-002 */
95  return 8192;
96 }
#define VTBAR_ENABLED
Definition: systemagent.h:38
#define VTBAR_MASK
Definition: systemagent.h:39
void soc_add_fixed_mmio_resources(struct device *dev, int *index)
Definition: systemagent.c:25
uint32_t soc_systemagent_max_chan_capacity_mib(u8 capid0_a_ddrsz)
Definition: systemagent.c:96
#define DEFVTBAR
Definition: systemagent.h:18
#define VTBAR_SIZE
Definition: systemagent.h:22
int soc_get_uncore_prmmr_base_and_mask(uint64_t *prmrr_base, uint64_t *prmrr_mask)
Definition: systemagent.c:48
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define KiB
Definition: helpers.h:75
#define MCHBAR32(x)
Definition: systemagent.h:23
#define MCHBAR64(x)
Definition: systemagent.h:24
void sa_add_fixed_mmio_resources(struct device *dev, int *resource_cnt, const struct sa_mmio_descriptor *sa_fixed_resources, size_t count)
Definition: systemagent.c:87
#define printk(level,...)
Definition: stdlib.h:16
int cpu_phys_address_size(void)
Definition: cpu_common.c:46
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
#define CAPID0_A
Definition: host_bridge.h:65
#define MCHBAR
Definition: host_bridge.h:7
#define PCIEXBAR
Definition: host_bridge.h:32
#define VTD_DISABLE
Definition: host_bridge.h:67
#define GFXVTBAR
Definition: mchbar.h:18
#define mmio_resource(dev, idx, basek, sizek)
Definition: device.h:334
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
#define MCH_BASE_ADDRESS
Definition: iomap.h:82
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define MCH_BASE_SIZE
Definition: memmap.h:6
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:107
unsigned int index
Definition: systemagent.h:45