LoginSignup
52
48

More than 5 years have passed since last update.

Linuxのブートプロセスを追うときに見るべきファイル(x86_64編)

Posted at

4.0というか4/25時点のLinusツリーのHEAD

リアルモードでbzImage(vmlinuz)の先頭から呼ばれる場合(LILOから呼ばれるときだっけ?)

  • arch/x86/boot/header.S
    • 圧縮されたカーネル(bzImage)の先頭にあるコード(setup.elf)のうちの一つ
    • エントリポイント_startがある
    • mainを呼ぶ
  • arch/x86/boot/main.c
    • mainがある
    • いろいろハードウェアを初期化する
    • go_to_protected_modeを呼ぶ
  • arch/x86/boot/pm.c
    • go_to_protected_modeがある
    • setup_idtとかsetup_gdt等でプロテクトモードへ入る準備をする
    • protected_mode_jumpでcode32_start(startup_32がある場所)へジャンプする
      • startup_32は0x100000にあるはず?

GRUB2から呼ばれる場合はここから。すでにプロテクトモードになってるはず。

  • arch/x86/boot/compressed/head_64.S
    • ブートローダ(GRUB2)から最初に呼ばれるエントリポイントstartup_32がある
      • エントリポイントはarch/x86/boot/compressed/vmlinux.lds.Sに書かれている
    • 64bitモードに入るときのエントリポイントstartup_64もここにある
    • 解凍ルーチンと圧縮されたカーネルを移動しdecompress_kernelを呼ぶ
  • arch/x86/boot/compressed/misc.c
    • カーネル解凍ルーチン(decompress_kernel)等がある
    • 解凍した後はstartup_64に戻る
  • arch/x86/boot/compressed/head_64.S
    • 解凍したカーネルの先頭にジャンプする
    • エントリポイントはstartup_64
      • arch/x86/kernel/vmlinux.lds.Sにかかれている
  • arch/x86/kernel/head_64.S
    • startup_64がある
    • initial_code(x86_64_start_kernel)に飛ぶ
  • arch/x86/kernel/head64.c
    • x86_64_start_kernelがある
    • x86_64_start_reservationsを経由してstart_kernelを呼ぶ
  • init/main.c
    • start_kernelがある
    • rest_init経由でcpu_startup_entry(kernel/sched/idle.c)を読んでidleループ(cpu_idle_loop)に入る

参考文献

52
48
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
52
48