kernel, driver/ps2: move decoding from kMain to interrupt handler
This commit is contained in:
parent
94ab9ffb41
commit
93907ef477
@ -7,6 +7,7 @@
|
|||||||
#include "../../../../runtime/panic_assert.h"
|
#include "../../../../runtime/panic_assert.h"
|
||||||
#include "../../../../runtime/stdio.h"
|
#include "../../../../runtime/stdio.h"
|
||||||
#include "../../../../graphics/graphics.h"
|
#include "../../../../graphics/graphics.h"
|
||||||
|
#include "../../../../driver/input/source.h"
|
||||||
|
|
||||||
|
|
||||||
bool irq_pic_ps2_HasMouse;
|
bool irq_pic_ps2_HasMouse;
|
||||||
@ -88,4 +89,23 @@ SYSV_ABI void irq_pic_ps2_IRQHandlerK() {
|
|||||||
|
|
||||||
SYSV_ABI void irq_pic_ps2_IRQHandlerM() {
|
SYSV_ABI void irq_pic_ps2_IRQHandlerM() {
|
||||||
queue_PushByte(&irq_pic_ps2_QueueMouse, inb(IRQ_PIC_PS2_IOPORT));
|
queue_PushByte(&irq_pic_ps2_QueueMouse, inb(IRQ_PIC_PS2_IOPORT));
|
||||||
|
|
||||||
|
while (queue_Size(&irq_pic_ps2_QueueMouse) && !(queue_FrontByte(&irq_pic_ps2_QueueMouse) & (1u << 3)))
|
||||||
|
queue_PopByte(&irq_pic_ps2_QueueMouse);
|
||||||
|
|
||||||
|
while (queue_Size(&irq_pic_ps2_QueueMouse) >= (irq_pic_ps2_Mouse4Bytes ? 4 : 3)) {
|
||||||
|
unsigned int moveX, moveY, state;
|
||||||
|
|
||||||
|
state = queue_PopByte(&irq_pic_ps2_QueueMouse);
|
||||||
|
|
||||||
|
unsigned int d = queue_PopByte(&irq_pic_ps2_QueueMouse);
|
||||||
|
moveX = d - ((state << 4) & 0x100);
|
||||||
|
d = queue_PopByte(&irq_pic_ps2_QueueMouse);
|
||||||
|
moveY = d - ((state << 3) & 0x100);
|
||||||
|
|
||||||
|
input_source_MoveMouse(moveX, -moveY);
|
||||||
|
|
||||||
|
if (irq_pic_ps2_Mouse4Bytes)
|
||||||
|
queue_PopByte(&irq_pic_ps2_QueueMouse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,24 +74,6 @@ SYSV_ABI void kMain() {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
asm volatile("hlt");
|
asm volatile("hlt");
|
||||||
|
|
||||||
while (queue_Size(&irq_pic_ps2_QueueMouse) >= (irq_pic_ps2_Mouse4Bytes ? 4 : 3)) {
|
|
||||||
unsigned int moveX, moveY, state;
|
|
||||||
|
|
||||||
do {
|
|
||||||
state = queue_PopByte(&irq_pic_ps2_QueueMouse);
|
|
||||||
} while (!(state & (1u << 3)));
|
|
||||||
|
|
||||||
unsigned int d = queue_PopByte(&irq_pic_ps2_QueueMouse);
|
|
||||||
moveX = d - ((state << 4) & 0x100);
|
|
||||||
d = queue_PopByte(&irq_pic_ps2_QueueMouse);
|
|
||||||
moveY = d - ((state << 3) & 0x100);
|
|
||||||
|
|
||||||
input_source_MoveMouse(moveX, -moveY);
|
|
||||||
|
|
||||||
if (irq_pic_ps2_Mouse4Bytes)
|
|
||||||
queue_PopByte(&irq_pic_ps2_QueueMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
//io_WriteConsoleASCII("kMain: Interrupt hit\n");
|
//io_WriteConsoleASCII("kMain: Interrupt hit\n");
|
||||||
graphics_SwapBuffer();
|
graphics_SwapBuffer();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user