From owner-freebsd-questions@FreeBSD.ORG Thu Dec 9 04:05:20 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 43C7616A4CE for ; Thu, 9 Dec 2004 04:05:20 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id E857343D54 for ; Thu, 9 Dec 2004 04:05:03 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.1) id iB9453qO050263; Wed, 8 Dec 2004 22:05:03 -0600 (CST) (envelope-from dan) Date: Wed, 8 Dec 2004 22:05:03 -0600 From: Dan Nelson To: cm c Message-ID: <20041209040502.GJ2629@dan.emsphone.com> References: <20041208035709.GF2629@dan.emsphone.com> <20041209034201.11670.qmail@web15307.mail.bjs.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041209034201.11670.qmail@web15307.mail.bjs.yahoo.com> X-OS: FreeBSD 5.3-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i 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 04:05:20 -0000 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