CbC による OS の実装(仮)

Taiki Taira / 05,Jun,2012

研究目標

複雑化、多様化した BIOS を書き換え改良した仕様の(U)EFI に準拠した、GRUB2 で起動する。64bit のメモリを有効に扱う。
shared library を減らす。
故障や部品交換等でOSそのものが止まるような箇所をなくす。
OS を構成する CPU 等の機器に多少の障害が起きてもすぐに切られることがないようにする。
CbC で動作し、Cerium の Task Manager をのせる。

設計

Cerium の Task Mangaer を載せ、OS に渡される処理を並列化する。 CbC のコンパイラを載せ、実行可能にする。

今週の作業 [~ 2011/06/12 ]

64bit へ移行するソースの理解と作業
コンパイラについて

compiler

gcc

MSR (Model Specific Register)

モデル固有レジスタ
CPU 内部制御用のレジスタ群
RDMSR WRMSR 命令を使用して読み書き

機能

MSR を操作する命令

RDMSR

ecx レジスタに MSR のアドレスを指定すると edx:eax レジスタに MSR の内容を読み込む。
上位32bit が edx , 下位 32bit が eax へ入る。

RDMSR

ecx レジスタに指定したMSR のアドレスに、 edx:eax レジスタの内容を書き込む。

#define MSR_EFER      0xc0000080 /* extended feature register */
#define _EFER_LME     8  /* Long mode enable */

/* Enable Long mode in EFER (Extended Feature Enable Register) */
movl    $MSR_EFER, %ecx
rdmsr
btsl    $_EFER_LME, %eax
wrmsr
      

今後やること

Multiboot Specification

Multiboot Specification で規定された少量の規定を満たせばこの企画に準拠したブートローダー(ex. grub) から起動できる。
Multiboot Specification2 が作られており、grub2 (gurb の最新 grub1.99 )が対応しているため、Multiboot Specification2 に対応させる必要がある。

Physical Address Extension (PAE)

物理アドレス拡張。
32bit CPU で 4GiB以上のメモリを扱う技術。
AMD の AMD 64 アーキテクチャと Interl 64 アーキテクチャでは PAE のページテーブルエントリ構造を保ったまま512エントリをもった4段のページテーブル構造にすることで仮想アドレス空間を48、物理アドレス空間を52bit まで拡張。
IA-32 の PAE 互換を使用する場合物理アドレス空間の範囲は64bit mode で使った場合と同様。

Intel x86 architectures --- Segment Descripter

Enable long mode

最初にCPUのIDを確認し、Long mode が使用可能かチェックする。

linux kernel 3.3

arch/x86/boot/compressed/head_64.S で protect mode からlong mode へ移行するアセンブラが記述してある。
64bit の GDT (Global Descripter Table) や PAE (Physical Address Extension) などもこのソースで用意している。

END

UEFI【Unified Extensible Firmware Interface】

OS とプラットフォームファームウェアとの間のソフトウェアインターフェースを定義する「仕様」
BIOS との置き換えになる。特定のプロセッサやアーキテクチャに限定されない。
2005 年に EFI から標準化され、 UEFI へ名前が変更された。

UEFI 特徴

2TiB を超える大きなディスクからブート可能
CPU に依存しないアーキテクチャ
CPU に依存しないドライバ
ネットワークも使用可能な柔軟なプレOS環境
MBR GUID サポート->2TB 以上のシリアルATA HDD から起動可能
BIOS -> 16 bit プロセッサモード 1MB アドレス空間
UEFI -> 32 bit ,64 bit のプロセッサモード
-> ブート前に 64bit アドレッシングの全メモリに直接アクセス可能

サポート

VMware Fusion
QEMU
ViertualBox 3.1 〜(Unix/Linux)

引用

wikipedia UEFI

xv6

MIT が operating systems Engineering という授業で使うために開発した OS 。
Sixth Edition Unix が元になっている。

VMware Fusion で動かすことに成功。

Any element with child nodes can build.

It doesn't have to be a list.

Slide with bullet points (small font)

Slide with a table

Name Occupation
Luke Mahé V.P. of Keepin’ It Real
Marcin Wichary The Michael Bay of Doodles

Slide with a table (smaller text)

Name Occupation
Luke Mahé V.P. of Keepin’ It Real
Marcin Wichary The Michael Bay of Doodles

Styles

Segue slide

Slide with an image

Source: Sergey Brin

Slide with an image (centered)

Source: Larry Page

Image filling the slide (with optional header)

Source: Eric Schmidt

This slide has some code

<script type='text/javascript'>
  // Say hello world until the user starts questioning
  // the meaningfulness of their existence.
  function helloWorld(world) {
    for (var i = 42; --i >= 0;) {
      alert('Hello ' + String(world));
    }
  }
</script>
<style>
  p { color: pink }
  b { color: blue }
  u { color: 'umber' }
</style>

This slide has some code (small font)

<script type='text/javascript'>
  // Say hello world until the user starts questioning
  // the meaningfulness of their existence.
  function helloWorld(world) {
    for (var i = 42; --i >= 0;) {
      alert('Hello ' + String(world));
    }
  }
</script>
<style>
  p { color: pink }
  b { color: blue }
  u { color: 'umber' }
</style>
The best way to predict the future is to invent it.
Alan Kay
A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable.
Leslie Lamport

A slide with an embed + title

Full-slide embed with (optional) slide title on top

Thank you!