VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS-new/pcibio32.asm@ 41991

Last change on this file since 41991 was 41991, checked in by vboxsync, 13 years ago

addendum to r78863, maybe we should drop this PCI detection code at all

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 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
41include pcicfg.inc
42
43if BX_PCIBIOS
44
45.386
46
47BIOS32 segment public 'CODE' use32
48
49public pcibios_protected
50
51align 16
52bios32_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
60align 16
61bios32_entry_point:
62 pushfd
63 cmp eax, 'ICP$' ; 0x49435024 "$PCI"
64 jne unknown_service
65
66ifdef 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
74endif
75
76ifdef 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
93endif
94 jmp unknown_service
95device_ok:
96 mov ebx, 000f0000h
97 mov ecx, 0
98 mov edx, pcibios_protected
99 xor al, al
100 jmp bios32_end
101
102unknown_service:
103 mov al, 80h
104bios32_end:
105 popfd
106 retf
107
108align 16
109pcibios_protected:
110 pushfd
111 cli
112 push esi
113 push edi
114 cmp al, 1 ; installation check
115 jne pci_pro_f02
116
117 mov bx, 0210h
118 mov cx, 0
119 mov edx, ' ICP' ; 0x20494350 "PCI "
120 mov al, 1
121 jmp pci_pro_ok
122
123pci_pro_f02: ;; find pci device
124 cmp al, 2
125 jne pci_pro_f03
126
127 shl ecx, 16
128 mov cx, dx
129 xor ebx, ebx
130 mov di, 0
131pci_pro_devloop:
132 call pci_pro_select_reg
133 mov dx, PCI_CFG2
134 in eax, dx
135 cmp eax, ecx
136 jne pci_pro_nextdev
137
138 cmp si, 0
139 je pci_pro_ok
140
141 dec si
142pci_pro_nextdev:
143 inc ebx
144 cmp ebx, MAX_BUSDEVFN
145 jne pci_pro_devloop
146
147 mov ah, 86h
148 jmp pci_pro_fail
149
150pci_pro_f03: ;; find class code
151 cmp al, 3
152 jne pci_pro_f08
153
154 xor ebx, ebx
155 mov di, 8
156pci_pro_devloop2:
157 call pci_pro_select_reg
158 mov dx, PCI_CFG2
159 in eax, dx
160 shr eax, 8
161 cmp eax, ecx
162 jne pci_pro_nextdev2
163
164 cmp si, 0
165 je pci_pro_ok
166
167 dec si
168pci_pro_nextdev2:
169 inc ebx
170 cmp ebx, MAX_BUSDEVFN
171 jne pci_pro_devloop2
172
173 mov ah, 86h
174 jmp pci_pro_fail
175
176pci_pro_f08: ;; read configuration byte
177 cmp al, 8
178 jne pci_pro_f09
179
180 call pci_pro_select_reg
181 push edx
182 mov dx, di
183 and dx, 3
184 add dx, PCI_CFG2
185 in al, dx
186 pop edx
187 mov cl, al
188 jmp pci_pro_ok
189
190pci_pro_f09: ;; read configuration word
191 cmp al, 9
192 jne pci_pro_f0a
193
194 call pci_pro_select_reg
195 push edx
196 mov dx, di
197 and dx, 2
198 add dx, PCI_CFG2
199 in ax, dx
200 pop edx
201 mov cx, ax
202 jmp pci_pro_ok
203
204pci_pro_f0a: ;; read configuration dword
205 cmp al, 0Ah
206 jne pci_pro_f0b
207
208 call pci_pro_select_reg
209 push edx
210 mov dx, PCI_CFG2
211 in eax, dx
212 pop edx
213 mov ecx, eax
214 jmp pci_pro_ok
215
216pci_pro_f0b: ;; write configuration byte
217 cmp al, 0Bh
218 jne pci_pro_f0c
219
220 call pci_pro_select_reg
221 push edx
222 mov dx, di
223 and dx, 3
224 add dx, PCI_CFG2
225 mov al, cl
226 out dx, al
227 pop edx
228 jmp pci_pro_ok
229
230pci_pro_f0c: ;; write configuration word
231 cmp al, 0Ch
232 jne pci_pro_f0d
233
234 call pci_pro_select_reg
235 push edx
236 mov dx, di
237 and dx, 2
238 add dx, PCI_CFG2
239 mov ax, cx
240 out dx, ax
241 pop edx
242 jmp pci_pro_ok
243
244pci_pro_f0d: ;; write configuration dword
245 cmp al, 0Dh
246 jne pci_pro_unknown
247 call pci_pro_select_reg
248 push edx
249 mov dx, PCI_CFG2
250 mov eax, ecx
251 out dx, eax
252 pop edx
253 jmp pci_pro_ok
254
255pci_pro_unknown:
256 mov ah, 81h
257pci_pro_fail:
258 pop edi
259 pop esi
260 popfd
261 stc
262 retf
263
264pci_pro_ok:
265 xor ah, ah
266 pop edi
267 pop esi
268 popfd
269 clc
270 retf
271
272pci_pro_select_reg:
273 push edx
274 mov eax, 800000h
275 mov ax, bx
276 shl eax, 8
277 and di, 0FFh
278 or ax, di
279 and al, 0FCh
280 mov dx, PCI_CFG1
281 out dx, eax
282 pop edx
283 ret
284
285BIOS32 ends
286
287endif ; BX_PCIBIOS
288
289 end
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