RASCSI/src/raspberrypi/devices/host_services.h
Uwe Seimet efbfb54d26
More unit tests, replacement of raw pointers and C arrays, separation of concerns (#878)
* Added unit tests

* Fixed SonarCloud issues

* Updated error handling

* Updated deletion of controllers

* Image folder handling cleanup

* Fixed clang warning

* Removed duplicate code

* Reduced code complexity

* Updated array handling

* Initialize device with ID and LUN

* Use smart pointers

* Updated memory management

* Logging updates

* Extracted methods

* Split scsi.h
2022-10-04 17:23:42 +02:00

66 lines
1.6 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI Reloaded
// for Raspberry Pi
//
// Copyright (C) 2022 Uwe Seimet
//
// Host Services with realtime clock and shutdown support
//
//---------------------------------------------------------------------------
#pragma once
#include "mode_page_device.h"
#include <vector>
#include <map>
class ControllerManager;
class HostServices: public ModePageDevice
{
public:
HostServices(int, const ControllerManager&);
~HostServices() override = default;
bool Dispatch(scsi_command) override;
vector<byte> InquiryInternal() const override;
void TestUnitReady() override;
void StartStopUnit();
bool SupportsFile() const override { return false; }
protected:
void SetUpModePages(map<int, vector<byte>>&, int, bool) const override;
private:
using mode_page_datetime = struct __attribute__((packed)) {
// Major and minor version of this data structure (e.g. 1.0)
uint8_t major_version;
uint8_t minor_version;
// Current date and time, with daylight savings time adjustment applied
uint8_t year; // year - 1900
uint8_t month; // 0-11
uint8_t day; // 1-31
uint8_t hour; // 0-23
uint8_t minute; // 0-59
uint8_t second; // 0-59
};
using super = ModePageDevice;
Dispatcher<HostServices> dispatcher;
const ControllerManager& controller_manager;
int ModeSense6(const vector<int>&, vector<BYTE>&) const override;
int ModeSense10(const vector<int>&, vector<BYTE>&) const override;
void AddRealtimeClockPage(map<int, vector<byte>>&, bool) const;
};