Android Deep Exploration--sixth chapter

Source: Internet
Author: User

Build Linux driver skeleton: The Linux kernel needs to load and unload the driver, load the driver: Set up the device file, allocate the memory address space, etc. module_init function handles the driver initialization, unloads the driver: Deletes the device file, frees the memory address space, etc. module_ The Exit function handles the exit, and the C program file containing the two macros for both functions can also be seen as a Linux-powered skeleton, registering and unregistering device files: Any Linux driver requires a device file, or the application will not be able to interact with the driver. Set up the device file: Completed in the first step of the function to process the Linux initialization work. Misc_register function, delete the device file: Completed in the first step of processing the Linux exit function. Misc_deregister function

Specify driver-related information: The driver is self-describing, the driver's author name, the open source protocol used, the alias, the driver description, and so on. This information needs to be specified in the driver source code.

Module_author, Module_license, Module_alls, Module_descripion, and other macros can specify driver-related information

Specify a callback function: A driver does not necessarily specify all callback functions, and the callback function is registered by the relevant mechanism.

Writing business logic: Specific business logic is related to the functionality of the drive, and the business logic may consist of multiple functions, multiple files, or even multiple Linux driver modules

Write the Makefile File: the compilation rules for the Linux kernel source code are defined by the makefile file. So writing a new Linux driver must have a makefile file

Compiling Linux drivers: can be compiled directly into the kernel, or can be compiled separately as a module

Install and uninstall Linux drivers: If the Linux driver is compiled into the kernel, as long as Linux uses the kernel, the driver will be automatically reproduced, if the Linux driver is separate from the module, you need to use the Insmod or Modprode command to load the Linux driver module, Rmmod command to uninstall the Linux driver module

Android Deep Exploration--sixth chapter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.