1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * "PROM" interface 29 */ 30 31 #include <sys/types.h> 32 #include <sys/promif.h> 33 #include <sys/salib.h> 34 35 #include <kmdb/kmdb_promif_impl.h> 36 #include <kmdb/kmdb_kdi.h> 37 #include <kmdb/kmdb_dpi.h> 38 #include <mdb/mdb_err.h> 39 #include <mdb/mdb_debug.h> 40 #include <mdb/mdb_string.h> 41 #include <mdb/mdb.h> 42 43 struct boot_syscalls *kmdb_sysp; 44 45 ssize_t 46 kmdb_prom_obp_writer(caddr_t buf, size_t len) 47 { 48 int i; 49 50 for (i = 0; i < len; i++) 51 prom_putchar(*buf++); 52 53 return (len); 54 } 55 56 /*ARGSUSED*/ 57 ihandle_t 58 kmdb_prom_get_handle(char *name) 59 { 60 /* no handles here */ 61 return (0); 62 } 63 64 char * 65 kmdb_prom_get_ddi_prop(kmdb_auxv_t *kav, char *propname) 66 { 67 int i; 68 69 if (kav->kav_pcache != NULL) { 70 for (i = 0; i < kav->kav_nprops; i++) { 71 kmdb_auxv_nv_t *nv = &kav->kav_pcache[i]; 72 if (strcmp(nv->kanv_name, propname) == 0) 73 return (nv->kanv_val); 74 } 75 } 76 77 return (NULL); 78 } 79 80 /*ARGSUSED*/ 81 void 82 kmdb_prom_free_ddi_prop(char *val) 83 { 84 } 85 86 /* 87 * This function is actually about checking if we are using 88 * local console versus serial console. Serial console can be named 89 * "ttyX" where X is [a-d], or "usb-serial". 90 */ 91 int 92 kmdb_prom_stdout_is_framebuffer(kmdb_auxv_t *kav) 93 { 94 char *dev; 95 96 /* 97 * The property "output-device" value is set in property cache, and 98 * is based on either "output-device" or "console" properties from 99 * the actual system. We can't use the official promif version, as we 100 * need to ensure that property lookups come from our property cache. 101 */ 102 103 if ((dev = kmdb_prom_get_ddi_prop(kav, "output-device")) == NULL) 104 return (0); 105 106 if (strncmp(dev, "tty", 3) == 0) 107 return (0); 108 if (strcmp(dev, "usb-serial") == 0) 109 return (0); 110 111 /* Anything else is classified as local console. */ 112 return (1); 113 } 114 115 void 116 kmdb_prom_get_tem_size(kmdb_auxv_t *kav, ushort_t *rows, ushort_t *cols) 117 { 118 char *val; 119 unsigned long u; 120 121 val = kmdb_prom_get_ddi_prop(kav, "screen-#rows"); 122 if (val != NULL) { 123 u = strtoul(val, NULL, 10); 124 *rows = (ushort_t)u; 125 } 126 val = kmdb_prom_get_ddi_prop(kav, "screen-#cols"); 127 if (val != NULL) { 128 u = strtoul(val, NULL, 10); 129 *cols = (ushort_t)u; 130 } 131 } 132