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/13485
-gerrit
commit c21bd6a6dbc79d9c6983f494345259686a26941d
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Tue Jan 26 18:22:43 2016 -0800
arch/x86: Implement minimal bootblock for C_ENVIRONMENT_BOTOBLOCK
Some newer x86 systems can boot from non-memory-mapped boot media
(e.g. EMMC). The bootblock may be backed by small amounts of SRAM, or
other memory, similar to how most ARM chipsets work. In such cases, we
may not have enough code space for romstage very early on. This means
that CAR setup and early boot media (e.g. SPI, EMMC) drivers need to
be implemented within the limited amount memory of storage available.
Since the reset vector has to be contained in this early code memory,
the bootblock is the best place to implement loading of other stages.
Implement a bootblock which does the minimal initialization, up to,
and including switch to protected mode. This then transfers control
to platform-specific code. No stack is needed, and control is
transferred via a "jmp" such that no stack operations are involved.
Change-Id: I009b42b9a707cf11a74493bd4d8c189dc09b8ace
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
src/arch/x86/Makefile.inc | 1 +
src/arch/x86/bootblock_crt0.S | 55 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index bc64815..821e7ee 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -112,6 +112,7 @@ $(obj)/arch/x86/id.bootblock.o: $(obj)/build.h
ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y)
+bootblock-y += bootblock_crt0.S
bootblock-y += memlayout.ld
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
diff --git a/src/arch/x86/bootblock_crt0.S b/src/arch/x86/bootblock_crt0.S
new file mode 100644
index 0000000..926cda0
--- /dev/null
+++ b/src/arch/x86/bootblock_crt0.S
@@ -0,0 +1,55 @@
+/*
+ * This is the modern bootblock. It is used by platforms which select
+ * C_ENVIRONMENT_BOOTBLOCK, and it prepares the system for C environment runtime
+ * setup. The actual setup is done by hardware-specific code.
+ *
+ * It provides a bootflow similar to other architectures, and thus is considered
+ * to be the modern approach.
+ *
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
+ *
+ * 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.
+ */
+
+#define CR0_MP (1 << 1)
+#define CR0_EM (1 << 2)
+
+#define CR4_OSFXSR (1 << 9)
+#define CR4_OSXMMEXCPT (1 << 10)
+
+/*
+ * Include the old code for reset vector and protected mode entry. That code has
+ * withstood the test of time.
+ */
+#include <arch/x86/prologue.inc>
+#include <cpu/x86/16bit/entry16.inc>
+#include <cpu/x86/16bit/reset16.inc>
+#include <cpu/x86/32bit/entry32.inc>
+
+
+bootblock_protected_mode_entry:
+ /* Save BIST result */
+ movd %eax, %mm0
+ /* Save an early timestamp */
+ rdtsc
+ movd %eax, %mm1
+ movd %edx, %mm2
+
+#if !IS_ENABLED(CONFIG_SSE)
+enable_sse:
+ mov %cr0, %eax
+ and $~CR0_EM, %ax /* Clear coprocessor emulation CR0.EM */
+ or $CR0_MP, %ax /* Set coprocessor monitoring CR0.MP */
+ mov %eax, %cr0
+ mov %cr4, %eax
+ or $(CR4_OSFXSR | CR4_OSXMMEXCPT), %ax
+ mov %eax, %cr4
+#endif /* IS_ENABLED(CONFIG_SSE) */
+
+ /* We're done. Now it's up to platform-specific code */
+ jmp bootblock_pre_c_entry
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/13302
-gerrit
commit f0f02db99cef3cfd782125629a772e2ecd7586a7
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Wed Oct 7 11:06:14 2015 -0700
cpu/x86/tsc: Compile delay_tsc.c for the bootblock as well
This is needed in a follow-on patch to enable udelay() handling on
apollolake, which is a dependency for the console code.
Change-Id: I7da6a060a91b83f3b32c5c5d269c102ce7ae3b8a
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/cpu/x86/tsc/Makefile.inc | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/cpu/x86/tsc/Makefile.inc b/src/cpu/x86/tsc/Makefile.inc
index bbebda9..7e2eab2 100644
--- a/src/cpu/x86/tsc/Makefile.inc
+++ b/src/cpu/x86/tsc/Makefile.inc
@@ -1,3 +1,4 @@
+bootblock-$(CONFIG_UDELAY_TSC) += delay_tsc.c
ramstage-$(CONFIG_UDELAY_TSC) += delay_tsc.c
romstage-$(CONFIG_TSC_CONSTANT_RATE) += delay_tsc.c
verstage-$(CONFIG_TSC_CONSTANT_RATE) += delay_tsc.c
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/13303
-gerrit
commit 05d53f82521dff182d1e17270ab5a596bd6f3425
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 6 16:31:34 2015 -0700
soc/apollolake: Add tsc_freq_mhz() functionality for udelay()
Change-Id: I2f1147cefe2438992bff45fc0a1e91064217915d
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 1 +
src/soc/intel/apollolake/Makefile.inc | 5 +++++
src/soc/intel/apollolake/include/soc/cpu.h | 20 ++++++++++++++++++++
src/soc/intel/apollolake/tsc_freq.c | 21 +++++++++++++++++++++
4 files changed, 47 insertions(+)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index f7ae68e..825a40f 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -32,6 +32,7 @@ config CPU_SPECIFIC_OPTIONS
select RELOCATABLE_RAMSTAGE # Build fails if this is not selected
select SOC_INTEL_COMMON
select UDELAY_TSC
+ select TSC_CONSTANT_RATE
config MMCONF_BASE_ADDRESS
hex "PCI MMIO Base Address"
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index cc3e013..d7d7ebc 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -8,9 +8,14 @@ subdirs-y += ../../../cpu/x86/smm
subdirs-y += ../../../cpu/x86/tsc
bootblock-y += bootblock/bootblock_car.c
+bootblock-y += tsc_freq.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
+romstage-y += tsc_freq.c
+
+ramstage-y += tsc_freq.c
+
romstage-y += placeholders.c
smm-y += placeholders.c
ramstage-y += placeholders.c
diff --git a/src/soc/intel/apollolake/include/soc/cpu.h b/src/soc/intel/apollolake/include/soc/cpu.h
new file mode 100644
index 0000000..d0d6afd
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/cpu.h
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+#ifndef _SOC_APOLLOLAKE_CPU_H_
+#define _SOC_APOLLOLAKE_CPU_H_
+
+#define MSR_PLATFORM_INFO 0xce
+
+#define BASE_CLOCK_MHZ 100
+
+#endif /* _SOC_APOLLOLAKE_CPU_H_ */
diff --git a/src/soc/intel/apollolake/tsc_freq.c b/src/soc/intel/apollolake/tsc_freq.c
new file mode 100644
index 0000000..2e90ef2
--- /dev/null
+++ b/src/soc/intel/apollolake/tsc_freq.c
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+#include <cpu/x86/msr.h>
+#include <cpu/x86/tsc.h>
+#include <soc/cpu.h>
+
+unsigned long tsc_freq_mhz(void)
+{
+ msr_t msr = rdmsr(MSR_PLATFORM_INFO);
+ return (BASE_CLOCK_MHZ * ((msr.lo >> 8) & 0xff));
+}
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/13299
-gerrit
commit f5123a94cef39b1c3e6fde387ab71e79eeaa7724
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 6 14:41:20 2015 -0700
arch/x86/Makefile.inc: Re-enable -Wa,--divide assembler flag
In the follow-on patches, we use constant division to calculate the
number of elements in an assembly structure. Since the size of one
element is not a power of two for all structures, we can't bit shift.
This allows us to do the computation at assembly time rather than
runtime.
Change-Id: Ic5693f39dee8daf759bfc16c79ac3c7ddb4de465
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/arch/x86/Makefile.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 821e7ee..616bc5c 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -84,7 +84,7 @@ define early_x86_stage
$(1)-y += memlayout.ld
# The '.' include path is needed for the generated assembly.inc file.
-$(1)-S-ccopts += -I.
+$(1)-S-ccopts += -I. -Wa,--divide
$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
@printf " LINK $$(subst $$(obj)/,,$$(@))\n"
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/13304
-gerrit
commit 9f507da022122dd2ee9597fcd8e46e4d74c898ec
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Oct 5 13:45:22 2015 -0700
soc/apollolake: Add minimal accessors for sideband bus (IOSF)
Some configuration registers for the UART are placed behind the
sideband bus.
Change-Id: I84a620dbd0cf4b8f3fec119836d1c8f75c7f200a
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/include/soc/iosf.h | 30 +++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/soc/intel/apollolake/include/soc/iosf.h b/src/soc/intel/apollolake/include/soc/iosf.h
new file mode 100644
index 0000000..c9f578c
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/iosf.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef _SOC_APOLLOLAKE_IOSF_H_
+#define _SOC_APOLLOLAKE_IOSF_H_
+
+#include <arch/io.h>
+
+inline static void iosf_write(uint8_t port, uint16_t reg, uint32_t val)
+{
+ uintptr_t base = CONFIG_IOSF_BASE_ADDRESS | (port << 16) | (reg & ~3);
+ write32((void *)base, val);
+}
+
+inline static uint32_t iosf_read(uint8_t port, uint16_t reg)
+{
+ uintptr_t base = CONFIG_IOSF_BASE_ADDRESS | (port << 16) | (reg & ~3);
+ return read32((void *)base);
+}
+
+#endif /* _SOC_APOLLOLAKE_IOSF_H_ */
the following patch was just integrated into master:
commit 43f16f8dd82e79d15a7bd067e45b0356cd5b3dd6
Author: Martin Roth <martinroth(a)google.com>
Date: Mon Jan 25 15:02:32 2016 -0700
src/: give scripts a .sh extension for easy identification
Just rename the two scripts that are in the src/ tree to give them
a .sh extension. Since we generally expect files in the src directory
to be source files, this allows to identify these as scripts easily.
Change-Id: I0ab20a083880370164488d37a752ba2d5a192fdc
Signed-off-by: Martin Roth <martinroth(a)google.com>
Reviewed-on: https://review.coreboot.org/13432
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
See https://review.coreboot.org/13432 for details.
-gerrit