barebox/include/block.h
Sascha Hauer e3a9e1fd62 block: reimplement caching
The current caching layer only has a single buffer for
writing and reading. The FAT driver often accesses the
fat and then data again, which currently can't be cached.
Reimplement this with a list of cached chunks. The number
of chunks and their sizes are currently hardcoded, but
that could be easily made configurable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-15 08:21:43 +01:00

35 lines
765 B
C

#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);
int (*read_start)(struct block_device *, void *buf, int block, int num_blocks);
int (*read_done)(struct block_device *);
};
struct chunk;
struct block_device {
struct device_d *dev;
struct block_device_ops *ops;
int blockbits;
int num_blocks;
int rdbufsize;
int blkmask;
struct list_head buffered_blocks;
struct list_head idle_blocks;
struct cdev cdev;
};
int blockdevice_register(struct block_device *blk);
int blockdevice_unregister(struct block_device *blk);
#endif /* __BLOCK_H */