<html>
<head>
<base href="http://bugzilla.gdcproject.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Add support for attribute to mark data as volatile."
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=126#c16">Comment # 16</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add support for attribute to mark data as volatile."
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=126">bug 126</a>
from <span class="vcard"><a class="email" href="mailto:code@dawg.eu" title="Martin Nowak <code@dawg.eu>"> <span class="fn">Martin Nowak</span></a>
</span></b>
<pre>(In reply to Johannes Pfau from <a href="show_bug.cgi?id=126#c15">comment #15</a>)
<span class="quote">> The classical hello world for these devices is usually blinking a LED
> (<a href="http://www.micahcarrick.com/tutorials/avr-microcontroller-tutorial/getting">http://www.micahcarrick.com/tutorials/avr-microcontroller-tutorial/getting</a>-
> started.html). This usually requires accessing two registers. Now if
> somebody asks us 'How does Hello World look like in D?' and we present a
> small D main function + 10 lines of ASM they'll laugh at us and will
> immediately stop considering D. It's the same for peek/poke.
> </span >
Nope, that would only be in the header/library that defines all those MM I/O
registers. Those "indirections" are used for any embedded programming. For
example in avr-libc you'll find this macro expansion.
GPIOA -> _SFR_MEM8(0x000A) -> _MMIO_BYTE(0x000A) -> (*(volatile uint8_t
*)(mem_addr)).
This expands to volatile, because volatile provides the correct semantics.
But you could as well expand it to some template in D which implements the
correct accesses.
This is what Michael did for ARM [1]. The only problem here is how to implement
volatile reads/writes semantically correct and with as little overhead as
possible. Currently he used shared for reading [2] and writing [3] and those
few places could as well be replaced with intrinsics or asm until intrinsics
are available.
<a href="https://github.com/JinShil/stm32_registers/blob/master/source/stm32/registers/rcc.d">https://github.com/JinShil/stm32_registers/blob/master/source/stm32/registers/rcc.d</a>
<a href="https://github.com/JinShil/memory_mapped_io/blob/d19cefb42000cd06605ddf4d4d6b120670400144/source/mmio.d#L335">https://github.com/JinShil/memory_mapped_io/blob/d19cefb42000cd06605ddf4d4d6b120670400144/source/mmio.d#L335</a>
<a href="https://github.com/JinShil/memory_mapped_io/blob/d19cefb42000cd06605ddf4d4d6b120670400144/source/mmio.d#L402">https://github.com/JinShil/memory_mapped_io/blob/d19cefb42000cd06605ddf4d4d6b120670400144/source/mmio.d#L402</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>