FreeBSD/sys/x86/cpufreq/est.c
/*
 * Flesh out a simple rate table containing the high and low frequencies
 * based on the current clock speed and the upper 32 bits of the MSR.
 */
Flesh out a simple rate table containing the high and low frequencies
based on the current clock speed and the upper 32 bits of the MSR.
Flesh out a simple rate table containing the high and low frequencies based on the current clock speed and the upper 32 bits of the MSR .
static int
est_msr_info(device_t dev, uint64_t msr, freq_info **freqs)
{
	struct est_softc *sc;
	freq_info *fp;
	int bus, freq, volts;
	uint16_t id;
	if (!msr_info_enabled)
		return (EOPNOTSUPP);
	freq = atomic_load_acq_64(&tsc_freq) / 1000000;
	id = msr >> 32;
	bus = freq / (id >> 8);
	device_printf(dev, "Guessed bus clock (high) of %d MHz\n", bus);
	if (!bus_speed_ok(bus)) {
		id = msr >> 48;
		bus = freq / (id >> 8);
		device_printf(dev, "Guessed bus clock (low) of %d MHz\n", bus);
		if (!bus_speed_ok(bus))
			return (EOPNOTSUPP);
		id = msr >> 32;
		freq = ((id >> 8) & 0xff) * bus;
	}
	sc = device_get_softc(dev);
	fp = malloc(sizeof(freq_info) * 3, M_DEVBUF, M_WAITOK | M_ZERO);
	volts = id & 0xff;
	if (volts != 0) {
		volts <<= 4;
		volts += 700;
	}
	fp[0].freq = freq;
	fp[0].volts = volts;
	fp[0].id16 = id;
	fp[0].power = CPUFREQ_VAL_UNKNOWN;
	device_printf(dev, "Guessed high setting of %d MHz @ %d Mv\n", freq,
	    volts);
	id = msr >> 48;
	freq = ((id >> 8) & 0xff) * bus;
	volts = id & 0xff;
	if (volts != 0) {
		volts <<= 4;
		volts += 700;
	}
	fp[1].freq = freq;
	fp[1].volts = volts;
	fp[1].id16 = id;
	fp[1].power = CPUFREQ_VAL_UNKNOWN;
	device_printf(dev, "Guessed low setting of %d MHz @ %d Mv\n", freq,
	    volts);
	sc->msr_settings = TRUE;
	*freqs = fp;
	return (0);
}
static int est_msr_info ( device_t dev , uint64_t msr , freq_info * * freqs ) { struct est_softc * sc ; freq_info * fp ; int bus , freq , volts ; uint16_t id ; if ( ! msr_info_enabled ) return ( EOPNOTSUPP ) ; freq = atomic_load_acq_64 ( & tsc_freq ) / 1000000 ; id = msr >> 32 ; bus = freq / ( id >> 8 ) ; device_printf ( dev , " \n " , bus ) ; if ( ! bus_speed_ok ( bus ) ) { id = msr >> 48 ; bus = freq / ( id >> 8 ) ; device_printf ( dev , " \n " , bus ) ; if ( ! bus_speed_ok ( bus ) ) return ( EOPNOTSUPP ) ; id = msr >> 32 ; freq = ( ( id >> 8 ) & 0xff ) * bus ; } sc = device_get_softc ( dev ) ; fp = malloc ( sizeof ( freq_info ) * 3 , M_DEVBUF , M_WAITOK | M_ZERO ) ; volts = id & 0xff ; if ( volts != 0 ) { volts <<= 4 ; volts += 700 ; } fp [ 0 ] . freq = freq ; fp [ 0 ] . volts = volts ; fp [ 0 ] . id16 = id ; fp [ 0 ] . power = CPUFREQ_VAL_UNKNOWN ; device_printf ( dev , " \n " , freq , volts ) ; id = msr >> 48 ; freq = ( ( id >> 8 ) & 0xff ) * bus ; volts = id & 0xff ; if ( volts != 0 ) { volts <<= 4 ; volts += 700 ; } fp [ 1 ] . freq = freq ; fp [ 1 ] . volts = volts ; fp [ 1 ] . id16 = id ; fp [ 1 ] . power = CPUFREQ_VAL_UNKNOWN ; device_printf ( dev , " \n " , freq , volts ) ; sc -> msr_settings = TRUE ; * freqs = fp ; return ( 0 ) ; }
Flesh out a simple rate table containing the high and low frequencies
 based on the current clock speed and the upper 32 bits of the MSR.
Flesh out a simple rate table containing the high and low frequencies based on the current clock speed and the upper 32 bits of the MSR .
/* Figure out the bus clock. */ /* We may be running on the low frequency. */ /* Calculate high frequency. */ /* Fill out a new freq table containing just the high and low freqs. */ /* First, the high frequency. */ /* Second, the low frequency. */ /* Table is already terminated due to M_ZERO. */