The driver development steps were learned in the previous section, and a real column was given to demonstrate how to develop a complete driver. But this driver is simply a demonstration of the implementation steps. Real drivers need to interact directly with the hardware. This section of the complete demo driver controls the 4 LEDs flashing on the development Board. We understand how it works before you develop it. Linux drives interact directly with the hardware, but not directly to the memory coprocessor data in the hardware, but to the input and output of the native computer. Several interactive functions are available in the system, and each system's hardware will have a map header address in IO. In the use of such functions to write memory is to specify these first address, write before driving understand the LED driver function, and test the LED on the Development Board. The driver creates a device file that gives the file control of 4, and so on, by sending a string to the file. 1 means open, 0 for off. Create LED-driven device files, step one: Initialize Cdev with the Cdev_init function, step two: Specify the device number, step three: Use the Cdev_add function to add a character device to the character device array in the kernel, fourth step: macro to create a struct class, Fifth step: Use the Device_create function to create the device file, unload the driver file, this is more simple than the above, need to call the Device_destroy, Class_destroy and Unregister_chrdev_region methods. Get an overview of register and initialize led drivers. There are two ways of controlling LEDs, which are controlled by strings and I/O commands are used to control LEDs. LED driver module parameters, previously written led driver can set the default state of 4 LEDs. Test led driver, described earlier by executing build. The sh script is compiled to install LED drivers and is tested with shell commands and test_led_sh scripts. These test methods can only be controlled by sending strings to the LED device files. Lde Drive transplant, drive transplant problem has been discussed, of course, most of today are doing transplants. The system can run normally, most of it is to see whether a variety of hardware can be identified. LED is a real and hardware-based driver of the book, although not complex, just controls four LEDs already contain all the necessary parts of the drive.
7th Chapter LED Flashing