BXE: basic probe

Then it bails out.

One difference between Plan 9 and BSD is when the ctlr gets allocated.  Plan 9
does it in the PCI/PNP stage.  In BSD, the sizeof (or something) is declared
earlier and someone else does it.  I think.  I'm less a fan of the latter part;
maybe I don't understand it.  But the pcidev->some_void_star = sc might be
useful.
diff --git a/kern/drivers/net/bxe/bxe.c b/kern/drivers/net/bxe/bxe.c
index b7d43f9..c9f9303 100644
--- a/kern/drivers/net/bxe/bxe.c
+++ b/kern/drivers/net/bxe/bxe.c
@@ -225,10 +225,10 @@
 /*
  * FreeBSD device entry points.
  */
-static int bxe_probe(device_t);
-static int bxe_attach(device_t);
-static int bxe_detach(device_t);
-static int bxe_shutdown(device_t);
+static int bxe_probe(struct pci_device *);
+static int bxe_attach(struct pci_device *);
+static int bxe_detach(struct pci_device *);
+static int bxe_shutdown(struct pci_device *);
 
 /*
  * FreeBSD KLD module/device interface event handler method.
@@ -2497,22 +2497,21 @@
  * This is the driver entry function called from the "kldload" command.
  *
  * Returns:
- *   BUS_PROBE_DEFAULT on success, positive value on failure.
+ *   0 on success, positive value on failure.
  */
-#warning "no probe function"
 
-static int
-bxe_probe(device_t dev)
+int bxe_probe(struct pci_device *dev)
 {
-#if 0
     struct bxe_adapter *sc;
     struct bxe_device_type *t;
     char *descbuf;
     uint16_t did, sdid, svid, vid;
 
     /* Find our device structure */
-    sc = device_get_softc(dev);
-    sc->pcidev= dev;
+		// BSD had the controllers already alloced.  Plan 9 does it after they
+		// are probed
+//    sc = device_get_softc(dev);
+//    sc->pcidev= dev;
     t = bxe_devs;
 
     /* Get the data for the device to be probed. */
@@ -2521,10 +2520,6 @@
     svid = pci_get_subvendor(dev);
     sdid = pci_get_subdevice(dev);
 
-    BLOGD(sc, DBG_LOAD,
-          "%s(); VID = 0x%04X, DID = 0x%04X, SVID = 0x%04X, "
-          "SDID = 0x%04X\n", __FUNCTION__, vid, did, svid, sdid);
-
     /* Look through the list of known devices for a match. */
     while (t->bxe_name != NULL) {
         if ((vid == t->bxe_vid) && (did == t->bxe_did) &&
@@ -2537,18 +2532,19 @@
             /* Print out the device identity. */
             snprintf(descbuf, BXE_DEVDESC_MAX,
                      "%s (%c%d) BXE v:%s\n", t->bxe_name,
-                     (((pcidev_read32(dev, PCIR_REVID) &
+                     (((pcidev_read32(dev, PCI_REVID_REG) &
                         0xf0) >> 4) + 'A'),
-                     (pcidev_read32(dev, PCIR_REVID) & 0xf),
+                     (pcidev_read32(dev, PCI_REVID_REG) & 0xf),
                      BXE_DRIVER_VERSION);
 
-            device_set_desc_copy(dev, descbuf);
+			/* Could add this field to our pcidevs, might be useful */
+            //device_set_desc_copy(dev, descbuf);
+            printk(descbuf);
             kfree(descbuf); /* M_TEMP */
-            return (BUS_PROBE_DEFAULT);
+            return 0;
         }
         t++;
     }
-#endif
     return (ENXIO);
 }
 
@@ -16209,7 +16205,7 @@
  *   0 = Success, >0 = Failure
  */
 static int
-bxe_attach(device_t dev)
+bxe_attach(struct bxe_adapter *sc)
 {
     struct bxe_adapter *sc;
 
@@ -16367,7 +16363,7 @@
  *   0 = Success, >0 = Failure
  */
 static int
-bxe_detach(device_t dev)
+bxe_detach(struct pcidev *dev)
 {
     struct bxe_adapter *sc;
     if_t ifp;
@@ -16442,7 +16438,7 @@
  *   Nothing
  */
 static int
-bxe_shutdown(device_t dev)
+bxe_shutdown(struct pcidev *dev)
 {
     struct bxe_adapter *sc;
 
diff --git a/kern/drivers/net/bxe/bxe.h b/kern/drivers/net/bxe/bxe.h
index b792430..2db5d3a 100644
--- a/kern/drivers/net/bxe/bxe.h
+++ b/kern/drivers/net/bxe/bxe.h
@@ -61,7 +61,6 @@
 typedef uintptr_t bus_dma_segment_t;
 typedef uintptr_t bus_space_tag_t;
 typedef uintptr_t vm_offset_t;
-typedef int device_t;
 // WTF ...
 typedef uint64_t uintmax_t;
 
diff --git a/kern/drivers/net/bxe/bxe_dev.c b/kern/drivers/net/bxe/bxe_dev.c
index 8b6efef..11e87ed 100644
--- a/kern/drivers/net/bxe/bxe_dev.c
+++ b/kern/drivers/net/bxe/bxe_dev.c
@@ -328,13 +328,11 @@
 		if (pcidev->class != 0x02 || pcidev->subclass != 0x00)
 			continue;
 		id = pcidev->dev_id << 16 | pcidev->ven_id;
-		switch (id) {
-			default:
-				continue;
-			/* TODO: cases for the IDs this driver supports */
-			case 1:
-				break;
-		}
+
+		extern int bxe_probe(struct pci_device *dev);
+		if (bxe_probe(pcidev))
+			continue;
+
 		printk("bxe driver found 0x%04x:%04x at %02x:%02x.%x\n",
 			   pcidev->ven_id, pcidev->dev_id,
 			   pcidev->bus, pcidev->dev, pcidev->func);
@@ -399,6 +397,9 @@
 	 * MMIO/port setup */
 	run_once(bxepci());
 
+
+return -1;
+
 	/* Any adapter matches if no edev->port is supplied, otherwise the ports
 	 * must match. */
 	for (;;) {	// check all ctlrs
@@ -444,5 +445,5 @@
 
 linker_func_3(etherbxelink)
 {
-	//addethercard("bxe", bxepnp);
+	addethercard("bxe", bxepnp);
 }