From 5b1bc49aacfbbdd064149470380581a436dd4c39 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Fri, 29 May 2026 22:24:58 -0500 Subject: [PATCH] cleanup: Make SIF binding handling more consistent If IOP reboot, deinit and re-bind Use server member of SIF client data as check for initialization --- ee/kernel/src/fileio.c | 22 +++---- ee/kernel/src/iopheap.c | 25 +++----- ee/kernel/src/loadfile.c | 19 +++--- ee/kernel/src/sifcmd.c | 26 ++++---- ee/kernel/src/sifrpc.c | 14 +++-- ee/network/netman/src/rpc_client.c | 83 +++++++++++++------------- ee/rpc/ahx/src/ahx_rpc.c | 96 ++++++++++-------------------- ee/rpc/audsrv/src/audsrv_rpc.c | 14 +++-- ee/rpc/camera/src/ps2cam_rpc.c | 14 +++-- ee/rpc/cdvd/src/internal.h | 3 - ee/rpc/cdvd/src/libcdvd.c | 36 +++++------ ee/rpc/cdvd/src/ncmd.c | 14 +++-- ee/rpc/cdvd/src/scmd.c | 15 +++-- ee/rpc/filexio/Makefile | 2 +- ee/rpc/filexio/src/fileXio_rpc.c | 25 +++----- ee/rpc/keyboard/src/libkbd.c | 11 ++-- ee/rpc/mouse/src/libmouse.c | 16 +++-- ee/rpc/multitap/src/libmtap.c | 21 ++++--- ee/rpc/pad/src/libpad.c | 22 ++++--- ee/rpc/poweroff/src/poweroff.c | 14 +++-- ee/rpc/ps2snd/src/ps2snd.c | 8 +++ ee/rpc/remote/src/librm.c | 18 +++++- ee/rpc/secr/src/libsecr.c | 9 +++ ee/rpc/tcpips/src/ps2ipc.c | 54 ++++++++++------- 24 files changed, 303 insertions(+), 278 deletions(-) diff --git a/ee/kernel/src/fileio.c b/ee/kernel/src/fileio.c index 4aacd1810d63..58b9a3f1b48c 100644 --- a/ee/kernel/src/fileio.c +++ b/ee/kernel/src/fileio.c @@ -25,9 +25,7 @@ #define D(fmt, args...) printf("(%s:%s:%i):" #fmt, __FILE__, __FUNCTION__, __LINE__, ##args) -extern int _iop_reboot_count; extern SifRpcClientData_t _fio_cd; -extern int _fio_init; extern int _fio_block_mode; extern int _fio_io_sema; extern int _fio_completion_sema; @@ -41,7 +39,6 @@ void _fio_intr(); SifRpcClientData_t _fio_cd; int _fio_recv_data[512] __attribute__((aligned(64))); int _fio_intr_data[32] __attribute__((aligned(64))); -int _fio_init = 0; int _fio_block_mode; int _fio_io_sema = -1; int _fio_completion_sema = -1; @@ -52,15 +49,16 @@ int fioInit(void) { int res; ee_sema_t sema; - static int _rb_count = 0; - - if (_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - - fioExit(); + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + fioExit(); + } } - if (_fio_init) + if (_fio_cd.server) return 0; sceSifInitRpc(0); @@ -87,7 +85,6 @@ int fioInit(void) if (_fio_io_sema < 0) return -E_LIB_SEMA_CREATE; - _fio_init = 1; _fio_block_mode = FIO_WAIT; return 0; @@ -151,8 +148,7 @@ void fioSetBlockMode(int blocking) #ifdef F_fio_exit void fioExit(void) { - if (_fio_init) { - _fio_init = 0; + if (_fio_cd.server) { memset(&_fio_cd, 0, sizeof _fio_cd); if (_fio_completion_sema >= 0) { DeleteSema(_fio_completion_sema); diff --git a/ee/kernel/src/iopheap.c b/ee/kernel/src/iopheap.c index bfe3e3272d05..6a66ef8251ee 100644 --- a/ee/kernel/src/iopheap.c +++ b/ee/kernel/src/iopheap.c @@ -19,29 +19,24 @@ #include "iopheap.h" -#define IH_C_BOUND 0x0001 - -extern int _iop_reboot_count; extern SifRpcClientData_t _ih_cd; -extern int _ih_caps; #ifdef F_SifInitIopHeap SifRpcClientData_t _ih_cd; -int _ih_caps = 0; int SifInitIopHeap() { int res; - - static int _rb_count = 0; - if (_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - memset(&_ih_cd, 0, sizeof _ih_cd); - _ih_caps = 0; - memset(&_ih_caps, 0, sizeof _ih_caps); + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + SifExitIopHeap(); + } } - if (_ih_caps) + if (_ih_cd.server) return 0; sceSifInitRpc(0); @@ -52,8 +47,6 @@ int SifInitIopHeap() if (res < 0) return -E_SIF_RPC_BIND; - _ih_caps |= IH_C_BOUND; - return 0; } #endif @@ -61,7 +54,7 @@ int SifInitIopHeap() #ifdef F_SifExitIopHeap void SifExitIopHeap() { - _ih_caps = 0; + memset(&_ih_cd, 0, sizeof _ih_cd); } #endif diff --git a/ee/kernel/src/loadfile.c b/ee/kernel/src/loadfile.c index cb908f2abec8..ce884f461b1b 100644 --- a/ee/kernel/src/loadfile.c +++ b/ee/kernel/src/loadfile.c @@ -26,28 +26,27 @@ #include #include -extern int _iop_reboot_count; extern SifRpcClientData_t _lf_cd; -extern int _lf_init; int _SifLoadElfPart(const char *path, const char *secname, t_ExecData *data, int fno); int _SifLoadModuleBuffer(void *ptr, int arg_len, const char *args, int *modres); #if defined(F_SifLoadFileInit) SifRpcClientData_t _lf_cd; -int _lf_init = 0; int SifLoadFileInit() { int res; - static int _rb_count = 0; - if (_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - memset(&_lf_cd, 0, sizeof _lf_cd); - _lf_init = 0; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + SifLoadFileExit(); + } } - if (_lf_init) + if (_lf_cd.server) return 0; sceSifInitRpc(0); @@ -58,7 +57,6 @@ int SifLoadFileInit() if (res < 0) return -E_SIF_RPC_BIND; - _lf_init = 1; return 0; } #endif @@ -66,7 +64,6 @@ int SifLoadFileInit() #if defined(F_SifLoadFileExit) void SifLoadFileExit() { - _lf_init = 0; memset(&_lf_cd, 0, sizeof _lf_cd); } #endif diff --git a/ee/kernel/src/sifcmd.c b/ee/kernel/src/sifcmd.c index 4629e89a34c4..367d2d8cd2ed 100644 --- a/ee/kernel/src/sifcmd.c +++ b/ee/kernel/src/sifcmd.c @@ -50,7 +50,6 @@ struct cmd_data int *sregs; } __attribute__((aligned(64))); -extern int _iop_reboot_count; extern struct cmd_data _sif_cmd_data; extern unsigned int _SifSendCmd(int cid, int mode, void *pkt, int pktsize, void *src, void *dest, int size); @@ -182,7 +181,6 @@ static SifCmdSysHandlerData_t sys_cmd_handlers[SYS_CMD_HANDLER_MAX]; static int sregs[32]; struct cmd_data _sif_cmd_data; -static int init = 0; static int sif0_id = -1; struct ca_pkt @@ -218,17 +216,16 @@ void sceSifInitCmd(void) { static struct ca_pkt packet __attribute((aligned(64))); int i; - static int _rb_count = 0; - if (_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - if (sif0_id >= 0) { - DisableDmac(DMAC_SIF0); - RemoveDmacHandler(DMAC_SIF0, sif0_id); + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + sceSifExitCmd(); } - init = 0; } - if (init) + if (sif0_id >= 0) return; DI(); @@ -267,7 +264,6 @@ void sceSifInitCmd(void) sif0_id = AddDmacHandler(DMAC_SIF0, &_SifCmdIntHandler, 0); EnableDmac(DMAC_SIF0); - init = 1; _sif_cmd_data.iopbuf = (void *)sceSifGetReg(SIF_SYSREG_SUBADDR); if (_sif_cmd_data.iopbuf) { @@ -293,9 +289,11 @@ void sceSifInitCmd(void) void sceSifExitCmd(void) { - DisableDmac(DMAC_SIF0); - RemoveDmacHandler(DMAC_SIF0, sif0_id); - init = 0; + if (sif0_id >= 0) { + DisableDmac(DMAC_SIF0); + RemoveDmacHandler(DMAC_SIF0, sif0_id); + sif0_id = -1; + } } #endif diff --git a/ee/kernel/src/sifrpc.c b/ee/kernel/src/sifrpc.c index 42c676599391..cc822a452134 100644 --- a/ee/kernel/src/sifrpc.c +++ b/ee/kernel/src/sifrpc.c @@ -50,7 +50,6 @@ struct rpc_data void *active_queue; } __attribute__((aligned(64))); -extern int _iop_reboot_count; extern struct rpc_data _sif_rpc_data; void *_rpc_get_packet(struct rpc_data *rpc_data); @@ -415,11 +414,14 @@ void sceSifInitRpc(int mode) (void)mode; - static int _rb_count = 0; - if (_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - sceSifExitCmd(); - init = 0; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + sceSifExitCmd(); + init = 0; + } } if (init) diff --git a/ee/network/netman/src/rpc_client.c b/ee/network/netman/src/rpc_client.c index 3decdd2fe8e5..1e608a0cf02a 100644 --- a/ee/network/netman/src/rpc_client.c +++ b/ee/network/netman/src/rpc_client.c @@ -35,7 +35,7 @@ static u8 *IOPFrameBuffer = NULL; /* On the IOP side. */ static struct NetManBD *IOPFrameBufferStatus = NULL; static struct NetManBD *FrameBufferStatus = NULL; -static unsigned char IsInitialized=0, IsProcessingTx; +static unsigned char IsProcessingTx; static void deinitCleanup(void) { @@ -50,6 +50,7 @@ static void deinitCleanup(void) DeleteThread(NETMAN_Tx_threadID); NETMAN_Tx_threadID = -1; } + memset(&NETMAN_rpc_cd, 0, sizeof(NETMAN_rpc_cd)); } static void NETMAN_TxThread(void *arg); @@ -59,49 +60,47 @@ int NetManInitRPCClient(void){ int result; ee_sema_t SemaData; ee_thread_t thread; - - if(!IsInitialized) { - SemaData.max_count=1; - SemaData.init_count=1; - SemaData.option=(u32)NetManID; - SemaData.attr=0; - if((NetManIOSemaID=CreateSema(&SemaData)) < 0) - { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; deinitCleanup(); - return NetManIOSemaID; } + } - thread.func=&NETMAN_TxThread; - thread.stack=NETMAN_Tx_ThreadStack; - thread.stack_size=sizeof(NETMAN_Tx_ThreadStack); - thread.gp_reg=&_gp; - thread.initial_priority=0x56; /* Should be given a higher priority than the protocol stack, so that it can dump frames in the EE and return. */ - thread.attr=thread.option=0; - - if((NETMAN_Tx_threadID=CreateThread(&thread)) >= 0) - { - IsProcessingTx = 0; - StartThread(NETMAN_Tx_threadID, NULL); - } else { - deinitCleanup(); - return NETMAN_Tx_threadID; - } + if(NETMAN_rpc_cd.server) + return 0; + SemaData.max_count=1; + SemaData.init_count=1; + SemaData.option=(u32)NetManID; + SemaData.attr=0; + if((NetManIOSemaID=CreateSema(&SemaData)) < 0) + { + deinitCleanup(); + return NetManIOSemaID; + } - while((sceSifBindRpc(&NETMAN_rpc_cd, NETMAN_RPC_NUMBER, 0)<0)||(NETMAN_rpc_cd.server==NULL)) - nopdelay(); + thread.func=&NETMAN_TxThread; + thread.stack=NETMAN_Tx_ThreadStack; + thread.stack_size=sizeof(NETMAN_Tx_ThreadStack); + thread.gp_reg=&_gp; + thread.initial_priority=0x56; /* Should be given a higher priority than the protocol stack, so that it can dump frames in the EE and return. */ + thread.attr=thread.option=0; - if((result=sceSifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_INIT, 0, NULL, 0, &ReceiveBuffer, sizeof(s32), NULL, NULL))>=0) - { - if((result=ReceiveBuffer.result) == 0) - IsInitialized=1; - else - deinitCleanup(); - }else{ - deinitCleanup(); - } + if((NETMAN_Tx_threadID=CreateThread(&thread)) < 0) + { + deinitCleanup(); + return NETMAN_Tx_threadID; } - else result=0; + IsProcessingTx = 0; + StartThread(NETMAN_Tx_threadID, NULL); + + while((sceSifBindRpc(&NETMAN_rpc_cd, NETMAN_RPC_NUMBER, 0)<0)||(NETMAN_rpc_cd.server==NULL)) + nopdelay(); + + if((result=sceSifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_INIT, 0, NULL, 0, &ReceiveBuffer, sizeof(s32), NULL, NULL))<0 || (result=ReceiveBuffer.result) != 0) + deinitCleanup(); return result; } @@ -159,14 +158,12 @@ int NetManRPCUnregisterNetworkStack(void) void NetManDeinitRPCClient(void) { - if(IsInitialized) + if(NETMAN_rpc_cd.server) { WaitSema(NetManIOSemaID); sceSifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_DEINIT, 0, NULL, 0, NULL, 0, NULL, NULL); deinitCleanup(); - - IsInitialized=0; } } @@ -294,7 +291,7 @@ int NetManSetMainIF(const char *name) { int result; - if (!IsInitialized) + if (!NETMAN_rpc_cd.server) return -1; WaitSema(NetManIOSemaID); @@ -313,7 +310,7 @@ int NetManQueryMainIF(char *name) { int result; - if (!IsInitialized) + if (!NETMAN_rpc_cd.server) return -1; WaitSema(NetManIOSemaID); @@ -336,7 +333,7 @@ int NetManSetLinkMode(int mode) { int result; - if (!IsInitialized) + if (!NETMAN_rpc_cd.server) return -1; WaitSema(NetManIOSemaID); diff --git a/ee/rpc/ahx/src/ahx_rpc.c b/ee/rpc/ahx/src/ahx_rpc.c index 59dcd0d2918e..643189d8b1ae 100644 --- a/ee/rpc/ahx/src/ahx_rpc.c +++ b/ee/rpc/ahx/src/ahx_rpc.c @@ -29,7 +29,6 @@ static struct t_SifRpcClientData cd0; /** EE mapped IOP mem */ #define IOP_MEM 0xbc000000 char* songbuffer_addr; -int ahx_init_done = 0; /** Read/Write IOP Mem * @@ -45,12 +44,18 @@ void iop_readwrite(void *addr, void *buf, u32 size, u32 read) EI(); } -int AHX_Init() +static int AHX_BindRpc_Impl(void) { - // struct t_SifDmaTransfer sdt; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&cd0, 0, sizeof(cd0)); + } + } - // if already init'd, exit - if (ahx_init_done) return 0; + if (cd0.server) return 0; // bind rpc while(1){ @@ -61,54 +66,48 @@ int AHX_Init() i = 0x10000; while(i--); } + return 0; +} + +#define AHX_BINDRPC() \ + { \ + int ret; \ + ret = AHX_BindRpc_Impl(); \ + if (ret) \ + return ret; \ + } + +int AHX_Init() +{ + AHX_BINDRPC(); sceSifCallRpc(&cd0,AHX_INIT,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); songbuffer_addr = (char*)sbuff[1]; - // set flag, init done - ahx_init_done = 1; return 0; } int AHX_Play() { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sceSifCallRpc(&cd0,AHX_PLAY,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; } int AHX_Pause() { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sceSifCallRpc(&cd0,AHX_PAUSE,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; } int AHX_SubSong(int songNo) { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sbuff[0] = (unsigned)songNo; sceSifCallRpc(&cd0,AHX_PAUSE,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; @@ -116,14 +115,8 @@ int AHX_SubSong(int songNo) int AHX_SetVolume(int volumePercentage) { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sbuff[0] = (unsigned)volumePercentage; sceSifCallRpc(&cd0,AHX_QUIT,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; @@ -131,14 +124,8 @@ int AHX_SetVolume(int volumePercentage) int AHX_SetBoost(int boostValue) { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sbuff[0] = (unsigned)boostValue; sceSifCallRpc(&cd0,AHX_SETBOOST,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; @@ -146,28 +133,16 @@ int AHX_SetBoost(int boostValue) int AHX_ToggleOversampling() { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sceSifCallRpc(&cd0,AHX_OVERSAMPLING,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; } int AHX_Quit() { - while(1){ - int i; + AHX_BINDRPC(); - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } sceSifCallRpc(&cd0,AHX_QUIT,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL); return 0; } @@ -177,14 +152,7 @@ int AHX_LoadSongBuffer(char* songdata, int songsize) // write song data to IOP song buffer iop_readwrite(songbuffer_addr, songdata, songsize, 0); - while(1){ - int i; - - if (sceSifBindRpc( &cd0, AHX_IRX, 0) < 0) return -1; - if (cd0.server != 0) break; - i = 0x10000; - while(i--); - } + AHX_BINDRPC(); // set oversample and boost sbuff[0] = (unsigned)songsize; diff --git a/ee/rpc/audsrv/src/audsrv_rpc.c b/ee/rpc/audsrv/src/audsrv_rpc.c index 8dbe0c884a5f..0782ee742bb1 100755 --- a/ee/rpc/audsrv/src/audsrv_rpc.c +++ b/ee/rpc/audsrv/src/audsrv_rpc.c @@ -34,7 +34,6 @@ static unsigned char rpc_server_stack[0x1800] __attribute__((aligned (16))); extern void *_gp; -static int initialized = 0; static int rpc_server_thread_id; static int audsrv_error = AUDSRV_ERR_NOERROR; static int completion_sema; @@ -331,14 +330,21 @@ int audsrv_init() ee_thread_t rpcThread; int ret; - if (initialized) + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&cd0, 0, sizeof(cd0)); + } + } + + if (cd0.server) { /* already done */ return 0; } - memset(&cd0, '\0', sizeof(cd0)); - while (1) { if (sceSifBindRpc(&cd0, AUDSRV_IRX, 0) < 0) diff --git a/ee/rpc/camera/src/ps2cam_rpc.c b/ee/rpc/camera/src/ps2cam_rpc.c index dc00571ffa63..3b9450a44b9d 100644 --- a/ee/rpc/camera/src/ps2cam_rpc.c +++ b/ee/rpc/camera/src/ps2cam_rpc.c @@ -22,7 +22,6 @@ -static int CamInited = 0; static SifRpcClientData_t cdata __attribute__((aligned(64))); static char data[1024] __attribute__((aligned(64))); static char campacket[896] __attribute__((aligned(64))); @@ -41,7 +40,16 @@ int PS2CamInit(int mode) // unsigned int i; // int timeout = 100000; - if(CamInited)return 0; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&cdata, 0, sizeof(cdata)); + } + } + if (cdata.server) + return 0; sceSifInitRpc(0); @@ -64,8 +72,6 @@ int PS2CamInit(int mode) sceSifCallRpc(&cdata, PS2CAM_RPC_INITIALIZE, 0, (void*)(&data[0]),4,(void*)(&data[0]),4,0,0); nopdelay(); - CamInited = 1; - printf("init done\n"); diff --git a/ee/rpc/cdvd/src/internal.h b/ee/rpc/cdvd/src/internal.h index f07760391e38..4d1a2c7f3657 100644 --- a/ee/rpc/cdvd/src/internal.h +++ b/ee/rpc/cdvd/src/internal.h @@ -29,9 +29,6 @@ extern volatile int cbSema; extern int CdThreadId; extern ee_thread_status_t CdThreadParam; -extern int bindNCmd; -extern int bindSCmd; - extern int nCmdSemaId; extern int sCmdSemaId; diff --git a/ee/rpc/cdvd/src/libcdvd.c b/ee/rpc/cdvd/src/libcdvd.c index 2affbbda4312..dcd971547f8b 100644 --- a/ee/rpc/cdvd/src/libcdvd.c +++ b/ee/rpc/cdvd/src/libcdvd.c @@ -62,10 +62,6 @@ typedef struct } SearchFilePkt; #ifdef F__libcdvd_internals -// bind variables -int bindInit = -1; -int bindDiskReady = -1; -int bindSearchFile = -1; // version variables int initVersionCdvdfsv; int initVersionCdvdman; @@ -110,9 +106,6 @@ u32 searchFileRecvBuff __attribute__((aligned(64))); #endif // Prototypes for multimodule -extern int bindInit; -extern int bindDiskReady; -extern int bindSearchFile; extern int initVersionCdvdfsv; extern int initVersionCdvdman; extern SifRpcClientData_t clientInit; @@ -143,11 +136,7 @@ s32 sceCdInit(s32 mode) return 0; sceSifInitRpc(0); CdThreadId = GetThreadId(); - bindSearchFile = -1; - bindNCmd = -1; - bindSCmd = -1; - bindDiskReady = -1; - bindInit = -1; + memset(&clientInit, 0, sizeof(clientInit)); while (1) { if (sceSifBindRpc(&clientInit, CD_SERVER_INIT, 0) < 0) { @@ -159,7 +148,6 @@ s32 sceCdInit(s32 mode) nopdelay(); } - bindInit = 0; initMode = mode; if (sceSifCallRpc(&clientInit, 0, 0, &initMode, sizeof(initMode), &cdInitRecvBuff, sizeof(cdInitRecvBuff), 0, 0) < 0) return 0; @@ -210,7 +198,15 @@ s32 sceCdSearchFile(sceCdlFILE *file, const char *name) return 0; } sceSifInitRpc(0); - if (bindSearchFile < 0) { + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&clientSearchFile, 0, sizeof(clientSearchFile)); + } + } + if (!clientSearchFile.server) { while (1) { if (sceSifBindRpc(&clientSearchFile, CD_SERVER_SEARCHFILE, 0) < 0) { if (CdDebug > 0) @@ -221,7 +217,6 @@ s32 sceCdSearchFile(sceCdlFILE *file, const char *name) nopdelay(); } - bindSearchFile = 0; } strncpy(searchFileSendBuff.name, name, 255); @@ -269,7 +264,15 @@ s32 sceCdDiskReady(s32 mode) } sceSifInitRpc(0); - if (bindDiskReady < 0) { + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&clientDiskReady, 0, sizeof(clientDiskReady)); + } + } + if (!clientDiskReady.server) { while (1) { if (sceSifBindRpc(&clientDiskReady, CD_SERVER_DISKREADY, 0) < 0) { if (CdDebug > 0) @@ -281,7 +284,6 @@ s32 sceCdDiskReady(s32 mode) nopdelay(); } } - bindDiskReady = 0; diskReadyMode = mode; if (sceSifCallRpc(&clientDiskReady, 0, 0, &diskReadyMode, 4, sCmdRecvBuff, 4, NULL, NULL) < 0) { diff --git a/ee/rpc/cdvd/src/ncmd.c b/ee/rpc/cdvd/src/ncmd.c index d67201569e2e..7c44c37c1688 100644 --- a/ee/rpc/cdvd/src/ncmd.c +++ b/ee/rpc/cdvd/src/ncmd.c @@ -76,8 +76,6 @@ typedef union } nCmdSendParams_t; #ifdef F__ncmd_internals -int bindNCmd = -1; - /** for n-cmds */ SifRpcClientData_t clientNCmd __attribute__((aligned(64))); @@ -815,8 +813,16 @@ int _CdCheckNCmd(int cmd) } sceSifInitRpc(0); + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&clientNCmd, 0, sizeof(clientNCmd)); + } + } // if already bound, return ok - if (bindNCmd >= 0) + if (clientNCmd.server) return 1; // bind rpc for n-commands while (1) { @@ -865,8 +871,6 @@ int _CdCheckNCmd(int cmd) eq_count += (((u8 *)uncached)[i] == ((u8 *)&tmpbuf)[i]) ? 1 : 0; initVersionCdvdfsv = (eq_count > sizeof(struct _cdvd_read_data_1300)) ? 0x200 : 0x104; } - - bindNCmd = 0; return 1; } #endif diff --git a/ee/rpc/cdvd/src/scmd.c b/ee/rpc/cdvd/src/scmd.c index e85280d03a37..6681018c6f29 100644 --- a/ee/rpc/cdvd/src/scmd.c +++ b/ee/rpc/cdvd/src/scmd.c @@ -87,8 +87,6 @@ typedef union } sCmdSendParams_t; #ifdef F__scmd_internals -int bindSCmd = -1; - SifRpcClientData_t clientSCmd __attribute__((aligned(64))); int sCmdSemaId = -1; @@ -102,7 +100,6 @@ int CdConfigRdWrNumBlocks; #endif extern int initVersionCdvdman; -extern int bindSCmd; extern SifRpcClientData_t clientSCmd; extern int sCmdSemaId; extern u8 sCmdRecvBuff[]; @@ -468,7 +465,15 @@ int _CdCheckSCmd(int cur_cmd) } sceSifInitRpc(0); - if (bindSCmd >= 0) + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&clientSCmd, 0, sizeof(clientSCmd)); + } + } + if (clientSCmd.server) return 1; while (1) { if (sceSifBindRpc(&clientSCmd, CD_SERVER_SCMD, 0) < 0) { @@ -480,8 +485,6 @@ int _CdCheckSCmd(int cur_cmd) nopdelay(); } - - bindSCmd = 0; return 1; } #endif diff --git a/ee/rpc/filexio/Makefile b/ee/rpc/filexio/Makefile index 2a2129bc022d..e09f90f53a29 100644 --- a/ee/rpc/filexio/Makefile +++ b/ee/rpc/filexio/Makefile @@ -11,7 +11,7 @@ EE_LIB = libfileXio.a CORE_OBJS = erl-support.o FILEXIO_RPC_OBJS = \ - __cd0.o __sbuff.o __intr_data.o __fileXioInited.o __fileXioBlockMode.o __fileXioCompletionSema.o __lock_sema_id.o \ + __cd0.o __sbuff.o __intr_data.o __fileXioBlockMode.o __fileXioCompletionSema.o __lock_sema_id.o \ fileXioInit.o fileXioExit.o fileXioStop.o fileXioGetDeviceList.o fileXioGetdir.o fileXioMount.o fileXioUmount.o \ fileXioCopyfile.o fileXioMkdir.o fileXioRmdir.o fileXioRemove.o fileXioRename.o fileXioSymlink.o fileXioReadlink.o \ fileXioChdir.o fileXioOpen.o fileXioClose.o fileXioRead.o fileXioWrite.o fileXioLseek.o fileXioLseek64.o fileXioChStat.o \ diff --git a/ee/rpc/filexio/src/fileXio_rpc.c b/ee/rpc/filexio/src/fileXio_rpc.c index 6882ceffafc3..15aa311c94b1 100644 --- a/ee/rpc/filexio/src/fileXio_rpc.c +++ b/ee/rpc/filexio/src/fileXio_rpc.c @@ -28,8 +28,6 @@ #include #include -extern int _iop_reboot_count; - void _ps2sdk_fileXio_init(); void _ps2sdk_fileXio_deinit(); @@ -51,12 +49,6 @@ int __intr_data[0xC00] __attribute__((aligned(64))); extern int __intr_data[0xC00] __attribute__((aligned(64))); #endif -#ifdef F___fileXioInited -int __fileXioInited = 0; -#else -extern int __fileXioInited; -#endif - #ifdef F___fileXioBlockMode int __fileXioBlockMode; #else @@ -95,16 +87,17 @@ int fileXioInit(void) { int res; ee_sema_t sp; - static int _rb_count = 0; - if(_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - - fileXioExit(); + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + fileXioExit(); + } } - if(__fileXioInited) + if(__cd0.server) { return 0; } @@ -127,7 +120,6 @@ int fileXioInit(void) if (__fileXioCompletionSema < 0) return -1; - __fileXioInited = 1; __fileXioBlockMode = FXIO_WAIT; _ps2sdk_fileXio_init(); @@ -139,7 +131,7 @@ int fileXioInit(void) #ifdef F_fileXioExit void fileXioExit(void) { - if(__fileXioInited) + if(__cd0.server) { if(__lock_sema_id >= 0) DeleteSema(__lock_sema_id); if(__fileXioCompletionSema >= 0) DeleteSema(__fileXioCompletionSema); @@ -147,7 +139,6 @@ void fileXioExit(void) memset(&__cd0, 0, sizeof(__cd0)); _ps2sdk_fileXio_deinit(); - __fileXioInited = 0; } } #endif diff --git a/ee/rpc/keyboard/src/libkbd.c b/ee/rpc/keyboard/src/libkbd.c index 234caa8a1f2e..5de2409e6da4 100644 --- a/ee/rpc/keyboard/src/libkbd.c +++ b/ee/rpc/keyboard/src/libkbd.c @@ -19,19 +19,20 @@ #include #include "libkbd.h" -extern int _iop_reboot_count; -static int kbd_iop = -1; static int kbd_fd = -1; static int curr_blockmode = PS2KBD_NONBLOCKING; static int curr_readmode = PS2KBD_READMODE_NORMAL; int PS2KbdInit(void) { - if (kbd_iop != _iop_reboot_count) - { - kbd_iop = _iop_reboot_count; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; kbd_fd = -1; } + } if(kbd_fd >= 0) /* Already initialised */ { diff --git a/ee/rpc/mouse/src/libmouse.c b/ee/rpc/mouse/src/libmouse.c index 46022db0314a..7cb93f5ac88b 100644 --- a/ee/rpc/mouse/src/libmouse.c +++ b/ee/rpc/mouse/src/libmouse.c @@ -36,19 +36,25 @@ static union { u32 data; u32 time; } buffer __attribute__((aligned(64))); -static int mouse_init = 0; int PS2MouseInit(void) { - if(mouse_init) + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&mouseif, 0, sizeof(mouseif)); + } + } + + if(mouseif.server) { printf("PS2Mouse Library already initialised\n"); return 0; } - mouseif.server = NULL; - do { if (sceSifBindRpc(&mouseif, PS2MOUSE_BIND_RPC_ID, 0) < 0) { return -1; @@ -56,8 +62,6 @@ int PS2MouseInit(void) nopdelay(); } while(!mouseif.server); - mouse_init = 1; - return 1; } diff --git a/ee/rpc/multitap/src/libmtap.c b/ee/rpc/multitap/src/libmtap.c index a24c20c42260..67ba81dec5ab 100644 --- a/ee/rpc/multitap/src/libmtap.c +++ b/ee/rpc/multitap/src/libmtap.c @@ -29,11 +29,20 @@ static unsigned int mtapRpcBuffer[32] __attribute__((aligned (64))); static struct t_SifRpcClientData clientPortOpen __attribute__((aligned (64))); static struct t_SifRpcClientData clientPortClose __attribute__((aligned (64))); static struct t_SifRpcClientData clientGetConnection __attribute__((aligned (64))); -static int mtapInited = 0; int mtapInit(void) { - if(mtapInited) return -1; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&clientPortOpen, 0, sizeof(clientPortOpen)); + memset(&clientPortClose, 0, sizeof(clientPortClose)); + memset(&clientGetConnection, 0, sizeof(clientGetConnection)); + } + } + if(clientPortOpen.server && clientPortClose.server && clientGetConnection.server) return -1; while(1) { @@ -59,14 +68,12 @@ int mtapInit(void) nopdelay(); } - mtapInited = 1; - return 1; } int mtapPortOpen(int port) { - if(!mtapInited) return -1; + if(!clientPortOpen.server) return -1; mtapRpcBuffer[0] = port; sceSifCallRpc(&clientPortOpen, 1, 0, mtapRpcBuffer, 4, mtapRpcBuffer, 8, NULL, NULL); @@ -76,7 +83,7 @@ int mtapPortOpen(int port) int mtapPortClose(int port) { - if(!mtapInited) return -1; + if(!clientPortClose.server) return -1; mtapRpcBuffer[0] = port; sceSifCallRpc(&clientPortClose, 1, 0, mtapRpcBuffer, 4, mtapRpcBuffer, 8, NULL, NULL); @@ -86,7 +93,7 @@ int mtapPortClose(int port) int mtapGetConnection(int port) { - if(!mtapInited) return -1; + if(!clientGetConnection.server) return -1; mtapRpcBuffer[0] = port; sceSifCallRpc(&clientGetConnection, 1, 0, mtapRpcBuffer, 4, mtapRpcBuffer, 8, NULL, NULL); diff --git a/ee/rpc/pad/src/libpad.c b/ee/rpc/pad/src/libpad.c index f5277d0e7c27..879cd416585c 100644 --- a/ee/rpc/pad/src/libpad.c +++ b/ee/rpc/pad/src/libpad.c @@ -139,7 +139,6 @@ struct open_slot u8 padding[116]; }; -extern int _iop_reboot_count; /* * Pad variables etc. */ @@ -250,6 +249,13 @@ static struct pad_state PadState[2][8]; * Local functions */ +static void padCleanup(void) +{ + memset(&padsif[0], 0, sizeof(padsif[0])); + memset(&padsif[1], 0, sizeof(padsif[1])); + padInitialised = 0; +} + /** Common helper */ static struct pad_data_new* padGetDmaStrNew(int port, int slot) @@ -301,16 +307,18 @@ padInit(int mode) { // Version check isn't used by default // int ver; - static int _rb_count = 0; int rpc_init_next; - if (_rb_count != _iop_reboot_count) { - _rb_count = _iop_reboot_count; - padInitialised = 0; + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + padCleanup(); + } } - if (padInitialised) + if (padsif[0].server && padsif[1].server) return 0; padInitialised = 0xFFFFFFFF; @@ -453,7 +461,7 @@ padEnd(void) ret = buffer.padResult.result; if (ret == 1) - padInitialised = 0; + padCleanup(); return ret; } diff --git a/ee/rpc/poweroff/src/poweroff.c b/ee/rpc/poweroff/src/poweroff.c index 1031b4ee6126..52d8f6a8bd2d 100644 --- a/ee/rpc/poweroff/src/poweroff.c +++ b/ee/rpc/poweroff/src/poweroff.c @@ -25,7 +25,6 @@ static void *poweroff_data = NULL; static u8 poffThreadStack[512 * 16] __attribute__((aligned(16))); -extern int _iop_reboot_count; static SifRpcClientData_t cd0; static struct t_SifRpcDataQueue cb_queue; static struct t_SifRpcServerData cb_srv; @@ -65,11 +64,18 @@ int poweroffInit(void) { ee_thread_t thread; int res; - static int _init_count = -1; - if (_init_count == _iop_reboot_count) + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&cd0, 0, sizeof(cd0)); + } + } + + if (cd0.server) return 0; - _init_count = _iop_reboot_count; while (((res = sceSifBindRpc(&cd0, PWROFF_IRX, 0)) < 0) || (cd0.server == NULL)) nopdelay(); diff --git a/ee/rpc/ps2snd/src/ps2snd.c b/ee/rpc/ps2snd/src/ps2snd.c index 00b6f9329736..5fe799c6ee52 100644 --- a/ee/rpc/ps2snd/src/ps2snd.c +++ b/ee/rpc/ps2snd/src/ps2snd.c @@ -20,6 +20,14 @@ static SifRpcClientData_t sd_client ALIGNED(64); int sceSdInit(int flag) { s32 buf[1] ALIGNED(64); + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + memset(&sd_client, 0, sizeof(sd_client)); + } + } { diff --git a/ee/rpc/remote/src/librm.c b/ee/rpc/remote/src/librm.c index edda2c6683c2..f62338a297c8 100644 --- a/ee/rpc/remote/src/librm.c +++ b/ee/rpc/remote/src/librm.c @@ -22,7 +22,7 @@ static SifRpcClientData_t rmmanif __attribute__((aligned(64))); static struct rmRpcPacket buffer __attribute__((aligned(64))); -static int rmman_type = 0; +static int rmman_type; struct port_state { @@ -51,11 +51,25 @@ static struct rmEEData *rmGetDmaStr(int port, int slot) } } +static void RMMan_Cleanup(void) +{ + memset(&rmmanif, 0, sizeof(rmmanif)); + rmman_type = 0; +} + int RMMan_Init(void) { int i; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + RMMan_Cleanup(); + } + } - if (rmman_type) + if (rmmanif.server) { printf("RMMan Library already initialised\n"); return 0; diff --git a/ee/rpc/secr/src/libsecr.c b/ee/rpc/secr/src/libsecr.c index 9d655efd7050..a8f80e154aa6 100644 --- a/ee/rpc/secr/src/libsecr.c +++ b/ee/rpc/secr/src/libsecr.c @@ -20,6 +20,15 @@ static unsigned char RpcBuffer[0x1000] ALIGNED(64); int SecrInit(void) { + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + SecrDeinit(); + } + } + sceSifInitRpc(0); nopdelay(); diff --git a/ee/rpc/tcpips/src/ps2ipc.c b/ee/rpc/tcpips/src/ps2ipc.c index d25b836f8063..53433897866b 100644 --- a/ee/rpc/tcpips/src/ps2ipc.c +++ b/ee/rpc/tcpips/src/ps2ipc.c @@ -21,7 +21,6 @@ #include #include -static int _init_check = 0; static int lock_sema = -1; static SifRpcClientData_t _ps2ip; static struct { @@ -64,6 +63,17 @@ extern void _ps2sdk_ps2ipc_deinit(void); int ps2ip_init(void) { ee_sema_t sema; + { + static int _rb_count; + extern int _iop_reboot_count; + if (_rb_count != _iop_reboot_count) { + _rb_count = _iop_reboot_count; + ps2ip_deinit(); + } + } + + if (_ps2ip.server) + return 0; while(1) { @@ -84,8 +94,6 @@ int ps2ip_init(void) _ps2sdk_ps2ipc_init(); - _init_check = 1; - return 0; } @@ -97,7 +105,7 @@ void ps2ip_deinit(void) DeleteSema(lock_sema); lock_sema = -1; - _init_check = 0; + memset(&_ps2ip, 0, sizeof(_ps2ip)); } int ps2ipc_accept(int s, struct sockaddr *addr, int *addrlen) @@ -105,7 +113,7 @@ int ps2ipc_accept(int s, struct sockaddr *addr, int *addrlen) int result; cmd_pkt *pkt = &_rpc_buffer.cmd_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -135,7 +143,7 @@ int ps2ipc_bind(int s, const struct sockaddr *name, int namelen) cmd_pkt *pkt = &_rpc_buffer.cmd_pkt; int result; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -160,7 +168,7 @@ int ps2ipc_disconnect(int s) { int result; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -184,7 +192,7 @@ int ps2ipc_connect(int s, const struct sockaddr *name, int namelen) int result; cmd_pkt *pkt = &_rpc_buffer.cmd_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -210,7 +218,7 @@ int ps2ipc_listen(int s, int backlog) int result; listen_pkt *pkt = &_rpc_buffer.listen_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -251,7 +259,7 @@ int ps2ipc_recv(int s, void *mem, int len, unsigned int flags) s_recv_pkt *send_pkt = &_rpc_buffer.s_recv_pkt; r_recv_pkt *recv_pkt = &_rpc_buffer.r_recv_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -285,7 +293,7 @@ int ps2ipc_recvfrom(int s, void *mem, int len, unsigned int flags, s_recv_pkt *send_pkt = &_rpc_buffer.s_recv_pkt; r_recv_pkt *recv_pkt = &_rpc_buffer.r_recv_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -412,7 +420,7 @@ int ps2ipc_socket(int domain, int type, int protocol) int result; socket_pkt *pkt = &_rpc_buffer.socket_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -437,7 +445,7 @@ int ps2ipc_ps2ip_setconfig(const t_ip_info *ip_info) { int result; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -459,7 +467,7 @@ int ps2ipc_ps2ip_setconfig(const t_ip_info *ip_info) int ps2ipc_ps2ip_getconfig(char *netif_name, t_ip_info *ip_info) { - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -518,7 +526,7 @@ int ps2ipc_select(int maxfdp1, struct fd_set *readset, struct fd_set *writeset, int result; select_pkt *pkt = &_rpc_buffer.select_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -565,7 +573,7 @@ int ps2ipc_ioctl(int s, long cmd, void *argp) int result; ioctl_pkt *pkt = &_rpc_buffer.ioctl_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -596,7 +604,7 @@ int ps2ipc_getsockname(int s, struct sockaddr *name, int *namelen) int result; cmd_pkt *pkt = &_rpc_buffer.cmd_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -623,7 +631,7 @@ int ps2ipc_getpeername(int s, struct sockaddr *name, int *namelen) int result; cmd_pkt *pkt = &_rpc_buffer.cmd_pkt; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -651,7 +659,7 @@ int ps2ipc_getsockopt(int s, int level, int optname, void* optval, socklen_t* op getsockopt_res_pkt *res_pkt = &_rpc_buffer.getsockopt_res_pkt; int result; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -680,7 +688,7 @@ int ps2ipc_setsockopt(int s, int level, int optname, const void *optval, socklen setsockopt_pkt *pkt = &_rpc_buffer.setsockopt_pkt; int result; - if(!_init_check) return -1; + if(!_ps2ip.server) return -1; WaitSema(lock_sema); @@ -713,7 +721,7 @@ struct hostent *ps2ipc_gethostbyname(const char *name) static ip_addr_t *addr_list[2]; static struct hostent hostent; - if(!_init_check) return NULL; + if(!_ps2ip.server) return NULL; WaitSema(lock_sema); @@ -745,7 +753,7 @@ void ps2ipc_dns_setserver(u8 numdns, const ip_addr_t *dnsserver) { dns_setserver_pkt *pkt = &_rpc_buffer.dns_setserver_pkt; - if(!_init_check) return; + if(!_ps2ip.server) return; WaitSema(lock_sema); @@ -765,7 +773,7 @@ const ip_addr_t *ps2ipc_dns_getserver(u8 numdns) dns_getserver_res_pkt *res_pkt = &_rpc_buffer.dns_getserver_res_pkt; ip_addr_t *dns; - if ((!_init_check) || (numdns >= DNS_MAX_SERVERS)) + if ((!_ps2ip.server) || (numdns >= DNS_MAX_SERVERS)) return IP4_ADDR_ANY; WaitSema(lock_sema);