From owner-freebsd-drivers@FreeBSD.ORG Mon Jul 20 21:35:58 2009 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 429FE106564A for ; Mon, 20 Jul 2009 21:35:58 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1782F8FC15 for ; Mon, 20 Jul 2009 21:35:58 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id CAC1046B53; Mon, 20 Jul 2009 17:35:57 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 0A91F8A09D; Mon, 20 Jul 2009 17:35:57 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Mon, 20 Jul 2009 09:58:48 -0400 User-Agent: KMail/1.9.7 References: <002801ca06f0$b1d42af0$157c80d0$@net> In-Reply-To: <002801ca06f0$b1d42af0$157c80d0$@net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200907200958.49119.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 20 Jul 2009 17:35:57 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.0 required=4.2 tests=AWL,BAYES_00, DATE_IN_PAST_06_12,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: Re: Driver development question X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jul 2009 21:35:58 -0000 On Friday 17 July 2009 11:10:17 am Chris Harrer wrote: > Hi All, > > I'm hoping someone can point me in the right direction... I'm developing a > FreeBSD driver for a PCIe card. The driver controls a hardware device that > has DRAM and various state information on it. I'm trying to mimic > functionality I have for other OS support such that I can dump memory and > state information from the card to a file I create from within my driver > (kernel module). > > For example, in a Linux driver I use filp_open to create the dump file > (represented by fp), then use fp->f_op->write to put information into the > file. > > FreeBSD doesn't have filp_* API's. I've tried searching for example drivers > and googling for file API's from kernel modules to no avail. Can someone > please offer some guidance as to how I might proceed here? > > Thanks in advance and any insight would be most appreciated! You can look at sys/kern/kern_ktrace.c to see how the ktrace() system call creates a file. I think in general you will wind up using NDINIT/namei() (to lookup the vnode for a pathname) and then vn_open() / vn_rdwr() / vn_close(). -- John Baldwin