VirtualBox

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

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

*: scm --update-copyright-year

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

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