summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2016-03-14 19:21:44 -0400
committerTom Rini <trini@konsulko.com>2016-03-14 19:21:44 -0400
commit88033d737d9f46e7eebda6a8f9770957eb9aae9c (patch)
tree0b7c3bc6caa5ab4b7f8e88f05ce51ace87f25890 /include
parent9f0f432c0aea1e70959a0c06938459d3175a36b0 (diff)
parent608e399fdef82e983db44c5cb8f5e772bba870e2 (diff)
downloadblackbird-obmc-uboot-88033d737d9f46e7eebda6a8f9770957eb9aae9c.tar.gz
blackbird-obmc-uboot-88033d737d9f46e7eebda6a8f9770957eb9aae9c.zip
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'include')
-rw-r--r--include/blk.h248
-rw-r--r--include/common.h2
-rw-r--r--include/configs/UCP1020.h1
-rw-r--r--include/configs/km/keymile-common.h1
-rw-r--r--include/configs/sandbox.h7
-rw-r--r--include/debug_uart.h4
-rw-r--r--include/dm/uclass-id.h1
-rw-r--r--include/dm/uclass.h15
-rw-r--r--include/ext4fs.h6
-rw-r--r--include/fat.h4
-rw-r--r--include/ide.h18
-rw-r--r--include/mmc.h2
-rw-r--r--include/part.h308
-rw-r--r--include/reiserfs.h2
-rw-r--r--include/sandboxblockdev.h4
-rw-r--r--include/sandboxfs.h2
-rw-r--r--include/sata.h2
-rw-r--r--include/spl.h10
-rw-r--r--include/systemace.h2
-rw-r--r--include/ubifs_uboot.h2
-rw-r--r--include/usb.h2
-rw-r--r--include/usb_mass_storage.h2
-rw-r--r--include/zfs_common.h4
23 files changed, 487 insertions, 162 deletions
diff --git a/include/blk.h b/include/blk.h
new file mode 100644
index 0000000000..e83c144e6c
--- /dev/null
+++ b/include/blk.h
@@ -0,0 +1,248 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef BLK_H
+#define BLK_H
+
+#ifdef CONFIG_SYS_64BIT_LBA
+typedef uint64_t lbaint_t;
+#define LBAFlength "ll"
+#else
+typedef ulong lbaint_t;
+#define LBAFlength "l"
+#endif
+#define LBAF "%" LBAFlength "x"
+#define LBAFU "%" LBAFlength "u"
+
+/* Interface types: */
+enum if_type {
+ IF_TYPE_UNKNOWN = 0,
+ IF_TYPE_IDE,
+ IF_TYPE_SCSI,
+ IF_TYPE_ATAPI,
+ IF_TYPE_USB,
+ IF_TYPE_DOC,
+ IF_TYPE_MMC,
+ IF_TYPE_SD,
+ IF_TYPE_SATA,
+ IF_TYPE_HOST,
+
+ IF_TYPE_COUNT, /* Number of interface types */
+};
+
+/*
+ * With driver model (CONFIG_BLK) this is uclass platform data, accessible
+ * with dev_get_uclass_platdata(dev)
+ */
+struct blk_desc {
+ /*
+ * TODO: With driver model we should be able to use the parent
+ * device's uclass instead.
+ */
+ enum if_type if_type; /* type of the interface */
+ int devnum; /* device number */
+ unsigned char part_type; /* partition type */
+ unsigned char target; /* target SCSI ID */
+ unsigned char lun; /* target LUN */
+ unsigned char hwpart; /* HW partition, e.g. for eMMC */
+ unsigned char type; /* device type */
+ unsigned char removable; /* removable device */
+#ifdef CONFIG_LBA48
+ /* device can use 48bit addr (ATA/ATAPI v7) */
+ unsigned char lba48;
+#endif
+ lbaint_t lba; /* number of blocks */
+ unsigned long blksz; /* block size */
+ int log2blksz; /* for convenience: log2(blksz) */
+ char vendor[40+1]; /* IDE model, SCSI Vendor */
+ char product[20+1]; /* IDE Serial no, SCSI product */
+ char revision[8+1]; /* firmware revision */
+#ifdef CONFIG_BLK
+ struct udevice *bdev;
+#else
+ unsigned long (*block_read)(struct blk_desc *block_dev,
+ lbaint_t start,
+ lbaint_t blkcnt,
+ void *buffer);
+ unsigned long (*block_write)(struct blk_desc *block_dev,
+ lbaint_t start,
+ lbaint_t blkcnt,
+ const void *buffer);
+ unsigned long (*block_erase)(struct blk_desc *block_dev,
+ lbaint_t start,
+ lbaint_t blkcnt);
+ void *priv; /* driver private struct pointer */
+#endif
+};
+
+#define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
+#define PAD_TO_BLOCKSIZE(size, blk_desc) \
+ (PAD_SIZE(size, blk_desc->blksz))
+
+#ifdef CONFIG_BLK
+struct udevice;
+
+/* Operations on block devices */
+struct blk_ops {
+ /**
+ * read() - read from a block device
+ *
+ * @dev: Device to read from
+ * @start: Start block number to read (0=first)
+ * @blkcnt: Number of blocks to read
+ * @buffer: Destination buffer for data read
+ * @return number of blocks read, or -ve error number (see the
+ * IS_ERR_VALUE() macro
+ */
+ unsigned long (*read)(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer);
+
+ /**
+ * write() - write to a block device
+ *
+ * @dev: Device to write to
+ * @start: Start block number to write (0=first)
+ * @blkcnt: Number of blocks to write
+ * @buffer: Source buffer for data to write
+ * @return number of blocks written, or -ve error number (see the
+ * IS_ERR_VALUE() macro
+ */
+ unsigned long (*write)(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer);
+
+ /**
+ * erase() - erase a section of a block device
+ *
+ * @dev: Device to (partially) erase
+ * @start: Start block number to erase (0=first)
+ * @blkcnt: Number of blocks to erase
+ * @return number of blocks erased, or -ve error number (see the
+ * IS_ERR_VALUE() macro
+ */
+ unsigned long (*erase)(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt);
+};
+
+#define blk_get_ops(dev) ((struct blk_ops *)(dev)->driver->ops)
+
+/*
+ * These functions should take struct udevice instead of struct blk_desc,
+ * but this is convenient for migration to driver model. Add a 'd' prefix
+ * to the function operations, so that blk_read(), etc. can be reserved for
+ * functions with the correct arguments.
+ */
+unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer);
+unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer);
+unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt);
+
+/**
+ * blk_get_device() - Find and probe a block device ready for use
+ *
+ * @if_type: Interface type (enum if_type_t)
+ * @devnum: Device number (specific to each interface type)
+ * @devp: the device, if found
+ * @return - if found, -ENODEV if no device found, or other -ve error value
+ */
+int blk_get_device(int if_type, int devnum, struct udevice **devp);
+
+/**
+ * blk_first_device() - Find the first device for a given interface
+ *
+ * The device is probed ready for use
+ *
+ * @devnum: Device number (specific to each interface type)
+ * @devp: the device, if found
+ * @return 0 if found, -ENODEV if no device, or other -ve error value
+ */
+int blk_first_device(int if_type, struct udevice **devp);
+
+/**
+ * blk_next_device() - Find the next device for a given interface
+ *
+ * This can be called repeatedly after blk_first_device() to iterate through
+ * all devices of the given interface type.
+ *
+ * The device is probed ready for use
+ *
+ * @devp: On entry, the previous device returned. On exit, the next
+ * device, if found
+ * @return 0 if found, -ENODEV if no device, or other -ve error value
+ */
+int blk_next_device(struct udevice **devp);
+
+/**
+ * blk_create_device() - Create a new block device
+ *
+ * @parent: Parent of the new device
+ * @drv_name: Driver name to use for the block device
+ * @name: Name for the device
+ * @if_type: Interface type (enum if_type_t)
+ * @devnum: Device number, specific to the interface type
+ * @blksz: Block size of the device in bytes (typically 512)
+ * @size: Total size of the device in bytes
+ * @devp: the new device (which has not been probed)
+ */
+int blk_create_device(struct udevice *parent, const char *drv_name,
+ const char *name, int if_type, int devnum, int blksz,
+ lbaint_t size, struct udevice **devp);
+
+/**
+ * blk_prepare_device() - Prepare a block device for use
+ *
+ * This reads partition information from the device if supported.
+ *
+ * @dev: Device to prepare
+ * @return 0 if ok, -ve on error
+ */
+int blk_prepare_device(struct udevice *dev);
+
+/**
+ * blk_unbind_all() - Unbind all device of the given interface type
+ *
+ * The devices are removed and then unbound.
+ *
+ * @if_type: Interface type to unbind
+ * @return 0 if OK, -ve on error
+ */
+int blk_unbind_all(int if_type);
+
+#else
+#include <errno.h>
+/*
+ * These functions should take struct udevice instead of struct blk_desc,
+ * but this is convenient for migration to driver model. Add a 'd' prefix
+ * to the function operations, so that blk_read(), etc. can be reserved for
+ * functions with the correct arguments.
+ */
+static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer)
+{
+ /*
+ * We could check if block_read is NULL and return -ENOSYS. But this
+ * bloats the code slightly (cause some board to fail to build), and
+ * it would be an error to try an operation that does not exist.
+ */
+ return block_dev->block_read(block_dev, start, blkcnt, buffer);
+}
+
+static inline ulong blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer)
+{
+ return block_dev->block_write(block_dev, start, blkcnt, buffer);
+}
+
+static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt)
+{
+ return block_dev->block_erase(block_dev, start, blkcnt);
+}
+#endif /* !CONFIG_BLK */
+
+#endif
diff --git a/include/common.h b/include/common.h
index 3e1a4c98b7..f9f4605dba 100644
--- a/include/common.h
+++ b/include/common.h
@@ -807,7 +807,7 @@ void gzwrite_progress_finish(int retcode,
* for files under 4GiB
*/
int gzwrite(unsigned char *src, int len,
- struct block_dev_desc *dev,
+ struct blk_desc *dev,
unsigned long szwritebuf,
u64 startoffs,
u64 szexpected);
diff --git a/include/configs/UCP1020.h b/include/configs/UCP1020.h
index b08072401b..139e629730 100644
--- a/include/configs/UCP1020.h
+++ b/include/configs/UCP1020.h
@@ -484,7 +484,6 @@
#define CONFIG_CMD_REGINFO
#define CONFIG_CMD_ERRATA
#define CONFIG_CMD_CRAMFS
-#define CONFIG_CRAMFS_CMDLINE
/*
* USB
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h
index 91b29b35ba..5edc8f68a9 100644
--- a/include/configs/km/keymile-common.h
+++ b/include/configs/km/keymile-common.h
@@ -83,7 +83,6 @@
#define CONFIG_MTD_CONCAT
#define CONFIG_CMD_CRAMFS
-#define CONFIG_CRAMFS_CMDLINE
#ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
#define CONFIG_KM_DEF_ENV_BOOTPARAMS \
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index d59beb80dd..cc22467442 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -43,6 +43,8 @@
#define CONFIG_CMD_FAT
#define CONFIG_CMD_EXT4
#define CONFIG_CMD_EXT4_WRITE
+#define CONFIG_CMD_CBFS
+#define CONFIG_CMD_CRAMFS
#define CONFIG_CMD_PART
#define CONFIG_DOS_PARTITION
#define CONFIG_HOST_MAX_DEVICES 4
@@ -52,8 +54,11 @@
#define CONFIG_CMD_GPT
#define CONFIG_PARTITION_UUIDS
-#define CONFIG_EFI_PARTITION
+#define CONFIG_AMIGA_PARTITION
#define CONFIG_DOS_PARTITION
+#define CONFIG_EFI_PARTITION
+#define CONFIG_ISO_PARTITION
+#define CONFIG_MAC_PARTITION
/*
* Size of malloc() pool, before and after relocation
diff --git a/include/debug_uart.h b/include/debug_uart.h
index 5d5349bbd2..0d640b96e7 100644
--- a/include/debug_uart.h
+++ b/include/debug_uart.h
@@ -117,13 +117,15 @@ void printhex8(uint value);
#define DEBUG_UART_FUNCS \
void printch(int ch) \
{ \
+ if (ch == '\n') \
+ _debug_uart_putc('\r'); \
_debug_uart_putc(ch); \
} \
\
void printascii(const char *str) \
{ \
while (*str) \
- _debug_uart_putc(*str++); \
+ printch(*str++); \
} \
\
static inline void printhex1(uint digit) \
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 3bea30807d..37c4176d57 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -26,6 +26,7 @@ enum uclass_id {
/* U-Boot uclasses start here - in alphabetical order */
UCLASS_ADC, /* Analog-to-digital converter */
+ UCLASS_BLK, /* Block device */
UCLASS_CLK, /* Clock source, e.g. used by peripherals */
UCLASS_CPU, /* CPU, typically part of an SoC */
UCLASS_CROS_EC, /* Chrome OS EC */
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index bfbd27afd6..fd368b6bd0 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -200,18 +200,29 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,
*
* @id: Uclass ID to look up
* @devp: Returns pointer to the first device in that uclass, or NULL if none
- * @return 0 if OK (found or not found), -1 on error
+ * @return 0 if OK (found or not found), other -ve on error
*/
int uclass_first_device(enum uclass_id id, struct udevice **devp);
/**
+ * uclass_first_device_err() - Get the first device in a uclass
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @id: Uclass ID to look up
+ * @devp: Returns pointer to the first device in that uclass, or NULL if none
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int uclass_first_device_err(enum uclass_id id, struct udevice **devp);
+
+/**
* uclass_next_device() - Get the next device in a uclass
*
* The device returned is probed if necessary, and ready for use
*
* @devp: On entry, pointer to device to lookup. On exit, returns pointer
* to the next device in the same uclass, or NULL if none
- * @return 0 if OK (found or not found), -1 on error
+ * @return 0 if OK (found or not found), other -ve on error
*/
int uclass_next_device(struct udevice **devp);
diff --git a/include/ext4fs.h b/include/ext4fs.h
index 6888adc56f..cc765ae468 100644
--- a/include/ext4fs.h
+++ b/include/ext4fs.h
@@ -110,7 +110,7 @@ struct ext_filesystem {
/* Journal Related */
/* Block Device Descriptor */
- block_dev_desc_t *dev_desc;
+ struct blk_desc *dev_desc;
};
extern struct ext2_data *ext4fs_root;
@@ -141,9 +141,9 @@ int ext4fs_exists(const char *filename);
int ext4fs_size(const char *filename, loff_t *size);
void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
-void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
+void ext4fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
long int read_allocated_block(struct ext2_inode *inode, int fileblock);
-int ext4fs_probe(block_dev_desc_t *fs_dev_desc,
+int ext4fs_probe(struct blk_desc *fs_dev_desc,
disk_partition_t *fs_partition);
int ext4_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
loff_t *actread);
diff --git a/include/fat.h b/include/fat.h
index 3038bd7e4f..9d053e6fa6 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -203,8 +203,8 @@ int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
loff_t maxsize, loff_t *actread);
int file_fat_read(const char *filename, void *buffer, int maxsize);
const char *file_getfsname(int idx);
-int fat_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
-int fat_register_device(block_dev_desc_t *dev_desc, int part_no);
+int fat_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
+int fat_register_device(struct blk_desc *dev_desc, int part_no);
int file_fat_write(const char *filename, void *buf, loff_t offset, loff_t len,
loff_t *actwrite);
diff --git a/include/ide.h b/include/ide.h
index f9357bee76..a4e65cf2a9 100644
--- a/include/ide.h
+++ b/include/ide.h
@@ -8,6 +8,8 @@
#ifndef _IDE_H
#define _IDE_H
+#include <blk.h>
+
#define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS))
#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
@@ -26,25 +28,15 @@ extern ulong ide_bus_offset[];
void ide_led(uchar led, uchar status);
#endif /* CONFIG_IDE_LED */
-#ifdef CONFIG_SYS_64BIT_LBA
-typedef uint64_t lbaint_t;
-#define LBAFlength "ll"
-#else
-typedef ulong lbaint_t;
-#define LBAFlength "l"
-#endif
-#define LBAF "%" LBAFlength "x"
-#define LBAFU "%" LBAFlength "u"
-
/*
* Function Prototypes
*/
void ide_init(void);
-typedef struct block_dev_desc block_dev_desc_t;
-ulong ide_read(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
+struct blk_desc;
+ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
void *buffer);
-ulong ide_write(block_dev_desc_t *block_dev, lbaint_t blknr, lbaint_t blkcnt,
+ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
const void *buffer);
#ifdef CONFIG_IDE_PREINIT
diff --git a/include/mmc.h b/include/mmc.h
index d652c1484e..cdb56e7ac1 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -376,7 +376,7 @@ struct mmc {
u64 capacity_gp[4];
u64 enh_user_start;
u64 enh_user_size;
- block_dev_desc_t block_dev;
+ struct blk_desc block_dev;
char op_cond_pending; /* 1 if we are waiting on an op_cond command */
char init_in_progress; /* 1 if we have done mmc_start_init() */
char preinit; /* start init as early as possible */
diff --git a/include/part.h b/include/part.h
index dc23949ae8..6d8f52049d 100644
--- a/include/part.h
+++ b/include/part.h
@@ -7,62 +7,14 @@
#ifndef _PART_H
#define _PART_H
+#include <blk.h>
#include <ide.h>
-#include <common.h>
-struct block_dev_desc {
- int if_type; /* type of the interface */
- int dev; /* device number */
- unsigned char part_type; /* partition type */
- unsigned char target; /* target SCSI ID */
- unsigned char lun; /* target LUN */
- unsigned char hwpart; /* HW partition, e.g. for eMMC */
- unsigned char type; /* device type */
- unsigned char removable; /* removable device */
-#ifdef CONFIG_LBA48
- unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
-#endif
- lbaint_t lba; /* number of blocks */
- unsigned long blksz; /* block size */
- int log2blksz; /* for convenience: log2(blksz) */
- char vendor [40+1]; /* IDE model, SCSI Vendor */
- char product[20+1]; /* IDE Serial no, SCSI product */
- char revision[8+1]; /* firmware revision */
- unsigned long (*block_read)(block_dev_desc_t *block_dev,
- lbaint_t start,
- lbaint_t blkcnt,
- void *buffer);
- unsigned long (*block_write)(block_dev_desc_t *block_dev,
- lbaint_t start,
- lbaint_t blkcnt,
- const void *buffer);
- unsigned long (*block_erase)(block_dev_desc_t *block_dev,
- lbaint_t start,
- lbaint_t blkcnt);
- void *priv; /* driver private struct pointer */
-};
-
-#define BLOCK_CNT(size, block_dev_desc) (PAD_COUNT(size, block_dev_desc->blksz))
-#define PAD_TO_BLOCKSIZE(size, block_dev_desc) \
- (PAD_SIZE(size, block_dev_desc->blksz))
#define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
((x & 0xffff0000) ? 16 : 0))
#define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))
-/* Interface types: */
-#define IF_TYPE_UNKNOWN 0
-#define IF_TYPE_IDE 1
-#define IF_TYPE_SCSI 2
-#define IF_TYPE_ATAPI 3
-#define IF_TYPE_USB 4
-#define IF_TYPE_DOC 5
-#define IF_TYPE_MMC 6
-#define IF_TYPE_SD 7
-#define IF_TYPE_SATA 8
-#define IF_TYPE_HOST 9
-#define IF_TYPE_MAX 10 /* Max number of IF_TYPE_* supported */
-
/* Part types */
#define PART_TYPE_UNKNOWN 0x00
#define PART_TYPE_MAC 0x01
@@ -101,91 +53,205 @@ typedef struct disk_partition {
/* Misc _get_dev functions */
#ifdef CONFIG_PARTITIONS
-block_dev_desc_t *get_dev(const char *ifname, int dev);
-block_dev_desc_t* ide_get_dev(int dev);
-block_dev_desc_t* sata_get_dev(int dev);
-block_dev_desc_t* scsi_get_dev(int dev);
-block_dev_desc_t* usb_stor_get_dev(int dev);
-block_dev_desc_t* mmc_get_dev(int dev);
+/**
+ * blk_get_dev() - get a pointer to a block device given its type and number
+ *
+ * Each interface allocates its own devices and typically struct blk_desc is
+ * contained with the interface's data structure. There is no global
+ * numbering for block devices, so the interface name must be provided.
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev: Device number (0 for first device on that interface, 1 for
+ * second, etc.
+ * @return pointer to the block device, or NULL if not available, or an
+ * error occurred.
+ */
+struct blk_desc *blk_get_dev(const char *ifname, int dev);
+struct blk_desc *ide_get_dev(int dev);
+struct blk_desc *sata_get_dev(int dev);
+struct blk_desc *scsi_get_dev(int dev);
+struct blk_desc *usb_stor_get_dev(int dev);
+struct blk_desc *mmc_get_dev(int dev);
+
+/**
+ * mmc_select_hwpart() - Select the MMC hardware partiion on an MMC device
+ *
+ * MMC devices can support partitioning at the hardware level. This is quite
+ * separate from the normal idea of software-based partitions. MMC hardware
+ * partitions must be explicitly selected. Once selected only the region of
+ * the device covered by that partition is accessible.
+ *
+ * The MMC standard provides for two boot partitions (numbered 1 and 2),
+ * rpmb (3), and up to 4 addition general-purpose partitions (4-7).
+ *
+ * @dev_num: Block device number (struct blk_desc->dev value)
+ * @hwpart: Hardware partition number to select. 0 means the raw device,
+ * 1 is the first partition, 2 is the second, etc.
+ * @return 0 if OK, other value for an error
+ */
int mmc_select_hwpart(int dev_num, int hwpart);
-block_dev_desc_t* systemace_get_dev(int dev);
-block_dev_desc_t* mg_disk_get_dev(int dev);
-block_dev_desc_t *host_get_dev(int dev);
-int host_get_dev_err(int dev, block_dev_desc_t **blk_devp);
+struct blk_desc *systemace_get_dev(int dev);
+struct blk_desc *mg_disk_get_dev(int dev);
+struct blk_desc *host_get_dev(int dev);
+int host_get_dev_err(int dev, struct blk_desc **blk_devp);
/* disk/part.c */
-int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
-void print_part (block_dev_desc_t *dev_desc);
-void init_part (block_dev_desc_t *dev_desc);
-void dev_print(block_dev_desc_t *dev_desc);
-int get_device(const char *ifname, const char *dev_str,
- block_dev_desc_t **dev_desc);
-int get_device_and_partition(const char *ifname, const char *dev_part_str,
- block_dev_desc_t **dev_desc,
- disk_partition_t *info, int allow_whole_dev);
+int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info);
+void part_print(struct blk_desc *dev_desc);
+void part_init(struct blk_desc *dev_desc);
+void dev_print(struct blk_desc *dev_desc);
+
+/**
+ * blk_get_device_by_str() - Get a block device given its interface/hw partition
+ *
+ * Each interface allocates its own devices and typically struct blk_desc is
+ * contained with the interface's data structure. There is no global
+ * numbering for block devices, so the interface name must be provided.
+ *
+ * The hardware parition is not related to the normal software partitioning
+ * of a device - each hardware partition is effectively a separately
+ * accessible block device. When a hardware parition is selected on MMC the
+ * other hardware partitions become inaccessible. The same block device is
+ * used to access all hardware partitions, but its capacity may change when a
+ * different hardware partition is selected.
+ *
+ * When a hardware partition number is given, the block device switches to
+ * that hardware partition.
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev_str: Device and optional hw partition. This can either be a string
+ * containing the device number (e.g. "2") or the device number
+ * and hardware partition number (e.g. "2.4") for devices that
+ * support it (currently only MMC).
+ * @dev_desc: Returns a pointer to the block device on success
+ * @return block device number (local to the interface), or -1 on error
+ */
+int blk_get_device_by_str(const char *ifname, const char *dev_str,
+ struct blk_desc **dev_desc);
+
+/**
+ * blk_get_device_part_str() - Get a block device and partition
+ *
+ * This calls blk_get_device_by_str() to look up a device. It also looks up
+ * a partition and returns information about it.
+ *
+ * @dev_part_str is in the format:
+ * <dev>.<hw_part>:<part> where <dev> is the device number,
+ * <hw_part> is the optional hardware partition number and
+ * <part> is the partition number
+ *
+ * If ifname is "hostfs" then this function returns the sandbox host block
+ * device.
+ *
+ * If ifname is ubi, then this function returns 0, with @info set to a
+ * special UBI device.
+ *
+ * If @dev_part_str is NULL or empty or "-", then this function looks up
+ * the "bootdevice" environment variable and uses that string instead.
+ *
+ * If the partition string is empty then the first partition is used. If the
+ * partition string is "auto" then the first bootable partition is used.
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev_part_str: Device and partition string
+ * @dev_desc: Returns a pointer to the block device on success
+ * @info: Returns partition information
+ * @allow_whole_dev: true to allow the user to select partition 0
+ * (which means the whole device), false to require a valid
+ * partition number >= 1
+ * @return partition number, or -1 on error
+ *
+ */
+int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
+ struct blk_desc **dev_desc,
+ disk_partition_t *info, int allow_whole_dev);
#else
-static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
+static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
{ return NULL; }
-static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
-static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
-static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
-static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
-static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *ide_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *sata_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *scsi_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *usb_stor_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *mmc_get_dev(int dev) { return NULL; }
static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; }
-static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
-static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
-static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }
+static inline struct blk_desc *host_get_dev(int dev) { return NULL; }
-static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
- disk_partition_t *info) { return -1; }
-static inline void print_part (block_dev_desc_t *dev_desc) {}
-static inline void init_part (block_dev_desc_t *dev_desc) {}
-static inline void dev_print(block_dev_desc_t *dev_desc) {}
-static inline int get_device(const char *ifname, const char *dev_str,
- block_dev_desc_t **dev_desc)
+static inline int part_get_info(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info) { return -1; }
+static inline void part_print(struct blk_desc *dev_desc) {}
+static inline void part_init(struct blk_desc *dev_desc) {}
+static inline void dev_print(struct blk_desc *dev_desc) {}
+static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
+ struct blk_desc **dev_desc)
{ return -1; }
-static inline int get_device_and_partition(const char *ifname,
+static inline int blk_get_device_part_str(const char *ifname,
const char *dev_part_str,
- block_dev_desc_t **dev_desc,
+ struct blk_desc **dev_desc,
disk_partition_t *info,
int allow_whole_dev)
{ *dev_desc = NULL; return -1; }
#endif
-#ifdef CONFIG_MAC_PARTITION
-/* disk/part_mac.c */
-int get_partition_info_mac (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
-void print_part_mac (block_dev_desc_t *dev_desc);
-int test_part_mac (block_dev_desc_t *dev_desc);
+/*
+ * We don't support printing partition information in SPL and only support
+ * getting partition information in a few cases.
+ */
+#ifdef CONFIG_SPL_BUILD
+# define part_print_ptr(x) NULL
+# if defined(CONFIG_SPL_EXT_SUPPORT) || \
+ defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
+# define part_get_info_ptr(x) x
+# else
+# define part_get_info_ptr(x) NULL
+# endif
+#else
+#define part_print_ptr(x) x
+#define part_get_info_ptr(x) x
#endif
-#ifdef CONFIG_DOS_PARTITION
-/* disk/part_dos.c */
-int get_partition_info_dos (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
-void print_part_dos (block_dev_desc_t *dev_desc);
-int test_part_dos (block_dev_desc_t *dev_desc);
-#endif
-#ifdef CONFIG_ISO_PARTITION
-/* disk/part_iso.c */
-int get_partition_info_iso (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
-void print_part_iso (block_dev_desc_t *dev_desc);
-int test_part_iso (block_dev_desc_t *dev_desc);
-#endif
+struct part_driver {
+ const char *name;
+ int part_type;
-#ifdef CONFIG_AMIGA_PARTITION
-/* disk/part_amiga.c */
-int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
-void print_part_amiga (block_dev_desc_t *dev_desc);
-int test_part_amiga (block_dev_desc_t *dev_desc);
-#endif
+ /**
+ * get_info() - Get information about a partition
+ *
+ * @dev_desc: Block device descriptor
+ * @part: Partition number (1 = first)
+ * @info: Returns partition information
+ */
+ int (*get_info)(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info);
+
+ /**
+ * print() - Print partition information
+ *
+ * @dev_desc: Block device descriptor
+ */
+ void (*print)(struct blk_desc *dev_desc);
+
+ /**
+ * test() - Test if a device contains this partition type
+ *
+ * @dev_desc: Block device descriptor
+ * @return 0 if the block device appears to contain this partition
+ * type, -ve if not
+ */
+ int (*test)(struct blk_desc *dev_desc);
+};
+
+/* Declare a new U-Boot partition 'driver' */
+#define U_BOOT_PART_TYPE(__name) \
+ ll_entry_declare(struct part_driver, __name, part_driver)
#ifdef CONFIG_EFI_PARTITION
#include <part_efi.h>
/* disk/part_efi.c */
-int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
/**
- * get_partition_info_efi_by_name() - Find the specified GPT partition table entry
+ * part_get_info_efi_by_name() - Find the specified GPT partition table entry
*
* @param dev_desc - block device descriptor
* @param gpt_name - the specified table entry name
@@ -193,10 +259,8 @@ int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partitio
*
* @return - '0' on match, '-1' on no match, otherwise error
*/
-int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc,
- const char *name, disk_partition_t *info);
-void print_part_efi (block_dev_desc_t *dev_desc);
-int test_part_efi (block_dev_desc_t *dev_desc);
+int part_get_info_efi_by_name(struct blk_desc *dev_desc,
+ const char *name, disk_partition_t *info);
/**
* write_gpt_table() - Write the GUID Partition Table to disk
@@ -207,7 +271,7 @@ int test_part_efi (block_dev_desc_t *dev_desc);
*
* @return - zero on success, otherwise error
*/
-int write_gpt_table(block_dev_desc_t *dev_desc,
+int write_gpt_table(struct blk_desc *dev_desc,
gpt_header *gpt_h, gpt_entry *gpt_e);
/**
@@ -233,7 +297,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
*
* @return - error on str_guid conversion error
*/
-int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
+int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
char *str_guid, int parts_count);
/**
@@ -246,7 +310,7 @@ int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
*
* @return zero on success
*/
-int gpt_restore(block_dev_desc_t *dev_desc, char *str_disk_guid,
+int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid,
disk_partition_t *partitions, const int parts_count);
/**
@@ -257,7 +321,7 @@ int gpt_restore(block_dev_desc_t *dev_desc, char *str_disk_guid,
*
* @return - '0' on success, otherwise error
*/
-int is_valid_gpt_buf(block_dev_desc_t *dev_desc, void *buf);
+int is_valid_gpt_buf(struct blk_desc *dev_desc, void *buf);
/**
* write_mbr_and_gpt_partitions() - write MBR, Primary GPT and Backup GPT
@@ -267,7 +331,7 @@ int is_valid_gpt_buf(block_dev_desc_t *dev_desc, void *buf);
*
* @return - '0' on success, otherwise error
*/
-int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf);
+int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf);
/**
* gpt_verify_headers() - Function to read and CRC32 check of the GPT's header
@@ -281,7 +345,7 @@ int write_mbr_and_gpt_partitions(block_dev_desc_t *dev_desc, void *buf);
*
* @return - '0' on success, otherwise error
*/
-int gpt_verify_headers(block_dev_desc_t *dev_desc, gpt_header *gpt_head,
+int gpt_verify_headers(struct blk_desc *dev_desc, gpt_header *gpt_head,
gpt_entry **gpt_pte);
/**
@@ -300,7 +364,7 @@ int gpt_verify_headers(block_dev_desc_t *dev_desc, gpt_header *gpt_head,
*
* @return - '0' on success, otherwise error
*/
-int gpt_verify_partitions(block_dev_desc_t *dev_desc,
+int gpt_verify_partitions(struct blk_desc *dev_desc,
disk_partition_t *partitions, int parts,
gpt_header *gpt_head, gpt_entry **gpt_pte);
#endif
diff --git a/include/reiserfs.h b/include/reiserfs.h
index 2d14d48fe0..ffe4e466d9 100644
--- a/include/reiserfs.h
+++ b/include/reiserfs.h
@@ -63,7 +63,7 @@ typedef enum
} reiserfs_error_t;
-extern void reiserfs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
+void reiserfs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
extern int reiserfs_ls (char *dirname);
extern int reiserfs_open (char *filename);
extern int reiserfs_read (char *buf, unsigned len);
diff --git a/include/sandboxblockdev.h b/include/sandboxblockdev.h
index 627787aa32..5174f45f5e 100644
--- a/include/sandboxblockdev.h
+++ b/include/sandboxblockdev.h
@@ -8,7 +8,9 @@
#define __SANDBOX_BLOCK_DEV__
struct host_block_dev {
- block_dev_desc_t blk_dev;
+#ifndef CONFIG_BLK
+ struct blk_desc blk_dev;
+#endif
char *filename;
int fd;
};
diff --git a/include/sandboxfs.h b/include/sandboxfs.h
index 4c7745de91..6e6e3c62ff 100644
--- a/include/sandboxfs.h
+++ b/include/sandboxfs.h
@@ -18,7 +18,7 @@
#ifndef __SANDBOX_FS__
#define __SANDBOX_FS__
-int sandbox_fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
+int sandbox_fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer,
loff_t maxsize, loff_t *actread);
diff --git a/include/sata.h b/include/sata.h
index fa61da8ddd..b35359aa5a 100644
--- a/include/sata.h
+++ b/include/sata.h
@@ -14,6 +14,6 @@ int sata_stop(void);
int __sata_stop(void);
int sata_port_status(int dev, int port);
-extern block_dev_desc_t sata_dev_desc[];
+extern struct blk_desc sata_dev_desc[];
#endif
diff --git a/include/spl.h b/include/spl.h
index 16f2f6a9ee..de4f70a377 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -90,14 +90,16 @@ int spl_usb_load_image(void);
int spl_sata_load_image(void);
/* SPL FAT image functions */
-int spl_load_image_fat(block_dev_desc_t *block_dev, int partition, const char *filename);
-int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition);
+int spl_load_image_fat(struct blk_desc *block_dev, int partition,
+ const char *filename);
+int spl_load_image_fat_os(struct blk_desc *block_dev, int partition);
void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
/* SPL EXT image functions */
-int spl_load_image_ext(block_dev_desc_t *block_dev, int partition, const char *filename);
-int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition);
+int spl_load_image_ext(struct blk_desc *block_dev, int partition,
+ const char *filename);
+int spl_load_image_ext_os(struct blk_desc *block_dev, int partition);
/**
* spl_init() - Set up device tree and driver model in SPL if enabled
diff --git a/include/systemace.h b/include/systemace.h
index 3f342d565c..3b6ec7da4b 100644
--- a/include/systemace.h
+++ b/include/systemace.h
@@ -11,7 +11,7 @@
# include <part.h>
-block_dev_desc_t * systemace_get_dev(int dev);
+struct blk_desc *systemace_get_dev(int dev);
#endif /* CONFIG_SYSTEMACE */
#endif /* __SYSTEMACE_H */
diff --git a/include/ubifs_uboot.h b/include/ubifs_uboot.h
index dab433a39f..d86da277b0 100644
--- a/include/ubifs_uboot.h
+++ b/include/ubifs_uboot.h
@@ -21,7 +21,7 @@ void uboot_ubifs_umount(void);
int ubifs_is_mounted(void);
int ubifs_load(char *filename, u32 addr, u32 size);
-int ubifs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
+int ubifs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
int ubifs_ls(const char *dir_name);
int ubifs_exists(const char *filename);
int ubifs_size(const char *filename, loff_t *size);
diff --git a/include/usb.h b/include/usb.h
index 0b410b6cd1..c2fa6849f1 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -228,7 +228,7 @@ int board_usb_cleanup(int index, enum usb_init_type init);
#ifdef CONFIG_USB_STORAGE
#define USB_MAX_STOR_DEV 7
-block_dev_desc_t *usb_stor_get_dev(int index);
+struct blk_desc *usb_stor_get_dev(int index);
int usb_stor_scan(int mode);
int usb_stor_info(void);
diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
index 5804b70c35..8229f62b97 100644
--- a/include/usb_mass_storage.h
+++ b/include/usb_mass_storage.h
@@ -23,7 +23,7 @@ struct ums {
unsigned int start_sector;
unsigned int num_sectors;
const char *name;
- block_dev_desc_t block_dev;
+ struct blk_desc block_dev;
};
int fsg_init(struct ums *ums_devs, int count);
diff --git a/include/zfs_common.h b/include/zfs_common.h
index 3bd575ef5f..bca3dff06e 100644
--- a/include/zfs_common.h
+++ b/include/zfs_common.h
@@ -63,7 +63,7 @@ enum zfs_errors {
struct zfs_filesystem {
/* Block Device Descriptor */
- block_dev_desc_t *dev_desc;
+ struct blk_desc *dev_desc;
};
struct device_s {
@@ -98,7 +98,7 @@ int zfs_close(zfs_file_t);
int zfs_ls(device_t dev, const char *path,
int (*hook) (const char *, const struct zfs_dirhook_info *));
int zfs_devread(int sector, int byte_offset, int byte_len, char *buf);
-void zfs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
+void zfs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
void zfs_unmount(struct zfs_data *data);
int lzjb_decompress(void *, void *, uint32_t, uint32_t);
#endif
OpenPOWER on IntegriCloud