Disabling auto-refresh of game list by default, as it is causing bugs sometimes
[open-ps2-loader.git] / labs / hdldsvrlab / hdldsvrlab.c
blob56bbb5230c28c8562941bf4cf39aa50075a5837d
2 #include <tamtypes.h>
3 #include <kernel.h>
4 #include <sifrpc.h>
5 #include <loadfile.h>
6 #include <fileio.h>
7 #include <fileXio_rpc.h>
8 #include <malloc.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <sbv_patches.h>
12 #include <iopcontrol.h>
13 #include <iopheap.h>
14 #include <debug.h>
15 #include <sys/time.h>
16 #include <time.h>
18 #define IP_ADDR "192.168.0.10"
19 #define NETMASK "255.255.255.0"
20 #define GATEWAY "192.168.0.1"
22 extern void discid_irx;
23 extern int size_discid_irx;
24 extern void poweroff_irx;
25 extern int size_poweroff_irx;
26 extern void ps2dev9_irx;
27 extern int size_ps2dev9_irx;
28 extern void smsutils_irx;
29 extern int size_smsutils_irx;
30 extern void smstcpip_irx;
31 extern int size_smstcpip_irx;
32 extern void smsmap_irx;
33 extern int size_smsmap_irx;
34 extern void ps2atad_irx;
35 extern int size_ps2atad_irx;
36 extern void ps2hdd_irx;
37 extern int size_ps2hdd_irx;
38 extern void hdldsvr_irx;
39 extern int size_hdldsvr_irx;
40 extern void iomanx_irx;
41 extern int size_iomanx_irx;
42 extern void filexio_irx;
43 extern int size_filexio_irx;
45 // for IP config
46 #define IPCONFIG_MAX_LEN 64
47 static char g_ipconfig[IPCONFIG_MAX_LEN] __attribute__((aligned(64)));
48 static int g_ipconfig_len;
50 static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
52 //--------------------------------------------------------------
53 void set_ipconfig(void)
55 memset(g_ipconfig, 0, IPCONFIG_MAX_LEN);
56 g_ipconfig_len = 0;
58 strncpy(&g_ipconfig[g_ipconfig_len], IP_ADDR, 15);
59 g_ipconfig_len += strlen(IP_ADDR) + 1;
60 strncpy(&g_ipconfig[g_ipconfig_len], NETMASK, 15);
61 g_ipconfig_len += strlen(NETMASK) + 1;
62 strncpy(&g_ipconfig[g_ipconfig_len], GATEWAY, 15);
63 g_ipconfig_len += strlen(GATEWAY) + 1;
66 //--------------------------------------------------------------
67 int main(int argc, char *argv[2])
69 int ret, id;
71 init_scr();
72 scr_clear();
73 scr_printf("\t hdldsvrlab\n\n");
75 SifInitRpc(0);
77 scr_printf("\t IOP Reset... ");
79 while(!SifIopReset("rom0:UDNL rom0:EELOADCNF",0));
80 while(!SifIopSync());;
81 fioExit();
82 SifExitIopHeap();
83 SifLoadFileExit();
84 SifExitRpc();
85 SifExitCmd();
87 SifInitRpc(0);
88 FlushCache(0);
89 FlushCache(2);
91 SifLoadFileInit();
92 SifInitIopHeap();
94 sbv_patch_enable_lmb();
95 sbv_patch_disable_prefix_check();
97 SifLoadModule("rom0:SIO2MAN", 0, 0);
98 SifLoadModule("rom0:PADMAN", 0, 0);
100 scr_printf("OK\n");
102 set_ipconfig();
104 scr_printf("\t loading modules... ");
106 id = SifExecModuleBuffer(&discid_irx, size_discid_irx, 0, NULL, &ret);
107 id = SifExecModuleBuffer(&iomanx_irx, size_iomanx_irx, 0, NULL, &ret);
108 id = SifExecModuleBuffer(&filexio_irx, size_filexio_irx, 0, NULL, &ret);
109 id = SifExecModuleBuffer(&poweroff_irx, size_poweroff_irx, 0, NULL, &ret);
110 id = SifExecModuleBuffer(&ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &ret);
111 id = SifExecModuleBuffer(&smsutils_irx, size_smsutils_irx, 0, NULL, &ret);
112 id = SifExecModuleBuffer(&smstcpip_irx, size_smstcpip_irx, 0, NULL, &ret);
113 id = SifExecModuleBuffer(&smsmap_irx, size_smsmap_irx, g_ipconfig_len, g_ipconfig, &ret);
114 id = SifExecModuleBuffer(&ps2atad_irx, size_ps2atad_irx, 0, NULL, &ret);
115 id = SifExecModuleBuffer(&ps2hdd_irx, size_ps2hdd_irx, sizeof(hddarg), hddarg, &ret);
116 id = SifExecModuleBuffer(&hdldsvr_irx, size_hdldsvr_irx, 0, NULL, &ret);
118 scr_printf("OK\n");
120 fileXioInit();
122 while(1);
124 SleepThread();
125 return 0;