3 #include <video_defines.h>
6 #include <pci-bother.h>
7 #include "../net/net.h"
8 #include "vga-overlay.h"
9 #include "../aseg/packet.h"
10 #include "../aseg/keyboard.h"
12 unsigned int lastctr = 0;
13 extern unsigned int counter;
15 static int curdev = 0;
17 static void cause_kbd_irq()
21 while (inb(0x64) & 0x1)
23 outb(0x60, 0xee); /* Cause an IRQ. */
24 while (inb(0x60) != 0xEE)
44 /* Read the real hardware and mask in our OBF if need be. */
46 if (kbd_has_injected_scancode())
48 dologf("OS wants to know; we have data");
51 b &= ~0x20; /* no mouse for you! */
54 curdev = (b & 0x20) ? 1 : 0;
55 *(unsigned char*)0xAFFD0 /* EAX */ = b;
58 if (kbd_has_injected_scancode())
60 b = kbd_get_injected_scancode();
62 while (inb(0x64) & 0x1)
66 if ((curdev == 0) && (b == 0x01)) { /* Escape */
67 outb(0xCF9, 0x4); /* Reboot */
71 /* If there is more nus to come, generate another IRQ. */
72 if (kbd_has_injected_scancode())
75 *(unsigned char*)0xAFFD0 /* EAX */ = b;
79 *(unsigned char*)0xAFFD0 /* EAX */ = b;
86 b = *(unsigned char*)0xAFFD0 /* EAX */;
87 dologf("WRITE: %08x (%02x)", cts, b);
88 outb(cts & 0xFFFF, b);
92 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;