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
デバイスドライバ
Search
Satoru Takeuchi
PRO
May 06, 2025
Technology
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
デバイスドライバ
以下動画のテキストです
https://youtu.be/rIbvTC3p-ZI
Satoru Takeuchi
PRO
May 06, 2025
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
78
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
110
あなたの知らないバージョン命名規則
sat
PRO
3
920
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
74
Machine Check Exception
sat
PRO
2
70
バイナリダンプの模様を読む
sat
PRO
0
110
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
110
114-ファイルのshallow_copy.pdf
sat
PRO
2
62
113-Btrfsのスナップショット.pdf
sat
PRO
0
46
Other Decks in Technology
See All in Technology
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
7
6k
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
300
分析AIエージェントを育てる、動く環境を育てる
codatum
1
1.1k
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
4
1.4k
会社説明資料
persolserverworks
0
9.7k
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
390
今さら理解するウェブフォントver.2026
takanorip
3
700
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
130
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
5
4.5k
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
110
不可逆な意思決定を避けながら10億超の顧客データを AI Ready にするデータ基盤設計
baseballyama
1
320
ハードウェアコンペでもAI駆動開発が進んでいる話
iotengineer22
1
720
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
New Earth Scene 8
popppiees
4
2.7k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
700
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
360
For a Future-Friendly Web
brad_frost
184
10k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
Transcript
デバイスドライバ May. 6th, 2025 Satoru Takeuchi X: satoru_takeuchi 1
デバイスドライバとは • デバイスの操作を担当するカーネル内のコンポーネント • おおざっぱにいうとデバイスの種類だけ存在する ◦ 📝 Linuxのコード数千万行のうち、ほとんどはデバイスドライバのコード 2
デバイスの操作方法 • デバイスには1つ以上のレジスタという領域が存在 • どのレジスタにどうアクセスすればデバイスをどんなふうに操作できるかが仕様に書かれている • デバイスドライバはユーザからの要求に応じて仕様通りにレジスタにアクセス 3 デバイス カーネル空間
物理世界 レジスタ デバイスドライバ アクセス
デバイスのレジスタにアクセスする方法 • メモリマップトI/O ◦ デバイスのレジスタをカーネルの仮想アドレス空間にマップしてアクセス ◦ メモリと同じようにアクセスできる ◦ 主流の方法。本動画でもこちらについて説明 •
ポートマップトI/O ◦ デバイスのレジスタを portと呼ばれるメモリとは別のインタフェースを介してアクセス ◦ 専用の機械語命令を発行する必要がある (例: x86だとin,out命令) 4
メモリマップトI/O • デバイスアクセス時はデバイスのレジスタをカーネルの仮想アドレス空間にマップし てアクセス ◦ 📝 実はカーネルがデバイスを認識した段階でデバイスのレジスタは物理アドレス空間にマップされ ている ◦ 📝
物理アドレスのどこに存在するかは OSではなくUEFIやACPIから得る 5 メモリ デバイスAの レジスタ(群) カーネルの 仮想アドレス空間 デバイスBの レジスタ(群) …
デバイスドライバのサンプル • 簡単な仕様の仮想的なディスクデバイスを使ってデバイスドライバがどんなことをし ているかを学ぶ 6 レジスタのオフセット 役割 0 読み書きに使うメモリ領域の開始アドレス 10
読み書きに使うディスク内のデータの開始オフセット 20 読み書きサイズ 30 ここに書き込むと処理を要求。 0なら読み出し、1なら書き込み 40 要求された処理が終わったかどうかを示す。処理を開始した時点で 0 になり、完了したら1になる。
初期状態 • カーネル仮想アドレス空間のアドレス500にディスクのレジスタがマップされている 7 メモリ 0 500 510 520 530
540 ??? ??? ??? ??? ??? 仮想アドレス空間 ディスクデバイス 2222 3333 1111 10 0 20
やりたいこと • メモリ領域0~100にディスクのオフセット100~200のデータを読み出す 8 メモリ 0 500 510 520 530
540 ??? ??? ??? ??? ??? ディスクデバイス 2222 3333 1111 100 0 200 ??? 100 仮想アドレス空間
デバイスドライバの読み出し処理はこんなかんじ func read(mem_addr, dev_offset, size) { regs[] = {500, 510,
520, 530, 540} regs[0] = mem_addr regs[1] = dev_offset regs[2] = size regs[3] = 0 } 9
読み書きするアドレス、オフセットの設定 • アドレス500,510,520にマップされたレジスタを設定 10 メモリ 0 500 510 520 530
540 0 100 100 ??? ??? ディスクデバイス 2222 3333 1111 100 0 200 ??? 100 仮想アドレス空間 メモリアドレス データサイズ ディスク上のオフセット
ディスクデバイスに処理を依頼 • アドレス530にマップしたレジスタに0を書き込む(読み出しを意味する) 11 メモリ 0 500 510 520 530
540 0 100 100 0 0 ディスクデバイス 2222 3333 1111 100 0 200 ??? 100 仮想アドレス空間
ディスクデバイスがデータを転送 12 メモリ 0 500 510 520 530 540 0
100 100 0 0 ディスクデバイス 2222 3333 1111 100 0 200 2222 100 仮想アドレス空間
ディスクデバイスが読み出し完了を示す • 📝 デバイスドライバが読み出し完了を検出する方法は次の動画で説明 13 メモリ 0 500 510 520
530 540 0 100 100 0 1 ディスク 2222 3333 1111 100 0 200 2222 100 仮想アドレス空間
まとめ • デバイスはデバイス内のレジスタ領域へのアクセスによって操作 • 何をしたいときにどうレジスタにアクセスすべきかは仕様に書いている • デバイスドライバはユーザからの要求に応じて仕様通りレジスタにアクセス • メモリマップトI/Oの場合アセンブリコード無しでメモリアクセスの感覚でデバイスの レジスタにアクセスできる
14