diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-01-22 15:40:43 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-22 22:03:44 +0100 |
commit | df132b9d7854507f7501b20d7134dd18c0c63f2b (patch) | |
tree | fe8daa797f0f49502b0008d8380de481c29554d6 /lib/bootstrap/disk.c | |
parent | 345dd514671a0afcad6b0d3291bca8c067b3930c (diff) | |
download | barebox-df132b9d7854507f7501b20d7134dd18c0c63f2b.tar.gz barebox-df132b9d7854507f7501b20d7134dd18c0c63f2b.tar.xz |
introduce common bootstrap code
This will allow to have a generic code to create different bootstrap
As example
Barebox as TI Xloader
Barebox as AT91 Bootstrap
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/bootstrap/disk.c')
-rw-r--r-- | lib/bootstrap/disk.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c new file mode 100644 index 0000000000..879d3315e8 --- /dev/null +++ b/lib/bootstrap/disk.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011 Sascha Hauer, Pengutronix + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com> + * + * Under GPLv2 + */ + +#include <common.h> +#include <fs.h> +#include <fcntl.h> +#include <sizes.h> +#include <errno.h> +#include <malloc.h> +#include <bootstrap.h> + +void* bootstrap_read_disk(char *dev, char *fstype) +{ + int ret; + void *buf; + int len; + char *path = "/"; + + ret = mount(dev, fstype, path); + if (ret) { + bootstrap_err("mounting %s failed with %d\n", dev, ret); + return NULL; + } + + buf = read_file("/barebox.bin", &len); + if (!buf) { + bootstrap_err("could not read barebox.bin from %s\n", dev); + umount(path); + return NULL; + } + + return buf; +} |