Add DMA information : always finding the right way to use a free DMA channel

master
F5OEO 2016-12-17 22:32:06 +00:00
rodzic 883238e5d4
commit 2c3d9b69bb
3 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -265,3 +265,23 @@ int mbox_open() {
void mbox_close(int file_desc) {
close(file_desc);
}
//https://github.com/sarfata/pi-blaster/pull/38#discussion_r28041695
unsigned get_dma_channels(int file_desc)
{
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x60001; // (the tag id)
p[i++] = 4; // (size of the buffer)
p[i++] = 0; // (size of the data)
p[i++] = 0; // response buffer
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}

Wyświetl plik

@ -46,3 +46,4 @@ void *unmapmem(void *addr, unsigned size);
unsigned execute_code(int file_desc, unsigned code, unsigned r0, unsigned r1, unsigned r2, unsigned r3, unsigned r4, unsigned r5);
unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control, unsigned noflush, unsigned timeout);
unsigned qpu_enable(int file_desc, unsigned enable);
unsigned get_dma_channels(int file_desc);

Wyświetl plik

@ -32,7 +32,7 @@ char InitDma(void *FunctionTerminate)
printf("Failed to open mailbox\n");
return(0);
}
printf("DMA used : %x\n",get_dma_channels(mbox.handle));
mbox.mem_ref = mem_alloc(mbox.handle, NUM_PAGES* PAGE_SIZE, PAGE_SIZE, mem_flag);
/* TODO: How do we know that succeeded? */
//printf("mem_ref %x\n", mbox.mem_ref);