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,33 +1,32 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "ezpReadSectorsAsm.h"
#include "ezpReadSdDataAsm.h"
#include "ezpWriteSectorsAsm.h"
#include "EzpReadSectorsPatchCode.h"
#include "EzpReadSdDataPatchCode.h"
#include "EzpWriteSectorsPatchCode.h"
/// @brief Implementation of LoaderPlatform for the EZ-Flash Parallel flashcard
class EZPLoaderPlatform : public LoaderPlatform
class EzpLoaderPlatform : public LoaderPlatform
{
public:
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new EZPReadSectorsPatchCode(patchHeap,
return new EzpReadSectorsPatchCode(patchHeap,
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new EZPReadSDDataPatchCode(patchHeap);
return new EzpReadSdDataPatchCode(patchHeap);
}));
});
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new EZPWriteSectorsPatchCode(patchHeap);
return new EzpWriteSectorsPatchCode(patchHeap);
});
}

View File

@@ -6,10 +6,10 @@ DEFINE_SECTION_SYMBOLS(ezp_readsddata);
extern "C" void ezp_readSdData(u32 srcSector, void* dst, u32 sectorCount, u32 sectorCountThisRead);
class EZPReadSDDataPatchCode : public PatchCode
class EzpReadSdDataPatchCode : public PatchCode
{
public:
explicit EZPReadSDDataPatchCode(PatchHeap& patchHeap)
explicit EzpReadSdDataPatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(ezp_readsddata), SECTION_SIZE(ezp_readsddata), patchHeap) { }
const void* GetReadSDDataFunction() const

View File

@@ -0,0 +1,27 @@
#pragma once
#include "sections.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
#include "EzpReadSdDataPatchCode.h"
DEFINE_SECTION_SYMBOLS(ezp_readsectors);
extern "C" void ezp_readSectors(u32 srcSector, void* dst, u32 sectorCount);
extern "C" u32 ezp_readSectors_readSdData_address;
class EzpReadSectorsPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
explicit EzpReadSectorsPatchCode(PatchHeap& patchHeap,
const EzpReadSdDataPatchCode* ezpReadSdDataPatchCode)
: PatchCode(SECTION_START(ezp_readsectors), SECTION_SIZE(ezp_readsectors), patchHeap)
{
ezp_readSectors_readSdData_address = (u32)ezpReadSdDataPatchCode->GetReadSDDataFunction();
}
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const ReadSectorsFunc)GetAddressAtTarget((void*)ezp_readSectors);
}
};

View File

@@ -0,0 +1,20 @@
#pragma once
#include "sections.h"
#include "patches/PatchCode.h"
#include "../IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(ezp_writesectors);
extern "C" void ezp_writeSectors(u32 dstSector, const void* src, u32 sectorCount);
class EzpWriteSectorsPatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
explicit EzpWriteSectorsPatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(ezp_writesectors), SECTION_SIZE(ezp_writesectors), patchHeap) { }
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const WriteSectorsFunc)GetAddressAtTarget((void*)ezp_writeSectors);
}
};

View File

@@ -1,26 +0,0 @@
#pragma once
#include "sections.h"
#include "../SdReadPatchCode.h"
#include "ezpReadSdDataAsm.h"
DEFINE_SECTION_SYMBOLS(ezp_readsectors);
extern "C" void ezp_readSectors(u32 srcSector, void* dst, u32 sectorCount);
extern "C" u32 ezp_readSectors_readSdData_address;
class EZPReadSectorsPatchCode : public SdReadPatchCode
{
public:
explicit EZPReadSectorsPatchCode(PatchHeap& patchHeap,
const EZPReadSDDataPatchCode* ezpReadSdDataPatchCode)
: SdReadPatchCode(SECTION_START(ezp_readsectors), SECTION_SIZE(ezp_readsectors), patchHeap)
{
ezp_readSectors_readSdData_address = (u32)ezpReadSdDataPatchCode->GetReadSDDataFunction();
}
const SdReadFunc GetSdReadFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)ezp_readSectors);
}
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "sections.h"
#include "../SdWritePatchCode.h"
DEFINE_SECTION_SYMBOLS(ezp_writesectors);
extern "C" void ezp_writeSectors(u32 dstSector, const void* src, u32 sectorCount);
class EZPWriteSectorsPatchCode : public SdWritePatchCode
{
public:
explicit EZPWriteSectorsPatchCode(PatchHeap& patchHeap)
: SdWritePatchCode(SECTION_START(ezp_writesectors), SECTION_SIZE(ezp_writesectors), patchHeap) { }
const SdWriteFunc GetSdWriteFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)ezp_writeSectors);
}
};