From owner-freebsd-drivers@FreeBSD.ORG Wed Apr 28 10:25:50 2010 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 DDC4E106566B for ; Wed, 28 Apr 2010 10:25:50 +0000 (UTC) (envelope-from 380008156@qq.com) Received: from smtpbg52.qq.com (smtpbg52.qq.com [64.71.138.43]) by mx1.freebsd.org (Postfix) with SMTP id C46E88FC21 for ; Wed, 28 Apr 2010 10:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s0907; t=1272450336; bh=v/BR+bZC7UnaZvwZxsiTjNwfQlWODo8kPP8FboPbOZM=; h=X-QQ-ThreadID:X-QQ-SSF:X-Originating-IP:X-QQ-STYLE:X-QQ-mid:From: To:Sender:Subject:Mime-Version:Content-Type: Content-Transfer-Encoding:Date:X-Priority:Message-ID:X-QQ-MIME: X-Mailer:X-QQ-Mailer; b=KQVLfvNDJZiNiJ/FYoloGIF3Lbnm79LEneN5A9wqQDoAeA+yb+zJL4Lz9PTM1sCzI HjQ5gtWqdbKb1YBBnyyNY1LyRbwTf6ZOwbX8lsXG1RZb5YJfiOM963i6XsSyxzh X-QQ-ThreadID: xPv6mQKhun,0 X-QQ-SSF: 000000000000006 X-Originating-IP: 60.176.112.196 X-QQ-STYLE: X-QQ-mid: webmail358t1272450332t12419 From: "=?ISO-8859-1?B?S0dC?=" To: "=?ISO-8859-1?B?ZnJlZWJzZC1kcml2ZXJz?=" Sender: 380008156@qq.com Mime-Version: 1.0 Date: Wed, 28 Apr 2010 18:25:32 +0800 X-Priority: 3 Message-ID: X-QQ-MIME: TCMime 1.0 by Tencent X-Mailer: QQMail 2.x X-QQ-Mailer: QQMail 2.x X-Mailman-Approved-At: Wed, 28 Apr 2010 11:55:53 +0000 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: base64 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: How to designate parameter array to the driver module? 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, 28 Apr 2010 10:25:50 -0000 SGkgYWxsOg0KICAgICAgSSB3YW50IHRvIGRlc2lnbmF0ZSBwYXJhbWV0ZXIgYXJyYXkgdG8g dGhlIGRyaXZlciBtb2R1bGUuSW4gbGludXggLEkgY2FuIHRoZSBNQUNSTyBtb2R1bGVfcGFy YW1fYXJyYXkuIFNvIEkgd2FudCB0byBrbm93IHNpbWlsYXIgYXBwcm9hY2ggaW4gZnJlZUJT RCA3Pw0KICANCiAgICAgIENhbiBzb21lb25lIGdpdmUgbWUgYWR2aWNlPw0KICAgICAgDQog ICAgICBUaGFua3MgaW4gYWR2YW5jZS4= From owner-freebsd-drivers@FreeBSD.ORG Thu Apr 29 12:46:26 2010 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 5E2FD106570F for ; Thu, 29 Apr 2010 12:46:26 +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 31E358FC17 for ; Thu, 29 Apr 2010 12:46:26 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id E04CB46B0D; Thu, 29 Apr 2010 08:46:25 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id C73608A021; Thu, 29 Apr 2010 08:46:24 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Thu, 29 Apr 2010 07:53:34 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201004290753.34712.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 29 Apr 2010 08:46:24 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: Re: How to designate parameter array to the driver module? 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, 29 Apr 2010 12:46:26 -0000 On Wednesday 28 April 2010 6:25:32 am KGB wrote: > Hi all: > I want to designate parameter array to the driver module.In linux ,I can the MACRO module_param_array. So I want to know similar approach in freeBSD 7? > > Can someone give me advice? > > Thanks in advance. In FreeBSD settings are passed to kernel modules via tunable strings set in the kernel environment (either via /boot/loader.conf or using kenv(1)). You can then fetch these settings in a module via the TUNABLE_* macros. For example: /* Number of widgets for each foo device. */ static int foo_widgets = DEFAULT_WIDGET_COUNT; TUNABLE_INT("hw.foo.widgets", &foo_widgets); A user can then override the default value by setting 'hw.foo.widgets=N' in the kernel environment. If you wish the value to also be tunable at runtime then you can expose it via sysctl as well. It is generally a good idea to do report tunables via read-only sysctls even if they aren't adjustable at runtime, thus: SYSCTL_NODE(_hw, OID_AUTO, foo, CTLFLAG_RD, NULL, "foo driver settings"); /* Number of widgets for each foo device. */ static int foo_widgets = DEFAULT_WIDGET_COUNT; TUNABLE_INT("hw.foo.widgets", &foo_widgets); SYSCTL_INT(_hw_foo, OID_AUTO, widgets, CTLFLAG_RDTUN, &foo_widgets, 0, "Number of widgets for each foo device"); If you need to pass in more complex data structures than simple settings then the approach may depend on what sort of data you are loading. If you wish to load a chunk of firmware, then you can use the firmware(9) interface which will let you store the firmware in a separate kernel module that can be loaded from the boot loader or on-demand at runtime. -- John Baldwin From owner-freebsd-drivers@FreeBSD.ORG Fri Apr 30 14:56:27 2010 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 55248106566C for ; Fri, 30 Apr 2010 14:56:27 +0000 (UTC) (envelope-from indranil@virident.com) Received: from caexchgw.virident.com (caexchgw.virident.com [209.31.25.116]) by mx1.freebsd.org (Postfix) with ESMTP id 348F08FC19 for ; Fri, 30 Apr 2010 14:56:26 +0000 (UTC) Received: from caexch1.virident.info ([172.16.32.15]) by caexchgw.virident.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 30 Apr 2010 07:39:26 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Date: Fri, 30 Apr 2010 07:39:28 -0700 Message-ID: <28631E6913C8074E95A698E8AC93D09101AAF44A@caexch1.virident.info> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Question about pci programming Thread-Index: AcrocuwyChFPiGf2SjOzk9Tv8x+gRw== From: "Indranil Bhattacharya" To: X-OriginalArrivalTime: 30 Apr 2010 14:39:26.0560 (UTC) FILETIME=[EEE85600:01CAE872] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Question about pci programming 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: Fri, 30 Apr 2010 14:56:27 -0000 Hi, =20 In freebsd, how do I set a dma mask for a pci device ? In linux the kernel api is pci_set_dma_mask(). In particular, I will like to enable PCI double address cycle mapping (64 bit addressing) for our device. =20 Thanks in advance, Indranil From owner-freebsd-drivers@FreeBSD.ORG Fri Apr 30 16:52:35 2010 Return-Path: Delivered-To: freebsd-drivers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F19C4106566C for ; Fri, 30 Apr 2010 16:52:35 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 8FF0F8FC12 for ; Fri, 30 Apr 2010 16:52:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o3UGmeTw022468; Fri, 30 Apr 2010 10:48:40 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Fri, 30 Apr 2010 10:48:53 -0600 (MDT) Message-Id: <20100430.104853.29593248078744249.imp@bsdimp.com> To: indranil@virident.com From: "M. Warner Losh" In-Reply-To: <28631E6913C8074E95A698E8AC93D09101AAF44A@caexch1.virident.info> References: <28631E6913C8074E95A698E8AC93D09101AAF44A@caexch1.virident.info> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-drivers@FreeBSD.org Subject: Re: Question about pci programming 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: Fri, 30 Apr 2010 16:52:36 -0000 In message: <28631E6913C8074E95A698E8AC93D09101AAF44A@caexch1.virident.info> "Indranil Bhattacharya" writes: : In freebsd, how do I set a dma mask for a pci device ? In linux the : kernel api is pci_set_dma_mask(). In particular, I will like to enable : PCI double address cycle mapping (64 bit addressing) for our device. Isn't this just done with the bus_dma routines passing in a 64-bit address mask? Warner