Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EE RPC]: break all RPC binding after 100 retries #698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ee/kernel/src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <fileio.h>
#include <string.h>
#include <fileio-common.h>
#include <loadfile.h>

#define D(fmt, args...) printf("(%s:%s:%i):" #fmt, __FILE__, __FUNCTION__, __LINE__, ##args)

Expand Down Expand Up @@ -50,6 +51,7 @@ int _fio_completion_sema = -1;
#ifdef F_fio_init
int fioInit(void)
{
int bind_retry = 100;
int res;
ee_sema_t sema;
static int _rb_count = 0;
Expand All @@ -66,8 +68,10 @@ int fioInit(void)
SifInitRpc(0);

while (((res = SifBindRpc(&_fio_cd, 0x80000001, 0)) >= 0) &&
(_fio_cd.server == NULL))
nopdelay();
(_fio_cd.server == NULL)) {
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
}

if (res < 0)
return res;
Expand Down
8 changes: 5 additions & 3 deletions ee/kernel/src/iopheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Review ps2sdk README & LICENSE files for further details.
*/

#include <loadfile.h>
#include "tamtypes.h"
#include "ps2lib_err.h"
#include "kernel.h"
Expand All @@ -31,7 +32,7 @@ int _ih_caps = 0;

int SifInitIopHeap()
{
int res;
int res, bind_retry = 100;

static int _rb_count = 0;
if (_rb_count != _iop_reboot_count) {
Expand All @@ -46,9 +47,10 @@ int SifInitIopHeap()

SifInitRpc(0);

while ((res = SifBindRpc(&_ih_cd, 0x80000003, 0)) >= 0 && !_ih_cd.server)
while ((res = SifBindRpc(&_ih_cd, 0x80000003, 0)) >= 0 && !_ih_cd.server) {
nopdelay();

if (--bind_retry < 1) return -SCE_EBINDMISS;
}
if (res < 0)
return -E_SIF_RPC_BIND;

Expand Down
7 changes: 4 additions & 3 deletions ee/kernel/src/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int _lf_init = 0;

int SifLoadFileInit()
{
int res;
int res, bind_retry = 100;;
static int _rb_count = 0;
if (_rb_count != _iop_reboot_count) {
_rb_count = _iop_reboot_count;
Expand All @@ -52,9 +52,10 @@ int SifLoadFileInit()

SifInitRpc(0);

while ((res = SifBindRpc(&_lf_cd, 0x80000006, 0)) >= 0 && !_lf_cd.server)
while ((res = SifBindRpc(&_lf_cd, 0x80000006, 0)) >= 0 && !_lf_cd.server) {
nopdelay();

if (--bind_retry < 1) return -SCE_EBINDMISS;
}
if (res < 0)
return -E_SIF_RPC_BIND;

Expand Down
7 changes: 5 additions & 2 deletions ee/network/netman/src/rpc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <malloc.h>
#include <netman.h>
#include <netman_rpc.h>
#include <loadfile.h>

#include "rpc_client.h"

Expand Down Expand Up @@ -56,7 +57,7 @@ static void NETMAN_TxThread(void *arg);

int NetManInitRPCClient(void){
static const char NetManID[]="NetMan";
int result;
int result, bind_retry = 100;
ee_sema_t SemaData;
ee_thread_t thread;

Expand Down Expand Up @@ -88,8 +89,10 @@ int NetManInitRPCClient(void){
return NETMAN_Tx_threadID;
}

while((SifBindRpc(&NETMAN_rpc_cd, NETMAN_RPC_NUMBER, 0)<0)||(NETMAN_rpc_cd.server==NULL))
while((SifBindRpc(&NETMAN_rpc_cd, NETMAN_RPC_NUMBER, 0)<0)||(NETMAN_rpc_cd.server==NULL)) {
if (--bind_retry < 1) return -SCE_EBINDMISS;
nopdelay();
}

if((result=SifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_INIT, 0, NULL, 0, &ReceiveBuffer, sizeof(s32), NULL, NULL))>=0)
{
Expand Down
4 changes: 3 additions & 1 deletion ee/rpc/ahx/src/ahx_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <loadfile.h>
#include "ahx_rpc.h"

static unsigned sbuff[64] __attribute__((aligned (64)));
Expand Down Expand Up @@ -51,7 +52,7 @@ int AHX_Init()

// if already init'd, exit
if (ahx_init_done) return 0;

int bind_retry = 100;
// bind rpc
while(1){
int i;
Expand All @@ -60,6 +61,7 @@ int AHX_Init()
if (cd0.server != 0) break;
i = 0x10000;
while(i--);
if (--bind_retry < 1) return -SCE_EBINDMISS;
}

SifCallRpc(&cd0,AHX_INIT,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,NULL,NULL);
Expand Down
6 changes: 6 additions & 0 deletions ee/rpc/audsrv/src/audsrv_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <sifrpc.h>
#include <tamtypes.h>
#include <string.h>
#include <loadfile.h>
#include <iopheap.h>

#include <audsrv.h>
Expand Down Expand Up @@ -353,6 +354,11 @@ int audsrv_init()
}

nopdelay();

if (--bind_retry < 1) {
set_error(AUDSRV_ERR_RPC_FAILED);
return -SCE_EBINDMISS;
}
}

compSema.init_count = 1;
Expand Down
11 changes: 7 additions & 4 deletions ee/rpc/camera/src/ps2cam_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <tamtypes.h>
#include <kernel.h>
#include <loadfile.h>
#include <sifrpc.h>
#include <stdio.h>
#include <string.h>
Expand All @@ -36,18 +37,20 @@ int sem;

int PS2CamInit(int mode)
{
int ret=0;
int *buf;
int ret = 0;
int *buf;
int bind_retry = 100;
// unsigned int i;
// int timeout = 100000;

if(CamInited)return 0;

SifInitRpc(0);

while (((ret = SifBindRpc(&cdata, PS2_CAM_RPC_ID, 0)) >= 0) && (cdata.server == NULL))
while (((ret = SifBindRpc(&cdata, PS2_CAM_RPC_ID, 0)) >= 0) && (cdata.server == NULL)) {
if (--bind_retry < 1) return -SCE_EBINDMISS;
nopdelay();

}
nopdelay();


Expand Down
3 changes: 3 additions & 0 deletions ee/rpc/cdvd/src/libcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <sifrpc.h>
#include <string.h>
#include <libcdvd.h>
#include <loadfile.h>
#include <stdarg.h>

#include "internal.h"
Expand Down Expand Up @@ -121,6 +122,7 @@ extern u32 searchFileRecvBuff;
#ifdef F_sceCdInit
s32 sceCdInit(s32 mode)
{
int bind_retry = 100;
if (_CdSyncS(1))
return 0;
SifInitRpc(0);
Expand All @@ -139,6 +141,7 @@ s32 sceCdInit(s32 mode)
break;

nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
}

bindInit = 0;
Expand Down
7 changes: 5 additions & 2 deletions ee/rpc/filexio/src/fileXio_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <sys/fcntl.h>
#include <loadfile.h>
#include <sys/stat.h>
#include <ps2sdkapi.h>

Expand Down Expand Up @@ -93,7 +94,7 @@ static inline int _unlock(void)
#ifdef F_fileXioInit
int fileXioInit(void)
{
int res;
int res, bind_retry = 100;
ee_sema_t sp;
static int _rb_count = 0;

Expand All @@ -114,8 +115,10 @@ int fileXioInit(void)
sp.option = 0;
__lock_sema_id = CreateSema(&sp);

while(((res = SifBindRpc(&__cd0, FILEXIO_IRX, 0)) >= 0) && (__cd0.server == NULL))
while(((res = SifBindRpc(&__cd0, FILEXIO_IRX, 0)) >= 0) && (__cd0.server == NULL)) {
if (--bind_retry < 1) return -SCE_EBINDMISS;
nopdelay();
}

if(res < 0)
return res;
Expand Down
4 changes: 3 additions & 1 deletion ee/rpc/memorycard/src/libmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <string.h>
#include "libmc.h"

Expand Down Expand Up @@ -229,7 +230,7 @@ static void mcStoreDir(void* arg)

int mcInit(int type)
{
int ret=0;
int ret = 0, bind_retry = 100;
mcRpcStat_t *rpcStat = (mcRpcStat_t*)UNCACHED_SEG(&g_rdata.rpcStat);
static int _rb_count = 0;

Expand Down Expand Up @@ -260,6 +261,7 @@ int mcInit(int type)
}
if(g_cdata.server == NULL)
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
}
while (g_cdata.server == NULL);

Expand Down
10 changes: 6 additions & 4 deletions ee/rpc/mouse/src/libmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <stdio.h>
#include <tamtypes.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <kernel.h>
#include <string.h>
#include "libmouse.h"
Expand All @@ -39,13 +40,13 @@ static union {
static int mouse_init = 0;

int PS2MouseInit(void)

{
if(mouse_init)
{
int bind_retry = 100;
if (mouse_init)
{
printf("PS2Mouse Library already initialised\n");
return 0;
}
}

mouseif.server = NULL;

Expand All @@ -54,6 +55,7 @@ int PS2MouseInit(void)
return -1;
}
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
} while(!mouseif.server);

mouse_init = 1;
Expand Down
13 changes: 10 additions & 3 deletions ee/rpc/multitap/src/libmtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <tamtypes.h>
#include <string.h>
#include <kernel.h>
#include <loadfile.h>
#include <sifrpc.h>
#include <stdarg.h>

Expand All @@ -33,30 +34,36 @@ static int mtapInited = 0;

int mtapInit(void)
{
int bind_retry = 100;
if(mtapInited) return -1;

while(1)
{
if (SifBindRpc(&clientPortOpen, MTAPSERV_PORT_OPEN, 0) < 0) return -1;
if (clientPortOpen.server != 0) break;
if (--bind_retry < 1) return -SCE_EBINDMISS;

nopdelay();
nopdelay();
}

bind_retry = 100;
while(1)
{
if (SifBindRpc(&clientPortClose, MTAPSERV_PORT_CLOSE, 0) < 0) return -1;
if (clientPortClose.server != 0) break;
if (--bind_retry < 1) return -SCE_EBINDMISS;

nopdelay();
nopdelay();
}

bind_retry = 100;
while(1)
{
if (SifBindRpc(&clientGetConnection, MTAPSERV_GET_CONNECTION, 0) < 0) return -1;
if (clientGetConnection.server != 0) break;
if (--bind_retry < 1) return -SCE_EBINDMISS;

nopdelay();
nopdelay();
}

mtapInited = 1;
Expand Down
5 changes: 5 additions & 0 deletions ee/rpc/pad/src/libpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <sifcmd.h>
#include "libpad.h"

Expand Down Expand Up @@ -299,6 +300,7 @@ padInit(int mode)
// Version check isn't used by default
// int ver;
static int _rb_count = 0;
int bind_retry = 100;

if (_rb_count != _iop_reboot_count)
{
Expand All @@ -319,13 +321,16 @@ padInit(int mode)
return -1;
}
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
} while(!padsif[0].server);

bind_retry = 100;
do {
if (SifBindRpc(&padsif[1], PAD_BIND_RPC_ID2, 0) < 0) {
return -3;
}
nopdelay();
if (--bind_retry < 1) return -SCE_EBINDMISS;
} while(!padsif[1].server);

// If you require a special version of the padman, check for that here (uncomment)
Expand Down
Loading
Loading