public bool TryWriteAccess(ulong offset, uint value, SysbusAccessWidth width) { int bytesToWrite = CheckAndGetWidth(width); var weHaveIt = false; if (HitInTheRegisterDictionary(out var tmpRegister, offset, bytesToWrite)) { weHaveIt = true; if (tmpRegister.HasWriteAccess) { LogWriteSuccess(value, tmpRegister.Peripheral.Name, tmpRegister.Name, offset); } else if (tmpRegister.HasWriteOnceAccess) { LogWriteSuccess(value, tmpRegister.Peripheral.Name, tmpRegister.Name, offset, true); } else { LogWriteFail(value, tmpRegister.Peripheral.Name, tmpRegister.Name, offset); } } else { LogWriteRequests(value, offset, bytesToWrite, ref weHaveIt); } return(weHaveIt); }
public bool TryReadAccess(ulong offset, out uint value, SysbusAccessWidth type) { var bytesToRead = CheckAndGetWidth(type); var weHaveIt = false; value = 0; if (HitInTheRegisterDictionary(out var tmpRegister, offset, bytesToRead)) { weHaveIt = true; if (tmpRegister.HasReadAccess) { value = tmpRegister.ResetValue; LogReadSuccess(value, tmpRegister.Peripheral.Name, tmpRegister.Name, offset); } else { LogReadFail(tmpRegister.Peripheral.Name, tmpRegister.Name, offset); } } else { value = AssambleValueFromRegisters(offset, bytesToRead, ref weHaveIt); } return(weHaveIt); }
public void Invoke(ICpuSupportingGdb cpu, ulong currentAddress, SysbusAccessWidth currentWidth, uint value = 0) { if ((currentWidth & width) != 0) { action(cpu, currentAddress, currentWidth, value); } }
public CFIFlash(string fileName, int size, SysbusAccessWidth bits = SysbusAccessWidth.DoubleWord, bool nonPersistent = false) { switch (bits) { case SysbusAccessWidth.Byte: busWidth = 0; break; case SysbusAccessWidth.Word: busWidth = 1; break; case SysbusAccessWidth.DoubleWord: 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 void Invoke(ulong currentAddress, SysbusAccessWidth currentWidth) { if (updateContext != null) { updateContext(); } if ((currentWidth & width) != 0) { action(currentAddress, currentWidth); } }
private static int CheckAndGetWidth(SysbusAccessWidth type) { switch(type) { case SysbusAccessWidth.Byte: case SysbusAccessWidth.Word: case SysbusAccessWidth.DoubleWord: return (int)type; default: throw new ArgumentException($"'{type}' is unsupported width of data."); } }
private static void LogNotTranslated(IBusPeripheral peripheral, SysbusAccessWidth operationWidth, long address, uint?value = null) { var strBldr = new StringBuilder(); strBldr.AppendFormat("Attempt to {0} {1} from peripheral that doesn't support {1} interface.", value.HasValue ? "write" : "read", operationWidth); strBldr.AppendFormat(" Offset 0x{0:X}", address); if (value.HasValue) { strBldr.AppendFormat(", value 0x{0:X}", value.Value); } strBldr.Append("."); peripheral.Log(LogLevel.Warning, peripheral.GetMachine().SystemBus.DecorateWithCPUNameAndPC(strBldr.ToString())); }
public BusHookHandler(Action <ulong, SysbusAccessWidth> action, SysbusAccessWidth width, Action updateContext) { this.action = action; this.width = width; this.updateContext = updateContext; }
public static void AddWatchpointHook(this SystemBus sysbus, ulong address, SysbusAccessWidth width, Access access, string pythonScript) { var engine = new WatchpointHookPythonEngine(sysbus, pythonScript); sysbus.AddWatchpointHook(address, width, access, engine.Hook); }
public BusHookHandler(BusHookDelegate action, SysbusAccessWidth width) { this.action = action; this.width = width; Enabled = true; }
public static void CFIFlashFromFile(this Machine machine, string fileName, ulong whereToRegister, string name, SysbusAccessWidth busWidth = SysbusAccessWidth.DoubleWord, 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 BusHookHandler(Action <ICpuSupportingGdb, ulong, SysbusAccessWidth> action, SysbusAccessWidth width) { this.action = action; this.width = width; Enabled = true; }