All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Herrmann <morpheus.ibis@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/11] DM: add block device core
Date: Thu, 20 Sep 2012 21:37:37 +0200	[thread overview]
Message-ID: <1348169867-2917-2-git-send-email-morpheus.ibis@gmail.com> (raw)
In-Reply-To: <1348169867-2917-1-git-send-email-morpheus.ibis@gmail.com>

This core will register all block devices (disk, cards, partitons) and provide
unfied access to them, instead of current method with device + partition offset

Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com>
---
 Makefile                  |   1 +
 drivers/blockdev/Makefile |  42 ++++++++++++++++
 include/dm/blockdev.h     | 121 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+)
 create mode 100644 drivers/blockdev/Makefile
 create mode 100644 include/dm/blockdev.h

diff --git a/Makefile b/Makefile
index ba74696..e43fd9d 100644
--- a/Makefile
+++ b/Makefile
@@ -303,6 +303,7 @@ LIBS-y += test/libtest.o
 
 LIBS-$(CONFIG_DM) += common/dm/libdm.o
 LIBS-$(CONFIG_DM) += drivers/demo/libdemo.o
+LIBS-${CONFIG_DM_BLOCK} += drivers/blockdev/libblockdev.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
diff --git a/drivers/blockdev/Makefile b/drivers/blockdev/Makefile
new file mode 100644
index 0000000..693e236
--- /dev/null
+++ b/drivers/blockdev/Makefile
@@ -0,0 +1,42 @@
+# 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.
+#
+# 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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	:= $(obj)libblockdev.o
+
+COBJS-${CONFIG_DM_BLOCK} := core.o
+
+COBJS	:= $(COBJS-y)
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/include/dm/blockdev.h b/include/dm/blockdev.h
new file mode 100644
index 0000000..828eb2b
--- /dev/null
+++ b/include/dm/blockdev.h
@@ -0,0 +1,121 @@
+/*
+ * (C) Copyright 2012
+ * Pavel Herrmann <morpheus.ibis@gmail.com>
+ *
+ * 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.
+ *
+ * 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
+ */
+
+#ifndef _DM_BLOCKDEV_H_
+#define _DM_BLOCKDEV_H_ 1
+
+#include <dm/options.h>
+#include <dm/structures.h>
+
+#define BLOCKDEV_IFTYPE_BITS 4
+#define BLOCKDEV_IFTYPE_COUNT (1<<BLOCKDEV_IFTYPE_BITS)
+#define BLOCKDEV_IFTYPE_MAX BLOCKDEV_IFTYPE_COUNT-1
+
+/* core interface structures */
+
+enum blockdev_iftype {
+	BLOCKDEV_IFTYPE_UNKNOWN = 0,
+	BLOCKDEV_IFTYPE_PARTITION,
+	BLOCKDEV_IFTYPE_ATA,
+	BLOCKDEV_IFTYPE_SD,
+	BLOCKDEV_IFTYPE_USB,
+};
+
+/* values from ATA specification */
+#define BLOCKDEV_TYPE_UNKNOWN	0xff
+#define BLOCKDEV_TYPE_HARDDISK	0x00
+#define BLOCKDEV_TYPE_TAPE	0x01
+#define BLOCKDEV_TYPE_CDROM	0x05
+#define BLOCKDEV_TYPE_OPDISK	0x07
+/* this one does not exist in ATA */
+#define BLOCKDEV_TYPE_PARTITION	0xfe
+
+enum blockdev_option_code {
+	BLKD_OPT_IFTYPE = 0,
+	BLKD_OPT_TYPE,
+	BLKD_OPT_BLOCKSIZE,
+	BLKD_OPT_BLOCKCOUNT,
+	BLKD_OPT_REMOVABLE,
+	BLKD_OPT_LBA48,
+	BLKD_OPT_VENDOR,
+	BLKD_OPT_PRODUCT,
+	BLKD_OPT_REVISION,
+	BLKD_OPT_SCSILUN,
+	BLKD_OPT_SCSITARGET,
+	BLKD_OPT_OFFSET
+};
+
+struct blockdev_ops {
+	lbaint_t	(*read)(struct instance *inst, lbaint_t start,
+				lbaint_t blkcnt, void *buffer);
+	lbaint_t	(*write)(struct instance *inst, lbaint_t start,
+				lbaint_t blkcnt, void *buffer);
+	lbaint_t	(*erase)(struct instance *inst, lbaint_t start,
+				lbaint_t blkcnt);
+	int		(*get_option)(struct instance *inst,
+				enum blockdev_option_code option,
+				struct option *result);
+	int		(*set_option)(struct instance *inst,
+				enum blockdev_option_code option,
+				struct option *value);
+};
+
+struct blockdev_core_hint {
+	enum blockdev_iftype iftype;
+	unsigned int part_number;
+};
+
+/* platform data for devices */
+
+struct blockdev_ata_platform_data {
+	int port_number;
+};
+
+struct blockdev_partition_platform_data {
+	lbaint_t offset;
+	lbaint_t block_count;
+	unsigned int part_number;
+};
+
+/* core command API */
+
+struct instance *get_blockdev_by_name(char *name);
+int scan_partitions(struct instance *i);
+int add_partition(struct instance *parent, lbaint_t start, lbaint_t length,
+	unsigned int number);
+int print_blockdev_info(struct instance *i);
+int print_blockdev_info_all(void);
+
+/* core driver API */
+
+lbaint_t blockdev_read(struct instance *i, lbaint_t start, lbaint_t blkcnt,
+		void *buffer);
+lbaint_t blockdev_write(struct instance *i, lbaint_t start, lbaint_t blkcnt,
+		void *buffer);
+lbaint_t blockdev_erase(struct instance *i, lbaint_t start, lbaint_t blkcnt);
+int blockdev_get_option(struct instance *i, enum blockdev_option_code op,
+		struct option *result);
+int blockdev_set_option(struct instance *i, enum blockdev_option_code op,
+		struct option *value);
+
+#endif
-- 
1.7.12

  reply	other threads:[~2012-09-20 19:37 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-20 19:37 [U-Boot] [PATCH 00/11] Add DM blockdev subsystem Pavel Herrmann
2012-09-20 19:37 ` Pavel Herrmann [this message]
2012-09-20 19:58   ` [U-Boot] [PATCH 01/11] DM: add block device core Marek Vasut
2012-09-21  7:11     ` Pavel Herrmann
2012-09-21 12:39       ` Marek Vasut
2012-09-21 13:27         ` Pavel Herrmann
2012-09-21 13:53           ` Marek Vasut
2012-09-21 14:57             ` Pavel Herrmann
2012-09-21 15:34               ` Marek Vasut
2012-09-21 15:48                 ` Pavel Herrmann
2012-09-21 15:55                   ` Marek Vasut
2012-09-21 17:19                     ` Pavel Herrmann
2012-09-21 18:00                       ` Marek Vasut
2012-09-21 18:53                         ` Pavel Herrmann
2012-09-21 19:17                           ` Marek Vasut
2012-09-21 19:29                             ` Pavel Herrmann
2012-09-21 21:11                               ` Marek Vasut
2012-09-21 23:43                                 ` Pavel Herrmann
2012-09-22  0:09                                   ` Marek Vasut
2012-09-22  9:39                                     ` Pavel Herrmann
2012-09-22 13:33                                       ` Marek Vasut
2012-09-22 13:59                                         ` Pavel Herrmann
2012-09-24 12:23                                           ` Pavel Herrmann
2012-09-20 20:49   ` [U-Boot] [U-Boot-DM] " Vikram Narayanan
2012-09-21  7:09     ` Pavel Herrmann
2012-09-21 12:39       ` Marek Vasut
2012-09-20 19:37 ` [U-Boot] [PATCH 02/11] DM: add support for scanning DOS partitions to blockdev core Pavel Herrmann
2012-09-20 20:03   ` Marek Vasut
2012-09-21  7:22     ` Pavel Herrmann
2012-09-21 12:47       ` Marek Vasut
2012-09-21 13:18         ` Pavel Herrmann
2012-09-21 13:54           ` Marek Vasut
2012-09-20 19:37 ` [U-Boot] [PATCH 03/11] DM: add block controller core Pavel Herrmann
2012-09-20 20:05   ` Marek Vasut
2012-09-21  7:21     ` Pavel Herrmann
2012-09-21 12:51       ` Marek Vasut
2012-09-21 13:14         ` Pavel Herrmann
2012-09-21 13:56           ` Marek Vasut
2012-09-21 15:04             ` Pavel Herrmann
2012-09-21 13:33         ` Pavel Herrmann
2012-09-21 13:58           ` Marek Vasut
2012-09-21 15:09             ` Pavel Herrmann
2012-09-21 15:39               ` Marek Vasut
2012-09-21 15:46                 ` Pavel Herrmann
2012-09-21 16:08                   ` Marek Vasut
2012-09-21 17:22                     ` Pavel Herrmann
2012-09-21 18:01                       ` Marek Vasut
2012-09-21 19:15                         ` Pavel Herrmann
2012-09-21 19:22                           ` Marek Vasut
2012-09-20 19:37 ` [U-Boot] [PATCH 04/11] DM: add sata_legacy driver for blockctrl Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 05/11] DM: add ata and partition blockdev drivers Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 06/11] DM: add cmd_block command Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 07/11] DM: use new blockdev API in FAT Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 08/11] DM: use new blockdev API in ext2 Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 09/11] DM: use new blockdev API in reiserfs Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 10/11] DM: use new blockdev API in ZFS Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 11/11] DM: switch sandbox to DM blockdev Pavel Herrmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348169867-2917-2-git-send-email-morpheus.ibis@gmail.com \
    --to=morpheus.ibis@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.