Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Dec 2004 22:05:03 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        cm c <beatlelittle@yahoo.com.cn>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How to write driver with load time parameter support?
Message-ID:  <20041209040502.GJ2629@dan.emsphone.com>
In-Reply-To: <20041209034201.11670.qmail@web15307.mail.bjs.yahoo.com>
References:  <20041208035709.GF2629@dan.emsphone.com> <20041209034201.11670.qmail@web15307.mail.bjs.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041209040502.GJ2629>