static void dpt_isa_identify (driver_t *driver, device_t parent) { device_t child; dpt_conf_t * conf; int isa_bases[] = { 0x1f0, 0x170, 0x330, 0x230, 0 }; int i; for (i = 0; isa_bases[i]; i++) { conf = dpt_pio_get_conf(isa_bases[i]); if (!conf) { if (bootverbose) device_printf(parent, "dpt: dpt_pio_get_conf(%x) failed.\n", isa_bases[i]); continue; } child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "dpt", -1); if (child == 0) { device_printf(parent, "dpt: BUS_ADD_CHILD() failed!\n"); continue; } device_set_driver(child, driver); bus_set_resource(child, SYS_RES_IOPORT, 0, isa_bases[i], 0x9); } return; }
static void smapi_identify (driver_t *driver, device_t parent) { device_t child; u_int32_t addr; int length; int rid; if (!device_is_alive(parent)) return; addr = bios_sigsearch(SMAPI_START, SMAPI_SIG, SMAPI_LEN, SMAPI_STEP, SMAPI_OFF); if (addr != 0) { rid = 0; length = ADDR2HDR(addr)->length; child = BUS_ADD_CHILD(parent, 5, "smapi", -1); device_set_driver(child, driver); bus_set_resource(child, SYS_RES_MEMORY, rid, addr, length); device_set_desc(child, "SMAPI BIOS"); } return; }
static void xc_identify(driver_t *driver, device_t parent) { device_t child; child = BUS_ADD_CHILD(parent, 0, driver_name, 0); device_set_driver(child, driver); device_set_desc(child, "Xen Console"); }
static void cferes_identify(driver_t* driver, device_t parent) { device_t child; int i; struct resource *res; int result; int rid; struct cferes_softc *sc; uint64_t addr, len, type; child = BUS_ADD_CHILD(parent, 100, "cferes", -1); device_set_driver(child, driver); sc = device_get_softc(child); sc->rnum = 0; for (i = 0; i < ~0U; i++) { result = cfe_enummem(i, CFE_FLG_FULL_ARENA, &addr, &len, &type); if (result < 0) break; if (type != CFE_MI_RESERVED) { if (bootverbose) printf("%s: skipping non reserved range 0x%0jx(%jd)\n", device_getnameunit(child), (uintmax_t)addr, (uintmax_t)len); continue; } bus_set_resource(child, SYS_RES_MEMORY, sc->rnum, addr, len); rid = sc->rnum; res = bus_alloc_resource_any(child, SYS_RES_MEMORY, &rid, 0); if (res == NULL) { bus_delete_resource(child, SYS_RES_MEMORY, sc->rnum); continue; } sc->rid[sc->rnum] = rid; sc->res[sc->rnum] = res; sc->rnum++; if (sc->rnum == MAX_CFE_RESERVATIONS) break; } if (sc->rnum == 0) { device_delete_child(parent, child); return; } device_set_desc(child, "CFE reserved memory"); }
static void atpic_isa_identify(driver_t *drv, device_t parent) { device_t child; child = BUS_ADD_CHILD(parent, ISA_ORDER_SENSITIVE, drv->name, -1); device_set_driver(child, drv); isa_set_logicalid(child, atpic_ids[0].ip_id); isa_set_vendorid(child, atpic_ids[0].ip_id); bus_set_resource(child, SYS_RES_IOPORT, ATPIC_MASTER, IO_ICU1, 2); bus_set_resource(child, SYS_RES_IOPORT, ATPIC_SLAVE, IO_ICU2, 2); /* ISA interrupts are routed through external interrupt 0. */ bus_set_resource(child, SYS_RES_IRQ, 0, PIC_IRQ_EXT(0), 1); }
static void ahc_isa_identify(driver_t *driver, device_t parent) { int slot; int max_slot; max_slot = 14; for (slot = 0; slot <= max_slot; slot++) { struct aic7770_identity *entry; bus_space_tag_t tag; bus_space_handle_t bsh; struct resource *regs; uint32_t iobase; int rid; rid = 0; iobase = (slot * AHC_EISA_SLOT_SIZE) + AHC_EISA_SLOT_OFFSET; regs = bus_alloc_resource(parent, SYS_RES_IOPORT, &rid, iobase, iobase, AHC_EISA_IOSIZE, RF_ACTIVE); if (regs == NULL) { if (bootverbose) printf("ahc_isa_identify %d: ioport 0x%x " "alloc failed\n", slot, iobase); continue; } tag = rman_get_bustag(regs); bsh = rman_get_bushandle(regs); entry = ahc_isa_find_device(tag, bsh); if (entry != NULL) { device_t child; child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ahc", -1); if (child != NULL) { device_set_driver(child, driver); bus_set_resource(child, SYS_RES_IOPORT, 0, iobase, AHC_EISA_IOSIZE); } } bus_release_resource(parent, SYS_RES_IOPORT, rid, regs); } }
static void vpd_identify (driver_t *driver, device_t parent) { device_t child; u_int32_t addr; int length; int rid; if (!device_is_alive(parent)) return; addr = bios_sigsearch(VPD_START, VPD_SIG, VPD_LEN, VPD_STEP, VPD_OFF); if (addr != 0) { rid = 0; length = ADDR2VPD(addr)->Length; child = BUS_ADD_CHILD(parent, 5, "vpd", -1); device_set_driver(child, driver); bus_set_resource(child, SYS_RES_MEMORY, rid, addr, length); device_set_desc(child, "Vital Product Data Area"); } return; }
static int device_amend(sd_device *device, const char *key, const char *value) { int r; assert(device); assert(key); assert(value); if (streq(key, "DEVPATH")) { char *path; path = strjoina("/sys", value); /* the caller must verify or trust this data (e.g., if it comes from the kernel) */ r = device_set_syspath(device, path, false); if (r < 0) return log_debug_errno(r, "sd-device: could not set syspath to '%s': %m", path); } else if (streq(key, "SUBSYSTEM")) { r = device_set_subsystem(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set subsystem to '%s': %m", value); } else if (streq(key, "DEVTYPE")) { r = device_set_devtype(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set devtype to '%s': %m", value); } else if (streq(key, "DEVNAME")) { r = device_set_devname(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set devname to '%s': %m", value); } else if (streq(key, "USEC_INITIALIZED")) { r = device_set_usec_initialized(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set usec-initialized to '%s': %m", value); } else if (streq(key, "DRIVER")) { r = device_set_driver(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set driver to '%s': %m", value); } else if (streq(key, "IFINDEX")) { r = device_set_ifindex(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set ifindex to '%s': %m", value); } else if (streq(key, "DEVMODE")) { r = device_set_devmode(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set devmode to '%s': %m", value); } else if (streq(key, "DEVUID")) { r = device_set_devuid(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set devuid to '%s': %m", value); } else if (streq(key, "DEVGID")) { r = device_set_devgid(device, value); if (r < 0) return log_debug_errno(r, "sd-device: could not set devgid to '%s': %m", value); } else if (streq(key, "DEVLINKS")) { const char *word, *state; size_t l; FOREACH_WORD(word, l, value, state) { char devlink[l + 1]; strncpy(devlink, word, l); devlink[l] = '\0'; r = device_add_devlink(device, devlink); if (r < 0) return log_debug_errno(r, "sd-device: could not add devlink '%s': %m", devlink); } } else if (streq(key, "TAGS")) {
static void orm_identify(driver_t* driver, device_t parent) { bus_space_handle_t bh; bus_space_tag_t bt; device_t child; u_int32_t chunk = IOMEM_START; struct resource *res; int rid; u_int32_t rom_size; struct orm_softc *sc; u_int8_t buf[3]; child = BUS_ADD_CHILD(parent, ISA_ORDER_SENSITIVE, "orm", -1); device_set_driver(child, driver); isa_set_logicalid(child, ORM_ID); isa_set_vendorid(child, ORM_ID); sc = device_get_softc(child); sc->rnum = 0; while (chunk < IOMEM_END) { bus_set_resource(child, SYS_RES_MEMORY, sc->rnum, chunk, IOMEM_STEP); rid = sc->rnum; res = bus_alloc_resource_any(child, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (res == NULL) { bus_delete_resource(child, SYS_RES_MEMORY, sc->rnum); chunk += IOMEM_STEP; continue; } bt = rman_get_bustag(res); bh = rman_get_bushandle(res); bus_space_read_region_1(bt, bh, 0, buf, sizeof(buf)); /* * We need to release and delete the resource since we're * changing its size, or the rom isn't there. There * is a checksum field in the ROM to prevent false * positives. However, some common hardware (IBM thinkpads) * neglects to put a valid checksum in the ROM, so we do * not double check the checksum here. On the ISA bus * areas that have no hardware read back as 0xff, so the * tests to see if we have 0x55 followed by 0xaa are * generally sufficient. */ bus_release_resource(child, SYS_RES_MEMORY, rid, res); bus_delete_resource(child, SYS_RES_MEMORY, sc->rnum); if (buf[0] != 0x55 || buf[1] != 0xAA || (buf[2] & 0x03) != 0) { chunk += IOMEM_STEP; continue; } rom_size = buf[2] << 9; bus_set_resource(child, SYS_RES_MEMORY, sc->rnum, chunk, rom_size); rid = sc->rnum; res = bus_alloc_resource_any(child, SYS_RES_MEMORY, &rid, 0); if (res == NULL) { bus_delete_resource(child, SYS_RES_MEMORY, sc->rnum); chunk += IOMEM_STEP; continue; } sc->rid[sc->rnum] = rid; sc->res[sc->rnum] = res; sc->rnum++; chunk += rom_size; } if (sc->rnum == 0) device_delete_child(parent, child); else if (sc->rnum == 1) device_set_desc(child, "ISA Option ROM"); else device_set_desc(child, "ISA Option ROMs"); }
/* * Non-destructive identify. */ static void ex_isa_identify (driver_t *driver, device_t parent) { device_t child; u_int32_t ioport; u_char enaddr[6]; u_int irq; int tmp; const char * desc; if (bootverbose) printf("ex_isa_identify()\n"); for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) { /* No board found at address */ if (!look_for_card(ioport)) { continue; } if (bootverbose) printf("ex: Found card at 0x%03x!\n", ioport); /* Board in PnP mode */ if (eeprom_read(ioport, EE_W0) & EE_W0_PNP) { /* Reset the card. */ outb(ioport + CMD_REG, Reset_CMD); DELAY(500); if (bootverbose) printf("ex: card at 0x%03x in PnP mode!\n", ioport); continue; } bzero(enaddr, sizeof(enaddr)); /* Reset the card. */ outb(ioport + CMD_REG, Reset_CMD); DELAY(400); ex_get_address(ioport, enaddr); tmp = eeprom_read(ioport, EE_W1) & EE_W1_INT_SEL; /* work out which set of irq <-> internal tables to use */ if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) { irq = plus_ee2irqmap[tmp]; desc = "Intel Pro/10+"; } else { irq = ee2irqmap[tmp]; desc = "Intel Pro/10"; } child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1); device_set_desc_copy(child, desc); device_set_driver(child, driver); bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1); bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE); if (bootverbose) printf("ex: Adding board at 0x%03x, irq %d\n", ioport, irq); } return; }
/* * Non-destructive identify. */ static void ex_isa_identify(driver_t *driver, device_t parent) { device_t child; bus_addr_t ioport; u_char enaddr[6]; u_int irq; int tmp; const char * desc; struct ex_softc sc; int rid; if (bootverbose) printf("ex_isa_identify()\n"); for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) { rid = 0; sc.ioport = bus_alloc_resource(parent, SYS_RES_IOPORT, &rid, ioport, ioport, 0x10, RF_ACTIVE); if (sc.ioport == NULL) continue; /* No board found at address */ if (!ex_look_for_card(&sc)) { bus_release_resource(parent, SYS_RES_IOPORT, rid, sc.ioport); continue; } if (bootverbose) printf("ex: Found card at 0x%03lx!\n", (unsigned long)ioport); /* Board in PnP mode */ if (ex_eeprom_read(&sc, EE_W0) & EE_W0_PNP) { /* Reset the card. */ CSR_WRITE_1(&sc, CMD_REG, Reset_CMD); DELAY(500); if (bootverbose) printf("ex: card at 0x%03lx in PnP mode!\n", (unsigned long)ioport); bus_release_resource(parent, SYS_RES_IOPORT, rid, sc.ioport); continue; } bzero(enaddr, sizeof(enaddr)); /* Reset the card. */ CSR_WRITE_1(&sc, CMD_REG, Reset_CMD); DELAY(400); ex_get_address(&sc, enaddr); tmp = ex_eeprom_read(&sc, EE_W1) & EE_W1_INT_SEL; /* work out which set of irq <-> internal tables to use */ if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) { irq = plus_ee2irqmap[tmp]; desc = "Intel Pro/10+"; } else { irq = ee2irqmap[tmp]; desc = "Intel Pro/10"; } bus_release_resource(parent, SYS_RES_IOPORT, rid, sc.ioport); child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1); device_set_desc_copy(child, desc); device_set_driver(child, driver); bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1); bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE); if (bootverbose) printf("ex: Adding board at 0x%03lx, irq %d\n", (unsigned long)ioport, irq); } return; }