forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to reinit libmc after IOP reset

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
dlanor



Joined: 28 Oct 2004
Posts: 269
Location: Stockholm, Sweden

PostPosted: Wed Jun 15, 2005 7:41 pm    Post subject: How to reinit libmc after IOP reset Reply with quote

In my work to improve LaunchELF I've discovered some problems associated with IOP reset.

One of them is that libmc still 'remembers' having initialized with mcInit before the reset, and refuses to allow it to be done again, even though I've loaded new instances of MCMAN+MCSERV to IOP.

I made some slight changes to libmc.h and libmc.c, which eliminated the problem:

In libmc.h I defined MC_TYPE_RESET:
Code:
// values to send to mcInit() to use either mcserv or xmcserv
#define MC_TYPE_MC   0
#define MC_TYPE_XMC   1
#define MC_TYPE_RESET 0xDEAD
//RA NB: mcInit(MC_TYPE_RESET) after IOP Reset, to forget old modules
//RA NB: This will not reinitialize anything for use of MC. To do that
//RA NB: you will need to mcInit(MC_TYPE_MC) or mcInit(MC_TYPE_XMC),
//RA NB: after having loaded modules to the IOP again.
In libmc.c I made a slight change to the start of mc_init:
Code:
int mcInit(int type)
{
   unsigned int i;
   int ret=0;

   if   (type == MC_TYPE_RESET)
   {   mclibInited = 0;
      cdata.server = NULL;
      return 0;
   }
Nothing else was altered. In the above I'm not sure if the clearing of cdata.server was needed, but I did that as a safety measure. My real objective was to clear mclibInited, as that flag prevented new mcInit.

I believe that other libs too may benefit from similar 'reset' additions, although this is the only one I've had occasion to investigate yet.

Best regards: dlanor
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Wed Jun 15, 2005 8:04 pm    Post subject: Reply with quote

perhaps mclibInited and friends should be in IOP space and have the rpc server reject a second attempt to init (or usage when not init'd), and send back an error code to the EE. Rather then bending over backwards to get lib* on EE to remain in sync with it's IRX counterpart.
This way you wouldn't need to notify the EE lib should circumstances change in the IOP (such as a reset)

This would cause extra rpc traffic, but wouldn't these instances be errors (or at least rare) and so no real need to optimize them..?
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
dlanor



Joined: 28 Oct 2004
Posts: 269
Location: Stockholm, Sweden

PostPosted: Wed Jun 15, 2005 9:06 pm    Post subject: Reply with quote

cheriff wrote:
perhaps mclibInited and friends should be in IOP space and have the rpc server reject a second attempt to init (or usage when not init'd), and send back an error code to the EE.

I'm not sure if that would be both safe and satisfactory. The EE lib routines probably need to be able to test the validity of some actions without sending any commands to the IOP. Also, I'm not sufficiently sure of how the RPC manager works, to be certain that it can be modified so that an IOP reset has the wanted 'restart' effect on the libs.

Quote:
Rather then bending over backwards to get lib* on EE to remain in sync with it's IRX counterpart.
I agree. Telling each lib by separate calls could get very messy.

Quote:
This way you wouldn't need to notify the EE lib should circumstances change in the IOP (such as a reset)
And that is even more important when the current program may have 'inherited' modules from its launcher, without being aware of them...

Quote:
This would cause extra rpc traffic, but wouldn't these instances be errors (or at least rare) and so no real need to optimize them..?
Not errors, as LaunchELF needs to do IOP reset to get rid of dependencies on other launchers, and will also need to do it after using some modules that ELFs to be launched may want to reuse later.

Since most other programs don't do this sort of thing, LaunchELF will have to deal with those issues both for 'incoming' and 'outgoing' launches, and with proper respect to the fact that LaunchELF itself may browse all PS2 media (using lots of driver modules) between 'incoming' and 'outgoing'. But even so, we are talking of very rare events, typically no more than two per LaunchELF session (which may be quite long, depending on activities).

If it can be safely implemented without having to request reset by each lib, that would be the best, as it eliminates a source of human errors.

Best regards: dlanor
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group