diff --git a/Enums/Images.cs b/Enums/Images.cs index ae1dea3..e7698e5 100644 --- a/Enums/Images.cs +++ b/Enums/Images.cs @@ -42,352 +42,378 @@ using System.Diagnostics.CodeAnalysis; // ReSharper disable UnusedMember.Global -namespace Aaru.CommonTypes.Enums +namespace Aaru.CommonTypes.Enums; + +/// Track (as partitioning element) types. +public enum TrackType : byte { - /// Track (as partitioning element) types. - public enum TrackType : byte - { - /// Audio track - Audio = 0, - /// Data track (not any of the below defined ones) - Data = 1, - /// Data track, compact disc mode 1 - CdMode1 = 2, - /// Data track, compact disc mode 2, formless - CdMode2Formless = 3, - /// Data track, compact disc mode 2, form 1 - CdMode2Form1 = 4, - /// Data track, compact disc mode 2, form 2 - CdMode2Form2 = 5 - } + /// Audio track + Audio = 0, + /// Data track (not any of the below defined ones) + Data = 1, + /// Data track, compact disc mode 1 + CdMode1 = 2, + /// Data track, compact disc mode 2, formless + CdMode2Formless = 3, + /// Data track, compact disc mode 2, form 1 + CdMode2Form1 = 4, + /// Data track, compact disc mode 2, form 2 + CdMode2Form2 = 5 +} - /// Type of subchannel in track - public enum TrackSubchannelType : byte - { - /// Track does not has subchannel dumped, or it's not a CD - None = 0, - /// Subchannel is packed and error corrected - Packed = 1, - /// Subchannel is interleaved - Raw = 2, - /// Subchannel is packed and comes interleaved with main channel in same file - PackedInterleaved = 3, - /// Subchannel is interleaved and comes interleaved with main channel in same file - RawInterleaved = 4, - /// Only Q subchannel is stored as 16 bytes - Q16 = 5, - /// Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file - Q16Interleaved = 6 - } +/// Type of subchannel in track +public enum TrackSubchannelType : byte +{ + /// Track does not has subchannel dumped, or it's not a CD + None = 0, + /// Subchannel is packed and error corrected + Packed = 1, + /// Subchannel is interleaved + Raw = 2, + /// Subchannel is packed and comes interleaved with main channel in same file + PackedInterleaved = 3, + /// Subchannel is interleaved and comes interleaved with main channel in same file + RawInterleaved = 4, + /// Only Q subchannel is stored as 16 bytes + Q16 = 5, + /// Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file + Q16Interleaved = 6 +} - /// Metadata present for each sector (aka, "tag"). - public enum SectorTagType - { - /// Apple's GCR sector tags, 12 bytes - AppleSectorTag = 0, - /// Sync frame from CD sector, 12 bytes - CdSectorSync = 1, - /// CD sector header, 4 bytes - CdSectorHeader = 2, - /// CD mode 2 sector subheader - CdSectorSubHeader = 3, - /// CD sector EDC, 4 bytes - CdSectorEdc = 4, - /// CD sector ECC P, 172 bytes - CdSectorEccP = 5, - /// CD sector ECC Q, 104 bytes - CdSectorEccQ = 6, - /// CD sector ECC (P and Q), 276 bytes - CdSectorEcc = 7, - /// CD sector subchannel, 96 bytes - CdSectorSubchannel = 8, - /// CD track ISRC, string, 12 bytes - CdTrackIsrc = 9, - /// CD track text, string, 13 bytes - CdTrackText = 10, - /// CD track flags, 1 byte - CdTrackFlags = 11, - /// DVD sector copyright information - DvdCmi = 12, - /// Floppy address mark (contents depend on underlying floppy format) - FloppyAddressMark = 13, - /// DVD sector title key, 5 bytes - DvdTitleKey = 14, - /// Decrypted DVD sector title key, 5 bytes - DvdTitleKeyDecrypted = 15 - } +/// Metadata present for each sector (aka, "tag"). +public enum SectorTagType +{ + /// Apple's GCR sector tags, 12 bytes + AppleSectorTag = 0, + /// Sync frame from CD sector, 12 bytes + CdSectorSync = 1, + /// CD sector header, 4 bytes + CdSectorHeader = 2, + /// CD mode 2 sector subheader + CdSectorSubHeader = 3, + /// CD sector EDC, 4 bytes + CdSectorEdc = 4, + /// CD sector ECC P, 172 bytes + CdSectorEccP = 5, + /// CD sector ECC Q, 104 bytes + CdSectorEccQ = 6, + /// CD sector ECC (P and Q), 276 bytes + CdSectorEcc = 7, + /// CD sector subchannel, 96 bytes + CdSectorSubchannel = 8, + /// CD track ISRC, string, 12 bytes + CdTrackIsrc = 9, + /// CD track text, string, 13 bytes + CdTrackText = 10, + /// CD track flags, 1 byte + CdTrackFlags = 11, + /// DVD sector copyright information + DvdCmi = 12, + /// Floppy address mark (contents depend on underlying floppy format) + FloppyAddressMark = 13, + /// DVD sector title key, 5 bytes + DvdTitleKey = 14, + /// Decrypted DVD sector title key, 5 bytes + DvdTitleKeyDecrypted = 15 +} - /// Metadata present for each media. - [SuppressMessage("ReSharper", "InconsistentNaming")] - public enum MediaTagType - { - /// CD table of contents - CD_TOC = 0, - /// CD session information - CD_SessionInfo = 1, - /// CD full table of contents - CD_FullTOC = 2, - /// CD PMA - CD_PMA = 3, - /// CD Address-Time-In-Pregroove - CD_ATIP = 4, - /// CD-Text - CD_TEXT = 5, - /// CD Media Catalogue Number - CD_MCN = 6, - /// DVD/HD DVD Physical Format Information - DVD_PFI = 7, - /// DVD Lead-in Copyright Management Information - DVD_CMI = 8, - /// DVD disc key - DVD_DiscKey = 9, - /// DVD/HD DVD Burst Cutting Area - DVD_BCA = 10, - /// DVD/HD DVD Lead-in Disc Manufacturer Information - DVD_DMI = 11, - /// Media identifier - DVD_MediaIdentifier = 12, - /// Media key block - DVD_MKB = 13, - /// DVD-RAM/HD DVD-RAM DDS information - DVDRAM_DDS = 14, - /// DVD-RAM/HD DVD-RAM Medium status - DVDRAM_MediumStatus = 15, - /// DVD-RAM/HD DVD-RAM Spare area information - DVDRAM_SpareArea = 16, - /// DVD-R/-RW/HD DVD-R RMD in last border-out - DVDR_RMD = 17, - /// Pre-recorded information from DVD-R/-RW lead-in - DVDR_PreRecordedInfo = 18, - /// DVD-R/-RW/HD DVD-R media identifier - DVDR_MediaIdentifier = 19, - /// DVD-R/-RW/HD DVD-R physical format information - DVDR_PFI = 20, - /// ADIP information - DVD_ADIP = 21, - /// HD DVD Lead-in copyright protection information - HDDVD_CPI = 22, - /// HD DVD-R Medium Status - HDDVD_MediumStatus = 23, - /// DVD+/-R DL Layer capacity - DVDDL_LayerCapacity = 24, - /// DVD-R DL Middle Zone start address - DVDDL_MiddleZoneAddress = 25, - /// DVD-R DL Jump Interval Size - DVDDL_JumpIntervalSize = 26, - /// DVD-R DL Start LBA of the manual layer jump - DVDDL_ManualLayerJumpLBA = 27, - /// Blu-ray Disc Information - BD_DI = 28, - /// Blu-ray Burst Cutting Area - BD_BCA = 29, - /// Blu-ray Disc Definition Structure - BD_DDS = 30, - /// Blu-ray Cartridge Status - BD_CartridgeStatus = 31, - /// Blu-ray Status of Spare Area - BD_SpareArea = 32, - /// AACS volume identifier - AACS_VolumeIdentifier = 33, - /// AACS pre-recorded media serial number - AACS_SerialNumber = 34, - /// AACS media identifier - AACS_MediaIdentifier = 35, - /// Lead-in AACS media key block - AACS_MKB = 36, - /// AACS data keys - AACS_DataKeys = 37, - /// LBA extents flagged for bus encryption by AACS - AACS_LBAExtents = 38, - /// CPRM media key block in Lead-in - AACS_CPRM_MKB = 39, - /// Recognized layer formats in hybrid discs - Hybrid_RecognizedLayers = 40, - /// Disc write protection status - MMC_WriteProtection = 41, - /// Disc standard information - MMC_DiscInformation = 42, - /// Disc track resources information - MMC_TrackResourcesInformation = 43, - /// BD-R Pseudo-overwrite information - MMC_POWResourcesInformation = 44, - /// SCSI INQUIRY response - SCSI_INQUIRY = 45, - /// SCSI MODE PAGE 2Ah - SCSI_MODEPAGE_2A = 46, - /// ATA IDENTIFY DEVICE response - ATA_IDENTIFY = 47, - /// ATA IDENTIFY PACKET DEVICE response - ATAPI_IDENTIFY = 48, - /// PCMCIA/CardBus Card Information Structure - PCMCIA_CIS = 49, - /// SecureDigital CID - SD_CID = 50, - /// SecureDigital CSD - SD_CSD = 51, - /// SecureDigital SCR - SD_SCR = 52, - /// SecureDigital OCR - SD_OCR = 53, - /// MultiMediaCard CID - MMC_CID = 54, - /// MultiMediaCard CSD - MMC_CSD = 55, - /// MultiMediaCard OCR - MMC_OCR = 56, - /// MultiMediaCard Extended CSD - MMC_ExtendedCSD = 57, - /// Xbox Security Sector - Xbox_SecuritySector = 58, - /// - /// On floppy disks, data in last cylinder usually in a different format that contains duplication or - /// manufacturing information - /// - Floppy_LeadOut = 59, - /// DVD Disc Control Blocks - DCB = 60, - /// Compact Disc First Track Pregap - CD_FirstTrackPregap = 61, - /// Compact Disc Lead-out - CD_LeadOut = 62, - /// SCSI MODE SENSE (6) - SCSI_MODESENSE_6 = 63, - /// SCSI MODE SENSE (10) - SCSI_MODESENSE_10 = 64, - /// USB descriptors - USB_Descriptors = 65, - /// XGD unlocked DMI - Xbox_DMI = 66, - /// XDG unlocked PFI - Xbox_PFI = 67, - /// Compact Disc Lead-in - CD_LeadIn = 68, - /// 8 bytes response that seems to define type of MiniDisc - MiniDiscType = 69, - /// 4 bytes response to vendor command D5h - MiniDiscD5 = 70, - /// User TOC, contains fragments, track names, and can be from 1 to 3 sectors of 2336 bytes - MiniDiscUTOC = 71, - /// Not entirely clear kind of TOC that only appears on MD-DATA discs - MiniDiscDTOC = 72, - /// Decrypted DVD disc key - DVD_DiscKey_Decrypted = 73 - } +/// Metadata present for each media. +[SuppressMessage("ReSharper", "InconsistentNaming")] +public enum MediaTagType +{ + /// CD table of contents + CD_TOC = 0, + /// CD session information + CD_SessionInfo = 1, + /// CD full table of contents + CD_FullTOC = 2, + /// CD PMA + CD_PMA = 3, + /// CD Address-Time-In-Pregroove + CD_ATIP = 4, + /// CD-Text + CD_TEXT = 5, + /// CD Media Catalogue Number + CD_MCN = 6, + /// DVD/HD DVD Physical Format Information + DVD_PFI = 7, + /// DVD Lead-in Copyright Management Information + DVD_CMI = 8, + /// DVD disc key + DVD_DiscKey = 9, + /// DVD/HD DVD Burst Cutting Area + DVD_BCA = 10, + /// DVD/HD DVD Lead-in Disc Manufacturer Information + DVD_DMI = 11, + /// Media identifier + DVD_MediaIdentifier = 12, + /// Media key block + DVD_MKB = 13, + /// DVD-RAM/HD DVD-RAM DDS information + DVDRAM_DDS = 14, + /// DVD-RAM/HD DVD-RAM Medium status + DVDRAM_MediumStatus = 15, + /// DVD-RAM/HD DVD-RAM Spare area information + DVDRAM_SpareArea = 16, + /// DVD-R/-RW/HD DVD-R RMD in last border-out + DVDR_RMD = 17, + /// Pre-recorded information from DVD-R/-RW lead-in + DVDR_PreRecordedInfo = 18, + /// DVD-R/-RW/HD DVD-R media identifier + DVDR_MediaIdentifier = 19, + /// DVD-R/-RW/HD DVD-R physical format information + DVDR_PFI = 20, + /// ADIP information + DVD_ADIP = 21, + /// HD DVD Lead-in copyright protection information + HDDVD_CPI = 22, + /// HD DVD-R Medium Status + HDDVD_MediumStatus = 23, + /// DVD+/-R DL Layer capacity + DVDDL_LayerCapacity = 24, + /// DVD-R DL Middle Zone start address + DVDDL_MiddleZoneAddress = 25, + /// DVD-R DL Jump Interval Size + DVDDL_JumpIntervalSize = 26, + /// DVD-R DL Start LBA of the manual layer jump + DVDDL_ManualLayerJumpLBA = 27, + /// Blu-ray Disc Information + BD_DI = 28, + /// Blu-ray Burst Cutting Area + BD_BCA = 29, + /// Blu-ray Disc Definition Structure + BD_DDS = 30, + /// Blu-ray Cartridge Status + BD_CartridgeStatus = 31, + /// Blu-ray Status of Spare Area + BD_SpareArea = 32, + /// AACS volume identifier + AACS_VolumeIdentifier = 33, + /// AACS pre-recorded media serial number + AACS_SerialNumber = 34, + /// AACS media identifier + AACS_MediaIdentifier = 35, + /// Lead-in AACS media key block + AACS_MKB = 36, + /// AACS data keys + AACS_DataKeys = 37, + /// LBA extents flagged for bus encryption by AACS + AACS_LBAExtents = 38, + /// CPRM media key block in Lead-in + AACS_CPRM_MKB = 39, + /// Recognized layer formats in hybrid discs + Hybrid_RecognizedLayers = 40, + /// Disc write protection status + MMC_WriteProtection = 41, + /// Disc standard information + MMC_DiscInformation = 42, + /// Disc track resources information + MMC_TrackResourcesInformation = 43, + /// BD-R Pseudo-overwrite information + MMC_POWResourcesInformation = 44, + /// SCSI INQUIRY response + SCSI_INQUIRY = 45, + /// SCSI MODE PAGE 2Ah + SCSI_MODEPAGE_2A = 46, + /// ATA IDENTIFY DEVICE response + ATA_IDENTIFY = 47, + /// ATA IDENTIFY PACKET DEVICE response + ATAPI_IDENTIFY = 48, + /// PCMCIA/CardBus Card Information Structure + PCMCIA_CIS = 49, + /// SecureDigital CID + SD_CID = 50, + /// SecureDigital CSD + SD_CSD = 51, + /// SecureDigital SCR + SD_SCR = 52, + /// SecureDigital OCR + SD_OCR = 53, + /// MultiMediaCard CID + MMC_CID = 54, + /// MultiMediaCard CSD + MMC_CSD = 55, + /// MultiMediaCard OCR + MMC_OCR = 56, + /// MultiMediaCard Extended CSD + MMC_ExtendedCSD = 57, + /// Xbox Security Sector + Xbox_SecuritySector = 58, + /// + /// On floppy disks, data in last cylinder usually in a different format that contains duplication or + /// manufacturing information + /// + Floppy_LeadOut = 59, + /// DVD Disc Control Blocks + DCB = 60, + /// Compact Disc First Track Pregap + CD_FirstTrackPregap = 61, + /// Compact Disc Lead-out + CD_LeadOut = 62, + /// SCSI MODE SENSE (6) + SCSI_MODESENSE_6 = 63, + /// SCSI MODE SENSE (10) + SCSI_MODESENSE_10 = 64, + /// USB descriptors + USB_Descriptors = 65, + /// XGD unlocked DMI + Xbox_DMI = 66, + /// XDG unlocked PFI + Xbox_PFI = 67, + /// Compact Disc Lead-in + CD_LeadIn = 68, + /// 8 bytes response that seems to define type of MiniDisc + MiniDiscType = 69, + /// 4 bytes response to vendor command D5h + MiniDiscD5 = 70, + /// User TOC, contains fragments, track names, and can be from 1 to 3 sectors of 2336 bytes + MiniDiscUTOC = 71, + /// Not entirely clear kind of TOC that only appears on MD-DATA discs + MiniDiscDTOC = 72, + /// Decrypted DVD disc key + DVD_DiscKey_Decrypted = 73 +} - /// Enumeration of media types defined in CICM metadata - public enum XmlMediaType : byte - { - /// Purely optical discs - OpticalDisc = 0, - /// Media that is physically block-based or abstracted like that - BlockMedia = 1, - /// Media that can be accessed by-byte or by-bit, like chips - LinearMedia = 2, - /// Media that can only store data when it is modulated to audio - AudioMedia = 3 - } +/// Enumeration of media types defined in CICM metadata +public enum XmlMediaType : byte +{ + /// Purely optical discs + OpticalDisc = 0, + /// Media that is physically block-based or abstracted like that + BlockMedia = 1, + /// Media that can be accessed by-byte or by-bit, like chips + LinearMedia = 2, + /// Media that can only store data when it is modulated to audio + AudioMedia = 3 +} - /// CD flags bitmask - [Flags] - public enum CdFlags : byte - { - /// Track is quadraphonic. - FourChannel = 0x08, - /// Track is non-audio (data). - DataTrack = 0x04, - /// Track is copy protected. - CopyPermitted = 0x02, - /// Track has pre-emphasis. - PreEmphasis = 0x01 - } +/// CD flags bitmask +[Flags] +public enum CdFlags : byte +{ + /// Track is quadraphonic. + FourChannel = 0x08, + /// Track is non-audio (data). + DataTrack = 0x04, + /// Track is copy protected. + CopyPermitted = 0x02, + /// Track has pre-emphasis. + PreEmphasis = 0x01 +} - /// Status of a requested floppy sector - [Flags] - public enum FloppySectorStatus : byte - { - /// Both address mark and data checksums are correct. - Correct = 0x01, - /// Data checksum is incorrect. - DataError = 0x02, - /// Address mark checksum is incorrect. - AddressMarkError = 0x04, - /// There is another sector in the same track/head with same sector id. - Duplicated = 0x08, - /// Sector data section is not magnetized. - Demagnetized = 0x10, - /// Sector data section has a physically visible hole. - Hole = 0x20, - /// There is no address mark containing the requested sector id in the track/head. - NotFound = 0x40 - } +/// Status of a requested floppy sector +[Flags] +public enum FloppySectorStatus : byte +{ + /// Both address mark and data checksums are correct. + Correct = 0x01, + /// Data checksum is incorrect. + DataError = 0x02, + /// Address mark checksum is incorrect. + AddressMarkError = 0x04, + /// There is another sector in the same track/head with same sector id. + Duplicated = 0x08, + /// Sector data section is not magnetized. + Demagnetized = 0x10, + /// Sector data section has a physically visible hole. + Hole = 0x20, + /// There is no address mark containing the requested sector id in the track/head. + NotFound = 0x40 +} - /// Types of floppy disks - public enum FloppyTypes : byte - { - /// 8" floppy - Floppy, - /// 5.25" floppy - MiniFloppy, - /// 3.5" floppy - MicroFloppy, - /// 3" floppy - CompactFloppy, - /// 5.25" twiggy - FileWare, - /// 2.5" quickdisk - QuickDisk - } +/// Types of floppy disks +public enum FloppyTypes : byte +{ + /// 8" floppy + Floppy, + /// 5.25" floppy + MiniFloppy, + /// 3.5" floppy + MicroFloppy, + /// 3" floppy + CompactFloppy, + /// 5.25" twiggy + FileWare, + /// 2.5" quickdisk + QuickDisk +} - /// Enumeration of floppy densities - public enum FloppyDensities : byte - { - /// Standard coercivity (about 300Oe as found in 8" and 5.25"-double-density disks). - Standard, - /// Double density coercivity (about 600Oe as found in 5.25" HD and 3.5" DD disks). - Double, - /// High density coercivity (about 700Oe as found in 3.5" HD disks). - High, - /// Extended density coercivity (about 750Oe as found in 3.5" ED disks). - Extended - } +/// Enumeration of floppy densities +public enum FloppyDensities : byte +{ + /// Standard coercivity (about 300Oe as found in 8" and 5.25"-double-density disks). + Standard, + /// Double density coercivity (about 600Oe as found in 5.25" HD and 3.5" DD disks). + Double, + /// High density coercivity (about 700Oe as found in 3.5" HD disks). + High, + /// Extended density coercivity (about 750Oe as found in 3.5" ED disks). + Extended +} - /// Capabilities for optical media image formats - [Flags] - public enum OpticalImageCapabilities : ulong - { - /// Can store Red Book audio tracks? - CanStoreAudioTracks = 0x01, - /// Can store CD-V analogue video tracks? - CanStoreVideoTracks = 0x02, - /// Can store Yellow Book data tracks? - CanStoreDataTracks = 0x03, - /// Can store pregaps without needing to interpret the subchannel? - CanStorePregaps = 0x04, - /// Can store indexes without needing to interpret the subchannel? - CanStoreIndexes = 0x08, - /// Can store raw P to W subchannel data? - CanStoreSubchannelRw = 0x10, - /// Can store more than one session? - CanStoreSessions = 0x20, - /// Can store track ISRCs without needing to interpret the subchannel? - CanStoreIsrc = 0x40, - /// Can store Lead-In's CD-TEXT? - CanStoreCdText = 0x80, - /// Can store the MCN without needing to interpret the subchannel? - CanStoreMcn = 0x100, - /// Can store the whole 2352 bytes of a sector? - CanStoreRawData = 0x200, - /// Can store more than 1 session in media that is not CD based (DVD et al)? - CanStoreNotCdSessions = 0x2000, - /// Can store more than 1 track in media that is not CD based (DVD et al)? - CanStoreNotCdTracks = 0x4000, +/// Capabilities for optical media image formats +[Flags] +public enum OpticalImageCapabilities : ulong +{ + /// Can store Red Book audio tracks? + CanStoreAudioTracks = 0x01, + /// Can store CD-V analogue video tracks? + CanStoreVideoTracks = 0x02, + /// Can store Yellow Book data tracks? + CanStoreDataTracks = 0x03, + /// Can store pregaps without needing to interpret the subchannel? + CanStorePregaps = 0x04, + /// Can store indexes without needing to interpret the subchannel? + CanStoreIndexes = 0x08, + /// Can store raw P to W subchannel data? + CanStoreSubchannelRw = 0x10, + /// Can store more than one session? + CanStoreSessions = 0x20, + /// Can store track ISRCs without needing to interpret the subchannel? + CanStoreIsrc = 0x40, + /// Can store Lead-In's CD-TEXT? + CanStoreCdText = 0x80, + /// Can store the MCN without needing to interpret the subchannel? + CanStoreMcn = 0x100, + /// Can store the whole 2352 bytes of a sector? + CanStoreRawData = 0x200, + /// Can store more than 1 session in media that is not CD based (DVD et al)? + CanStoreNotCdSessions = 0x2000, + /// Can store more than 1 track in media that is not CD based (DVD et al)? + CanStoreNotCdTracks = 0x4000, - // TODO: Implement - /// Can store scrambled data? - CanStoreScrambledData = 0x400, - /// Can store only the user area of a sector (2048, 2324, etc)? - CanStoreCookedData = 0x800, - /// Can store more than 1 track? - CanStoreMultipleTracks = 0x1000 - } + // TODO: Implement + /// Can store scrambled data? + CanStoreScrambledData = 0x400, + /// Can store only the user area of a sector (2048, 2324, etc)? + CanStoreCookedData = 0x800, + /// Can store more than 1 track? + CanStoreMultipleTracks = 0x1000 +} + +/// Enumeration of linear memory device types +public enum LinearMemoryType +{ + /// Unknown device type + Unknown = 0, + /// Read-only memory + ROM = 1, + /// Read-write memory, power-off persistent, used to save data + SaveRAM = 2, + /// Read-write volatile memory + WorkRAM = 3, + /// NOR flash memory + NOR = 4, + /// NAND flash memory + NAND = 5, + /// Memory mapper device + Mapper = 6, + /// Processor, CPU, DSP, etc + Processor = 7, + /// Programmable Array Logic + PAL = 8, + /// Generic Array Logic + GAL = 9, + /// Electronically Erasable Programmable Read Only Memory + EEPROM = 10 } \ No newline at end of file diff --git a/Interfaces/IByteAddressableImage.cs b/Interfaces/IByteAddressableImage.cs index 7f35ffe..2c9f174 100644 --- a/Interfaces/IByteAddressableImage.cs +++ b/Interfaces/IByteAddressableImage.cs @@ -38,6 +38,7 @@ using System.Collections.Generic; using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Structs; namespace Aaru.CommonTypes.Interfaces; @@ -63,7 +64,7 @@ public interface IByteAddressableImage : IBaseWritableImage /// Gets the linear memory mappings, e.g. interleaving, starting address, etc. /// Format still not decided /// Error number - ErrorNumber GetMappings(out object mappings); + ErrorNumber GetMappings(out LinearMemoryMap mappings); /// Reads a byte from the image /// The byte read @@ -106,7 +107,7 @@ public interface IByteAddressableImage : IBaseWritableImage /// Sets the linear memory mappings, e.g. interleaving, starting address, etc. /// Format still not decided /// Error number - ErrorNumber SetMappings(object mappings); + ErrorNumber SetMappings(LinearMemoryMap mappings); /// Writes a byte to the image /// The byte to be written diff --git a/Structs/Images.cs b/Structs/Images.cs index 48aad8d..84cb1ee 100644 --- a/Structs/Images.cs +++ b/Structs/Images.cs @@ -38,153 +38,208 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -namespace Aaru.CommonTypes.Structs +namespace Aaru.CommonTypes.Structs; + +/// Contains information about a dump image and its contents +public struct ImageInfo { - /// Contains information about a dump image and its contents - public struct ImageInfo - { - /// Image contains partitions (or tracks for optical media) - public bool HasPartitions; - /// Image contains sessions (optical media only) - public bool HasSessions; - /// Size of the image without headers - public ulong ImageSize; - /// Sectors contained in the image - public ulong Sectors; - /// Size of sectors contained in the image - public uint SectorSize; - /// Media tags contained by the image - public List ReadableMediaTags; - /// Sector tags contained by the image - public List ReadableSectorTags; - /// Image version - public string Version; - /// Application that created the image - public string Application; - /// Version of the application that created the image - public string ApplicationVersion; - /// Who (person) created the image? - public string Creator; - /// Image creation time - public DateTime CreationTime; - /// Image last modification time - public DateTime LastModificationTime; - /// Title of the media represented by the image - public string MediaTitle; - /// Image comments - public string Comments; - /// Manufacturer of the media represented by the image - public string MediaManufacturer; - /// Model of the media represented by the image - public string MediaModel; - /// Serial number of the media represented by the image - public string MediaSerialNumber; - /// Barcode of the media represented by the image - public string MediaBarcode; - /// Part number of the media represented by the image - public string MediaPartNumber; - /// Media type represented by the image - public MediaType MediaType; - /// Number in sequence for the media represented by the image - public int MediaSequence; - /// Last media of the sequence the media represented by the image corresponds to - public int LastMediaSequence; - /// Manufacturer of the drive used to read the media represented by the image - public string DriveManufacturer; - /// Model of the drive used to read the media represented by the image - public string DriveModel; - /// Serial number of the drive used to read the media represented by the image - public string DriveSerialNumber; - /// Firmware revision of the drive used to read the media represented by the image - public string DriveFirmwareRevision; - /// Type of the media represented by the image to use in XML sidecars - public XmlMediaType XmlMediaType; + /// Image contains partitions (or tracks for optical media) + public bool HasPartitions; + /// Image contains sessions (optical media only) + public bool HasSessions; + /// Size of the image without headers + public ulong ImageSize; + /// Sectors contained in the image + public ulong Sectors; + /// Size of sectors contained in the image + public uint SectorSize; + /// Media tags contained by the image + public List ReadableMediaTags; + /// Sector tags contained by the image + public List ReadableSectorTags; + /// Image version + public string Version; + /// Application that created the image + public string Application; + /// Version of the application that created the image + public string ApplicationVersion; + /// Who (person) created the image? + public string Creator; + /// Image creation time + public DateTime CreationTime; + /// Image last modification time + public DateTime LastModificationTime; + /// Title of the media represented by the image + public string MediaTitle; + /// Image comments + public string Comments; + /// Manufacturer of the media represented by the image + public string MediaManufacturer; + /// Model of the media represented by the image + public string MediaModel; + /// Serial number of the media represented by the image + public string MediaSerialNumber; + /// Barcode of the media represented by the image + public string MediaBarcode; + /// Part number of the media represented by the image + public string MediaPartNumber; + /// Media type represented by the image + public MediaType MediaType; + /// Number in sequence for the media represented by the image + public int MediaSequence; + /// Last media of the sequence the media represented by the image corresponds to + public int LastMediaSequence; + /// Manufacturer of the drive used to read the media represented by the image + public string DriveManufacturer; + /// Model of the drive used to read the media represented by the image + public string DriveModel; + /// Serial number of the drive used to read the media represented by the image + public string DriveSerialNumber; + /// Firmware revision of the drive used to read the media represented by the image + public string DriveFirmwareRevision; + /// Type of the media represented by the image to use in XML sidecars + public XmlMediaType XmlMediaType; - // CHS geometry... - /// Cylinders of the media represented by the image - public uint Cylinders; - /// Heads of the media represented by the image - public uint Heads; - /// Sectors per track of the media represented by the image (for variable image, the smallest) - public uint SectorsPerTrack; - } + // CHS geometry... + /// Cylinders of the media represented by the image + public uint Cylinders; + /// Heads of the media represented by the image + public uint Heads; + /// Sectors per track of the media represented by the image (for variable image, the smallest) + public uint SectorsPerTrack; +} - /// Session defining structure. - public struct Session - { - /// Session number, 1-started - public ushort Sequence; - /// First track present on this session - public uint StartTrack; - /// Last track present on this session - public uint EndTrack; - /// First sector present on this session - public ulong StartSector; - /// Last sector present on this session - public ulong EndSector; - } +/// Session defining structure. +public struct Session +{ + /// Session number, 1-started + public ushort Sequence; + /// First track present on this session + public uint StartTrack; + /// Last track present on this session + public uint EndTrack; + /// First sector present on this session + public ulong StartSector; + /// Last sector present on this session + public ulong EndSector; +} - /// Track defining structure. - public class Track - { - /// How many main channel / user data bytes are per sector in this track - public int BytesPerSector; - /// Information that does not find space in this struct - public string Description; - /// Track ending sector - public ulong EndSector; - /// Which file stores this track - public string File; - /// Starting at which byte is this track stored - public ulong FileOffset; - /// What kind of file is storing this track - public string FileType; - /// Which filter stores this track - public IFilter Filter; - /// Indexes, 00 to 99 and sector offset - public Dictionary Indexes; - /// Track pre-gap - public ulong Pregap; - /// How many main channel bytes per sector are in the file with this track - public int RawBytesPerSector; - /// Track number, 1-started - public uint Sequence; - /// Session this track belongs to - public ushort Session; - /// Track starting sector - public ulong StartSector; - /// Which file stores this track's subchannel - public string SubchannelFile; - /// Which filter stores this track's subchannel - public IFilter SubchannelFilter; - /// Starting at which byte are this track's subchannel stored - public ulong SubchannelOffset; - /// Type of subchannel stored for this track - public TrackSubchannelType SubchannelType; - /// Partition type - public TrackType Type; +/// Track defining structure. +public class Track +{ + /// How many main channel / user data bytes are per sector in this track + public int BytesPerSector; + /// Information that does not find space in this struct + public string Description; + /// Track ending sector + public ulong EndSector; + /// Which file stores this track + public string File; + /// Starting at which byte is this track stored + public ulong FileOffset; + /// What kind of file is storing this track + public string FileType; + /// Which filter stores this track + public IFilter Filter; + /// Indexes, 00 to 99 and sector offset + public Dictionary Indexes; + /// Track pre-gap + public ulong Pregap; + /// How many main channel bytes per sector are in the file with this track + public int RawBytesPerSector; + /// Track number, 1-started + public uint Sequence; + /// Session this track belongs to + public ushort Session; + /// Track starting sector + public ulong StartSector; + /// Which file stores this track's subchannel + public string SubchannelFile; + /// Which filter stores this track's subchannel + public IFilter SubchannelFilter; + /// Starting at which byte are this track's subchannel stored + public ulong SubchannelOffset; + /// Type of subchannel stored for this track + public TrackSubchannelType SubchannelType; + /// Partition type + public TrackType Type; - /// Initializes an empty instance of this structure - public Track() => Indexes = new Dictionary(); - } + /// Initializes an empty instance of this structure + public Track() => Indexes = new Dictionary(); +} - /// Floppy physical characteristics structure. - public struct FloppyInfo - { - /// Physical floppy type. - public FloppyTypes Type; - /// Bitrate in bits per second used to write the floppy, 0 if unknown or track-variable. - public uint Bitrate; - /// Physical magnetic density (coercivity) of floppy medium. - public FloppyDensities Coercivity; - /// How many physical tracks are actually written in the floppy image. - public ushort Tracks; - /// How many physical heads are actually written in the floppy image. - public byte Heads; - /// How many tracks per inch are actually written in the floppy image. - public ushort TrackDensity; - } +/// Floppy physical characteristics structure. +public struct FloppyInfo +{ + /// Physical floppy type. + public FloppyTypes Type; + /// Bitrate in bits per second used to write the floppy, 0 if unknown or track-variable. + public uint Bitrate; + /// Physical magnetic density (coercivity) of floppy medium. + public FloppyDensities Coercivity; + /// How many physical tracks are actually written in the floppy image. + public ushort Tracks; + /// How many physical heads are actually written in the floppy image. + public byte Heads; + /// How many tracks per inch are actually written in the floppy image. + public ushort TrackDensity; +} + +/// Provides a map for linear memory structure +public struct LinearMemoryMap +{ + /// List of devices that are mapped to linear memory + [NotNull] + public LinearMemoryDevice[] Devices { get; set; } +} + +/// Provides information about a linear memory device +public struct LinearMemoryDevice +{ + /// Device manufacturer + public string Manufacturer { get; set; } + /// Device model + public string Model { get; set; } + /// Device package, e.g. DIP28 + public string Package { get; set; } + /// Device location marking in PCB, e.g. U28 + public string Location { get; set; } + /// Device functional type + public LinearMemoryType Type { get; set; } + /// Arbitrary device information + public string Description { get; set; } + /// + /// Physical addressing is the address considering all devices in the linear memory media, starting at the lowest + /// marking in PCB and going up incrementally. This is the view of the memory inside Aaru. + /// + public LinearMemoryAddressing PhysicalAddress { get; set; } + /// + /// Virtual addressing is the address as seen by the hardware directly accessing the linear memory media. This + /// allows devices to be overlapped or banked. + /// + public LinearMemoryAddressing VirtualAddress { get; set; } +} + +/// Maps the addressing of a linear memory device +public class LinearMemoryAddressing +{ + /// Start in memory where the device is mapped + public ulong Start { get; set; } + /// Length in bytes of the device, not including interleaving + public ulong Length { get; set; } + /// Interleaving information + public LinearMemoryInterleave Interleave { get; set; } +} + +/// Provides information about a device interleaving +public class LinearMemoryInterleave +{ + /// How many bytes to skip from start of map before device first byte starts + public uint Offset { get; set; } + /// How many bytes in memory to skip every device byte + public uint Value { get; set; } } \ No newline at end of file