]>
Commit | Line | Data |
---|---|---|
035d7af7 JW |
1 | #include <io.h> |
2 | ||
31be35cd | 3 | unsigned int counter = 0; |
035d7af7 JW |
4 | unsigned long pcisave; |
5 | unsigned char vgasave; | |
6 | unsigned char thestr[512]; | |
31be35cd | 7 | unsigned char logents[4][41] = {0}; |
035d7af7 JW |
8 | |
9 | unsigned char vgaread(unsigned char idx) | |
10 | { | |
11 | outb(0x3D4, idx); | |
12 | inb(0x3D5); | |
13 | } | |
14 | ||
31be35cd | 15 | void strblit(char *src, int r, int c) |
035d7af7 | 16 | { |
31be35cd JW |
17 | char *destp = (char*)(0xB8000UL | (((unsigned int)vgaread(0xC)) << 9) | (((unsigned int)vgaread(0xD)) << 1)) + r*80*2 + c*2; |
18 | unsigned char smramc; | |
19 | ||
20 | smramc = pci_read8(0, 0, 0, 0x70); | |
21 | pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08); | |
035d7af7 JW |
22 | while (*src) |
23 | { | |
24 | *(destp++) = *(src++); | |
25 | *(destp++) = 0x1F; | |
26 | } | |
31be35cd JW |
27 | pci_write8(0, 0, 0, 0x70, smramc); |
28 | } | |
29 | ||
30 | void outlog() | |
31 | { | |
32 | int y, x; | |
33 | unsigned char smramc; | |
34 | unsigned char *basep = (char*)(0xB8000UL | (((unsigned int)vgaread(0xC)) << 9) | (((unsigned int)vgaread(0xD)) << 1)); | |
35 | ||
36 | smramc = pci_read8(0, 0, 0, 0x70); | |
37 | pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08); | |
38 | for (y = 0; y < 4; y++) | |
39 | for (x = 40; x < 80; x++) | |
40 | { | |
41 | basep[y*80*2+x*2] = ' '; | |
42 | basep[y*80*2+x*2+1] = 0x1F; | |
43 | } | |
44 | pci_write8(0, 0, 0, 0x70, smramc); | |
45 | ||
46 | for (y = 0; y < 4; y++) | |
47 | strblit(logents[y], y, 40); | |
48 | ||
49 | } | |
50 | ||
51 | void dolog(char *s) | |
52 | { | |
53 | memmove(logents[0], logents[1], sizeof(logents[0])*3); | |
54 | strcpy(logents[3], s); | |
035d7af7 | 55 | } |
4bea7daf | 56 | |
98765740 JP |
57 | void pci_dump() { |
58 | unsigned char s[40]; | |
59 | unsigned long cts; | |
60 | static int curdev = 0; /* 0 if kbd, 1 if mouse */ | |
61 | ||
62 | cts = inl(0x84C); | |
63 | ||
64 | outl(0x848, 0x0); | |
85bc8ca6 | 65 | outl(0x840, 0x0); |
98765740 JP |
66 | switch(cts&0xF0000) |
67 | { | |
68 | case 0x20000: | |
69 | { | |
70 | unsigned char b; | |
71 | strcpy(s, "READxxxxxxxxxxxxxxxx"); | |
72 | tohex(s+4, cts); | |
73 | b = inb(cts & 0xFFFF); | |
74 | tohex(s+12, b); | |
75 | if ((cts & 0xFFFF) == 0x64) | |
76 | curdev = (b & 0x20) ? 1 : 0; | |
77 | if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01)) | |
78 | outb(0xCF9, 0x4); | |
79 | dolog(s); | |
80 | *(unsigned char*)0xAFFD0 /* EAX */ = b; | |
81 | break; | |
82 | } | |
83 | case 0x30000: | |
84 | { | |
85 | unsigned char b; | |
86 | ||
87 | strcpy(s, "WRITxxxxxxxxxxxxxxxx"); | |
88 | b = *(unsigned char*)0xAFFD0 /* EAX */; | |
89 | tohex(s+4, cts); | |
90 | tohex(s+12, b); | |
91 | dolog(s); | |
92 | outb(cts & 0xFFFF, b); | |
93 | break; | |
94 | } | |
95 | default: | |
96 | dolog("Unhandled PCI cycle"); | |
97 | } | |
85bc8ca6 JW |
98 | |
99 | outl(0x848, 0x1000); | |
100 | outl(0x840, 0x0100); | |
98765740 JP |
101 | } |
102 | ||
015cd976 JW |
103 | void __start (void) |
104 | { | |
035d7af7 | 105 | unsigned char smramc; |
31be35cd | 106 | static int first = 1; |
035d7af7 JW |
107 | |
108 | pcisave = inl(0xCF8); | |
109 | vgasave = inb(0x3D4); | |
31be35cd JW |
110 | |
111 | if (first) | |
112 | { | |
113 | first = 0; | |
114 | dolog("NetWatch running..."); | |
115 | } | |
035d7af7 | 116 | |
4bea7daf | 117 | counter++; |
31be35cd | 118 | outb(0x80, (counter & 0xFF)); |
035d7af7 | 119 | |
31be35cd JW |
120 | strcpy(thestr, "15-412! xxxxxxxx xxxxxxxx"); |
121 | tohex(thestr + 8, inl(0x0834)); | |
122 | tohex(thestr + 17, counter); | |
123 | strblit(thestr, 0, 0); | |
035d7af7 | 124 | |
31be35cd JW |
125 | if (inl(0x834) & 0x20) |
126 | dolog("Warning: unhandled APM access"); | |
4122ee13 JW |
127 | if (inl(0x834) & 0x1000) |
128 | { | |
129 | if (inl(0x844) & 0x1000) /* devact_sts */ | |
130 | { | |
98765740 | 131 | pci_dump(); |
85bc8ca6 | 132 | outl(0x844, 0x1000); /* ack it */ |
4122ee13 JW |
133 | } |
134 | } | |
31be35cd JW |
135 | if (inl(0x834) & 0x4000) |
136 | dolog("Long periodic timer"); | |
98765740 JP |
137 | if (inl(0x840) & 0x1000) |
138 | { | |
98765740 JP |
139 | pci_dump(); |
140 | outl(0x840, 0x1100); | |
141 | outl(0x840, 0x0100); | |
142 | } | |
31be35cd JW |
143 | if (inl(0x834) & ~(0x4160)) |
144 | { | |
145 | unsigned char s[40]; | |
146 | strcpy(s, "Unknown: xxxxxxxx"); | |
147 | tohex(s + 9, inl(0x834) & ~(0x140)); | |
148 | dolog(s); | |
149 | } | |
98765740 JP |
150 | |
151 | ||
31be35cd | 152 | outlog(); |
035d7af7 JW |
153 | |
154 | outl(0xCF8, pcisave); | |
155 | outb(0x3D4, vgasave); | |
a46bffee | 156 | |
4122ee13 | 157 | outl(0x848, 0x1000); |
31be35cd | 158 | outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ |
a46bffee JW |
159 | outb(0x830, (inb(0x830) | 0x2) & ~0x40); |
160 | outb(0x830, inb(0x830) | 0x40); | |
161 | ||
4bea7daf JW |
162 | } |
163 |