- outl(0x844, 0x0);
- outl(0x848, 0x0);
- while (inb(0x64) & 0x1)
- inb(0x60);
- outb(0x60, 0xee); /* Cause an IRQ. */
- while (inb(0x60) != 0xEE)
- ;
+ return _ibf_ready && !_waiting_for_data && !adding_locks_from_time_to_time;
+}
+
+void _try_inject()
+{
+ if (kbd_has_injected_scancode() && _inject_ready())
+ {
+ smi_disable_event(SMI_EVENT_DEVTRAP_KBC);
+ int i = 1000;
+ while (inb(0x64) & 0x02) /* Busy? */
+ ;
+ outb(0x64, 0xD2); /* "Inject, please!" */
+ while (inb(0x64) & 0x02) /* Busy? */
+ ;
+ outb(0x60, kbd_get_injected_scancode()); /* data */
+ while ((inb(0x64) & 0x02) && i--) /* wait for completion */
+ ;
+ outl(0x844, 0x1000);
+ adding_locks_from_time_to_time++;
+ smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
+ } else if (kbd_has_injected_scancode())
+ outputf("Would like to inject, but %d %d", _ibf_ready, _waiting_for_data);