Page 1 of 1

Memory mapped IO: pros/cons?

Posted: Fri Dec 15, 2006 4:57 am
by xlq
What are the pros/cons of using memory-mapped io? I would have thought it would be slower, and would risk writing to random IO addresses if code somewhere fails.

Posted: Fri Dec 15, 2006 5:30 am
by Combuster
In all cases i know (for the x86), the device decides wether to use memory accesses or port accesses. In essence, you're stuck with it.

Re: Memory mapped IO: pros/cons?

Posted: Fri Dec 15, 2006 6:57 am
by JoeKayzA
xlq wrote:I would have thought it would be slower, and would risk writing to random IO addresses if code somewhere fails.
That's what you would use an MMU for. AFAIK there is no difference in speed at all, btw, it's just a different set of instructions.

Re: Memory mapped IO: pros/cons?

Posted: Fri Dec 15, 2006 7:05 am
by m
Hi.
xlq wrote:What are the pros/cons of using memory-mapped io?
Exactly,memory-mapping I/O has got both advantages and disadvantages.
I would have thought it would be slower,
(I think)It would be no slower than isolated I/O because it's implemented on hardware layer.It may take the I/O module little extra time to process the uniformed opcodes(or commands) and schedule the common resource.
and would risk writing to random IO addresses if code somewhere fails.
If the hardware doesn't provide such checks or protection,the error would occur.It's the softwares' responsibility to avoid its happening.

Another pro for memory-mapped I/O is that we can use almost all opcodes for memory operation to operate I/O as well,because in a system programmer's view,the opcodes are uniform.This would be convenient to process I/O in an efficient way.

And...What else? :roll:

Posted: Fri Dec 15, 2006 8:06 am
by Hadrien
The pros of memory mapped IO I can think of are :

1) it may be easier to understand

Maybe this is just me, but here are my thoughts. I started on Amiga / 680x0 where a range of addresses were used for IO. You just used the legacy instructions to move an int but used those special addresses. Simple to use and understand.

When I started to look at the x86, I was quite confused by the "in" and "out" instructions. It's only later I understood the concept of a dedicated IO piece of hardware inside the CPU.

2) it can be directly accessed without any assembly instruction

As shown in this hypothetical C++ example:

Code: Select all

// Read the mouse on my cool YBox 720 platform
int32* pRegMouseXY = (int32*) 0xffff4000;

int32 nMouseX = pRegMouseXY[0];
int32 nMouseY = pRegMouseXY[1];