Introduction to Linux device driver 潘仁義
The role of device driver Flexible Mechanism? Policy? 只提供存取硬體的能力,而不加諸任何限制 介於『應用程式』與『硬體裝置』的軟體層 功能性 ? 簡潔性 ?
Splitting the Kernel
Classes of devices and modules Character device Can be accessed as a stream of bytes open, close, read, write /dev/console Block device Can host a filesystem and transfer any number of bytes at a time mount a filesystem Network interface Can exchange data with other hosts packet transmission
Kernel compile and installation Version above Kernel source Make kernel cd /usr/src/linux make clean make menuconfig make dep; make bzImage make modules; make modules_install cp arch/i386/boot/bzImage /boot/vmlinuz cp.config /boot/config cp System.map /boot/System.map lilo; reboot; dmesg
/usr/src/linux directory kernel/ 除了 fs, mm, networking 外的核心碼 fs/ File system mm/ Memory management net/ Socket library, Protocol stack ipc/ and lib/ Include/ and arch/ driver/ driver/char, driver/block, driver/net
Linux booting process A Guided Tour of a Linux Boot tm The Linux Boot Process The Linux Kernel HOWTO howto/linux_boot_process.html
Demo example Source Make cd ~/ldd2/misc-modules/ make clean; make Oops? cd /usr/include/ mv linux linux.orig ln –s /usr/src/linux/include/linux/ linux mv asm asm.orig ln –s /usr/src/linux/include/linux/acm/ asm Oops? Again make export.ver #include Run tail – f /var/log/messages insmod./hello.o MODULE_LICENSE( “ GPL ” )
作業 裝一台 linux, compile kernel, boot 裝上 demo code, 執行 eCos eCos home eCosCentric WebCast: A License-Free Alternative RTOS for the G4 PowerPC