Date: Tue, 21 Jul 2009 17:34:32 -0700 From: Sam Leffler <sam@errno.com> To: Marc Loerner <marc.loerner@hob.de> Cc: freebsd-drivers@freebsd.org Subject: Re: Driver development question Message-ID: <4A665E98.2060800@errno.com> In-Reply-To: <200907210834.21541.marc.loerner@hob.de> References: <002801ca06f0$b1d42af0$157c80d0$@net> <200907200958.49119.jhb@freebsd.org> <4A64F200.2060900@errno.com> <200907210834.21541.marc.loerner@hob.de>
index | next in thread | previous in thread | raw e-mail
Marc Loerner wrote: > 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? These require a process context. alq is designed for exactly what the OP wants. The writes are non-blocking and can be done from interrupt context. The only (current) limitation is records must be fixed size but that's easy to deal with. I use alq to trace register r/w operations in a driver and it works great (low overhead so doesn't noticeably affect real-time operation). In fact it works so well that I ported the code to linux (you can find it in the madwifi code base). Samhelp
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A665E98.2060800>
