VirtualBox

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

Last change on this file since 53426 was 44209, checked in by vboxsync, 12 years ago

BIOS: Do not use IRQ 5 for PCI devices.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
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
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
98 mov eax, 0E0000000h ; base for memory init
99 push eax
100 mov ax, 0D000h ; base for i/o init
101 push ax
102 mov ax, 010h ; start at base address #0
103 push ax
104 mov bx, 8
105pci_init_io_loop1:
106 mov dl, 0
107 call pcibios_init_sel_reg
108 mov dx, PCI_CFG2
109 in ax, dx
110 cmp ax, 0FFFFh
111 jz next_pci_dev
112
113ifndef VBOX ; This currently breaks restoring a previously saved state. */
114 mov dl, 4 ; disable i/o and memory space access
115 call pcibios_init_sel_reg
116 mov dx, PCI_CFG2
117 in al, dx
118 and al, 0FCh
119 out dx, al
120pci_init_io_loop2:
121 mov dl, [bp-8]
122 call pcibios_init_sel_reg
123 mov dx, PCI_CFG2
124 in eax, dx
125 test al, 1
126 jnz init_io_base
127
128 mov ecx, eax
129 mov eax, 0FFFFFFFFh
130 out dx, eax
131 in eax, dx
132 cmp eax, ecx
133 je next_pci_base
134 xor eax, 0FFFFFFFFh
135 mov ecx, eax
136 mov eax, [bp-4]
137 out dx, eax
138 add eax, ecx ; calculate next free mem base
139 add eax, 01000000h
140 and eax, 0FF000000h
141 mov [bp-4], eax
142 jmp next_pci_base
143
144init_io_base:
145 mov cx, ax
146 mov ax, 0FFFFh
147 out dx, eax
148 in eax, dx
149 cmp ax, cx
150 je next_pci_base
151
152 xor ax, 0FFFEh
153 mov cx, ax
154 mov ax, [bp-6]
155 out dx, eax
156 add ax, cx ; calculate next free i/o base
157 add ax, 00100h
158 and ax, 0FF00h
159 mov [bp-6], ax
160next_pci_base:
161 mov al, [bp-8]
162 add al, 4
163 cmp al, 28h
164 je enable_iomem_space
165
166 mov byte ptr[bp-8], al
167 jmp pci_init_io_loop2
168endif ; !VBOX
169
170enable_iomem_space:
171 mov dl, 4 ;; enable i/o and memory space access if available
172 call pcibios_init_sel_reg
173 mov dx, PCI_CFG2
174 in al, dx
175 or al, 7
176 out dx, al
177ifdef VBOX
178 mov dl, 0 ; check if PCI device is AMD PCNet
179 call pcibios_init_sel_reg
180 mov dx, PCI_CFG2
181 in eax, dx
182 cmp eax, 020001022h
183 jne next_pci_dev
184
185 mov dl, 10h ; get I/O address
186 call pcibios_init_sel_reg
187 mov dx, PCI_CFG2
188 in ax, dx
189 and ax, 0FFFCh
190 mov cx, ax
191 mov dx, cx
192 add dx, 14h ; reset register if PCNet is in word I/O mode
193 in ax, dx ; reset is performed by reading the reset register
194 mov dx, cx
195 add dx, 18h ; reset register if PCNet is in word I/O mode
196 in eax, dx ; reset is performed by reading the reset register
197endif ; VBOX
198next_pci_dev:
199 mov byte ptr[bp-8], 10h
200 inc bx
201 cmp bx, 0100h
202 jne pci_init_io_loop1
203 mov sp, bp
204 pop bp
205 ret
206
207pcibios_init_set_elcr:
208 push ax
209 push cx
210 mov dx, 04D0h
211 test al, 8
212 jz is_master_pic
213
214 inc dx
215 and al, 7
216is_master_pic:
217 mov cl, al
218 mov bl, 1
219 shl bl, cl
220 in al, dx
221 or al, bl
222 out dx, al
223 pop cx
224 pop ax
225 ret
226
227pcibios_init_irqs:
228 push ds
229 push bp
230 mov ax, 0F000h
231 mov ds, ax
232 mov dx, 04D0h ;; reset ELCR1 + ELCR2
233 mov al, 0
234 out dx, al
235 inc dx
236 out dx, al
237 mov si, pci_routing_table_structure
238 mov bh, [si+8]
239 mov bl, [si+9]
240 mov dl, 0
241 call pcibios_init_sel_reg
242 mov dx, PCI_CFG2
243 in eax, dx
244 cmp eax, [si+12] ;; check irq router
245 jne pci_init_end
246
247 mov dl, [si+34]
248 call pcibios_init_sel_reg
249 push bx ;; save irq router bus + devfunc
250 mov dx, PCI_CFG2
251 mov ax, 8080h
252 out dx, ax ;; reset PIRQ route control
253 add dx, 2
254 out dx, ax
255 mov ax, [si+6]
256 sub ax, 20h
257 shr ax, 4
258 mov cx, ax
259 add si, 20h ;; set pointer to 1st entry
260 mov bp, sp
261 mov ax, pci_irq_list
262 push ax
263 xor ax, ax
264 push ax
265pci_init_irq_loop1:
266 mov bh, [si]
267 mov bl, [si+1]
268pci_init_irq_loop2:
269 mov dl, 0
270 call pcibios_init_sel_reg
271 mov dx, PCI_CFG2
272 in ax, dx
273 cmp ax, 0FFFFh
274 jnz pci_test_int_pin
275
276 test bl, 7
277 jz next_pir_entry
278
279 jmp next_pci_func
280
281pci_test_int_pin:
282 mov dl, 3Ch
283 call pcibios_init_sel_reg
284 mov dx, PCI_CFG2 + 1 ; TODO: was #0x0cfd - is that right?
285 in al, dx
286 and al, 7
287 jz next_pci_func
288
289 dec al ;; determine pirq reg
290 mov dl, 3
291 mul dl
292 add al, 2
293 xor ah, ah
294 mov bx, ax
295 mov al, [si+bx]
296 mov dl, al
297 mov bx, [bp]
298 call pcibios_init_sel_reg
299 mov dx, PCI_CFG2
300 and al, 3
301 add dl, al
302 in al, dx
303 cmp al, 80h
304 jb pirq_found
305
306 mov bx, [bp-2] ;; pci irq list pointer
307 mov al, [bx]
308 out dx, al
309 inc bx
310 mov [bp-2], bx
311 call pcibios_init_set_elcr
312pirq_found:
313 mov bh, [si]
314 mov bl, [si+1]
315 add bl, [bp-3] ;; pci function number
316 mov dl, 3Ch
317 call pcibios_init_sel_reg
318 mov dx, PCI_CFG2
319 out dx, al
320next_pci_func:
321 inc byte ptr[bp-3]
322 inc bl
323 test bl, 7
324 jnz pci_init_irq_loop2
325
326next_pir_entry:
327 add si, 10h
328 mov byte ptr[bp-3], 0
329 loop pci_init_irq_loop1
330
331 mov sp, bp
332 pop bx
333pci_init_end:
334 pop bp
335 pop ds
336 ret
337
338.286
339
340endif ; !BX_ROMBIOS32
341
342endif ; BX_PCIBIOS
343
Note: See TracBrowser for help on using the repository browser.

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