1 // 2 // Copyright (c) 2010-2025 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 9 using System; 10 using Antmicro.Renode.Core; 11 using Antmicro.Renode.Peripherals.Bus; 12 using Antmicro.Renode.Time; 13 using Antmicro.Renode.Utilities; 14 using System.Collections.Generic; 15 16 namespace Antmicro.Renode.Peripherals.CPU 17 { 18 public interface ICPU : IPeripheral, IHasOwnLife, IHaltable 19 { 20 string Architecture { get; } 21 uint MultiprocessingId { get; } 22 string Model { get; } 23 RegisterValue PC { get; set; } 24 // Extend `IsHalted` with a getter by using the `new` keyword 25 new bool IsHalted { get; set; } 26 IBusController Bus { get; } 27 /// <summary> 28 /// Returns true if the thread calling this property is possesed 29 /// by the object. 30 /// </summary> 31 bool OnPossessedThread { get; } 32 ulong ExecutedInstructions { get; } SyncTime()33 void SyncTime(); 34 event Action<HaltArguments> Halted; 35 TimeHandle TimeHandle { get; } 36 Step(int count = 1)37 ulong Step(int count = 1); 38 ExecutionMode ExecutionMode { get; set; } 39 40 ELFSharp.ELF.Endianess Endianness { get; } 41 42 EmulationCPUState EmulationState { get; } 43 event Action<ICPU, EmulationCPUState, EmulationCPUState> StateChanged; 44 } 45 46 public static class ICPUExtensions 47 { GetCPUThreadName(this ICPU cpu, IMachine machine)48 public static string GetCPUThreadName(this ICPU cpu, IMachine machine) 49 { 50 string machineName; 51 if(EmulationManager.Instance.CurrentEmulation.TryGetMachineName(machine, out machineName)) 52 { 53 machineName += "."; 54 } 55 return "{0}{1}[{2}]".FormatWith(machineName, machine.GetLocalName(cpu), machine.SystemBus.GetCPUSlot(cpu)); 56 } 57 } 58 } 59 60