[En-Nut-Discussion] Nut/OS Initialization

Nathan Moore nategoose at gmail.com
Wed Sep 17 18:14:51 CEST 2008


On Wed, Sep 17, 2008 at 11:09 AM, Alain M. <alainm at pobox.com> wrote:

>
> Thiago A. Corrêa escreveu:
> > I don't know exactly how this is implemented in the C code, but we
> > could use this approach to remove the hardware init from main.
> > If some void hardwareInit() is provided, then it will be called before
> main (?)
>
> That is against C rules. So I vote against it :(


How is this against C rules?  Lots of stuff typically happens before main is
called in programs.
Under linux _init is the standard entry point for a program, and it loads
ld.so which is responsible
for loading any other libraries that the program needs before main is ever
called.  There is also a
test for static and/or global class constructor calls (even if the app isn't
C++, objective C, or other
OO language) that happens before main is called.
This isn't unlike the preparation that main() would need to come up.
Also, nut/os's main already does break the rules since it doesn't get argc
and argv and main can't
return in Nut/Os.
Having an user definable hardware init that gets called before threads are
enabled seems like a good
thing to me.  In other embedded OSes it's common for the first code that
runs to be code that wasn't
written by the OS vendor, but since Nut/Os is ~vended~ by the producer of
the boards that it is
intended to run on the current init is done by code that is in the OS
distribution.

Nathan



More information about the En-Nut-Discussion mailing list