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,7 +1,6 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "../SdReadPatchCode.h"
DEFINE_SECTION_SYMBOLS(scsd_change_mode);
DEFINE_SECTION_SYMBOLS(scsd_common);

View File

@@ -4,7 +4,7 @@
#include "thumbInstructions.h"
#include "SuperCardDefinitions.h"
#include "SuperCardLoaderPlatform.h"
#include "SuperCardSDCommands.h"
#include "SuperCardSdCommands.h"
enum SupercardType
{

View File

@@ -1,5 +1,4 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "SuperCardCommon.h"
#include "sclite/SuperCardLiteImpl.h"
@@ -9,17 +8,17 @@
class SuperCardLoaderPlatform : public LoaderPlatform
{
public:
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
auto common = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardCommonPatchCode(patchHeap);
});
auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardChangeModePatchCode(patchHeap);
});
auto common = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardCommonPatchCode(patchHeap);
});
auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardChangeModePatchCode(patchHeap);
});
if (isScLite)
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
@@ -54,17 +53,17 @@ public:
}
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
auto common = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardCommonPatchCode(patchHeap);
});
auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardChangeModePatchCode(patchHeap);
});
auto common = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardCommonPatchCode(patchHeap);
});
auto changeMode = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new SuperCardChangeModePatchCode(patchHeap);
});
if (isScLite)
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]

View File

@@ -1,6 +1,6 @@
#include "common.h"
#include "../SdioDefinitions.h"
#include "SuperCardSDCommands.h"
#include "SuperCardSdCommands.h"
#include "SuperCardDefinitions.h"
#define BUSY_WAIT_TIMEOUT 500000

View File

@@ -1,8 +1,9 @@
#pragma once
#include "sections.h"
#include "../SuperCardCommon.h"
#include "../../SdReadPatchCode.h"
#include "../../SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "../../IReadSectorsPatchCode.h"
#include "../../IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(sclite_sd_command_drop);
DEFINE_SECTION_SYMBOLS(sclite_write_sector);
@@ -68,7 +69,7 @@ public:
}
};
class SuperCardReadSectorLitePatchCode : public SdReadPatchCode
class SuperCardReadSectorLitePatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
SuperCardReadSectorLitePatchCode(PatchHeap& patchHeap,
@@ -76,7 +77,7 @@ public:
const SuperCardChangeModePatchCode* superCardChangeModePatchCode,
const SuperCardSDCommandAndDropLitePatchCode* superCardSdCommandAndDropLitePatchCode,
const SuperCardReadDataLitePatchCode* superCardReadDataLitePatchCode)
: SdReadPatchCode(SECTION_START(sclite_read_sector), SECTION_SIZE(sclite_read_sector), patchHeap)
: PatchCode(SECTION_START(sclite_read_sector), SECTION_SIZE(sclite_read_sector), patchHeap)
{
INTERWORK_LABEL(sccmn_changeMode, readInterwork) = (u32)superCardChangeModePatchCode->GetScChangeModeFunction();
INTERWORK_LABEL(sclite_sdCommandAndDropResponse6, readInterwork)
@@ -85,13 +86,13 @@ public:
INTERWORK_LABEL(sccmn_sdSendClock10, readInterwork) = (u32)superCardCommonPatchCode->GetSdSendClock10Function();
}
const SdReadFunc GetSdReadFunction() const override
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)sclite_readSector);
return (const ReadSectorsFunc)GetAddressAtTarget((void*)sclite_readSector);
}
};
class SuperCardWriteSectorLitePatchCode : public SdWritePatchCode
class SuperCardWriteSectorLitePatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
SuperCardWriteSectorLitePatchCode(PatchHeap& patchHeap,
@@ -99,7 +100,7 @@ public:
const SuperCardChangeModePatchCode* superCardChangeModePatchCode,
const SuperCardSDCommandAndDropLitePatchCode* superCardSdCommandAndDropLitePatchCode,
const SuperCardWriteDataLitePatchCode* superCardWriteDataLitePatchCode)
: SdWritePatchCode(SECTION_START(sclite_write_sector), SECTION_SIZE(sclite_write_sector), patchHeap)
: PatchCode(SECTION_START(sclite_write_sector), SECTION_SIZE(sclite_write_sector), patchHeap)
{
INTERWORK_LABEL(sclite_writeData, writeInterwork) = (u32)superCardWriteDataLitePatchCode->GetWriteDataLiteFunction();
INTERWORK_LABEL(sccmn_sdio4BitCrc16, writeInterwork) = (u32)superCardCommonPatchCode->GetCrc16ChecksumFunction();
@@ -109,9 +110,9 @@ public:
= (u32)superCardSdCommandAndDropLitePatchCode->GetSdCommandAndDropResponse6Function();
}
const SdWriteFunc GetSdWriteFunction() const override
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)sclite_writeSector);
return (const WriteSectorsFunc)GetAddressAtTarget((void*)sclite_writeSector);
}
};

View File

@@ -1,8 +1,9 @@
#pragma once
#include "sections.h"
#include "../SuperCardCommon.h"
#include "../../SdReadPatchCode.h"
#include "../../SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "../../IReadSectorsPatchCode.h"
#include "../../IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(scsd_sd_command_drop);
DEFINE_SECTION_SYMBOLS(scsd_write_sector);
@@ -68,7 +69,7 @@ public:
}
};
class SuperCardWriteSectorPatchCode : public SdWritePatchCode
class SuperCardWriteSectorPatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
SuperCardWriteSectorPatchCode(PatchHeap& patchHeap,
@@ -76,7 +77,7 @@ public:
const SuperCardChangeModePatchCode* superCardChangeModePatchCode,
const SuperCardSdCommandAndDropPatchCode* superCardSdCommandAndDropPatchCode,
const SuperCardWriteDataPatchCode* superCardWriteDataPatchCode)
: SdWritePatchCode(SECTION_START(scsd_write_sector), SECTION_SIZE(scsd_write_sector), patchHeap)
: PatchCode(SECTION_START(scsd_write_sector), SECTION_SIZE(scsd_write_sector), patchHeap)
{
INTERWORK_LABEL(scsd_writeData, writeInterwork) = (u32)superCardWriteDataPatchCode->GetWriteDataFunction();
INTERWORK_LABEL(sccmn_sdio4BitCrc16, writeInterwork) = (u32)superCardCommonPatchCode->GetCrc16ChecksumFunction();
@@ -86,13 +87,13 @@ public:
= (u32)superCardSdCommandAndDropPatchCode->GetSdCommandAndDropResponse6Function();
}
const SdWriteFunc GetSdWriteFunction() const override
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)scsd_writeSector);
return (const WriteSectorsFunc)GetAddressAtTarget((void*)scsd_writeSector);
}
};
class SuperCardReadSectorPatchCode : public SdReadPatchCode
class SuperCardReadSectorPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
SuperCardReadSectorPatchCode(PatchHeap& patchHeap,
@@ -100,7 +101,7 @@ public:
const SuperCardChangeModePatchCode* superCardChangeModePatchCode,
const SuperCardSdCommandAndDropPatchCode* superCardSdCommandAndDropPatchCode,
const SuperCardReadDataPatchCode* superCardReadDataPatchCode)
: SdReadPatchCode(SECTION_START(scsd_read_sector), SECTION_SIZE(scsd_read_sector), patchHeap)
: PatchCode(SECTION_START(scsd_read_sector), SECTION_SIZE(scsd_read_sector), patchHeap)
{
INTERWORK_LABEL(sccmn_changeMode, readInterwork) = (u32)superCardChangeModePatchCode->GetScChangeModeFunction();
INTERWORK_LABEL(scsd_sdCommandAndDropResponse6, readInterwork)
@@ -109,9 +110,9 @@ public:
INTERWORK_LABEL(sccmn_sdSendClock10, readInterwork) = (u32)superCardCommonPatchCode->GetSdSendClock10Function();
}
const SdReadFunc GetSdReadFunction() const override
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)scsd_readSector);
return (const ReadSectorsFunc)GetAddressAtTarget((void*)scsd_readSector);
}
};