Develop an Android driver that counts the number of words (top)

Source: Internet
Author: User
Tags virtual environment

Android is essentially a Linux kernel based system, which means Android is a Linux operating system. But most of the time it will run on arm-architecture devices, such as Android phones, tablets, and so on. Android drives are actually Linux drivers, but here's Android Deep Exploration (Volume 1): The cross-compilers that install the C + + cross-compilation environment introduce Linux drivers to the ARM architecture, so drivers can be installed in the Android simulator, Android phones (need root) or tablet (these devices all use the CPU to give arm architecture), of course, using traditional GCC can also be compiled into a X86 architecture driver (no need to modify the code), so you can also install Linux on Ubuntu Linux driver.

This article and the following articles mainly describes how to use the Android simulator and s3c6410 Development Board to develop the Linux driver to arm architecture, of course, the test environment is Android, rather than our usual Ubuntu Linux and other X86 architecture system. Finally, you'll see how to test this drive in a variety of ways, including the command line, NDK, Android (Java code), and so on, and, of course, at the very end, if you embed the drive into the Linux kernel, then Android automatically owns the drive when it starts.

Children's shoes that want to learn about the bottom of Android can be fully mastered in this article to develop an Android-based Linux-driven complete step. In the Android Depth Explorer (Volume 1): HAL and Drive development with the book CD with the full experimental environment (VMWare Ubuntu Linux12.04lts), if you don't want to configure trouble, you can copy the virtual environment from the CD, the virtual file is too large (3.6G), can not be sent up, only article!

First, what is the Linux driver is a thing

Programmers who have never been exposed to driver development may feel Linux drivers are mysterious. It can be very complicated to develop. In fact, this is entirely a misunderstanding. In fact, there is no essential difference between Linux drivers and ordinary Linuxapi. Linux is only driven in a way that is different from the way Linux APIs are used.

Before we learn about Linux drivers, let's take a look at how Linux drives work. If readers have previously been exposed to Windows or other non-UNIX system operating systems, it is best to temporarily forget how they work, because these memories will interfere with our understanding of the bottom of the Linux details.

Linux driver work and access is one of the highlights of Linux, but also by the industry's wide acclaim. The Linux system maps each drive to a single file. These files, called device files or driver files, are saved in the/dev directory. This design concept makes interacting with Linux drivers as easy as interacting with normal files. Of course, it's much easier than visiting Linuxapi. Since most Linux drivers have their corresponding device files, switching data with the Linux driver becomes the exchange of data with the device file. For example, to send a print command to a Linux printer driver, you can open the device file directly using the C language function open, and then use the C language function ioctl to send a print command to the driver's device file.

Of course, more advanced functionality is required to write Linux drivers. When writing data to a printer driver, for the printer driver, you need to receive these written data and send them to the printer via the PC's port, USB, and so on. To implement this process, Linux drivers are required to respond to the data that the application passes over. This is the Linux-driven event, although there is no concept of events in the C language, but there is a similar concept to events, which is the callback (callback) function. Therefore, the most important step in writing a Linux driver is to write a callback function, otherwise the data that interacts with the device file will not be processed. Figure 6-1 is the relationship between the application software, device files, drivers, and hardware.

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.