niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » Unix internals
memory mapped IO: device registers mapped to virtual memory or physical memory?
Post new topic   Reply to topic Page 1 of 1 [14 Posts] View previous topic :: View next topic
Author Message
Ian
*nix forums Guru


Joined: 16 Aug 2005
Posts: 1615

PostPosted: Thu Feb 09, 2006 10:44 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Olumide wrote:
Quote:
Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

I think there is a more important issue here, you say 'simplify device

driver writing', I'd counter by saying 'produce a driver that works only
on the platform and OS version you develop it on'

The OS provides you with and API to protect you form the shifting sands
of kernel updates and endian issues.

--
Ian Collins.
Back to top
Richard L. Hamilton
*nix forums Guru Wannabe


Joined: 22 Feb 2005
Posts: 277

PostPosted: Thu Feb 09, 2006 9:59 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

In article <dsb7pp$o9b$2@news1brm.central.sun.com>,
Eric Sosman <Eric.Sosman@sun.com> writes:
Quote:


Maxim S. Shatskih wrote On 02/07/06 17:09,:
Look up DVMA (Direct Virtual Memory Access). Some systems
allow devices to deal in virtual memory addresses, passing
their address requests through the MMU to resolve them.
That means that a mapping of not necessarily contigous
physical pages to a contiguous range of virtual memory
can be done, and the device doesn't need to be able to
do scatter/gather operations (list of pages to transfer
to/from all at once). The old sun4m (SPARC/Sbus) systems
typically worked like that.


Windows supports this fully with their notion of "adapter object" and "logical
address" (the device-side address).

More so: AGP bus works exactly this way, its "MMU" is called GART - Graphics
Address Remap Table or such. The organization of this table is
chipset-specific, and thus the "AGP driver" for Windows.

Well, I guess there are more things in Heaven and
Earth than are dreamt of in my philosophy. Seems like
an awfully strange way to arrange things -- but live
and learn. What will they think of next? And is there
the faintest chance it will make sense? Wink

Time makes all things make sense, or at least allows one to discover
perspectives under which someone might have thought they made sense.
That is, it isn't always what they'll think of next, it may be what
they already thought of some time back.

(I'm assuming that someone who works for Sun, but didn't already have
the sun4m DVMA counter-example staring them in the face, is younger than
I am...)

I wonder if cache coherency issues didn't kill some of these things.

When someone comes up with really fast memory that's still low power and
very high density, and maybe some really slick electrical/optical
components, allowing optical memory interconnects (so distance won't
matter so much), it seems like it will cut so much complication out;
wouldn't have to work so damn hard on cache coherency if you didn't need a
cache, NUMA would only be needed with geographic level redundancy, etc. :-)


But from what I gather the poster that mentioned Windows was saying, both
operating systems (Solaris and Windows) have frameworks that allow for the
possibility of devices operating either in terms of physical or virtual
addresses, at least in some cases. So potentially they both serve to
abstract the hardware in that way as in so many others.

--
mailto:rlhamil@smart.net http://www.smart.net/~rlhamil

Lasik/PRK theme music:
"In the Hall of the Mountain King", from "Peer Gynt"
Back to top
Eric Sosman
*nix forums Guru


Joined: 21 Feb 2005
Posts: 1246

PostPosted: Tue Feb 07, 2006 10:43 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Maxim S. Shatskih wrote On 02/07/06 17:09,:
Quote:
Look up DVMA (Direct Virtual Memory Access). Some systems
allow devices to deal in virtual memory addresses, passing
their address requests through the MMU to resolve them.
That means that a mapping of not necessarily contigous
physical pages to a contiguous range of virtual memory
can be done, and the device doesn't need to be able to
do scatter/gather operations (list of pages to transfer
to/from all at once). The old sun4m (SPARC/Sbus) systems
typically worked like that.


Windows supports this fully with their notion of "adapter object" and "logical
address" (the device-side address).

More so: AGP bus works exactly this way, its "MMU" is called GART - Graphics
Address Remap Table or such. The organization of this table is
chipset-specific, and thus the "AGP driver" for Windows.

Well, I guess there are more things in Heaven and
Earth than are dreamt of in my philosophy. Seems like
an awfully strange way to arrange things -- but live
and learn. What will they think of next? And is there
the faintest chance it will make sense? ;-)

--
Eric.Sosman@sun.com
Back to top
Maxim S. Shatskih
*nix forums addict


Joined: 02 Apr 2005
Posts: 55

PostPosted: Tue Feb 07, 2006 10:09 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Quote:
Look up DVMA (Direct Virtual Memory Access). Some systems
allow devices to deal in virtual memory addresses, passing
their address requests through the MMU to resolve them.
That means that a mapping of not necessarily contigous
physical pages to a contiguous range of virtual memory
can be done, and the device doesn't need to be able to
do scatter/gather operations (list of pages to transfer
to/from all at once). The old sun4m (SPARC/Sbus) systems
typically worked like that.

Windows supports this fully with their notion of "adapter object" and "logical
address" (the device-side address).

More so: AGP bus works exactly this way, its "MMU" is called GART - Graphics
Address Remap Table or such. The organization of this table is
chipset-specific, and thus the "AGP driver" for Windows.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
Back to top
Richard L. Hamilton
*nix forums Guru Wannabe


Joined: 22 Feb 2005
Posts: 277

PostPosted: Mon Feb 06, 2006 9:53 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

In article <drqmfo$9k3$1@news1brm.central.sun.com>,
Eric Sosman <eric.sosman@sun.com> writes:
Quote:


Olumide wrote On 02/01/06 10:49,:
Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

How could device registers inhabit virtual memory?
That'd require every device to be sensitive to the MMU,
would insert the device registers into every process'
address space, would make machines with multiple CPUs
(more specifically, multiple MMUs) either impossible or
woefully inefficient, would make it impossible or very
difficult to change MMU settings while any device was
active, and would bring about the end of civilization as
we know it Wink Device registers inhabit physical memory
space; devices that do DMA generally do so to and from
physical-memory buffers.

Look up DVMA (Direct Virtual Memory Access). Some systems
allow devices to deal in virtual memory addresses, passing
their address requests through the MMU to resolve them.
That means that a mapping of not necessarily contigous
physical pages to a contiguous range of virtual memory
can be done, and the device doesn't need to be able to
do scatter/gather operations (list of pages to transfer
to/from all at once). The old sun4m (SPARC/Sbus) systems
typically worked like that.

However, that may well be fairly unusual; many systems
may well require the device to work in terms of physical
memory addresses; but as long as the OS hides all this
from the application, unless you're writing a device
driver, it shouldn't be a big deal one way or the other.

Quote:
That said, the CPU usually reads and writes virtual
addresses that are translated to physical addresses by
the MMU. So if the CPU is to access device registers,
it must configure the MMU so that it has a virtual-to-
physical mapping that associates some virtual address
with the physical address of the target register. In
that sense, device registers inhabit virtual memory --
but in that sense, RAM inhabits virtual memory, too.

Well, between the device possibly being able to reference
virtual memory addresses, and the user program being able
to reference virtual memory addresses to access the device,
unless you're writing kernel code, the distinction hardly
matters, does it?

All this could indeed get more complicated on a multiprocessor
system, which is why designing them so that multithreaded
apps scale almost linearly with number of CPUs is so difficult.

--
mailto:rlhamil@smart.net http://www.smart.net/~rlhamil

Lasik/PRK theme music:
"In the Hall of the Mountain King", from "Peer Gynt"
Back to top
Alexei A. Frounze
*nix forums Guru Wannabe


Joined: 10 Apr 2005
Posts: 243

PostPosted: Thu Feb 02, 2006 2:32 am    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

"Eli Gottlieb" <eligottlieb@gmail.com> wrote in message
news:EW5Ef.1712$5Q3.733@twister.nyroc.rr.com...
Quote:
Alexei A. Frounze wrote:
"Eli Gottlieb" <eligottlieb@gmail.com> wrote in message
news:FR4Ef.1708$5Q3.1219@twister.nyroc.rr.com...

Olumide wrote:

Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

Thanks,

- Olumide


Device registers have a "physical" address that can be mapped into
virtual memory using normal paging techniques, AFAIK.


Correct for real, physical devices in non-virtualized environments. If we
go for virtual ones, we may never know what is real and what is emulated
in some way (e.g. a page fault handler would do the emulation).

Alex


Is virtualization so common now that we actually bother to think about it?

It starts gaining some real importance in the business solutions (putting a
few servers that would otherwise run on different machines to one; untying
from particular hardware and making it possible to move the server to
another machine in a matter of minutes (well, maybe a few hours), to
replicate it, to back it up, to do all kinds of things that would otherwise
be hard to do with something real). And then there are applications for
which running in a virtualized environment is more secure (think of the
internet browser with all its bugs and vulnerables).

Quote:
Theoretically, the same software should run on both.

Right.

Quote:
If it doesn't, then I see no point in the virtualization, as it would just
be the creation of an arbitrary hardware platform that doesn't have any
real hardware.

You may underestimate it. While it doesn't make sense now, it may make a lot
of sence some time later. But as I told you, untying the software from the
particular devices makes it more portable.

Alex
Back to top
50295@web.de
*nix forums beginner


Joined: 09 Feb 2005
Posts: 32

PostPosted: Thu Feb 02, 2006 1:24 am    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Eric Sosman wrote:
Quote:
How could device registers inhabit virtual memory?
That'd require every device to be sensitive to the MMU,
would insert the device registers into every process'
address space, would make machines with multiple CPUs
(more specifically, multiple MMUs) either impossible or
woefully inefficient, would make it impossible or very
difficult to change MMU settings while any device was
active, and would bring about the end of civilization as
we know it Wink Device registers inhabit physical memory
space; devices that do DMA generally do so to and from
physical-memory buffers.

That said, the CPU usually reads and writes virtual
addresses that are translated to physical addresses by
the MMU. So if the CPU is to access device registers,
it must configure the MMU so that it has a virtual-to-
physical mapping that associates some virtual address
with the physical address of the target register. In
that sense, device registers inhabit virtual memory --
but in that sense, RAM inhabits virtual memory, too.

Thanks Eric!
Back to top
50295@web.de
*nix forums beginner


Joined: 09 Feb 2005
Posts: 32

PostPosted: Thu Feb 02, 2006 1:24 am    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Eric Sosman wrote:
Quote:
How could device registers inhabit virtual memory?
That'd require every device to be sensitive to the MMU,
would insert the device registers into every process'
address space, would make machines with multiple CPUs
(more specifically, multiple MMUs) either impossible or
woefully inefficient, would make it impossible or very
difficult to change MMU settings while any device was
active, and would bring about the end of civilization as
we know it Wink Device registers inhabit physical memory
space; devices that do DMA generally do so to and from
physical-memory buffers.

That said, the CPU usually reads and writes virtual
addresses that are translated to physical addresses by
the MMU. So if the CPU is to access device registers,
it must configure the MMU so that it has a virtual-to-
physical mapping that associates some virtual address
with the physical address of the target register. In
that sense, device registers inhabit virtual memory --
but in that sense, RAM inhabits virtual memory, too.

Thanks Eric!
Back to top
Maxim S. Shatskih
*nix forums addict


Joined: 02 Apr 2005
Posts: 55

PostPosted: Wed Feb 01, 2006 6:51 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

They are mapped to physical by hardware, and then also to virtual by the
OS - by a call like Windows's MmMapIoSpace.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Olumide" <50295@web.de> wrote in message
news:1138808976.217767.140250@z14g2000cwz.googlegroups.com...
Quote:
Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

Thanks,

- Olumide
Back to top
Eli Gottlieb
*nix forums beginner


Joined: 20 Jan 2006
Posts: 9

PostPosted: Wed Feb 01, 2006 5:08 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Alexei A. Frounze wrote:
Quote:
"Eli Gottlieb" <eligottlieb@gmail.com> wrote in message
news:FR4Ef.1708$5Q3.1219@twister.nyroc.rr.com...

Olumide wrote:

Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

Thanks,

- Olumide


Device registers have a "physical" address that can be mapped into virtual
memory using normal paging techniques, AFAIK.


Correct for real, physical devices in non-virtualized environments. If we go
for virtual ones, we may never know what is real and what is emulated in
some way (e.g. a page fault handler would do the emulation).

Alex


Is virtualization so common now that we actually bother to think about

it? Theoretically, the same software should run on both. If it
doesn't, then I see no point in the virtualization, as it would just be
the creation of an arbitrary hardware platform that doesn't have any
real hardware.
Back to top
Eric Sosman
*nix forums Guru


Joined: 21 Feb 2005
Posts: 1246

PostPosted: Wed Feb 01, 2006 4:09 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Olumide wrote On 02/01/06 10:49,:
Quote:
Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

How could device registers inhabit virtual memory?
That'd require every device to be sensitive to the MMU,
would insert the device registers into every process'
address space, would make machines with multiple CPUs
(more specifically, multiple MMUs) either impossible or
woefully inefficient, would make it impossible or very
difficult to change MMU settings while any device was
active, and would bring about the end of civilization as
we know it Wink Device registers inhabit physical memory
space; devices that do DMA generally do so to and from
physical-memory buffers.

That said, the CPU usually reads and writes virtual
addresses that are translated to physical addresses by
the MMU. So if the CPU is to access device registers,
it must configure the MMU so that it has a virtual-to-
physical mapping that associates some virtual address
with the physical address of the target register. In
that sense, device registers inhabit virtual memory --
but in that sense, RAM inhabits virtual memory, too.

--
Eric.Sosman@sun.com
Back to top
Alexei A. Frounze
*nix forums Guru Wannabe


Joined: 10 Apr 2005
Posts: 243

PostPosted: Wed Feb 01, 2006 4:08 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

"Eli Gottlieb" <eligottlieb@gmail.com> wrote in message
news:FR4Ef.1708$5Q3.1219@twister.nyroc.rr.com...
Quote:
Olumide wrote:
Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

Thanks,

- Olumide

Device registers have a "physical" address that can be mapped into virtual
memory using normal paging techniques, AFAIK.

Correct for real, physical devices in non-virtualized environments. If we go
for virtual ones, we may never know what is real and what is emulated in
some way (e.g. a page fault handler would do the emulation).

Alex
Back to top
Eli Gottlieb
*nix forums beginner


Joined: 20 Jan 2006
Posts: 9

PostPosted: Wed Feb 01, 2006 3:55 pm    Post subject: Re: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Olumide wrote:
Quote:
Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

Thanks,

- Olumide

Device registers have a "physical" address that can be mapped into

virtual memory using normal paging techniques, AFAIK.
Back to top
50295@web.de
*nix forums beginner


Joined: 09 Feb 2005
Posts: 32

PostPosted: Wed Feb 01, 2006 3:49 pm    Post subject: memory mapped IO: device registers mapped to virtual memory or physical memory? Reply with quote

Hi -

I know memory mapped IO is about mapping device/controller registers to
memory space in order to reduce the number of processor instructions
(and simplify device driver writing) . My question is: are device
registers mapped to virtual memory or physical memory? I suspect the
former, and I have looked up a number of texts but everyone just seems
to skirt about the issue.

Thanks,

- Olumide
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [14 Posts] View previous topic :: View next topic
The time now is Sat Nov 22, 2008 1:38 pm | All times are GMT
navigation Forum index » Programming » Unix internals
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Postfix 2.3.8 Virtual problem Blotto Postfix 0 Fri Apr 04, 2008 6:11 am
No new posts postfix out of memory error - please help metind Postfix 0 Mon Sep 11, 2006 1:54 am
No new posts Non IBM memory in p630 Ron AIX 0 Fri Jul 21, 2006 2:05 pm
No new posts database Share Memory Limit (2 GB ) in a Instance is tota... sadanjan@gmail.com IBM DB2 0 Fri Jul 21, 2006 12:57 pm
No new posts Where is this code not freeing memory ? jithoosin C++ 2 Fri Jul 21, 2006 9:39 am

Best Credit Cards | Loan | Personal Finance | Free Ringtones | Personal Car Finance
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.4102s ][ Queries: 20 (0.2408s) ][ GZIP on - Debug on ]