The problem that I found was due to the bottom of the queue's data buffer being miscalculated to be the start of the q_resp aica_queue_t structure rather than just after it (as is the case with the q_cmd queue). The fixed code is below in which I have kept the naming convention of the introduced 'qa' variable as is the case in snd_sh4_to_aica(...)
Hope this of some use.
Dave
Code: Select all
uint32 bot, start, stop, top, size, cnt, *pkt32;
sem_wait(&sem_qram);
/* Set these up for reference */
bot = SPU_RAM_BASE + AICA_MEM_RESP_QUEUE;
assert_msg(g2_read_32(bot + offsetof(aica_queue_t, valid)), "Queue is not yet valid");
top = SPU_RAM_BASE + AICA_MEM_RESP_QUEUE + g2_read_32(bot + offsetof(aica_queue_t, size));
start = SPU_RAM_BASE + AICA_MEM_RESP_QUEUE + g2_read_32(bot + offsetof(aica_queue_t, tail));
stop = SPU_RAM_BASE + AICA_MEM_RESP_QUEUE + g2_read_32(bot + offsetof(aica_queue_t, head));
Code: Select all
uint32 qa, bot, start, stop, top, size, cnt, *pkt32;
sem_wait(&sem_qram);
/* Set these up for reference */
qa = SPU_RAM_BASE + AICA_MEM_RESP_QUEUE;
assert_msg(g2_read_32(qa + offsetof(aica_queue_t, valid)), "Queue is not yet valid");
bot = SPU_RAM_BASE + g2_read_32(qa + offsetof(aica_queue_t, data));
top = bot + g2_read_32(qa + offsetof(aica_queue_t, size));
start = bot + g2_read_32(qa + offsetof(aica_queue_t, tail));
stop = bot + g2_read_32(qa + offsetof(aica_queue_t, head));
Code: Select all
if(stop > top)
stop -= top - (SPU_RAM_BASE + AICA_MEM_RESP_QUEUE);
Code: Select all
if(stop > top)
stop -= top - bot;
Code: Select all
/* Finally, write a new tail value to signify that we've removed a packet */
g2_write_32(bot + offsetof(aica_queue_t, tail), start - (SPU_RAM_BASE + AICA_MEM_RESP_QUEUE));
Code: Select all
/* Finally, write a new tail value to signify that we've removed a packet */
g2_write_32(qa + offsetof(aica_queue_t, tail), start - bot);