"Android Deep Exploration" seventh chapter experience

Source: Internet
Author: User

The seventh chapter of "Android Deep Exploration" is about the LED flashing for me: controlling the LEDs. 1. Create LED-driven device files: 1th step: Initialize Cdev with the Cdev_init function, step 2nd: Specify the device number, the device number of the Linux device file is the primary device number and the secondary device number. The device number is specified and dynamically assigned in the code, and the 3rd step is to add the character device to the character device array in the kernel using the Cdev_add function, and 4th step: Create the struct class using the Class_create macro; step 5th: Use the Device_ The CREATE function creates a device file. 2. Uninstalling the LED-driven device files requires calling the Device_destroy, Class_destroy, and Unregister_chrdev_region methods sequentially. 3. The control led,led driver can control the LEDs in two ways, string and I/O commands.

I learned from the seventh chapter that Linux drives work with hardware, but not Linux drives directly to the memory in the hardware to write data, but rather to interact with the native I/O memory. The so-called I/O memory is a mapping of hardware in host memory that is connected to the host through various interfaces. The memory management module of the Linux kernel is responsible for synchronizing the data in I/O memory and hardware. Every hardware that connects to Linux has a map header address in I/O memory. LED driver is the first real Linux driver to deal with hardware, although led driver is not complicated, just control 4 LEDs, but led driver has included all the necessary parts of Linux drive. A complete Linux driver consists of two parts: internal processing and hardware interaction. The internal processing mainly refers to the Linux driver loading, unloading, device file-related action processing, and business logic. Interaction with hardware mainly refers to the data interaction with the registers in the hardware through the functions of iowrite32, IOREAD32 and so on. The porting of Linux drivers on different platforms is also handled in these two parts. If the porting between different Linux kernel versions is mainly porting the 1th part, if the porting on different hardware platforms, the transplant is mainly the 2nd part.

"Android Deep Exploration" seventh chapter experience

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.