wavelength 1.0.0
Loading...
Searching...
No Matches
dmapacket.h
Go to the documentation of this file.
1#pragma once
2
4struct alignas(16) DmaQuadword {
5 union {
6 unsigned long long mDword[2];
7 unsigned int mWord[4];
8 unsigned short mHalf[8];
9 float mFloat[4];
10 };
11};
12
19class DmaPacket {
20public:
27
33 static DmaPacket &shared();
34
41 void OpenDmaTag();
42
54 void CloseDmaTag(int nId, unsigned int nAddress, int nQwc);
55
67 void CloseGifTag(int bEop, int nLoops);
68
81 void OpenGifTag(int nFlg, int nRegs, unsigned long long nRegList, int nPrim);
82
92 void Init(DmaQuadword *pBase, int nChannel, int bVif);
93
100 void Reset();
101
108 void Wait();
109
119 unsigned int Close(Mode eMode, unsigned int nAddress);
120
129 void Send(Mode eMode, unsigned int nAddress);
130
133 return mBase;
134 }
135
137 void SetBase(DmaQuadword *pBase) {
138 mBase = pBase;
139 }
140
143 return mCursor;
144 }
145
147 void SetCursor(DmaQuadword *pCursor) {
148 mCursor = pCursor;
149 }
150
156 void Advance(int nQuadwords = 1) {
157 mCursor += nQuadwords;
158 }
159
162 return mGifTag;
163 }
164
165private:
166 DmaQuadword *mDmaTag;
167 DmaQuadword *mBase;
168 DmaQuadword *mCursor;
169 DmaQuadword *mGifTag;
170 DmaQuadword *mVifDirect;
171 unsigned short mChannel;
172 unsigned short mVif;
173};
Builder of a DMA packet of GIF data, with DMA tags, GIF tags, and optional VIF DIRECT codes.
Definition dmapacket.h:19
void OpenGifTag(int nFlg, int nRegs, unsigned long long nRegList, int nPrim)
Close the GIF tag being filled and open a new one at the cursor.
DmaQuadword * GetBase() const
Definition dmapacket.h:132
void OpenDmaTag()
Close the DMA tag being filled and open a new one at the cursor.
void CloseDmaTag(int nId, unsigned int nAddress, int nQwc)
Close the DMA tag being filled.
void SetCursor(DmaQuadword *pCursor)
Definition dmapacket.h:147
static DmaPacket & shared()
Report the instance at the start of the scratchpad.
Mode
How Close() ends the packet and how the channel transfers it.
Definition dmapacket.h:22
@ kModeNormal
Definition dmapacket.h:23
@ kModeChainTagged
Definition dmapacket.h:25
@ kModeChain
Definition dmapacket.h:24
void Wait()
Wait for the channel to stop.
void CloseGifTag(int bEop, int nLoops)
Close the GIF tag being filled.
DmaQuadword * GetCursor() const
Definition dmapacket.h:142
void SetBase(DmaQuadword *pBase)
Definition dmapacket.h:137
DmaQuadword * GetGifTag() const
Definition dmapacket.h:161
unsigned int Close(Mode eMode, unsigned int nAddress)
Close the packet and program the channel's registers for it.
void Advance(int nQuadwords=1)
Move the cursor past quadwords written in place.
Definition dmapacket.h:156
void Init(DmaQuadword *pBase, int nChannel, int bVif)
Set the buffer and the channel, and empty the packet.
void Reset()
Empty the packet.
void Send(Mode eMode, unsigned int nAddress)
Close the packet and start the transfer.
One quadword of a DMA packet, viewed as doublewords, words, or halfwords.
Definition dmapacket.h:4
unsigned long long mDword[2]
Definition dmapacket.h:6
unsigned short mHalf[8]
Definition dmapacket.h:8
unsigned int mWord[4]
Definition dmapacket.h:7
float mFloat[4]
Definition dmapacket.h:9