From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 1 10:16:30 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 96817195; Wed, 1 Oct 2014 10:16:30 +0000 (UTC) Received: from mail-ig0-x229.google.com (mail-ig0-x229.google.com [IPv6:2607:f8b0:4001:c05::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5E701BA4; Wed, 1 Oct 2014 10:16:30 +0000 (UTC) Received: by mail-ig0-f169.google.com with SMTP id uq10so6058igb.2 for ; Wed, 01 Oct 2014 03:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=UKWJQCZfy2zGhm12ph4huStaXHkz3lVgaU3eUEKBYaQ=; b=MLBjSu6Ylhwbyfr2XgE7lSPs7opw32oCOtCTiJzolb+BUjR40GqIVIUp0QzRkeB7lZ MW8G46i1bA28Kk20wzOh8Q0BLFY1pb/Cq0Q6s+HvkkzfRUvo+Ee4sHV3Nwuk0xB75fxd kMnrW1igjmcvJnilG1t2xHnZbiQxlvppne+kZ81BJTJPQB3AQ/eh3RjCKt0VWLjF+3ug hCN9SDEk8ocMWy02EyTdu+nT7NmcAICjh2L6g3R+dSbcdnnnXkWUCFhmFP8O++l6sTRL RCt9M9DhDxFMfijJ52UIkH78DGZ3x26Cf7U7q5anpTyPnXm7ZgeFuzQyWhpZmlDRoUuy 0FLA== MIME-Version: 1.0 X-Received: by 10.50.73.130 with SMTP id l2mr17423611igv.42.1412158589726; Wed, 01 Oct 2014 03:16:29 -0700 (PDT) Received: by 10.50.2.69 with HTTP; Wed, 1 Oct 2014 03:16:29 -0700 (PDT) In-Reply-To: <20141001091252.GP26076@kib.kiev.ua> References: <20141001091252.GP26076@kib.kiev.ua> Date: Wed, 1 Oct 2014 20:16:29 +1000 Message-ID: Subject: Re: does linsysfs support mmap on pci resources (e.g. pci device's registers etc.) From: leon zadorin To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 X-Mailman-Approved-At: Wed, 01 Oct 2014 11:13:50 +0000 Cc: freebsd-emulation@freebsd.org, hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2014 10:16:30 -0000 On Wed, Oct 1, 2014 at 7:12 PM, Konstantin Belousov wrote: > You choice of the list to ask the question is weird. I added hackers@ > as more suitable ML. I see, Sure thing about adding the post to another list -- sorry about doing the original post to this list (freebsd-emulation). I had read the lists's description: "A list for the Development of Emulators of other operating systems and enviroments for FreeBSD. These include: BSDI, Linux, and some microsoft products. " https://lists.freebsd.org/mailman/listinfo/freebsd-emulation and given that my post was essentially about whether FreeBSD emulated linux OS "sysfs" feature(s) I thought it might be of some relevance to the list... but being a noob to the list I have possibly not made the best choice :) > On Wed, Oct 01, 2014 at 03:44:48PM +1000, leon zadorin wrote: >> Hello everyone, >> Sorry if this is a bit of a noob question -- I'm just starting on this >> topic... does FreeBSD's emulation of sysfs (from linux world) support >> "mmap" on pci resources? >> >> Something similar to the following in the linux environment: >> >> fd = open("/sys/devices/pci0001\:00/0001\:00\:07.0/resource0", O_RDWR | O_SYNC); >> ptr = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); >> printf("PCI BAR0 0x0000 = 0x%4x\n", *((unsigned short *) ptr); >> >> (above taken from >> http://billfarrow.blogspot.com.au/2010/09/userspace-access-to-pci-memory.html) [...] > AFAIK, there is no facilities in FreeBSD kernel which allow you to get > the configuration registers or memory BARs mmapped into the userspace. > The linsysfs is out of question for this sort of hacks. The native > FreeBSD' /dev/pci does not support mmaping either. > > It should be not too hard to extend the /dev/pci to do what you described. > Start looking at the sys/dev/pci/pci_user.c > > PCIe configuration window is active, so you could access it by hand by > mmapping /dev/mem. Also, the window is mapped into KVA, so you could > access it by /dev/kmem as well. /dev/mem would be easier, I think, > because it needs the physical address, which can be learned from ACPI > MCFG much easier than the value of the static symbol pcie_base. I see -- thanks for the pointers! I shall consider my options :)