Memory-mapped I/O and port-mapped I/O

Memory-mapped I/O (MMIO) and port-mapped I/O (PMIO) are two complementary methods of performing input/output (I/O) between the central processing unit (CPU) and peripheral devices in a computer (often mediating access via chipset). An alternative approach is using dedicated I/O processors, commonly known as channels on mainframe computers, which execute their own instructions.

Memory-mapped I/O uses the same address space to address both main memory[a] and I/O devices.[1] The memory and registers of the I/O devices are mapped to (associated with) address values, so a memory address may refer to either a portion of physical RAM or to memory and registers of the I/O device. Thus, the CPU instructions used to access the memory (e.g. MOV ...) can also be used for accessing devices. Each I/O device either monitors the CPU's address bus and responds to any CPU access of an address assigned to that device, connecting the system bus to the desired device's hardware register, or uses a dedicated bus.

To accommodate the I/O devices, some areas of the address bus used by the CPU must be reserved for I/O and must not be available for normal physical memory; the range of addresses used for I/O devices is determined by the hardware. The reservation may be permanent, or temporary (as achieved via bank switching). An example of the latter is found in the Commodore 64, which uses a form of memory mapping to cause RAM or I/O hardware to appear in the 0xD0000xDFFF range.

Port-mapped I/O often uses a special class of CPU instructions designed specifically for performing I/O, such as the in and out instructions found on microprocessors based on the x86 architecture. Different forms of these two instructions can copy one, two or four bytes (outb, outw and outl, respectively) between the EAX register or one of that register's subdivisions on the CPU and a specified I/O port address which is assigned to an I/O device. I/O devices have a separate address space from general memory, either accomplished by an extra "I/O" pin on the CPU's physical interface, or an entire bus dedicated to I/O. Because the address space for I/O is isolated from that for main memory, this is sometimes referred to as isolated I/O.[2] On the x86 architecture, index/data pair is often used for port-mapped I/O.[3]

Overview

Different CPU-to-device communication methods, such as memory mapping, do not affect the direct memory access (DMA) for a device, because, by definition, DMA is a memory-to-device communication method that bypasses the CPU.

Hardware interrupts are another communication method between the CPU and peripheral devices, however, for a number of reasons, interrupts are always treated separately. An interrupt is device-initiated, as opposed to the methods mentioned above, which are CPU-initiated. It is also unidirectional, as information flows only from device to CPU. Lastly, each interrupt line carries only one bit of information with a fixed meaning, namely "an event that requires attention has occurred in a device on this interrupt line".

I/O operations can slow memory access if the address and data buses are shared. This is because the peripheral device is usually much slower than main memory. In some architectures, port-mapped I/O operates via a dedicated I/O bus, alleviating the problem.

One merit of memory-mapped I/O is that, by discarding the extra complexity that port I/O brings, a CPU requires less internal logic and is thus cheaper, faster, easier to build, consumes less power and can be physically smaller; this follows the basic tenets of reduced instruction set computing, and is also advantageous in embedded systems. The other advantage is that, because regular memory instructions are used to address devices, all of the CPU's addressing modes are available for the I/O as well as the memory, and instructions that perform an ALU operation directly on a memory operand (loading an operand from a memory location, storing the result to a memory location, or both) can be used with I/O device registers as well. In contrast, port-mapped I/O instructions are often very limited, often providing only for simple load-and-store operations between CPU registers and I/O ports, so that, for example, to add a constant to a port-mapped device register would require three instructions: read the port to a CPU register, add the constant to the CPU register, and write the result back to the port.

As 16-bit processors have become obsolete and replaced with 32-bit and 64-bit in general use, reserving ranges of memory address space for I/O is less of a problem, as the memory address space of the processor is usually much larger than the required space for all memory and I/O devices in a system. Therefore, it has become more frequently practical to take advantage of the benefits of memory-mapped I/O. However, even with address space being no longer a major concern, neither I/O mapping method is universally superior to the other, and there will be cases where using port-mapped I/O is still preferable.

x86

Memory-mapped I/O is preferred in IA-32 and x86-64 based architectures because the instructions that perform port-based I/O are limited to one register: EAX, AX, and AL are the only registers that data can be moved into or out of, and either a byte-sized immediate value in the instruction or a value in register DX determines which port is the source or destination port of the transfer.[4][5] Since any general-purpose register can send or receive data to or from memory and memory-mapped I/O devices, memory-mapped I/O uses fewer instructions and can run faster than port I/O. AMD did not extend the port I/O instructions when defining the x86-64 architecture to support 64-bit ports, so 64-bit transfers cannot be performed using port I/O.[6]

On newer Intel platforms beginning with 2008 5 series, I/O devices on the chipset directly communicate via a dedicated Direct Media Interface (DMI) bus.[b][7]

Memory barriers

Since the caches mediate accesses to memory addresses, data written to different addresses may reach the peripherals' memory or registers out of the program order, i.e. if software writes data to an address and then writes data to another address, the cache write buffer does not guarantee that the data will reach the peripherals in that order.[8] Any program that does not include cache-flushing instructions after each write in the sequence may see unintended IO effects if a cache system optimizes the write order. Writes to memory can often be reordered to reduce redundancy or to make better use of memory access cycles without changing the final state of what got stored; whereas, the same optimizations might completely change the meaning and effect of writes to memory-mapped I/O regions.

Lack of foresight in the choice of memory-mapped I/O regions led to many of the RAM-capacity barriers in older generations of computers. Designers rarely expected machines to grow to make full use of an architecture's theoretical RAM capacity, and thus often used some of the high-order bits of the address-space as selectors for memory-mapped I/O functions. For example, the 640 KB barrier in the IBM PC and derivatives is due to reserving the region between 640 and 1024 KB (64k segments 10 through 16) for the Upper Memory Area. This choice initially made little impact, but it eventually limited the total amount of RAM available within the 20-bit available address space. The 3 GB barrier and PCI hole are similar manifestations of this with 32-bit address spaces, exacerbated by details of the x86 boot process and MMU design. 64-bit architectures often technically have similar issues, but these only rarely have practical consequences.

Examples

A sample system memory map
Address range (hexadecimal) Size Device
0000–7FFF 32 KiB RAM
8000–80FF 256 bytes General-purpose I/O
9000–90FF 256 bytes Sound controller
A000–A7FF 2 KiB Video controller/text-mapped display RAM
C000–FFFF 16 KiB ROM

A simple system built around an 8-bit microprocessor might provide 16-bit address lines, allowing it to address up to 64 kibibytes (KiB) of memory. On such a system, the first 32 KiB of address space may be allotted to random access memory (RAM), another 16 KiB to read-only memory (ROM) and the remainder to a variety of other devices such as timers, counters, video display chips, sound generating devices, etc.

The hardware of the system is arranged so that devices on the address bus will only respond to particular addresses which are intended for them, while all other addresses are ignored. This is the job of the address decoding circuitry, and that establishes the memory map of the system. As a result, system's memory map may look like in the table on the right. This memory map contains gaps, which is also quite common in actual system architectures.

Assuming the fourth register of the video controller sets the background colour of the screen, the CPU can set this colour by writing a value to the memory location A003 using its standard memory write instruction. Using the same method, graphs can be displayed on a screen by writing character values into a special area of RAM within the video controller. Prior to cheap RAM that enabled bit-mapped displays, this character cell method was a popular technique for computer video displays (see Text user interface).

Basic types of address decoding

Address decoding types, in which a device may decode addresses completely or incompletely, include the following:

Complete (exhaustive) decoding
1:1 mapping of unique addresses to one hardware register (physical memory location). Involves checking every line of the address bus.
Incomplete (partial) decoding
n:1 mapping of n unique addresses to one hardware register. Partial decoding allows a memory location to have more than one address, allowing the programmer to reference a memory location using n different addresses. It may also be done to simplify the decoding hardware by using simpler and often cheaper logic that examines only some address lines, when not all of the CPU's address space is needed. Commonly, the decoding itself is programmable, so the system can reconfigure its own memory map as required, though this is a newer development and generally in conflict with the intent of being cheaper.
Synonyms: foldback, multiply mapped, partially mapped, address aliasing.[9][10]
Linear decoding
Address lines are used directly without any decoding logic. This is done with devices such as RAMs and ROMs that have a sequence of address inputs, and with peripheral chips that have a similar sequence of inputs for addressing a bank of registers. Linear addressing is rarely used alone (only when there are few devices on the bus, as using purely linear addressing for more than one device usually wastes a lot of address space) but instead is combined with one of the other methods to select a device or group of devices within which the linear addressing selects a single register or memory location.

Port I/O via device drivers

In Windows-based computers, memory can also be accessed via specific drivers such as DOLLx8KD which gives I/O access in 8-, 16- and 32-bit on most Windows platforms starting from Windows 95 up to Windows 7. Installing I/O port drivers will ensure memory access by activating the drivers with simple DLL calls allowing port I/O and when not needed, the driver can be closed to prevent unauthorized access to the I/O ports.

Linux provides the pcimem utility to allow reading from and writing to MMIO addresses. The Linux kernel also allows tracing MMIO access from kernel modules (drivers) using the kernel's mmiotrace debug facility. To enable this, the Linux kernel should be compiled with the corresponding option enabled. mmiotrace is used for debugging closed-source device drivers.

See also

Notes

  1. ^ A memory that besides registers is directly accessible by the processor, e.g. DRAM in IBM PC compatible computers or Flash/SRAM in microcontrollers.
  2. ^ See Intel datasheets on specific CPU family e.g. 2014 "10th Generation Intel Processor Families" (PDF). Intel. April 2020. Retrieved 2023-06-05.;

References

  1. ^ Hayes, John P. (1978). Computer Architecture and Organization. McGraw-Hill International Book Company. p. 419. ISBN 0-07-027363-4.
  2. ^ Dandamudi, Sivarama P. (2006-05-31). "Chapter 19 Input/Output Organization" (PDF). Fundamentals of Computer Organization and Design. Springer Science+Business Media. ISBN 978-0-387-21566-2.
  3. ^ "Bochs VBE Extensions - OSDev Wiki".
  4. ^ "Intel 64 and IA-32 Architectures Software Developer's Manual: Volume 2A: Instruction Set Reference, A-M" (PDF). Intel 64 and IA-32 Architectures Software Developer's Manual. Intel Corporation. June 2010. pp. 3–520. Retrieved 2010-08-21.
  5. ^ "Intel 64 and IA-32 Architectures Software Developer's Manual: Volume 2B: Instruction Set Reference, N-Z" (PDF). Intel 64 and IA-32 Architectures Software Developer's Manual. Intel Corporation. June 2010. pp. 4–22. Retrieved 2010-08-21.
  6. ^ "AMD64 Architecture Programmer's Manual: Volume 3: General-Purpose and System Instructions" (PDF). AMD64 Architecture Programmer's Manual. Advanced Micro Devices. November 2009. pp. 117, 181. Retrieved 2010-08-21.
  7. ^ "What Is the Direct Media Interface (DMI) of Intel Processors?". Intel. Retrieved 2023-06-05.
  8. ^ ARM Cortex-A Series Programmer's Guide. Literature number ARM DEN0013D. pp. 10–13.
  9. ^ "Partial Address Decoding and I/O Space in Windows Operating Systems". Microsoft. 2001-12-04.
  10. ^ "Address aliasing". Hewlett-Packard.

Read other articles:

CrawlingSingel oleh Linkin Parkdari album Hybrid TheorySisi-BPapercut (Langsung dari BBC)Dirilis14 November 2000[1]DirekamNew Orleans, Louisiana, 1998-1999Genre Nu metal[2][3] rap metal[4] rap rock[3] Durasi3:29LabelWarner Bros.PenciptaLinkin ParkProduserDon GilmoreKronologi singel Linkin Park One Step Closer (2000) Crawling (2000) Papercut (2001) Video musikCrawling di YouTube Crawling adalah sebuah lagu oleh grup musik rok Amerika Linkin Park. Ini ada...

 

Ramoji Film City This is a list of films produced in the Telugu cinema also known as Tollywood and in the Telugu language.[1] 1930s List of Telugu films of the 1930s 1940s List of Telugu films of the 1940s List of Telugu films of 1941 List of Telugu films of 1942 List of Telugu films of 1943 List of Telugu films of 1944 List of Telugu films of 1945 List of Telugu films of 1946 List of Telugu films of 1947 List of Telugu films of 1948 List of Telugu films of 1949 List of Telugu films o...

 

В Википедии есть статьи о других людях с фамилией Альбани. Его Высокопреосвященство кардиналАлессандро Альбаниитал. Alessandro Albani Кардинал-протодьякон 16 января 1747 года — 11 декабря 1779 года Предшественник Кардинал Карло Мария Марини Преемник Кардинал Доменико Орсин...

War memorial The Mametz Wood Memorial commemorates an engagement of the 38th (Welsh) Division of the British Army during the First Battle of the Somme in France in 1916. The memorial Mametz Wood and memorial. The memorial assembly blurred due to copyright restrictions The memorial, erected in 1987 by Welsh sculptor David Petersen, is a Welsh red dragon on top of a three-metre stone plinth, facing the wood and tearing at barbed wire. It was commissioned by the South Wales Branch of the Western...

 

Japanese light novel series Young Gun CarnavalCover of Young Gun Carnval #1, Light Novel Version by Tokuma Novelsヤングガン・カルナバル(Yanggugan Karunabaru)GenreAction, Adventure, Drama Light novelWritten byMakoto FukamiIllustrated byTow FukinoPublished byTokuma ShotenImprintTokuma NovelsDemographicMaleOriginal runJune 2005 – October 2010Volumes12 MangaWritten byMakoto FukamiIllustrated byYuko SatōPublished byFlex ComixMagazineFlex Comix NextDemogr...

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Possum Kingdom song – news · newspapers · books · scholar · JSTOR (January 2010) (Learn how and when to remove this template message) 1994 single by ToadiesPossum KingdomSingle by Toadiesfrom the album Rubberneck Released1994GenreGrunge[1][2 ...

Upper house of the Wisconsin Legislature Wisconsin SenateWisconsin State LegislatureTypeTypeUpper house Term limitsNoneHistoryNew session startedJanuary 3, 2023LeadershipPresidentChris Kapenga (R) since January 4, 2021 President pro temporePatrick Testin (R) since January 4, 2021 Majority LeaderDevin LeMahieu (R) since January 4, 2021 Minority LeaderDianne Hesselbein (D) since December 1, 2023 StructureSeats33Political groupsMajority   Republican (22) Minority   Democratic...

 

Sridevi at the premiere of her film English Vinglish in 2012 Sridevi (born Shree Amma Yanger Ayyapan; 13 August 1963 – 24 February 2018) was an Indian actress and film producer, who primarily worked in Telugu, Tamil, Hindi, Malayalam and Kannada films.[1] Her acting career started in South Indian Cinema at the age of 4, with the Tamil film Kandan Karunai. She then made her early transition to adult roles by the age of 13 with director, K. Balachander's film, Moondru Mudichu. Due to ...

 

Governing body for international ocean rowing Ocean Rowing Society InternationalSportOcean RowingJurisdictionWorldwideAbbreviationORSIFounded1983 (1983) by Kenneth CrutchlowHeadquartersUnited KingdomDirectorTatiana Rezvaya-CrutchlowOfficial websitewww.oceanrowing.com Ocean Rowing Society International (ORSI) (prior to 2006 known as ORS), is the governing body for international ocean rowing and official adjudicator of ocean rowing records for Guinness World Records. ORSI was founded in 19...

American sport shooter Joshua RichmondRichmond at the 2016 OlympicsPersonal informationBorn (1985-12-19) December 19, 1985 (age 37)Sayre, Pennsylvania, U.S.Height188 cm (6 ft 2 in)Weight91 kg (201 lb)SportSportTrap shootingEventDouble trapClubU.S. Army Marksmanship Unit, Fort Benning, Georgia Medal record Representing the  United States Pan American Games 2007 Rio de Janeiro Double trap Double trap world championships 2006 Zagreb Team 2007 Nicosia Individual...

 

John HoranHoran in June 2018President of the Gaelic Athletic AssociationIn office24 February 2018 – 27 February 2021Preceded byAogán Ó FearghailSucceeded byLarry McCarthy Personal detailsBorn1958Dublin, IrelandOccupationRetired Secondary school principal John Horan (born 1958) is a Gaelic games administrator who served as 39th president of the GAA. He was chairman of the Leinster Council from 2014 to 2017 and was previously vice-chairman from 2011 to 2014. A member of the Na Fian...

 

Indian television producer Nivedita BasuBasu at Lakme Fashion WeekBornNivedita Basu (1978-05-04) 4 May 1978 (age 45)New Delhi, IndiaOccupation(s)vice president content and business alliances at Atrangii, Director, Creative Director,Writer, Creator And ProducerYears active2000-presentSpouseYadunath Bhargavan Nivedita Basu is The vice president content and business alliances at Atrangii[1] and Indian television producer who was creative director at Balaji Telefilms.[2]...

Japanese footballer Keita Endo Personal informationDate of birth (1997-11-22) 22 November 1997 (age 26)Place of birth Asahi-ku, Yokohama, JapanHeight 1.75 m (5 ft 9 in)Position(s) WingerTeam informationCurrent team Eintracht Braunschweig (on loan from Union Berlin)Number 8Youth career2010–2015 Yokohama F. MarinosSenior career*Years Team Apps (Gls)2016–2021 Yokohama F. Marinos 103 (13)2020–2021 → Union Berlin (loan) 16 (1)2021– Union Berlin 4 (0)2022– → Eintra...

 

В Википедии есть статьи о других людях с такой фамилией, см. Дэвис; Дэвис, Джозеф. Джозеф Эдвард Дэвисангл. Joseph Edward Davies Посол США в СССР 16 ноября 1936 — 11 июня 1938[1] Президент Франклин Рузвельт Предшественник Уильям Буллит Преемник Лоуренс Штейнгардт Посол США в Бель...

 

American politician For other people named John Dent, see John Dent (disambiguation). This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: John Herman Dent – news · newspapers · books · scholar · JSTOR (October 2020) (Learn how and when to remove this template message) John H. DentMember of the U.S. House ...

Not to be confused with J. D. McArthur. American businessman and philanthropist John D. MacArthurBornJohn Donald MacArthur(1897-03-06)March 6, 1897Pittston, Pennsylvania, U.S.DiedJanuary 6, 1978(1978-01-06) (aged 80)West Palm Beach, Florida, U.S.Occupation(s)Businessman, philanthropistKnown forMacArthur FoundationSpouses Louise Ingalls ​(div. 1937)​ Catherine T. Hyland ​(m. 1938)​ Children2, including J. Roderick MacArthurRel...

 

1976 novel by Wallace Stegner First edition cover The Spectator Bird is a 1976 novel by Wallace Stegner. It won the National Book Award for Fiction in 1977, one of the two most prestigious literary awards in the United States.[1] The book tells the story of retired literary agent Joe Allston, who receives a postcard from an old friend, a Danish countess named Astrid. Joe initially hides the postcard from his wife, Ruth. However, he soon reveals to her not only its existence but that o...

 

1979 Cleveland mayoral election ← 1978 (recall) November 6, 1979 1981 →   Candidate George Voinovich Dennis Kucinich Party Nonpartisan Nonpartisan Popular vote 94,541 73,755 Percentage 56.18% 43.83% Mayor before election Dennis Kucinich Democratic Elected Mayor George Voinovich Republican Elections in Ohio Federal government U.S. President 1804 1808 1812 1816 1820 1824 1828 1832 1836 1840 1844 1848 1852 1856 1860 1864 1868 1872 1876 1880 1884 1888 1892 1896 190...

German tool manufacturer Wera Werkzeuge GmbHTypeLimited liability company (GmbH)IndustryHand toolsFounded1936 (Wuppertal, Germany)HeadquartersWuppertal, GermanyProductsScrewdrivers; VDE insulated screwdrivers; bits; torque wrenches; ESD screwdrivers; stainless steel tools; hex keys; dead blow hammers; socket wrenches; wrenchesOwnerBitburger Braugruppe GmbHNumber of employees850Websitewww-de.wera.de/en Wera screwdrivers Wera Tools is the popular name for tool manufacturer Wera Werkzeuge GmbH (...

 

Hospital Antonio Lorena Antigua portada del Hospital Antonio Lorena.LocalizaciónPaís Perú PerúLocalidad Plazoleta de Belén s/n, CuscoCoordenadas 13°31′37″S 71°58′51″O / -13.526968, -71.980927Datos generalesFundación 1934Sistema asistencia PúblicoFinanciamiento PúblicoClasificación Hospital Nivel III(Categoría III-1)[1]​Red hospitalaria Ministerio de Salud del PerúSitio web oficial[editar datos en Wikidata] Hospital Antonio Lorena ...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!