]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | unsigned int counter = 0; | |
9 | unsigned long pcisave; | |
10 | unsigned char vgasave; | |
11 | ||
12 | void pci_dump() { | |
13 | unsigned long cts; | |
14 | static int curdev = 0; /* 0 if kbd, 1 if mouse */ | |
15 | ||
16 | cts = inl(0x84C); | |
17 | ||
18 | outl(0x848, 0x0); | |
19 | outl(0x840, 0x0); | |
20 | switch(cts&0xF0000) | |
21 | { | |
22 | case 0x20000: | |
23 | { | |
24 | unsigned char b; | |
25 | b = inb(cts & 0xFFFF); | |
26 | dologf("READ: %08x (%02x)", cts, b); | |
27 | if ((cts & 0xFFFF) == 0x64) | |
28 | curdev = (b & 0x20) ? 1 : 0; | |
29 | if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01)) | |
30 | outb(0xCF9, 0x4); | |
31 | *(unsigned char*)0xAFFD0 /* EAX */ = b; | |
32 | break; | |
33 | } | |
34 | case 0x30000: | |
35 | { | |
36 | unsigned char b; | |
37 | ||
38 | b = *(unsigned char*)0xAFFD0 /* EAX */; | |
39 | dologf("WRITE: %08x (%02x)", cts, b); | |
40 | outb(cts & 0xFFFF, b); | |
41 | break; | |
42 | } | |
43 | default: | |
44 | dolog("Unhandled PCI cycle"); | |
45 | } | |
46 | ||
47 | outl(0x848, 0x1000); | |
48 | outl(0x840, 0x0100); | |
49 | } | |
50 | ||
51 | void timer_handler(smi_event_t ev) | |
52 | { | |
53 | static unsigned int ticks = 0; | |
54 | ||
55 | smi_disable_event(SMI_EVENT_FAST_TIMER); | |
56 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
57 | ||
58 | outb(0x80, (ticks++) & 0xFF); | |
59 | ||
60 | outlog(); | |
61 | } | |
62 | ||
63 | void kbc_handler(smi_event_t ev) | |
64 | { | |
65 | pci_dump(); | |
66 | } | |
67 | ||
68 | void gbl_rls_handler(smi_event_t ev) | |
69 | { | |
70 | unsigned long ecx; | |
71 | ||
72 | ecx = *(unsigned long*)0xAFFD4; | |
73 | dologf("ECX was %08x", ecx); | |
74 | *(unsigned long*)0xAFFD4 = 0x2BADD00D; | |
75 | } | |
76 | ||
77 | void smi_entry(void) | |
78 | { | |
79 | char statstr[512]; | |
80 | ||
81 | pcisave = inl(0xCF8); | |
82 | vgasave = inb(0x3D4); | |
83 | ||
84 | counter++; | |
85 | sprintf(statstr, "15-412! %08x %08x", smi_status(), counter); | |
86 | strblit(statstr, 0, 0); | |
87 | ||
88 | if (inl(0x840) & 0x1000) | |
89 | { | |
90 | pci_dump(); | |
91 | outl(0x840, 0x1100); | |
92 | outl(0x840, 0x0100); | |
93 | } | |
94 | ||
95 | smi_poll(); | |
96 | ||
97 | outl(0xCF8, pcisave); | |
98 | outb(0x3D4, vgasave); | |
99 | } | |
100 |