mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCHv2] Rework of handling disk like media
@ 2011-11-22  8:29 Juergen Beisert
  2011-11-22  8:29 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

This patch stack reworks the handling of disk like media (hard disks, USB mass
storage, SD/MMC cards). It should simplify the code by using the generic
blockdevice layer.
Also partition handling is now a separate step to provide more partition types
than the D*S one in the future.
At the end of this series support for a subset of ATA devices and their
interface is added.

Update: This series contains a fixed and improved version of the partition
patch (PATCH 08/13).

Comments are welcome.

Juergen Beisert (13):
      USB Mass Storage driver: Fix compile time warning
      Create a unique cdev number for on demand devices
      ATA/DISK: Add generic disk support when enabling the BIOS disk driver
      ATA/DISK: Enabling write support does not belong to 'drive types'
      ATA/DISK: Reorganize file structure and names for future updates
      ATA/DISK: The BIOS based disk driver is not an interface
      ATA/DISK: Share important constants and structures
      DISK: Add common partition handling for disk like media
      Use generic block layer to access the drives and do partition parsing
      Remove 'disk_drive.c' as it is now replaced by generic partition handling
      ATA/DISK: Remove the now unused header <ata.h>
      ATA Disk Support: Add support for native ATA type drives
      Add driver for IDE like interfaces

 common/Kconfig                            |   18 +
 common/Makefile                           |    2 +
 common/partitions.c                       |  231 +++++++++++
 drivers/Makefile                          |    2 +-
 drivers/ata/Kconfig                       |   47 ++-
 drivers/ata/Makefile                      |    5 +-
 drivers/ata/disk_ata_drive.c              |  631 +++++++++++++++++++++++++++++
 drivers/ata/{bios.c => disk_bios_drive.c} |   97 +++--
 drivers/ata/disk_drive.c                  |  247 -----------
 drivers/ata/intf_platform_ide.c           |  129 ++++++
 drivers/mci/Kconfig                       |    3 +-
 drivers/mci/mci-core.c                    |  135 ++++---
 drivers/usb/storage/Kconfig               |    1 +
 drivers/usb/storage/usb.c                 |  126 ++++---
 drivers/usb/storage/usb.h                 |    8 +-
 fs/devfs-core.c                           |   14 +
 include/ata.h                             |   39 --
 include/ata_drive.h                       |  194 +++++++++
 include/disks.h                           |   41 ++
 include/driver.h                          |    1 +
 include/mci.h                             |    3 +-
 include/platform_ide.h                    |   31 ++
 22 files changed, 1544 insertions(+), 461 deletions(-)
 create mode 100644 common/partitions.c
 create mode 100644 drivers/ata/disk_ata_drive.c
 rename drivers/ata/{bios.c => disk_bios_drive.c} (79%)
 delete mode 100644 drivers/ata/disk_drive.c
 create mode 100644 drivers/ata/intf_platform_ide.c
 delete mode 100644 include/ata.h
 create mode 100644 include/ata_drive.h
 create mode 100644 include/disks.h
 create mode 100644 include/platform_ide.h

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/13] USB Mass Storage driver: Fix compile time warning
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 02/13] Create a unique cdev number for on demand devices Juergen Beisert
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

drivers/usb/storage/usb.c: In function 'usb_stor_blk_io':
drivers/usb/storage/usb.c:257:16: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/usb/storage/usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d033b29..6dba8cc 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -193,7 +193,7 @@ static int usb_stor_write_10(ccb *srb, struct us_data *us,
  * Disk driver interface
  ***********************************************************************/
 
-#define US_MAX_IO_BLK 32U
+#define US_MAX_IO_BLK 32
 
 enum { io_rd, io_wr };
 
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 02/13] Create a unique cdev number for on demand devices
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
  2011-11-22  8:29 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 03/13] ATA/DISK: Add generic disk support when enabling the BIOS disk driver Juergen Beisert
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

For disk like devices attached to MCI, ATA or USB it depends on the order they
will be recognized. So an unique number for all disk like devices is required.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 fs/devfs-core.c  |   14 ++++++++++++++
 include/driver.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 519e18e..89704b1 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -40,6 +40,20 @@ struct cdev *cdev_by_name(const char *filename)
 	return NULL;
 }
 
+int cdev_find_free_number(const char *basename)
+{
+	int i;
+	char fname[100];
+
+	for (i = 0; i < 1000; i++) {
+		snprintf(fname, sizeof(fname), "%s%d", basename, i);
+		if (cdev_by_name(fname) == NULL)
+			return i;
+	}
+
+	return -1;
+}
+
 struct cdev *cdev_open(const char *name, unsigned long flags)
 {
 	struct cdev *cdev = cdev_by_name(name);
diff --git a/include/driver.h b/include/driver.h
index 80de0c8..99b33d0 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -394,6 +394,7 @@ struct cdev {
 
 int devfs_create(struct cdev *);
 int devfs_remove(struct cdev *);
+int cdev_find_free_number(const char *);
 struct cdev *cdev_by_name(const char *filename);
 struct cdev *cdev_open(const char *name, unsigned long flags);
 void cdev_close(struct cdev *cdev);
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 03/13] ATA/DISK: Add generic disk support when enabling the BIOS disk driver
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
  2011-11-22  8:29 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert
  2011-11-22  8:29 ` [PATCH 02/13] Create a unique cdev number for on demand devices Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 04/13] ATA/DISK: Enabling write support does not belong to 'drive types' Juergen Beisert
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

The BIOS based disk driver makes no sense without the generic disk support.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index d7f4dcb..6a57e5c 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -21,6 +21,7 @@ comment "interface types"
 
 config ATA_BIOS
 	bool "BIOS based"
+	select ATA_DISK
 	depends on X86_BIOS_BRINGUP
 	help
 	  Gain disk drive access via int13 calls to the standard PC-BIOS.
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 04/13] ATA/DISK: Enabling write support does not belong to 'drive types'
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (2 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 03/13] ATA/DISK: Add generic disk support when enabling the BIOS disk driver Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 05/13] ATA/DISK: Reorganize file structure and names for future updates Juergen Beisert
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 6a57e5c..5be1805 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -6,12 +6,12 @@ menuconfig ATA
 
 if ATA
 
-comment "drive types"
-
 config ATA_WRITE
 	select BLOCK_WRITE
 	bool "support writing to ATA drives"
 
+comment "drive types"
+
 config ATA_DISK
 	bool "disk drives"
 	help
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 05/13] ATA/DISK: Reorganize file structure and names for future updates
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (3 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 04/13] ATA/DISK: Enabling write support does not belong to 'drive types' Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 06/13] ATA/DISK: The BIOS based disk driver is not an interface Juergen Beisert
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

'ATA' means more an interface than a disk drive. Change the names to reflect
their real meaning.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/Makefile         |    2 +-
 drivers/ata/Kconfig      |   23 +++++++++++++----------
 drivers/ata/Makefile     |    2 +-
 drivers/ata/disk_drive.c |    4 ++--
 drivers/mci/Kconfig      |    4 ++--
 5 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 16b3bb1..592c39e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -4,7 +4,7 @@ obj-y	+= serial/
 obj-y	+= mtd/
 obj-y	+= nor/
 obj-y	+= usb/
-obj-$(CONFIG_ATA) += ata/
+obj-$(CONFIG_DISK) += ata/
 obj-$(CONFIG_SPI) += spi/
 obj-$(CONFIG_I2C) += i2c/
 obj-$(CONFIG_MCI) += mci/
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 5be1805..025ff94 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -1,27 +1,30 @@
-menuconfig ATA
+menuconfig DISK
 	select BLOCK
-	bool "ATA                           "
+	bool "Disk support                  "
 	help
-	  Add support for ATA types of drives like harddisks and CDROMs.
+	  Add support for disk like drives like harddisks, CDROMs, SD cards and
+	  CF cards.
 
-if ATA
+if DISK
 
-config ATA_WRITE
+config DISK_WRITE
 	select BLOCK_WRITE
-	bool "support writing to ATA drives"
+	bool "support writing to disk drives"
 
 comment "drive types"
 
-config ATA_DISK
-	bool "disk drives"
+config DISK_DRIVE
+	bool "Generic disk drives"
 	help
-	  Add support for regular disk drives
+	  Add support for generic disk drives. Common behaviour for this kind
+	  of devices is using a partition table in the first sector. Say Y here
+	  if you intend to work with disk drives (also CF cards and SD cards).
 
 comment "interface types"
 
 config ATA_BIOS
 	bool "BIOS based"
-	select ATA_DISK
+	select DISK_DRIVE
 	depends on X86_BIOS_BRINGUP
 	help
 	  Gain disk drive access via int13 calls to the standard PC-BIOS.
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 30d15cc..c3260d7 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,6 +1,6 @@
 # drive types
 
-obj-$(CONFIG_ATA_DISK) += disk_drive.o
+obj-$(CONFIG_DISK_DRIVE) += disk_drive.o
 
 # interface types
 
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
index 6a5dc87..c2a6a51 100644
--- a/drivers/ata/disk_drive.c
+++ b/drivers/ata/disk_drive.c
@@ -144,7 +144,7 @@ static int atablk_read(struct block_device *blk, void *buf, int block,
 	return atablk->intf->read(atablk->dev, block, num_blocks, buf);
 }
 
-#ifdef CONFIG_ATA_WRITE
+#ifdef CONFIG_DISK_WRITE
 static int atablk_write(struct block_device *blk, const void *buf, int block,
 		int num_blocks)
 {
@@ -156,7 +156,7 @@ static int atablk_write(struct block_device *blk, const void *buf, int block,
 
 static struct block_device_ops ataops = {
 	.read = atablk_read,
-#ifdef CONFIG_ATA_WRITE
+#ifdef CONFIG_DISK_WRITE
 	.write = atablk_write,
 #endif
 };
diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 0d5a0e0..d24e606 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -1,7 +1,7 @@
 menuconfig MCI
 	bool "MCI drivers                   "
-	select ATA
-	select ATA_DISK
+	select DISK
+	select DISK_DRIVE
 	help
 	  Add support for MCI drivers, used to handle MMC and SD cards
 
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 06/13] ATA/DISK: The BIOS based disk driver is not an interface
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (4 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 05/13] ATA/DISK: Reorganize file structure and names for future updates Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 07/13] ATA/DISK: Share important constants and structures Juergen Beisert
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

Using the BIOS to access attached hard disks means a full disk driver, not only
an interface to the drives.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig           |    6 +-
 drivers/ata/Makefile          |    2 +-
 drivers/ata/bios.c            |  290 -----------------------------------------
 drivers/ata/disk_bios_drive.c |  290 +++++++++++++++++++++++++++++++++++++++++
 drivers/ata/disk_drive.c      |   10 +-
 5 files changed, 299 insertions(+), 299 deletions(-)
 delete mode 100644 drivers/ata/bios.c
 create mode 100644 drivers/ata/disk_bios_drive.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 025ff94..f3b2939 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -20,9 +20,7 @@ config DISK_DRIVE
 	  of devices is using a partition table in the first sector. Say Y here
 	  if you intend to work with disk drives (also CF cards and SD cards).
 
-comment "interface types"
-
-config ATA_BIOS
+config DISK_BIOS
 	bool "BIOS based"
 	select DISK_DRIVE
 	depends on X86_BIOS_BRINGUP
@@ -32,4 +30,6 @@ config ATA_BIOS
 	  media to work on. Disadvantage is: Due to its 16 bit nature it is
 	  slow.
 
+comment "interface types"
+
 endif
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index c3260d7..10f3957 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,7 +1,7 @@
 # drive types
 
 obj-$(CONFIG_DISK_DRIVE) += disk_drive.o
+obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
 
 # interface types
 
-obj-$(CONFIG_ATA_BIOS) += bios.o
diff --git a/drivers/ata/bios.c b/drivers/ata/bios.c
deleted file mode 100644
index 6e2377c..0000000
--- a/drivers/ata/bios.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
- *
- * Mostly stolen from the GRUB2 project
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  Free Software Foundation, 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; either version 2 of
- * the License, or (at your option) any later version.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-/**
- * @file
- * @brief Media communication layer through the standard 16 bit PC-BIOS
- *
- * This communication driver does all accesses to the boot medium via 16 bit
- * real mode calls into the standard BIOS. Due to this method, its possible
- * to use all the medias to boot from that are supported by the BIOS. This
- * also includes emulated only medias.
- *
- * To be able to call the real mode BIOS, this driver must switch back to
- * real mode for each access. This will slow down the access a little bit, but
- * we are a boot loader here, not an operating system...
- *
- * Note: We need scratch memory for the BIOS communication, because the BIOS
- * can only handle memory below 0xA0000. So we must copy all data between
- * the flat mode buffers and realmode buffers.
- *
- * Note: This driver makes no sense on other architectures than x86.
- *
- * Note: This driver does only support LBA addressing. Currently no CHS!
- */
-
-#include <stdio.h>
-#include <linux/types.h>
-#include <init.h>
-#include <driver.h>
-#include <string.h>
-#include <xfuncs.h>
-#include <asm/syslib.h>
-#include <ata.h>
-#include <errno.h>
-
-/**
- * Sector count handled in one count
- *
- * @todo 127 are always possible, some BIOS manufacturer supports up to 255.
- * Is it's worth to detect Phoenic's restriction?
- */
-#define SECTORS_AT_ONCE 64
-
-/** Size of one sector in bytes */
-#define SECTOR_SIZE 512
-
-/** Command to read sectors from media */
-#define BIOS_READ_CMD 0
-
-/** Command to write sectors to media */
-#define BIOS_WRT_CMD 1
-
-/**
- * "Disk Address Packet Structure" to be used when calling
- * BIOS's int13, function 0x42/0x43
- */
-struct DAPS
-{
-	uint8_t size;		/**< always '16' */
-	uint8_t res1;		/**< always '0' */
-	int8_t count;		/**< number of sectors 0...127 */
-	uint8_t res2;		/**< always '0' */
-	uint16_t offset;	/**< buffer address: offset */
-	uint16_t segment;	/**< buffer address: segment */
-	uint64_t lba;		/**< LBA of the start sector */
-} __attribute__ ((packed));
-
-/**
- * Collection of data we need to know about the connected drive
- */
-struct media_access {
-	int drive_no;	/**< drive number used by the BIOS */
-	int is_cdrom;	/**< drive is a CDROM e.g. no write support */
-};
-
-/**
- * Scratch memory for BIOS communication to handle data in chunks of 32 kiB
- *
- * Note: This variable is located in the .bss segment, assuming it is located
- * below 0xA0000. If not, the BIOS is not able to read or store any data
- * from/to it. The variable must also aligned to a 16 byte boundary to easify
- * linear to segment:offset address conversion.
- */
-static uint8_t scratch_buffer[SECTORS_AT_ONCE * SECTOR_SIZE] __attribute__((aligned(16)));
-
-/**
- * Communication buffer for the 16 bit int13 BIOS call
- *
- * Note: This variable is located in the .bss segment, assuming it is located
- * below 0xA0000. If not, the BIOS is not able to read or store any data
- * from/to it. The variable must also aligned to a 16 byte boundary to easify
- * linear to segment:offset conversion.
- */
-static struct DAPS bios_daps __attribute__((aligned(16)));
-
-/**
- * @param media our data we need to do the access
- * @param cmd Command to forward to the BIOS
- * @param sector_start LBA of the start sector
- * @param sector_count Sector count
- * @param buffer Buffer to read from or write to (in the low memory area)
- * @return 0 on success, anything else on failure
- */
-static int biosdisk_bios_call(struct media_access *media, int cmd, uint64_t sector_start, unsigned sector_count, void *buffer)
-{
-	int rc;
-
-	/* prepare the DAPS for the int13 call */
-	bios_daps.size = sizeof(struct DAPS);
-	bios_daps.res1 = 0;
-	bios_daps.count = sector_count;	/* always less than 128! */
-	bios_daps.res2 = 0;
-	bios_daps.segment = (unsigned long)buffer >> 4;
-	bios_daps.offset = (unsigned long)buffer - (unsigned long)(bios_daps.segment << 4);
-	bios_daps.lba = sector_start;
-
-	if (cmd == BIOS_READ_CMD)
-		rc = bios_disk_rw_int13_extensions(0x42, media->drive_no, &bios_daps);
-	else if (cmd == BIOS_WRT_CMD)
-		rc = bios_disk_rw_int13_extensions(0x43, media->drive_no, &bios_daps);
-	else
-		return -1;
-
-	return rc;
-}
-
-/**
- * Read a chunk of sectors from media
- * @param dev our data we need to do the access
- * @param sector_start Sector's LBA number to start read from
- * @param sector_count Sectors to read
- * @param buffer Buffer to read into
- * @return 0 on success, anything else on failure
- *
- * This routine expects the buffer has the correct size to store all data!
- */
-static int biosdisk_read(struct device_d *dev, uint64_t sector_start, unsigned sector_count, void *buffer)
-{
-	int rc;
-	struct ata_interface *intf = dev->platform_data;
-	struct media_access *media = intf->priv;
-
-	while (sector_count >= SECTORS_AT_ONCE) {
-		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
-		if (rc != 0)
-			return rc;
-		__builtin_memcpy(buffer, scratch_buffer, sizeof(scratch_buffer));
-		buffer += sizeof(scratch_buffer);
-		sector_start += SECTORS_AT_ONCE;
-		sector_count -= SECTORS_AT_ONCE;
-	};
-
-	/* Are sectors still remaining? */
-	if (sector_count) {
-		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, sector_count, scratch_buffer);
-		__builtin_memcpy(buffer, scratch_buffer, sector_count * SECTOR_SIZE);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-/**
- * Write a chunk of sectors to media
- * @param dev our data we need to do the access
- * @param sector_start Sector's LBA number to start write to
- * @param sector_count Sectors to write
- * @param buffer Buffer to write from
- * @return 0 on success, anything else on failure
- *
- * This routine expects the buffer has the correct size to read all data!
- */
-static int biosdisk_write(struct device_d *dev, uint64_t sector_start, unsigned sector_count, const void *buffer)
-{
-	int rc;
-	struct ata_interface *intf = dev->platform_data;
-	struct media_access *media = intf->priv;
-
-	while (sector_count >= SECTORS_AT_ONCE) {
-		__builtin_memcpy(scratch_buffer, buffer, sizeof(scratch_buffer));
-		rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
-		if (rc != 0)
-			return rc;
-		buffer += sizeof(scratch_buffer);
-		sector_start += SECTORS_AT_ONCE;
-		sector_count -= SECTORS_AT_ONCE;
-	};
-
-	/* Are sectors still remaining? */
-	if (sector_count) {
-		__builtin_memcpy(scratch_buffer, buffer, sector_count * SECTOR_SIZE);
-		rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, sector_count, scratch_buffer);
-	} else
-		rc = 0;
-
-	return rc;
-}
-
-/**
- * Probe for connected drives and register them
- *
- * Detecting if a drive is present is done by simply reading its MBR.
- *
- * FIXME: Relation between BIOS disk numbering scheme and our representation
- * here in barebox (and later on in the linux kernel)
- */
-static int biosdisk_probe(struct device_d *dev)
-{
-	int drive, rc;
-	struct media_access media, *m;
-	struct device_d *drive_dev;
-	struct ata_interface *p;
-
-	for (drive = 0x80; drive < 0x90; drive++) {
-		media.drive_no = drive;
-		media.is_cdrom = 0;	/* don't know yet */
-		rc = biosdisk_bios_call(&media, BIOS_READ_CMD, 0, 1, scratch_buffer);
-		if (rc != 0)
-			continue;
-
-		printf("BIOSdrive %d seems valid. Registering...\n", media.drive_no);
-
-		drive_dev = xzalloc(sizeof(struct device_d) + sizeof(struct media_access) + sizeof(struct ata_interface));
-		if (drive_dev == NULL) {
-			dev_err(dev, "Out of memory\n");
-			return -1;
-		}
-		m = (struct media_access*)&drive_dev[1];
-		p = (struct ata_interface*)&m[1];
-
-		m->drive_no = drive;
-		m->is_cdrom = 0;
-
-		p->write = biosdisk_write;
-		p->read = biosdisk_read;
-		p->priv = m;
-
-		strcpy(drive_dev->name, "biosdisk");
-		drive_dev->id = drive - 0x80;
-		drive_dev->resource[0].start = 0;
-		drive_dev->platform_data = p;
-
-		register_device(drive_dev);
-	}
-
-	return 0;
-}
-
-static struct driver_d biosdisk_driver = {
-        .name   = "biosdrive",
-        .probe  = biosdisk_probe,
-};
-
-static int biosdisk_init(void)
-{
-	/* sanity */
-	if (scratch_buffer > (uint8_t*)0x9FFFF) {
-		printf("BIOS driver: Scratch memory not in real mode area. Cannot continue!\n");
-		return -EIO;
-	}
-	if (&bios_daps > (struct DAPS*)0x9FFFF) {
-		printf("BIOS driver: DAPS memory not in real mode area. Cannot continue!\n");
-		return -EIO;
-	}
-
-	register_driver(&biosdisk_driver);
-	return 0;
-}
-
-device_initcall(biosdisk_init);
diff --git a/drivers/ata/disk_bios_drive.c b/drivers/ata/disk_bios_drive.c
new file mode 100644
index 0000000..6e2377c
--- /dev/null
+++ b/drivers/ata/disk_bios_drive.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (C) 2009 Juergen Beisert, Pengutronix
+ *
+ * Mostly stolen from the GRUB2 project
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  Free Software Foundation, 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+/**
+ * @file
+ * @brief Media communication layer through the standard 16 bit PC-BIOS
+ *
+ * This communication driver does all accesses to the boot medium via 16 bit
+ * real mode calls into the standard BIOS. Due to this method, its possible
+ * to use all the medias to boot from that are supported by the BIOS. This
+ * also includes emulated only medias.
+ *
+ * To be able to call the real mode BIOS, this driver must switch back to
+ * real mode for each access. This will slow down the access a little bit, but
+ * we are a boot loader here, not an operating system...
+ *
+ * Note: We need scratch memory for the BIOS communication, because the BIOS
+ * can only handle memory below 0xA0000. So we must copy all data between
+ * the flat mode buffers and realmode buffers.
+ *
+ * Note: This driver makes no sense on other architectures than x86.
+ *
+ * Note: This driver does only support LBA addressing. Currently no CHS!
+ */
+
+#include <stdio.h>
+#include <linux/types.h>
+#include <init.h>
+#include <driver.h>
+#include <string.h>
+#include <xfuncs.h>
+#include <asm/syslib.h>
+#include <ata.h>
+#include <errno.h>
+
+/**
+ * Sector count handled in one count
+ *
+ * @todo 127 are always possible, some BIOS manufacturer supports up to 255.
+ * Is it's worth to detect Phoenic's restriction?
+ */
+#define SECTORS_AT_ONCE 64
+
+/** Size of one sector in bytes */
+#define SECTOR_SIZE 512
+
+/** Command to read sectors from media */
+#define BIOS_READ_CMD 0
+
+/** Command to write sectors to media */
+#define BIOS_WRT_CMD 1
+
+/**
+ * "Disk Address Packet Structure" to be used when calling
+ * BIOS's int13, function 0x42/0x43
+ */
+struct DAPS
+{
+	uint8_t size;		/**< always '16' */
+	uint8_t res1;		/**< always '0' */
+	int8_t count;		/**< number of sectors 0...127 */
+	uint8_t res2;		/**< always '0' */
+	uint16_t offset;	/**< buffer address: offset */
+	uint16_t segment;	/**< buffer address: segment */
+	uint64_t lba;		/**< LBA of the start sector */
+} __attribute__ ((packed));
+
+/**
+ * Collection of data we need to know about the connected drive
+ */
+struct media_access {
+	int drive_no;	/**< drive number used by the BIOS */
+	int is_cdrom;	/**< drive is a CDROM e.g. no write support */
+};
+
+/**
+ * Scratch memory for BIOS communication to handle data in chunks of 32 kiB
+ *
+ * Note: This variable is located in the .bss segment, assuming it is located
+ * below 0xA0000. If not, the BIOS is not able to read or store any data
+ * from/to it. The variable must also aligned to a 16 byte boundary to easify
+ * linear to segment:offset address conversion.
+ */
+static uint8_t scratch_buffer[SECTORS_AT_ONCE * SECTOR_SIZE] __attribute__((aligned(16)));
+
+/**
+ * Communication buffer for the 16 bit int13 BIOS call
+ *
+ * Note: This variable is located in the .bss segment, assuming it is located
+ * below 0xA0000. If not, the BIOS is not able to read or store any data
+ * from/to it. The variable must also aligned to a 16 byte boundary to easify
+ * linear to segment:offset conversion.
+ */
+static struct DAPS bios_daps __attribute__((aligned(16)));
+
+/**
+ * @param media our data we need to do the access
+ * @param cmd Command to forward to the BIOS
+ * @param sector_start LBA of the start sector
+ * @param sector_count Sector count
+ * @param buffer Buffer to read from or write to (in the low memory area)
+ * @return 0 on success, anything else on failure
+ */
+static int biosdisk_bios_call(struct media_access *media, int cmd, uint64_t sector_start, unsigned sector_count, void *buffer)
+{
+	int rc;
+
+	/* prepare the DAPS for the int13 call */
+	bios_daps.size = sizeof(struct DAPS);
+	bios_daps.res1 = 0;
+	bios_daps.count = sector_count;	/* always less than 128! */
+	bios_daps.res2 = 0;
+	bios_daps.segment = (unsigned long)buffer >> 4;
+	bios_daps.offset = (unsigned long)buffer - (unsigned long)(bios_daps.segment << 4);
+	bios_daps.lba = sector_start;
+
+	if (cmd == BIOS_READ_CMD)
+		rc = bios_disk_rw_int13_extensions(0x42, media->drive_no, &bios_daps);
+	else if (cmd == BIOS_WRT_CMD)
+		rc = bios_disk_rw_int13_extensions(0x43, media->drive_no, &bios_daps);
+	else
+		return -1;
+
+	return rc;
+}
+
+/**
+ * Read a chunk of sectors from media
+ * @param dev our data we need to do the access
+ * @param sector_start Sector's LBA number to start read from
+ * @param sector_count Sectors to read
+ * @param buffer Buffer to read into
+ * @return 0 on success, anything else on failure
+ *
+ * This routine expects the buffer has the correct size to store all data!
+ */
+static int biosdisk_read(struct device_d *dev, uint64_t sector_start, unsigned sector_count, void *buffer)
+{
+	int rc;
+	struct ata_interface *intf = dev->platform_data;
+	struct media_access *media = intf->priv;
+
+	while (sector_count >= SECTORS_AT_ONCE) {
+		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
+		if (rc != 0)
+			return rc;
+		__builtin_memcpy(buffer, scratch_buffer, sizeof(scratch_buffer));
+		buffer += sizeof(scratch_buffer);
+		sector_start += SECTORS_AT_ONCE;
+		sector_count -= SECTORS_AT_ONCE;
+	};
+
+	/* Are sectors still remaining? */
+	if (sector_count) {
+		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, sector_count, scratch_buffer);
+		__builtin_memcpy(buffer, scratch_buffer, sector_count * SECTOR_SIZE);
+	} else
+		rc = 0;
+
+	return rc;
+}
+
+/**
+ * Write a chunk of sectors to media
+ * @param dev our data we need to do the access
+ * @param sector_start Sector's LBA number to start write to
+ * @param sector_count Sectors to write
+ * @param buffer Buffer to write from
+ * @return 0 on success, anything else on failure
+ *
+ * This routine expects the buffer has the correct size to read all data!
+ */
+static int biosdisk_write(struct device_d *dev, uint64_t sector_start, unsigned sector_count, const void *buffer)
+{
+	int rc;
+	struct ata_interface *intf = dev->platform_data;
+	struct media_access *media = intf->priv;
+
+	while (sector_count >= SECTORS_AT_ONCE) {
+		__builtin_memcpy(scratch_buffer, buffer, sizeof(scratch_buffer));
+		rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
+		if (rc != 0)
+			return rc;
+		buffer += sizeof(scratch_buffer);
+		sector_start += SECTORS_AT_ONCE;
+		sector_count -= SECTORS_AT_ONCE;
+	};
+
+	/* Are sectors still remaining? */
+	if (sector_count) {
+		__builtin_memcpy(scratch_buffer, buffer, sector_count * SECTOR_SIZE);
+		rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, sector_count, scratch_buffer);
+	} else
+		rc = 0;
+
+	return rc;
+}
+
+/**
+ * Probe for connected drives and register them
+ *
+ * Detecting if a drive is present is done by simply reading its MBR.
+ *
+ * FIXME: Relation between BIOS disk numbering scheme and our representation
+ * here in barebox (and later on in the linux kernel)
+ */
+static int biosdisk_probe(struct device_d *dev)
+{
+	int drive, rc;
+	struct media_access media, *m;
+	struct device_d *drive_dev;
+	struct ata_interface *p;
+
+	for (drive = 0x80; drive < 0x90; drive++) {
+		media.drive_no = drive;
+		media.is_cdrom = 0;	/* don't know yet */
+		rc = biosdisk_bios_call(&media, BIOS_READ_CMD, 0, 1, scratch_buffer);
+		if (rc != 0)
+			continue;
+
+		printf("BIOSdrive %d seems valid. Registering...\n", media.drive_no);
+
+		drive_dev = xzalloc(sizeof(struct device_d) + sizeof(struct media_access) + sizeof(struct ata_interface));
+		if (drive_dev == NULL) {
+			dev_err(dev, "Out of memory\n");
+			return -1;
+		}
+		m = (struct media_access*)&drive_dev[1];
+		p = (struct ata_interface*)&m[1];
+
+		m->drive_no = drive;
+		m->is_cdrom = 0;
+
+		p->write = biosdisk_write;
+		p->read = biosdisk_read;
+		p->priv = m;
+
+		strcpy(drive_dev->name, "biosdisk");
+		drive_dev->id = drive - 0x80;
+		drive_dev->resource[0].start = 0;
+		drive_dev->platform_data = p;
+
+		register_device(drive_dev);
+	}
+
+	return 0;
+}
+
+static struct driver_d biosdisk_driver = {
+        .name   = "biosdrive",
+        .probe  = biosdisk_probe,
+};
+
+static int biosdisk_init(void)
+{
+	/* sanity */
+	if (scratch_buffer > (uint8_t*)0x9FFFF) {
+		printf("BIOS driver: Scratch memory not in real mode area. Cannot continue!\n");
+		return -EIO;
+	}
+	if (&bios_daps > (struct DAPS*)0x9FFFF) {
+		printf("BIOS driver: DAPS memory not in real mode area. Cannot continue!\n");
+		return -EIO;
+	}
+
+	register_driver(&biosdisk_driver);
+	return 0;
+}
+
+device_initcall(biosdisk_init);
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
index c2a6a51..c5c1ee9 100644
--- a/drivers/ata/disk_drive.c
+++ b/drivers/ata/disk_drive.c
@@ -61,7 +61,7 @@ struct partition_entry {
  * @param table partition table
  * @return size in sectors
  */
-#ifdef CONFIG_ATA_BIOS
+#ifdef CONFIG_DISK_BIOS
 static unsigned long disk_guess_size(struct device_d *dev, struct partition_entry *table)
 {
 	int part_order[4] = {0, 1, 2, 3};
@@ -186,14 +186,14 @@ static int disk_probe(struct device_d *dev)
 	 * the drive ordering must not correspond to the Linux drive order,
 	 * use the 'biosdisk' name instead.
 	 */
-#ifdef CONFIG_ATA_BIOS
+#ifdef CONFIG_DISK_BIOS
 	if (strcmp(dev->driver->name, "biosdisk") == 0)
 		atablk->blk.cdev.name = asprintf("biosdisk%d", dev->id);
 	else
 #endif
 		atablk->blk.cdev.name = asprintf("disk%d", dev->id);
 
-#ifdef CONFIG_ATA_BIOS
+#ifdef CONFIG_DISK_BIOS
 	/* On x86, BIOS based disks are coming without a valid .size field */
 	if (dev->resource[0].size == 0) {
 		/* guess the size of this drive if not otherwise given */
@@ -223,7 +223,7 @@ on_error:
 	return rc;
 }
 
-#ifdef CONFIG_ATA_BIOS
+#ifdef CONFIG_DISK_BIOS
 static struct driver_d biosdisk_driver = {
         .name   = "biosdisk",
         .probe  = disk_probe,
@@ -237,7 +237,7 @@ static struct driver_d disk_driver = {
 
 static int disk_init(void)
 {
-#ifdef CONFIG_ATA_BIOS
+#ifdef CONFIG_DISK_BIOS
 	register_driver(&biosdisk_driver);
 #endif
 	register_driver(&disk_driver);
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 07/13] ATA/DISK: Share important constants and structures
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (5 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 06/13] ATA/DISK: The BIOS based disk driver is not an interface Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 08/13] DISK: Add common partition handling for disk like media Juergen Beisert
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 include/disks.h |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
 create mode 100644 include/disks.h

diff --git a/include/disks.h b/include/disks.h
new file mode 100644
index 0000000..ec136d4
--- /dev/null
+++ b/include/disks.h
@@ -0,0 +1,39 @@
+/*
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * 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 DISKS_H
+#define DISKS_H
+
+struct block_device;
+
+/** Size of one sector in bytes */
+#define SECTOR_SIZE 512
+
+/** Size of one sector in bit shift */
+#define SECTOR_SHIFT 9
+
+/**
+ * Description of one partition table entry (D*S type)
+ */
+struct partition_entry {
+	uint8_t boot_indicator;	/*! Maybe marked as an active partition */
+	uint8_t chs_begin[3];	/*! Start of the partition in cylinders, heads and sectors */
+	uint8_t type;		/*! Filesystem type */
+	uint8_t chs_end[3];	/*! End of the partition in cylinders, heads and sectors */
+	uint32_t partition_start; /*! Start of the partition in LBA notation */
+	uint32_t partition_size; /*! Start of the partition in LBA notation */
+} __attribute__ ((packed));
+
+#endif /* DISKS_H */
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 08/13] DISK: Add common partition handling for disk like media
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (6 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 07/13] ATA/DISK: Share important constants and structures Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 09/13] Use generic block layer to access the drives and do partition parsing Juergen Beisert
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

This covers disk like media like SD card, CF cards, regular hard disks and also
USB mass storage devices. Most common used partition table is still of DOS type.
This implementation is prepared to support more partition types in the future.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 common/Kconfig      |   18 ++++
 common/Makefile     |    2 +
 common/partitions.c |  231 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/disks.h     |    2 +
 4 files changed, 253 insertions(+), 0 deletions(-)
 create mode 100644 common/partitions.c

diff --git a/common/Kconfig b/common/Kconfig
index 8e96920..1318e7d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -406,6 +406,24 @@ config PARTITION
 	bool
 	prompt "Enable Partitions"
 
+if PARTITION
+
+config PARTITION_DISK
+	bool "DISK partition support"
+	help
+	  Add support for handling common partition tables on all kind of disk
+	  like devices (harddisks, CF cards, SD cards and so on)
+
+if PARTITION_DISK
+
+config PARTITION_DISK_DOS
+	bool "DOS partition support"
+	help
+	  Add support to handle partitions in DOS style.
+
+endif
+endif
+
 config DEFAULT_ENVIRONMENT
 	bool
 	default y
diff --git a/common/Makefile b/common/Makefile
index 7bb8ea4..3edf38f 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -7,6 +7,8 @@ obj-$(CONFIG_ENV_HANDLING)	+= environment.o
 obj-$(CONFIG_AUTO_COMPLETE)	+= complete.o
 obj-$(CONFIG_POLLER)		+= poller.o
 obj-$(CONFIG_BLOCK)		+= block.o
+obj-$(CONFIG_PARTITION_DISK)	+= partitions.o
+
 obj-$(CONFIG_CMD_LOADS)		+= s_record.o
 obj-$(CONFIG_OFTREE)		+= oftree.o
 
diff --git a/common/partitions.c b/common/partitions.c
new file mode 100644
index 0000000..6310988
--- /dev/null
+++ b/common/partitions.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2009...2011 Juergen Beisert, Pengutronix
+ *
+ * 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.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+/**
+ * @file
+ * @brief Generic support for partition tables on disk like media
+ *
+ * @todo Support for disks larger than 4 GiB
+ * @todo Reliable size detection for BIOS based disks (on x86 only)
+ */
+#include <common.h>
+#include <malloc.h>
+#include <errno.h>
+#include <block.h>
+#include <asm/unaligned.h>
+#include <disks.h>
+
+struct partition {
+	uint64_t first_sec;
+	uint64_t size;
+};
+
+struct partition_desc {
+	int used_entries;
+	struct partition parts[8];
+};
+
+static void add_one_partition_entry(struct partition *p,
+						struct partition_desc *pdesc)
+{
+	if (pdesc->used_entries >= 8)
+		return;	/* ignore */
+	pdesc->parts[pdesc->used_entries] = *p;
+	pdesc->used_entries++;
+}
+
+/**
+ * Reject values which cannot be used in Barebox
+ * @param val Value to be check
+ * @return 0 if value can be used in Barebox, -EINVAL if not
+ *
+ * @note this routine can be removes when Barebox uses file offsets larger
+ * than 32 bit
+ */
+static int check_offset_value(uint64_t val)
+{
+#if 1	/* until Barebox can handle 64 bit offsets */
+	if (val > 0x7fffff)
+		return -EINVAL;
+#endif
+	return 0;
+}
+
+/**
+ * Guess the size of the disk, based on the partition table entries
+ * @param dev device to create partitions for
+ * @param table partition table
+ * @return size in sectors
+ */
+static uint64_t disk_guess_size(struct device_d *dev, struct partition_entry *table)
+{
+	int part_order[4] = {0, 1, 2, 3};
+	uint64_t size = 0;
+	int i;
+
+	for (i = 0; i < 4; i++) {
+		if (table[part_order[i]].partition_start != 0) {
+			size += table[part_order[i]].partition_start - size;
+			size += table[part_order[i]].partition_size;
+		}
+	}
+	/* limit disk sector counts we can't handle due to 32 bit limits */
+	if (check_offset_value(size) > 0x7fffffff) {
+		dev_warn(dev, "Warning: Sector count limited due to 31 bit"
+				"contraints\n");
+		size = 0x7fffffff;
+	}
+
+	return size;
+}
+
+/**
+ * Read and check a DOS partition table
+ * @param blk Info about the whole disk
+ * @param sector_buf Buffer for at least one sector
+ * @return 0 on success
+ */
+static int read_dos_partition_table(struct block_device *blk, uint8_t *sector_buf)
+{
+	int rc;
+
+	/* read in the MBR to get the partition table */
+	rc = blk->ops->read(blk, sector_buf, 0, 1);
+	if (rc != 0) {
+		dev_err(blk->dev, "Cannot read MBR/partition table\n");
+		return -ENODEV;
+	}
+
+	if ((sector_buf[510] != 0x55) || (sector_buf[511] != 0xAA)) {
+		dev_info(blk->dev, "No partition table found\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/**
+ * Check if a DOS like partition describes this block device
+ * @param blk Block device to register to
+ * @param pd Where to store the partition information
+ * @return 0 on success, -EINVAL if no partition table was found
+ *
+ * It seems at least on ARM this routine canot use temp. stack space for the
+ * sector. So, keep the malloc/free.
+ */
+static int __maybe_unused try_dos_partition(struct block_device *blk,
+						struct partition_desc *pd)
+{
+	int part_order[4] = {0, 1, 2, 3};
+	uint8_t *buffer;
+	struct partition_entry *table;
+	struct partition pentry;
+	int i, rc;
+
+	buffer = xmalloc(SECTOR_SIZE);
+
+	rc = read_dos_partition_table(blk, (uint8_t*)buffer);
+	if (rc != 0)
+		goto on_error;
+
+	table = (struct partition_entry *)&buffer[446];
+
+	/* valid for x86 BIOS based disks only */
+	if (blk->num_blocks == 0)
+		disk_guess_size(blk->dev, table);
+
+	for (i = 0; i < 4; i++) {
+		pentry.first_sec =
+			get_unaligned(&table[part_order[i]].partition_start);
+		pentry.size =
+			get_unaligned(&table[part_order[i]].partition_size);
+
+		/* do we have to ignore this partition due to limitations? */
+		if (check_offset_value(pentry.first_sec) != 0)
+			continue;
+		if (check_offset_value(pentry.size) != 0)
+			continue;
+
+		if (pentry.first_sec != 0)
+			add_one_partition_entry(&pentry, pd);
+		else {
+			dev_dbg(blk->dev, "Skipping empty partition %d\n", i);
+		}
+	}
+
+on_error:
+	free(buffer);
+	return rc;
+}
+
+/**
+ * Register one partition on the given block device
+ * @param blk Block device to register to
+ * @param part Partition description
+ * @param no Partition number
+ * @return 0 on success
+ */
+static int register_one_partition(struct block_device *blk,
+					struct partition *part, int no)
+{
+	char partition_name[19];
+
+	sprintf(partition_name, "%s.%d", blk->cdev.name, no);
+	dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
+				partition_name, blk->cdev.name);
+	return devfs_add_partition(blk->cdev.name,
+				part->first_sec * SECTOR_SIZE,
+				part->size * SECTOR_SIZE,
+				DEVFS_PARTITION_FIXED, partition_name);
+}
+
+/**
+ * Try to collect partition information on the given block device
+ * @param blk Block device to examine
+ * @return 0 most of the time, negative value else
+ *
+ * It is not a failure if no partition information is found
+ */
+int parse_partition_table(struct block_device *blk)
+{
+	struct partition_desc pdesc = { .used_entries = 0, };
+	int i;
+	int rc = 0;
+
+#ifdef CONFIG_PARTITION_DISK_DOS
+	if (pdesc.used_entries == 0)
+		try_dos_partition(blk, &pdesc);
+#endif
+
+	if (pdesc.used_entries != 0) {
+		/* at least one partition description found */
+		for (i = 0; i < pdesc.used_entries; i++) {
+			rc = register_one_partition(blk, &pdesc.parts[i], i);
+			if (rc != 0)
+				dev_err(blk->dev,
+					"Failed to register partition %d on %s (%d)\n",
+					i, blk->cdev.name, rc);
+			if (rc != -ENODEV)
+				rc = 0;
+		}
+	}
+
+	return rc;
+}
diff --git a/include/disks.h b/include/disks.h
index ec136d4..9932750 100644
--- a/include/disks.h
+++ b/include/disks.h
@@ -36,4 +36,6 @@ struct partition_entry {
 	uint32_t partition_size; /*! Start of the partition in LBA notation */
 } __attribute__ ((packed));
 
+extern int parse_partition_table(struct block_device*);
+
 #endif /* DISKS_H */
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 09/13] Use generic block layer to access the drives and do partition parsing
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (7 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 08/13] DISK: Add common partition handling for disk like media Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling Juergen Beisert
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

Change all relevant blockdevice users to the simplified interface.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig           |    2 +
 drivers/ata/disk_bios_drive.c |   97 +++++++++++++++++------------
 drivers/mci/Kconfig           |    1 -
 drivers/mci/mci-core.c        |  135 ++++++++++++++++++++++++-----------------
 drivers/usb/storage/Kconfig   |    1 +
 drivers/usb/storage/usb.c     |  124 ++++++++++++++++++++++----------------
 drivers/usb/storage/usb.h     |    8 +--
 include/mci.h                 |    3 +-
 8 files changed, 216 insertions(+), 155 deletions(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index f3b2939..a85958c 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -1,5 +1,7 @@
 menuconfig DISK
 	select BLOCK
+	select PARTITION
+	select PARTITION_DISK
 	bool "Disk support                  "
 	help
 	  Add support for disk like drives like harddisks, CDROMs, SD cards and
diff --git a/drivers/ata/disk_bios_drive.c b/drivers/ata/disk_bios_drive.c
index 6e2377c..28154dc 100644
--- a/drivers/ata/disk_bios_drive.c
+++ b/drivers/ata/disk_bios_drive.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
+ * Copyright (C) 2009...2011 Juergen Beisert, Pengutronix
  *
  * Mostly stolen from the GRUB2 project
  *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  Free Software Foundation, Inc.
@@ -43,15 +43,13 @@
  * Note: This driver does only support LBA addressing. Currently no CHS!
  */
 
-#include <stdio.h>
-#include <linux/types.h>
+#include <common.h>
 #include <init.h>
-#include <driver.h>
-#include <string.h>
-#include <xfuncs.h>
 #include <asm/syslib.h>
-#include <ata.h>
 #include <errno.h>
+#include <block.h>
+#include <disks.h>
+#include <malloc.h>
 
 /**
  * Sector count handled in one count
@@ -61,9 +59,6 @@
  */
 #define SECTORS_AT_ONCE 64
 
-/** Size of one sector in bytes */
-#define SECTOR_SIZE 512
-
 /** Command to read sectors from media */
 #define BIOS_READ_CMD 0
 
@@ -89,10 +84,13 @@ struct DAPS
  * Collection of data we need to know about the connected drive
  */
 struct media_access {
+	struct block_device blk; /**< the main device */
 	int drive_no;	/**< drive number used by the BIOS */
 	int is_cdrom;	/**< drive is a CDROM e.g. no write support */
 };
 
+#define to_media_access(x) container_of((x), struct media_access, blk)
+
 /**
  * Scratch memory for BIOS communication to handle data in chunks of 32 kiB
  *
@@ -146,19 +144,23 @@ static int biosdisk_bios_call(struct media_access *media, int cmd, uint64_t sect
 
 /**
  * Read a chunk of sectors from media
- * @param dev our data we need to do the access
- * @param sector_start Sector's LBA number to start read from
- * @param sector_count Sectors to read
+ * @param blk All info about the block device we need
  * @param buffer Buffer to read into
+ * @param block Sector's LBA number to start read from
+ * @param num_blocks Sector count to read
  * @return 0 on success, anything else on failure
  *
  * This routine expects the buffer has the correct size to store all data!
+ *
+ * @note Due to 'block' is of type 'int' only small disks can be handled!
  */
-static int biosdisk_read(struct device_d *dev, uint64_t sector_start, unsigned sector_count, void *buffer)
+static int biosdisk_read(struct block_device *blk, void *buffer, int block,
+				int num_blocks)
 {
 	int rc;
-	struct ata_interface *intf = dev->platform_data;
-	struct media_access *media = intf->priv;
+	uint64_t sector_start = block;
+	unsigned sector_count = num_blocks;
+	struct media_access *media = to_media_access(blk);
 
 	while (sector_count >= SECTORS_AT_ONCE) {
 		rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
@@ -182,19 +184,23 @@ static int biosdisk_read(struct device_d *dev, uint64_t sector_start, unsigned s
 
 /**
  * Write a chunk of sectors to media
- * @param dev our data we need to do the access
- * @param sector_start Sector's LBA number to start write to
- * @param sector_count Sectors to write
+ * @param blk All info about the block device we need
  * @param buffer Buffer to write from
+ * @param block Sector's LBA number to start write to
+ * @param num_blocks Sector count to write
  * @return 0 on success, anything else on failure
  *
  * This routine expects the buffer has the correct size to read all data!
+ *
+ * @note Due to 'block' is of type 'int' only small disks can be handled!
  */
-static int biosdisk_write(struct device_d *dev, uint64_t sector_start, unsigned sector_count, const void *buffer)
+static int __maybe_unused biosdisk_write(struct block_device *blk,
+				const void *buffer, int block, int num_blocks)
 {
 	int rc;
-	struct ata_interface *intf = dev->platform_data;
-	struct media_access *media = intf->priv;
+	uint64_t sector_start = block;
+	unsigned sector_count = num_blocks;
+	struct media_access *media = to_media_access(blk);
 
 	while (sector_count >= SECTORS_AT_ONCE) {
 		__builtin_memcpy(scratch_buffer, buffer, sizeof(scratch_buffer));
@@ -216,6 +222,13 @@ static int biosdisk_write(struct device_d *dev, uint64_t sector_start, unsigned
 	return rc;
 }
 
+static struct block_device_ops bios_ata = {
+	.read = biosdisk_read,
+#ifdef CONFIG_BLOCK_WRITE
+	.write = biosdisk_write,
+#endif
+};
+
 /**
  * Probe for connected drives and register them
  *
@@ -228,8 +241,6 @@ static int biosdisk_probe(struct device_d *dev)
 {
 	int drive, rc;
 	struct media_access media, *m;
-	struct device_d *drive_dev;
-	struct ata_interface *p;
 
 	for (drive = 0x80; drive < 0x90; drive++) {
 		media.drive_no = drive;
@@ -240,27 +251,31 @@ static int biosdisk_probe(struct device_d *dev)
 
 		printf("BIOSdrive %d seems valid. Registering...\n", media.drive_no);
 
-		drive_dev = xzalloc(sizeof(struct device_d) + sizeof(struct media_access) + sizeof(struct ata_interface));
-		if (drive_dev == NULL) {
-			dev_err(dev, "Out of memory\n");
-			return -1;
-		}
-		m = (struct media_access*)&drive_dev[1];
-		p = (struct ata_interface*)&m[1];
+		m = xzalloc(sizeof(struct media_access));
 
-		m->drive_no = drive;
-		m->is_cdrom = 0;
+		m->blk.dev = dev;
+		m->blk.ops = &bios_ata;
+		m->is_cdrom = 0;	/* don't know yet */
+		m->blk.num_blocks = 0;	/* we don't know the size of this disk! */
 
-		p->write = biosdisk_write;
-		p->read = biosdisk_read;
-		p->priv = m;
+		rc = cdev_find_free_number("disk");
+		if (rc == -1)
+			pr_err("Cannot find a free number for the disk node\n");
+		m->blk.cdev.name = asprintf("disk%d", rc);
+		m->blk.blockbits = SECTOR_SHIFT;
 
-		strcpy(drive_dev->name, "biosdisk");
-		drive_dev->id = drive - 0x80;
-		drive_dev->resource[0].start = 0;
-		drive_dev->platform_data = p;
+		rc = blockdevice_register(&m->blk);
+		if (rc != 0) {
+			dev_err(dev, "Cannot register BIOSdrive %d\n",
+						media.drive_no);
+			free(m);
+			return rc;
+		}
 
-		register_device(drive_dev);
+		/* create partitions on demand */
+		rc = parse_partition_table(&m->blk);
+		if (rc != 0)
+			dev_warn(dev, "No partition table found\n");
 	}
 
 	return 0;
diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index d24e606..6ec4527 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -1,7 +1,6 @@
 menuconfig MCI
 	bool "MCI drivers                   "
 	select DISK
-	select DISK_DRIVE
 	help
 	  Add support for MCI drivers, used to handle MMC and SD cards
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 138efcc..3347456 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -36,7 +36,8 @@
 #include <errno.h>
 #include <asm-generic/div64.h>
 #include <asm/byteorder.h>
-#include <ata.h>
+#include <block.h>
+#include <disks.h>
 
 #define MAX_BUFFER_NUMBER 0xffffffff
 
@@ -104,10 +105,10 @@ static void *sector_buf;
  * @param mci_dev MCI instance
  * @param src Where to read from to write to the card
  * @param blocknum Block number to write
+ * @param blocks Block count to write
  * @return Transaction status (0 on success)
  */
-#ifdef CONFIG_MCI_WRITE
-static int mci_block_write(struct device_d *mci_dev, const void *src, unsigned blocknum,
+static int mci_block_write(struct device_d *mci_dev, const void *src, int blocknum,
 	int blocks)
 {
 	struct mci *mci = GET_MCI_DATA(mci_dev);
@@ -154,7 +155,6 @@ static int mci_block_write(struct device_d *mci_dev, const void *src, unsigned b
 
 	return ret;
 }
-#endif
 
 /**
  * Read one block of data from the card
@@ -163,7 +163,7 @@ static int mci_block_write(struct device_d *mci_dev, const void *src, unsigned b
  * @param blocknum Block number to read
  * @param blocks number of blocks to read
  */
-static int mci_read_block(struct device_d *mci_dev, void *dst, unsigned blocknum,
+static int mci_read_block(struct device_d *mci_dev, void *dst, int blocknum,
 		int blocks)
 {
 	struct mci *mci = GET_MCI_DATA(mci_dev);
@@ -821,14 +821,14 @@ static int mci_startup(struct device_d *mci_dev)
 	mci_extract_card_capacity_from_csd(mci_dev);
 
 	/* sanitiy? */
-	if (mci->read_bl_len > 512) {
-		mci->read_bl_len = 512;
+	if (mci->read_bl_len > SECTOR_SIZE) {
+		mci->read_bl_len = SECTOR_SIZE;
 		pr_debug("Limiting max. read block size down to %u\n",
 				mci->read_bl_len);
 	}
 
-	if (mci->write_bl_len > 512) {
-		mci->write_bl_len = 512;
+	if (mci->write_bl_len > SECTOR_SIZE) {
+		mci->write_bl_len = SECTOR_SIZE;
 		pr_debug("Limiting max. write block size down to %u\n",
 				mci->read_bl_len);
 	}
@@ -957,73 +957,68 @@ static int sd_send_if_cond(struct device_d *mci_dev)
 	return 0;
 }
 
-/* ------------------ attach to the ATA API --------------------------- */
+/* ------------------ attach to the blocklayer --------------------------- */
 
 /**
  * Write a chunk of sectors to media
- * @param disk_dev Disk device instance
- * @param sector_start Sector's number to start write to
- * @param sector_count Sectors to write
+ * @param blk All info about the block device we need
  * @param buffer Buffer to write from
+ * @param block Sector's number to start write to
+ * @param num_blocks Sector count to write
  * @return 0 on success, anything else on failure
  *
  * This routine expects the buffer has the correct size to read all data!
  */
-#ifdef CONFIG_MCI_WRITE
-static int mci_sd_write(struct device_d *disk_dev, uint64_t sector_start,
-			unsigned sector_count, const void *buffer)
+static int __maybe_unused mci_sd_write(struct block_device *blk,
+				const void *buffer, int block, int num_blocks)
 {
-	struct ata_interface *intf = disk_dev->platform_data;
-	struct device_d *mci_dev = intf->priv;
+	struct device_d *mci_dev = blk->dev;
 	struct mci *mci = GET_MCI_DATA(mci_dev);
 	int rc;
 
-	pr_debug("%s: Write %u block(s), starting at %u\n",
-		__func__, sector_count, (unsigned)sector_start);
+	pr_debug("%s: Write %d block(s), starting at %d\n",
+		__func__, num_blocks, block);
 
-	if (mci->write_bl_len != 512) {
-		pr_debug("MMC/SD block size is not 512 bytes (its %u bytes instead)\n",
-				mci->read_bl_len);
+	if (mci->write_bl_len != SECTOR_SIZE) {
+		pr_debug("MMC/SD block size is not %d bytes (its %u bytes instead)\n",
+				SECTOR_SIZE, mci->read_bl_len);
 		return -EINVAL;
 	}
 
 	/* size of the block number field in the MMC/SD command is 32 bit only */
-	if (sector_start > MAX_BUFFER_NUMBER) {
-		pr_debug("Cannot handle block number %llu. Too large!\n",
-			sector_start);
+	if (block > MAX_BUFFER_NUMBER) {
+		pr_debug("Cannot handle block number %d. Too large!\n", block);
 		return -EINVAL;
 	}
 
-	rc = mci_block_write(mci_dev, buffer, sector_start, sector_count);
+	rc = mci_block_write(mci_dev, buffer, block, num_blocks);
 	if (rc != 0) {
-		pr_debug("Writing block %u failed with %d\n", (unsigned)sector_start, rc);
+		pr_debug("Writing block %d failed with %d\n", block, rc);
 		return rc;
 	}
 
 	return 0;
 }
-#endif
 
 /**
- * Read a chunk of sectors from media
- * @param disk_dev Disk device instance
- * @param sector_start Sector's number to start read from
- * @param sector_count Sectors to read
+ * Read a chunk of sectors from the drive
+ * @param blk All info about the block device we need
  * @param buffer Buffer to read into
+ * @param block Sector's LBA number to start read from
+ * @param num_blocks Sector count to read
  * @return 0 on success, anything else on failure
  *
  * This routine expects the buffer has the correct size to store all data!
  */
-static int mci_sd_read(struct device_d *disk_dev, uint64_t sector_start,
-			unsigned sector_count, void *buffer)
+static int mci_sd_read(struct block_device *blk, void *buffer, int block,
+				int num_blocks)
 {
-	struct ata_interface *intf = disk_dev->platform_data;
-	struct device_d *mci_dev = intf->priv;
+	struct device_d *mci_dev = blk->dev;
 	struct mci *mci = GET_MCI_DATA(mci_dev);
 	int rc;
 
-	pr_debug("%s: Read %u block(s), starting at %u\n",
-		__func__, sector_count, (unsigned)sector_start);
+	pr_debug("%s: Read %d block(s), starting at %d\n",
+		__func__, num_blocks, block);
 
 	if (mci->read_bl_len != 512) {
 		pr_debug("MMC/SD block size is not 512 bytes (its %u bytes instead)\n",
@@ -1031,15 +1026,14 @@ static int mci_sd_read(struct device_d *disk_dev, uint64_t sector_start,
 		return -EINVAL;
 	}
 
-	if (sector_start > MAX_BUFFER_NUMBER) {
-		pr_err("Cannot handle block number %u. Too large!\n",
-			(unsigned)sector_start);
+	if (block > MAX_BUFFER_NUMBER) {
+		pr_err("Cannot handle block number %d. Too large!\n", block);
 		return -EINVAL;
 	}
 
-	rc = mci_read_block(mci_dev, buffer, (unsigned)sector_start, sector_count);
+	rc = mci_read_block(mci_dev, buffer, block, num_blocks);
 	if (rc != 0) {
-		pr_debug("Reading block %u failed with %d\n", (unsigned)sector_start, rc);
+		pr_debug("Reading block %d failed with %d\n", block, rc);
 		return rc;
 	}
 
@@ -1178,6 +1172,25 @@ static int mci_check_if_already_initialized(struct device_d *mci_dev)
 	return 0;
 }
 
+static int mci_calc_blk_cnt(uint64_t cap, unsigned shift)
+{
+	unsigned ret = cap >> shift;
+
+	if (ret > 0x7fffffff) {
+		pr_warn("Limiting card size due to 31 bit contraints\n");
+		return 0x7fffffff;
+	}
+
+	return (int)ret;
+}
+
+static struct block_device_ops mci_ops = {
+	.read = mci_sd_read,
+#ifdef CONFIG_BLOCK_WRITE
+	.write = mci_sd_write,
+#endif
+};
+
 /**
  * Probe an MCI card at the given host interface
  * @param mci_dev MCI device instance
@@ -1187,9 +1200,7 @@ static int mci_card_probe(struct device_d *mci_dev)
 {
 	struct mci *mci = GET_MCI_DATA(mci_dev);
 	struct mci_host *host = GET_MCI_PDATA(mci_dev);
-	struct ata_interface *p;
 	int rc;
-	struct device_d *dev;
 
 	/* start with a host interface reset */
 	rc = (host->init)(host, mci_dev);
@@ -1233,16 +1244,29 @@ static int mci_card_probe(struct device_d *mci_dev)
 	 * An MMC/SD card acts like an ordinary disk.
 	 * So, re-use the disk driver to gain access to this media
 	 */
-	p = xzalloc(sizeof(struct ata_interface));
+	mci->blk.dev = mci_dev;
+	mci->blk.ops = &mci_ops;
 
-#ifdef CONFIG_MCI_WRITE
-	p->write = mci_sd_write;
-#endif
-	p->read = mci_sd_read;
-	p->priv = mci_dev;
+	rc = cdev_find_free_number("disk");
+	if (rc == -1)
+		pr_err("Cannot find a free number for the disk node\n");
+
+	mci->blk.cdev.name = asprintf("disk%d", rc);
+	mci->blk.blockbits = SECTOR_SHIFT;
+	mci->blk.num_blocks = mci_calc_blk_cnt(mci->capacity, mci->blk.blockbits);
+
+	rc = blockdevice_register(&mci->blk);
+	if (rc != 0) {
+		dev_err(mci_dev, "Failed to register MCI/SD blockdevice\n");
+		goto on_error;
+	}
 
-	dev = add_generic_device("disk", -1, NULL, 0, mci->capacity, IORESOURCE_MEM, p);
-	dev_add_child(&host->dev, dev);
+	/* create partitions on demand */
+	rc = parse_partition_table(&mci->blk);
+	if (rc != 0) {
+		dev_warn(mci_dev, "No partition table found\n");
+		rc = 0; /* it's not a failure */
+	}
 
 	pr_debug("SD Card successfully added\n");
 
@@ -1373,8 +1397,9 @@ device_initcall(mci_init);
  */
 int mci_register(struct mci_host *host)
 {
-	struct device_d *mci_dev = &host->dev;
+	struct device_d *mci_dev = xzalloc(sizeof(struct device_d));
 
+	mci_dev->id = -1;
 	strcpy(mci_dev->name, mci_driver.name);
 	mci_dev->platform_data = (void*)host;
 	dev_add_child(host->hw_dev, mci_dev);
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index f6c8c06..b80c039 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -1,2 +1,3 @@
 config USB_STORAGE
 	tristate "USB Mass Storage support"
+	select DISK
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 6dba8cc..b201b2b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -195,33 +195,32 @@ static int usb_stor_write_10(ccb *srb, struct us_data *us,
 
 #define US_MAX_IO_BLK 32
 
+#define to_usb_mass_storage(x) container_of((x), struct us_blk_dev, blk)
+
 enum { io_rd, io_wr };
 
 /* Read / write a chunk of sectors on media */
-static int usb_stor_blk_io(int io_op, struct device_d *disk_dev,
-                           uint64_t sector_start, unsigned sector_count,
-                           void *buffer)
+static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
+			int sector_start, int sector_count, void *buffer)
 {
-	struct ata_interface *pata_if = disk_dev->platform_data;
-	struct us_blk_dev *pblk_dev = (struct us_blk_dev *)pata_if->priv;
+	struct us_blk_dev *pblk_dev = to_usb_mass_storage(disk_dev);
 	struct us_data *us = pblk_dev->us;
 	ccb us_ccb;
-	ushort const sector_size = 512;
 	unsigned sectors_done;
 
 	if (sector_count == 0)
 		return 0;
 
 	/* check for unsupported block size */
-	if (pblk_dev->blksz != sector_size) {
-		US_DEBUGP("%s: unsupported block size %lu\n",
-		          __func__, pblk_dev->blksz);
+	if (pblk_dev->blk.blockbits != SECTOR_SHIFT) {
+		US_DEBUGP("%s: unsupported block shift %d\n",
+		          __func__, pblk_dev->blk.blockbits);
 		return -EINVAL;
 	}
 
 	/* check for invalid sector_start */
-	if (sector_start >= pblk_dev->blknum || sector_start > (ulong)-1) {
-		US_DEBUGP("%s: start sector %llu too large\n",
+	if (sector_start >= pblk_dev->blk.num_blocks || sector_start > (ulong)-1) {
+		US_DEBUGP("%s: start sector %d too large\n",
 		          __func__, sector_start);
 		return -EINVAL;
 	}
@@ -242,21 +241,21 @@ static int usb_stor_blk_io(int io_op, struct device_d *disk_dev,
 		sector_count = INT_MAX;
 		US_DEBUGP("Restricting I/O to %u blocks\n", sector_count);
 	}
-	if (sector_start + sector_count > pblk_dev->blknum) {
-		sector_count = pblk_dev->blknum - sector_start;
+	if (sector_start + sector_count > pblk_dev->blk.num_blocks) {
+		sector_count = pblk_dev->blk.num_blocks - sector_start;
 		US_DEBUGP("Restricting I/O to %u blocks\n", sector_count);
 	}
 
 	/* read / write the requested data */
-	US_DEBUGP("%s %u block(s), starting from %llu\n",
+	US_DEBUGP("%s %u block(s), starting from %d\n",
 	          ((io_op == io_rd) ? "Read" : "Write"),
 	          sector_count, sector_start);
 	sectors_done = 0;
 	while (sector_count > 0) {
 		int result;
-		ushort n = (ushort)min(sector_count, US_MAX_IO_BLK);
-		us_ccb.pdata = buffer + sectors_done * sector_size;
-		us_ccb.datalen = n * (ulong)sector_size;
+		unsigned n = min(sector_count, US_MAX_IO_BLK);
+		us_ccb.pdata = buffer + (sectors_done * SECTOR_SIZE);
+		us_ccb.datalen = n * SECTOR_SIZE;
 		if (io_op == io_rd)
 			result = usb_stor_read_10(&us_ccb, us,
 			                          (ulong)sector_start, n);
@@ -264,7 +263,7 @@ static int usb_stor_blk_io(int io_op, struct device_d *disk_dev,
 			result = usb_stor_write_10(&us_ccb, us,
 			                           (ulong)sector_start, n);
 		if (result != 0) {
-			US_DEBUGP("I/O error at sector %llu\n", sector_start);
+			US_DEBUGP("I/O error at sector %d\n", sector_start);
 			break;
 		}
 		sector_start += n;
@@ -274,27 +273,31 @@ static int usb_stor_blk_io(int io_op, struct device_d *disk_dev,
 
 	usb_disable_asynch(0);
 
-	US_DEBUGP("Successful I/O of %u blocks\n", sectors_done);
+	US_DEBUGP("Successful I/O of %d blocks\n", sectors_done);
 
 	return (sector_count != 0) ? -EIO : 0;
 }
 
 /* Write a chunk of sectors to media */
-static int usb_stor_blk_write(struct device_d *disk_dev, uint64_t sector_start,
-                              unsigned sector_count, const void *buffer)
+static int __maybe_unused usb_stor_blk_write(struct block_device *blk,
+				const void *buffer, int block, int num_blocks)
 {
-	return usb_stor_blk_io(io_wr, disk_dev, sector_start, sector_count,
-	                       (void *)buffer);
+	return usb_stor_blk_io(io_wr, blk, block, num_blocks, (void *)buffer);
 }
 
 /* Read a chunk of sectors from media */
-static int usb_stor_blk_read(struct device_d *disk_dev, uint64_t sector_start,
-                             unsigned sector_count, void *buffer)
+static int usb_stor_blk_read(struct block_device *blk, void *buffer, int block,
+				int num_blocks)
 {
-	return usb_stor_blk_io(io_rd, disk_dev, sector_start, sector_count,
-	                       buffer);
+	return usb_stor_blk_io(io_rd, blk, block, num_blocks, buffer);
 }
 
+static struct block_device_ops usb_mass_storage_ops = {
+	.read = usb_stor_blk_read,
+#ifdef CONFIG_BLOCK_WRITE
+	.write = usb_stor_blk_write,
+#endif
+};
 
 /***********************************************************************
  * Block device routines
@@ -302,6 +305,16 @@ static int usb_stor_blk_read(struct device_d *disk_dev, uint64_t sector_start,
 
 static unsigned char us_io_buf[512];
 
+static int usb_limit_blk_cnt(unsigned cnt)
+{
+	if (cnt > 0x7fffffff) {
+		pr_warn("Limiting device size due to 31 bit contraints\n");
+		return 0x7fffffff;
+	}
+
+	return (int)cnt;
+}
+
 /* Prepare a disk device */
 static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 {
@@ -313,7 +326,7 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	us_ccb.pdata = us_io_buf;
 	us_ccb.lun = pblk_dev->lun;
 
-	pblk_dev->blknum = 0;
+	pblk_dev->blk.num_blocks = 0;
 	usb_disable_asynch(1);
 
 	/* get device info */
@@ -350,11 +363,12 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
 	}
 	pcap = (unsigned long *)us_ccb.pdata;
 	US_DEBUGP("Read Capacity returns: 0x%lx, 0x%lx\n", pcap[0], pcap[1]);
-	pblk_dev->blknum = be32_to_cpu(pcap[0]);
-	pblk_dev->blksz = be32_to_cpu(pcap[1]);
-	pblk_dev->blknum++;
-	US_DEBUGP("Capacity = 0x%llx, blocksz = 0x%lx\n",
-	          pblk_dev->blknum, pblk_dev->blksz);
+	pblk_dev->blk.num_blocks = usb_limit_blk_cnt(be32_to_cpu(pcap[0]) + 1);
+	if (be32_to_cpu(pcap[1]) != SECTOR_SIZE)
+		pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
+	pblk_dev->blk.blockbits = SECTOR_SHIFT;
+	US_DEBUGP("Capacity = 0x%x, blockshift = 0x%x\n",
+	          pblk_dev->blk.num_blocks, pblk_dev->blk.blockbits);
 
 Exit:
 	usb_disable_asynch(0);
@@ -362,39 +376,45 @@ Exit:
 }
 
 /* Create and register a disk device for the specified LUN */
-static int usb_stor_add_blkdev(struct us_data *us, unsigned char lun)
+static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
+							unsigned char lun)
 {
 	struct us_blk_dev *pblk_dev;
-	struct device_d *pdev;
-	struct ata_interface *pata_if;
 	int result;
 
-	/* allocate blk dev data */
-	pblk_dev = (struct us_blk_dev *)malloc(sizeof(struct us_blk_dev));
-	if (!pblk_dev)
-		return -ENOMEM;
-	memset(pblk_dev, 0, sizeof(struct us_blk_dev));
+	/* allocate a new USB block device */
+	pblk_dev = xzalloc(sizeof(struct us_blk_dev));
 
 	/* initialize blk dev data */
+	pblk_dev->blk.dev = dev;
+	pblk_dev->blk.ops = &usb_mass_storage_ops;
 	pblk_dev->us = us;
 	pblk_dev->lun = lun;
-	pata_if = &pblk_dev->ata_if;
-	pata_if->read = &usb_stor_blk_read;
-	pata_if->write = &usb_stor_blk_write;
-	pata_if->priv = pblk_dev;
-	pdev = &pblk_dev->dev;
-	strcpy(pdev->name, "disk");
-	pdev->platform_data = pata_if;
 
 	/* read some info and get the unit ready */
 	result = usb_stor_init_blkdev(pblk_dev);
 	if (result < 0)
 		goto BadDevice;
 
-	/* register disk device */
-	result = register_device(pdev);
-	if (result < 0)
+	result = cdev_find_free_number("disk");
+	if (result == -1)
+		pr_err("Cannot find a free number for the disk node\n");
+	pr_info("Using index %d for the new disk\n", result);
+
+	pblk_dev->blk.cdev.name = asprintf("disk%d", result);
+	pblk_dev->blk.blockbits = SECTOR_SHIFT;
+
+	result = blockdevice_register(&pblk_dev->blk);
+	if (result != 0) {
+		dev_err(dev, "Failed to register blockdevice\n");
 		goto BadDevice;
+	}
+
+	/* create partitions on demand */
+	result = parse_partition_table(&pblk_dev->blk);
+	if (result != 0)
+		dev_warn(dev, "No partition table found\n");
+
 	list_add_tail(&pblk_dev->list, &us_blkdev_list);
 	US_DEBUGP("USB disk device successfully added\n");
 
@@ -485,7 +505,7 @@ static int usb_stor_scan(struct usb_device *usbdev, struct us_data *us)
 
 	/* register a disk device for each active LUN */
 	for (lun=0; lun<=us->max_lun; lun++) {
-		if (usb_stor_add_blkdev(us, lun) == 0)
+		if (usb_stor_add_blkdev(us, &usbdev->dev, lun) == 0)
 			num_devs++;
 	}
 
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 17a1e12..5942393 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -26,7 +26,8 @@
 #define _STORAGE_USB_H_
 
 #include <usb/usb.h>
-#include <ata.h>
+#include <block.h>
+#include <disks.h>
 #include <scsi.h>
 #include <linux/list.h>
 
@@ -85,10 +86,7 @@ struct us_data {
 /* one us_blk_dev object allocated per LUN */
 struct us_blk_dev {
 	struct us_data		*us;		/* LUN's enclosing dev */
-	struct device_d		dev;		/* intf to generic driver */
-	struct ata_interface	ata_if;		/* intf to "disk" driver */
-	uint64_t		blknum;		/* capacity */
-	unsigned long		blksz;		/* block size */
+	struct block_device	blk;		/* the blockdevice for the dev */
 	unsigned char 		lun;		/* the LUN of this blk dev */
 	struct list_head	list;		/* siblings */
 };
diff --git a/include/mci.h b/include/mci.h
index 69cffe8..2375581 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -31,6 +31,7 @@
 #define _MCI_H_
 
 #include <linux/list.h>
+#include <block.h>
 
 /* Firmware revisions for SD cards */
 #define SD_VERSION_SD		0x20000
@@ -194,7 +195,6 @@ struct mci_data {
 /** host information */
 struct mci_host {
 	struct device_d *hw_dev;	/**< the host MCI hardware device */
-	struct device_d dev;		/**< our device */
 	unsigned voltages;
 	unsigned host_caps;	/**< Host's interface capabilities, refer MMC_VDD_* */
 	unsigned f_min;		/**< host interface lower limit */
@@ -212,6 +212,7 @@ struct mci_host {
 
 /** MMC/SD and interface instance information */
 struct mci {
+	struct block_device blk;	/**< the blockdevice for the card */
 	unsigned version;
 	/** != 0 when a high capacity card is connected (OCR -> OCR_HCS) */
 	int high_capacity;
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (8 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 09/13] Use generic block layer to access the drives and do partition parsing Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 11/13] ATA/DISK: Remove the now unused header <ata.h> Juergen Beisert
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig      |    8 --
 drivers/ata/Makefile     |    1 -
 drivers/ata/disk_drive.c |  247 ----------------------------------------------
 3 files changed, 0 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/ata/disk_drive.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index a85958c..86b5673 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -15,16 +15,8 @@ config DISK_WRITE
 
 comment "drive types"
 
-config DISK_DRIVE
-	bool "Generic disk drives"
-	help
-	  Add support for generic disk drives. Common behaviour for this kind
-	  of devices is using a partition table in the first sector. Say Y here
-	  if you intend to work with disk drives (also CF cards and SD cards).
-
 config DISK_BIOS
 	bool "BIOS based"
-	select DISK_DRIVE
 	depends on X86_BIOS_BRINGUP
 	help
 	  Gain disk drive access via int13 calls to the standard PC-BIOS.
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 10f3957..e2b41b7 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,6 +1,5 @@
 # drive types
 
-obj-$(CONFIG_DISK_DRIVE) += disk_drive.o
 obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
 
 # interface types
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
deleted file mode 100644
index c5c1ee9..0000000
--- a/drivers/ata/disk_drive.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
- *
- * 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.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-/**
- * @file
- * @brief Generic disk drive support
- *
- * @todo Support for disks larger than 4 GiB
- * @todo Reliable size detection for BIOS based disks (on x86 only)
- */
-
-#include <stdio.h>
-#include <init.h>
-#include <driver.h>
-#include <types.h>
-#include <ata.h>
-#include <xfuncs.h>
-#include <errno.h>
-#include <string.h>
-#include <linux/kernel.h>
-#include <malloc.h>
-#include <common.h>
-#include <block.h>
-#include <asm/unaligned.h>
-
-/**
- * Description of one partition table entry (D*S type)
- */
-struct partition_entry {
-	uint8_t boot_indicator;
-	uint8_t chs_begin[3];
-	uint8_t type;
-	uint8_t chs_end[3];
-	uint32_t partition_start;
-	uint32_t partition_size;
-} __attribute__ ((packed));
-
-/** one for all */
-#define SECTOR_SIZE 512
-
-/**
- * Guess the size of the disk, based on the partition table entries
- * @param dev device to create partitions for
- * @param table partition table
- * @return size in sectors
- */
-#ifdef CONFIG_DISK_BIOS
-static unsigned long disk_guess_size(struct device_d *dev, struct partition_entry *table)
-{
-	int part_order[4] = {0, 1, 2, 3};
-	unsigned long size = 0;
-	int i;
-
-	/* TODO order the partitions */
-
-	for (i = 0; i < 4; i++) {
-		if (table[part_order[i]].partition_start != 0) {
-			size += table[part_order[i]].partition_start - size; /* the gap */
-			size += table[part_order[i]].partition_size;
-		}
-	}
-#if 1
-/* limit disk sizes we can't handle due to 32 bit limits */
-	if (size > 0x7fffff) {
-		dev_warn(dev, "Warning: Size limited due to 32 bit contraints\n");
-		size = 0x7fffff;
-	}
-#endif
-	return size;
-}
-#endif
-
-/**
- * Register partitions found on the drive
- * @param dev device to create partitions for
- * @param table partition table
- * @return 0 on success
- */
-static int disk_register_partitions(struct device_d *dev, struct partition_entry *table)
-{
-	int part_order[4] = {0, 1, 2, 3};
-	int i, rc;
-	char drive_name[16], partition_name[19];
-	u32 partition_start, partition_size;
-
-	/* TODO order the partitions */
-
-	for (i = 0; i < 4; i++) {
-		partition_start = get_unaligned(&table[part_order[i]].partition_start);
-		partition_size  = get_unaligned(&table[part_order[i]].partition_size);
-
-		sprintf(drive_name, "%s%d", dev->name, dev->id);
-		sprintf(partition_name, "%s%d.%d", dev->name, dev->id, i);
-		if (partition_start != 0) {
-#if 1
-/* ignore partitions we can't handle due to 32 bit limits */
-			if (partition_start > 0x7fffff)
-				continue;
-			if (partition_size > 0x7fffff)
-				continue;
-#endif
-			dev_dbg(dev, "Registering partition %s to drive %s\n",
-				partition_name, drive_name);
-			rc = devfs_add_partition(drive_name,
-				partition_start * SECTOR_SIZE,
-				partition_size * SECTOR_SIZE,
-				DEVFS_PARTITION_FIXED, partition_name);
-			if (rc != 0)
-				dev_err(dev, "Failed to register partition %s (%d)\n", partition_name, rc);
-		}
-	}
-
-	return 0;
-}
-
-struct ata_block_device {
-	struct block_device blk;
-	struct device_d *dev;
-	struct ata_interface *intf;
-};
-
-static int atablk_read(struct block_device *blk, void *buf, int block,
-		int num_blocks)
-{
-	struct ata_block_device *atablk = container_of(blk, struct ata_block_device, blk);
-
-	return atablk->intf->read(atablk->dev, block, num_blocks, buf);
-}
-
-#ifdef CONFIG_DISK_WRITE
-static int atablk_write(struct block_device *blk, const void *buf, int block,
-		int num_blocks)
-{
-	struct ata_block_device *atablk = container_of(blk, struct ata_block_device, blk);
-
-	return atablk->intf->write(atablk->dev, block, num_blocks, buf);
-}
-#endif
-
-static struct block_device_ops ataops = {
-	.read = atablk_read,
-#ifdef CONFIG_DISK_WRITE
-	.write = atablk_write,
-#endif
-};
-
-/**
- * Probe the connected disk drive
- */
-static int disk_probe(struct device_d *dev)
-{
-	uint8_t *sector;
-	int rc;
-	struct ata_interface *intf = dev->platform_data;
-	struct ata_block_device *atablk = xzalloc(sizeof(*atablk));
-
-	sector = xmalloc(SECTOR_SIZE);
-
-	rc = intf->read(dev, 0, 1, sector);
-	if (rc != 0) {
-		dev_err(dev, "Cannot read MBR of this device\n");
-		rc = -ENODEV;
-		goto on_error;
-	}
-
-	/*
-	 * BIOS based disks needs special handling. Not the driver can
-	 * enumerate the hardware, the BIOS did it already. To show the user
-	 * the drive ordering must not correspond to the Linux drive order,
-	 * use the 'biosdisk' name instead.
-	 */
-#ifdef CONFIG_DISK_BIOS
-	if (strcmp(dev->driver->name, "biosdisk") == 0)
-		atablk->blk.cdev.name = asprintf("biosdisk%d", dev->id);
-	else
-#endif
-		atablk->blk.cdev.name = asprintf("disk%d", dev->id);
-
-#ifdef CONFIG_DISK_BIOS
-	/* On x86, BIOS based disks are coming without a valid .size field */
-	if (dev->resource[0].size == 0) {
-		/* guess the size of this drive if not otherwise given */
-		dev->resource[0].size = disk_guess_size(dev,
-			(struct partition_entry*)&sector[446]) * SECTOR_SIZE;
-		dev_info(dev, "Drive size guessed to %u kiB\n", dev->resource[0].size / 1024);
-	}
-#endif
-	atablk->blk.num_blocks = dev->resource[0].size / SECTOR_SIZE;
-	atablk->blk.ops = &ataops;
-	atablk->blk.blockbits = 9;
-	atablk->dev = dev;
-	atablk->intf = intf;
-	blockdevice_register(&atablk->blk);
-
-	if ((sector[510] != 0x55) || (sector[511] != 0xAA)) {
-		dev_info(dev, "No partition table found\n");
-		rc = 0;
-		goto on_error;
-	}
-
-
-	rc = disk_register_partitions(dev, (struct partition_entry*)&sector[446]);
-
-on_error:
-	free(sector);
-	return rc;
-}
-
-#ifdef CONFIG_DISK_BIOS
-static struct driver_d biosdisk_driver = {
-        .name   = "biosdisk",
-        .probe  = disk_probe,
-};
-#endif
-
-static struct driver_d disk_driver = {
-        .name   = "disk",
-        .probe  = disk_probe,
-};
-
-static int disk_init(void)
-{
-#ifdef CONFIG_DISK_BIOS
-	register_driver(&biosdisk_driver);
-#endif
-	register_driver(&disk_driver);
-	return 0;
-}
-
-device_initcall(disk_init);
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 11/13] ATA/DISK: Remove the now unused header <ata.h>
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (9 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 12/13] ATA Disk Support: Add support for native ATA type drives Juergen Beisert
  2011-11-22  8:29 ` [PATCH 13/13] Add driver for IDE like interfaces Juergen Beisert
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

This file is obsolete now.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 include/ata.h |   39 ---------------------------------------
 1 files changed, 0 insertions(+), 39 deletions(-)
 delete mode 100644 include/ata.h

diff --git a/include/ata.h b/include/ata.h
deleted file mode 100644
index d56399e..0000000
--- a/include/ata.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
- *
- * 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.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-/**
- * @file
- * @brief Declarations to communicate with ATA types of drives
- */
-
-#include <types.h>
-#include <driver.h>
-
-/**
- * Access functions from drives through the specified interface
- */
-struct ata_interface {
-	/** write a count of sectors from a buffer to the drive */
-	int (*write)(struct device_d*, uint64_t, unsigned, const void*);
-	/** read a count of sectors from the drive into the buffer */
-	int (*read)(struct device_d*, uint64_t, unsigned, void*);
-	/** private interface data */
-	void *priv;
-};
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 12/13] ATA Disk Support: Add support for native ATA type drives
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (10 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 11/13] ATA/DISK: Remove the now unused header <ata.h> Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  2011-11-22  8:29 ` [PATCH 13/13] Add driver for IDE like interfaces Juergen Beisert
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig          |   12 +
 drivers/ata/Makefile         |    1 +
 drivers/ata/disk_ata_drive.c |  631 ++++++++++++++++++++++++++++++++++++++++++
 include/ata_drive.h          |  194 +++++++++++++
 4 files changed, 838 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/disk_ata_drive.c
 create mode 100644 include/ata_drive.h

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 86b5673..0a15863 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -24,6 +24,18 @@ config DISK_BIOS
 	  media to work on. Disadvantage is: Due to its 16 bit nature it is
 	  slow.
 
+config DISK_ATA
+	bool "ATA type drives"
+	select DISK_DRIVE
+	help
+	  Support for native ATA/IDE drives
+
+config DISK_LE_ATTACHED
+	bool "little endianess attachment"
+	depends on DISK_ATA
+	help
+	  How the drive's data port (16 bit) is connected to the CPU: LE or BE
+
 comment "interface types"
 
 endif
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index e2b41b7..cdbcbe7 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,6 +1,7 @@
 # drive types
 
 obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
+obj-$(CONFIG_DISK_ATA) += disk_ata_drive.o
 
 # interface types
 
diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
new file mode 100644
index 0000000..cd0dabe
--- /dev/null
+++ b/drivers/ata/disk_ata_drive.c
@@ -0,0 +1,631 @@
+/*
+ * Copyright (C) 2011 Juergen Beisert, Pengutronix
+ *
+ * Inspired from various soures like http://wiki.osdev.org/ATA_PIO_Mode,
+ * u-boot and the linux kernel
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <xfuncs.h>
+#include <io.h>
+#include <malloc.h>
+#include <errno.h>
+#include <block.h>
+#include <ata_drive.h>
+#include <disks.h>
+
+#define ATA_CMD_ID_DEVICE 0xEC
+#define ATA_CMD_RD_CONF 0x40
+#define ATA_CMD_RD	0x20
+#define ATA_CMD_WR	0x30
+
+#define DISK_MASTER 0
+#define DISK_SLAVE 1
+
+#define MAX_TIMEOUT 30000
+
+/**
+ * Collection of data we need to know about this drive
+ */
+struct ata_drive_access {
+	struct block_device blk; /**< the main device */
+	struct ata_ioports *io;	/**< register file */
+	uint16_t id[(SECTOR_SIZE / sizeof(uint16_t))];
+};
+
+#define to_ata_drive_access(x) container_of((x), struct ata_drive_access, blk)
+
+#define ata_id_u32(id,n)        \
+        (((uint32_t) (id)[(n) + 1] << 16) | ((uint32_t) (id)[(n)]))
+#define ata_id_u64(id,n)        \
+        ( ((uint64_t) (id)[(n) + 3] << 48) | \
+          ((uint64_t) (id)[(n) + 2] << 32) | \
+          ((uint64_t) (id)[(n) + 1] << 16) | \
+          ((uint64_t) (id)[(n) + 0]) )
+
+#define ata_id_has_lba(id)               ((id)[49] & (1 << 9))
+
+#define ATA_ID_LBA48_SECTORS 100
+#define ATA_ID_LBA_SECTORS 60
+
+static uint16_t ata_rd_word(struct ata_ioports *io)
+{
+#ifdef CONFIG_DISK_LE_ATTACHED
+	return le16_to_cpu(readw(io->data_addr));
+#else
+	return be16_to_cpu(readw(io->data_addr));
+#endif
+}
+static void ata_wr_word(struct ata_ioports *io, uint16_t w)
+{
+#ifdef CONFIG_DISK_LE_ATTACHED
+	writew(cpu_to_le16(w), io->data_addr);
+#else
+	writew(cpu_to_be16(w), io->data_addr);
+#endif
+}
+
+static inline int ata_id_has_lba48(const uint16_t *id)
+{
+	if ((id[83] & 0xC000) != 0x4000)
+		return 0;
+	if (!ata_id_u64(id, 100))
+		return 0;
+	return id[83] & (1 << 10);
+}
+
+static uint64_t ata_id_n_sectors(uint16_t *id)
+{
+	if (ata_id_has_lba(id)) {
+		if (ata_id_has_lba48(id))
+			return ata_id_u64(id, ATA_ID_LBA48_SECTORS);
+		else
+			return ata_id_u32(id, ATA_ID_LBA_SECTORS);
+	}
+
+	return 0;
+}
+
+static void ata_id_string(const uint16_t *id, unsigned char *s,
+				unsigned ofs, unsigned len)
+{
+	unsigned c;
+
+	while (len > 0) {
+		c = id[ofs] >> 8;
+		*s = c;
+		s++;
+
+		c = id[ofs] & 0xff;
+		*s = c;
+		s++;
+
+		ofs++;
+		len -= 2;
+	}
+}
+
+static void ata_id_c_string(const uint16_t *id, unsigned char *s,
+				unsigned ofs, unsigned len)
+{
+	unsigned char *p;
+
+	ata_id_string(id, s, ofs, len - 1);
+
+	p = s + strnlen((char *)s, len - 1);
+	while (p > s && p[-1] == ' ')
+		p--;
+	*p = '\0';
+}
+
+#define ATA_ID_SERNO 10
+#define ATA_ID_SERNO_LEN 20
+#define ATA_ID_FW_REV 23
+#define ATA_ID_FW_REV_LEN 8
+#define ATA_ID_PROD 27
+#define ATA_ID_PROD_LEN 40
+
+static void __maybe_unused ata_dump_id(uint16_t *id)
+{
+	unsigned char serial[ATA_ID_SERNO_LEN + 1];
+	unsigned char firmware[ATA_ID_FW_REV_LEN + 1];
+	unsigned char product[ATA_ID_PROD_LEN + 1];
+	uint64_t n_sectors;
+
+	/* Serial number */
+	ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
+	printf("S/N: %s\n\r", serial);
+
+	/* Firmware version */
+	ata_id_c_string(id, firmware, ATA_ID_FW_REV, sizeof(firmware));
+	printf("Firmware version: %s\n\r", firmware);
+
+	/* Product model */
+	ata_id_c_string(id, product, ATA_ID_PROD, sizeof(product));
+	printf("Product model number: %s\n\r", product);
+
+	/* Total sectors of device  */
+	n_sectors = ata_id_n_sectors(id);
+	printf("Capablity: %lld sectors\n\r", n_sectors);
+
+	printf ("id[49]: capabilities = 0x%04x\n"
+		"id[53]: field valid = 0x%04x\n"
+		"id[63]: mwdma = 0x%04x\n"
+		"id[64]: pio = 0x%04x\n"
+		"id[75]: queue depth = 0x%04x\n",
+		id[49],
+		id[53],
+		id[63],
+		id[64],
+		id[75]);
+
+	printf ("id[76]: sata capablity = 0x%04x\n"
+		"id[78]: sata features supported = 0x%04x\n"
+		"id[79]: sata features enable = 0x%04x\n",
+		id[76],
+		id[78],
+		id[79]);
+
+	printf ("id[80]: major version = 0x%04x\n"
+		"id[81]: minor version = 0x%04x\n"
+		"id[82]: command set supported 1 = 0x%04x\n"
+		"id[83]: command set supported 2 = 0x%04x\n"
+		"id[84]: command set extension = 0x%04x\n",
+		id[80],
+		id[81],
+		id[82],
+		id[83],
+		id[84]);
+	printf ("id[85]: command set enable 1 = 0x%04x\n"
+		"id[86]: command set enable 2 = 0x%04x\n"
+		"id[87]: command set default = 0x%04x\n"
+		"id[88]: udma = 0x%04x\n"
+		"id[93]: hardware reset result = 0x%04x\n",
+		id[85],
+		id[86],
+		id[87],
+		id[88],
+		id[93]);
+}
+
+/**
+ * Swap little endian data on demand
+ * @param buf Buffer with little endian word data
+ * @param wds 16 bit word count
+ *
+ * ATA disks report their ID data in little endian notation on a 16 bit word
+ * base. So swap the buffer content if the running CPU differs in their
+ * endiaeness.
+ */
+static void ata_fix_endianess(uint16_t *buf, unsigned wds)
+{
+#if __BYTE_ORDER == __BIG_ENDIAN
+	unsigned u;
+
+	for (u = 0; u < wds; u++)
+		buf[u] = le16_to_cpu(buf[u]);
+#endif
+}
+
+/**
+ * Read the status register of the ATA drive
+ * @param io Register file
+ * @return Register's content
+ */
+static uint8_t ata_rd_status(struct ata_ioports *io)
+{
+	return readb(io->status_addr);
+}
+
+#define ATA_STATUS_BUSY (1 << 7)
+#define ATA_STATUS_READY (1 << 6)
+#define ATA_STATUS_WR_FLT (1 << 5)
+#define ATA_STATUS_DRQ (1 << 4)
+#define ATA_STATUS_CORR (1 << 3)
+#define ATA_STATUS_ERROR (1 << 1)
+
+/**
+ * Wait until the disk is busy or time out
+ * @param io Register file
+ * @param timeout Timeout in [ms]
+ * @return 0 on success, -ETIMEDOUT else
+ */
+static int ata_wait_busy(struct ata_ioports *io, unsigned timeout)
+{
+	uint8_t status;
+
+	timeout *= 100;
+
+	while (timeout) {
+		status = ata_rd_status(io);
+		if (status & ATA_STATUS_BUSY)
+			break;
+		udelay(10);
+		timeout -= 10;
+	};
+
+	if (timeout) {
+		pr_debug("%s: Finished with %u us remaining\n", __func__, timeout);
+		return 0;
+	}
+
+	pr_debug("%s: Waiting timed out!\n", __func__);
+	return -ETIMEDOUT;
+}
+
+/**
+ * Wait until the disk is ready again or time out
+ * @param io Register file
+ * @param timeout Timeout in [ms]
+ * @return 0 on success, -ETIMEDOUT else
+ *
+ * This function is useful to check if the disk has accepted a command.
+ */
+static int ata_wait_ready(struct ata_ioports *io, unsigned timeout)
+{
+	uint8_t status;
+
+	timeout *= 100;
+
+	while (timeout) {
+		status = ata_rd_status(io);
+		if (!(status & ATA_STATUS_BUSY)) {
+			if (status & ATA_STATUS_READY)
+				break;
+		}
+		udelay(10);
+		timeout -= 10;
+	};
+
+	if (timeout) {
+		pr_debug("%s: Finished with %u us remaining\n", __func__, timeout);
+		return 0;
+	}
+
+	pr_debug("%s: Waiting timed out!\n", __func__);
+	return -ETIMEDOUT;
+}
+
+#define LBA_FLAG (1 << 6)
+
+/**
+ * Setup the sector number in LBA notation (LBA28)
+ * @param io Register file
+ * @param drive 0 master drive, 1 slave drive
+ * @param num Sector number
+ *
+ * @todo LBA48 support
+ */
+static int ata_set_lba_sector(struct ata_ioports *io, unsigned drive, uint64_t num)
+{
+	pr_debug("%s: Drive: %d, Sector: %llu\n", __func__, drive, num);
+
+	if (num > 0x0FFFFFFF || drive > 1)
+		return -EINVAL;
+
+	writeb(0xA0 | LBA_FLAG | drive << 4 | num >> 24, io->device_addr);
+	writeb(0x00, io->error_addr);
+	writeb(0x01, io->nsect_addr);
+	writeb(num, io->lbal_addr);	/* 0 ... 7 */
+	writeb(num >> 8, io->lbam_addr); /* 8 ... 15 */
+	writeb(num >> 16, io->lbah_addr); /* 16 ... 23 */
+
+	return 0;
+}
+
+/**
+ * Write an ATA command into the disk
+ * @param io Register file
+ * @param cmd Command to write
+ * @return 0 on success
+ */
+static int ata_wr_cmd(struct ata_ioports *io, uint8_t cmd)
+{
+	int rc;
+
+	rc = ata_wait_ready(io, MAX_TIMEOUT);
+	if (rc != 0)
+		return rc;
+
+	writeb(cmd, io->command_addr);
+	return 0;
+}
+
+#define ATA_DEVCTL_SOFT_RESET (1 << 2)
+#define ATA_DEVCTL_INTR_DISABLE (1 << 1)
+
+/**
+ * Write a new value into the "device control register"
+ * @param io Register file
+ * @param val Value to write
+ */
+static void ata_wr_dev_ctrl(struct ata_ioports *io, uint8_t val)
+{
+	writeb(val, io->ctl_addr);
+}
+
+/**
+ * Read one sector from the drive (always SECTOR_SIZE bytes at once)
+ * @param io Register file
+ * @param buf Buffer to read the data into
+ */
+static void ata_rd_sector(struct ata_ioports *io, void *buf)
+{
+	unsigned u = SECTOR_SIZE / sizeof(uint16_t);
+	uint16_t *b = buf;
+
+	for (; u > 0; u--)
+		*b++ = ata_rd_word(io);
+}
+
+/**
+ * Write one sector into the drive
+ * @param io Register file
+ * @param buf Buffer to read the data from
+ */
+static void ata_wr_sector(struct ata_ioports *io, const void *buf)
+{
+	unsigned u = SECTOR_SIZE / sizeof(uint16_t);
+	const uint16_t *b = buf;
+
+	for (; u > 0; u--)
+		ata_wr_word(io, *b++);
+}
+
+/**
+ * Read the capacity of the attached drive
+ * @param l Result of the ATA_CMD_ID command
+ * @return Sector count
+ */
+static uint64_t ata_rd_capacity(struct ata_id_layout *l)
+{
+#if __BYTE_ORDER == __BIG_ENDIAN
+	return l->lba_capacity << 16 | l->lba_capacity >> 16;
+#else
+	return l->lba_capacity;
+#endif
+}
+
+/**
+ * Read the ATA disk's description info
+ * @param d All we need to know about the disk
+ * @return 0 on success
+ */
+static int ata_get_id(struct ata_drive_access *d)
+{
+	int rc;
+	struct ata_id_layout *l;
+
+	writeb(0xA0, d->io->device_addr);	/* FIXME drive */
+	writeb(0x00, d->io->lbal_addr);
+	writeb(0x00, d->io->lbam_addr);
+	writeb(0x00, d->io->lbah_addr);
+
+	rc = ata_wr_cmd(d->io, ATA_CMD_ID_DEVICE);
+	if (rc != 0)
+		return rc;
+
+	rc = ata_wait_ready(d->io, MAX_TIMEOUT);
+	if (rc != 0)
+		return rc;
+
+	ata_rd_sector(d->io, &d->id);
+	l = (struct ata_id_layout *)&d->id;
+
+	ata_fix_endianess(d->id, SECTOR_SIZE / sizeof(uint16_t));
+
+	if ((l->field_valid & 1) == 0) {
+		pr_debug("Drive's ID seems invalid\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int ata_reset(struct ata_ioports *io)
+{
+	int rc;
+	uint8_t reg;
+
+	/* try a hard reset first (if available) */
+	if (io->reset != NULL) {
+		pr_debug("%s: Resetting drive...\n", __func__);
+		io->reset(1);
+		rc = ata_wait_busy(io, 500);
+		io->reset(0);
+		if (rc == 0) {
+			rc = ata_wait_ready(io, MAX_TIMEOUT);
+			if (rc != 0)
+				return rc;
+		} else {
+			pr_debug("%s: Drive does not respond to RESET line. Ignored\n",
+					__func__);
+		}
+	}
+
+	/* try a soft reset */
+	ata_wr_dev_ctrl(io, ATA_DEVCTL_SOFT_RESET | ATA_DEVCTL_INTR_DISABLE);
+	rc = ata_wait_busy(io, MAX_TIMEOUT);	/* does the drive accept the command? */
+	if (rc != 0) {
+		pr_debug("%s: Drive fails on soft reset\n", __func__);
+		return rc;
+	}
+	ata_wr_dev_ctrl(io, ATA_DEVCTL_INTR_DISABLE);
+	rc = ata_wait_ready(io, MAX_TIMEOUT);
+	if (rc != 0) {
+		pr_debug("%s: Drive fails after soft reset\n", __func__);
+		return rc;
+	}
+
+	reg = ata_rd_status(io) & 0xf;
+
+	if (reg == 0xf) {
+		pr_debug("%s: Seems no drive connected!\n", __func__);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+/**
+ * Read a chunk of sectors from the drive
+ * @param blk All info about the block device we need
+ * @param buffer Buffer to read into
+ * @param block Sector's LBA number to start read from
+ * @param num_blocks Sector count to read
+ * @return 0 on success, anything else on failure
+ *
+ * This routine expects the buffer has the correct size to store all data!
+ *
+ * @note Due to 'block' is of type 'int' only small disks can be handled!
+ * @todo Optimize the read loop
+ */
+static int ata_read(struct block_device *blk, void *buffer, int block,
+				int num_blocks)
+{
+	int rc;
+	uint64_t sector = block;
+	struct ata_drive_access *drv = to_ata_drive_access(blk);
+
+	while (num_blocks) {
+		rc = ata_set_lba_sector(drv->io, DISK_MASTER, sector);
+		if (rc != 0)
+			return rc;
+		rc = ata_wr_cmd(drv->io, ATA_CMD_RD);
+		if (rc != 0)
+			return rc;
+		rc = ata_wait_ready(drv->io, MAX_TIMEOUT);
+		if (rc != 0)
+			return rc;
+		ata_rd_sector(drv->io, buffer);
+		num_blocks--;
+		sector++;
+		buffer += SECTOR_SIZE;
+	}
+
+	return 0;
+}
+
+/**
+ * Write a chunk of sectors into the drive
+ * @param blk All info about the block device we need
+ * @param buffer Buffer to write from
+ * @param block Sector's number to start write to
+ * @param num_blocks Sector count to write
+ * @return 0 on success, anything else on failure
+ *
+ * This routine expects the buffer has the correct size to read all data!
+ *
+ * @note Due to 'block' is of type 'int' only small disks can be handled!
+ * @todo Optimize the write loop
+ */
+static int __maybe_unused ata_write(struct block_device *blk,
+				const void *buffer, int block, int num_blocks)
+{
+	int rc;
+	uint64_t sector = block;
+	struct ata_drive_access *drv = to_ata_drive_access(blk);
+
+	while (num_blocks) {
+		rc = ata_set_lba_sector(drv->io, DISK_MASTER, sector);
+		if (rc != 0)
+			return rc;
+		rc = ata_wr_cmd(drv->io, ATA_CMD_WR);
+		if (rc != 0)
+			return rc;
+		ata_wr_sector(drv->io, buffer);
+		num_blocks--;
+		sector++;
+		buffer += SECTOR_SIZE;
+	}
+
+	return 0;
+}
+
+static struct block_device_ops ata_ops = {
+	.read = ata_read,
+#ifdef CONFIG_BLOCK_WRITE
+	.write = ata_write,
+#endif
+};
+
+/**
+ * Register an ATA drive behind an IDE like interface
+ * @param dev The interface device
+ * @param io ATA register file description
+ * @return 0 on success
+ */
+int register_ata_drive(struct device_d *dev, struct ata_ioports *io)
+{
+	int rc;
+	struct ata_id_layout *l;
+	struct ata_drive_access *drive;
+
+	drive = xzalloc(sizeof(struct ata_drive_access));
+
+	drive->io = io;
+	drive->blk.dev = dev;
+	drive->blk.ops = &ata_ops;
+	l = (struct ata_id_layout *)&drive->id;
+
+	rc = ata_reset(io);
+	if (rc) {
+		dev_dbg(dev, "Resetting failed\n");
+		goto on_error;
+	}
+
+	rc = ata_get_id(drive);
+	if (rc != 0) {
+		dev_dbg(dev, "Reading ID failed\n");
+		goto on_error;
+	}
+
+#ifdef DEBUG
+	ata_dump_id(drive->id);
+#endif
+	rc = cdev_find_free_number("disk");
+	if (rc == -1)
+		pr_err("Cannot find a free number for the disk node\n");
+
+	drive->blk.num_blocks = ata_rd_capacity(l);
+	drive->blk.cdev.name = asprintf("disk%d", rc);
+	drive->blk.blockbits = SECTOR_SHIFT;
+
+	rc = blockdevice_register(&drive->blk);
+	if (rc != 0) {
+		dev_err(dev, "Failed to register blockdevice\n");
+		goto on_error;
+	}
+
+	/* create partitions on demand */
+	rc = parse_partition_table(&drive->blk);
+	if (rc != 0)
+		dev_warn(dev, "No partition table found\n");
+
+	return 0;
+
+on_error:
+	free(drive);
+	return rc;
+}
+
+/**
+ * @file
+ * @brief Generic ATA disk drive support
+ *
+ * Please be aware: This driver covers only a subset of the available ATA drives
+ *
+ * @todo Support for disks larger than 4 GiB
+ * @todo LBA48
+ * @todo CHS
+ */
diff --git a/include/ata_drive.h b/include/ata_drive.h
new file mode 100644
index 0000000..9710614
--- /dev/null
+++ b/include/ata_drive.h
@@ -0,0 +1,194 @@
+/*
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * 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 ATA_DISK_H
+# define ATA_DISK
+
+/* IDE register file */
+#define IDE_REG_DATA 0x00
+#define IDE_REG_ERR 0x01
+#define IDE_REG_NSECT 0x02
+#define IDE_REG_LBAL 0x03
+#define IDE_REG_LBAM 0x04
+#define IDE_REG_LBAH 0x05
+#define IDE_REG_DEVICE 0x06
+#define IDE_REG_STATUS 0x07
+
+#define IDE_REG_FEATURE IDE_REG_ERR /* and their aliases */
+#define IDE_REG_CMD IDE_REG_STATUS
+
+#define IDE_REG_ALT_STATUS 0x00
+#define IDE_REG_DEV_CTL 0x00
+#define IDE_REG_DRV_ADDR 0x01
+
+/** addresses of each individual IDE drive register */
+struct ata_ioports {
+	void __iomem *cmd_addr;
+	void __iomem *data_addr;
+	void __iomem *error_addr;
+	void __iomem *feature_addr;
+	void __iomem *nsect_addr;
+	void __iomem *lbal_addr;
+	void __iomem *lbam_addr;
+	void __iomem *lbah_addr;
+	void __iomem *device_addr;
+	void __iomem *status_addr;
+	void __iomem *command_addr;
+	void __iomem *altstatus_addr;
+	void __iomem *ctl_addr;
+	void __iomem *alt_dev_addr;
+
+	/* hard reset line handling */
+	void (*reset)(int);	/* true: assert reset, false: de-assert reset */
+};
+
+/** data layout of the ATA identify command
+ * @note all multibyte values are in little endian (on a 16 word base)
+ */
+struct ata_id_layout {
+	uint16_t config;	/**< lots of obsolete bit flags */
+	uint16_t cyls;		/**< "physical" cyls */
+	uint16_t reserved2;	/**< reserved (word 2) */
+	uint16_t heads;		/**< "physical" heads */
+	uint16_t track_bytes;	/**< unformatted bytes per track */
+	uint16_t sector_bytes;	/**< unformatted bytes per sector */
+	uint16_t sectors;	/**< "physical" sectors per track */
+	uint16_t vendor0;	/**< vendor unique */
+	uint16_t vendor1;	/**< vendor unique */
+	uint16_t vendor2;	/**< vendor unique */
+	uint8_t serial_no[20];	/**< 0 = not_specified */
+	uint16_t buf_type;
+	uint16_t buf_size;	/**< 512 byte increments; 0 = not_specified */
+	uint16_t ecc_bytes;	/**< for r/w long cmds; 0 = not_specified */
+	uint8_t fw_rev[8];	/**< 0 = not_specified */
+	uint8_t model[40];	/**< 0 = not_specified */
+	uint8_t max_multsect;	/**< 0=not_implemented */
+	uint8_t vendor3;	/**< vendor unique */
+	uint16_t dword_io;	/**< 0=not_implemented; 1=implemented */
+	uint8_t vendor4;	/**< vendor unique */
+	uint8_t capability;	/**< bits 0:DMA 1:LBA 2:IORDYsw 3:IORDYsup*/
+	uint16_t reserved50;	/**< reserved (word 50) */
+	uint8_t vendor5;	/**< vendor unique */
+	uint8_t tPIO;		/**< 0=slow, 1=medium, 2=fast */
+	uint8_t vendor6;	/**< vendor unique */
+	uint8_t tDMA;		/**< 0=slow, 1=medium, 2=fast */
+	uint16_t field_valid;	/**< bits 0:cur_ok 1:eide_ok */
+	uint16_t cur_cyls;	/**< logical cylinders */
+	uint16_t cur_heads;	/**< logical heads */
+	uint16_t cur_sectors;	/**< logical sectors per track */
+	uint16_t cur_capacity0;	/**< logical total sectors on drive */
+	uint16_t cur_capacity1;	/**< (2 words, misaligned int) */
+	uint8_t multsect;	/**< current multiple sector count */
+	uint8_t multsect_valid;	/**< when (bit0==1) multsect is ok */
+	uint32_t lba_capacity;	/**< total number of sectors */
+	uint16_t dma_1word;	/**< single-word dma info */
+	uint16_t dma_mword;	/**< multiple-word dma info */
+	uint16_t eide_pio_modes; /**< bits 0:mode3 1:mode4 */
+	uint16_t eide_dma_min;	/**< min mword dma cycle time (ns) */
+	uint16_t eide_dma_time;	/**< recommended mword dma cycle time (ns) */
+	uint16_t eide_pio;	/**< min cycle time (ns), no IORDY  */
+	uint16_t eide_pio_iordy; /**< min cycle time (ns), with IORDY */
+	uint16_t words69_70[2];	/**< reserved words 69-70 */
+	uint16_t words71_74[4];	/**< reserved words 71-74 */
+	uint16_t queue_depth;
+	uint16_t words76_79[4];	/**< reserved words 76-79 */
+	uint16_t major_rev_num;
+	uint16_t minor_rev_num;
+	uint16_t command_set_1;	/**< bits 0:Smart 1:Security 2:Removable 3:PM */
+	uint16_t command_set_2;	/**< bits 14:Smart Enabled 13:0 zero 10:lba48 support*/
+	uint16_t cfsse;		/**< command set-feature supported extensions */
+	uint16_t cfs_enable_1;	/**< command set-feature enabled */
+	uint16_t cfs_enable_2;	/**<*< command set-feature enabled */
+	uint16_t csf_default;	/**< command set-feature default */
+	uint16_t dma_ultra;
+	uint16_t word89;	/**< reserved (word 89) */
+	uint16_t word90;	/**< reserved (word 90) */
+	uint16_t CurAPMvalues;	/**< current APM values */
+	uint16_t word92;	/**< reserved (word 92) */
+	uint16_t hw_config;	/**< hardware config */
+	uint16_t words94_99[6];	/**< reserved words 94-99 */
+	uint16_t lba48_capacity[4]; /**< 4 16bit values containing lba 48 total number of sectors */
+	uint16_t words104_125[22]; /**< reserved words 104-125 */
+	uint16_t last_lun;	/**< reserved (word 126) */
+	uint16_t word127;	/**< reserved (word 127) */
+	uint16_t dlf;		/**< device lock function
+				 * 15:9	reserved
+				 * 8	security level 1:max 0:high
+				 * 7:6	reserved
+				 * 5	enhanced erase
+				 * 4	expire
+				 * 3	frozen
+				 * 2	locked
+				 * 1	en/disabled
+				 * 0	capability
+				 */
+	uint16_t csfo;		/**< current set features options
+				 * 15:4	reserved
+				 * 3	auto reassign
+				 * 2	reverting
+				 * 1	read-look-ahead
+				 * 0	write cache
+				 */
+	uint16_t words130_155[26]; /**< reserved vendor words 130-155 */
+	uint16_t word156;
+	uint16_t words157_159[3]; /**< reserved vendor words 157-159 */
+	uint16_t words160_162[3]; /**< reserved words 160-162 */
+	uint16_t cf_advanced_caps;
+	uint16_t words164_255[92]; /**< reserved words 164-255 */
+};
+
+struct device_d;
+extern int register_ata_drive(struct device_d*, struct ata_ioports*);
+
+/**
+ * @file
+ * @brief Register file examples of generic types of ATA devices
+ *
+ * PC IDE:
+ *
+ *        Offset       Read      Write           Note
+ *-----------------------------------------------------------
+ *        0x1f0        data      data        16 bit register
+ *        0x1f1        error    feature
+ *        0x1f2       sec cnt   set cnt
+ *        0x1f3       sec no    sec no
+ *        0x1f4       cyl low   cyl low
+ *        0x1f5       cyl high  cyl high
+ *        0x1f6        head      head
+ *        0x1f7       status    command
+ *        0x3f6     alt status  dev cntrl
+ *        0x3f7       drv addr
+ *
+ * PCMCIA memory mapped:
+ *
+ *        Offset       Read      Write           Note
+ *-----------------------------------------------------------
+ *        0x0          data      data        16 bit register
+ *        0x1          error    feature
+ *        0x2         sec cnt   set cnt
+ *        0x3         sec no    sec no
+ *        0x4         cyl low   cyl low
+ *        0x5         cyl high  cyl high
+ *        0x6          head      head
+ *        0x7         status    command
+ *        0x8          data      data       16 bit or 8 bit register (even byte)
+ *        0x9          data      data       8 bit register (odd byte)
+ *        0xd          error    feature     dup of offset 1
+ *        0xe       alt status  dev cntrl
+ *        0xf        drv addr
+ *       0x400         data      data       16 bit area with 1 kiB in size
+ */
+
+#endif /* ATA_DISK */
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 13/13] Add driver for IDE like interfaces
  2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
                   ` (11 preceding siblings ...)
  2011-11-22  8:29 ` [PATCH 12/13] ATA Disk Support: Add support for native ATA type drives Juergen Beisert
@ 2011-11-22  8:29 ` Juergen Beisert
  12 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-22  8:29 UTC (permalink / raw)
  To: barebox

This simple driver enables a generic driver for ATA type of devices to get
access to the so called 'register file' of an ATA drive.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig             |    7 ++
 drivers/ata/Makefile            |    1 +
 drivers/ata/intf_platform_ide.c |  129 +++++++++++++++++++++++++++++++++++++++
 include/platform_ide.h          |   31 +++++++++
 4 files changed, 168 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/intf_platform_ide.c
 create mode 100644 include/platform_ide.h

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 0a15863..153882d 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -38,4 +38,11 @@ config DISK_LE_ATTACHED
 
 comment "interface types"
 
+config DISK_INTF_PLATFORM_IDE
+	bool "Platform IDE"
+	select DISK_ATA
+	help
+	  Generic platform driver for simple IDE like interfaces to a connected
+	  ATA device.
+
 endif
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index cdbcbe7..2560076 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_DISK_ATA) += disk_ata_drive.o
 
 # interface types
 
+obj-$(CONFIG_DISK_INTF_PLATFORM_IDE) += intf_platform_ide.o
diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
new file mode 100644
index 0000000..f499ea0
--- /dev/null
+++ b/drivers/ata/intf_platform_ide.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2011 Juergen Beisert, Pengutronix
+ *
+ * Derived from the Linux kernel: Generic platform device PATA driver
+ *  Copyright (C) 2006 - 2007  Paul Mundt
+ *  Based on pata_pcmcia:
+ *  Copyright 2005-2006 Red Hat Inc, all rights reserved.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <xfuncs.h>
+#include <malloc.h>
+#include <errno.h>
+#include <ata_drive.h>
+#include <platform_ide.h>
+
+/**
+ * Setup the register specific addresses for an ATA like divice
+ * @param reg_base Base address of the standard ATA like registers
+ * @param alt_base Base address of the alternate ATA like registers
+ * @param ioaddr Register file structure to setup
+ * @param shift Shift offset between registers
+ *
+ * Some of the registers have different names but use the same offset. This is
+ * due to the fact read or write access at the same offset reaches different
+ * registers.
+ */
+static void platform_ide_setup_port(void *reg_base, void *alt_base,
+			struct ata_ioports *ioaddr, unsigned shift)
+{
+	/* standard registers (0 ... 7) */
+	ioaddr->cmd_addr = reg_base;
+
+	ioaddr->data_addr = reg_base + (IDE_REG_DATA << shift);
+
+	ioaddr->error_addr = reg_base + (IDE_REG_ERR << shift);
+	ioaddr->feature_addr = reg_base + (IDE_REG_FEATURE << shift);
+
+	ioaddr->nsect_addr = reg_base + (IDE_REG_NSECT << shift);
+
+	ioaddr->lbal_addr = reg_base + (IDE_REG_LBAL << shift);
+
+	ioaddr->lbam_addr = reg_base + (IDE_REG_LBAM << shift);
+
+	ioaddr->lbah_addr = reg_base + (IDE_REG_LBAH << shift);
+
+	ioaddr->device_addr = reg_base + (IDE_REG_DEVICE << shift);
+
+	ioaddr->status_addr = reg_base + (IDE_REG_STATUS << shift);
+	ioaddr->command_addr = reg_base + (IDE_REG_CMD << shift);
+
+	ioaddr->altstatus_addr = alt_base + (IDE_REG_ALT_STATUS << shift);
+	ioaddr->ctl_addr = alt_base + (IDE_REG_DEV_CTL << shift);
+
+	ioaddr->alt_dev_addr = alt_base + (IDE_REG_DRV_ADDR << shift);
+}
+
+static int platform_ide_probe(struct device_d *dev)
+{
+	int rc;
+	struct ide_port_info *pdata = dev->platform_data;
+	struct ata_ioports *io;
+	void *reg_base, *alt_base;
+
+	if (pdata == NULL) {
+		dev_err(dev, "No platform data. Cannot continue\n");
+		return -EINVAL;
+	}
+
+	io = xzalloc(sizeof(struct ata_ioports));
+	reg_base = dev_request_mem_region(dev, 0);
+	alt_base = dev_request_mem_region(dev, 1);
+	platform_ide_setup_port(reg_base, alt_base, io, pdata->ioport_shift);
+	io->reset = pdata->reset;
+
+	rc = register_ata_drive(dev, io);
+	if (rc != 0) {
+		dev_err(dev, "Cannot register IDE interface\n");
+		free(io);
+	}
+
+	return rc;
+}
+
+static struct driver_d platform_ide_driver = {
+	.name   = "ide_intf",
+	.probe  = platform_ide_probe,
+};
+
+static int platform_ide_init(void)
+{
+	return register_driver(&platform_ide_driver);
+}
+
+device_initcall(platform_ide_init);
+
+/**
+ * @file
+ * @brief Interface driver for an ATA drive behind an IDE like interface
+ *
+ * This communication driver does all accesses to the drive via memory IO
+ * instructions.
+ *
+ * This kind of interface is also useable for regular bus like access, when
+ * there is no dedicated IDE available.
+ *
+ * "IDE like" means the platform data defines addresses to the register file
+ * of the attached ATA drive.
+ *
+ * This driver does not change any access timings due to the fact it has no idea
+ * how to do so. So, do not expect an impressive data throughput.
+ *
+ * @todo Support also the IO port access method, the x86 architecture is using
+ */
diff --git a/include/platform_ide.h b/include/platform_ide.h
new file mode 100644
index 0000000..4f14b5f
--- /dev/null
+++ b/include/platform_ide.h
@@ -0,0 +1,31 @@
+/*
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * 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 __PLATFORM_IDE_H
+#define __PLATFORM_IDE_H
+
+struct ide_port_info {
+	/*
+	 * I/O port shift, for platforms with ports that are
+	 * constantly spaced and need larger than the 1-byte
+	 * spacing
+	 */
+	unsigned ioport_shift;
+
+	/* handle hard reset of this port */
+	void (*reset)(int);	/* true: assert reset, false: de-assert reset */
+};
+
+#endif /* __PLATFORM_IDE_H */
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/13] USB Mass Storage driver: Fix compile time warning
  2011-11-24 12:43 [PATCHv3] Rework of handling disk like media Juergen Beisert
@ 2011-11-24 12:43 ` Juergen Beisert
  0 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-24 12:43 UTC (permalink / raw)
  To: barebox

drivers/usb/storage/usb.c: In function 'usb_stor_blk_io':
drivers/usb/storage/usb.c:257:16: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/usb/storage/usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d033b29..6dba8cc 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -193,7 +193,7 @@ static int usb_stor_write_10(ccb *srb, struct us_data *us,
  * Disk driver interface
  ***********************************************************************/
 
-#define US_MAX_IO_BLK 32U
+#define US_MAX_IO_BLK 32
 
 enum { io_rd, io_wr };
 
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/13] USB Mass Storage driver: Fix compile time warning
  2011-11-16  9:24 Rework of handling disk like media Juergen Beisert
@ 2011-11-16  9:24 ` Juergen Beisert
  0 siblings, 0 replies; 16+ messages in thread
From: Juergen Beisert @ 2011-11-16  9:24 UTC (permalink / raw)
  To: barebox

drivers/usb/storage/usb.c: In function 'usb_stor_blk_io':
drivers/usb/storage/usb.c:257:16: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/usb/storage/usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d033b29..6dba8cc 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -193,7 +193,7 @@ static int usb_stor_write_10(ccb *srb, struct us_data *us,
  * Disk driver interface
  ***********************************************************************/
 
-#define US_MAX_IO_BLK 32U
+#define US_MAX_IO_BLK 32
 
 enum { io_rd, io_wr };
 
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-11-24 12:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
2011-11-22  8:29 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert
2011-11-22  8:29 ` [PATCH 02/13] Create a unique cdev number for on demand devices Juergen Beisert
2011-11-22  8:29 ` [PATCH 03/13] ATA/DISK: Add generic disk support when enabling the BIOS disk driver Juergen Beisert
2011-11-22  8:29 ` [PATCH 04/13] ATA/DISK: Enabling write support does not belong to 'drive types' Juergen Beisert
2011-11-22  8:29 ` [PATCH 05/13] ATA/DISK: Reorganize file structure and names for future updates Juergen Beisert
2011-11-22  8:29 ` [PATCH 06/13] ATA/DISK: The BIOS based disk driver is not an interface Juergen Beisert
2011-11-22  8:29 ` [PATCH 07/13] ATA/DISK: Share important constants and structures Juergen Beisert
2011-11-22  8:29 ` [PATCH 08/13] DISK: Add common partition handling for disk like media Juergen Beisert
2011-11-22  8:29 ` [PATCH 09/13] Use generic block layer to access the drives and do partition parsing Juergen Beisert
2011-11-22  8:29 ` [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling Juergen Beisert
2011-11-22  8:29 ` [PATCH 11/13] ATA/DISK: Remove the now unused header <ata.h> Juergen Beisert
2011-11-22  8:29 ` [PATCH 12/13] ATA Disk Support: Add support for native ATA type drives Juergen Beisert
2011-11-22  8:29 ` [PATCH 13/13] Add driver for IDE like interfaces Juergen Beisert
  -- strict thread matches above, loose matches on Subject: below --
2011-11-24 12:43 [PATCHv3] Rework of handling disk like media Juergen Beisert
2011-11-24 12:43 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert
2011-11-16  9:24 Rework of handling disk like media Juergen Beisert
2011-11-16  9:24 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox