#pragma once #define PLATFORM DESKTOP #include "../Types.h" struct TestDevice { 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) { memcpy(dst, buf+addr*512, 512); return true; } bool writeSingleBlock(LBA512 addr, const uint8_t* src) { memcpy(buf+addr*512, src, 512); return true; } void reset(uint8_t val) { for (int i = 0; i < sizeof(buf); ++i) {buf[i] = val;} } };