示例#1
0
        static unsafe void IRQHandler(IDT.ISRData data)
        {
            uint index = (uint)data.Stack->IrqIndex - 0x20;

            if ((index < 0) || (index > 0x0F))
            {
                return;
            }

            irqs[index] = true;

            if (callBacks[index].callback != null)
            {
                // call the callback methods
                // note this is a temporary solution until threads are implemented

                bool mine = callBacks[index].callback.OnInterrupt(index);

                //if (mine)
                //	irqs[index] = false;
            }
        }
示例#2
0
        private static unsafe void TimerHandler(IDT.ISRData data)
        {
            ticks++;

            for (int x = 0; x < EntryModule.MaxEventHandlers; ++x)
            {
                if (timerEvent[x] == 0)
                {
                    continue;
                }

                MemoryUtil.Call(timerEvent[x], ticks);
            }


            SharpOS.Kernel.ADC.Thread thread = Dispatcher.Dispatch((void *)data.Stack);
            if (thread != null)
            {
                IDT.Stack *newStack = (IDT.Stack *)thread.StackPointer;
                newStack->IrqIndex = data.Stack->IrqIndex;
                data.Stack         = newStack;
            }
        }
示例#3
0
 static unsafe void DivideByZeroHandler(IDT.ISRData data)
 {
     SharpOS.Korlib.Runtime.Runtime.Throw(new InternalSystem.DivideByZeroException(), 4);
 }
示例#4
0
        static unsafe void KeyboardHandler(IDT.ISRData data)
        {
            // Read from the keyboard's data buffer
            byte input;
            uint scancode;
            bool pressed;

            input = IO.ReadByte(IO.Port.KB_data_port);

            /* XXX: why is this commented out?
             *
             * if (input == KeyboardMessages.Too_Many_Keys ||
             *      input == KeyboardMessages.Keyboard_Error)
             * {
             *      // TODO: do something usefull here..
             *      return;
             * }
             *
             */

            if (input == 0xe0)
            {
                input    = IO.ReadByte(IO.Port.KB_data_port);
                scancode = (uint)((input & 0x7F) >> 8) | 0xe0;
                pressed  = (input & 0x80) == 0;
            }
            else if (input == 0xe1)
            {
                input    = IO.ReadByte(IO.Port.KB_data_port);
                scancode = (uint)(input & 0x7F);
                pressed  = (input & 0x80) == 0;
                return;
            }
            else
            {
                scancode = (uint)(input & 0x7F);
                pressed  = (input & 0x80) == 0;
            }

            if (scancode == (uint)Keys.CapsLock)                                                // CapsLock
            {
                if (pressed)
                {
                    if (capsLockReleased)
                    {
                        capsLock = !capsLock;
                    }
                    capsLockReleased = false;
                    SetLEDs();
                }
                else
                {
                    capsLockReleased = true;
                }
                return;
            }
            else if (scancode == (uint)Keys.NumLock)                                    // NumLock
            {
                if (pressed)
                {
                    if (numLockReleased)
                    {
                        numLock = !numLock;
                    }
                    numLockReleased = false;
                    SetLEDs();
                }
                else
                {
                    numLockReleased = true;
                }
                return;
            }
            else if (scancode == (uint)Keys.ScrollLock)                                         // ScrollLock
            {
                if (pressed)
                {
                    if (scrollLockReleased)
                    {
                        scrollLock = !scrollLock;
                    }
                    scrollLockReleased = false;
                    SetLEDs();
                }
                else
                {
                    scrollLockReleased = true;
                }
                return;
            }
            else if (scancode == (uint)Keys.LeftControl)                                 // left control
            {
                leftControl = pressed;
                return;
            }
            else if (scancode == (uint)Keys.LeftShift)                   // left shift
            {
                leftShift = pressed;
                return;
            }
            else if (scancode == (uint)Keys.LeftAlt)                     // left alt
            {
                leftAlt = pressed;
                return;
            }
            else if (scancode == (uint)Keys.RightAlt)                  // right alt
            {
                rightAlt = pressed;
                return;
            }
            else if (scancode == (uint)Keys.RightControl)                  // right control
            {
                rightControl = pressed;
                return;
            }
            else if (scancode == (uint)Keys.RightShift)                  // right shift
            {
                rightShift = pressed;
                return;
            }

            if (pressed)
            {
                for (int x = 0; x < EntryModule.MaxEventHandlers; ++x)
                {
                    if (keyDownEvent [x] == 0)
                    {
                        continue;
                    }

                    MemoryUtil.Call(keyDownEvent [x], scancode);
                }
            }
            else
            {
                for (int x = 0; x < EntryModule.MaxEventHandlers; ++x)
                {
                    if (keyUpEvent [x] == 0)
                    {
                        continue;
                    }

                    MemoryUtil.Call(keyUpEvent [x], scancode);
                }
            }
        }