OS
https://github.com/nuta/resea
Cで書かれたマイクロカーネルOS(Rustによるアプリ実装例もある)

カーネルの実装

kernel ディレクトリにあるやつだけ

ブート

multibootに対応している→GRUBから起動できる(tools/grub.cfgが存在する)
kernel/arch/<any>/boot.S から始まる bootラベルから始まるのか、boot.S の先頭から逐次実行なのかわからない
例えばx64用の boot.S では、222行目で init() を呼んでいる これはおそらく kernel/arch/x64/init.c@init で、シリアル通信機・PIC・割り込みの初期化をしてから kmain() を呼んでいる

kmain()

kernel/boot.c
以下を呼ぶ:

  • task_init()
  • mp_start()
  • task_lookup_unchecked() のあと task_create()
    • 前者でtaskのアロケート的なことやって、後者で初期化?
    • INIT_TASK の作成を行っている
  • mpmain()

mpmain()

kernel/boot.c
IDLE_TASK を作成して、 arch_idle()を呼ぶ
x64ではsti (SeT Interrupt) してhltしてcli (CLear Interrupt) している
mp_selfって何?mpが何の略なのかわからない→multi processorである可能性?mp.cに「mp table」というワードがでてきたので、調べたらこんなものがでてきた

There is a utility called ‘mptable’ which can be used to examine the MPS table on motherboards.