Introduction to Linux device driver Splitting the Kernel









- Slides: 9
Introduction to Linux device driver 潘仁義
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 2. 4. 10 above Kernel source http: //www. kernel. org/ Make kernel cd /usr/src/linux make clean make menuconfig make dep; make bz. Image make modules; make modules_install cp arch/i 386/boot/bz. Image /boot/vmlinuz-2. 4. 24 cp. config /boot/config-2. 4. 24 cp System. map /boot/System. map. 2. 4. 24 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/char, driver/block, driver/net
Linux booting process A Guided Tour of a Linux Boot http: //ourworld. compuserve. com/homepages/Kanji. Flash/BPTour. h tm The Linux Boot Process http: //oldfield. wattle. id. au/luv/boot. html The Linux Kernel HOWTO http: //24. 221. 230. 253/HOWTO/kernelhowto/linux_boot_process. html
Demo example Source http: //www. oreilly. com. tw/chinese/linux/ldd 2. html http: //www. oreilly. com. tw/bookcode/ldd 2 -samples-1. 0. 2. tar. gz Make cd ~/ldd 2/misc-modules/ make clean; make Oops? cd /usr/include/ mv linux. orig ln –s /usr/src/linux/include/linux/ linux mv asm. orig ln –s /usr/src/linux/include/linux/acm/ asm Oops? Again make export. ver #include<slab. h> Run tail –f /var/log/messages insmod. /hello. o MODULE_LICENSE(“GPL”)
作業 裝一台linux, compile kernel, boot 裝上demo code, 執行 e. Cos home http: //www. ecos. sourceware. org/ e. Cos. Centric http: //www. ecoscentric. com/ Web. Cast: A License-Free Alternative RTOS for the G 4 Power. PC http: //seminar 2. techonline. com/~pentek 22/sep 2303/index. shtml