1 // Copyright (c) 2012- PPSSPP Project.
2 
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
6 
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 // GNU General Public License 2.0 for more details.
11 
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
14 
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17 
18 #include "Core/HLE/HLE.h"
19 #include "Core/HLE/FunctionWrappers.h"
20 #include "Core/HLE/proAdhoc.h"
21 #include "Core/HLE/sceOpenPSID.h"
22 #include "Core/MemMapHelpers.h"
23 
24 SceOpenPSID dummyOpenPSID = { 0x10, 0x02, 0xA3, 0x44, 0x13, 0xF5, 0x93, 0xB0, 0xCC, 0x6E, 0xD1, 0x32, 0x27, 0x85, 0x0F, 0x9D };
25 
__OpenPSIDInit()26 void __OpenPSIDInit() {
27 	// Making sure the ID is unique
28 	getLocalMac((SceNetEtherAddr*)&dummyOpenPSID);
29 	return;
30 }
31 
__OpenPSIDShutdown()32 void __OpenPSIDShutdown() {
33 
34 	return;
35 }
36 
sceOpenPSIDGetOpenPSID(u32 OpenPSIDPtr)37 static int sceOpenPSIDGetOpenPSID(u32 OpenPSIDPtr)
38 {
39 	WARN_LOG(HLE, "UNTESTED %s(%08x)", __FUNCTION__, OpenPSIDPtr);
40 
41 	if (Memory::IsValidAddress(OpenPSIDPtr))
42 	{
43 		Memory::WriteStruct(OpenPSIDPtr, &dummyOpenPSID);
44 	}
45 	return 0;
46 }
47 
sceOpenPSIDGetPSID(u32 OpenPSIDPtr,u32 unknown)48 static int sceOpenPSIDGetPSID(u32 OpenPSIDPtr,u32 unknown)
49 {
50 	WARN_LOG(HLE, "UNTESTED %s(%08x, %08x)", __FUNCTION__, OpenPSIDPtr, unknown);
51 
52 	if (Memory::IsValidAddress(OpenPSIDPtr))
53 	{
54 		Memory::WriteStruct(OpenPSIDPtr, &dummyOpenPSID);
55 	}
56 	return 0;
57 }
58 
59 /*
60 Verify if the provided signature is valid for the specified data. The public key
61 is provided by the system software.
62 
63 Note:
64 	The ECDSA algorithm is used to verify a signature.
65 
66 Parameters:
67 	pData	Pointer to data the signature has to be verified for. Data length: KIRK_ECDSA_SRC_DATA_LEN.
68 	pSig	Pointer to the signature to verify. Signature length: KIRK_ECDSA_SIG_LEN.
69 
70 Returns:
71 	0 on success, otherwise < 0.
72 */
sceDdrdb_F013F8BF(u32 pDataPtr,u32 pSigPtr)73 static s32 sceDdrdb_F013F8BF(u32 pDataPtr, u32 pSigPtr) {
74 	ERROR_LOG(HLE, "UNIMPL %s(%08x, %08x)", __FUNCTION__, pDataPtr, pSigPtr);
75 
76 	return 0;
77 }
78 
79 
80 
81 const HLEFunction sceOpenPSID[] =
82 {
83 	{0XC69BEBCE, &WrapI_U<sceOpenPSIDGetOpenPSID>,   "sceOpenPSIDGetOpenPSID", 'i', "x" },
84 };
85 
Register_sceOpenPSID()86 void Register_sceOpenPSID()
87 {
88 	RegisterModule("sceOpenPSID", ARRAY_SIZE(sceOpenPSID), sceOpenPSID);
89 }
90 
91 // According to https://playstationdev.wiki/pspprxlibraries/5.00/kd/openpsid.xml
92 // sceOpenPSID_driver library seems to contains a duplicate of sceOpenPSIDGetOpenPSID just like sceOpenPSID library, is this allowed here?
93 const HLEFunction sceOpenPSID_driver[] =
94 {
95 	{0x19D579F0, &WrapI_UU<sceOpenPSIDGetPSID>,      "sceOpenPSIDGetPSID",     'i', "xx" },
96 	{0XC69BEBCE, &WrapI_U<sceOpenPSIDGetOpenPSID>,   "sceOpenPSIDGetOpenPSID", 'i', "x"  },
97 };
98 
Register_sceOpenPSID_driver()99 void Register_sceOpenPSID_driver()
100 {
101 	RegisterModule("sceOpenPSID_driver", ARRAY_SIZE(sceOpenPSID_driver), sceOpenPSID_driver);
102 }
103 const HLEFunction sceDdrdb[] =
104 {
105 	{0xF013F8BF, &WrapI_UU<sceDdrdb_F013F8BF>,   "sceDdrdb_F013F8BF", 'i', "xx" },
106 };
107 
Register_sceDdrdb()108 void Register_sceDdrdb()
109 {
110 	RegisterModule("sceDdrdb", ARRAY_SIZE(sceDdrdb), sceDdrdb);
111 }
112