[U-Boot] what is the purpose of the "init_f" function pointer in struct post_test?

Robert P. J. Day rpjday at crashcourse.ca
Mon Mar 28 13:18:09 CEST 2016


  continuing my journey through u-boot POST code, and i can see the
"init_f" function pointer here:

struct post_test {
        char *name;
        char *cmd;
        char *desc;
        int flags;
        int (*test) (int flags);
        int (*init_f) (void);     <-----
        void (*reloc) (void);
        unsigned long testid;
};

but what *specific* issue was it introduced to solve?

  i can see over in common/board_f.c the sequence of init routines,
including this snippet:


#if defined(CONFIG_ARM) || defined(CONFIG_X86) ||
defined(CONFIG_NDS32) || \
                defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32)
        dram_init,              /* configure available RAM banks */
#endif
#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) ||
defined(CONFIG_M68K)
        init_func_ram,
#endif
#ifdef CONFIG_POST
        post_init_f,        <-----
#endif
        INIT_FUNC_WATCHDOG_RESET
#if defined(CONFIG_SYS_DRAM_TEST)
        testdram,
#endif /* CONFIG_SYS_DRAM_TEST */
        INIT_FUNC_WATCHDOG_RESET

#ifdef CONFIG_POST
        init_post,
#endif


so, first, it seems clear that those callbacks are meant to be invoked
immediately after configuring RAM but before testing it. and over in
post/post.c, we have:


int post_init_f(void)
{
        int res = 0;
        unsigned int i;

        for (i = 0; i < post_list_size; i++) {
                struct post_test *test = post_list + i;

                if (test->init_f && test->init_f())
                        res = -1;
        }

        gd->post_init_f_time = post_time_ms(0);
        if (!gd->post_init_f_time)
                printf("%s: post_time_ms not implemented\n", __FILE__);

        return res;
}


so if any tests have that pointer set, the corresponding routine will
be invoked.

  so i can see that the post_init_f() routine is useful for setting
the start time of these tests (if, in fact, there are any), but i'm
still unclear on the value of allowing POST tests to register a
routine to be invoked at *precisely* that point in the startup.

  what is so magical about allowing POST test routines at that exact
point?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================





More information about the U-Boot mailing list