From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 00:12:03 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 37D7916A41F for ; Tue, 18 Oct 2005 00:12:03 +0000 (GMT) (envelope-from bharmaji@gmail.com) Received: from qproxy.gmail.com (qproxy.gmail.com [72.14.204.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id C216743D46 for ; Tue, 18 Oct 2005 00:12:02 +0000 (GMT) (envelope-from bharmaji@gmail.com) Received: by qproxy.gmail.com with SMTP id a39so906476qbd for ; Mon, 17 Oct 2005 17:12:02 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=lETip9D3auJggR+LnOI/DBRYI7BqfYB9PHX7NDsOyCw9rG1uY7s4Cv0FH6mqzh83kBLe759reVUUopLB6YKc6PWbTWGtq5O0gijuGEy2kvAcQSahGk5C9965M7Lpr9cVILoZAQQeMZ8/DcMZwWAPEr1YLJ66SkKNvoOF4bnGikI= Received: by 10.65.98.20 with SMTP id a20mr2502853qbm; Mon, 17 Oct 2005 17:12:02 -0700 (PDT) Received: by 10.65.132.10 with HTTP; Mon, 17 Oct 2005 17:12:02 -0700 (PDT) Message-ID: <67beabb0510171712v1b1a5d18p15d5a866776392ec@mail.gmail.com> Date: Mon, 17 Oct 2005 17:12:02 -0700 From: Bharma Ji To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: loading microcode automatically while loading the driver 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, 18 Oct 2005 00:12:03 -0000 Hi I need to run a script that loads microcode onto a chip after its driver ha= s been loaded during startup. How can this be done? In essence - the requirement is to run a user specified script during startup(but only after the driver has been loaded) Thanks for any answers From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 00:33:35 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1279416A41F for ; Tue, 18 Oct 2005 00:33:35 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id A6A0043D49 for ; Tue, 18 Oct 2005 00:33:34 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9I0VaD6015013; Mon, 17 Oct 2005 18:31:36 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 17 Oct 2005 18:32:52 -0600 (MDT) Message-Id: <20051017.183252.78709558.imp@bsdimp.com> To: bharmaji@gmail.com From: "M. Warner Losh" In-Reply-To: <67beabb0510171712v1b1a5d18p15d5a866776392ec@mail.gmail.com> References: <67beabb0510171712v1b1a5d18p15d5a866776392ec@mail.gmail.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Mon, 17 Oct 2005 18:31:36 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: loading microcode automatically while loading the driver 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, 18 Oct 2005 00:33:35 -0000 In message: <67beabb0510171712v1b1a5d18p15d5a866776392ec@mail.gmail.com> Bharma Ji writes: : I need to run a script that loads microcode onto a chip after its driver has : been loaded during startup. How can this be done? In essence - the : requirement is to run a user specified script during startup(but only after : the driver has been loaded) There's a number of different options for this. By far the easiest is to create a rc.d script and place it in /etc/rc.d or /usr/local/etc/rc.d. You can load firmware and do whatever else you need to do there. Another alternative is to hook into devd and have a script run when the driver attaches. This would have the advantage of running automatically when you load the driver as well as at boot. IF all you want to do is load firmware, you can use techniques similar to isp and ispfw to place the firmware in a module that's loaded as necessary to load the device's firmware. Warner From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 01:25:28 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 06E7816A41F for ; Tue, 18 Oct 2005 01:25:28 +0000 (GMT) (envelope-from bharmaji@gmail.com) Received: from qproxy.gmail.com (qproxy.gmail.com [72.14.204.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F48843D46 for ; Tue, 18 Oct 2005 01:25:27 +0000 (GMT) (envelope-from bharmaji@gmail.com) Received: by qproxy.gmail.com with SMTP id a39so916893qbd for ; Mon, 17 Oct 2005 18:25:26 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=NrJHHTdIrzwWG/hvDCEQCblPj86HrbGIUPjuMm7GDGsksTx6PMy6YHdUXf6Xq3vH0Z8MtwkRw3wN4gpV4QKL8dza27TZ2xb/ebtAMrjQzFU/acGzjegRIsQt9NTbcW1wTr7wGOl0R6kOkvaPyE6/eLlBiWD1W3FeFI+QAsrW520= Received: by 10.65.81.2 with SMTP id i2mr2548931qbl; Mon, 17 Oct 2005 18:25:26 -0700 (PDT) Received: by 10.65.132.10 with HTTP; Mon, 17 Oct 2005 18:25:26 -0700 (PDT) Message-ID: <67beabb0510171825q1e124bf6v2adbe0c9f235a6ae@mail.gmail.com> Date: Mon, 17 Oct 2005 18:25:26 -0700 From: Bharma Ji To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Recommended ways to log driver operations 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, 18 Oct 2005 01:25:28 -0000 Hi I recently wrote a driver for a chip. I am wondering if there are any standard recommended ways of logging the driver operations. I have used printf in the driver and I look at it using dmesg so far. Am wondering if i= t is possible to create a driver specific log file so that it is easy to debug. Also, if the driver emits copious output then the log buffer will overflow and some messages may be truncated. Writing to a specific log file may help in that case. However, I have no idea if this is worth investigating. Any suggestions appreciated From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 03:09:35 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CDAE316A41F for ; Tue, 18 Oct 2005 03:09:35 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 643AA43D45 for ; Tue, 18 Oct 2005 03:09:35 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9I38cs4016223; Mon, 17 Oct 2005 21:08:39 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Mon, 17 Oct 2005 21:09:55 -0600 (MDT) Message-Id: <20051017.210955.104032631.imp@bsdimp.com> To: bharmaji@gmail.com From: "M. Warner Losh" In-Reply-To: <67beabb0510171825q1e124bf6v2adbe0c9f235a6ae@mail.gmail.com> References: <67beabb0510171825q1e124bf6v2adbe0c9f235a6ae@mail.gmail.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Mon, 17 Oct 2005 21:08:39 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: Recommended ways to log driver operations 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, 18 Oct 2005 03:09:36 -0000 In message: <67beabb0510171825q1e124bf6v2adbe0c9f235a6ae@mail.gmail.com> Bharma Ji writes: : I recently wrote a driver for a chip. I am wondering if there are any : standard recommended ways of logging the driver operations. I have used : printf in the driver and I look at it using dmesg so far. Am wondering if it : is possible to create a driver specific log file so that it is easy to : debug. Also, if the driver emits copious output then the log buffer will : overflow and some messages may be truncated. Writing to a specific log file : may help in that case. However, I have no idea if this is worth : investigating. Any suggestions appreciated printf(9) doesn't give you much of a chance to segregate the logs. You can also use log(9), but that just adds the ability to give a priority to the log message, which can help. If you want to debug the driver to find out what's going on at a high rate, you might want to look at ktr(9) and alq(9). These facilities are more for debugging and performance tuning, rather than day to day operations. In general, FreeBSD drivers follow the unix tradition of only complaining when there are problems. Warner From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 08:27:01 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6F8116A420 for ; Tue, 18 Oct 2005 08:27:01 +0000 (GMT) (envelope-from mayong@mail.com) Received: from cal1-1.us4.outblaze.com (cal1-1.us4.outblaze.com [205.158.62.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5CD8943D75 for ; Tue, 18 Oct 2005 08:26:56 +0000 (GMT) (envelope-from mayong@mail.com) Received: (from mdrop@localhost) by cal1-1.us4.outblaze.com (8.11.6/8.11.6) id j9I8Quw26871; Tue, 18 Oct 2005 08:26:56 GMT Message-Id: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 From: "Yong Ma" To: freebsd-drivers@freebsd.org Date: Tue, 18 Oct 2005 03:26:56 -0500 Received: from [159.226.5.225] by cal1-1.us4.outblaze.com with http for mayong@mail.com; Tue, 18 Oct 2005 03:26:56 -0500 X-Originating-Ip: 159.226.5.225 X-Originating-Server: cal1-1.us4.outblaze.com Subject: Some Questions 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, 18 Oct 2005 08:27:01 -0000 Hi everybody: =20 I'm new here,nice to meet you all! I'm also aFreeBSD_device_driver newbie, = and now I'm enaged in writting a driverfor a cryptographic accelerator card= .As a preparation I read thesections of device driver in "FreeBSD Architect= ure Handbook",andexercised the example driver in the book.now I have severa= l questions(maybeeasy for you but most useful for me): 1)Some drivers declares the device_open() as int device_open(dev_t dev,...)= ,and some declare it as int device_open(struct cdev *dev,...),sometimes the first one couldn't be compliedsuccessfully,what's t= he difference? 2) if (pci_get_vendor(dev) =3D=3D 0x11c1) { ... ~~~~~~~~how to get this number if I don't kno= w it? 3)Could the device on PCI slot be listed by /pciconf -l /without driver. 4)The printf() seems not work under XWindow mode in functions like deviec_p= rob or device_attach,how to make it work? 5)If only the pseudo-device in /dev can be destroyed with destroy_dev(sc->d= ev0) in detach() function in a KLD driver? I can't do that! Thanks=20 Ma --=20 ___________________________________________________ Play 100s of games for FREE! http://games.mail.com/ From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 13:31:22 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DEF5916A420 for ; Tue, 18 Oct 2005 13:31:22 +0000 (GMT) (envelope-from nsrashmi@gmail.com) Received: from qproxy.gmail.com (qproxy.gmail.com [72.14.204.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id D95BD43D4C for ; Tue, 18 Oct 2005 13:31:21 +0000 (GMT) (envelope-from nsrashmi@gmail.com) Received: by qproxy.gmail.com with SMTP id e11so30348qbe for ; Tue, 18 Oct 2005 06:31:21 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=Vn6eSEasjjAEvhyJE0U/iszHGlVpa8c36g+zNMphc2/MyXmHjNYF2wHQAo5pJKhf87fGiSsKwq/GqFdTlNGn6412dgf1r0lgmC45Uu+5jpAeAziEYn2Dl/wp13H0e6UYqlZHtvWBeVVJ3ivb2KssJjTis6jwqmnLISrj5Uq3074= Received: by 10.65.206.16 with SMTP id i16mr561775qbq; Tue, 18 Oct 2005 06:31:21 -0700 (PDT) Received: by 10.64.201.3 with HTTP; Tue, 18 Oct 2005 06:31:21 -0700 (PDT) Message-ID: <9f9993160510180631n147bf7catfe693452f89ebb06@mail.gmail.com> Date: Tue, 18 Oct 2005 19:01:21 +0530 From: rashmi ns To: bugi@lists.redbrick.dcu.ie, freebsd-drivers@freebsd.org, freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: help regarding : To recieve and tranmit packet th' an interface 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, 18 Oct 2005 13:31:23 -0000 Hello List-members, we are writing a driver for HDLC-Controller We have coded upto some extent and actully we are able to transmit and recieve a char buff in loopback (from inside a driver). But we want to tranmit/Rx a real packet in (mbuf structure) and test our code .As it is a HDLC controller does'nt have std MAC ADDRRSS . How can i actually achieve a packet transmition and reception .Are there some drivers which does the same Thanks and Regards, Memeber From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 13:38:54 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5F34016A41F; Tue, 18 Oct 2005 13:38:54 +0000 (GMT) (envelope-from garyj@jennejohn.org) Received: from peedub.jennejohn.org (J9c05.j.pppool.de [85.74.156.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9A0C543D45; Tue, 18 Oct 2005 13:38:53 +0000 (GMT) (envelope-from garyj@jennejohn.org) Received: from jennejohn.org (localhost [127.0.0.1]) by peedub.jennejohn.org (8.13.4/8.11.6) with ESMTP id j9IDcfw2006408; Tue, 18 Oct 2005 15:38:41 +0200 (CEST) (envelope-from garyj@jennejohn.org) Message-Id: <200510181338.j9IDcfw2006408@peedub.jennejohn.org> X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.0.4 To: rashmi ns In-Reply-To: Message from rashmi ns of "Tue, 18 Oct 2005 19:01:21 +0530." <9f9993160510180631n147bf7catfe693452f89ebb06@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 18 Oct 2005 15:38:41 +0200 From: Gary Jennejohn Cc: freebsd-hackers@freebsd.org, freebsd-drivers@freebsd.org, bugi@lists.redbrick.dcu.ie Subject: Re: help regarding : To recieve and tranmit packet th' an interface 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, 18 Oct 2005 13:38:54 -0000 rashmi ns writes: > Hello List-members, > we are writing a driver for HDLC-Controller We have coded upto some extent > and actully we are able to transmit and recieve a char buff in loopback > (from inside a driver). > But we want to tranmit/Rx a real packet in (mbuf structure) and test our > code .As it is a HDLC controller does'nt have std MAC ADDRRSS . How can i > actually achieve a packet transmition and reception .Are there some drivers > which does the same > I've done this under Linux (ethernet-over-HDLC) and just used a faked MAC which wouldn't conflict with existing HW. --- Gary Jennejohn / garyjATjennejohnDOTorg gjATfreebsdDOTorg garyjATdenxDOTde From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 13:39:17 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D557216A426; Tue, 18 Oct 2005 13:39:17 +0000 (GMT) (envelope-from david@madole.net) Received: from a.omd3.com (a.omd3.com [69.90.174.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 56D2C43D46; Tue, 18 Oct 2005 13:39:17 +0000 (GMT) (envelope-from david@madole.net) Received: from dhcp-66-212-201-164.myeastern.com ([66.212.201.164] helo=david) by a.omd3.com with esmtpa (Exim 4.50) id 1ERrgP-000Fb6-A8; Tue, 18 Oct 2005 09:39:13 -0400 Message-ID: <141d01c5d3e9$53470090$c3e7a8c0@david> From: "David S. Madole" To: "rashmi ns" , , , References: <9f9993160510180631n147bf7catfe693452f89ebb06@mail.gmail.com> Date: Tue, 18 Oct 2005 09:39:11 -0400 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Cc: Subject: Re: help regarding : To recieve and tranmit packet th' an interface 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, 18 Oct 2005 13:39:18 -0000 From: "rashmi ns" > > But we want to tranmit/Rx a real packet in (mbuf structure) and test > our > code .As it is a HDLC controller does'nt have std MAC ADDRRSS . How can > i > actually achieve a packet transmition and reception .Are there some > drivers > which does the same I would think any of the existing drivers for WAN-type interfaces would be facing all of the the same issues as you might. Take a look at the Hardware Notes for whatever release you are using under the Miscellaneous Network section: http://www.freebsd.org/releases/5.4R/hardware-i386.html David From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 15:12:55 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ED68F16A41F for ; Tue, 18 Oct 2005 15:12:55 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A3A243D46 for ; Tue, 18 Oct 2005 15:12:55 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9IFAHZi026200; Tue, 18 Oct 2005 09:10:17 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 18 Oct 2005 09:11:34 -0600 (MDT) Message-Id: <20051018.091134.85411642.imp@bsdimp.com> To: mayong@mail.com From: "M. Warner Losh" In-Reply-To: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> References: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Tue, 18 Oct 2005 09:10:18 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: Some Questions 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, 18 Oct 2005 15:12:56 -0000 In message: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> "Yong Ma" writes: : 1)Some drivers declares the device_open() as int device_open(dev_t : dev,...),and some declare it as int device_open(struct cdev : *dev,...),sometimes the first one couldn't be : compliedsuccessfully,what's the difference? In 4.x, the former was used. In 5.x and newer, the latter is used. On 4.x you could get away with the latter because dev_t was typedefed to be struct cdev *. : 2) if (pci_get_vendor(dev) == 0x11c1) { ... : ~~~~~~~~how to get this number if I don't know it? (1) Ask the vendor of your device (2) Read the datasheet for your device (3) pciconf -l :-) : 3)Could the device on PCI slot be listed by /pciconf -l /without driver. Yes. : 4)The printf() seems not work under XWindow mode in functions like : deviec_prob or device_attach,how to make it work? It works. However, the output is sent to the console. Under X windows, the console is normally hidden from you somewhere. You can get the last bit of console output, however, using the dmesg command. : 5)If only the pseudo-device in /dev can be destroyed with : destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't : do that! I'm afraid I don't understand this question. If you have, say, a global control device for all instances of the driver, you can keep a 'reference count' of the number of instances attached and then delete the device when the last one detaches. If it is something else, then I'll need more information. Warner From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 15:50:50 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B7BD316A424 for ; Tue, 18 Oct 2005 15:50:50 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 122FD43D45 for ; Tue, 18 Oct 2005 15:50:49 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from [10.50.41.234] (Not Verified[10.50.41.234]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Tue, 18 Oct 2005 12:07:16 -0400 From: John Baldwin To: freebsd-drivers@freebsd.org Date: Tue, 18 Oct 2005 11:17:51 -0400 User-Agent: KMail/1.8.2 References: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> In-Reply-To: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200510181117.52583.jhb@freebsd.org> Cc: Subject: Re: Some Questions 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, 18 Oct 2005 15:50:50 -0000 On Tuesday 18 October 2005 04:26 am, Yong Ma wrote: > Hi everybody: > > > I'm new here,nice to meet you all! I'm also aFreeBSD_device_driver newbie, > and now I'm enaged in writting a driverfor a cryptographic accelerator > card.As a preparation I read thesections of device driver in "FreeBSD > Architecture Handbook",andexercised the example driver in the book.now I > have several questions(maybeeasy for you but most useful for me): > > 1)Some drivers declares the device_open() as int device_open(dev_t > dev,...),and some declare it as int device_open(struct cdev > *dev,...),sometimes the first one couldn't be compliedsuccessfully,what's > the difference? On 6.0 and later you should use 'struct cdev *dev' and on 5.x and earlier 'dev_t dev'. > 2) if (pci_get_vendor(dev) == 0x11c1) { ... > ~~~~~~~~how to get this number if I don't > know it? This number is part of the chip ID in pciconf -l output. For example, on my laptop: pcib1@pci0:1:0: class=0x060400 card=0x00000000 chip=0x1a318086 rev=0x04 hdr=0x01 For this device, pci_get_devid(dev) would return 0x1a318086. pci_get_vendor(dev) would return the 0x8086 part of that. > 3)Could the device on PCI slot be listed by /pciconf -l /without driver. You mean cutting out the pcib1 part from the line above? You could always use something like awk, sed, or cut. For example: % pciconf -l | cut -d @ -f 2 pci0:0:0: class=0x060000 card=0x56001558 chip=0x1a308086 rev=0x04 hdr=0x00 pci0:1:0: class=0x060400 card=0x00000000 chip=0x1a318086 rev=0x04 hdr=0x01 pci0:29:0: class=0x0c0300 card=0x56001558 chip=0x24828086 rev=0x02 hdr=0x00 ... > 4)The printf() seems not work under XWindow mode in functions like > deviec_prob or device_attach,how to make it work? Run 'dmesg' in your Xterminal to see the messages. Alternatively, you can use the 'xconsole' program which should show the messages in its window. > 5)If only the pseudo-device in /dev can be destroyed with > destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't do > that! I'm not sure what you are asking here. You can't leave an entry in /dev around when your module is unloaded via kldunload since you would be removing the devsw and devsw functions that back that device resulting in a kernel panic the next time some process tried to use the /dev entry. What exact problem are you trying to solve? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 16:13:12 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5DC4B16A41F; Tue, 18 Oct 2005 16:13:12 +0000 (GMT) (envelope-from babkin@verizon.net) Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2257543D46; Tue, 18 Oct 2005 16:13:12 +0000 (GMT) (envelope-from babkin@verizon.net) Received: from vms170.mailsrvcs.net ([192.168.1.3]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IOK00GHHCI5D911@vms044.mailsrvcs.net>; Tue, 18 Oct 2005 11:01:17 -0500 (CDT) Date: Tue, 18 Oct 2005 11:01:17 -0500 (CDT) From: Sergey Babkin To: rashmi ns , bugi@lists.redbrick.dcu.ie, freebsd-drivers@freebsd.org, freebsd-hackers@freebsd.org Message-id: <9974216.1129651277680.JavaMail.root@vms170.mailsrvcs.net> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Cc: Subject: Re: help regarding : To recieve and tranmit packet th' an interface X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: babkin@users.sf.net List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2005 16:13:12 -0000 >From: rashmi ns >Hello List-members, >we are writing a driver for HDLC-Controller We have coded upto some extent >and actully we are able to transmit and recieve a char buff in loopback >(from inside a driver). >But we want to tranmit/Rx a real packet in (mbuf structure) and test our >code .As it is a HDLC controller does'nt have std MAC ADDRRSS . How can i >actually achieve a packet transmition and reception .Are there some drivers >which does the same All the point-to-point interfaces don't have a MAC address. You don't need it since there is only one place to which you can write data, into the port. Well, the problems start when you want to establish X.25 connections. Then you use the X.25 address similarly to a MAC address. But since usually the X.25 connections are static, you set up your table of connections and the translation table between the target IP address and X.25 address, similar to ARP but static. -SB From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 17:01:07 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3852A16A41F; Tue, 18 Oct 2005 17:01:07 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from gate.bitblocks.com (bitblocks.com [209.204.185.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id C401243D49; Tue, 18 Oct 2005 17:01:06 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost [127.0.0.1]) by gate.bitblocks.com (8.13.4/8.13.1) with ESMTP id j9IH151N023966; Tue, 18 Oct 2005 10:01:06 -0700 (PDT) (envelope-from bakul@bitblocks.com) Message-Id: <200510181701.j9IH151N023966@gate.bitblocks.com> To: rashmi ns In-reply-to: Your message of "Tue, 18 Oct 2005 19:01:21 +0530." <9f9993160510180631n147bf7catfe693452f89ebb06@mail.gmail.com> Date: Tue, 18 Oct 2005 10:01:05 -0700 From: Bakul Shah Cc: freebsd-hackers@freebsd.org, freebsd-drivers@freebsd.org, bugi@lists.redbrick.dcu.ie Subject: Re: help regarding : To recieve and tranmit packet th' an interface 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, 18 Oct 2005 17:01:07 -0000 > we are writing a driver for HDLC-Controller We have coded upto some extent > and actully we are able to transmit and recieve a char buff in loopback > (from inside a driver). > > But we want to tranmit/Rx a real packet in (mbuf structure) and test our > code .As it is a HDLC controller does'nt have std MAC ADDRRSS . How can i > actually achieve a packet transmition and reception .Are there some drivers > which does the same Look at /sys/net/if_spppsubr.c or /sys/netgraph/ng_sppp.c. One other option is to let your driver present a simple serial IO interface and implement higher level logic in a user level daemon that uses a tun device to plug into the network layer (like /usr/sbin/ppp). Also be, sure to read RFC1661! From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 18:10:20 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 61CC616A41F for ; Tue, 18 Oct 2005 18:10:20 +0000 (GMT) (envelope-from bharmaji@gmail.com) Received: from qproxy.gmail.com (qproxy.gmail.com [72.14.204.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id EBFD743D45 for ; Tue, 18 Oct 2005 18:10:19 +0000 (GMT) (envelope-from bharmaji@gmail.com) Received: by qproxy.gmail.com with SMTP id a39so144617qbd for ; Tue, 18 Oct 2005 11:10:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=JZATloQ88Q3Z7PN09oiis+q9FRJ1ZsXfHWOE2vc61JQNybJW6mKPu2Hyk1wAHGboT08jTfYw3CLAhjajqaBcP6DYFJTVtme/mg0TMN2/5PM8vKoZ0VU4YemMFO2OuRyze8SElGCKGViH3mEl/ifC9RvqcVZZFPoDivWENNf/sAc= Received: by 10.65.98.20 with SMTP id a20mr3254462qbm; Tue, 18 Oct 2005 11:10:11 -0700 (PDT) Received: by 10.65.132.10 with HTTP; Tue, 18 Oct 2005 11:10:11 -0700 (PDT) Message-ID: <67beabb0510181110s75928f6ah3825dff282da0f88@mail.gmail.com> Date: Tue, 18 Oct 2005 11:10:11 -0700 From: Bharma Ji To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: How to build only the modified in the driver. 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, 18 Oct 2005 18:10:20 -0000 When I do make buildkernel conf=3D, the entire kernel seems t= o be built. Is there a way to build only the driver files that have been modified? I have also tried make buildkernel conf =3D GENERIC and modified = a random file in one of the drivers. The entire kernel still gets built. Thanks for any answers From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 18:30:22 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C4E4D16A423 for ; Tue, 18 Oct 2005 18:30:22 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E60943D75 for ; Tue, 18 Oct 2005 18:30:13 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from [10.50.41.234] (Not Verified[10.50.41.234]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Tue, 18 Oct 2005 14:46:40 -0400 From: John Baldwin To: freebsd-drivers@freebsd.org Date: Tue, 18 Oct 2005 14:30:14 -0400 User-Agent: KMail/1.8.2 References: <67beabb0510181110s75928f6ah3825dff282da0f88@mail.gmail.com> In-Reply-To: <67beabb0510181110s75928f6ah3825dff282da0f88@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200510181430.15508.jhb@freebsd.org> Cc: Bharma Ji Subject: Re: How to build only the modified in the driver. 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, 18 Oct 2005 18:30:23 -0000 On Tuesday 18 October 2005 02:10 pm, Bharma Ji wrote: > When I do make buildkernel conf=, the entire kernel seems to > be built. Is there a way to build only the driver files that have been > modified? I have also tried make buildkernel conf = GENERIC and modified a > random file in one of the drivers. The entire kernel still gets built. > Thanks for any answers Use NO_KERNELCLEAN=yes. You may also be able to use NO_KERNELCONFIG=yes and NO_KERNELDEPEND=yes to speed up things in certain cases as well. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 18:36:42 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 88DA116A41F for ; Tue, 18 Oct 2005 18:36:42 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id C255943D46 for ; Tue, 18 Oct 2005 18:36:41 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9IIZlGs028327; Tue, 18 Oct 2005 12:35:48 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 18 Oct 2005 12:37:02 -0600 (MDT) Message-Id: <20051018.123702.41876411.imp@bsdimp.com> To: bharmaji@gmail.com From: "M. Warner Losh" In-Reply-To: <67beabb0510181110s75928f6ah3825dff282da0f88@mail.gmail.com> References: <67beabb0510181110s75928f6ah3825dff282da0f88@mail.gmail.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Tue, 18 Oct 2005 12:35:48 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: How to build only the modified in the driver. 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, 18 Oct 2005 18:36:42 -0000 In message: <67beabb0510181110s75928f6ah3825dff282da0f88@mail.gmail.com> Bharma Ji writes: : When I do make buildkernel conf=, the entire kernel seems to : be built. Is there a way to build only the driver files that have been : modified? I have also tried make buildkernel conf = GENERIC and modified a : random file in one of the drivers. The entire kernel still gets built. Yes. make -DNO_KERNCLEAN will do that. make -DNO_KERNDEPEND and -DNO_KERNCONFIG may also be useful. Warner From owner-freebsd-drivers@FreeBSD.ORG Wed Oct 19 01:32:26 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB91616A41F; Wed, 19 Oct 2005 01:32:25 +0000 (GMT) (envelope-from mayong@mail.com) Received: from cal1-1.us4.outblaze.com (cal1-1.us4.outblaze.com [205.158.62.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6745343D45; Wed, 19 Oct 2005 01:32:25 +0000 (GMT) (envelope-from mayong@mail.com) Received: (from mdrop@localhost) by cal1-1.us4.outblaze.com (8.11.6/8.11.6) id j9J1WOg16689; Wed, 19 Oct 2005 01:32:24 GMT Message-Id: <200510190132.j9J1WOg16689@cal1-1.us4.outblaze.com> Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 From: "Yong Ma" To: "John Baldwin" , freebsd-drivers@freebsd.org Date: Tue, 18 Oct 2005 20:32:24 -0500 Received: from [159.226.5.225] by cal1-1.us4.outblaze.com with http for mayong@mail.com; Tue, 18 Oct 2005 20:32:24 -0500 X-Originating-Ip: 159.226.5.225 X-Originating-Server: cal1-1.us4.outblaze.com Cc: Subject: Re: Some Questions 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: Wed, 19 Oct 2005 01:32:26 -0000 ----- Original Message ----- From: "John Baldwin" To: freebsd-drivers@freebsd.org Subject: Re: Some Questions Date: Tue, 18 Oct 2005 11:17:51 -0400 >=20 > On Tuesday 18 October 2005 04:26 am, Yong Ma wrote: > > Hi everybody: > > > > > > I'm new here,nice to meet you all! I'm also aFreeBSD_device_driver newb= ie, > > and now I'm enaged in writting a driverfor a cryptographic accelerator > > card.As a preparation I read thesections of device driver in "FreeBSD > > Architecture Handbook",andexercised the example driver in the book.now I > > have several questions(maybeeasy for you but most useful for me): > > > > 1)Some drivers declares the device_open() as int device_open(dev_t > > dev,...),and some declare it as int device_open(struct cdev > > *dev,...),sometimes the first one couldn't be compliedsuccessfully,what= 's > > the difference? >=20 > On 6.0 and later you should use 'struct cdev *dev' and on 5.x and earlier > 'dev_t dev'. >=20 > > 2) if (pci_get_vendor(dev) =3D=3D 0x11c1) { ... > > ~~~~~~~~how to get this number if I don't > > know it? >=20 > This number is part of the chip ID in pciconf -l output. For example, on= my > laptop: >=20 > pcib1@pci0:1:0: class=3D0x060400 card=3D0x00000000 chip=3D0x1a318086 rev= =3D0x04 > hdr=3D0x01 >=20 > For this device, pci_get_devid(dev) would return 0x1a318086. > pci_get_vendor(dev) would return the 0x8086 part of that. >=20 > > 3)Could the device on PCI slot be listed by /pciconf -l /without driver. >=20 > You mean cutting out the pcib1 part from the line above? You could alway= s use > something like awk, sed, or cut. For example: >=20 > % pciconf -l | cut -d @ -f 2 > pci0:0:0: class=3D0x060000 card=3D0x56001558 chip=3D0x1a308086 rev= =3D0x04 > hdr=3D0x00 > pci0:1:0: class=3D0x060400 card=3D0x00000000 chip=3D0x1a318086 rev= =3D0x04 > hdr=3D0x01 > pci0:29:0: class=3D0x0c0300 card=3D0x56001558 chip=3D0x24828086 rev= =3D0x02 > hdr=3D0x00 > ... >=20 > > 4)The printf() seems not work under XWindow mode in functions like > > deviec_prob or device_attach,how to make it work? >=20 > Run 'dmesg' in your Xterminal to see the messages. Alternatively, you ca= n use > the 'xconsole' program which should show the messages in its window. >=20 > > 5)If only the pseudo-device in /dev can be destroyed with > > destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't do > > that! >=20 > I'm not sure what you are asking here. You can't leave an entry in /dev > around when your module is unloaded via kldunload since you would be remo= ving > the devsw and devsw functions that back that device resulting in a kernel > panic the next time some process tried to use the /dev entry. What exact > problem are you trying to solve? >=20 There is a make_dev() in the attach() in my test driver,and a destroy_dev()= and a bus_generic_detach() in the detach(),but the later ones seems don't = work when I unload the KLD module,while the make_dev() works properly,so as= I load and unload the module,there are quite a few devices in /dev have th= e same name(for me they are mypci0). Several days ago,I did a driver test of a PSEUDO-DEVICE with the detach() w= orks properly.I wander if it is because of the real HARDWARE device this ti= me ? this is my detach() function: static int mypci_detach(device_t dev) { struct mypci_softc *sc; sc =3D (struct mypci_softc *) device_get_softc(dev); destroy_dev(sc->dev0); bus_generic_detach(dev); bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->res); printf("Mypci detached!\n"); return (0); } > -- > John Baldwin <>< http://www.FreeBSD.org/~jhb/ > "Power Users Use the Power to Serve" =3D http://www.FreeBSD.org Thanks very much Yong --=20 ___________________________________________________ Play 100s of games for FREE! http://games.mail.com/ From owner-freebsd-drivers@FreeBSD.ORG Wed Oct 19 15:35:50 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00B0116A46B for ; Wed, 19 Oct 2005 15:35:49 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7254043D4C for ; Wed, 19 Oct 2005 15:35:49 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from [10.50.41.234] (Not Verified[10.50.41.234]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Wed, 19 Oct 2005 11:52:20 -0400 From: John Baldwin To: "Yong Ma" Date: Wed, 19 Oct 2005 11:26:25 -0400 User-Agent: KMail/1.8.2 References: <200510190132.j9J1WOg16689@cal1-1.us4.outblaze.com> In-Reply-To: <200510190132.j9J1WOg16689@cal1-1.us4.outblaze.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200510191126.26371.jhb@freebsd.org> Cc: freebsd-drivers@freebsd.org Subject: Re: Some Questions 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: Wed, 19 Oct 2005 15:35:50 -0000 On Tuesday 18 October 2005 09:32 pm, Yong Ma wrote: > ----- Original Message ----- > From: "John Baldwin" > To: freebsd-drivers@freebsd.org > Subject: Re: Some Questions > Date: Tue, 18 Oct 2005 11:17:51 -0400 > > > On Tuesday 18 October 2005 04:26 am, Yong Ma wrote: > > > Hi everybody: > > > > > > > > > I'm new here,nice to meet you all! I'm also aFreeBSD_device_driver > > > newbie, and now I'm enaged in writting a driverfor a cryptographic > > > accelerator card.As a preparation I read thesections of device driver > > > in "FreeBSD Architecture Handbook",andexercised the example driver in > > > the book.now I have several questions(maybeeasy for you but most useful > > > for me): > > > > > > 1)Some drivers declares the device_open() as int device_open(dev_t > > > dev,...),and some declare it as int device_open(struct cdev > > > *dev,...),sometimes the first one couldn't be > > > compliedsuccessfully,what's the difference? > > > > On 6.0 and later you should use 'struct cdev *dev' and on 5.x and earlier > > 'dev_t dev'. > > > > > 2) if (pci_get_vendor(dev) == 0x11c1) { ... > > > ~~~~~~~~how to get this number if I don't > > > know it? > > > > This number is part of the chip ID in pciconf -l output. For example, on > > my laptop: > > > > pcib1@pci0:1:0: class=0x060400 card=0x00000000 chip=0x1a318086 rev=0x04 > > hdr=0x01 > > > > For this device, pci_get_devid(dev) would return 0x1a318086. > > pci_get_vendor(dev) would return the 0x8086 part of that. > > > > > 3)Could the device on PCI slot be listed by /pciconf -l /without > > > driver. > > > > You mean cutting out the pcib1 part from the line above? You could > > always use something like awk, sed, or cut. For example: > > > > % pciconf -l | cut -d @ -f 2 > > pci0:0:0: class=0x060000 card=0x56001558 chip=0x1a308086 rev=0x04 > > hdr=0x00 > > pci0:1:0: class=0x060400 card=0x00000000 chip=0x1a318086 rev=0x04 > > hdr=0x01 > > pci0:29:0: class=0x0c0300 card=0x56001558 chip=0x24828086 rev=0x02 > > hdr=0x00 > > ... > > > > > 4)The printf() seems not work under XWindow mode in functions like > > > deviec_prob or device_attach,how to make it work? > > > > Run 'dmesg' in your Xterminal to see the messages. Alternatively, you > > can use the 'xconsole' program which should show the messages in its > > window. > > > > > 5)If only the pseudo-device in /dev can be destroyed with > > > destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't do > > > that! > > > > I'm not sure what you are asking here. You can't leave an entry in /dev > > around when your module is unloaded via kldunload since you would be > > removing the devsw and devsw functions that back that device resulting in > > a kernel panic the next time some process tried to use the /dev entry. > > What exact problem are you trying to solve? > > There is a make_dev() in the attach() in my test driver,and a destroy_dev() > and a bus_generic_detach() in the detach(),but the later ones seems don't > work when I unload the KLD module,while the make_dev() works properly,so as > I load and unload the module,there are quite a few devices in /dev have the > same name(for me they are mypci0). Several days ago,I did a driver test of > a PSEUDO-DEVICE with the detach() works properly.I wander if it is because > of the real HARDWARE device this time ? > > this is my detach() function: > > static int > mypci_detach(device_t dev) > { > > struct mypci_softc *sc; > sc = (struct mypci_softc *) device_get_softc(dev); > destroy_dev(sc->dev0); > bus_generic_detach(dev); > bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->res); > printf("Mypci detached!\n"); > return (0); > } Do any processes have /dev/mypci0 open when you try to kldunload? You probably should maintain a count of open clients and if it is > 0, return EBUSY in my_pcidetach(). -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org From owner-freebsd-drivers@FreeBSD.ORG Wed Oct 19 15:57:51 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0159216A420; Wed, 19 Oct 2005 15:57:51 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 692A043D48; Wed, 19 Oct 2005 15:57:50 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9JFupt3068540; Wed, 19 Oct 2005 09:56:51 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 19 Oct 2005 09:58:10 -0600 (MDT) Message-Id: <20051019.095810.102655404.imp@bsdimp.com> To: jhb@freebsd.org From: "M. Warner Losh" In-Reply-To: <200510191126.26371.jhb@freebsd.org> References: <200510190132.j9J1WOg16689@cal1-1.us4.outblaze.com> <200510191126.26371.jhb@freebsd.org> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Wed, 19 Oct 2005 09:56:51 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: Some Questions 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: Wed, 19 Oct 2005 15:57:51 -0000 In message: <200510191126.26371.jhb@freebsd.org> John Baldwin writes: : On Tuesday 18 October 2005 09:32 pm, Yong Ma wrote: : > ----- Original Message ----- : > From: "John Baldwin" : > To: freebsd-drivers@freebsd.org : > Subject: Re: Some Questions : > Date: Tue, 18 Oct 2005 11:17:51 -0400 : > : > > On Tuesday 18 October 2005 04:26 am, Yong Ma wrote: : > > > Hi everybody: : > > > : > > > : > > > I'm new here,nice to meet you all! I'm also aFreeBSD_device_driver : > > > newbie, and now I'm enaged in writting a driverfor a cryptographic : > > > accelerator card.As a preparation I read thesections of device driver : > > > in "FreeBSD Architecture Handbook",andexercised the example driver in : > > > the book.now I have several questions(maybeeasy for you but most useful : > > > for me): : > > > : > > > 1)Some drivers declares the device_open() as int device_open(dev_t : > > > dev,...),and some declare it as int device_open(struct cdev : > > > *dev,...),sometimes the first one couldn't be : > > > compliedsuccessfully,what's the difference? : > > : > > On 6.0 and later you should use 'struct cdev *dev' and on 5.x and earlier : > > 'dev_t dev'. : > > : > > > 2) if (pci_get_vendor(dev) == 0x11c1) { ... : > > > ~~~~~~~~how to get this number if I don't : > > > know it? : > > : > > This number is part of the chip ID in pciconf -l output. For example, on : > > my laptop: : > > : > > pcib1@pci0:1:0: class=0x060400 card=0x00000000 chip=0x1a318086 rev=0x04 : > > hdr=0x01 : > > : > > For this device, pci_get_devid(dev) would return 0x1a318086. : > > pci_get_vendor(dev) would return the 0x8086 part of that. : > > : > > > 3)Could the device on PCI slot be listed by /pciconf -l /without : > > > driver. : > > : > > You mean cutting out the pcib1 part from the line above? You could : > > always use something like awk, sed, or cut. For example: : > > : > > % pciconf -l | cut -d @ -f 2 : > > pci0:0:0: class=0x060000 card=0x56001558 chip=0x1a308086 rev=0x04 : > > hdr=0x00 : > > pci0:1:0: class=0x060400 card=0x00000000 chip=0x1a318086 rev=0x04 : > > hdr=0x01 : > > pci0:29:0: class=0x0c0300 card=0x56001558 chip=0x24828086 rev=0x02 : > > hdr=0x00 : > > ... : > > : > > > 4)The printf() seems not work under XWindow mode in functions like : > > > deviec_prob or device_attach,how to make it work? : > > : > > Run 'dmesg' in your Xterminal to see the messages. Alternatively, you : > > can use the 'xconsole' program which should show the messages in its : > > window. : > > : > > > 5)If only the pseudo-device in /dev can be destroyed with : > > > destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't do : > > > that! : > > : > > I'm not sure what you are asking here. You can't leave an entry in /dev : > > around when your module is unloaded via kldunload since you would be : > > removing the devsw and devsw functions that back that device resulting in : > > a kernel panic the next time some process tried to use the /dev entry. : > > What exact problem are you trying to solve? : > : > There is a make_dev() in the attach() in my test driver,and a destroy_dev() : > and a bus_generic_detach() in the detach(),but the later ones seems don't : > work when I unload the KLD module,while the make_dev() works properly,so as : > I load and unload the module,there are quite a few devices in /dev have the : > same name(for me they are mypci0). Several days ago,I did a driver test of : > a PSEUDO-DEVICE with the detach() works properly.I wander if it is because : > of the real HARDWARE device this time ? : > : > this is my detach() function: : > : > static int : > mypci_detach(device_t dev) : > { : > : > struct mypci_softc *sc; : > sc = (struct mypci_softc *) device_get_softc(dev); : > destroy_dev(sc->dev0); : > bus_generic_detach(dev); : > bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->res); : > printf("Mypci detached!\n"); : > return (0); : > } : : Do any processes have /dev/mypci0 open when you try to kldunload? You : probably should maintain a count of open clients and if it is > 0, return : EBUSY in my_pcidetach(). You don't need to keep a count of open clients, per se, since the vfs layer will do that for you and the open/close pairs might not be pairs. The driver's close will only be called when all referneces go away, unless you have D_TRACK_CLOSE in your flags... In my drivers, I often use D_TRACK_CLOSE, call driver_busy in open, and driver_unbusy in close. I then check busy in detach and refuse to detach if things are busy. There are problems with doing this for detachable devices, because the driver will be forcibly torn down if detach fails anyway.... Warner From owner-freebsd-drivers@FreeBSD.ORG Thu Oct 20 02:04:01 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00C6016A420 for ; Thu, 20 Oct 2005 02:04:00 +0000 (GMT) (envelope-from mayong@mail.com) Received: from webmail-outgoing.us4.outblaze.com (webmail-outgoing.us4.outblaze.com [205.158.62.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C59943D62 for ; Thu, 20 Oct 2005 02:04:00 +0000 (GMT) (envelope-from mayong@mail.com) Received: from unknown (unknown [192.168.9.180]) by webmail-outgoing.us4.outblaze.com (Postfix) with QMQP id D2CAA18001B3 for ; Thu, 20 Oct 2005 02:03:57 +0000 (GMT) X-OB-Received: from unknown (205.158.62.182) by wfilter.us4.outblaze.com; 20 Oct 2005 02:03:57 -0000 Received: by ws1-6.us4.outblaze.com (Postfix, from userid 1001) id C0CE31CE304; Thu, 20 Oct 2005 02:03:57 +0000 (GMT) Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 From: "Yong Ma" To: "John Baldwin" Date: Wed, 19 Oct 2005 21:03:57 -0500 Received: from [159.226.5.225] by ws1-6.us4.outblaze.com with http for mayong@mail.com; Wed, 19 Oct 2005 21:03:57 -0500 X-Originating-Ip: 159.226.5.225 X-Originating-Server: ws1-6.us4.outblaze.com Message-Id: <20051020020357.C0CE31CE304@ws1-6.us4.outblaze.com> Cc: freebsd-drivers@freebsd.org Subject: Re: Some Questions 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: Thu, 20 Oct 2005 02:04:01 -0000 John Baldwin wrote: > Do any processes have /dev/mypci0 open when you try to kldunload? You > probably should maintain a count of open clients and if it is > 0, return= =20 > EBUSY in my_pcidetach(). > I have met another question(seems I have so many to ask!): I have to translate the function pci_resource_start() in the origina= l Linux driver,and I use following method: (reference:http://lists.freebsd.org/pipermail/freebsd-hackers/2005-April/01= 1724.html) =20=20 183 int rid =3D 0x10; 184 res =3D bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); 185 printf("resource alloc successfully!\n"); 186 sc->bst =3D rman_get_btag(res); 187 sc->bsh =3D rman_get_handle(res); // to pci_resource_start() An error occurred when I make it: test.c: In function `mypci_attach': test.c:186: warning: implicit declaration of function `rman_get_btag' test.c:186: warning: nested extern declaration of `rman_get_btag' test.c:187: warning: implicit declaration of function `rman_get_handle' test.c:187: warning: nested extern declaration of `rman_get_handle' and [root] #kldload -v ./test.ko kldload: can't load ./test.ko: No such file or directory (but the test.ko was just there!) Delete the last two lines and it will be complied and loaded successfully,b= ut I have to keep these two lines.I don't know what to do,tell me please! btw:I had #include in the file. Thanks and best regards Yong --=20 ___________________________________________________ Play 100s of games for FREE! http://games.mail.com/ From owner-freebsd-drivers@FreeBSD.ORG Thu Oct 20 03:43:01 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BBE0616A41F; Thu, 20 Oct 2005 03:43:01 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B7B043D64; Thu, 20 Oct 2005 03:43:01 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9K3eSwS074072; Wed, 19 Oct 2005 21:40:28 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 19 Oct 2005 21:41:49 -0600 (MDT) Message-Id: <20051019.214149.104032722.imp@bsdimp.com> To: mayong@mail.com From: "M. Warner Losh" In-Reply-To: <20051020020357.C0CE31CE304@ws1-6.us4.outblaze.com> References: <20051020020357.C0CE31CE304@ws1-6.us4.outblaze.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Wed, 19 Oct 2005 21:40:29 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: Some Questions 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: Thu, 20 Oct 2005 03:43:01 -0000 In message: <20051020020357.C0CE31CE304@ws1-6.us4.outblaze.com> "Yong Ma" writes: : John Baldwin wrote: : : > Do any processes have /dev/mypci0 open when you try to kldunload? You : > probably should maintain a count of open clients and if it is > 0, return : > EBUSY in my_pcidetach(). : > : I have met another question(seems I have so many to ask!): : I have to translate the function pci_resource_start() in the original Linux driver,and I use following method: : (reference:http://lists.freebsd.org/pipermail/freebsd-hackers/2005-April/011724.html) : : 183 int rid = 0x10; : 184 res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); : 185 printf("resource alloc successfully!\n"); : 186 sc->bst = rman_get_btag(res); : 187 sc->bsh = rman_get_handle(res); // to pci_resource_start() : : : An error occurred when I make it: : : test.c: In function `mypci_attach': : test.c:186: warning: implicit declaration of function `rman_get_btag' : test.c:186: warning: nested extern declaration of `rman_get_btag' : test.c:187: warning: implicit declaration of function `rman_get_handle' : test.c:187: warning: nested extern declaration of `rman_get_handle' Try rman_get_bustag and rman_get_bushandle instead. Warner