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,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,
|
||||
@@ -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);
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user