Skip to contentSkip to conversation

Add PCI

PATCH New Hollis Blanchard 1 participant 1 message Apr 30, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add PCI

qemu/hw/ppc440.c +27 -0
@@ -8,17 +8,32 @@
  *
  */
 
+
+#include "hw.h"
+#include "hw/isa.h"
 #include "ppc440.h"
+
+#define PPC440EP_PCI_CONFIG 0xeec00000
+#define PPC440EP_PCI_INTACK 0xeed00000
+#define PPC440EP_PCI_SPECIAL 0xeed00000
+#define PPC440EP_PCI_REGS 0xef400000
+#define PPC440EP_PCI_IO 0xe8000000
+#define PPC440EP_PCI_IOLEN 0x10000
+#define PPC440EP_PCI_MEM 0xa0000000
+#define PPC440EP_PCI_MEMLEN 0x20000000
+
 
 void ppc440ep_init(CPUState *env,
 		target_phys_addr_t ram_bases[2],
 		target_phys_addr_t ram_sizes[2],
 		qemu_irq **picp,
+		ppc4xx_pci_t **pcip,
 		int do_init)
 {
 	ppc4xx_mmio_t *mmio;
 	qemu_irq *pic, *irqs;
 	ram_addr_t offset;
+	ppc4xx_pci_t *pci;
 	int i;
 
 	ppc_dcr_init(env, NULL, NULL);
@@ -45,6 +60,18 @@ void ppc440ep_init(CPUState *env,
 	for (i = 0; i < 2; i++)
 		offset += ram_sizes[i];
 
+	/* PCI */
+	pci = ppc4xx_pci_init(env, pic,
+	                      PPC440EP_PCI_CONFIG,
+	                      PPC440EP_PCI_INTACK,
+	                      PPC440EP_PCI_SPECIAL,
+	                      PPC440EP_PCI_REGS);
+	if (!pci)
+		printf("couldn't create PCI controller!\n");
+	*pcip = pci;
+
+	isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
+
 	/* serial ports on page 126 of 440EP user manual */
 	if (serial_hds[0]) {
 		printf("Initializing first serial port\n");
qemu/hw/ppc440.h +1 -0
@@ -24,6 +24,7 @@ void ppc440ep_init(CPUState *env,
 		target_phys_addr_t ram_bases[2],
 		target_phys_addr_t ram_sizes[2],
 		qemu_irq **picp,
+		ppc4xx_pci_t **pcip,
 		int do_init);
 
 #endif
qemu/hw/ppc440_bamboo.c +27 -1
@@ -9,6 +9,11 @@
  */
 
 #include "config.h"
+#include "qemu-common.h"
+#include "net.h"
+#include "hw.h"
+#include "pci.h"
+#include "sysemu.h"
 #include "ppc440.h"
 #include "qemu-kvm.h"
 #include "device_tree.h"
@@ -26,7 +31,9 @@ void bamboo_init(ram_addr_t ram_size, in
 {
 	char *buf=NULL;
 	target_phys_addr_t ram_bases[4], ram_sizes[4];
+	NICInfo *nd;
 	qemu_irq *pic;
+	ppc4xx_pci_t *pci;
 	CPUState *env;
 	target_ulong ep=0;
 	target_ulong la=0;
@@ -77,7 +84,7 @@ void bamboo_init(ram_addr_t ram_size, in
 
 	/* call init */
 	printf("Calling function ppc440_init\n");
-	ppc440ep_init(env, ram_bases, ram_sizes, &pic,1);
+	ppc440ep_init(env, ram_bases, ram_sizes, &pic, &pci, 1);
 	printf("Done calling ppc440_init\n");
 
 	/* Register mem */
@@ -168,6 +175,25 @@ void bamboo_init(ram_addr_t ram_size, in
 		env->nip = ep;
 	}
 
+	if (pci) {
+		int unit_id = 0;
+
+		/* Add virtio block devices. */
+		while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
+			virtio_blk_init(pci->bus, 0x1AF4, 0x1001,
+				drives_table[i].bdrv);
+			unit_id++;
+		}
+
+		/* Register network interfaces. */
+		for (i = 0; i < nb_nics; i++) {
+			nd = &nd_table[i];
+			if (!nd->model)
+				nd->model = "virtio";
+			pci_nic_init(pci->bus, nd, -1);
+		}
+	}
+
 	printf("%s: DONE\n", __func__);
 }
 
qemu/pc-bios/bamboo.dtb binary +0 -0
index e02fa8e0bf23b992b04fe87dfce37d4cc08777a6..81f971c64745aaf79152e1ed6f09e5d36137e461
GIT binary patch

*7oxiAT}OUGa@mX9ZIR(!lwmeee#$ZY2cfvR=Kufz

qemu/pc-bios/bamboo.dts +39 -0
@@ -187,6 +187,45 @@
 
 		};
 
+		PCI0: pci@ec000000 {
+			device_type = "pci";
+			#interrupt-cells = <1>;
+			#size-cells = <2>;
+			#address-cells = <3>;
+			compatible = "ibm,plb440ep-pci", "ibm,plb-pci";
+			primary;
+			reg = <0 eec00000 8     /* Config space access */
+			       0 eed00000 4     /* IACK */
+			       0 eed00000 4     /* Special cycle */
+			       0 ef400000 40>;  /* Internal registers */
+  
+			/* Outbound ranges, one memory and one IO,
+			 * later cannot be changed. Chip supports a second
+			 * IO range but we don't use it for now
+			 */
+			ranges = <02000000 0 a0000000 0 a0000000 0 20000000
+				  01000000 0 00000000 0 e8000000 0 00010000>;
+  
+			/* Inbound 2GB range starting at 0 */
+			dma-ranges = <42000000 0 0 0 0 0 80000000>;
+  
+			/* Bamboo has all 4 IRQ pins tied together per slot */
+			interrupt-map-mask = <f800 0 0 0>;
+			interrupt-map = <
+				/* IDSEL 1 */
+				0800 0 0 0 &UIC0 1c 8
+  
+				/* IDSEL 2 */
+				1000 0 0 0 &UIC0 1b 8
+  
+				/* IDSEL 3 */
+				1800 0 0 0 &UIC0 1a 8
+  
+				/* IDSEL 4 */
+				2000 0 0 0 &UIC0 19 8
+			>;
+		};
+
 	};
 
 	chosen {

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
kvm-ppc-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel