In the Android Hardware Abstraction Layer (HAL) Overview and Learning Plan article, we briefly describe the ways in which Android systems write drivers for hardware. In short, hardware drivers are distributed on the Linux kernel, and on the other hand, in the hardware abstraction layer of user space. Next, writing a Linux
Notes for compiling Linux network drivers
3.1 interrupt sharing
In Linux, several devices run to share the same interrupt. If you need to share, specify the sharing method when applying. Definition of system-provided request_irq () call:
Int request_irq (unsigned int IRQ,Void (* Handler) (int irq, void * dev_id, struct pt_regs * regs ),Unsigned long flags,Const
1. Write Linux device driver, require engineers have a certain hardware foundation, know how SRAM, Flash, SDRAM, disk read and write,The interface of UART, I²c, USB and other devices, polling, interrupt, DMA principle, PCI bus working mode and CPU memory management MMU.2. Have a good C language Foundation, can flexibly use the structure, pointers, function pointers and memory dynamic application and release.3. Have a certain
Introduction: from 2.4 to 2.6, the Linux kernel has greatly changed in terms of the module mechanism, device model, and some core APIs that can be loaded, device driver developers are faced with porting drivers from 2.4 to 2.6 kernels, or enabling drivers to support both 2.4 and 2.6 kernels... news nbsp
Introduction: from 2.4 to 2.6, the
Linux Network DriverI would like to use this article to commemorate the past yearsI. PrefaceIn Linux, the network driver is also a big head, how to understand the network drive is as a Linux driver engineers must have the skills. But the same equipment, in different people's hands will have different effects, the reason is that the driver is good or not.Two. Devi
Activate the network card to see the network card status
Ifconfig eth0 up (NIC device name, eth0 for example)
Ifconfig-a
Mode two: Source code driver package installation method (Take Realtek rtl8168/8111 Nic as an example)
Download the source code package from the Realtek website, then the Linux system, create a directory, extract the source code package into this directory.
Mkdir/temp
Cd/t
reached 66MHz or even 133MHz
Equipped with a 32-bit data bus, and the specification already includes 64-bit extensions
Platform independence as much as possible
simplifies the task of adding and removing peripherals to the system
PCI device is a jumper-free device that can be configured automatically during the boot phase
PCI Addressing
each PCI peripheral is identified by a bus number, a device number,
be added to the kernel at run time is called a "module." The Linux kernel supports several types of modules, including but not limited to device drivers. Each module consists of the target code, which can be used to connect the module to the running kernel using the INSMOD program, or to remove the connection using the Rmmod program.The Linux system divides the
This example is for Android up-Reading Exploration (vol. 1): The Demo sample program included with the HAL and Driver Development book. are now pasted out for inspection.Terminal operations, commands that may be used:Insmond Word_count.kolsmod | grep Word_count to see if the driver was successfully installed Rmmod WORD_COUNTDMESG | grep word_cout | Tail-n 2 View log information with Linux driver output Cat/var/log/syslong | grep Word_count | Tail-n 2m
will have to also." ”3, see example Drive, Linux kernel driver, generally have a relatively simple example code, specifically, see the first step of the TXT document. With this simple example code, we further clarify how the drive works.4, good, ready to work to complete, here should formally start. Write it yourself? No, or secretly lazy, online to find ready-made, there is just your chip driver, really lucky, direct use, of course, often can not be
based on the Sbull program in the Linux device driver book to Linux Block device driver summary analysis.Before you begin, learn about the core data structures in this block device:struct Sbull_dev {int size; /* Device Size in sectors */U8 *data; /* The data array */Short users; /* How many users * *Short Media_change; /* Flag a media change? */spinlock_t lock; /* for mutual exclusion */struct Request_queue
queue, and non-blocking I/O is implemented by polling.One, blocking I/O implementation--waiting queue1. Basic conceptIn Linux drivers, you can use the wait queue (wait queues) to wake up a blocking process . Wait queue is very early as a basic functional unit in the Linux kernel, it is a queue-based data structure, and process scheduling mechanism tightly integr
atomic items that must be transmitted, and the direction of the transmission
void Set_dma_mode (unsigned int channel, char mode);
Mode
Dma_mode_read
Dma_mode_write
Dma_mode_cascade
Release control of the bus
void set_dma_addr (unsigned int channel, unsigned int addr);
void Set_dma_count (unsigned int channel, unsigne
code under default and clean starts with the TAB key.Third, compile the Globalvar modulePut the previous globalvar.c file and the makefile file in the same folder, I was placed in the Globalvar folder I created, go to the Globalvar folder, open the terminal, and then log in root permissions, enter the make command compile module. Four, write the test program of the Globalvar module, name it test_globalvar.c, the source code is as follows: #include Compile the test file in the terminal input Di
, the kernel does not need to handle the concurrent access hardware, only one application instance will access the hardwarePossible user-space device driversUSB with Libusb, http://www.libusb.org/SPI with Spidev, Documentation/spi/spidevI²c with I2cdev, Documentation/i2c/dev-interfacememory-mapped devices with UIO, including interrupt handling, documentation/docbook/uio-howto/Some device drivers are implemented in user space, part of the kernel space
contiguous and the corresponding data block on disk is also adjacent, then the general block layer can be merged with them, this way to produce a larger memory area is the physical segment.Common block Layer:1. The common block layer is a kernel component that handles requests from all block devices in the systemI\O Scheduler:1. Block device drivers can transmit one sector at a time, but the block i\o layer does not do so because it is time-consuming
of the LCD controller.
Specifically:
Fill in a fbinfo Structure
Use reigster_framebuffer (fbinfo *) to register the fbinfo structure to the kernel
For the fbinfo structure, the most important thing is its fs_ops member. You need to implement interfaces in fs_ops for specific devices.
Whether to use interrupt handling
Memory Access
If the video card does not have its own video memory, the system memory is allocated as the video memory.
The graphics card comes with a vide
;}/* The distory function */Int cleanup_module (){Printk ("I will shut down myself in kernerl mod/n )";Retutn 0;}
This example is complete. We also write a makefile example to make it suitable for our applications with heavy program. Here is the content of the makfile.
# A makefile for a moduleCC = gccMODCFLAGS: =-Wall _ DMODULE-D_KERNEL _-DLinuxHello. o hello. c/usr/inculde? Linux/version. hCC $ (MODCFLAGS) 0c hello. cEcho the module
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.