The tenth chapter is mainly about the complex Linux driver and Hal and other libraries, need to use a variety of methods to debug it. For example, setting breakpoints, stepping through code, outputting debugging information, and so on.
The use of the PRINTK function is similar to the printf function except that the PRINTK function runs in kernel space and the printf function runs in user space. In other words, Linux kernel programs like Linux drivers can only output debugging information using the PRINTK function. The PRINTK function is implemented in the Printk.c file.
Although it is easy to write messages to the log file or console using the PRINTK function. However, the heavy use of the PRINTK function to frequently manipulate log files or console device files (/dev/console) can severely affect Linux drive performance (so the write disk is much faster than reading and writing memory), so This requires that the Linux driver only uses the PRINTK function to output information during the development phase, removing the PRINTK function that may affect performance when the Linux driver is formally released.
In Linux file systems,/proc is often used as a tool for data interaction between kernel space and user space. The/proc file system behaves in a similar manner to the device file system (/dev). /proc is a virtual file system, which means that/proc is not a real file system, but a memory map. All read-write/PROC operations are read-write to memory. Therefore, reading and writing/proc file systems is much faster than reading/writing/dev file systems. As a result, the/proc file system can also serve as a tool for Linux to interact with user-space programs.
Android Driver Development Tenth chapter notes