Linux Driver Development Blind spot Note 1

Source: Internet
Author: User
Tags readable

1. After finding the search target in Vim, use N and N to locate
2. Use GG to the best first line in Vim, use XXXG to a line, or G directly to the last line;
3. Ln-s The resulting link file eventually points to the target file src that is newly generated by the current soft-link file DST. ln-s Project (a file or directory that actually exists on disk) A.lnkln-s SRC DST (newly generated file dst,dst linked to SRC) Symlink features similar
4 TAR-CZVF Final production of tar packaged files or folders to be packagedtar czvf a.tar.bz a

5. The key point of porting DTS is that the DTS files to be compiled need to be placed under/arch/arm/boot/dts. Make will find the DTS compile file entry by default here. Then compile with the same name DTB to perform make compile to be makefile resolved to the target, and then to find DTS with the same name by DTC to produce DTB files. And DTB is the final binary file compiled from DTS, located under Arch/arm/boot
6. Be aware of the Linux kernel interrupt programming:scheduling hibernation cannot occur in the context of an interrupt. That is, you cannot use mutexes, the semaphore PV operation can cause hibernation, and so on. It also takes a short time to interrupt a critical resource that normally needs to be handled by the spin lock protection. sleep cannot occur in a generic atomic context. Msleep/wait_event_interrupt and other functions are scheduled to sleep delay, it can not appear in the context of the interrupt.
7. The difference between List_for_each and List_for_each_safeTherefore, you can use List_for_each () when traversing a linked list without deleting a node, and use List_for_each_safe () when you want to delete a node operation.
8. Module Entry function code note the module Init/exit function is an argument-free function and should be the return value of type int
9. Version number of the Linux compile module use Modinfo to view the kernel version number of the compiled KO file using uname or cat/proc/version to view the kernel version number on the target system. You can view the files generated by the kernel compilation process: Include/generated/utsrelease.h, which determines the version number of the compiled kernel.
DF Displays disk partition information such as DF-H, du-sh to display the size information for each file and directory in the current directory
declare-f xxx for output of function output currently supported by Shell
Find-name *xxx Find Files
grep "xxx"-r./*
14cat/proc/version View Ubuntu version number, lsb_release-acat/etc/issue

Makefile = and: = The former will see the global value of the assignment variable when it is assigned, and only see if the assigned variable is already defined before it is assigned.
& is the process running in the background does not occupy the terminal
17Linux device driver blocking and non-blocking mode, blocking and non-blocking is for the data read and write, that is, the acquisition of resources, when there is no resources, blocking will dispatch process hibernation, and not blocking immediately return。 The essence of the poll function is simply to query whether the current device is readable or writable pollin and pollout. Select and poll can be used to ensure non-blocking operation of the device (select and poll itself is a blocking operation, blocking completion can indicate that the read and write resources are OK, so that the resources are read and write operations) and so-called blocking operations, is the device read and write directly to the process of scheduling and hibernation Until the data is readable or writable before returning back.
in the FoPs poll interface that you define, you need to implement the Poll_wait function, which simply joins the currently required process poll_table into a waiting queue header and does not produce hibernation, butA real hibernation schedule needs to be dispatched by Poll_schedule_timeout to hibernate in Do_sys_poll. after waiting for the queue header to be wake_up awakened, the poll interface call continues to be executed once again, adding itself to the wait queue, after which it is generally possible to pollin or pollout to exit the Do_sys_poll call and return the query result to the user layer.

static inline void poll_wait (struct file * Filp, wait_queue_head_t * wait_address, poll_table *p) {if (P && p-& Gt;_qproc && wait_address) p->_qproc (Filp, wait_address, p);//__pollwait}
static void __pollwait (struct file *filp, wait_queue_head_t *wait_address, poll_table *p) {struct POLL_W    Queues *pwq = container_of (p, struct poll_wqueues, PT);    struct Poll_table_entry *entry = poll_get_entry (PWQ);    if (!entry) return;    Get_file (FILP);    Entry->filp = FILP;    entry->wait_address = wait_address;    Entry->key = p->_key;    Init_waitqueue_func_entry (&entry->wait, Pollwake); Entry->wait.private = Pwq;Add_wait_queue(Wait_address, &entry->wait);//Add wait for the poll process to the wait queue header}
Linux Interrupt Nesting Fundamentals 1) After the Linux response is interrupted, the responder is divided into two parts: top and bottom, 2) when the top is finished, the interrupt is turned on (the associated interrupt flag is cleared), the bottom is run by the system, the bottom is run, the interrupt is allowed, and 3) if the driver is When an application is interrupted REQUEST_IQR (),with the parameter irqf_disabled, when the interrupt handler function is called, all interrupts are masked, allowing the interrupt to be executed quickly. 4) (2) and 3), Linux allows interrupt nesting.
Devm_kzalloc can better manage the resources of the equipment
After lable in DTS understand the structure of the basic device tree, we will always put these structures on device tree source code. In Linux kernel, the file with the extension DTS is the device tree source file that describes the hardware information, and in the DTS file, a node is defined as:
[Label:] node-name[@unit-address] {[Properties definitions] [child nodes]}
"[]" means option, so you can define an empty node with only node name. The label is conveniently referenced in the DTS file, which is described later. The format of child node is exactly the same as node, so a DTS file is a description of several nested node,property as well as the child note and Child note property.
The process of include DTSi in DTS was tried, and it seems that the reference to the label is independent of the location of the include, should be in advance of loading similar to Makefile's include processing, rather than C-compiled processing
Push-pull Open_drain Open-drain plus pull, in the high level when the current is very small, there is a problem is the level of the flip speed is relatively slow, in short, the driving capacity is not. But the way of open-drain can be realized by line and logic to achieve quasi-bidirectional io, which is not push-pull.
Floating empty, as the name implies is suspended in the air, the above with a rope pull up, the following with a rope to sink down. Pull up, pull down the settings are mainly to see your external driver circuit configuration of the specific situation. Open leakage, is equal to the output of an NPN transistor, and only the e,b. C pole is open, you can directly connect a resistor to 3.3V, you can also connect a resistor to 5v, so that when the output 1, there is a 5V of voltage, can also output 3.3V of voltage, but not the resistor pull up, this output high is not possible.push-pull, that is, there is push pull, any time the IO Port point ping du is determined, do not need external pull-up or pull-down resistor

& Usage in. DTSIn root node, if there is a a:a{} child node, and then in this DTS root nodes/{} outside of the added&a{xxxxxxOther node information}is this a way of just adding information to the a node, which is essentially just one, a node, just a separate description?
DTS device node definition name definition format:[Label:] node-name[@unit-address]For example, Cif:[email protected], the corresponding device node name or cif,[] indicates the selectable existence.

The sum of the FFS functions takes the lowest valid position and is set to 1, and the remaining bits are zeroed

Vmalloc_user after each vmalloc, the kernel creates a vm_struct to map the contiguous area of memory allocated to itVMA is the virtual address space that maps physical memory to a process。and Vm_struct is the linear address space that maps physical memory to the kernelMm_struct is the virtual address space that manages the entire process and is generally obtained by current->mm. Vmalloc_user space mapped back to user Remap_vmalloc_range
Linux driver automatic loading sequence, different levels according to the level of INIT, the same level according to the compilation order defined in Makefile, the first compiled module will be linked to the same level of the area blockmodules A and B are defined in makefile:Obj-y=a;obj-y=b;A , B module of the same level, a will be loaded first, b after loading

Example DTS/{soc0{compatible = "My, soc0";node1{compatible = "My, Node1"; node1_1{compatible = "My, node1_1";node1_1_1{compatible = "My, node1_1_1";}}}node2{}}soc1{compatible = "My, Soc1";}}
Shell script function variables
variables meaning
$ File name of the current script
$n Arguments passed to the script or function. N is a number that represents the first few parameters. For example, the first parameter is $ $, and the second argument is $ A.
$# The number of arguments passed to the script or function.
$* All parameters passed to the script or function.
[Email protected] All parameters passed to the script or function. When enclosed by double quotation marks (""), it is slightly different from $*, as will be mentioned below.
$? The exit state of the last command, or the return value of the function.
$$ The current shell process ID. For Shell scripts, this is the process ID where the scripts are located.

Linux Driver Development Blind spot Note 1

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.