From: kaka <sha...@gm...> - 2007-11-20 06:39:28
|
Hi All, void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); I am providing 16,00,000 as length parameter in mmap command. It is giving me error as Can't mmap region. on the other hand when i am providing 9,00,000 as length parameter in mmap command. It is successful. This mmap command is being issued from User space. On the other hand in the framebuffer driver in the kernel spce i have specified the length of mmio in the ioremap as 16,00,000. Can anybody provide any clue on it? I want to access the mmio regs at offset ( 0 to 16,00,000). -- Thanks & Regards, kaka |
From: kaka <sha...@gm...> - 2007-11-20 09:40:39
|
Hi Denis, Thanks for the reply. I am writing gfxdriver for directFB library for broadcom chip. I have also written a frambuffer driver for broadcom chip. In directFB code, static volatile void * system_map_mmio( unsigned int offset, int length ) { void *addr; if (length <= 0) length = dfb_fbdev->shared->fix.mmio_len; addr = mmap( NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, dfb_fbdev->fd, dfb_fbdev->shared->fix.smem_len + offset ); if ((int)(addr) == -1) { D_PERROR( "DirectFB/FBDev: Could not mmap MMIO region " "(offset %d, length %d)!\n", offset, length ); return NULL; } return(volatile void*) ((u8*) addr + (dfb_fbdev->shared->fix.mmio_start& dfb_fbdev->shared->page_mask)); } the length and offset i am providing as 0 and -1. It is throwing me error as Could not mmap MMIO region. length coming from dfb_fbdev->shared->fix.smem_len is 16,00,000. When i change the code to addr = mmap( NULL, 900000, PROT_READ | PROT_WRITE, MAP_SHARED, dfb_fbdev->fd, dfb_fbdev->shared->fix.smem_len + offset ); Then it works fine but it is not allowing me to write to addresses with offset greater than 900000. My requirement is to write in to the MMIO registers with offset between 900000 and 16 00 000. Could you please help me in htis regard? Thanks in Advance. On 11/20/07, Denis Oliver Kropp <do...@di...> wrote: > > kaka wrote: > > Hi All, > > > > void *mmap(void *start, size_t length, int prot, int flags, > int > > fd, off_t offset); > > > > I am providing 16,00,000 as length parameter in mmap command. > > It is giving me error as Can't mmap region. on the other hand when i am > > providing 9,00,000 as length parameter in mmap command. > > It is successful. > > This mmap command is being issued from User space. > > > > On the other hand in the framebuffer driver in the kernel spce i have > > specified the length of mmio in the ioremap as 16,00,000. > > The ioremap() is independent of the values propagated to user space > and fbmem.c via fix.mmio_start and fix.mmio_len, please check these. > > -- > Best regards, > Denis Oliver Kropp > > .------------------------------------------. > | DirectFB - Hardware accelerated graphics | > | http://www.directfb.org/ | > "------------------------------------------" > -- Thanks & Regards, kaka |
From: Denis O. K. <do...@di...> - 2007-11-20 10:43:39
|
kaka wrote: > Hi Denis, > > Thanks for the reply. > I am writing gfxdriver for directFB library for broadcom chip. > I have also written a frambuffer driver for broadcom chip. Directly for broadcom or at another company? > In directFB code, > > static volatile void * > system_map_mmio( unsigned int offset, > int length ) > { > void *addr; > > if (length <= 0) > length = dfb_fbdev->shared->fix.mmio_len; > > addr = mmap( NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, > dfb_fbdev->fd, dfb_fbdev->shared->fix.smem_len + offset ); > if ((int)(addr) == -1) { > D_PERROR( "DirectFB/FBDev: Could not mmap MMIO region " > "(offset %d, length %d)!\n", offset, length ); > return NULL; > } > > return(volatile void*) ((u8*) addr + (dfb_fbdev->shared->fix.mmio_start& > dfb_fbdev->shared->page_mask)); > } Can you add printfs to show dfb_fbdev->shared->fix.mmio_start, mmio_len, smem_start and smem_len? > the length and offset i am providing as 0 and -1. You mean offset 0 and length -1? > It is throwing me error as Could not mmap MMIO region. > length coming from dfb_fbdev->shared->fix.smem_len is 16,00,000. 1600000 = 1.6MB? > When i change the code to addr = mmap( NULL, 900000, PROT_READ | > PROT_WRITE, MAP_SHARED, dfb_fbdev->fd, dfb_fbdev->shared->fix.smem_len + > offset ); You changed the length to 900000, but you need to use this to map offset 900000: addr = mmap( NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, dfb_fbdev->fd, 900000 ); But it should work if you set smem_len to 900000 in the fb driver. > Then it works fine but it is not allowing me to write to addresses with > offset greater than 900000. Segfault? > My requirement is to write in to the MMIO registers with offset between > 900000 and 16 00 000. What exactly is your frame buffer size and physical MMIO address? You need to put the frame buffer size into smem_len and the physical MMIO address into mmio_start, the length into mmio_len. -- Best regards, Denis Oliver Kropp .------------------------------------------. | DirectFB - Hardware accelerated graphics | | http://www.directfb.org/ | "------------------------------------------" |
From: Denis O. K. <do...@di...> - 2007-11-20 08:30:26
|
kaka wrote: > Hi All, > > void *mmap(void *start, size_t length, int prot, int flags, int > fd, off_t offset); > > I am providing 16,00,000 as length parameter in mmap command. > It is giving me error as Can't mmap region. on the other hand when i am > providing 9,00,000 as length parameter in mmap command. > It is successful. > This mmap command is being issued from User space. > > On the other hand in the framebuffer driver in the kernel spce i have > specified the length of mmio in the ioremap as 16,00,000. The ioremap() is independent of the values propagated to user space and fbmem.c via fix.mmio_start and fix.mmio_len, please check these. -- Best regards, Denis Oliver Kropp .------------------------------------------. | DirectFB - Hardware accelerated graphics | | http://www.directfb.org/ | "------------------------------------------" |