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; } }
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); } } }