lay base for supporting different MP interfaces

This commit is contained in:
Arisotura
2024-08-07 13:19:46 +02:00
parent 0ad1fa8514
commit bdbcd9c351
9 changed files with 109 additions and 42 deletions

View File

@ -21,6 +21,7 @@
#include "types.h"
#include "Platform.h"
#include "MPInterface.h"
namespace melonDS
{
@ -46,7 +47,7 @@ constexpr u32 kPacketQueueSize = 0x10000;
constexpr u32 kReplyQueueSize = 0x10000;
constexpr u32 kMaxFrameSize = 0x948;
class LocalMP
class LocalMP : public MPInterface
{
public:
LocalMP() noexcept;
@ -56,8 +57,7 @@ public:
LocalMP& operator=(LocalMP&& other) = delete;
~LocalMP() noexcept;
[[nodiscard]] int GetRecvTimeout() const noexcept { return RecvTimeout; }
void SetRecvTimeout(int timeout) noexcept { RecvTimeout = timeout; }
void Process() {}
void Begin(int inst);
void End(int inst);
@ -69,11 +69,13 @@ public:
int SendAck(int inst, u8* data, int len, u64 timestamp);
int RecvHostPacket(int inst, u8* data, u64* timestamp);
u16 RecvReplies(int inst, u8* data, u64 timestamp, u16 aidmask);
private:
void FIFORead(int inst, int fifo, void* buf, int len) noexcept;
void FIFOWrite(int inst, int fifo, void* buf, int len) noexcept;
int SendPacketGeneric(int inst, u32 type, u8* packet, int len, u64 timestamp) noexcept;
int RecvPacketGeneric(int inst, u8* packet, bool block, u64* timestamp) noexcept;
Platform::Mutex* MPQueueLock;
MPStatusData MPStatus {};
u8 MPPacketQueue[kPacketQueueSize] {};
@ -81,8 +83,6 @@ private:
u32 PacketReadOffset[16] {};
u32 ReplyReadOffset[16] {};
int RecvTimeout = 25;
int LastHostID = -1;
Platform::Semaphore* SemPool[32] {};
};