[jhc] [BUG] Poke should use volatile.
john at repetae.net
Wed Mar 6 16:05:52 CET 2013
On Wed, Mar 6, 2013 at 6:43 AM, Kiwamu Okabe <kiwamu at gmail.com> wrote:
> How do I write the code with extern volatile style?
As a quick test that won't require modifying jhc, add
extern volatile void physicalAddress;
to your rts header
and compile adding the flag "-Wl,--defsym=physicalAddress=0"
then in your haskell code where you want to do hardware register access do
foreign import "&physicalAddress" physicalAddress :: Ptr Word32
and use physicalAddress instead of nullPtr in your code as the base,
by going through the volatile physicalAddress it will know not to
optimize it away, whereas it knows that 'nullPtr' is actually zero
which is why it was causing issues. So you would have
periphBase = physicalAddress `plusPtr` 0x40000000
then you won't have to modify the poke and peek primitives.
More information about the jhc