1 // 2 // Copyright (c) 2010-2024 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System; 9 using Antmicro.Renode.Core; 10 using Antmicro.Renode.Peripherals.Bus; 11 using System.IO; 12 using Antmicro.Renode.Exceptions; 13 14 namespace Antmicro.Renode.Peripherals.MTD 15 { 16 public static class CFIFlashExtensions 17 { CFIFlashFromFile(this IMachine machine, string fileName, ulong whereToRegister, string name, SysbusAccessWidth busWidth = SysbusAccessWidth.DoubleWord, bool nonPersistent = false, int? size = null)18 public static void CFIFlashFromFile(this IMachine machine, string fileName, ulong whereToRegister, string name, SysbusAccessWidth busWidth = SysbusAccessWidth.DoubleWord, bool nonPersistent = false, int? size = null) 19 { 20 CFIFlash flash; 21 try 22 { 23 flash = new CFIFlash(fileName, size, busWidth, nonPersistent); 24 } 25 catch(Exception e) 26 { 27 throw new ConstructionException(String.Format("Could not create object of type {0}", typeof(CFIFlash).Name), e); 28 } 29 machine.SystemBus.Register(flash, new BusPointRegistration(whereToRegister)); 30 machine.SetLocalName(flash, name); 31 } 32 } 33 } 34 35