[En-Nut-Discussion] Nut/OS Initialization
Thiago A. Corrêa
thiago.correa at gmail.com
Wed Sep 17 16:34:58 CEST 2008
On Wed, Sep 17, 2008 at 5:59 AM, Ole Reinhardt
<ole.reinhardt at embedded-it.de> wrote:
> Hi Harald,
>
>> > 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.
>>
>> I understand the data structure and how it forces the linker to include
>> the driver. But I do not understand, how the program code becomes aware
>> of this structure to make use of the specified routines. In other words:
>> How does the initialization code know that TRIZEPS4 exists and that it
>> can call trizeps4_init() via (*init_machine)()?
>
> I'll examine this mechanism futher on friday. Today and tomorrow I won't
> be in office and will have to do some service work at some customers...
>
> But in general this kind of glue logic is used in several places in the
> linux kernel and allows you quite nice driver design.
>
I'm no kernel hacker, but I guess this is more for modules. At least
ARMs and other embedded platforms have a board specific code under
arch that does PIN and IRQ reservations and registers hardware,
passing structs. In that regards, it's no different from Ethernut.
Regards,
Thiago A. Correa
More information about the En-Nut-Discussion
mailing list