Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
UEFIをつくる
Search
Akira Moroo
March 24, 2018
Technology
1.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
UEFIをつくる
第11回 自作OSもくもく会でお話した内容です.
Akira Moroo
March 24, 2018
More Decks by Akira Moroo
See All by Akira Moroo
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
640
Exploring x86 MSR Space
retrage
0
1.6k
LLMでバイナリ解析支援
retrage
0
290
GitHub ActionsでDevSecOpsごっこ
retrage
0
130
Practical Rust (Hypervisor) Firmware
retrage
3
2k
Bypassing UEFI Secure Boot with Thin-Hypervisor
retrage
0
1.3k
Porting Linux to Nabla Containers
retrage
0
1.3k
Network Boot from Bell Labs
retrage
2
1.9k
Unikernelで始める自作OS/OS Development with Unikernel
retrage
1
730
Other Decks in Technology
See All in Technology
ドメインエキスパートは いかにして AI を使って プロダクト開発をするか
tatsuyashiraishi
1
160
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
1
240
DevelopersIO 2026 Tokyo 現時点の衛星通信サービスの現状を整理してみる
maroon1st
0
280
sue445's proposals 2026
sue445
0
140
AI秘書と毎日働くのはもう当たり前。開発以外の業務に足りない機能をどう埋める?
minorun365
PRO
0
770
DevelopersIO2026 -バックアップは“消されないこと”が9割-
yoshida0129
0
390
AWSセキュリティで活用するAI機能
cmusudakeisuke
1
280
AWSDirectConnectの構築の進め方を整理してみた
masa_my
1
170
背中から、背中へ ー 社外コミュニティで学んだ「雑に背中を押す」という恩送り ー / easygoing encouragement and pay forward to community
naitosatoshi
0
180
野良MCPサーバーを排除せよ!MCPサーバーのガバナンス
yukiogawa
1
230
CSS2026:OWS研究会・招待講演「世界観を、実装する」
atsush1_sada
2
280
「私が一番顧客に詳しい」を捨てる~ 全員が一次情報に精通する開発チームをつくり、PMが次のボトルネックへ染み出すまで
kaminashi
3
2.3k
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.3k
Amusing Abliteration
ianozsvald
1
360
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
530
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
Building Adaptive Systems
keathley
44
3.3k
Visualization
eitanlees
153
17k
Chasing Engaging Ingredients in Design
codingconduct
0
370
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Evolving SEO for Evolving Search Engines
ryanjones
0
330
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Transcript
UEFIをつくる 2018/03/24 第11回 自作OSもくもく会 @retrage
Recap: UEFI • Unified Extensible Firmware Interface • 標準化されたBIOSの規格とその実装 •
そもそもの始まりはIA-64向けにIntelが開発したEFI • EFIをベースにUEFI Forumにより標準化⇒UEFI • TianoCore: オープンソースなリファレンス実装 1
yabits • OSの起動にのみ特化したyet anotherなUEFI実装 • いろいろ動く • GRUB2 • Linux
kernel • OpenBSD • TianoCoreと比較して • 起動時間: 1/2 • フットプリント: 1/10 • 概要はMitou Demo Day 2017の動画にて • https://youtu.be/OIdPUK9a7vI 2
UEFI再考 • UEFIはOSではない.インターフェースである. • No multitask • No multithread •
No Ring Protection • 従来のLegacy BIOS同様,bootloaderやOSに対して 機能を提供することが目的 • UEFIのゴールはOSを起動すること 3
Boot Process 4 PEI DXE BDS TSL RT Hardware Init
Driver Driver Driver Driver Services Boot Manager Boot Loader OS
Handoff • Boot ManagerがESPを探索し,EFI Appを起動 • デフォルトでは\EFI\BOOT\BOOT<arch>.EFI • 起動時にスタックorレジスタに情報が渡される •
EFI_SYSTEM_TABLE * • EFI_HANDLE • IA-32の場合 5
EFI_SYSTEM_TABLE • UEFIの提供するServicesをまとめたstruct 6 typedef struct { EFI_TABLE_HEADER Hdr; CHAR16
*FirmwareVendor; UINT32 FirmwareRevision; EFI_HANDLE ConsoleInHandle; EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn; EFI_HANDLE ConsoleOutHandle; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut; EFI_HANDLE StandardErrorHandle; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr; EFI_RUNTIME_SERVICES *RuntimeServices; EFI_BOOT_SERVICES *BootServices; UINTN NumberOfTableEntries; EFI_CONFIGURATION_TABLE *ConfigurationTable; } EFI_SYSTEM_TABLE;
OSの起動に必要な機能 • BootServices • RuntimeServices • GPT+ESP対応 • デバイスドライバ •
最低限以上の機能があればOSの起動は可能 7
BootServices • ExitBootServices()されるまで提供するServices • 35個ほどあるが全て必要というわけでもない • メモリ関連 • {Allocate, Free}Pages(),
{Allocate, Free}Pool() など • Image関連 • LoadImage(), StartImage() • 他にもEventやProtocol関係のServiceがある • Servicesには依存関係が存在 • 例: LoadImage()の内部でAllocatePages()を呼び出す 8
ExitBootServices() • BootServices()のうちの1つ • 機能: BootServicesの提供を終了 • OSの条件: ExitBootServices()を呼ぶこと •
EFI AppではExit()によりUEFIに処理を戻す • が,実際にはExitBootServices()後もBootServicesが 利用できる • Linuxでは少なくともそうなっている • arch/x86/kernel/setup.c:1149 参照 9
RuntimeServices • OS起動後もUEFIが提供するServices • ExitBootServices()が呼ばれても存続 • NVRAM関連 • GetNextVariableName(), {Get,
Set}Variable() • 時間関連 • {Get, Set}Time(), {Get, Set}WakeupTime() • UEFI対応したOSではこれらを利用しているはず 10
SetVirtualAddressMap() • RuntimeServices()の1つ • UEFIのアドレッシングモードをPhysicalからVirtualへ • ExitBootServices()後に1度だけ呼び出される • UEFIはこれによりRuntimeServicesをリロケーション •
デバッグの非常に難しいところ 11
GUID Partition Table: GPT • MBR代替のPartition Tableの標準規格 • MBRを前提としたBIOSが読んでもPartition Tableが
壊れないようにLBA 0にProtective MBRが存在 12
EFI System Partition: ESP • 実質FATファイルシステム • 持っているGUIDが異なる • ライセンスとしてはMicrosoftがESPの利用に限って
認めているような状況(だったはず) • Linuxの場合: /boot • GRUB2などのbootloaderもここに置かれる • Boot ManagerはESPを探索,bootloader/OSを起動 • デフォルトでは\EFI\BOOT\BOOT<arch>.EFI • NVRAMのVariableにも依存 13
デバイスドライバ • 当然UEFIでも各種デバイスにアクセスする必要が あるのでデバイスドライバが必須 • 例: • PCIe, USB, IDE,
AHCIなど • UEFIでは基本的にはポーリング • yabitsではLibpayloadやFILO,depthchargeのドライ バを活用 14
OS開発者から見たUEFI • UNIX系をベースとしている場合非常に面倒 • Calling Conventionの違いなど • Linuxでの対応方法 • GRUB2による起動
• EFI Appなヘッダを作成してOSをEFI Appとして起動 • OpenBSDやBitVisorでの対応方法 • EFI対応の1st loader+共通の2nd loader • UEFI対応についてLinuxと同じ方針をとったnon GPL なtoy OSがあると幸せかもしれない 15
まとめ • UEFIは標準化されたBIOSの規格とその実装 • UEFIはbootloaderやOSに対するインターフェース • UEFIはBootServices, RuntimeServicesなどの機能を 提供 •
OS開発者から見た場合,UEFIは利用できる機能は Legacy BIOSと比較して増えたものの,その分煩雑 になったとも言える 16
参考文献 • http://www.uefi.org/sites/default/files/resources/ UEFI%20Spec%202_7_A%20Sept%206.pdf • http://wiki.phoenix.com/wiki/index.php/EFI_BOOT _SERVICES • http://wiki.phoenix.com/wiki/index.php/EFI_RUNTI ME_SERVICES
• https://github.com/yabits/uefi 17