Guest User

PIT Problem

a guest
Mar 22nd, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. Mit diesem Code initialisiere ich den PIT:
  2.         public static void Mode0(uint frequency)
  3.         {
  4.             dewitcher.Core.IDT.Remap();
  5.             uint divisor = 1193182 / frequency;
  6.             IO.PortIO.outb(0x43, 0x30);
  7.             IO.PortIO.outb(0x40, (byte)(divisor & 0xFF));
  8.             IO.PortIO.outb(0x40, (byte)((divisor >> 8) & 0xFF));
  9.             dewitcher.Core.IRQ.ClearMask(0);
  10.             dewitcher.Core.IRQ.ClearMask(15);
  11.         }
  12.  
  13. Das hier ist der Originalcode für Mode2:
  14.         public static void Mode2(uint frequency)
  15.         {
  16.             dewitcher.Core.IDT.Remap();
  17.             uint divisor = 1193182 / frequency;
  18.             IO.PortIO.outb(0x43, 0x36);
  19.             IO.PortIO.outb(0x40, (byte)(divisor & 0xFF));
  20.             IO.PortIO.outb(0x40, (byte)((divisor >> 8) & 0xFF));
  21.             dewitcher.Core.IRQ.ClearMask(0);
  22.             dewitcher.Core.IRQ.ClearMask(15);
  23.         }
  24.  
  25. Hiermit remappe ich den IDT:
  26.         public static void Remap()
  27.         {
  28.             IO.PortIO.outb(0x20, 0x11);
  29.             IO.PortIO.outb(0xA0, 0x11);
  30.             IO.PortIO.outb(0x21, 0x20);
  31.             IO.PortIO.outb(0xA1, 0x28);
  32.             IO.PortIO.outb(0x21, 0x04);
  33.             IO.PortIO.outb(0xA1, 0x02);
  34.             IO.PortIO.outb(0x21, 0x01);
  35.             IO.PortIO.outb(0xA1, 0x01);
  36.             IO.PortIO.outb(0x21, 0x0);
  37.             IO.PortIO.outb(0xA1, 0x0);
  38.         }
  39.  
  40. Das hier ist der Code für IRQ.ClearMask:
  41.         public static void ClearMask(byte IRQline)
  42.         {
  43.             ushort port;
  44.             byte value;
  45.  
  46.             if (IRQline < 8)
  47.             {
  48.                 port = 0x20 + 1;
  49.             }
  50.             else
  51.             {
  52.                 port = 0xA0 + 1;
  53.                 IRQline -= 8;
  54.             }
  55.             value = (byte)(IO.PortIO.inb(port) & ~(1 << IRQline));
  56.             IO.PortIO.outb(port, value);
  57.         }
Advertisement
Add Comment
Please, Sign In to add comment