1 | ;;
|
---|
2 | ;; Copyright (C) 2006-2011 Oracle Corporation
|
---|
3 | ;;
|
---|
4 | ;; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | ;; available from http://www.virtualbox.org. This file is free software;
|
---|
6 | ;; you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | ;; General Public License (GPL) as published by the Free Software
|
---|
8 | ;; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | ;; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | ;; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | ;; --------------------------------------------------------------------
|
---|
12 | ;;
|
---|
13 | ;; This code is based on:
|
---|
14 | ;;
|
---|
15 | ;; ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
|
---|
16 | ;;
|
---|
17 | ;; Copyright (C) 2002 MandrakeSoft S.A.
|
---|
18 | ;;
|
---|
19 | ;; MandrakeSoft S.A.
|
---|
20 | ;; 43, rue d'Aboukir
|
---|
21 | ;; 75002 Paris - France
|
---|
22 | ;; http://www.linux-mandrake.com/
|
---|
23 | ;; http://www.mandrakesoft.com/
|
---|
24 | ;;
|
---|
25 | ;; This library is free software; you can redistribute it and/or
|
---|
26 | ;; modify it under the terms of the GNU Lesser General Public
|
---|
27 | ;; License as published by the Free Software Foundation; either
|
---|
28 | ;; version 2 of the License, or (at your option) any later version.
|
---|
29 | ;;
|
---|
30 | ;; This library is distributed in the hope that it will be useful,
|
---|
31 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
32 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
33 | ;; Lesser General Public License for more details.
|
---|
34 | ;;
|
---|
35 | ;; You should have received a copy of the GNU Lesser General Public
|
---|
36 | ;; License along with this library; if not, write to the Free Software
|
---|
37 | ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
38 | ;;
|
---|
39 | ;;
|
---|
40 |
|
---|
41 | include pcicfg.inc
|
---|
42 |
|
---|
43 | if BX_PCIBIOS
|
---|
44 |
|
---|
45 | .386
|
---|
46 |
|
---|
47 | BIOS32 segment public 'CODE' use32
|
---|
48 |
|
---|
49 | public pcibios_protected
|
---|
50 |
|
---|
51 | align 16
|
---|
52 | bios32_structure:
|
---|
53 | db '_32_' ; signature
|
---|
54 | dw bios32_entry_point, 0Fh ;; 32 bit physical address
|
---|
55 | db 0 ; revision level
|
---|
56 | db 1 ; length in paragraphs
|
---|
57 | db 0 ; checksum (updated externally)
|
---|
58 | db 0,0,0,0,0 ; reserved
|
---|
59 |
|
---|
60 | align 16
|
---|
61 | bios32_entry_point:
|
---|
62 | pushfd
|
---|
63 | cmp eax, 'ICP$' ; 0x49435024 "$PCI"
|
---|
64 | jne unknown_service
|
---|
65 |
|
---|
66 | ifdef PCI_FIXED_HOST_BRIDGE_1
|
---|
67 | mov eax, 80000000h
|
---|
68 | mov dx, PCI_CFG1
|
---|
69 | out dx, eax
|
---|
70 | mov dx, PCI_CFG2
|
---|
71 | in eax, dx
|
---|
72 | cmp eax, PCI_FIXED_HOST_BRIDGE_1
|
---|
73 | je device_ok
|
---|
74 | endif
|
---|
75 |
|
---|
76 | ifdef PCI_FIXED_HOST_BRIDGE_2
|
---|
77 | ; 18h << 11
|
---|
78 | mov eax, 8000c000h
|
---|
79 | mov dx, PCI_CFG1
|
---|
80 | out dx, eax
|
---|
81 | mov dx, PCI_CFG2
|
---|
82 | in eax, dx
|
---|
83 | cmp eax, PCI_FIXED_HOST_BRIDGE_2
|
---|
84 | je device_ok
|
---|
85 | ; 19h << 11
|
---|
86 | mov eax, 8000c800h
|
---|
87 | mov dx, PCI_CFG1
|
---|
88 | out dx, eax
|
---|
89 | mov dx, PCI_CFG2
|
---|
90 | in eax, dx
|
---|
91 | cmp eax, PCI_FIXED_HOST_BRIDGE_2
|
---|
92 | je device_ok
|
---|
93 | endif
|
---|
94 | jmp unknown_service
|
---|
95 | device_ok:
|
---|
96 | mov ebx, 000f0000h
|
---|
97 | mov ecx, 0
|
---|
98 | mov edx, pcibios_protected
|
---|
99 | xor al, al
|
---|
100 | jmp bios32_end
|
---|
101 |
|
---|
102 | unknown_service:
|
---|
103 | mov al, 80h
|
---|
104 | bios32_end:
|
---|
105 | popfd
|
---|
106 | retf
|
---|
107 |
|
---|
108 | align 16
|
---|
109 | pcibios_protected:
|
---|
110 | if 1
|
---|
111 | ;; The old implementation of pcibios_protected will eventually go,
|
---|
112 | ;; replaced by C code.
|
---|
113 | else
|
---|
114 |
|
---|
115 | extrn _pci32_function:near
|
---|
116 |
|
---|
117 | pushfd
|
---|
118 | push es
|
---|
119 | pushad
|
---|
120 | call _pci32_function
|
---|
121 | popad
|
---|
122 | pop es
|
---|
123 | popfd
|
---|
124 | retf
|
---|
125 | endif
|
---|
126 | pushfd
|
---|
127 | cli
|
---|
128 | push esi
|
---|
129 | push edi
|
---|
130 | cmp al, 1 ; installation check
|
---|
131 | jne pci_pro_f02
|
---|
132 |
|
---|
133 | mov bx, 0210h
|
---|
134 | mov cx, 0
|
---|
135 | mov edx, ' ICP' ; 0x20494350 "PCI "
|
---|
136 | mov al, 1
|
---|
137 | jmp pci_pro_ok
|
---|
138 |
|
---|
139 | pci_pro_f02: ;; find pci device
|
---|
140 | cmp al, 2
|
---|
141 | jne pci_pro_f03
|
---|
142 |
|
---|
143 | shl ecx, 16
|
---|
144 | mov cx, dx
|
---|
145 | xor ebx, ebx
|
---|
146 | mov di, 0
|
---|
147 | pci_pro_devloop:
|
---|
148 | call pci_pro_select_reg
|
---|
149 | mov dx, PCI_CFG2
|
---|
150 | in eax, dx
|
---|
151 | cmp eax, ecx
|
---|
152 | jne pci_pro_nextdev
|
---|
153 |
|
---|
154 | cmp si, 0
|
---|
155 | je pci_pro_ok
|
---|
156 |
|
---|
157 | dec si
|
---|
158 | pci_pro_nextdev:
|
---|
159 | inc ebx
|
---|
160 | cmp ebx, MAX_BUSDEVFN
|
---|
161 | jne pci_pro_devloop
|
---|
162 |
|
---|
163 | mov ah, 86h
|
---|
164 | jmp pci_pro_fail
|
---|
165 |
|
---|
166 | pci_pro_f03: ;; find class code
|
---|
167 | cmp al, 3
|
---|
168 | jne pci_pro_f08
|
---|
169 |
|
---|
170 | xor ebx, ebx
|
---|
171 | mov di, 8
|
---|
172 | pci_pro_devloop2:
|
---|
173 | call pci_pro_select_reg
|
---|
174 | mov dx, PCI_CFG2
|
---|
175 | in eax, dx
|
---|
176 | shr eax, 8
|
---|
177 | cmp eax, ecx
|
---|
178 | jne pci_pro_nextdev2
|
---|
179 |
|
---|
180 | cmp si, 0
|
---|
181 | je pci_pro_ok
|
---|
182 |
|
---|
183 | dec si
|
---|
184 | pci_pro_nextdev2:
|
---|
185 | inc ebx
|
---|
186 | cmp ebx, MAX_BUSDEVFN
|
---|
187 | jne pci_pro_devloop2
|
---|
188 |
|
---|
189 | mov ah, 86h
|
---|
190 | jmp pci_pro_fail
|
---|
191 |
|
---|
192 | pci_pro_f08: ;; read configuration byte
|
---|
193 | cmp al, 8
|
---|
194 | jne pci_pro_f09
|
---|
195 |
|
---|
196 | call pci_pro_select_reg
|
---|
197 | push edx
|
---|
198 | mov dx, di
|
---|
199 | and dx, 3
|
---|
200 | add dx, PCI_CFG2
|
---|
201 | in al, dx
|
---|
202 | pop edx
|
---|
203 | mov cl, al
|
---|
204 | jmp pci_pro_ok
|
---|
205 |
|
---|
206 | pci_pro_f09: ;; read configuration word
|
---|
207 | cmp al, 9
|
---|
208 | jne pci_pro_f0a
|
---|
209 |
|
---|
210 | call pci_pro_select_reg
|
---|
211 | push edx
|
---|
212 | mov dx, di
|
---|
213 | and dx, 2
|
---|
214 | add dx, PCI_CFG2
|
---|
215 | in ax, dx
|
---|
216 | pop edx
|
---|
217 | mov cx, ax
|
---|
218 | jmp pci_pro_ok
|
---|
219 |
|
---|
220 | pci_pro_f0a: ;; read configuration dword
|
---|
221 | cmp al, 0Ah
|
---|
222 | jne pci_pro_f0b
|
---|
223 |
|
---|
224 | call pci_pro_select_reg
|
---|
225 | push edx
|
---|
226 | mov dx, PCI_CFG2
|
---|
227 | in eax, dx
|
---|
228 | pop edx
|
---|
229 | mov ecx, eax
|
---|
230 | jmp pci_pro_ok
|
---|
231 |
|
---|
232 | pci_pro_f0b: ;; write configuration byte
|
---|
233 | cmp al, 0Bh
|
---|
234 | jne pci_pro_f0c
|
---|
235 |
|
---|
236 | call pci_pro_select_reg
|
---|
237 | push edx
|
---|
238 | mov dx, di
|
---|
239 | and dx, 3
|
---|
240 | add dx, PCI_CFG2
|
---|
241 | mov al, cl
|
---|
242 | out dx, al
|
---|
243 | pop edx
|
---|
244 | jmp pci_pro_ok
|
---|
245 |
|
---|
246 | pci_pro_f0c: ;; write configuration word
|
---|
247 | cmp al, 0Ch
|
---|
248 | jne pci_pro_f0d
|
---|
249 |
|
---|
250 | call pci_pro_select_reg
|
---|
251 | push edx
|
---|
252 | mov dx, di
|
---|
253 | and dx, 2
|
---|
254 | add dx, PCI_CFG2
|
---|
255 | mov ax, cx
|
---|
256 | out dx, ax
|
---|
257 | pop edx
|
---|
258 | jmp pci_pro_ok
|
---|
259 |
|
---|
260 | pci_pro_f0d: ;; write configuration dword
|
---|
261 | cmp al, 0Dh
|
---|
262 | jne pci_pro_unknown
|
---|
263 | call pci_pro_select_reg
|
---|
264 | push edx
|
---|
265 | mov dx, PCI_CFG2
|
---|
266 | mov eax, ecx
|
---|
267 | out dx, eax
|
---|
268 | pop edx
|
---|
269 | jmp pci_pro_ok
|
---|
270 |
|
---|
271 | pci_pro_unknown:
|
---|
272 | mov ah, 81h
|
---|
273 | pci_pro_fail:
|
---|
274 | pop edi
|
---|
275 | pop esi
|
---|
276 | popfd
|
---|
277 | stc
|
---|
278 | retf
|
---|
279 |
|
---|
280 | pci_pro_ok:
|
---|
281 | xor ah, ah
|
---|
282 | pop edi
|
---|
283 | pop esi
|
---|
284 | popfd
|
---|
285 | clc
|
---|
286 | retf
|
---|
287 |
|
---|
288 | pci_pro_select_reg:
|
---|
289 | push edx
|
---|
290 | mov eax, 800000h
|
---|
291 | mov ax, bx
|
---|
292 | shl eax, 8
|
---|
293 | and di, 0FFh
|
---|
294 | or ax, di
|
---|
295 | and al, 0FCh
|
---|
296 | mov dx, PCI_CFG1
|
---|
297 | out dx, eax
|
---|
298 | pop edx
|
---|
299 | ret
|
---|
300 |
|
---|
301 | BIOS32 ends
|
---|
302 |
|
---|
303 | endif ; BX_PCIBIOS
|
---|
304 |
|
---|
305 | end
|
---|