1 // 2 // Copyright (c) 2010-2025 Antmicro 3 // Copyright (c) 2023 Western Digital Corporation 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 System.Collections.Generic; 10 using Antmicro.Renode.Core.Structure; 11 using Antmicro.Renode.EventRecording; 12 using Antmicro.Renode.Logging.Profiling; 13 using Antmicro.Renode.Peripherals; 14 using Antmicro.Renode.Peripherals.Bus; 15 using Antmicro.Renode.Peripherals.CPU; 16 using Antmicro.Renode.Time; 17 using Antmicro.Renode.Utilities; 18 19 namespace Antmicro.Renode.Core 20 { 21 public interface IMachine: IEmulationElement 22 { AddUserStateHook(Func<string, bool> predicate, Action<string> hook)23 void AddUserStateHook(Func<string, bool> predicate, Action<string> hook); AppendDirtyAddresses(ICPU cpu, long[] addresses)24 void AppendDirtyAddresses(ICPU cpu, long[] addresses); AttachGPIO(IPeripheral source, int sourceNumber, IGPIOReceiver destination, int destinationNumber, int? localReceiverNumber = null)25 void AttachGPIO(IPeripheral source, int sourceNumber, IGPIOReceiver destination, int destinationNumber, int? localReceiverNumber = null); AttachGPIO(IPeripheral source, IGPIOReceiver destination, int destinationNumber, int? localReceiverNumber = null)26 void AttachGPIO(IPeripheral source, IGPIOReceiver destination, int destinationNumber, int? localReceiverNumber = null); AttachGPIO(IPeripheral source, string connectorName, IGPIOReceiver destination, int destinationNumber, int? localReceiverNumber = null)27 void AttachGPIO(IPeripheral source, string connectorName, IGPIOReceiver destination, int destinationNumber, int? localReceiverNumber = null); CheckRecorderPlayer()28 void CheckRecorderPlayer(); EnableGdbLogging(int port, bool enabled)29 void EnableGdbLogging(int port, bool enabled); EnableProfiler(string outputPath = null)30 void EnableProfiler(string outputPath = null); GetAllNames()31 IEnumerable<string> GetAllNames(); GetAnyNameOrTypeName(IPeripheral peripheral)32 string GetAnyNameOrTypeName(IPeripheral peripheral); GetChildrenPeripherals(IPeripheral peripheral)33 IEnumerable<IPeripheral> GetChildrenPeripherals(IPeripheral peripheral); GetClockSourceInfo()34 string[,] GetClockSourceInfo(); GetLocalName(IPeripheral peripheral)35 string GetLocalName(IPeripheral peripheral); GetNewDirtyAddressesForCore(ICPU cpu)36 long[] GetNewDirtyAddressesForCore(ICPU cpu); GetParentPeripherals(IPeripheral peripheral)37 IEnumerable<IPeripheral> GetParentPeripherals(IPeripheral peripheral); GetPeripheralRegistrationPoints(IPeripheral parentPeripheral, IPeripheral childPeripheral)38 IEnumerable<IRegistrationPoint> GetPeripheralRegistrationPoints(IPeripheral parentPeripheral, IPeripheral childPeripheral); GetPeripheralsOfType()39 IEnumerable<T> GetPeripheralsOfType<T>(); GetPeripheralsOfType(Type t)40 IEnumerable<IPeripheral> GetPeripheralsOfType(Type t); GetRegisteredPeripherals()41 IEnumerable<PeripheralTreeEntry> GetRegisteredPeripherals(); GetSystemBus(IBusPeripheral peripheral)42 IBusController GetSystemBus(IBusPeripheral peripheral); HandleTimeDomainEvent(Action<T> handler, T handlerArgument, TimeStamp eventTime, Action postAction = null)43 void HandleTimeDomainEvent<T>(Action<T> handler, T handlerArgument, TimeStamp eventTime, Action postAction = null); HandleTimeDomainEvent(Action<T1, T2> handler, T1 handlerArgument1, T2 handlerArgument2, TimeStamp eventTime, Action postAction = null)44 void HandleTimeDomainEvent<T1, T2>(Action<T1, T2> handler, T1 handlerArgument1, T2 handlerArgument2, TimeStamp eventTime, Action postAction = null); HandleTimeDomainEvent(Action<T> handler, T handlerArgument, bool timeDomainInternalEvent)45 void HandleTimeDomainEvent<T>(Action<T> handler, T handlerArgument, bool timeDomainInternalEvent); HandleTimeDomainEvent(Action<T1, T2> handler, T1 handlerArgument1, T2 handlerArgument2, bool timeDomainInternalEvent)46 void HandleTimeDomainEvent<T1, T2>(Action<T1, T2> handler, T1 handlerArgument1, T2 handlerArgument2, bool timeDomainInternalEvent); HandleTimeProgress(TimeInterval diff)47 void HandleTimeProgress(TimeInterval diff); InitAtomicMemoryState()48 void InitAtomicMemoryState(); IsRegistered(IPeripheral peripheral)49 bool IsRegistered(IPeripheral peripheral); ObtainManagedThread(Action action, uint frequency, string name = R, IEmulationElement owner = null, Func<bool> stopCondition = null)50 IManagedThread ObtainManagedThread(Action action, uint frequency, string name = "managed thread", IEmulationElement owner = null, Func<bool> stopCondition = null); ObtainManagedThread(Action action, TimeInterval period, string name = R, IEmulationElement owner = null, Func<bool> stopCondition = null)51 IManagedThread ObtainManagedThread(Action action, TimeInterval period, string name = "managed thread", IEmulationElement owner = null, Func<bool> stopCondition = null); ObtainPausedState(bool internalPause = false)52 IDisposable ObtainPausedState(bool internalPause = false); Pause()53 void Pause(); PauseAndRequestEmulationPause(bool precise = false)54 void PauseAndRequestEmulationPause(bool precise = false); PlayFrom(ReadFilePath fileName)55 void PlayFrom(ReadFilePath fileName); PostCreationActions()56 void PostCreationActions(); RecordTo(string fileName, RecordingBehaviour recordingBehaviour)57 void RecordTo(string fileName, RecordingBehaviour recordingBehaviour); RegisterAsAChildOf(IPeripheral peripheralParent, IPeripheral peripheralChild, IRegistrationPoint registrationPoint)58 void RegisterAsAChildOf(IPeripheral peripheralParent, IPeripheral peripheralChild, IRegistrationPoint registrationPoint); RegisterBusController(IBusPeripheral peripheral, IBusController controller)59 IBusController RegisterBusController(IBusPeripheral peripheral, IBusController controller); RequestReset()60 void RequestReset(); RequestResetInSafeState(Action postReset = null, ICollection<IPeripheral> unresetable = null)61 void RequestResetInSafeState(Action postReset = null, ICollection<IPeripheral> unresetable = null); Reset()62 void Reset(); ScheduleAction(TimeInterval delay, Action<TimeInterval> action, string name = null)63 void ScheduleAction(TimeInterval delay, Action<TimeInterval> action, string name = null); SetLocalName(IPeripheral peripheral, string name)64 void SetLocalName(IPeripheral peripheral, string name); Start()65 void Start(); StartGdbServer(int port, bool autostartEmulation = true, string cpuCluster = R)66 void StartGdbServer(int port, bool autostartEmulation = true, string cpuCluster = ""); StartGdbServer(int port, bool autostartEmulation, ICluster<ICpuSupportingGdb> cpu)67 void StartGdbServer(int port, bool autostartEmulation, ICluster<ICpuSupportingGdb> cpu); StopGdbServer(int? port = null)68 void StopGdbServer(int? port = null); AttachConnectionAcceptedListenerToGdbStub(int port, Action<System.IO.Stream> listener)69 bool AttachConnectionAcceptedListenerToGdbStub(int port, Action<System.IO.Stream> listener); DetachConnectionAcceptedListenerFromGdbStub(int port, Action<System.IO.Stream> listener)70 bool DetachConnectionAcceptedListenerFromGdbStub(int port, Action<System.IO.Stream> listener); IsGdbConnectedToServer(int port)71 bool IsGdbConnectedToServer(int port); ToString()72 string ToString(); TryGetAnyName(IPeripheral peripheral, out string name)73 bool TryGetAnyName(IPeripheral peripheral, out string name); TryGetBusController(IBusPeripheral peripheral, out IBusController controller)74 bool TryGetBusController(IBusPeripheral peripheral, out IBusController controller); 75 bool TryGetByName<T>(string name, out T peripheral, out string longestMatch) where T : class, IPeripheral; 76 bool TryGetByName<T>(string name, out T peripheral) where T : class, IPeripheral; TryGetLocalName(IPeripheral peripheral, out string name)77 bool TryGetLocalName(IPeripheral peripheral, out string name); TryRestartTranslationBlockOnCurrentCpu(bool quiet = false)78 bool TryRestartTranslationBlockOnCurrentCpu(bool quiet = false); UnregisterAsAChildOf(IPeripheral peripheralParent, IPeripheral peripheralChild)79 void UnregisterAsAChildOf(IPeripheral peripheralParent, IPeripheral peripheralChild); UnregisterAsAChildOf(IPeripheral peripheralParent, IRegistrationPoint registrationPoint)80 void UnregisterAsAChildOf(IPeripheral peripheralParent, IRegistrationPoint registrationPoint); UnregisterFromParent(IPeripheral peripheral)81 void UnregisterFromParent(IPeripheral peripheral); ExchangeRegistrationPointForPeripheral(IPeripheral parent, IPeripheral child, IRegistrationPoint oldPoint, IRegistrationPoint newPoint)82 void ExchangeRegistrationPointForPeripheral(IPeripheral parent, IPeripheral child, IRegistrationPoint oldPoint, IRegistrationPoint newPoint); 83 84 IPeripheral this[string name] { get; } 85 IntPtr AtomicMemoryStatePointer { get; } 86 IClockSource ClockSource { get; } 87 bool HasRecorder { get; } 88 bool HasPlayer { get; } 89 Profiler Profiler { get; } 90 string UserState { get; set; } 91 IBusController SystemBus { get; } 92 IPeripheralsGroupsManager PeripheralsGroups { get; } 93 Platform Platform { get; set; } 94 bool IsPaused { get; } 95 TimeStamp ElapsedVirtualTime { get; } 96 TimeSourceBase LocalTimeSource { get; set; } 97 DateTime RealTimeClockDateTime { get; } 98 RealTimeClockMode RealTimeClockMode { get; set; } 99 DateTime RealTimeClockStart { get; } 100 bool InternalPause { get; } 101 bool IgnorePeripheralRegistrationConditions { get; set; } 102 103 event Action<IMachine> MachineReset; 104 event Action<IMachine, PeripheralsChangedEventArgs> PeripheralsChanged; 105 event Action<IMachine> RealTimeClockModeChanged; 106 event Action<IMachine, MachineStateChangedEventArgs> StateChanged; 107 } 108 } 109 110