private void HandleIRQ(ref INTs.IRQContext aContext) { int T0Delay = (int)T0DelyNS; PITTimer hndlr = null; if (ActiveHandlers.Count > 0) { T0Countdown = 65535; } for (int i = ActiveHandlers.Count - 1; i >= 0; i--) { hndlr = ActiveHandlers[i]; hndlr.NSRemaining -= T0Delay; if (hndlr.NSRemaining < 1) { if (hndlr.Recuring) { hndlr.NSRemaining = hndlr.NanosecondsTimeout; } else { hndlr.ID = -1; ActiveHandlers.RemoveAt(i); } hndlr.HandleTrigger(); } } }
protected void HandleNetworkInterrupt(ref INTs.IRQContext aContext) { UInt32 cur_status = StatusRegister; //Console.WriteLine("AMD PCNet IRQ raised!"); if ((cur_status & 0x100) != 0) { mInitDone = true; } if ((cur_status & 0x200) != 0) { if (mTransmitBuffer.Count > 0) { byte[] data = mTransmitBuffer.Peek(); if (SendBytes(ref data) == true) { mTransmitBuffer.Dequeue(); } } } if ((cur_status & 0x400) != 0) { ReadRawData(); } StatusRegister = cur_status; Cosmos.Core.Global.PIC.EoiSlave(); }
private void HandleIRQ(ref INTs.IRQContext aContext) { uint Status = ReadRegister(0xC0); if ((Status & 0x04) != 0) { //Turn link up LinkUp(); } if ((Status & 0x10) != 0) { //Good threshold } if ((Status & 0x80) != 0) { uint _RXCurr = RXCurr; RXDesc *desc = (RXDesc *)(RXDescs + (RXCurr * 16)); while ((desc->status & 0x1) != 0) { byte[] data = new byte[desc->length]; byte * ptr = (byte *)desc->addr; for (int i = 0; i < desc->length; i++) { data[i] = ptr[i]; } DataReceived(data); desc->status = 0; RXCurr = (RXCurr + 1) % 32; WriteRegister(0x2818, _RXCurr); } } }
public ProcessControlBlock(int priority, string commandLine, string[] args) { ProcessID = ProcessManager.CurrentPid++; Priority = priority; Context = new INTs.IRQContext(); CommandLine = commandLine; Args = args; Status = ProcessStatus.Ready; StatusCode = 0; }
private void HandleIRQ(ref INTs.IRQContext aContext) { byte xScanCode = IO.Port60.Byte; bool xReleased = (xScanCode & 0x80) == 0x80; if (xReleased) { xScanCode = (byte)(xScanCode ^ 0x80); } HandleScancode(xScanCode, xReleased); }
private void HandleIRQ(ref INTs.IRQContext aContext) { var xScanCode = IO.Data.Byte; var xReleased = (xScanCode & 0x80) == 0x80; if (xReleased) { xScanCode = (byte)(xScanCode ^ 0x80); } OnKeyPressed?.Invoke(xScanCode, xReleased); }
private void HandleInterrupt(ref INTs.IRQContext aContext) { ushort sr = pTransferStatus.Word; if ((sr & IRQ_LVBCI) > 0) { // Last Valid Buffer interrupt pTransferStatus.Word = IRQ_LVBCI; } else if ((sr & IRQ_BCIS) > 0) { // Load a buffer ahead int next = lastValidIdx + 1; if (next >= BUFFER_COUNT) { next -= BUFFER_COUNT; } BufferProvider.RequestBuffer(transferBuffer); fixed(byte *mainBufPtr = transferBuffer.RawData) { MemoryOperations.Copy( dest: bufferDescriptorList[next].pointer, src: mainBufPtr, size: bufferSizeBytes ); } // Set the index to the current one lastValidIdx++; if (lastValidIdx == BUFFER_COUNT) { lastValidIdx = 0; } pLastValidEntry.Byte = lastValidIdx; pTransferStatus.Word = IRQ_BCIS; } else if ((sr & IRQ_FIFO_ERROR) > 0) { pTransferStatus.Word = IRQ_FIFO_ERROR; } }
private void HandleInterrupt(ref INTs.IRQContext context) { try { byte status = commandPort.Byte; if ((byte)(status & 20) == 0) { return; } buffer[offset] = dataPort.Byte; offset = (byte)((offset + 1) % 3); if (offset == 0) { for (byte i = 0; i < 3; i++) { if ((buffer[0] & (0x1 << i)) != (buttons & (0x1 << i))) { if ((byte)(buttons & (0x1 << i)) != 0) { MouseManager.MouseState = MouseState.None; } else { MouseManager.MouseState = MouseState.Left; } } } if (buffer[1] != 0 || buffer[2] != 0) { MouseManager.HandleMouse((sbyte)buffer[1], (sbyte)-buffer[2], (int)MouseManager.MouseState, 0); } buttons = buffer[0]; } } catch (sys.Exception ex) { } }
public void HandleMouse(ref INTs.IRQContext context) { if (mMouseCycle == 0) { mMouseByte[0] = IO.Data.Byte; //Bit 3 of byte 0 is 1, then we have a good package if ((mMouseByte[0] & (1 << 3)) == (1 << 3)) { mMouseCycle++; } } else if (mMouseCycle == 1) { mMouseByte[1] = IO.Data.Byte; mMouseCycle++; } else if (mMouseCycle == 2) { mMouseByte[2] = IO.Data.Byte; if (HasScrollWheel) { mMouseCycle++; } } // TODO: move conditions to the if statement when stack corruption detection // works better for complex conditions var xTest1 = (mMouseCycle == 2 && !HasScrollWheel); var xTest2 = (mMouseCycle == 3 && HasScrollWheel); if (xTest1 || xTest2) { int xDeltaX = 0; int xDeltaY = 0; int xScrollWheel = 0; int xMouseState; if ((mMouseByte[0] & (1 << 4)) == (1 << 4)) { xDeltaX = (mMouseByte[1] | ~0xFF); } else { xDeltaX = mMouseByte[1]; } if ((mMouseByte[0] & (1 << 5)) == 1 << 5) { xDeltaY = -(mMouseByte[2] | ~0xFF); } else { xDeltaY = -mMouseByte[2]; } xMouseState = mMouseByte[0] & 0b0000_0111; if (HasScrollWheel) { var xScrollWheelByte = mMouseByte[3] & 0x0F; xScrollWheel = (xScrollWheelByte & 0b1000) == 0 ? xScrollWheelByte : xScrollWheelByte | ~0x0F; if (mMouseID == 4) { var xAdditionalButtonsByte = mMouseByte[3] & 0b0011_0000; xMouseState |= (xAdditionalButtonsByte >> 1); } } mDebugger.SendInternal($"(PS/2 Mouse) IRQ 12: Mouse State: ({xDeltaX}, {xDeltaY}, {xMouseState})"); OnMouseChanged?.Invoke(xDeltaX, xDeltaY, xMouseState, xScrollWheel); mMouseCycle = 0; } }
/// <summary> /// This is the default mouse handling code. /// </summary> /// <param name="context"></param> public void HandleMouse(ref INTs.IRQContext context) { switch (mouse_cycle) { case 0: mouse_byte[0] = p60.Byte; if ((mouse_byte[0] & 0x8) == 0x8) { mouse_cycle++; } break; case 1: mouse_byte[1] = p60.Byte; mouse_cycle++; break; case 2: mouse_byte[2] = p60.Byte; mouse_cycle = 0; if ((mouse_byte[0] & 0x10) == 0x10) { X -= mouse_byte[1] ^ 0xff; } else { X += mouse_byte[1]; } if ((mouse_byte[0] & 0x20) == 0x20) { Y += mouse_byte[2] ^ 0xff; } else { Y -= mouse_byte[2]; } if (X < 0) { X = 0; } else if (X > 319) { X = 319; } if (Y < 0) { Y = 0; } else if (Y > 199) { Y = 199; } Buttons = (MouseState)(mouse_byte[0] & 0x7); break; } }
public static void HandleIRQ2(ref INTs.IRQContext aContext) { Console.WriteLine("IRQ2"); }
/// <summary> /// Handles the ATAPI IRQ as specified in Init() /// </summary> /// <param name="aContext"></param> private void HandleIRQ(ref INTs.IRQContext aContext) { Ata.AtaDebugger.Send("ATAPI IRQ"); }
public void HandleMouse(ref INTs.IRQContext context) { switch (mouse_cycle) { case 0: mouse_byte[0] = Read(); //Bit 3 of byte 0 is 1, then we have a good package if ((mouse_byte[0] & 0x8) == 0x8) { mouse_cycle++; } break; case 1: mouse_byte[1] = Read(); mouse_cycle++; break; case 2: mouse_byte[2] = Read(); mouse_cycle = 0; if ((mouse_byte[0] & 0x10) == 0x10) { X -= (mouse_byte[1] ^ 0xff); } else { X += mouse_byte[1]; } if ((mouse_byte[0] & 0x20) == 0x20) { Y += (mouse_byte[2] ^ 0xff); } else { Y -= mouse_byte[2]; } if (X < 0) { X = 0; } else if (X > ScreenWidth - 1) { X = (int)ScreenWidth - 1; } if (Y < 0) { Y = 0; } else if (Y > ScreenHeight - 1) { Y = (int)ScreenHeight - 1; } Buttons = (MouseState)(mouse_byte[0] & 0x7); break; } }