Device: Add disk formatting

This commit is contained in:
Yasser Yassine
2025-07-22 20:02:06 +00:00
committed by Kyle Schwarz
parent d70defbf8a
commit 1e5e714f5b
20 changed files with 351 additions and 7 deletions
+17
View File
@@ -26,6 +26,7 @@
#include "icsneo/disk/diskreaddriver.h"
#include "icsneo/disk/diskwritedriver.h"
#include "icsneo/disk/nulldiskdriver.h"
#include "icsneo/disk/diskdetails.h"
#include "icsneo/communication/communication.h"
#include "icsneo/communication/packetizer.h"
#include "icsneo/communication/encoder.h"
@@ -637,6 +638,22 @@ public:
bool unsubscribeLiveData(const LiveDataHandle& handle);
bool clearAllLiveData();
bool setValueLiveData(std::shared_ptr<LiveDataSetValueMessage> message);
enum class DiskFormatDirective : uint8_t {
Continue,
Stop
};
using DiskFormatProgress = std::function<DiskFormatDirective(uint64_t sectorsFormatted, uint64_t sectorsTotal)>;
bool formatDisk(
const DiskDetails& config,
const DiskFormatProgress& handler = {},
std::chrono::milliseconds interval = std::chrono::milliseconds(500) /** Send updates at an interval of 500ms */
);
bool forceDiskConfigUpdate(const DiskDetails& config); // Forces a disk layout and enables change without formatting
std::shared_ptr<DiskDetails> getDiskDetails(std::chrono::milliseconds timeout = std::chrono::milliseconds(100));
virtual size_t getDiskCount() const { return 0; }
bool supportsDiskFormatting() const { return getDiskCount() != 0; }
// VSA Read functions
+2 -1
View File
@@ -924,7 +924,8 @@ public:
template<typename T> T getStructure() const { return *getStructurePointer<T>(); }
template<typename T> bool applyStructure(const T& newStructure);
const size_t& getSize() const { return structSize; }
size_t getSize() const { return structSize; }
size_t getSerialSize() const { return settings.size(); }
// if settings are disabled for this device. always false unless constructed null
bool disabled = false;
@@ -70,6 +70,10 @@ protected:
}
bool supportsGPTP() const override { return true; }
size_t getDiskCount() const override {
return 2;
}
};
@@ -141,6 +141,10 @@ protected:
bool supportsEraseMemory() const override {
return true;
}
size_t getDiskCount() const override {
return 1;
}
};
}
@@ -91,6 +91,10 @@ protected:
return true;
}
size_t getDiskCount() const override {
return 2;
}
};
}
@@ -75,6 +75,10 @@ protected:
bool supportsEraseMemory() const override {
return true;
}
size_t getDiskCount() const override {
return 2;
}
};
}
@@ -54,6 +54,10 @@ protected:
bool supportsEraseMemory() const override {
return true;
}
size_t getDiskCount() const override {
return 1;
}
};
}
@@ -107,6 +107,10 @@ protected:
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
return 0;
}
size_t getDiskCount() const override {
return 1;
}
};
}
@@ -120,6 +120,10 @@ protected:
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
return 0;
}
size_t getDiskCount() const override {
return 1;
}
};
}
@@ -137,6 +137,11 @@ namespace icsneo
{
return 0;
}
size_t getDiskCount() const override
{
return 1;
}
};
}