17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5c3a9724dSVikram Hegde * Common Development and Distribution License (the "License"). 6c3a9724dSVikram Hegde * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 2123a1cceaSRoger A. Faulkner 227c478bd9Sstevel@tonic-gate /* 2387ea2c5cSAnil udupa * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <stdio.h> 307c478bd9Sstevel@tonic-gate #include <stdarg.h> 317c478bd9Sstevel@tonic-gate #include <stdlib.h> 327c478bd9Sstevel@tonic-gate #include <unistd.h> 337c478bd9Sstevel@tonic-gate #include <strings.h> 347c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h> 357c478bd9Sstevel@tonic-gate #include <sys/types.h> 367c478bd9Sstevel@tonic-gate #include <sys/stat.h> 377c478bd9Sstevel@tonic-gate #include "prtconf.h" 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate struct prt_opts opts; 407c478bd9Sstevel@tonic-gate struct prt_dbg dbg; 417c478bd9Sstevel@tonic-gate static char new_path[MAXPATHLEN]; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define INDENT_LENGTH 4 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #ifdef __x86 46524b24f9SJudy Chen static const char *usage = "%s [ -V | -x | -abcdvpPD ] [ <device_path > ]\n"; 477c478bd9Sstevel@tonic-gate #else 48524b24f9SJudy Chen static const char *usage = 49524b24f9SJudy Chen "%s [ -F | -V | -x | -abcdvpPD ][ <device_path > ]\n"; 507c478bd9Sstevel@tonic-gate #endif /* __x86 */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate static void 5323a1cceaSRoger A. Faulkner setpname(const char *name) 547c478bd9Sstevel@tonic-gate { 557c478bd9Sstevel@tonic-gate char *p; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate if (name == NULL) 587c478bd9Sstevel@tonic-gate opts.o_progname = "prtconf"; 597c478bd9Sstevel@tonic-gate else if (p = strrchr(name, '/')) 607c478bd9Sstevel@tonic-gate opts.o_progname = (const char *) p + 1; 617c478bd9Sstevel@tonic-gate else 627c478bd9Sstevel@tonic-gate opts.o_progname = name; 637c478bd9Sstevel@tonic-gate } 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/ 667c478bd9Sstevel@tonic-gate void 677c478bd9Sstevel@tonic-gate dprintf(const char *fmt, ...) 687c478bd9Sstevel@tonic-gate { 697c478bd9Sstevel@tonic-gate if (dbg.d_debug) { 707c478bd9Sstevel@tonic-gate va_list ap; 717c478bd9Sstevel@tonic-gate va_start(ap, fmt); 727c478bd9Sstevel@tonic-gate (void) vfprintf(stderr, fmt, ap); 737c478bd9Sstevel@tonic-gate va_end(ap); 747c478bd9Sstevel@tonic-gate } 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate void 787c478bd9Sstevel@tonic-gate indent_to_level(int ilev) 797c478bd9Sstevel@tonic-gate { 807c478bd9Sstevel@tonic-gate (void) printf("%*s", INDENT_LENGTH * ilev, ""); 817c478bd9Sstevel@tonic-gate } 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate static void 847c478bd9Sstevel@tonic-gate cleanup_path(const char *input_path, char *path) 857c478bd9Sstevel@tonic-gate { 867c478bd9Sstevel@tonic-gate char *ptr, *ptr2; 877c478bd9Sstevel@tonic-gate size_t len; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate if ((input_path == NULL) || (path == NULL)) 907c478bd9Sstevel@tonic-gate return; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate (void) strcpy(path, input_path); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /*LINTED*/ 957c478bd9Sstevel@tonic-gate while (1) { 967c478bd9Sstevel@tonic-gate len = strlen(path); 977c478bd9Sstevel@tonic-gate if (len == 0) 987c478bd9Sstevel@tonic-gate break; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* change substring "//" into "/" */ 1017c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "//")) { 1027c478bd9Sstevel@tonic-gate len = strlen(ptr + 1); 1037c478bd9Sstevel@tonic-gate (void) memmove(ptr, ptr + 1, len + 1); 1047c478bd9Sstevel@tonic-gate continue; 1057c478bd9Sstevel@tonic-gate } 1067c478bd9Sstevel@tonic-gate /* change substring "/./" into "/" */ 1077c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "/./")) { 1087c478bd9Sstevel@tonic-gate len = strlen(ptr + 2); 1097c478bd9Sstevel@tonic-gate (void) memmove(ptr, ptr + 2, len + 1); 1107c478bd9Sstevel@tonic-gate continue; 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* change substring "/<foo>/../" into "/" */ 1147c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "/../")) { 1157c478bd9Sstevel@tonic-gate len = strlen(ptr + 3); 1167c478bd9Sstevel@tonic-gate *ptr = '\0'; 1177c478bd9Sstevel@tonic-gate ptr2 = strrchr(path, (int)'/'); 1187c478bd9Sstevel@tonic-gate if (ptr2 == NULL) { 1197c478bd9Sstevel@tonic-gate /* path had a leading "/../" */ 1207c478bd9Sstevel@tonic-gate ptr2 = path; 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate (void) memmove(ptr2, ptr + 3, len + 1); 1237c478bd9Sstevel@tonic-gate continue; 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* change trailing "/<foo>/.." into "/" */ 1277c478bd9Sstevel@tonic-gate if ((len >= 3) && 1287c478bd9Sstevel@tonic-gate (path[len - 3] == '/') && 1297c478bd9Sstevel@tonic-gate (path[len - 2] == '.') && 1307c478bd9Sstevel@tonic-gate (path[len - 1] == '.')) { 1317c478bd9Sstevel@tonic-gate path[len - 3] = '\0'; 1327c478bd9Sstevel@tonic-gate ptr2 = strrchr(path, (int)'/'); 1337c478bd9Sstevel@tonic-gate if (ptr2 != NULL) { 1347c478bd9Sstevel@tonic-gate ptr2[1] = '\0'; 1357c478bd9Sstevel@tonic-gate } else { 1367c478bd9Sstevel@tonic-gate /* path was "/.." */ 1377c478bd9Sstevel@tonic-gate path[0] = '/'; 1387c478bd9Sstevel@tonic-gate path[1] = '\0'; 1397c478bd9Sstevel@tonic-gate } 1407c478bd9Sstevel@tonic-gate continue; 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* change trailing "/." into "/" */ 1447c478bd9Sstevel@tonic-gate if ((len >= 2) && 1457c478bd9Sstevel@tonic-gate (path[len - 2] == '/') && 1467c478bd9Sstevel@tonic-gate (path[len - 1] == '.')) { 1477c478bd9Sstevel@tonic-gate path[len - 1] = '\0'; 1487c478bd9Sstevel@tonic-gate continue; 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* remove trailing "/" unless it's the root */ 1527c478bd9Sstevel@tonic-gate if ((len > 1) && (path[len - 1] == '/')) { 1537c478bd9Sstevel@tonic-gate path[len - 1] = '\0'; 1547c478bd9Sstevel@tonic-gate continue; 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate break; 1587c478bd9Sstevel@tonic-gate } 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* 1637c478bd9Sstevel@tonic-gate * debug version has two more flags: 1647c478bd9Sstevel@tonic-gate * -L force load driver 1657c478bd9Sstevel@tonic-gate * -M: print per driver list 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #ifdef DEBUG 169524b24f9SJudy Chen static const char *optstring = "abcdDvVxpPFf:M:dLuC"; 1707c478bd9Sstevel@tonic-gate #else 171524b24f9SJudy Chen static const char *optstring = "abcdDvVxpPFf:uC"; 1727c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate int 1757c478bd9Sstevel@tonic-gate main(int argc, char *argv[]) 1767c478bd9Sstevel@tonic-gate { 1777c478bd9Sstevel@tonic-gate long pagesize, npages; 1787c478bd9Sstevel@tonic-gate int c, ret; 1797c478bd9Sstevel@tonic-gate char hw_provider[SYS_NMLN]; 1807c478bd9Sstevel@tonic-gate 18123a1cceaSRoger A. Faulkner setpname(argv[0]); 1827c478bd9Sstevel@tonic-gate opts.o_promdev = "/dev/openprom"; 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, optstring)) != -1) { 1857c478bd9Sstevel@tonic-gate switch (c) { 1867c478bd9Sstevel@tonic-gate case 'a': 1877c478bd9Sstevel@tonic-gate ++opts.o_ancestors; 1887c478bd9Sstevel@tonic-gate break; 1897c478bd9Sstevel@tonic-gate case 'b': 1907c478bd9Sstevel@tonic-gate ++opts.o_productinfo; 1917c478bd9Sstevel@tonic-gate break; 1927c478bd9Sstevel@tonic-gate case 'c': 1937c478bd9Sstevel@tonic-gate ++opts.o_children; 1947c478bd9Sstevel@tonic-gate break; 195524b24f9SJudy Chen case 'd': 196524b24f9SJudy Chen ++opts.o_pciid; 197524b24f9SJudy Chen break; 1987c478bd9Sstevel@tonic-gate case 'D': 1997c478bd9Sstevel@tonic-gate ++opts.o_drv_name; 2007c478bd9Sstevel@tonic-gate break; 2017c478bd9Sstevel@tonic-gate case 'v': 2027c478bd9Sstevel@tonic-gate ++opts.o_verbose; 2037c478bd9Sstevel@tonic-gate break; 2047c478bd9Sstevel@tonic-gate case 'p': 2057c478bd9Sstevel@tonic-gate ++opts.o_prominfo; 2067c478bd9Sstevel@tonic-gate break; 2077c478bd9Sstevel@tonic-gate case 'f': 2087c478bd9Sstevel@tonic-gate opts.o_promdev = optarg; 2097c478bd9Sstevel@tonic-gate break; 2107c478bd9Sstevel@tonic-gate case 'V': 2117c478bd9Sstevel@tonic-gate ++opts.o_promversion; 2127c478bd9Sstevel@tonic-gate break; 2137c478bd9Sstevel@tonic-gate case 'x': 2147c478bd9Sstevel@tonic-gate ++opts.o_prom_ready64; 2157c478bd9Sstevel@tonic-gate break; 2167c478bd9Sstevel@tonic-gate case 'F': 2177c478bd9Sstevel@tonic-gate ++opts.o_fbname; 2187c478bd9Sstevel@tonic-gate ++opts.o_noheader; 2197c478bd9Sstevel@tonic-gate break; 2207c478bd9Sstevel@tonic-gate case 'P': 2217c478bd9Sstevel@tonic-gate ++opts.o_pseudodevs; 2227c478bd9Sstevel@tonic-gate break; 2237c478bd9Sstevel@tonic-gate case 'C': 2247c478bd9Sstevel@tonic-gate ++opts.o_forcecache; 2257c478bd9Sstevel@tonic-gate break; 2267c478bd9Sstevel@tonic-gate #ifdef DEBUG 2277c478bd9Sstevel@tonic-gate case 'M': 2287c478bd9Sstevel@tonic-gate dbg.d_drivername = optarg; 2297c478bd9Sstevel@tonic-gate ++dbg.d_bydriver; 2307c478bd9Sstevel@tonic-gate break; 2317c478bd9Sstevel@tonic-gate case 'L': 2327c478bd9Sstevel@tonic-gate ++dbg.d_forceload; 2337c478bd9Sstevel@tonic-gate break; 2347c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate default: 2377c478bd9Sstevel@tonic-gate (void) fprintf(stderr, usage, opts.o_progname); 2387c478bd9Sstevel@tonic-gate return (1); 2397c478bd9Sstevel@tonic-gate } 2407c478bd9Sstevel@tonic-gate } 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate (void) uname(&opts.o_uts); 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate if (opts.o_fbname) 2457c478bd9Sstevel@tonic-gate return (do_fbname()); 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate if (opts.o_promversion) 2487c478bd9Sstevel@tonic-gate return (do_promversion()); 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate if (opts.o_prom_ready64) 2517c478bd9Sstevel@tonic-gate return (do_prom_version64()); 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate if (opts.o_productinfo) 2547c478bd9Sstevel@tonic-gate return (do_productinfo()); 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate opts.o_devices_path = NULL; 2577c478bd9Sstevel@tonic-gate opts.o_devt = DDI_DEV_T_NONE; 2587c478bd9Sstevel@tonic-gate opts.o_target = 0; 2597c478bd9Sstevel@tonic-gate if (optind < argc) { 2607c478bd9Sstevel@tonic-gate struct stat sinfo; 2617c478bd9Sstevel@tonic-gate char *path = argv[optind]; 2627c478bd9Sstevel@tonic-gate int error; 2637c478bd9Sstevel@tonic-gate 264c3a9724dSVikram Hegde if (opts.o_prominfo) { 265c3a9724dSVikram Hegde /* PROM tree cannot be used with path */ 266c3a9724dSVikram Hegde (void) fprintf(stderr, "%s: path and -p option are " 267c3a9724dSVikram Hegde "mutually exclusive\n", opts.o_progname); 268c3a9724dSVikram Hegde return (1); 269c3a9724dSVikram Hegde } 270c3a9724dSVikram Hegde 2717c478bd9Sstevel@tonic-gate if (strlen(path) >= MAXPATHLEN) { 2727c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: " 2737c478bd9Sstevel@tonic-gate "path specified is too long\n", opts.o_progname); 2747c478bd9Sstevel@tonic-gate return (1); 2757c478bd9Sstevel@tonic-gate } 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate if (error = stat(path, &sinfo)) { 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate /* an invalid path was specified */ 2807c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: invalid path specified\n", 2817c478bd9Sstevel@tonic-gate opts.o_progname); 2827c478bd9Sstevel@tonic-gate return (1); 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate } else if (((sinfo.st_mode & S_IFMT) == S_IFCHR) || 2857c478bd9Sstevel@tonic-gate ((sinfo.st_mode & S_IFMT) == S_IFBLK)) { 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate opts.o_devt = sinfo.st_rdev; 2887c478bd9Sstevel@tonic-gate error = 0; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate } else if ((sinfo.st_mode & S_IFMT) == S_IFDIR) { 2917c478bd9Sstevel@tonic-gate size_t len, plen; 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate /* clean up the path */ 2947c478bd9Sstevel@tonic-gate cleanup_path(path, new_path); 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate len = strlen(new_path); 2977c478bd9Sstevel@tonic-gate plen = strlen("/devices"); 2987c478bd9Sstevel@tonic-gate if (len < plen) { 2997c478bd9Sstevel@tonic-gate /* This is not a valid /devices path */ 3007c478bd9Sstevel@tonic-gate error = 1; 3017c478bd9Sstevel@tonic-gate } else if ((len == plen) && 3027c478bd9Sstevel@tonic-gate (strcmp(new_path, "/devices") == 0)) { 3037c478bd9Sstevel@tonic-gate /* /devices is the root nexus */ 3047c478bd9Sstevel@tonic-gate opts.o_devices_path = "/"; 3057c478bd9Sstevel@tonic-gate error = 0; 3067c478bd9Sstevel@tonic-gate } else if (strncmp(new_path, "/devices/", plen + 1)) { 3077c478bd9Sstevel@tonic-gate /* This is not a valid /devices path */ 3087c478bd9Sstevel@tonic-gate error = 1; 3097c478bd9Sstevel@tonic-gate } else { 3107c478bd9Sstevel@tonic-gate /* a /devices/ path was specified */ 3117c478bd9Sstevel@tonic-gate opts.o_devices_path = new_path + plen; 3127c478bd9Sstevel@tonic-gate error = 0; 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate } else { 3167c478bd9Sstevel@tonic-gate /* an invalid device path was specified */ 3177c478bd9Sstevel@tonic-gate error = 1; 3187c478bd9Sstevel@tonic-gate } 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate if (error) { 3217c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: " 3227c478bd9Sstevel@tonic-gate "invalid device path specified\n", 3237c478bd9Sstevel@tonic-gate opts.o_progname); 3247c478bd9Sstevel@tonic-gate return (1); 3257c478bd9Sstevel@tonic-gate } 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate opts.o_target = 1; 3287c478bd9Sstevel@tonic-gate } 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate if ((opts.o_ancestors || opts.o_children) && (!opts.o_target)) { 3317c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: options require a device path\n", 3327c478bd9Sstevel@tonic-gate opts.o_progname); 3337c478bd9Sstevel@tonic-gate return (1); 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate if (opts.o_target) { 3377c478bd9Sstevel@tonic-gate prtconf_devinfo(); 3387c478bd9Sstevel@tonic-gate return (0); 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate ret = sysinfo(SI_HW_PROVIDER, hw_provider, sizeof (hw_provider)); 3427c478bd9Sstevel@tonic-gate /* 3437c478bd9Sstevel@tonic-gate * If 0 bytes are returned (the system returns '1', for the \0), 344*0f24ff92SPiotr Jasiukajtis * we're probably on x86, default to Oracle. 3457c478bd9Sstevel@tonic-gate */ 3467c478bd9Sstevel@tonic-gate if (ret <= 1) { 34787ea2c5cSAnil udupa (void) strncpy(hw_provider, "Oracle Corporation", 3487c478bd9Sstevel@tonic-gate sizeof (hw_provider)); 3497c478bd9Sstevel@tonic-gate } 3507c478bd9Sstevel@tonic-gate (void) printf("System Configuration: %s %s\n", hw_provider, 3517c478bd9Sstevel@tonic-gate opts.o_uts.machine); 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate pagesize = sysconf(_SC_PAGESIZE); 3547c478bd9Sstevel@tonic-gate npages = sysconf(_SC_PHYS_PAGES); 3557c478bd9Sstevel@tonic-gate (void) printf("Memory size: "); 3567c478bd9Sstevel@tonic-gate if (pagesize == -1 || npages == -1) 3577c478bd9Sstevel@tonic-gate (void) printf("unable to determine\n"); 3587c478bd9Sstevel@tonic-gate else { 3597c478bd9Sstevel@tonic-gate const int64_t kbyte = 1024; 3607c478bd9Sstevel@tonic-gate const int64_t mbyte = 1024 * 1024; 3617c478bd9Sstevel@tonic-gate int64_t ii = (int64_t)pagesize * npages; 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate if (ii >= mbyte) 3647c478bd9Sstevel@tonic-gate (void) printf("%ld Megabytes\n", 3657c478bd9Sstevel@tonic-gate (long)((ii+mbyte-1) / mbyte)); 3667c478bd9Sstevel@tonic-gate else 3677c478bd9Sstevel@tonic-gate (void) printf("%ld Kilobytes\n", 3687c478bd9Sstevel@tonic-gate (long)((ii+kbyte-1) / kbyte)); 3697c478bd9Sstevel@tonic-gate } 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate if (opts.o_prominfo) { 3727c478bd9Sstevel@tonic-gate (void) printf("System Peripherals (PROM Nodes):\n\n"); 3737c478bd9Sstevel@tonic-gate if (do_prominfo() == 0) 3747c478bd9Sstevel@tonic-gate return (0); 3757c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: Defaulting to non-PROM mode...\n", 3767c478bd9Sstevel@tonic-gate opts.o_progname); 3777c478bd9Sstevel@tonic-gate } 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate (void) printf("System Peripherals (Software Nodes):\n\n"); 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate (void) prtconf_devinfo(); 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate return (0); 3847c478bd9Sstevel@tonic-gate } 385