Linux»·¾³½ø³Ì¼äͨÐÅ£¨Î壩: ¹²ÏíÄڴ棨ÉÏ£©
ÎĵµÑ¡Ïî
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º ³õ¼¶
Ö£ÑåÐË (mlinux@163.com), ¹ú·À¿Æ´ó¹¥¶Á²©Ê¿Ñ§Î»
2003 Äê 5 ÔÂ 01 ÈÕ
¹²ÏíÄÚ´æ¿ÉÒÔ˵ÊÇ×îÓÐÓõĽø³Ì¼äͨÐÅ·½Ê½£¬Ò²ÊÇ×î¿ìµÄIPCÐÎʽ¡£Á½¸ö²»Í¬½ø³ÌA¡¢B¹²ÏíÄÚ´æµÄÒâ˼ÊÇ£¬Í¬Ò»¿éÎïÀíÄÚ´æ±»Ó³Éäµ½½ø³ÌA¡¢B¸÷×ԵĽø³ÌµØÖ·¿Õ¼ä¡£½ø³ÌA¿ÉÒÔ¼´Ê±¿´µ½½ø³ÌB¶Ô¹²ÏíÄÚ´æÖÐÊý¾ÝµÄ¸üУ¬·´Ö®ÒàÈ»¡£ÓÉÓÚ¶à¸ö½ø³Ì¹²Ïíͬһ¿éÄÚ´æÇøÓò£¬±ØÈ»ÐèҪijÖÖͬ²½»úÖÆ£¬»¥³âËøºÍÐźÅÁ¿¶¼¿ÉÒÔ¡£
²ÉÓù²ÏíÄÚ´æͨÐŵÄÒ»¸öÏÔ¶øÒ×¼ûµÄºÃ´¦ÊÇЧÂʸߣ¬ÒòΪ½ø³Ì¿ÉÒÔÖ±½Ó¶ÁдÄڴ棬¶ø²»ÐèÒªÈκÎÊý¾ÝµÄ¿½±´¡£¶ÔÓÚÏñ¹ÜµÀºÍÏûÏ¢¶ÓÁеÈͨÐÅ·½Ê½£¬ÔòÐèÒªÔÚÄں˺ÍÓû§¿Õ¼ä½øÐÐËĴεÄÊý¾Ý¿½±´£¬¶ø¹²ÏíÄÚ´æÔòÖ»¿½±´Á½´ÎÊý¾Ý[1]£ºÒ»´Î´ÓÊäÈëÎļþµ½¹²ÏíÄÚ´æÇø£¬ÁíÒ»´Î´Ó¹²ÏíÄÚ´æÇøµ½Êä³öÎļþ¡£Êµ¼ÊÉÏ£¬½ø³ÌÖ®¼äÔÚ¹²ÏíÄÚ´æʱ£¬²¢²»×ÜÊǶÁдÉÙÁ¿Êý¾Ýºó¾Í½â³ýÓ³É䣬ÓÐеÄͨÐÅʱ£¬ÔÙÖØн¨Á¢¹²ÏíÄÚ´æÇøÓò¡£¶øÊDZ£³Ö¹²ÏíÇøÓò£¬Ö±µ½Í¨ÐÅÍê±ÏΪֹ£¬ÕâÑù£¬Êý¾ÝÄÚÈÝÒ»Ö±±£´æÔÚ¹²ÏíÄÚ´æÖУ¬²¢Ã»ÓÐд»ØÎļþ¡£¹²ÏíÄÚ´æÖеÄÄÚÈÝÍùÍùÊÇÔÚ½â³ýÓ³Éäʱ²Åд»ØÎļþµÄ¡£Òò´Ë£¬²ÉÓù²ÏíÄÚ´æµÄͨÐÅ·½Ê½Ð§ÂÊÊǷdz£¸ßµÄ¡£
LinuxµÄ2.2.xÄÚºËÖ§³Ö¶àÖÖ¹²ÏíÄڴ淽ʽ£¬Èçmmap()ϵͳµ÷Óã¬Posix¹²ÏíÄڴ棬ÒÔ¼°ÏµÍ³V¹²ÏíÄÚ´æ¡£linux·¢Ðа汾ÈçRedhat 8.0Ö§³Ömmap()ϵͳµ÷Óü°ÏµÍ³V¹²ÏíÄڴ棬µ«»¹Ã»ÊµÏÖPosix¹²ÏíÄڴ棬±¾ÎĽ«Ö÷Òª½éÉÜmmap()ϵͳµ÷Óü°ÏµÍ³V¹²ÏíÄÚ´æAPIµÄÔÀí¼°Ó¦Óá£
Ò»¡¢ÄÚºËÔõÑù±£Ö¤¸÷¸ö½ø³ÌÑ°Ö·µ½Í¬Ò»¸ö¹²ÏíÄÚ´æÇøÓòµÄÄÚ´æÒ³Ãæ
1¡¢page cache¼°swap cacheÖÐÒ³ÃæµÄÇø·Ö£ºÒ»¸ö±»·ÃÎÊÎļþµÄÎïÀíÒ³Ã涼פÁôÔÚpage cache»òswap cacheÖУ¬Ò»¸öÒ³ÃæµÄËùÓÐÐÅÏ¢ÓÉstruct pageÀ´ÃèÊö¡£struct pageÖÐÓÐÒ»¸öÓòΪָÕëmapping £¬ËüÖ¸ÏòÒ»¸östruct address_spaceÀàÐͽṹ¡£page cache»òswap cacheÖеÄËùÓÐÒ³Ãæ¾ÍÊǸù¾Ýaddress_space½á¹¹ÒÔ¼°Ò»¸öÆ«ÒÆÁ¿À´Çø·ÖµÄ¡£
2¡¢ÎļþÓëaddress_space½á¹¹µÄ¶ÔÓ¦£ºÒ»¸ö¾ßÌåµÄÎļþÔÚ´ò¿ªºó£¬Äں˻áÔÚÄÚ´æÖÐΪ֮½¨Á¢Ò»¸östruct inode½á¹¹£¬ÆäÖеÄi_mappingÓòÖ¸ÏòÒ»¸öaddress_space½á¹¹¡£ÕâÑù£¬Ò»¸öÎļþ¾Í¶ÔÓ¦Ò»¸öaddress_space½á¹¹£¬Ò»¸öaddress_spaceÓëÒ»¸öÆ«ÒÆÁ¿Äܹ»È·¶¨Ò»¸öpage cache »òswap cacheÖеÄÒ»¸öÒ³Ãæ¡£Òò´Ë£¬µ±ÒªÑ°Ö·Ä³¸öÊý¾Ýʱ£¬ºÜÈÝÒ׸ù¾Ý¸ø¶¨µÄÎļþ¼°Êý¾ÝÔÚÎļþÄÚµÄÆ«ÒÆÁ¿¶øÕÒµ½ÏàÓ¦µÄÒ³Ãæ¡£
3¡¢½ø³Ìµ÷ÓÃmmap()ʱ£¬Ö»ÊÇÔÚ½ø³Ì¿Õ¼äÄÚÐÂÔöÁËÒ»¿éÏàÓ¦´óСµÄ»º³åÇø£¬²¢ÉèÖÃÁËÏàÓ¦µÄ·ÃÎʱêʶ£¬
Ïà¹ØÎĵµ£º
´¦ÀíÆ÷µÄ·ÖÀ࣬ÈçÏÂͼËùʾ£º
´æ´¢Æ÷¿É·ÖΪֻ¶Á´æ´¢Æ÷£¨ROM£©¡¢ÉÁ´æ£¨Flash£©¡¢Ëæ»ú´æÈ¡´æ´¢Æ÷£¨RAM£©¡¢¹â½éÖÊ´æ´¢Æ÷ºÍ´Å½éÖÊ´æ´¢Æ÷
Nor FlashºÍcpuµÄ½Ó¿ÚÊôÓÚµäÐ͵ÄÀàSRAM½Ó¿Ú£¬²»ÐèÒªÔö¼Ó¶îÍâµÄ¿ØÖƵç·¡£Nor FlashµÄÌصãÊÇ¿ÉоƬÄÚÖ´ÐУ¬³ÌÐò¿ÉÒÔÖ±½ÓÔÚNorÄÚÔËÐС£¶øNand FashºÍcpuµÄ½Ó¿Ú±ØÐëÓÉÏàÓ¦µÄ¿ØÖƵç·½øÐÐת»»£ ......
ʹÓÃÏÂÁкé¿ÉÒÔͨ¹ýÖ÷É豸ºÅºÍ´ÎÉ豸ºÅÉú³Édev_t
MKDEV(int major, int mainor)
Èç¹û¸´ÖƵÄÄÚ´æÊǼòµ¥ÀàÐÍ£¬Èçchar¡¢int¡¢longµÈ£¬Ôò¿ÉÒÔʹÓüòµ¥µÄput_user()ºÍget_user()
Linuxϵͳ½¨ÒéÒÔÈçͼ·½Ê½¶¨ÒåioctlÃüÁîÂë
ÃüÁËÂëµÄÉ豸ÀàÐÍ×Ö¶ÎΪһ¸ö“»ÃÊý”£¬¿ÉÒÔÊÇ0-0xffÖ®¼äµÄÖµ£¬ÄÚºËÖеÄioctl-number ......
ÖжϣºcpuÔÚÖ´ÐгÌÐòµÄ¹ý³ÌÖУ¬³öÏÖÁËijЩͻ·¢Ê¼þʱcpu±ØÐëÔÝÍ£Ö´Ðе±Ç°µÄ³ÌÐò£¬×ªÈ¥´¦ÀíÍ»·¢Ê¼þ£¬´¦ÀíÍê±ÏºócpuÓÖ·µ»ØÔ³ÌÐò±»ÖжϵÄλÖò¢¼ÌÐøÖ´ÐÐ
¸ù¾ÝÖжÏÈë¿ÚÌøת·½·¨µÄ²»Í¬£¬ÖжϷÖΪÏòÁ¿ÖжϺͷÇÏòÁ¿Öжϡ£
²ÉÓÃÏòÁ¿ÖжϵÄcpuͨ³£Îª²»Í¬µÄÖжϷÖÅ䲻ͬµÄÖжϺţ¬µ±¼ì²âµ½Ä³ÖжϺŵÄÖжϵ½À´ºó£¬¾Í×Ô¶¯Ì ......
Spca5xx ÉãÏñÍ·Çý¶¯ÒÆÖ²£¨For Linux 2.6.14£©
Ò»£®ÏÂÔز¢½âѹSpca5xxÇý¶¯£¬±¾ÎÄʹÓÃÁËgspcav1-20070508°æ±¾¡£
¶þ£®°æ±¾ËµÃ÷£ºÖ®Ç°³¢ÊÔ¹ýspca5xx*µÄ¶à¸ö°æ±¾£¬ËäÈ»ÒÆֲûÓÐÎÊÌ⣬µ«ÊÇÔÚ½øÐÐv4lÓ¦ÓÃʱ£¬³öÏֺܶàĪÃûÆäÃîµÄ´íÎ󣬱ÈÈçISOC data errorµÈ£¬ºóÀ´»»³ÉÁË×îеÄgspca°æ±¾£¬ÎÊÌâÈ«²¿½â¾ö¡£
Èý£®ÍêÕû±àÒëÒÆÖ²ºÃµÄLi ......