]> Joshua Wise's Git repositories - netwatch.git/blob - aseg/counter.c
add poke-rls tool
[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) & 0x1000)
70         {
71                 if (inl(0x844) & 0x1000)        /* devact_sts */
72                 {
73                         pci_dump();
74                         outl(0x844, 0x1000);    /* ack it */
75                 }
76         }
77         if (inl(0x840) & 0x1000)
78         {
79                 pci_dump();
80                 outl(0x840, 0x1100);
81                 outl(0x840, 0x0100);
82         }
83
84         smi_poll();
85         outlog();
86         
87         outl(0xCF8, pcisave);
88         outb(0x3D4, vgasave);
89 }
90
This page took 0.032562 seconds and 4 git commands to generate.