Suggestion for handling of boot-time driver options

Roderich Schupp (
Sat, 13 Dec 1997 20:17:57 +0100

I just saw that init/main.c is full of constructs of the form
{ "ez=", ez_setup },
{ "floppy=", floppy_setup },
(and corresponding
extern void floppy_setup(char *str, int *ints);
etc). The whole purpose of this tangle is to fill the "bootsetups"
array so that init options of drivers can be recognized and the appropriate
setup function (actually implemented in the driver source file)
be invoked.
This could be achieved more elegantly (and without cluttering init/main.c
with entries for every setup function imaginable) with some ELF linking
E.g. for the floppy driver, but something like
BOOTSETUP( "floppy=", floppy_setup );
into drivers/block/floppy.c (where floppy_setup is implemented anyway)
where BOOTSETUP is defined as
#define BOOTSETUP(str, setup_func) \
static struct bootsetup __bootsetup \
__attribute__ ((__section__ (".bootsetup"))) \
= { str, setup_func };
then gather all table entries from link section .bootsetup with
something like
. = ALIGN(4096); /* Init code and data */
__init_begin = .;
.text.init : { *(.text.init) }
.data.init : { *(.data.init) }
__start__bootsetups = . ;
.bootsetup : { *(.bootsetup) }
__stop__bootsetups = . ;
. = ALIGN(4096);
__init_end = .;
in the kernel link configuration file. The lookup code in init/main.c
then would look like this
extern struct bootsetup __start__bootsetups[], __stop__bootsetups[];
__initfunc(static int checksetup(char *line))
struct bootsetup *p = __start__bootsetups;
int ints[11];
while (p < __stop__bootsetups) {
int n = strlen(p->str);
if (!strncmp(line,p->str,n)) {
p->setup_func(get_options(line+n,ints), ints);
return 1;
return 0;

Any suggestions, objections, flames?
Cheers, Roderich

WHAT? I thought these were stuffed peppers.  Honey, what the heck IS this??
               Whatever it is, I'm not eating it!
Roderich Schupp
ExperTeam GmbH 
Munich, Germany               Linux: 2.1.72