Split out sceNetAdhoc* into a separate file from sceNet.

This commit is contained in:
Henrik Rydgard 2013-09-07 00:55:42 +02:00
parent d4c8edd17d
commit cc8e4cb8fe
9 changed files with 443 additions and 335 deletions

View File

@ -870,6 +870,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HLE/sceMpeg.h
Core/HLE/sceNet.cpp
Core/HLE/sceNet.h
Core/HLE/sceNetAdhoc.cpp
Core/HLE/sceNetAdhoc.h
Core/HLE/sceOpenPSID.cpp
Core/HLE/sceOpenPSID.h
Core/HLE/sceP3da.cpp

View File

@ -224,6 +224,7 @@
<ClCompile Include="HLE\sceKernelVTimer.cpp" />
<ClCompile Include="HLE\sceMpeg.cpp" />
<ClCompile Include="HLE\sceNet.cpp" />
<ClCompile Include="HLE\sceNetAdhoc.cpp" />
<ClCompile Include="HLE\sceNp.cpp" />
<ClCompile Include="HLE\sceOpenPSID.cpp" />
<ClCompile Include="HLE\sceParseHttp.cpp" />
@ -462,6 +463,7 @@
<ClInclude Include="HLE\sceKernelTime.h" />
<ClInclude Include="HLE\sceMpeg.h" />
<ClInclude Include="HLE\sceNet.h" />
<ClInclude Include="HLE\sceNetAdhoc.h" />
<ClInclude Include="HLE\sceNp.h" />
<ClInclude Include="HLE\sceOpenPSID.h" />
<ClInclude Include="HLE\sceParseHttp.h" />

View File

@ -490,6 +490,9 @@
<ClCompile Include="HLE\sceHeap.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
<ClCompile Include="HLE\sceNetAdhoc.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@ -900,6 +903,9 @@
<ClInclude Include="HLE\sceHeap.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
<ClInclude Include="HLE\sceNetAdhoc.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />

View File

@ -18,6 +18,10 @@
#include "HLE.h"
#include "sceHttp.h"
#include "net/http_client.h"
// If http isn't loaded (seems unlikely), most functions should return SCE_KERNEL_ERROR_LIBRARY_NOTFOUND
// Could come in handy someday if we ever implement sceHttp* for real.
enum PSPHttpMethod {
@ -26,18 +30,32 @@ enum PSPHttpMethod {
PSP_HTTP_METHOD_HEAD
};
// Just a holder for settings like user agent string
class HTTPTemplate {
char useragent[512];
};
class HTTPConnection {
};
class HTTPRequest {
};
int sceHttpSetResolveRetry(int connectionID, int retryCount) {
ERROR_LOG(HLE, "UNIMPL sceHttpSetResolveRetry(%d, %d)", connectionID, retryCount);
return 0;
}
int sceHttpInit() {
ERROR_LOG(HLE, "UNIMPL sceHttpInit()");
int sceHttpInit(int unknown) {
ERROR_LOG(HLE, "UNIMPL sceHttpInit(%i)", unknown);
return 0;
}
int sceHttpEnd() {
ERROR_LOG(HLE, "UNIMPL sceHttpInit()");
ERROR_LOG(HLE, "UNIMPL sceHttpEnd()");
return 0;
}
@ -259,7 +277,7 @@ int sceHttpGetContentLength(int requestID, u64 contentLengthPtr) {
0x71eef62d sceSircsSend
*/
const HLEFunction sceHttp[] = {
{0xab1abe07,WrapI_V<sceHttpInit>,"sceHttpInit"},
{0xab1abe07,WrapI_I<sceHttpInit>,"sceHttpInit"},
{0xd1c8945e,WrapI_V<sceHttpEnd>,"sceHttpEnd"},
{0xa6800c34,WrapI_I<sceHttpInitCache>,"sceHttpInitCache"},
{0x78b54c09,WrapI_V<sceHttpEndCache>,"sceHttpEndCache"},

View File

@ -59,6 +59,7 @@
#include "sceKernelTime.h"
#include "sceMpeg.h"
#include "sceNet.h"
#include "sceNetAdhoc.h"
#include "scePower.h"
#include "sceUtility.h"
#include "sceUmd.h"
@ -125,6 +126,7 @@ void __KernelInit()
__UsbInit();
__FontInit();
__NetInit();
__NetAdhocInit();
__VaudioInit();
__CheatInit();
@ -150,6 +152,7 @@ void __KernelShutdown()
kernelObjects.Clear();
__NetShutdown();
__NetAdhocShutdown();
__FontShutdown();
__MpegShutdown();
@ -209,6 +212,7 @@ void __KernelDoState(PointerWrap &p)
__JpegDoState(p);
__MpegDoState(p);
__NetDoState(p);
__NetAdhocDoState(p);
__PowerDoState(p);
__PsmfDoState(p);
__PsmfPlayerDoState(p);

View File

@ -28,13 +28,9 @@
static bool netInited;
static bool netInetInited;
static bool netAdhocInited;
static bool netAdhocctlInited;
static bool netAdhocMatchingInited;
static bool netApctlInited;
// TODO: Determine how many handlers we can actually have
const size_t MAX_ADHOCCTL_HANDLERS = 32;
const size_t MAX_APCTL_HANDLERS = 32;
enum {
@ -46,38 +42,10 @@ enum {
ERROR_NET_RESOLVER_ALREADY_STOPPED = 0x8041040a,
ERROR_NET_RESOLVER_INVALID_HOST = 0x80410414,
ERROR_NET_ADHOC_INVALID_SOCKET_ID = 0x80410701,
ERROR_NET_ADHOC_INVALID_ADDR = 0x80410702,
ERROR_NET_ADHOC_NO_DATA_AVAILABLE = 0x80410709,
ERROR_NET_ADHOC_PORT_IN_USE = 0x8041070a,
ERROR_NET_ADHOC_NOT_INITIALIZED = 0x80410712,
ERROR_NET_ADHOC_ALREADY_INITIALIZED = 0x80410713,
ERROR_NET_ADHOC_DISCONNECTED = 0x8041070c,
ERROR_NET_ADHOC_TIMEOUT = 0x80410715,
ERROR_NET_ADHOC_NO_ENTRY = 0x80410716,
ERROR_NET_ADHOC_CONNECTION_REFUSED = 0x80410718,
ERROR_NET_ADHOC_INVALID_MATCHING_ID = 0x80410807,
ERROR_NET_ADHOC_MATCHING_ALREADY_INITIALIZED = 0x80410812,
ERROR_NET_ADHOC_MATCHING_NOT_INITIALIZED = 0x80410813,
ERROR_NET_APCTL_ALREADY_INITIALIZED = 0x80410a01,
ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF = 0x80410b03,
ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED = 0x80410b07,
ERROR_NET_ADHOCCTL_NOT_INITIALIZED = 0x80410b08,
ERROR_NET_ADHOCCTL_DISCONNECTED = 0x80410b09,
ERROR_NET_ADHOCCTL_BUSY = 0x80410b10,
ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12,
};
// These might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc..
struct SceNetAdhocctlParams {
s32_le channel; //which ad-hoc channel to connect to
char name[8]; //connection name
u8 bssid[6]; //BSSID of the connection?
char nickname[128]; //PSP's nickname?
};
struct ProductStruct {
s32_le unknown; // Unknown, set to 0
char product[9]; // Game ID (Example: ULUS10000)
@ -91,12 +59,6 @@ struct SceNetMallocStat {
static struct SceNetMallocStat netMallocStat;
struct AdhocctlHandler {
u32 entryPoint;
u32 argument;
};
static std::map<int, AdhocctlHandler> adhocctlHandlers;
struct ApctlHandler {
u32 entryPoint;
@ -107,12 +69,8 @@ static std::map<int, ApctlHandler> apctlHandlers;
void __ResetInitNetLib() {
netInited = false;
netAdhocInited = false;
netAdhocctlInited = false;
netAdhocMatchingInited = false;
netApctlInited = false;
netInetInited = false;
adhocctlHandlers.clear();
memset(&netMallocStat, 0, sizeof(netMallocStat));
}
@ -125,17 +83,6 @@ void __NetShutdown() {
__ResetInitNetLib();
}
void __UpdateAdhocctlHandlers(int flag, int error) {
u32 args[3] = { 0, 0, 0 };
args[0] = flag;
args[1] = error;
for(std::map<int, AdhocctlHandler>::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); ++it) {
args[2] = it->second.argument;
__KernelDirectMipsCall(it->second.entryPoint, NULL, args, 3, true);
}
}
void __UpdateApctlHandlers(int oldState, int newState, int flag, int error) {
u32 args[5] = { 0, 0, 0, 0, 0 };
@ -155,11 +102,7 @@ void __UpdateApctlHandlers(int oldState, int newState, int flag, int error) {
void __NetDoState(PointerWrap &p) {
p.Do(netInited);
p.Do(netInetInited);
p.Do(netAdhocInited);
p.Do(netApctlInited);
p.Do(netAdhocctlInited);
p.Do(netAdhocMatchingInited);
p.Do(adhocctlHandlers);
p.Do(apctlHandlers);
p.Do(netMallocStat);
p.DoMarker("net");
@ -183,24 +126,6 @@ u32 sceNetTerm() {
return 0;
}
u32 sceNetAdhocInit() {
ERROR_LOG(HLE,"UNIMPL sceNetAdhocInit()");
if (netAdhocInited)
return ERROR_NET_ADHOC_ALREADY_INITIALIZED;
netAdhocInited = true;
return 0;
}
u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) {
ERROR_LOG(HLE,"UNIMPL sceNetAdhocctlInit(%i, %i, %08x)", stackSize, prio, productAddr);
if(netAdhocctlInited)
return ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED;
netAdhocctlInited = true;
return 0;
}
u32 sceWlanGetEtherAddr(u32 addrAddr) {
static const u8 fakeEtherAddr[6] = { 1, 2, 3, 4, 5, 6 };
DEBUG_LOG(HLE, "sceWlanGetEtherAddr(%08x)", addrAddr);
@ -220,87 +145,6 @@ u32 sceWlanGetSwitchState() {
return 0;
}
// TODO: How many handlers can the PSP actually have for Adhocctl?
// TODO: Should we allow the same handler to be added more than once?
u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 handlerArg) {
bool foundHandler = false;
u32 retval = 0;
struct AdhocctlHandler handler;
memset(&handler, 0, sizeof(handler));
while (adhocctlHandlers.find(retval) != adhocctlHandlers.end())
++retval;
handler.entryPoint = handlerPtr;
handler.argument = handlerArg;
for(std::map<int, AdhocctlHandler>::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); it++) {
if(it->second.entryPoint == handlerPtr) {
foundHandler = true;
break;
}
}
if(!foundHandler && Memory::IsValidAddress(handlerPtr)) {
if(adhocctlHandlers.size() >= MAX_ADHOCCTL_HANDLERS) {
ERROR_LOG(HLE, "UNTESTED UNTESTED sceNetAdhocctlAddHandler(%x, %x): Too many handlers", handlerPtr, handlerArg);
retval = ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS;
return retval;
}
adhocctlHandlers[retval] = handler;
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, retval);
}
else
ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Same handler already exists", handlerPtr, handlerArg);
// The id to return is the number of handlers currently registered
return retval;
}
u32 sceNetAdhocctlDisconnect() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()");
__UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF);
return 0;
}
u32 sceNetAdhocctlDelHandler(u32 handlerID) {
if(adhocctlHandlers.find(handlerID) != adhocctlHandlers.end()) {
adhocctlHandlers.erase(handlerID);
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%d): deleted handler %d", handlerID, handlerID);
}
else
ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%d): asked to delete invalid handler %d", handlerID, handlerID);
return 0;
}
int sceNetAdhocMatchingTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingTerm()");
netAdhocMatchingInited = false;
return 0;
}
int sceNetAdhocctlTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlTerm()");
netAdhocctlInited = false;
return 0;
}
int sceNetAdhocTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocTerm()");
// Seems to return this when called a second time after being terminated without another initialisation
if(!netAdhocInited)
return SCE_KERNEL_ERROR_LWMUTEX_NOT_FOUND;
netAdhocInited = false;
return 0;
}
// Probably a void function, but often returns a useful value.
int sceNetEtherNtostr(u32 macPtr, u32 bufferPtr) {
DEBUG_LOG(HLE, "sceNetEtherNtostr(%08x, %08x)", macPtr, bufferPtr);
@ -368,85 +212,6 @@ int sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
}
}
// Seems to always return 0, and write 0 to the pointer..
// TODO: Eventually research what possible states there are
int sceNetAdhocctlGetState(u32 ptrToStatus) {
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus);
if(Memory::IsValidAddress(ptrToStatus))
Memory::Write_U32(0, ptrToStatus);
else
ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x): Tried to write invalid location", ptrToStatus);
return 0;
}
// Always return -1 since we don't have any real networking...
int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpCreate(%s, %x, %x, %x)", mac, port, bufferSize, unknown);
return -1;
}
// TODO: Should we really write the struct if we're disconnected?
int sceNetAdhocctlGetParameter(u32 paramAddr) {
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetParameter(%x)", paramAddr);
struct SceNetAdhocctlParams params;
params.channel = 0;
for(int i = 0; i < 6; i++)
params.bssid[i] = i + 1;
strcpy(params.name, "");
strcpy(params.nickname, "");
if(Memory::IsValidAddress(paramAddr))
Memory::WriteStruct(paramAddr, &params);
return ERROR_NET_ADHOCCTL_DISCONNECTED;
}
// Return -1 packets since we don't have networking yet..
int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpRecv(%d, %s, %d, %p, %p, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock);
return -1;
}
// Assuming < 0 for failure, homebrew SDK doesn't have much to say about this one..
int sceNetAdhocSetSocketAlert(int id, int flag) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocSetSocketAlert(%d, %d)", id, flag);
return -1;
}
int sceNetAdhocPdpDelete(int id, int unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpDelete(%d, %d)", id, unknown);
return 0;
}
int sceNetAdhocctlGetAdhocId(u32 productStructAddr) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId(%x)", productStructAddr);
return 0;
}
int sceNetAdhocctlScan() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlScan()");
__UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF);
return 0;
}
int sceNetAdhocctlGetScanInfo() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetScanInfo()");
return 0;
}
int sceNetAdhocctlConnect(u32 ptrToGroupName) {
if (Memory::IsValidAddress(ptrToGroupName))
{
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(groupName=%s)", Memory::GetCharPointer(ptrToGroupName));
}
else
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName);
__UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF);
return 0;
}
// Write static data since we don't actually manage any memory for sceNet* yet.
int sceNetGetMallocStat(u32 statPtr) {
@ -459,15 +224,6 @@ int sceNetGetMallocStat(u32 statPtr) {
return 0;
}
int sceNetAdhocMatchingInit(u32 memsize) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingInit(%08x)", memsize);
if(netAdhocMatchingInited)
return ERROR_NET_ADHOC_MATCHING_ALREADY_INITIALIZED;
netAdhocMatchingInited = true;
return 0;
}
int sceNetInetInit() {
ERROR_LOG(HLE, "UNIMPL sceNetInetInit()");
if (netInetInited)
@ -486,7 +242,7 @@ int sceNetInetTerm() {
int sceNetApctlInit() {
ERROR_LOG(HLE, "UNIMPL sceNetApctlInit()");
if (netAdhocInited)
if (netApctlInited)
return ERROR_NET_APCTL_ALREADY_INITIALIZED;
netApctlInited = true;
@ -595,88 +351,6 @@ const HLEFunction sceNet[] = {
{0xad6844c6, 0, "sceNetThreadAbort"},
};
const HLEFunction sceNetAdhoc[] = {
{0xE1D621D7, WrapU_V<sceNetAdhocInit>, "sceNetAdhocInit"},
{0xA62C6F57, WrapI_V<sceNetAdhocTerm>, "sceNetAdhocTerm"},
{0x0AD043ED, 0, "sceNetAdhocctlConnect"},
{0x6f92741b, WrapI_CUIU<sceNetAdhocPdpCreate>, "sceNetAdhocPdpCreate"},
{0xabed3790, 0, "sceNetAdhocPdpSend"},
{0xdfe53e03, WrapI_ICUVVUI<sceNetAdhocPdpRecv>, "sceNetAdhocPdpRecv"},
{0x7f27bb5e, WrapI_II<sceNetAdhocPdpDelete>, "sceNetAdhocPdpDelete"},
{0xc7c1fc57, 0, "sceNetAdhocGetPdpStat"},
{0x157e6225, 0, "sceNetAdhocPtpClose"},
{0x4da4c788, 0, "sceNetAdhocPtpSend"},
{0x877f6d66, 0, "sceNetAdhocPtpOpen"},
{0x8bea2b3e, 0, "sceNetAdhocPtpRecv"},
{0x9df81198, 0, "sceNetAdhocPtpAccept"},
{0xe08bdac1, 0, "sceNetAdhocPtpListen"},
{0xfc6fc07b, 0, "sceNetAdhocPtpConnect"},
{0x9ac2eeac, 0, "sceNetAdhocPtpFlush"},
{0xb9685118, 0, "sceNetAdhocGetPtpStat"},
{0x3278ab0c, 0, "sceNetAdhocGameModeCreateReplica"},
{0x98c204c8, 0, "sceNetAdhocGameModeUpdateMaster"},
{0xfa324b4e, 0, "sceNetAdhocGameModeUpdateReplica"},
{0xa0229362, 0, "sceNetAdhocGameModeDeleteMaster"},
{0x0b2228e9, 0, "sceNetAdhocGameModeDeleteReplica"},
{0x7F75C338, 0, "sceNetAdhocGameModeCreateMaster"},
{0x73bfd52d, WrapI_II<sceNetAdhocSetSocketAlert>, "sceNetAdhocSetSocketAlert"},
{0x7a662d6b, 0, "sceNetAdhocPollSocket"},
{0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"},
};
const HLEFunction sceNetAdhocMatching[] = {
{0x2a2a1e07, WrapI_U<sceNetAdhocMatchingInit>, "sceNetAdhocMatchingInit"},
{0x7945ecda, WrapI_V<sceNetAdhocMatchingTerm>, "sceNetAdhocMatchingTerm"},
{0xca5eda6f, 0, "sceNetAdhocMatchingCreate"},
{0x93ef3843, 0, "sceNetAdhocMatchingStart"},
{0x32b156b3, 0, "sceNetAdhocMatchingStop"},
{0xf16eaf4f, 0, "sceNetAdhocMatchingDelete"},
{0x5e3d4b79, 0, "sceNetAdhocMatchingSelectTarget"},
{0xea3c6108, 0, "sceNetAdhocMatchingCancelTarget"},
{0x8f58bedf, 0, "sceNetAdhocMatchingCancelTargetWithOpt"},
{0xb58e61b7, 0, "sceNetAdhocMatchingSetHelloOpt"},
{0xc58bcd9e, 0, "sceNetAdhocMatchingGetMembers"},
{0xec19337d, 0, "sceNetAdhocMatchingAbortSendData"},
{0xf79472d7, 0, "sceNetAdhocMatchingSendData"},
{0x40F8F435, 0, "sceNetAdhocMatchingGetPoolMaxAlloc"},
{0xb5d96c2a, 0, "sceNetAdhocMatchingGetHelloOpt"},
{0x9c5cfb7d, 0, "sceNetAdhocMatchingGetPoolStat"},
};
const HLEFunction sceNetAdhocctl[] = {
{0xE26F226E, WrapU_IIU<sceNetAdhocctlInit>, "sceNetAdhocctlInit"},
{0x9D689E13, WrapI_V<sceNetAdhocctlTerm>, "sceNetAdhocctlTerm"},
{0x20B317A0, WrapU_UU<sceNetAdhocctlAddHandler>, "sceNetAdhocctlAddHandler"},
{0x6402490B, WrapU_U<sceNetAdhocctlDelHandler>, "sceNetAdhocctlDelHandler"},
{0x34401D65, WrapU_V<sceNetAdhocctlDisconnect>, "sceNetAdhocctlDisconnect"},
{0x0ad043ed, WrapI_U<sceNetAdhocctlConnect>, "sceNetAdhocctlConnect"},
{0x08fff7a0, WrapI_V<sceNetAdhocctlScan>, "sceNetAdhocctlScan"},
{0x75ecd386, WrapI_U<sceNetAdhocctlGetState>, "sceNetAdhocctlGetState"},
{0x8916c003, 0, "sceNetAdhocctlGetNameByAddr"},
{0xded9d28e, WrapI_U<sceNetAdhocctlGetParameter>, "sceNetAdhocctlGetParameter"},
{0x81aee1be, WrapI_V<sceNetAdhocctlGetScanInfo>, "sceNetAdhocctlGetScanInfo"},
{0x5e7f79c9, 0, "sceNetAdhocctlJoin"},
{0x8db83fdc, 0, "sceNetAdhocctlGetPeerInfo"},
{0xec0635c1, 0, "sceNetAdhocctlCreate"},
{0xa5c055ce, 0, "sceNetAdhocctlCreateEnterGameMode"},
{0x1ff89745, 0, "sceNetAdhocctlJoinEnterGameMode"},
{0xcf8e084d, 0, "sceNetAdhocctlExitGameMode"},
{0xe162cb14, 0, "sceNetAdhocctlGetPeerList"},
{0x362cbe8f, WrapI_U<sceNetAdhocctlGetAdhocId>, "sceNetAdhocctlGetAdhocId"},
{0x5a014ce0, 0, "sceNetAdhocctlGetGameModeInfo"},
{0x99560abe, 0, "sceNetAdhocctlGetAddrByName"},
{0xb0b80e80, 0, "sceNetAdhocctlCreateEnterGameModeMin"},
};
const HLEFunction sceNetAdhocDiscover[] = {
{0x941B3877, 0, "sceNetAdhocDiscoverInitStart"},
{0x52DE1B97, 0, "sceNetAdhocDiscoverUpdate"},
{0x944DDBC6, 0, "sceNetAdhocDiscoverGetStatus"},
{0xA2246614, 0, "sceNetAdhocDiscoverTerm"},
{0xF7D13214, 0, "sceNetAdhocDiscoverStop"},
{0xA423A21B, 0, "sceNetAdhocDiscoverRequestSuspend"},
};
const HLEFunction sceNetResolver[] = {
{0x224c5f44, 0, "sceNetResolverStartNtoA"},
{0x244172af, 0, "sceNetResolverCreate"},
@ -750,10 +424,6 @@ const HLEFunction sceWlanDrv[] = {
void Register_sceNet() {
RegisterModule("sceNet", ARRAY_SIZE(sceNet), sceNet);
RegisterModule("sceNetAdhoc", ARRAY_SIZE(sceNetAdhoc), sceNetAdhoc);
RegisterModule("sceNetAdhocMatching", ARRAY_SIZE(sceNetAdhocMatching), sceNetAdhocMatching);
RegisterModule("sceNetAdhocDiscover", ARRAY_SIZE(sceNetAdhocDiscover), sceNetAdhocDiscover);
RegisterModule("sceNetAdhocctl", ARRAY_SIZE(sceNetAdhocctl), sceNetAdhocctl);
RegisterModule("sceNetResolver", ARRAY_SIZE(sceNetResolver), sceNetResolver);
RegisterModule("sceNetInet", ARRAY_SIZE(sceNetInet), sceNetInet);
RegisterModule("sceNetApctl", ARRAY_SIZE(sceNetApctl), sceNetApctl);

379
Core/HLE/sceNetAdhoc.cpp Normal file
View File

@ -0,0 +1,379 @@
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Core/HLE/HLE.h"
#include "Core/HLE/sceNetAdhoc.h"
#include "sceKernel.h"
#include "sceKernelThread.h"
#include "sceKernelMutex.h"
#include "sceUtility.h"
#include "net/resolve.h"
enum {
ERROR_NET_ADHOC_INVALID_SOCKET_ID = 0x80410701,
ERROR_NET_ADHOC_INVALID_ADDR = 0x80410702,
ERROR_NET_ADHOC_NO_DATA_AVAILABLE = 0x80410709,
ERROR_NET_ADHOC_PORT_IN_USE = 0x8041070a,
ERROR_NET_ADHOC_NOT_INITIALIZED = 0x80410712,
ERROR_NET_ADHOC_ALREADY_INITIALIZED = 0x80410713,
ERROR_NET_ADHOC_DISCONNECTED = 0x8041070c,
ERROR_NET_ADHOC_TIMEOUT = 0x80410715,
ERROR_NET_ADHOC_NO_ENTRY = 0x80410716,
ERROR_NET_ADHOC_CONNECTION_REFUSED = 0x80410718,
ERROR_NET_ADHOC_INVALID_MATCHING_ID = 0x80410807,
ERROR_NET_ADHOC_MATCHING_ALREADY_INITIALIZED = 0x80410812,
ERROR_NET_ADHOC_MATCHING_NOT_INITIALIZED = 0x80410813,
ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF = 0x80410b03,
ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED = 0x80410b07,
ERROR_NET_ADHOCCTL_NOT_INITIALIZED = 0x80410b08,
ERROR_NET_ADHOCCTL_DISCONNECTED = 0x80410b09,
ERROR_NET_ADHOCCTL_BUSY = 0x80410b10,
ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12,
};
const size_t MAX_ADHOCCTL_HANDLERS = 32;
static bool netAdhocInited;
static bool netAdhocctlInited;
static bool netAdhocMatchingInited;
// These might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc..
struct SceNetAdhocctlParams {
s32_le channel; //which ad-hoc channel to connect to
char name[8]; //connection name
u8 bssid[6]; //BSSID of the connection?
char nickname[128]; //PSP's nickname?
};
struct AdhocctlHandler {
u32 entryPoint;
u32 argument;
};
static std::map<int, AdhocctlHandler> adhocctlHandlers;
void __NetAdhocInit() {
netAdhocInited = false;
netAdhocctlInited = false;
netAdhocMatchingInited = false;
adhocctlHandlers.clear();
}
void __NetAdhocShutdown() {
}
void __NetAdhocDoState(PointerWrap &p) {
p.Do(netAdhocInited);
p.Do(netAdhocctlInited);
p.Do(netAdhocMatchingInited);
p.Do(adhocctlHandlers);
p.DoMarker("netadhoc");
}
void __UpdateAdhocctlHandlers(int flag, int error) {
u32 args[3] = { 0, 0, 0 };
args[0] = flag;
args[1] = error;
for(std::map<int, AdhocctlHandler>::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); ++it) {
args[2] = it->second.argument;
__KernelDirectMipsCall(it->second.entryPoint, NULL, args, 3, true);
}
}
u32 sceNetAdhocInit() {
ERROR_LOG(HLE,"UNIMPL sceNetAdhocInit()");
if (netAdhocInited)
return ERROR_NET_ADHOC_ALREADY_INITIALIZED;
netAdhocInited = true;
return 0;
}
u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) {
ERROR_LOG(HLE,"UNIMPL sceNetAdhocctlInit(%i, %i, %08x)", stackSize, prio, productAddr);
if(netAdhocctlInited)
return ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED;
netAdhocctlInited = true;
return 0;
}
// Seems to always return 0, and write 0 to the pointer..
// TODO: Eventually research what possible states there are
int sceNetAdhocctlGetState(u32 ptrToStatus) {
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus);
if(Memory::IsValidAddress(ptrToStatus))
Memory::Write_U32(0, ptrToStatus);
else
ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x): Tried to write invalid location", ptrToStatus);
return 0;
}
// Always return -1 since we don't have any real networking...
int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpCreate(%s, %x, %x, %x)", mac, port, bufferSize, unknown);
return -1;
}
// TODO: Should we really write the struct if we're disconnected?
int sceNetAdhocctlGetParameter(u32 paramAddr) {
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetParameter(%x)", paramAddr);
struct SceNetAdhocctlParams params;
params.channel = 0;
for(int i = 0; i < 6; i++)
params.bssid[i] = i + 1;
strcpy(params.name, "");
strcpy(params.nickname, "");
if(Memory::IsValidAddress(paramAddr))
Memory::WriteStruct(paramAddr, &params);
return ERROR_NET_ADHOCCTL_DISCONNECTED;
}
// Return -1 packets since we don't have networking yet..
int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpRecv(%d, %s, %d, %p, %p, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock);
return -1;
}
// Assuming < 0 for failure, homebrew SDK doesn't have much to say about this one..
int sceNetAdhocSetSocketAlert(int id, int flag) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocSetSocketAlert(%d, %d)", id, flag);
return -1;
}
int sceNetAdhocPdpDelete(int id, int unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpDelete(%d, %d)", id, unknown);
return 0;
}
int sceNetAdhocctlGetAdhocId(u32 productStructAddr) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId(%x)", productStructAddr);
return 0;
}
int sceNetAdhocctlScan() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlScan()");
__UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF);
return 0;
}
int sceNetAdhocctlGetScanInfo() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetScanInfo()");
return 0;
}
int sceNetAdhocctlConnect(u32 ptrToGroupName) {
if (Memory::IsValidAddress(ptrToGroupName))
{
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(groupName=%s)", Memory::GetCharPointer(ptrToGroupName));
}
else
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName);
__UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF);
return 0;
}
// TODO: How many handlers can the PSP actually have for Adhocctl?
// TODO: Should we allow the same handler to be added more than once?
u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 handlerArg) {
bool foundHandler = false;
u32 retval = 0;
struct AdhocctlHandler handler;
memset(&handler, 0, sizeof(handler));
while (adhocctlHandlers.find(retval) != adhocctlHandlers.end())
++retval;
handler.entryPoint = handlerPtr;
handler.argument = handlerArg;
for(std::map<int, AdhocctlHandler>::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); it++) {
if(it->second.entryPoint == handlerPtr) {
foundHandler = true;
break;
}
}
if(!foundHandler && Memory::IsValidAddress(handlerPtr)) {
if(adhocctlHandlers.size() >= MAX_ADHOCCTL_HANDLERS) {
ERROR_LOG(HLE, "UNTESTED UNTESTED sceNetAdhocctlAddHandler(%x, %x): Too many handlers", handlerPtr, handlerArg);
retval = ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS;
return retval;
}
adhocctlHandlers[retval] = handler;
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, retval);
}
else
ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Same handler already exists", handlerPtr, handlerArg);
// The id to return is the number of handlers currently registered
return retval;
}
u32 sceNetAdhocctlDisconnect() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()");
__UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF);
return 0;
}
u32 sceNetAdhocctlDelHandler(u32 handlerID) {
if(adhocctlHandlers.find(handlerID) != adhocctlHandlers.end()) {
adhocctlHandlers.erase(handlerID);
WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%d): deleted handler %d", handlerID, handlerID);
}
else
ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%d): asked to delete invalid handler %d", handlerID, handlerID);
return 0;
}
int sceNetAdhocctlTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlTerm()");
netAdhocctlInited = false;
return 0;
}
int sceNetAdhocTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocTerm()");
// Seems to return this when called a second time after being terminated without another initialisation
if(!netAdhocInited)
return SCE_KERNEL_ERROR_LWMUTEX_NOT_FOUND;
netAdhocInited = false;
return 0;
}
int sceNetAdhocMatchingInit(u32 memsize) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingInit(%08x)", memsize);
if(netAdhocMatchingInited)
return ERROR_NET_ADHOC_MATCHING_ALREADY_INITIALIZED;
netAdhocMatchingInited = true;
return 0;
}
int sceNetAdhocMatchingTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingTerm()");
netAdhocMatchingInited = false;
return 0;
}
const HLEFunction sceNetAdhoc[] = {
{0xE1D621D7, WrapU_V<sceNetAdhocInit>, "sceNetAdhocInit"},
{0xA62C6F57, WrapI_V<sceNetAdhocTerm>, "sceNetAdhocTerm"},
{0x0AD043ED, 0, "sceNetAdhocctlConnect"},
{0x6f92741b, WrapI_CUIU<sceNetAdhocPdpCreate>, "sceNetAdhocPdpCreate"},
{0xabed3790, 0, "sceNetAdhocPdpSend"},
{0xdfe53e03, WrapI_ICUVVUI<sceNetAdhocPdpRecv>, "sceNetAdhocPdpRecv"},
{0x7f27bb5e, WrapI_II<sceNetAdhocPdpDelete>, "sceNetAdhocPdpDelete"},
{0xc7c1fc57, 0, "sceNetAdhocGetPdpStat"},
{0x157e6225, 0, "sceNetAdhocPtpClose"},
{0x4da4c788, 0, "sceNetAdhocPtpSend"},
{0x877f6d66, 0, "sceNetAdhocPtpOpen"},
{0x8bea2b3e, 0, "sceNetAdhocPtpRecv"},
{0x9df81198, 0, "sceNetAdhocPtpAccept"},
{0xe08bdac1, 0, "sceNetAdhocPtpListen"},
{0xfc6fc07b, 0, "sceNetAdhocPtpConnect"},
{0x9ac2eeac, 0, "sceNetAdhocPtpFlush"},
{0xb9685118, 0, "sceNetAdhocGetPtpStat"},
{0x3278ab0c, 0, "sceNetAdhocGameModeCreateReplica"},
{0x98c204c8, 0, "sceNetAdhocGameModeUpdateMaster"},
{0xfa324b4e, 0, "sceNetAdhocGameModeUpdateReplica"},
{0xa0229362, 0, "sceNetAdhocGameModeDeleteMaster"},
{0x0b2228e9, 0, "sceNetAdhocGameModeDeleteReplica"},
{0x7F75C338, 0, "sceNetAdhocGameModeCreateMaster"},
{0x73bfd52d, WrapI_II<sceNetAdhocSetSocketAlert>, "sceNetAdhocSetSocketAlert"},
{0x7a662d6b, 0, "sceNetAdhocPollSocket"},
{0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"},
};
const HLEFunction sceNetAdhocMatching[] = {
{0x2a2a1e07, WrapI_U<sceNetAdhocMatchingInit>, "sceNetAdhocMatchingInit"},
{0x7945ecda, WrapI_V<sceNetAdhocMatchingTerm>, "sceNetAdhocMatchingTerm"},
{0xca5eda6f, 0, "sceNetAdhocMatchingCreate"},
{0x93ef3843, 0, "sceNetAdhocMatchingStart"},
{0x32b156b3, 0, "sceNetAdhocMatchingStop"},
{0xf16eaf4f, 0, "sceNetAdhocMatchingDelete"},
{0x5e3d4b79, 0, "sceNetAdhocMatchingSelectTarget"},
{0xea3c6108, 0, "sceNetAdhocMatchingCancelTarget"},
{0x8f58bedf, 0, "sceNetAdhocMatchingCancelTargetWithOpt"},
{0xb58e61b7, 0, "sceNetAdhocMatchingSetHelloOpt"},
{0xc58bcd9e, 0, "sceNetAdhocMatchingGetMembers"},
{0xec19337d, 0, "sceNetAdhocMatchingAbortSendData"},
{0xf79472d7, 0, "sceNetAdhocMatchingSendData"},
{0x40F8F435, 0, "sceNetAdhocMatchingGetPoolMaxAlloc"},
{0xb5d96c2a, 0, "sceNetAdhocMatchingGetHelloOpt"},
{0x9c5cfb7d, 0, "sceNetAdhocMatchingGetPoolStat"},
};
const HLEFunction sceNetAdhocctl[] = {
{0xE26F226E, WrapU_IIU<sceNetAdhocctlInit>, "sceNetAdhocctlInit"},
{0x9D689E13, WrapI_V<sceNetAdhocctlTerm>, "sceNetAdhocctlTerm"},
{0x20B317A0, WrapU_UU<sceNetAdhocctlAddHandler>, "sceNetAdhocctlAddHandler"},
{0x6402490B, WrapU_U<sceNetAdhocctlDelHandler>, "sceNetAdhocctlDelHandler"},
{0x34401D65, WrapU_V<sceNetAdhocctlDisconnect>, "sceNetAdhocctlDisconnect"},
{0x0ad043ed, WrapI_U<sceNetAdhocctlConnect>, "sceNetAdhocctlConnect"},
{0x08fff7a0, WrapI_V<sceNetAdhocctlScan>, "sceNetAdhocctlScan"},
{0x75ecd386, WrapI_U<sceNetAdhocctlGetState>, "sceNetAdhocctlGetState"},
{0x8916c003, 0, "sceNetAdhocctlGetNameByAddr"},
{0xded9d28e, WrapI_U<sceNetAdhocctlGetParameter>, "sceNetAdhocctlGetParameter"},
{0x81aee1be, WrapI_V<sceNetAdhocctlGetScanInfo>, "sceNetAdhocctlGetScanInfo"},
{0x5e7f79c9, 0, "sceNetAdhocctlJoin"},
{0x8db83fdc, 0, "sceNetAdhocctlGetPeerInfo"},
{0xec0635c1, 0, "sceNetAdhocctlCreate"},
{0xa5c055ce, 0, "sceNetAdhocctlCreateEnterGameMode"},
{0x1ff89745, 0, "sceNetAdhocctlJoinEnterGameMode"},
{0xcf8e084d, 0, "sceNetAdhocctlExitGameMode"},
{0xe162cb14, 0, "sceNetAdhocctlGetPeerList"},
{0x362cbe8f, WrapI_U<sceNetAdhocctlGetAdhocId>, "sceNetAdhocctlGetAdhocId"},
{0x5a014ce0, 0, "sceNetAdhocctlGetGameModeInfo"},
{0x99560abe, 0, "sceNetAdhocctlGetAddrByName"},
{0xb0b80e80, 0, "sceNetAdhocctlCreateEnterGameModeMin"},
};
const HLEFunction sceNetAdhocDiscover[] = {
{0x941B3877, 0, "sceNetAdhocDiscoverInitStart"},
{0x52DE1B97, 0, "sceNetAdhocDiscoverUpdate"},
{0x944DDBC6, 0, "sceNetAdhocDiscoverGetStatus"},
{0xA2246614, 0, "sceNetAdhocDiscoverTerm"},
{0xF7D13214, 0, "sceNetAdhocDiscoverStop"},
{0xA423A21B, 0, "sceNetAdhocDiscoverRequestSuspend"},
};
void Register_sceNetAdhoc() {
RegisterModule("sceNetAdhoc", ARRAY_SIZE(sceNetAdhoc), sceNetAdhoc);
RegisterModule("sceNetAdhocMatching", ARRAY_SIZE(sceNetAdhocMatching), sceNetAdhocMatching);
RegisterModule("sceNetAdhocDiscover", ARRAY_SIZE(sceNetAdhocDiscover), sceNetAdhocDiscover);
RegisterModule("sceNetAdhocctl", ARRAY_SIZE(sceNetAdhocctl), sceNetAdhocctl);
}

26
Core/HLE/sceNetAdhoc.h Normal file
View File

@ -0,0 +1,26 @@
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "Common/ChunkFile.h"
void Register_sceNetAdhoc();
void __NetAdhocInit();
void __NetAdhocShutdown();
void __NetAdhocDoState(PointerWrap &p);

View File

@ -282,6 +282,7 @@ LOCAL_SRC_FILES := \
$(SRC)/Core/HLE/sceMp4.cpp \
$(SRC)/Core/HLE/sceMp3.cpp \
$(SRC)/Core/HLE/sceNet.cpp \
$(SRC)/Core/HLE/sceNetAdhoc.cpp \
$(SRC)/Core/HLE/sceOpenPSID.cpp \
$(SRC)/Core/HLE/sceP3da.cpp \
$(SRC)/Core/HLE/sceParseHttp.cpp \