aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2014-01-30 17:19:46 -0600
committerAaron Durbin <adurbin@google.com>2014-02-15 18:39:29 +0100
commit0f333071ef9151b89de3fcf6dc5c14dba596941a (patch)
tree7a250a88218d16dd9baf7d5b1d9a35baa08c3390 /src/include
parente9aaa71fb1e05c4432d768d87071ef842c536cb4 (diff)
coreboot: infrastructure for different ramstage loaders
There are 2 methods currently available in coreboot to load ramstage from romstage: cbfs and vboot. The vboot path had to be explicitly enabled and code needed to be added to each chipset to support both. Additionally, many of the paths were duplicated between the two. An additional complication is the presence of having a relocatable ramstage which creates another path with duplication. To rectify this situation provide a common API through the use of a callback to load the ramstage. The rest of the existing logic to handle all the various cases is put in a common place. Change-Id: I5268ce70686cc0d121161a775c3a86ea38a4d8ae Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5087 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/cbfs.h22
-rw-r--r--src/include/cbmem.h5
-rw-r--r--src/include/ramstage_loader.h34
-rw-r--r--src/include/romstage_handoff.h10
4 files changed, 67 insertions, 4 deletions
diff --git a/src/include/cbfs.h b/src/include/cbfs.h
index c05566d0b0..9ce862bbe5 100644
--- a/src/include/cbfs.h
+++ b/src/include/cbfs.h
@@ -83,6 +83,10 @@ void selfboot(void *entry);
/* Defined in individual arch / board implementation. */
int init_default_cbfs_media(struct cbfs_media *media);
+#if defined(__PRE_RAM__)
+struct romstage_handoff;
+struct cbmem_entry;
+
#if CONFIG_RELOCATABLE_RAMSTAGE && defined(__PRE_RAM__)
/* The cache_loaded_ramstage() and load_cached_ramstage() functions are defined
* to be weak so that board and chipset code may override them. Their job is to
@@ -90,9 +94,6 @@ int init_default_cbfs_media(struct cbfs_media *media);
* relocated ramstage is saved using the cbmem infrastructure. These
* functions are only valid during romstage. */
-struct romstage_handoff;
-struct cbmem_entry;
-
/* The implementer of cache_loaded_ramstage() may use the romstage_handoff
* structure to store information, but note that the handoff variable can be
* NULL. The ramstage cbmem_entry represents the region occupied by the loaded
@@ -105,7 +106,22 @@ cache_loaded_ramstage(struct romstage_handoff *handoff,
void * __attribute__((weak))
load_cached_ramstage(struct romstage_handoff *handoff,
const struct cbmem_entry *ramstage);
+#else /* CONFIG_RELOCATABLE_RAMSTAGE */
+
+static inline void cache_loaded_ramstage(struct romstage_handoff *handoff,
+ const struct cbmem_entry *ramstage, void *entry_point)
+{
+}
+
+static inline void *
+load_cached_ramstage(struct romstage_handoff *handoff,
+ const struct cbmem_entry *ramstage)
+{
+ return NULL;
+}
+
#endif /* CONFIG_RELOCATABLE_RAMSTAGE */
+#endif /* defined(__PRE_RAM__) */
#endif
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 9e68ba92f4..b47a847718 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -66,6 +66,7 @@
#define CBMEM_ID_HOB_POINTER 0x484f4221
#ifndef __ASSEMBLER__
+#include <stddef.h>
#include <stdint.h>
struct cbmem_entry;
@@ -150,6 +151,10 @@ void cbmem_late_set_table(uint64_t base, uint64_t size);
void get_cbmem_table(uint64_t *base, uint64_t *size);
struct cbmem_entry *get_cbmem_toc(void);
+static inline const struct cbmem_entry *cbmem_entry_find(uint32_t id)
+{
+ return NULL;
+}
#endif /* CONFIG_DYNAMIC_CBMEM */
/* Common API between cbmem and dynamic cbmem. */
diff --git a/src/include/ramstage_loader.h b/src/include/ramstage_loader.h
new file mode 100644
index 0000000000..ad085c0ba5
--- /dev/null
+++ b/src/include/ramstage_loader.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef RAMSTAGE_LOADER_H
+#define RAMSTAGE_LOADER_H
+
+#include <stdint.h>
+struct cbmem_entry;
+
+/* Run ramstage from romstage. */
+void run_ramstage(void);
+
+struct ramstage_loader_ops {
+ const char *name;
+ void *(*load)(uint32_t cbmem_id, const char *name,
+ const struct cbmem_entry **cbmem_entry);
+};
+
+#endif /* RAMSTAGE_LOADER_H */
diff --git a/src/include/romstage_handoff.h b/src/include/romstage_handoff.h
index 699838a260..307babd329 100644
--- a/src/include/romstage_handoff.h
+++ b/src/include/romstage_handoff.h
@@ -41,6 +41,7 @@ struct romstage_handoff {
};
#if defined(__PRE_RAM__)
+#if CONFIG_EARLY_CBMEM_INIT
/* The romstage_handoff_find_or_add() function provides the necessary logic
* for initializing the romstage_handoff structure in cbmem. Different components
* of the romstage may be responsible for setting up different fields. Therefore
@@ -63,7 +64,14 @@ static inline struct romstage_handoff *romstage_handoff_find_or_add(void)
return handoff;
}
-#endif
+#else /* CONFIG_EARLY_CBMEM_INIT */
+static inline struct romstage_handoff *romstage_handoff_find_or_add(void)
+{
+ return NULL;
+}
+#endif /* CONFIG_EARLY_CBMEM_INIT */
+
+#endif /* defined(__PRE_RAM__) */
#endif /* ROMSTAGE_HANDOFF_H */