Reading configuration file from driver during load
Warner Losh
imp at bsdimp.com
Tue Sep 19 07:46:05 PDT 2006
From: Oliver Fromme <olli at lurza.secnetix.de>
Subject: Re: Reading configuration file from driver during load
Date: Tue, 19 Sep 2006 15:46:09 +0200 (CEST)
> Gireesh wrote:
> > I have a driver which has some parameters hardcoded as of now. It requires
> > values of these parameters to be available during load (during attach
> > function). My requirement is to read these parameters from a configuration
> > file so that we can load driver with different values to parameters without
> > rebuilding driver.
>
> I think that sysctl or kenv variables are best suited for
> that purpose. There are a lot of examples for that in
> existing drivers.
The 'kenv' variables are best wrapped in the tunable interfaces. For
example:
u_long cbb_start_16_io = CBB_START_16_IO;
TUNABLE_ULONG("hw.cbb.start_16_io", &cbb_start_16_io);
SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RW,
&cbb_start_16_io, CBB_START_16_IO,
"Starting ioport for 16-bit cards");
This is from the cbb driver. It is a hint/tunable that can also set
the starting I/O port address range to use for 16-bit cards. Users
can either place the following line in /boot/loader.conf or in
/etc/sysctl.conf.
hw.cbb.start_16_io=0x300
The former sets it at attach time, while the latter sets it early in
the boot process, but after it has attached. You can also set it at
run-time:
sysctl hw.cbb.start_16_io=0x300
Warner
More information about the freebsd-drivers
mailing list