ExecModuleBuffer issue

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

Moderators: cheriff, Herben

Post Reply
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

ExecModuleBuffer issue

Post by KaylaKaze »

This is a little wierd I think. The following code works:

Code: Select all

printf("Executing module size=%d\n",size);
		if (size>0)
		{
			module.Close();
			char temp2[1025];
			sprintf(temp2,"host:%s.irx",filename);
			File o(temp2,O_CREAT|O_WRONLY);
			o.Write((u8*)buffer,size);
			o.Close();
			SifExecModuleBuffer((char*)buffer, size, ag_len, args, mod_res);
			delete [] buffer;
			return 1;
}
But this code doesn't (causes the system to freeze)

Code: Select all

printf("Executing module size=%d\n",size);
		if (size>0)
		{
			module.Close();
			SifExecModuleBuffer((char*)buffer, size, ag_len, args, mod_res);
			delete [] buffer;
			return 1;
}
My first thought was the delay caused by the file writting but I added a for loop and that didn't help. But if that is probably the issue, maybe my loop wasn't big enough.

Anyone else have any ideas?

Also, after the modules necessary for HD access are loaded, if I hit RESET on InLink to restart ps2link, the system freezes instead of restarting. It only happens when the modules have been loaded and as far as I can tell, I use the same steps that I used in MCMGR, which reset fine. This is pretty important 'cause it'd be VERY hard to code if I have to do a complete ps2 reboot everytime I make a change. Anyone else had a similar problem and solved it?
ole
Posts: 92
Joined: Sat May 08, 2004 11:14 pm
Location: Czech Republic

Post by ole »

I would trace/debug the scenario this way:
1) comment single lines (those which are missing in the second case) and search for the "trouble_making_line" or the combination
OR -
2) rewrite the code to the C (not cpp) and unfold all the content of the methods (constructors etc) into single function (main). Then put trace printfs between the trouble section lines and watch the results.

BTW: Do you know for sure that freeze is caused by SifExecModuleBuffer function and not by the delete function (can you comment the SifExecModuleBuffer and test wether it freeze too ?)?
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Maybe you'd want to look at the asm code too...
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
ole
Posts: 92
Joined: Sat May 08, 2004 11:14 pm
Location: Czech Republic

Post by ole »

or check this out: http://forums.ps2dev.org/viewtopic.php?t=316.
If I remember well the key to load modules from buffer is to reset iop correctly....
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

Post by KaylaKaze »

I commented out the SifExecModuleBuffer and I get a weird situation. But first, some background. The ExecModule funtion I'm working on searches for the irx file to load (first in SYS-MODULES on the MCs, then host, then if the HDD is initialized, SYS-MODULES on __boot). First it looks for compressed modules (compressed with zlib) and loads them with my ReadCompFile function which reads a compressed file and stores the uncompressed data to the memory buffer (which I've tested over and over and it decompresses perfectly). Now the weird part. If I just comment out the SifExecModuleBuffer in the second block of code I previously posted, the ReadCompFile function says the fileID on the compressed file is 0x0000 (should be 0x4C5A) and fails to load the file. If I put a printf() (such as printf("Closing module.\n)) before the Close() call, it reads fine. It also works fine if I put a for loop before it. So it seems it's continuing to carry out instructions even before the file is completely handled (and as far as I can tell, ReadCompFile shouldn't return until the file is handled). Is this normal?

Well, even if I flank the call to SifExecModuleBuffer with like .75 second delays (which is much more than the file writing caused) it still freezes (it loads the first 2 modules (poweroff and iomanx but freezes on filexio))

I'm going to try to make some sense of that post you referenced, though since it works properly with the file writing code, I'm not sure if that would be the case. Maybe I should update my PS2SDK code and see if that fixes it.

Oh! I forgot that I had tried the code using only the noncompressed, not the compressed and it worked perfectly (except for not restarting when I wanted it to). So I think I'll get back to the compressed drivers later and figuring out the reset issue should be my #1 priority right now.

Update: I changed the order in which my modules start and it seems to have fixed the PS2Link problem. Yay!
Post Reply