ARM bare-metal programming in D (cont) - volatile

Russel Winder russel at winder.org.uk
Sun Oct 27 02:12:09 PDT 2013


On Sat, 2013-10-26 at 14:49 +0200, Timo Sintonen wrote:
[…]
> A little bit sad that the honored leader of the language still 
> thinks that the right way to go is what we did with Commodore 
> 64...

Not a good style of argument, since the way of the Commodore 64 might be
a good one. It isn't, but it might have been.

The core problem with peek and poke for writing device drivers is that
hardware controllers do not just use byte structured memory for things,
they use bit structures.

So for data I/O, 

	device->buffer = value
	value = device->buffer

can be replaced easily with:

	poke(device->buffer, value)
	value = peek(device->buffer)

but this doesn't work when you are using bitfields, you end up having to
do all the ugly bit mask manipulation explicitly. Thus, what the
equivalent of:

	device->csw.enable = 1
	status = device->csw.ready

is, is left to the imagination.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



More information about the Digitalmars-d mailing list