ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
rpc_client.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int NetManInitRPCClient (void)
 
void NetManDeinitRPCClient (void)
 
int NetManRPCRegisterNetworkStack (void)
 
int NetManRPCUnregisterNetworkStack (void)
 
int NetManRpcIoctl (unsigned int command, void *arg, unsigned int arg_len, void *output, unsigned int length)
 
void NetManRpcNetIFXmit (void)
 

Function Documentation

◆ NetManDeinitRPCClient()

void NetManDeinitRPCClient ( void  )

Definition at line 160 of file rpc_client.c.

161 {
162  if(IsInitialized)
163  {
165 
167  deinitCleanup();
168 
169  IsInitialized=0;
170  }
171 }
s32 WaitSema(s32 sema_id)
@ NETMAN_IOP_RPC_FUNC_DEINIT
Definition: netman_rpc.h:24
static SifRpcClientData_t NETMAN_rpc_cd
Definition: rpc_client.c:11
static int NetManIOSemaID
Definition: rpc_client.c:30
static void deinitCleanup(void)
Definition: rpc_client.c:40
static unsigned char IsInitialized
Definition: rpc_client.c:38
int SifCallRpc(SifRpcClientData_t *client, int rpc_number, int mode, void *send, int ssize, void *receive, int rsize, SifRpcEndFunc_t end_function, void *end_param)
#define NULL
Definition: tamtypes.h:91

References deinitCleanup(), IsInitialized, NETMAN_IOP_RPC_FUNC_DEINIT, NETMAN_rpc_cd, NetManIOSemaID, NULL, SifCallRpc(), and WaitSema().

Referenced by NetManDeinit().

◆ NetManInitRPCClient()

int NetManInitRPCClient ( void  )

Definition at line 57 of file rpc_client.c.

57  {
58  static const char NetManID[]="NetMan";
59  int result;
60  ee_sema_t SemaData;
61  ee_thread_t thread;
62 
63  if(!IsInitialized)
64  {
65  SemaData.max_count=1;
66  SemaData.init_count=1;
67  SemaData.option=(u32)NetManID;
68  SemaData.attr=0;
69  if((NetManIOSemaID=CreateSema(&SemaData)) < 0)
70  {
71  deinitCleanup();
72  return NetManIOSemaID;
73  }
74 
75  thread.func=&NETMAN_TxThread;
77  thread.stack_size=sizeof(NETMAN_Tx_ThreadStack);
78  thread.gp_reg=&_gp;
79  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. */
80  thread.attr=thread.option=0;
81 
82  if((NETMAN_Tx_threadID=CreateThread(&thread)) >= 0)
83  {
84  IsProcessingTx = 0;
86  } else {
87  deinitCleanup();
88  return NETMAN_Tx_threadID;
89  }
90 
92  nopdelay();
93 
95  {
96  if((result=ReceiveBuffer.result) == 0)
97  IsInitialized=1;
98  else
99  deinitCleanup();
100  }else{
101  deinitCleanup();
102  }
103  }
104  else result=0;
105 
106  return result;
107 }
s32 CreateSema(ee_sema_t *sema)
static void nopdelay(void)
Definition: kernel.h:141
s32 CreateThread(ee_thread_t *thread)
s32 StartThread(s32 thread_id, void *args)
#define NETMAN_RPC_NUMBER
Definition: netman_rpc.h:12
@ NETMAN_IOP_RPC_FUNC_INIT
Definition: netman_rpc.h:23
static unsigned char NETMAN_Tx_ThreadStack[0x1000]
Definition: rpc_client.c:31
static unsigned char IsProcessingTx
Definition: rpc_client.c:38
static int NETMAN_Tx_threadID
Definition: rpc_client.c:30
void * _gp
static union @21 ReceiveBuffer
static void NETMAN_TxThread(void *arg)
Definition: rpc_client.c:197
s32 result
Definition: rpc_client.c:23
int SifBindRpc(SifRpcClientData_t *client, int rpc_number, int mode)
struct t_SifRpcServerData * server
Definition: sifrpc.h:142
int init_count
Definition: kernel.h:218
int max_count
Definition: kernel.h:217
u32 option
Definition: kernel.h:221
u32 attr
Definition: kernel.h:220
void * gp_reg
Definition: kernel.h:230
u32 option
Definition: kernel.h:234
int stack_size
Definition: kernel.h:229
void * func
Definition: kernel.h:227
void * stack
Definition: kernel.h:228
u32 attr
Definition: kernel.h:233
int initial_priority
Definition: kernel.h:231
signed int s32
Definition: tamtypes.h:58
unsigned int u32
Definition: tamtypes.h:30

References _gp, ee_sema_t::attr, ee_thread_t::attr, CreateSema(), CreateThread(), deinitCleanup(), ee_thread_t::func, ee_thread_t::gp_reg, ee_sema_t::init_count, ee_thread_t::initial_priority, IsInitialized, IsProcessingTx, ee_sema_t::max_count, NETMAN_IOP_RPC_FUNC_INIT, NETMAN_rpc_cd, NETMAN_RPC_NUMBER, NETMAN_Tx_threadID, NETMAN_Tx_ThreadStack, NETMAN_TxThread(), NetManIOSemaID, nopdelay(), NULL, ee_sema_t::option, ee_thread_t::option, ReceiveBuffer, result, SifRpcClientData_t::server, SifBindRpc(), SifCallRpc(), ee_thread_t::stack, ee_thread_t::stack_size, and StartThread().

Referenced by NetManInit().

◆ NetManRpcIoctl()

int NetManRpcIoctl ( unsigned int  command,
void *  arg,
unsigned int  arg_len,
void *  output,
unsigned int  length 
)

Definition at line 173 of file rpc_client.c.

174 {
175  int result;
176  struct NetManIoctl *IoctlArgs=&TransmitBuffer.IoctlArgs;
177 
179 
181  memcpy(IoctlArgs->args, args, args_len);
185 
187  {
188  result=ReceiveBuffer.IoctlResult.result;
189  memcpy(output, ReceiveBuffer.IoctlResult.output, length);
190  }
191 
193 
194  return result;
195 }
s32 SignalSema(s32 sema_id)
s32 command
Definition: libpad.c:156
@ NETMAN_IOP_RPC_FUNC_IOCTL
Definition: netman_rpc.h:27
static union @20 TransmitBuffer
struct NetManIoctl IoctlArgs
Definition: rpc_client.c:16
u32 args_len
Definition: netman_rpc.h:59
u8 args[64]
Definition: netman_rpc.h:58
void * output
Definition: netman_rpc.h:60

References NetManIoctl::args, NetManIoctl::args_len, NetManIoctl::command, command, IoctlArgs, NetManIoctl::length, NETMAN_IOP_RPC_FUNC_IOCTL, NETMAN_rpc_cd, NetManIOSemaID, NULL, NetManIoctl::output, ReceiveBuffer, result, SifCallRpc(), SignalSema(), TransmitBuffer, and WaitSema().

Referenced by NetManIoctl().

◆ NetManRpcNetIFXmit()

void NetManRpcNetIFXmit ( void  )

Definition at line 284 of file rpc_client.c.

285 {
286  if(!IsProcessingTx)
288 }
s32 WakeupThread(s32 thread_id)

References IsProcessingTx, NETMAN_Tx_threadID, and WakeupThread().

Referenced by NetManNetIFXmit().

◆ NetManRPCRegisterNetworkStack()

int NetManRPCRegisterNetworkStack ( void  )

Definition at line 109 of file rpc_client.c.

110 {
111  int result;
112 
114 
115  if(FrameBufferStatus == NULL) FrameBufferStatus = memalign(64, NETMAN_RPC_BLOCK_SIZE * sizeof(struct NetManBD));
116 
117  if(FrameBufferStatus != NULL)
118  {
119  memset(UNCACHED_SEG(FrameBufferStatus), 0, NETMAN_RPC_BLOCK_SIZE * sizeof(struct NetManBD));
120  TransmitBuffer.NetStack.FrameBufferStatus = FrameBufferStatus;
122 
124  {
125  if((result=ReceiveBuffer.NetStackResult.result) == 0)
126  {
127  IOPFrameBuffer = ReceiveBuffer.NetStackResult.FrameBuffer;
128  IOPFrameBufferStatus = ReceiveBuffer.NetStackResult.FrameBufferStatus;
129  }
130  }
131  }
132  else
133  {
134  result = -ENOMEM;
135  }
136 
138 
139  return result;
140 }
#define ENOMEM
Definition: errno.h:42
#define UNCACHED_SEG(x)
Definition: kernel.h:35
#define NETMAN_RPC_BLOCK_SIZE
Definition: netman_rpc.h:54
@ NETMAN_IOP_RPC_FUNC_REG_NETWORK_STACK
Definition: netman_rpc.h:25
static struct NetManBD * IOPFrameBufferStatus
Definition: rpc_client.c:35
static unsigned short int IOPFrameBufferWrPtr
Definition: rpc_client.c:33
static u8 * IOPFrameBuffer
Definition: rpc_client.c:34
static struct NetManBD * FrameBufferStatus
Definition: rpc_client.c:36

References ENOMEM, FrameBufferStatus, IOPFrameBuffer, IOPFrameBufferStatus, IOPFrameBufferWrPtr, NETMAN_IOP_RPC_FUNC_REG_NETWORK_STACK, NETMAN_RPC_BLOCK_SIZE, NETMAN_rpc_cd, NetManIOSemaID, NULL, ReceiveBuffer, result, SifCallRpc(), SignalSema(), TransmitBuffer, UNCACHED_SEG, and WaitSema().

Referenced by NetManRegisterNetworkStack().

◆ NetManRPCUnregisterNetworkStack()

int NetManRPCUnregisterNetworkStack ( void  )