1 | #include <thbase.h>
|
---|
2 | #include <thevent.h>
|
---|
3 | #include <iomanX.h>
|
---|
4 | #include <stdio.h>
|
---|
5 | #include <loadcore.h>
|
---|
6 | #include <intrman.h>
|
---|
7 | #include <sys/stat.h>
|
---|
8 | #include <dev9.h>
|
---|
9 | #include <sifrpc.h>
|
---|
10 |
|
---|
11 | #include "ps2_hdd.h"
|
---|
12 | #include "hdd.h"
|
---|
13 |
|
---|
14 | int __attribute__((unused)) shutdown() { return 0; }
|
---|
15 |
|
---|
16 | /* function declaration */
|
---|
17 | void rpcMainThread(void* param);
|
---|
18 | void *rpcCommandHandler(int command, void *Data, int Size);
|
---|
19 |
|
---|
20 | static SifRpcDataQueue_t Rpc_Queue __attribute__((aligned(64)));
|
---|
21 | static SifRpcServerData_t Rpc_Server __attribute((aligned(64)));
|
---|
22 | static int Rpc_Buffer[1024] __attribute((aligned(64)));
|
---|
23 |
|
---|
24 | /* Description: Module entry point */
|
---|
25 | int _start(int argc, char **argv)
|
---|
26 | {
|
---|
27 | iop_thread_t param;
|
---|
28 | int id;
|
---|
29 |
|
---|
30 | printf("Hdl Info: PS2 HDLoader Information Module v 0.1\n");
|
---|
31 | printf("Hdl Info: 2006 Polo\n");
|
---|
32 |
|
---|
33 | printf("Hdl Info: IOP RPC Initialization.\n");
|
---|
34 | /*create thread*/
|
---|
35 | param.attr = TH_C;
|
---|
36 | param.thread = rpcMainThread;
|
---|
37 | param.priority = 40;
|
---|
38 | param.stacksize = 0x800;
|
---|
39 | param.option = 0;
|
---|
40 |
|
---|
41 | id = CreateThread(¶m);
|
---|
42 | if (id > 0) {
|
---|
43 | StartThread(id,0);
|
---|
44 | return 0;
|
---|
45 | } else
|
---|
46 | return 1;
|
---|
47 |
|
---|
48 | return MODULE_RESIDENT_END;
|
---|
49 | }
|
---|
50 |
|
---|
51 | void rpcMainThread(void* param)
|
---|
52 | {
|
---|
53 | SifInitRpc(0);
|
---|
54 | SifSetRpcQueue(&Rpc_Queue, GetThreadId());
|
---|
55 | SifRegisterRpc(&Rpc_Server, HDL_IRX, (void *) rpcCommandHandler, (u8 *) &Rpc_Buffer, 0, 0, &Rpc_Queue);
|
---|
56 | SifRpcLoop(&Rpc_Queue);
|
---|
57 | }
|
---|
58 |
|
---|
59 | void *rpcCommandHandler(int command, void *Data, int Size)
|
---|
60 | {
|
---|
61 | switch (command) {
|
---|
62 | case 4: //HDL Get Game Info
|
---|
63 | ((int *)Data)[0] = HdlGetGameInfo((char *)Data, (GameInfo *)(Data+4));
|
---|
64 | break;
|
---|
65 | case 5: //HDL Rename Game
|
---|
66 | ((int *)Data)[0] = HdlRenameGame((char*)Data);
|
---|
67 | break;
|
---|
68 | default:
|
---|
69 | break;
|
---|
70 | }
|
---|
71 | return Data;
|
---|
72 | }
|
---|