您的当前位置:首页正文

内核

2020-08-11 来源:钮旅网
内核菜单构建过程顶层Makefile中关键代码ARCH=armSRCARCH=$ARCHconfig %config: scripts_basic outputmakefile FORCE$(Q)mkdir -p include/linux include/config$(Q)$(MAKE) $(build)=scripts/kconfig $@

make menuconfigmake s3c2410_defconfigScripts/kconfig/MakefileKconfig := arch/$(SRCARCH)/Kconfigmenuconfig: $(obj)/mconf$< $(Kconfig)

%_defconfig: $(obj)/conf$(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)

mconf arch/$(SRCARCH)/Kconfigconfig 生成菜单项menu/endmenu 生成菜单

choice/endchoice 同一类选项单选或多选source 导入次级菜单编译过程顶层Makefileall: vmlinuxvmlinux-init := $(head-y) $(init-y)vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)vmlinux-all := $(vmlinux-init) $(vmlinux-main)Vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.ldsVmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCEmodpost-init := $(filter-out init/built-in.o, $(vmlinux-init))vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE$(call if_changed_rule,vmlinux-modpost)$(obj)/zImage:$(obj)/compressed/vmlinux FORCE

$(call if_changed,objcopy)@echo ' Kernel: $@ is ready'arch/arm/MakefileHEAD= head.oOBJS= misc.o$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \\ $(addprefix $(obj)/, $(OBJS)) FORCE$(call if_changed,ld)@:$(obj)/piggy.gz: $(obj)/../Image FORCE$(call if_changed,gzip)$(obj)/piggy.o: $(obj)/piggy.gz FORCE$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile .config@sed \"$(SEDFLAGS)\" < $< > $@arch/arm/compressed/Makefilearch/arm/kernel/MakefileHead-y := head$(MMUEXT).oextra-y := $(head-y) init_task.o vmlinux.lds内核启动流程开始执行内核arch/arm/boot/compressed/head.Sbldecompress_kernelbcall_kernel解压内核并跳到真正的内核执行处理器校验arch/arm/kernel/head.smrcp15, 0, r9, c0, c0bl__lookup_processor_typmovsr10, r5beq__error_p@error p内核停止运行bl__lookup_machine_typemovsr8, r5beq__error_a@error a 内核停止运行bladr__create_page_tableslr, __enable_mmu平台校验初始化页表MMUinit/main.cstart_kernelsetup_mechine获得mdescphys_to_virt(mdes->boot_params)setup_archreset_initkernel_initmtd/ubimount_block_root系统运行prepare_namespacenfsRun_init_process/sbin/init/etc/init/bin/init/bin/shrun_init_process(Execute_command)name_to_dev_tmount_rootMount_nfs_rootsys_open(console)do_mount_rootinit_postsys_mountsys_chroot

因篇幅问题不能全部显示,请点此查看更多更全内容