]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/counter.c
add printf/dologf
[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;
98765740 28 b = inb(cts & 0xFFFF);
d24901e6 29 dologf("READ: %08x (%02x)", cts, b);
98765740
JP
30 if ((cts & 0xFFFF) == 0x64)
31 curdev = (b & 0x20) ? 1 : 0;
32 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
33 outb(0xCF9, 0x4);
98765740
JP
34 *(unsigned char*)0xAFFD0 /* EAX */ = b;
35 break;
36 }
37 case 0x30000:
38 {
39 unsigned char b;
40
41 strcpy(s, "WRITxxxxxxxxxxxxxxxx");
42 b = *(unsigned char*)0xAFFD0 /* EAX */;
43 tohex(s+4, cts);
44 tohex(s+12, b);
45 dolog(s);
46 outb(cts & 0xFFFF, b);
47 break;
48 }
49 default:
50 dolog("Unhandled PCI cycle");
51 }
85bc8ca6
JW
52
53 outl(0x848, 0x1000);
54 outl(0x840, 0x0100);
98765740
JP
55}
56
015cd976
JW
57void __start (void)
58{
31be35cd 59 static int first = 1;
035d7af7
JW
60
61 pcisave = inl(0xCF8);
62 vgasave = inb(0x3D4);
31be35cd
JW
63
64 if (first)
65 {
66 first = 0;
67 dolog("NetWatch running...");
68 }
035d7af7 69
4bea7daf 70 counter++;
31be35cd 71 outb(0x80, (counter & 0xFF));
035d7af7 72
31be35cd
JW
73 strcpy(thestr, "15-412! xxxxxxxx xxxxxxxx");
74 tohex(thestr + 8, inl(0x0834));
75 tohex(thestr + 17, counter);
76 strblit(thestr, 0, 0);
035d7af7 77
31be35cd
JW
78 if (inl(0x834) & 0x20)
79 dolog("Warning: unhandled APM access");
4122ee13
JW
80 if (inl(0x834) & 0x1000)
81 {
82 if (inl(0x844) & 0x1000) /* devact_sts */
83 {
98765740 84 pci_dump();
85bc8ca6 85 outl(0x844, 0x1000); /* ack it */
4122ee13
JW
86 }
87 }
31be35cd
JW
88 if (inl(0x834) & 0x4000)
89 dolog("Long periodic timer");
98765740
JP
90 if (inl(0x840) & 0x1000)
91 {
98765740
JP
92 pci_dump();
93 outl(0x840, 0x1100);
94 outl(0x840, 0x0100);
95 }
31be35cd 96 if (inl(0x834) & ~(0x4160))
d24901e6 97 dologf("Unknown: %08x", inl(0x834) & ~(0x140));
98765740 98
31be35cd 99 outlog();
035d7af7
JW
100
101 outl(0xCF8, pcisave);
102 outb(0x3D4, vgasave);
a46bffee 103
4122ee13 104 outl(0x848, 0x1000);
31be35cd 105 outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ
a46bffee
JW
106 outb(0x830, (inb(0x830) | 0x2) & ~0x40);
107 outb(0x830, inb(0x830) | 0x40);
108
4bea7daf
JW
109}
110
This page took 0.034556 seconds and 4 git commands to generate.