IO Kit is used for interfacing the different devices just as you are working on the particular operating system. In fact it’s a sort of trainer on which you work for your applications. In this way you can program different devices to work the way you want for the purpose of developing different applications. Mostly we develop the device drivers in a high level language like objective C. To follow are some of the important tools for iPhone and iPad which might be of help to you for developing the device drivers.
Before you start developing device drivers you should have a know how of C++ and kernel programming. You have to be more creative in your approach towards programming using I/O kit tools.
The I/O kit is provided with plug n play, sleep mode, separate memory banks for kernel and user applications, parallel and symmetric multiprocessing and it provides a lot of room for code reusability.
The kernel features supported by these drivers are objected oriented programming framework, primitives for communication, data management and threading. It is compatible with all bus types. Instantiated objects that belong to different classes are tracked through I/O registry. Layering of client and provider objects can be done without a fuss; no matter how complicated the order is. There is a great room for code reusability in the latest model of the I/O kit.
The latest model of the I/O kit is different to its predecessors in a lot of ways. The available models before this were deficient in one way or the other. Many features of a modern operating system for example power management, driver stacking, automatic configuration etc. were absent in the previous models.
The crux of the design philosophy lies in the fact that object oriented programming model was developed. This architecture supports many devices with a way that is common among them. In the earlier versions this kit software development kits were separate entities but now the hardware is so much sophisticated that there is no requirement of complex codes. Application programming interface is open to all, resulting in facilitating the developers to use the source code for developing new drivers.
Provision of Namespaces
Name spaces are always helpful in identifying the classes. Therefore you should always try to use them and a reverse chronological order is preferred. Be cautioned never to declare an I/O subclass in namespace.
High Level Language Used
The programming language used is C++. However not every feature of this language is usable. There were many features in C++ that don’t suite a multithreaded environment resulting in their exclusion. As a programmer you cannot play with exceptions, templates and multiple inheritance. The I/O kit possesses its own runtime typing system so no need for C++ to provide that.
Different parts of the I/O kit are described as below:;
Three C++ libraries are used by I/O kit. These are cloaked by framework. There are three frameworks used in all. These are IOKit, kernel IO kit and kernel libkern.
The kernel software can be developed by using the classes contained in the kernel libkern library. The kernel resident device drivers are built using the classes contained in the kernel IOkit library. The interfacing with different devices is carried out using the classes contained in the IOkit library.
Very few development applications are required to build device drivers. IO registry explorer is an application which helps us visualize the IO registry files. Xcode is the basic tool in developing the device drivers through the IO kit. It contains the editor for editing code files. Projects are created through this application. Compiler is also provided, moreover a software simulation is also provided in the Xcode. Moreover debugging is also performed through the Xcode. Package Maker is the software that is parallel to a burning tool in microcontrollers. You can install the device drivers through this application.
Command line Tools
There are different commands provided for developing the drivers.
- Iostat is used for diplaying kernel IO stats on terminal, CPU and disks.
- Ioclasscount gives the instance count of a certain class.
- Ioallaccount gives the details of the memory allocation by IO kit objects in the kernel.
- Ioreg is used for printing the contents of the IO registry.
- Kextload is used for loading device drivers. With the help of this command you can perform remote debugging.
- Kextcache is used for indexing the kernel extensions which is used for loading the kernel files at boot time.
- Gcc is used for compiling. Correct flags are automatically invoked for compilation.
- Gdb is used for debugging purposes.
- Kextunload is used for unloading the kernel extension.
- Kextstat is used for showing the stats about the currently loaded drivers and their extensions.
Programming in the Kernel
It is very intricate and precarious to program in the kernel. There are always paths to do a task without using the kernel environment. By inserting more code in the kernel memory the user program memory gets depleted.
Kernel coding is so much vulnerable that even a single wrong memory access can collapse the whole system. In kernel coding you can encounter bugs which are sometimes impossible to handle. This is because there isn’t enough experience available to consult with.
There are numerous application programming interfaces that have been provided by Apple in order to get around the need of kernel programming. For example there are many high level application programming interfaces that might help in accessing the hardware. There is also a device interface technology available which helps your application to access the hardware through the kernel.