Changing Printk behavior with early_printk enabled

Usually printkdoes not print messages before console_initthat are present in start_kernel. But with it on, it early_printk printkstarts to print messages before the console is initialized. Now, how has this behavior changed printksince I am still using the function printkto print debug messages, not early_printk. How is this mapping performed?

+4
source share
1 answer

This is not really a display. When the option is early_printkturned on, the same one is printk()used as before, in this case only the new boot console is registered, and printk()uses it in the early stages of loading.

Take a look at arch / arm / kernel / early_printk.c . You can see that:

  • new console registered by function register_console()
  • this console has a flag CON_BOOT, so it is automatically registered as soon as the real console is registered.
  • printing is performed using a function early_write(), which, in turn, uses a function printch()that is implemented for each platform separately

Where in the kernel source code is early_consoledisabled after initialization of the kernel console?

register_console():

if (bcon &&
    ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) &&
    !keep_bootcon) {
        /* We need to iterate through all boot consoles, to make
         * sure we print everything out, before we unregister them.
         */
         for_each_console(bcon)
             if (bcon->flags & CON_BOOT)
                 unregister_console(bcon);
}

unregister_console() ( ).

?

- register_console(). :

?

. , , .

, , , . , .config *_defconfig . , .

- , register_console(), , , .

+2

Source: https://habr.com/ru/post/1666708/


All Articles