Annotation in Linux kernel)

Source: Internet
Author: User

From: http://blog.yaabou.com /? P = 82

_ User indicates a pointer to a user space, so the kernel cannot be used directly.

# Ifdef _ checker __
# DEFINE _ User _ attribute _ (noderef, address_space (1 )))
# DEFINE _ KERNEL/* default address space */
# Else
# DEFINE _ User
# DEFINE _ KERNEL
# Endif

Noderef tells the compiler that the pointer reference should not be removed because it is meaningless in the current address space.

The checker indicates whether sprase is used (a static analysis tool used to analyze bugs in the kernel source code ). Do you want to study it? Haha. See http://sparse.wiki.kernel.org/index.php/Main_Page

Therefore, copy_to_user and copy_from_user are used in the kernel.

_ Iomem is a feature added in 2.6.9. Indicates the memory space that points to an I/O. It is mainly used to consider the versatility of the driver. The representation of I/O space may vary depending on the CPU architecture. When _ iomem is used, compiler ignores the variable check (because void _ iomem is used ). HoweverSparse will check it. When the _ iomem pointer is mixed with the normal pointer, it will issue some warnings.

The following are some new functions for a variable:

Unsigned int ioread8 (void _ iomem * ADDR );
Unsigned int ioread16 (void _ iomem * ADDR );
Unsigned int ioread32 (void _ iomem * ADDR );
Void iowrite8 (u8 value, void _ iomem * ADDR );
Void iowrite16 (2010value, void _ iomem * ADDR );
Void iowrite32 (u32 value, void _ iomem * ADDR );

You can take a look at the http://lwn.net/Articles/102240/
And http://lwn.net/Articles/102232/

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.