]> Joshua Wise's Git repositories - netwatch.git/blob - aseg/counter.c
changes to make it compile
[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 #include <pci-bother.h>
7 #include "../net/net.h"
8 #include "vga-overlay.h"
9 #include "packet.h"
10
11 unsigned int counter = 0;
12 unsigned long pcisave;
13 unsigned char vgasave;
14
15 void pci_dump() {
16         unsigned long cts;
17         static int curdev = 0;  /* 0 if kbd, 1 if mouse */
18                 
19         cts = inl(0x84C);
20         
21         outl(0x848, 0x0);
22         outl(0x840, 0x0);
23         switch(cts&0xF0000)
24         {
25         case 0x20000:
26         {
27                 unsigned char b;
28                 b = inb(cts & 0xFFFF);
29                 dologf("READ: %08x (%02x)", cts, b);
30                 if ((cts & 0xFFFF) == 0x64)
31                         curdev = (b & 0x20) ? 1 : 0;
32                 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
33                         outb(0xCF9, 0x4);
34                 *(unsigned char*)0xAFFD0 /* EAX */ = b;
35                 break;
36         }
37         case 0x30000:
38         {
39                 unsigned char b;
40                 
41                 b = *(unsigned char*)0xAFFD0 /* EAX */;
42                 dologf("WRITE: %08x (%02x)", cts, b);
43                 outb(cts & 0xFFFF, b);
44                 break;
45         }
46         default:
47                 dolog("Unhandled PCI cycle");
48         }
49         
50         outl(0x848, 0x1000);
51         outl(0x840, 0x0100);
52 }
53
54 void timer_handler(smi_event_t ev)
55 {
56         static unsigned int ticks = 0;
57         
58         smi_disable_event(SMI_EVENT_FAST_TIMER);
59         smi_enable_event(SMI_EVENT_FAST_TIMER);
60         
61         outb(0x80, (ticks++) & 0xFF);
62         
63         outlog();
64 }
65
66 void kbc_handler(smi_event_t ev)
67 {
68         pci_dump();
69 }
70
71 void gbl_rls_handler(smi_event_t ev)
72 {
73         unsigned long ecx;
74         
75         ecx = *(unsigned long*)0xAFFD4;
76
77         packet_t * packet = check_packet(ecx);
78         if (!packet)
79         {
80                 dologf("WARN: bad packet at %08x", ecx);
81                 return;
82         }
83
84         dologf("Got packet: type %08x", packet->type);
85
86         if (packet->type == 42) {
87                 dump_log((char *)packet->data);
88                 *(unsigned long*)0xAFFD4 = 42;
89         } else {
90                 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
91         }
92 }
93
94 void smi_entry(void)
95 {
96         char statstr[512];
97         
98         pcisave = inl(0xCF8);
99         vgasave = inb(0x3D4);
100         pci_unbother_all();
101         
102         counter++;
103         sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
104         strblit(statstr, 0, 0);
105         
106         eth_poll();
107         
108         if (inl(0x840) & 0x1000)
109         {
110                 pci_dump();
111                 outl(0x840, 0x1100);
112                 outl(0x840, 0x0100);
113         }
114
115         smi_poll();
116         
117         pci_bother_all();
118         outl(0xCF8, pcisave);
119         outb(0x3D4, vgasave);
120 }
121
This page took 0.027444 seconds and 4 git commands to generate.