public CFIFlash(string fileName, int size, BusWidth bits = BusWidth.Bits32, bool nonPersistent = false) { switch (bits) { case BusWidth.Bits8: busWidth = 0; break; case BusWidth.Bits16: busWidth = 1; break; case BusWidth.Bits32: busWidth = 2; break; default: throw new ArgumentOutOfRangeException(); } CheckSize(size); this.size = size; // default erase block is whole flash or 256KB EraseBlockSize = Math.Min(size, DefaultEraseBlockSize); this.nonPersistent = nonPersistent; Init(fileName); CheckBuffer(0); }
public static void CFIFlashFromFile(this Machine machine, string fileName, long whereToRegister, string name, BusWidth busWidth = BusWidth.Bits32, bool nonPersistent = false, int? size = null) { CFIFlash flash; try { flash = new CFIFlash(fileName, size ?? (int)new FileInfo(fileName).Length, busWidth, nonPersistent); } catch(Exception e) { throw new ConstructionException(String.Format("Could not create object of type {0}", typeof(CFIFlash).Name), e); } machine.SystemBus.Register(flash, new BusPointRegistration(whereToRegister)); machine.SetLocalName(flash, name); }
public CFIFlash(string fileName, int size, BusWidth bits = BusWidth.Bits32, bool nonPersistent = false) { switch(bits) { case BusWidth.Bits8: busWidth = 0; break; case BusWidth.Bits16: busWidth = 1; break; case BusWidth.Bits32: busWidth = 2; break; default: throw new ArgumentOutOfRangeException(); } CheckSize(size); this.size = size; // default erase block is whole flash or 256KB EraseBlockSize = Math.Min(size, DefaultEraseBlockSize); this.nonPersistent = nonPersistent; Init(fileName); CheckBuffer(0); }
public static void CFIFlashFromFile(this Machine machine, string fileName, long whereToRegister, string name, BusWidth busWidth = BusWidth.Bits32, bool nonPersistent = false, int?size = null) { CFIFlash flash; try { flash = new CFIFlash(fileName, size ?? (int)new FileInfo(fileName).Length, busWidth, nonPersistent); } catch (Exception e) { throw new ConstructionException(String.Format("Could not create object of type {0}", typeof(CFIFlash).Name), e); } machine.SystemBus.Register(flash, new BusPointRegistration(whereToRegister)); machine.SetLocalName(flash, name); }