]> Joshua Wise's Git repositories - netwatch.git/blob - aseg/counter.c
Remove the 'first' stuff. Rename the entry point to smi_entry.
[netwatch.git] / aseg / counter.c
1 #include <io.h>
2 #include <smram.h>
3 #include <video_defines.h>
4 #include <minilib.h>
5 #include <smi.h>
6
7 char thestr[512];
8
9 #include "vga-overlay.h"
10
11 unsigned int counter = 0;
12 unsigned long pcisave;
13 unsigned char vgasave;
14
15 void pci_dump() {
16         char s[40];
17         unsigned long cts;
18         static int curdev = 0;  /* 0 if kbd, 1 if mouse */
19                 
20         cts = inl(0x84C);
21         
22         outl(0x848, 0x0);
23         outl(0x840, 0x0);
24         switch(cts&0xF0000)
25         {
26         case 0x20000:
27         {
28                 unsigned char b;
29                 b = inb(cts & 0xFFFF);
30                 dologf("READ: %08x (%02x)", cts, b);
31                 if ((cts & 0xFFFF) == 0x64)
32                         curdev = (b & 0x20) ? 1 : 0;
33                 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
34                         outb(0xCF9, 0x4);
35                 *(unsigned char*)0xAFFD0 /* EAX */ = b;
36                 break;
37         }
38         case 0x30000:
39         {
40                 unsigned char b;
41                 
42                 strcpy(s, "WRITxxxxxxxxxxxxxxxx");
43                 b = *(unsigned char*)0xAFFD0 /* EAX */;
44                 tohex(s+4, cts);
45                 tohex(s+12, b);
46                 dolog(s);
47                 outb(cts & 0xFFFF, b);
48                 break;
49         }
50         default:
51                 dolog("Unhandled PCI cycle");
52         }
53         
54         outl(0x848, 0x1000);
55         outl(0x840, 0x0100);
56 }
57
58 void smi_entry(void)
59 {
60         pcisave = inl(0xCF8);
61         vgasave = inb(0x3D4);
62         
63         counter++;
64         outb(0x80, (counter & 0xFF));
65         
66         sprintf(thestr, "15-412! %08x %08x", smi_status(), counter);
67         strblit(thestr, 0, 0);
68         
69         if (inl(0x834) & 0x20)
70                 dolog("Warning: unhandled APM access");
71         if (inl(0x834) & 0x1000)
72         {
73                 if (inl(0x844) & 0x1000)        /* devact_sts */
74                 {
75                         pci_dump();
76                         outl(0x844, 0x1000);    /* ack it */
77                 }
78         }
79         if (inl(0x834) & 0x4000)
80                 dolog("Long periodic timer");
81         if (inl(0x840) & 0x1000)
82         {
83                 pci_dump();
84                 outl(0x840, 0x1100);
85                 outl(0x840, 0x0100);
86         }
87         if (inl(0x834) & ~(0x4160))
88                 dologf("Unknown: %08x", inl(0x834) & ~(0x140));
89
90         outlog();
91         
92         outl(0xCF8, pcisave);
93         outb(0x3D4, vgasave);
94         
95         outl(0x848, 0x1000);
96         outl(0x834, /*0x40*/0xFFFF);    // ack the periodic IRQ
97         outb(0x830, (inb(0x830) | 0x2) & ~0x40);
98         outb(0x830, inb(0x830) | 0x40);
99         
100 }
101
This page took 0.027796 seconds and 4 git commands to generate.