Linux内核源代码导读.ppt
- 格式:ppt
- 大小:1.64 MB
- 文档页数:28
4.1 实模式setup阶段setup用于体系结构相关的硬件初始化工作,在arch目录中的各个系统结构的平台相关都有类似功能的代码。
在32位的x86平台中,setup的入口点是arch/x86/boot/header.S 中的_start。
代码片段 4.1.节自arch/x86/boot/header.S1 .code162 section ".bstext", "ax"34 .global bootsect_start5 bootsect_start:67 # Normalize the start address8 ljmp $BOOTSEG, $start2910 start2:11 movw %cs, %ax12 movw %ax, %ds13 movw %ax, %es14 movw %ax, %ss15 xorw %sp, %sp16 sti17 cld1819 movw $bugger_off_msg, %si2021 msg_loop:22 lodsb23 andb %al, %al24 jz bs_die25 movb $0xe, %ah26 movw $7, %bx27 int $0x1028 jmp msg_loop29 .......30 .section ".bsdata", "a"31 bugger_off_msg:32 .ascii "Direct booting from floppy is no longer supported\r\n"33 .ascii "Please use a boot loader program instead.\r\n"34 .ascii "\n"35 .ascii "Remove disk and press any key to reboot . . .\r\n"3738 .section ".header", "a"3940 .globl hdr41 hdr:42 setup_sects: .byte SETUPSECTS43 root_flags: .word ROOT_RDONLY44 syssize: .long SYSSIZE45 ram_size: .word RAMDISK46 vid_mode: .word SVGA_MODE47 root_dev: .word ROOT_DEV48 boot_flag: .word 0xAA554950 # offset 512, entry point51 .globl _start52 _start:53 # Explicitly enter this as bytes, or the assembler54 # tries to generate a 3-byte jump here, which causes55 # everything else to push off to the wrong offset.56 .byte 0xeb # short (2-byte) jump57 .byte start_of_setup-1f58 1:59 ......60 code32_start: # here loaders can put a different61 # start address for 32-bit code.62 #ifndef __BIG_KERNEL__63 .long 0x1000 # 0x1000 = default for zImage64 #else65 .long 0x100000 # 0x100000 = default for big kernel66 #endif从第48行可以看出,第一个引导扇区以0x55AA 结尾,现在的内核都需要由Boot Loader 来加载。