A few NDIS drivers come with additional files that the core driver module will load during initialization time. Typically, these files contain firmware which the driver will transfer to the device in order to make it fully operational. In Windows[rg], these files are usually just copied into one of the system directories along with the driver itself. In .Fx there are two mechanism for loading these files. If the driver is built as a loadable kernel module which is loaded after the kernel has finished booting (and after the root file system has been mounted), the extra files can simply be copied to the /compat/ndis directory, and they will be loaded into the kernel on demand when the the driver needs them. If however the driver is required to bootstrap the system (i.e., if the NDIS-based network interface is to be used for diskless/PXE booting), the files need to be pre-loaded by the bootstrap loader in order to be accessible, since the driver will need them before the root file system has been mounted. However, the bootstrap loader is only able to load files that are shared .Fx binary objects. The -f flag can be used to convert an arbitrary file firmfile into shared object format (the actual conversion is done using the objcopy(1) and ld(1) commands). The resulting files can then be copied to the /boot/kernel directory, and can be pre-loaded directly from the boot loader prompt, or automatically by editing the loader.conf(5) file. If desired, the files can also be loaded into memory at runtime using the kldload(8) command. When an NDIS driver tries to open an external file, the ndisapi(9) code will first search for a loaded kernel module that matches the name specified in the open request, and if that fails, it will then try to open the file from the /compat/ndis directory as well. Note that during kernel bootstrap, the ability to open files from /compat/ndis is disabled: only the module search will be performed. When using the -f flag, ndiscvt will generate both a relocatable object file (with a .o extension) and a shared object file (with a .ko extension). The shared object is the one that should be placed in the /boot/kernel directory. The relocatable object file is useful if the user wishes to create a completely static kernel image: the object file can be linked into the kernel directly along with the driver itself. Some editing of the kernel configuration files will be necessary in order to have the extra object included in the build. |