]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/counter.c
3c90x change
[netwatch.git] / aseg / counter.c
CommitLineData
035d7af7 1#include <io.h>
36ce375d
JP
2#include <smram.h>
3#include <video_defines.h>
4#include <minilib.h>
d71d9872 5#include <smi.h>
3b3161a1 6#include "3c905.h"
91a6abf7 7#include "vga-overlay.h"
0cd80c51 8#include "packet.h"
36ce375d 9
91a6abf7
JP
10unsigned int counter = 0;
11unsigned long pcisave;
12unsigned char vgasave;
4bea7daf 13
98765740 14void pci_dump() {
98765740
JP
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);
85bc8ca6 21 outl(0x840, 0x0);
98765740
JP
22 switch(cts&0xF0000)
23 {
24 case 0x20000:
25 {
26 unsigned char b;
98765740 27 b = inb(cts & 0xFFFF);
d24901e6 28 dologf("READ: %08x (%02x)", cts, b);
98765740
JP
29 if ((cts & 0xFFFF) == 0x64)
30 curdev = (b & 0x20) ? 1 : 0;
31 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
32 outb(0xCF9, 0x4);
98765740
JP
33 *(unsigned char*)0xAFFD0 /* EAX */ = b;
34 break;
35 }
36 case 0x30000:
37 {
38 unsigned char b;
39
98765740 40 b = *(unsigned char*)0xAFFD0 /* EAX */;
34205a17 41 dologf("WRITE: %08x (%02x)", cts, b);
98765740
JP
42 outb(cts & 0xFFFF, b);
43 break;
44 }
45 default:
46 dolog("Unhandled PCI cycle");
47 }
85bc8ca6
JW
48
49 outl(0x848, 0x1000);
50 outl(0x840, 0x0100);
98765740
JP
51}
52
07d1dd26
JW
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
8a677ebb
JW
65void kbc_handler(smi_event_t ev)
66{
67 pci_dump();
68}
69
73fb9b4c
JW
70void gbl_rls_handler(smi_event_t ev)
71{
72 unsigned long ecx;
73
7d252e04 74 ecx = *(unsigned long*)0xAFFD4;
0cd80c51
JP
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
d5cffad7
JP
85 if (packet->type == 42) {
86 dump_log((char *)packet->data);
87 *(unsigned long*)0xAFFD4 = 42;
88 } else {
89 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
90 }
73fb9b4c
JW
91}
92
d71d9872 93void smi_entry(void)
015cd976 94{
34205a17
JW
95 char statstr[512];
96
035d7af7
JW
97 pcisave = inl(0xCF8);
98 vgasave = inb(0x3D4);
31be35cd 99
4bea7daf 100 counter++;
34205a17
JW
101 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
102 strblit(statstr, 0, 0);
035d7af7 103
3b3161a1 104 eth_poll();
e8351f1a 105
98765740
JP
106 if (inl(0x840) & 0x1000)
107 {
98765740
JP
108 pci_dump();
109 outl(0x840, 0x1100);
110 outl(0x840, 0x0100);
111 }
98765740 112
4fb81ad0 113 smi_poll();
035d7af7
JW
114
115 outl(0xCF8, pcisave);
116 outb(0x3D4, vgasave);
4bea7daf
JW
117}
118
This page took 0.038756 seconds and 4 git commands to generate.