Linux I/O port and I/O memory-Linux general technology-Linux programming and kernel information. For details, see the following. The CPU can address the physical address of the peripheral port in two ways: IO ing and memory ing. In Linux, IO Ports Based on IO ing and memory ing are collectively referred to as IO region ).
IO region is still an IO resource, so it can still be described by the resource structure type.
Linux IO region management:
1) request_region ()
Allocate the I/O port of a given range to an I/O device.
2) check_region ()
Check whether the IO port in a given range is idle or whether some of the ports have been allocated to an IO Device.
3) release_region ()
Releases the I/O port allocated to an I/O device in the specified range.
In Linux, you can use the following auxiliary functions to access the I/O port:
Inb (), inw (), inl (), outb (), outw (), outl ()
"B" "w" and "l" represent 8-bit, 16-bit, and 32-bit respectively.
Access to IO memory resources
1) request_mem_region ()
Request to allocate the specified IO memory resources.
2) check_mem_region ()
Check whether the specified IO memory is occupied.
3) release_mem_region ()
Releases the specified IO memory.
The start address parameter passed to the function is the physical address of the memory area (the preceding function parameter table is omitted ). Driver developers can regard IO ports mapped to memory and peripheral memory as IO memory resources. Ioremap () is used to map the physical addresses of IO resources to the virtual address space (3 GB-4 GB) of the kernel. the addr parameter is a pointer to the virtual address of the kernel.
In Linux, you can use the following auxiliary functions to access IO memory resources:
Linux in the kernel/resource. the global variables ioport_resource and iomem_resource are defined in file c, to describe the entire IO port space based on IO ing and IO memory resource space based on memory ing (including IO port and peripheral memory ).
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