VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/pcibios.inc@ 67668

最後變更 在這個檔案從67668是 67668,由 vboxsync 提交於 8 年 前

PDM: rip out the entire FakePCIBIOS support, no longer triggered from here
Devices/Bus: register magic port to trigger FakePCIBIOS
BIOS: disable the unneeded function for PCI resource/IRQ initialization (only partially used anyway) and use the magic port to trigger FakePCIBIOS

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.7 KB
 
1;;
2;; Copyright (C) 2006-2015 Oracle Corporation
3;;
4;; This file is part of VirtualBox Open Source Edition (OSE), as
5;; available from http://www.alldomusa.eu.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
42; Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
43; other than GPL or LGPL is available it will apply instead, Oracle elects to use only
44; the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
45; a choice of LGPL license versions is made available with the language indicating
46; that LGPLv2 or any later version may be used, or where a choice of which version
47; of the LGPL is applied is otherwise unspecified.
48
49include pcicfg.inc
50
51if BX_PCIBIOS
52
53ifdef DEBUG
54
55; Publics for easier debugging and disassembly
56
57public pcibios_init_iomem_bases
58public pci_init_io_loop1
59public pci_init_io_loop2
60public init_io_base
61public next_pci_base
62public enable_iomem_space
63public next_pci_dev
64public pcibios_init_set_elcr
65public is_master_pic
66public pcibios_init_irqs
67public pci_init_irq_loop1
68public pci_init_irq_loop2
69public pci_test_int_pin
70public pirq_found
71public next_pci_func
72public next_pir_entry
73public pci_init_end
74
75endif
76
77.386
78
79if not BX_ROMBIOS32
80pci_irq_list:
81 db 11, 10, 9, 11
82
83pcibios_init_sel_reg:
84 push eax
85 mov eax, 800000h
86 mov ax, bx
87 shl eax, 8
88 and dl, 0FCh
89 or al, dl
90 mov dx, PCI_CFG1
91 out dx, eax
92 pop eax
93 ret
94
95pcibios_init_iomem_bases:
96 push bp
97 mov bp, sp
98ifdef VBOX
99 mov eax,19200509
100 mov dx,410h
101 out dx, eax
102else
103; This incomplete PCI resource setup code is less functional than the PCI
104; resource assignment created by the fake PCI BIOS and is therefore disabled.
105; Blindly enabling everything on the root bus (including bus mastering!) can
106; only be called buggy. It causes the trouble with AMD PCNet which it then
107; tries to work around, but that still contains a race.
108 mov eax, 0E0000000h ; base for memory init
109 push eax
110 mov ax, 0D000h ; base for i/o init
111 push ax
112 mov ax, 010h ; start at base address #0
113 push ax
114 mov bx, 8
115pci_init_io_loop1:
116 mov dl, 0
117 call pcibios_init_sel_reg
118 mov dx, PCI_CFG2
119 in ax, dx
120 cmp ax, 0FFFFh
121 jz next_pci_dev
122
123ifndef VBOX ; This currently breaks restoring a previously saved state.
124 mov dl, 4 ; disable i/o and memory space access
125 call pcibios_init_sel_reg
126 mov dx, PCI_CFG2
127 in al, dx
128 and al, 0FCh
129 out dx, al
130pci_init_io_loop2:
131 mov dl, [bp-8]
132 call pcibios_init_sel_reg
133 mov dx, PCI_CFG2
134 in eax, dx
135 test al, 1
136 jnz init_io_base
137
138 mov ecx, eax
139 mov eax, 0FFFFFFFFh
140 out dx, eax
141 in eax, dx
142 cmp eax, ecx
143 je next_pci_base
144 xor eax, 0FFFFFFFFh
145 mov ecx, eax
146 mov eax, [bp-4]
147 out dx, eax
148 add eax, ecx ; calculate next free mem base
149 add eax, 01000000h
150 and eax, 0FF000000h
151 mov [bp-4], eax
152 jmp next_pci_base
153
154init_io_base:
155 mov cx, ax
156 mov ax, 0FFFFh
157 out dx, eax
158 in eax, dx
159 cmp ax, cx
160 je next_pci_base
161
162 xor ax, 0FFFEh
163 mov cx, ax
164 mov ax, [bp-6]
165 out dx, eax
166 add ax, cx ; calculate next free i/o base
167 add ax, 00100h
168 and ax, 0FF00h
169 mov [bp-6], ax
170next_pci_base:
171 mov al, [bp-8]
172 add al, 4
173 cmp al, 28h
174 je enable_iomem_space
175
176 mov byte ptr[bp-8], al
177 jmp pci_init_io_loop2
178endif ; !VBOX
179
180enable_iomem_space:
181 mov dl, 4 ;; enable i/o and memory space access if available
182 call pcibios_init_sel_reg
183 mov dx, PCI_CFG2
184 in al, dx
185 or al, 7
186 out dx, al
187ifdef VBOX
188 mov dl, 0 ; check if PCI device is AMD PCNet
189 call pcibios_init_sel_reg
190 mov dx, PCI_CFG2
191 in eax, dx
192 cmp eax, 020001022h
193 jne next_pci_dev
194
195 mov dl, 10h ; get I/O address
196 call pcibios_init_sel_reg
197 mov dx, PCI_CFG2
198 in ax, dx
199 and ax, 0FFFCh
200 mov cx, ax
201 mov dx, cx
202 add dx, 14h ; reset register if PCNet is in word I/O mode
203 in ax, dx ; reset is performed by reading the reset register
204 mov dx, cx
205 add dx, 18h ; reset register if PCNet is in word I/O mode
206 in eax, dx ; reset is performed by reading the reset register
207endif ; VBOX
208next_pci_dev:
209 mov byte ptr[bp-8], 10h
210 inc bx
211 cmp bx, 0100h
212 jne pci_init_io_loop1
213endif ; !VBOX
214 mov sp, bp
215 pop bp
216 ret
217
218pcibios_init_set_elcr:
219 push ax
220 push cx
221 mov dx, 04D0h
222 test al, 8
223 jz is_master_pic
224
225 inc dx
226 and al, 7
227is_master_pic:
228 mov cl, al
229 mov bl, 1
230 shl bl, cl
231 in al, dx
232 or al, bl
233 out dx, al
234 pop cx
235 pop ax
236 ret
237
238pcibios_init_irqs:
239 push ds
240 push bp
241 mov ax, 0F000h
242 mov ds, ax
243ifndef VBOX
244; this code works OK, but it's unnecessary effort since the fake PCI BIOS
245; already configured the IRQ lines and the ELCR correctly
246 mov dx, 04D0h ;; reset ELCR1 + ELCR2
247 mov al, 0
248 out dx, al
249 inc dx
250 out dx, al
251 mov si, pci_routing_table_structure
252 mov bh, [si+8]
253 mov bl, [si+9]
254 mov dl, 0
255 call pcibios_init_sel_reg
256 mov dx, PCI_CFG2
257 in eax, dx
258 cmp eax, [si+12] ;; check irq router
259 jne pci_init_end
260
261 mov dl, [si+34]
262 call pcibios_init_sel_reg
263 push bx ;; save irq router bus + devfunc
264 mov dx, PCI_CFG2
265 mov ax, 8080h
266 out dx, ax ;; reset PIRQ route control
267 add dx, 2
268 out dx, ax
269 mov ax, [si+6]
270 sub ax, 20h
271 shr ax, 4
272 mov cx, ax
273 add si, 20h ;; set pointer to 1st entry
274 mov bp, sp
275 mov ax, pci_irq_list
276 push ax
277 xor ax, ax
278 push ax
279pci_init_irq_loop1:
280 mov bh, [si]
281 mov bl, [si+1]
282pci_init_irq_loop2:
283 mov dl, 0
284 call pcibios_init_sel_reg
285 mov dx, PCI_CFG2
286 in ax, dx
287 cmp ax, 0FFFFh
288 jnz pci_test_int_pin
289
290 test bl, 7
291 jz next_pir_entry
292
293 jmp next_pci_func
294
295pci_test_int_pin:
296 mov dl, 3Ch
297 call pcibios_init_sel_reg
298 mov dx, PCI_CFG2 + 1 ; access config space at 3Dh
299 in al, dx
300 and al, 7
301 jz next_pci_func
302
303 dec al ;; determine pirq reg
304 mov dl, 3
305 mul dl
306 add al, 2
307 xor ah, ah
308 mov bx, ax
309 mov al, [si+bx]
310 mov dl, al
311 mov bx, [bp]
312 call pcibios_init_sel_reg
313 mov dx, PCI_CFG2
314 and al, 3
315 add dl, al
316 in al, dx
317 cmp al, 80h
318 jb pirq_found
319
320 mov bx, [bp-2] ;; pci irq list pointer
321 mov al, [bx]
322 out dx, al
323 inc bx
324 mov [bp-2], bx
325 call pcibios_init_set_elcr
326pirq_found:
327 mov bh, [si]
328 mov bl, [si+1]
329 add bl, [bp-3] ;; pci function number
330 mov dl, 3Ch
331 call pcibios_init_sel_reg
332 mov dx, PCI_CFG2
333 out dx, al
334next_pci_func:
335 inc byte ptr[bp-3]
336 inc bl
337 test bl, 7
338 jnz pci_init_irq_loop2
339
340next_pir_entry:
341 add si, 10h
342 mov byte ptr[bp-3], 0
343 loop pci_init_irq_loop1
344
345 mov sp, bp
346 pop bx
347pci_init_end:
348endif
349 pop bp
350 pop ds
351 ret
352
353endif ; !BX_ROMBIOS32
354
355endif ; BX_PCIBIOS
356
357SET_DEFAULT_CPU_286
358
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette