From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 26 05:21:00 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28B981065670 for ; Sat, 26 Jun 2010 05:21:00 +0000 (UTC) (envelope-from crb@chrisbowman.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id DEF718FC08 for ; Sat, 26 Jun 2010 05:20:59 +0000 (UTC) Received: by qwg5 with SMTP id 5so982376qwg.13 for ; Fri, 25 Jun 2010 22:20:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.250.81 with SMTP id mn17mr1095895qcb.182.1277529658255; Fri, 25 Jun 2010 22:20:58 -0700 (PDT) Received: by 10.229.225.142 with HTTP; Fri, 25 Jun 2010 22:20:58 -0700 (PDT) X-Originating-IP: [139.181.0.34] In-Reply-To: <02DA6157-87CE-47E5-91D0-ED014FB88AD0@gsoft.com.au> References: <02DA6157-87CE-47E5-91D0-ED014FB88AD0@gsoft.com.au> Date: Fri, 25 Jun 2010 22:20:58 -0700 Message-ID: From: Christopher Bowman To: "Daniel O'Connor" X-Mailman-Approved-At: Sat, 26 Jun 2010 11:02:47 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: PCI Express and drivers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jun 2010 05:21:00 -0000 On Fri, Jun 25, 2010 at 8:18 PM, Daniel O'Connor wrote: > > On 26/06/2010, at 3:01, Christopher Bowman wrote: > > I have a Xilinx PCI Express board that has an on board PCIe interface > > macro. I intend to have an address space with memory and another with my > > devices control registers. I wish to program this board under FreeBSD. > It > > would seem to me that the way to do this would be to write a driver that > > would allow me to map these two address spaces into a user process which > > could then directly interact with the device. In my case my board > doesn't > > really support multiple users, and it doesn't really seem to make sense > to > > me to put a lot of code in the kernel to create some sort of interface to > > allow multiple processes to interact with my device via some sort of > syscall > > which would impose a lot of overhead in any case. By mapping the address > > ranges into a user process I can write user programs to drive the board > > without having to recompile and reboot the kernel each time I make a > change, > > plus if I do something stupid and crash my user space process it > shouldn't > > bring down the whole kernel. Am I thinking about this wrong? Is there > some > > place I can go to read up on what I should be doing? If I am thinking > about > > this correctly, then how does one map device memory into a user space > > process? How does one make sure that only one process has such a > mapping? > > You could use mmap() I think, > > For a driver I maintain I did the following -> > /* Magic sauce stolen from src/sys/pci/xrpu.c via phk > * http://www.mail-archive.com/freebsd-hackers%40freebsd.org/msg11729.html > */ > *paddr = rman_get_start(sc->g_membase.reshandle) + offset; > > g_membase is.. > struct resource *reshandle; /* Resource handle */ > bus_space_tag_t sc_st; /* bus space tag */ > bus_space_handle_t sc_sh; /* bus space handle */ > > PS what board are you using? :) > > Daniel, Cool, that looks like what I am looking for. I'll go and read up on it, thanks very much. I am using the Xilinx SP605 http://www.xilinx.com/products/devkits/EK-S6-SP605-G.htm perfect for playing with hardware for a frame buffer device or graphics device. It comes with a full license for the synthesis and PCIe IP for the device on that board which is a great deal. Christopher -- > Daniel O'Connor software and network engineer > for Genesis Software - http://www.gsoft.com.au > "The nice thing about standards is that there > are so many of them to choose from." > -- Andrew Tanenbaum > GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C > > > > > > >