140 likes | 355 Views
Linux Device Driver. NCTU OS Lab Chi-Wei Yang. Outline. Overall Architecture Character Driver Block Driver Network Driver Support Functions. Overall Architecture. VFS Driver Types character block network. Overall Architecture (cont.). Overall Architecture (cont.). Operation Modes
E N D
Linux Device Driver NCTU OS Lab Chi-Wei Yang
Outline • Overall Architecture • Character Driver • Block Driver • Network Driver • Support Functions
Overall Architecture • VFS • Driver Types • character • block • network
Overall Architecture (cont.) • Operation Modes • polling • interrupt • DMA
Character Driver • Device Properties • can’t be randomly accessed • can’t be buffered • usually are slow devices • Export Interface • file_operations • Data Flow in read/write
Block Driver • Device Properties • can be randomly accessed • accessed in units of blocks • to speed up access, buffer cache is used • Export Interface • file_operations • request_fn() • Data Flow in read/write
Network Driver • Export Interface • Data Flow in read/write
Support Functions • I/O ports reservations • request_region() • Memory Allocations • kmalloc(), vmalloc(), get_free_page() • Interrupt Handler Registration • request_irq() • Data Transfer between User/Kernel • memcpy_fromfs()
Support Functions (cont.) • Bottom Halves • mark_bh() • its main purpose is to provide fewer blocking time due to interrupts • top half/bottom half • priority-based • limitions in writing bottom halves • can't call schedule(), can't block