增加字符存储接口,初步测试通过

This commit is contained in:
nnhy 2015-10-15 04:39:51 +00:00
parent c94e1eef0b
commit c81fbf420d
2 changed files with 27 additions and 3 deletions

View File

@ -26,7 +26,7 @@ bool BlockStorage::Write(uint address, const ByteArray& bs)
if(address < Start || address + len > Start + Size) return false;
#if STORAGE_DEBUG
debug_printf("BlockStorage::Write(0x%08x, %d, 0x%08x, %d)", address, len, bs.GetBuffer());
debug_printf("BlockStorage::Write(0x%08x, %d, 0x%08x)", address, len, bs.GetBuffer());
int len2 = 0x10;
if(len < len2) len2 = len;
//debug_printf(" Data: ");
@ -171,3 +171,17 @@ bool BlockStorage::IsErased(uint address, uint len)
return true;
}
bool CharStorage::Read(uint address, ByteArray& bs)
{
bs.Copy((byte*)address);
return true;
}
bool CharStorage::Write(uint address, const ByteArray& bs)
{
bs.CopyTo((byte*)address);
return true;
}

View File

@ -9,9 +9,9 @@ class Storage
{
public:
// 读取
virtual bool Read(uint address, ByteArray& bs);
virtual bool Read(uint address, ByteArray& bs) = 0;
// 写入
virtual bool Write(uint address, const ByteArray& bs);
virtual bool Write(uint address, const ByteArray& bs) = 0;
};
// 块存储接口
@ -41,4 +41,14 @@ protected:
virtual bool IsErased(uint address, uint len);
};
// 字符存储接口
class CharStorage : public Storage
{
public:
// 读取
virtual bool Read(uint address, ByteArray& bs);
// 写入
virtual bool Write(uint address, const ByteArray& bs);
};
#endif