3 #include <video_defines.h>
6 #include <pci-bother.h>
7 #include "../net/net.h"
8 #include "vga-overlay.h"
12 unsigned int counter = 0;
13 unsigned int lastctr = 0;
14 unsigned long pcisave;
15 unsigned char vgasave;
16 static int curdev = 0; /* 0 if kbd, 1 if mouse */
18 static void cause_kbd_irq()
22 while (inb(0x64) & 0x1)
24 outb(0x60, 0xee); /* Cause an IRQ. */
25 while (!(inb(0x64) & 0x1))
27 while (inb(0x64) & 0x1)
47 /* Read the real hardware and mask in our OBF if need be. */
49 if (kbd_has_injected_scancode())
51 dologf("OS wants to know; we have data");
54 b &= ~0x20; /* no mouse for you! */
57 curdev = (b & 0x20) ? 1 : 0;
58 *(unsigned char*)0xAFFD0 /* EAX */ = b;
61 if (kbd_has_injected_scancode())
63 b = kbd_get_injected_scancode();
68 if ((curdev == 0) && (b == 0x01)) { /* Escape */
69 outb(0xCF9, 0x4); /* Reboot */
73 /* If there is more nus to come, generate another IRQ. */
74 if (kbd_has_injected_scancode())
77 *(unsigned char*)0xAFFD0 /* EAX */ = b;
81 *(unsigned char*)0xAFFD0 /* EAX */ = b;
88 b = *(unsigned char*)0xAFFD0 /* EAX */;
89 dologf("WRITE: %08x (%02x)", cts, b);
90 outb(cts & 0xFFFF, b);
94 dolog("Unhandled PCI cycle");
101 void timer_handler(smi_event_t ev)
103 static unsigned int ticks = 0;
105 smi_disable_event(SMI_EVENT_FAST_TIMER);
106 smi_enable_event(SMI_EVENT_FAST_TIMER);
108 if (kbd_has_injected_scancode() && (counter > (lastctr + 2)))
110 smi_disable_event(SMI_EVENT_DEVTRAP_KBC);
111 dolog("Kicking timer");
113 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
116 outb(0x80, (ticks++) & 0xFF);
121 void kbc_handler(smi_event_t ev)
126 void gbl_rls_handler(smi_event_t ev)
130 ecx = *(unsigned long*)0xAFFD4;
132 packet_t * packet = check_packet(ecx);
135 dologf("WARN: bad packet at %08x", ecx);
139 dologf("Got packet: type %08x", packet->type);
141 if (packet->type == 42) {
142 dump_log((char *)packet->data);
143 *(unsigned long*)0xAFFD4 = 42;
144 } else if (packet->type == 0xAA) {
147 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
155 pcisave = inl(0xCF8);
156 vgasave = inb(0x3D4);
160 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
161 strblit(statstr, 0, 0);
165 if (inl(0x840) & 0x1000)
175 outl(0xCF8, pcisave);
176 outb(0x3D4, vgasave);