linux-mips
[Top] [All Lists]

Re: How can I access h/w registers in user space?

To: "Ardelean, Andrei" <Andrei.Ardelean@idt.com>
Subject: Re: How can I access h/w registers in user space?
From: Manuel Lauss <manuel.lauss@googlemail.com>
Date: Mon, 18 Apr 2011 20:27:46 +0200
Cc: linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=8hLX4ZiK/XW7ZNxY60elYzUZ4UbxZzBRpS1POsBw0Zs=; b=N3S23RLFClf/yVDkiiWkPwXtJqMxcsIIydbgwTZTuu2REaj0aQ02qA8lCj/P0WzRaM aCuT1ggg+d1cygF/2MqDE9Y/tLiHOJVP+G3R6bSZg+4qayUnkSnBFE38nQjRScD5P44X 6uceyhzy8qXeWZKw8zpeAWNUNGJPmk8aXuwVY=
Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=dPyl8SWdl32WGK5ttVU9phmS0zjIFGhuxCe1nUqYCWS4VN1Mifz76LFOlHu3ZrSHZp Wb+Z0+H5+stWzsMbPglrBjROOBR4bbsn5v3lZfh6ntZL/mm8OpzM4Mc6AEj8LqRQGZi/ PeaMIIaDPxzYtHd/EAHPeGsAjPC/Zu2rcYO74=
In-reply-to: <AEA634773855ED4CAD999FBB1A66D07601988EC8@CORPEXCH1.na.ads.idt.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <AEA634773855ED4CAD999FBB1A66D07601988DFA@CORPEXCH1.na.ads.idt.com> <BANLkTi=QLZe68o2=1Vk+4QTu-ru1T6H=vQ@mail.gmail.com> <AEA634773855ED4CAD999FBB1A66D07601988EC8@CORPEXCH1.na.ads.idt.com>
Sender: linux-mips-bounce@linux-mips.org
On Mon, Apr 18, 2011 at 8:14 PM, Ardelean, Andrei
<Andrei.Ardelean@idt.com> wrote:
> Mmap() worked fine for one io memory region, but when I tried to open
> twice for different io memory regions with different base addresses and
> sizes it didn't work. It returned the same memory pointer value in both
> cases. In my design the h/w guys put those h/w registers in two distinct
> memory mapped regions with a large reserved area in between. Is it any
> solution for this case?

This works for me.  Unlike QNX, you can only map multiples of the page size
and the base must also be aligned on a page boundary:

#define MMIO    0x11900000    /* SYS_xxx */
#define MMIO2   0x14000000   /* MEM_xxx */

memfd = open("/dev/mem", O_RDWR);
pgsize = sysconf(_SC_PAGESIZE);
mmio = (unsigned long)mmap(0, pgsize, PROT_READ | PROT_WRITE,
                                        MAP_SHARED, memfd, MMIO);
mmio2 = (unsigned long)mmap(0, 2 * pgsize, PROT_READ | PROT_WRITE,
                                        MAP_SHARED, memfd, MMIO2);

Manuel

<Prev in Thread] Current Thread [Next in Thread>