2014-07-12 09:46:14 +02:00
|
|
|
#include "stdafx.h"
|
2015-02-22 12:38:14 +01:00
|
|
|
#include "Emu/System.h"
|
2016-03-21 20:43:03 +01:00
|
|
|
#include "Emu/IdManager.h"
|
|
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2015-07-15 10:52:20 +02:00
|
|
|
|
2015-02-22 15:50:11 +01:00
|
|
|
#include "cellRudp.h"
|
2013-09-28 04:36:57 +02:00
|
|
|
|
2017-05-13 20:30:37 +02:00
|
|
|
logs::channel cellRudp("cellRudp");
|
2013-09-28 04:36:57 +02:00
|
|
|
|
2015-08-04 16:47:37 +02:00
|
|
|
struct rudp_t
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2015-07-27 16:59:21 +02:00
|
|
|
// allocator functions
|
2016-07-27 23:43:22 +02:00
|
|
|
std::function<vm::ptr<void>(ppu_thread& ppu, u32 size)> malloc;
|
|
|
|
|
std::function<void(ppu_thread& ppu, vm::ptr<void> ptr)> free;
|
2013-09-28 04:36:57 +02:00
|
|
|
|
2015-07-27 16:59:21 +02:00
|
|
|
// event handler function
|
2015-08-04 16:47:37 +02:00
|
|
|
vm::ptr<CellRudpEventHandler> handler = vm::null;
|
2015-07-27 16:59:21 +02:00
|
|
|
vm::ptr<void> handler_arg;
|
2015-08-04 16:47:37 +02:00
|
|
|
};
|
2015-02-22 15:50:11 +01:00
|
|
|
|
|
|
|
|
s32 cellRudpInit(vm::ptr<CellRudpAllocator> allocator)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellRudp.warning("cellRudpInit(allocator=*0x%x)", allocator);
|
2015-02-22 15:50:11 +01:00
|
|
|
|
2015-08-06 15:05:33 +02:00
|
|
|
const auto rudp = fxm::make<rudp_t>();
|
2015-08-04 16:47:37 +02:00
|
|
|
|
|
|
|
|
if (!rudp)
|
2015-07-15 10:52:20 +02:00
|
|
|
{
|
2015-02-22 15:50:11 +01:00
|
|
|
return CELL_RUDP_ERROR_ALREADY_INITIALIZED;
|
2015-07-15 10:52:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
|
{
|
2015-08-04 16:47:37 +02:00
|
|
|
rudp->malloc = allocator->app_malloc;
|
|
|
|
|
rudp->free = allocator->app_free;
|
2015-07-27 16:59:21 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-07-27 23:43:22 +02:00
|
|
|
rudp->malloc = [](ppu_thread& ppu, u32 size)
|
2015-07-27 16:59:21 +02:00
|
|
|
{
|
|
|
|
|
return vm::ptr<void>::make(vm::alloc(size, vm::main));
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-27 23:43:22 +02:00
|
|
|
rudp->free = [](ppu_thread& ppu, vm::ptr<void> ptr)
|
2015-07-27 16:59:21 +02:00
|
|
|
{
|
|
|
|
|
if (!vm::dealloc(ptr.addr(), vm::main))
|
|
|
|
|
{
|
2016-08-08 18:01:06 +02:00
|
|
|
fmt::throw_exception("Memory deallocation failed (ptr=0x%x)" HERE, ptr);
|
2015-07-27 16:59:21 +02:00
|
|
|
}
|
|
|
|
|
};
|
2015-07-15 10:52:20 +02:00
|
|
|
}
|
2015-02-22 15:50:11 +01:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpEnd()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellRudp.warning("cellRudpEnd()");
|
2015-02-22 15:50:11 +01:00
|
|
|
|
2015-08-06 15:05:33 +02:00
|
|
|
if (!fxm::remove<rudp_t>())
|
2015-07-15 10:52:20 +02:00
|
|
|
{
|
2015-02-22 15:50:11 +01:00
|
|
|
return CELL_RUDP_ERROR_NOT_INITIALIZED;
|
2015-07-15 10:52:20 +02:00
|
|
|
}
|
2015-02-22 15:50:11 +01:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpEnableInternalIOThread()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 16:59:21 +02:00
|
|
|
s32 cellRudpSetEventHandler(vm::ptr<CellRudpEventHandler> handler, vm::ptr<void> arg)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellRudp.todo("cellRudpSetEventHandler(handler=*0x%x, arg=*0x%x)", handler, arg);
|
2015-07-15 10:52:20 +02:00
|
|
|
|
2015-08-06 15:05:33 +02:00
|
|
|
const auto rudp = fxm::get<rudp_t>();
|
2015-08-04 16:47:37 +02:00
|
|
|
|
|
|
|
|
if (!rudp)
|
2015-07-15 10:52:20 +02:00
|
|
|
{
|
|
|
|
|
return CELL_RUDP_ERROR_NOT_INITIALIZED;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-04 16:47:37 +02:00
|
|
|
rudp->handler = handler;
|
|
|
|
|
rudp->handler_arg = arg;
|
2015-07-15 10:52:20 +02:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-16 19:28:47 +02:00
|
|
|
s32 cellRudpSetMaxSegmentSize(u16 mss)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellRudp.todo("cellRudpSetMaxSegmentSize(mss=%d)", mss);
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetMaxSegmentSize()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpCreateContext()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpSetOption()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetOption()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetContextStatus()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetStatus()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetLocalInfo()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetRemoteInfo()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpBind()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpInitiate()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpActivate()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpTerminate()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpRead()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpWrite()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetSizeReadable()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpGetSizeWritable()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpFlush()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpPollCreate()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpPollDestroy()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpPollControl()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpPollWait()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
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()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-22 12:38:14 +01:00
|
|
|
s32 cellRudpProcessEvents()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED_FUNC(cellRudp);
|
|
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
DECLARE(ppu_module_manager::cellRudp)("cellRudp", []()
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2015-02-20 14:58:40 +01:00
|
|
|
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);
|
2013-09-28 04:36:57 +02:00
|
|
|
|
2015-02-20 14:58:40 +01:00
|
|
|
REG_FUNC(cellRudp, cellRudpNetReceived);
|
|
|
|
|
REG_FUNC(cellRudp, cellRudpProcessEvents);
|
2015-02-22 12:38:14 +01:00
|
|
|
});
|