static void slhci_opio_attach(struct device *parent, struct device *self, void *aux) { struct slhci_opio_softc *sc = (struct slhci_opio_softc *)self; struct obio_attach_args *oba = aux; struct opio_softc *psc = (struct opio_softc *)device_parent(self); struct obio_softc *bsc = (struct obio_softc *)device_parent(&psc->sc_dev); bus_space_tag_t iot = oba->oba_iot; bus_space_handle_t ioh; printf("\n"); /* Map I/O space */ if (bus_space_map(iot, oba->oba_addr, PORTSIZE, 0, &ioh)) { printf("%s: can't map I/O space\n", sc->sc_sc.sc_bus.bdev.dv_xname); return; } /* Initialize sc */ sc->sc_sc.sc_iot = iot; sc->sc_sc.sc_ioh = ioh; sc->sc_sc.sc_dmat = &pxa2x0_bus_dma_tag; /* XXX */ sc->sc_sc.sc_enable_power = slhci_opio_enable_power; sc->sc_sc.sc_enable_intr = slhci_opio_enable_intr; sc->sc_sc.sc_arg = sc; /* Establish the interrupt handler */ sc->sc_ih = obio_intr_establish(bsc, oba->oba_intr, IPL_BIO, IST_LEVEL_HIGH, slhci_opio_intr, sc); if( sc->sc_ih == NULL) { printf("%s: can't establish interrupt\n", sc->sc_sc.sc_bus.bdev.dv_xname); return; } #if 0 /* Reset controller */ obio_peripheral_reset(bsc, 2, 1); delay(100); obio_peripheral_reset(bsc, 2, 0); delay(40000); #endif bus_space_write_1(iot, ioh, SL11_IDX_ADDR, SL11_CTRL); bus_space_write_1(iot, ioh, SL11_IDX_DATA, 0x01); /* Attach SL811HS/T */ if (slhci_attach(&sc->sc_sc, self)) return; }
static void slhci_opio_enable_intr(void *arg, int mode) { struct slhci_opio_softc *sc = arg; struct obio_softc *bsc; bsc = (struct obio_softc *)device_parent( device_parent(&sc->sc_sc.sc_bus.bdev)); if (mode == INTR_ON) obio_intr_unmask(bsc, sc->sc_ih); else obio_intr_mask(bsc, sc->sc_ih); }
/* * Queue a transfer request, and if possible, hand it to the controller. */ void rastrategy(struct buf *bp) { struct ra_softc *ra = mscp_device_lookup(bp->b_dev); int b; /* * Make sure this is a reasonable drive to use. */ if (ra == NULL) { bp->b_error = ENXIO; goto done; } /* * If drive is open `raw' or reading label, let it at it. */ if (ra->ra_state == DK_RDLABEL) { /* Make some statistics... /bqt */ b = splbio(); disk_busy(&ra->ra_disk); splx(b); mscp_strategy(bp, device_parent(ra->ra_dev)); return; } /* If disk is not online, try to put it online */ if (ra->ra_state == DK_CLOSED) if (ra_putonline(bp->b_dev, ra) == MSCP_FAILED) { bp->b_error = EIO; goto done; } /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ if (bounds_check_with_label(&ra->ra_disk, bp, ra->ra_wlabel) <= 0) goto done; /* Make some statistics... /bqt */ b = splbio(); disk_busy(&ra->ra_disk); splx(b); mscp_strategy(bp, device_parent(ra->ra_dev)); return; done: biodone(bp); }
static void fxp_cardbus_setup(struct fxp_softc * sc) { struct fxp_cardbus_softc *csc = (struct fxp_cardbus_softc *)sc; struct cardbus_softc *psc = device_private(device_parent(sc->sc_dev)); cardbus_chipset_tag_t cc = psc->sc_cc; cardbus_function_tag_t cf = psc->sc_cf; pcireg_t command; cardbustag_t tag = cardbus_make_tag(cc, cf, csc->ct->ct_bus, csc->ct->ct_func); command = Cardbus_conf_read(csc->ct, tag, CARDBUS_COMMAND_STATUS_REG); if (csc->base0_reg) { Cardbus_conf_write(csc->ct, tag, CARDBUS_BASE0_REG, csc->base0_reg); (cf->cardbus_ctrl) (cc, CARDBUS_MEM_ENABLE); command |= CARDBUS_COMMAND_MEM_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE; } else if (csc->base1_reg) { Cardbus_conf_write(csc->ct, tag, CARDBUS_BASE1_REG, csc->base1_reg); (cf->cardbus_ctrl) (cc, CARDBUS_IO_ENABLE); command |= (CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE); } (cf->cardbus_ctrl) (cc, CARDBUS_BM_ENABLE); /* enable the card */ Cardbus_conf_write(csc->ct, tag, CARDBUS_COMMAND_STATUS_REG, command); }
void vexpress_device_register(device_t self, void *aux) { prop_dictionary_t dict = device_properties(self); if (device_is_a(self, "armperiph") && device_is_a(device_parent(self), "mainbus")) { /* * XXX KLUDGE ALERT XXX * The iot mainbus supplies is completely wrong since it scales * addresses by 2. The simpliest remedy is to replace with our * bus space used for the armcore regisers (which armperiph uses). */ struct mainbus_attach_args *const mb = aux; mb->mb_iot = &vexpress_bs_tag; return; } #if defined(CPU_CORTEXA7) || defined(CPU_CORTEXA15) if (device_is_a(self, "armgtmr")) { /* * The frequency of the generic timer is the reference * frequency. */ prop_dictionary_set_uint32(dict, "frequency", VEXPRESS_REF_FREQ); return; } #endif }
void ibm4xx_device_register(struct device *dev, void *aux) { struct device *parent = device_parent(dev); if (device_is_a(dev, "emac") && device_is_a(parent, "opb")) { /* Set the mac-addr of the on-chip Ethernet. */ struct opb_attach_args *oaa = aux; if (oaa->opb_instance < 10) { prop_data_t pd; unsigned char prop_name[15]; snprintf(prop_name, sizeof(prop_name), "emac%d-mac-addr", oaa->opb_instance); pd = prop_dictionary_get(board_properties, prop_name); if (pd == NULL) { printf("WARNING: unable to get mac-addr " "property from board properties\n"); return; } if (prop_dictionary_set(device_properties(dev), "mac-addr", pd) == false) { printf("WARNING: unable to set mac-addr " "property for %s\n", dev->dv_xname); } } return; } }
int ld_cac_start(struct ld_softc *ld, struct buf *bp) { int flags, cmd; struct cac_softc *cac; struct ld_cac_softc *sc; struct cac_context cc; sc = (struct ld_cac_softc *)ld; cac = device_private(device_parent(ld->sc_dv)); cc.cc_handler = ld_cac_done; cc.cc_context = bp; cc.cc_dv = ld->sc_dv; if ((bp->b_flags & B_READ) == 0) { cmd = CAC_CMD_WRITE; flags = CAC_CCB_DATA_OUT; } else { cmd = CAC_CMD_READ; flags = CAC_CCB_DATA_IN; } return (cac_cmd(cac, cmd, bp->b_data, bp->b_bcount, sc->sc_hwunit, bp->b_rawblkno, flags, &cc)); }
int lcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l) { struct pxa2x0_lcd_softc *sc = v; struct obio_softc *osc = device_private(device_parent(sc->dev)); uint16_t reg; switch (cmd) { case WSDISPLAYIO_SVIDEO: reg = bus_space_read_2(osc->sc_iot, osc->sc_obioreg_ioh, G42XXEB_LCDCTL); if (*(int *)data == WSDISPLAYIO_VIDEO_ON) reg |= LCDCTL_BL_ON; else reg &= ~LCDCTL_BL_ON; bus_space_write_2(osc->sc_iot, osc->sc_obioreg_ioh, G42XXEB_LCDCTL, reg); bus_space_write_1(osc->sc_iot, osc->sc_obioreg_ioh, G42XXEB_LED, reg); printf("LCD control: %x\n", reg); break; /* turn on/off LCD controller */ } return pxa2x0_lcd_ioctl(v, vs, cmd, data, flag, l); }
void fdfinish(struct fd_softc *fd, struct buf *bp) { struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); /* * Move this drive to the end of the queue to give others a `fair' * chance. We only force a switch if N operations are completed while * another drive is waiting to be serviced, since there is a long motor * startup delay whenever we switch. */ (void)BUFQ_GET(fd->sc_q); if (TAILQ_NEXT(fd, sc_drivechain) && ++fd->sc_ops >= 8) { fd->sc_ops = 0; TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); if (BUFQ_PEEK(fd->sc_q) != NULL) TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); else fd->sc_active = 0; } bp->b_resid = fd->sc_bcount; fd->sc_skip = 0; #if NRND > 0 rnd_add_uint32(&fd->rnd_source, bp->b_blkno); #endif biodone(bp); /* turn off motor 5s from now */ callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd); fdc->sc_state = DEVIDLE; }
void device_register(device_t self, void *aux) { device_t parent = device_parent(self); if (parent != NULL && device_is_a(parent, "mainbus")) { // If we are attaching a mainbus device, see if we know how // to bring it out of reset. struct mainbus_attach_args * const ma = aux; for (const struct cfg_info *map = map_info; map < map_info + __arraycount(map_info); map++) { if (device_is_a(self, map->map_name)) { ra_device_fixup(ma->ma_memt, map); delay(1000); break; } } #if defined(RT3883) || defined(MT7620) if (device_is_a(self, "ohci") || device_is_a(self, "ehci")) { const uint32_t cfg1 = bus_space_read_4(ma->ma_memt, ra_sysctl_bsh, RA_SYSCTL_CFG1); if ((cfg1 & SYSCTL_CFG1_USB0_HOST_MODE) == 0) { bus_space_write_4(ma->ma_memt, ra_sysctl_bsh, RA_SYSCTL_CFG1, cfg1 | SYSCTL_CFG1_USB0_HOST_MODE); delay(10); } } #endif } }
void zynq7000_device_register(device_t self, void *aux) { prop_dictionary_t dict = device_properties(self); if (device_is_a(self, "armperiph") && device_is_a(device_parent(self), "mainbus")) { /* * XXX KLUDGE ALERT XXX * The iot mainbus supplies is completely wrong since it scales * addresses by 2. The simpliest remedy is to replace with our * bus space used for the armcore registers (which armperiph uses). */ struct mainbus_attach_args * const mb = aux; mb->mb_iot = zynq7000_armcore_bst; return; } /* * We need to tell the A9 Global/Watchdog Timer * what frequency it runs at. */ if (device_is_a(self, "a9tmr") || device_is_a(self, "a9wdt")) { prop_dictionary_set_uint32(dict, "frequency", 666666666 / PERIPHCLK_N); return; } }
parse_ranges_property(device *current, const char *property_name, const char *property_value) { int nr_ranges; int range_nr; range_property_spec *ranges; const char *chp; /* determine the number of ranges specified */ nr_ranges = count_entries(current, property_name, property_value, 3); /* create a property of that size */ ranges = zalloc(nr_ranges * sizeof(*ranges)); /* fill it in */ chp = property_value; for (range_nr = 0; range_nr < nr_ranges; range_nr++) { chp = parse_address(current, current, chp, &ranges[range_nr].child_address); chp = parse_address(current, device_parent(current), chp, &ranges[range_nr].parent_address); chp = parse_size(current, current, chp, &ranges[range_nr].size); } /* create it */ device_add_range_array_property(current, property_name, ranges, nr_ranges); zfree(ranges); }
parse_reg_property(device *current, const char *property_name, const char *property_value) { int nr_regs; int reg_nr; reg_property_spec *regs; const char *chp; device *bus = device_parent(current); /* determine the number of reg entries by counting tokens */ nr_regs = count_entries(current, property_name, property_value, 1 + (device_nr_size_cells(bus) > 0)); /* create working space */ regs = zalloc(nr_regs * sizeof(*regs)); /* fill it in */ chp = property_value; for (reg_nr = 0; reg_nr < nr_regs; reg_nr++) { chp = parse_address(current, bus, chp, ®s[reg_nr].address); if (device_nr_size_cells(bus) > 0) chp = parse_size(current, bus, chp, ®s[reg_nr].size); else memset(®s[reg_nr].size, 0, sizeof (®s[reg_nr].size)); } /* create it */ device_add_reg_array_property(current, property_name, regs, nr_regs); zfree(regs); }
static void spc_intio_attach(device_t parent, device_t self, void *aux) { struct spc_softc *sc = device_private(self); struct intio_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_bst; bus_space_handle_t ioh; sc->sc_dev = self; intio_map_allocate_region(device_parent(parent), ia, INTIO_MAP_ALLOCATE); if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED, &ioh)) { aprint_error(": can't map i/o space\n"); return; } aprint_normal("\n"); sc->sc_iot = iot; sc->sc_ioh = ioh; sc->sc_initiator = IODEVbase->io_sram[0x70] & 0x7; /* XXX */ if (intio_intr_establish(ia->ia_intr, "spc", spc_intr, sc)) panic("spcattach: interrupt vector busy"); spc_attach(sc); }
static void mtustart(struct mt_softc *sc) { dlog(LOG_DEBUG, "%s ustart", device_xname(sc->sc_dev)); if (hpibreq(device_parent(sc->sc_dev), &sc->sc_hq)) mtstart(sc); }
void icpsp_intr(struct icp_ccb *ic) { struct scsipi_xfer *xs; struct icp_softc *icp; int soff; #ifdef DIAGNOSTIC struct icpsp_softc *sc = device_private(ic->ic_dv); #endif xs = ic->ic_context; icp = device_private(device_parent(ic->ic_dv)); soff = ICP_SCRATCH_SENSE + ic->ic_ident * sizeof(struct scsi_sense_data); SC_DEBUG(xs->xs_periph, SCSIPI_DB2, ("icpsp_intr\n")); bus_dmamap_sync(icp->icp_dmat, icp->icp_scr_dmamap, soff, sizeof(xs->sense.scsi_sense), BUS_DMASYNC_POSTREAD); if (ic->ic_status == ICP_S_OK) { xs->status = SCSI_OK; xs->resid = 0; } else if (ic->ic_status != ICP_S_RAW_SCSI || icp->icp_info >= 0x100) { xs->error = XS_SELTIMEOUT; xs->resid = xs->datalen; } else { xs->status = icp->icp_info; switch (xs->status) { case SCSI_OK: #ifdef DIAGNOSTIC printf("%s: error return (%d), but SCSI_OK?\n", device_xname(sc->sc_dv), icp->icp_info); #endif xs->resid = 0; break; case SCSI_CHECK: memcpy(&xs->sense.scsi_sense, (char *)icp->icp_scr + soff, sizeof(xs->sense.scsi_sense)); xs->error = XS_SENSE; /* FALLTHROUGH */ default: /* * XXX Don't know how to get residual count. */ xs->resid = xs->datalen; break; } } if (xs->datalen != 0) icp_ccb_unmap(icp, ic); icp_ccb_free(icp, ic); scsipi_done(xs); }
/* * Attempt to find the device from which we were booted. */ void device_register(struct device *dev, void *aux) { struct bootdev_data *b = bootdev_data; struct device *parent = device_parent(dev); static int found = 0, initted = 0, scsiboot = 0; static struct device *scsibusdev = NULL; if (b == NULL) return; /* There is no hope. */ if (found) return; if (!initted) { if (strcmp(b->dev_type, "sd") == 0) scsiboot = 1; initted = 1; } if (scsiboot && device_is_a(dev, "scsibus")) { /* XXX device_unit() abuse */ if (device_unit(dev) == b->bus) { scsibusdev = dev; #if 0 printf("\nscsibus = %s\n", dev->dv_xname); #endif } return; } if (!device_is_a(dev, b->dev_type)) return; if (device_is_a(dev, "sd")) { struct scsipibus_attach_args *sa = aux; if (scsiboot && scsibusdev && parent == scsibusdev && sa->sa_periph->periph_target == b->unit) { booted_device = dev; #if 0 printf("\nbooted_device = %s\n", dev->dv_xname); #endif found = 1; } return; } /* XXX device_unit() abuse */ if (device_unit(dev) == b->unit) { booted_device = dev; #if 0 printf("\nbooted_device = %s\n", dev->dv_xname); #endif found = 1; } }
int ld_cac_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt) { struct ld_cac_softc *sc; sc = (struct ld_cac_softc *)ld; return (cac_cmd(device_private(device_parent(ld->sc_dv)), CAC_CMD_WRITE_MEDIA, data, blkcnt * ld->sc_secsize, sc->sc_hwunit, blkno, CAC_CCB_DATA_OUT, NULL)); }
static void sackbc_disable_intrhandler(struct sackbc_softc *sc) { if (sc->polling && sc->ih_rx) { sacc_intr_disestablish( (sacc_chipset_tag_t *) device_private(device_parent(sc->dev)), sc->ih_rx); sc->ih_rx = NULL; } }
static void findbootdev_slave(ddlist_t *ddlist, int ctlr, int slave, int punit) { struct dev_data *cdd, *dd; /* * Find the booted controller. */ for (cdd = LIST_FIRST(ddlist); ctlr != 0 && cdd != NULL; cdd = LIST_NEXT(cdd, dd_clist)) ctlr--; if (cdd == NULL) { /* * Oof, couldn't find it... */ return; } /* * Now find the device with the right slave/punit * that's a child of the controller. */ for (dd = LIST_FIRST(&dev_data_list); dd != NULL; dd = LIST_NEXT(dd, dd_list)) { /* * "sd" -> "scsibus" -> "spc" * "rd" -> "hpibbus" -> "fhpib" */ if (device_parent(device_parent(dd->dd_dev)) != cdd->dd_dev) continue; if (dd->dd_slave == slave && dd->dd_punit == punit) { /* * Found it! */ booted_device = dd->dd_dev; break; } } }
static int slhci_opio_match(struct device *parent, struct cfdata *cf, void *aux) { struct obio_attach_args *oba = aux; bus_space_tag_t iot = &pxa2x0_a4x_bs_tag; /* Use special BS funcs */ bus_space_handle_t ioh; struct obio_softc *bsc = (struct obio_softc *)device_parent(parent); struct pxa2x0_softc *psc; int type; uint32_t reg; struct slhci_softc sc; obio_peripheral_reset(bsc, 2, 0); psc = (struct pxa2x0_softc *)device_parent(&bsc->sc_dev); reg = bus_space_read_4(psc->saip.sc_iot, psc->sc_memctl_ioh, MEMCTL_MSC2); #if 0 bus_space_write_4(psc->saip.sc_iot, psc->sc_memctl_ioh, MEMCTL_MSC2,xxx) #endif oba->oba_iot = iot; if (oba->oba_addr == OBIOCF_ADDR_DEFAULT) oba->oba_addr = PXA2X0_CS5_START; if (oba->oba_intr == OBIOCF_INTR_DEFAULT) oba->oba_intr = G4250EBX_INT_EXT2; if (bus_space_map(iot, oba->oba_addr, PORTSIZE, 0, &ioh)) return 0; /* construct fake softc to call sl811hs */ sc.sc_iot = iot; sc.sc_ioh = ioh; type = sl811hs_find(&sc); bus_space_unmap(iot, ioh, PORTSIZE); return type >= 0; }
/* * lptwrite --copy a line from user space to a local buffer, then call * putc to get the chars moved to the output queue. * * Flagging of interrupted write added. */ int lptwrite(dev_t dev_id, struct uio * uio, int ioflag) { int error=0; size_t n, cnt; device_t dev = device_lookup(&lpt_cd, LPTUNIT(dev_id)); struct lpt_softc * sc = device_private(dev); /* Check state and flags */ if(!(sc->sc_state & HAVEBUS)) { LPT_DPRINTF(("%s(%s): attempt to write using device which does " "not own the bus(%s).\n", __func__, device_xname(dev), device_xname(device_parent(dev)))); return EINVAL; } LPT_VPRINTF(("%s(%s): writing %zu bytes\n", __func__, device_xname(dev), uio->uio_resid)); /* Write the data */ sc->sc_state &= ~INTERRUPTED; while (uio->uio_resid) { n = MIN(BUFSIZE, uio->uio_resid); error = uiomove(sc->sc_inbuf, n, uio); if (error) break; error = ppbus_write(device_parent(dev), sc->sc_inbuf, n, ioflag, &cnt); if (error) { if (error != EWOULDBLOCK) sc->sc_state |= INTERRUPTED; break; } } LPT_VPRINTF(("%s(%s): transfer finished, error %d.\n", __func__, device_xname(dev), error)); return error; }
void fd_motor_on(void *arg) { struct fd_softc *fd = arg; struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); mutex_enter(&fdc->sc_mtx); fd->sc_flags &= ~FD_MOTOR_WAIT; if (TAILQ_FIRST(&fdc->sc_drives) == fd && fdc->sc_state == MOTORWAIT) (void)fdcintr1(fdc); mutex_exit(&fdc->sc_mtx); }
print_reg_property(device *me, const device_property *property) { int reg_nr; reg_property_spec reg; for (reg_nr = 0; device_find_reg_array_property(me, property->name, reg_nr, ®); reg_nr++) { print_address(device_parent(me), ®.address); print_size(me, ®.size); } }
void debug_obio_ne(struct dp8390_softc *sc) { struct obio_softc *osc = device_private(device_parent(sc->sc_dev)); struct pxa2x0_softc *psc = device_private(device_parent(osc->sc_dev)); printf( "ISR=%02x obio: pending=(%x,%x) mask=%x pending=%x mask=%x\n", bus_space_read_1(sc->sc_regt, sc->sc_regh, ED_P0_ISR ), bus_space_read_2(osc->sc_iot, osc->sc_obioreg_ioh, G4250EBX_INTSTS1), bus_space_read_2(osc->sc_iot, osc->sc_obioreg_ioh, G4250EBX_INTSTS2), bus_space_read_2(osc->sc_iot, osc->sc_obioreg_ioh, G4250EBX_INTMASK), osc->sc_intr_pending, osc->sc_intr_mask ); printf( "intc: mask=%08x pending=%08x\n", bus_space_read_4(psc->saip.sc_iot, psc->saip.sc_ioh, SAIPIC_MR ), bus_space_read_4(psc->saip.sc_iot, psc->saip.sc_ioh, SAIPIC_IP ) ); }
/* * If we failed to allocate uba resources, put us on a queue to wait * until there is available resources. Resources to compete about * are map registers and BDPs. This is normally only a problem on * Unibus systems, Qbus systems have more map registers than usable. */ void uba_enqueue(struct uba_unit *uu) { struct uba_softc *uh; int s; uh = device_private(device_parent(uu->uu_dev)); s = spluba(); SIMPLEQ_INSERT_TAIL(&uh->uh_resq, uu, uu_resq); splx(s); }
static void hw_nvram_init_address(device *me) { hw_nvram_device *nvram = (hw_nvram_device*)device_data(me); /* use the generic init code to attach this device to its parent bus */ generic_device_init_address(me); /* find the first non zero reg property and use that as the device size */ if (nvram->sizeof_memory == 0) { reg_property_spec reg; int reg_nr; for (reg_nr = 0; device_find_reg_array_property(me, "reg", reg_nr, ®); reg_nr++) { unsigned attach_size; if (device_size_to_attach_size(device_parent(me), ®.size, &attach_size, me)) { nvram->sizeof_memory = attach_size; break; } } if (nvram->sizeof_memory == 0) device_error(me, "reg property must contain a non-zero phys-addr:size tupple"); if (nvram->sizeof_memory < 8) device_error(me, "NVRAM must be at least 8 bytes in size"); } /* initialize the hw_nvram */ if (nvram->memory == NULL) { nvram->memory = zalloc(nvram->sizeof_memory); } else memset(nvram->memory, 0, nvram->sizeof_memory); if (device_find_property(me, "timezone") == NULL) nvram->timezone = 0; else nvram->timezone = device_find_integer_property(me, "timezone"); nvram->addr_year = nvram->sizeof_memory - 1; nvram->addr_month = nvram->sizeof_memory - 2; nvram->addr_date = nvram->sizeof_memory - 3; nvram->addr_day = nvram->sizeof_memory - 4; nvram->addr_hour = nvram->sizeof_memory - 5; nvram->addr_minutes = nvram->sizeof_memory - 6; nvram->addr_seconds = nvram->sizeof_memory - 7; nvram->addr_control = nvram->sizeof_memory - 8; }
static struct vioscsi_req * vioscsi_req_get(struct vioscsi_softc *sc) { struct virtio_softc *vsc = device_private(device_parent(sc->sc_dev)); struct virtqueue *vq = &sc->sc_vqs[2]; struct vioscsi_req *vr; int r, slot; if ((r = virtio_enqueue_prep(vsc, vq, &slot)) != 0) { DPRINTF(("%s: virtio_enqueue_get error %d\n", __func__, r)); goto err1; } vr = &sc->sc_reqs[slot]; vr->vr_req.id = slot; vr->vr_req.task_attr = VIRTIO_SCSI_S_SIMPLE; r = bus_dmamap_create(vsc->sc_dmat, offsetof(struct vioscsi_req, vr_xs), 1, offsetof(struct vioscsi_req, vr_xs), 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &vr->vr_control); if (r != 0) { DPRINTF(("%s: bus_dmamap_create xs error %d\n", __func__, r)); goto err2; } r = bus_dmamap_create(vsc->sc_dmat, MAXPHYS, sc->sc_seg_max, MAXPHYS, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &vr->vr_data); if (r != 0) { DPRINTF(("%s: bus_dmamap_create data error %d\n", __func__, r)); goto err3; } r = bus_dmamap_load(vsc->sc_dmat, vr->vr_control, vr, offsetof(struct vioscsi_req, vr_xs), NULL, BUS_DMA_NOWAIT); if (r != 0) { DPRINTF(("%s: bus_dmamap_create ctrl error %d\n", __func__, r)); goto err4; } DPRINTF(("%s: %p, %d\n", __func__, vr, slot)); return vr; err4: bus_dmamap_destroy(vsc->sc_dmat, vr->vr_data); err3: bus_dmamap_destroy(vsc->sc_dmat, vr->vr_control); err2: virtio_enqueue_abort(vsc, vq, slot); err1: return NULL; }
print_ranges_property(device *me, const device_property *property) { int range_nr; range_property_spec range; for (range_nr = 0; device_find_range_array_property(me, property->name, range_nr, &range); range_nr++) { print_address(me, &range.child_address); print_address(device_parent(me), &range.parent_address); print_size(me, &range.size); } }
void fd_motor_off(void *arg) { struct fd_softc *fd = arg; struct fdc_softc *fdc; fdc = device_private(device_parent(fd->sc_dev)); mutex_enter(&fdc->sc_mtx); fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); fd_set_motor(fdc, 0); mutex_exit(&fdc->sc_mtx); }