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