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
54
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
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
390
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
カツオ、ご期待ください
suneo3476
0
190
残高管理から台帳サービスへの進化
artoy
1
200
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
180
AWSに止められる覚悟してますか?
morizo_1984
2
530
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
300
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
500
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
300
Jetpack Compose Mechanisms
skydoves
3
820
Featured
See All Featured
Building Adaptive Systems
keathley
44
3.2k
Navigating Weather and Climate Data
rabernat
0
560
Mind Mapping
helmedeiros
1
400
Abbi's Birthday
coloredviolet
4
10k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Site-Speed That Sticks
csswizardry
13
1.6k
So, you think you're a good person
axbom
PRO
2
2.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
Thoughts on Productivity
jonyablonski
76
5.4k
We Have a Design System, Now What?
morganepeng
55
8.4k
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