Initial commit

This commit is contained in:
Gericom
2025-11-23 14:02:39 +01:00
commit 3bb550c12e
53 changed files with 4301 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
#pragma once
typedef enum
{
DLDI_IPC_CMD_SETUP,
DLDI_IPC_CMD_READ_SECTORS,
DLDI_IPC_CMD_WRITE_SECTORS
} DldiIpcCommand;
typedef struct alignas(32)
{
u32 cmd;
void* buffer;
u32 sector;
u32 count;
} dldi_ipc_cmd_t;

View File

@@ -0,0 +1,11 @@
#include "common.h"
#include <libtwl/ipc/ipcFifoSystem.h>
#include "IpcService.h"
void IpcService::Start()
{
ipc_setChannelHandler(_ipcChannel, [] (u32 channel, u32 data, void* arg)
{
static_cast<IpcService*>(arg)->OnMessageReceived(data);
}, this);
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <libtwl/ipc/ipcFifoSystem.h>
class IpcService
{
const u32 _ipcChannel;
protected:
explicit IpcService(u32 ipcChannel)
: _ipcChannel(ipcChannel) { }
void SendResponseMessage(u32 data) const
{
ipc_sendFifoMessage(_ipcChannel, data);
}
public:
virtual void Start();
virtual void OnMessageReceived(u32 data) = 0;
};

View File

@@ -0,0 +1,33 @@
#include "common.h"
#include "ThreadIpcService.h"
void ThreadIpcService::ThreadMain()
{
while (true)
{
rtos_waitEvent(&_event, false, true);
if (_messageValid)
{
_messageValid = false;
HandleMessage(_message);
}
}
}
void ThreadIpcService::Start()
{
rtos_createEvent(&_event);
rtos_createThread(&_thread, _priority, [] (void* arg)
{
static_cast<ThreadIpcService*>(arg)->ThreadMain();
}, this, _stack, _stackSize);
rtos_wakeupThread(&_thread);
IpcService::Start();
}
void ThreadIpcService::OnMessageReceived(u32 data)
{
_message = data;
_messageValid = true;
rtos_signalEvent(&_event);
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include <libtwl/rtos/rtosThread.h>
#include <libtwl/rtos/rtosEvent.h>
#include "IpcService.h"
class ThreadIpcService : public IpcService
{
rtos_thread_t _thread;
rtos_event_t _event;
u32* _stack;
u32 _stackSize;
u8 _priority;
bool _messageValid = false;
u32 _message;
void ThreadMain();
public:
ThreadIpcService(u32 ipcChannel, u8 priority, u32* stack, u32 stackSize)
: IpcService(ipcChannel), _stack(stack), _stackSize(stackSize), _priority(priority) { }
void Start() override;
void OnMessageReceived(u32 data) override;
virtual void HandleMessage(u32 data);
};

View File

@@ -0,0 +1,7 @@
#pragma once
#define IPC_CHANNEL_DSI_SD 16
#define IPC_CHANNEL_DLDI 17
#define IPC_CHANNEL_LOADER 18
#define IPC_CHANNEL_SOUND 19
#define IPC_CHANNEL_RTC 20