diff --git a/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml b/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml index 29cf0a05cb..52d27534ad 100644 --- a/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml +++ b/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml @@ -1,65 +1,68 @@ - - Writing FreeBSD Device Drivers + + Writing FreeBSD Device Drivers - This chapter was written by Murray Stokely with selections from - a variety of sources including the intro(4) man page by Joerg - Wunsch. + This chapter was written by &.murray with selections + from a variety of sources including the intro(4) man page by Joerg + Wunsch. - - Introduction - - This chapter provides a brief introduction to writing device - drivers for FreeBSD. A device in this context is a term used - mostly for hardware-related stuff that belongs to the system, - like disks, printers, or a graphics display with its keyboard. - A device driver is the software component of the operating - system that controls a specific device. There are also - so-called pseudo-devices where a device driver emulates the - behaviour of a device in software without any particular - underlying hardware. Device drivers can be compiled into the - system statically or loaded on demand through the dynamic - kernel linker facility `kld'. + + Introduction + This chapter provides a brief introduction to writing device + drivers for FreeBSD. A device in this context is a term used + mostly for hardware-related stuff that belongs to the system, + like disks, printers, or a graphics display with its keyboard. + A device driver is the software component of the operating + system that controls a specific device. There are also + so-called pseudo-devices where a device driver emulates the + behaviour of a device in software without any particular + underlying hardware. Device drivers can be compiled into the + system statically or loaded on demand through the dynamic kernel + linker facility `kld'. - Most devices in a Unix-like operating system are - accessed through device-nodes, sometimes also called special - files. These files are usually located under the directory - /dev in the file system hierarchy. Until - devfs is fully integrated into FreeBSD, each device node must - be created statically and independent of the existence of the - associated device driver. Most device nodes on the system are - created by running MAKEDEV. + Most devices in a Unix-like operating system are accessed + through device-nodes, sometimes also called special files. + These files are usually located under the directory + /dev in the file system hierarchy. Until + devfs is fully integrated into FreeBSD, each device node must be + created statically and independent of the existence of the + associated device driver. Most device nodes on the system are + created by running MAKEDEV. - Device drivers can roughly be broken down into two - categories; character and network device drivers. - + Device drivers can roughly be broken down into two + categories; character and network device drivers. - - Dynamic Kernel Linker Facility - KLD - The kld interface allows system administrators to - dynamically add and remove functionality from a running - system. This allows device driver writers to load their new - changes into a running kernel without constantly rebooting to - test changes. + - The kld interface is used through the following - administrator commands : - - kldload - loads a new kernel + + Dynamic Kernel Linker Facility - KLD + + The kld interface allows system administrators to + dynamically add and remove functionality from a running system. + This allows device driver writers to load their new changes into + a running kernel without constantly rebooting to test + changes. + + The kld interface is used through the following + administrator commands : + + + kldload - loads a new kernel module - kldunload - unloads a kernel + kldunload - unloads a kernel module - kldstat - lists the currently loadded + kldstat - lists the currently loadded modules - - + + + + Skeleton Layout of a kernel module - Skeleton Layout of a kernel module /* * KLD Skeleton * Inspired by Andrew Reiter's Daemonnews article @@ -100,67 +103,73 @@ skel_loader(struct module *m, int what, void *arg) DECLARE_MODULE(skeleton, skel_loader, SI_SUB_KLD, SI_ORDER_ANY); - - Makefile - FreeBSD provides a makefile include that you can use - to quickly compile your kernel addition. - SRCS=skeleton.c + + Makefile + + FreeBSD provides a makefile include that you can use to + quickly compile your kernel addition. + + SRCS=skeleton.c KMOD=skeleton .include <bsd.kmod.mk> - - Simply running make with - this makefile will create a file - skeleton.ko that can be loaded into - your system by typing : - -&prompt.root kldload -v ./skeleton.ko + Simply running make with this makefile + will create a file skeleton.ko that can + be loaded into your system by typing : + &prompt.root + kldload -v ./skeleton.ko - - - + + + - - Accessing a device driver - Unix provides a common set of system calls for user - applications to use. The upper layers of the kernel dispatch - these calls to the corresponding device driver when a user - accesses a device node. The /dev/MAKEDEV - script makes most of the device nodes for your system but if - you are doing your own driver development it may be necessary - to create your own device nodes with mknod - + + Accessing a device driver - - Creating static device nodes - The mknod command requires four - arguments to create a device node. You must specify the - name of this device node, the type of device, the major number - of the device, and the minor number of the device. - + Unix provides a common set of system calls for user + applications to use. The upper layers of the kernel dispatch + these calls to the corresponding device driver when a user + accesses a device node. The /dev/MAKEDEV + script makes most of the device nodes for your system but if you + are doing your own driver development it may be necessary to + create your own device nodes with mknod + - - Dynamic device nodes - The device filesystem, or devfs, provides access to the + + Creating static device nodes + + The mknod command requires four + arguments to create a device node. You must specify the name + of this device node, the type of device, the major number of + the device, and the minor number of the device. + + + + Dynamic device nodes + + The device filesystem, or devfs, provides access to the kernel's device namespace in the global filesystem namespace. This eliminates the problems of potentially having a device driver without a static device node, or a device node without - an installed device driver. Devfs is still a work in progress, - but it is already working quite nice. - + an installed device driver. Devfs is still a work in + progress, but it is already working quite nice. + - + + + + Character Devices + + A character device driver is one that transfers data + directly to and from a user process. This is the most common + type of device driver and there are plenty of simple examples in + the source tree. + + This simple example pseudo-device remembers whatever values + you write to it and can then supply them back to you when you + read from it. - - Character Devices - A character device driver is one that transfers data - directly to and from a user process. This is the most common - type of device driver and there are plenty of simple examples - in the source tree. - This simple example pseudo-device remembers whatever values you write - to it and can then supply them back to you when you read from - it. /* * Simple `echo' pseudo-device KLD * @@ -320,43 +329,51 @@ echo_write(dev_t dev, struct uio *uio, int ioflag) DEV_MODULE(echo,echo_loader,NULL); -To install this driver you will first need to make a node on - your filesystem with a command such as : + To install this driver you will first need to make a node on + your filesystem with a command such as : + &prompt.root mknod /dev/echo c 33 0 -With this driver loaded you should now be able to type something - like : + + With this driver loaded you should now be able to type + something like : + &prompt.root echo -n "Test Data" > /dev/echo &prompt.root cat /dev/echo Test Data - Real hardware devices in the next chapter.. - Additional Resources - - Real hardware devices in the next chapter.. + + Additional Resources + + Dynamic Kernel Linker (KLD) Facility Programming Tutorial - Daemonnews October 2000 - How to Write Kernel Drivers with NEWBUS - Daemonnews July 2000 - - - + + + - - Network Drivers - Drivers for network devices do not use device nodes in - ord to be accessed. Their selection is based on other - decisions made inside the kernel and instead of calling - open(), use of a network device is generally introduced by - using the system call socket(2). - man ifnet(), loopback device, Bill Pauls drivers, etc.. - + + Network Drivers - + Drivers for network devices do not use device nodes in order + to be accessed. Their selection is based on other decisions + made inside the kernel and instead of calling open(), use of a + network device is generally introduced by using the system call + socket(2). + + man ifnet(), loopback device, Bill Paul's drivers, + etc.. + + + + diff --git a/en_US.ISO8859-1/books/developers-handbook/driverbasics/chapter.sgml b/en_US.ISO8859-1/books/developers-handbook/driverbasics/chapter.sgml index 29cf0a05cb..52d27534ad 100644 --- a/en_US.ISO8859-1/books/developers-handbook/driverbasics/chapter.sgml +++ b/en_US.ISO8859-1/books/developers-handbook/driverbasics/chapter.sgml @@ -1,65 +1,68 @@ - - Writing FreeBSD Device Drivers + + Writing FreeBSD Device Drivers - This chapter was written by Murray Stokely with selections from - a variety of sources including the intro(4) man page by Joerg - Wunsch. + This chapter was written by &.murray with selections + from a variety of sources including the intro(4) man page by Joerg + Wunsch. - - Introduction - - This chapter provides a brief introduction to writing device - drivers for FreeBSD. A device in this context is a term used - mostly for hardware-related stuff that belongs to the system, - like disks, printers, or a graphics display with its keyboard. - A device driver is the software component of the operating - system that controls a specific device. There are also - so-called pseudo-devices where a device driver emulates the - behaviour of a device in software without any particular - underlying hardware. Device drivers can be compiled into the - system statically or loaded on demand through the dynamic - kernel linker facility `kld'. + + Introduction + This chapter provides a brief introduction to writing device + drivers for FreeBSD. A device in this context is a term used + mostly for hardware-related stuff that belongs to the system, + like disks, printers, or a graphics display with its keyboard. + A device driver is the software component of the operating + system that controls a specific device. There are also + so-called pseudo-devices where a device driver emulates the + behaviour of a device in software without any particular + underlying hardware. Device drivers can be compiled into the + system statically or loaded on demand through the dynamic kernel + linker facility `kld'. - Most devices in a Unix-like operating system are - accessed through device-nodes, sometimes also called special - files. These files are usually located under the directory - /dev in the file system hierarchy. Until - devfs is fully integrated into FreeBSD, each device node must - be created statically and independent of the existence of the - associated device driver. Most device nodes on the system are - created by running MAKEDEV. + Most devices in a Unix-like operating system are accessed + through device-nodes, sometimes also called special files. + These files are usually located under the directory + /dev in the file system hierarchy. Until + devfs is fully integrated into FreeBSD, each device node must be + created statically and independent of the existence of the + associated device driver. Most device nodes on the system are + created by running MAKEDEV. - Device drivers can roughly be broken down into two - categories; character and network device drivers. - + Device drivers can roughly be broken down into two + categories; character and network device drivers. - - Dynamic Kernel Linker Facility - KLD - The kld interface allows system administrators to - dynamically add and remove functionality from a running - system. This allows device driver writers to load their new - changes into a running kernel without constantly rebooting to - test changes. + - The kld interface is used through the following - administrator commands : - - kldload - loads a new kernel + + Dynamic Kernel Linker Facility - KLD + + The kld interface allows system administrators to + dynamically add and remove functionality from a running system. + This allows device driver writers to load their new changes into + a running kernel without constantly rebooting to test + changes. + + The kld interface is used through the following + administrator commands : + + + kldload - loads a new kernel module - kldunload - unloads a kernel + kldunload - unloads a kernel module - kldstat - lists the currently loadded + kldstat - lists the currently loadded modules - - + + + + Skeleton Layout of a kernel module - Skeleton Layout of a kernel module /* * KLD Skeleton * Inspired by Andrew Reiter's Daemonnews article @@ -100,67 +103,73 @@ skel_loader(struct module *m, int what, void *arg) DECLARE_MODULE(skeleton, skel_loader, SI_SUB_KLD, SI_ORDER_ANY); - - Makefile - FreeBSD provides a makefile include that you can use - to quickly compile your kernel addition. - SRCS=skeleton.c + + Makefile + + FreeBSD provides a makefile include that you can use to + quickly compile your kernel addition. + + SRCS=skeleton.c KMOD=skeleton .include <bsd.kmod.mk> - - Simply running make with - this makefile will create a file - skeleton.ko that can be loaded into - your system by typing : - -&prompt.root kldload -v ./skeleton.ko + Simply running make with this makefile + will create a file skeleton.ko that can + be loaded into your system by typing : + &prompt.root + kldload -v ./skeleton.ko - - - + + + - - Accessing a device driver - Unix provides a common set of system calls for user - applications to use. The upper layers of the kernel dispatch - these calls to the corresponding device driver when a user - accesses a device node. The /dev/MAKEDEV - script makes most of the device nodes for your system but if - you are doing your own driver development it may be necessary - to create your own device nodes with mknod - + + Accessing a device driver - - Creating static device nodes - The mknod command requires four - arguments to create a device node. You must specify the - name of this device node, the type of device, the major number - of the device, and the minor number of the device. - + Unix provides a common set of system calls for user + applications to use. The upper layers of the kernel dispatch + these calls to the corresponding device driver when a user + accesses a device node. The /dev/MAKEDEV + script makes most of the device nodes for your system but if you + are doing your own driver development it may be necessary to + create your own device nodes with mknod + - - Dynamic device nodes - The device filesystem, or devfs, provides access to the + + Creating static device nodes + + The mknod command requires four + arguments to create a device node. You must specify the name + of this device node, the type of device, the major number of + the device, and the minor number of the device. + + + + Dynamic device nodes + + The device filesystem, or devfs, provides access to the kernel's device namespace in the global filesystem namespace. This eliminates the problems of potentially having a device driver without a static device node, or a device node without - an installed device driver. Devfs is still a work in progress, - but it is already working quite nice. - + an installed device driver. Devfs is still a work in + progress, but it is already working quite nice. + - + + + + Character Devices + + A character device driver is one that transfers data + directly to and from a user process. This is the most common + type of device driver and there are plenty of simple examples in + the source tree. + + This simple example pseudo-device remembers whatever values + you write to it and can then supply them back to you when you + read from it. - - Character Devices - A character device driver is one that transfers data - directly to and from a user process. This is the most common - type of device driver and there are plenty of simple examples - in the source tree. - This simple example pseudo-device remembers whatever values you write - to it and can then supply them back to you when you read from - it. /* * Simple `echo' pseudo-device KLD * @@ -320,43 +329,51 @@ echo_write(dev_t dev, struct uio *uio, int ioflag) DEV_MODULE(echo,echo_loader,NULL); -To install this driver you will first need to make a node on - your filesystem with a command such as : + To install this driver you will first need to make a node on + your filesystem with a command such as : + &prompt.root mknod /dev/echo c 33 0 -With this driver loaded you should now be able to type something - like : + + With this driver loaded you should now be able to type + something like : + &prompt.root echo -n "Test Data" > /dev/echo &prompt.root cat /dev/echo Test Data - Real hardware devices in the next chapter.. - Additional Resources - - Real hardware devices in the next chapter.. + + Additional Resources + + Dynamic Kernel Linker (KLD) Facility Programming Tutorial - Daemonnews October 2000 - How to Write Kernel Drivers with NEWBUS - Daemonnews July 2000 - - - + + + - - Network Drivers - Drivers for network devices do not use device nodes in - ord to be accessed. Their selection is based on other - decisions made inside the kernel and instead of calling - open(), use of a network device is generally introduced by - using the system call socket(2). - man ifnet(), loopback device, Bill Pauls drivers, etc.. - + + Network Drivers - + Drivers for network devices do not use device nodes in order + to be accessed. Their selection is based on other decisions + made inside the kernel and instead of calling open(), use of a + network device is generally introduced by using the system call + socket(2). + + man ifnet(), loopback device, Bill Paul's drivers, + etc.. + + + + diff --git a/en_US.ISO_8859-1/books/developers-handbook/driverbasics/chapter.sgml b/en_US.ISO_8859-1/books/developers-handbook/driverbasics/chapter.sgml index 29cf0a05cb..52d27534ad 100644 --- a/en_US.ISO_8859-1/books/developers-handbook/driverbasics/chapter.sgml +++ b/en_US.ISO_8859-1/books/developers-handbook/driverbasics/chapter.sgml @@ -1,65 +1,68 @@ - - Writing FreeBSD Device Drivers + + Writing FreeBSD Device Drivers - This chapter was written by Murray Stokely with selections from - a variety of sources including the intro(4) man page by Joerg - Wunsch. + This chapter was written by &.murray with selections + from a variety of sources including the intro(4) man page by Joerg + Wunsch. - - Introduction - - This chapter provides a brief introduction to writing device - drivers for FreeBSD. A device in this context is a term used - mostly for hardware-related stuff that belongs to the system, - like disks, printers, or a graphics display with its keyboard. - A device driver is the software component of the operating - system that controls a specific device. There are also - so-called pseudo-devices where a device driver emulates the - behaviour of a device in software without any particular - underlying hardware. Device drivers can be compiled into the - system statically or loaded on demand through the dynamic - kernel linker facility `kld'. + + Introduction + This chapter provides a brief introduction to writing device + drivers for FreeBSD. A device in this context is a term used + mostly for hardware-related stuff that belongs to the system, + like disks, printers, or a graphics display with its keyboard. + A device driver is the software component of the operating + system that controls a specific device. There are also + so-called pseudo-devices where a device driver emulates the + behaviour of a device in software without any particular + underlying hardware. Device drivers can be compiled into the + system statically or loaded on demand through the dynamic kernel + linker facility `kld'. - Most devices in a Unix-like operating system are - accessed through device-nodes, sometimes also called special - files. These files are usually located under the directory - /dev in the file system hierarchy. Until - devfs is fully integrated into FreeBSD, each device node must - be created statically and independent of the existence of the - associated device driver. Most device nodes on the system are - created by running MAKEDEV. + Most devices in a Unix-like operating system are accessed + through device-nodes, sometimes also called special files. + These files are usually located under the directory + /dev in the file system hierarchy. Until + devfs is fully integrated into FreeBSD, each device node must be + created statically and independent of the existence of the + associated device driver. Most device nodes on the system are + created by running MAKEDEV. - Device drivers can roughly be broken down into two - categories; character and network device drivers. - + Device drivers can roughly be broken down into two + categories; character and network device drivers. - - Dynamic Kernel Linker Facility - KLD - The kld interface allows system administrators to - dynamically add and remove functionality from a running - system. This allows device driver writers to load their new - changes into a running kernel without constantly rebooting to - test changes. + - The kld interface is used through the following - administrator commands : - - kldload - loads a new kernel + + Dynamic Kernel Linker Facility - KLD + + The kld interface allows system administrators to + dynamically add and remove functionality from a running system. + This allows device driver writers to load their new changes into + a running kernel without constantly rebooting to test + changes. + + The kld interface is used through the following + administrator commands : + + + kldload - loads a new kernel module - kldunload - unloads a kernel + kldunload - unloads a kernel module - kldstat - lists the currently loadded + kldstat - lists the currently loadded modules - - + + + + Skeleton Layout of a kernel module - Skeleton Layout of a kernel module /* * KLD Skeleton * Inspired by Andrew Reiter's Daemonnews article @@ -100,67 +103,73 @@ skel_loader(struct module *m, int what, void *arg) DECLARE_MODULE(skeleton, skel_loader, SI_SUB_KLD, SI_ORDER_ANY); - - Makefile - FreeBSD provides a makefile include that you can use - to quickly compile your kernel addition. - SRCS=skeleton.c + + Makefile + + FreeBSD provides a makefile include that you can use to + quickly compile your kernel addition. + + SRCS=skeleton.c KMOD=skeleton .include <bsd.kmod.mk> - - Simply running make with - this makefile will create a file - skeleton.ko that can be loaded into - your system by typing : - -&prompt.root kldload -v ./skeleton.ko + Simply running make with this makefile + will create a file skeleton.ko that can + be loaded into your system by typing : + &prompt.root + kldload -v ./skeleton.ko - - - + + + - - Accessing a device driver - Unix provides a common set of system calls for user - applications to use. The upper layers of the kernel dispatch - these calls to the corresponding device driver when a user - accesses a device node. The /dev/MAKEDEV - script makes most of the device nodes for your system but if - you are doing your own driver development it may be necessary - to create your own device nodes with mknod - + + Accessing a device driver - - Creating static device nodes - The mknod command requires four - arguments to create a device node. You must specify the - name of this device node, the type of device, the major number - of the device, and the minor number of the device. - + Unix provides a common set of system calls for user + applications to use. The upper layers of the kernel dispatch + these calls to the corresponding device driver when a user + accesses a device node. The /dev/MAKEDEV + script makes most of the device nodes for your system but if you + are doing your own driver development it may be necessary to + create your own device nodes with mknod + - - Dynamic device nodes - The device filesystem, or devfs, provides access to the + + Creating static device nodes + + The mknod command requires four + arguments to create a device node. You must specify the name + of this device node, the type of device, the major number of + the device, and the minor number of the device. + + + + Dynamic device nodes + + The device filesystem, or devfs, provides access to the kernel's device namespace in the global filesystem namespace. This eliminates the problems of potentially having a device driver without a static device node, or a device node without - an installed device driver. Devfs is still a work in progress, - but it is already working quite nice. - + an installed device driver. Devfs is still a work in + progress, but it is already working quite nice. + - + + + + Character Devices + + A character device driver is one that transfers data + directly to and from a user process. This is the most common + type of device driver and there are plenty of simple examples in + the source tree. + + This simple example pseudo-device remembers whatever values + you write to it and can then supply them back to you when you + read from it. - - Character Devices - A character device driver is one that transfers data - directly to and from a user process. This is the most common - type of device driver and there are plenty of simple examples - in the source tree. - This simple example pseudo-device remembers whatever values you write - to it and can then supply them back to you when you read from - it. /* * Simple `echo' pseudo-device KLD * @@ -320,43 +329,51 @@ echo_write(dev_t dev, struct uio *uio, int ioflag) DEV_MODULE(echo,echo_loader,NULL); -To install this driver you will first need to make a node on - your filesystem with a command such as : + To install this driver you will first need to make a node on + your filesystem with a command such as : + &prompt.root mknod /dev/echo c 33 0 -With this driver loaded you should now be able to type something - like : + + With this driver loaded you should now be able to type + something like : + &prompt.root echo -n "Test Data" > /dev/echo &prompt.root cat /dev/echo Test Data - Real hardware devices in the next chapter.. - Additional Resources - - Real hardware devices in the next chapter.. + + Additional Resources + + Dynamic Kernel Linker (KLD) Facility Programming Tutorial - Daemonnews October 2000 - How to Write Kernel Drivers with NEWBUS - Daemonnews July 2000 - - - + + + - - Network Drivers - Drivers for network devices do not use device nodes in - ord to be accessed. Their selection is based on other - decisions made inside the kernel and instead of calling - open(), use of a network device is generally introduced by - using the system call socket(2). - man ifnet(), loopback device, Bill Pauls drivers, etc.. - + + Network Drivers - + Drivers for network devices do not use device nodes in order + to be accessed. Their selection is based on other decisions + made inside the kernel and instead of calling open(), use of a + network device is generally introduced by using the system call + socket(2). + + man ifnet(), loopback device, Bill Paul's drivers, + etc.. + + + +