critical section cannot be too long; spin----lock can be used in an interrupt contextSignal Volume----need a header file linux/semaphore.h----struct semaphore sem; Define the semaphore----Sema_init (sem,1); Initialize the semaphore----Down_interruptible (SEM); Get the semaphore----......//Critical area code----Up (SEM); Release semaphore----Description: The semaphore differs from the spin lock, which is a sleep lock that cannot be used in an interrup
Memdev.h#ifndef _memdev_h#define _memdev_h#define mem_magic ' m ' #define Mem_restart _io (mem_magic, 0)//Use the kernel-provided macros to generate commands #define MEM _set _iow (mem_magic, 1, int)//change command to pass a shaping parameter to the kernel #endifDriver MEMDEV.C#include Application MEM_READ.C#include The device number is dynamically assigned in the driver and the device number assigned by the system to Memdev is viewed through cat/proc/devices.Use the command Mknod/dev/memde
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
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
Linux driver-LED Drivers _ 1, linuxled_1
Steps:
1. Framework
2. complete hardware operations:
A. view the principle diagram and pins
B. Check the 2440 manual.
C. write code: ioremap is required for the IO port.
My board sub-circuit is as follows:
1,Configure GPBCON registersConfiguration output is configured in the open function.
2,Configure GPBDAT registersConfigure in the write function
#################
Clock management for linux Device Drivers (4) ---- it turns out to be a child
When I was a child, I saw a TV series called "Little Dragon man". You don't have to mention it. It's actually very inspirational. To find my mother, it's a great TV series, what are the children watching? Xuanyuan sword, god of every day, magic, illusion, and flashy stuff. Apart from commercial value, what kind of stuff can be use
# If kernelrelease is defined, we 've been invoked from# Kernel build system and can use its language.Ifneq ($ (kernelrelease ),)OBJ-M: = Hello. o
# Otherwise we were called directly from the command# Line; invoke the kernel build system.
ElseKerneldir? =/Lib/modules/$ (shell uname-R)/buildPWD: = $ (shell PWD)Default:$ (Make)-C $ (kerneldir) M = $ (PWD) ModulesEndif
When we knocked on make, we entered this authoritative makefile twice. The first time she entered makefile and found that ker
1. Module_i2c_driver (adxl34x_driver) expand toStatic int__intAdxl34x_driver_init (void){returnI2c_register_driver ( adxl34x_driver);} Module_init (adxl34x_driver_init);Static void__exitAdxl34x_driver_exit (void){returnI2c_del_driver ( adxl34x_driver);} Module_exit (adxl34x_driver_exit);Function: Instead of registering initialization functions and module_init () and Module_exit (), you can replace them with this if you do nothing in the initialization function. Common macros in
previous blog post, assuming that the interrupt action occurred, the mask value will be told to the kernel. The meaning of the value of mask:
Constant
Description
Pollin
Normal or priority with data-readable
Pollrdnorm
Plain Data readable
Pollrdband
Priority with data-readable
Pollpri
High-priority data readable
Pollout
Plain data can be written
Pollwrnorm
function returns, any work function that was committed before the call does not run anywhere on the system.After you have finished using the work queue, you can call the following function to release the related resources:void Destroy_workqueue (struct work_queue_struct *queue);Shared queuesThe device driver can use the shared default work queue provided by the kernel.Initializing the WORK_STRUCT structurestatic struct work_struct jiq_work;Init_work (jiq_work, Jiq_print_wq, jiq_data);int schedu
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
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 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.