PPC U-Boot隨讀隨寫(1)

來源:互聯網
上載者:User
 PPC U-Boot隨讀隨寫(1)
U-Boot目錄下,board,cpu,include/configs在移植過程中會涉及。board主要是關於開發板的,flash驅動可以放在此;cpu如同其名,開發板所用的CPU,本文為MPC8260;include/configs一些系統定義,比如boot flash地址,boot參數,boot command等等,比較重要。U-Boot的編譯可以參考Readme以及doc目錄下的文檔.
  U-Boot從cpu/mpc8260/start.S啟動,調用cpu_init_f初始化IMMR,然後bl board_init_f。
  board_init_f中,gd指標指向CFG_INIT_RAM_ADDR+CFG_GBL_DATA_OFFSET,CFG_INIT_RAM_ADDR為CFG_IMMR即cpu內部ram,MPC8260 internal RAM為128K(0x2000),CFG_GBL_DATA_OFFSET=(0x2000 - 128),即為GD分配128bytes,位於internal RAM的(0x2000-128). 調用init_sequence初始化timebase/serial/clocks/console etc.,並把相關資訊儲存在gd裡。接著分配RAM,從最高地址向下,分別分配Kernel log buffer,protected RAM,LCD framebuffer,memory for U-Boot code, data & bss,memory for malloc() arena,Board Info(比較重要),最後是設定新的stack,初始化bd,調用relocate_code(start.S).
  main_loop()中,函數abortboot()用於中止auto boot,KEY在include/configs中CONFIG_AUTOBOOT_STOP_STR設定. 若是auto boot模式,擷取bootcmd,getenv ("bootcmd"); run_command (s, 0)直接boot image. boot command在include/configs中CONFIG_BOOTCOMMAND定義,例如#define CONFIG_BOOTCOMMAND    "bootm ff020000 ff120000"    /* autoboot command */。
  run_command()調用do_bootm(). do_bootm()中,解析參數個數,從第一個參數擷取到kernel image的address,讀出image header, CRC效驗,hdr->ih_type為IH_TYPE_KERNEL,hdr->ih_comp為IH_COMP_GZIP,gunzip解壓縮到hdr->ih_load,根據hdr->ih_os調用do_bootm_linux();do_bootm_linux()中,擷取啟動參數s = getenv("bootargs"),     
    strcpy (cmdline, s);
    cmd_start    = (ulong)&cmdline[0];
    cmd_end      = cmd_start + strlen(cmdline);
kernel指向(void (*)(bd_t *, ulong, ulong, ulong, ulong)) ntohl(hdr->ih_ep), 參數大於3時,設定結構體kbd(board info),從參數argv[2]擷取initrd的地址, data = ddr + sizeof(image_header_t); 設定initrd_start = data;        initrd_end = initrd_start + len;  調用(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
      Linux Kernel Parameters:
       r3: ptr to board info data
       r4: initrd_start or 0 if no initrd
       r5: initrd_end - unused if r4 is 0
       r6: Start of command line string
       r7: End   of command line string
啟動kernel,執行arch/ppc/kernel/head.S.

以上bootloader解壓核心到記憶體,然後跳轉到核心入口處開始執行。
另外一種是核心自解壓,入口在arch/ppc/boot/simple/head.S

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.