mirror of
https://github.com/akuker/RASCSI.git
synced 2025-04-24 20:06:36 +00:00
renamed classes
This commit is contained in:
parent
97f857b3b7
commit
b7c88d2d45
@ -104,7 +104,7 @@ SRC_RASCSI = \
|
||||
localizer.cpp
|
||||
SRC_RASCSI += $(shell find ./controllers -name '*.cpp')
|
||||
SRC_RASCSI += $(shell find ./devices -name '*.cpp')
|
||||
SRC_RASCSI += $(shell find ./file_access -name '*.cpp')
|
||||
SRC_RASCSI += $(shell find ./disk_image -name '*.cpp')
|
||||
SRC_RASCSI += $(SRC_PROTOBUF)
|
||||
|
||||
SRC_SCSIMON = \
|
||||
@ -140,8 +140,8 @@ SRC_SASIDUMP = \
|
||||
fileio.cpp\
|
||||
rascsi_version.cpp
|
||||
|
||||
vpath %.h ./ ./controllers ./devices ./file_access ./monitor
|
||||
vpath %.cpp ./ ./controllers ./devices ./file_access ./monitor
|
||||
vpath %.h ./ ./controllers ./devices ./disk_image ./monitor
|
||||
vpath %.cpp ./ ./controllers ./devices ./disk_image ./monitor
|
||||
vpath %.o ./$(OBJDIR)
|
||||
vpath ./$(BINDIR)
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "exceptions.h"
|
||||
#include "disk.h"
|
||||
#include "mode_page_device.h"
|
||||
#include "file_access/file_access_factory.h"
|
||||
#include "disk_image/disk_image_handle_factory.h"
|
||||
|
||||
using namespace scsi_defs;
|
||||
|
||||
@ -108,7 +108,7 @@ void Disk::Open(const Filepath& path)
|
||||
|
||||
// Cache initialization
|
||||
assert (!disk.dcache);
|
||||
disk.dcache = FileAccessFactory::CreateFileAccess(path, disk.size, disk.blocks, disk.image_offset);
|
||||
disk.dcache = DiskImageHandleFactory::CreateFileAccess(path, disk.size, disk.blocks, disk.image_offset);
|
||||
|
||||
// Can read/write open
|
||||
Fileio fio;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "controllers/scsidev_ctrl.h"
|
||||
#include "device.h"
|
||||
#include "device_factory.h"
|
||||
#include "file_access/file_access.h"
|
||||
#include "disk_image/disk_image_handle_factory.h"
|
||||
#include "file_support.h"
|
||||
#include "filepath.h"
|
||||
#include "interfaces/scsi_block_commands.h"
|
||||
@ -49,7 +49,7 @@ private:
|
||||
uint32_t size; // Sector Size (8=256, 9=512, 10=1024, 11=2048, 12=4096)
|
||||
// TODO blocks should be a 64 bit value in order to support higher capacities
|
||||
uint32_t blocks; // Total number of sectors
|
||||
FileAccess *dcache; // Disk cache
|
||||
DiskImageHandle *dcache; // Disk cache
|
||||
off_t image_offset; // Offset to actual data
|
||||
bool is_medium_changed;
|
||||
} disk_t;
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "scsicd.h"
|
||||
#include "fileio.h"
|
||||
#include "exceptions.h"
|
||||
#include "file_access/file_access_factory.h"
|
||||
#include "disk_image/disk_image_handle_factory.h"
|
||||
|
||||
using namespace scsi_defs;
|
||||
|
||||
@ -533,7 +533,7 @@ int SCSICD::Read(const DWORD *cdb, BYTE *buf, uint64_t block)
|
||||
// Recreate the disk cache
|
||||
Filepath path;
|
||||
track[index]->GetPath(path);
|
||||
disk.dcache = FileAccessFactory::CreateFileAccess(path, GetSectorSizeShiftCount(), GetBlockCount());
|
||||
disk.dcache = DiskImageHandleFactory::CreateFileAccess(path, GetSectorSizeShiftCount(), GetBlockCount());
|
||||
disk.dcache->SetRawMode(rawfile);
|
||||
|
||||
// Reset data index
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "file_access.h"
|
||||
#include "disk_image/disk_image_handle.h"
|
||||
|
||||
FileAccess::FileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff){
|
||||
DiskImageHandle::DiskImageHandle(const Filepath& path, int size, uint32_t blocks, off_t imgoff){
|
||||
|
||||
serial = 0;
|
||||
sec_path = path;
|
||||
@ -8,18 +8,18 @@ FileAccess::FileAccess(const Filepath& path, int size, uint32_t blocks, off_t im
|
||||
sec_blocks = blocks;
|
||||
imgoffset = imgoff;
|
||||
}
|
||||
FileAccess::~FileAccess(){
|
||||
DiskImageHandle::~DiskImageHandle(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
off_t FileAccess::GetSectorOffset(int block){
|
||||
off_t DiskImageHandle::GetSectorOffset(int block){
|
||||
|
||||
int sector_num = block & 0xff;
|
||||
return (off_t)sector_num << sec_size;
|
||||
}
|
||||
|
||||
off_t FileAccess::GetTrackOffset(int block){
|
||||
off_t DiskImageHandle::GetTrackOffset(int block){
|
||||
|
||||
// Assuming that all tracks hold 256 sectors
|
||||
int track_num = block >> 8;
|
@ -19,11 +19,11 @@
|
||||
|
||||
#include "filepath.h"
|
||||
|
||||
class FileAccess
|
||||
class DiskImageHandle
|
||||
{
|
||||
public:
|
||||
FileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
virtual ~FileAccess();
|
||||
DiskImageHandle(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
virtual ~DiskImageHandle();
|
||||
|
||||
void SetRawMode(bool raw) { cd_raw = raw; }; // CD-ROM raw mode setting
|
||||
|
@ -15,29 +15,29 @@
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "file_access/file_access_factory.h"
|
||||
#include "disk_image/disk_image_handle_factory.h"
|
||||
#include "log.h"
|
||||
#include "file_access/disk_track_cache.h"
|
||||
#include "file_access/mmap_file_access.h"
|
||||
#include "file_access/posix_file_access.h"
|
||||
#include "disk_image/disk_track_cache.h"
|
||||
#include "disk_image/mmap_file_handle.h"
|
||||
#include "disk_image/posix_file_handle.h"
|
||||
|
||||
FileAccessType FileAccessFactory::current_access_type = FileAccessType::ePosixFile;
|
||||
DiskImageHandleType DiskImageHandleFactory::current_access_type = DiskImageHandleType::ePosixFile;
|
||||
|
||||
FileAccess *FileAccessFactory::CreateFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff){
|
||||
DiskImageHandle *DiskImageHandleFactory::CreateFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff){
|
||||
|
||||
FileAccess *result = NULL;
|
||||
DiskImageHandle *result = NULL;
|
||||
|
||||
if (current_access_type == FileAccessType::eMmapFile){
|
||||
if (current_access_type == DiskImageHandleType::eMmapFile){
|
||||
LOGINFO("%s Creating MmapFileAccess %s", __PRETTY_FUNCTION__, path.GetPath())
|
||||
result = new MmapFileAccess(path, size, blocks, imgoff);
|
||||
result = new MmapFileHandle(path, size, blocks, imgoff);
|
||||
}
|
||||
else if(current_access_type == FileAccessType::eRamCache) {
|
||||
else if(current_access_type == DiskImageHandleType::eRamCache) {
|
||||
LOGINFO("%s Creating DiskCache %s", __PRETTY_FUNCTION__, path.GetPath())
|
||||
result = new DiskCache(path, size, blocks, imgoff);
|
||||
}
|
||||
else if(current_access_type == FileAccessType::ePosixFile) {
|
||||
LOGINFO("%s Creating PosixFileAccess %s", __PRETTY_FUNCTION__, path.GetPath())
|
||||
result = new PosixFileAccess(path, size, blocks, imgoff);
|
||||
else if(current_access_type == DiskImageHandleType::ePosixFile) {
|
||||
LOGINFO("%s Creating PosixFileHandle %s", __PRETTY_FUNCTION__, path.GetPath())
|
||||
result = new PosixFileHandle(path, size, blocks, imgoff);
|
||||
}
|
||||
|
||||
if (result == NULL){
|
@ -15,22 +15,24 @@
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "file_access/file_access.h"
|
||||
#pragma once
|
||||
|
||||
enum FileAccessType {
|
||||
#include "disk_image/disk_image_handle.h"
|
||||
|
||||
enum DiskImageHandleType {
|
||||
eRamCache,
|
||||
eMmapFile,
|
||||
ePosixFile,
|
||||
};
|
||||
|
||||
class FileAccessFactory
|
||||
class DiskImageHandleFactory
|
||||
{
|
||||
public:
|
||||
static void SetFileAccessMethod(FileAccessType method) { current_access_type = method; };
|
||||
static FileAccessType GetFileAccessMethod() { return current_access_type; };
|
||||
static void SetFileAccessMethod(DiskImageHandleType method) { current_access_type = method; };
|
||||
static DiskImageHandleType GetFileAccessMethod() { return current_access_type; };
|
||||
|
||||
static FileAccess *CreateFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
static DiskImageHandle *CreateFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
|
||||
private:
|
||||
static FileAccessType current_access_type;
|
||||
static DiskImageHandleType current_access_type;
|
||||
};
|
@ -341,7 +341,7 @@ bool DiskTrack::WriteSector(const BYTE *buf, int sec)
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
DiskCache::DiskCache(const Filepath& path, int size, uint32_t blocks, off_t imgoff) : FileAccess(path, size, blocks, imgoff)
|
||||
DiskCache::DiskCache(const Filepath& path, int size, uint32_t blocks, off_t imgoff) : DiskImageHandle(path, size, blocks, imgoff)
|
||||
{
|
||||
ASSERT(blocks > 0);
|
||||
ASSERT(imgoff >= 0);
|
@ -18,7 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "filepath.h"
|
||||
#include "file_access/file_access.h"
|
||||
#include "disk_image/disk_image_handle.h"
|
||||
|
||||
// Number of tracks to cache
|
||||
#define CacheMax 16
|
||||
@ -58,7 +58,7 @@ private:
|
||||
int GetTrack() const { return dt.track; } // Get track
|
||||
};
|
||||
|
||||
class DiskCache : public FileAccess
|
||||
class DiskCache : public DiskImageHandle
|
||||
{
|
||||
public:
|
||||
// Internal data definition
|
@ -17,7 +17,7 @@
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "mmap_file_access.h"
|
||||
#include "mmap_file_handle.h"
|
||||
#include "log.h"
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
@ -28,7 +28,7 @@
|
||||
// Direct file access that will map the file into virtual memory space
|
||||
//
|
||||
//===========================================================================
|
||||
MmapFileAccess::MmapFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff) : FileAccess(path, size, blocks, imgoff)
|
||||
MmapFileHandle::MmapFileHandle(const Filepath& path, int size, uint32_t blocks, off_t imgoff) : DiskImageHandle(path, size, blocks, imgoff)
|
||||
{
|
||||
ASSERT(blocks > 0);
|
||||
ASSERT(imgoff >= 0);
|
||||
@ -58,7 +58,7 @@ MmapFileAccess::MmapFileAccess(const Filepath& path, int size, uint32_t blocks,
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
MmapFileAccess::~MmapFileAccess()
|
||||
MmapFileHandle::~MmapFileHandle()
|
||||
{
|
||||
munmap((void*)memory_block, sb.st_size);
|
||||
close(fd);
|
||||
@ -67,7 +67,7 @@ MmapFileAccess::~MmapFileAccess()
|
||||
sync();
|
||||
}
|
||||
|
||||
bool MmapFileAccess::ReadSector(BYTE *buf, int block)
|
||||
bool MmapFileHandle::ReadSector(BYTE *buf, int block)
|
||||
{
|
||||
ASSERT(sec_size != 0);
|
||||
ASSERT(buf);
|
||||
@ -85,7 +85,7 @@ bool MmapFileAccess::ReadSector(BYTE *buf, int block)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MmapFileAccess::WriteSector(const BYTE *buf, int block)
|
||||
bool MmapFileHandle::WriteSector(const BYTE *buf, int block)
|
||||
{
|
||||
|
||||
ASSERT(buf);
|
@ -23,14 +23,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "filepath.h"
|
||||
#include "file_access/file_access.h"
|
||||
#include "disk_image/disk_image_handle.h"
|
||||
|
||||
class MmapFileAccess : public FileAccess
|
||||
class MmapFileHandle : public DiskImageHandle
|
||||
{
|
||||
|
||||
public:
|
||||
MmapFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
~MmapFileAccess();
|
||||
MmapFileHandle(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
~MmapFileHandle();
|
||||
|
||||
void SetRawMode(BOOL raw); // CD-ROM raw mode setting
|
||||
|
@ -5,11 +5,11 @@
|
||||
//
|
||||
// Copyright (C) 2021 akuker
|
||||
//
|
||||
// [ PosixFileAccess ]
|
||||
// [ PosixFileHandle ]
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "posix_file_access.h"
|
||||
#include "posix_file_handle.h"
|
||||
#include "log.h"
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
@ -20,7 +20,7 @@
|
||||
// Direct file access that will map the file into virtual memory space
|
||||
//
|
||||
//===========================================================================
|
||||
PosixFileAccess::PosixFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff) : FileAccess(path, size, blocks, imgoff)
|
||||
PosixFileHandle::PosixFileHandle(const Filepath& path, int size, uint32_t blocks, off_t imgoff) : DiskImageHandle(path, size, blocks, imgoff)
|
||||
{
|
||||
ASSERT(blocks > 0);
|
||||
ASSERT(imgoff >= 0);
|
||||
@ -42,7 +42,7 @@ PosixFileAccess::PosixFileAccess(const Filepath& path, int size, uint32_t blocks
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
PosixFileAccess::~PosixFileAccess()
|
||||
PosixFileHandle::~PosixFileHandle()
|
||||
{
|
||||
close(fd);
|
||||
|
||||
@ -50,7 +50,7 @@ PosixFileAccess::~PosixFileAccess()
|
||||
sync();
|
||||
}
|
||||
|
||||
bool PosixFileAccess::ReadSector(BYTE *buf, int block)
|
||||
bool PosixFileHandle::ReadSector(BYTE *buf, int block)
|
||||
{
|
||||
if(!initialized){
|
||||
return false;
|
||||
@ -76,7 +76,7 @@ bool PosixFileAccess::ReadSector(BYTE *buf, int block)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PosixFileAccess::WriteSector(const BYTE *buf, int block)
|
||||
bool PosixFileHandle::WriteSector(const BYTE *buf, int block)
|
||||
{
|
||||
if(!initialized){
|
||||
return false;
|
@ -5,21 +5,21 @@
|
||||
//
|
||||
// Copyright (C) 2021 akuker
|
||||
//
|
||||
// [ PosixFileAccess ]
|
||||
// [ PosixFileHandle ]
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "filepath.h"
|
||||
#include "file_access/file_access.h"
|
||||
#include "disk_image/disk_image_handle.h"
|
||||
|
||||
class PosixFileAccess : public FileAccess
|
||||
class PosixFileHandle : public DiskImageHandle
|
||||
{
|
||||
|
||||
public:
|
||||
PosixFileAccess(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
~PosixFileAccess();
|
||||
PosixFileHandle(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||||
~PosixFileHandle();
|
||||
|
||||
void SetRawMode(BOOL raw); // CD-ROM raw mode setting
|
||||
|
||||
@ -29,13 +29,8 @@ public:
|
||||
bool WriteSector(const BYTE *buf, int block); // Sector Write
|
||||
bool GetCache(int index, int& track, DWORD& serial) const { return true; }; // Get cache information
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int fd;
|
||||
|
||||
bool initialized = false;
|
||||
|
||||
};
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "rasutil.h"
|
||||
#include "rascsi_image.h"
|
||||
#include "rascsi_interface.pb.h"
|
||||
#include "file_access/file_access_factory.h"
|
||||
#include "disk_image/disk_image_handle.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include <string>
|
||||
@ -1297,13 +1297,13 @@ bool ParseArgument(int argc, char* argv[], int& port)
|
||||
LOGWARN("Cache mode %s", cache_mode.c_str());
|
||||
switch(cache_mode.at(0)){
|
||||
case 'R':
|
||||
FileAccessFactory::SetFileAccessMethod(FileAccessType::eRamCache);
|
||||
DiskImageHandleFactory::SetFileAccessMethod(DiskImageHandleType::eRamCache);
|
||||
break;
|
||||
case 'P':
|
||||
FileAccessFactory::SetFileAccessMethod(FileAccessType::ePosixFile);
|
||||
DiskImageHandleFactory::SetFileAccessMethod(DiskImageHandleType::ePosixFile);
|
||||
break;
|
||||
case 'M':
|
||||
FileAccessFactory::SetFileAccessMethod(FileAccessType::eMmapFile);
|
||||
DiskImageHandleFactory::SetFileAccessMethod(DiskImageHandleType::eMmapFile);
|
||||
break;
|
||||
default:
|
||||
LOGWARN("Invalid cache mode: %s Expected \"RAM, Posix or Mmmap\"", cache_mode.c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user