]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/counter.c
Hacky network transmitter.
[netwatch.git] / aseg / counter.c
CommitLineData
035d7af7 1#include <io.h>
36ce375d
JP
2#include <smram.h>
3#include <video_defines.h>
4#include <minilib.h>
d71d9872 5#include <smi.h>
4d898e0b 6#include <pci-bother.h>
3e6d6106 7#include "../net/net.h"
91a6abf7 8#include "vga-overlay.h"
0cd80c51 9#include "packet.h"
36ce375d 10
91a6abf7
JP
11unsigned int counter = 0;
12unsigned long pcisave;
13unsigned char vgasave;
4bea7daf 14
98765740 15void pci_dump() {
98765740
JP
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);
85bc8ca6 22 outl(0x840, 0x0);
98765740
JP
23 switch(cts&0xF0000)
24 {
25 case 0x20000:
26 {
27 unsigned char b;
98765740 28 b = inb(cts & 0xFFFF);
c2e34447 29 //dologf("READ: %08x (%02x)", cts, b);
98765740
JP
30 if ((cts & 0xFFFF) == 0x64)
31 curdev = (b & 0x20) ? 1 : 0;
32 if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01))
33 outb(0xCF9, 0x4);
98765740
JP
34 *(unsigned char*)0xAFFD0 /* EAX */ = b;
35 break;
36 }
37 case 0x30000:
38 {
39 unsigned char b;
40
98765740 41 b = *(unsigned char*)0xAFFD0 /* EAX */;
34205a17 42 dologf("WRITE: %08x (%02x)", cts, b);
98765740
JP
43 outb(cts & 0xFFFF, b);
44 break;
45 }
46 default:
47 dolog("Unhandled PCI cycle");
48 }
85bc8ca6
JW
49
50 outl(0x848, 0x1000);
51 outl(0x840, 0x0100);
98765740
JP
52}
53
07d1dd26
JW
54void 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
8a677ebb
JW
66void kbc_handler(smi_event_t ev)
67{
68 pci_dump();
69}
70
73fb9b4c
JW
71void gbl_rls_handler(smi_event_t ev)
72{
73 unsigned long ecx;
74
7d252e04 75 ecx = *(unsigned long*)0xAFFD4;
0cd80c51
JP
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
d5cffad7
JP
86 if (packet->type == 42) {
87 dump_log((char *)packet->data);
88 *(unsigned long*)0xAFFD4 = 42;
89 } else {
90 *(unsigned long*)0xAFFD4 = 0x2BADD00D;
91 }
73fb9b4c
JW
92}
93
d71d9872 94void smi_entry(void)
015cd976 95{
34205a17
JW
96 char statstr[512];
97
035d7af7
JW
98 pcisave = inl(0xCF8);
99 vgasave = inb(0x3D4);
4d898e0b 100 pci_unbother_all();
31be35cd 101
4bea7daf 102 counter++;
34205a17
JW
103 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
104 strblit(statstr, 0, 0);
035d7af7 105
3b3161a1 106 eth_poll();
e8351f1a 107
98765740
JP
108 if (inl(0x840) & 0x1000)
109 {
98765740
JP
110 pci_dump();
111 outl(0x840, 0x1100);
112 outl(0x840, 0x0100);
113 }
98765740 114
4fb81ad0 115 smi_poll();
035d7af7 116
4d898e0b 117 pci_bother_all();
035d7af7
JW
118 outl(0xCF8, pcisave);
119 outb(0x3D4, vgasave);
4bea7daf
JW
120}
121
This page took 0.031977 seconds and 4 git commands to generate.