mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-06-02 09:16:49 +02:00
Refactored platform code to use interfaces for patch code with a special feature and improved patch code file names
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
#include "../LoaderPlatform.h"
|
||||
#include "stargateReadSdAsm.h"
|
||||
#include "stargateReadSdDmaAsm.h"
|
||||
#include "stargateWriteSdAsm.h"
|
||||
#include "StargateReadSdPatchCode.h"
|
||||
#include "StargateReadSdDmaPatchCode.h"
|
||||
#include "StargateWriteSdPatchCode.h"
|
||||
|
||||
/// @brief Implementation of LoaderPlatform for the Stargate 3DS flashcard
|
||||
class StargateLoaderPlatform : 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<StargateReadSdDmaPatchCode>(
|
||||
patchHeap, miiCardDmaCopy32Ptr);
|
||||
}
|
||||
|
||||
const SdWritePatchCode* CreateSdWritePatchCode(
|
||||
const IWriteSectorsPatchCode* CreateSdWritePatchCode(
|
||||
PatchCodeCollection& patchCodeCollection, PatchHeap& patchHeap) const override
|
||||
{
|
||||
return patchCodeCollection.GetOrAddSharedPatchCode([&]
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "sections.h"
|
||||
#include "patches/PatchCode.h"
|
||||
#include "../IReadSectorsDmaPatchCode.h"
|
||||
|
||||
DEFINE_SECTION_SYMBOLS(stargate_readsddma);
|
||||
|
||||
extern "C" void stargate_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
|
||||
extern "C" void stargate_finishReadSdDma(void);
|
||||
|
||||
extern u32 stargate_readSdDma_miiCardDmaCopy32Ptr;
|
||||
|
||||
class StargateReadSdDmaPatchCode : public PatchCode, public IReadSectorsDmaPatchCode
|
||||
{
|
||||
public:
|
||||
StargateReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr)
|
||||
: PatchCode(SECTION_START(stargate_readsddma), SECTION_SIZE(stargate_readsddma), patchHeap)
|
||||
{
|
||||
stargate_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr;
|
||||
}
|
||||
|
||||
const ReadSectorsDmaFunc GetSdReadDmaFunction() const override
|
||||
{
|
||||
return (const ReadSectorsDmaFunc)GetAddressAtTarget((void*)stargate_readSdDma);
|
||||
}
|
||||
|
||||
const ReadSectorsDmaFinishFunc GetSdReadDmaFinishFunction() const override
|
||||
{
|
||||
return (const ReadSectorsDmaFinishFunc)GetAddressAtTarget((void*)stargate_finishReadSdDma);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "sections.h"
|
||||
#include "patches/PatchCode.h"
|
||||
#include "../IReadSectorsPatchCode.h"
|
||||
|
||||
DEFINE_SECTION_SYMBOLS(stargate_readsd);
|
||||
|
||||
extern "C" void stargate_readSd(u32 srcSector, void* dst, u32 sectorCount);
|
||||
|
||||
class StargateReadSdPatchCode : public PatchCode, public IReadSectorsPatchCode
|
||||
{
|
||||
public:
|
||||
explicit StargateReadSdPatchCode(PatchHeap& patchHeap)
|
||||
: PatchCode(SECTION_START(stargate_readsd), SECTION_SIZE(stargate_readsd), patchHeap) { }
|
||||
|
||||
const ReadSectorsFunc GetReadSectorsFunction() const override
|
||||
{
|
||||
return (const ReadSectorsFunc)GetAddressAtTarget((void*)stargate_readSd);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "sections.h"
|
||||
#include "patches/PatchCode.h"
|
||||
#include "../IWriteSectorsPatchCode.h"
|
||||
|
||||
DEFINE_SECTION_SYMBOLS(stargate_writesd);
|
||||
|
||||
extern "C" void stargate_writeSd(u32 dstSector, const void* src, u32 sectorCount);
|
||||
|
||||
class StargateWriteSdPatchCode : public PatchCode, public IWriteSectorsPatchCode
|
||||
{
|
||||
public:
|
||||
explicit StargateWriteSdPatchCode(PatchHeap& patchHeap)
|
||||
: PatchCode(SECTION_START(stargate_writesd), SECTION_SIZE(stargate_writesd), patchHeap) { }
|
||||
|
||||
const WriteSectorsFunc GetWriteSectorFunction() const override
|
||||
{
|
||||
return (const WriteSectorsFunc)GetAddressAtTarget((void*)stargate_writeSd);
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include "sections.h"
|
||||
#include "../SdReadPatchCode.h"
|
||||
|
||||
DEFINE_SECTION_SYMBOLS(stargate_readsd);
|
||||
|
||||
extern "C" void stargate_readSd(u32 srcSector, void* dst, u32 sectorCount);
|
||||
|
||||
class StargateReadSdPatchCode : public SdReadPatchCode
|
||||
{
|
||||
public:
|
||||
explicit StargateReadSdPatchCode(PatchHeap& patchHeap)
|
||||
: SdReadPatchCode(SECTION_START(stargate_readsd), SECTION_SIZE(stargate_readsd), patchHeap) { }
|
||||
|
||||
const SdReadFunc GetSdReadFunction() const override
|
||||
{
|
||||
return (const SdReadFunc)GetAddressAtTarget((void*)stargate_readSd);
|
||||
}
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#include "sections.h"
|
||||
#include "../SdReadDmaPatchCode.h"
|
||||
|
||||
DEFINE_SECTION_SYMBOLS(stargate_readsddma);
|
||||
|
||||
extern "C" void stargate_readSdDma(u32 srcSector, u32 previousSrcSector, u32 dmaChannel, void* dst);
|
||||
extern "C" void stargate_finishReadSdDma(void);
|
||||
|
||||
extern u32 stargate_readSdDma_miiCardDmaCopy32Ptr;
|
||||
|
||||
class StargateReadSdDmaPatchCode : public SdReadDmaPatchCode
|
||||
{
|
||||
public:
|
||||
StargateReadSdDmaPatchCode(PatchHeap& patchHeap, const void* miiCardDmaCopy32Ptr)
|
||||
: SdReadDmaPatchCode(SECTION_START(stargate_readsddma), SECTION_SIZE(stargate_readsddma), patchHeap)
|
||||
{
|
||||
stargate_readSdDma_miiCardDmaCopy32Ptr = (u32)miiCardDmaCopy32Ptr;
|
||||
}
|
||||
|
||||
const SdReadDmaFunc GetSdReadDmaFunction() const override
|
||||
{
|
||||
return (const SdReadDmaFunc)GetAddressAtTarget((void*)stargate_readSdDma);
|
||||
}
|
||||
|
||||
const SdReadDmaFinishFunc GetSdReadDmaFinishFunction() const override
|
||||
{
|
||||
return (const SdReadDmaFinishFunc)GetAddressAtTarget((void*)stargate_finishReadSdDma);
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include "sections.h"
|
||||
#include "../SdWritePatchCode.h"
|
||||
|
||||
DEFINE_SECTION_SYMBOLS(stargate_writesd);
|
||||
|
||||
extern "C" void stargate_writeSd(u32 dstSector, const void* src, u32 sectorCount);
|
||||
|
||||
class StargateWriteSdPatchCode : public SdWritePatchCode
|
||||
{
|
||||
public:
|
||||
explicit StargateWriteSdPatchCode(PatchHeap& patchHeap)
|
||||
: SdWritePatchCode(SECTION_START(stargate_writesd), SECTION_SIZE(stargate_writesd), patchHeap) { }
|
||||
|
||||
const SdWriteFunc GetSdWriteFunction() const override
|
||||
{
|
||||
return (const SdWriteFunc)GetAddressAtTarget((void*)stargate_writeSd);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user