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