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

@@ -192,8 +192,8 @@ static void handleGetSdFunctionsCommand()
{
auto sdReadPatchCode = sLoaderPlatform->CreateSdReadPatchCode(patchCodeCollection, patchHeap);
auto sdWritePatchCode = sLoaderPlatform->CreateSdWritePatchCode(patchCodeCollection, patchHeap);
*(vu32*)0x037F8000 = (u32)sdReadPatchCode->GetSdReadFunction();
*(vu32*)0x037F8004 = (u32)sdWritePatchCode->GetSdWriteFunction();
*(vu32*)0x037F8000 = (u32)sdReadPatchCode->GetReadSectorsFunction();
*(vu32*)0x037F8004 = (u32)sdWritePatchCode->GetWriteSectorFunction();
patchCodeCollection.CopyAllToTarget();
}
dc_flushAll();

View File

@@ -0,0 +1,10 @@
#pragma once
class ISectorRemapPatchCode
{
protected:
ISectorRemapPatchCode() { }
public:
virtual const void* GetRemapFunction() const = 0;
};

View File

@@ -1,17 +1,17 @@
#pragma once
#include "sections.h"
#include "SectorRemapPatchCode.h"
#include "PatchCode.h"
#include "ISectorRemapPatchCode.h"
DEFINE_SECTION_SYMBOLS(offsettosectorremap);
extern "C" u32 offset_to_sector_remap(u32 romOffset);
class OffsetToSectorRemapPatchCode : public SectorRemapPatchCode
class OffsetToSectorRemapPatchCode : public PatchCode, public ISectorRemapPatchCode
{
public:
explicit OffsetToSectorRemapPatchCode(PatchHeap& patchHeap)
: SectorRemapPatchCode(SECTION_START(offsettosectorremap), SECTION_SIZE(offsettosectorremap), patchHeap)
{ }
: PatchCode(SECTION_START(offsettosectorremap), SECTION_SIZE(offsettosectorremap), patchHeap) { }
const void* GetRemapFunction() const override
{

View File

@@ -1,6 +1,7 @@
#pragma once
#include "sections.h"
#include "SectorRemapPatchCode.h"
#include "PatchCode.h"
#include "ISectorRemapPatchCode.h"
#include "fileInfo.h"
DEFINE_SECTION_SYMBOLS(saveoffsettosdsector);
@@ -9,11 +10,11 @@ extern "C" u32 save_offset_to_sd_sector_asm(u32 saveOffset);
extern u32 saveoffsettosdsector_fatDataPtr;
class SaveOffsetToSdSectorPatchCode : public SectorRemapPatchCode
class SaveOffsetToSdSectorPatchCode : public PatchCode, public ISectorRemapPatchCode
{
public:
SaveOffsetToSdSectorPatchCode(PatchHeap& patchHeap, const save_file_info_t* fatDataPtr)
: SectorRemapPatchCode(SECTION_START(saveoffsettosdsector), SECTION_SIZE(saveoffsettosdsector), patchHeap)
: PatchCode(SECTION_START(saveoffsettosdsector), SECTION_SIZE(saveoffsettosdsector), patchHeap)
{
saveoffsettosdsector_fatDataPtr = (u32)fatDataPtr;
}

View File

@@ -1,11 +0,0 @@
#pragma once
#include "PatchCode.h"
class SectorRemapPatchCode : public PatchCode
{
public:
SectorRemapPatchCode(const void* code, u32 size, PatchHeap& patchHeap)
: PatchCode(code, size, patchHeap) { }
virtual const void* GetRemapFunction() const = 0;
};

View File

@@ -1,8 +1,8 @@
#pragma once
#include "sections.h"
#include "../PatchCode.h"
#include "../SectorRemapPatchCode.h"
#include "../platform/SdReadPatchCode.h"
#include "patches/PatchCode.h"
#include "patches/ISectorRemapPatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(readsave);
@@ -15,12 +15,12 @@ extern u32 readsave_sdread_asm_address;
class ReadSavePatchCode : public PatchCode
{
public:
ReadSavePatchCode(PatchHeap& patchHeap, const SectorRemapPatchCode* sectorRemapPatchCode,
const SdReadPatchCode* sdReadPatchCode, void* tmpBuffer)
ReadSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode,
const IReadSectorsPatchCode* readSectorsPatchCode, void* tmpBuffer)
: PatchCode(SECTION_START(readsave), SECTION_SIZE(readsave), patchHeap)
{
readsave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction();
readsave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
readsave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction();
readsave_tmpBufferPtr = (u32)tmpBuffer;
}

View File

@@ -1,8 +1,8 @@
#pragma once
#include "sections.h"
#include "../PatchCode.h"
#include "../SectorRemapPatchCode.h"
#include "../platform/SdReadPatchCode.h"
#include "patches/PatchCode.h"
#include "patches/ISectorRemapPatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(verifysave);
@@ -15,12 +15,12 @@ extern u32 verifysave_sdread_asm_address;
class VerifySavePatchCode : public PatchCode
{
public:
VerifySavePatchCode(PatchHeap& patchHeap, const SectorRemapPatchCode* sectorRemapPatchCode,
const SdReadPatchCode* sdReadPatchCode, void* tmpBuffer)
VerifySavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode,
const IReadSectorsPatchCode* readSectorsPatchCode, void* tmpBuffer)
: PatchCode(SECTION_START(verifysave), SECTION_SIZE(verifysave), patchHeap)
{
verifysave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction();
verifysave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
verifysave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction();
verifysave_tmpBufferPtr = (u32)tmpBuffer;
}

View File

@@ -1,9 +1,9 @@
#pragma once
#include "sections.h"
#include "../PatchCode.h"
#include "../SectorRemapPatchCode.h"
#include "../platform/SdReadPatchCode.h"
#include "../platform/SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "patches/ISectorRemapPatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
#include "patches/platform/IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(writesave);
@@ -17,13 +17,13 @@ extern u32 writesave_sdwrite_asm_address;
class WriteSavePatchCode : public PatchCode
{
public:
WriteSavePatchCode(PatchHeap& patchHeap, const SectorRemapPatchCode* sectorRemapPatchCode,
const SdReadPatchCode* sdReadPatchCode, const SdWritePatchCode* sdWritePatchCode, void* tmpBuffer)
WriteSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode,
const IReadSectorsPatchCode* readSectorsPatchCode, const IWriteSectorsPatchCode* writeSectorsPatchCode, void* tmpBuffer)
: PatchCode(SECTION_START(writesave), SECTION_SIZE(writesave), patchHeap)
{
writesave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction();
writesave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
writesave_sdwrite_asm_address = (u32)sdWritePatchCode->GetSdWriteFunction();
writesave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction();
writesave_sdwrite_asm_address = (u32)writeSectorsPatchCode->GetWriteSectorFunction();
writesave_tmpBufferPtr = (u32)tmpBuffer;
}

View File

@@ -3,12 +3,12 @@
#include <array>
#include "fileInfo.h"
#include "patches/PatchContext.h"
#include "patches/arm7/ReadSaveAsm.h"
#include "patches/arm7/WriteSaveAsm.h"
#include "patches/arm7/VerifySaveAsm.h"
#include "patches/arm7/ReadSavePatchCode.h"
#include "patches/arm7/WriteSavePatchCode.h"
#include "patches/arm7/VerifySavePatchCode.h"
#include "patches/FunctionSignature.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "patches/SaveOffsetToSdSectorPatchCode.h"
#include "patches/arm7/CardiTaskThreadPatchAsm.h"
#include "thumbInstructions.h"
#include "CardiTaskThreadPatch.h"

View File

@@ -2,10 +2,10 @@
#include "patches/PatchContext.h"
#include "thumbInstructions.h"
#include "fileInfo.h"
#include "patches/arm7/ReadSaveAsm.h"
#include "patches/arm7/WriteSaveAsm.h"
#include "patches/arm7/VerifySaveAsm.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "patches/arm7/ReadSavePatchCode.h"
#include "patches/arm7/WriteSavePatchCode.h"
#include "patches/arm7/VerifySavePatchCode.h"
#include "patches/SaveOffsetToSdSectorPatchCode.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/arm7/CardiTaskThreadPatchAsm.h"
#include "CardiDoTaskFromArm9Patch.h"

View File

@@ -1,8 +1,8 @@
#pragma once
#include "patches/PatchCode.h"
#include "sections.h"
#include "patches/platform/SdReadPatchCode.h"
#include "patches/platform/SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
#include "patches/platform/IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(patch_dsisdredirect);
@@ -16,12 +16,12 @@ extern u32 __patch_dsisdredirect_control_get_drive_struct_address;
class Sdk5DsiSdCardRedirectPatchCode : public PatchCode
{
public:
Sdk5DsiSdCardRedirectPatchCode(PatchHeap& patchHeap, const SdReadPatchCode* sdReadPatchCode,
const SdWritePatchCode* sdWritePatchCode, u32 getDriveStructAddress)
Sdk5DsiSdCardRedirectPatchCode(PatchHeap& patchHeap, const IReadSectorsPatchCode* readSectorsPatchCode,
const IWriteSectorsPatchCode* writeSectorsPatchCode, u32 getDriveStructAddress)
: PatchCode(SECTION_START(patch_dsisdredirect), SECTION_SIZE(patch_dsisdredirect), patchHeap)
{
__patch_dsisdredirect_io_readsd_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
__patch_dsisdredirect_io_writesd_asm_address = (u32)sdWritePatchCode->GetSdWriteFunction();
__patch_dsisdredirect_io_readsd_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction();
__patch_dsisdredirect_io_writesd_asm_address = (u32)writeSectorsPatchCode->GetWriteSectorFunction();
__patch_dsisdredirect_control_get_drive_struct_address = getDriveStructAddress;
}

View File

@@ -2,7 +2,7 @@
#include "thumbInstructions.h"
#include "../PatchContext.h"
#include "../FunctionSignature.h"
#include "CardiReadRomIdCorePatchAsm.h"
#include "CardiReadRomIdCorePatchCode.h"
#include "CardiReadRomIdCorePatch.h"
static constexpr auto sSignaturesArm = std::to_array<const FunctionSignature>

View File

@@ -1,9 +1,9 @@
#include "common.h"
#include "gameCode.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "ReadNandSaveAsm.h"
#include "WriteNandSaveAsm.h"
#include "patches/SaveOffsetToSdSectorPatchCode.h"
#include "ReadNandSavePatchCode.h"
#include "WriteNandSavePatchCode.h"
#include "FaceTrainingNandSavePatch.h"
// This code was based on nds-bootstrap:

View File

@@ -1,9 +1,9 @@
#include "common.h"
#include "gameCode.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "ReadNandSaveAsm.h"
#include "WriteNandSaveAsm.h"
#include "patches/SaveOffsetToSdSectorPatchCode.h"
#include "ReadNandSavePatchCode.h"
#include "WriteNandSavePatchCode.h"
#include "JamWithTheBandNandSavePatch.h"
// This code was based on nds-bootstrap:

View File

@@ -1,9 +1,9 @@
#include "common.h"
#include "gameCode.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "ReadNandSaveAsm.h"
#include "WriteNandSaveAsm.h"
#include "patches/SaveOffsetToSdSectorPatchCode.h"
#include "ReadNandSavePatchCode.h"
#include "WriteNandSavePatchCode.h"
#include "NintendoDSGuideNandSavePatch.h"
// This code was based on nds-bootstrap:

View File

@@ -1,8 +1,8 @@
#pragma once
#include "patches/PatchCode.h"
#include "sections.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "patches/platform/SdReadPatchCode.h"
#include "patches/PatchCode.h"
#include "patches/ISectorRemapPatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(patch_readnandsave);
@@ -14,12 +14,12 @@ extern u32 patch_readNandSave_sdread_asm_address;
class ReadNandSavePatchCode : public PatchCode
{
public:
ReadNandSavePatchCode(PatchHeap& patchHeap, const SaveOffsetToSdSectorPatchCode* saveOffsetToSdSectorPatchCode,
const SdReadPatchCode* sdReadPatchCode)
ReadNandSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode,
const IReadSectorsPatchCode* readSectorsPatchCode)
: PatchCode(SECTION_START(patch_readnandsave), SECTION_SIZE(patch_readnandsave), patchHeap)
{
patch_readNandSave_save_offset_to_sd_sector_asm_address = (u32)saveOffsetToSdSectorPatchCode->GetRemapFunction();
patch_readNandSave_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
patch_readNandSave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction();
patch_readNandSave_sdread_asm_address = (u32)readSectorsPatchCode->GetReadSectorsFunction();
}
const void* GetReadNandSaveFunction() const

View File

@@ -1,9 +1,9 @@
#include "common.h"
#include "gameCode.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "ReadNandSaveAsm.h"
#include "WriteNandSaveAsm.h"
#include "patches/SaveOffsetToSdSectorPatchCode.h"
#include "ReadNandSavePatchCode.h"
#include "WriteNandSavePatchCode.h"
#include "WarioWareDiyNandSavePatch.h"
// This code was based on nds-bootstrap:

View File

@@ -1,8 +1,8 @@
#pragma once
#include "patches/PatchCode.h"
#include "sections.h"
#include "patches/SaveOffsetToSdSectorAsm.h"
#include "patches/platform/SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "patches/ISectorRemapPatchCode.h"
#include "patches/platform/IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(patch_writenandsave);
@@ -14,12 +14,12 @@ extern u32 patch_writeNandSave_sdwrite_asm_address;
class WriteNandSavePatchCode : public PatchCode
{
public:
WriteNandSavePatchCode(PatchHeap& patchHeap, const SaveOffsetToSdSectorPatchCode* saveOffsetToSdSectorPatchCode,
const SdWritePatchCode* sdWritePatchCode)
WriteNandSavePatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode,
const IWriteSectorsPatchCode* writeSectorsPatchCode)
: PatchCode(SECTION_START(patch_writenandsave), SECTION_SIZE(patch_writenandsave), patchHeap)
{
patch_writeNandSave_save_offset_to_sd_sector_asm_address = (u32)saveOffsetToSdSectorPatchCode->GetRemapFunction();
patch_writeNandSave_sdwrite_asm_address = (u32)sdWritePatchCode->GetSdWriteFunction();
patch_writeNandSave_save_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction();
patch_writeNandSave_sdwrite_asm_address = (u32)writeSectorsPatchCode->GetWriteSectorFunction();
}
const void* GetWriteNandSaveFunction() const

View File

@@ -1,8 +1,8 @@
#include "common.h"
#include "../PatchContext.h"
#include "patches/PatchContext.h"
#include "thumbInstructions.h"
#include "../platform/LoaderPlatform.h"
#include "OSResetSystemPatchAsm.h"
#include "patches/platform/LoaderPlatform.h"
#include "OSResetSystemPatchCode.h"
#include "OSResetSystemPatch.h"
static const u32 sOSResetSystemPatternSdk2Old[] = { 0xE59F101Cu, 0xE3A00010u, 0xE5815000u, 0xEB000005u };

View File

@@ -2,7 +2,7 @@
#include "../PatchCode.h"
#include "sections.h"
#include "LoaderInfo.h"
#include "../platform/SdReadPatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(patch_osresetsystem);
DEFINE_SECTION_SYMBOLS(patch_osresetsystem_boot);
@@ -34,11 +34,11 @@ class OSResetSystemPatchCode : public PatchCode
{
public:
OSResetSystemPatchCode(PatchHeap& patchHeap, const loader_info_t* loaderInfo,
const SdReadPatchCode* sdReadPatchCode, const OSResetSystemPart2PatchCode* part2PatchCode)
const IReadSectorsPatchCode* sdReadPatchCode, const OSResetSystemPart2PatchCode* part2PatchCode)
: PatchCode(SECTION_START(patch_osresetsystem), SECTION_SIZE(patch_osresetsystem), patchHeap)
{
patch_osresetsystem_loader_info_address = loaderInfo;
patch_osresetsystem_readSdSectors_address = (u32)sdReadPatchCode->GetSdReadFunction();
patch_osresetsystem_readSdSectors_address = (u32)sdReadPatchCode->GetReadSectorsFunction();
patch_osresetsystem_bootPicoLoader_address = (u32)part2PatchCode->GetOSResetSystemPart2Function();
}

View File

@@ -1,7 +1,7 @@
#include "common.h"
#include "../PatchContext.h"
#include "../platform/LoaderPlatform.h"
#include "PokemonDownloaderArm9PatchAsm.h"
#include "PokemonDownloaderArm9PatchCode.h"
#include "PokemonDownloaderArm9Patch.h"
static const u32 sBootFunctionPattern[] = { 0xE92D4010u, 0xE59F003Cu, 0xE5904000u, 0xE3540000u };

View File

@@ -1,8 +1,8 @@
#pragma once
#include "../PatchCode.h"
#include "patches/PatchCode.h"
#include "sections.h"
#include "LoaderInfo.h"
#include "../platform/SdReadPatchCode.h"
#include "patches/platform/IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(patch_pokemondownloader9);
@@ -15,11 +15,11 @@ class PokemonDownloaderArm9PatchCode : public PatchCode
{
public:
PokemonDownloaderArm9PatchCode(PatchHeap& patchHeap, const loader_info_t* loaderInfo,
const SdReadPatchCode* sdReadPatchCode)
const IReadSectorsPatchCode* readSectorsPatchCode)
: PatchCode(SECTION_START(patch_pokemondownloader9), SECTION_SIZE(patch_pokemondownloader9), patchHeap)
{
patch_pokemondownloader9_loader_info_address = loaderInfo;
patch_pokemondownloader9_readSdSectors_address = (u32)sdReadPatchCode->GetSdReadFunction();
patch_pokemondownloader9_readSdSectors_address = (u32)readSectorsPatchCode->GetReadSectorsFunction();
}
const void* GetBoot9Function() const

View File

@@ -1,6 +1,7 @@
#pragma once
#include "sections.h"
#include "../SectorRemapPatchCode.h"
#include "../PatchCode.h"
#include "../ISectorRemapPatchCode.h"
#include "fileInfo.h"
DEFINE_SECTION_SYMBOLS(romoffsettosdsector);
@@ -9,11 +10,11 @@ extern "C" u32 rom_offset_to_sd_sector_asm(u32 romOffset);
extern u32 romoffsettosdsector_fatDataPtr;
class RomOffsetToSdSectorPatchCode : public SectorRemapPatchCode
class RomOffsetToSdSectorPatchCode : public PatchCode, public ISectorRemapPatchCode
{
public:
RomOffsetToSdSectorPatchCode(PatchHeap& patchHeap, const rom_file_info_t* fatDataPtr)
: SectorRemapPatchCode(SECTION_START(romoffsettosdsector), SECTION_SIZE(romoffsettosdsector), patchHeap)
: PatchCode(SECTION_START(romoffsettosdsector), SECTION_SIZE(romoffsettosdsector), patchHeap)
{
romoffsettosdsector_fatDataPtr = (u32)fatDataPtr;
}

View File

@@ -3,8 +3,8 @@
#include "fileInfo.h"
#include "thumbInstructions.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/arm9/RomOffsetToSdSectorAsm.h"
#include "patches/OffsetToSectorRemapAsm.h"
#include "patches/arm9/RomOffsetToSdSectorPatchCode.h"
#include "patches/OffsetToSectorRemapPatchCode.h"
#include "patches/arm9/FixCp15Asm.h"
#include "CardiReadCardPatchAsm.h"
#include "CardiReadCardPatch.h"
@@ -119,7 +119,7 @@ void CardiReadCardPatch::ApplyPatch(PatchContext& patchContext)
return new OffsetToSectorRemapPatchCode(patchContext.GetPatchHeap());
});
__patch_cardireadcard_rom_offset_to_sd_sector_asm_address = (u32)offsetToSectorRemapPatchCode->GetRemapFunction();
__patch_cardireadcard_sdread_asm_address = (u32)romReadPatchCode->GetSdReadFunction();
__patch_cardireadcard_sdread_asm_address = (u32)romReadPatchCode->GetReadSectorsFunction();
}
else
{
@@ -131,7 +131,7 @@ void CardiReadCardPatch::ApplyPatch(PatchContext& patchContext)
(const rom_file_info_t*)((u32)SHARED_ROM_FILE_INFO - 0x02F00000 + 0x02700000));
});
__patch_cardireadcard_rom_offset_to_sd_sector_asm_address = (u32)romOffsetToSdSectorPatchCode->GetRemapFunction();
__patch_cardireadcard_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
__patch_cardireadcard_sdread_asm_address = (u32)sdReadPatchCode->GetReadSectorsFunction();
}
u32 patch4Size = SECTION_SIZE(fixcp15);
void* patch4Address = patchContext.GetPatchHeap().Alloc(patch4Size);

View File

@@ -1,8 +1,8 @@
#pragma once
#include "patches/PatchCode.h"
#include "sections.h"
#include "patches/arm9/RomOffsetToSdSectorAsm.h"
#include "patches/platform/SdReadDmaPatchCode.h"
#include "patches/ISectorRemapPatchCode.h"
#include "patches/platform/IReadSectorsDmaPatchCode.h"
DEFINE_SECTION_SYMBOLS(patch_cardisetcarddma);
@@ -18,15 +18,16 @@ extern u32 patch_cardionreadcard_sdreaddma_finish_asm_address;
class CardiSetCardDmaPatchCode : public PatchCode
{
public:
CardiSetCardDmaPatchCode(PatchHeap& patchHeap, const RomOffsetToSdSectorPatchCode* romOffsetToSdSectorPatchCode,
const SdReadDmaPatchCode* sdReadDmaPatchCode, const void* cardiCommonPointer, const void* osDisableIrqMaskPointer)
CardiSetCardDmaPatchCode(PatchHeap& patchHeap, const ISectorRemapPatchCode* sectorRemapPatchCode,
const IReadSectorsDmaPatchCode* readSectorsDmaPatchCode, const void* cardiCommonPointer,
const void* osDisableIrqMaskPointer)
: PatchCode(SECTION_START(patch_cardisetcarddma), SECTION_SIZE(patch_cardisetcarddma), patchHeap)
{
patch_cardisetcarddma_cardi_common = (u32)cardiCommonPointer;
patch_cardisetcarddma_rom_offset_to_sd_sector_asm_address = (u32)romOffsetToSdSectorPatchCode->GetRemapFunction();
patch_cardisetcarddma_sdreaddma_asm_address = (u32)sdReadDmaPatchCode->GetSdReadDmaFunction();
patch_cardisetcarddma_rom_offset_to_sd_sector_asm_address = (u32)sectorRemapPatchCode->GetRemapFunction();
patch_cardisetcarddma_sdreaddma_asm_address = (u32)readSectorsDmaPatchCode->GetSdReadDmaFunction();
patch_cardionreadcard_osdisableirqmask_address = (u32)osDisableIrqMaskPointer;
patch_cardionreadcard_sdreaddma_finish_asm_address = (u32)sdReadDmaPatchCode->GetSdReadDmaFinishFunction();
patch_cardionreadcard_sdreaddma_finish_asm_address = (u32)readSectorsDmaPatchCode->GetSdReadDmaFinishFunction();
}
const void* GetCardiSetCardDmaFunction() const

View File

@@ -1,8 +1,9 @@
#include "common.h"
#include "patches/PatchContext.h"
#include "thumbInstructions.h"
#include "CardiSetCardDmaPatchAsm.h"
#include "CardiSetCardDmaPatchCode.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/arm9/RomOffsetToSdSectorPatchCode.h"
#include "CardiTryReadCardDmaPatch.h"
static const u32 sCARDiTryReadCardDmaPatternPingPals[] = { 0xE92D47F0u, 0xE1A0A000u, 0xE59F9120u, 0xE3A08000u };

View File

@@ -3,8 +3,8 @@
#include "fileInfo.h"
#include "thumbInstructions.h"
#include "patches/platform/LoaderPlatform.h"
#include "patches/arm9/RomOffsetToSdSectorAsm.h"
#include "patches/OffsetToSectorRemapAsm.h"
#include "patches/arm9/RomOffsetToSdSectorPatchCode.h"
#include "patches/OffsetToSectorRemapPatchCode.h"
#include "CardiReadRomWithCpuPatchAsm.h"
#include "patches/arm9/FixCp15Asm.h"
#include "CardiReadRomWithCpuPatch.h"
@@ -88,7 +88,7 @@ void CardiReadRomWithCpuPatch::ApplyPatch(PatchContext& patchContext)
return new OffsetToSectorRemapPatchCode(patchContext.GetPatchHeap());
});
__patch_cardireadromwithcpu_rom_offset_to_sd_sector_asm_address = (u32)offsetToSectorRemapPatchCode->GetRemapFunction();
__patch_cardireadromwithcpu_sdread_asm_address = (u32)romReadPatchCode->GetSdReadFunction();
__patch_cardireadromwithcpu_sdread_asm_address = (u32)romReadPatchCode->GetReadSectorsFunction();
}
else
{
@@ -99,7 +99,7 @@ void CardiReadRomWithCpuPatch::ApplyPatch(PatchContext& patchContext)
return new RomOffsetToSdSectorPatchCode(patchContext.GetPatchHeap(), SHARED_ROM_FILE_INFO);
});
__patch_cardireadromwithcpu_rom_offset_to_sd_sector_asm_address = (u32)romOffsetToSdSectorPatchCode->GetRemapFunction();
__patch_cardireadromwithcpu_sdread_asm_address = (u32)sdReadPatchCode->GetSdReadFunction();
__patch_cardireadromwithcpu_sdread_asm_address = (u32)sdReadPatchCode->GetReadSectorsFunction();
}
u32 patch1Size = SECTION_SIZE(patch_cardireadromwithcpu);

View File

@@ -1,28 +1,26 @@
#pragma once
#include "../PatchCode.h"
/// @brief Abstract base class for patch code implementing dma SD reads
class SdReadDmaPatchCode : public PatchCode
/// @brief Abstract base class for patch code implementing dma sector reads
class IReadSectorsDmaPatchCode
{
protected:
SdReadDmaPatchCode(const void* code, u32 size, PatchHeap& patchHeap)
: PatchCode(code, size, patchHeap) { }
IReadSectorsDmaPatchCode() { }
public:
/// @brief Pointer to a function for reading a single SD sector using the given dmaChannel.
/// In first sector of batch read, previousSrcSector will be 0.
/// On further reads previousSrcSector will contains the previous srcSector
/// which can be used to continue a sequential read.
typedef void (*SdReadDmaFunc)(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
typedef void (*ReadSectorsDmaFunc)(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
/// @brief Pointer to a function for finishing a batch of dma reads.
typedef void (*SdReadDmaFinishFunc)(void);
typedef void (*ReadSectorsDmaFinishFunc)(void);
/// @brief Gets a pointer to the dma SD read function in the patch code.
/// @return The pointer to the dma SD read function.
virtual const SdReadDmaFunc GetSdReadDmaFunction() const = 0;
virtual const ReadSectorsDmaFunc GetSdReadDmaFunction() const = 0;
/// @brief Gets a pointer to the dma SD read finish function in the patch code.
/// @return The pointer to the dma SD read finish function.
virtual const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const = 0;
virtual const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const = 0;
};

View File

@@ -0,0 +1,17 @@
#pragma once
/// @brief Abstract base class for patch code implementing sector reads
class IReadSectorsPatchCode
{
protected:
IReadSectorsPatchCode() { }
public:
/// @brief Pointer to a function for reading sectorCount sectors
/// from srcSector to the given dst buffer.
typedef void (*ReadSectorsFunc)(u32 srcSector, void* dst, u32 sectorCount);
/// @brief Gets a pointer to the sector read function in the patch code.
/// @return The pointer to the sector read function.
virtual const ReadSectorsFunc GetReadSectorsFunction() const = 0;
};

View File

@@ -0,0 +1,17 @@
#pragma once
/// @brief Abstract base class for patch code implementing sector writes
class IWriteSectorsPatchCode
{
protected:
IWriteSectorsPatchCode() { }
public:
/// @brief Pointer to a function for writing sectorCount sectors
/// from the given src buffer to dstSector.
typedef void (*WriteSectorsFunc)(u32 dstSector, const void* src, u32 sectorCount);
/// @brief Gets a pointer to the sector write function in the patch code.
/// @return The pointer to the sector write function.
virtual const WriteSectorsFunc GetWriteSectorFunction() const = 0;
};

View File

@@ -1,8 +1,7 @@
#pragma once
#include <memory>
#include "SdReadPatchCode.h"
#include "SdReadDmaPatchCode.h"
#include "SdWritePatchCode.h"
#include "IReadSectorsPatchCode.h"
#include "IReadSectorsDmaPatchCode.h"
#include "IWriteSectorsPatchCode.h"
#include "../PatchHeap.h"
#include "../PatchCodeCollection.h"
#include "LoaderPlatformType.h"
@@ -14,29 +13,29 @@ public:
/// @brief Creates the SD read patch code for the platform.
/// @param patchCodeCollection The patch code collection.
/// @param patchHeap The patch heap.
/// @return A unique pointer to the created SD read patch code.
virtual const SdReadPatchCode* CreateSdReadPatchCode(
/// @return A pointer to the created SD read patch code.
virtual const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const = 0;
/// @brief Creates the SD read dma patch code for the platform.
/// @param patchCodeCollection The patch code collection.
/// @param patchHeap The patch heap.
/// @return A unique pointer to the created SD read dma patch code.
virtual const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(
/// @return A pointer to the created SD read dma patch code.
virtual const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const { return nullptr; }
/// @brief Creates the SD write patch code for the platform.
/// @param patchCodeCollection The patch code collection.
/// @param patchHeap The patch heap.
/// @return A unique pointer to the created SD write patch code.
virtual const SdWritePatchCode* CreateSdWritePatchCode(
/// @return A pointer to the created SD write patch code.
virtual const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const = 0;
/// @brief Creates the rom read patch code for the platform.
/// @param patchCodeCollection The patch code collection.
/// @param patchHeap The patch heap.
/// @return A unique pointer to the created rom read patch code.
virtual const SdReadPatchCode* CreateRomReadPatchCode(
/// @return A pointer to the created rom read patch code.
virtual const IReadSectorsPatchCode* CreateRomReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const { return nullptr; }
/// @brief Returns the type of this loader platform.

View File

@@ -7,12 +7,12 @@
#include "patches/platform/ace3ds/Ace3DSLoaderPlatform.h"
#include "patches/platform/g003/G003LoaderPlatform.h"
#include "patches/platform/melonds/MelonDSLoaderPlatform.h"
#include "patches/platform/dstt/DSTTLoaderPlatform.h"
#include "patches/platform/ak2/AK2LoaderPlatform.h"
#include "patches/platform/akrpg/AKRPGLoaderPlatform.h"
#include "patches/platform/r4idsn/R4iDSNLoaderPlatform.h"
#include "patches/platform/dstt/DsttLoaderPlatform.h"
#include "patches/platform/ak2/Ak2LoaderPlatform.h"
#include "patches/platform/akrpg/AkRpgLoaderPlatform.h"
#include "patches/platform/r4idsn/R4iDsnLoaderPlatform.h"
#include "patches/platform/supercard/SuperCardLoaderPlatform.h"
#include "patches/platform/ezp/EZPLoaderPlatform.h"
#include "patches/platform/ezp/EzpLoaderPlatform.h"
#include "patches/platform/datel/DatelLoaderPlatform.h"
#include "patches/platform/stargate/StargateLoaderPlatform.h"
#include "LoaderPlatformFactory.h"
@@ -34,17 +34,17 @@ LoaderPlatform* LoaderPlatformFactory::CreateLoaderPlatform() const
#elif defined(PICO_LOADER_TARGET_MELONDS)
return new MelonDSLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_DSTT)
return new DSTTLoaderPlatform();
return new DsttLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_AK2)
return new AK2LoaderPlatform();
return new Ak2LoaderPlatform();
#elif defined(PICO_LOADER_TARGET_AKRPG)
return new AKRPGLoaderPlatform();
return new AkRpgLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_R4iDSN)
return new R4iDSNLoaderPlatform();
return new R4iDsnLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_SUPERCARD)
return new SuperCardLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_EZP)
return new EZPLoaderPlatform();
return new EzpLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_DATEL)
return new DatelLoaderPlatform();
#elif defined(PICO_LOADER_TARGET_STARGATE)

View File

@@ -1,19 +0,0 @@
#pragma once
#include "../PatchCode.h"
/// @brief Abstract base class for patch code implementing SD reads
class SdReadPatchCode : public PatchCode
{
protected:
SdReadPatchCode(const void* code, u32 size, PatchHeap& patchHeap)
: PatchCode(code, size, patchHeap) { }
public:
/// @brief Pointer to a function for reading sectorCount SD sectors
/// from srcSector to the given dst buffer.
typedef void (*SdReadFunc)(u32 srcSector, void* dst, u32 sectorCount);
/// @brief Gets a pointer to the SD read function in the patch code.
/// @return The pointer to the SD read function.
virtual const SdReadFunc GetSdReadFunction() const = 0;
};

View File

@@ -1,19 +0,0 @@
#pragma once
#include "../PatchCode.h"
/// @brief Abstract base class for patch code implementing SD writes
class SdWritePatchCode : public PatchCode
{
protected:
SdWritePatchCode(const void* code, u32 size, PatchHeap& patchHeap)
: PatchCode(code, size, patchHeap) { }
public:
/// @brief Pointer to a function for writing sectorCount SD sectors
/// from the given src buffer to dstSector.
typedef void (*SdWriteFunc)(u32 dstSector, const void* src, u32 sectorCount);
/// @brief Gets a pointer to the SD write function in the patch code.
/// @return The pointer to the SD write function.
virtual const SdWriteFunc GetSdWriteFunction() const = 0;
};

View File

@@ -1,15 +1,14 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "ace3dsReadSdAsm.h"
#include "ace3dsReadSdDmaAsm.h"
#include "ace3dsWriteSdAsm.h"
#include "Ace3DSReadSdPatchCode.h"
#include "Ace3DSReadSdDmaPatchCode.h"
#include "Ace3DSWriteSdPatchCode.h"
/// @brief Implementation of LoaderPlatform for the Ace3DS+ flashcard
class Ace3DSLoaderPlatform : public LoaderPlatform
{
public:
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
@@ -18,14 +17,14 @@ public:
});
}
const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection,
const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection,
PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const override
{
return patchCodeCollection.AddUniquePatchCode<Ace3DSReadSdDmaPatchCode>(
patchHeap, miiCardDmaCopy32Ptr);
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]

View File

@@ -0,0 +1,31 @@
#pragma once
#include "sections.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsDmaPatchCode.h"
DEFINE_SECTION_SYMBOLS(ace3ds_readsddma);
extern "C" void ace3ds_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
extern "C" void ace3ds_finishReadSdDma(void);
extern u32 ace3ds_readSdDma_miiCardDmaCopy32Ptr;
class Ace3DSReadSdDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode
{
public:
Ace3DSReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr)
: PatchCode(SECTION_START(ace3ds_readsddma), SECTION_SIZE(ace3ds_readsddma), patchHeap)
{
ace3ds_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr;
}
const ReadSectorsDmaFunc GetSdReadDmaFunction() const override
{
return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)ace3ds_readSdDma);
}
const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override
{
return (const ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)ace3ds_finishReadSdDma);
}
};

View File

@@ -0,0 +1,20 @@
#pragma once
#include "sections.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(ace3ds_readsd);
extern "C" void ace3ds_readSd(u32 srcSector, void* dst, u32 sectorCount);
class Ace3DSReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
explicit Ace3DSReadSdPatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(ace3ds_readsd), SECTION_SIZE(ace3ds_readsd), patchHeap) { }
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const ReadSectorsFunc)GetAddressAtTarget((void*)ace3ds_readSd);
}
};

View File

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

View File

@@ -1,19 +0,0 @@
#pragma once
#include "sections.h"
#include "../SdReadPatchCode.h"
DEFINE_SECTION_SYMBOLS(ace3ds_readsd);
extern "C" void ace3ds_readSd(u32 srcSector, void* dst, u32 sectorCount);
class Ace3DSReadSdPatchCode : public SdReadPatchCode
{
public:
explicit Ace3DSReadSdPatchCode(PatchHeap& patchHeap)
: SdReadPatchCode(SECTION_START(ace3ds_readsd), SECTION_SIZE(ace3ds_readsd), patchHeap) { }
const SdReadFunc GetSdReadFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)ace3ds_readSd);
}
};

View File

@@ -1,30 +0,0 @@
#pragma once
#include "sections.h"
#include "../SdReadDmaPatchCode.h"
DEFINE_SECTION_SYMBOLS(ace3ds_readsddma);
extern "C" void ace3ds_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
extern "C" void ace3ds_finishReadSdDma(void);
extern u32 ace3ds_readSdDma_miiCardDmaCopy32Ptr;
class Ace3DSReadSdDmaPatchCode : public SdReadDmaPatchCode
{
public:
explicit Ace3DSReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr)
: SdReadDmaPatchCode(SECTION_START(ace3ds_readsddma), SECTION_SIZE(ace3ds_readsddma), patchHeap)
{
ace3ds_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr;
}
const SdReadDmaFunc GetSdReadDmaFunction() const override
{
return (const SdReadDmaFunc)GetAddressAtTarget((void*)ace3ds_readSdDma);
}
const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override
{
return (const SdReadDmaFinishFunc)GetAddressAtTarget((void*)ace3ds_finishReadSdDma);
}
};

View File

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

View File

@@ -1,5 +1,4 @@
#pragma once
#include "common.h"
#include <libtwl/card/card.h>
/// All RPG-based SDIO drivers use this as base, and add latency/size as needed
@@ -11,7 +10,7 @@
#define IORPG_CMD_SET_SD_MODE_SDHC (0xC101000000000000ull)
/// @brief SDIO parameter types. Used with IORPG_CMD_SDIO command.
enum ioRPGSdioParamTypes
enum IoRpgSdioParamTypes
{
IORPG_SDIO_NORESPONSE = 0ull,
IORPG_SDIO_READ_RESPONSE = 1ull,

View File

@@ -1,11 +1,11 @@
#include "common.h"
#include <libtwl/card/card.h>
#include "ioRPGDefinitions.h"
#include "IoRpgDefinitions.h"
#include "../SdioDefinitions.h"
#include "waitByLoop.h"
#include "IoRPGLoaderPlatform.h"
#include "IoRpgLoaderPlatform.h"
bool IoRPGLoaderPlatform::InitializeSdCard()
bool IoRpgLoaderPlatform::InitializeSdCard()
{
bool isSdhc = false;
bool isSdVersion2 = false;
@@ -70,7 +70,7 @@ bool IoRPGLoaderPlatform::InitializeSdCard()
return isSuccess;
}
void IoRPGLoaderPlatform::SdSendSdioCommand(u64 command, u8* buffer, u32 length) const
void IoRpgLoaderPlatform::SdSendSdioCommand(u64 command, u8* buffer, u32 length) const
{
u32 flags;
if (length == 0)
@@ -140,7 +140,7 @@ void IoRPGLoaderPlatform::SdSendSdioCommand(u64 command, u8* buffer, u32 length)
card_romWaitBusy();
}
u32 IoRPGLoaderPlatform::SdSendR1Command(u8 cmd, u32 argument) const
u32 IoRpgLoaderPlatform::SdSendR1Command(u8 cmd, u32 argument) const
{
u64 buffer = 0;
SdSendSdioCommand(IoRpgCmdSdio(cmd, IORPG_SDIO_READ_RESPONSE, argument), (u8*)&buffer, SD_R1_RESPONSE_LENGTH_BITS);
@@ -148,7 +148,7 @@ u32 IoRPGLoaderPlatform::SdSendR1Command(u8 cmd, u32 argument) const
return (u32)(buffer >> 9);
}
void IoRPGLoaderPlatform::SdSendR2Command(u8 cmd, u32 argument) const
void IoRpgLoaderPlatform::SdSendR2Command(u8 cmd, u32 argument) const
{
ALIGN(4) u8 ret[136 >> 3] = {};
SdSendSdioCommand(IoRpgCmdSdio(cmd, IORPG_SDIO_READ_RESPONSE, argument), ret, SD_R2_RESPONSE_LENGTH_BITS);

View File

@@ -1,14 +1,13 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "iorpgSendSdioCommandAsm.h"
#include "iorpgSdWaitForStateAsm.h"
#include "IoRpgSendSdioCommandPatchCode.h"
#include "IoRpgSdWaitForStatePatchCode.h"
/// @brief Implementation of LoaderPlatform for flashcarts based on the Acekard RPG family
class IoRPGLoaderPlatform : public LoaderPlatform
class IoRpgLoaderPlatform : public LoaderPlatform
{
public:
explicit IoRPGLoaderPlatform(u8 ioRpgCmdSdioByte)
explicit IoRpgLoaderPlatform(u8 ioRpgCmdSdioByte)
: _ioRpgCmdSdioByte(ioRpgCmdSdioByte) { }
LoaderPlatformType GetPlatformType() const override { return LoaderPlatformType::Slot1; }
@@ -42,7 +41,7 @@ private:
/// @brief Builds a card command containing the SDIO command, SDIO parameter and the parameter type
/// @param SDIO command
/// @param Parameter type seen in ioRPGSdioParamTypes
/// @param Parameter type seen in IoRpgSdioParamTypes
/// @param Parameter to SDIO command.
/// @return A u64 to be written to REG_MCCMD0
u64 IoRpgCmdSdio(u8 sdio, u8 paramType, u32 parameter) const

View File

@@ -1,15 +1,16 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "patches/PatchCode.h"
DEFINE_SECTION_SYMBOLS(iorpg_sdwaitforstate);
extern "C" void iorpg_sdWaitForState(u32 status_shift, u8 state);
class ioRPGSDWaitForStatePatchCode : public PatchCode
class IoRpgSdWaitForStatePatchCode : public PatchCode
{
public:
explicit ioRPGSDWaitForStatePatchCode(PatchHeap& patchHeap)
explicit IoRpgSdWaitForStatePatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(iorpg_sdwaitforstate), SECTION_SIZE(iorpg_sdwaitforstate), patchHeap) { }
const void* GetSDWaitForStateFunction() const

View File

@@ -1,15 +1,16 @@
#pragma once
#include "sections.h"
#include "thumbInstructions.h"
#include "patches/PatchCode.h"
DEFINE_SECTION_SYMBOLS(iorpg_sendsdiocommand);
extern "C" void iorpg_sendSdioCommand(u8 sdio, u8 param_type, u32 param, u32 read_len);
class ioRPGSendSDIOCommandPatchCode : public PatchCode
class IoRpgSendSdioCommandPatchCode : public PatchCode
{
public:
explicit ioRPGSendSDIOCommandPatchCode(PatchHeap& patchHeap)
explicit IoRpgSendSdioCommandPatchCode(PatchHeap& patchHeap)
: PatchCode(SECTION_START(iorpg_sendsdiocommand), SECTION_SIZE(iorpg_sendsdiocommand), patchHeap) { }
const void* GetSendSdioCommandFunction() const

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);
}
};

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);
}
};

View File

@@ -1,15 +1,14 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "DatelSpiCommandsAsm.h"
#include "DatelReadSectorsAsm.h"
#include "DatelWriteSectorsAsm.h"
#include "DatelSendSdioCommandPatchCode.h"
#include "DatelReadSdPatchCode.h"
#include "DatelWriteSdPatchCode.h"
/// @brief Implementation of LoaderPlatform for the DATEL line of flashcarts
class DatelLoaderPlatform : public LoaderPlatform
{
public:
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
auto spi = patchCodeCollection.GetOrAddSharedPatchCode([&]
@@ -18,7 +17,7 @@ public:
});
auto sendSdio = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new DatelSendSDIOCommandPatchCode(patchHeap, spi);
return new DatelSendSdioCommandPatchCode(patchHeap, spi);
});
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{
@@ -26,7 +25,7 @@ public:
});
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
auto spi = patchCodeCollection.GetOrAddSharedPatchCode([&]
@@ -35,7 +34,7 @@ public:
});
auto sendSdio = patchCodeCollection.GetOrAddSharedPatchCode([&]
{
return new DatelSendSDIOCommandPatchCode(patchHeap, spi);
return new DatelSendSdioCommandPatchCode(patchHeap, spi);
});
return patchCodeCollection.GetOrAddSharedPatchCode([&]
{

View File

@@ -1,6 +1,8 @@
#pragma once
#include "sections.h"
#include "../SdReadPatchCode.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(datel_read);
extern u16 datel_readSectorSdhcLabel;
@@ -12,13 +14,13 @@ extern u32 datel_SDReadMultipleSector_ReadSpiShort;
extern "C" void datel_SDReadMultipleSector(u32 srcSector, void* dst, u32 sectorCount);
class DatelReadSdPatchCode : public SdReadPatchCode
class DatelReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
DatelReadSdPatchCode(PatchHeap& patchHeap,
const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode,
const DatelSendSDIOCommandPatchCode* datelSendSDIOCommandPatchCode)
: SdReadPatchCode(SECTION_START(datel_read), SECTION_SIZE(datel_read), patchHeap)
const DatelSendSdioCommandPatchCode* datelSendSDIOCommandPatchCode)
: PatchCode(SECTION_START(datel_read), SECTION_SIZE(datel_read), patchHeap)
{
datel_SDReadMultipleSector_SpiSendSDIOCommandR0 = (u32)datelSendSDIOCommandPatchCode->GetSpiSendSDIOCommandR0Function();
@@ -26,8 +28,8 @@ public:
datel_SDReadMultipleSector_ReadSpiShort = (u32)datelReadSpiBytePatchCode->GetReadSpiShortFunction();
}
const SdReadFunc GetSdReadFunction() const override
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)datel_SDReadMultipleSector);
return (const ReadSectorsFunc)GetAddressAtTarget((void*)datel_SDReadMultipleSector);
}
};

View File

@@ -1,6 +1,6 @@
#pragma once
#include "sections.h"
#include "../SdReadDmaPatchCode.h"
#include "patches/PatchCode.h"
DEFINE_SECTION_SYMBOLS(datel_read_spi);
DEFINE_SECTION_SYMBOLS(datel_spi_send);
@@ -49,11 +49,10 @@ public:
}
};
class DatelSendSDIOCommandPatchCode : public PatchCode
class DatelSendSdioCommandPatchCode : public PatchCode
{
public:
DatelSendSDIOCommandPatchCode(PatchHeap& patchHeap,
const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode)
DatelSendSdioCommandPatchCode(PatchHeap& patchHeap, const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode)
: PatchCode(SECTION_START(datel_spi_send), SECTION_SIZE(datel_spi_send), patchHeap)
{
datel_spiSendSDIOCommandR0_ReadWriteSpiByte = (u32)datelReadSpiBytePatchCode->GetReadWriteSpiByteFunction();

View File

@@ -1,6 +1,7 @@
#pragma once
#include "sections.h"
#include "../SdWritePatchCode.h"
#include "patches/PatchCode.h"
#include "../IWriteSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(datel_write);
@@ -13,13 +14,13 @@ extern u32 datel_SDWriteMultipleSector_ReadSpiByte;
extern "C" void datel_SDWriteMultipleSector(u32 srcSector, void* dst, u32 sectorCount);
class DatelWriteSdPatchCode : public SdWritePatchCode
class DatelWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode
{
public:
DatelWriteSdPatchCode(PatchHeap& patchHeap,
const DatelReadSpiBytePatchCode* datelReadSpiBytePatchCode,
const DatelSendSDIOCommandPatchCode* datelSendSDIOCommandPatchCode)
: SdWritePatchCode(SECTION_START(datel_write), SECTION_SIZE(datel_write), patchHeap)
const DatelSendSdioCommandPatchCode* datelSendSDIOCommandPatchCode)
: PatchCode(SECTION_START(datel_write), SECTION_SIZE(datel_write), patchHeap)
{
datel_SDWriteMultipleSector_SpiSendSDIOCommand = (u32)datelSendSDIOCommandPatchCode->GetSpiSendSDIOCommandFunction();
@@ -27,8 +28,8 @@ public:
datel_SDWriteMultipleSector_ReadSpiByte = (u32)datelReadSpiBytePatchCode->GetReadSpiByteFunction();
}
const SdWriteFunc GetSdWriteFunction() const override
const WriteSectorsFunc GetWriteSectorFunction() const override
{
return (const SdWriteFunc)GetAddressAtTarget((void*)datel_SDWriteMultipleSector);
return (const WriteSectorsFunc)GetAddressAtTarget((void*)datel_SDWriteMultipleSector);
}
};

View File

@@ -1,15 +1,14 @@
#pragma once
#include "common.h"
#include "../LoaderPlatform.h"
#include "dspicoReadSectorsAsm.h"
#include "dspicoReadSdSectorDmaAsm.h"
#include "dspicoWriteSectorsAsm.h"
#include "DSPicoReadSdSectorsPatchCode.h"
#include "DSPicoReadSdSectorDmaPatchCode.h"
#include "DSPicoWriteSdSectorsPatchCode.h"
/// @brief Implementation of LoaderPlatform for the DS pico flashcard
class DSPicoLoaderPlatform : public LoaderPlatform
{
public:
const SdReadPatchCode* CreateSdReadPatchCode(
const IReadSectorsPatchCode* CreateSdReadPatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]
@@ -22,7 +21,7 @@ public:
});
}
const SdReadDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection,
const IReadSectorsDmaPatchCode* CreateSdReadDmaPatchCode(PatchCodeCollection& patchCodeCollection,
PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr) const override
{
auto pollSdDataReadyPatchCode = patchCodeCollection.GetOrAddSharedPatchCode([&]
@@ -34,7 +33,7 @@ public:
patchHeap, pollSdDataReadyPatchCode, miiCardDmaCopy32Ptr);
}
const SdWritePatchCode* CreateSdWritePatchCode(
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
{
return patchCodeCollection.GetOrAddSharedPatchCode([&]

View File

@@ -1,6 +1,7 @@
#pragma once
#include "sections.h"
#include "../SdReadDmaPatchCode.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsDmaPatchCode.h"
DEFINE_SECTION_SYMBOLS(dspico_readsdsectordma);
DEFINE_SECTION_SYMBOLS(dspico_readsdsectordma_pollSdDataReady);
@@ -23,34 +24,34 @@ public:
return GetAddressAtTarget((void*)dspico_readSdSectorDma_pollSdDataReady);
}
const SdReadDmaPatchCode::SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const
const IReadSectorsDmaPatchCode::ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const
{
return (const SdReadDmaPatchCode::SdReadDmaFinishFunc)GetAddressAtTarget((void*)dspico_finishReadSdSectorDma);
return (const IReadSectorsDmaPatchCode::ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)dspico_finishReadSdSectorDma);
}
};
class DSPicoReadSdSectorDmaPatchCode : public SdReadDmaPatchCode
class DSPicoReadSdSectorDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode
{
public:
DSPicoReadSdSectorDmaPatchCode(PatchHeap& patchHeap,
const DSPicoReadSdSectorDmaPollSdDataReadyPatchCode* pollSdDataReadyPatchCode, const void* miiCardDmaCopy32Ptr)
: SdReadDmaPatchCode(SECTION_START(dspico_readsdsectordma), SECTION_SIZE(dspico_readsdsectordma), patchHeap)
: PatchCode(SECTION_START(dspico_readsdsectordma), SECTION_SIZE(dspico_readsdsectordma), patchHeap)
, _sdReadDmaFinishFunc(pollSdDataReadyPatchCode->GetSdReadDmaFinishFunction())
{
dspico_readSdSectorDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr;
dspico_readSdSectorDma_pollSdDataReadyPtr = (u32)pollSdDataReadyPatchCode->GetPollSdDataReadyFunction();
}
const SdReadDmaFunc GetSdReadDmaFunction() const override
const ReadSectorsDmaFunc GetSdReadDmaFunction() const override
{
return (const SdReadDmaFunc)GetAddressAtTarget((void*)dspico_readSdSectorDma);
return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)dspico_readSdSectorDma);
}
const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override
const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override
{
return _sdReadDmaFinishFunc;
}
private:
const SdReadDmaFinishFunc _sdReadDmaFinishFunc;
const ReadSectorsDmaFinishFunc _sdReadDmaFinishFunc;
};

View File

@@ -1,6 +1,7 @@
#pragma once
#include "sections.h"
#include "../SdReadPatchCode.h"
#include "patches/PatchCode.h"
#include "../IReadSectorsPatchCode.h"
DEFINE_SECTION_SYMBOLS(dspico_readsdsectors);
DEFINE_SECTION_SYMBOLS(dspico_readsdsectors_readdirect);
@@ -22,17 +23,17 @@ public:
}
};
class DSPicoReadSdSectorsPatchCode : public SdReadPatchCode
class DSPicoReadSdSectorsPatchCode : public PatchCode, public IReadSectorsPatchCode
{
public:
DSPicoReadSdSectorsPatchCode(PatchHeap& patchHeap, const DSPicoReadSdSectorsDirectPatchCode* readSdSectorsDirectPatchCode)
: SdReadPatchCode(SECTION_START(dspico_readsdsectors), SECTION_SIZE(dspico_readsdsectors), patchHeap)
: PatchCode(SECTION_START(dspico_readsdsectors), SECTION_SIZE(dspico_readsdsectors), patchHeap)
{
dspico_readsdsectors_readDirectAddress = (u32)readSdSectorsDirectPatchCode->GetReadSdSectorsDirectFunction();
}
const SdReadFunc GetSdReadFunction() const override
const ReadSectorsFunc GetReadSectorsFunction() const override
{
return (const SdReadFunc)GetAddressAtTarget((void*)dspico_readSdSectors);
return (const ReadSectorsFunc)GetAddressAtTarget((void*)dspico_readSdSectors);
}
};

View File

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

View File

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

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;

Some files were not shown because too many files have changed in this diff Show More