static void pckbc_ebus_attach(device_t parent, device_t self, void *aux) { struct pckbc_js_softc *jsc = device_private(self); struct ebus_attach_args *ea = aux; bus_space_tag_t iot; bus_addr_t ioaddr; int intr; int stdin_node, node; int isconsole; jsc->jsc_pckbc.sc_dv = self; iot = ea->ea_bustag; ioaddr = EBUS_ADDR_FROM_REG(&ea->ea_reg[0]); intr = ea->ea_nintr ? ea->ea_intr[0] : /* line */ 0; /* search children of "8042" node for stdin (keyboard) */ stdin_node = prom_instance_to_package(prom_stdin()); isconsole = 0; for (node = prom_firstchild(ea->ea_node); node != 0; node = prom_nextsibling(node)) if (node == stdin_node) { isconsole = 1; break; } pckbc_js_attach_common(jsc, iot, ioaddr, intr, isconsole); }
/* * Match a struct device against the bootpath, by * comparing it's firmware package handle and calculating * the target/lun suffix and comparing that against * the bootpath remainder. */ static void dev_path_drive_match(struct device *dev, int ctrlnode, int target, int lun) { int child = 0; char buf[OFPATHLEN]; DPRINTF(ACDB_BOOTDEV, ("dev_path_drive_match: %s, controller %x, " "target %d lun %d\n", device_xname(dev), ctrlnode, target, lun)); /* * The ofbootpackage points to a disk on this controller, so * iterate over all child nodes and compare. */ for (child = prom_firstchild(ctrlnode); child != 0; child = prom_nextsibling(child)) if (child == ofbootpackage) break; if (child == ofbootpackage) { /* boot device is on this controller */ DPRINTF(ACDB_BOOTDEV, ("found controller of bootdevice\n")); sprintf(buf, "%s@%d,%d", prom_getpropstring(child, "name"), target, lun); if (ofboottarget && strcmp(buf, ofboottarget) == 0) { booted_device = dev; if (ofbootpartition) booted_partition = *ofbootpartition - 'a'; DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" ", partition %d\n", device_xname(dev), booted_partition)); } } }
/* * Match a device_t against the bootpath, by * comparing it's firmware package handle and calculating * the target/lun suffix and comparing that against * the bootpath remainder. */ static void dev_path_drive_match(device_t dev, int ctrlnode, int target, uint64_t wwn, int lun) { int child = 0; char buf[OFPATHLEN]; DPRINTF(ACDB_BOOTDEV, ("dev_path_drive_match: %s, controller %x, " "target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev), ctrlnode, target, wwn, lun)); /* * The ofbootpackage points to a disk on this controller, so * iterate over all child nodes and compare. */ for (child = prom_firstchild(ctrlnode); child != 0; child = prom_nextsibling(child)) if (child == ofbootpackage) break; if (child == ofbootpackage) { const char * name = prom_getpropstring(child, "name"); /* boot device is on this controller */ DPRINTF(ACDB_BOOTDEV, ("found controller of bootdevice\n")); /* * Note: "child" here is == ofbootpackage (s.a.), which * may be completely wrong for the device we are checking, * what we realy do here is to match "target" and "lun". */ if (wwn) sprintf(buf, "%s@w%016" PRIx64 ",%d", name, wwn, lun); else sprintf(buf, "%s@%d,%d", name, target, lun); if (ofboottarget && strcmp(buf, ofboottarget) == 0) { booted_device = dev; if (ofbootpartition) booted_partition = *ofbootpartition - 'a'; DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" ", partition %d\n", device_xname(dev), booted_partition)); } } }
/* * Match a device_t against the bootpath, by * comparing its firmware package handle and calculating * the target/lun suffix and comparing that against * the bootpath remainder. */ static void dev_path_drive_match(device_t dev, int ctrlnode, int target, uint64_t wwn, int lun) { int child = 0, ide_node = 0; char buf[OFPATHLEN]; DPRINTF(ACDB_BOOTDEV, ("dev_path_drive_match: %s, controller %x, " "target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev), ctrlnode, target, wwn, lun)); /* * The ofbootpackage points to a disk on this controller, so * iterate over all child nodes and compare. */ for (child = prom_firstchild(ctrlnode); child != 0; child = prom_nextsibling(child)) if (child == ofbootpackage) break; if (child != ofbootpackage) { /* * Try Mac firmware style (also used by QEMU/OpenBIOS): * below the controller there is an intermediate node * for each IDE channel, and individual targets always * are "@0" */ for (ide_node = prom_firstchild(ctrlnode); ide_node != 0; ide_node = prom_nextsibling(ide_node)) { const char * name = prom_getpropstring(ide_node, "device_type"); if (strcmp(name, "ide") != 0) continue; for (child = prom_firstchild(ide_node); child != 0; child = prom_nextsibling(child)) if (child == ofbootpackage) break; if (child == ofbootpackage) break; } } if (child == ofbootpackage) { const char * name = prom_getpropstring(child, "name"); /* boot device is on this controller */ DPRINTF(ACDB_BOOTDEV, ("found controller of bootdevice\n")); /* * Note: "child" here is == ofbootpackage (s.a.), which * may be completely wrong for the device we are checking, * what we realy do here is to match "target" and "lun". */ if (wwn) snprintf(buf, sizeof(buf), "%s@w%016" PRIx64 ",%d", name, wwn, lun); else if (ide_node) snprintf(buf, sizeof(buf), "%s@0", device_is_a(dev, "cd") ? "cdrom" : "disk"); else snprintf(buf, sizeof(buf), "%s@%d,%d", name, target, lun); if (ofboottarget && strcmp(buf, ofboottarget) == 0) { booted_device = dev; if (ofbootpartition) booted_partition = *ofbootpartition - 'a'; DPRINTF(ACDB_BOOTDEV, ("found boot device: %s" ", partition %d\n", device_xname(dev), booted_partition)); } } }