示例#1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="traits">The memory traits.</param>
 /// <param name="sRegion">The unique name of the memory region.</param>
 /// <param name="regnAddr">The region's (start,end) addresses.</param>
 /// <param name="memDomain">The memory domain type.</param>
 /// <param name="memSubDomain">The memory sub-domain type.</param>
 /// <exception cref="InvalidOperationException">Thrown if the map can't provide the region's
 ///                                             memory traits.</exception>
 public MemoryRegionBase(MemTraits traits, string sRegion, AddressRange regnAddr, PICMemoryDomain memDomain, PICMemorySubDomain memSubDomain)
 {
     this.Trait  = null !;
     this.traits = traits;
     RegionName  = sRegion;
     if (regnAddr != null)
     {
         LogicalByteAddrRange  = regnAddr;
         PhysicalByteAddrRange = regnAddr;
     }
     else
     {
         LogicalByteAddrRange = PhysicalByteAddrRange = new AddressRange(Address.Ptr32(0), Address.Ptr32(0));
     }
     TypeOfMemory    = memDomain;
     SubtypeOfMemory = memSubDomain;
     if (SubtypeOfMemory != PICMemorySubDomain.NNMR)  // Non-Memory-Mapped-Registers have no memory characteristics.
     {
         if (!this.traits.GetTrait(memDomain, memSubDomain, out IPICMemTrait trait))
         {
             throw new InvalidOperationException($"Missing characteristics for [{memDomain}/{memSubDomain}] memory region '{RegionName}'");
         }
         Trait = trait;
     }
 }
示例#2
0
 /// <summary>
 /// Gets the memory trait corresponding to the specified memory domain and sub-domain.
 /// </summary>
 /// <param name="dom">A memory domain value from the <see cref="PICMemoryDomain"/> enumeration.</param>
 /// <param name="subdom">A sub-domain value from the <see cref="PICMemorySubDomain"/> enumeration.</param>
 /// <param name="trait">[out] The memory trait.</param>
 /// <returns>
 /// True if it succeeds, false if it fails.
 /// </returns>
 public bool GetTrait(PICMemoryDomain dom, PICMemorySubDomain subdom, out IPICMemTrait trait)
 {
     if (!maptraits.TryGetValue(new MemoryDomainKey(dom, subdom), out trait))
     {
         trait = memtraitdefault;
     }
     return(true);
 }
示例#3
0
 public MemoryDomainKey(PICMemoryDomain dom, PICMemorySubDomain subdom)
 {
     Domain    = dom;
     SubDomain = subdom;
 }