Andrey Petrov (andrey.petrov(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13861
-gerrit
commit 96a49a435d77b30f55193f687fbbda262f9829f3
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Sun Feb 28 22:37:15 2016 -0800
arch/x86: Add common assembly code for stages that run in CAR
This adds a few assembly lines that are generic enough to be shared
between romstage and verstage that are ran in CAR. The GDT reload
is bypassed and the stack is reloaded with the CAR stack defined
in car.ld. The entry point for all those stages is car_stage_entry().
Change-Id: Ie7ef6a02f62627f29a109126d08c68176075bd67
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/arch/x86/assembly_entry.S | 38 +++++++++++++++++++++++++++++++++++++-
src/arch/x86/include/arch/cpu.h | 9 +++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/src/arch/x86/assembly_entry.S b/src/arch/x86/assembly_entry.S
index 01e91b0..e4d166c 100644
--- a/src/arch/x86/assembly_entry.S
+++ b/src/arch/x86/assembly_entry.S
@@ -1,7 +1,8 @@
/*
* This file is part of the coreboot project.
*
- * Copyright 2015 Google Inc.
+ * Copyright 2016 Google Inc.
+ * Copyright (C) 2016 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
@@ -13,6 +14,8 @@
* GNU General Public License for more details.
*/
+#if !IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK)
+
/* This file assembles the start of the romstage program by the order of the
* includes. Thus, it's extremely important that one pays very careful
* attention to the order of the includes. */
@@ -31,3 +34,36 @@
* cache-as-ram setup files would be here.
*/
#include <generated/assembly.inc>
+
+#else
+
+/*
+ * This path is for stages that post bootblock when employing
+ * CONFIG_C_ENVIRONMENT_BOOTBLOCK. There's no need to re-load the gdt, etc
+ * as all those settings are cached within the processor. In order to
+ * continue with C code execution one needs to set stack pointer and clear
+ * CAR_GLOBAL variables that are stage specific.
+ */
+.section ".text._start", "ax", @progbits
+.global _start
+_start:
+
+ /* reset stack pointer to CAR stack */
+ mov $_car_stack_end, %esp
+
+ /* clear CAR_GLOBAL area as it is not shared */
+ cld
+ xor %eax, %eax
+ movl $(_car_global_end), %ecx
+ movl $(_car_global_start), %edi
+ sub %edi, %ecx
+ rep stosl
+
+ jmp car_stage_entry
+
+/* This is here for linking purposes. */
+.weak car_stage_entry
+car_stage_entry:
+1:
+ jmp 1b
+#endif
diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h
index 408fa15..f50901f 100644
--- a/src/arch/x86/include/arch/cpu.h
+++ b/src/arch/x86/include/arch/cpu.h
@@ -239,4 +239,13 @@ static inline void get_fms(struct cpuinfo_x86 *c, uint32_t tfms)
#define asmlinkage __attribute__((regparm(0)))
#define alwaysinline inline __attribute__((always_inline))
+#ifndef __ROMCC__
+/*
+ * When using CONFIG_C_ENVIRONMENT_BOOTBLOCK the car_stage_entry()
+ * is the symbol jumped to for each stage after bootblock using
+ * cache-as-ram.
+ */
+void asmlinkage car_stage_entry(void);
+#endif
+
#endif /* ARCH_CPU_H */
Andrey Petrov (andrey.petrov(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13800
-gerrit
commit 30621ca63725f3fdb4cf754aacb0897c9187fd62
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Thu Feb 25 14:19:07 2016 -0800
drivers/intel/fsp2_0: Add Notify Phase API
This adds Notify Phase API. This is an important call that is used
to inform FSP runtimes of different stages of SoC initializations
by the coreboot.
Change-Id: Icec770d0c1c4d239adb2ef342bf6cc9c35666e4d
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
---
src/drivers/intel/fsp2_0/notify.c | 40 +++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/drivers/intel/fsp2_0/notify.c b/src/drivers/intel/fsp2_0/notify.c
new file mode 100644
index 0000000..820bd45
--- /dev/null
+++ b/src/drivers/intel/fsp2_0/notify.c
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#include <arch/cpu.h>
+#include <console/console.h>
+#include <fsp/api.h>
+#include <fsp/util.h>
+#include <string.h>
+
+struct fsp_notify_params {
+ enum fsp_notify_phase phase;
+};
+
+typedef asmlinkage enum fsp_status (*fsp_notify_fn)
+ (struct fsp_notify_params *);
+
+enum fsp_status fsp_notify(enum fsp_notify_phase phase)
+{
+ fsp_notify_fn fspnotify;
+ struct fsp_notify_params notify_params = { .phase = phase };
+
+ if (!fsps_hdr.silicon_init_entry_offset)
+ return FSP_NOT_FOUND;
+
+ fspnotify = (void*) (fsps_hdr.image_base +
+ fsps_hdr.notify_phase_entry_offset);
+
+ printk(BIOS_DEBUG, "FspNotify %x\n", (uint32_t) phase);
+
+ return fspnotify(¬ify_params);
+}
Andrey Petrov (andrey.petrov(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13804
-gerrit
commit c5572f8828af468c276abb66da21d7e68013f167
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Thu Feb 25 17:22:17 2016 -0800
arch/x86: document CAR symbols and expose them in symbols.h
Attempt to better document the symbol usage in car.ld for
cache-as-ram usage. Additionally, add _car_region_[start|end]
that completely covers the entire cache-as-ram region. The
_car_data_[start|end] symbols were renamed to
_car_relocatable_data_[start|end] in the hopes of making it
clearer that objects within there move. Lastly, all these
symbols were added to arch/symbols.h.
Change-Id: I1f1af4983804dc8521d0427f43381bde6d23a060
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/arch/x86/car.ld | 11 +++---
src/arch/x86/include/arch/early_variables.h | 8 ++---
src/arch/x86/include/arch/symbols.h | 52 +++++++++++++++++++++++++++++
src/cpu/amd/car/post_cache_as_ram.c | 4 +--
src/cpu/x86/car.c | 10 +++---
5 files changed, 69 insertions(+), 16 deletions(-)
diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld
index d19e613..c221fb8 100644
--- a/src/arch/x86/car.ld
+++ b/src/arch/x86/car.ld
@@ -18,6 +18,7 @@
/* This file is included inside a SECTIONS block */
. = CONFIG_DCACHE_RAM_BASE;
.car.data . (NOLOAD) : {
+ _car_region_start = . ;
/* Vboot work buffer is completely volatile outside of verstage and
* romstage. Appropriate code needs to handle the transition. */
#if IS_ENABLED(CONFIG_SEPARATE_VERSTAGE)
@@ -36,12 +37,12 @@
* so that multiple stages (romstage and verstage) have a consistent
* link address of these shared objects. */
PRERAM_CBMEM_CONSOLE(., (CONFIG_LATE_CBMEM_INIT ? 0 : 0xc00))
- _car_data_start = .;
+ _car_relocatable_data_start = .;
/* The timestamp implementation relies on this storage to be around
* after migration. One of the fields indicates not to use it as the
* backing store once cbmem comes online. Therefore, this data needs
- * to reside in the migrated area (between _car_data_start and
- * _car_data_end). */
+ * to reside in the migrated area (between _car_relocatable_data_start
+ * and _car_relocatable_data_end). */
TIMESTAMP(., 0x100)
/* _car_global_start and _car_global_end provide symbols to per-stage
* variables that are not shared like the timestamp and the pre-ram
@@ -51,7 +52,9 @@
*(.car.global_data);
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_car_global_end = .;
- _car_data_end = .;
+ _car_relocatable_data_end = .;
+
+ _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start);
}
/* Global variables are not allowed in romstage
diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h
index 16eeacc..e78b846 100644
--- a/src/arch/x86/include/arch/early_variables.h
+++ b/src/arch/x86/include/arch/early_variables.h
@@ -16,6 +16,7 @@
#ifndef ARCH_EARLY_VARIABLES_H
#define ARCH_EARLY_VARIABLES_H
+#include <arch/symbols.h>
#include <stdlib.h>
#include <rules.h>
@@ -59,18 +60,15 @@ void *car_sync_var_ptr(void *var);
#define car_set_var(var, val) \
do { car_get_var(var) = (val); } while(0)
-extern char _car_data_start[];
-extern char _car_data_end[];
-
static inline size_t car_data_size(void)
{
- size_t car_size = &_car_data_end[0] - &_car_data_start[0];
+ size_t car_size = _car_relocatable_data_size;
return ALIGN(car_size, 64);
}
static inline size_t car_object_offset(void *ptr)
{
- return (char *)ptr - &_car_data_start[0];
+ return (char *)ptr - &_car_relocatable_data_start[0];
}
#else
diff --git a/src/arch/x86/include/arch/symbols.h b/src/arch/x86/include/arch/symbols.h
new file mode 100644
index 0000000..e055fa0
--- /dev/null
+++ b/src/arch/x86/include/arch/symbols.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Intel Corp.
+ * Copyright 2016 Google Inc.
+ *
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ARCH_SYMBOLS_H
+#define __ARCH_SYMBOLS_H
+
+/*
+ * The _car_region_[start|end] covers the entirety of the cache as ram
+ * region. All other symbols with the _car prefix a subsets of this
+ * larger region.
+ */
+extern char _car_region_start[];
+extern char _car_region_end[];
+#define _car_region_size (_car_region_end - _car_region_start)
+
+/*
+ * This is the stack used under CONFIG_C_ENVIRONMENT_BOOTBLOCK for
+ * all stages that execute when cache-as-ram is up.
+ */
+extern char _car_stack_start[];
+extern char _car_stack_end[];
+#define _car_stack_size (_car_stack_end - _car_stack_start)
+
+/*
+ * The _car_relocatable_data_[start|end] symbols cover CAR data which is
+ * relocatable once memory comes online. Variables with CAR_GLOBAL decoration
+ * reside within this region. The _car_global_[start|end] is a subset of the
+ * relocatable region which excludes the timestamp region because of
+ * intricacies in the timestamp code.
+ */
+extern char _car_relocatable_data_start[];
+extern char _car_relocatable_data_end[];
+#define _car_relocatable_data_size \
+ (_car_relocatable_data_end - _car_relocatable_data_start)
+extern char _car_global_start[];
+extern char _car_global_end[];
+#define _car_global_size (_car_global_end - _car_global_start)
+
+#endif
diff --git a/src/cpu/amd/car/post_cache_as_ram.c b/src/cpu/amd/car/post_cache_as_ram.c
index 7e33d32..0a59696 100644
--- a/src/cpu/amd/car/post_cache_as_ram.c
+++ b/src/cpu/amd/car/post_cache_as_ram.c
@@ -150,11 +150,11 @@ void post_cache_as_ram(void)
void *migrated_car = (void *)(CONFIG_RAMTOP - car_size);
print_car_debug("Copying data from cache to RAM...");
- memcpy_(migrated_car, &_car_data_start[0], car_size);
+ memcpy_(migrated_car, _car_relocatable_data_start, car_size);
print_car_debug(" Done\n");
print_car_debug("Verifying data integrity in RAM...");
- if (memcmp_(migrated_car, &_car_data_start[0], car_size) == 0)
+ if (memcmp_(migrated_car, _car_relocatable_data_start, car_size) == 0)
print_car_debug(" Done\n");
else
print_car_debug(" FAILED\n");
diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c
index fda3f7d..f9b427a 100644
--- a/src/cpu/x86/car.c
+++ b/src/cpu/x86/car.c
@@ -46,8 +46,8 @@ void *car_get_var_ptr(void *var)
{
char *migrated_base = NULL;
int offset;
- void * _car_start = &_car_data_start;
- void * _car_end = &_car_data_end;
+ void * _car_start = _car_relocatable_data_start;
+ void * _car_end = _car_relocatable_data_end;
/* If the cache-as-ram has not been migrated return the pointer
* passed in. */
@@ -84,8 +84,8 @@ void *car_get_var_ptr(void *var)
void *car_sync_var_ptr(void *var)
{
void ** mig_var = car_get_var_ptr(var);
- void * _car_start = &_car_data_start;
- void * _car_end = &_car_data_end;
+ void * _car_start = _car_relocatable_data_start;
+ void * _car_end = _car_relocatable_data_end;
/* Not moved or migrated yet. */
if (mig_var == var)
@@ -129,7 +129,7 @@ static void do_car_migrate_variables(void)
return;
}
- memcpy(migrated_base, &_car_data_start[0], car_size);
+ memcpy(migrated_base, _car_relocatable_data_start, car_size);
/* Mark that the data has been moved. */
car_migrated = ~0;
Andrey Petrov (andrey.petrov(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13861
-gerrit
commit dff058dc4274882214432ebea1efbebeb851dc90
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Sun Feb 28 22:37:15 2016 -0800
arch/x86: Add common assembly code for stages that run in CAR
This adds a few assembly lines that are generic enough to be shared
between romstage and verstage that are ran in CAR. The GDT reload
is bypassed and the stack is reloaded with the CAR stack defined
in car.ld. The entry point for all those stages is car_stage_entry().
Change-Id: Ie7ef6a02f62627f29a109126d08c68176075bd67
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
Signed-off-by: Aaron Durbin <adurbin(a)chromium.org>
---
src/arch/x86/assembly_entry.S | 38 +++++++++++++++++++++++++++++++++++++-
src/arch/x86/include/arch/cpu.h | 9 +++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/src/arch/x86/assembly_entry.S b/src/arch/x86/assembly_entry.S
index 01e91b0..e4d166c 100644
--- a/src/arch/x86/assembly_entry.S
+++ b/src/arch/x86/assembly_entry.S
@@ -1,7 +1,8 @@
/*
* This file is part of the coreboot project.
*
- * Copyright 2015 Google Inc.
+ * Copyright 2016 Google Inc.
+ * Copyright (C) 2016 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
@@ -13,6 +14,8 @@
* GNU General Public License for more details.
*/
+#if !IS_ENABLED(CONFIG_C_ENVIRONMENT_BOOTBLOCK)
+
/* This file assembles the start of the romstage program by the order of the
* includes. Thus, it's extremely important that one pays very careful
* attention to the order of the includes. */
@@ -31,3 +34,36 @@
* cache-as-ram setup files would be here.
*/
#include <generated/assembly.inc>
+
+#else
+
+/*
+ * This path is for stages that post bootblock when employing
+ * CONFIG_C_ENVIRONMENT_BOOTBLOCK. There's no need to re-load the gdt, etc
+ * as all those settings are cached within the processor. In order to
+ * continue with C code execution one needs to set stack pointer and clear
+ * CAR_GLOBAL variables that are stage specific.
+ */
+.section ".text._start", "ax", @progbits
+.global _start
+_start:
+
+ /* reset stack pointer to CAR stack */
+ mov $_car_stack_end, %esp
+
+ /* clear CAR_GLOBAL area as it is not shared */
+ cld
+ xor %eax, %eax
+ movl $(_car_global_end), %ecx
+ movl $(_car_global_start), %edi
+ sub %edi, %ecx
+ rep stosl
+
+ jmp car_stage_entry
+
+/* This is here for linking purposes. */
+.weak car_stage_entry
+car_stage_entry:
+1:
+ jmp 1b
+#endif
diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h
index 408fa15..f50901f 100644
--- a/src/arch/x86/include/arch/cpu.h
+++ b/src/arch/x86/include/arch/cpu.h
@@ -239,4 +239,13 @@ static inline void get_fms(struct cpuinfo_x86 *c, uint32_t tfms)
#define asmlinkage __attribute__((regparm(0)))
#define alwaysinline inline __attribute__((always_inline))
+#ifndef __ROMCC__
+/*
+ * When using CONFIG_C_ENVIRONMENT_BOOTBLOCK the car_stage_entry()
+ * is the symbol jumped to for each stage after bootblock using
+ * cache-as-ram.
+ */
+void asmlinkage car_stage_entry(void);
+#endif
+
#endif /* ARCH_CPU_H */