mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-27 14:29:31 +00:00
2beb78727f
* Added support for new interfaces syntax * rasctl output update * Added operation parameters * Fixed typo * Manpage update * Added deprecation warning * Moved parser * Updated parser * Updated parameter override * Removed debug code * Made netmask handling more flexible * Updated logging * Logging update * Logging update * Comment update * Removed unused field * Replaced BOOL by bool * Moved code * Logging update * Removed useless comments * Added TODZ * Logging update * Logging update * Logging update * No need to report that an error is an error twice * Removed duplicate logging * Updated error handling * Updated error handling * Fixed typo * Removed magic constant * Fixed 32 bit platform issue * Signature update * Fixed message string * Comment update * Fixed SCSI command opcode * Updated StopPrint * Logging update * Removed obsolete casts * Renaming * Removed duplicate logging * Updated flushing caches * Added FlushCache() method * Reduced visibility * Reduced visibility * Reduced visibility * Code cleanup, removed useless comments * Removed useless comments * Updated error handling * Removed duplicate code * Manpage update
118 lines
3.2 KiB
C++
118 lines
3.2 KiB
C++
//---------------------------------------------------------------------------
|
||
//
|
||
// SCSI Target Emulator RaSCSI (*^..^*)
|
||
// for Raspberry Pi
|
||
//
|
||
// Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
|
||
// Copyright (C) 2014-2020 GIMONS
|
||
// Copyright (C) akuker
|
||
//
|
||
// Licensed under the BSD 3-Clause License.
|
||
// See LICENSE file in the project root folder.
|
||
//
|
||
// [ SCSI CD-ROM ]
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
#pragma once
|
||
|
||
#include "os.h"
|
||
#include "disk.h"
|
||
#include "filepath.h"
|
||
#include "interfaces/scsi_mmc_commands.h"
|
||
#include "interfaces/scsi_primary_commands.h"
|
||
|
||
class SCSICD;
|
||
|
||
//===========================================================================
|
||
//
|
||
// CD-ROM Track
|
||
//
|
||
//===========================================================================
|
||
class CDTrack
|
||
{
|
||
private:
|
||
|
||
friend class SCSICD;
|
||
|
||
CDTrack(SCSICD *scsicd);
|
||
virtual ~CDTrack() {}
|
||
|
||
public:
|
||
|
||
void Init(int track, DWORD first, DWORD last);
|
||
|
||
// Properties
|
||
void SetPath(bool cdda, const Filepath& path); // Set the path
|
||
void GetPath(Filepath& path) const; // Get the path
|
||
void AddIndex(int index, DWORD lba); // Add index
|
||
DWORD GetFirst() const; // Get the start LBA
|
||
DWORD GetLast() const; // Get the last LBA
|
||
DWORD GetBlocks() const; // Get the number of blocks
|
||
int GetTrackNo() const; // Get the track number
|
||
bool IsValid(DWORD lba) const; // Is this a valid LBA?
|
||
bool IsAudio() const; // Is this an audio track?
|
||
|
||
private:
|
||
SCSICD *cdrom; // Parent device
|
||
bool valid; // Valid track
|
||
int track_no; // Track number
|
||
DWORD first_lba; // First LBA
|
||
DWORD last_lba; // Last LBA
|
||
bool audio; // Audio track flag
|
||
bool raw; // RAW data flag
|
||
Filepath imgpath; // Image file path
|
||
};
|
||
|
||
//===========================================================================
|
||
//
|
||
// SCSI CD-ROM
|
||
//
|
||
//===========================================================================
|
||
class SCSICD : public Disk, public ScsiMmcCommands, public FileSupport
|
||
{
|
||
|
||
public:
|
||
enum {
|
||
TrackMax = 96 // Maximum number of tracks
|
||
};
|
||
|
||
SCSICD();
|
||
~SCSICD();
|
||
|
||
bool Dispatch(SCSIDEV *) override;
|
||
|
||
void Open(const Filepath& path) override;
|
||
|
||
// Commands
|
||
int Inquiry(const DWORD *cdb, BYTE *buf) override; // INQUIRY command
|
||
int Read(const DWORD *cdb, BYTE *buf, uint64_t block) override; // READ command
|
||
int ReadToc(const DWORD *cdb, BYTE *buf); // READ TOC command
|
||
|
||
private:
|
||
typedef Disk super;
|
||
|
||
Dispatcher<SCSICD, SASIDEV> dispatcher;
|
||
|
||
// Open
|
||
void OpenCue(const Filepath& path); // Open(CUE)
|
||
void OpenIso(const Filepath& path); // Open(ISO)
|
||
void OpenPhysical(const Filepath& path); // Open(Physical)
|
||
|
||
void ReadToc(SASIDEV *) override;
|
||
void GetEventStatusNotification(SASIDEV *) override;
|
||
|
||
void LBAtoMSF(DWORD lba, BYTE *msf) const; // LBA→MSF conversion
|
||
|
||
bool rawfile; // RAW flag
|
||
|
||
// Track management
|
||
void ClearTrack(); // Clear the track
|
||
int SearchTrack(DWORD lba) const; // Track search
|
||
CDTrack* track[TrackMax]; // Track opbject references
|
||
int tracks; // Effective number of track objects
|
||
int dataindex; // Current data track
|
||
int audioindex; // Current audio track
|
||
|
||
int frame; // Frame number
|
||
};
|