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
Primeiro módulo de kernel
Search
Diego Ramos Ruggeri
May 16, 2014
Programming
42
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Primeiro módulo de kernel
Diego Ramos Ruggeri
May 16, 2014
More Decks by Diego Ramos Ruggeri
See All by Diego Ramos Ruggeri
Exploiting process variability in voltage frequency control
diegor2
0
39
Energy profiler for android emulator
diegor2
0
51
Clamber network
diegor2
0
36
Designers e Programadores em um projeto ágil
diegor2
0
30
Prime quest
diegor2
0
32
Jogos Interativos como Ferramenta para Reconhecimento de Números Primos
diegor2
0
33
Open VSwitch on Android
diegor2
0
120
Other Decks in Programming
See All in Programming
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
260
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.3k
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
330
AIエージェント時代のコードレビューを設計する
nogu66
6
2.7k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
370
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
270
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
330
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
620
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
130
Webの地図
yosuke_furukawa
PRO
6
4.5k
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
250
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
4k
エンジニアに許された特別な時間の終わり
watany
109
250k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
240
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
Documentation Writing (for coders)
carmenintech
77
5.5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
WENDY [Excerpt]
tessaabrams
14
39k
Prompt Engineering for Job Search
mfonobong
0
450
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
240
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Transcript
Escreva seu primeiro MÓDULO DE KERNEL (LINUX)
Em quatro atos • Hello World! • Character driver •
Miscellaneous driver • Ramdisk
0 – Hello World • Olá mundo! • Diego Ramos
Ruggeri • http://vai.la/62u3
0 – Hello World • Linux é monolítico • Módulos
carregados em tempo de execução • Ciclo de vida • Básico: Inicializar e Limpar
0 – Hello World Porque? • Hardware livre • Entender
o Linux • OOP em C • Projeto de software livre
static int __init hello_module(void) { printk(KERN_INFO "Hello World!\n"); return 0;
} static void __exit goodbye_module(void) { printk(KERN_INFO "Adios\n"); } module_init(hello_module); module_exit(goodbye_module); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Diego Ruggeri"); MODULE_DESCRIPTION("Hello World module");
0 – Hello World obj-m += hello.o all: make -C
/lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
0 – Hello World • modinfo • insmod • lsmod
• rmmod • dmesg
1 – Char Dev • ioctls • net • /dev
• /sys • /dev • Block device • Character device • Major Minor
static struct file_operations fops = { .read = device_read, .write
= device_write, .open = device_open, .release = device_release }; static int __init hello_module(void) { major = register_chrdev(0, DEVICE, &fops); /* … */ } static void __exit goodbye_module(void) { unregister_chrdev(major, DEVICE); }
2 – Misc Dev • mknod /dev/fisl15 c $MAJOR $MINOR
• udev • Miscellaneous API
static struct file_operations fops = { /*...*/ }; static struct
miscdevice mdev = { .minor = MISC_DYNAMIC_MINOR, .name = DEVICE, .fops = &fops, }; static int __init hello_module(void) { misc_register(&mdev) /* … */ } static void __exit goodbye_module(void) { misc_deregister(&mdev); }
3 - Ramdisk • Char device + • Misc api
+ • Aloca memória (slab) + • open, close, read, write
static int __init hello_module(void) { disk = (char*) kzalloc(DISK_SIZE *
sizeof(char), GFP_KERNEL); /*…*/ } static void __exit goodbye_module(void) { kfree(disk); /*...*/ }
static ssize_t device_read(struct file *filp, char *buffer, size_t length,loff_t *
offset) { /*...*/ copy_to_user(buffer, message, len); /*...*/ } static ssize_t device_write(struct file *filp, const char *buff, size_t len, loff_t * off) { copy_from_user(disk, buff, len) }
Obrigado
[email protected]
http://github.com/diegor2