I tested _uram and _ostk, and kmalloc was only using _ostk.
This is strange because _uram is the default. xD Well, no need to solve every mystery.
Now, how do I actually use dma_memset to clear the depth buffer?
You need the buffer to be both 32-aligned and have a size multiple of 32. Also, the size is in bytes.
GALIGNED(32) static fp depthBuffer[RENDER_WIDTH * RENDER_HEIGHT];
dma_memset(depthBuffer, *(uint32_t *)value, sizeof depthBuffer);
assuming RENDER_WIDTH * RENDER_HEIGHT is a multiple of 8, which it probably is.
Now, there is a caveat, which is that the DMA only has access to the physical address space. Hence, the note in dma_memset()'s documentation that you can't use P0 addresses, which is any address lower than 0x80000000. The only things in P0 are the add-in code and data segment; since you are using the latter, you are in fact using space invisible to the DMA.
That could be a problem since virtualized addresses may map to discontinuous sections of physical memory, which is what the DMA uses. This implies that you can't copy code from your add-in with the DMA, for instance. Fortunately, the data segment is mapped as a single block, so your buffer is too and we can find its physical address.
void *mmu_translate_uram(void *ptr)
return mmu_uram() + ((uint32_t)ptr - 0x08100000);
dma_memset(mmu_translate_uram(depthBuffer), *(uint32_t *)value, sizeof depthBuffer);
I should provide that function in gint, and probably bake that translation into the DMA driver too.
(You don't get that problem with malloc() because gint translates to physical addresses before setting up the arena.)