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 */ 217c478bd9Sstevel@tonic-gate /* 22c3a9724dSVikram Hegde * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 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 307c478bd9Sstevel@tonic-gate #include <stdio.h> 317c478bd9Sstevel@tonic-gate #include <stdarg.h> 327c478bd9Sstevel@tonic-gate #include <stdlib.h> 337c478bd9Sstevel@tonic-gate #include <unistd.h> 347c478bd9Sstevel@tonic-gate #include <strings.h> 357c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h> 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate #include <sys/stat.h> 387c478bd9Sstevel@tonic-gate #include "prtconf.h" 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate struct prt_opts opts; 417c478bd9Sstevel@tonic-gate struct prt_dbg dbg; 427c478bd9Sstevel@tonic-gate static char new_path[MAXPATHLEN]; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #define INDENT_LENGTH 4 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #ifdef __x86 47*524b24f9SJudy Chen static const char *usage = "%s [ -V | -x | -abcdvpPD ] [ <device_path > ]\n"; 487c478bd9Sstevel@tonic-gate #else 49*524b24f9SJudy Chen static const char *usage = 50*524b24f9SJudy Chen "%s [ -F | -V | -x | -abcdvpPD ][ <device_path > ]\n"; 517c478bd9Sstevel@tonic-gate #endif /* __x86 */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate static void 547c478bd9Sstevel@tonic-gate setprogname(const char *name) 557c478bd9Sstevel@tonic-gate { 567c478bd9Sstevel@tonic-gate char *p; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate if (name == NULL) 597c478bd9Sstevel@tonic-gate opts.o_progname = "prtconf"; 607c478bd9Sstevel@tonic-gate else if (p = strrchr(name, '/')) 617c478bd9Sstevel@tonic-gate opts.o_progname = (const char *) p + 1; 627c478bd9Sstevel@tonic-gate else 637c478bd9Sstevel@tonic-gate opts.o_progname = name; 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/ 677c478bd9Sstevel@tonic-gate void 687c478bd9Sstevel@tonic-gate dprintf(const char *fmt, ...) 697c478bd9Sstevel@tonic-gate { 707c478bd9Sstevel@tonic-gate if (dbg.d_debug) { 717c478bd9Sstevel@tonic-gate va_list ap; 727c478bd9Sstevel@tonic-gate va_start(ap, fmt); 737c478bd9Sstevel@tonic-gate (void) vfprintf(stderr, fmt, ap); 747c478bd9Sstevel@tonic-gate va_end(ap); 757c478bd9Sstevel@tonic-gate } 767c478bd9Sstevel@tonic-gate } 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate void 797c478bd9Sstevel@tonic-gate indent_to_level(int ilev) 807c478bd9Sstevel@tonic-gate { 817c478bd9Sstevel@tonic-gate (void) printf("%*s", INDENT_LENGTH * ilev, ""); 827c478bd9Sstevel@tonic-gate } 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate static void 857c478bd9Sstevel@tonic-gate cleanup_path(const char *input_path, char *path) 867c478bd9Sstevel@tonic-gate { 877c478bd9Sstevel@tonic-gate char *ptr, *ptr2; 887c478bd9Sstevel@tonic-gate size_t len; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate if ((input_path == NULL) || (path == NULL)) 917c478bd9Sstevel@tonic-gate return; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate (void) strcpy(path, input_path); 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /*LINTED*/ 967c478bd9Sstevel@tonic-gate while (1) { 977c478bd9Sstevel@tonic-gate len = strlen(path); 987c478bd9Sstevel@tonic-gate if (len == 0) 997c478bd9Sstevel@tonic-gate break; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* change substring "//" into "/" */ 1027c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "//")) { 1037c478bd9Sstevel@tonic-gate len = strlen(ptr + 1); 1047c478bd9Sstevel@tonic-gate (void) memmove(ptr, ptr + 1, len + 1); 1057c478bd9Sstevel@tonic-gate continue; 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate /* change substring "/./" into "/" */ 1087c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "/./")) { 1097c478bd9Sstevel@tonic-gate len = strlen(ptr + 2); 1107c478bd9Sstevel@tonic-gate (void) memmove(ptr, ptr + 2, len + 1); 1117c478bd9Sstevel@tonic-gate continue; 1127c478bd9Sstevel@tonic-gate } 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* change substring "/<foo>/../" into "/" */ 1157c478bd9Sstevel@tonic-gate if (ptr = strstr(path, "/../")) { 1167c478bd9Sstevel@tonic-gate len = strlen(ptr + 3); 1177c478bd9Sstevel@tonic-gate *ptr = '\0'; 1187c478bd9Sstevel@tonic-gate ptr2 = strrchr(path, (int)'/'); 1197c478bd9Sstevel@tonic-gate if (ptr2 == NULL) { 1207c478bd9Sstevel@tonic-gate /* path had a leading "/../" */ 1217c478bd9Sstevel@tonic-gate ptr2 = path; 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate (void) memmove(ptr2, ptr + 3, len + 1); 1247c478bd9Sstevel@tonic-gate continue; 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* change trailing "/<foo>/.." into "/" */ 1287c478bd9Sstevel@tonic-gate if ((len >= 3) && 1297c478bd9Sstevel@tonic-gate (path[len - 3] == '/') && 1307c478bd9Sstevel@tonic-gate (path[len - 2] == '.') && 1317c478bd9Sstevel@tonic-gate (path[len - 1] == '.')) { 1327c478bd9Sstevel@tonic-gate path[len - 3] = '\0'; 1337c478bd9Sstevel@tonic-gate ptr2 = strrchr(path, (int)'/'); 1347c478bd9Sstevel@tonic-gate if (ptr2 != NULL) { 1357c478bd9Sstevel@tonic-gate ptr2[1] = '\0'; 1367c478bd9Sstevel@tonic-gate } else { 1377c478bd9Sstevel@tonic-gate /* path was "/.." */ 1387c478bd9Sstevel@tonic-gate path[0] = '/'; 1397c478bd9Sstevel@tonic-gate path[1] = '\0'; 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate continue; 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* change trailing "/." into "/" */ 1457c478bd9Sstevel@tonic-gate if ((len >= 2) && 1467c478bd9Sstevel@tonic-gate (path[len - 2] == '/') && 1477c478bd9Sstevel@tonic-gate (path[len - 1] == '.')) { 1487c478bd9Sstevel@tonic-gate path[len - 1] = '\0'; 1497c478bd9Sstevel@tonic-gate continue; 1507c478bd9Sstevel@tonic-gate } 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* remove trailing "/" unless it's the root */ 1537c478bd9Sstevel@tonic-gate if ((len > 1) && (path[len - 1] == '/')) { 1547c478bd9Sstevel@tonic-gate path[len - 1] = '\0'; 1557c478bd9Sstevel@tonic-gate continue; 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate break; 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* 1647c478bd9Sstevel@tonic-gate * debug version has two more flags: 1657c478bd9Sstevel@tonic-gate * -L force load driver 1667c478bd9Sstevel@tonic-gate * -M: print per driver list 1677c478bd9Sstevel@tonic-gate */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #ifdef DEBUG 170*524b24f9SJudy Chen static const char *optstring = "abcdDvVxpPFf:M:dLuC"; 1717c478bd9Sstevel@tonic-gate #else 172*524b24f9SJudy Chen static const char *optstring = "abcdDvVxpPFf:uC"; 1737c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate int 1767c478bd9Sstevel@tonic-gate main(int argc, char *argv[]) 1777c478bd9Sstevel@tonic-gate { 1787c478bd9Sstevel@tonic-gate long pagesize, npages; 1797c478bd9Sstevel@tonic-gate int c, ret; 1807c478bd9Sstevel@tonic-gate char hw_provider[SYS_NMLN]; 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate setprogname(argv[0]); 1837c478bd9Sstevel@tonic-gate opts.o_promdev = "/dev/openprom"; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, optstring)) != -1) { 1867c478bd9Sstevel@tonic-gate switch (c) { 1877c478bd9Sstevel@tonic-gate case 'a': 1887c478bd9Sstevel@tonic-gate ++opts.o_ancestors; 1897c478bd9Sstevel@tonic-gate break; 1907c478bd9Sstevel@tonic-gate case 'b': 1917c478bd9Sstevel@tonic-gate ++opts.o_productinfo; 1927c478bd9Sstevel@tonic-gate break; 1937c478bd9Sstevel@tonic-gate case 'c': 1947c478bd9Sstevel@tonic-gate ++opts.o_children; 1957c478bd9Sstevel@tonic-gate break; 196*524b24f9SJudy Chen case 'd': 197*524b24f9SJudy Chen ++opts.o_pciid; 198*524b24f9SJudy Chen break; 1997c478bd9Sstevel@tonic-gate case 'D': 2007c478bd9Sstevel@tonic-gate ++opts.o_drv_name; 2017c478bd9Sstevel@tonic-gate break; 2027c478bd9Sstevel@tonic-gate case 'v': 2037c478bd9Sstevel@tonic-gate ++opts.o_verbose; 2047c478bd9Sstevel@tonic-gate break; 2057c478bd9Sstevel@tonic-gate case 'p': 2067c478bd9Sstevel@tonic-gate ++opts.o_prominfo; 2077c478bd9Sstevel@tonic-gate break; 2087c478bd9Sstevel@tonic-gate case 'f': 2097c478bd9Sstevel@tonic-gate opts.o_promdev = optarg; 2107c478bd9Sstevel@tonic-gate break; 2117c478bd9Sstevel@tonic-gate case 'V': 2127c478bd9Sstevel@tonic-gate ++opts.o_promversion; 2137c478bd9Sstevel@tonic-gate break; 2147c478bd9Sstevel@tonic-gate case 'x': 2157c478bd9Sstevel@tonic-gate ++opts.o_prom_ready64; 2167c478bd9Sstevel@tonic-gate break; 2177c478bd9Sstevel@tonic-gate case 'F': 2187c478bd9Sstevel@tonic-gate ++opts.o_fbname; 2197c478bd9Sstevel@tonic-gate ++opts.o_noheader; 2207c478bd9Sstevel@tonic-gate break; 2217c478bd9Sstevel@tonic-gate case 'P': 2227c478bd9Sstevel@tonic-gate ++opts.o_pseudodevs; 2237c478bd9Sstevel@tonic-gate break; 2247c478bd9Sstevel@tonic-gate case 'C': 2257c478bd9Sstevel@tonic-gate ++opts.o_forcecache; 2267c478bd9Sstevel@tonic-gate break; 2277c478bd9Sstevel@tonic-gate #ifdef DEBUG 2287c478bd9Sstevel@tonic-gate case 'M': 2297c478bd9Sstevel@tonic-gate dbg.d_drivername = optarg; 2307c478bd9Sstevel@tonic-gate ++dbg.d_bydriver; 2317c478bd9Sstevel@tonic-gate break; 2327c478bd9Sstevel@tonic-gate case 'L': 2337c478bd9Sstevel@tonic-gate ++dbg.d_forceload; 2347c478bd9Sstevel@tonic-gate break; 2357c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate default: 2387c478bd9Sstevel@tonic-gate (void) fprintf(stderr, usage, opts.o_progname); 2397c478bd9Sstevel@tonic-gate return (1); 2407c478bd9Sstevel@tonic-gate } 2417c478bd9Sstevel@tonic-gate } 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate (void) uname(&opts.o_uts); 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate if (opts.o_fbname) 2467c478bd9Sstevel@tonic-gate return (do_fbname()); 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate if (opts.o_promversion) 2497c478bd9Sstevel@tonic-gate return (do_promversion()); 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate if (opts.o_prom_ready64) 2527c478bd9Sstevel@tonic-gate return (do_prom_version64()); 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate if (opts.o_productinfo) 2557c478bd9Sstevel@tonic-gate return (do_productinfo()); 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate opts.o_devices_path = NULL; 2587c478bd9Sstevel@tonic-gate opts.o_devt = DDI_DEV_T_NONE; 2597c478bd9Sstevel@tonic-gate opts.o_target = 0; 2607c478bd9Sstevel@tonic-gate if (optind < argc) { 2617c478bd9Sstevel@tonic-gate struct stat sinfo; 2627c478bd9Sstevel@tonic-gate char *path = argv[optind]; 2637c478bd9Sstevel@tonic-gate int error; 2647c478bd9Sstevel@tonic-gate 265c3a9724dSVikram Hegde if (opts.o_prominfo) { 266c3a9724dSVikram Hegde /* PROM tree cannot be used with path */ 267c3a9724dSVikram Hegde (void) fprintf(stderr, "%s: path and -p option are " 268c3a9724dSVikram Hegde "mutually exclusive\n", opts.o_progname); 269c3a9724dSVikram Hegde return (1); 270c3a9724dSVikram Hegde } 271c3a9724dSVikram Hegde 2727c478bd9Sstevel@tonic-gate if (strlen(path) >= MAXPATHLEN) { 2737c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: " 2747c478bd9Sstevel@tonic-gate "path specified is too long\n", opts.o_progname); 2757c478bd9Sstevel@tonic-gate return (1); 2767c478bd9Sstevel@tonic-gate } 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate if (error = stat(path, &sinfo)) { 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate /* an invalid path was specified */ 2817c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: invalid path specified\n", 2827c478bd9Sstevel@tonic-gate opts.o_progname); 2837c478bd9Sstevel@tonic-gate return (1); 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate } else if (((sinfo.st_mode & S_IFMT) == S_IFCHR) || 2867c478bd9Sstevel@tonic-gate ((sinfo.st_mode & S_IFMT) == S_IFBLK)) { 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate opts.o_devt = sinfo.st_rdev; 2897c478bd9Sstevel@tonic-gate error = 0; 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate } else if ((sinfo.st_mode & S_IFMT) == S_IFDIR) { 2927c478bd9Sstevel@tonic-gate size_t len, plen; 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate /* clean up the path */ 2957c478bd9Sstevel@tonic-gate cleanup_path(path, new_path); 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate len = strlen(new_path); 2987c478bd9Sstevel@tonic-gate plen = strlen("/devices"); 2997c478bd9Sstevel@tonic-gate if (len < plen) { 3007c478bd9Sstevel@tonic-gate /* This is not a valid /devices path */ 3017c478bd9Sstevel@tonic-gate error = 1; 3027c478bd9Sstevel@tonic-gate } else if ((len == plen) && 3037c478bd9Sstevel@tonic-gate (strcmp(new_path, "/devices") == 0)) { 3047c478bd9Sstevel@tonic-gate /* /devices is the root nexus */ 3057c478bd9Sstevel@tonic-gate opts.o_devices_path = "/"; 3067c478bd9Sstevel@tonic-gate error = 0; 3077c478bd9Sstevel@tonic-gate } else if (strncmp(new_path, "/devices/", plen + 1)) { 3087c478bd9Sstevel@tonic-gate /* This is not a valid /devices path */ 3097c478bd9Sstevel@tonic-gate error = 1; 3107c478bd9Sstevel@tonic-gate } else { 3117c478bd9Sstevel@tonic-gate /* a /devices/ path was specified */ 3127c478bd9Sstevel@tonic-gate opts.o_devices_path = new_path + plen; 3137c478bd9Sstevel@tonic-gate error = 0; 3147c478bd9Sstevel@tonic-gate } 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate } else { 3177c478bd9Sstevel@tonic-gate /* an invalid device path was specified */ 3187c478bd9Sstevel@tonic-gate error = 1; 3197c478bd9Sstevel@tonic-gate } 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate if (error) { 3227c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: " 3237c478bd9Sstevel@tonic-gate "invalid device path specified\n", 3247c478bd9Sstevel@tonic-gate opts.o_progname); 3257c478bd9Sstevel@tonic-gate return (1); 3267c478bd9Sstevel@tonic-gate } 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate opts.o_target = 1; 3297c478bd9Sstevel@tonic-gate } 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate if ((opts.o_ancestors || opts.o_children) && (!opts.o_target)) { 3327c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: options require a device path\n", 3337c478bd9Sstevel@tonic-gate opts.o_progname); 3347c478bd9Sstevel@tonic-gate return (1); 3357c478bd9Sstevel@tonic-gate } 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate if (opts.o_target) { 3387c478bd9Sstevel@tonic-gate prtconf_devinfo(); 3397c478bd9Sstevel@tonic-gate return (0); 3407c478bd9Sstevel@tonic-gate } 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate ret = sysinfo(SI_HW_PROVIDER, hw_provider, sizeof (hw_provider)); 3437c478bd9Sstevel@tonic-gate /* 3447c478bd9Sstevel@tonic-gate * If 0 bytes are returned (the system returns '1', for the \0), 3457c478bd9Sstevel@tonic-gate * we're probably on x86, and there has been no si-hw-provider 3467c478bd9Sstevel@tonic-gate * set in /etc/bootrc, so just default to Sun. 3477c478bd9Sstevel@tonic-gate */ 3487c478bd9Sstevel@tonic-gate if (ret <= 1) { 3497c478bd9Sstevel@tonic-gate (void) strncpy(hw_provider, "Sun Microsystems", 3507c478bd9Sstevel@tonic-gate sizeof (hw_provider)); 3517c478bd9Sstevel@tonic-gate } else { 3527c478bd9Sstevel@tonic-gate /* 3537c478bd9Sstevel@tonic-gate * Provide backward compatibility by stripping out the _. 3547c478bd9Sstevel@tonic-gate */ 3557c478bd9Sstevel@tonic-gate if (strcmp(hw_provider, "Sun_Microsystems") == 0) 3567c478bd9Sstevel@tonic-gate hw_provider[3] = ' '; 3577c478bd9Sstevel@tonic-gate } 3587c478bd9Sstevel@tonic-gate (void) printf("System Configuration: %s %s\n", hw_provider, 3597c478bd9Sstevel@tonic-gate opts.o_uts.machine); 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate pagesize = sysconf(_SC_PAGESIZE); 3627c478bd9Sstevel@tonic-gate npages = sysconf(_SC_PHYS_PAGES); 3637c478bd9Sstevel@tonic-gate (void) printf("Memory size: "); 3647c478bd9Sstevel@tonic-gate if (pagesize == -1 || npages == -1) 3657c478bd9Sstevel@tonic-gate (void) printf("unable to determine\n"); 3667c478bd9Sstevel@tonic-gate else { 3677c478bd9Sstevel@tonic-gate const int64_t kbyte = 1024; 3687c478bd9Sstevel@tonic-gate const int64_t mbyte = 1024 * 1024; 3697c478bd9Sstevel@tonic-gate int64_t ii = (int64_t)pagesize * npages; 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate if (ii >= mbyte) 3727c478bd9Sstevel@tonic-gate (void) printf("%ld Megabytes\n", 3737c478bd9Sstevel@tonic-gate (long)((ii+mbyte-1) / mbyte)); 3747c478bd9Sstevel@tonic-gate else 3757c478bd9Sstevel@tonic-gate (void) printf("%ld Kilobytes\n", 3767c478bd9Sstevel@tonic-gate (long)((ii+kbyte-1) / kbyte)); 3777c478bd9Sstevel@tonic-gate } 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate if (opts.o_prominfo) { 3807c478bd9Sstevel@tonic-gate (void) printf("System Peripherals (PROM Nodes):\n\n"); 3817c478bd9Sstevel@tonic-gate if (do_prominfo() == 0) 3827c478bd9Sstevel@tonic-gate return (0); 3837c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s: Defaulting to non-PROM mode...\n", 3847c478bd9Sstevel@tonic-gate opts.o_progname); 3857c478bd9Sstevel@tonic-gate } 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate (void) printf("System Peripherals (Software Nodes):\n\n"); 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate (void) prtconf_devinfo(); 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate return (0); 3927c478bd9Sstevel@tonic-gate } 393