Re: Memory mapped IO

2011-01-10 Thread Lars T. Kyllingstad
On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:

 I'm exploring D for embedded work as a nice alternative to C/C++ for the
 32-bitters and am finding it has a nice set of features.  But, what is
 the best way handle memory mapped IO?  I don't see volatile like in C.
 Is writing asm {} the best way to ensure memory access?
 
 Thanks,
 Dan Olson

Would std.mmfile be what you need?

http://www.digitalmars.com/d/2.0/phobos/std_mmfile.html

-Lars


Re: Memory mapped IO

2011-01-10 Thread Dan Olson
Lars T. Kyllingstad pub...@kyllingen.nospamnet writes:

 On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:

 I'm exploring D for embedded work as a nice alternative to C/C++ for the
 32-bitters and am finding it has a nice set of features.  But, what is
 the best way handle memory mapped IO?  I don't see volatile like in C.
 Is writing asm {} the best way to ensure memory access?
 
 Thanks,
 Dan Olson

 Would std.mmfile be what you need?

 http://www.digitalmars.com/d/2.0/phobos/std_mmfile.html

 -Lars

Ok, thanks.  So I see that is a wrapper for mmap.  So that would be good
for user space code running on top of posix or win32.  But...

I'm more interested in the general embedded case with a small OS or no
OS (just ISRs and main loop).  I'm betting without volatile, asm {} is
the next best thing for tickling a controllers peripheral registers? Yes/No?

I searched the news groups and saw there used to be a volatile.  But it
looks like it was done away with because of how it was misused (like C
volatile) for thread sharing.  But this is different.  This is just
telling the compiler not to optimize away an access.

-- 
Dan Olson



Re: Memory mapped IO

2011-01-10 Thread Lars T. Kyllingstad
On Mon, 10 Jan 2011 08:38:15 -0800, Dan Olson wrote:

 Lars T. Kyllingstad pub...@kyllingen.nospamnet writes:
 
 On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:

 I'm exploring D for embedded work as a nice alternative to C/C++ for
 the 32-bitters and am finding it has a nice set of features.  But,
 what is the best way handle memory mapped IO?  I don't see volatile
 like in C. Is writing asm {} the best way to ensure memory access?
 
 Thanks,
 Dan Olson

 Would std.mmfile be what you need?

 http://www.digitalmars.com/d/2.0/phobos/std_mmfile.html

 -Lars
 
 Ok, thanks.  So I see that is a wrapper for mmap.  So that would be good
 for user space code running on top of posix or win32.  But...

Ah, I should have read your post more closely.  I just saw memory mapped 
IO and latched onto that. :)


 I'm more interested in the general embedded case with a small OS or no
 OS (just ISRs and main loop).  I'm betting without volatile, asm {} is
 the next best thing for tickling a controllers peripheral registers?
 Yes/No?
 
 I searched the news groups and saw there used to be a volatile.  But it
 looks like it was done away with because of how it was misused (like C
 volatile) for thread sharing.  But this is different.  This is just
 telling the compiler not to optimize away an access.

AFAIK, that's right.  The compiler does not optimise across asm {} blocks.

-Lars


Memory mapped IO

2011-01-09 Thread Dan Olson
I'm exploring D for embedded work as a nice alternative to C/C++ for the
32-bitters and am finding it has a nice set of features.  But, what is
the best way handle memory mapped IO?  I don't see volatile like in C.
Is writing asm {} the best way to ensure memory access?

Thanks,
Dan Olson