Create a device node file in the Android framework

Source: Internet
Author: User

Android and linux use device drivers to access hardware devices. device node files are logical files of device drivers. Applications Use device node files to access device drivers, in linux, mknod is used to create device node files. Android has its own method. Android uses the Init process to create a device node file. There are two scenarios: static node file and dynamic node file to deal with the hot swapping device that has been defined after cold plugging and system running. For cold plugging devices, the init process obtains the drivers waiting for the cold plugging process in advance, and defines the device node file (in android_source_code/system/core/init/devices. c). The device node name is listed in struct perms_devices. Access permission, user ID, and group ID. To add a new user-defined device, you must add information about the weight of the device. Init first calls the device_init () function, creates a socket to receive uevent, and then calls do_coldboot () through cold_boot () perform cold Plugging for the driver registered under/sys during kernel startup. do_coldboot starts uevent, receives uevent information in handler_device_fd (), and writes it to uevent struct, call handle_device_event () to create a node file. First, create all subdirectories and then call make_device () to create a node file. Init uses event processing loops for hot-swappable dynamic devices. It uses poll () to listen to uevents from the driver and then calls handle_device_fd () to create a device node.

Related Article

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.