From owner-freebsd-drivers@FreeBSD.ORG Tue Jul 21 11:11:31 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 761B61065677 for ; Tue, 21 Jul 2009 11:11:31 +0000 (UTC) (envelope-from charrer@alacritech.com) Received: from smtp135.iad.emailsrvr.com (smtp135.iad.emailsrvr.com [207.97.245.135]) by mx1.freebsd.org (Postfix) with ESMTP id 3A7888FC08 for ; Tue, 21 Jul 2009 11:11:31 +0000 (UTC) (envelope-from charrer@alacritech.com) Received: from relay23.relay.iad.mlsrvr.com (localhost [127.0.0.1]) by relay23.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id 8D5921B4079; Tue, 21 Jul 2009 06:55:13 -0400 (EDT) Received: by relay23.relay.iad.mlsrvr.com (Authenticated sender: charrer-AT-alacritech.com) with ESMTPA id 77A321B4072; Tue, 21 Jul 2009 06:55:13 -0400 (EDT) From: "Christopher J. Harrer" To: "'Marc Loerner'" , References: <002801ca06f0$b1d42af0$157c80d0$@net> <200907200958.49119.jhb@freebsd.org> <4A64F200.2060900@errno.com> <200907210834.21541.marc.loerner@hob.de> In-Reply-To: <200907210834.21541.marc.loerner@hob.de> Date: Tue, 21 Jul 2009 06:55:26 -0400 Message-ID: <081601ca09f1$c1458ed0$43d0ac70$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcoJz+87ENR0XiwATFeGv39Bv8l9cgAIa5vQ Content-Language: en-us 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: Tue, 21 Jul 2009 11:11:31 -0000 > -----Original Message----- > From: owner-freebsd-drivers@freebsd.org [mailto:owner-freebsd- > drivers@freebsd.org] On Behalf Of Marc Loerner > Sent: Tuesday, July 21, 2009 2:34 AM > To: freebsd-drivers@freebsd.org > Subject: Re: Driver development question > > Am Dienstag 21 Juli 2009 00:38:56 schrieb Sam Leffler: > > John Baldwin wrote: > > > 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(). > > > > man alq(9). > > > > > > Why not use kern_open, kern_close, kern_preadv, kern_pwritev? > > Regards, > Marc Thanks for the suggestions everyone, I will be investigating more today. I appreciate all the pointers! Cheers, Chris