Hi, John.
Thank's for your advice.
On Thu, Mar 7, 2013 at 12:05 AM, John Meacham
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.
It's good. My application controls memory mapped IO with the patch extern_volatile.patch (attached). But I have more question. Ajhc with your patch outputs hs_main.c file (attached) from Main.hs file (attached). --- In hs_main.c static wptr_t A_STD A_MALLOC fW$__fMain_ledOff(gc_t gc,uint16_t v691543073) { *((uint16_t *)(1207963688 + ((uintptr_t)&jhc_physicalAddress))) = v691543073; return SET_RAW_TAG(CJhc_Prim_Prim_$LR); } -------- It casts &jhc_physicalAddress with uintptr_t. Does it strip the volatile type? If not, extern volatile method resolves my problem perfectly. Thank's. -- Kiwamu Okabe