mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Disk: Read driver for Plasion
This commit is contained in:
@@ -24,10 +24,6 @@ public:
|
||||
void joinThreads() override;
|
||||
bool sendPacket(std::vector<uint8_t>& bytes) override;
|
||||
|
||||
protected:
|
||||
bool preprocessPacket(std::deque<uint8_t>& usbReadFifo);
|
||||
|
||||
private:
|
||||
enum class CommandType : uint8_t {
|
||||
PlasmaReadRequest = 0x10, // Status read request to HSC
|
||||
PlasmaStatusResponse = 0x11, // Status response by HSC
|
||||
@@ -49,6 +45,10 @@ private:
|
||||
Microblaze_to_HostPC = 0x81 // Microblaze processor data to host PC
|
||||
};
|
||||
|
||||
protected:
|
||||
bool preprocessPacket(std::deque<uint8_t>& usbReadFifo);
|
||||
|
||||
private:
|
||||
static bool CommandTypeIsValid(CommandType cmd) {
|
||||
switch(cmd) {
|
||||
case CommandType::PlasmaReadRequest:
|
||||
@@ -77,8 +77,10 @@ private:
|
||||
static bool CommandTypeHasAddress(CommandType cmd) {
|
||||
// Check CommandTypeIsValid before this, you will get false on an invalid command
|
||||
switch(cmd) {
|
||||
case CommandType::SDCC1_to_HostPC:
|
||||
case CommandType::SDCC2_to_HostPC:
|
||||
case CommandType::HostPC_to_SDCC1:
|
||||
case CommandType::HostPC_from_SDCC1:
|
||||
case CommandType::HostPC_to_SDCC2:
|
||||
case CommandType::HostPC_from_SDCC2:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "icsneo/device/tree/plasion/plasion.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/platform/ftdi.h"
|
||||
#include "icsneo/disk/plasiondiskreaddriver.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
@@ -24,7 +25,7 @@ public:
|
||||
|
||||
private:
|
||||
NeoVIION(neodevice_t neodevice) : Plasion(neodevice) {
|
||||
initialize<FTDI>();
|
||||
initialize<FTDI, NullSettings, Disk::PlasionDiskReadDriver>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef __PLASIONDISKREADDRIVER_H__
|
||||
#define __PLASIONDISKREADDRIVER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/disk/diskreaddriver.h"
|
||||
#include <limits>
|
||||
#include <chrono>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
namespace Disk {
|
||||
|
||||
/**
|
||||
* A disk read driver which uses the PLASION HID command set to read from the 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");
|
||||
return { static_cast<uint32_t>(SectorSize), static_cast<uint32_t>(MaxSize) };
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr const uint32_t MaxSize = 65024;
|
||||
static constexpr const std::chrono::duration CacheTime = std::chrono::seconds(1);
|
||||
|
||||
std::array<uint8_t, MaxSize> cache;
|
||||
uint64_t cachePos = 0;
|
||||
std::chrono::time_point<std::chrono::steady_clock> cachedAt;
|
||||
|
||||
optional<uint64_t> readLogicalDiskAligned(Communication& com, device_eventhandler_t report,
|
||||
uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout) override;
|
||||
};
|
||||
|
||||
} // namespace Disk
|
||||
|
||||
} // namespace icsneo
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // __NEOMEMORYDISKREADDRIVER_H__
|
||||
Reference in New Issue
Block a user