cpu.c (191380) | cpu.c (193156) |
---|---|
1/*- 2 * Copyright (c) 2001 Matt Thomas. 3 * Copyright (c) 2001 Tsubai Masanari. 4 * Copyright (c) 1998, 1999, 2001 Internet Research Institute, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 41 unchanged lines hidden (view full) --- 50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * 57 * from $NetBSD: cpu_subr.c,v 1.1 2003/02/03 17:10:09 matt Exp $ | 1/*- 2 * Copyright (c) 2001 Matt Thomas. 3 * Copyright (c) 2001 Tsubai Masanari. 4 * Copyright (c) 1998, 1999, 2001 Internet Research Institute, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 41 unchanged lines hidden (view full) --- 50 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * 57 * from $NetBSD: cpu_subr.c,v 1.1 2003/02/03 17:10:09 matt Exp $ |
58 * $FreeBSD: head/sys/powerpc/powerpc/cpu.c 191380 2009-04-22 13:31:52Z raj $ | 58 * $FreeBSD: head/sys/powerpc/powerpc/cpu.c 193156 2009-05-31 09:01:23Z nwhitehorn $ |
59 */ 60 61#include <sys/param.h> 62#include <sys/systm.h> 63#include <sys/bus.h> 64#include <sys/conf.h> | 59 */ 60 61#include <sys/param.h> 62#include <sys/systm.h> 63#include <sys/bus.h> 64#include <sys/conf.h> |
65#include <sys/cpu.h> |
|
65#include <sys/kernel.h> 66#include <sys/sysctl.h> 67 68#include <machine/bus.h> 69#include <machine/hid.h> 70#include <machine/md_var.h> 71#include <machine/spr.h> 72 --- 210 unchanged lines hidden (view full) --- 283 284 printf("cpu%d: HID0 %b\n", cpuid, hid0, bitmask); 285} 286 287void 288cpu_print_speed(void) 289{ 290 uint64_t cps; | 66#include <sys/kernel.h> 67#include <sys/sysctl.h> 68 69#include <machine/bus.h> 70#include <machine/hid.h> 71#include <machine/md_var.h> 72#include <machine/spr.h> 73 --- 210 unchanged lines hidden (view full) --- 284 285 printf("cpu%d: HID0 %b\n", cpuid, hid0, bitmask); 286} 287 288void 289cpu_print_speed(void) 290{ 291 uint64_t cps; |
292 293 if (cpu_est_clockrate(0, &cps) == 0) 294 printf(", %lld.%02lld MHz", cps / 1000000, (cps / 10000) % 100); 295} |
|
291 | 296 |
292 mtspr(SPR_MMCR0, SPR_MMCR0_FC); 293 mtspr(SPR_PMC1, 0); 294 mtspr(SPR_MMCR0, SPR_MMCR0_PMC1SEL(PMCN_CYCLES)); 295 DELAY(100000); 296 cps = (mfspr(SPR_PMC1) * 10) + 4999; 297 printf(", %lld.%02lld MHz", cps / 1000000, (cps / 10000) % 100); | 297/* Get current clock frequency for the given cpu id. */ 298int 299cpu_est_clockrate(int cpu_id, uint64_t *cps) 300{ 301 uint16_t vers; 302 303 vers = mfpvr() >> 16; 304 305 switch (vers) { 306 case MPC7450: 307 case MPC7455: 308 case MPC7457: 309 case MPC750: 310 case IBM750FX: 311 case MPC7400: 312 case MPC7410: 313 case MPC7447A: 314 case MPC7448: 315 mtspr(SPR_MMCR0, SPR_MMCR0_FC); 316 mtspr(SPR_PMC1, 0); 317 mtspr(SPR_MMCR0, SPR_MMCR0_PMC1SEL(PMCN_CYCLES)); 318 DELAY(100000); 319 *cps = (mfspr(SPR_PMC1) * 10) + 4999; 320 return (0); 321 } 322 323 return (ENXIO); |
298} 299 300void 301cpu_print_cacheinfo(u_int cpuid, uint16_t vers) 302{ 303 uint32_t hid; 304 305 --- 44 unchanged lines hidden --- | 324} 325 326void 327cpu_print_cacheinfo(u_int cpuid, uint16_t vers) 328{ 329 uint32_t hid; 330 331 --- 44 unchanged lines hidden --- |