[Top] [All Lists]

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

To: "Ardelean, Andrei" <>
Subject: Re: How can I access h/w registers in user space?
From: Manuel Lauss <>
Date: Mon, 18 Apr 2011 20:27:46 +0200
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; 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;; 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: <>
Original-recipient: rfc822;
References: <> <> <>
On Mon, Apr 18, 2011 at 8:14 PM, Ardelean, Andrei
<> 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);


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