ARMLinux的启动和初始化代码:vmlinux-init vmlinux-init :=(head-y)(init-y) ●head-y=? 根Makefile中以include的方式包含了arm体系结构相关部分的Makefile #Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. #KBUILD_DEFCONFIG may point out an alternative default configuration used for'make defconfig' include $(srctree)/arch/$(SRCARCH)/Makefile export KBUILD_DEFCONFIG 在这个Makefi1e中 #Default value head-y :arch/arn/kernel/heads(MMUEXT).o arch/arm/kernel/init_task.o textofs-y :=0x00008000 其中,变量MMUEXT的定义如下 defines filename extension depending menory manement type. ifeq (S(CONFIG_MMU).) MMUEXT :=-nommu endif head-nommu.还是head 陈香兰(xlanchenoustc,edu.cn)(升异轧应 长人式锌饰泰统 Novenber 27.2014 15/48
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ARMLinux的启动和初始化代码:vmlinux-init . . vmlinux-init := (head − y)(init-y) .. 1. head-y = ? 根Makefile中以include的方式包含了arm体系结构相关部分的Makefile . . # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. # KBUILD_DEFCONFIG may point out an alternative default configuration # used for ’make defconfig’ include $(srctree)/arch/$(SRCARCH)/Makefile export KBUILD_DEFCONFIG 在这个Makefile中 . . #Default value head-y := arch/arm/kernel/head$(MMUEXT).o arch/arm/kernel/init_task.o textofs-y := 0x00008000 其中,变量MMUEXT的定义如下 . . # defines filename extension depending memory manement type. ifeq ($(CONFIG_MMU),) MMUEXT := -nommu endif head-nommu还是head 陈香兰(xlanchen@ustc.edu.cn) (计算机应用教研室@计算机学院嵌入式系统实验室 嵌入式操作系统 @苏州研究院中国科学技术大学Fall 2014) November 27, 2014 15 / 48
ARMLinux的启动和初始化代码:vmlinux-init vmlinux-init :=(head-y)(init-y) init-y = 在根Makefile中 #Objjects we will link into vmlinux subdirs we need to visit init-y :init/ drivers-y :drivers/sound/ net-y :net/ libs-y :=1ib/ core-y :usr/ 4口4四1是4P,刀00 陈香兰(xlanchenoustc,ed加.cn)(计年丸应 收人式排作系蛇 ovenber27,201415/48
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ARMLinux的启动和初始化代码:vmlinux-init . . vmlinux-init := (head − y)(init-y) .. 2. init-y = ? 在根Makefile中 . . # Objects we will link into vmlinux / subdirs we need to visit init-y := init/ drivers-y := drivers/ sound/ net-y := net/ libs-y := lib/ core-y := usr/ 陈香兰(xlanchen@ustc.edu.cn) (计算机应用教研室@计算机学院嵌入式系统实验室 嵌入式操作系统 @苏州研究院中国科学技术大学Fall 2014) November 27, 2014 15 / 48
为便于阅读,了解关于命令输出的相关内容 并Beautify output 共 # Normally,we echo the whole command before executing it.By making #that echo s(s(quiet)s(cmd)),we now have the possibility to set #S(quiet)to choose other forms of output instead.e.8. #quiet_cmd_cc_o_c Compiling S(RELDIR)/So #cmd_cc_o_c =$(CC)S(c_flags)-c -o Se S If s(quiet)is empty,the whole command will be printed. If it is set to quiet_",only the short version will be printed. If it is set to"silent_",nothing will be printed at all,since the variable $(silent_cmd_cc_o_c)doesn't exist. #A simple variant is to prefix commands with $(Q)-that's useful for commands that shall be hidden in non-verbose mode. #S(Q)In So : If KBUILD_VERBOSE equals 0 then the above command will be hidden. #If KBUILD_VERBOSE equals 1 then the above command is displayed. ifeq (S(KBUILD_VERBOSE).1) quiet Q= else quiet=quiet_ Q=0 endif 陈香兰(xlanchenoustc,edu,cn) (计异机应 长人式样作系蛇 Novenber23.201416/48
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 为便于阅读,了解关于命令输出的相关内容 . . . # Beautify output # ————————————————————————— # # Normally, we echo the whole command before executing it. By making # that echo $($(quiet)$(cmd)), we now have the possibility to set # $(quiet) to choose other forms of output instead, e.g. # # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< # # If $(quiet) is empty, the whole command will be printed. # If it is set to ”quiet_”, only the short version will be printed. # If it is set to ”silent_”, nothing will be printed at all, since # the variable $(silent_cmd_cc_o_c) doesn’t exist. # # A simple variant is to prefix commands with $(Q) - that’s useful # for commands that shall be hidden in non-verbose mode. # # $(Q)ln $@ :< # # If KBUILD_VERBOSE equals 0 then the above command will be hidden. # If KBUILD_VERBOSE equals 1 then the above command is displayed. ifeq ($(KBUILD_VERBOSE),1) quiet = Q = else quiet=quiet_ Q = @ endif 陈香兰(xlanchen@ustc.edu.cn) (计算机应用教研室@计算机学院嵌入式系统实验室 嵌入式操作系统 @苏州研究院中国科学技术大学Fall 2014) November 27, 2014 16 / 48
考虑体系结构相关的产物1 ●我们已经知道vmlinux是如何生成的,下面看看体系结构 相关的产物,例如z Image是如何生成的? o make <default>,OR make zImage,OR o在arch/arm/Makefile中 1口4四1是42刀00 陈香兰(xlanchenoustc,edu,cn)(升界丸应 长人式操作香统 ovenber27,201417/48
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 考虑体系结构相关的产物 I 我们已经知道vmlinux是如何生成的,下面看看体系结构 相关的产物,例如zImage是如何生成的? make <default>, OR make zImage, OR ... 在arch/arm/Makefile中 陈香兰(xlanchen@ustc.edu.cn) (计算机应用教研室@计算机学院嵌入式系统实验室 嵌入式操作系统 @苏州研究院中国科学技术大学Fall 2014) November 27, 2014 17 / 48
考虑体系结构相关的产物II Default target when executing plain make ifeq (S(CONFIG_XIP_KERNEL).y) KBUILD_IMAGE :xipImage else KBUILD_IMAGE :zImage endif a11:S(KBUILD_IMAGE) Convert bzImage to zImage bzImage:zImage zImage Image xipImage bootpImage ulmage:vmlinux S(Q)S(MAKE)$(build)=S(boot)MACHINE=S(MACHINE)$(boot)/Se zinstall install:vmlinux S(Q)S(MAKE)$(build)=$(boot)MACHINE=S(MACHINE)$0 ·z代表压缩;b代表大内核 对于arm,没有大小内核之分 4口4四1是14P刀00 陈香兰(xlanchenoustc,edu,cn)(计界轧应 长人式样饰系统 ovenber27,201418/48
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 考虑体系结构相关的产物 II . . ... # Default target when executing plain make ifeq ($(CONFIG_XIP_KERNEL),y) KBUILD_IMAGE := xipImage else KBUILD_IMAGE := zImage endif all: $(KBUILD_IMAGE) ... # Convert bzImage to zImage bzImage: zImage zImage Image xipImage bootpImage uImage: vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ zinstall install: vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ ▶ z代表压缩;b代表大内核 ▶ 对于arm,没有大小内核之分 陈香兰(xlanchen@ustc.edu.cn) (计算机应用教研室@计算机学院嵌入式系统实验室 嵌入式操作系统 @苏州研究院中国科学技术大学Fall 2014) November 27, 2014 18 / 48