Interrupt in Linux£¨Ó²¼þƪ£©—— APIC2
1.2.2 LAPIC
ÊÕµ½À´×ÔIOAPICµÄÖжÏÏûÏ¢ºó£¬LAPIC»á½«¸ÃÖжϽ»ÓÉCPU´¦Àí¡£ºÍIOAPIC±È½Ï£¬LAPIC¾ßÓиü¶àµÄ¼Ä´æÆ÷ÒÔ¼°¸ü¸´ÔӵĻúÖÆ¡£µ«¶ÔÓÚ´¦ÀíÀ´×ÔIOAPICµÄÖжÏÏûÏ¢£¬×îÖØÒªµÄ¼Ä´æÆ÷»¹ÊÇIRR¡¢ISRÒÔ¼°EOI¡£
ͼ1-4ÏÔʾÁËx86ƽ̨ÉÏ£¬IRRºÍISRµÄ¸ñʽ£º
ͼ1-4 IRR¡¢ISR¹¹³É
ÓëPICÖеÄIRR¡¢ISR²»Í¬µÄÊÇ£¬LAPICµÄISR¡¢IRR¾ùΪ256bit¼Ä´æÆ÷£¬¶ÔÓ¦x86ƽ̨ÉϵÄ256¸öÖжÏvector£¬ÆäÖÐ0~15Ϊ¼Ü¹¹Ô¤Áô¡£
u IRR£º¹¦ÄܺÍPICµÄÀàËÆ£¬´ú±íLAPICÒѽÓÊÕÖжϣ¬µ«»¹Î´½»CPU´¦Àí¡£
u ISR£º¹¦ÄܺÍPICÀàËÆ£¬´ú±íCPUÒÑ¿ªÊ¼´¦ÀíÖжϣ¬µ«»¹Î´Íê³É¡£ÓëPICÓÐËù²»Í¬µÄÊÇ£¬µ±CPUÕýÔÚ´¦ÀíijÖжÏʱ£¬Í¬ÀàÐÍÖжÏÈç¹û·¢Éú£¬ÏàÓ¦µÄIRR bit»áÔÙ´ÎÖÃÒ»£¨PICģʽÏ£¬Í¬ÀàÐ͵ÄÖжϱ»ÆÁ±Î£©£»Èç¹ûijÖжϱ»pendingÔÚIRRÖУ¬Í¬ÀàÐ͵ÄÖжϷ¢Éú£¬ÔòISRÖÐÏàÓ¦µÄbit±»ÖÃÒ»¡£Õâ˵Ã÷ÔÚAPICϵͳÖУ¬Í¬Ò»ÀàÐÍÖжÏ×î¶à¿ÉÒÔ±»¼ÆÊýÁ½´Î£¨Ï벻ͨʲôÒâ˼£¿Ï벻ͨ¾ÍÁªÏëÒ»ÏÂLinux¿ÉÐÅÐźţ©¡£³¬¹ýÁ½´Îʱ£¬²»Í¬¼Ü¹¹´¦Àí²»Ò»Ñù¡£¶ÔÓÚPentiumϵÁÐCPUºÍP6¼Ü¹¹£¬ÖжÏÏûÏ¢±»LAPIC¾Ü¾ø£»¶ÔÓÚPentium4ºÍXeonϵÁУ¬ÐÂÀ´µÄÖжϺÍIRRÖжÔÓ¦µÄbitÖصþ¡£
±ÊÕߣºÉÏͼ»¹ÓиöTMR¼Ä´æÆ÷£¬¼´Trigger Mode Register£¬ÓÃÓÚ±íʾµ±Ç°ÕýÔÚ´¦ÀíÖжϵĴ¥·¢Ä£Ê½¡£1Ϊlevel£¬0Ϊedge¡£¶ÔÓÚlevel´¥·¢µÄÖжϣ¬µ±Èí¼þдEOIʱ£¬»á±»¹ã²¥µ½ËùÓÐIOAPIC£¬ÏûÏ¢Öк¬ÓÐÖжϵÄvector£¬IOAPICÊÕµ½ºó¼ì²é×Ô¼ºµÄPRT±í£¬°ÑÏàÓ¦RTEµÄRemote IRRλÇåÁã¡£
¶ÔÓÚIRR£¬x86 spec˵£º“µ±CPU×¼±¸´¦ÀíÖжÏʱ£¬IRRÖÐ×î¸ßÓÅÏȼ¶µÄbit±»ÇåÁ㣬ISRÖжÔÓ¦bit±»ÖÃÒ»”¡£ÕâÑù˵²»ÄÜËã´í£¬µ«ÖÁÉÙ²»×¼È·¡£¸ù¾Ý¡¶Multi-Processor Computer System With Interrupt Controllers Providing Remote Reading¡·Ò»ÎÄÖÐAPICµÄʵÏÖ£¬Ö»ÓжÔÓÚedge´¥·¢µÄÖжϣ¬ISR¶ÔÓ¦bitÖÃһʱIRRÏàÓ¦ bit²ÅÇåÁã¡£¶ÔÓÚlevel´¥·¢£¬IRRÖеÄbit±£Áôµ½Èí¼þдEOI£¬LAPICÊÕµ½IOAPIC·¢³öµÄLevel-deassertÏûÏ¢ºó²ÅÇåÁã¡£
Èç¹ûÄã×Ðϸ¿´ÁËÇ°Ãæ¹ØÓÚRemote IRRµÄ½éÉÜ£¬´Ëʱһ¶¨»á²úÉúÒ»¸öÒÉÎÊ¡£ÕâÀï˵ͬÀàÐÍÖжϷ¢ÉúÁ½´Î£¬»áͬʱPendingÔÚISRºÍIRRµÄ¶ÔÓ¦bitÖС£ÎÊÌâÊÇ£¬Ç°ÃæRemote IRRµÄÒì»òÂß¼±£Ö¤ÁËÔÚдEOIÇ°£¬ÐµÄÖжϲ»»á·¢¹ýÀ´°¡£¿ºÇºÇ£¬»òÐíÄãÏëµ½´ð°¸ÁË£¬ÕâÖÖpendingÁ½´ÎµÄ»úÖÆ£¬Ö»¶Ôedge´¥·¢ÖжÏÓÐЧ¡£
ÓëPICÒ»Ñù£¬LAPICͬÑùÐèÒªÈí¼þдEOIÀ´Öª»áÖжϴ¦ÀíµÄÍê³É£¬²»Í¬µÄÊÇ£¬LAPICÖеÄEOIÊÇÒ»¸ö32bit¼Ä
Ïà¹ØÎĵµ£º
ÔÚSolarisÉÏÃ湤×÷Óм¸¸ö²»·½±ãµØ·½:
Ò»¸öÊÇls²»ÄÜ°´ÕÕÎļþÀàÐÍÏÔʾÑÕÉ«;
ÁíÒ»¸öÊÇVIÒ²²»ÄÜÏÔÏÖÓ﷨ɫ²Ê;
ÕâÀï¾ÍÀ´ËµÃ÷ÈçºÎ½â¾öÕâÁ½¸öÎÊÌâ:
ÆäʵÕâÁ½¸öÎÊÌⶼÊÇSolaris×ÔÉíËù´øµÄlsºÍvi°æ±¾µÄÎÊÌâ;
ËùÒÔ½â¾ö°ì·¨¾ÍÊÇÏÂÔØ×îеÄlsºÍvimÔ´Îļþ°üÖØбàÒë½øÐа²×°,¿´ÉÏÈ¥ºÃÏñͦÂé·³,Æäʵ¾Í¼¸²½,ºÜ¼òµ¥µÄ:
×îеÄlsÊÇÔÚ ......
ÎÒÃÇÖªµÀ£¬´ÓCMOSÖжÁ³öÀ´µÄϵͳʱ¼ä²¢²»ÊÇtime_tÀàÐÍ£¬¶øÊÇÀàËÆÓÚstruct tmÄÇÑù£¬ÄêÔÂÈÕʱ·ÖÃëÊÇ·Ö¿ª´æ´¢µÄ¡£
ÄÇô£¬Òª°ÑËüת»¯ÎªÏµÍ³±ãÓÚ´¦ÀíµÄtime_tÀàÐÍ£¬¾ÍÐèÒªËã·¨½øÐÐת»»¡£
ÎÒÃǶ¼ÖªµÀÎÒÃǵĹ«Àú»¹ÊDZȽϸ´Ôӵģ¬ÓдóÔÂСÔ£¬ÓÐÈòÄê·ÇÈòÄ꣬´¦ÀíÆðÀ´»áºÜÂé·³¡£
&n ......
ѧϰӦ¸ÃÊÇÒ»¸öÏÈ°ÑÎÊÌâ¼òµ¥»¯£¬ÔÚ°ÑÎÊÌ⸴ÔÓ»¯µÄ¹ý³Ì¡£Ò»¿ªÊ¼¾Í×ÅÊÖ´¦Àí¸´ÔÓµÄÎÊÌ⣬ÄÑÃâÈà ÈËÓÐÐľªµ¨²ü£¬×½½ó¼ûÖâµÄ¸Ð¾õ¡£¶ÁLinuxÍø¿¨Çý¶¯Ò²ÊÇÒ»Ñù¡£Ädz¤³¤µÄÔ´Âë¼ÐÔÓ×ÅÄÇЩÎÒÃÇÄ°ÉúµÄ±äÁ¿ºÍ·ûºÅ£¬Íû¶øÉúη±ãÊÇÀíËùµ±È»µÄÁË¡£²»Òªµ£ÐÄ£¬ÊÂÇé ×ÜÓнâ¾öµÄ°ì·¨£¬ÏÈ°ÑһЩÎÒÃǹܲ»×ŵĴúÂëÇиî³öÈ¥£¬ÁôϱØÐëµÄ²¿·Ö£¬°Ñ¿ò¼ÜÕ ......
ÔÚ¿´LKD(µÚ¶þ°æ)µÚÁùÕÂ(ÖжϺÍÖжϴ¦Àí³ÌÐò)µÄʱºò£¬¸Õ¿ªÊ¼½Ó´¥µ½ÖжÏÏߺź͹²ÏíÖжÏÏßµÄʱºò°ëÌìã¶ÊÇûÓÐÏëÃ÷°×£¬ÔÀ´Àí½âµÄÖжϺÍÖжϺÍÖжϴ¦Àí³ÌÐò¾ÍÊÇͨ¹ýÖжÏÏߺÅÀ´½øÐйØÁª£¬Ó²¼þ·¢ÉúÖжϣ¬È»ºóͨ¹ýÖжÏÏߺŲéÕÒ¶ÔÓ¦µÄÖжϴ¦Àí³ÌÐò£¬×îºóÖжϴ¦Àí³ÌÐò·µ»Ø£¬´Ë´ÎÖжÏÔò´¦ÀíÍê±Ï£¬Ã»Ïë ......
1.2ÏÖ´úµÄAPIC
APICËäºÅ³ÆÏÖ´ú£¬µ«Ò²³öÏÖ10¼¸ÄêÁË£¬PC»úÊг¡×ÜÊǺÜÍí²ÅÄܽӴ¥µ½Ðµļ¼Êõ£¬Ç°Ãæ˵ÁË£¬ÎÒµÄT42ÓõĻ¹ÊÇPICÄØ¡£APICÏà½ÏÓÚPICÀ´Ëµ£¬×î´óµÄÓŵãÊÇÄÜÊÊÓÃÓÚMPƽ̨£¬µ±È»£¬¹Ü½Å¶àÊÇËüÁíÒ»¸öÓŵ㡣APICÓÉÁ½²¿·Ö×é³É£¬Ò»¸ö³ÆΪLAPIC£¨Local APIC£¬±¾µØ¸ß¼¶ÖжϿØÖÆÆ÷£©£¬Ò»¸ö³ÆΪIOAPIC£¨I/O APCI£¬I/O¸ß¼¶ÖжϿØÖÆ ......