public void DisconnectFromAll(IEmulationElement element) { var interestingKeys = connections.GetAllForRight(element); foreach(var external in interestingKeys) { Disconnect(external, element); } }
public ClockEntry(ulong period, long ratio, Action handler, IEmulationElement owner, string localName, bool enabled = true, Direction direction = Direction.Ascending, WorkMode workMode = WorkMode.Periodic) : this() { this.Value = direction == Direction.Ascending ? 0 : period; this.Ratio = ratio; this.Period = period; this.Handler = handler; this.Enabled = enabled; this.Direction = direction; this.WorkMode = workMode; this.Owner = owner; this.LocalName = localName; }
public void Disconnect(IConnectable connector, IEmulationElement connectee) { try { ((dynamic)connector).DetachFrom((dynamic)connectee); connections.RemovePair(connector, connectee); } catch(RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType(), true); } }
public void Disconnect(IConnectable connector, IEmulationElement connectee) { try { ((dynamic)connector).DetachFrom((dynamic)connectee); connections.RemovePair(connector, connectee); } catch (RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType(), true); } }
public void Connect(IEmulationElement connectee, IConnectable connector) { try { ((dynamic)connector).AttachTo((dynamic)connectee); connections.Add(connector, connectee); } catch (RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType()); } }
public void Connect(IEmulationElement connectee, IConnectable connector) { try { ((dynamic)connector).AttachTo((dynamic)connectee); connections.Add(connector, connectee); } catch (RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType()); } }
public ClockEntry(ulong period, long frequency, Action handler, IEmulationElement owner, string localName, bool enabled = true, Direction direction = Direction.Ascending, WorkMode workMode = WorkMode.Periodic, long step = 1) : this() { this.Value = direction == Direction.Ascending ? 0 : period; this.Frequency = frequency; this.Step = step; this.Period = period; this.Handler = handler; this.Enabled = enabled; this.Direction = direction; this.WorkMode = workMode; this.Owner = owner; this.LocalName = localName; this.Ratio = Step * FrequencyToRatio(owner, Frequency); }
public static long HzToTicksSafe(long hz, IEmulationElement sender) { var result = (long)Math.Round(HzToTicks(hz)); if(result == 0) { result = 1; } var againInHz = TicksToHz(result); if(Math.Abs(againInHz - hz) / hz > MaximalDifference) { sender.Log(LogLevel.Warning, "Significant difference between desired and actual frequency: {0}Hz={1}Hz vs {2}Hz={3}Hz,", Misc.NormalizeDecimal(hz), Misc.NormalizeDecimal(againInHz), hz, againInHz); } return result; }
public bool TryGetEmulationElementByName(string name, object context, out IEmulationElement element) { if (name == null) { element = null; return(false); } var machineContext = context as Machine; if (machineContext != null) { IPeripheral outputPeripheral; if ((machineContext.TryGetByName(name, out outputPeripheral) || machineContext.TryGetByName(string.Format("sysbus.{0}", name), out outputPeripheral))) { element = outputPeripheral; return(true); } } Machine machine; if (TryGetMachineByName(name, out machine)) { element = machine; return(true); } IExternal external; if (ExternalsManager.TryGetByName(name, out external)) { element = external; return(true); } IHostMachineElement hostMachineElement; if (name.StartsWith(string.Format("{0}.", HostMachine.HostMachineName)) && HostMachine.TryGetByName(name.Substring(HostMachine.HostMachineName.Length + 1), out hostMachineElement)) { element = hostMachineElement; return(true); } element = null; return(false); }
private static string GetName(IEmulationElement element, IEmulationElement nextElement = null) { string elementName; var emulation = EmulationManager.Instance.CurrentEmulation; emulation.TryGetEmulationElementName(element, out elementName); if (nextElement != null) { string nextElementName; emulation.TryGetEmulationElementName(nextElement, out nextElementName); nextElementName = nextElementName.Replace(':', '-').Replace('.', '-'); return("{0}-{1}-{2}".FormatWith(WiresharkExternalPrefix, elementName, nextElementName)); } return("{0}-{1}".FormatWith(WiresharkExternalPrefix, elementName)); }
public static long HzToTicksSafe(long hz, IEmulationElement sender) { var result = (long)Math.Round(HzToTicks(hz)); if (result == 0) { result = 1; } var againInHz = TicksToHz(result); if (Math.Abs(againInHz - hz) / hz > MaximalDifference) { sender.Log(LogLevel.Warning, "Significant difference between desired and actual frequency: {0}Hz={1}Hz vs {2}Hz={3}Hz,", Misc.NormalizeDecimal(hz), Misc.NormalizeDecimal(againInHz), hz, againInHz); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="Emul8.Utilities.Runtime.NativeBinder"/> class /// and performs binding between the class and given library. /// </summary> /// <param name='classToBind'> /// Class to bind. /// </param> /// <param name='libraryFile'> /// Library file to bind. /// </param> /// <remarks> /// Please note that: /// <list type="bullet"> /// <item><description> /// This works now only with ELF libraries. /// </description></item> /// <item><description> /// You have to hold the reference to created native binder as long as the native functions /// can call managed one. /// </description></item> /// <item><description> /// You should dispose native binder after use to free memory taken by the native library. /// </description></item> /// </list> /// </remarks> public NativeBinder(IEmulationElement classToBind, string libraryFile) { delegateStore = new object[0]; this.classToBind = classToBind; libraryAddress = SharedLibraries.LoadLibrary(libraryFile); libraryFileName = libraryFile; try { ResolveCallsToNative(); ResolveCallsToManaged(); } catch { Dispose(); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="Emul8.Utilities.Runtime.NativeBinder"/> class /// and performs binding between the class and given library. /// </summary> /// <param name='classToBind'> /// Class to bind. /// </param> /// <param name='libraryFile'> /// Library file to bind. /// </param> /// <remarks> /// Please note that: /// <list type="bullet"> /// <item><description> /// This works now only with ELF libraries. /// </description></item> /// <item><description> /// You have to hold the reference to created native binder as long as the native functions /// can call managed one. /// </description></item> /// <item><description> /// You should dispose native binder after use to free memory taken by the native library. /// </description></item> /// </list> /// </remarks> public NativeBinder(IEmulationElement classToBind, string libraryFile) { delegateStore = new object[0]; handles = new GCHandle[0]; this.classToBind = classToBind; libraryAddress = SharedLibraries.LoadLibrary(libraryFile); libraryFileName = libraryFile; try { ResolveCallsToNative(); ResolveCallsToManaged(); } catch { Dispose(); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="Antmicro.Renode.Utilities.Runtime.NativeBinder"/> class /// and performs binding between the class and given library. /// </summary> /// <param name='classToBind'> /// Class to bind. /// </param> /// <param name='libraryFile'> /// Library file to bind. /// </param> /// <remarks> /// Please note that: /// <list type="bullet"> /// <item><description> /// This works now only with ELF libraries. /// </description></item> /// <item><description> /// You have to hold the reference to created native binder as long as the native functions /// can call managed one. /// </description></item> /// <item><description> /// You should dispose native binder after use to free memory taken by the native library. /// </description></item> /// </list> /// </remarks> public NativeBinder(IEmulationElement classToBind, string libraryFile) { delegateStore = new object[0]; #if !PLATFORM_WINDOWS handles = new GCHandle[0]; #endif this.classToBind = classToBind; libraryAddress = SharedLibraries.LoadLibrary(libraryFile); libraryFileName = libraryFile; var importFields = classToBind.GetType().GetAllFields().Where(x => x.IsDefined(typeof(ImportAttribute), false)).ToList(); EnsureWrappersType(importFields); wrappersObj = CreateWrappersObject(); try { ResolveCallsToNative(importFields); ResolveCallsToManaged(); } catch { Dispose(); throw; } }
private bool SetLogLevel(LogLevel level, string backendName = null, string peripheralName = null) { IEmulationElement emulationElement = null; if (peripheralName != null && !EmulationManager.Instance.CurrentEmulation.TryGetEmulationElementByName(peripheralName, monitor.Machine, out emulationElement)) { return(false); } int id = (emulationElement == null) ? -1 : EmulationManager.Instance.CurrentEmulation.CurrentLogger.GetOrCreateSourceId(emulationElement); bool somethingWasSet = false; foreach (var b in Logger.GetBackends()) { if ((backendName == null || b.Key == backendName) && b.Value.IsControllable) { b.Value.SetLogLevel(level, id); somethingWasSet = true; } } return(somethingWasSet); }
public void Disconnect(IEmulationElement connectee, IConnectable connector) { Disconnect(connector, connectee); }
public static void NoisyLog(this IEmulationElement e, string message) { Log(e, LogLevel.Noisy, message); }
public static void DebugLog(this IEmulationElement e, string message, params object[] args) { DebugLog(e, string.Format(message, args)); }
public static void DebugLog(this IEmulationElement e, string message) { Log(e, LogLevel.Debug, message); }
public static void Log(this IEmulationElement e, LogLevel type, string message, params object[] args) { LogAs(e, type, message, args); }
public static void Log(this IEmulationElement e, LogLevel type, string message) { LogAs(e, type, message, null); }
public Packer(IEmulationElement parent) { this.parent = parent; byteQueue = new Queue <byte>(); queueLock = new object(); }
public IEnumerable <IConnectable <IEmulationElement> > GetConnectionsFor(IEmulationElement obj) { return(connections.GetAllForRight(obj).Cast <IConnectable <IEmulationElement> >()); }
// TODO: think about delayed resolution of message generator public static void DebugLog(this IEmulationElement e, Func <string> messageGenerator) { DebugLog(e, messageGenerator()); }
public Encoder(int width, IEmulationElement loggingParent = null) { this.loggingParent = loggingParent; buffer = new bool[width]; Reset(); }
public IEnumerable<IConnectable<IEmulationElement>> GetConnectionsFor(IEmulationElement obj) { return connections.GetAllForRight(obj).Cast<IConnectable<IEmulationElement>>(); }
public void Disconnect(IEmulationElement connectee, IConnectable connector) { Disconnect(connector, connectee); }