]>
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> |
035d7af7 | 6 | |
36ce375d | 7 | char thestr[512]; |
36ce375d | 8 | |
91a6abf7 | 9 | #include "vga-overlay.h" |
36ce375d | 10 | |
91a6abf7 JP |
11 | unsigned int counter = 0; |
12 | unsigned long pcisave; | |
13 | unsigned char vgasave; | |
4bea7daf | 14 | |
98765740 | 15 | void pci_dump() { |
36ce375d | 16 | char s[40]; |
98765740 JP |
17 | unsigned long cts; |
18 | static int curdev = 0; /* 0 if kbd, 1 if mouse */ | |
19 | ||
20 | cts = inl(0x84C); | |
21 | ||
22 | outl(0x848, 0x0); | |
85bc8ca6 | 23 | outl(0x840, 0x0); |
98765740 JP |
24 | switch(cts&0xF0000) |
25 | { | |
26 | case 0x20000: | |
27 | { | |
28 | unsigned char b; | |
98765740 | 29 | b = inb(cts & 0xFFFF); |
d24901e6 | 30 | dologf("READ: %08x (%02x)", cts, b); |
98765740 JP |
31 | if ((cts & 0xFFFF) == 0x64) |
32 | curdev = (b & 0x20) ? 1 : 0; | |
33 | if ((curdev == 0) && ((cts & 0xFFFF) == 0x60) && (b == 0x01)) | |
34 | outb(0xCF9, 0x4); | |
98765740 JP |
35 | *(unsigned char*)0xAFFD0 /* EAX */ = b; |
36 | break; | |
37 | } | |
38 | case 0x30000: | |
39 | { | |
40 | unsigned char b; | |
41 | ||
42 | strcpy(s, "WRITxxxxxxxxxxxxxxxx"); | |
43 | b = *(unsigned char*)0xAFFD0 /* EAX */; | |
44 | tohex(s+4, cts); | |
45 | tohex(s+12, b); | |
46 | dolog(s); | |
47 | outb(cts & 0xFFFF, b); | |
48 | break; | |
49 | } | |
50 | default: | |
51 | dolog("Unhandled PCI cycle"); | |
52 | } | |
85bc8ca6 JW |
53 | |
54 | outl(0x848, 0x1000); | |
55 | outl(0x840, 0x0100); | |
98765740 JP |
56 | } |
57 | ||
d71d9872 | 58 | void smi_entry(void) |
015cd976 | 59 | { |
035d7af7 JW |
60 | pcisave = inl(0xCF8); |
61 | vgasave = inb(0x3D4); | |
31be35cd | 62 | |
4bea7daf | 63 | counter++; |
31be35cd | 64 | outb(0x80, (counter & 0xFF)); |
035d7af7 | 65 | |
d71d9872 | 66 | sprintf(thestr, "15-412! %08x %08x", smi_status(), counter); |
31be35cd | 67 | strblit(thestr, 0, 0); |
035d7af7 | 68 | |
31be35cd JW |
69 | if (inl(0x834) & 0x20) |
70 | dolog("Warning: unhandled APM access"); | |
4122ee13 JW |
71 | if (inl(0x834) & 0x1000) |
72 | { | |
73 | if (inl(0x844) & 0x1000) /* devact_sts */ | |
74 | { | |
98765740 | 75 | pci_dump(); |
85bc8ca6 | 76 | outl(0x844, 0x1000); /* ack it */ |
4122ee13 JW |
77 | } |
78 | } | |
31be35cd JW |
79 | if (inl(0x834) & 0x4000) |
80 | dolog("Long periodic timer"); | |
98765740 JP |
81 | if (inl(0x840) & 0x1000) |
82 | { | |
98765740 JP |
83 | pci_dump(); |
84 | outl(0x840, 0x1100); | |
85 | outl(0x840, 0x0100); | |
86 | } | |
31be35cd | 87 | if (inl(0x834) & ~(0x4160)) |
d24901e6 | 88 | dologf("Unknown: %08x", inl(0x834) & ~(0x140)); |
98765740 | 89 | |
31be35cd | 90 | outlog(); |
035d7af7 JW |
91 | |
92 | outl(0xCF8, pcisave); | |
93 | outb(0x3D4, vgasave); | |
a46bffee | 94 | |
4122ee13 | 95 | outl(0x848, 0x1000); |
31be35cd | 96 | outl(0x834, /*0x40*/0xFFFF); // ack the periodic IRQ |
a46bffee JW |
97 | outb(0x830, (inb(0x830) | 0x2) & ~0x40); |
98 | outb(0x830, inb(0x830) | 0x40); | |
99 | ||
4bea7daf JW |
100 | } |
101 |