コード例 #1
0
ファイル: cpu.c プロジェクト: andreiw/polaris
/*
 * Display the CPUs present on this board.
 */
void
display_cpus(Board_node *board)
{
	Prom_node *cpu;

	/*
	 * display the CPUs' operating frequency, cache size, impl. field
	 * and mask revision.
	 */
	for (cpu = dev_find_type(board->nodes, "cpu"); cpu != NULL;
	    cpu = dev_next_type(cpu, "cpu")) {
		int freq;	 /* CPU clock frequency */
		int ecache_size; /* External cache size */
		int *mid;
		int *impl;
		int *mask, decoded_mask;

		mid = (int *)get_prop_val(find_prop(cpu, "upa-portid"));
		if (mid == NULL) {
			mid = (int *)get_prop_val(find_prop(cpu, "portid"));
		}

		freq = (get_cpu_freq(cpu) + 500000) / 1000000;
		ecache_size = get_ecache_size(cpu);
		impl = (int *)get_prop_val(find_prop(cpu, "implementation#"));
		mask = (int *)get_prop_val(find_prop(cpu, "mask#"));

		/* Do not display a failed CPU node */
		if ((freq != 0) && (node_failed(cpu) == 0)) {
			/* Board number */
			display_boardnum(board->board_num);

			/* CPU MID */
			log_printf(" %2d  ", *mid, 0);

			/* Module number */
			display_mid(*mid);

			/* Running frequency */
			log_printf(" %3d   ", freq, 0);

			/* Ecache size */
			if (ecache_size == 0)
				log_printf(" %3s    ", "N/A", 0);
			else
				log_printf(" %4.1f   ",
					(float)ecache_size / (float)(1<<20),
					0);

			/* Implementation */
			if (impl == NULL) {
				log_printf("%6s  ", "N/A", 0);
			} else {
				switch (*impl) {
				case SPITFIRE_IMPL:
					log_printf("%-6s  ", "US-I", 0);
					break;
				case BLACKBIRD_IMPL:
					log_printf("%-6s  ", "US-II", 0);
					break;
				case CHEETAH_IMPL:
					log_printf("%-6s  ", "US-III", 0);
					break;
				case CHEETAH_PLUS_IMPL:
					log_printf("%-7s  ", "US-III+", 0);
					break;
				case JAGUAR_IMPL:
					log_printf("%-6s  ", "US-IV", 0);
					break;
				default:
					log_printf("%-6x  ", *impl, 0);
					break;
				}
			}

			/* CPU Mask */
			if (mask == NULL) {
				log_printf(" %3s", "N/A", 0);
			} else {
				if ((impl) && IS_CHEETAH(*impl))
					decoded_mask =
						REMAP_CHEETAH_MASK(*mask);
				else
					decoded_mask = *mask;

				log_printf(" %d.%d", (decoded_mask >> 4) & 0xf,
					decoded_mask & 0xf, 0);
			}

			log_printf("\n", 0);
		}
	}
コード例 #2
0
ファイル: cherrystone.c プロジェクト: apprisi/illumos-gate
void
display_cpus(Board_node *board)
{
	Prom_node 	*cpu;
	uint_t freq;
	int ecache_size;
	int *l3_shares;
	int *mid;
	int *impl;
	int *mask;
	int *coreid;
	char fru_prev = 'X'; /* Valid frus are 'A','B' */
	int mid_prev;
	int ecache_size_prev = 0;
	char fru_name;

	/*
	 * display the CPUs' operating frequency, cache size, impl. field
	 * and mask revision.
	 */

	for (cpu = dev_find_type(board->nodes, "cpu"); cpu != NULL;
	    cpu = dev_next_type(cpu, "cpu")) {

		mid = (int *)get_prop_val(find_prop(cpu, "portid"));
		if (mid == NULL)
			mid = (int *)get_prop_val(find_prop(cpu, "cpuid"));
		freq = HZ_TO_MHZ(get_cpu_freq(cpu));
		ecache_size = get_ecache_size(cpu);
		impl = (int *)get_prop_val(find_prop(cpu, "implementation#"));
		mask = (int *)get_prop_val(find_prop(cpu, "mask#"));
		l3_shares =
		    (int *)get_prop_val(find_prop(cpu, "l3-cache-sharing"));

		/* Do not display a failed CPU node */
		if ((impl == NULL) || (freq == 0) || (node_failed(cpu)))
			continue;

		fru_name = CHERRYSTONE_GETSLOT_LABEL(*mid);
		if (CPU_IMPL_IS_CMP(*impl)) {
			coreid = (int *)get_prop_val(find_prop(cpu, "reg"));
			if (coreid == NULL) {
				continue;
			}
			if ((fru_prev == 'X') ||
			    ((fru_prev != 'X') &&
			    (fru_name != fru_prev))) {
				fru_prev = fru_name;
				mid_prev = *mid;
				ecache_size_prev = ecache_size;
				continue;
			} else {
				/*
				 * Some CMP chips have a split E$,
				 * so the size for both cores is added
				 * together to get the total size for
				 * the chip.
				 *
				 * Still, other CMP chips have E$ (L3)
				 * which is logically shared, so the
				 * total size is equal to the core size.
				 */
				if ((l3_shares == NULL) ||
				    ((l3_shares != NULL) &&
				    MULTIPLE_BITS_SET(*l3_shares))) {
					ecache_size += ecache_size_prev;
				}
				ecache_size_prev = 0;
				fru_prev = 'X';
			}
		}

		log_printf(" %c", fru_name);

		/* CPU Module ID */
		if (CPU_IMPL_IS_CMP(*impl)) {
			log_printf("%3d,%3d ", mid_prev, *mid, 0);
		} else
			log_printf("   %2d   ", *mid);

		/* Running frequency */
		log_printf("%4u", freq);

		if (ecache_size == 0)
			log_printf(" N/A  ");
		else
			log_printf(" %4.1f ",
			    (float)ecache_size / (float)(1<<20));
			/* Implementation */
		if (impl == NULL) {
			log_printf(dgettext(TEXT_DOMAIN, "  N/A   "));
		} else {
			if (IS_CHEETAH(*impl))
				log_printf(dgettext(TEXT_DOMAIN,
				    "US-III  "));
			else if (IS_CHEETAH_PLUS(*impl))
				log_printf(dgettext(TEXT_DOMAIN,
				    "US-III+ "));
			else if (IS_JAGUAR(*impl))
				log_printf(dgettext(TEXT_DOMAIN,
				    "US-IV   "));
			else if (IS_PANTHER(*impl))
				log_printf(dgettext(TEXT_DOMAIN,
				    "US-IV+  "));
			else
				log_printf("%-6x  ", *impl);
		}

		/* CPU Mask */
		if (mask == NULL) {
			log_printf(dgettext(TEXT_DOMAIN, " N/A\n"));
		} else {
			log_printf(dgettext(TEXT_DOMAIN, " %d.%d\n"),
			    (*mask >> 4) & 0xf, *mask & 0xf);
		}
	}
}