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 long pcisave;
14 unsigned char vgasave;
18 static int curdev = 0; /* 0 if kbd, 1 if mouse */
19 static int takeover = 0;
34 /* Read the real hardware and mask in our OBF if need be. */
36 if (kbd_has_injected_scancode())
40 b &= ~0x20; /* no mouse for you! */
43 curdev = (b & 0x20) ? 1 : 0;
44 *(unsigned char*)0xAFFD0 /* EAX */ = b;
49 b = kbd_get_injected_scancode();
53 if ((curdev == 0) && (b == 0x01)) { /* Escape */
54 outb(0xCF9, 0x4); /* Reboot */
57 *(unsigned char*)0xAFFD0 /* EAX */ = b;
61 *(unsigned char*)0xAFFD0 /* EAX */ = b;
68 b = *(unsigned char*)0xAFFD0 /* EAX */;
69 dologf("WRITE: %08x (%02x)", cts, b);
70 outb(cts & 0xFFFF, b);
74 dolog("Unhandled PCI cycle");
81 void timer_handler(smi_event_t ev)
83 static unsigned int ticks = 0;
85 smi_disable_event(SMI_EVENT_FAST_TIMER);
86 smi_enable_event(SMI_EVENT_FAST_TIMER);
88 outb(0x80, (ticks++) & 0xFF);
93 void kbc_handler(smi_event_t ev)
98 void gbl_rls_handler(smi_event_t ev)
102 ecx = *(unsigned long*)0xAFFD4;
104 packet_t * packet = check_packet(ecx);
107 dologf("WARN: bad packet at %08x", ecx);
111 dologf("Got packet: type %08x", packet->type);
113 if (packet->type == 42) {
114 dump_log((char *)packet->data);
115 *(unsigned long*)0xAFFD4 = 42;
116 } else if (packet->type == 0xAA) {
119 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
127 pcisave = inl(0xCF8);
128 vgasave = inb(0x3D4);
132 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
133 strblit(statstr, 0, 0);
137 if (inl(0x840) & 0x1000)
147 outl(0xCF8, pcisave);
148 outb(0x3D4, vgasave);