From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: vj <vicencb@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 8/9] omap4: add filesystem support over usb boot
Date: Sun, 30 Sep 2012 15:53:56 +0200 [thread overview]
Message-ID: <20120930135356.GP26553@game.jcrosoft.org> (raw)
In-Reply-To: <1348973437-31132-9-git-send-email-vicencb@gmail.com>
On 04:50 Sun 30 Sep , vj wrote:
> ---
> arch/arm/mach-omap/xload.c | 26 ++++++
> fs/Kconfig | 5 +
> fs/Makefile | 1 +
> fs/omap4_usbbootfs.c | 223 +++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 255 insertions(+)
> create mode 100644 fs/omap4_usbbootfs.c
>
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 225b19a..5fda314 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -54,6 +54,26 @@ void *omap_xload_boot_mmc(void)
> return buf;
> }
>
> +#ifdef CONFIG_FS_OMAP4_USBBOOT
drop the ifdef
> +void *omap4_xload_boot_usb(void){
> + int ret;
> + void *buf;
> + int len;
> +
> + ret = mount("omap4_usbboot", "omap4_usbbootfs", "/");
> + if (ret) {
> + printf("Unable to mount omap4_usbbootfs (%d)\n", ret);
> + return NULL;
> + }
> +
> + buf = read_file("/barebox.bin", &len);
> + if (!buf)
> + printf("could not read barebox.bin from omap4_usbbootfs\n");
> +
> + return buf;
> +}
> +#endif
> +
> enum omap_boot_src omap_bootsrc(void)
> {
> #if defined(CONFIG_ARCH_OMAP3)
> @@ -76,6 +96,12 @@ int run_shell(void)
> printf("booting from MMC1\n");
> func = omap_xload_boot_mmc();
> break;
> +#ifdef CONFIG_FS_OMAP4_USBBOOT
> + case OMAP_BOOTSRC_USB1:
if (IS_ENABLED(...) {
...
} else {
printf("booting from usb1 not enabled\n");
}
> + printf("booting from USB1\n");
> + func = omap4_xload_boot_usb();
> + break;
> +#endif
> case OMAP_BOOTSRC_UNKNOWN:
> default:
> printf("unknown boot source. Fall back to nand\n");
> diff --git a/fs/Kconfig b/fs/Kconfig
> index 4c66543..0ab69d7 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -29,6 +29,11 @@ config FS_TFTP
> prompt "tftp support"
> depends on NET
>
> +config FS_OMAP4_USBBOOT
> + bool
> + prompt "Filesystem over usb boot"
> + depends on OMAP4_USBBOOT
> +
> config FS_NFS
> depends on NET
> bool
> diff --git a/fs/Makefile b/fs/Makefile
> index 1b52bee..ad745d9 100644
> --- a/fs/Makefile
> +++ b/fs/Makefile
> @@ -5,4 +5,5 @@ obj-$(CONFIG_FS_DEVFS) += devfs.o
> obj-$(CONFIG_FS_FAT) += fat/
> obj-y += fs.o
> obj-$(CONFIG_FS_TFTP) += tftp.o
> +obj-$(CONFIG_FS_OMAP4_USBBOOT) += omap4_usbbootfs.o
> obj-$(CONFIG_FS_NFS) += nfs.o
> diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
> new file mode 100644
> index 0000000..874d530
> --- /dev/null
> +++ b/fs/omap4_usbbootfs.c
> @@ -0,0 +1,223 @@
> +/*
> + * omap4_usbbootfs.c
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * 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 <common.h>
> +#include <malloc.h>
> +#include <fs.h>
> +#include <fcntl.h>
> +#include <init.h>
> +#include <linux/stat.h>
> +#include <linux/err.h>
> +#include <mach/omap4_rom_usb.h>
> +
> +#define OMAP4_USBBOOT_FS_MAGIC 0x5562464D
> +#define OMAP4_USBBOOT_FS_CMD_OPEN 0x46530000
> +#define OMAP4_USBBOOT_FS_CMD_CLOSE 0x46530001
> +#define OMAP4_USBBOOT_FS_CMD_READ 0x46530002
> +#define OMAP4_USBBOOT_FS_CMD_END 0x4653FFFF
> +
> +struct file_priv {
> + s32 id;
> + u32 size;
> +};
> +/*
> +static int omap4_usbbootfs_create(
> + struct device_d *dev, const char *pathname, mode_t mode)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_unlink(struct device_d *dev, const char *pathname)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_mkdir(struct device_d *dev, const char *pathname)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_rmdir(struct device_d *dev, const char *pathname)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_write(
> + struct device_d *_dev, FILE *f, const void *inbuf, size_t size)
> +{
> + return -ENOSYS;
> +}
> +
> +static int omap4_usbbootfs_truncate(struct device_d *dev, FILE *f, ulong size)
> +{
> + return -ENOSYS;
> +}
> +*/
> +
> +static struct file_priv *omap4_usbbootfs_do_open(
> + struct device_d *dev, int accmode, const char *filename)
> +{
> + struct file_priv *priv;
> + u32 data;
> +
> + if (accmode & O_ACCMODE)
> + return ERR_PTR(-ENOSYS);
> +
> + priv = xzalloc(sizeof(*priv));
> + if (!priv)
> + return ERR_PTR(-ENOMEM);
> +
> + data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
> + data = OMAP4_USBBOOT_FS_CMD_OPEN; omap4_usbboot_write(&data, 4);
> + omap4_usbboot_puts(filename);
> + data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
> +
> + if (omap4_usbboot_read(&priv->id, 4) ||
> + omap4_usbboot_read(&priv->size, 4)
> + ) {
> + free(priv);
> + return ERR_PTR(-EIO);
> + }
> + if (priv->id < 0) {
> + free(priv);
> + return ERR_PTR(-ENOENT);
> + }
> +
> + return priv;
> +}
> +
> +static int omap4_usbbootfs_open(
> + struct device_d *dev, FILE *file, const char *filename)
> +{
> + struct file_priv *priv;
> +
> + priv = omap4_usbbootfs_do_open(dev, file->flags, filename);
> + if (IS_ERR(priv))
> + return PTR_ERR(priv);
> +
> + file->inode = priv;
> + file->size = priv->size;
> +
> + return 0;
> +}
> +
> +static int omap4_usbbootfs_do_close(struct file_priv *priv)
> +{
> + u32 data;
> + data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
> + data = OMAP4_USBBOOT_FS_CMD_CLOSE; omap4_usbboot_write(&data, 4);
> + omap4_usbboot_write(&priv->id, 4);
> + data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
> + free(priv);
> + return 0;
> +}
> +
> +static int omap4_usbbootfs_close(struct device_d *dev, FILE *f)
> +{
> + struct file_priv *priv = f->inode;
> + return omap4_usbbootfs_do_close(priv);
> +}
> +
> +static int omap4_usbbootfs_read(
> + struct device_d *dev, FILE *f, void *buf, size_t size)
> +{
> + struct file_priv *priv = f->inode;
> + u32 data;
> +
> + if (size > priv->size - f->pos)
> + size = priv->size - f->pos;
> + if (!size)
> + return 0;
> +
> + data = OMAP4_USBBOOT_FS_MAGIC ; omap4_usbboot_write(&data, 4);
> + data = OMAP4_USBBOOT_FS_CMD_READ; omap4_usbboot_write(&data, 4);
> + omap4_usbboot_write(&priv->id, 4);
> + omap4_usbboot_write(&f->pos, 4);
> + omap4_usbboot_write(&size, 4);
> + data = OMAP4_USBBOOT_FS_CMD_END ; omap4_usbboot_write(&data, 4);
> +
> + if (omap4_usbboot_read(buf, size))
> + return -EIO;
> +
> + return size;
> +}
> +
> +static loff_t omap4_usbbootfs_lseek(struct device_d *dev, FILE *f, loff_t pos)
> +{
> + f->pos = pos;
> + return pos;
> +}
> +
> +static DIR *omap4_usbbootfs_opendir(struct device_d *dev, const char *pathname)
> +{
> + return NULL;
> +}
> +
> +static int omap4_usbbootfs_stat(
> + struct device_d *dev, const char *filename, struct stat *s)
> +{
> + struct file_priv *priv;
> +
> + priv = omap4_usbbootfs_do_open(dev, O_RDONLY, filename);
> + if (IS_ERR(priv))
> + return PTR_ERR(priv);
> +
> + s->st_mode = S_IFREG |
> + S_IRUSR | S_IRGRP | S_IROTH |
> + S_IXUSR | S_IXGRP | S_IXOTH ;
> + s->st_size = priv->size;
> +
> + omap4_usbbootfs_do_close(priv);
> +
> + return 0;
> +}
> +
> +static int omap4_usbbootfs_probe(struct device_d *dev)
> +{
> + return 0;
> +}
> +static void omap4_usbbootfs_remove(struct device_d *dev)
> +{
> +}
> +
> +static struct fs_driver_d omap4_usbbootfs_driver = {
> + .open = omap4_usbbootfs_open,
> + .close = omap4_usbbootfs_close,
> + .read = omap4_usbbootfs_read,
> + .lseek = omap4_usbbootfs_lseek,
> + .opendir = omap4_usbbootfs_opendir,
> + .stat = omap4_usbbootfs_stat,
> +/*
> + .create = omap4_usbbootfs_create,
> + .unlink = omap4_usbbootfs_unlink,
> + .mkdir = omap4_usbbootfs_mkdir,
> + .rmdir = omap4_usbbootfs_rmdir,
> + .write = omap4_usbbootfs_write,
> + .truncate= omap4_usbbootfs_truncate,
> +*/
> + .flags = 0,
> + .drv = {
> + .probe = omap4_usbbootfs_probe,
> + .remove = omap4_usbbootfs_remove,
> + .name = "omap4_usbbootfs",
> + }
> +};
> +
> +static int omap4_usbbootfs_init(void)
> +{
> + return register_fs_driver(&omap4_usbbootfs_driver);
> +}
> +coredevice_initcall(omap4_usbbootfs_init);
> --
> 1.7.12.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-09-30 13:56 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-30 2:50 [PATCH 0/9] archosg9: add support for tablet, second round vj
2012-09-30 2:50 ` [PATCH 1/9] ARM: set rev instead of returning it vj
2012-09-30 2:50 ` [PATCH 2/9] mmc_omap: improve error message vj
2012-09-30 2:50 ` [PATCH 3/9] omap4: add/rename definitions to match datasheet vj
2012-09-30 2:50 ` [PATCH 4/9] twl6030: add debug info vj
2012-09-30 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:46 ` Sascha Hauer
2012-09-30 2:50 ` [PATCH 5/9] add gitignore file vj
2012-09-30 2:50 ` [PATCH 6/9] omap4: add usb boot support vj
2012-09-30 12:14 ` Antony Pavlov
2012-09-30 14:02 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` vj
2012-09-30 15:29 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 16:00 ` vj
2012-10-01 12:48 ` Sascha Hauer
2012-09-30 14:07 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:23 ` vj
2012-09-30 15:30 ` vj
[not found] ` <CAAMcf8B0Qif3zVfw44zx5G813fYrMQTfUKi86Kr+JuFm=yf5rQ@mail.gmail.com>
2012-09-30 15:32 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02 13:51 ` Sascha Hauer
2012-09-30 2:50 ` [PATCH 7/9] omap4: add serial communications over usb boot vj
2012-09-30 2:50 ` [PATCH 8/9] omap4: add filesystem support " vj
2012-09-30 13:53 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-09-30 2:50 ` [PATCH 9/9] Add support for Archos G9 tablet vj
2012-09-30 14:00 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 15:02 ` Antony Pavlov
2012-10-02 17:06 ` [PATCH 0/9] archosg9: add support for tablet, second round Sascha Hauer
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=20120930135356.GP26553@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
--cc=vicencb@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox