PERFORCE change 94458 for review

Kip Macy kmacy at FreeBSD.org
Sun Apr 2 09:27:00 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=94458

Change 94458 by kmacy at kmacy_storage:sun4v_work on 2006/04/02 09:26:45

	fix PCI probing issues

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hypervisor_api.h#9 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hcall.S#7 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#11 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hypervisor_api.h#9 (text+ko) ====

@@ -39,15 +39,9 @@
 #ifndef _ASM
 
 typedef uint64_t devhandle_t;
-
+typedef uint64_t pci_device_t;
 typedef uint32_t pci_config_offset_t;
-
-typedef enum pci_config_size {
-	PCI_CFG_SIZE_BYTE = 0,
-	PCI_CFG_SIZE_WORD,
-	PCI_CFG_SIZE_DWORD
-} pci_config_size_t;
-
+typedef uint8_t pci_config_size_t;
 typedef union pci_cfg_data {
 	uint8_t b;
 	uint16_t w;
@@ -108,11 +102,11 @@
 extern uint64_t hvio_intr_settarget(uint64_t sysino, uint32_t cpuid);
 extern uint64_t hvio_peek(devhandle_t dev_hdl, uint64_t r_addr, uint64_t size,
 			  uint64_t *err_flag, uint64_t *data);
-extern uint64_t hvio_config_get(devhandle_t dev_hdl, uint64_t pci_device, 
-				uint64_t r_addr, pci_config_size_t size, pci_cfg_data_t *data);
-extern uint64_t hvio_config_put(devhandle_t dev_hdl, uint64_t pci_device, 
+extern uint64_t hvio_config_get(devhandle_t dev_hdl, pci_device_t pci_device, 
+				pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t *data);
+extern uint64_t hvio_config_put(devhandle_t dev_hdl, pci_device_t pci_device, 
 				pci_config_offset_t off, pci_config_size_t size, 
-				pci_cfg_data_t data, uint32_t *err_flags);
+				pci_cfg_data_t data);
 
 extern void hv_magic_trap_on(void);
 extern void hv_magic_trap_off(void);

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hcall.S#7 (text+ko) ====

@@ -574,7 +574,6 @@
 	ENTRY(hvio_config_put)
 	mov	HVIO_CONFIG_PUT, %o5
 	ta	FAST_TRAP
-	 stuw	%o1, [%o5]
 	retl
 	nop
 	SET_SIZE(hvio_config_put)

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#11 (text+ko) ====

@@ -51,6 +51,8 @@
 
 #include "pcib_if.h"
 
+#include <sys/rman.h>
+#define	SUN4V_REG_SPEC2CFG_HDL(x)	((x >> 32) & ~(0xfull << 28))
 /*
  * Methods
  */
@@ -122,19 +124,32 @@
 hvpci_attach(device_t dev)
 {
 	struct hvpci_softc *sc;
+
 	phandle_t node;
+#if 0
 	uint32_t cell;
+#endif
+	uint64_t reg, nreg;
 
 	node = ofw_bus_get_node(dev);
 	if (node == -1)
 		panic("%s: ofw_bus_get_node failed.", __func__);
 
 	sc = device_get_softc(dev);
+#if 0
 	if (OF_getprop(node, "reg", &cell, sizeof cell) == -1)
 		panic("%s: OF_getprop failed.", __func__);
 	sc->hs_devhandle = cell & 0xfffffff;
+#else 
+	bus_get_resource(dev, SYS_RES_MEMORY, 0, &reg, &nreg);
+	sc->hs_devhandle = SUN4V_REG_SPEC2CFG_HDL(reg);
 
+#endif
+
+	printf("%s, devhandle=0x%lx\n", __func__, sc->hs_devhandle);
+
 	device_add_child(dev, "pci", -1);
+
 	return (bus_generic_attach(dev));
 }
 
@@ -158,17 +173,17 @@
 {
 	struct hvpci_softc *sc;
 	uint32_t data;
-	uint32_t ret;
 	int r;
+	uint64_t ret;
 
 	sc = device_get_softc(dev);
 
 	r = hvio_config_get(sc->hs_devhandle, HVPCI_BDF(bus, slot, func),
-	    reg, width, &data);
-
-	printf("%d = read_config(%#x, %#x, %d, %d) = %#x\n", r,
-	    sc->hs_devhandle, HVPCI_BDF(bus, slot, func), reg, width, data);
-
+			    reg, width, (pci_cfg_data_t *)&data);
+#if 0
+	printf("%d = read_config(%#lx, %#x, %d, %d) = %#x\n", r,
+	       sc->hs_devhandle, HVPCI_BDF(bus, slot, func), reg, width, data);
+#endif
 	if (r == H_EOK) {
 		switch (width) {
 		case 1:
@@ -180,10 +195,11 @@
 		case 4:
 			ret = data;
 			break;
+		default:
+			ret = -1;
 		}
-		return ret;
+		return data;
 	}
-
 	return -1;
 }
 
@@ -198,10 +214,8 @@
 {
 	struct hvpci_softc *sc;
 	uint32_t data;
-	uint32_t err_flags;
 
 	sc = device_get_softc(dev);
-
 	switch (width) {
 	case 1:
 		*(uint8_t *)&data = val;
@@ -215,9 +229,8 @@
 	default:
 		panic("unsupported width: %d", width);
 	}
-
 	hvio_config_put(sc->hs_devhandle, HVPCI_BDF(bus, slot, func), reg,
-			width, data, &err_flags);
+			width, (pci_cfg_data_t)data);
 }
 
 #ifdef notyet


More information about the p4-projects mailing list