]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/counter.c
Have a log console -- needs to be refactored
[netwatch.git] / aseg / counter.c
CommitLineData
035d7af7 1#include <io.h>
31be35cd 2#include <minilib.h>
035d7af7 3
31be35cd 4unsigned int counter = 0;
035d7af7
JW
5unsigned long pcisave;
6unsigned char vgasave;
7unsigned char thestr[512];
31be35cd 8unsigned char logents[4][41] = {0};
035d7af7
JW
9
10unsigned char vgaread(unsigned char idx)
11{
12 outb(0x3D4, idx);
13 inb(0x3D5);
14}
15
31be35cd 16void strblit(char *src, int r, int c)
035d7af7 17{
31be35cd
JW
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);
035d7af7
JW
23 while (*src)
24 {
25 *(destp++) = *(src++);
26 *(destp++) = 0x1F;
27 }
31be35cd
JW
28 pci_write8(0, 0, 0, 0x70, smramc);
29}
30
31void 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
52void dolog(char *s)
53{
54 memmove(logents[0], logents[1], sizeof(logents[0])*3);
55 strcpy(logents[3], s);
035d7af7 56}
4bea7daf 57
015cd976
JW
58void __start (void)
59{
035d7af7 60 unsigned char smramc;
31be35cd 61 static int first = 1;
035d7af7
JW
62
63 pcisave = inl(0xCF8);
64 vgasave = inb(0x3D4);
31be35cd
JW
65
66 if (first)
67 {
68 first = 0;
69 dolog("NetWatch running...");
70 }
035d7af7 71
4bea7daf 72 counter++;
31be35cd 73 outb(0x80, (counter & 0xFF));
035d7af7 74
31be35cd
JW
75 strcpy(thestr, "15-412! xxxxxxxx xxxxxxxx");
76 tohex(thestr + 8, inl(0x0834));
77 tohex(thestr + 17, counter);
78 strblit(thestr, 0, 0);
035d7af7 79
31be35cd
JW
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();
035d7af7
JW
93
94 outl(0xCF8, pcisave);
95 outb(0x3D4, vgasave);
a46bffee 96
31be35cd 97 outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ
a46bffee
JW
98 outb(0x830, (inb(0x830) | 0x2) & ~0x40);
99 outb(0x830, inb(0x830) | 0x40);
100
4bea7daf
JW
101}
102
This page took 0.037005 seconds and 4 git commands to generate.