1. Get the kernel version
When the device driver needs to support different kernel versions at the same time, in the compilation phase, the kernel module needs to know the version of the currently used kernel source code to use the corresponding kernel API. In the 2.4 and 2.6 kernels, the source code header file Linux/version. H is defined as follows:
Linux_version_code: the binary representation of the kernel version. Each of the primary, slave, and
Note: a good article on understanding PCI devices and PCI drivers
To understand the Linux PCI device driver, first understand that the so-called Linux PCI device driver actually includes the Linux PCI device driver and the device driver. I do not know whether the reader understands this sentence. I think this sentence
Linux provides a set of functions to handle the PCI configuration block. Before a PCI device can be used, the Linux driver needs to determine the specific parameters of the device from the information in the PCI device configuration block, making the relevant settings so that the PCI device can operate correctly.The General PCI device initialization function processing process is:(1) Check whether the kern
Step 2: Create the int init_test (void) function)
Register the device here:
Result = register_chrdev (254, "test", test_fops );
(2) set test. copy c to the/uclinux/linux/drivers/char directory, and mem in the/uclinux/linux/drivers/char directory. in c, add the following code to the int c
the device here:
Result = register_chrdev (254, "test", test_fops );
(2) set test. copy c to the/uclinux/linux/drivers/char directory, and mem in the/uclinux/linux/drivers/char directory. in c, add the following code to the int chr_dev_init () function:
# Ifdef CONFIG_TESTDRIVE
Init_test ();
# Endif
(3) add
Distory function*/
int Cleanup_module ()
{
PRINTK ("I'll shut down myself in Kernerl mod/n)";
RETUTN 0;
}Such an example is done. We also write a makefile example to fit our application in large program heavy applications. This is the content of the Makfile file.
# A Makefile for a module
cc=gcc
modcflags:=-wall _dmodule-d_kernel_-dlinux
HELLO.O Hello.c/usr/inculde? Linux/version.h
CC $ (modcflags) 0c hello.c
echo the module is Complie completely
The
1.1 In object-oriented programming, the device driver core layer and examples can define a base class for a class of similar things, and specific things can inherit the functions in this base class. If the implementation of a function of the inherited object is the same as that of the base class, it can directly inherit the functions of the base class. On the contrary, it can be overloaded. This object-oriented design method greatly improves the code reusable ability and is a good display of the
Linux device driversOne, the role of device-drivenThe most popular explanation for device drivers is " Drive hardware Device Actions ". Drive and the underlying hardware directly to deal with, according to the specific work of the hardware device, read and write device registers, the completion of the device polling (polling (Polling) is a CPU decision how to provide peripheral equipment services, also know
, process management, file management, storage management, equipment management, network and communication management, user interface, in which the processor management is actually process management. Because the processor is allocated and executed in a process-based unit. and storage management means memory management.Further, the computer has a network card, video card, sound card, etc., you can also external USB flash drive, printer and so on peripherals, so many devices have no classificatio
Compiling of Linux kernel modules and drivers-general Linux technology-Linux programming and kernel information. For details, refer to the following. The Linux kernel is an integral structure, so it is very difficult to add anything to or delete some features to the kernel.
Article reprinted to CSDN community Luo Shenyang's Android tour, original address: http://blog.csdn.net/luoshengyang/article/details/6573809In 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 ker
interface for the operating system.★File_operations struct
There are many types of drivers, and their programs will be different. How can drivers provide unified interfaces? The most important thing is this struct, which is defined in the include/linux/fs. h file.
struct file_operations {struct module *owner;loff_t (*llseek) (struct file *, loff_t, int);ssize_t
Brief introduction
The name of the TTY device is abbreviated from the previous telex, originally referred to as a physical or virtual terminal connected to a UNIX system
The core of the Linux TTY driver is immediately below the standard character device driver layer and provides a range of functions that are used as interfaces by terminal type devices
There are three types of TTY drivers
Linux character device driver programming process 1. first, some version information is useless, but not less # define _ NO_VERSION _ www.2cto.com # include lt; linux/modules. h gt; # include lt; linux/version. h gt; charkern...
Basic process for writing Linux character device
Recently, I have been reading books and learning about Linux device drivers. I am getting started with the simplest character device drivers and can have a macro understanding of the driver framework and functions of various elements. The following is a detailed analysis of the device driver with the first character I have written. I will sort out some basic driv
uses system functions to interview device files.So be sure to have a device file in your filesystem that corresponds to your device driver, so your app has access to your device drivers.Device files are typically placed below the/dev folder. You can view it through the LS command. How do I create a device file node?The ability to use the Mknod command, such as I want to create a master device number of 103. A character device file with a secondary device number of 0. You can enter: Mknod/dev/xx
int Dma_map_device (struct device *dev,struct scatterlist *sg, int nents,enum dma_data_directiondirection);
There can be a relatively simple way to pre-allocate buffers in a Linux system, which is to synchronize the "mem=" parameter to reserve memory. For example, for a system with a memory of 64MB, passing the MEM=62MB command-line argument to it allowsThe top 2MB memory is reserved for use as IO memory, this 2MB memory can be statica
Learning device driver Programming also has a period of time, also wrote a few drivers, so there are some new understanding and understanding of the device driver, summed up. Learning device driver Programming also has a period of time, also wrote a few drivers, so there are some new understanding and understanding of the device driver, summed up.★ What is a driverWhen I first started learning about device
Using asynchronous notifications in device drivers can make access to the device accessible to the application by the driver when it is accessible. Therefore, applications that use nonblocking I/O do not need to poll the device for access, and blocking access can be superseded by asynchronous notifications like "break". Asynchronous notifications are similar to the concept of "interrupts" on hardware, and the more accurate term is "signal-driven async
DMA controller
unsigned long claim_dma_lock ();
The information that must be loaded into the controller consists of three parts: the address of the RAM, the number of 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
Rel
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.