linux module Makefile
²»ÖªµÀÔÚʲçÛʱºò£¬×ªÔØLinux ³öÏÖÁË module ÕâÖÖ¶«Î÷£¬µÄÈ·£¬ËüÊÇ Linux µÄÒ»´ó¸ïС£ÓÐÁË module Ö®ºó£¬Ð´
device driver ²»ÔÙÊÇÒ»Ïî¶ñÃΣ¬ÐÞ¸Ä kernel Ò²²»ÔÙÊÇÒ»¼þÍ´¿àµÄÊÂÁË¡£ÒòΪÄã²»ÐèҪÿ´ÎÒª²âÊÔ driver ¾ÍÖØÐÂ
compile kernel Ò»´Î¡£ÄǼòÖ±ÊÇ»áÀÛËÀÈË¡£Module ¿ÉÒÔÔÊÐíÎÒÃǶ¯Ì¬µÄ¸Ä±ä kernel£¬¼ÓÔØ device
driver£¬¶øÇÒËüÒ²ÄÜËõ¶ÌÎÒÃÇ driver development µÄʱ¼ä¡£ÔÚÕâÆªÎÄÕÂÀÎÒ½«Òª¸ú¸÷λ½éÉÜһϠmodule
µÄÔÀí£¬ÒÔ¼°ÈçºÎдһ¸ö module¡£
module ·Òë³ÉÖÐÎľÍÊÇÄ£¿é£¬²»¹ý£¬ÊÂʵÉÏÈ¥·ÒëÕâ¸ö×ÖÒ»µã¶¼Ã»ÒâÒå¡£ÔÚ½²Ä£¿é֮ǰ£¬ÎÒÏȾÙÒ»¸öÀý×Ó¡£ÏàÐźܶàÈ˶¼Óùý RedHat¡£ÔÚ
RedHat ÀÎÒÃÇ¿ÉÒÔÖ´ÐÐ sndconfig£¬Ëü¿ÉÒÔ°ïÎÒÃÇ config Éù¿¨¡£config
ÍêÖ®ºóÈç¹û×½µÃµ½ÄãµÄÉù¿¨£¬ÄÇÄãµÄÉù¿¨ÂíÉϾͿÉÒÔ¶¯ÁË£¬¶øÇÒ»¹²»ÓÃÖØÐ¼¤»î¼ÆËã»ú¡£ÕâÊÇÔõçÛ×öµÄÄØ ? ¾ÍÊÇ¿¿module¡£module
ÆäʵÊÇÒ»°ãµÄ³ÌÐò¡£µ«ÊÇËü¿ÉÒÔ±»¶¯Ì¬Ôص½ kernel Àï³ÉΪ kernelµÄÒ»²¿·Ö¡£Ôص½ kernel ÀïµÄ module Ëü¾ßÓиú
kernel Ò»ÑùµÄȨÁ¦¡£¿ÉÒÔ access ÈκΠkernel µÄ data structure¡£ÄãÌý¹ý kdebug Âð ? ËüÊÇÓÃÀ´
debug kernel µÄ¡£Ëü¾ÍÊÇÏȽ«Ëü±¾ÉíµÄÒ»¸ö module ÔØµ½ kernel À¶øÔÚ user space µÄ gdb
¾Í¿ÉÒÔ¾ÓɸúÕâ¸ö module ¹µÍ¨£¬µÃÖª kernel ÀïµÄ data structure µÄÖµ£¬³ý´ËÖ®Í⣬»¹¿ÉÒÔ¾ÓÉÔØµ½ kernel µÄ
module È¥¸ü¸Ä kernel Àï data structure¡£
ÎÒÃÇÖªµÀ£¬ÔÚд C ³ÌÐòµÄʱºò£¬Ò»¸ö³ÌÐòÖ»ÄÜÓÐÒ»¸ö main¡£Kernel ±¾ÉíÆäʵҲÊÇÒ»¸ö³ÌÐò£¬Ëü±¾ÉíÒ²Óиö main£¬½Ð
start_kernel()¡£µ±ÎÒÃǰÑÒ»¸ö module ÔØµ½ kernel ÀïµÄʱºò£¬Ëü»á¸ú kernel ÕûºÏÔÚÒ»Æð£¬³ÉΪ kernel
µÄÒ»²¿·Ö¡£Çë¸÷λÏëÏ룬ÄÇ module ¿ÉÒÔÓÐ main Âð ? ´ð°¸ºÜÃ÷ÏԵģ¬ÊÇ No¡£ÀíÓɺܼòµ¥¡£Ò»¸ö³ÌÐòÖ»ÄÜÓÐÒ»¸ö main¡£ÔÚʹÓÃ
module ʱ£¬ÓÐÒ»µãÒª¼ÇסµÄÊÇ module ÊÇ´¦ÓÚ±»¶¯µÄ½ÇÉ«¡£ËüÊÇÌṩijЩ¹¦ÄÜÈñðÈËȥʹÓõġ£
Kernel ÀïÓÐÒ»¸ö±äÁ¿½Ð module_list£¬Ã¿µ± user ½«Ò»¸ö module ÔØµ½ kernel ÀïµÄʱºò£¬Õâ¸ö module
¾Í»á±»¼Ç¼ÔÚ module_list ÀïÃæ¡£µ± kernel ҪʹÓõ½Õâ¸ö module ÌṩµÄ function ʱ£¬Ëü¾Í»áÈ¥ search
Õâ¸ö list£¬ÕÒµ½ module£¬È»ºóÔÙʹÓÃÆäÌṩµÄ function »ò variable¡£Ã¿Ò»¸ö module ¶¼¿ÉÒÔ export
һЩ function »ò±äÁ¿À´ÈñðÈËʹÓᣳý´ËÖ®Í⣬module Ò²¿ÉÒÔʹÓÃÒÑ¾ÔØµ½ kernel ÀïµÄ module ÌṩµÄ
function¡£ÕâÖÖÇéÐνÐ×ö module stack¡£±È·½Ëµ£¬mod
Ïà¹ØÎĵµ£º
ǶÈëʽLinux²Ù×÷ϵͳѧϰ¹æ»®
ARM+LINUX·Ïߣ¬Ö÷¹¥Ç¶ÈëʽLinux²Ù×÷ϵͳ¼°ÆäÉÏÓ¦ÓÃÈí¼þ¿ª·¢Ä¿±ê£º
£¨1£© ÕÆÎÕÖ÷Á÷ǶÈëʽ΢´¦ÀíÆ÷µÄ½á¹¹ÓëÔÀí£¨³õ²½¶¨Îªarm9£©
£¨2£© ±ØÐëÕÆÎÕÒ»¸öǶÈëʽ²Ù×÷ϵͳ £¨³õ²½¶¨Îªuclinux»òlinux,°æ±¾´ý¶¨£©
£¨3£© ±ØÐëÊìϤǶÈëʽÈí¼þ¿ª·¢Á÷³Ì²¢ÖÁÉÙ×öÒ ......
vmstat 5 10 ºÍ vmstat -d
r-->;ÔÚÔËÐжÓÁÐÖеȴýµÄ½ø³ÌÊý
b-->;ÔڵȴýioµÄ½ø³ÌÊý
w-->;¿ÉÒÔ½øÈëÔËÐжÓÁе«±»Ìæ»»µÄ½ø³Ì
memoy
swap-->;ÏÖʱ¿ÉÓõĽ»»»Äڴ棨k±íʾ£©
free-->;¿ÕÏеÄÄڴ棨k±íʾ£©
pages
re££¡·»ØÊÕµÄÒ³Ãæ
mf££¡··ÇÑÏÖØ´íÎóµÄÒ³Ãæ
pi££¡·½øÈëÒ³ÃæÊý£¨k±íʾ£©
po£ ......
Book Note: Linux Device Driver Dos and Don'ts
http://janitor.kernelnewbies.org/docs/driver-howto.html
what a hardened (robust) device
driver should mean and how it should be implemented and measured.
1.3 Robust device drivers
-Follows the Linux CodingStyle.
-Efficient in managing faults and ha ......
¾¹ýÉÏÊöµÄ¼¸¸ö²½Öè¡£µÚÒ»¸öÄ¿±ê£¬´úÂëÄܹ»±àÒëͨ¹ý»ù±¾ÉÏÊDz»»áÓÐʲôÎÊÌâµÄ¡£Ö»Òª°ÑÎպöþ¸öÐ޸ĴúÂëµÄ»ù±¾ÔÔò£¬µÚÒ»¡£ÒýÈëеĴúÂ룬¶ø²»ÐÞ¸ÄÔÓеĴúÂë¡£ÔÚûÓа취½øÐе÷ÊÔǰÐÞ¸ÄÔ´´úÂëÊDz»ÔÊÐíµÄ£¬Ð޸ĵIJ»ºÃ¾Í»áÒýÆð×îºó´úÂëÔËÐÐÂß¼µÄ»ìÂÒ£¬¶øÇÒÔÚ´úÂëÄܹ»ÔËÐÐ֮ǰÊǺÜÄÑ·¢ÏÖÎÊÌâµÄ¡£ËùÒÔ³ý·Ç·Ç³£ÓаÑÎÕ£¬·ñÔò²»Òª ......
WindowsÓëLinuxÖеĻ»ÐÐÊDz»Ò»ÑùµÄ£¬ÒѾÓöµ½¹ýºÃ¼¸´ÎÎÊÌâÁË¡«ÅúÁ¿Ð½¨Óû§µÄʱºò£¬ÐÂÓû§²»ÄܵǼ£¬ÒòΪÎÒµÄÎı¾ÊÇÔÚWindowsÏÂÉú³ÉµÄ£¬»»ÐÐÊÇWindows¸ñʽ£¬¶øLinuxÖÐʹÓÃnewusersÃüÁîµ¼Èëµ½passwdÎļþ£¬ÊÇÖ±½Ó¸´ÖƹýÈ¥µÄ¡«²»ÄÜÒ»ÐÐÒ»Ðеĸİ¡¡«ºÇºÇ£¬¸Õ¸Õѧµ½ÁËÒ»ÕС£
×Ö·ûÎļþÔÚÁ½¸öϵͳ֮¼ä¿½±´Ö®ºó£¬¿ÉÒÔʹÓÃdos2unix» ......