c++ - What real platforms map hardware ports to memory addresses? -


i see statements on platforms following c or c++ code:

int* ptr; *ptr = 0; 

can result in writing hardware input-output port if ptr happens store address port mapped. called "embedded platforms".

what real examples of such platforms?

most systems in experience use memory-mapped i/o. x86 platform has separate, non-memory-mapped i/o address space (that uses in/out family of processor op-codes), pc architecture extensively uses standard memory address space device i/o, has larger address space, faster access (generally), , easier programming (generally).

i think separate i/o address space used because memory address space of processors quite limited , made little sense use portion of device access. once memory address space opened megabytes or more, reason separate i/o addresses memory addresses became less important.

i'm not sure how many processors provide separate i/o address space x86 does. indication of how separate i/o address space has fallen out of favor, when x86 architecture moved 32-bit realm, nothing done increase i/o address space 64kb (though did add ability move 32-bit chunks of data in 1 instruction). when x86 moved 64-realm, i/o address space remained @ 64kb , didn't add ability move data in 64-bit units...

also note modern desktop , server platforms (or other systems use virtual memory) don't permit application access i/o ports, whether they're memory-mapped or not. access restricted device drivers, , device drivers have os interface deal virtual memory mappings of physical address and/or set dma access.

on smaller systems, embedded systems, i/o addresses accessed directly application. systems use memory-mapped addresses, done setting pointer physical address of device's i/o port , using pointer other. however, ensure access occurs , occurs in right order, pointer must declared pointing volatile object.

to access device uses other memory-mapped i/o port (like x86's i/o address space), compiler provide extension allows read or write address space. in absence of such extension, you'd need call assembly language function perform i/o.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -