Is virtual memory used when using port-mapped I / O?

If I have an I / O device with memory, and I want to write to the register for this device located at 0x16D34 , the address 0x16D34 actually a virtual address, and the CPU will translate it, first enter the physical address and then write the data to the physical address .

But what about port-mapped I / O devices (like a serial port), so if I want to write to the register for the serial port located at 0x3F8 , is the address 0x3F8 physical address or a virtual address?


Edit: I am in x86 architecture.

+5
source share
2 answers

Inputs / outputs with port mapping on x86 / x86-64 (most other modern architectures do not even support it) occurs in a completely separate address space. This address space cannot be displayed in memory, so there are no virtual port addresses, only physical ones. Special in and out commands should be used to perform port I / O; simple memory access (for example, using mov ) cannot access this separate address space. Access protection based on privilege level is possible; most modern operating systems do not allow user-space processes to access the default I / O ports.

For more information, see Intel's “INPUT / OUTPUT” Intel® 64 and IA-32 Developer's Guide for Developers: Volume 1 ” (Chapter 18 at the time of this writing) .

Note that in the early days of x86, port addresses were tied to each device, including ISA expansion cards. If you were lucky, the card had a set of jumpers to select one of a limited set of possible port ranges for the device to avoid collisions between devices. Plug and Play was later introduced for dynamic selection at system startup. PCI further clarified this, so that I / O BARs can be matched to a large extent within the 0x0000-0xffff address space of the operating system and / or firmware. Port-mapped I / O is now highly discouraged when developing new equipment due to the many inherent limitations.

+3
source

It looks like your question will be about the differences between I / O with memory mapping and IO with port mapping. Typically, two methods for the processor are connected to external devices that relate to memory or port input mapping.

Memory input / output

Memory I / Os use the same address space to address both memory and I / O devices. Therefore, when the address gets access to the CPU, it can refer to part of the physical RAM, but it can also refer to the memory of the I / O device (based on the I / O with memory in the Wiki ).

The value 0x16D34 in your first example will be virtual memory and will be mapped to physical memory. An I / O device will reference the same physical memory to provide access to the CPU.

Port mapping with port mapping

Port-mapped inputs / outputs use a separate dedicated address space and are accessible through a special set of microprocessor instructions. For 0x3F8 in the second example, this is the address of its own address specific to memory and input / output devices. This is not an address shared between memory and I / O, as previously mentioned in memory I / O. You can get more information in IO mapping with map mapping with IO port mapping

0
source

Source: https://habr.com/ru/post/1268502/


All Articles