diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-03-24 13:52:39 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-04-11 15:57:51 +0200 |
commit | 61f41e3c548e5ab5194511727045409721e2c8bd (patch) | |
tree | 71de089186df814e837edc65b2eba49ada13ea66 /include/block.h | |
parent | 77e8307b322085f838bcc3dd523436d5925ba664 (diff) | |
download | barebox-61f41e3c548e5ab5194511727045409721e2c8bd.tar.gz barebox-61f41e3c548e5ab5194511727045409721e2c8bd.tar.xz |
add block support
This adds a simple block layer to barebox. Reading and writing
to block devices can be painfully slow without caching, so
add a simple caching layer here.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/block.h')
-rw-r--r-- | include/block.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/block.h b/include/block.h new file mode 100644 index 0000000000..aaab4e3b36 --- /dev/null +++ b/include/block.h @@ -0,0 +1,32 @@ +#ifndef __BLOCK_H +#define __BLOCK_H + +#include <driver.h> + +struct block_device; + +struct block_device_ops { + int (*read)(struct block_device *, void *buf, int block, int num_blocks); + int (*write)(struct block_device *, const void *buf, int block, int num_blocks); +}; + +struct block_device { + struct device_d *dev; + struct block_device_ops *ops; + int blockbits; + int num_blocks; + void *rdbuf; /* read buffer */ + int rdbufsize; + int rdblock; /* start block in read buffer */ + int rdblockend; /* end block in read buffer */ + void *wrbuf; /* write buffer */ + int wrblock; /* start block in write buffer */ + int wrbufblocks; /* number of blocks currently in write buffer */ + int wrbufsize; /* size of write buffer in blocks */ + struct cdev cdev; +}; + +int blockdevice_register(struct block_device *blk); +int blockdevice_unregister(struct block_device *blk); + +#endif /* __BLOCK_H */ |