]>
Commit | Line | Data |
---|---|---|
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> |
91a6abf7 | 6 | #include "vga-overlay.h" |
0cd80c51 | 7 | #include "packet.h" |
36ce375d | 8 | |
91a6abf7 JP |
9 | unsigned int counter = 0; |
10 | unsigned long pcisave; | |
11 | unsigned char vgasave; | |
4bea7daf | 12 | |
98765740 | 13 | void pci_dump() { |
98765740 JP |
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); | |
85bc8ca6 | 20 | outl(0x840, 0x0); |
98765740 JP |
21 | switch(cts&0xF0000) |
22 | { | |
23 | case 0x20000: | |
24 | { | |
25 | unsigned char b; | |
98765740 | 26 | b = inb(cts & 0xFFFF); |
d24901e6 | 27 | dologf("READ: %08x (%02x)", cts, b); |
98765740 JP |
28 | if ((cts & 0xFFFF) == 0x64) |
29 | curdev = (b & 0x20) ? 1 : 0; | |
30 | if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01)) | |
31 | outb(0xCF9, 0x4); | |
98765740 JP |
32 | *(unsigned char*)0xAFFD0 /* EAX */ = b; |
33 | break; | |
34 | } | |
35 | case 0x30000: | |
36 | { | |
37 | unsigned char b; | |
38 | ||
98765740 | 39 | b = *(unsigned char*)0xAFFD0 /* EAX */; |
34205a17 | 40 | dologf("WRITE: %08x (%02x)", cts, b); |
98765740 JP |
41 | outb(cts & 0xFFFF, b); |
42 | break; | |
43 | } | |
44 | default: | |
45 | dolog("Unhandled PCI cycle"); | |
46 | } | |
85bc8ca6 JW |
47 | |
48 | outl(0x848, 0x1000); | |
49 | outl(0x840, 0x0100); | |
98765740 JP |
50 | } |
51 | ||
07d1dd26 JW |
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 | ||
8a677ebb JW |
64 | void kbc_handler(smi_event_t ev) |
65 | { | |
66 | pci_dump(); | |
67 | } | |
68 | ||
73fb9b4c JW |
69 | void gbl_rls_handler(smi_event_t ev) |
70 | { | |
71 | unsigned long ecx; | |
72 | ||
7d252e04 | 73 | ecx = *(unsigned long*)0xAFFD4; |
0cd80c51 JP |
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 | ||
d5cffad7 JP |
84 | if (packet->type == 42) { |
85 | dump_log((char *)packet->data); | |
86 | *(unsigned long*)0xAFFD4 = 42; | |
87 | } else { | |
88 | *(unsigned long*)0xAFFD4 = 0x2BADD00D; | |
89 | } | |
73fb9b4c JW |
90 | } |
91 | ||
d71d9872 | 92 | void smi_entry(void) |
015cd976 | 93 | { |
34205a17 JW |
94 | char statstr[512]; |
95 | ||
035d7af7 JW |
96 | pcisave = inl(0xCF8); |
97 | vgasave = inb(0x3D4); | |
31be35cd | 98 | |
4bea7daf | 99 | counter++; |
34205a17 JW |
100 | sprintf(statstr, "15-412! %08x %08x", smi_status(), counter); |
101 | strblit(statstr, 0, 0); | |
035d7af7 | 102 | |
e8351f1a JW |
103 | extern void do_bother(); |
104 | do_bother(); | |
105 | ||
98765740 JP |
106 | if (inl(0x840) & 0x1000) |
107 | { | |
98765740 JP |
108 | pci_dump(); |
109 | outl(0x840, 0x1100); | |
110 | outl(0x840, 0x0100); | |
111 | } | |
98765740 | 112 | |
4fb81ad0 | 113 | smi_poll(); |
035d7af7 JW |
114 | |
115 | outl(0xCF8, pcisave); | |
116 | outb(0x3D4, vgasave); | |
4bea7daf JW |
117 | } |
118 |