{"id":680,"date":"2020-12-05T16:06:11","date_gmt":"2020-12-05T16:06:11","guid":{"rendered":"https:\/\/www.ecsdump.net\/?page_id=680"},"modified":"2020-12-09T06:23:22","modified_gmt":"2020-12-09T11:23:22","slug":"pic-ing","status":"publish","type":"page","link":"https:\/\/www.ecsdump.net\/?page_id=680","title":{"rendered":"PIC&#8211;ing"},"content":{"rendered":"\n<p><strong>Ref:<\/strong> www.jamesmolloy.co.uk https:\/\/wiki.osdev.org\/8259_PIC \/ http:\/\/www.brokenthorn.com\/Resources\/OSDevPic.html<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"302\" src=\"https:\/\/i0.wp.com\/www.ecsdump.net\/wp-content\/uploads\/2019\/07\/8086_interrupts-11.gif?resize=649%2C302&#038;ssl=1\" alt=\"\" class=\"wp-image-542\"\/><\/figure><\/div>\n\n\n\n<p><strong>The IBM PC 8259 PIC Architecture<\/strong><br>In the beginning (IBM PC and XT), only a single 8259 PIC chip was used, which provided 8 IRQs to the system. These were traditionally mapped by the BIOS to interrupts 8 to 15 (0x08 to 0x0F). It is unlikely that any of these single-PIC machines will be encountered these days.<\/p>\n\n\n\n<p><br><strong>The IBM PC\/AT 8259 PIC Architecture<\/strong><br>The IBM PC\/AT extended the PC architecture by adding a second 8259 PIC chip. This was possible due to the 8259A&#8217;s ability to cascade interrupts, that is, have them flow through one chip and into another. This gives a total of 15 interrupts. Why 15 and not 16? That&#8217;s because when you cascade chips, the PIC needs to use one of the interrupt lines to signal the other chip.<br>The low-level concepts behind external interrupts are not very complex. All devices that are interrupt-capable have a line connecting them to the PIC (programmable interrupt controller). The PIC is the only device that is directly connected to the CPU&#8217;s interrupt pin. It is used as a multiplexer, and has the ability to prioritize between interrupting devices. It is, essentially, a glorified 8-1 multiplexer. At some point, someone somewhere realized that 8 IRQ lines just wasn&#8217;t enough, and they daisy-chained another 8-1 PIC beside the original. So in all modern PCs, you have 2 PICs, the master and the slave, serving a total of 15 interruptable devices (one line is used to signal the slave PIC).<br>Only hardware interrupts are handled through the Programmable Interrupt Controller. The special, CPU-dedicated interrupts are shown below.<br><\/p>\n\n\n\n<p>0 &#8211; Division by zero exception<br>1 &#8211; Debug exception<br>2 &#8211; Non maskable interrupt<br>3 &#8211; Break-point exception<br>4 &#8211; &#8216;Into detected overflow&#8217;<br>5 &#8211; Out of bounds exception<br>6 &#8211; Invalid opcode exception<br>7 &#8211; No co-processor exception<br>8 &#8211; Double fault (pushes an error code)<br>9 &#8211; Co-processor segment overrun<br>10 &#8211; Bad TSS (pushes an error code)<br>11 &#8211; Segment not present (pushes an error code)<br>12 &#8211; Stack fault (pushes an error code)<br>13 &#8211; General protection fault (pushes an error code)<br>14 &#8211; Page fault (pushes an error code)<br>15 &#8211; Unknown interrupt exception<br>16 &#8211; Co-processor fault<br>17 &#8211; Alignment check exception<br>18 &#8211; Machine check exception<br>19-31 &#8211; Reserved<br><\/p>\n\n\n\n<p><em>See: Intel\u00ae 64 and IA-32 Architectures Software Developer\u2019s Manual Volume 3 (3A, 3B, 3C &amp; 3D): System Programming Guide &#8211; 6.3.1 External Interrupts<\/em><br>WR Pin: This pin connects to a write strobe signal (One of 8 on a Pentium)<br>RD Pin: This connects to the IOCR (Input Output Control Routine) signal.<br>INT Pin: Connects to the INTR pin on the microprocessor.<br>INTA Pin: Connects to the INTA pin on the microprocessor.<br>A0 Pin: Selects different Command WORDS<br>CS Pin: Enables the chip for programming and control.<br>SP\/EN Pin: Slave program (SP) \/ Enable Buffer (EN).<br>Slave Program (1=Master, 0=Slave)<br>Enable Buffer (Controls data bus transievers when in buffered mode)<br>CAS0, CAS1, CAS2 Pins: Used to output from master to slave PIC controllers in cascaded systems.<br>D0 &#8211; D7 Pins: 8 bit Data connector pins.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>x86 Hardware Interrupts<\/th><\/tr><tr><td>8259A Input pin<\/td><td>Interrupt Number<\/td><td>Description<\/td><\/tr><tr><td>IRQ0<\/td><td>0x08<\/td><td>Timer<\/td><\/tr><tr><td>IRQ1<\/td><td>0x09<\/td><td>Keyboard<\/td><\/tr><tr><td>IRQ2<\/td><td>0x0A<\/td><td>Cascade for 8259A Slave controller<\/td><\/tr><tr><td>IRQ3<\/td><td>0x0B<\/td><td>Serial port 2<\/td><\/tr><tr><td>IRQ4<\/td><td>0x0C<\/td><td>Serial port 1<\/td><\/tr><tr><td>IRQ5<\/td><td>0x0D<\/td><td>AT systems: Parallel Port 2. PS\/2 systems: reserved<\/td><\/tr><tr><td>IRQ6<\/td><td>0x0E<\/td><td>Diskette drive<\/td><\/tr><tr><td>IRQ7<\/td><td>0x0F<\/td><td>Parallel Port 1<\/td><\/tr><tr><td>IRQ8\/IRQ0<\/td><td>0x70<\/td><td>CMOS Real time clock<\/td><\/tr><tr><td>IRQ9\/IRQ1<\/td><td>0x71<\/td><td>CGA vertical retrace<\/td><\/tr><tr><td>IRQ10\/IRQ2<\/td><td>0x72<\/td><td>Reserved<\/td><\/tr><tr><td>IRQ11\/IRQ3<\/td><td>0x73<\/td><td>Reserved<\/td><\/tr><tr><td>IRQ12\/IRQ4<\/td><td>0x74<\/td><td>AT systems: reserved. PS\/2: auxiliary device<\/td><\/tr><tr><td>IRQ13\/IRQ5<\/td><td>0x75<\/td><td>FPU<\/td><\/tr><tr><td>IRQ14\/IRQ6<\/td><td>0x76<\/td><td>Hard disk controller<\/td><\/tr><tr><td>IRQ15\/IRQ7<\/td><td>0x77<\/td><td>Reserved<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>8259A Registers<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Command Register &#8211; This is a write only register that is used to send commands to the microcontroller.<\/li><li>Status register &#8211; This is a read only register that can be accessed to determin the status of the PIC.<\/li><li>Interrupt Request Register (IRR) &#8211; This register specifies which interrupts are pending acknowledgment. Note: This register is internal, and cannot be accessed directly.<\/li><li>In-Sevice Register (ISR) &#8211; This register specifies which interrupts have already been acknowledged, but are awaiting for the End of Interrupt (EOI) signal.<\/li><li>Interrupt Mask Register (IMR) &#8211; This specifies what interrupts are to be ignored, and not acknowledged.<\/li><\/ul>\n\n\n\n<p><strong>Programming with the 8259 PIC<\/strong><br>When the computer boots, the default interrupt mappings are:<br>IRQ 0..7 &#8211; INT 0x8..0xF<br>IRQ 8..15 &#8211; INT 0x70..0x77<br>Each chip (master and slave) has a command port and a data port (given in the table below). When no command is issued, the data port allows us to access the interrupt mask of the 8259 PIC.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Chip &#8211; Purpose<\/td><td>&nbsp;I\/O port<\/td><\/tr><tr><td>Master PIC -Command<\/td><td>0x0020<\/td><\/tr><tr><td>Master PIC &#8211; Data<\/td><td>0x0021<\/td><\/tr><tr><td>Slave PIC -Command<\/td><td>0x00A0<\/td><\/tr><tr><td>Slave PIC &#8211; Data<\/td><td>0x00A1<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Ref: www.jamesmolloy.co.uk https:\/\/wiki.osdev.org\/8259_PIC \/ http:\/\/www.brokenthorn.com\/Resources\/OSDevPic.html The IBM PC 8259 PIC ArchitectureIn the beginning (IBM PC and XT), only a single 8259 PIC chip was used, which provided 8 IRQs to the system. These were traditionally mapped by the BIOS to interrupts 8 to 15 (0x08 to 0x0F). It is unlikely that any of these single-PIC&hellip;<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/www.ecsdump.net\/?page_id=680\" title=\"Continue reading &lsquo;PIC&#8211;ing&rsquo;\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":683,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-templates\/full-width.php","meta":{"footnotes":""},"categories":[4,15],"tags":[61,67,60,53],"wf_page_folders":[69],"class_list":["post-680","page","type-page","status-publish","hentry","category-boot-process","category-hardware","tag-61","tag-hardware","tag-pic","tag-watdos"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages\/680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=680"}],"version-history":[{"count":0,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages\/680\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages\/683"}],"wp:attachment":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=680"},{"taxonomy":"wf_page_folders","embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fwf_page_folders&post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}