Messages in this thread |  | | Date | Sat, 24 Apr 1999 14:01:36 -0700 | | From | Kirk Petersen <> | | Subject | Re: How/When does the kernel know to load a module? |
| |
> My first question is by what means the bare kernel knows that it needs a > function residing in a module?
It is up to each part of the kernel to determine when a module is required and load it. It isn't something that happens by function dependencies, like linking a binary might. A good example is sock_create() in linux/net/socket.c. When a socket is created, a call to request_module() is made with 'net-pf-%d' where the %d is filled in by the socket family. request_module() is what execve()s modprobe and does the actual work.
> For example: I traced the souce code of the network. As the bare kernel > setting up, it calls 'net_dev_init()'. 'net_dev_init()' will follow the > link: 'dev_base' to autoprobe net devices. I have a NE2000 card. I think > the kernel would call 'ne_probe()',( the function is in the module ne.o > ), but it didn't. The ne.o module is loaded only when the 'rc.d' shell > runs 'ifconfig eth0...'. My second question is why the kernel didn't > call 'ne_probe()' at first? and is it the 'ifconfig' informs the kernel > to load a module? and by what means to inform?
ifconfig tells the kernel to configure eth0, for example, and the kernel eventually calls request_module() with 'eth0'. The user has, hopefully, aliased eth0 to something like 'ne' and modprobe therefore loads the ne.o module (and any other module that ne.o depends on). When ne.o is loaded, its init_module() function is called, which registers some callback functions that get called to do things like send/receive packets or probe the card.
-- Kirk Petersen www.speakeasy.org/~kirk/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
|  |