Looking at the definition of CYG_HAL_TABLE_TYPE and CYG_HAL_TABLE_BEGIN,
I see that the CYG_HAL_TABLE_BEGIN uses an alignment of
CYGARC_P2ALIGNMENT and the CYG_HAL_TABLE_TYPE uses an alignment of
CYGARC_ALIGNMENT.
For the ARM architecture, these are defined to be different
(CYGARC_P2ALIGNMENT is 2 and CYGARC_ALIGNMENT is 4). This would result
in the table label being 4 byte aligned and the elements 16 byte aligned.
The question is why has this not caused me problems before this?
Jay
On 1/20/2011 9:30 AM, Jay Foster wrote:
I have used the CYG_HAL_TABLE mechanism before with success, but I am
now running into an alignment problem with a new application. This is
on an ARM architecture.
I have an object defined as:
typedef struct
{
....
} CYG_HAL_TABLE_TYPE MY_TYPE;
I then declare the HAL table array as:
CYG_HAL_TABLE_BEGIN( _MY_LABEL_, _my_name_ );
CYG_HAL_TABLE_END( _MY_LABEL_END_, _my_name_ );
I then place two instances of the object into the HAL table array:
MY_TYPE my_instance1 CYG_HAL_TABLE_QUALIFIED_ENTRY(_my_name_, 2) =
{
....
};
MY_TYPE my_instance2 CYG_HAL_TABLE_QUALIFIED_ENTRY(_my_name_, 3) =
{
....
};
I then iterate the table using:
MY_TYPE *p;
for (p=&(_MY_LABEL_[0]); p!=&(_MY_LABEL_END_); p++)
{
}
This fails due to alignment issues:
The _MY_LABEL_ is not at the same address as the first element in
the array (my_instance1) due to alignment issues. The iteration then
fails. _MY_LABEL_ is aligned on a 4 byte boundary and the array
elements are aligned on 16 byte boundaries. Is there any way to make
this work?
Jay
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss