worked on FAT32 stuff

This commit is contained in:
2021-02-21 09:33:08 +01:00
parent da12992ae8
commit 4ac72c678f
13 changed files with 494 additions and 148 deletions

View File

@@ -17,6 +17,8 @@
#include <fstream>
#include <fmt/format.h>
//class Simu {
// FILE* f;
@@ -60,13 +62,13 @@ public:
fclose(f);
}
uint32_t readSingleBlock(LBA512 addr, uint8_t* dst) {
uint32_t readBlock(LBA512 addr, uint8_t* dst) {
Log::addInfo("SD", "read512(%d*512)", addr);
memcpy(dst, data+addr*512, 512);
return 512;
}
uint32_t writeSingleBlock(LBA512 addr, const uint8_t* src) {
uint32_t writeBlock(LBA512 addr, const uint8_t* src) {
Log::addInfo("SD", "write512(%d*512)", addr);
memcpy(data+addr*512, src, 512);
return 512;
@@ -76,8 +78,16 @@ public:
#include <gtest/gtest.h>
//#define logInfo(fmt, ...) std::string s = fmt::format(FMT_STRING(fmt), __VA_ARGS__);
int main(int argc, char** argv) {
//logInfo("{:s}", "I am not a number")
//std::string s = fmt::format(FMT_STRING("{:s}"), "I am not a number");
//std::string s = fmt::format(FMT_STRING("{:s}"), "I am not a number");
::testing::InitGoogleTest(&argc, argv);
::testing::GTEST_FLAG(filter) = "*TestCreate*";
return RUN_ALL_TESTS();
@@ -99,10 +109,6 @@ int main(int argc, char** argv) {
FAT32FS fat(ah, mbr.getPartition(0).getFirstSector() * 512);
auto callback = [] (const int percent) {
std::cout << percent << std::endl;
};
FAT32FS::DirIterator dir = fat.getRoot();
while(false) {
@@ -114,7 +120,7 @@ int main(int argc, char** argv) {
if (1==0) {
uint8_t* bufff = (uint8_t*) malloc(1024*1024);
uint32_t read = f.read(f.getSize(), bufff, callback);
uint32_t read = f.read(f.getSize(), bufff);
std::string name = f.getName();
std::ofstream out("/tmp/ram/" + name);
@@ -132,10 +138,10 @@ int main(int argc, char** argv) {
//FAT32::DirEntryAt root = fat.getRoot().cur();
FAT32FS::File2 file = fat.create2("tmp1.txt");
FAT32FS::File2 file = fat.getOrCreateFile("tmp1.txt");
uint8_t src[128];
file.write(128, src, [] (int percent) {} );
file.write(128, src);
// diff /tmp/ram/TETRIS.GB /apps/workspace/gbemu/tests/tetris.gb
// diff /tmp/ram/KIRBY1.GB /apps/workspace/gbemu/tests/Kirby\'s\ Dream\ Land\ \(USA\,\ Europe\).gb