2014-12-05 01:56:45 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Common
|
|
|
|
|
{
|
2016-12-14 15:11:07 +00:00
|
|
|
|
/// <summary>
|
2017-04-27 16:56:33 +00:00
|
|
|
|
/// This is a property of <seealso cref="IDebuggable"/>, and defines the means by which a client
|
2016-12-14 15:11:07 +00:00
|
|
|
|
/// gets and sets memory callbacks in the core. A memory callback should fire any time memory is
|
|
|
|
|
/// read/written/executed by the core, and depends on the type specified by the callback
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <seealso cref="IDebuggable"/>
|
2014-12-07 19:38:42 +00:00
|
|
|
|
public interface IMemoryCallbackSystem : IEnumerable<IMemoryCallback>
|
2014-12-05 01:56:45 +00:00
|
|
|
|
{
|
2014-12-17 01:20:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* DANGER:
|
|
|
|
|
* Many cores will blindly call CallReads(), CallWrites(), CallExecutes() on every rwx no matter what.
|
|
|
|
|
* These functions must return very quickly if the list is empty. Very very quickly.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-01-25 22:14:58 +00:00
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Gets a value indicating whether or not Execute callbacks are available for this this implementation
|
2015-01-25 22:14:58 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
bool ExecuteCallbacksAvailable { get; }
|
|
|
|
|
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Gets a value indicating whether or not there are currently any read hooks
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
bool HasReads { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Gets a value indicating whether or not there are currently any write hooks
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
bool HasWrites { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Gets a value indicating whether or not there are currently any execute hooks
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
bool HasExecutes { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2014-12-07 18:53:56 +00:00
|
|
|
|
/// Adds a callback for the given type to the given address
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// If no address is specified the callback will be hooked to all addresses
|
2014-12-07 18:53:56 +00:00
|
|
|
|
/// Note: an execute callback can not be added without an address, else an InvalidOperationException will occur
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
2014-12-07 19:09:36 +00:00
|
|
|
|
void Add(IMemoryCallback callback);
|
2014-12-05 01:56:45 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Executes all Read callbacks for the given address
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
2014-12-07 18:53:56 +00:00
|
|
|
|
void CallReads(uint addr);
|
2014-12-05 01:56:45 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Executes all Write callbacks for the given address
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
2014-12-07 18:53:56 +00:00
|
|
|
|
void CallWrites(uint addr);
|
2014-12-05 01:56:45 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-04-26 14:10:00 +00:00
|
|
|
|
/// Executes all Execute callbacks for the given address
|
2014-12-05 01:56:45 +00:00
|
|
|
|
/// </summary>
|
2014-12-07 18:53:56 +00:00
|
|
|
|
void CallExecutes(uint addr);
|
2014-12-05 01:56:45 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes the given callback from the list
|
|
|
|
|
/// </summary>
|
|
|
|
|
void Remove(Action action);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes the given callbacks from the list
|
|
|
|
|
/// </summary>
|
|
|
|
|
void RemoveAll(IEnumerable<Action> actions);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes all read,write, and execute callbacks
|
|
|
|
|
/// </summary>
|
|
|
|
|
void Clear();
|
|
|
|
|
}
|
2014-12-07 18:53:56 +00:00
|
|
|
|
|
2016-12-14 15:11:07 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// This service defines a memory callback used by an IMemoryCallbackSystem implementation
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <seealso cref="IMemoryCallbackSystem"/>
|
2014-12-07 19:09:36 +00:00
|
|
|
|
public interface IMemoryCallback
|
|
|
|
|
{
|
|
|
|
|
MemoryCallbackType Type { get; }
|
|
|
|
|
string Name { get; }
|
|
|
|
|
Action Callback { get; }
|
|
|
|
|
uint? Address { get; }
|
2016-08-08 11:37:39 +00:00
|
|
|
|
uint? AddressMask { get; }
|
2014-12-07 19:09:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 12:44:23 +00:00
|
|
|
|
public enum MemoryCallbackType
|
|
|
|
|
{
|
|
|
|
|
Read, Write, Execute
|
|
|
|
|
}
|
2014-12-05 01:56:45 +00:00
|
|
|
|
}
|