From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Ian Romanick <idr@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: Special handling of sysfs device resource files?
Date: Wed, 12 Apr 2006 10:20:11 -0700 [thread overview]
Message-ID: <200604121020.11309.jbarnes@virtuousgeek.org> (raw)
In-Reply-To: <443C42EA.1050608@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]
On Tuesday, April 11, 2006 4:59 pm, Ian Romanick wrote:
> I was a little mistaken about this. The BAR that causes the problem
> is not I/O. It *is* memory.
>
> 01:00.0 VGA compatible controller: Matrox Graphics, Inc. G400/G450
> (rev 03) (prog-if 00 [VGA])
> Subsystem: Matrox Graphics, Inc. Millennium G400 16Mb SGRAM
> Flags: bus master, medium devsel, latency 64, IRQ 11
> Memory at cc000000 (32-bit, prefetchable) [size=32M]
> Memory at cfefc000 (32-bit, non-prefetchable) [size=16K]
> Memory at cf000000 (32-bit, non-prefetchable) [size=8M]
> Expansion ROM at cfee0000 [disabled] [size=64K]
>
> When I open and mmap resource0 (the framebuffer) I get 0x2b9aa48ea000.
> When I open and mmap resource1 (the card's registers) I get
> 0x2b9aa68ea000. I can access the resource0 pointer all day long
> without problems. The firs access to the resource1 pointer results in
> a segfault.
Just tested on my x86-64 machine with this dumb little test program. It
seems to work ok, though I haven't tried writing data to the resource.
Jesse
[-- Attachment #2: mapdump.c --]
[-- Type: text/x-csrc, Size: 962 bytes --]
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
int main(int argc, char *argv[])
{
size_t len;
int fd, i;
void *ptr;
uint32_t *val;
if (argc != 3) {
fprintf(stderr, "usage: %s <file> <mapsize>\n",
argv[0]);
return -1;
}
len = atoi(argv[2]);
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
fprintf(stderr, "open failed: %s\n", strerror(errno));
return errno;
}
ptr = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) {
fprintf(stderr, "mmap failed: %s\n", strerror(errno));
return errno;
}
val = ptr;
len = len / sizeof(uint32_t);
for (i = 0; i < len; i += 4) {
printf("%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", i * 4, val[i],
val[i+1], val[i+2], val[i+3]);
}
munmap(ptr, len); /* ignore any errors, we don't care */
close(fd);
return 0;
}
next prev parent reply other threads:[~2006-04-12 17:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-11 21:25 Ian Romanick
2006-04-11 23:59 ` Ian Romanick
2006-04-12 17:14 ` Jesse Barnes
2006-04-12 17:20 ` Jesse Barnes [this message]
2006-04-12 4:45 ` Paul Mackerras
2006-04-12 15:06 ` Ian Romanick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200604121020.11309.jbarnes@virtuousgeek.org \
--to=jbarnes@virtuousgeek.org \
--cc=idr@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome