rpcsx/rpcs3/Emu/SysCalls/Modules/cellRudp.cpp

291 lines
5 KiB
C++
Raw Normal View History

2014-07-12 09:46:14 +02:00
#include "stdafx.h"
2015-02-22 12:38:14 +01:00
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
2015-07-15 10:52:20 +02:00
#include "sys_net.h"
#include "cellRudp.h"
2015-02-22 12:38:14 +01:00
extern Module cellRudp;
2015-07-27 16:59:21 +02:00
struct RudpInternal
{
2015-07-27 16:59:21 +02:00
std::atomic<bool> init;
2015-07-27 16:59:21 +02:00
// allocator functions
std::function<vm::ptr<void>(PPUThread& ppu, u32 size)> malloc;
std::function<void(PPUThread& ppu, vm::ptr<void> ptr)> free;
2015-07-27 16:59:21 +02:00
// event handler function
vm::ptr<CellRudpEventHandler> handler;
vm::ptr<void> handler_arg;
}
g_rudp;
s32 cellRudpInit(vm::ptr<CellRudpAllocator> allocator)
{
2015-07-27 16:59:21 +02:00
cellRudp.Warning("cellRudpInit(allocator=*0x%x)", allocator);
2015-07-27 16:59:21 +02:00
if (g_rudp.init.load())
2015-07-15 10:52:20 +02:00
{
return CELL_RUDP_ERROR_ALREADY_INITIALIZED;
2015-07-15 10:52:20 +02:00
}
if (allocator)
{
2015-07-27 16:59:21 +02:00
g_rudp.malloc = allocator->app_malloc;
g_rudp.free = allocator->app_free;
}
else
{
g_rudp.malloc = [](PPUThread& ppu, u32 size)
{
return vm::ptr<void>::make(vm::alloc(size, vm::main));
};
g_rudp.free = [](PPUThread& ppu, vm::ptr<void> ptr)
{
if (!vm::dealloc(ptr.addr(), vm::main))
{
throw EXCEPTION("Memory deallocation failed (ptr=0x%x)", ptr);
}
};
2015-07-15 10:52:20 +02:00
}
2015-07-27 16:59:21 +02:00
if (g_rudp.init.exchange(true))
{
throw EXCEPTION("Unexpected");
}
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpEnd()
{
2015-07-27 16:59:21 +02:00
cellRudp.Warning("cellRudpEnd()");
2015-07-27 16:59:21 +02:00
if (!g_rudp.init.load())
2015-07-15 10:52:20 +02:00
{
return CELL_RUDP_ERROR_NOT_INITIALIZED;
2015-07-15 10:52:20 +02:00
}
2015-07-27 16:59:21 +02:00
if (!g_rudp.init.exchange(false))
{
throw EXCEPTION("Unexpected");
}
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpEnableInternalIOThread()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-07-27 16:59:21 +02:00
s32 cellRudpSetEventHandler(vm::ptr<CellRudpEventHandler> handler, vm::ptr<void> arg)
{
2015-07-27 16:59:21 +02:00
cellRudp.Todo("cellRudpSetEventHandler(handler=*0x%x, arg=*0x%x)", handler, arg);
2015-07-15 10:52:20 +02:00
2015-07-27 16:59:21 +02:00
if (!g_rudp.init.load())
2015-07-15 10:52:20 +02:00
{
return CELL_RUDP_ERROR_NOT_INITIALIZED;
}
2015-07-27 16:59:21 +02:00
g_rudp.handler = handler;
g_rudp.handler_arg = arg;
2015-07-15 10:52:20 +02:00
return CELL_OK;
}
2015-07-16 19:28:47 +02:00
s32 cellRudpSetMaxSegmentSize(u16 mss)
{
2015-07-16 19:28:47 +02:00
cellRudp.Todo("cellRudpSetMaxSegmentSize(mss=%d)", mss);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetMaxSegmentSize()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpCreateContext()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpSetOption()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetOption()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetContextStatus()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetStatus()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetLocalInfo()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetRemoteInfo()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpBind()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpInitiate()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpActivate()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpTerminate()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpRead()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpWrite()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetSizeReadable()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpGetSizeWritable()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpFlush()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpPollCreate()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpPollDestroy()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpPollControl()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpPollWait()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-07-27 16:59:21 +02:00
s32 cellRudpPollCancel()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpNetReceived()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
s32 cellRudpProcessEvents()
{
UNIMPLEMENTED_FUNC(cellRudp);
return CELL_OK;
}
2015-02-22 12:38:14 +01:00
Module cellRudp("cellRudp", []()
{
2015-07-27 16:59:21 +02:00
g_rudp.init = false;
REG_FUNC(cellRudp, cellRudpInit);
REG_FUNC(cellRudp, cellRudpEnd);
REG_FUNC(cellRudp, cellRudpEnableInternalIOThread);
REG_FUNC(cellRudp, cellRudpSetEventHandler);
REG_FUNC(cellRudp, cellRudpSetMaxSegmentSize);
REG_FUNC(cellRudp, cellRudpGetMaxSegmentSize);
REG_FUNC(cellRudp, cellRudpCreateContext);
REG_FUNC(cellRudp, cellRudpSetOption);
REG_FUNC(cellRudp, cellRudpGetOption);
REG_FUNC(cellRudp, cellRudpGetContextStatus);
REG_FUNC(cellRudp, cellRudpGetStatus);
REG_FUNC(cellRudp, cellRudpGetLocalInfo);
REG_FUNC(cellRudp, cellRudpGetRemoteInfo);
REG_FUNC(cellRudp, cellRudpBind);
REG_FUNC(cellRudp, cellRudpInitiate);
REG_FUNC(cellRudp, cellRudpActivate);
REG_FUNC(cellRudp, cellRudpTerminate);
REG_FUNC(cellRudp, cellRudpRead);
REG_FUNC(cellRudp, cellRudpWrite);
REG_FUNC(cellRudp, cellRudpGetSizeReadable);
REG_FUNC(cellRudp, cellRudpGetSizeWritable);
REG_FUNC(cellRudp, cellRudpFlush);
REG_FUNC(cellRudp, cellRudpPollCreate);
REG_FUNC(cellRudp, cellRudpPollDestroy);
REG_FUNC(cellRudp, cellRudpPollControl);
REG_FUNC(cellRudp, cellRudpPollWait);
2015-07-27 16:59:21 +02:00
REG_FUNC(cellRudp, cellRudpPollCancel);
REG_FUNC(cellRudp, cellRudpNetReceived);
REG_FUNC(cellRudp, cellRudpProcessEvents);
2015-02-22 12:38:14 +01:00
});