Index: trunk/src/VBox/Devices/PC/BIOS/inlines.h
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/inlines.h	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/inlines.h	(revision 42332)
@@ -61,4 +61,26 @@
     modify exact [] nomemory aborts;
 
+#ifdef __386__
+
+void rep_movsb(void __far *d, void __far *s, int nbytes);
+#pragma aux rep_movsb =     \
+    "push   ds"             \
+    "mov    ds, dx"         \
+    "rep    movsb"          \
+    "pop    ds"             \
+    parm [es edi] [dx esi] [ecx];
+
+#else
+
+void rep_movsb(void __far *d, void __far *s, int nbytes);
+#pragma aux rep_movsb =     \
+    "push   ds"             \
+    "mov    ds, dx"         \
+    "rep    movsb"          \
+    "pop    ds"             \
+    parm [es di] [dx si] [cx];
+
+#endif
+
 void rep_movsw(void __far *d, void __far *s, int nwords);
 #pragma aux rep_movsw =     \
Index: trunk/src/VBox/Devices/PC/BIOS/makefile
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/makefile	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/makefile	(revision 42332)
@@ -15,5 +15,5 @@
 !endif
 CFLAGS   = -q -0 -wx -zu -s -oas -d1+ -ms
-CFLAGS32 = -q -wx -zu -s -oas -d1+ -nt=BIOS32 -nd=BIOS32
+CFLAGS32 = -q -wx -zu -s -oas -d1+ -ms -nt=BIOS32 -nd=BIOS32
 
 DEFS = -DVBOX -DVBOX_LANBOOT_SEG=0xE200 -DVBOX_VERSION_STRING=$(Q)0.9$(Q) &
Index: trunk/src/VBox/Devices/PC/BIOS/orgs.asm
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/orgs.asm	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/orgs.asm	(revision 42332)
@@ -110,5 +110,4 @@
 extrn		_int19_function:near
 extrn		_int1a_function:near
-extrn		_int1a_function_pci:near
 extrn		_pci16_function:near
 extrn		_int70_function:near
@@ -1646,21 +1645,4 @@
 		jne	int1a_normal
 
-if 0
-		call	pcibios_real
-		jc	pcibios_error
-
-		jmp	iret_modify_cf	; don't trash caller's flags!
-
-pcibios_error:
-;		mov	bl, ah
-;		mov	ah, 0B1h
-		pusha
-;		mov	ax, ss	; set readable descriptor to DS for calling
-;		mov	ds, ax	; PCI BIOS from 16-bit protected mode
-		; TODO: C environment?!
-		call	_int1a_function_pci
-		popa
-		iret
-else
 		push	es
 		push	ds
@@ -1674,5 +1656,4 @@
 		pop	es
 		iret
-endif
 
 int1a_normal:
Index: trunk/src/VBox/Devices/PC/BIOS/pcibio32.asm
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/pcibio32.asm	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/pcibio32.asm	(revision 42332)
@@ -116,7 +116,9 @@
 
 		pushfd
+		push	es
 		pushad
 		call	_pci32_function
 		popad
+		pop	es
 		popfd
 		retf
Index: trunk/src/VBox/Devices/PC/BIOS/pcibios.c
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/pcibios.c	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/pcibios.c	(revision 42332)
@@ -97,4 +97,5 @@
 typedef struct {
     pushad_regs_t   gr;
+    uint32_t        es;
     uint32_t        flags;
 } pci_regs_t;
@@ -157,4 +158,14 @@
 
 #endif
+
+/* PCI IRQ routing expansion buffer descriptor. */
+typedef struct {
+    uint16_t        buf_size;
+    uint8_t __far   *buf_ptr;
+} pci_route_buf;
+
+/* Defined in assembler module .*/
+extern char     pci_routing_table[];
+extern uint16_t pci_routing_table_size;
 
 /* Write the CONFIG_ADDRESS register to prepare for data access. Requires
@@ -293,5 +304,6 @@
 void BIOSCALL PCIxx(function)(volatile pci_regs_t r)
 {
-    uint16_t    device;
+    pci_route_buf __far     *route_buf;
+    uint16_t                device;
 
     BX_DEBUG_PCI("PCI: AX=%04X BX=%04X CX=%04X\n", AX, BX, CX);
@@ -367,4 +379,13 @@
         }
         break;
+    case GET_IRQ_ROUTING:
+        route_buf = ES :> (void *)DI;
+        if (pci_routing_table_size > route_buf->buf_size) {
+            SET_AH(BUFFER_TOO_SMALL);
+            SET_CF();
+        } else {
+            rep_movsb(route_buf->buf_ptr, pci_routing_table, pci_routing_table_size);
+        }
+        break;
     default:
         BX_INFO("PCI: Unsupported function AX=%04X BX=%04X called\n", AX, BX);
Index: trunk/src/VBox/Devices/PC/BIOS/pcibios.inc
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/pcibios.inc	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/pcibios.inc	(revision 42332)
@@ -49,15 +49,4 @@
 ; Publics for easier debugging and disassembly
 
-public		pcibios_real
-public		pci_present
-public		pci_real_f02
-public		pci_real_devloop
-public		pci_real_nextdev
-public		pci_real_f03
-public		pci_real_devloop2
-public		pci_real_nextdev2
-public		pci_real_ok
-public		pci_real_fail
-public		pci_real_select_reg
 public		pcibios_init_iomem_bases
 public		pci_init_io_loop1
@@ -81,263 +70,4 @@
 
 .386
-pcibios_real:
-		push	eax
-		push	dx
-ifdef PCI_FIXED_HOST_BRIDGE_1
-		mov	eax, 80000000h
-		mov	dx, PCI_CFG1
-		out	dx, eax
-		mov	dx, PCI_CFG2
-		in	eax, dx
-		cmp	eax, PCI_FIXED_HOST_BRIDGE_1
-		je	pci_present
-endif
-
-ifdef PCI_FIXED_HOST_BRIDGE_2
-		; 18h << 11
-		mov	eax, 8000c000h
-		mov	dx, PCI_CFG1
-		out	dx, eax
-		mov	dx, PCI_CFG2
-		in	eax, dx
-		cmp	eax, PCI_FIXED_HOST_BRIDGE_2
-		je	pci_present
-		; 19h << 11
-		mov	eax, 8000c800h
-		mov	dx, PCI_CFG1
-		out	dx, eax
-		mov	dx, PCI_CFG2
-		in	eax, dx
-		cmp	eax, PCI_FIXED_HOST_BRIDGE_2
-		je	pci_present
-endif
-		pop	dx
-		pop	eax
-		mov	ah, 0FFh
-		stc
-		ret
-pci_present:
-		pop	dx
-		pop	eax
-		cmp	al, 1		; installation check
-		jne pci_real_f02
-		mov	ax, 0001h
-		mov	bx, 0210h
-		mov	cx, 0
-		mov	edx, ' ICP'	; #0x20494350 "PCI "
-;; @todo!
-if 0
-		mov	edi, 0f0000h
-		mov	di, pcibios_protected
-else
-		mov	edi, pcibios_protected
-endif
-		clc
-		ret
-
-pci_real_f02: ;; find pci device
-		push	esi
-		push	edi
-		push	edx
-		cmp	al, 2
-		jne	pci_real_f03
-
-		shl	ecx, 16
-		mov	cx, dx
-		xor	ebx, ebx
-		mov	di, 0
-pci_real_devloop:
-		call	pci_real_select_reg
-		mov	dx, PCI_CFG2
-		in	eax, dx
-		cmp	eax, ecx
-		jne	pci_real_nextdev
-
-		cmp	si, 0
-		je	pci_real_ok
-
-		dec	si
-pci_real_nextdev:
-		inc	ebx
-		cmp	ebx, MAX_BUSDEVFN
-		jne	pci_real_devloop
-
-		mov	dx, cx
-		shr	ecx, 16
-		mov	ax, 8602h
-		jmp	pci_real_fail
-pci_real_f03: ;; find class code
-		cmp	al, 3
-		jne	pci_real_f08
-		xor	ebx, ebx
-		mov	di, 8
-pci_real_devloop2:
-		call	pci_real_select_reg
-		mov	dx, PCI_CFG2
-		in	eax, dx
-		shr	eax, 8
-		cmp	eax, ecx
-		jne	pci_real_nextdev2
-
-		cmp	si, 0
-		je	pci_real_ok
-
-		dec	si
-pci_real_nextdev2:
-		inc	ebx
-		cmp	ebx, MAX_BUSDEVFN
-		jne	pci_real_devloop2
-
-		mov	ax, 8603h
-		jmp	pci_real_fail
-
-pci_real_f08: ;; read configuration byte
-		cmp	al, 8
-		jne	pci_real_f09
-
-		call	pci_real_select_reg
-		push	dx
-		mov	dx, di
-		and	dx, 3
-		add	dx, PCI_CFG2
-		in	al, dx
-		pop	dx
-		mov	cl, al
-		jmp	pci_real_ok
-
-pci_real_f09: ;; read configuration word
-		cmp	al, 9
-		jne	pci_real_f0a
-
-		call	pci_real_select_reg
-		push	dx
-		mov	dx, di
-		and	dx, 2
-		add	dx, PCI_CFG2
-		in	ax, dx
-		pop	dx
-		mov	cx, ax
-		jmp	pci_real_ok
-pci_real_f0a: ;; read configuration dword
-		cmp	al, 0Ah
-		jne	pci_real_f0b
-
-		call	pci_real_select_reg
-		push	dx
-		mov	dx, PCI_CFG2
-		in	eax, dx
-		pop	dx
-		mov	ecx, eax
-		jmp	pci_real_ok
-
-pci_real_f0b: ;; write configuration byte
-		cmp	al, 0Bh
-		jne	pci_real_f0c
-
-		call	pci_real_select_reg
-		push	dx
-		mov	dx, di
-		and	dx, 3
-		add	dx, PCI_CFG2
-		mov	al, cl
-		out	dx, al
-		pop	dx
-		jmp	pci_real_ok
-
-pci_real_f0c: ;; write configuration word
-		cmp	al, 0Ch
-		jne	pci_real_f0d
-
-		call	pci_real_select_reg
-		push	dx
-		mov	dx, di
-		and	dx, 2
-		add	dx, PCI_CFG2
-		mov	ax, cx
-		out	dx, ax
-		pop	dx
-		jmp	pci_real_ok
-
-pci_real_f0d: ;; write configuration dword
-		cmp	al, 0Dh
-		jne	pci_real_f0e
-
-		call	pci_real_select_reg
-		push	dx
-		mov	dx, PCI_CFG2
-		mov	eax, ecx
-		out	dx, eax
-		pop	dx
-		jmp	pci_real_ok
-
-pci_real_f0e: ;; get irq routing options
-		cmp	al, 0Eh
-		jne	pci_real_unknown
-
-		cmp	word ptr es:[di], pci_routing_table_structure_end - pci_routing_table_structure_start
-		jb	pci_real_too_small
-
-		mov	word ptr es:[di], pci_routing_table_structure_end - pci_routing_table_structure_start
-		pushf
-		push	ds
-		push	es
-		push	cx
-		push	si
-		push	di
-		cld
-		mov	si, pci_routing_table_structure_start
-		push	cs
-		pop	ds
-		mov	cx, es:[di+2]
-		mov	es, es:[di+4]
-		mov	di, cx
-		mov	cx, pci_routing_table_structure_end - pci_routing_table_structure_start
-		rep	movsb
-		pop	di
-		pop	si
-		pop	cx
-		pop	es
-		pop	ds
-		popf
-		mov	bx, (1 shl 9) or (1 shl 11) ; #(1 << 9) | (1 << 11)   ;; irq 9 and 11 are used
-		jmp	pci_real_ok
-
-pci_real_too_small:
-		mov	word ptr es:[di], pci_routing_table_structure_end - pci_routing_table_structure_start
-		mov	ah, 89h
-		jmp	pci_real_fail
-
-pci_real_unknown:
-		mov	ah, 81h
-pci_real_fail:
-		pop	edx
-		pop	edi
-		pop	esi
-		stc
-		ret
-pci_real_ok:
-		xor	ah, ah
-		pop	edx
-		pop	edi
-		pop	esi
-		clc
-		ret
-
-;; prepare from reading the PCI config space; on input:
-;; bx = bus/dev/fn
-;; di = offset into config space header
-;; destroys eax and may modify di
-pci_real_select_reg:
-		push	dx
-		mov	eax, 800000h
-		mov	ax,  bx
-		shl	eax, 8
-		and	di,  0FFh
-		or	ax,  di
-		and	al,  0FCh
-		mov	dx,  PCI_CFG1
-		out	dx,  eax
-		pop	dx
-		ret
 
 if not BX_ROMBIOS32
Index: trunk/src/VBox/Devices/PC/BIOS/pirq.inc
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/pirq.inc	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/pirq.inc	(revision 42332)
@@ -40,5 +40,6 @@
 
 if BX_PCIBIOS
-public pci_routing_table_structure      ; For disassembly
+public _pci_routing_table
+public _pci_routing_table_size
 
 align 16
@@ -63,5 +64,6 @@
   db 7 ;; checksum
 endif ; !VBOX
-pci_routing_table_structure_start:
+_pci_routing_table:
+pci_routing_table:
   ;; first slot entry PCI-to-ISA (embedded)
   db 0 ;; pci bus number
@@ -456,5 +458,7 @@
   db 0 ;; reserved
 endif ; VBOX
-pci_routing_table_structure_end:
+pci_routing_table_end:
+;; Size of the table
+pci_routing_table_size dw	pci_routing_table_end - pci_routing_table
 
 endif   ; BX_PCIBIOS
Index: trunk/src/VBox/Devices/PC/BIOS/timepci.c
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/timepci.c	(revision 42260)
+++ trunk/src/VBox/Devices/PC/BIOS/timepci.c	(revision 42332)
@@ -146,38 +146,4 @@
 // in the following routines
 
-/* The PCI BIOS routine must be callable from protected mode, and
- * therefore must not modify any segment registers(!).
- */
-#if BX_PCIBIOS
-void BIOSCALL int1a_function_pci(i1apci_regs_t r)
-{
-#if 0
-    // real mode PCI BIOS functions now handled in assembler code
-    // this C code handles the error code for information only
-    if (r.gr.u.r8.ah == 0xff) {
-        BX_INFO("PCI BIOS: PCI not present\n");
-    } else if (r.gr.u.r8.ah == 0x81) {
-        BX_INFO("unsupported PCI BIOS function 0x%02x\n", r.gr.u.r8.al);
-    } else if (r.gr.u.r8.ah == 0x83) {
-        BX_INFO("bad PCI vendor ID %04x\n", r.gr.u.r16.dx);
-    } else if (r.gr.u.r8.ah == 0x86) {
-        if (r.gr.u.r8.ah == 0x02) {
-            BX_INFO("PCI device %04x:%04x not found at index %d\n", r.gr.u.r16.dx, r.gr.u.r16.cx, r.gr.u.r16.si);
-        } else {
-            BX_INFO("no PCI device with class code 0x%02x%04x found at index %d\n", r.gr.u.r8.cl, r.gr.u.r16.dx, r.gr.u.r16.si);
-        }
-    }
-#endif
-    //@todo: OS/2 MCP2 apparently calls us in protected mode with a DS which does not
-    // point to the BIOS segment!?!
-    send(BIOS_PRINTF_INFO, '!');
-    send(BIOS_PRINTF_INFO, '\n');
-    if (!GetCF(r.ra.flags)) {
-        SetCF(r.ra.flags);
-    }
-}
-#endif
-
-
 void BIOSCALL int1a_function(pusha_regs_t regs, uint16_t ds, uint16_t es, iret_addr_t iret_addr)
 {
