2009-11-21 01:45:08 +00:00
|
|
|
#ifndef __BLOCKDEVICE_H__
|
|
|
|
#define __BLOCKDEVICE_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2009-12-16 01:33:28 +00:00
|
|
|
#include <ProFUSE/Exception.h>
|
2009-11-21 01:45:08 +00:00
|
|
|
|
2009-12-21 13:57:48 +00:00
|
|
|
#include <Device/TrackSector.h>
|
|
|
|
|
2010-05-18 19:59:18 +00:00
|
|
|
#include <Cache/BlockCache.h>
|
|
|
|
|
2009-12-16 01:33:28 +00:00
|
|
|
namespace Device {
|
2009-11-21 01:45:08 +00:00
|
|
|
|
|
|
|
class BlockDevice {
|
|
|
|
public:
|
2009-12-12 23:57:17 +00:00
|
|
|
|
2010-05-19 23:47:48 +00:00
|
|
|
|
|
|
|
// static methods.
|
|
|
|
static unsigned ImageType(const char *type, unsigned defv = 0);
|
|
|
|
|
|
|
|
static BlockDevice *Open(const char *name, bool readOnly, unsigned imageType = 0);
|
|
|
|
static BlockDevice *Create(const char *fname, const char *vname, unsigned blocks, unsigned imageType = 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-21 01:45:08 +00:00
|
|
|
virtual ~BlockDevice();
|
|
|
|
|
2010-05-18 21:26:07 +00:00
|
|
|
virtual BlockCache *createBlockCache();
|
2010-05-18 19:59:18 +00:00
|
|
|
|
|
|
|
|
2009-11-21 01:45:08 +00:00
|
|
|
virtual void read(unsigned block, void *bp) = 0;
|
2010-05-19 01:07:47 +00:00
|
|
|
//virtual void read(TrackSector ts, void *bp) = 0
|
2009-12-21 13:57:48 +00:00
|
|
|
|
2009-11-21 01:45:08 +00:00
|
|
|
virtual void write(unsigned block, const void *bp) = 0;
|
2010-05-19 01:07:47 +00:00
|
|
|
//virtual void write(TrackSector ts, const void *bp) = 0;
|
2009-11-21 01:45:08 +00:00
|
|
|
|
2009-12-21 13:57:48 +00:00
|
|
|
|
|
|
|
virtual unsigned blocks() = 0;
|
|
|
|
|
|
|
|
virtual bool mapped();
|
|
|
|
|
2009-11-21 01:45:08 +00:00
|
|
|
virtual bool readOnly() = 0;
|
2009-11-22 21:56:32 +00:00
|
|
|
|
2009-12-21 13:57:48 +00:00
|
|
|
virtual void sync() = 0;
|
|
|
|
virtual void sync(unsigned block);
|
2010-05-19 01:07:47 +00:00
|
|
|
//virtual void sync(TrackSector ts);
|
2009-11-23 03:19:38 +00:00
|
|
|
|
2009-12-21 13:57:48 +00:00
|
|
|
|
2009-11-22 21:56:32 +00:00
|
|
|
void zeroBlock(unsigned block);
|
2009-12-11 00:59:53 +00:00
|
|
|
|
|
|
|
protected:
|
2009-12-14 00:14:59 +00:00
|
|
|
BlockDevice();
|
2009-11-21 01:45:08 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-04-01 14:38:39 +00:00
|
|
|
#endif
|