Play-/Source/iop/Iop_SifMan.h
Jean-Philip Desjardins 33f1b7ea01
Some checks are pending
Build Android / build_android (apk) (push) Waiting to run
Build Android / build_android (libretro) (push) Waiting to run
Build iOS / build_ios (push) Waiting to run
Build JavaScript / build_js (push) Waiting to run
Build Linux / build_linux (push) Waiting to run
Build Linux ARM32 / build_linux_arm32 (push) Waiting to run
Build Linux ARM64 / build_linux_arm64 (push) Waiting to run
Build macOS / build_macos (push) Waiting to run
Build Windows / build_windows (x86_32, Visual Studio 16 2019, installer32.nsi, win32_msvc2019, Win32) (push) Waiting to run
Build Windows / build_windows (x86_64, Visual Studio 16 2019, installer64.nsi, win64_msvc2019_64, x64) (push) Waiting to run
Build Windows Psf / build_windows_psf (off, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Waiting to run
Build Windows Psf / build_windows_psf (on, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Waiting to run
Check Format / run_clangformat (push) Waiting to run
Revisit SIF DMA delay mechanism.
Fixes Call of Cthulhu.
2025-01-03 18:03:23 -05:00

66 lines
1.9 KiB
C++

#pragma once
#include "../SifModule.h"
#include "../SifDefs.h"
#include "Iop_Module.h"
namespace Iop
{
class CSysmem;
class CSifMan : public CModule
{
public:
static constexpr uint32 SIFDMA_XFER_ID = 0x2222;
typedef std::function<void(const std::string&)> ModuleResetHandler;
typedef std::function<void(uint32)> CustomCommandHandler;
CSifMan() = default;
virtual ~CSifMan() = default;
void PrepareModuleData(uint8*, CSysmem&);
void CountTicks(int32);
std::string GetId() const override;
std::string GetFunctionName(unsigned int) const override;
void Invoke(CMIPS&, unsigned int) override;
virtual void RegisterModule(uint32, CSifModule*) = 0;
virtual bool IsModuleRegistered(uint32) = 0;
virtual void UnregisterModule(uint32) = 0;
virtual void SendPacket(const void*, uint32) = 0;
virtual void SetDmaBuffer(uint32, uint32) = 0;
virtual void SetCmdBuffer(uint32, uint32) = 0;
virtual void SendCallReply(uint32, const void*) = 0;
virtual void GetOtherData(uint32, uint32, uint32) = 0;
virtual void SetModuleResetHandler(const ModuleResetHandler&) = 0;
virtual void SetCustomCommandHandler(const CustomCommandHandler&) = 0;
virtual void ExecuteSifDma(uint32, uint32) = 0;
private:
uint32 SifSetDma(uint32, uint32);
uint32 SifDmaStat(uint32);
uint32 SifCheckInit();
uint32 SifSetDmaCallback(CMIPS&, uint32, uint32, uint32, uint32);
enum
{
SIFSETDMACALLBACK_HANDLER_SIZE = 0x28,
DMA_TRANSFER_TIMES_SIZE = 5,
};
struct MODULEDATA
{
uint8 sifSetDmaCallbackHandler[SIFSETDMACALLBACK_HANDLER_SIZE];
int32 dmaTransferTimes[DMA_TRANSFER_TIMES_SIZE];
int32 nextDmaTransferIdx;
};
static_assert(sizeof(MODULEDATA) == 0x40);
MODULEDATA* m_moduleData = nullptr;
uint32 m_sifSetDmaCallbackHandlerAddr = 0;
};
typedef std::shared_ptr<CSifMan> SifManPtr;
}