| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
January 10, 2011 Memory mapped IO | ||||
|---|---|---|---|---|
| ||||
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
| ||||
January 10, 2011 Re: Memory mapped IO | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Dan Olson | 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 | |||
January 10, 2011 Re: Memory mapped IO | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad | "Lars T. Kyllingstad" <public@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 | |||
January 10, 2011 Re: Memory mapped IO | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Dan Olson | On Mon, 10 Jan 2011 08:38:15 -0800, Dan Olson wrote: > "Lars T. Kyllingstad" <public@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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply