static void bcmrng_get(struct bcm2835rng_softc *sc) { uint32_t status, cnt; uint32_t buf[RNG_DATA_MAX]; /* 1k on the stack */ mutex_spin_enter(&sc->sc_intr_lock); while (sc->sc_bytes_wanted) { status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, RNG_STATUS); cnt = __SHIFTOUT(status, RNG_STATUS_CNT); KASSERT(cnt < RNG_DATA_MAX); if (cnt == 0) continue; /* XXX Busy-waiting seems wrong... */ bus_space_read_multi_4(sc->sc_iot, sc->sc_ioh, RNG_DATA, buf, cnt); /* * This lock dance is necessary because rnd_add_data * may call bcmrng_get_cb which takes the intr lock. */ mutex_spin_exit(&sc->sc_intr_lock); mutex_spin_enter(&sc->sc_rnd_lock); rnd_add_data(&sc->sc_rndsource, buf, (cnt * 4), (cnt * 4 * NBBY)); mutex_spin_exit(&sc->sc_rnd_lock); mutex_spin_enter(&sc->sc_intr_lock); sc->sc_bytes_wanted -= MIN(sc->sc_bytes_wanted, (cnt * 4)); } explicit_memset(buf, 0, sizeof(buf)); mutex_spin_exit(&sc->sc_intr_lock); }
__stdcall static void hal_readport_buf_ulong(uint32_t *port, uint32_t *val, uint32_t cnt) { bus_space_read_multi_4(NDIS_BUS_SPACE_IO, 0x0, (bus_size_t)port, val, cnt); return; }
u_char ppc_io(device_t ppcdev, int iop, u_char *addr, int cnt, u_char byte) { struct ppc_data *ppc = DEVTOSOFTC(ppcdev); switch (iop) { case PPB_OUTSB_EPP: bus_space_write_multi_1(ppc->bst, ppc->bsh, PPC_EPP_DATA, addr, cnt); break; case PPB_OUTSW_EPP: bus_space_write_multi_2(ppc->bst, ppc->bsh, PPC_EPP_DATA, (u_int16_t *)addr, cnt); break; case PPB_OUTSL_EPP: bus_space_write_multi_4(ppc->bst, ppc->bsh, PPC_EPP_DATA, (u_int32_t *)addr, cnt); break; case PPB_INSB_EPP: bus_space_read_multi_1(ppc->bst, ppc->bsh, PPC_EPP_DATA, addr, cnt); break; case PPB_INSW_EPP: bus_space_read_multi_2(ppc->bst, ppc->bsh, PPC_EPP_DATA, (u_int16_t *)addr, cnt); break; case PPB_INSL_EPP: bus_space_read_multi_4(ppc->bst, ppc->bsh, PPC_EPP_DATA, (u_int32_t *)addr, cnt); break; case PPB_RDTR: return (r_dtr(ppc)); case PPB_RSTR: return (r_str(ppc)); case PPB_RCTR: return (r_ctr(ppc)); case PPB_REPP_A: return (r_epp_A(ppc)); case PPB_REPP_D: return (r_epp_D(ppc)); case PPB_RECR: return (r_ecr(ppc)); case PPB_RFIFO: return (r_fifo(ppc)); case PPB_WDTR: w_dtr(ppc, byte); break; case PPB_WSTR: w_str(ppc, byte); break; case PPB_WCTR: w_ctr(ppc, byte); break; case PPB_WEPP_A: w_epp_A(ppc, byte); break; case PPB_WEPP_D: w_epp_D(ppc, byte); break; case PPB_WECR: w_ecr(ppc, byte); break; case PPB_WFIFO: w_fifo(ppc, byte); break; default: panic("%s: unknown I/O operation", __func__); break; } return (0); /* not significative */ }
void itherm_refresh_sensor_data(struct itherm_softc *sc) { u_int16_t data; int64_t energy; u_int32_t i; /* Thermometer sensor */ sc->sensors[ITHERM_SENSOR_THERMOMETER].value = IREAD1(sc, ITHERM_TSTR); itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_THERMOMETER]); /* * The Intel 3400 Thermal Sensor has separate sensors for each * core, reported as a 16 bit value. Bits 13:6 are the integer * part of the temperature in C and bits 5:0 are the fractional * part of the temperature, in 1/64 degree C intervals. * Bit 15 is used to indicate an invalid temperature */ /* Core 1 temperature */ data = IREAD2(sc, ITHERM_CTV1); if (data & ITHERM_CTV_INVALID) sc->sensors[ITHERM_SENSOR_CORETEMP1].flags |= SENSOR_FINVALID; else { sc->sensors[ITHERM_SENSOR_CORETEMP1].flags &= ~SENSOR_FINVALID; sc->sensors[ITHERM_SENSOR_CORETEMP1].value = (data & ITHERM_CTV_INT_MASK) >> 6; sc->sensors[ITHERM_SENSOR_CORETEMP1].value *= 1000000; data &= ITHERM_CTV_FRAC_MASK; data *= 1000000 / 64; sc->sensors[ITHERM_SENSOR_CORETEMP1].value += data; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_CORETEMP1]); } /* Core 2 temperature */ data = IREAD2(sc, ITHERM_CTV2); if (data & ITHERM_CTV_INVALID) sc->sensors[ITHERM_SENSOR_CORETEMP2].flags |= SENSOR_FINVALID; else { sc->sensors[ITHERM_SENSOR_CORETEMP2].flags &= ~SENSOR_FINVALID; sc->sensors[ITHERM_SENSOR_CORETEMP2].value = (data & ITHERM_CTV_INT_MASK) >> 6; sc->sensors[ITHERM_SENSOR_CORETEMP2].value *= 1000000; data &= ITHERM_CTV_FRAC_MASK; data *= 1000000 / 64; sc->sensors[ITHERM_SENSOR_CORETEMP2].value += data; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_CORETEMP2]); } /* * The core energy sensor reports the number of Joules * of energy consumed by the processor since powerup. * This number is scaled by 65535 and is continually * increasing, so we save the old value and compute * the difference for the Watt sensor value. */ i = IREAD4(sc, ITHERM_CEV1); /* Convert to Joules per interval */ energy = (i / 65535); energy = energy - sc->energy_prev; sc->energy_prev = (i / 65535); /* Convert to Joules per second */ energy = energy / ITHERM_REFRESH_INTERVAL; /* Convert to micro Joules per second (micro Watts) */ energy = energy * 1000 * 1000; sc->sensors[ITHERM_SENSOR_COREENERGY].value = energy; /* * XXX - the GPU temp is reported as a 64 bit value with no * documented structure. Disabled for now */ sc->sensors[ITHERM_SENSOR_GPUTEMP].flags |= SENSOR_FINVALID; #if 0 bus_space_read_multi_4(sc->iot, sc->ioh, ITHERM_MGTV, (u_int32_t *)&sc->sensors[ITHERM_SENSOR_GPUTEMP].value, 2); sc->sensors[ITHERM_SENSOR_GPUTEMP].value *= 1000000; sc->sensors[ITHERM_SENSOR_GPUTEMP].value += 273150000; #endif /* Max processor temperature */ sc->sensors[ITHERM_SENSOR_MAXPROCTEMP].value = IREAD1(sc, ITHERM_PTV) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_MAXPROCTEMP]); /* DIMM 1 */ sc->sensors[ITHERM_SENSOR_DIMMTEMP1].value = IREAD1(sc, ITHERM_DTV) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_DIMMTEMP1]); /* DIMM 2 */ sc->sensors[ITHERM_SENSOR_DIMMTEMP2].value = IREAD1(sc, ITHERM_DTV+1) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_DIMMTEMP2]); /* DIMM 3 */ sc->sensors[ITHERM_SENSOR_DIMMTEMP3].value = IREAD1(sc, ITHERM_DTV+2) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_DIMMTEMP3]); /* DIMM 4 */ sc->sensors[ITHERM_SENSOR_DIMMTEMP4].value = IREAD1(sc, ITHERM_DTV+3) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_DIMMTEMP4]); /* GPU Temperature */ sc->sensors[ITHERM_SENSOR_GPUTEMP_ABSOLUTE].value = IREAD1(sc, ITHERM_ITV+1) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_GPUTEMP_ABSOLUTE]); /* PCH Temperature */ sc->sensors[ITHERM_SENSOR_PCHTEMP_ABSOLUTE].value = IREAD1(sc, ITHERM_ITV) * 1000000; itherm_bias_temperature_sensor( &sc->sensors[ITHERM_SENSOR_PCHTEMP_ABSOLUTE]); }
void bs_through_bs_rm_4(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset, u_int32_t *addr, bus_size_t count) { bus_space_read_multi_4(t->bs_base, bsh, offset, addr, count); }