[coreboot] New patch to review for filo: d987dd3 Hook up AHCI driver in FILO

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Thu Nov 8 14:47:12 CET 2012


Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1807

-gerrit

commit d987dd3a38ab417051e38916b0c5946faa57c706
Author: Nico Huber <nico.huber at secunet.com>
Date:   Fri Oct 5 15:10:22 2012 +0200

    Hook up AHCI driver in FILO
    
    IDE simply starts enumerating where AHCI ends. Since AHCI
    is whitelisted on individual PCI IDs, there's no risk that
    existing systems change device order.
    
    Change-Id: I069882493a6b9adc8e9f9404ba61866359943759
    Signed-off-by: Nico Huber <nico.huber at secunet.com>
    Signed-off-by: Patrick Georgi <patrick.georgi at secunet.com>
---
 Config.in     |  7 +++++++
 fs/blockdev.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 main/filo.c   |  4 ++++
 3 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/Config.in b/Config.in
index 251bd2a..f164ad4 100644
--- a/Config.in
+++ b/Config.in
@@ -143,6 +143,13 @@ config IDE_NEW_DISK
 	help
 	  Jens Axboe's fine IDE driver
 
+config LIBPAYLOAD_STORAGE
+	bool "Use libpayload's storage drivers"
+	default n
+	help
+	  If selected, libpayloads storage drivers will be used to access
+	  hard disk and optical drives.
+
 config USB_DISK
 	bool "USB Stack"
 	default y
diff --git a/fs/blockdev.c b/fs/blockdev.c
index e1e9d57..7dd6c2e 100644
--- a/fs/blockdev.c
+++ b/fs/blockdev.c
@@ -20,6 +20,9 @@
 
 #include <libpayload.h>
 #include <libpayload-config.h>
+#if defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE)
+#include <storage/storage.h>
+#endif
 #include <config.h>
 #include <fs.h>
 
@@ -245,14 +248,28 @@ int devopen(const char *name, int *reopen)
 		length = (length + DEV_SECTOR_MASK) & ~DEV_SECTOR_MASK;
 	}
 
+	int tmp_drive = drive;
 	switch (type) {
-#if defined(CONFIG_IDE_DISK) || defined(CONFIG_IDE_NEW_DISK)
+#if (defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE)) || \
+		defined(CONFIG_IDE_DISK) || defined(CONFIG_IDE_NEW_DISK)
 	case DISK_IDE:
-		if (ide_probe(drive) != 0) {
+#if defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE)
+		if (drive < storage_device_count()) {
+			if (storage_probe(drive) != POLL_MEDIUM_PRESENT)
+				return 0;
+			disk_size = (uint32_t) - 1;	/* FIXME */
+			break;
+		} else {
+			tmp_drive -= storage_device_count();
+		}
+#endif
+#if defined(CONFIG_IDE_DISK) || defined(CONFIG_IDE_NEW_DISK)
+		if (ide_probe(tmp_drive) != 0) {
 			debug("Failed to open IDE.\n");
 			return 0;
 		}
 		disk_size = (uint32_t) - 1;	/* FIXME */
+#endif
 		break;
 #endif
 #ifdef CONFIG_USB_DISK
@@ -373,18 +390,36 @@ static void *read_sector(unsigned long sector)
 	if (cache_sect[hash] != sector) {
 		cache_sect[hash] = (unsigned long) -1;
 		switch (dev_type) {
-#if defined(CONFIG_IDE_DISK) 
-		case DISK_IDE:
-			if (ide_read(dev_drive, sector, buf) != 0)
-				goto readerr;
-			break;
-#endif
-#if defined(CONFIG_IDE_NEW_DISK)
+#if (defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE)) || \
+			defined(CONFIG_IDE_DISK) || defined(CONFIG_IDE_NEW_DISK)
 		case DISK_IDE:
 		{
+			int tmp_drive = dev_drive;
+#if defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE)
+			if (dev_drive < storage_device_count()) {
+				int count = (NUM_CACHE-hash>8)?8:(NUM_CACHE-hash);
+				if (storage_probe(tmp_drive) == POLL_NO_MEDIUM) {
+					printf("No disk in drive.\n");
+					goto err_out;
+				}
+				if (storage_read_blocks512(tmp_drive,
+							sector, count, buf) != count)
+					goto readerr;
+				while (--count>0) {
+					cache_sect[hash+count] = sector + count;
+				}
+				break;
+			} else {
+				tmp_drive -= storage_device_count();
+			}
+#endif
+#if defined(CONFIG_IDE_DISK)
+			if (ide_read(tmp_drive, sector, buf) != 0)
+				goto readerr;
+#elif defined(CONFIG_IDE_NEW_DISK)
 			int count = (NUM_CACHE-hash>8)?8:(NUM_CACHE-hash);
 			int ret;
-			ret = ide_read_blocks(dev_drive, sector, count, buf);
+			ret = ide_read_blocks(tmp_drive, sector, count, buf);
 			if (ret == 2) {
 				printf("No disk in drive.\n");
 				goto err_out;
@@ -394,6 +429,7 @@ static void *read_sector(unsigned long sector)
 			while (--count>0) {
 				cache_sect[hash+count] = sector + count;
 			}
+#endif
 			break;
 		}
 #endif
@@ -428,7 +464,8 @@ static void *read_sector(unsigned long sector)
       readerr:
 	printf("Disk read error dev=%d drive=%d sector=%lu\n",
 	       dev_type, dev_drive, sector);
-#ifdef CONFIG_IDE_NEW_DISK
+#if defined(CONFIG_IDE_NEW_DISK) || \
+	(defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE))
       err_out:
 #endif
 	flush_cache();
diff --git a/main/filo.c b/main/filo.c
index e37559b..eba6603 100644
--- a/main/filo.c
+++ b/main/filo.c
@@ -72,6 +72,10 @@ static void init(void)
     collect_sys_info(&sys_info);
     relocate();
 
+#if defined(CONFIG_LIBPAYLOAD_STORAGE) && defined(CONFIG_STORAGE)
+    /* libpayload storage drivers */
+    storage_initialize();
+#endif
 #if defined(CONFIG_USB_DISK)
 #if defined(CONFIG_USB)
     /* libpayload USB stack is there */




More information about the coreboot mailing list