函数fb_find_logo实现在文件kernel/goldfish/drivers/video/logo/logo.c文件中,如下所示:
- extern const struct linux_logo logo_linux_mono;
- extern const struct linux_logo logo_linux_vga16;
- extern const struct linux_logo logo_linux_clut224;
- extern const struct linux_logo logo_blackfin_vga16;
- extern const struct linux_logo logo_blackfin_clut224;
- extern const struct linux_logo logo_dec_clut224;
- extern const struct linux_logo logo_mac_clut224;
- extern const struct linux_logo logo_parisc_clut224;
- extern const struct linux_logo logo_sgi_clut224;
- extern const struct linux_logo logo_sun_clut224;
- extern const struct linux_logo logo_superh_mono;
- extern const struct linux_logo logo_superh_vga16;
- extern const struct linux_logo logo_superh_clut224;
- extern const struct linux_logo logo_m32r_clut224;
- static int nologo;
- module_param(nologo, bool, 0);
- MODULE_PARM_DESC(nologo, "Disables startup logo");
- /* logo's are marked __initdata. Use __init_refok to tell
- * modpost that it is intended that this function uses data
- * marked __initdata.
- */
- const struct linux_logo * __init_refok fb_find_logo(int depth)
- {
- const struct linux_logo *logo = NULL;
- if (nologo)
- return NULL;
- if (depth >= 1) {
- #ifdef CONFIG_LOGO_LINUX_MONO
- /* Generic Linux logo */
- logo = &logo_linux_mono;
- #endif
- #ifdef CONFIG_LOGO_SUPERH_MONO
- /* SuperH Linux logo */
- logo = &logo_superh_mono;
- #endif
- }
- if (depth >= 4) {
- #ifdef CONFIG_LOGO_LINUX_VGA16
- /* Generic Linux logo */
- logo = &logo_linux_vga16;
- #endif
- #ifdef CONFIG_LOGO_BLACKFIN_VGA16
- /* Blackfin processor logo */
- logo = &logo_blackfin_vga16;
- #endif
- #ifdef CONFIG_LOGO_SUPERH_VGA16
- /* SuperH Linux logo */
- logo = &logo_superh_vga16;
- #endif
- }
- if (depth >= 8) {
- #ifdef CONFIG_LOGO_LINUX_CLUT224
- /* Generic Linux logo */
- logo = &logo_linux_clut224;
- #endif
- #ifdef CONFIG_LOGO_BLACKFIN_CLUT224
- /* Blackfin Linux logo */
- logo = &logo_blackfin_clut224;
- #endif
- #ifdef CONFIG_LOGO_DEC_CLUT224
- /* DEC Linux logo on MIPS/MIPS64 or ALPHA */
- logo = &logo_dec_clut224;
- #endif
- #ifdef CONFIG_LOGO_MAC_CLUT224
- /* Macintosh Linux logo on m68k */
- if (MACH_IS_MAC)
- logo = &logo_mac_clut224;
- #endif
- #ifdef CONFIG_LOGO_PARISC_CLUT224
- /* PA-RISC Linux logo */
- logo = &logo_parisc_clut224;
- #endif
- #ifdef CONFIG_LOGO_SGI_CLUT224
- /* SGI Linux logo on MIPS/MIPS64 and VISWS */
- logo = &logo_sgi_clut224;
- #endif
- #ifdef CONFIG_LOGO_SUN_CLUT224
- /* Sun Linux logo */
- logo = &logo_sun_clut224;
- #endif
- #ifdef CONFIG_LOGO_SUPERH_CLUT224
- /* SuperH Linux logo */
- logo = &logo_superh_clut224;
- #endif
- #ifdef CONFIG_LOGO_M32R_CLUT224
- /* M32R Linux logo */
- logo = &logo_m32r_clut224;
- #endif
- }
- return logo;
- }
- EXPORT_SYMBOL_GPL(fb_find_logo);
文件开始声明的一系列linux_logo结构体变量分别用来保存kernel/goldfish/drivers/video/logo目录下的一系列ppm或者pbm文件的内容的。这些ppm或者pbm文件都是用来描述第一个开机画面的。
全局变量nologo是一个类型为布尔变量的模块参数,它的默认值等于0,表示要显示第一个开机画面。在这种情况下,函数fb_find_logo就会根据参数depth的值以及不同的编译选项来选择第一个开机画面的内容,并且保存在变量logo中返回给调用者。
这一步执行完成之后,第一个开机画面的内容就保存在模块fbmem的全局变量fb_logo的成员变量logo中了。这时候控制台的初始化过程也结束了,接下来系统就会执行切换控制台的操作。前面提到,当系统执行切换控制台的操作的时候,模块fbcon中的函数fbcon_switch就会被调用。在调用的过程中,就会执行显示第一个开机画面的操作。
- static int fbcon_switch(struct vc_data *vc)
- {
- struct fb_info *info, *old_info = NULL;
- struct fbcon_ops *ops;
- struct display *p = &fb_display[vc->vc_num];
- struct fb_var_screeninfo var;
- int i, prev_console, charcnt = 256;
- ......
- if (logo_shown == FBCON_LOGO_DRAW) {
- logo_shown = fg_console;
- /* This is protected above by initmem_freed */
- fb_show_logo(info, ops->rotate);
- ......
- return 0;
- }
- return 1;
- }
由于前面在准备第一个开机画面的内容的时候,全局变量logo_show的值被设置为FBCON_LOGO_DRAW,因此,接下来就会调用函数fb_show_logo来显示第一个开机画面。在显示之前,这个函数会将全局变量logo_shown的值设置为fg_console,后者表示系统当前可见的控制台的编号。
函数fb_show_logo实现在文件kernel/goldfish/drivers/video/fbmem.c中,如下所示:
- int fb_show_logo(struct fb_info *info, int rotate)
- {
- int y;
- y = fb_show_logo_line(info, rotate, fb_logo.logo, 0,
- num_online_cpus());
- ......
- return y;
- }
这个函数调用另外一个函数fb_show_logo_line来进一步执行渲染第一个开机画面的操作。