summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:38 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:38 +0200
commitcf7a56fc78a3304fd9ad4b22c6da30cc452a5b4b (patch)
treed74423adf47b86daea48bac089b9ecc32afe4d42 /common
parent5c1f0869414930fdebc35755217ead72d39879ec (diff)
downloadbarebox-cf7a56fc78a3304fd9ad4b22c6da30cc452a5b4b.tar.gz
barebox-cf7a56fc78a3304fd9ad4b22c6da30cc452a5b4b.tar.xz
svn_rev_268
WIP
Diffstat (limited to 'common')
-rw-r--r--common/Makefile3
-rw-r--r--common/cmd_flash.c2
-rw-r--r--common/cmd_mem.c23
-rw-r--r--common/env.c6
-rw-r--r--common/mtdpart.c4
5 files changed, 23 insertions, 15 deletions
diff --git a/common/Makefile b/common/Makefile
index bbbf8ad0c9..e0e4cd044c 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -90,3 +90,6 @@ obj-y += mtdpart.o
obj-y += env.o
obj-y += startup.o
obj-y += misc.o
+
+obj-y += cmd_fs.o
+
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index 4395ca930e..43c44f2818 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -51,7 +51,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
- erase(mem.device, mem.size, mem.start);
+ dev_erase(mem.device, mem.size, mem.start);
return 0;
}
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 1da58d22bb..0a026f6b2a 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -131,9 +131,9 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
do {
now = min(RW_BUF_SIZE, nbytes);
- r = read(mem.device, rw_buf, now, offs, RW_SIZE(size));
+ r = dev_read(mem.device, rw_buf, now, offs, RW_SIZE(size));
if (r <= 0) {
- perror("read", r);
+ perror("read");
return r;
}
@@ -184,7 +184,7 @@ int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
count = size;
if (count == size) {
- return write(mem.device, (uchar *)&writeval, count, mem.start, RW_SIZE(size));
+ return dev_write(mem.device, (uchar *)&writeval, count, mem.start, RW_SIZE(size));
} else {
printf("write multiple not yet implemented\n");
}
@@ -300,11 +300,11 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
while (count > 0) {
now = min(RW_BUF_SIZE, count);
- ret = read(src.device, rw_buf, now, src.start + offset, RW_SIZE(size));
+ ret = dev_read(src.device, rw_buf, now, src.start + offset, RW_SIZE(size));
if (ret <= 0)
return ret;
- ret = write(dst.device, rw_buf, ret, dst.start + offset, RW_SIZE(size));
+ ret = dev_write(dst.device, rw_buf, ret, dst.start + offset, RW_SIZE(size));
if (ret <= 0)
return ret;
if (ret < now)
@@ -432,14 +432,19 @@ static void memcpy_sz(void *_dst, void *_src, ulong count, ulong rwsize)
ssize_t mem_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong rwflags)
{
- memcpy_sz(buf, (void *)(dev->map_base + offset), count, rwflags & RW_SIZE_MASK);
- return count;
+ ulong size;
+ size = min(count, dev->size - offset);
+ printf("mem_read: dev->map_base: %p size: %d offset: %d\n",dev->map_base, size, offset);
+ memcpy_sz(buf, (void *)(dev->map_base + offset), size, rwflags & RW_SIZE_MASK);
+ return size;
}
ssize_t mem_write(struct device_d *dev, void *buf, size_t count, ulong offset, ulong rwflags)
{
- memcpy_sz((void *)(dev->map_base + offset), buf, count, rwflags & RW_SIZE_MASK);
- return count;
+ ulong size;
+ size = min(count, dev->size - offset);
+ memcpy_sz((void *)(dev->map_base + offset), buf, size, rwflags & RW_SIZE_MASK);
+ return size;
}
static struct device_d mem_dev = {
diff --git a/common/env.c b/common/env.c
index d8fb867957..8a69017218 100644
--- a/common/env.c
+++ b/common/env.c
@@ -123,7 +123,7 @@ int add_env_spec(char *spec)
env_list->next = NULL;
- err = read(info.device, env, env_size, info.start, 0);
+ err = dev_read(info.device, env, env_size, info.start, 0);
if (err != env_size)
goto err_out;
@@ -206,13 +206,13 @@ int saveenv(void)
*(ulong *)env = crc32(0, env + sizeof(ulong), env_size - sizeof(ulong));
- ret = erase(info.device, info.size, info.start);
+ ret = dev_erase(info.device, info.size, info.start);
if (ret) {
printf("unable to erase\n");
goto err_out;
}
- ret = write(info.device, env, info.size, info.start, 0);
+ ret = dev_write(info.device, env, info.size, info.start, 0);
if (ret < 0) {
printf("unable to write\n");
goto err_out;
diff --git a/common/mtdpart.c b/common/mtdpart.c
index 788aeda060..3b4cc7f715 100644
--- a/common/mtdpart.c
+++ b/common/mtdpart.c
@@ -196,14 +196,14 @@ ssize_t part_read(struct device_d *dev, void *buf, size_t count, unsigned long o
{
struct partition *part = dev->platform_data;
- return read(part->parent, buf, count, offset + part->offset, flags);
+ return dev_read(part->parent, buf, count, offset + part->offset, flags);
}
ssize_t part_write(struct device_d *dev, void *buf, size_t count, unsigned long offset, ulong flags)
{
struct partition *part = dev->platform_data;
- return write(part->parent, buf, count, offset + part->offset, flags);
+ return dev_write(part->parent, buf, count, offset + part->offset, flags);
}
struct driver_d part_driver = {