3 #include <video_defines.h>
6 #include <pci-bother.h>
8 #include "../net/net.h"
9 #include "vga-overlay.h"
10 #include "../aseg/packet.h"
11 #include "../aseg/keyboard.h"
13 unsigned int lastctr = 0;
14 extern unsigned int counter;
16 static int curdev = 0;
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");
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);
118 if (!fb || fb->curmode.text)
122 void kbc_handler(smi_event_t ev)
127 void gbl_rls_handler(smi_event_t ev)
131 ecx = *(unsigned long*)0xAFFD4;
133 packet_t * packet = check_packet(ecx);
136 dologf("WARN: bad packet at %08x", ecx);
140 dologf("Got packet: type %08x", packet->type);
142 if (packet->type == 42) {
143 dump_log((char *)packet->data);
144 *(unsigned long*)0xAFFD4 = 42;
145 } else if (packet->type == 0xAA) {
148 *(unsigned long*)0xAFFD4 = 0x2BADD00D;