linux-mips
[Top] [All Lists]

Usage of mmap command

To: "Denis Oliver Kropp" <dok@directfb.org>
Subject: Usage of mmap command
From: kaka <share.kt@gmail.com>
Date: Tue, 20 Nov 2007 15:10:36 +0530
Cc: linux-mips@linux-mips.org, uclinux-dev@uclinux.org, celinux-dev@tree.celinuxforum.org, linux-fbdev-users@lists.sourceforge.net, directfb-users@directfb.org, directfb-dev@directfb.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=m78fUfcuddF2cykoHWIbV7X2MMthHNtq6MfkAvm/ZLc=; b=howHKGq4CSlVslL9XMHrEc6edlbaLCPSiEPoQWOZWGDzAqCHlQGz3ttFFm4IeVepXe4Yv25ouYok7ZtBLuCX1A3HE65KQrCzkTKMLLE7r7MaArk+l/ZVKjzHz8BCeodWzYBFN9XFEB8k6MCO+m1QJ30G4IADATUmKKKT+RlBB0M=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=JsIWxAy1eeCox2yjTxcZtETVc0oI6zj9mGlYU+NTuVCYi45oRV4PzMMYRspWmT66H8FbgN4erlXZjfjsi6ujrYSkbTvtVaSlBkuX1tzcUhH4TdkcPYRCKJ3UnbfU8J8/3UJg4DMCf+rFrA5twA6Teh4vGzb7VBYFemXVYwkQzkY=
In-reply-to: <47429AEF.3010403@directfb.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <eea8a9c90711192239q6009cbb8y76790fa73bc4a5b7@mail.gmail.com> <47429AEF.3010403@directfb.org>
Sender: linux-mips-bounce@linux-mips.org
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 <dok@directfb.org> 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
<Prev in Thread] Current Thread [Next in Thread>