哪沒有輸出vesafb信息,是在那一步中斷的呢?逐步跟蹤,終於眼前一亮: if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB) return -ENODEV; 據我所知,screen_info是與「vga=」參數有密切關係的!查看VIDEO_TYPE_VLFB定義 #define VIDEO_TYPE_VLFB 0x23 /* VESA VGA in graphic mode */ 正是想要的。
進一步驗證,screen_info的元素orig_video_isVGA位於距起點「0x0f」處。繼續往回找, 有screen_info = SCREEN_INFO; 而 #define PARAM (boot_params) #define SCREEN_INFO (*(struct screen_info *) (PARAM+0)) 在/arch/i386/kernel/head.s文件中找到這麼一段 /* * Copy bootup parameters out of the way. * Note: %esi still has the pointer to the real-mode data. * With the kexec as boot loader, parameter segment might be loaded beyond * kernel image and might not even be addressable by early boot page tables. * (kexec on panic case). Hence copy out the parameters before initializing * page tables. */ movl $(boot_params - __PAGE_OFFSET),%edi movl $(PARAM_SIZE/4),%ecx cld rep movsl 註釋意思說,將啟動參數拷貝到boot_params指向的地方。在vedio.s中,有相關代碼處理vesa驅動。 mopar_gr: leaw modelist+1024, %di movb $0x23, %fs:(PARAM_HAVE_VGA) 。。。。。。 而PARAM_HAVE_VGA定義為 #define PARAM_HAVE_VGA 0x0f
這裡說明一點,「vga=」參數由grub處理,處理結果放在內核文件vmlinuz的頭部的vidmode處。 linux啟動開始,讀取該值 movw %fs:(0x01fa), %ax # User selected video mode cmpw $ASK_VGA, %ax # Bring up the menu jz vid2 call mode_set # Set the mode 這裡%fs:(0x01fa)就是引用內核映像中vidmode處 內核頭部在bootsect.s中能看到 .org 497 setup_sects: .byte SETUPSECTS root_flags: .word ROOT_RDONLY syssize: .word SYSSIZE swap_dev: .word SWAP_DEV ram_size: .word RAMDISK vid_mode: .word SVGA_MODE root_dev: .word ROOT_DEV boot_flag: .word 0xAA55