mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / ee_core / src / main.c
blobe294a47200ba15a7c91a9fe952e2a067ade968ca
1 /*
2 Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo
3 Copyright 2006-2008 Polo
4 Licenced under Academic Free License version 3.0
5 Review OpenUsbLd README & LICENSE files for further details.
7 Some parts of the code are taken from HD Project by Polo
8 */
10 #include "ee_core.h"
11 #include "modmgr.h"
12 #include "util.h"
13 #include "syshook.h"
15 static char ElfPath[255]; // it should be here to avoid it to be wiped by the clear user mem
17 int main(int argc, char **argv){
19 DINIT();
20 DPRINTF("OPL EE core start!\n");
22 SifInitRpc(0);
24 #ifdef LOAD_EECORE_DOWN
25 g_buf = (u8 *)0x01700000;
26 #else
27 g_buf = (u8 *)0x00088000;
28 #endif
29 DPRINTF("g_buf at 0x%08x\n", (int)g_buf);
31 argv[1][11]=0x00; // fix for 8+3 filename.
33 _strcpy(ElfPath, "cdrom0:\\");
34 _strcat(ElfPath, argv[1]);
35 _strcat(ElfPath, ";1");
36 _strcpy(GameID, argv[1]);
37 DPRINTF("Elf path = '%s'\n", ElfPath);
38 DPRINTF("Game ID = '%s'\n", GameID);
40 if (!_strncmp(argv[0], "USB_MODE", 8))
41 GameMode = USB_MODE;
42 else if (!_strncmp(argv[0], "ETH_MODE", 8))
43 GameMode = ETH_MODE;
44 else if (!_strncmp(argv[0], "HDD_MODE", 8))
45 GameMode = HDD_MODE;
46 DPRINTF("Game Mode = %d\n", GameMode);
48 DisableDebug = 0;
49 if (!_strncmp(&argv[0][9], "1", 1)) {
50 DisableDebug = 1;
51 DPRINTF("Debug color screens enabled\n");
54 char *p = _strtok(&argv[0][11], " ");
55 if (!_strncmp(p, "Browser", 7))
56 ExitPath[0] = '\0';
57 else
58 _strcpy(ExitPath, p);
59 DPRINTF("Exit Path = (%s)\n", ExitPath);
61 p = _strtok(NULL, " ");
62 USBDelay = _strtoui(p);
63 DPRINTF("USB Delay = %d\n", USBDelay);
65 p = _strtok(NULL, " ");
66 HDDSpindown = _strtoui(p);
67 DPRINTF("HDD Spindown = %d\n", HDDSpindown);
69 p = _strtok(NULL, " ");
70 _strcpy(g_ps2_ip, p);
71 p = _strtok(NULL, " ");
72 _strcpy(g_ps2_netmask, p);
73 p = _strtok(NULL, " ");
74 _strcpy(g_ps2_gateway, p);
75 DPRINTF("IP=%s NM=%s GW=%s\n", g_ps2_ip, g_ps2_netmask, g_ps2_gateway);
77 // bitmask of the compat. settings
78 g_compat_mask = _strtoui(argv[2]);
79 DPRINTF("Compat Mask = 0x%02x\n", g_compat_mask);
81 set_ipconfig();
83 DPRINTF("Get back IOP modules from Kernel RAM...\n");
84 GetIrxKernelRAM();
86 /* installing kernel hooks */
87 DPRINTF("Installing Kernel Hooks...\n");
88 Install_Kernel_Hooks();
90 if(!DisableDebug)
91 GS_BGCOLOUR = 0xff0000;
93 DPRINTF("Executing '%s'...\n", ElfPath);
94 LoadExecPS2(ElfPath, 0, NULL);
96 if(!DisableDebug)
97 GS_BGCOLOUR = 0x0000ff;
98 DPRINTF("LoadExecPS2 failed!\n");
100 SleepThread();
102 return 0;