[coreboot-gerrit] Change in coreboot[master]: soc/intel/apollolake: Pass storage structures via cbmem

Lee Leahy (Code Review) gerrit at coreboot.org
Sat Apr 15 02:12:45 CEST 2017


Lee Leahy has uploaded a new change for review. ( https://review.coreboot.org/19303 )

Change subject: soc/intel/apollolake: Pass storage structures via cbmem
......................................................................

soc/intel/apollolake: Pass storage structures via cbmem

Copy media and sdhci_ctrlr structures from CAR into cbmem.  Use the copy
in ramstage.

TEST=Build and run on Reef

Change-Id: I7d050878164a9208db6921eb31ec476c57d8fe06
Signed-off-by: Lee Leahy <Leroy.P.Leahy at intel.com>
---
M src/soc/intel/apollolake/emmc_test.c
1 file changed, 35 insertions(+), 5 deletions(-)


  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/19303/1

diff --git a/src/soc/intel/apollolake/emmc_test.c b/src/soc/intel/apollolake/emmc_test.c
index 75443fb..5b5b7be 100644
--- a/src/soc/intel/apollolake/emmc_test.c
+++ b/src/soc/intel/apollolake/emmc_test.c
@@ -16,6 +16,8 @@
 #include <arch/early_variables.h>
 #include <arch/io.h>
 #include <assert.h>
+#include <cbmem.h>
+#include <commonlib/cbmem_id.h>
 #include <console/console.h>
 #include <device/sdhci.h>
 #include <device/storage.h>
@@ -23,6 +25,7 @@
 #include <soc/emmc_test.h>
 #include <soc/iomap.h>
 #include <soc/pci_devs.h>
+#include <string.h>
 
 #if IS_ENABLED(CONFIG_STORAGE_LOG)
 struct log_entry log[LOG_ENTRIES] CAR_GLOBAL;
@@ -158,12 +161,15 @@
 
 	/* Get the structure addresses */
 	media = NULL;
-	if (IS_ENABLED(CONFIG_CAR_DRIVERS_STORAGE)
-		&& (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE)) {
-		media = car_get_var_ptr(&_car_drivers_storage_start);
+	if (IS_ENABLED(CONFIG_CAR_DRIVERS_STORAGE)) {
+		if (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE)
+			media = car_get_var_ptr(&_car_drivers_storage_start);
+		else
+			media = cbmem_find(CBMEM_ID_STORAGE_DATA);
 		sdhci_ctrlr = (void *)(((uintptr_t)(media + 1) + 0x7) & ~7);
-		ASSERT((sdhci_ctrlr + 1)
-			<= (struct sdhci_ctrlr *)&_car_drivers_storage_end);
+		if (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE)
+			ASSERT((struct sdhci_ctrlr *)&_car_drivers_storage_end
+				>= (sdhci_ctrlr + 1));
 	} else {
 		media = &local_media;
 		sdhci_ctrlr = &local_sdhci_ctrlr;
@@ -237,3 +243,27 @@
 	storage_set_partition(media, previous_partition);
 }
 #endif
+
+#if ENV_ROMSTAGE && IS_ENABLED(CONFIG_CAR_DRIVERS_STORAGE)
+static void copy_storage_structures(int is_recovery)
+{
+	struct storage_media *media;
+	struct sdhci_ctrlr *sdhci_ctrlr;
+	size_t size;
+
+	/* Locate the data structures in CBMEM */
+	size = &_car_drivers_storage_end - &_car_drivers_storage_start;
+	ASSERT(size == 256);
+	media = cbmem_add(CBMEM_ID_STORAGE_DATA, size);
+	ASSERT(media != NULL);
+	sdhci_ctrlr = (void *)(((uintptr_t)(media + 1) + 0x7) & ~7);
+	ASSERT((sdhci_ctrlr + 1)
+		<= (struct sdhci_ctrlr *)&_car_drivers_storage_end);
+
+	/* Migrate the data into CBMEM */
+	memcpy(media, &_car_drivers_storage_start, size);
+	media->ctrlr = &sdhci_ctrlr->sd_mmc_ctrlr;
+}
+
+ROMSTAGE_CBMEM_INIT_HOOK(copy_storage_structures);
+#endif

-- 
To view, visit https://review.coreboot.org/19303
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d050878164a9208db6921eb31ec476c57d8fe06
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Lee Leahy <leroy.p.leahy at intel.com>



More information about the coreboot-gerrit mailing list