1 // 2 // Copyright (c) 2010-2024 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 8 using System.Linq; 9 using Antmicro.Renode.Core.Structure; 10 using Antmicro.Renode.Peripherals.Bus; 11 12 namespace Antmicro.Renode.Peripherals.CPU 13 { 14 public class TCMConfiguration 15 { TCMConfiguration(uint address, ulong size, uint regionIndex, uint interfaceIndex = 0)16 public TCMConfiguration(uint address, ulong size, uint regionIndex, uint interfaceIndex = 0) 17 { 18 Address = address; 19 Size = size; 20 InterfaceIndex = interfaceIndex; 21 RegionIndex = regionIndex; 22 } 23 TryFindRegistrationAddress(IBusController sysbus, ICPU cpu, IMemory memory, out ulong address)24 public static bool TryFindRegistrationAddress(IBusController sysbus, ICPU cpu, IMemory memory, out ulong address) 25 { 26 address = 0x0ul; 27 var busRegistration = ((SystemBus)sysbus).GetRegistrationPoints(memory, cpu) 28 .OfType<IBusRegistration>() 29 .Where(x => x.Initiator == cpu) 30 .SingleOrDefault(); 31 32 if(busRegistration == default(IBusRegistration)) 33 { 34 return false; 35 } 36 address = busRegistration.StartingPoint; 37 return true; 38 } 39 40 public uint Address { get; } 41 public ulong Size { get; } 42 public uint InterfaceIndex { get; } 43 public uint RegionIndex { get; } 44 } 45 } 46