WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Userspace PIO access under xen

To: Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>, Dror Goldenberg <gdror@xxxxxxxxxxxxxx>
Subject: [Xen-devel] Userspace PIO access under xen
From: "Michael S. Tsirkin" <mst@xxxxxxxxxxxxxx>
Date: Mon, 25 Jul 2005 14:31:49 +0300
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 25 Jul 2005 11:27:44 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: "Michael S. Tsirkin" <mst@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.2.1i
Hi!
The following simple program (below) mmaps PCI I/O memory
into userspace. This works fine under linux, but not in Xen dom0.

Linux:

# ./test1 /sys/bus/pci/devices/0000\:07\:00.0/resource0 0
0 0

Xen dom0:

# ./test1 /sys/bus/pci/devices/0000\:07\:00.0/resource0 0
0 0xf000eef3

Where does one start looking at fixing this?
Thanks,
MST

---

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>


/* Usage: test0 file offset */


int main(int argc, char** argv)
{
    int fd;
    if (argc < 3) {
            fprintf(stderr, "Usage: %s file offset\n", argv[0]);
            return 2;
    }

    fd = open(argv[1], O_RDWR | O_SYNC);
    if (fd < 0) {
            perror("open");
            return errno;
    }

    long o = strtol(argv[2], NULL, 0);

    long* ptr = mmap(NULL, 0x1000, PROT_READ, MAP_SHARED, fd, o);

    if ( (! ptr) || (ptr == MAP_FAILED) ) {
            perror("mmap");
            return errno;
    }

    printf("%#lx %#lx\n", o, *ptr);

    return 0;
}

-- 
MST

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel