13434Sesaxe /* 23434Sesaxe * CDDL HEADER START 33434Sesaxe * 43434Sesaxe * The contents of this file are subject to the terms of the 53434Sesaxe * Common Development and Distribution License (the "License"). 63434Sesaxe * You may not use this file except in compliance with the License. 73434Sesaxe * 83434Sesaxe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93434Sesaxe * or http://www.opensolaris.org/os/licensing. 103434Sesaxe * See the License for the specific language governing permissions 113434Sesaxe * and limitations under the License. 123434Sesaxe * 133434Sesaxe * When distributing Covered Code, include this CDDL HEADER in each 143434Sesaxe * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153434Sesaxe * If applicable, add the following below this CDDL HEADER, with the 163434Sesaxe * fields enclosed by brackets "[]" replaced with your own identifying 173434Sesaxe * information: Portions Copyright [yyyy] [name of copyright owner] 183434Sesaxe * 193434Sesaxe * CDDL HEADER END 203434Sesaxe */ 213434Sesaxe 223434Sesaxe /* 233434Sesaxe * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 243434Sesaxe * Use is subject to license terms. 253434Sesaxe */ 263434Sesaxe 273434Sesaxe #pragma ident "%Z%%M% %I% %E% SMI" 283434Sesaxe 293434Sesaxe /* 303434Sesaxe * Display processor group information 313434Sesaxe */ 323434Sesaxe 333434Sesaxe #include "pg.h" 343434Sesaxe 353434Sesaxe #include <mdb/mdb_modapi.h> 363434Sesaxe #include <sys/pghw.h> 373434Sesaxe 383434Sesaxe /* 393434Sesaxe * PG hardware types indexed by hardware ID 403434Sesaxe */ 413434Sesaxe char *pg_hw_names[] = { 423434Sesaxe "hw", 433434Sesaxe "ipipe", 443434Sesaxe "cache", 453434Sesaxe "fpu", 46*5079Sjc25722 "mpipe", 47*5079Sjc25722 "chip", 483434Sesaxe "memory", 493434Sesaxe }; 503434Sesaxe 513434Sesaxe #define A_CNT(arr) (sizeof (arr) / sizeof (arr[0])) 523434Sesaxe 533434Sesaxe #define NHW A_CNT(pg_hw_names) 543434Sesaxe 553434Sesaxe /* 563434Sesaxe * Convert HW id to symbolic name 573434Sesaxe */ 583434Sesaxe static char * 593434Sesaxe pg_hw_name(int hw) 603434Sesaxe { 613434Sesaxe return ((hw < 0 || hw > NHW) ? "UNKNOWN" : pg_hw_names[hw]); 623434Sesaxe } 633434Sesaxe 643434Sesaxe /* 653434Sesaxe * Display processor group. 663434Sesaxe */ 673434Sesaxe /* ARGSUSED */ 683434Sesaxe int 693434Sesaxe pg(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 703434Sesaxe { 713434Sesaxe pg_t pg; 723434Sesaxe pghw_t pghw; 733434Sesaxe pg_class_t pg_class; 743434Sesaxe int opt_q = 0; /* display only address. */ 753434Sesaxe 763434Sesaxe /* Should provide an address */ 773434Sesaxe if (! (flags & DCMD_ADDRSPEC)) 783434Sesaxe return (DCMD_USAGE); 793434Sesaxe 803434Sesaxe if (mdb_getopts(argc, argv, 813434Sesaxe 'q', MDB_OPT_SETBITS, TRUE, &opt_q, 82*5079Sjc25722 NULL) != argc) 833434Sesaxe return (DCMD_USAGE); 843434Sesaxe 853434Sesaxe if (flags & DCMD_PIPE_OUT) 863434Sesaxe opt_q = B_TRUE; 873434Sesaxe 883434Sesaxe if (DCMD_HDRSPEC(flags) && !opt_q) { 893434Sesaxe mdb_printf("%6s %?s %6s %7s %9s %5s\n", 903434Sesaxe "PGID", 913434Sesaxe "ADDR", 923434Sesaxe "PHYSID", 933434Sesaxe "CLASS", 943434Sesaxe "HARDWARE", 953434Sesaxe "#CPUs"); 963434Sesaxe } 973434Sesaxe 983434Sesaxe /* 993434Sesaxe * Read pg at specified address 1003434Sesaxe */ 1013434Sesaxe if (mdb_vread(&pg, sizeof (struct pg), addr) == -1) { 1023434Sesaxe mdb_warn("unable to read 'pg' at %p", addr); 1033434Sesaxe return (DCMD_ERR); 1043434Sesaxe } 1053434Sesaxe 1063434Sesaxe /* 1073434Sesaxe * In quiet mode just print pg address 1083434Sesaxe */ 1093434Sesaxe if (opt_q) { 1103434Sesaxe mdb_printf("%0?p\n", addr); 1113434Sesaxe return (DCMD_OK); 1123434Sesaxe } 1133434Sesaxe 1143434Sesaxe if (mdb_vread(&pg_class, sizeof (struct pg_class), 115*5079Sjc25722 (uintptr_t)pg.pg_class) == -1) { 1163434Sesaxe mdb_warn("unable to read 'pg_class' at %p", pg.pg_class); 1173434Sesaxe return (DCMD_ERR); 1183434Sesaxe } 1193434Sesaxe 1203434Sesaxe if (pg.pg_relation == PGR_PHYSICAL) { 1213434Sesaxe if (mdb_vread(&pghw, sizeof (struct pghw), addr) == -1) { 1223434Sesaxe mdb_warn("unable to read 'pghw' at %p", addr); 1233434Sesaxe return (DCMD_ERR); 1243434Sesaxe } 1253434Sesaxe /* 1263434Sesaxe * Display the physical PG info. 1273434Sesaxe */ 1283434Sesaxe mdb_printf("%6d %?p %6d %7s %9s %5d\n", 1293434Sesaxe pg.pg_id, addr, pghw.pghw_instance, 1303434Sesaxe pg_class.pgc_name, pg_hw_name(pghw.pghw_hw), 1313434Sesaxe pg.pg_cpus.grp_size); 1323434Sesaxe } else { 1333434Sesaxe /* 1343434Sesaxe * Display the basic PG info. 1353434Sesaxe */ 1363434Sesaxe mdb_printf("%6d %?p %7s %5d\n", 1373434Sesaxe pg.pg_id, addr, pg_class.pgc_name, 1383434Sesaxe pg.pg_cpus.grp_size); 1393434Sesaxe } 1403434Sesaxe 1413434Sesaxe return (DCMD_OK); 1423434Sesaxe } 143