3 #include <video_defines.h>
6 unsigned int counter = 0;
10 char logents[4][41] = {{0}};
12 #define VRAM_BASE 0xA0000UL
13 #define TEXT_CONSOLE_OFFSET 0x18000UL
15 #define TEXT_CONSOLE_BASE (VRAM_BASE + TEXT_CONSOLE_OFFSET)
19 unsigned char vga_read(unsigned char idx)
21 outb(CRTC_IDX_REG, idx);
22 return inb(CRTC_DATA_REG);
29 | (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 9)
30 | (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 1)
34 void strblit(char *src, int row, int col)
36 char *destp = vga_base() + row * 80 * 2 + col * 2;
37 smram_state_t old_state = smram_save_state();
39 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
43 *(destp++) = *(src++);
47 smram_restore_state(old_state);
53 char *basep = vga_base();
55 smram_state_t old_state = smram_save_state();
57 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
59 for (y = 0; y < 4; y++)
60 for (x = 40; x < 80; x++)
62 basep[y*80*2+x*2] = ' ';
63 basep[y*80*2+x*2+1] = 0x1F;
66 smram_restore_state(old_state);
68 for (y = 0; y < 4; y++)
69 strblit(logents[y], y, 40);
74 memmove(logents[0], logents[1], sizeof(logents[0])*3);
75 strcpy(logents[3], s);
81 static int curdev = 0; /* 0 if kbd, 1 if mouse */
92 strcpy(s, "READxxxxxxxxxxxxxxxx");
94 b = inb(cts & 0xFFFF);
96 if ((cts & 0xFFFF) == 0x64)
97 curdev = (b & 0x20) ? 1 : 0;
98 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
101 *(unsigned char*)0xAFFD0 /* EAX */ = b;
108 strcpy(s, "WRITxxxxxxxxxxxxxxxx");
109 b = *(unsigned char*)0xAFFD0 /* EAX */;
113 outb(cts & 0xFFFF, b);
117 dolog("Unhandled PCI cycle");
126 static int first = 1;
128 pcisave = inl(0xCF8);
129 vgasave = inb(0x3D4);
134 dolog("NetWatch running...");
138 outb(0x80, (counter & 0xFF));
140 strcpy(thestr, "15-412! xxxxxxxx xxxxxxxx");
141 tohex(thestr + 8, inl(0x0834));
142 tohex(thestr + 17, counter);
143 strblit(thestr, 0, 0);
145 if (inl(0x834) & 0x20)
146 dolog("Warning: unhandled APM access");
147 if (inl(0x834) & 0x1000)
149 if (inl(0x844) & 0x1000) /* devact_sts */
152 outl(0x844, 0x1000); /* ack it */
155 if (inl(0x834) & 0x4000)
156 dolog("Long periodic timer");
157 if (inl(0x840) & 0x1000)
163 if (inl(0x834) & ~(0x4160))
166 strcpy(s, "Unknown: xxxxxxxx");
167 tohex(s + 9, inl(0x834) & ~(0x140));
174 outl(0xCF8, pcisave);
175 outb(0x3D4, vgasave);
178 outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ
179 outb(0x830, (inb(0x830) | 0x2) & ~0x40);
180 outb(0x830, inb(0x830) | 0x40);