[En-Nut-Discussion] Nut/OS Initialization

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue Sep 16 09:30:10 CEST 2008


Hi Harald,

> As more complex devices are added, the main() routine becomes 
> contaminated with system specific code.
> 
> One suggested solution would be to implement a callback function like 
> HardwareInit(), which has to be included into the application 
> "somewhere". IMHO, this is not more elegant than simply calling 
> HardwareInit() at the beginning of main.

Why not implement some board initialisation like it is done for most
other OSes and bootloaders?

For example u-boot and linux both use a board definition file where all
this very low level hardware initialisation stuff is done.

For example in linux this is done by filling up a struct like this one

MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
        /* MAINTAINER("Jürgen Schindele") */
        .phys_io        = 0x40000000,
        .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
        .boot_params    = TRIZEPS4_SDRAM_BASE + 0x100,
        .init_machine   = trizeps4_init,
        .map_io         = trizeps4_map_io,
        .init_irq       = pxa_init_irq,
        .timer          = &pxa_timer,
MACHINE_END

and linking it with the application. Right now I don't know the _exact_
mechanism, but I should not be that complicate.

This will allow you to define several configuration options and to
register the init functions. If the application won't provide this
struct we could have a standard board definition / startup function for
at least the controller specific hardware.

So this approach is quite similar to what you suggested, but quite
extensible and not limited to a function call.

Bye,

Ole

-- 
 _____________________________________________________________
|                                                             |
| Embedded-IT          Hard- und Softwarelösungen             |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|                      UstID / VAT:       DE198944716         |
|_____________________________________________________________|




More information about the En-Nut-Discussion mailing list