【linux】U-BOOT與linux kernel通訊: struct tag

來源:互聯網
上載者:User

標籤:

?u-boot與linux通訊格式

?

?

如,開機時執行u-boot, u-boot引導完後,就是交給linux系統了,但是linux需要一些基本資料,如記憶體大小,啟動方式等,這就涉及到u-boot和linux通訊。

而通訊格式由linux規定了,以其中atag格式舉例,詳情查閱Documentation/arm/Setup

?

格式結構體為struct tag: 定義在 Setup.h (src\arch\arm\include\uapi\asm):147

struct tag {

struct tag_header hdr;

union {

struct tag_core core;

struct tag_mem32 mem;

struct tag_videotext videotext;

struct tag_ramdisk ramdisk;

struct tag_initrd initrd;

struct tag_serialnr serialnr;

struct tag_revision revision;

struct tag_videolfb videolfb;

struct tag_cmdline cmdline;

?

/*

* Acorn specific

*/

struct tag_acorn acorn;

?

/*

* DC21285 specific

*/

struct tag_memclk memclk;

} u;

};

?

?

u-boot會按照上述格式,在記憶體中劃分一塊atag參數地區,對該地區進行賦值。此處不對u-boot做討論,後面在專門寫文章。當賦值完成後,將cpu初始化成 MMU = off, D-cache = off, I-cache = dont care, r0 = 0, r1 = machine nr, r2 = atags or dtb pointer,跳轉到linux代碼起始處。

?

Linux atag參數解析流程

Linux代碼執行後,在第一階段(start_kernel函數之前),會驗證該地區正確性(bl __vet_atags)。

進入第二階段後(start_kernel函數之後):會開始真正解析atag參數,並賦值給相應的變數。流程:start_kernel →setup_arch→setup_machine_tags→parse_tags→parse_tag

?

Init.h (src\include\linux) :中定義了大部分的 section,比較重要的有

#define __init __section(.init.text) __cold notrace

#define __initdata __section(.init.data)

#define __initconst __constsection(.init.rodata)

#define __exitdata __section(.exit.data)

#define __exit_call __used __section(.exitcall.exit)

?

?

【linux】U-BOOT與linux kernel通訊: struct tag

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.