This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about HAL_IO_BARRIER() macro?


hal_io.h says:

//-----------------------------------------------------------------------------
// Enforce in-order IO for all HAL reads/writes using this macro.
#define HAL_IO_BARRIER()                        \
    asm volatile ( "" : : : "memory" )

Basically, the compiler can rearrange the order insturctions are
executed in if it makes the code more optimal. This can have bad
effects on IO code which requires that actions happen in order. This
macro tells the compiler it must finish all actions before this
barrier point before doing any actions that follow that point.

        Andrew


On Fri, Sep 20, 2002 at 02:30:16PM +0100, Qiang Huang wrote:
> Hi all:
>      Does anyone know what is 
> 
> #define HAL_IO_BARRIER()       asm volatile ( "" : : : "memory" )
> 
> used for (Is this necessary?)?
> 
> When accessing the register value as following:
> 
> #define HAL_READ_UINT8( _register_, _value_ )           \
>     CYG_MACRO_START                                     \
>     ((_value_) = *((volatile CYG_BYTE *)(_register_))); \
>     HAL_IO_BARRIER ();                                  \
>     CYG_MACRO_END
> 
> how does HAL_IO_BARRIER() works here?
> 
> BTW what's the "memory" in HAL_IO_BARRIER stands for?
> 
> Thanks a lot.
> 
> 
> -- 
> Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
> and search the list archive: http://sources.redhat.com/ml/ecos-discuss
> 

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]