Linux Device Driver NCTU OS Lab Chi-Wei Yang
Outline b Overall Architecture b Character Driver b Block Driver b Network Driver b Support Functions
Overall Architecture b VFS b Driver Types charactercharacter blockblock networknetwork
Overall Architecture (cont.)
b Operation Modes pollingpolling interruptinterrupt DMADMA
Character Driver b Device Properties can’t be randomly accessedcan’t be randomly accessed can’t be bufferedcan’t be buffered usually are slow devicesusually are slow devices b Export Interface file_operationsfile_operations b Data Flow in read/write
Character Driver (cont.)
Block Driver b Device Properties can be randomly accessedcan be randomly accessed accessed in units of blocksaccessed in units of blocks to speed up access, buffer cache is usedto speed up access, buffer cache is used b Export Interface file_operationsfile_operations request_fn()request_fn() b Data Flow in read/write
Block Driver (cont.)
Network Driver b Export Interface b Data Flow in read/write
Network Driver (cont.)
Support Functions b I/O ports reservations request_region()request_region() b Memory Allocations kmalloc(), vmalloc(), get_free_page()kmalloc(), vmalloc(), get_free_page() b Interrupt Handler Registration request_irq()request_irq() b Data Transfer between User/Kernel memcpy_fromfs()memcpy_fromfs()
Support Functions (cont.) b Bottom Halves mark_bh()mark_bh() its main purpose is to provide fewer blocking time due to interruptsits main purpose is to provide fewer blocking time due to interrupts top half/bottom halftop half/bottom half priority-basedpriority-based limitions in writing bottom halveslimitions in writing bottom halves –can't call schedule(), can't block