From owner-p4-projects@FreeBSD.ORG Sun Apr 2 09:27:00 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 82A6A16A422; Sun, 2 Apr 2006 09:27:00 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 407C516A420 for ; Sun, 2 Apr 2006 09:27:00 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C076643D4C for ; Sun, 2 Apr 2006 09:26:59 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k329Qxxr034318 for ; Sun, 2 Apr 2006 09:26:59 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k329QxiA034315 for perforce@freebsd.org; Sun, 2 Apr 2006 09:26:59 GMT (envelope-from kmacy@freebsd.org) Date: Sun, 2 Apr 2006 09:26:59 GMT Message-Id: <200604020926.k329QxiA034315@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 94458 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2006 09:27:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=94458 Change 94458 by kmacy@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 +#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, ®, &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