Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13331
-gerrit
commit 46deaabbcf03756783f8b444e67792172b9e7e1a
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Fri Oct 30 18:05:57 2015 -0700
drivers/intel/fsp2.0: Add semantic patch for FspUpdVpd.h header
Previous FSP implementations in coreboot have included FspUpdVpd.h
directly, along with with efi headers. Instead of taking that
approach in FSP 2.0, we provide a semantic patch that, with minimal
modifications, makes FspUpdVpd.h easier to include in coreboot, and
eliminates reliance on external headers and definitions.
Change-Id: I0c2a6f7baf6fb50ae22b64e08e653cfe1aefdaf9
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
.../intel/fsp2_0/header_util/fspupdvpd.spatch | 147 +++++++++++++++++++++
.../intel/fsp2_0/header_util/fspupdvpd_sanitize.sh | 22 +++
2 files changed, 169 insertions(+)
diff --git a/src/drivers/intel/fsp2_0/header_util/fspupdvpd.spatch b/src/drivers/intel/fsp2_0/header_util/fspupdvpd.spatch
new file mode 100644
index 0000000..8f41836
--- /dev/null
+++ b/src/drivers/intel/fsp2_0/header_util/fspupdvpd.spatch
@@ -0,0 +1,147 @@
+/*
+ * Semantic patch for fspupdvpd_sanitize.sh. Please call the script directly.
+ *
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+@ kill_pragma_pack @
+@@
+- #pragma pack(...)
+
+/*
+ * Convert named typedef'd structs
+ */
+@ named_struct @
+identifier i;
+type t;
+@@
+typedef struct i { ... } t;
+
+/* Make typename usable as identifier */
+@ script:python named_struct_type @
+t << named_struct.t;
+i;
+@@
+coccinelle.i = t.rstrip('_t')
+
+
+@ convert_named_struct_decls @
+type named_struct.t;
+identifier named_struct_type.i;
+identifier g;
+@@
+- typedef struct g {
++ struct i {
+...
+}
+- t
+;
+
+/* Replace type with struct */
+@ named_typedef_to_struct @
+type named_struct.t;
+identifier named_struct_type.i;
+@@
+- t
++ struct i
+
+
+/*
+ * Convert unnamed typedef'd structs
+ */
+@ unnamed_struct @
+type t;
+@@
+typedef struct { ... } t;
+
+/* Make typename usable as identifier */
+@ script:python unnamed_struct_type @
+t << unnamed_struct.t;
+i;
+@@
+coccinelle.i = t.rstrip('_t')
+
+@ convert_unnamed_struct_decls @
+type unnamed_struct.t;
+identifier unnamed_struct_type.i;
+@@
+-typedef struct {
++struct i {
+ ...
+}
+- t
+;
+
+/* Replace type with struct */
+@ unnamed_typedef_to_struct @
+type unnamed_struct.t;
+identifier unnamed_struct_type.i;
+@@
+-t
++struct i
+
+/*
+ * Pack _ALL_ structs
+ */
+@ pack_structs @
+identifier s;
+@@
+
+struct s {
+...
+}
++ __attribute__((packed))
+;
+
+/*
+ * BIGINT to stdint
+ */
+@ uint8_t @
+typedef UINT8;
+typedef uint8_t;
+@@
+- UINT8
++ uint8_t
+
+@ uint16_t @
+typedef UINT16;
+typedef uint16_t;
+@@
+- UINT16
++ uint16_t
+
+@ uint32_t @
+typedef UINT32;
+typedef uint32_t;
+@@
+- UINT32
++ uint32_t
+
+@ uint64_t @
+typedef UINT64;
+typedef uint64_t;
+@@
+- UINT64
++ uint64_t
+
+@ bool @
+typedef BOOLEAN;
+typedef bool;
+@@
+- BOOLEAN
++ bool
+
+@ wchar_t @
+typedef CHAR16;
+typedef wchar_t;
+@@
+- CHAR16
++ wchar_t
diff --git a/src/drivers/intel/fsp2_0/header_util/fspupdvpd_sanitize.sh b/src/drivers/intel/fsp2_0/header_util/fspupdvpd_sanitize.sh
new file mode 100644
index 0000000..7c3195e
--- /dev/null
+++ b/src/drivers/intel/fsp2_0/header_util/fspupdvpd_sanitize.sh
@@ -0,0 +1,22 @@
+#
+# Convert the FspUpdVpd.h header file into a format usable by coreboot
+# Usage:
+# fspupdvpd_sanitize.sh <path/to/FspUpdVpd.h>
+#
+# This file is part of the coreboot project.
+#
+# Copyright (C) 2015 Intel Corp.
+# (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+HOME=$(dirname "${BASH_SOURCE[0]}")
+DEST=$HOME
+
+SPATCH=spatch
+
+$SPATCH -sp_file $HOME/fspupdvpd.spatch \
+ -in_place $1
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13326
-gerrit
commit 042c0da31046ca3acc287567d53b382e125b9952
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Wed Oct 28 12:28:41 2015 -0700
soc/apollolake: Only allow mmaped accesses to IFD BIOS region
Only the BIOS region is memory-mapped by the hardware. Anything below
that is invisible via MMIO. Also, the 256 KiB right below 4G are being
decoded by readonly SRAM. Fail accesses to those regions, rather than
returning false data.
Change-Id: I34779109ffce50a1c5a4842d7bf75870b8b4dff8
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 2 +-
src/soc/intel/apollolake/mmap_boot.c | 32 ++++++++++++++++++++------------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index 4a4efa4..317a439 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -78,7 +78,7 @@ config IFD_BIOS_START
The starting address of flash region 1 (BIOS), as declared in the
firmware descriptor. This can be obtained via 'ifdtool -d'.
-config IFD_BIOS_SIZE
+config IFD_BIOS_END
hex
default ROM_SIZE
help
diff --git a/src/soc/intel/apollolake/mmap_boot.c b/src/soc/intel/apollolake/mmap_boot.c
index 7e9080b..60f7c1a 100644
--- a/src/soc/intel/apollolake/mmap_boot.c
+++ b/src/soc/intel/apollolake/mmap_boot.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2015 Intel Corp.
* (Written by Andrey Petrov <andrey.petrov(a)intel.com> for Intel Corp.)
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -11,31 +12,38 @@
*/
#include <boot_device.h>
-#include <console/console.h>
#include <cbfs.h>
-#include <endian.h>
-#include <stdlib.h>
#include <commonlib/region.h>
+#include <console/console.h>
#include <fmap.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* The 256 KiB right below 4G are decoded by readonly SRAM, not boot media */
+#define IFD_BIOS_MAX_MAPPED (CONFIG_IFD_BIOS_END - 256 * KiB)
+#define IFD_MAPPED_SIZE (IFD_BIOS_MAX_MAPPED - CONFIG_IFD_BIOS_START)
+#define IFD_BIOS_SIZE (CONFIG_IFD_BIOS_END - CONFIG_IFD_BIOS_START)
/*
* If Apollo Lake is configured to boot from SPI flash "BIOS" region
* (as defined in descriptor) is mapped below 4GiB. Form a pointer for
* the base.
*/
-#define ROM_BASE ((void *)(uintptr_t)(0x100000000ULL - CONFIG_IFD_BIOS_SIZE))
+#define VIRTUAL_ROM_BASE ((uintptr_t)(0x100000000ULL - IFD_BIOS_SIZE))
-static const struct mem_region_device boot_dev = {
- .base = (void *) ROM_BASE,
- /* typically not whole flash is memory mapped */
- .rdev = REGION_DEV_INIT(&mem_rdev_ops, CONFIG_IFD_BIOS_START,
- CONFIG_IFD_BIOS_SIZE)
-};
+static const struct mem_region_device shadow_dev = MEM_REGION_DEV_INIT(
+ VIRTUAL_ROM_BASE, IFD_BIOS_MAX_MAPPED
+);
+
+static const struct xlate_region_device real_dev = XLATE_REGION_INIT(
+ &shadow_dev.rdev, CONFIG_IFD_BIOS_START,
+ IFD_MAPPED_SIZE, CONFIG_ROM_SIZE
+);
const struct region_device *boot_device_ro(void)
{
- return &boot_dev.rdev;
-}
+ return &real_dev.rdev;
+};
static int iafw_boot_region_properties(struct cbfs_props *props)
{
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13327
-gerrit
commit 966ab9dac9ec343086963d215d7716140bd1e0c4
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Wed Oct 28 12:38:48 2015 -0700
intel/apollolake_rvp: Update name of IFD_BIOS_START variable
It was recently changed in soc/intel/apollolake.
Change-Id: I5cd41154bf85700752977e37cc1824ec2651e5bb
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/mainboard/intel/apollolake_rvp/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mainboard/intel/apollolake_rvp/Kconfig b/src/mainboard/intel/apollolake_rvp/Kconfig
index 492ccdc..5e6c4f0 100755
--- a/src/mainboard/intel/apollolake_rvp/Kconfig
+++ b/src/mainboard/intel/apollolake_rvp/Kconfig
@@ -17,7 +17,7 @@ config MAINBOARD_VENDOR
string
default "Intel"
-config IFD_BIOS_SIZE
+config IFD_BIOS_END
hex
default 0x700000
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13324
-gerrit
commit 479226c17026fb79893da9fc42040152e6dfc883
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Mon Oct 26 18:10:04 2015 -0700
soc/apollolake: Add BAR setup and enables essential for raminit
Change-Id: I884e677e607a14e9e88877a8e94e8518d473cf83
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/bootblock/bootblock_car.c | 7 ++--
src/soc/intel/apollolake/include/soc/iomap.h | 26 +++++++++++++++
src/soc/intel/apollolake/romstage/romstage.c | 37 ++++++++++++++++++++++
3 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/src/soc/intel/apollolake/bootblock/bootblock_car.c b/src/soc/intel/apollolake/bootblock/bootblock_car.c
index 7dd359b..8d317a1 100644
--- a/src/soc/intel/apollolake/bootblock/bootblock_car.c
+++ b/src/soc/intel/apollolake/bootblock/bootblock_car.c
@@ -16,6 +16,7 @@
#include <device/pci.h>
#include <soc/bootblock.h>
#include <soc/cpu.h>
+#include <soc/iomap.h>
#include <soc/uart.h>
static void disable_watchdog(void)
@@ -24,14 +25,14 @@ static void disable_watchdog(void)
device_t dev = PCI_DEV(0, 0xd, 1);
/* Open up an IO window */
- pci_write_config16(dev, PCI_BASE_ADDRESS_4, 0x400);
+ pci_write_config16(dev, PCI_BASE_ADDRESS_4, ACPI_PMIO_BASE);
pci_write_config32(dev, PCI_COMMAND,
PCI_COMMAND_MASTER | PCI_COMMAND_IO);
/* We don't have documentation for this bit, but it prevents reboots */
- reg = inl(0x400 + 0x68);
+ reg = inl(ACPI_PMIO_BASE + 0x68);
reg |= 1 << 11;
- outl(reg, 0x400 + 0x68);
+ outl(reg, ACPI_PMIO_BASE + 0x68);
}
static void call_romstage(void *entry)
diff --git a/src/soc/intel/apollolake/include/soc/iomap.h b/src/soc/intel/apollolake/include/soc/iomap.h
new file mode 100644
index 0000000..09ae67d
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/iomap.h
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Andrey Petrov <andrey.petrov(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _SOC_APOLLOLAKE_IOMAP_H_
+#define _SOC_APOLLOLAKE_IOMAP_H_
+
+#define P2SB_BAR 0xd0000000
+#define MCH_BASE_ADDR 0xfed10000
+
+#define ACPI_PMIO_BASE 0x400
+#define R_ACPI_PM1_TMR 0x8
+
+/* Accesses to these BARs are hardcoded in FSP */
+#define PMC_BAR0 0xfe042000
+#define PMC_BAR1 0xfe044000
+
+#endif /* _SOC_APOLLOLAKE_IOMAP_H_ */
diff --git a/src/soc/intel/apollolake/romstage/romstage.c b/src/soc/intel/apollolake/romstage/romstage.c
index f76476b..1bf94f4 100644
--- a/src/soc/intel/apollolake/romstage/romstage.c
+++ b/src/soc/intel/apollolake/romstage/romstage.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2015 Intel Corp.
* (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ * (Written by Andrey Petrov <andrey.petrov(a)intel.com> for Intel Corp.)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -10,10 +11,44 @@
* (at your option) any later version.
*/
+#include <arch/io.h>
#include <console/console.h>
+#include <cpu/x86/msr.h>
+#include <device/pci_def.h>
+#include <soc/iomap.h>
#include <soc/romstage.h>
#include <soc/uart.h>
+/*
+ * Enables several BARs and devices which are needed for memory init
+ * - MCH_BASE_ADDR is needed in order to talk to the memory controller
+ * - PMC_BAR0 and PMC_BAR1 are used by FSP (with the base address hardcoded)
+ * Once raminit is done, we can safely let the allocator re-assign them
+ * - HPET is enabled because FSP wants to store a pointer to global data in the
+ * HPET comparator register
+ */
+static void soc_early_romstage_init(void)
+{
+ device_t pmc = PCI_DEV(0, 13, 1);
+
+ /* Set MCH base address */
+ pci_write_config32(PCI_DEV(0, 0, 0), 0x48, MCH_BASE_ADDR);
+
+ /* Set PMC base address */
+ pci_write_config32(pmc, PCI_BASE_ADDRESS_0, PMC_BAR0);
+ pci_write_config32(pmc, PCI_BASE_ADDRESS_1, 0); /* 64-bit BAR */
+ pci_write_config32(pmc, PCI_BASE_ADDRESS_2, PMC_BAR1);
+ pci_write_config32(pmc, PCI_BASE_ADDRESS_3, 0); /* 64-bit BAR */
+
+ /* PMIO BAR4 was already set in bootblock, hence the COMMAND_IO below */
+ pci_write_config32(pmc, PCI_COMMAND,
+ PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
+ PCI_COMMAND_MASTER);
+
+ /* Enable decoding for HPET */
+ pci_write_config32(PCI_DEV(0, 13, 0), 0x60, 1<<7);
+}
+
asmlinkage void romstage_entry(void)
{
/* Be careful. Bootblock might already have initialized the console */
@@ -24,6 +59,8 @@ asmlinkage void romstage_entry(void)
printk(BIOS_DEBUG, "Starting romstage...\n");
+ soc_early_romstage_init();
+
/* This function must not return */
while(1)
;