From owner-freebsd-questions@FreeBSD.ORG Thu Dec 9 05:20:23 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A12C616A4D0 for ; Thu, 9 Dec 2004 05:20:23 +0000 (GMT) Received: from web15302.mail.bjs.yahoo.com (web15302.mail.cnb.yahoo.com [202.43.216.177]) by mx1.FreeBSD.org (Postfix) with SMTP id 3F84643D48 for ; Thu, 9 Dec 2004 05:20:22 +0000 (GMT) (envelope-from beatlelittle@yahoo.com.cn) Message-ID: <20041209052020.9471.qmail@web15302.mail.bjs.yahoo.com> Received: from [220.194.103.228] by web15302.mail.cnb.yahoo.com via HTTP; Thu, 09 Dec 2004 13:20:20 CST Date: Thu, 9 Dec 2004 13:20:20 +0800 (CST) From: cm c To: Dan Nelson In-Reply-To: <20041209040502.GJ2629@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.1 cc: freebsd-questions@freebsd.org Subject: Re: How to write driver with load time parameter support? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2004 05:20:23 -0000 Thank you very much! It does work! CcM Dan Nelson wrote: In the last episode (Dec 09), cm c said: > I'm still not very clear the way to do this. Does this method do set > the parameters at load time or after load ? Cause Linux can > insmod abc.o param=123; > param is set to 123 when abc is linked to the kernel. You would put something like abc.param="123" in loader.conf or add it via kenv, and then in your variable declaration area: static int myparam = 0; TUNABLE_INT("abc.param", &myparam); That works for a module that can only be loaded once, and a static tuneable name. If you don't know the name of the tunable until your driver is loaded, you can use the TUNABLE_INT_FETCH() macro in a function. Sysctls are recommended if you have a value that can be changed after the module is loaded. If you are writing a device driver, take a look at how if_fxp.c pulls in per-device tunable/sysctls (search for bundle_max). -- Dan Nelson dnelson@allantgroup.com _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" --------------------------------- Do You Yahoo!? 注册世界一流品质的雅虎免费电邮