Device: Add disk read driver framework

Allow access to the device's logical disk.

At the moment, no drivers are implemented, so all devices have Access::None.
This commit is contained in:
Paul Hollinsky
2022-02-25 01:14:57 -05:00
parent 9e6970fd39
commit fe4d5e0c15
9 changed files with 200 additions and 1 deletions
+14
View File
@@ -474,6 +474,20 @@ Network Device::getNetworkByNumber(Network::Type type, size_t index) const {
return Network::NetID::Invalid;
}
optional<uint64_t> Device::readLogicalDisk(uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout) {
if(!into || timeout <= std::chrono::milliseconds(0)) {
report(APIEvent::Type::RequiredParameterNull, APIEvent::Severity::Error);
return nullopt;
}
if(!isOpen()) {
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
return nullopt;
}
return diskReadDriver->readLogicalDisk(*com, report, pos, into, amount, timeout);
}
optional<bool> Device::getDigitalIO(IO type, size_t number /* = 1 */) {
if(number == 0) { // Start counting from 1
report(APIEvent::Type::ParameterOutOfRange, APIEvent::Severity::Error);