1919#include <tamtypes.h>
2020#include <kernel.h>
2121#include <sifcmd.h>
22+ #include <iopcontrol.h>
2223
2324#define CMD_PACKET_MAX 128
2425#define CMD_PACKET_DATA_MAX 112
@@ -50,7 +51,6 @@ struct cmd_data
5051 int * sregs ;
5152} __attribute__((aligned (64 )));
5253
53- extern int _iop_reboot_count ;
5454extern struct cmd_data _sif_cmd_data ;
5555extern unsigned int _SifSendCmd (int cid , int mode , void * pkt , int pktsize , void * src ,
5656 void * dest , int size );
@@ -182,7 +182,6 @@ static SifCmdSysHandlerData_t sys_cmd_handlers[SYS_CMD_HANDLER_MAX];
182182static int sregs [32 ];
183183
184184struct cmd_data _sif_cmd_data ;
185- static int init = 0 ;
186185static int sif0_id = -1 ;
187186
188187struct ca_pkt
@@ -218,17 +217,10 @@ void sceSifInitCmd(void)
218217{
219218 static struct ca_pkt packet __attribute((aligned (64 )));
220219 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 );
227- }
228- init = 0 ;
229- }
220+ if (HasIopRebootedSinceLastCall ())
221+ sceSifExitCmd ();
230222
231- if (init )
223+ if (sif0_id >= 0 )
232224 return ;
233225
234226 DI ();
@@ -267,7 +259,6 @@ void sceSifInitCmd(void)
267259 sif0_id = AddDmacHandler (DMAC_SIF0 , & _SifCmdIntHandler , 0 );
268260 EnableDmac (DMAC_SIF0 );
269261
270- init = 1 ;
271262
272263 _sif_cmd_data .iopbuf = (void * )sceSifGetReg (SIF_SYSREG_SUBADDR );
273264 if (_sif_cmd_data .iopbuf ) {
@@ -293,9 +284,11 @@ void sceSifInitCmd(void)
293284
294285void sceSifExitCmd (void )
295286{
296- DisableDmac (DMAC_SIF0 );
297- RemoveDmacHandler (DMAC_SIF0 , sif0_id );
298- init = 0 ;
287+ if (sif0_id >= 0 ) {
288+ DisableDmac (DMAC_SIF0 );
289+ RemoveDmacHandler (DMAC_SIF0 , sif0_id );
290+ sif0_id = -1 ;
291+ }
299292}
300293#endif
301294
0 commit comments