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,6 +1,6 @@
#include "common.h"
#include <libtwl/card/card.h>
#include "dsttDefinitions.h"
#include "DsttDefinitions.h"
#include "../SdioDefinitions.h"
#include "waitByLoop.h"
#include "DSTTLoaderPlatform.h"
@@ -92,7 +92,7 @@ static void sdHostSetRegister(u8 bits)
waitByLoop(0x600);
}
bool DSTTLoaderPlatform::InitializeSdCard(void)
bool DsttLoaderPlatform::InitializeSdCard(void)
{
bool isSdVersion2 = false;
bool isSdhc = false;

View File

@@ -1,35 +1,34 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "dsttReadSdAsm.h"
#include "dsttWriteSdAsm.h"
#include "DsttReadSdPatchCode.h"
#include "DsttWriteSdPatchCode.h"
/// @brief Implementation of LoaderPlatform for the DSTT flashcard
class DSTTLoaderPlatform : public LoaderPlatform
class DsttLoaderPlatform : public LoaderPlatform
{
public:
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new DSTTReadSdPatchCode(patchHeap,
return new DsttReadSdPatchCode(patchHeap,
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new DSTTReadSdStopTransmissionPatchCode(patchHeap);
return new DsttReadSdStopTransmissionPatchCode(patchHeap);
}));
});
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new DSTTWriteSdPatchCode(patchHeap,
return new DsttWriteSdPatchCode(patchHeap,
patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new DSTTWriteSdContinuePatchCode(patchHeap);
return new DsttWriteSdContinuePatchCode(patchHeap);
}));
});
}

View File

@@ -1,7 +1,8 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "../SdReadPatchCode.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(dstt_readsd);
DEFINE_SECTION_SYMBOLS(dstt_readsd_stopTransmission);
@@ -12,10 +13,10 @@ extern "C" void dstt_stopTransmission();
extern u32 dstt_stopTransmission_address;
extern u16 dstt_readSd_sdsc_shift;
class DSTTReadSdStopTransmissionPatchCode : public PatchCode
class DsttReadSdStopTransmissionPatchCode : public PatchCode
{
public:
explicit DSTTReadSdStopTransmissionPatchCode(PatchHeap& patchHeap)
explicit DsttReadSdStopTransmissionPatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(dstt_readsd_stopTransmission), SECTION_SIZE(dstt_readsd_stopTransmission), patchHeap) { }
const void* GetStopTransmissionFunction() const
@@ -24,18 +25,18 @@ public:
}
};
class DSTTReadSdPatchCode : public SdReadPatchCode
class DsttReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
explicit DSTTReadSdPatchCode(PatchHeap& patchHeap,
const DSTTReadSdStopTransmissionPatchCode* dsttReadSdStopTransmissionPatchCode)
: SdReadPatchCode(SECTION_START(dstt_readsd), SECTION_SIZE(dstt_readsd), patchHeap)
explicit DsttReadSdPatchCode(PatchHeap& patchHeap,
const DsttReadSdStopTransmissionPatchCode* dsttReadSdStopTransmissionPatchCode)
: PatchCode(SECTION_START(dstt_readsd), SECTION_SIZE(dstt_readsd), patchHeap)
{
dstt_stopTransmission_address = (u32)dsttReadSdStopTransmissionPatchCode->GetStopTransmissionFunction();
}
const SdReadFunc GetSdReadFunction() const override
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)dstt_readSd);
return (const ReadSectorsFunc)GetAddressAtTarget((void*)dstt_readSd);
}
};

View File

@@ -1,6 +1,7 @@
#pragma once
#include "sections.h"
#include "../SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "../IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(dstt_writesd);
DEFINE_SECTION_SYMBOLS(dstt_writesd_continue);
@@ -11,10 +12,10 @@ extern "C" void dstt_writeSdContinue();
extern u32 dstt_writeSdContinue_address;
extern u16 dstt_writeSd_sdsc_shift;
class DSTTWriteSdContinuePatchCode : public PatchCode
class DsttWriteSdContinuePatchCode : public PatchCode
{
public:
explicit DSTTWriteSdContinuePatchCode(PatchHeap& patchHeap)
explicit DsttWriteSdContinuePatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(dstt_writesd_continue), SECTION_SIZE(dstt_writesd_continue), patchHeap) { }
const void* GetWriteSdContinueFunction() const
@@ -23,18 +24,18 @@ public:
}
};
class DSTTWriteSdPatchCode : public SdWritePatchCode
class DsttWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
explicit DSTTWriteSdPatchCode(PatchHeap& patchHeap,
const DSTTWriteSdContinuePatchCode* dsttWriteSdContinuePatchCode)
: SdWritePatchCode(SECTION_START(dstt_writesd), SECTION_SIZE(dstt_writesd), patchHeap)
DsttWriteSdPatchCode(PatchHeap& patchHeap,
const DsttWriteSdContinuePatchCode* dsttWriteSdContinuePatchCode)
: PatchCode(SECTION_START(dstt_writesd), SECTION_SIZE(dstt_writesd), patchHeap)
{
dstt_writeSdContinue_address = (u32)dsttWriteSdContinuePatchCode->GetWriteSdContinueFunction();
}
const SdWriteFunc GetSdWriteFunction() const override
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)dstt_writeSd);
return (const WriteSectorsFunc)GetAddressAtTarget((void*)dstt_writeSd);
}
};