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: static constructors in HAL startup


On Tue, 2003-12-30 at 18:29, james_maxwell wrote:
> Dear Friends,
> 
> I am trying to bring the Redboot to my Samsung SND100 board. 
> However, I found the system always get stuck at the function 
> call, cyg_hal_invoke_constructors().
> 
> I am wondering if someone can tell me where I can get further 
> information to resolve this ?
> Or, if someone can tell me what is the purpose of this function call ?

The purpose of the call is to enumerate the static C++ constructors
used by the eCos program.  This is a list of functions which has 
been created by the linker.  The routine is normally found in
the architecture file hal/ARCHITECTURE/arch/current/src/hal_misc.c

For example, the version from the PowerPC architecture looks like
this:

  typedef void (*pfunc) (void);
  extern pfunc __CTOR_LIST__[];
  extern pfunc __CTOR_END__[];

  void
  cyg_hal_invoke_constructors (void)
  {
  #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
      static pfunc *p = &__CTOR_END__[-1];
      
      cyg_hal_stop_constructors = 0;
      for (; p >= __CTOR_LIST__; p--) {
          (*p) ();
          if (cyg_hal_stop_constructors) {
              p--;
              break;
          }
      }
  #else
      pfunc *p;

      for (p = &__CTOR_END__[-1]; p >= __CTOR_LIST__; p--) {
  #ifdef DEBUG_CONSTRUCTORS
          diag_printf("Calling %p[%p]\n", *p, p);
  #endif
          (*p) ();
      }
  #endif
  }

Whenever I have problems or questions about this routine, I would
add a print statement to tell me what's going on, as shown above.

Common problems with this are:
  * The CTOR list is not created properly (linker problem)
  * The routines called fail


-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates


-- 
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]