Device: Find the VSA offset for Disk::Access::EntireDisk

This commit is contained in:
Paul Hollinsky
2022-02-28 15:55:16 -05:00
parent 1fadb85206
commit c314417277
5 changed files with 98 additions and 0 deletions
+15
View File
@@ -4,6 +4,7 @@
#include "icsneo/communication/command.h"
#include "icsneo/device/extensions/deviceextension.h"
#include "icsneo/platform/optional.h"
#include "icsneo/disk/fat.h"
#include <string.h>
#include <iostream>
#include <sstream>
@@ -532,6 +533,20 @@ optional<uint64_t> Device::getLogicalDiskSize() {
return info->getReportedSize();
}
optional<uint64_t> Device::getVSAOffsetInLogicalDisk() {
if(!isOpen()) {
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
return nullopt;
}
if (diskReadDriver->getAccess() == Disk::Access::VSA || diskReadDriver->getAccess() == Disk::Access::None)
return 0ull;
return Disk::FindVSAInFAT([this](uint64_t pos, uint8_t *into, uint64_t amount) {
return readLogicalDisk(pos, into, amount);
});
}
optional<bool> Device::getDigitalIO(IO type, size_t number /* = 1 */) {
if(number == 0) { // Start counting from 1
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);