coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_init.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/mmio.h>
4 #include <device/pci_ops.h>
5 #include <device/pci_def.h>
6 #include <soc/iomap.h>
7 #include <soc/pci_devs.h>
8 #include <soc/romstage.h>
9 #include <soc/systemagent.h>
10 
11 static void broadwell_setup_bars(void)
12 {
13  /* Set up all hardcoded northbridge BARs */
14  pci_write_config32(HOST_BRIDGE, MCHBAR, CONFIG_FIXED_MCHBAR_MMIO_BASE | 1);
15  pci_write_config32(HOST_BRIDGE, DMIBAR, CONFIG_FIXED_DMIBAR_MMIO_BASE | 1);
16  pci_write_config32(HOST_BRIDGE, EPBAR, CONFIG_FIXED_EPBAR_MMIO_BASE | 1);
17 
20 
21  /* Set C0000-FFFFF to access RAM on both reads and writes */
29 }
30 
32 {
33  const bool vtd_capable =
35 
37 
38  /* Device enable: IGD and Mini-HD */
40 
41  if (vtd_capable) {
42  /* setup BARs: zeroize top 32 bits; set enable bit */
47 
48  /* set PRSCAPDIS, lock GFXVTBAR policy cfg registers */
49  u32 reg32;
50  reg32 = read32((void *)(GFXVT_BASE_ADDRESS + ARCHDIS));
52  reg32 | DMAR_LCKDN | PRSCAPDIS);
53  /* lock VTVC0BAR policy cfg registers */
54  reg32 = read32((void *)(VTVC0_BASE_ADDRESS + ARCHDIS));
56  reg32 | DMAR_LCKDN);
57  }
58 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static uint32_t read32(const void *addr)
Definition: mmio.h:22
static __always_inline void mchbar_write32(const uintptr_t offset, const uint32_t value)
Definition: fixed_bars.h:36
#define PAM0
Definition: host_bridge.h:38
#define PAM6
Definition: host_bridge.h:44
#define PAM5
Definition: host_bridge.h:43
#define DEVEN_D0EN
Definition: host_bridge.h:24
#define DEVEN_D2EN
Definition: host_bridge.h:20
#define CAPID0_A
Definition: host_bridge.h:65
#define MCHBAR
Definition: host_bridge.h:7
#define PAM2
Definition: host_bridge.h:40
#define VTD_DISABLE
Definition: host_bridge.h:67
#define PAM1
Definition: host_bridge.h:39
#define DMIBAR
Definition: host_bridge.h:33
#define EPBAR
Definition: host_bridge.h:6
#define DEVEN
Definition: host_bridge.h:16
#define PAM3
Definition: host_bridge.h:41
#define DEVEN_D3EN
Definition: host_bridge.h:19
#define PAM4
Definition: host_bridge.h:42
#define EDRAMBAR
Definition: mchbar.h:19
#define VTVC0BAR
Definition: mchbar.h:20
#define GFXVTBAR
Definition: mchbar.h:18
#define GDXCBAR
Definition: mchbar.h:22
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
#define ARCHDIS
Definition: haswell.h:23
#define PRSCAPDIS
Definition: haswell.h:27
#define DMAR_LCKDN
Definition: haswell.h:24
#define GFXVT_BASE_ADDRESS
Definition: memmap.h:18
#define EDRAM_BASE_ADDRESS
Definition: memmap.h:12
#define VTVC0_BASE_ADDRESS
Definition: memmap.h:21
#define GDXC_BASE_ADDRESS
Definition: memmap.h:15
void systemagent_early_init(void)
Definition: early_init.c:151
static void broadwell_setup_bars(void)
Definition: early_init.c:11
@ HOST_BRIDGE
Definition: reg_access.h:23
uint32_t u32
Definition: stdint.h:51