From b02dbe3f5fae0c7393216852d3fad23f321f7102 Mon Sep 17 00:00:00 2001 From: The Dax Date: Tue, 4 Jun 2013 00:39:03 -0400 Subject: [PATCH 1/3] Add a multitude of sceNet* stubs. I tried this in an attempt to fix the Peace Walker hangs, but it didn't seem to help, so it must be related to something else. --- Core/HLE/FunctionWrappers.h | 16 ++++- Core/HLE/sceNet.cpp | 125 ++++++++++++++++++++++++++++++++---- 2 files changed, 126 insertions(+), 15 deletions(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index d7c72d1a1f..d946126989 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -18,7 +18,7 @@ #pragma once #include "../../Globals.h" - +#include "sceNet.h" //TODO: How do I make this not reliant on sceNet? :\ // For easy parameter parsing and return value processing. // 64bit wrappers @@ -92,6 +92,16 @@ template void WrapU_IVI() { RETURN(retval); } +template void WrapI_ICUVVUI() { + u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); + RETURN(retval); +} + +template void WrapU_IV() { + u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1))); + RETURN(retval); +} + template void WrapF_V() { RETURNF(func()); } @@ -480,6 +490,10 @@ template void WrapV_CUIU() { func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); } +template void WrapV_CU() { + func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); +} + template void WrapI_CUIU() { int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); RETURN(retval); diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index e334a5c76e..9527b8d4a1 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -52,6 +52,21 @@ enum { ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12, }; +//these might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc +typedef struct SceNetAdhocctlParams +{ + int 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? +}; + +typedef struct ProductStruct +{ + int unknown; //unknown, set to 0 + char product[9]; //Product name? +}; + void __NetInit() { netInited = false; netAdhocInited = false; @@ -114,11 +129,93 @@ u32 sceWlanGetSwitchState() { return 0; } +//handler probably shouldn't be an int... +u32 sceNetAdhocctlAddHandler(int handler, void *unknown) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlAddHandler(%x, %x)", handler, unknown); + return 0; +} + +u32 sceNetAdhocctlDisconnect() { + DEBUG_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()"); + return 0; +} + +u32 sceNetAdhocctlDelHandler(int handler) { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDelHandler(%x)", handler); + return 0; +} + +int sceNetAdhocMatchingTerm() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingTerm()"); + return 0; +} + +int sceNetAdhocctlTerm() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlTerm()"); + return 0; +} + +int sceNetAdhocTerm() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocTerm()"); + return 0; +} + +void sceNetEtherNtostr(const char *mac, u32 bufferPtr) { + DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr); + int len = strlen(mac); + for (int i = 0; i < len; i++) + Memory::Write_U8(mac[i], bufferPtr + i); +} + +//write SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED to attempt to stop games from spamming wifi syscalls... +int sceNetAdhocctlGetState(u32 ptrToStatus) { + DEBUG_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus); + Memory::Write_U32(SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED, 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 sceNetAdhocctlAddHandler(%s, %x, %x, %x)", mac, port, bufferSize, unknown); + return -1; +} + +//SHOULD be int sceNetAdhocctlGetParameter(struct SceNetAdhocctlParams *params), but I don't want +//to mess up the function wrappers.. +int sceNetAdhocctlGetParameter() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetParameter()"); + return -1; +} + +//SHOULD be int sceNetAdhocctlGetAdhocId(struct productStruct * product), but I don't want +//to mess up the function wrappers.. +int sceNetAdhocctlGetAdhocId() { + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId()"); + return -1; +} + +//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, %d, %d, %x, %x, %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; +} + const HLEFunction sceNet[] = { {0x39AF39A6, sceNetInit, "sceNetInit"}, {0x281928A9, WrapU_V, "sceNetTerm"}, - {0x89360950, 0, "sceNetEtherNtostr"}, + {0x89360950, WrapV_CU, "sceNetEtherNtostr"}, {0x0bf0a3ae, 0, "sceNetGetLocalEtherAddr"}, {0xd27961c9, 0, "sceNetEtherStrton"}, {0x50647530, 0, "sceNetFreeThreadinfo"}, @@ -129,12 +226,12 @@ const HLEFunction sceNet[] = const HLEFunction sceNetAdhoc[] = { {0xE1D621D7, WrapU_V, "sceNetAdhocInit"}, - {0xA62C6F57, 0, "sceNetAdhocTerm"}, + {0xA62C6F57, WrapI_V, "sceNetAdhocTerm"}, {0x0AD043ED, 0, "sceNetAdhocctlConnect"}, - {0x6f92741b, 0, "sceNetAdhocPdpCreate"}, + {0x6f92741b, WrapI_CUIU, "sceNetAdhocPdpCreate"}, {0xabed3790, 0, "sceNetAdhocPdpSend"}, - {0xdfe53e03, 0, "sceNetAdhocPdpRecv"}, - {0x7f27bb5e, 0, "sceNetAdhocPdpDelete"}, + {0xdfe53e03, WrapI_ICUVVUI, "sceNetAdhocPdpRecv"}, + {0x7f27bb5e, WrapI_II, "sceNetAdhocPdpDelete"}, {0xc7c1fc57, 0, "sceNetAdhocGetPdpStat"}, {0x157e6225, 0, "sceNetAdhocPtpClose"}, {0x4da4c788, 0, "sceNetAdhocPtpSend"}, @@ -151,7 +248,7 @@ const HLEFunction sceNetAdhoc[] = {0xa0229362, 0, "sceNetAdhocGameModeDeleteMaster"}, {0x0b2228e9, 0, "sceNetAdhocGameModeDeleteReplica"}, {0x7F75C338, 0, "sceNetAdhocGameModeCreateMaster"}, - {0x73bfd52d, 0, "sceNetAdhocSetSocketAlert"}, + {0x73bfd52d, WrapI_II, "sceNetAdhocSetSocketAlert"}, {0x7a662d6b, 0, "sceNetAdhocPollSocket"}, {0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"}, }; @@ -164,7 +261,7 @@ int sceNetAdhocMatchingInit(u32 memsize) { const HLEFunction sceNetAdhocMatching[] = { {0x2a2a1e07, WrapI_U, "sceNetAdhocMatchingInit"}, - {0x7945ecda, 0, "sceNetAdhocMatchingTerm"}, + {0x7945ecda, WrapI_V, "sceNetAdhocMatchingTerm"}, {0xca5eda6f, 0, "sceNetAdhocMatchingCreate"}, {0x93ef3843, 0, "sceNetAdhocMatchingStart"}, {0x32b156b3, 0, "sceNetAdhocMatchingStop"}, @@ -184,15 +281,15 @@ const HLEFunction sceNetAdhocMatching[] = const HLEFunction sceNetAdhocctl[] = { {0xE26F226E, WrapU_IIU, "sceNetAdhocctlInit"}, - {0x9D689E13, 0, "sceNetAdhocctlTerm"}, - {0x20B317A0, 0, "sceNetAdhocctlAddHandler"}, - {0x6402490B, 0, "sceNetAdhocctlDelHandler"}, - {0x34401D65, 0, "sceNetAdhocctlDisconnect"}, + {0x9D689E13, WrapI_V, "sceNetAdhocctlTerm"}, + {0x20B317A0, WrapU_IV, "sceNetAdhocctlAddHandler"}, + {0x6402490B, WrapU_I, "sceNetAdhocctlDelHandler"}, + {0x34401D65, WrapU_V, "sceNetAdhocctlDisconnect"}, {0x0ad043ed, 0, "sceNetAdhocctlConnect"}, {0x08fff7a0, 0, "sceNetAdhocctlScan"}, - {0x75ecd386, 0, "sceNetAdhocctlGetState"}, + {0x75ecd386, WrapI_U, "sceNetAdhocctlGetState"}, {0x8916c003, 0, "sceNetAdhocctlGetNameByAddr"}, - {0xded9d28e, 0, "sceNetAdhocctlGetParameter"}, + {0xded9d28e, WrapI_V, "sceNetAdhocctlGetParameter"}, {0x81aee1be, 0, "sceNetAdhocctlGetScanInfo"}, {0x5e7f79c9, 0, "sceNetAdhocctlJoin"}, {0x8db83fdc, 0, "sceNetAdhocctlGetPeerInfo"}, @@ -201,7 +298,7 @@ const HLEFunction sceNetAdhocctl[] = {0x1ff89745, 0, "sceNetAdhocctlJoinEnterGameMode"}, {0xcf8e084d, 0, "sceNetAdhocctlExitGameMode"}, {0xe162cb14, 0, "sceNetAdhocctlGetPeerList"}, - {0x362cbe8f, 0, "sceNetAdhocctlGetAdhocId"}, + {0x362cbe8f, WrapI_V, "sceNetAdhocctlGetAdhocId"}, {0x5a014ce0, 0, "sceNetAdhocctlGetGameModeInfo"}, {0x99560abe, 0, "sceNetAdhocctlGetAddrByName"}, {0xb0b80e80, 0, "sceNetAdhocctlCreateEnterGameModeMin"}, From 50dc015d44ae3eb2515a3dd4530e7acf22a0d4f8 Mon Sep 17 00:00:00 2001 From: The Dax Date: Tue, 4 Jun 2013 00:41:50 -0400 Subject: [PATCH 2/3] Remove useless dependency in FunctionWrappers.h. --- Core/HLE/FunctionWrappers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index d946126989..6ac01e8f81 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -18,7 +18,6 @@ #pragma once #include "../../Globals.h" -#include "sceNet.h" //TODO: How do I make this not reliant on sceNet? :\ // For easy parameter parsing and return value processing. // 64bit wrappers From fadea64ebfe659fc13a4e2b2b5b44116c812639a Mon Sep 17 00:00:00 2001 From: The Dax Date: Tue, 4 Jun 2013 01:53:32 -0400 Subject: [PATCH 3/3] Fix sceNetEtherNtostr. --- Core/HLE/FunctionWrappers.h | 4 ---- Core/HLE/sceNet.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 6ac01e8f81..5952f68d55 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -489,10 +489,6 @@ template void WrapV_CUIU() { func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); } -template void WrapV_CU() { - func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); -} - template void WrapI_CUIU() { int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); RETURN(retval); diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 9527b8d4a1..d3df74d981 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -160,11 +160,14 @@ int sceNetAdhocTerm() { return 0; } -void sceNetEtherNtostr(const char *mac, u32 bufferPtr) { +//homebrew SDK claims it's a void function, but tests seem to indicate otherwise +int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr); int len = strlen(mac); for (int i = 0; i < len; i++) Memory::Write_U8(mac[i], bufferPtr + i); + + return 0; } //write SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED to attempt to stop games from spamming wifi syscalls... @@ -215,7 +218,7 @@ const HLEFunction sceNet[] = { {0x39AF39A6, sceNetInit, "sceNetInit"}, {0x281928A9, WrapU_V, "sceNetTerm"}, - {0x89360950, WrapV_CU, "sceNetEtherNtostr"}, + {0x89360950, WrapI_CU, "sceNetEtherNtostr"}, {0x0bf0a3ae, 0, "sceNetGetLocalEtherAddr"}, {0xd27961c9, 0, "sceNetEtherStrton"}, {0x50647530, 0, "sceNetFreeThreadinfo"},