xref: /illumos-gate/usr/src/cmd/mdb/intel/kmdb/kmdb_promif_isadep.c (revision e4d060fb4c00d44cd578713eb9a921f594b733b8)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * "PROM" interface
31  */
32 
33 #include <sys/types.h>
34 #include <sys/promif.h>
35 
36 #include <kmdb/kmdb_promif_impl.h>
37 #include <kmdb/kmdb_kdi.h>
38 #include <kmdb/kmdb_dpi.h>
39 #include <mdb/mdb_err.h>
40 #include <mdb/mdb_debug.h>
41 #include <mdb/mdb_string.h>
42 #include <mdb/mdb.h>
43 
44 struct boot_syscalls *kmdb_sysp;
45 
46 ssize_t
47 kmdb_prom_obp_writer(caddr_t buf, size_t len)
48 {
49 	int i;
50 
51 	for (i = 0; i < len; i++)
52 		prom_putchar(*buf++);
53 
54 	return (len);
55 }
56 
57 /*ARGSUSED*/
58 ihandle_t
59 kmdb_prom_get_handle(char *name)
60 {
61 	/* no handles here */
62 	return (0);
63 }
64 
65 char *
66 kmdb_prom_get_ddi_prop(kmdb_auxv_t *kav, char *propname)
67 {
68 	int i;
69 
70 	if (kav->kav_pcache != NULL) {
71 		for (i = 0; i < kav->kav_nprops; i++) {
72 			kmdb_auxv_nv_t *nv = &kav->kav_pcache[i];
73 			if (strcmp(nv->kanv_name, propname) == 0)
74 				return (nv->kanv_val);
75 		}
76 	}
77 
78 	return (NULL);
79 }
80 
81 /*ARGSUSED*/
82 void
83 kmdb_prom_free_ddi_prop(char *val)
84 {
85 }
86 
87 int
88 kmdb_prom_stdout_is_framebuffer(kmdb_auxv_t *kav)
89 {
90 	char *dev;
91 
92 	/*
93 	 * We can't use the official promif version, as we need to ensure that
94 	 * property lookups come from our property cache.
95 	 */
96 
97 	if ((dev = kmdb_prom_get_ddi_prop(kav, "output-device")) == NULL)
98 		return (0);
99 
100 	return (strcmp(dev, "screen") == 0);
101 }
102