title: Setting up IRQ mapping
body: <p>I'm following several tutorials and references trying to get my kernel set up. I've come across some unfamiliar code in a tutorial that isn't explaining it at all. It's code that I'm told maps the <code>16 IRQs (0-15)</code> to ISR locations <code>32-47</code>:</p>
  
  <pre><code>void irq_remap(void)
  {
      outportb(0x20, 0x11);
      outportb(0xA0, 0x11);
      outportb(0x21, 0x20);
      outportb(0xA1, 0x28);
      outportb(0x21, 0x04);
      outportb(0xA1, 0x02);
      outportb(0x21, 0x01);
      outportb(0xA1, 0x01);
      outportb(0x21, 0x0);
      outportb(0xA1, 0x0);
  }
  </code></pre>
  
  <p>The code for <code>outportb()</code> is as follows, but I already have a clear grasp of what its doing:</p>
  
  <pre><code>void outPortB(unsigned short port, unsigned char data)
  {
      __asm__ __volatile__ ("outb %1, %0" : : "dN" (port), "a" (data));
  }
  </code></pre>
  
  <p>I should mention that this is on x86 architecture in protected mode. This source code works fine and I understand what it does, but I don't understand how it does it. Can someone explain to me what's going on here, so that in case I need to expand on this I will know what I'm doing?</p>