SifinitRpc hangs when using Free McBoot 1.8b

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

SifinitRpc hangs when using Free McBoot 1.8b

Post by Mega Man »

Hello,

when I start a program the following way (tested on fat PS2 and slim PSTwo):
1. Free Mc Boot 1.8b
2. uLaunchELF v4.39
3. ps2link (current from SVN)
4. My program (IOP reset, all programs making IOP reset seem not to work):

Code: Select all

#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <kernel.h>
#include <iopheap.h>
#include <loadfile.h>
#include <sbv_patches.h>
#include <sifrpc.h>
#include <iopcontrol.h>
#include <debug.h>

static char s_pUDNL   &#91;&#93; __attribute__&#40;   &#40;  section&#40; ".data" &#41;, aligned&#40; 1 &#41;  &#41;   &#41; = "rom0&#58;UDNL rom0&#58;EELOADCNF";

int main&#40;&#41;
&#123;   
	u32 value;
	u32 iopbuffer;
	init_scr&#40;&#41;;

	value = SifGetReg&#40;0x80000000&#41;;
	scr_printf&#40;"SifReg 0x80000000 = 0x%08x\n", value&#41;;
	iopbuffer = value;
	value = SifGetReg&#40;0x80000002&#41;;
	scr_printf&#40;"SifReg 0x80000002 = 0x%08x\n", value&#41;;
	FlushCache&#40;0&#41;;

	SifExitIopHeap&#40;&#41;;
	SifLoadFileExit&#40;&#41;;
	SifExitRpc&#40;&#41;;
	SifStopDma&#40;&#41;;

	SifIopReset&#40;s_pUDNL, 0&#41;;

	while &#40;SifIopSync&#40;&#41;&#41;;
	scr_printf&#40;"Working %s&#58;%d\n", __FILE__, __LINE__&#41;;

	value = SifGetReg&#40;0x80000000&#41;;
	scr_printf&#40;"SifReg 0x80000000 = 0x%08x\n", value&#41;;
	value = SifGetReg&#40;0x80000002&#41;;
	scr_printf&#40;"SifReg 0x80000002 = 0x%08x\n", value&#41;;

#if 0
	SifSetReg&#40;0x80000000, iopbuffer&#41;;
	SifSetReg&#40;0x80000002, 1&#41;;
#endif

	SifInitRpc&#40;0&#41;;
	scr_printf&#40;"Working %s&#58;%d\n", __FILE__, __LINE__&#41;;

	sbv_patch_enable_lmb&#40;&#41;;
	scr_printf&#40;"Working %s&#58;%d\n", __FILE__, __LINE__&#41;;
	sbv_patch_disable_prefix_check&#40;&#41;;
	scr_printf&#40;"Working %s&#58;%d\n", __FILE__, __LINE__&#41;;
    
    return 0;
&#125;
The call to SifInitRpc(0); hangs in SifInitCmd(). The following code causes the dead lock:

Code: Select all

while &#40;!&#40;SifGetReg&#40;SIF_REG_SMFLAG&#41; & 0x20000&#41;&#41; ;
When I use a different boot method, it is working (replace step 1 by Sony's PS2 Linux and reload or the old memory card exploit). It is also working if my different boot method was started by the Free McBoot OSD.

When I replace "#if 0" in the above code by "#if 1", SifInitRpc() is executed normally. RPC is not usable after this.

As I have written a replacement PS2 kernel in the past, I believed that the SMFLAG stuff is not working (only working at system startup one time). I simulated it by setting the SifRegs manually in my PS2 replacement kernel. I now detected that this assumption is wrong.
I reverse engineered in the past that the SifReg 0x80000000 is only set by the IOP at startup via an SifSendCmd() (0x80000000 stores the pointer to the IOP buffer for RPC messages. 0x80000002 is set to 1 when RPC is initialised). The SifReg 0x80000000 and 0x80000002 is set to 0 after IOP reset (in both cases, working and not working loader). So I assume that IOP sets the register successfully to 0 while IOP reset. The conculsion is that the IOP has been crashed after IOP reset (or dead lock).
Maybe some hardware engine need to be disabled by ps2link, before starting an EE program.

I need a fix to be able to test kernelloader as it is used by slim PSTwo owners. Do somebody know why IOP is not reacting after reset when using Free McBoot?
Post Reply