]>
Commit | Line | Data |
---|---|---|
1 | #include <io.h> | |
2 | #include <minilib.h> | |
3 | ||
4 | unsigned int counter = 0; | |
5 | unsigned long pcisave; | |
6 | unsigned char vgasave; | |
7 | unsigned char thestr[512]; | |
8 | unsigned char logents[4][41] = {0}; | |
9 | ||
10 | unsigned char vgaread(unsigned char idx) | |
11 | { | |
12 | outb(0x3D4, idx); | |
13 | inb(0x3D5); | |
14 | } | |
15 | ||
16 | void strblit(char *src, int r, int c) | |
17 | { | |
18 | char *destp = (char*)(0xB8000UL | (((unsigned int)vgaread(0xC)) << 9) | (((unsigned int)vgaread(0xD)) << 1)) + r*80*2 + c*2; | |
19 | unsigned char smramc; | |
20 | ||
21 | smramc = pci_read8(0, 0, 0, 0x70); | |
22 | pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08); | |
23 | while (*src) | |
24 | { | |
25 | *(destp++) = *(src++); | |
26 | *(destp++) = 0x1F; | |
27 | } | |
28 | pci_write8(0, 0, 0, 0x70, smramc); | |
29 | } | |
30 | ||
31 | void outlog() | |
32 | { | |
33 | int y, x; | |
34 | unsigned char smramc; | |
35 | unsigned char *basep = (char*)(0xB8000UL | (((unsigned int)vgaread(0xC)) << 9) | (((unsigned int)vgaread(0xD)) << 1)); | |
36 | ||
37 | smramc = pci_read8(0, 0, 0, 0x70); | |
38 | pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08); | |
39 | for (y = 0; y < 4; y++) | |
40 | for (x = 40; x < 80; x++) | |
41 | { | |
42 | basep[y*80*2+x*2] = ' '; | |
43 | basep[y*80*2+x*2+1] = 0x1F; | |
44 | } | |
45 | pci_write8(0, 0, 0, 0x70, smramc); | |
46 | ||
47 | for (y = 0; y < 4; y++) | |
48 | strblit(logents[y], y, 40); | |
49 | ||
50 | } | |
51 | ||
52 | void dolog(char *s) | |
53 | { | |
54 | memmove(logents[0], logents[1], sizeof(logents[0])*3); | |
55 | strcpy(logents[3], s); | |
56 | } | |
57 | ||
58 | void __start (void) | |
59 | { | |
60 | unsigned char smramc; | |
61 | static int first = 1; | |
62 | ||
63 | pcisave = inl(0xCF8); | |
64 | vgasave = inb(0x3D4); | |
65 | ||
66 | if (first) | |
67 | { | |
68 | first = 0; | |
69 | dolog("NetWatch running..."); | |
70 | } | |
71 | ||
72 | counter++; | |
73 | outb(0x80, (counter & 0xFF)); | |
74 | ||
75 | strcpy(thestr, "15-412! xxxxxxxx xxxxxxxx"); | |
76 | tohex(thestr + 8, inl(0x0834)); | |
77 | tohex(thestr + 17, counter); | |
78 | strblit(thestr, 0, 0); | |
79 | ||
80 | if (inl(0x834) & 0x20) | |
81 | dolog("Warning: unhandled APM access"); | |
82 | if (inl(0x834) & 0x4000) | |
83 | dolog("Long periodic timer"); | |
84 | if (inl(0x834) & ~(0x4160)) | |
85 | { | |
86 | unsigned char s[40]; | |
87 | strcpy(s, "Unknown: xxxxxxxx"); | |
88 | tohex(s + 9, inl(0x834) & ~(0x140)); | |
89 | dolog(s); | |
90 | } | |
91 | ||
92 | outlog(); | |
93 | ||
94 | outl(0xCF8, pcisave); | |
95 | outb(0x3D4, vgasave); | |
96 | ||
97 | outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ | |
98 | outb(0x830, (inb(0x830) | 0x2) & ~0x40); | |
99 | outb(0x830, inb(0x830) | 0x40); | |
100 | ||
101 | } | |
102 |