@@ -50,7 +50,6 @@ struct cmd_data
5050 int * sregs ;
5151} __attribute__((aligned (64 )));
5252
53- extern int _iop_reboot_count ;
5453extern struct cmd_data _sif_cmd_data ;
5554extern unsigned int _SifSendCmd (int cid , int mode , void * pkt , int pktsize , void * src ,
5655 void * dest , int size );
@@ -182,7 +181,6 @@ static SifCmdSysHandlerData_t sys_cmd_handlers[SYS_CMD_HANDLER_MAX];
182181static int sregs [32 ];
183182
184183struct cmd_data _sif_cmd_data ;
185- static int init = 0 ;
186184static int sif0_id = -1 ;
187185
188186struct ca_pkt
@@ -218,17 +216,16 @@ void sceSifInitCmd(void)
218216{
219217 static struct ca_pkt packet __attribute((aligned (64 )));
220218 int i ;
221- static int _rb_count = 0 ;
222- if ( _rb_count != _iop_reboot_count ) {
223- _rb_count = _iop_reboot_count ;
224- if (sif0_id >= 0 ) {
225- DisableDmac ( DMAC_SIF0 ) ;
226- RemoveDmacHandler ( DMAC_SIF0 , sif0_id );
219+ {
220+ static int _rb_count ;
221+ extern int _iop_reboot_count ;
222+ if (_rb_count != _iop_reboot_count ) {
223+ _rb_count = _iop_reboot_count ;
224+ sceSifExitCmd ( );
227225 }
228- init = 0 ;
229226 }
230227
231- if (init )
228+ if (sif0_id >= 0 )
232229 return ;
233230
234231 DI ();
@@ -267,7 +264,6 @@ void sceSifInitCmd(void)
267264 sif0_id = AddDmacHandler (DMAC_SIF0 , & _SifCmdIntHandler , 0 );
268265 EnableDmac (DMAC_SIF0 );
269266
270- init = 1 ;
271267
272268 _sif_cmd_data .iopbuf = (void * )sceSifGetReg (SIF_SYSREG_SUBADDR );
273269 if (_sif_cmd_data .iopbuf ) {
@@ -293,9 +289,11 @@ void sceSifInitCmd(void)
293289
294290void sceSifExitCmd (void )
295291{
296- DisableDmac (DMAC_SIF0 );
297- RemoveDmacHandler (DMAC_SIF0 , sif0_id );
298- init = 0 ;
292+ if (sif0_id >= 0 ) {
293+ DisableDmac (DMAC_SIF0 );
294+ RemoveDmacHandler (DMAC_SIF0 , sif0_id );
295+ sif0_id = -1 ;
296+ }
299297}
300298#endif
301299
0 commit comments