summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-15 13:50:04 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2007-07-15 13:50:04 +0200
commit665291e693efd1fd2955c6f8bfb89956711b0aef (patch)
tree0c9d871da372b4a640a9760f8946a8a57e3fbbba /fs
parent9b3761c4459167a335d3a1c30543824afa2d654d (diff)
downloadbarebox-665291e693efd1fd2955c6f8bfb89956711b0aef.tar.gz
barebox-665291e693efd1fd2955c6f8bfb89956711b0aef.tar.xz
implement memmap().
With this function we can get a pointer to directly memory mapped devices like nor flash or RAM. Useful for bootm where we save one memcopy when the image is mappable
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs.c8
-rw-r--r--fs/fs.c19
2 files changed, 27 insertions, 0 deletions
diff --git a/fs/devfs.c b/fs/devfs.c
index 5e60362f3f..aafcc34439 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -50,6 +50,13 @@ static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, unsigned lo
return dev_erase(dev, count, offset);
}
+static int devfs_memmap(struct device_d *_dev, FILE *f, void **map, int flags)
+{
+ struct device_d *dev = f->inode;
+
+ return dev_memmap(dev, map, flags);
+}
+
static int devfs_open(struct device_d *_dev, FILE *file, const char *filename)
{
struct device_d *dev = get_device_by_id(filename + 1);
@@ -146,6 +153,7 @@ static struct fs_driver_d devfs_driver = {
.closedir = devfs_closedir,
.stat = devfs_stat,
.erase = devfs_erase,
+ .memmap = devfs_memmap,
.flags = FS_DRIVER_NO_DEV,
.drv = {
.type = DEVICE_TYPE_FS,
diff --git a/fs/fs.c b/fs/fs.c
index 51e59309d8..57d75ddb3b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -516,6 +516,25 @@ int erase(int fd, size_t count, unsigned long offset)
return errno;
}
+void *memmap(int fd, int flags)
+{
+ struct device_d *dev;
+ struct fs_driver_d *fsdrv;
+ FILE *f = &files[fd];
+ void *ret = NULL;
+
+ dev = f->dev;
+
+ fsdrv = (struct fs_driver_d *)dev->driver->type_data;
+
+ if (fsdrv->memmap)
+ errno = fsdrv->memmap(dev, f, &ret, flags);
+ else
+ errno = -EINVAL;
+
+ return ret;
+}
+
int close(int fd)
{
struct device_d *dev;