<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 淺談分析Arm linux 內(nèi)核移植及系統(tǒng)初始化的過程一

          淺談分析Arm linux 內(nèi)核移植及系統(tǒng)初始化的過程一

          作者: 時間:2016-11-09 來源:網(wǎng)絡(luò) 收藏
          學習嵌入式ARMlinux,主要想必三個方向發(fā)展:

          1、嵌入式linux應(yīng)用軟件開發(fā)
          2、linux內(nèi)核的剪裁和移植
          3、嵌入式linux底層驅(qū)動的開發(fā)
          主 要介紹內(nèi)核移植過程中涉及文件的分布及其用途,以及簡單介紹系統(tǒng)的初始化過程。整個armlinux內(nèi)核的啟動可分為三個階段:第一階段主要是進行 cpu和體系結(jié)構(gòu)的檢查、cpu本身的初始化以及頁表的建立等;第二階段主要是對系統(tǒng)中的一些基礎(chǔ)設(shè)施進行初始化;最后則是更高層次的初始化,如根設(shè)備和 外部設(shè)備的初始化。了解系統(tǒng)的初始化過程,有益于更好地移植內(nèi)核。
          1. 內(nèi)核移植

          本文引用地址:http://www.ex-cimer.com/article/201611/318025.htm

          2. 涉及文件分布介紹
          2.1. 內(nèi)核移植

          2.2. 涉及的頭文件
          /linux-2.6.18.8/include
          [root@localhostinclude]#tree-L1
          .
          |--Kbuild
          |--acpi
          |--asm->asm-arm
          |--asm-alpha
          |--asm-arm------------------------------->(1)
          |--asm-sparc
          |--asm-sparc64
          |--config
          |--keys
          |--linux ------------------------------->(2)
          |--math-emu
          |--media
          |--mtd
          |--net
          |--pcmcia
          |--rdma
          |--rxrpc
          |--scsi
          |--sound
          `--video
          內(nèi)核移植過程中涉及到的頭文件包括處理器相關(guān)的頭文件(1)和處理器無關(guān)的頭文件(2)。
          2.3. 內(nèi)核移植2.4. 涉及的源文件
          /linux-2.6.18.8/arch/arm
          [root@localhostarm]#tree-L1
          .
          |--Kconfig
          |--Kconfig-nommu
          |--Kconfig.debug
          |--Makefile
          |--boot------------------------------->(2)
          |--common
          |--configs
          |--kernel------------------------------->(3)
          |--lib
          |--mach-at91rm9200
          ……
          |--mach-omap1
          |--mach-omap2
          |--mach-realview
          |--mach-rpc
          |--mach-s3c2410------------------------------->(4)
          |--mach-sa1100
          |--mach-versatile
          |--mm------------------------------->(5)
          |--nwfpe
          |--oprofile
          |--plat-omap
          |--tools------------------------------->(1)
          `--vfp
          (1)
          /linux-2.6.18.8/arch/arm/tools
          [root@localhosttools]#tree-L1
          .
          |--Makefile
          |--gen-mach-types
          `--mach-types
          Mach-types文件定義了不同系統(tǒng)平臺的系統(tǒng)平臺號。移植linux內(nèi)核到新的平臺上需要對新的平臺登記系統(tǒng)平臺號。
          Mach-types文件格式如下:
          #machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
          s3c2410 ARCH_S3C2410 S3C2410 182
          smdk2410 ARCH_SMDK2410 SMDK2410 193
          之 所以需要這些信息,是因為腳本文件linux/arch/arm/tools/gen-mach-types需要linux/arch/tools /mach-types來產(chǎn)生linux/include/asm-arm/mach-types.h文件,該文件中設(shè)置了一些宏定義,需要這些宏定義來 為目標系統(tǒng)選擇合適的代碼。
          (2)
          linux-2.6.18.8/arch/arm/boot/compressed
          [root@localhostcompressed]#tree-L1
          .
          |--Makefile
          |--Makefile.debug
          |--big-endian.S
          |--head-at91rm9200.S

          2淺談分析Arm linux 內(nèi)核移植及系統(tǒng)初始化的過程
          |--head.S
          |--ll_char_wr.S
          |--misc.c
          |--ofw-shark.c
          |--piggy.S
          `--vmlinux.lds.in
          Head.s是 內(nèi)核映像的入口代碼,是自引導程序。自引導程序包含一些初始化程序,這些程序都是體系結(jié)構(gòu)相關(guān)的。在對系統(tǒng)作完初始化設(shè)置工作后,調(diào)用misc.c文件中 的decompress_kernel()函數(shù)解壓縮內(nèi)核映像到指定的位置,然后跳轉(zhuǎn)到kernel的入口地址。
          Vmlinux.lds.in用來生成內(nèi)核映像的內(nèi)存配置文件。
          (3)
          linux-2.6.18.8/arch/arm/kernel
          [root@localhostkernel]#tree-L1
          .
          |--Makefile
          |--apm.c
          |--armksyms.c
          |--arthur.c
          |--asm-offsets.c
          |--bios32.c
          |--calls.S
          |--dma.c
          |--ecard.c
          |--entry-armv.S
          |--entry-common.S
          |--entry-header.S
          |--fiq.c
          |--head-common.S
          |--head-nommu.S
          |--head.S
          |--init_task.c
          |--io.c
          |--irq.c
          |--isa.c
          |--module.c
          |--process.c
          |--ptrace.c
          |--ptrace.h
          |--semaphore.c
          |--setup.c
          |--smp.c
          |--sys_arm.c
          |--time.c
          |--traps.c
          `--vmlinux.lds.S
          內(nèi)核入口處也是由一段匯編語言實現(xiàn)的,由head.s和head-common.s兩個文件組成。
          Head.s是 內(nèi)核的入口文件,在head.s的末尾處#i nclude"head-common.S"。經(jīng)過一系列的初始化后,跳轉(zhuǎn)到linux-2.6.18.8/init/main.c中的 start_kernel()函數(shù)中,開始內(nèi)核的基本初始化過程。
          /linux-2.6.18.8/init
          [root@localhostinit]#tree
          .
          |--Kconfig
          |--Makefile
          |--calibrate.c
          |--do_mounts.c
          |--do_mounts.h
          |--do_mounts_initrd.c
          |--do_mounts_md.c
          |--do_mounts_rd.c
          |--initramfs.c
          |--main.c
          `--version.c
          (4)
          /linux-2.6.18.8/arch/arm/mach-s3c2410
          [root@localhostmach-s3c2410]#tree-L1
          .
          |--Kconfig
          |--Makefile
          |--Makefile.boot
          |--bast-irq.c
          |--bast.h
          |--clock.c
          |--clock.h
          |--common-smdk.c
          |--common-smdk.h
          |--cpu.c
          |--cpu.h
          |--devs.c
          |--devs.h
          |--dma.c
          |--gpio.c
          |--irq.c
          |--irq.h
          |--mach-anubis.c
          |--mach-smdk2410.c
          |--pm-simtec.c
          |--pm.c
          |--pm.h
          |--s3c2400-gpio.c
          |--s3c2400.h
          |--s3c2410-clock.c
          |--s3c2410-gpio.c
          |--s3c2410.c
          |--s3c2410.h
          |--sleep.S
          |--time.c
          |--usb-simtec.c
          `--usb-simtec.h
          這個目錄中的文件都是板級相關(guān)的,其中比較重要是如下幾個:
          linux/arch/arm/mach-s3c2410/cpu.c
          linux/arch/arm/mach-s3c2410/common-smdk.c
          linux/arch/arm/mach-s3c2410/devs.c
          linux/arch/arm/mach-s3c2410/mach-smdk2410.c
          linux/arch/arm/mach-s3c2410/Makefile.boot
          linux/arch/arm/mach-s3c2410/s3c2410.c
          3. 處理器和設(shè)備4.
          這里主要介紹處理器和設(shè)備的描述和操作過程。設(shè)備描述在linux/arch/arm/mach-s3c2410/devs.c和linux/arch/arm/mach-s3c2410/common-smdk.c中實現(xiàn)。最后以nandflash為例具體介紹。



          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();