Sixth chapter
Linux drives work and access: Each driver is mapped to a file called a device file or driver file, which is stored in the/dev directory, which makes interacting with Linux drivers as easy as interacting with normal files.
To write a Linux driver:
1. Build Linux drive skeleton (load and unload Linux drivers): Basic skeleton is a C program file that specifies the Module_init and module_exit macros and specifies the two macros for both functions.
2. Registering and destroying device files: Create and remove device files using the Misc_register and Misc_deregister functions, respectively.
3, specify the information related to the drive.
4, specify the callback function.
5, write the business logic, the core part, realize the function.
6, write Makefile file, write a new Linux driver must have a makefile file.
7, compile the Linux driver, can be directly compiled into the kernel, or can be compiled separately as a module.
8, install and uninstall Linux drivers: If the driver is compiled into the kernel, as long as Linux uses the kernel, the driver will be automatically loaded. If the Linux driver is in a separate module, use the Insmod or modprobe command to load the driver module, and use the Rmmod command to unload the driver module.
Test method:
1. Use Ubuntu Linux test Drive.
2, on the Android simulator through the native C program test drive.
3, using the Android NDK test Drive.
4. Use Java code to directly manipulate the device files to test the driver.
5, using the s3c6410 Development Board test Drive. 6, the driver compiled into the kernel test.
Reading notes the sixth chapter