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 "ak2ReadSdAsm.h"
#include "ak2SdReadSectorAsm.h"
#include "ak2WriteSdAsm.h"
#include "../acekard-common/IoRpgLoaderPlatform.h"
#include "Ak2ReadSdPatchCode.h"
#include "Ak2SdReadSectorPatchCode.h"
#include "Ak2WriteSdPatchCode.h"
/// @brief Implementation of LoaderPlatform for the Acekard 2 flashcard
class AK2LoaderPlatform : public IoRPGLoaderPlatform
class Ak2LoaderPlatform : public IoRpgLoaderPlatform
{
private:
enum
@@ -15,43 +14,43 @@ private:
};
public:
AK2LoaderPlatform() : IoRPGLoaderPlatform(IORPG_CMD_SDIO_BYTE) { }
Ak2LoaderPlatform() : 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 AK2ReadSdPatchCode(patchHeap,
return new Ak2ReadSdPatchCode(patchHeap,
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new ioRPGSendSDIOCommandPatchCode(patchHeap);
return new IoRpgSendSdioCommandPatchCode(patchHeap);
}),
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new AK2SDReadSectorPatchCode(patchHeap, waitForStatePatchCode);
return new Ak2SdReadSectorPatchCode(patchHeap, waitForStatePatchCode);
}),
waitForStatePatchCode);
});
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new AK2WriteSdPatchCode(patchHeap,
return new Ak2WriteSdPatchCode(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 "Ak2SdReadSectorPatchCode.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
#include "../acekard-common/IoRpgSendSdioCommandPatchCode.h"
#include "../acekard-common/IoRpgSdWaitForStatePatchCode.h"
DEFINE_SECTION_SYMBOLS(ak2_readsd);
extern "C" void ak2_readSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 ak2_readSd_sendSdioCommand_address;
extern u32 ak2_readSd_sdReadSector_address;
extern u32 ak2_readSd_sdWaitForState_address;
extern u16 ak2_readSd_sdsc_shift;
class Ak2ReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
Ak2ReadSdPatchCode(PatchHeap& patchHeap,
const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode,
const Ak2SdReadSectorPatchCode* ak2SdReadSectorPatchCode,
const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: PatchCode(SECTION_START(ak2_readsd), SECTION_SIZE(ak2_readsd), patchHeap)
{
ak2_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
ak2_readSd_sdReadSector_address = (u32)ak2SdReadSectorPatchCode->GetSDReadSectorFunction();
ak2_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const ReadSectorsFunc)GetAddressAtTarget((void*)ak2_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(ak2_sdreadsector);
@@ -9,11 +9,11 @@ extern "C" void ak2_sdReadSector(u32 srcSector, void* dst, u32 sectorCount);
extern u32 ak2_sdReadSector_sdWaitForState_address;
class AK2SDReadSectorPatchCode : public PatchCode
class Ak2SdReadSectorPatchCode : public PatchCode
{
public:
explicit AK2SDReadSectorPatchCode(PatchHeap& patchHeap,
const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
explicit Ak2SdReadSectorPatchCode(PatchHeap& patchHeap,
const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: PatchCode(SECTION_START(ak2_sdreadsector), SECTION_SIZE(ak2_sdreadsector), patchHeap)
{
ak2_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(ak2_writesd);
extern "C" void ak2_writeSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 ak2_writeSd_sendSdioCommand_address;
extern u32 ak2_writeSd_sdWaitForState_address;
extern u16 ak2_writeSd_sdsc_shift;
class Ak2WriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
Ak2WriteSdPatchCode(PatchHeap& patchHeap,
const IoRpgSendSdioCommandPatchCode* iorpgSendSdioCommandPatchCode,
const IoRpgSdWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: PatchCode(SECTION_START(ak2_writesd), SECTION_SIZE(ak2_writesd), patchHeap)
{
ak2_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
ak2_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const WriteSectorsFunc)GetAddressAtTarget((void*)ak2_writeSd);
}
};

View File

@@ -1,36 +0,0 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "ak2SdReadSectorAsm.h"
#include "../SdReadPatchCode.h"
#include "../acekard-common/iorpgSendSdioCommandAsm.h"
#include "../acekard-common/iorpgSdWaitForStateAsm.h"
DEFINE_SECTION_SYMBOLS(ak2_readsd);
extern "C" void ak2_readSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 ak2_readSd_sendSdioCommand_address;
extern u32 ak2_readSd_sdReadSector_address;
extern u32 ak2_readSd_sdWaitForState_address;
extern u16 ak2_readSd_sdsc_shift;
class AK2ReadSdPatchCode : public SdReadPatchCode
{
public:
explicit AK2ReadSdPatchCode(PatchHeap& patchHeap,
const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode,
const AK2SDReadSectorPatchCode* ak2SdReadSectorPatchCode,
const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: SdReadPatchCode(SECTION_START(ak2_readsd), SECTION_SIZE(ak2_readsd), patchHeap)
{
ak2_readSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
ak2_readSd_sdReadSector_address = (u32)ak2SdReadSectorPatchCode->GetSDReadSectorFunction();
ak2_readSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const SdReadFunc GetSdReadFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)ak2_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(ak2_writesd);
extern "C" void ak2_writeSd(u32 srcSector, void* dst, u32 sectorCount);
extern u32 ak2_writeSd_sendSdioCommand_address;
extern u32 ak2_writeSd_sdWaitForState_address;
extern u16 ak2_writeSd_sdsc_shift;
class AK2WriteSdPatchCode : public SdWritePatchCode
{
public:
explicit AK2WriteSdPatchCode(PatchHeap& patchHeap,
const ioRPGSendSDIOCommandPatchCode* iorpgSendSdioCommandPatchCode,
const ioRPGSDWaitForStatePatchCode* iorpgSdWaitForStatePatchCode)
: SdWritePatchCode(SECTION_START(ak2_writesd), SECTION_SIZE(ak2_writesd), patchHeap)
{
ak2_writeSd_sendSdioCommand_address = (u32)iorpgSendSdioCommandPatchCode->GetSendSdioCommandFunction();
ak2_writeSd_sdWaitForState_address = (u32)iorpgSdWaitForStatePatchCode->GetSDWaitForStateFunction();
}
const SdWriteFunc GetSdWriteFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)ak2_writeSd);
}
};