td
-
Upload
tiago-maluta -
Category
Technology
-
view
557 -
download
3
description
Transcript of td
![Page 2: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/2.jpg)
Evolução
1991 i386
2010
avr32, frv, m32r, microblaze, parisc, score, um,
alpha, blackfin, h8300, m68k, mips, powerpcsh, x86,
arm, cris, ia64, m68knommu, mn10300, s390, sparc, xtensa
Fonte: www.kernel.org
Monday, June 28, 2010
![Page 3: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/3.jpg)
Como gerenciar este crescimento?
Monday, June 28, 2010
![Page 4: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/4.jpg)
Monday, June 28, 2010
![Page 5: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/5.jpg)
Controle de versão descentralizado
• Linus tem seu repositório:git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
• Recebe um e-mail do mantenedor do um subsistema “Linus, please pull from: ssh://master.kernel.org/pub/scm/linux/
kernel/git/mchehab/linux-2.6.git v4l_for_2.6.35”
• Ele [Linus] faz o merge no seu repositório no momento que achar adequado.
Linus
A B C
Monday, June 28, 2010
![Page 6: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/6.jpg)
Módulos no kernel
Módulos de sistemas vfat - suporte ao filesystem FAT32
usbnet - subsistema de rede com USB Módulos de dispositivo
asix - controlador do conversor USB/Ethernet nvidia - placa de vídeo
Podem existir módulos proprietários, mas algumas interfaces são exclusivas para licenças livres
Monday, June 28, 2010
![Page 7: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/7.jpg)
#include <stdio.h>
static int start(void) { printf(“Hello from userspace!”); return 0;}
int main(void) { return start();}
Monday, June 28, 2010
![Page 8: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/8.jpg)
#include <stdio.h>
static int start(void) { printf(“Hello from userspace!”); return 0;}
int main(void) { return start();}
Monday, June 28, 2010
![Page 9: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/9.jpg)
#include <stdio.h>
static int start(void) { printf(“Hello from userspace!”); return 0;}
int main(void) { return start();}
gcc -Wall main.c -o main
Monday, June 28, 2010
![Page 10: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/10.jpg)
#include <linux/kernel .h> #include <linux/init .h>#include <linux/module.h>
static int __init start(void) {
printk(“Hello from kernelspace!”); return 0;}
staticvoid __exit stop(void) { }
module_init(start); module_exit(stop);
MODULE_AUTHOR(“”); MODULE_DESCRIPTION(“”); MODULE_LICENSE(“GPL”) ;
Monday, June 28, 2010
![Page 11: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/11.jpg)
#include <linux/kernel .h> #include <linux/init .h>#include <linux/module.h>
static int __init start(void) {
printk(“Hello from kernelspace!”); return 0;}
staticvoid __exit stop(void) { }
module_init(start); module_exit(stop);
MODULE_AUTHOR(“”); MODULE_DESCRIPTION(“”); MODULE_LICENSE(“GPL”) ;
Monday, June 28, 2010
![Page 12: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/12.jpg)
#include <linux/kernel .h> #include <linux/init .h>#include <linux/module.h>
static int __init start(void) {
printk(“Hello from kernelspace!”); return 0;}
staticvoid __exit stop(void) { }
module_init(start); module_exit(stop);
MODULE_AUTHOR(“”); MODULE_DESCRIPTION(“”); MODULE_LICENSE(“GPL”) ;
Monday, June 28, 2010
![Page 13: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/13.jpg)
#include <linux/kernel .h> #include <linux/init .h>#include <linux/module.h>
static int __init start(void) {
printk(“Hello from kernelspace!”); return 0;}
staticvoid __exit stop(void) { }
module_init(start); module_exit(stop);
MODULE_AUTHOR(“”); MODULE_DESCRIPTION(“”); MODULE_LICENSE(“GPL”) ;
Monday, June 28, 2010
![Page 14: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/14.jpg)
#include <linux/kernel .h> #include <linux/init .h>#include <linux/module.h>
static int __init start(void) {
printk(“Hello from kernelspace!”); return 0;}
staticvoid __exit stop(void) { }
module_init(start); module_exit(stop);
MODULE_AUTHOR(“”); MODULE_DESCRIPTION(“”); MODULE_LICENSE(“GPL”) ;
Monday, June 28, 2010
![Page 15: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/15.jpg)
#include <linux/kernel .h> #include <linux/init .h>#include <linux/module.h>
static int __init start(void) {
printk(“Hello from kernelspace!”); return 0;}
staticvoid __exit stop(void) { }
module_init(start); module_exit(stop);
MODULE_AUTHOR(“”); MODULE_DESCRIPTION(“”); MODULE_LICENSE(“GPL”) ;
obj−m:= hello.o KDIR := /lib/modules/$(shell uname −r)/buildPWD := $(shell pwd) default : $(MAKE) −C $(KDIR) M=$(PWD) modulesclean : $(MAKE) −C $(KDIR) M=$(PWD) clean
Monday, June 28, 2010
![Page 16: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/16.jpg)
Liga
BIOS/EFI
Bootloader (GRUB/Lilo/U-boot)
Kernel (modo real)
Kernel (modo protegido)
Processo init
Processos dos usuários
Monday, June 28, 2010
![Page 17: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/17.jpg)
Liga
BIOS/EFI
Bootloader (GRUB/Lilo/U-boot)
Kernel (modo real)
Kernel (modo protegido)
Processo init
Processos dos usuários
Monday, June 28, 2010
![Page 18: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/18.jpg)
Liga
BIOS/EFI
Bootloader (GRUB/Lilo/U-boot)
Kernel (modo real)
Kernel (modo protegido)
Processo init
Processos dos usuários
Monday, June 28, 2010
![Page 19: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/19.jpg)
Sincronismo
• Spinlocks • Mutexes• Operações atômicas
Monday, June 28, 2010
![Page 20: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/20.jpg)
Sincronismo
• Spinlocks • Mutexes• Operações atômicas
Monday, June 28, 2010
![Page 21: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/21.jpg)
Sincronismo
• Spinlocks • Mutexes• Operações atômicas
#include <linux/spinlock .h>
spinlock t mylock = SPIN_LOCK_ULOCKED;
spin_lock(&mylock );/∗ região crítica ∗/ spin_unlock(&mylock );
Monday, June 28, 2010
![Page 22: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/22.jpg)
Sincronismo
• Spinlocks • Mutexes• Operações atômicas
#include <linux/spinlock .h>
spinlock t mylock = SPIN_LOCK_ULOCKED;
spin_lock(&mylock );/∗ região crítica ∗/ spin_unlock(&mylock );
Monday, June 28, 2010
![Page 23: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/23.jpg)
Sincronismo
• Spinlocks • Mutexes• Operações atômicas
#include <linux/spinlock .h>
spinlock t mylock = SPIN_LOCK_ULOCKED;
spin_lock(&mylock );/∗ região crítica ∗/ spin_unlock(&mylock );
#include <linux/mutex .h>
static DEFINE_MUTEX(mymutex);
mutex_lock(&mymutex);/∗ região crítica ∗/ mutex_unlock(&mymutex);
Monday, June 28, 2010
![Page 24: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/24.jpg)
Facilitadores
• Udev - para gerenciamento de nós /dev• Sysfs - exportar informações para os processos do usuário.• Kobjects e Krefs - contador de referências
Monday, June 28, 2010
![Page 25: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/25.jpg)
Udev
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="cdrw", ENV{GENERATED}="1"
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="dvd", ENV{GENERATED}="1"
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="dvdrw", ENV{GENERATED}="1"
/etc/udev/rules.d/70-persistent-cd.rules
Monday, June 28, 2010
![Page 26: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/26.jpg)
Udev
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="cdrw", ENV{GENERATED}="1"
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="dvd", ENV{GENERATED}="1"
ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="ide-1:0", SYMLINK+="dvdrw", ENV{GENERATED}="1"
/etc/udev/rules.d/70-persistent-cd.rules
Monday, June 28, 2010
![Page 27: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/27.jpg)
sysfs
/sys/class/mmc_host/mmc0/device/leds/mmc0::
$ echo “1” > brightness$ cat brightness
kernel-space user-space
Objetos Diretórios
Atributos Arquivos
Relações Links simbólicos
Monday, June 28, 2010
![Page 28: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/28.jpg)
kobject krefs
Contador de referências, para o kernel gerenciar o número de
objetos associados em uma mesma estrutura.
struct kref { atomic_t refcount;}
struct kobject { const char *name;
struct list_head entry;
struct kobject *parent;
struct kset *kset; struct kobj_type *ktype;
struct sysfs_dirent *sd;
struct kref kref;}
Monday, June 28, 2010
![Page 29: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/29.jpg)
Modelo de Driver do Linux
• Devices• Devices drivers• Bus drivers• Devices Classes• Devices Interfaces
O modelo propôs uma representação genérica de objetos:
Monday, June 28, 2010
![Page 30: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/30.jpg)
Modelo de Driver do Linux
• Devices• Devices drivers• Bus drivers• Devices Classes• Devices Interfaces
O modelo propôs uma representação genérica de objetos:
Funções para operar e controlar cada tipo de objeto.
Monday, June 28, 2010
![Page 31: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/31.jpg)
Modelo de Driver do Linux
• Devices• Devices drivers• Bus drivers• Devices Classes• Devices Interfaces
O modelo propôs uma representação genérica de objetos:
Funções para operar e controlar cada tipo de objeto.
Monday, June 28, 2010
![Page 32: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/32.jpg)
Modelo de Driver do Linux
• Devices• Devices drivers• Bus drivers• Devices Classes• Devices Interfaces
O modelo propôs uma representação genérica de objetos:
Funções para operar e controlar cada tipo de objeto.
Um device driver implementa uma ou mais interfaces (devices interfaces) de uma classe de dispositivos (devices classes) para um grupo de dipositivos (devices) em um barramento (bus driver) específico.
Monday, June 28, 2010
![Page 33: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/33.jpg)
USB/Ethernet
Controlador
Ethernet USB
asix.ko
Monday, June 28, 2010
![Page 34: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/34.jpg)
USB/Ethernet
Preenchimento de estruturas:
Monday, June 28, 2010
![Page 35: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/35.jpg)
USB/Ethernet
Preenchimento de estruturas:
Monday, June 28, 2010
![Page 36: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/36.jpg)
USB/Ethernet
Preenchimento de estruturas:
static struct usb_driver asix_driver = { .name = "asix", .id_table = products, .probe = usbnet_probe, .suspend = usbnet_suspend, .resume = usbnet_resume, .disconnect = usbnet_disconnect, .supports_autosuspend = 1,};
Monday, June 28, 2010
![Page 37: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/37.jpg)
USB/Ethernet
Preenchimento de estruturas:
static struct usb_driver asix_driver = { .name = "asix", .id_table = products, .probe = usbnet_probe, .suspend = usbnet_suspend, .resume = usbnet_resume, .disconnect = usbnet_disconnect, .supports_autosuspend = 1,};
Monday, June 28, 2010
![Page 38: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/38.jpg)
USB/Ethernet
Preenchimento de estruturas:
static struct usb_driver asix_driver = { .name = "asix", .id_table = products, .probe = usbnet_probe, .suspend = usbnet_suspend, .resume = usbnet_resume, .disconnect = usbnet_disconnect, .supports_autosuspend = 1,};
static const struct net_device_ops ax88172_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, .ndo_start_xmit = usbnet_start_xmit, .ndo_tx_timeout = usbnet_tx_timeout, .ndo_change_mtu = usbnet_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, .ndo_do_ioctl = asix_ioctl, .ndo_set_multicast_list = ax88172_set_multicast,};
Monday, June 28, 2010
![Page 39: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/39.jpg)
USB/Ethernet
Operações:
Monday, June 28, 2010
![Page 40: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/40.jpg)
USB/Ethernet
Operações:
Monday, June 28, 2010
![Page 41: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/41.jpg)
USB/Ethernet
Operações:
asix_read_cmd
asix_write_cmd
asix_async_cmd_callback
asix_write_cmd_async
asix_rx_fixup
asix_tx_fixup
asix_status
asix_set_sw_mii
asix_set_hw_mii
asix_get_phy_addr
asix_sw_reset
asix_read_rx_ctl
asix_write_rx_ctl
asix_read_medium_status
asix_write_medium_mode
asix_write_gpio
asix_set_multicast
asix_mdio_read
asix_mdio_write
asix_get_phyid
asix_get_wol
asix_set_wol
asix_get_eeprom_len
asix_get_eeprom
asix_get_drvinfo
asix_get_link
asix_ioctl
asix_set_mac_address
ax88172_set_multicast
ax88172_link_reset
ax88172_bind
ax88772_link_reset
ax88772_bind
marvell_phy_init
marvell_led_status
ax88178_link_reset
ax88178_set_mfb
ax88178_change_mtu
ax88178_bind
Monday, June 28, 2010
![Page 42: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/42.jpg)
Conclusão
Monday, June 28, 2010
![Page 43: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/43.jpg)
Crescimento com
pouca manutenção do código.
Monday, June 28, 2010
![Page 44: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/44.jpg)
Padronização das estruturas básicas.
Monday, June 28, 2010
![Page 45: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/45.jpg)
Sistemas Embarcados
Monday, June 28, 2010
![Page 46: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/46.jpg)
LKML et all;
Linux Kernel Mail List
Monday, June 28, 2010
![Page 47: td](https://reader034.fdocumentos.com/reader034/viewer/2022042714/5576f0eed8b42ab22b8b4ed9/html5/thumbnails/47.jpg)
--tmMonday, June 28, 2010