Device Drivers: Building and Installing a Device Driver
Device Drivers: Building and Installing a Kernel Driver
The section tells you how to prepare, compile, and install your kernel driver.
- Export your driver's entry points by using the __declspec() macro:
__declspec(dllexport)
status_t init_hardware(void);
- Tell the linker to produce a shared library. If you're using the BeIDE, go to the Settings window, pop open the Project list, click on PPC Project or x86 Project, and select "Shared Library" in the Project Type popup menu. If you're using make, include the -G option.
- Disable the default behavior of linking against the shared system libraries. If you're using the BeIDE, remove the libroot, libbe, and libdll libraries from the project window. If you're using make, include the -nodefaults option.
- Add the kernel exports to the link list. On x86, this is located in /boot/develop/lib/x86/_KERNEL_.LIB. On PowerPC, you must link against a copy of the kernel renamed to _KERNEL_.
When an attempt is made to open a device, the kernel first looks for the driver for that device among those already loaded into memory. Failing that, the kernel looks for a driver in the following directories (in this order):
1. /beos/system/add-ons/kernel/drivers (on a floppy)
2. /boot/home/config/add-ons/kernel/drivers
3. /boot/beos/system/add-ons/kernel/drivers
Finished, publishable drivers should be installed in #2, /boot/home/config/add-ons/kernel/drivers. Do not install in the beos/system directory.
Once your driver has been installed, it is available immediately; there is no need to restart the system, unless you are replacing a driver that has previously been installed and loaded into memory.
The Be Book, in lovely HTML, for BeOS Release 3.
Copyright © 1998 Be, Inc. All rights reserved.
Last modified March 27, 1998.