Fix linear memory mapping structure.

This commit is contained in:
2021-11-21 18:19:17 +00:00
parent 1b06a5a972
commit be2f77fbe3
3 changed files with 561 additions and 479 deletions

View File

@@ -42,8 +42,8 @@ using System.Diagnostics.CodeAnalysis;
// ReSharper disable UnusedMember.Global
namespace Aaru.CommonTypes.Enums
{
namespace Aaru.CommonTypes.Enums;
/// <summary>Track (as partitioning element) types.</summary>
public enum TrackType : byte
{
@@ -390,4 +390,30 @@ namespace Aaru.CommonTypes.Enums
/// <summary>Can store more than 1 track?</summary>
CanStoreMultipleTracks = 0x1000
}
/// <summary>Enumeration of linear memory device types</summary>
public enum LinearMemoryType
{
/// <summary>Unknown device type</summary>
Unknown = 0,
/// <summary>Read-only memory</summary>
ROM = 1,
/// <summary>Read-write memory, power-off persistent, used to save data</summary>
SaveRAM = 2,
/// <summary>Read-write volatile memory</summary>
WorkRAM = 3,
/// <summary>NOR flash memory</summary>
NOR = 4,
/// <summary>NAND flash memory</summary>
NAND = 5,
/// <summary>Memory mapper device</summary>
Mapper = 6,
/// <summary>Processor, CPU, DSP, etc</summary>
Processor = 7,
/// <summary>Programmable Array Logic</summary>
PAL = 8,
/// <summary>Generic Array Logic</summary>
GAL = 9,
/// <summary>Electronically Erasable Programmable Read Only Memory</summary>
EEPROM = 10
}

View File

@@ -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
/// <summary>Gets the linear memory mappings, e.g. interleaving, starting address, etc.</summary>
/// <param name="mappings">Format still not decided</param>
/// <returns>Error number</returns>
ErrorNumber GetMappings(out object mappings);
ErrorNumber GetMappings(out LinearMemoryMap mappings);
/// <summary>Reads a byte from the image</summary>
/// <param name="b">The byte read</param>
@@ -106,7 +107,7 @@ public interface IByteAddressableImage : IBaseWritableImage
/// <summary>Sets the linear memory mappings, e.g. interleaving, starting address, etc.</summary>
/// <param name="mappings">Format still not decided</param>
/// <returns>Error number</returns>
ErrorNumber SetMappings(object mappings);
ErrorNumber SetMappings(LinearMemoryMap mappings);
/// <summary>Writes a byte to the image</summary>
/// <param name="b">The byte to be written</param>

View File

@@ -38,11 +38,12 @@
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;
/// <summary>Contains information about a dump image and its contents</summary>
public struct ImageInfo
{
@@ -187,4 +188,58 @@ namespace Aaru.CommonTypes.Structs
/// <summary>How many tracks per inch are actually written in the floppy image.</summary>
public ushort TrackDensity;
}
/// <summary>Provides a map for linear memory structure</summary>
public struct LinearMemoryMap
{
/// <summary>List of devices that are mapped to linear memory</summary>
[NotNull]
public LinearMemoryDevice[] Devices { get; set; }
}
/// <summary>Provides information about a linear memory device</summary>
public struct LinearMemoryDevice
{
/// <summary>Device manufacturer</summary>
public string Manufacturer { get; set; }
/// <summary>Device model</summary>
public string Model { get; set; }
/// <summary>Device package, e.g. DIP28</summary>
public string Package { get; set; }
/// <summary>Device location marking in PCB, e.g. U28</summary>
public string Location { get; set; }
/// <summary>Device functional type</summary>
public LinearMemoryType Type { get; set; }
/// <summary>Arbitrary device information</summary>
public string Description { get; set; }
/// <summary>
/// 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.
/// </summary>
public LinearMemoryAddressing PhysicalAddress { get; set; }
/// <summary>
/// Virtual addressing is the address as seen by the hardware directly accessing the linear memory media. This
/// allows devices to be overlapped or banked.
/// </summary>
public LinearMemoryAddressing VirtualAddress { get; set; }
}
/// <summary>Maps the addressing of a linear memory device</summary>
public class LinearMemoryAddressing
{
/// <summary>Start in memory where the device is mapped</summary>
public ulong Start { get; set; }
/// <summary>Length in bytes of the device, not including interleaving</summary>
public ulong Length { get; set; }
/// <summary>Interleaving information</summary>
public LinearMemoryInterleave Interleave { get; set; }
}
/// <summary>Provides information about a device interleaving</summary>
public class LinearMemoryInterleave
{
/// <summary>How many bytes to skip from start of map before device first byte starts</summary>
public uint Offset { get; set; }
/// <summary>How many bytes in memory to skip every device byte</summary>
public uint Value { get; set; }
}