]>
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" |
36ce375d | 7 | |
91a6abf7 JP |
8 | unsigned int counter = 0; |
9 | unsigned long pcisave; | |
10 | unsigned char vgasave; | |
4bea7daf | 11 | |
98765740 | 12 | void pci_dump() { |
98765740 JP |
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); | |
85bc8ca6 | 19 | outl(0x840, 0x0); |
98765740 JP |
20 | switch(cts&0xF0000) |
21 | { | |
22 | case 0x20000: | |
23 | { | |
24 | unsigned char b; | |
98765740 | 25 | b = inb(cts & 0xFFFF); |
d24901e6 | 26 | dologf("READ: %08x (%02x)", cts, b); |
98765740 JP |
27 | if ((cts & 0xFFFF) == 0x64) |
28 | curdev = (b & 0x20) ? 1 : 0; | |
29 | if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01)) | |
30 | outb(0xCF9, 0x4); | |
98765740 JP |
31 | *(unsigned char*)0xAFFD0 /* EAX */ = b; |
32 | break; | |
33 | } | |
34 | case 0x30000: | |
35 | { | |
36 | unsigned char b; | |
37 | ||
98765740 | 38 | b = *(unsigned char*)0xAFFD0 /* EAX */; |
34205a17 | 39 | dologf("WRITE: %08x (%02x)", cts, b); |
98765740 JP |
40 | outb(cts & 0xFFFF, b); |
41 | break; | |
42 | } | |
43 | default: | |
44 | dolog("Unhandled PCI cycle"); | |
45 | } | |
85bc8ca6 JW |
46 | |
47 | outl(0x848, 0x1000); | |
48 | outl(0x840, 0x0100); | |
98765740 JP |
49 | } |
50 | ||
07d1dd26 JW |
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 | ||
8a677ebb JW |
63 | void kbc_handler(smi_event_t ev) |
64 | { | |
65 | pci_dump(); | |
66 | } | |
67 | ||
d71d9872 | 68 | void smi_entry(void) |
015cd976 | 69 | { |
34205a17 JW |
70 | char statstr[512]; |
71 | ||
035d7af7 JW |
72 | pcisave = inl(0xCF8); |
73 | vgasave = inb(0x3D4); | |
31be35cd | 74 | |
4bea7daf | 75 | counter++; |
34205a17 JW |
76 | sprintf(statstr, "15-412! %08x %08x", smi_status(), counter); |
77 | strblit(statstr, 0, 0); | |
035d7af7 | 78 | |
98765740 JP |
79 | if (inl(0x840) & 0x1000) |
80 | { | |
98765740 JP |
81 | pci_dump(); |
82 | outl(0x840, 0x1100); | |
83 | outl(0x840, 0x0100); | |
84 | } | |
98765740 | 85 | |
4fb81ad0 | 86 | smi_poll(); |
035d7af7 JW |
87 | |
88 | outl(0xCF8, pcisave); | |
89 | outb(0x3D4, vgasave); | |
4bea7daf JW |
90 | } |
91 |