sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
packet.c
1
#include <
string.h
>
2
#include <
stdlib.h
>
3
#include <malloc.h>
4
#include <
packet.h
>
5
6
#define SPR_BEGIN 0x70000000
7
8
packet_t
*
packet_init
(
int
qwords,
int
type)
9
{
10
11
int
byte_size = 0;
12
packet_t
*packet = (
packet_t
*)calloc(1,
sizeof
(
packet_t
));
13
14
if
(packet == NULL)
15
{
16
17
return
NULL;
18
19
}
20
21
if
(type == PACKET_SPR)
22
{
23
24
packet->data = (qword_t *)SPR_BEGIN;
25
packet->qwc = 0x1000;
26
27
}
28
else
29
{
30
// Size of qwords in bytes.
31
byte_size = qwords << 4;
32
33
// Allocate the data area in bytes aligned to cache line.
34
if
((packet->data = memalign(64, byte_size)) == NULL)
35
{
36
free(packet);
37
return
NULL;
38
39
}
40
}
41
42
// Set the pointer attribute to ucab space.
43
if
(type == PACKET_UCAB)
44
{
45
46
packet->data = (qword_t *)((u32)packet->data | 0x30000000);
47
48
}
49
50
// Clear the packet area.
51
memset(packet->data, 0, byte_size);
52
53
// Set the packet counts
54
packet->qwc = 0;
55
packet->qwords = qwords;
56
packet->type = type;
57
58
// End function.
59
return
packet;
60
61
}
62
63
void
packet_free
(
packet_t
*packet)
64
{
65
66
// Free the allocated data buffer.
67
if
(packet->type == PACKET_SPR)
68
{
69
70
packet->data = NULL;
71
72
}
73
else
74
{
75
if
(packet->type == PACKET_UCAB)
76
{
77
78
packet->data = (qword_t *)((u32)packet->data ^ 0x30000000);
79
80
}
81
82
free(packet->data);
83
}
84
85
free(packet);
86
87
}
88
89
void
packet_reset
(
packet_t
*packet)
90
{
91
92
// Reset the quadword counter.
93
packet->qwc = 0;
94
95
if
(packet->type == PACKET_SPR)
96
{
97
98
packet->data = (qword_t *)SPR_BEGIN;
99
return
;
100
101
}
102
103
// Zero out the data
104
memset(packet->data, 0, packet->qwords << 4);
105
106
}
packet.h
packet_init
packet_t * packet_init(int qwords, int type)
Definition
packet.c:8
packet_free
void packet_free(packet_t *packet)
Definition
packet.c:63
packet_reset
void packet_reset(packet_t *packet)
Definition
packet.c:89
stdlib.h
string.h
packet_t
Definition
packet.h:24
core
packet
src
packet.c
Generated by
1.18.0