How to write a Linux driver
1. wrote driver function file(s) .
2. stored in the proper folder, eg: character driver stored in folder drivers/char/
3. modified Makefile in this folder(eg: drivers/char/)
-added configuration at somewhere: type like that "obj-$(CONFIG_TESTDRIVER) += testdriver.o"
4. modified config.in in the same folder
-added configuration at somewhere: type like that "bool 'Mytestdriver' CONFIG_TESTDRIVER"
5. modified mem.c in the same folder
-added initial function of my driver into mem.c with same rule within it.
5. added device node in Makefile in folder vendors/Samsung/4510B
-added parameters(same as command mknod's parameters) in DEVICES section, eg: test, c, 254, 0, which stands for the register driver name, device type(char), major device number, minor device number
6. used command make menuconfig at linux root folder(eg: uClinux-dist) to let my driver choice available
7. re-compiled linux with some commands
That's all!
Ïà¹ØÎĵµ£º
6)Linux³ÌÐòÉè¼ÆÈëÃÅ--ÏûÏ¢¹ÜÀí
ǰÑÔ:LinuxϵĽø³ÌͨÐÅ(IPC)
LinuxϵĽø³ÌͨÐÅ(IPC)
POSIXÎÞÃûÐźÅÁ¿
System VÐźÅÁ¿
System VÏûÏ¢¶ÓÁÐ
System V¹²ÏíÄÚ´æ
1¡£POSIXÎÞÃûÐźÅÁ¿ Èç¹ûÄãѧϰ¹ý²Ù×÷ϵͳ,ÄÇô¿Ï¶¨ÊìϤPV²Ù×÷ÁË.PV²Ù×÷ÊÇÔ×Ó
²Ù×÷.Ò²¾ÍÊDzÙ×÷ÊDz»¿ÉÒÔÖжϵÄ,ÔÚÒ»¶¨µÄʱ¼äÄÚ,Ö»Äܹ»ÓÐÒ»¸ö½ø³ÌµÄ´ ......
1¡¢Í¨¹ýlsmodÀ´»ñµÃÄÚºËÒѼÓÔØÁËÄÇЩģ¿é£¬Õâ¸öÃüÁîÊǶÁÈ¡/proc/modulesÎļþµÄÄÚÈÝÀ´»ñµÃÐÅÏ¢µÄ¡£
2¡¢ÄÚºËÄ£¿é¹ÜÀíÊØ»¤½ø³ÌkmodÖ´ÐÐmodprobeÈ¥¼ÓÔØÄÚºËÄ£¿é¡£modprobeµÄ¹¦ÄܺÍinsmodÀàËÆ£¬µ«ÊÇËü³ýÁË×°ÈëÖ¸¶¨Ä£¿éÍ⣬»¹Í¬Ê±×°ÈëÖ¸¶¨Ä£¿éËùÒÀÀµµÄÆäËûÄ£¿é¡£
3¡¢Èç¹ûÄÚºËÖдò¿ªÁËCONFIG_MODVERSIONSÑ¡Ïî£¬Ô ......
¹¤×÷Öо³£ÐèÒªKill¶à¸ö½ø³Ì£¬Èç¹ûÕâЩ½ø³ÌÓй²Í¬µÄÌØµã£¬¾Í¿ÉÒÔÓÃÒ»ÌõÃüÁîKillµôËüÃÇ¡£
±ÈÈçÇå³ýOracleÊý¾Ý¿âµÄËùÓÐÔ¶³ÌÁ¬½Ó½ø³Ì£º
ps -efww|grep LOCAL=NO|grep -v grep|cut -c 9-15|xargs kill -9
¡¡¡¡¹ÜµÀ·û“|”ÓÃÀ´¸ô¿ªÁ½¸öÃüÁ¹ÜµÀ·û×ó±ßÃüÁîµÄÊä³ö»á×÷Ϊ¹ÜµÀ·ûÓÒ±ßÃüÁîµÄÊäÈë¡£ÏÂÃæËµËµÓà ......
Sun·¢²¼µÄJDK/JREÓÐÁ½ÖÖ°æ±¾£¬Ò»ÖÖÊÇ.rpm.bin¸ñʽµÄ£¬ÁíÒ»ÖÖÔòÊÇ.bin¸ñʽµÄ£¬Ç°ÕßÎÒûÓÐÊÔ£¬µ«ÊÇÎÒÏëÓ¦¸ÃÊÇÊʺÏÓÚrpmµÄ£¬¿ÉÄܻᰲװµ½/usrÀïÃæÈ¥£¬¶øÇÒ×Ô¶¯»¯³Ì¶È¿ÉÒÔ¸ßһЩ¡£ºóÕßÔòÍêÈ«ÊÇÂÌÉ«Èí¼þ£¬Ö»ÊÇ×öÒ»¸ö½âѹµÄ¶¯×÷¡£ÏÂÃæÎÒ¾ÍÀ´½²ºóÕߵݲװȫ¹¥ÂÔ¡£
1¡¢Ê×ÏÈÎÒÃÇÒªµ½SunµÄÍøÕ¾ÉÏÈ¥ÏÂÔØJDK/JRE£¨µãÕâÀï½øÈ룩£¬×îе ......
¹¤×÷¶ÓÁУ¨work queue£©ÊÇÁíÍâÒ»ÖÖ½«¹¤×÷ÍÆºóÖ´ÐеÄÐÎʽ £¬ËüºÍÎÒÃÇÇ°ÃæÌÖÂÛµÄËùÓÐÆäËûÐÎʽ¶¼Óв»Í¬¡£¹¤×÷¶ÓÁпÉÒ԰ѹ¤×÷ÍÆºó£¬½»ÓÉÒ»¸öÄÚºËÏß³ÌÈ¥Ö´ÐУ¬Ò²¾ÍÊÇ˵£¬Õâ¸öϰ벿·Ö¿ÉÒÔÔÚ½ø³ÌÉÏÏÂÎÄÖÐÖ´ÐС£ÕâÑù£¬Í¨¹ý¹¤×÷¶ÓÁÐÖ´ÐеĴúÂëÄÜÕ¼¾¡½ø³ÌÉÏÏÂÎĵÄËùÓÐÓÅÊÆ¡£×îÖØÒªµÄ¾ÍÊǹ¤×÷¶ÓÁÐÔÊÐí±»ÖØÐµ÷¶ÈÉõÖÁÊÇ˯Ãß¡£
ÄÇô£ ......