RASCSI/cpp/disk_image/disk_image_handle.h

49 lines
1.3 KiB
C
Raw Normal View History

2023-01-09 02:04:49 +00:00
//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI (*^..^*)
// for Raspberry Pi
//
// Copyright (C) 2022 akuker
//
// Base class for interfacing with disk images.
//
// [ DiskImageHandle ]
//
//---------------------------------------------------------------------------
#pragma once
2023-01-09 03:39:07 +00:00
// #include "filepath.h"
#include <string>
#include <cstdint>
#include <vector>
using namespace std;
2023-01-09 02:04:49 +00:00
class DiskImageHandle
{
public:
2023-01-09 03:39:07 +00:00
DiskImageHandle(const string &path, int size, uint32_t blocks, off_t imgoff = 0);
2023-01-09 02:04:49 +00:00
virtual ~DiskImageHandle();
void SetRawMode(bool raw) { cd_raw = raw; }; // CD-ROM raw mode setting
// Access
virtual bool Save() = 0; // Save and release all
2023-01-09 03:39:07 +00:00
virtual bool ReadSector(vector<uint8_t>& buf, int block) = 0; // Sector Read
virtual bool WriteSector(const vector<uint8_t>& buf, int block) = 0; // Sector Write
virtual bool GetCache(int index, int &track, uint32_t &serial) const = 0; // Get cache information
2023-01-09 02:04:49 +00:00
protected:
bool cd_raw = false;
2023-01-09 03:39:07 +00:00
uint32_t serial; // Last serial number
string sec_path; // Path
2023-01-09 02:04:49 +00:00
int sec_size; // Sector Size (8=256, 9=512, 10=1024, 11=2048, 12=4096)
int sec_blocks; // Blocks per sector
off_t imgoffset; // Offset to actual data
off_t GetTrackOffset(int block);
off_t GetSectorOffset(int block);
};