Disk: Allow mismatched access for Read and Write drivers

This will cause the driver to fall back to the least common
denominator.
This commit is contained in:
Paul Hollinsky
2022-03-03 20:29:13 -05:00
parent 1118428250
commit 0a15adbe91
9 changed files with 56 additions and 7 deletions
+20 -1
View File
@@ -25,8 +25,27 @@ enum class Access {
class Driver {
public:
virtual ~Driver() = default;
virtual Access getAccess() const = 0;
Access getAccess() const {
if(vsaOffset)
return Access::VSA;
return getPossibleAccess();
}
virtual std::pair<uint32_t, uint32_t> getBlockSizeBounds() const = 0;
void setVSAOffset(uint64_t offset) { vsaOffset = offset; }
protected:
uint64_t vsaOffset = 0;
private:
/**
* Report the possible access that this driver has
*
* In some cases, such as a mismatched possible access between
* read and write drivers, this will be overridden in the driver
* layer.
*/
virtual Access getPossibleAccess() const = 0;
};
} // namespace Disk
@@ -16,7 +16,6 @@ namespace Disk {
*/
class ExtExtractorDiskReadDriver : public ReadDriver {
public:
Access getAccess() const override { return Access::EntireCard; }
std::pair<uint32_t, uint32_t> getBlockSizeBounds() const override {
static_assert(SectorSize <= std::numeric_limits<uint32_t>::max(), "Incorrect sector size");
static_assert(SectorSize >= std::numeric_limits<uint32_t>::min(), "Incorrect sector size");
@@ -36,6 +35,8 @@ private:
uint8_t headerLength = 7; // Correct for Ethernet
Access getPossibleAccess() const override { return Access::EntireCard; }
optional<uint64_t> readLogicalDiskAligned(Communication& com, device_eventhandler_t report,
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout) override;
};
@@ -18,7 +18,6 @@ namespace Disk {
*/
class NeoMemoryDiskReadDriver : public ReadDriver {
public:
Access getAccess() const override { return Access::VSA; }
std::pair<uint32_t, uint32_t> getBlockSizeBounds() const override {
static_assert(SectorSize <= std::numeric_limits<uint32_t>::max(), "Incorrect sector size");
static_assert(SectorSize >= std::numeric_limits<uint32_t>::min(), "Incorrect sector size");
@@ -33,6 +32,8 @@ private:
uint64_t cachePos = 0;
std::chrono::time_point<std::chrono::steady_clock> cachedAt;
Access getPossibleAccess() const override { return Access::VSA; }
optional<uint64_t> readLogicalDiskAligned(Communication& com, device_eventhandler_t report,
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout) override;
};
+2 -1
View File
@@ -22,7 +22,6 @@ public:
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout = DefaultTimeout) override;
optional<uint64_t> writeLogicalDisk(Communication& com, device_eventhandler_t report, ReadDriver& readDriver,
uint64_t pos, const uint8_t* from, uint64_t amount, std::chrono::milliseconds timeout = DefaultTimeout) override;
Access getAccess() const override { return Access::None; }
std::pair<uint32_t, uint32_t> getBlockSizeBounds() const override {
static_assert(SectorSize <= std::numeric_limits<uint32_t>::max(), "Incorrect sector size");
static_assert(SectorSize >= std::numeric_limits<uint32_t>::min(), "Incorrect sector size");
@@ -30,6 +29,8 @@ public:
}
private:
Access getPossibleAccess() const override { return Access::None; }
optional<uint64_t> readLogicalDiskAligned(Communication& com, device_eventhandler_t report,
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout) override;
optional<uint64_t> writeLogicalDiskAligned(Communication& com, device_eventhandler_t report,
+2 -1
View File
@@ -16,7 +16,6 @@ namespace Disk {
*/
class PlasionDiskReadDriver : public ReadDriver {
public:
Access getAccess() const override { return Access::EntireCard; }
std::pair<uint32_t, uint32_t> getBlockSizeBounds() const override {
static_assert(SectorSize <= std::numeric_limits<uint32_t>::max(), "Incorrect sector size");
static_assert(SectorSize >= std::numeric_limits<uint32_t>::min(), "Incorrect sector size");
@@ -31,6 +30,8 @@ private:
uint64_t cachePos = 0;
std::chrono::time_point<std::chrono::steady_clock> cachedAt;
Access getPossibleAccess() const override { return Access::EntireCard; }
optional<uint64_t> readLogicalDiskAligned(Communication& com, device_eventhandler_t report,
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout) override;
};