I/O port and I/O memory

Source: Internet
Author: User

CPUFor peripheralsIoThere are two address addressing methods: one isI/OIng method (I/O-Mapped), The other isMemory ing method (Memory-Mapped).

Some architecture CPUs (such as PowerPC and m68k) generally only implement one physical address space (RAM ). In this case, the physical address of the peripheral I/O port is mapped to the CPUSinglePhysical address space,And become a part of the memory.At this time,The CPU can access the peripheral I/O ports as it accesses a memory unit without the need to set up dedicated peripheral I/O commands. This is the so-called"Memory ing mode" (memory-mapped).

In additionCPU (such as x86) is dedicated for peripheralsSeparateAddress Space, called"I/O address space"Or"I/O port space". This is an address space different from the physical address space of the CPU. All the peripheral I/O ports are located in this space. The CPU uses dedicated I/O commands (such as x86 In and out commands) to access the address units (I/O Ports) in the space ). This is the so-called"I/O ing mode" (I/O-mapped).Compared with the ram physical address space, I/O address space is usually relatively small, for example, x86 cpu I/O space is only 64 KB (0-0xffff ).This is"I/O ing mode".

LinuxI/O ing modeOrMemory ing modeThe I/O port of is called"I/O Region" (I/O Region).

========================================================== ========================================================

1. Peripherals are performed by reading and writing registers on the device, the peripheral registers are also called "I/O port" , io ports can be configured in two ways: independent addressing and . the CPU architecture determines which one is used. For example, PowerPC and m68k adopt uniform addressing, while x86 adopt independent addressing. But for Linux kernel, it may be used for different CPUs, so it must consider both methods, so it adopts a new method, i/O port based on I/O ing or memory ing is called "I/O Region" (I/O Region) , no matter which method you use, you must first apply for the IO region: request_resource () and release it at the end: release_resource ().
for an established system, it is either an independent addressing, that is, in "I/O port" mode, the peripheral registers are located in "I/O space", or they are compiled in a unified manner, that is, "I/O memory" , the peripheral registers are located in "memory space" (many peripherals have their own memory, buffers, And the peripherals register and memory are collectively referred to as "I/O space ").

2. Access to peripherals is divided into I/O port access and I/O memory access.
the process for accessing Io memory is: request_mem_region ()-> ioremap ()-> ioread8 () /iowrite8 ()-> iounmap ()-> release_mem_region ().
I/O port There are 2 access methods, i/O ing (I/O-mapped) and memory ing (memory-mapped ). The previous method directly uses functions such as intb ()/outb () to read and write Io ports, and the latter (to achieve the same interface identity) first, map the IO port to the IO memory ("memory space"): ioport_map (), and then use the function to access the IO memory to access the IO port.

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.