[jhc] [BUG] Poke should use volatile.

Kiwamu Okabe kiwamu at gmail.com
Thu Mar 7 07:07:09 CET 2013


Hi John.

On Thu, Mar 7, 2013 at 7:59 AM, John Meacham <john at repetae.net> wrote:
> include the attached header file and add the arm-addresses.lds file to
> the gcc or ld command line. Then you can foreign import the pointers.
>
> If you can verify this works then I can implement it as part of the
> ForeignData proposal with a volatile extension and have the compiler
> automatically take these steps.
>
> http://hackage.haskell.org/trac/haskell-prime/wiki/ForeignData
>
> so if you do this
> foreign import "volatile &periphBase" periphBase :: Ptr a = 0x40000000
>
> it will automatically create the appropriate header and lds entries.

I tried this method and running test is green.
But I have some question on C code outputted with Ajhc.
Is it correct to cast volatile pointer with (uint16_t *)?

--- hs_main.c
static wptr_t A_STD A_MALLOC
fW$__fMain_ledOff(gc_t gc,uint16_t v1167729185)
{
        *((uint16_t *)((uintptr_t)&jhc_phys_brrPtr)) = v1167729185;
        return SET_RAW_TAG(CJhc_Prim_Prim_$LR);
}
---------

I have same success result running with below C header.

--- stm32f3-discovery/jhc_custom/rts/jhc_rts_header.h
extern void jhc_phys_brrPtr;
extern void jhc_phys_bsrrPtr; // without volatile
-------

Best regards,
--
Kiwamu Okabe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: use_lds.patch
Type: application/octet-stream
Size: 1842 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/jhc/attachments/20130307/02f0499d/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hs_main.c
Type: text/x-csrc
Size: 23088 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/jhc/attachments/20130307/02f0499d/attachment-0001.c>


More information about the jhc mailing list