DSTT: Add DMA support and reduce code size (#162) Fixes #111

This commit is contained in:
lifehackerhansol
2026-05-10 00:37:38 -07:00
committed by GitHub
parent ae034ae1f6
commit e227cff9ee
12 changed files with 452 additions and 140 deletions

View File

@@ -0,0 +1,44 @@
#pragma once
#include "sections.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsDmaPatchCode.h"
#include "DsttSdStopTransmissionPatchCode.h"
#include "DsttReadSdHelperPatchCode.h"
DEFINE_SECTION_SYMBOLS(dstt_readsddma);
extern "C" void dstt_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
extern u32 dstt_readSdDma_applySectorCommand_address;
extern u32 dstt_readSdDma_waitDataReady_address;
extern u32 dstt_readSdDma_stopTransmission_address;
extern u32 dstt_readSdDma_miiCardDmaCopy32Ptr;
class DsttReadSdDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode
{
public:
DsttReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr,
const DsttSdStopTransmissionPatchCode* dsttSdStopTransmissionPatchCode,
const DsttReadSdHelperPatchCode* dsttReadSdHelperPatchCode)
: PatchCode(SECTION_START(dstt_readsddma), SECTION_SIZE(dstt_readsddma), patchHeap)
{
dstt_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr;
dstt_readSdDma_stopTransmission_address = (u32)dsttSdStopTransmissionPatchCode->GetStopTransmissionFunction();
dstt_readSdDma_applySectorCommand_address = (u32)dsttReadSdHelperPatchCode->GetApplySectorCommandFunction();
dstt_readSdDma_waitDataReady_address = (u32)dsttReadSdHelperPatchCode->GetWaitDataReadyFunction();
_sdReadDmaFinishFunc = (ReadSectorsDmaFinishFunc)dsttSdStopTransmissionPatchCode->GetStopTransmissionFunction();
}
const ReadSectorsDmaFunc GetReadSectorsDmaFunction() const override
{
return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)dstt_readSdDma);
}
const ReadSectorsDmaFinishFunc GetReadSectorsDmaFinishFunction() const override
{
return _sdReadDmaFinishFunc;
}
private:
ReadSectorsDmaFinishFunc _sdReadDmaFinishFunc = 0;
};