ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).

Macros

#define PACKET2_COUNT_QWC   1 << 16
 

Functions

static void packet2_chain_set_dma_tag (dma_tag_t *tag, u32 qwc, u32 pce, u32 id, u8 irq, const u128 *addr, u8 spr)
 
static void packet2_chain_add_dma_tag (packet2_t *packet2, u32 qwc, u32 pce, enum DmaTagType id, u8 irq, const u128 *addr, u8 spr)
 
static void packet2_chain_close_tag (packet2_t *packet2)
 
static void packet2_chain_open_cnt (packet2_t *packet2, u8 irq, u32 pce, u8 spr)
 
static void packet2_chain_open_end (packet2_t *packet2, u8 irq, u32 pce)
 
static void packet2_chain_ref (packet2_t *packet2, const void *ref_data, u32 qw_length, u8 irq, u8 spr, u32 pce)
 
static void packet2_chain_next (packet2_t *packet2, const dma_tag_t *next_tag, u8 irq, u8 spr, u32 pce)
 
static void packet2_chain_refs (packet2_t *packet2, const void *ref_data, u32 qw_length, u8 irq, u8 spr, u32 pce)
 
static void packet2_chain_refe (packet2_t *packet2, const void *ref_data, u32 qw_length, u8 irq, u8 spr, u32 pce)
 
static void packet2_chain_call (packet2_t *packet2, const void *next_tag, u8 irq, u8 spr, u32 pce)
 
static void packet2_chain_ret (packet2_t *packet2, u8 irq, u32 pce)
 

Detailed Description

Chain mode related functions of libpacket2.

Macro Definition Documentation

◆ PACKET2_COUNT_QWC

#define PACKET2_COUNT_QWC   1 << 16

Definition at line 26 of file packet2_chain.h.

Function Documentation

◆ packet2_chain_add_dma_tag()

static void packet2_chain_add_dma_tag ( packet2_t packet2,
u32  qwc,
u32  pce,
enum DmaTagType  id,
u8  irq,
const u128 addr,
u8  spr 
)
inlinestatic

Add dma tag. For more details, check description of dma_tag_t. Will move current buffer position by: DWORD if packet->tte == true, QWORD if packet->tte == false

Parameters
packet2Pointer to packet.
qwcQword count. If you want to use packet2_chain_close_tag(), and count qwords automatically, set value to PACKET2_COUNT_QWC.
pcePriority Control Enable. 0 by default.
idTag ID.
irqInterrupt Request. False by default.
addrAddress.
sprMemory/SPR Selection. False by default.

Definition at line 74 of file packet2_chain.h.

75  {
76  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
77  assert(packet2->tag_opened_at == NULL); // All previous tags are closed.
78 
79  if (qwc == PACKET2_COUNT_QWC)
80  {
81  packet2_chain_set_dma_tag((dma_tag_t *)packet2->next, 0, pce, id, irq, addr, spr); // placeholder
82  packet2->tag_opened_at = (dma_tag_t *)packet2->next;
83  }
84  else
85  {
86  packet2_chain_set_dma_tag((dma_tag_t *)packet2->next, qwc, pce, id, irq, addr, spr);
87  packet2->tag_opened_at = (dma_tag_t *)NULL;
88  }
89  if (!packet2->tte)
90  packet2_advance_next(packet2, sizeof(dma_tag_t));
91  else
92  packet2_advance_next(packet2, sizeof(u64));
93  }
#define PACKET2_COUNT_QWC
Definition: packet2_chain.h:26
static void packet2_chain_set_dma_tag(dma_tag_t *tag, u32 qwc, u32 pce, u32 id, u8 irq, const u128 *addr, u8 spr)
Definition: packet2_chain.h:48
static void packet2_advance_next(packet2_t *packet2, u32 i)
Definition: packet2.h:96
dma_tag_t * tag_opened_at
qword_t * next
#define NULL
Definition: tamtypes.h:91
unsigned int u32
Definition: tamtypes.h:30
unsigned long u64
Definition: tamtypes.h:34

References packet2_t::next, NULL, packet2_advance_next(), packet2_chain_set_dma_tag(), PACKET2_COUNT_QWC, packet2_t::tag_opened_at, and packet2_t::tte.

Referenced by packet2_chain_call(), packet2_chain_next(), packet2_chain_open_cnt(), packet2_chain_open_end(), packet2_chain_ref(), packet2_chain_refe(), packet2_chain_refs(), and packet2_chain_ret().

◆ packet2_chain_call()

static void packet2_chain_call ( packet2_t packet2,
const void *  next_tag,
u8  irq,
u8  spr,
u32  pce 
)
inlinestatic

Add CALL tag.

Note
packet2_chain_close_tag() required. Qwords are counted automatically. For more details, check description of dma_tag_t.
Parameters
packet2Pointer to packet.
next_tagPointer to next tag.
irqInterrupt Request. False by default.
sprMemory/SPR Selection. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 223 of file packet2_chain.h.

224  {
225  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
226  packet2_chain_add_dma_tag(packet2, PACKET2_COUNT_QWC, pce, P2_DMA_TAG_CALL, irq, (u128 *)next_tag, spr);
227  }
static void packet2_chain_add_dma_tag(packet2_t *packet2, u32 qwc, u32 pce, enum DmaTagType id, u8 irq, const u128 *addr, u8 spr)
Definition: packet2_chain.h:74
@ P2_DMA_TAG_CALL
Definition: packet2_types.h:73
unsigned int u128
Definition: tamtypes.h:36

References packet2_t::next, P2_DMA_TAG_CALL, packet2_chain_add_dma_tag(), and PACKET2_COUNT_QWC.

◆ packet2_chain_close_tag()

static void packet2_chain_close_tag ( packet2_t packet2)
inlinestatic

Close dma tag. In reality, get back to pointer "tag_opened_at" and fix qwc value.

Parameters
packet2Pointer to packet.

Definition at line 100 of file packet2_chain.h.

101  {
102  assert(packet2->tag_opened_at != NULL); // There is opened tag.
103  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
104  packet2->tag_opened_at->QWC = (((u32)packet2->next - (u32)packet2->tag_opened_at) / 16 - 1);
105  packet2->tag_opened_at = (dma_tag_t *)NULL;
106  }

References packet2_t::next, NULL, dma_tag_t::QWC, and packet2_t::tag_opened_at.

Referenced by packet2_utils_vu_add_continue_program(), packet2_utils_vu_add_double_buffer(), packet2_utils_vu_add_end_tag(), packet2_utils_vu_add_start_program(), and packet2_utils_vu_close_unpack().

◆ packet2_chain_next()

static void packet2_chain_next ( packet2_t packet2,
const dma_tag_t next_tag,
u8  irq,
u8  spr,
u32  pce 
)
inlinestatic

Add NEXT tag.

Note
packet2_chain_close_tag() required. Qwords are counted automatically. For more details, check description of dma_tag_t.
Parameters
next_tagPointer to next tag.
irqInterrupt Request. False by default.
sprMemory/SPR Selection. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 170 of file packet2_chain.h.

171  {
172  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
173  packet2_chain_add_dma_tag(packet2, PACKET2_COUNT_QWC, pce, P2_DMA_TAG_NEXT, irq, (u128 *)next_tag, spr);
174  }
@ P2_DMA_TAG_NEXT
Definition: packet2_types.h:58

References packet2_t::next, P2_DMA_TAG_NEXT, packet2_chain_add_dma_tag(), and PACKET2_COUNT_QWC.

◆ packet2_chain_open_cnt()

static void packet2_chain_open_cnt ( packet2_t packet2,
u8  irq,
u32  pce,
u8  spr 
)
inlinestatic

Add CNT tag.

Note
packet2_chain_close_tag() required. Qwords are counted automatically. For more details, check description of dma_tag_t.
Parameters
packet2Pointer to packet.
irqInterrupt Request. False by default.
pcePriority Control Enable. 0 by default.
sprMemory/SPR Selection. False by default.

Definition at line 122 of file packet2_chain.h.

123  {
124  packet2_chain_add_dma_tag(packet2, PACKET2_COUNT_QWC, pce, P2_DMA_TAG_CNT, irq, 0, spr);
125  }
@ P2_DMA_TAG_CNT
Definition: packet2_types.h:56

References P2_DMA_TAG_CNT, packet2_chain_add_dma_tag(), and PACKET2_COUNT_QWC.

Referenced by packet2_utils_vu_add_continue_program(), packet2_utils_vu_add_double_buffer(), packet2_utils_vu_add_start_program(), and packet2_utils_vu_open_unpack().

◆ packet2_chain_open_end()

static void packet2_chain_open_end ( packet2_t packet2,
u8  irq,
u32  pce 
)
inlinestatic

Add END tag.

Note
packet2_chain_close_tag() required. Qwords are counted automatically. For more details, check description of dma_tag_t.
Don't forget about close_tag()!
Parameters
packet2Pointer to packet.
irqInterrupt Request. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 137 of file packet2_chain.h.

138  {
140  }
@ P2_DMA_TAG_END
Definition: packet2_types.h:85

References P2_DMA_TAG_END, packet2_chain_add_dma_tag(), and PACKET2_COUNT_QWC.

Referenced by packet2_utils_vu_add_end_tag().

◆ packet2_chain_ref()

static void packet2_chain_ref ( packet2_t packet2,
const void *  ref_data,
u32  qw_length,
u8  irq,
u8  spr,
u32  pce 
)
inlinestatic

Add REF tag.

Note
Qwords are NOT counted automatically, so there is NO need to use packet2_chain_close_tag(); For more details, check description of dma_tag_t.
Parameters
packet2Pointer to packet.
ref_dataPointer to data.
qw_lengthSize of data in qwords.
irqInterrupt Request. False by default.
sprMemory/SPR Selection. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 154 of file packet2_chain.h.

155  {
156  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
157  packet2_chain_add_dma_tag(packet2, qw_length, pce, P2_DMA_TAG_REF, irq, (const u128 *)ref_data, spr);
158  }
@ P2_DMA_TAG_REF
Definition: packet2_types.h:60

References packet2_t::next, P2_DMA_TAG_REF, and packet2_chain_add_dma_tag().

Referenced by packet2_utils_vu_add_unpack_data(), and packet2_vif_add_micro_program().

◆ packet2_chain_refe()

static void packet2_chain_refe ( packet2_t packet2,
const void *  ref_data,
u32  qw_length,
u8  irq,
u8  spr,
u32  pce 
)
inlinestatic

Add REFE tag.

Note
Qwords are NOT counted automatically, so there is NO need to use packet2_chain_close_tag(); For more details, check description of dma_tag_t.
Parameters
packet2Pointer to packet.
ref_dataPointer to data.
qw_lengthSize of data in qwords.
irqInterrupt Request. False by default.
sprMemory/SPR Selection. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 206 of file packet2_chain.h.

207  {
208  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
209  packet2_chain_add_dma_tag(packet2, qw_length, pce, P2_DMA_TAG_REFE, irq, (const u128 *)ref_data, spr);
210  }
@ P2_DMA_TAG_REFE
Definition: packet2_types.h:54

References packet2_t::next, P2_DMA_TAG_REFE, and packet2_chain_add_dma_tag().

◆ packet2_chain_refs()

static void packet2_chain_refs ( packet2_t packet2,
const void *  ref_data,
u32  qw_length,
u8  irq,
u8  spr,
u32  pce 
)
inlinestatic

Add REFS tag.

Note
Qwords are NOT counted automatically, so there is NO need to use packet2_chain_close_tag(); For more details, check description of dma_tag_t.
Parameters
packet2Pointer to packet.
ref_dataPointer to data.
qw_lengthSize of data in qwords.
irqInterrupt Request. False by default.
sprMemory/SPR Selection. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 188 of file packet2_chain.h.

189  {
190  assert(((u32)packet2->next & 0xF) == 0); // Free space in packet is aligned properly.
191  packet2_chain_add_dma_tag(packet2, qw_length, pce, P2_DMA_TAG_REFS, irq, (const u128 *)ref_data, spr);
192  }
@ P2_DMA_TAG_REFS
Definition: packet2_types.h:66

References packet2_t::next, P2_DMA_TAG_REFS, and packet2_chain_add_dma_tag().

◆ packet2_chain_ret()

static void packet2_chain_ret ( packet2_t packet2,
u8  irq,
u32  pce 
)
inlinestatic

Add RET tag.

Note
packet2_chain_close_tag() required. Qwords are counted automatically. For more details, check description of dma_tag_t.
Parameters
packet2Pointer to packet.
irqInterrupt Request. False by default.
pcePriority Control Enable. 0 by default.

Definition at line 238 of file packet2_chain.h.

239  {
241  }
@ P2_DMA_TAG_RET
Definition: packet2_types.h:83

References P2_DMA_TAG_RET, packet2_chain_add_dma_tag(), and PACKET2_COUNT_QWC.

◆ packet2_chain_set_dma_tag()

static void packet2_chain_set_dma_tag ( dma_tag_t tag,
u32  qwc,
u32  pce,
u32  id,
u8  irq,
const u128 addr,
u8  spr 
)
inlinestatic

Set dma tag. For more details, check description of dma_tag_t.

Parameters
tagPointer to DMA tag to set.
qwcQword count.
pcePriority Control Enable. 0 by default.
idTag ID.
irqInterrupt Request. False by default.
addrAddress.
sprMemory/SPR Selection. False by default.

Definition at line 48 of file packet2_chain.h.

49  {
50  tag->QWC = qwc;
51  tag->PCE = pce;
52  tag->ID = id;
53  tag->IRQ = irq;
54  tag->ADDR = (u64)((u32)addr);
55  tag->SPR = spr;
56  }

References dma_tag_t::ADDR, dma_tag_t::ID, dma_tag_t::IRQ, dma_tag_t::PCE, dma_tag_t::QWC, and dma_tag_t::SPR.

Referenced by packet2_chain_add_dma_tag().