]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - aseg/counter.c
add some more structured packet handling
[netwatch.git] / aseg / counter.c
... / ...
CommitLineData
1#include <io.h>
2#include <smram.h>
3#include <video_defines.h>
4#include <minilib.h>
5#include <smi.h>
6#include "vga-overlay.h"
7#include "packet.h"
8
9unsigned int counter = 0;
10unsigned long pcisave;
11unsigned char vgasave;
12
13void pci_dump() {
14 unsigned long cts;
15 static int curdev = 0; /* 0 if kbd, 1 if mouse */
16
17 cts = inl(0x84C);
18
19 outl(0x848, 0x0);
20 outl(0x840, 0x0);
21 switch(cts&0xF0000)
22 {
23 case 0x20000:
24 {
25 unsigned char b;
26 b = inb(cts & 0xFFFF);
27 dologf("READ: %08x (%02x)", cts, b);
28 if ((cts & 0xFFFF) == 0x64)
29 curdev = (b & 0x20) ? 1 : 0;
30 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
31 outb(0xCF9, 0x4);
32 *(unsigned char*)0xAFFD0 /* EAX */ = b;
33 break;
34 }
35 case 0x30000:
36 {
37 unsigned char b;
38
39 b = *(unsigned char*)0xAFFD0 /* EAX */;
40 dologf("WRITE: %08x (%02x)", cts, b);
41 outb(cts & 0xFFFF, b);
42 break;
43 }
44 default:
45 dolog("Unhandled PCI cycle");
46 }
47
48 outl(0x848, 0x1000);
49 outl(0x840, 0x0100);
50}
51
52void timer_handler(smi_event_t ev)
53{
54 static unsigned int ticks = 0;
55
56 smi_disable_event(SMI_EVENT_FAST_TIMER);
57 smi_enable_event(SMI_EVENT_FAST_TIMER);
58
59 outb(0x80, (ticks++) & 0xFF);
60
61 outlog();
62}
63
64void kbc_handler(smi_event_t ev)
65{
66 pci_dump();
67}
68
69void gbl_rls_handler(smi_event_t ev)
70{
71 unsigned long ecx;
72
73 ecx = *(unsigned long*)0xAFFD4;
74
75 packet_t * packet = check_packet(ecx);
76 if (!packet)
77 {
78 dologf("WARN: bad packet at %08x", ecx);
79 return;
80 }
81
82 dologf("Got packet: type %08x", packet->type);
83
84 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
85}
86
87void smi_entry(void)
88{
89 char statstr[512];
90
91 pcisave = inl(0xCF8);
92 vgasave = inb(0x3D4);
93
94 counter++;
95 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
96 strblit(statstr, 0, 0);
97
98 if (inl(0x840) & 0x1000)
99 {
100 pci_dump();
101 outl(0x840, 0x1100);
102 outl(0x840, 0x0100);
103 }
104
105 smi_poll();
106
107 outl(0xCF8, pcisave);
108 outb(0x3D4, vgasave);
109}
110
This page took 0.026041 seconds and 4 git commands to generate.