Skip to content
Jens Nyberg edited this page Mar 3, 2014 · 9 revisions

Writing

A module is simply a object file with the postfix .ko. These are compiled as relocatable object files meaning when they are loaded they will be modified to accommodate the memory address it was loaded to. A module is part of the kernel after load and will run in privileged mode. This means that when writing a module you will need to pay extra attention to it because it could potentially break the whole system. The reason for this has to do with speed. As fudge is a monolithic kernel it has chosen this path to be as fast as possible.

By including the header files from either the kernel or another module you can call any function as if it had been compiled together because the module loader will take care of the address relocations for you. However this requires that in the case of calling another module that the module has been loaded in a previous step.

A module needs to have an init() and a destroy() function. These are called when the module is loaded and unloaded. The init function is the entry point of your module. The entry point should setup all parts of the module and then register whatever bus, device, driver or interface you have created.

Loading on boot

To load a module during boot edit packages/init/initmod.conf and add an entry for your module and also list what other modules it might depend on.

Loading manually

Manually load a module from the shell by typing:

$ modload < mymodule.ko