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