Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Kernel bootstrap

1,100 views

Published on

Learning resource of bootstraping linux kernel on x86.

Published in: Software
  • Download or read that Ebooks here ... ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks }} ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Kernel bootstrap

  1. 1. Kernel Bootstrap Kai Sasaki(@Lewuathe)
  2. 2. 今日のお話 • BIOS • Bootloader • header.S • main.c ※アーキテクチャはx86
  3. 3. まず電源ボタンを押します
  4. 4. マザーボード 1.マザーボードに十分な電力が与えられる 2.CPUを走らせるためにすべてのregisterを初期化
 
 
 3.Real modeで起動を開始する IP 0xfff0 CS base 0xffff0000
  5. 5. Real Mode • x86互換のCPUでの起動時の動作モード • メモリを20bit(1MB)の空間で分割 • すべてのプログラムが直接的に
 メモリにアクセス可能
  6. 6. Real Mode Mem メモリバスは20bit CPU register registerは16bit
  7. 7. Real Mode Mem メモリバスは20bit CPU register registerは16bit メモリ空間は1MB(2^20)あるのに16bit registerしかない
  8. 8. Real Mode 65535 65535 … CP:IP base address offset
  9. 9. Real Mode 65535 65535 … CP:IP 0x2000 0x0010 (0x2000 << 4) + 0x1000 対象のアドレスは
  10. 10. Reset Vector IP 0xfff0 CS base 0xffff0000 0xffff0000:0xfff0 Logical Address
  11. 11. Reset Vector IP 0xfff0 CS base 0xffff0000 0xffff0000:0xfff0 Logical Address これをReset Vectorといい、すべての初期化が
 終わった段階で最初に行う命令がこのアドレスに入っている
  12. 12. jump命令 • Reset Vectorの先にはjump命令が入っている • 多くはBIOSへと飛ぶ無条件分岐命令 .section ".reset" .code16 .globl reset_vector reset_vector: .byte 0xe9 .int _start - ( . + 2 ) ... coreboot(http://www.coreboot.org/) より
  13. 13. BIOS • ハードウェアの初期化、チェックを行い
 次にブート可能なデバイスを探す • マザーボード毎に実装され、通常はROMなどの
 不揮発性メモリの上に乗っている
  14. 14. BIOS • ブートセクターを探す • デバイス毎にブートプログラムを可能している • 通常そのデバイスの先頭512byteに格納 P1 P2 P3BS 5120
  15. 15. Master Boot Record • ブートセクタにおいてあるプログラム • BIOSは先頭512byteの
 ロードのみ保証 • そのためこのプログラムが
 後続のプログラムを次々に
 ロードしていく形になる http://ja.wikipedia.org/wiki/マスターブートレコード
  16. 16. Bootloader • MBRにインストールされているソフトウェア • GRUBやLILOが一般的 • BIOSはBootloaderを選択し処理を受け渡す • このBootloaderとして利用可能なプログラムは
 Kernelの を実装しているBoot Protocol https://github.com/torvalds/linux/blob/master/Documentation/x86/boot.txt
  17. 17. GRUB stage1(boot.img) BIOS stage2
 (diskboot.img) grub_main
  18. 18. header • Boot Protocolでヘッダの設定が規定されている • Bootloaderはこれらの設定を行う必要がある https://github.com/torvalds/linux/blob/master/arch/x86/boot/header.S#L280-L288
  19. 19. kernel loading • Boot Protocolに従いカーネルをメモリにロードする https://github.com/torvalds/linux/blob/master/Documentation/x86/boot.txt
  20. 20. kernel setup • loadが完了すると処理がkernelに移る • kernelのsetupは_startからはじまる • ここのメモリ上のoffsetはBootloaderは知っている https://github.com/torvalds/linux/blob/master/arch/x86/boot/header.S#L293
  21. 21. header.S 1. label 1へのjump 2. headerのsetup 3. start_of_setup 1. segment registerの検証 : dsとesの両segment registerを同じ箇所を指すようにする 2. スタックの設定 : 3. bssの設定 : 静的なデータ領域の設定を行う 4. main.cへのjump .byte 0xeb .byte start_of_setup-1f
  22. 22. main.c https://github.com/torvalds/linux/blob/master/arch/x86/boot/main.c ここからはC お疲れ様でした
  23. 23. Reference • linux-internals • http://0xax.gitbooks.io/linux-insides/content/index.html

×