sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
libmtap.c
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
15
16
#include <
tamtypes.h
>
17
#include <
string.h
>
18
#include <
kernel.h
>
19
#include <sifrpc.h>
20
#include <stdarg.h>
21
#include <
iopcontrol.h
>
22
23
#include "
libmtap.h
"
24
25
#define MTAPSERV_PORT_OPEN 0x80000901
26
#define MTAPSERV_PORT_CLOSE 0x80000902
27
#define MTAPSERV_GET_CONNECTION 0x80000903
28
29
static
unsigned
int
mtapRpcBuffer[32]
__attribute__
((aligned (64)));
30
static
struct
t_SifRpcClientData
clientPortOpen
__attribute__
((aligned (64)));
31
static
struct
t_SifRpcClientData
clientPortClose
__attribute__
((aligned (64)));
32
static
struct
t_SifRpcClientData
clientGetConnection
__attribute__
((aligned (64)));
33
34
int
mtapInit
(
void
)
35
{
36
if
(HasIopRebootedSinceLastCall())
37
{
38
memset(&clientPortOpen, 0,
sizeof
(clientPortOpen));
39
memset(&clientPortClose, 0,
sizeof
(clientPortClose));
40
memset(&clientGetConnection, 0,
sizeof
(clientGetConnection));
41
}
42
if
(clientPortOpen.server && clientPortClose.server && clientGetConnection.server)
return
-1;
43
44
while
(1)
45
{
46
if
(sceSifBindRpc(&clientPortOpen, MTAPSERV_PORT_OPEN, 0) < 0)
return
-1;
47
if
(clientPortOpen.server != 0)
break
;
48
49
nopdelay();
50
}
51
52
while
(1)
53
{
54
if
(sceSifBindRpc(&clientPortClose, MTAPSERV_PORT_CLOSE, 0) < 0)
return
-1;
55
if
(clientPortClose.server != 0)
break
;
56
57
nopdelay();
58
}
59
60
while
(1)
61
{
62
if
(sceSifBindRpc(&clientGetConnection, MTAPSERV_GET_CONNECTION, 0) < 0)
return
-1;
63
if
(clientGetConnection.server != 0)
break
;
64
65
nopdelay();
66
}
67
68
return
1;
69
}
70
71
int
mtapPortOpen
(
int
port)
72
{
73
if
(!clientPortOpen.server)
return
-1;
74
75
mtapRpcBuffer[0] = port;
76
sceSifCallRpc(&clientPortOpen, 1, 0, mtapRpcBuffer, 4, mtapRpcBuffer, 8, NULL, NULL);
77
78
return
mtapRpcBuffer[1];
79
}
80
81
int
mtapPortClose
(
int
port)
82
{
83
if
(!clientPortClose.server)
return
-1;
84
85
mtapRpcBuffer[0] = port;
86
sceSifCallRpc(&clientPortClose, 1, 0, mtapRpcBuffer, 4, mtapRpcBuffer, 8, NULL, NULL);
87
88
return
mtapRpcBuffer[1];
89
}
90
91
int
mtapGetConnection
(
int
port)
92
{
93
if
(!clientGetConnection.server)
return
-1;
94
95
mtapRpcBuffer[0] = port;
96
sceSifCallRpc(&clientGetConnection, 1, 0, mtapRpcBuffer, 4, mtapRpcBuffer, 8, NULL, NULL);
97
98
return
mtapRpcBuffer[1];
99
}
iopcontrol.h
kernel.h
libmtap.h
mtapInit
int mtapInit(void)
Definition
libmtap.c:34
mtapGetConnection
int mtapGetConnection(int port)
Definition
libmtap.c:91
mtapPortClose
int mtapPortClose(int port)
Definition
libmtap.c:81
mtapPortOpen
int mtapPortOpen(int port)
Definition
libmtap.c:71
string.h
__attribute__
Definition
gif_registers.h:40
t_SifRpcClientData
Definition
sifrpc-common.h:136
tamtypes.h
core
mtap
src
libmtap.c
Generated by
1.18.0