ICpuContext.cs
1 using System; 2 3 namespace Ryujinx.Cpu 4 { 5 /// <summary> 6 /// CPU context interface. 7 /// </summary> 8 public interface ICpuContext : IDisposable 9 { 10 /// <summary> 11 /// Creates a new execution context that will store thread CPU register state when executing guest code. 12 /// </summary> 13 /// <param name="exceptionCallbacks">Optional functions to be called when the CPU receives an interrupt</param> 14 /// <returns>Execution context</returns> 15 IExecutionContext CreateExecutionContext(ExceptionCallbacks exceptionCallbacks); 16 17 /// <summary> 18 /// Starts executing code at a specified entry point address. 19 /// </summary> 20 /// <remarks> 21 /// This function only returns when the execution is stopped, by calling <see cref="IExecutionContext.StopRunning"/>. 22 /// </remarks> 23 /// <param name="context">Execution context to be used for this run</param> 24 /// <param name="address">Entry point address</param> 25 void Execute(IExecutionContext context, ulong address); 26 27 /// <summary> 28 /// Invalidates the instruction cache for a given memory region. 29 /// </summary> 30 /// <remarks> 31 /// This should be called if code is modified to make the CPU emulator aware of the modifications, 32 /// otherwise it might run stale code which will lead to errors and crashes. 33 /// Calling this function is not necessary if the code memory was modified by guest code, 34 /// as the expectation is that it will do it on its own using the appropriate cache invalidation instructions, 35 /// except on Arm32 where those instructions can't be used in unprivileged mode. 36 /// </remarks> 37 /// <param name="address">Address of the region to be invalidated</param> 38 /// <param name="size">Size of the region to be invalidated</param> 39 void InvalidateCacheRegion(ulong address, ulong size); 40 41 /// <summary> 42 /// Loads cached code from disk for a given application. 43 /// </summary> 44 /// <remarks> 45 /// If the execution engine is recompiling guest code, this can be used to load cached code from disk. 46 /// </remarks> 47 /// <param name="titleIdText">Title ID of the application in padded hex form</param> 48 /// <param name="displayVersion">Version of the application</param> 49 /// <param name="enabled">True if the cache should be loaded from disk if it exists, false otherwise</param> 50 /// <returns>Disk cache load progress reporter and manager</returns> 51 IDiskCacheLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled); 52 53 /// <summary> 54 /// Indicates that code has been loaded into guest memory, and that it might be executed in the future. 55 /// </summary> 56 /// <remarks> 57 /// Some execution engines might use this information to cache recompiled code on disk or to ensure it can be executed. 58 /// </remarks> 59 /// <param name="address">CPU virtual address where the code starts</param> 60 /// <param name="size">Size of the code range in bytes</param> 61 void PrepareCodeRange(ulong address, ulong size); 62 } 63 }