Refactored platform code to use interfaces for patch code with a special feature and improved patch code file names

This commit is contained in:
Gericom
2026-01-02 15:18:45 +01:00
parent d6080984d1
commit 231f14a783
180 changed files with 1073 additions and 1057 deletions

View File

@@ -1,12 +1,11 @@
#pragma once
#include "common.h"
#include "../acekard-common/IoRPGLoaderPlatform.h"
#include "akrpgReadSdAsm.h"
#include "akrpgSdReadSectorAsm.h"
#include "akrpgWriteSdAsm.h"
#include "AkRpgReadSdPatchCode.h"
#include "AkRpgSdReadSectorPatchCode.h"
#include "AkRpgWriteSdPatchCode.h"
/// @brief Implementation of LoaderPlatform for the Acekard RPG SD card.
class AKRPGLoaderPlatform : public IoRPGLoaderPlatform
class AkRpgLoaderPlatform : public IoRpgLoaderPlatform
{
private:
enum
@@ -15,43 +14,43 @@ private:
};
public:
AKRPGLoaderPlatform() : IoRPGLoaderPlatform(IORPG_CMD_SDIO_BYTE) { }
AkRpgLoaderPlatform() : IoRpgLoaderPlatform(IORPG_CMD_SDIO_BYTE) { }
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
auto* waitForStatePatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new ioRPGSDWaitForStatePatchCode(patchHeap);
return new IoRpgSdWaitForStatePatchCode(patchHeap);
});
return new AKRPGReadSdPatchCode(patchHeap,
return new AkRpgReadSdPatchCode(patchHeap,
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new ioRPGSendSDIOCommandPatchCode(patchHeap);
return new IoRpgSendSdioCommandPatchCode(patchHeap);
}),
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new AKRPGSDReadSectorPatchCode(patchHeap, waitForStatePatchCode);
return new AkRpgSdReadSectorPatchCode(patchHeap, waitForStatePatchCode);
}),
waitForStatePatchCode);
});
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new AKRPGWriteSdPatchCode(patchHeap,
return new AkRpgWriteSdPatchCode(patchHeap,
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new ioRPGSendSDIOCommandPatchCode(patchHeap);
return new IoRpgSendSdioCommandPatchCode(patchHeap);
}),
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new ioRPGSDWaitForStatePatchCode(patchHeap);
return new IoRpgSdWaitForStatePatchCode(patchHeap);
}));
});
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "AkRpgSdReadSectorPatchCode.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h"
#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h"
DEFINE_SECTION_SYMBOLS(akrpg_readsd);
extern "C" void akrpg_readSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 akrpg_readSd_sendSdioCommand_address;
extern u32 akrpg_readSd_sdReadSector_address;
extern u32 akrpg_readSd_sdWaitForState_address;
extern u16 akrpg_readSd_sdsc_shift;
class AkRpgReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
AkRpgReadSdPatchCode(PatchHeap& patchHeap,
const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode,
const AkRpgSdReadSectorPatchCode* akrpgSdReadSectorPatchCode,
const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: PatchCode(SECTION_START(akrpg_readsd), SECTION_SIZE(akrpg_readsd), patchHeap)
{
akrpg_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
akrpg_readSd_sdReadSector_address = (u32)akrpgSdReadSectorPatchCode->GetSDReadSectorFunction();
akrpg_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const ReadSectorsFunc)GetAddressAtTarget((void*)akrpg_readSd);
}
};

View File

@@ -1,7 +1,7 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "../acekard-common/iorpgSdWaitForStateAsm.h"
#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h"
DEFINE_SECTION_SYMBOLS(akrpg_sdreadsector);
@@ -9,11 +9,11 @@ extern "C" void akrpg_sdReadSector(u32 srcSector, void* dst, u32 sectorCount);
extern u32 akrpg_sdReadSector_sdWaitForState_address;
class AKRPGSDReadSectorPatchCode : public PatchCode
class AkRpgSdReadSectorPatchCode : public PatchCode
{
public:
explicit AKRPGSDReadSectorPatchCode(PatchHeap& patchHeap,
const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
explicit AkRpgSdReadSectorPatchCode(PatchHeap& patchHeap,
const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: PatchCode(SECTION_START(akrpg_sdreadsector), SECTION_SIZE(akrpg_sdreadsector), patchHeap)
{
akrpg_sdReadSector_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();

View File

@@ -0,0 +1,33 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "patches/PatchCode.h"
#include "../IWriteSectorsPatchCode.h"
#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h"
#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h"
DEFINE_SECTION_SYMBOLS(akrpg_writesd);
extern "C" void akrpg_writeSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 akrpg_writeSd_sendSdioCommand_address;
extern u32 akrpg_writeSd_sdWaitForState_address;
extern u16 akrpg_writeSd_sdsc_shift;
class AkRpgWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
AkRpgWriteSdPatchCode(PatchHeap& patchHeap,
const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode,
const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: PatchCode(SECTION_START(akrpg_writesd), SECTION_SIZE(akrpg_writesd), patchHeap)
{
akrpg_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
akrpg_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const WriteSectorsFunc)GetAddressAtTarget((void*)akrpg_writeSd);
}
};

View File

@@ -1,36 +0,0 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "akrpgSdReadSectorAsm.h"
#include "../SdReadPatchCode.h"
#include "../acekard-common/iorpgSendSdioCommandAsm.h"
#include "../acekard-common/iorpgSdWaitForStateAsm.h"
DEFINE_SECTION_SYMBOLS(akrpg_readsd);
extern "C" void akrpg_readSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 akrpg_readSd_sendSdioCommand_address;
extern u32 akrpg_readSd_sdReadSector_address;
extern u32 akrpg_readSd_sdWaitForState_address;
extern u16 akrpg_readSd_sdsc_shift;
class AKRPGReadSdPatchCode : public SdReadPatchCode
{
public:
explicit AKRPGReadSdPatchCode(PatchHeap& patchHeap,
const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode,
const AKRPGSDReadSectorPatchCode* akrpgSdReadSectorPatchCode,
const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: SdReadPatchCode(SECTION_START(akrpg_readsd), SECTION_SIZE(akrpg_readsd), patchHeap)
{
akrpg_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
akrpg_readSd_sdReadSector_address = (u32)akrpgSdReadSectorPatchCode->GetSDReadSectorFunction();
akrpg_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const SdReadFunc GetSdReadFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)akrpg_readSd);
}
};

View File

@@ -1,32 +0,0 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "../SdWritePatchCode.h"
#include "../acekard-common/iorpgSendSdioCommandAsm.h"
#include "../acekard-common/iorpgSdWaitForStateAsm.h"
DEFINE_SECTION_SYMBOLS(akrpg_writesd);
extern "C" void akrpg_writeSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 akrpg_writeSd_sendSdioCommand_address;
extern u32 akrpg_writeSd_sdWaitForState_address;
extern u16 akrpg_writeSd_sdsc_shift;
class AKRPGWriteSdPatchCode : public SdWritePatchCode
{
public:
explicit AKRPGWriteSdPatchCode(PatchHeap& patchHeap,
const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode,
const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: SdWritePatchCode(SECTION_START(akrpg_writesd), SECTION_SIZE(akrpg_writesd), patchHeap)
{
akrpg_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
akrpg_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const SdWriteFunc GetSdWriteFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)akrpg_writeSd);
}
};