testing spacket on vu1
This commit is contained in:
@@ -60,10 +60,9 @@ private:
|
|||||||
u8 isDoubleBufferSet;
|
u8 isDoubleBufferSet;
|
||||||
void checkDataAlignment(void *data);
|
void checkDataAlignment(void *data);
|
||||||
VU1BuildList buildList;
|
VU1BuildList buildList;
|
||||||
char dmaBuffer1[VIF_BUFFER_SIZE] __attribute__((aligned(16)));
|
spacket_t *spackets[2] __attribute__((aligned(16)));
|
||||||
char dmaBuffer2[VIF_BUFFER_SIZE] __attribute__((aligned(16)));
|
spacket_t *currPacket;
|
||||||
void *currentBuffer;
|
u8 switchPacket;
|
||||||
u32 switchBuffer;
|
|
||||||
static u32 countProgramSize(u32 *t_start, u32 *t_end);
|
static u32 countProgramSize(u32 *t_start, u32 *t_end);
|
||||||
void checkList();
|
void checkList();
|
||||||
inline s32 AddUnpack(int format, int addr, int num, int usetops = 0, int nosign = 1, int masking = 0)
|
inline s32 AddUnpack(int format, int addr, int num, int usetops = 0, int nosign = 1, int masking = 0)
|
||||||
|
|||||||
+51
-54
@@ -22,8 +22,10 @@
|
|||||||
VU1::VU1()
|
VU1::VU1()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing VU1");
|
PRINT_LOG("Initializing VU1");
|
||||||
currentBuffer = 0;
|
currPacket = 0;
|
||||||
switchBuffer = 0;
|
switchPacket = 0;
|
||||||
|
spackets[0] = spacket_create(3072, SPACKET_NORMAL);
|
||||||
|
spackets[1] = spacket_create(3072, SPACKET_NORMAL);
|
||||||
PRINT_LOG("VU1 initialized!");
|
PRINT_LOG("VU1 initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,14 +38,15 @@ VU1::~VU1() {}
|
|||||||
/** Create dynamic list */
|
/** Create dynamic list */
|
||||||
void VU1::createList()
|
void VU1::createList()
|
||||||
{
|
{
|
||||||
switchBuffer = !switchBuffer;
|
switchPacket = !switchPacket;
|
||||||
memset((char *)&buildList, 0, sizeof(buildList));
|
memset((char *)&buildList, 0, sizeof(buildList));
|
||||||
|
|
||||||
if (switchBuffer)
|
if (switchPacket)
|
||||||
currentBuffer = (char *)&dmaBuffer1;
|
currPacket = spackets[0];
|
||||||
else
|
else
|
||||||
currentBuffer = (char *)&dmaBuffer2;
|
currPacket = spackets[1];
|
||||||
buildList.kickBuffer = currentBuffer;
|
spacket_reset(currPacket, false);
|
||||||
|
buildList.kickBuffer = currPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add reference list and send via VIF1
|
/** Add reference list and send via VIF1
|
||||||
@@ -57,10 +60,10 @@ void VU1::sendSingleRefList(int t_destAddress, void *t_data, int t_quadSize)
|
|||||||
spacket_vif_stcycl(spacket, 0, 0x0101, 0);
|
spacket_vif_stcycl(spacket, 0, 0x0101, 0);
|
||||||
spacket_open_unpack(spacket, VIF_UNPACK_V4_32, t_destAddress, 0, 0, 0, 0);
|
spacket_open_unpack(spacket, VIF_UNPACK_V4_32, t_destAddress, 0, 0, 0, 0);
|
||||||
spacket_close_unpack(spacket, t_quadSize);
|
spacket_close_unpack(spacket, t_quadSize);
|
||||||
spacket_chain_close_tag(spacket);
|
|
||||||
spacket_chain_open_end(spacket, 0, 0, true);
|
spacket_chain_open_end(spacket, 0, 0, true);
|
||||||
spacket_vif_nop(spacket, 0);
|
spacket_vif_nop(spacket, 0);
|
||||||
spacket_vif_nop(spacket, 0);
|
spacket_vif_nop(spacket, 0);
|
||||||
|
spacket_chain_close_tag(spacket);
|
||||||
spacket_send_chain(spacket, DMA_CHANNEL_VIF1, true, true, true);
|
spacket_send_chain(spacket, DMA_CHANNEL_VIF1, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,10 +80,10 @@ void VU1::addListBeginning()
|
|||||||
|
|
||||||
buildList.dmaSizeAll += buildList.dmaSize;
|
buildList.dmaSizeAll += buildList.dmaSize;
|
||||||
buildList.dmaSize = 0;
|
buildList.dmaSize = 0;
|
||||||
buildList.offset = currentBuffer;
|
buildList.offset = currPacket;
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0); // placeholder
|
spacket_chain_open_cnt(currPacket, 0, 0, 0, true);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101); // placeholder
|
spacket_vif_stcycl(currPacket, 0, 0x0101, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_UNPACK_V4_32, 0, 0); // placeholder
|
spacket_open_unpack(currPacket, V4_32, 0, 1, 0, 0, 0);
|
||||||
buildList.isBuilding = 1;
|
buildList.isBuilding = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,17 +95,9 @@ void VU1::addListEnding()
|
|||||||
PRINT_ERR("Please add list beginning first. Nothing to end!");
|
PRINT_ERR("Please add list beginning first. Nothing to end!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
spacket_align_to_qw(currPacket);
|
||||||
while ((buildList.dmaSize & 0xF))
|
spacket_chain_close_tag(currPacket);
|
||||||
{
|
spacket_close_unpack(currPacket, ((u32)currPacket->next - (u32)currPacket->unpackOpenedAt) >> 4);
|
||||||
*((u32 *)currentBuffer)++ = 0;
|
|
||||||
buildList.dmaSize += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
*((u64 *)buildList.offset)++ = DMA_CNT_TAG(buildList.dmaSize >> 4);
|
|
||||||
*((u32 *)buildList.offset)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
|
|
||||||
*((u32 *)buildList.offset)++ = AddUnpack(V4_32, 0, buildList.dmaSize >> 4, 1);
|
|
||||||
|
|
||||||
buildList.isBuilding = 0;
|
buildList.isBuilding = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +113,10 @@ void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
|
|||||||
checkDataAlignment(t_data);
|
checkDataAlignment(t_data);
|
||||||
if (buildList.isBuilding == 1)
|
if (buildList.isBuilding == 1)
|
||||||
PRINT_ERR("Please end current list list before adding new one!");
|
PRINT_ERR("Please end current list list before adding new one!");
|
||||||
*((u64 *)currentBuffer)++ = DMA_REF_TAG((u32)t_data, t_size);
|
spacket_ref(currPacket, t_data, t_size, 0, 0, 0, 1);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
|
spacket_vif_stcycl(currPacket, 0, 0x0101, 0);
|
||||||
*((u32 *)currentBuffer)++ =
|
spacket_open_unpack(currPacket, V4_32, 0, t_useTops, 0, 0, 0);
|
||||||
AddUnpack(V4_32, t_useTops == 1 ? buildList.dmaSize >> 4 : t_offset >> 4, t_size, t_useTops);
|
spacket_close_unpack(currPacket, t_useTops ? ((u32)currPacket->next - (u32)currPacket->unpackOpenedAt) >> 4 : t_offset >> 4);
|
||||||
buildList.dmaSize += t_size * 8;
|
buildList.dmaSize += t_size * 8;
|
||||||
buildList.dmaSizeAll += buildList.dmaSize;
|
buildList.dmaSizeAll += buildList.dmaSize;
|
||||||
}
|
}
|
||||||
@@ -129,45 +124,47 @@ void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
|
|||||||
/** Start VU1 program */
|
/** Start VU1 program */
|
||||||
void VU1::addStartProgram()
|
void VU1::addStartProgram()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
spacket_chain_open_cnt(currPacket, 0, 0, 0, 1);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
spacket_vif_mscal(currPacket, 0, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
spacket_vif_flush(currPacket, 0);
|
||||||
;
|
spacket_chain_close_tag(currPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Continue VU1 program from "--cont" line */
|
/** Continue VU1 program from "--cont" line */
|
||||||
void VU1::addContinueProgram()
|
void VU1::addContinueProgram()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
spacket_chain_open_cnt(currPacket, 0, 0, 0, 1);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
|
spacket_vif_mscnt(currPacket, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
spacket_vif_flush(currPacket, 0);
|
||||||
;
|
spacket_chain_close_tag(currPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add end tag and send packet via VIF1 */
|
/** Add end tag and send packet via VIF1 */
|
||||||
void VU1::sendList()
|
void VU1::sendList()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_END_TAG(0);
|
spacket_chain_open_end(currPacket, 0, 0, 1);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
spacket_vif_nop(currPacket, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
spacket_vif_nop(currPacket, 0);
|
||||||
FlushCache(0);
|
spacket_chain_close_tag(currPacket);
|
||||||
dma_channel_send_chain(DMA_CHANNEL_VIF1, buildList.kickBuffer, (u32 *)currentBuffer - (u32 *)buildList.kickBuffer, DMA_FLAG_TRANSFERTAG, 0);
|
printf("QWS:%d\n", spacket_get_qw_count(currPacket));
|
||||||
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
|
spacket_send_chain(currPacket, DMA_CHANNEL_VIF1, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::addDoubleBufferSetting()
|
void VU1::addDoubleBufferSetting()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
spacket_chain_open_cnt(currPacket, 0, 0, 0, 1);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_BASE, 0, 8);
|
spacket_vif_base(currPacket, 8, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_OFFSET, 0, 496);
|
spacket_vif_offset(currPacket, 496, 0);
|
||||||
isDoubleBufferSet = 1;
|
isDoubleBufferSet = 1;
|
||||||
|
spacket_chain_close_tag(currPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::addFlush()
|
void VU1::addFlush()
|
||||||
{
|
{
|
||||||
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
|
spacket_chain_open_cnt(currPacket, 0, 0, 0, 1);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
|
spacket_vif_nop(currPacket, 0);
|
||||||
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
|
spacket_vif_flush(currPacket, 0);
|
||||||
|
spacket_chain_close_tag(currPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::checkDataAlignment(void *t_data)
|
void VU1::checkDataAlignment(void *t_data)
|
||||||
@@ -183,29 +180,29 @@ void VU1::checkDataAlignment(void *t_data)
|
|||||||
void VU1::add128(u64 v1, u64 v2)
|
void VU1::add128(u64 v1, u64 v2)
|
||||||
{
|
{
|
||||||
checkList();
|
checkList();
|
||||||
*((u64 *)currentBuffer)++ = v1;
|
spacket_add_u64(currPacket, v1);
|
||||||
*((u64 *)currentBuffer)++ = v2;
|
spacket_add_u64(currPacket, v2);
|
||||||
buildList.dmaSize += 16;
|
buildList.dmaSize += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::add64(u64 v)
|
void VU1::add64(u64 v)
|
||||||
{
|
{
|
||||||
checkList();
|
checkList();
|
||||||
*((u64 *)currentBuffer)++ = v;
|
spacket_add_u64(currPacket, v);
|
||||||
buildList.dmaSize += 8;
|
buildList.dmaSize += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::add32(u32 v)
|
void VU1::add32(u32 v)
|
||||||
{
|
{
|
||||||
checkList();
|
checkList();
|
||||||
*((u32 *)currentBuffer)++ = v;
|
spacket_add_u32(currPacket, v);
|
||||||
buildList.dmaSize += 4;
|
buildList.dmaSize += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VU1::addFloat(float v)
|
void VU1::addFloat(float v)
|
||||||
{
|
{
|
||||||
checkList();
|
checkList();
|
||||||
*((float *)currentBuffer)++ = v;
|
spacket_add_float(currPacket, v);
|
||||||
buildList.dmaSize += 4;
|
buildList.dmaSize += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,8 +210,8 @@ void VU1::checkList()
|
|||||||
{
|
{
|
||||||
if (buildList.isBuilding == 0)
|
if (buildList.isBuilding == 0)
|
||||||
PRINT_ERR("Please add list beginning before adding data!");
|
PRINT_ERR("Please add list beginning before adding data!");
|
||||||
if (buildList.dmaSizeAll > VIF_BUFFER_SIZE)
|
// if (buildList.dmaSizeAll > VIF_BUFFER_SIZE)
|
||||||
PRINT_ERR("Buffer size exceed!");
|
// PRINT_ERR("Buffer size exceed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
|
|||||||
Reference in New Issue
Block a user