1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #include <stdio.h> 34*7c478bd9Sstevel@tonic-gate #include <stdarg.h> 35*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 36*7c478bd9Sstevel@tonic-gate #include <unistd.h> 37*7c478bd9Sstevel@tonic-gate #include <strings.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 41*7c478bd9Sstevel@tonic-gate #include "prtconf.h" 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate struct prt_opts opts; 44*7c478bd9Sstevel@tonic-gate struct prt_dbg dbg; 45*7c478bd9Sstevel@tonic-gate static char new_path[MAXPATHLEN]; 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate #define INDENT_LENGTH 4 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #ifdef __x86 50*7c478bd9Sstevel@tonic-gate static const char *usage = "%s [ -V | -x | -abcvpPD ] [ <device_path > ]\n"; 51*7c478bd9Sstevel@tonic-gate #else 52*7c478bd9Sstevel@tonic-gate static const char *usage = "%s [ -F | -V | -x | -abcvpPD ][ <device_path > ]\n"; 53*7c478bd9Sstevel@tonic-gate #endif /* __x86 */ 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate static void 56*7c478bd9Sstevel@tonic-gate setprogname(const char *name) 57*7c478bd9Sstevel@tonic-gate { 58*7c478bd9Sstevel@tonic-gate char *p; 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate if (name == NULL) 61*7c478bd9Sstevel@tonic-gate opts.o_progname = "prtconf"; 62*7c478bd9Sstevel@tonic-gate else if (p = strrchr(name, '/')) 63*7c478bd9Sstevel@tonic-gate opts.o_progname = (const char *) p + 1; 64*7c478bd9Sstevel@tonic-gate else 65*7c478bd9Sstevel@tonic-gate opts.o_progname = name; 66*7c478bd9Sstevel@tonic-gate } 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/ 69*7c478bd9Sstevel@tonic-gate void 70*7c478bd9Sstevel@tonic-gate dprintf(const char *fmt, ...) 71*7c478bd9Sstevel@tonic-gate { 72*7c478bd9Sstevel@tonic-gate if (dbg.d_debug) { 73*7c478bd9Sstevel@tonic-gate va_list ap; 74*7c478bd9Sstevel@tonic-gate va_start(ap, fmt); 75*7c478bd9Sstevel@tonic-gate (void) vfprintf(stderr, fmt, ap); 76*7c478bd9Sstevel@tonic-gate va_end(ap); 77*7c478bd9Sstevel@tonic-gate } 78*7c478bd9Sstevel@tonic-gate } 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate void 81*7c478bd9Sstevel@tonic-gate indent_to_level(int ilev) 82*7c478bd9Sstevel@tonic-gate { 83*7c478bd9Sstevel@tonic-gate (void) printf("%*s", INDENT_LENGTH * ilev, ""); 84*7c478bd9Sstevel@tonic-gate } 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate static void 87*7c478bd9Sstevel@tonic-gate cleanup_path(const char *input_path, char *path) 88*7c478bd9Sstevel@tonic-gate { 89*7c478bd9Sstevel@tonic-gate char *ptr, *ptr2; 90*7c478bd9Sstevel@tonic-gate size_t len; 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate if ((input_path == NULL) || (path == NULL)) 93*7c478bd9Sstevel@tonic-gate return; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate (void) strcpy(path, input_path); 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate /*LINTED*/ 98*7c478bd9Sstevel@tonic-gate while (1) { 99*7c478bd9Sstevel@tonic-gate len = strlen(path); 100*7c478bd9Sstevel@tonic-gate if (len == 0) 101*7c478bd9Sstevel@tonic-gate break; 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* change substring "//" into "/" */ 104*7c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "//")) { 105*7c478bd9Sstevel@tonic-gate len = strlen(ptr + 1); 106*7c478bd9Sstevel@tonic-gate (void) memmove(ptr, ptr + 1, len + 1); 107*7c478bd9Sstevel@tonic-gate continue; 108*7c478bd9Sstevel@tonic-gate } 109*7c478bd9Sstevel@tonic-gate /* change substring "/./" into "/" */ 110*7c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "/./")) { 111*7c478bd9Sstevel@tonic-gate len = strlen(ptr + 2); 112*7c478bd9Sstevel@tonic-gate (void) memmove(ptr, ptr + 2, len + 1); 113*7c478bd9Sstevel@tonic-gate continue; 114*7c478bd9Sstevel@tonic-gate } 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate /* change substring "/<foo>/../" into "/" */ 117*7c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "/../")) { 118*7c478bd9Sstevel@tonic-gate len = strlen(ptr + 3); 119*7c478bd9Sstevel@tonic-gate *ptr = '\0'; 120*7c478bd9Sstevel@tonic-gate ptr2 = strrchr(path, (int)'/'); 121*7c478bd9Sstevel@tonic-gate if (ptr2 == NULL) { 122*7c478bd9Sstevel@tonic-gate /* path had a leading "/../" */ 123*7c478bd9Sstevel@tonic-gate ptr2 = path; 124*7c478bd9Sstevel@tonic-gate } 125*7c478bd9Sstevel@tonic-gate (void) memmove(ptr2, ptr + 3, len + 1); 126*7c478bd9Sstevel@tonic-gate continue; 127*7c478bd9Sstevel@tonic-gate } 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* change trailing "/<foo>/.." into "/" */ 130*7c478bd9Sstevel@tonic-gate if ((len >= 3) && 131*7c478bd9Sstevel@tonic-gate (path[len - 3] == '/') && 132*7c478bd9Sstevel@tonic-gate (path[len - 2] == '.') && 133*7c478bd9Sstevel@tonic-gate (path[len - 1] == '.')) { 134*7c478bd9Sstevel@tonic-gate path[len - 3] = '\0'; 135*7c478bd9Sstevel@tonic-gate ptr2 = strrchr(path, (int)'/'); 136*7c478bd9Sstevel@tonic-gate if (ptr2 != NULL) { 137*7c478bd9Sstevel@tonic-gate ptr2[1] = '\0'; 138*7c478bd9Sstevel@tonic-gate } else { 139*7c478bd9Sstevel@tonic-gate /* path was "/.." */ 140*7c478bd9Sstevel@tonic-gate path[0] = '/'; 141*7c478bd9Sstevel@tonic-gate path[1] = '\0'; 142*7c478bd9Sstevel@tonic-gate } 143*7c478bd9Sstevel@tonic-gate continue; 144*7c478bd9Sstevel@tonic-gate } 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate /* change trailing "/." into "/" */ 147*7c478bd9Sstevel@tonic-gate if ((len >= 2) && 148*7c478bd9Sstevel@tonic-gate (path[len - 2] == '/') && 149*7c478bd9Sstevel@tonic-gate (path[len - 1] == '.')) { 150*7c478bd9Sstevel@tonic-gate path[len - 1] = '\0'; 151*7c478bd9Sstevel@tonic-gate continue; 152*7c478bd9Sstevel@tonic-gate } 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* remove trailing "/" unless it's the root */ 155*7c478bd9Sstevel@tonic-gate if ((len > 1) && (path[len - 1] == '/')) { 156*7c478bd9Sstevel@tonic-gate path[len - 1] = '\0'; 157*7c478bd9Sstevel@tonic-gate continue; 158*7c478bd9Sstevel@tonic-gate } 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate break; 161*7c478bd9Sstevel@tonic-gate } 162*7c478bd9Sstevel@tonic-gate } 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate /* 166*7c478bd9Sstevel@tonic-gate * debug version has two more flags: 167*7c478bd9Sstevel@tonic-gate * -L force load driver 168*7c478bd9Sstevel@tonic-gate * -M: print per driver list 169*7c478bd9Sstevel@tonic-gate */ 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 172*7c478bd9Sstevel@tonic-gate static const char *optstring = "abcDvVxpPFf:M:dLuC"; 173*7c478bd9Sstevel@tonic-gate #else 174*7c478bd9Sstevel@tonic-gate static const char *optstring = "abcDvVxpPFf:uC"; 175*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate int 178*7c478bd9Sstevel@tonic-gate main(int argc, char *argv[]) 179*7c478bd9Sstevel@tonic-gate { 180*7c478bd9Sstevel@tonic-gate long pagesize, npages; 181*7c478bd9Sstevel@tonic-gate int c, ret; 182*7c478bd9Sstevel@tonic-gate char hw_provider[SYS_NMLN]; 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate setprogname(argv[0]); 185*7c478bd9Sstevel@tonic-gate opts.o_promdev = "/dev/openprom"; 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, optstring)) != -1) { 188*7c478bd9Sstevel@tonic-gate switch (c) { 189*7c478bd9Sstevel@tonic-gate case 'a': 190*7c478bd9Sstevel@tonic-gate ++opts.o_ancestors; 191*7c478bd9Sstevel@tonic-gate break; 192*7c478bd9Sstevel@tonic-gate case 'b': 193*7c478bd9Sstevel@tonic-gate ++opts.o_productinfo; 194*7c478bd9Sstevel@tonic-gate break; 195*7c478bd9Sstevel@tonic-gate case 'c': 196*7c478bd9Sstevel@tonic-gate ++opts.o_children; 197*7c478bd9Sstevel@tonic-gate break; 198*7c478bd9Sstevel@tonic-gate case 'D': 199*7c478bd9Sstevel@tonic-gate ++opts.o_drv_name; 200*7c478bd9Sstevel@tonic-gate break; 201*7c478bd9Sstevel@tonic-gate case 'v': 202*7c478bd9Sstevel@tonic-gate ++opts.o_verbose; 203*7c478bd9Sstevel@tonic-gate break; 204*7c478bd9Sstevel@tonic-gate case 'p': 205*7c478bd9Sstevel@tonic-gate ++opts.o_prominfo; 206*7c478bd9Sstevel@tonic-gate break; 207*7c478bd9Sstevel@tonic-gate case 'f': 208*7c478bd9Sstevel@tonic-gate opts.o_promdev = optarg; 209*7c478bd9Sstevel@tonic-gate break; 210*7c478bd9Sstevel@tonic-gate case 'V': 211*7c478bd9Sstevel@tonic-gate ++opts.o_promversion; 212*7c478bd9Sstevel@tonic-gate break; 213*7c478bd9Sstevel@tonic-gate case 'x': 214*7c478bd9Sstevel@tonic-gate ++opts.o_prom_ready64; 215*7c478bd9Sstevel@tonic-gate break; 216*7c478bd9Sstevel@tonic-gate case 'F': 217*7c478bd9Sstevel@tonic-gate ++opts.o_fbname; 218*7c478bd9Sstevel@tonic-gate ++opts.o_noheader; 219*7c478bd9Sstevel@tonic-gate break; 220*7c478bd9Sstevel@tonic-gate case 'P': 221*7c478bd9Sstevel@tonic-gate ++opts.o_pseudodevs; 222*7c478bd9Sstevel@tonic-gate break; 223*7c478bd9Sstevel@tonic-gate case 'C': 224*7c478bd9Sstevel@tonic-gate ++opts.o_forcecache; 225*7c478bd9Sstevel@tonic-gate break; 226*7c478bd9Sstevel@tonic-gate #ifdef DEBUG 227*7c478bd9Sstevel@tonic-gate case 'M': 228*7c478bd9Sstevel@tonic-gate dbg.d_drivername = optarg; 229*7c478bd9Sstevel@tonic-gate ++dbg.d_bydriver; 230*7c478bd9Sstevel@tonic-gate break; 231*7c478bd9Sstevel@tonic-gate case 'L': 232*7c478bd9Sstevel@tonic-gate ++dbg.d_forceload; 233*7c478bd9Sstevel@tonic-gate break; 234*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 235*7c478bd9Sstevel@tonic-gate 236*7c478bd9Sstevel@tonic-gate default: 237*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, usage, opts.o_progname); 238*7c478bd9Sstevel@tonic-gate return (1); 239*7c478bd9Sstevel@tonic-gate } 240*7c478bd9Sstevel@tonic-gate } 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate (void) uname(&opts.o_uts); 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate if (opts.o_fbname) 245*7c478bd9Sstevel@tonic-gate return (do_fbname()); 246*7c478bd9Sstevel@tonic-gate 247*7c478bd9Sstevel@tonic-gate if (opts.o_promversion) 248*7c478bd9Sstevel@tonic-gate return (do_promversion()); 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate if (opts.o_prom_ready64) 251*7c478bd9Sstevel@tonic-gate return (do_prom_version64()); 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate if (opts.o_productinfo) 254*7c478bd9Sstevel@tonic-gate return (do_productinfo()); 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate opts.o_devices_path = NULL; 257*7c478bd9Sstevel@tonic-gate opts.o_devt = DDI_DEV_T_NONE; 258*7c478bd9Sstevel@tonic-gate opts.o_target = 0; 259*7c478bd9Sstevel@tonic-gate if (optind < argc) { 260*7c478bd9Sstevel@tonic-gate struct stat sinfo; 261*7c478bd9Sstevel@tonic-gate char *path = argv[optind]; 262*7c478bd9Sstevel@tonic-gate int error; 263*7c478bd9Sstevel@tonic-gate 264*7c478bd9Sstevel@tonic-gate if (strlen(path) >= MAXPATHLEN) { 265*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: " 266*7c478bd9Sstevel@tonic-gate "path specified is too long\n", opts.o_progname); 267*7c478bd9Sstevel@tonic-gate return (1); 268*7c478bd9Sstevel@tonic-gate } 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate if (error = stat(path, &sinfo)) { 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate /* an invalid path was specified */ 273*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: invalid path specified\n", 274*7c478bd9Sstevel@tonic-gate opts.o_progname); 275*7c478bd9Sstevel@tonic-gate return (1); 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate } else if (((sinfo.st_mode & S_IFMT) == S_IFCHR) || 278*7c478bd9Sstevel@tonic-gate ((sinfo.st_mode & S_IFMT) == S_IFBLK)) { 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate opts.o_devt = sinfo.st_rdev; 281*7c478bd9Sstevel@tonic-gate error = 0; 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate } else if ((sinfo.st_mode & S_IFMT) == S_IFDIR) { 284*7c478bd9Sstevel@tonic-gate size_t len, plen; 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate /* clean up the path */ 287*7c478bd9Sstevel@tonic-gate cleanup_path(path, new_path); 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate len = strlen(new_path); 290*7c478bd9Sstevel@tonic-gate plen = strlen("/devices"); 291*7c478bd9Sstevel@tonic-gate if (len < plen) { 292*7c478bd9Sstevel@tonic-gate /* This is not a valid /devices path */ 293*7c478bd9Sstevel@tonic-gate error = 1; 294*7c478bd9Sstevel@tonic-gate } else if ((len == plen) && 295*7c478bd9Sstevel@tonic-gate (strcmp(new_path, "/devices") == 0)) { 296*7c478bd9Sstevel@tonic-gate /* /devices is the root nexus */ 297*7c478bd9Sstevel@tonic-gate opts.o_devices_path = "/"; 298*7c478bd9Sstevel@tonic-gate error = 0; 299*7c478bd9Sstevel@tonic-gate } else if (strncmp(new_path, "/devices/", plen + 1)) { 300*7c478bd9Sstevel@tonic-gate /* This is not a valid /devices path */ 301*7c478bd9Sstevel@tonic-gate error = 1; 302*7c478bd9Sstevel@tonic-gate } else { 303*7c478bd9Sstevel@tonic-gate /* a /devices/ path was specified */ 304*7c478bd9Sstevel@tonic-gate opts.o_devices_path = new_path + plen; 305*7c478bd9Sstevel@tonic-gate error = 0; 306*7c478bd9Sstevel@tonic-gate } 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate } else { 309*7c478bd9Sstevel@tonic-gate /* an invalid device path was specified */ 310*7c478bd9Sstevel@tonic-gate error = 1; 311*7c478bd9Sstevel@tonic-gate } 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate if (error) { 314*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: " 315*7c478bd9Sstevel@tonic-gate "invalid device path specified\n", 316*7c478bd9Sstevel@tonic-gate opts.o_progname); 317*7c478bd9Sstevel@tonic-gate return (1); 318*7c478bd9Sstevel@tonic-gate } 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate opts.o_target = 1; 321*7c478bd9Sstevel@tonic-gate } 322*7c478bd9Sstevel@tonic-gate 323*7c478bd9Sstevel@tonic-gate if ((opts.o_ancestors || opts.o_children) && (!opts.o_target)) { 324*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: options require a device path\n", 325*7c478bd9Sstevel@tonic-gate opts.o_progname); 326*7c478bd9Sstevel@tonic-gate return (1); 327*7c478bd9Sstevel@tonic-gate } 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate if (opts.o_target) { 330*7c478bd9Sstevel@tonic-gate prtconf_devinfo(); 331*7c478bd9Sstevel@tonic-gate return (0); 332*7c478bd9Sstevel@tonic-gate } 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate ret = sysinfo(SI_HW_PROVIDER, hw_provider, sizeof (hw_provider)); 335*7c478bd9Sstevel@tonic-gate /* 336*7c478bd9Sstevel@tonic-gate * If 0 bytes are returned (the system returns '1', for the \0), 337*7c478bd9Sstevel@tonic-gate * we're probably on x86, and there has been no si-hw-provider 338*7c478bd9Sstevel@tonic-gate * set in /etc/bootrc, so just default to Sun. 339*7c478bd9Sstevel@tonic-gate */ 340*7c478bd9Sstevel@tonic-gate if (ret <= 1) { 341*7c478bd9Sstevel@tonic-gate (void) strncpy(hw_provider, "Sun Microsystems", 342*7c478bd9Sstevel@tonic-gate sizeof (hw_provider)); 343*7c478bd9Sstevel@tonic-gate } else { 344*7c478bd9Sstevel@tonic-gate /* 345*7c478bd9Sstevel@tonic-gate * Provide backward compatibility by stripping out the _. 346*7c478bd9Sstevel@tonic-gate */ 347*7c478bd9Sstevel@tonic-gate if (strcmp(hw_provider, "Sun_Microsystems") == 0) 348*7c478bd9Sstevel@tonic-gate hw_provider[3] = ' '; 349*7c478bd9Sstevel@tonic-gate } 350*7c478bd9Sstevel@tonic-gate (void) printf("System Configuration: %s %s\n", hw_provider, 351*7c478bd9Sstevel@tonic-gate opts.o_uts.machine); 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate pagesize = sysconf(_SC_PAGESIZE); 354*7c478bd9Sstevel@tonic-gate npages = sysconf(_SC_PHYS_PAGES); 355*7c478bd9Sstevel@tonic-gate (void) printf("Memory size: "); 356*7c478bd9Sstevel@tonic-gate if (pagesize == -1 || npages == -1) 357*7c478bd9Sstevel@tonic-gate (void) printf("unable to determine\n"); 358*7c478bd9Sstevel@tonic-gate else { 359*7c478bd9Sstevel@tonic-gate const int64_t kbyte = 1024; 360*7c478bd9Sstevel@tonic-gate const int64_t mbyte = 1024 * 1024; 361*7c478bd9Sstevel@tonic-gate int64_t ii = (int64_t)pagesize * npages; 362*7c478bd9Sstevel@tonic-gate 363*7c478bd9Sstevel@tonic-gate if (ii >= mbyte) 364*7c478bd9Sstevel@tonic-gate (void) printf("%ld Megabytes\n", 365*7c478bd9Sstevel@tonic-gate (long)((ii+mbyte-1) / mbyte)); 366*7c478bd9Sstevel@tonic-gate else 367*7c478bd9Sstevel@tonic-gate (void) printf("%ld Kilobytes\n", 368*7c478bd9Sstevel@tonic-gate (long)((ii+kbyte-1) / kbyte)); 369*7c478bd9Sstevel@tonic-gate } 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate if (opts.o_prominfo) { 372*7c478bd9Sstevel@tonic-gate (void) printf("System Peripherals (PROM Nodes):\n\n"); 373*7c478bd9Sstevel@tonic-gate if (do_prominfo() == 0) 374*7c478bd9Sstevel@tonic-gate return (0); 375*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: Defaulting to non-PROM mode...\n", 376*7c478bd9Sstevel@tonic-gate opts.o_progname); 377*7c478bd9Sstevel@tonic-gate } 378*7c478bd9Sstevel@tonic-gate 379*7c478bd9Sstevel@tonic-gate (void) printf("System Peripherals (Software Nodes):\n\n"); 380*7c478bd9Sstevel@tonic-gate 381*7c478bd9Sstevel@tonic-gate (void) prtconf_devinfo(); 382*7c478bd9Sstevel@tonic-gate 383*7c478bd9Sstevel@tonic-gate return (0); 384*7c478bd9Sstevel@tonic-gate } 385