Index: freebsd/sys/sh/include/machine/legacyvar.h
===================================================================
--- freebsd/sys/sh/include/machine/legacyvar.h	(revision e599318e912d8836c59d8b5202e3e31a6b8dcae9)
+++ freebsd/sys/sh/include/machine/legacyvar.h	(revision af5333e0a02b2295304d4e029b15ee15a4fe2b3a)
@@ -32,5 +32,7 @@
 enum legacy_device_ivars {
 	LEGACY_IVAR_PCIDOMAIN,
-	LEGACY_IVAR_PCIBUS
+	LEGACY_IVAR_PCIBUS,
+	LEGACY_IVAR_PCISLOT,
+	LEGACY_IVAR_PCIFUNC
 };
 
@@ -40,4 +42,6 @@
 LEGACY_ACCESSOR(pcidomain,		PCIDOMAIN,	uint32_t)
 LEGACY_ACCESSOR(pcibus,			PCIBUS,		uint32_t)
+LEGACY_ACCESSOR(pcislot,		PCISLOT,	int)
+LEGACY_ACCESSOR(pcifunc,		PCIFUNC,	int)
 
 #undef LEGACY_ACCESSOR
@@ -54,4 +58,6 @@
 struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child,
     int type, int *rid, u_long start, u_long end, u_long count, u_int flags);
+int	legacy_pcib_map_msi(device_t pcib, device_t dev, int irq,
+    uint64_t *addr, uint32_t *data);
 
 #endif /* !_MACHINE_LEGACYVAR_H_ */
Index: freebsd/sys/sh/pci/pci_bus.c
===================================================================
--- freebsd/sys/sh/pci/pci_bus.c	(revision e599318e912d8836c59d8b5202e3e31a6b8dcae9)
+++ freebsd/sys/sh/pci/pci_bus.c	(revision af5333e0a02b2295304d4e029b15ee15a4fe2b3a)
@@ -38,4 +38,5 @@
 #include <sys/malloc.h>
 #include <sys/module.h>
+#include <sys/rman.h>
 #include <sys/sysctl.h>
 
@@ -113,12 +114,26 @@
 }
 
-static int
+int
 legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
     uint32_t *data)
 {
-	device_t bus;
+	device_t bus, hostb;
+	int error, func, slot;
 
 	bus = device_get_parent(pcib);
-	return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
+	error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data);
+	if (error)
+		return (error);
+
+	slot = legacy_get_pcislot(pcib);
+	func = legacy_get_pcifunc(pcib);
+	if (slot == -1 || func == -1)
+		return (0);
+	hostb = pci_find_bsf(0, slot, func);
+	KASSERT(hostb != NULL, ("%s: missing hostb for 0:%d:%d", __func__,
+	    slot, func));
+	pci_ht_map_msi(hostb, *addr);
+	return (0);
+	
 }
 
@@ -445,4 +460,6 @@
 			device_set_desc(child, s);
 			legacy_set_pcibus(child, busnum);
+			legacy_set_pcislot(child, slot);
+			legacy_set_pcifunc(child, func);
 
 			found = 1;
@@ -578,8 +595,8 @@
 
 	/* Bus interface */
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
 	DEVMETHOD(bus_read_ivar,	legacy_pcib_read_ivar),
 	DEVMETHOD(bus_write_ivar,	legacy_pcib_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	legacy_pcib_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
@@ -599,5 +616,5 @@
 	DEVMETHOD(pcib_map_msi,		legacy_pcib_map_msi),
 
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
@@ -674,5 +691,4 @@
 
 	/* Bus interface */
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
 	DEVMETHOD(bus_read_ivar,	pcib_read_ivar),
 	DEVMETHOD(bus_write_ivar,	pcib_write_ivar),
@@ -695,5 +711,5 @@
 	DEVMETHOD(pcib_map_msi,		pcib_map_msi),
 
-	{0, 0}
+	DEVMETHOD_END
 };
 
Index: freebsd/sys/sh/sh/legacy.c
===================================================================
--- freebsd/sys/sh/sh/legacy.c	(revision e599318e912d8836c59d8b5202e3e31a6b8dcae9)
+++ freebsd/sys/sh/sh/legacy.c	(revision af5333e0a02b2295304d4e029b15ee15a4fe2b3a)
@@ -62,5 +62,7 @@
 static MALLOC_DEFINE(M_LEGACYDEV, "legacydrv", "legacy system device");
 struct legacy_device {
-	int			lg_pcibus;
+	int	lg_pcibus;
+	int	lg_pcislot;
+	int	lg_pcifunc;
 };
 
@@ -90,4 +92,5 @@
 	DEVMETHOD(bus_write_ivar,	legacy_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
@@ -185,4 +188,6 @@
 		return(NULL);
 	atdev->lg_pcibus = -1;
+	atdev->lg_pcislot = -1;
+	atdev->lg_pcifunc = -1;
 
 	child = device_add_child_ordered(bus, order, name, unit);
@@ -208,4 +213,10 @@
 		*result = atdev->lg_pcibus;
 		break;
+	case LEGACY_IVAR_PCISLOT:
+		*result = atdev->lg_pcislot;
+		break;
+	case LEGACY_IVAR_PCIFUNC:
+		*result = atdev->lg_pcifunc;
+		break;
 	default:
 		return ENOENT;
@@ -225,4 +236,10 @@
 	case LEGACY_IVAR_PCIBUS:
 		atdev->lg_pcibus = value;
+		break;
+	case LEGACY_IVAR_PCISLOT:
+		atdev->lg_pcislot = value;
+		break;
+	case LEGACY_IVAR_PCIFUNC:
+		atdev->lg_pcifunc = value;
 		break;
 	default:
@@ -261,5 +278,4 @@
 	DEVMETHOD(bus_add_child,	cpu_add_child),
 	DEVMETHOD(bus_read_ivar,	cpu_read_ivar),
-	DEVMETHOD(bus_print_child,	bus_generic_print_child),
 	DEVMETHOD(bus_get_resource_list, cpu_get_rlist),
 	DEVMETHOD(bus_get_resource,	bus_generic_rl_get_resource),
@@ -267,5 +283,4 @@
 	DEVMETHOD(bus_alloc_resource,	bus_generic_rl_alloc_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_rl_release_resource),
-	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
@@ -273,5 +288,5 @@
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
 
-	{ 0, 0 }
+	DEVMETHOD_END
 };
 
@@ -295,10 +310,9 @@
 	 * bridges (which are added at order 100).
 	 */
-	for (i = 0; i <= mp_maxid; i++)
-		if (!CPU_ABSENT(i)) {
-			child = BUS_ADD_CHILD(parent, 150, "cpu", i);
-			if (child == NULL)
-				panic("legacy_attach cpu");
-		}
+	CPU_FOREACH(i) {
+		child = BUS_ADD_CHILD(parent, 150, "cpu", i);
+		if (child == NULL)
+			panic("legacy_attach cpu");
+	}
 }
 
