1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
/*
* Copyright 1999 Egbert Eich
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the authors not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The authors makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "debug.h"
#if defined(__alpha__) || defined (__ia64__)
#include <sys/io.h>
#endif
#include "v86bios.h"
#include "AsmMacros.h"
#include "pci.h"
static int int1A_handler(struct regs86 *regs);
static int int42_handler(int num, struct regs86 *regs);
int
int_handler(int num, struct regs86 *regs)
{
switch (num) {
case 0x10:
case 0x42:
return (int42_handler(num,regs));
case 0x1A:
return (int1A_handler(regs));
default:
return 0;
}
return 0;
}
static int
int42_handler(int num,struct regs86 *regs)
{
unsigned char c;
CARD32 val;
i_printf("int 0x%x: ax:0x%lx bx:0x%lx cx:0x%lx dx:0x%lx\n",num,
regs->eax,regs->ebx, regs->ecx, regs->edx);
/*
* video bios has modified these -
* leave it to the video bios to do this
*/
val = getIntVect(num);
if (val != 0xF000F065)
return 0;
if ((regs->ebx & 0xff) == 0x32) {
switch (regs->eax & 0xFFFF) {
case 0x1200:
i_printf("enabling video\n");
c = inb(0x3cc);
c |= 0x02;
outb(0x3c2,c);
return 1;
case 0x1201:
i_printf("disabling video\n");
c = inb(0x3cc);
c &= ~0x02;
outb(0x3c2,c);
return 1;
default:
}
}
if (num == 0x42)
return 1;
else
return 0;
}
#define SUCCESSFUL 0x00
#define DEVICE_NOT_FOUND 0x86
#define BAD_REGISTER_NUMBER 0x87
static int
int1A_handler(struct regs86 *regs)
{
CARD32 Slot;
PciStructPtr pPci;
if (! CurrentPci) return 0; /* oops */
i_printf("int 0x1a: ax=0x%lx bx=0x%lx cx=0x%lx dx=0x%lx di=0x%lx"
" si=0x%lx\n", regs->eax,regs->ebx,regs->ecx,regs->edx,
regs->edi,regs->esi);
switch (regs->eax & 0xFFFF) {
case 0xb101:
regs->eax &= 0xFF00; /* no config space/special cycle support */
regs->edx = 0x20494350; /* " ICP" */
regs->ebx = 0x0210; /* Version 2.10 */
regs->ecx &= 0xFF00;
regs->ecx |= (pciMaxBus & 0xFF); /* Max bus number in system */
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
i_printf("ax=0x%lx dx=0x%lx bx=0x%lx cx=0x%lx flags=0x%lx\n",
regs->eax,regs->edx,regs->ebx,regs->ecx,regs->eflags);
return 1;
case 0xb102:
if (((regs->edx & 0xFFFF) == CurrentPci->VendorID) &&
((regs->ecx & 0xFFFF) == CurrentPci->DeviceID) &&
(regs->esi == 0)) {
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
regs->ebx = pciSlotBX(CurrentPci);
}
else if (Config.ShowAllDev &&
(pPci = findPciDevice(regs->edx,regs->ecx,regs->esi)) != NULL) {
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
regs->ebx = pciSlotBX(pPci);
} else {
regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx bx=0x%lx flags=0x%lx\n",
regs->eax,regs->ebx,regs->eflags);
return 1;
case 0xb103:
if (((regs->ecx & 0xFF) == CurrentPci->Interface) &&
(((regs->ecx & 0xFF00) >> 8) == CurrentPci->SubClass) &&
(((regs->ecx & 0xFFFF0000) >> 16) == CurrentPci->BaseClass) &&
((regs->esi & 0xff) == 0)) {
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->ebx = pciSlotBX(CurrentPci);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
}
else if (Config.ShowAllDev
&& (pPci = findPciClass(regs->ecx & 0xFF, (regs->ecx & 0xff00) >> 8,
(regs->ecx & 0xffff0000) >> 16, regs->esi)) != NULL) {
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->ebx = pciSlotBX(pPci);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx flags=0x%lx\n",regs->eax,regs->eflags);
return 1;
case 0xb108:
i_printf("Slot=0x%x\n",CurrentPci->Slot.l);
if ((Slot = findPci(regs->ebx))) {
regs->ecx &= 0xFFFFFF00;
regs->ecx |= PciRead8(regs->edi,Slot);
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n",
regs->eax,regs->ecx,regs->eflags);
return 1;
case 0xb109:
i_printf("Slot=0x%x\n",CurrentPci->Slot.l);
if ((Slot = findPci(regs->ebx))) {
regs->ecx &= 0xFFFF0000;
regs->ecx |= PciRead16(regs->edi,Slot);
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n",
regs->eax,regs->ecx,regs->eflags);
return 1;
case 0xb10a:
i_printf("Slot=0x%x\n",CurrentPci->Slot.l);
if ((Slot = findPci(regs->ebx))) {
regs->ecx &= 0;
regs->ecx |= PciRead32(regs->edi,Slot);
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n",
regs->eax,regs->ecx,regs->eflags);
return 1;
case 0xb10b:
i_printf("Slot=0x%x\n",CurrentPci->Slot.l);
if ((Slot = findPci(regs->ebx))) {
PciWrite8(regs->edi,(CARD8)regs->ecx,Slot);
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags);
return 1;
case 0xb10c:
i_printf("Slot=0x%x\n",CurrentPci->Slot.l);
if ((Slot = findPci(regs->ebx))) {
PciWrite16(regs->edi,(CARD16)regs->ecx,Slot);
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags);
return 1;
case 0xb10d:
i_printf("Slot=0x%x\n",CurrentPci->Slot.l);
if ((Slot = findPci(regs->ebx))) {
PciWrite32(regs->edi,(CARD32)regs->ecx,Slot);
regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8);
regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */
} else {
regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8);
regs->eflags |= ((unsigned long)0x01); /* set carry flag */
}
i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags);
return 1;
default:
return 0;
}
}
|