kernel, driver/ps2: move decoding from kMain to interrupt handler
This commit is contained in:
parent
94ab9ffb41
commit
3a8b59c39f
@ -7,6 +7,7 @@
|
||||
#include "../../../../runtime/panic_assert.h"
|
||||
#include "../../../../runtime/stdio.h"
|
||||
#include "../../../../graphics/graphics.h"
|
||||
#include "../../../../driver/input/source.h"
|
||||
|
||||
|
||||
bool irq_pic_ps2_HasMouse;
|
||||
@ -88,4 +89,23 @@ SYSV_ABI void irq_pic_ps2_IRQHandlerK() {
|
||||
|
||||
SYSV_ABI void irq_pic_ps2_IRQHandlerM() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "../interrupt/syscall.h"
|
||||
#include "../driver/irq/pic/pic.h"
|
||||
#include "../driver/irq/pic/ps2/ps2.h"
|
||||
#include "../driver/input/source.h"
|
||||
|
||||
#include "../execformat/pe/reloc.h"
|
||||
void execformat_pe_ReadSystemHeader(execformat_pe_PortableExecutable *pe);
|
||||
@ -74,24 +73,6 @@ SYSV_ABI void kMain() {
|
||||
for (;;) {
|
||||
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");
|
||||
graphics_SwapBuffer();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user