rtems-CVS-050303 i.MX/MX1/csb336 BUG and BUGFIX
Ralf Corsepius
ralf.corsepius at rtems.org
Fri Mar 4 05:15:47 UTC 2005
On Fri, 2005-03-04 at 01:58 +0100, Pavel Pisa wrote:
> Hello Joel and all others,
>
> there has been introduced bug into bsp_vector_table definition.
Well, I agree, you are right, there is a new bug, but ... I think this
bug only exposes another, more severe bug in all arm BSPs :(
> It has been changed to "rtems_irq_hdl bsp_vector_table;".
> This means, that ldscript declares address of variable
> of the function pointer type.
> This is than silently casted from (rtems_irq_hdl) to (rtems_irq_hdl*)
> aka (long*) in
>
> rtems/c/src/lib/libbsp/arm/shared/irq/irq_init.c:rtems_irq_mngt_init()
> vectorTable = (long *) VECTOR_TABLE;
This code is plain wrong.
> and uninitialized memory contents is used as base address for the vector table
>
> /* Initialize the vector table contents with default handler */
> for (i=0; i<BSP_MAX_INT; i++)
> *(vectorTable + i) = (long)(default_int_handler);
Worse, this code probably is non functionial.
I think,
volatile rtems_irq_hdl* vectorTable
is required, because as far as I understand the this code is supposed to
initialize hardware addresses.
> Next oneliner patch solves described problem
>
> ---------------------------------------------------------------------------------------------
> diff --minimal -r -u -P -p rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h.orig rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h
> --- rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h.orig 2005-03-04 00:57:56.000000000 +0100
> +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h 2005-03-04 01:00:05.000000000 +0100
> @@ -114,7 +114,7 @@ typedef void (*rtems_irq_enable) (con
> typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*);
> typedef int (*rtems_irq_is_enabled)(const struct __rtems_irq_connect_data__*);
>
> -extern rtems_irq_hdl bsp_vector_table;
> +extern rtems_irq_hdl bsp_vector_table[BSP_MAX_INT];
> #define VECTOR_TABLE bsp_vector_table
>
> typedef struct __rtems_irq_connect_data__ {
I'd assume bsp_vector_table should be volatile, too.
> ---------------------------------------------------------------------------------------------
>
> But I have big problem to analyze and find this hidden bug.
Me thinks, this code needs to be redesigned - :(
Ralf
More information about the users
mailing list