]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/counter.c
Wkesden in grubload
[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>
035d7af7 5
36ce375d 6char thestr[512];
36ce375d 7
91a6abf7 8#include "vga-overlay.h"
36ce375d 9
91a6abf7
JP
10unsigned int counter = 0;
11unsigned long pcisave;
12unsigned char vgasave;
4bea7daf 13
98765740 14void pci_dump() {
36ce375d 15 char s[40];
98765740
JP
16 unsigned long cts;
17 static int curdev = 0; /* 0 if kbd, 1 if mouse */
18
19 cts = inl(0x84C);
20
21 outl(0x848, 0x0);
85bc8ca6 22 outl(0x840, 0x0);
98765740
JP
23 switch(cts&0xF0000)
24 {
25 case 0x20000:
26 {
27 unsigned char b;
28 strcpy(s, "READxxxxxxxxxxxxxxxx");
29 tohex(s+4, cts);
30 b = inb(cts & 0xFFFF);
31 tohex(s+12, b);
32 if ((cts & 0xFFFF) == 0x64)
33 curdev = (b & 0x20) ? 1 : 0;
34 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
35 outb(0xCF9, 0x4);
36 dolog(s);
37 *(unsigned char*)0xAFFD0 /* EAX */ = b;
38 break;
39 }
40 case 0x30000:
41 {
42 unsigned char b;
43
44 strcpy(s, "WRITxxxxxxxxxxxxxxxx");
45 b = *(unsigned char*)0xAFFD0 /* EAX */;
46 tohex(s+4, cts);
47 tohex(s+12, b);
48 dolog(s);
49 outb(cts & 0xFFFF, b);
50 break;
51 }
52 default:
53 dolog("Unhandled PCI cycle");
54 }
85bc8ca6
JW
55
56 outl(0x848, 0x1000);
57 outl(0x840, 0x0100);
98765740
JP
58}
59
015cd976
JW
60void __start (void)
61{
31be35cd 62 static int first = 1;
035d7af7
JW
63
64 pcisave = inl(0xCF8);
65 vgasave = inb(0x3D4);
31be35cd
JW
66
67 if (first)
68 {
69 first = 0;
70 dolog("NetWatch running...");
71 }
035d7af7 72
4bea7daf 73 counter++;
31be35cd 74 outb(0x80, (counter & 0xFF));
035d7af7 75
31be35cd
JW
76 strcpy(thestr, "15-412! xxxxxxxx xxxxxxxx");
77 tohex(thestr + 8, inl(0x0834));
78 tohex(thestr + 17, counter);
79 strblit(thestr, 0, 0);
035d7af7 80
31be35cd
JW
81 if (inl(0x834) & 0x20)
82 dolog("Warning: unhandled APM access");
4122ee13
JW
83 if (inl(0x834) & 0x1000)
84 {
85 if (inl(0x844) & 0x1000) /* devact_sts */
86 {
98765740 87 pci_dump();
85bc8ca6 88 outl(0x844, 0x1000); /* ack it */
4122ee13
JW
89 }
90 }
31be35cd
JW
91 if (inl(0x834) & 0x4000)
92 dolog("Long periodic timer");
98765740
JP
93 if (inl(0x840) & 0x1000)
94 {
98765740
JP
95 pci_dump();
96 outl(0x840, 0x1100);
97 outl(0x840, 0x0100);
98 }
31be35cd
JW
99 if (inl(0x834) & ~(0x4160))
100 {
36ce375d 101 char s[40];
31be35cd
JW
102 strcpy(s, "Unknown: xxxxxxxx");
103 tohex(s + 9, inl(0x834) & ~(0x140));
104 dolog(s);
105 }
98765740
JP
106
107
31be35cd 108 outlog();
035d7af7
JW
109
110 outl(0xCF8, pcisave);
111 outb(0x3D4, vgasave);
a46bffee 112
4122ee13 113 outl(0x848, 0x1000);
31be35cd 114 outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ
a46bffee
JW
115 outb(0x830, (inb(0x830) | 0x2) & ~0x40);
116 outb(0x830, inb(0x830) | 0x40);
117
4bea7daf
JW
118}
119
This page took 0.039668 seconds and 4 git commands to generate.