huge work on FAT32, initial support for writing

This commit is contained in:
2021-02-14 21:35:47 +01:00
parent 6aa951190e
commit da12992ae8
14 changed files with 609 additions and 91 deletions

View File

@@ -6,7 +6,23 @@
struct TestDevice {
uint8_t buf[4096];
size_t size;
uint8_t* buf;
TestDevice(size_t size) : size(size) {
buf = (uint8_t*) malloc(size);
memset(buf, 0, size);
}
~TestDevice() {
free(buf);
}
void toFile(const std::string& name) {
FILE* f = fopen(name.c_str(), "w+");
fwrite(buf, size, 1, f);
fclose(f);
}
/** read a 512 byte block into dst */
bool readSingleBlock(LBA512 addr, uint8_t* dst) {
@@ -14,7 +30,7 @@ struct TestDevice {
return true;
}
bool writeSingleBlock(LBA512 addr, uint8_t* src) {
bool writeSingleBlock(LBA512 addr, const uint8_t* src) {
memcpy(buf+addr*512, src, 512);
return true;
}