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(0x60) != 0xEE)
45 /* Read the real hardware and mask in our OBF if need be. */
47 if (kbd_has_injected_scancode())
49 dologf("OS wants to know; we have data");
52 b &= ~0x20; /* no mouse for you! */
55 curdev = (b & 0x20) ? 1 : 0;
56 *(unsigned char*)0xAFFD0 /* EAX */ = b;
59 if (kbd_has_injected_scancode())
61 b = kbd_get_injected_scancode();
63 while (inb(0x64) & 0x1)
67 if ((curdev == 0) && (b == 0x01)) { /* Escape */
68 outb(0xCF9, 0x4); /* Reboot */
72 /* If there is more nus to come, generate another IRQ. */
73 if (kbd_has_injected_scancode())
76 *(unsigned char*)0xAFFD0 /* EAX */ = b;
80 *(unsigned char*)0xAFFD0 /* EAX */ = b;
87 b = *(unsigned char*)0xAFFD0 /* EAX */;
88 dologf("WRITE: %08x (%02x)", cts, b);
89 outb(cts & 0xFFFF, b);
93 dolog("Unhandled PCI cycle");
100 void timer_handler(smi_event_t ev)
102 static unsigned int ticks = 0;
104 smi_disable_event(SMI_EVENT_FAST_TIMER);
105 smi_enable_event(SMI_EVENT_FAST_TIMER);
107 if (kbd_has_injected_scancode() && (counter > (lastctr + 2)))
109 smi_disable_event(SMI_EVENT_DEVTRAP_KBC);
110 dolog("Kicking timer");
112 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
115 outb(0x80, (ticks++) & 0xFF);
120 void kbc_handler(smi_event_t ev)
125 void gbl_rls_handler(smi_event_t ev)
129 ecx = *(unsigned long*)0xAFFD4;
131 packet_t * packet = check_packet(ecx);
134 dologf("WARN: bad packet at %08x", ecx);
138 dologf("Got packet: type %08x", packet->type);
140 if (packet->type == 42) {
141 dump_log((char *)packet->data);
142 *(unsigned long*)0xAFFD4 = 42;
143 } else if (packet->type == 0xAA) {
146 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
154 pcisave = inl(0xCF8);
155 vgasave = inb(0x3D4);
159 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
160 strblit(statstr, 0, 0);
164 if (inl(0x840) & 0x1000)
174 outl(0xCF8, pcisave);
175 outb(0x3D4, vgasave);