Nov 16, 2012 at 10:49pm UTC
Hi, Members of cplusplus
I hope you can help me.
I have maked some new program.
I need some dynamicly spareram , but i have tryed it, but no luck.
This is my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
memory_tmp = (unsigned char *)mmap(0, DMA_BLOCKSIZE + 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, SPARE_RAM);
if (memory_tmp == MAP_FAILED) {
printf("[grabber] mmap failed\n" );
blank = true ;return false ;
}
volatile unsigned long *mem_dma;
if (!(mem_dma = (volatile unsigned long *)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, (stb_type == BRCM7400) ? 0x10c02000 : 0x10c01000)))
{
if (m_debug){
fprintf(stderr, "[Debug] Mainmemory: <Memmapping failed> DMA control\n" );
blank = true ;return false ;
}
}
for (i=0; i < tmp_size; i += DMA_BLOCKSIZE)
{
unsigned long *descriptor = (unsigned long *)memory_tmp;
if (i + DMA_BLOCKSIZE > tmp_size)
tmp_len = tmp_size - i;
descriptor[0] = /* READ */ adr + i;
descriptor[1] = /* WRITE */ SPARE_RAM + 0x1000;
descriptor[2] = 0x40000000 | /* LEN */ tmp_len;
descriptor[3] = 0;
descriptor[4] = 0;
descriptor[5] = 0;
descriptor[6] = 0;
descriptor[7] = 0;
mem_dma[1] = /* FIRST_DESCRIPTOR */ SPARE_RAM;
mem_dma[3] = /* DMA WAKE CTRL */ 3;
mem_dma[2] = 1;
while (mem_dma[5] == 1)
usleep(2);
mem_dma[2] = 0;
}
munmap((void *)mem_dma, 0x1000);
memory_tmp += 0x1000;
I have tryed it with malloc, but with no luck.
I need 4mb 4x1024x1024.
i have tryed this
1 2 3 4 5 6 7 8 9 10 11
unsigned char *memread;
memread = (unsigned char *)malloc(4*1024*1024); //4 MB is enough...
if (!memread){
printf("unable to allocate size \n" );
}else {
//printf("SPARE_RAM: the base of allocation is %p \n",SPARE_RAM);
printf("memread : the base of allocation is %p \n" ,memread);
}
unsigned long int SPARE_RAM = (unsigned long int )memread;
free(memread);
Now the question is, how to use in this memory2 memory code.
I hope someone can helpme.
P.s sorry for my bad english.
Gr Sp
Last edited on Nov 16, 2012 at 10:50pm UTC
Nov 17, 2012 at 2:07pm UTC
In what way is there "no luck"? Does it not work? Does your code not compile? Do you get any error messages?
Nov 17, 2012 at 3:57pm UTC
Hi,
It won't start, then hanging. then i must reboot the whole box
It's for a satelittetuner mipselbased.
I can use 252*1024*1024, this is working.
But this memory wil be overwritten when i do a recording on the box.
So i need dynamic mem.
Kind regards Martijn
Last edited on Nov 17, 2012 at 3:57pm UTC