This topic was published by DevynCJohnson and viewed 1712 times since "". The last page revision was "".
- Topics - 444
Drivers are small programs that enable the operating system to communicate and handle hardware or protocols (rules and standards). Without a driver, the kernel does not know how to communicate with the hardware or handle protocols (the kernel actually hands the commands to the BIOS and the BIOS passes them on the the hardware). The XNU Kernel uses a driver framework called "I/O Kit". Device drivers can be written using this framework which is similar to Embedded C++. Most drivers are in the user-space, but some drivers run in the kernel space. Remember, XNU is a hybrid kernel.
There are different terms that should be understood so that the information below is more understandable. An I/O device is an Input/Output device. A modem and network card are examples of this; they send and receive data. A monitor is an output device - information only comes out. A keyboard, mouse, and joystick are input only - data goes into the system. Storage devices store data. Examples of these include SD cards, Hard-drives, CD-roms, memory cards, etc. The CPU (also called a processor) is the "brain" or "heart" of the computer. Without this single processing chip, the computer cannot function. A motherboard (mainboard) is a small board with printed circuits that connect to the components that are on the board. The board and the components are essential to the functionality of a computer. Many computer users say that the motherboard is the heart of the computer (the motherboard holds the CPU). The motherboard contains ports for peripherals. Peripherals include the input, output, and storage devices. A bus is the circuitry of the motherboard and connection to peripherals. Network devices deal with the connection of two or more computers. Ports are devices that users can plug another device or cable into. For example, users would plug a FireWire memory stick into a FireWire port; an Ethernet cable would go into an Ethernet port. Optical discs are read using lasers that read off of reflective surfaces that will either scatter or reflect the laser light. A common optical disk is the DVD. Many systems are 32-bit or 64-bit systems; this refers to the number of bits of registers, address buses, or data buses. For instance, on a 64-bit motherboard, the data buses (the silver lines going between components) have sixty-four lines running parallel to the same destination. Memory addresses are addresses to the memory in the form of bits (ones and zeros). So, a 32-bit memory address contains thirty-two ones and zeros that give the location of a spot on the memory.
The I/O Kit is not at all like the driver framework used in Mac OS 9 or BSD. Rather, the I/O Kit is a derivative of NeXTSTEP's DriverKit. I/O Kit also provides a power management system. The source code for the power management is found at ./iokit/IOKit/pwr_mgt/. On active operating systems using the XNU kernel, the I/O Kit drivers are stored under /System/Library/Extensions/. I/O Kit is also responsible for creating the files under /dev/.
NOTE: Any references to the source code assume that the user is in the root of the source code directory.
XNU does contain some kernel-space drivers. The drivers used to control various ports and connection protocols (like FireWire and Ethernet) are in the BSD portion of the kernel. In the source code, the kernel-space drivers pertaining to networking and connection protocols can be found under ./bsd/net/. For instance, the Ethernet protocol can be found at ./bsd/net/ethernet.h and ./bsd/net/ieee8023ad.h. Some drivers for psuedo/virtual filesystems can be found under ./bsd/miscfs/. The HFS driver is in ./bsd/hfs/.
When adding modules or Kernel Extensions (KEXTs) to the XNU kernel, list the added files in the proper place. For instance, if adding files to the BSD portion of the kernel, list the new files in the proper places under ./bsd/conf/. If extending the Mach kernel, list the files under ./osfmk/conf/.
To gain a deeper understanding of the drivers, it may help to learn how to program using the I/O Kit framework.
- XNU Kernel and Similar Topics (Reading Guide) - http://dcjtech.info/topic/os-x-darwin-and-friends/