xref: /titanic_54/usr/src/uts/i86pc/io/consplat.c (revision c401c7a8bedb1f911c705cc50370729a523e703c)
1ae115bc7Smrj /*
2ae115bc7Smrj  * CDDL HEADER START
3ae115bc7Smrj  *
4ae115bc7Smrj  * The contents of this file are subject to the terms of the
5ae115bc7Smrj  * Common Development and Distribution License (the "License").
6ae115bc7Smrj  * You may not use this file except in compliance with the License.
7ae115bc7Smrj  *
8ae115bc7Smrj  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9ae115bc7Smrj  * or http://www.opensolaris.org/os/licensing.
10ae115bc7Smrj  * See the License for the specific language governing permissions
11ae115bc7Smrj  * and limitations under the License.
12ae115bc7Smrj  *
13ae115bc7Smrj  * When distributing Covered Code, include this CDDL HEADER in each
14ae115bc7Smrj  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15ae115bc7Smrj  * If applicable, add the following below this CDDL HEADER, with the
16ae115bc7Smrj  * fields enclosed by brackets "[]" replaced with your own identifying
17ae115bc7Smrj  * information: Portions Copyright [yyyy] [name of copyright owner]
18ae115bc7Smrj  *
19ae115bc7Smrj  * CDDL HEADER END
20ae115bc7Smrj  */
21ae115bc7Smrj 
22ae115bc7Smrj /*
2378323854SJudy Chen  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24ae115bc7Smrj  * Use is subject to license terms.
25ae115bc7Smrj  */
26ae115bc7Smrj 
27ae115bc7Smrj /*
28ae115bc7Smrj  * isa-specific console configuration routines
29ae115bc7Smrj  */
30ae115bc7Smrj 
31ae115bc7Smrj #include <sys/types.h>
32ae115bc7Smrj #include <sys/param.h>
33ae115bc7Smrj #include <sys/cmn_err.h>
34ae115bc7Smrj #include <sys/systm.h>
35ae115bc7Smrj #include <sys/conf.h>
36ae115bc7Smrj #include <sys/debug.h>
37ae115bc7Smrj #include <sys/ddi.h>
38ae115bc7Smrj #include <sys/sunddi.h>
39ae115bc7Smrj #include <sys/sunndi.h>
40ae115bc7Smrj #include <sys/esunddi.h>
41ae115bc7Smrj #include <sys/ddi_impldefs.h>
42ae115bc7Smrj #include <sys/promif.h>
43ae115bc7Smrj #include <sys/modctl.h>
44ae115bc7Smrj #include <sys/termios.h>
4545e46d06Srui zang - Sun Microsystems - Beijing China #include <sys/pci.h>
46843e1988Sjohnlev #if defined(__xpv)
47843e1988Sjohnlev #include <sys/hypervisor.h>
48843e1988Sjohnlev #include <sys/boot_console.h>
49843e1988Sjohnlev #endif
50ae115bc7Smrj 
5178323854SJudy Chen extern int pseudo_isa;
5278323854SJudy Chen 
53ae115bc7Smrj int
54ae115bc7Smrj plat_use_polled_debug() {
55ae115bc7Smrj 	return (0);
56ae115bc7Smrj }
57ae115bc7Smrj 
58ae115bc7Smrj int
59ae115bc7Smrj plat_support_serial_kbd_and_ms() {
60ae115bc7Smrj 	return (0);
61ae115bc7Smrj }
62ae115bc7Smrj 
63843e1988Sjohnlev #define	A_CNT(arr)	(sizeof (arr) / sizeof (arr[0]))
64843e1988Sjohnlev 
65ae115bc7Smrj #define	CONS_INVALID	-1
66ae115bc7Smrj #define	CONS_SCREEN	0
67ae115bc7Smrj #define	CONS_TTYA	1
68ae115bc7Smrj #define	CONS_TTYB	2
69ae115bc7Smrj #define	CONS_USBSER	3
70843e1988Sjohnlev #define	CONS_HYPERVISOR	4
71ae115bc7Smrj 
72583da248Srz201010 char *plat_fbpath(void);
73583da248Srz201010 
74ae115bc7Smrj static int
75ae115bc7Smrj console_type()
76ae115bc7Smrj {
77ae115bc7Smrj 	static int boot_console = CONS_INVALID;
78ae115bc7Smrj 
79ae115bc7Smrj 	char *cons;
80ae115bc7Smrj 	dev_info_t *root;
81ae115bc7Smrj 
82ae115bc7Smrj 	if (boot_console != CONS_INVALID)
83ae115bc7Smrj 		return (boot_console);
84ae115bc7Smrj 
85843e1988Sjohnlev #if defined(__xpv)
86843e1988Sjohnlev 	if (!DOMAIN_IS_INITDOMAIN(xen_info) || bcons_hypervisor_redirect()) {
87843e1988Sjohnlev 		boot_console = CONS_HYPERVISOR;
88843e1988Sjohnlev 		return (boot_console);
89843e1988Sjohnlev 	}
90843e1988Sjohnlev #endif /* __xpv */
91843e1988Sjohnlev 
92ae115bc7Smrj 	/*
93ae115bc7Smrj 	 * console is defined by "console" property, with
94ae115bc7Smrj 	 * fallback on the old "input-device" property.
95583da248Srz201010 	 * If "input-device" is not defined either, also check "output-device".
96ae115bc7Smrj 	 */
97ae115bc7Smrj 	boot_console = CONS_SCREEN;	/* default is screen/kb */
98ae115bc7Smrj 	root = ddi_root_node();
99ae115bc7Smrj 	if ((ddi_prop_lookup_string(DDI_DEV_T_ANY, root,
100ae115bc7Smrj 	    DDI_PROP_DONTPASS, "console", &cons) == DDI_SUCCESS) ||
101ae115bc7Smrj 	    (ddi_prop_lookup_string(DDI_DEV_T_ANY, root,
102583da248Srz201010 	    DDI_PROP_DONTPASS, "input-device", &cons) == DDI_SUCCESS) ||
103583da248Srz201010 	    (ddi_prop_lookup_string(DDI_DEV_T_ANY, root,
104583da248Srz201010 	    DDI_PROP_DONTPASS, "output-device", &cons) == DDI_SUCCESS)) {
105843e1988Sjohnlev 		if (strcmp(cons, "ttya") == 0) {
106ae115bc7Smrj 			boot_console = CONS_TTYA;
107843e1988Sjohnlev 		} else if (strcmp(cons, "ttyb") == 0) {
108ae115bc7Smrj 			boot_console = CONS_TTYB;
109843e1988Sjohnlev 		} else if (strcmp(cons, "usb-serial") == 0) {
110ae115bc7Smrj 			(void) i_ddi_attach_hw_nodes("ehci");
111ae115bc7Smrj 			(void) i_ddi_attach_hw_nodes("uhci");
112ae115bc7Smrj 			(void) i_ddi_attach_hw_nodes("ohci");
113ae115bc7Smrj 			/*
114ae115bc7Smrj 			 * USB device enumerate asynchronously.
115ae115bc7Smrj 			 * Wait 2 seconds for USB serial devices to attach.
116ae115bc7Smrj 			 */
117ae115bc7Smrj 			delay(drv_usectohz(2000000));
118ae115bc7Smrj 			boot_console = CONS_USBSER;
119843e1988Sjohnlev #if defined(__xpv)
120843e1988Sjohnlev 		} else if (strcmp(cons, "hypervisor") == 0) {
121843e1988Sjohnlev 			boot_console = CONS_HYPERVISOR;
122843e1988Sjohnlev #endif /* __xpv */
123ae115bc7Smrj 		}
124ae115bc7Smrj 		ddi_prop_free(cons);
125ae115bc7Smrj 	}
126583da248Srz201010 
127583da248Srz201010 	/*
128583da248Srz201010 	 * If the console is configured to use a framebuffer but none
129583da248Srz201010 	 * could be found, fallback to "ttya" since it's likely to exist
130583da248Srz201010 	 * and it matches longstanding behavior on SPARC.
131583da248Srz201010 	 */
132583da248Srz201010 	if (boot_console == CONS_SCREEN && plat_fbpath() == NULL)
133583da248Srz201010 		boot_console = CONS_TTYA;
134583da248Srz201010 
135ae115bc7Smrj 	return (boot_console);
136ae115bc7Smrj }
137ae115bc7Smrj 
138ae115bc7Smrj int
139ae115bc7Smrj plat_stdin_is_keyboard(void)
140ae115bc7Smrj {
141ae115bc7Smrj 	return (console_type() == CONS_SCREEN);
142ae115bc7Smrj }
143ae115bc7Smrj 
144ae115bc7Smrj int
145ae115bc7Smrj plat_stdout_is_framebuffer(void)
146ae115bc7Smrj {
147ae115bc7Smrj 	return (console_type() == CONS_SCREEN);
148ae115bc7Smrj }
149ae115bc7Smrj 
15078323854SJudy Chen static char *
15178323854SJudy Chen plat_devpath(char *name, char *path)
15278323854SJudy Chen {
15378323854SJudy Chen 	major_t major;
15478323854SJudy Chen 	dev_info_t *dip, *pdip;
15578323854SJudy Chen 
15678323854SJudy Chen 	if ((major = ddi_name_to_major(name)) == (major_t)-1)
15778323854SJudy Chen 		return (NULL);
15878323854SJudy Chen 
15978323854SJudy Chen 	if ((dip = devnamesp[major].dn_head) == NULL)
16078323854SJudy Chen 		return (NULL);
16178323854SJudy Chen 
16278323854SJudy Chen 	pdip = ddi_get_parent(dip);
16378323854SJudy Chen 	if (i_ddi_attach_node_hierarchy(pdip) != DDI_SUCCESS)
16478323854SJudy Chen 		return (NULL);
16578323854SJudy Chen 	if (ddi_initchild(pdip, dip) != DDI_SUCCESS)
16678323854SJudy Chen 		return (NULL);
16778323854SJudy Chen 
16878323854SJudy Chen 	(void) ddi_pathname(dip, path);
16978323854SJudy Chen 
17078323854SJudy Chen 	return (path);
17178323854SJudy Chen }
17278323854SJudy Chen 
173ae115bc7Smrj /*
174ae115bc7Smrj  * Return generic path to keyboard device from the alias.
175ae115bc7Smrj  */
176ae115bc7Smrj char *
177ae115bc7Smrj plat_kbdpath(void)
178ae115bc7Smrj {
17978323854SJudy Chen 	static char kbpath[MAXPATHLEN];
18078323854SJudy Chen 
181ae115bc7Smrj 	/*
182ae115bc7Smrj 	 * Hardcode to isa keyboard path
183ae115bc7Smrj 	 * XXX make it settable via bootprop?
184ae115bc7Smrj 	 */
18578323854SJudy Chen 	if (pseudo_isa)
186ae115bc7Smrj 		return ("/isa/i8042@1,60/keyboard@0");
18778323854SJudy Chen 
18878323854SJudy Chen 	if (plat_devpath("kb8042", kbpath) == NULL)
18978323854SJudy Chen 		return (NULL);
19078323854SJudy Chen 
19178323854SJudy Chen 	return (kbpath);
192ae115bc7Smrj }
193ae115bc7Smrj 
19445e46d06Srui zang - Sun Microsystems - Beijing China static int
19545e46d06Srui zang - Sun Microsystems - Beijing China find_fb_dev(dev_info_t *dip, void *found_dip)
19645e46d06Srui zang - Sun Microsystems - Beijing China {
19745e46d06Srui zang - Sun Microsystems - Beijing China 	char *dev_type;
19845e46d06Srui zang - Sun Microsystems - Beijing China 	dev_info_t *pdip;
19945e46d06Srui zang - Sun Microsystems - Beijing China 	char *parent_type;
20045e46d06Srui zang - Sun Microsystems - Beijing China 
20145e46d06Srui zang - Sun Microsystems - Beijing China 	if (dip == ddi_root_node())
20245e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
20345e46d06Srui zang - Sun Microsystems - Beijing China 
20445e46d06Srui zang - Sun Microsystems - Beijing China 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
20545e46d06Srui zang - Sun Microsystems - Beijing China 	    "device_type", &dev_type) != DDI_SUCCESS)
20645e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
20745e46d06Srui zang - Sun Microsystems - Beijing China 
20845e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(dev_type, "isa") == 0) || (strcmp(dev_type, "eisa") == 0)) {
20945e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
21045e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
21145e46d06Srui zang - Sun Microsystems - Beijing China 	}
21245e46d06Srui zang - Sun Microsystems - Beijing China 
21345e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(dev_type, "pci") == 0) ||
21445e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(dev_type, "pciex") == 0)) {
21545e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_acc_handle_t pci_conf;
21645e46d06Srui zang - Sun Microsystems - Beijing China 		uint16_t data16;
217*c401c7a8Srui zang - Sun Microsystems - Beijing China 		char *nodename;
21845e46d06Srui zang - Sun Microsystems - Beijing China 
21945e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
22045e46d06Srui zang - Sun Microsystems - Beijing China 
221*c401c7a8Srui zang - Sun Microsystems - Beijing China 		nodename = ddi_node_name(dip);
22245e46d06Srui zang - Sun Microsystems - Beijing China 
223*c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (strcmp(nodename, "pci") == 0) {
224*c401c7a8Srui zang - Sun Microsystems - Beijing China 			/* pci root dip */
22545e46d06Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_CONTINUE);
22645e46d06Srui zang - Sun Microsystems - Beijing China 		}
22745e46d06Srui zang - Sun Microsystems - Beijing China 
228*c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
229*c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
230*c401c7a8Srui zang - Sun Microsystems - Beijing China 
231*c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (pci_config_setup(dip, &pci_conf) != DDI_SUCCESS)
232*c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
233*c401c7a8Srui zang - Sun Microsystems - Beijing China 
23445e46d06Srui zang - Sun Microsystems - Beijing China 		data16 = pci_config_get16(pci_conf, PCI_BCNF_BCNTRL);
23545e46d06Srui zang - Sun Microsystems - Beijing China 		pci_config_teardown(&pci_conf);
23645e46d06Srui zang - Sun Microsystems - Beijing China 
23745e46d06Srui zang - Sun Microsystems - Beijing China 		if (data16 & PCI_BCNF_BCNTRL_VGA_ENABLE)
23845e46d06Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_CONTINUE);
23945e46d06Srui zang - Sun Microsystems - Beijing China 
24045e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
24145e46d06Srui zang - Sun Microsystems - Beijing China 	}
24245e46d06Srui zang - Sun Microsystems - Beijing China 
24345e46d06Srui zang - Sun Microsystems - Beijing China 	if (strcmp(dev_type, "display") != 0) {
24445e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
24545e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
24645e46d06Srui zang - Sun Microsystems - Beijing China 	}
24745e46d06Srui zang - Sun Microsystems - Beijing China 
24845e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_prop_free(dev_type);
24945e46d06Srui zang - Sun Microsystems - Beijing China 
25045e46d06Srui zang - Sun Microsystems - Beijing China 	if ((pdip = ddi_get_parent(dip)) == NULL)
251*c401c7a8Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
25245e46d06Srui zang - Sun Microsystems - Beijing China 
25345e46d06Srui zang - Sun Microsystems - Beijing China 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, pdip, DDI_PROP_DONTPASS,
25445e46d06Srui zang - Sun Microsystems - Beijing China 	    "device_type", &parent_type) != DDI_SUCCESS)
255*c401c7a8Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
25645e46d06Srui zang - Sun Microsystems - Beijing China 
25745e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(parent_type, "isa") == 0) ||
25845e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(parent_type, "eisa") == 0)) {
25945e46d06Srui zang - Sun Microsystems - Beijing China 		*(dev_info_t **)found_dip = dip;
26045e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(parent_type);
26145e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_TERMINATE);
26245e46d06Srui zang - Sun Microsystems - Beijing China 	}
26345e46d06Srui zang - Sun Microsystems - Beijing China 
26445e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(parent_type, "pci") == 0) ||
26545e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(parent_type, "pciex") == 0)) {
26645e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_acc_handle_t pci_conf;
26745e46d06Srui zang - Sun Microsystems - Beijing China 		uint16_t data16;
26845e46d06Srui zang - Sun Microsystems - Beijing China 
26945e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(parent_type);
27045e46d06Srui zang - Sun Microsystems - Beijing China 
27145e46d06Srui zang - Sun Microsystems - Beijing China 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
272*c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
27345e46d06Srui zang - Sun Microsystems - Beijing China 
27445e46d06Srui zang - Sun Microsystems - Beijing China 		if (pci_config_setup(dip, &pci_conf) != DDI_SUCCESS)
275*c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
27645e46d06Srui zang - Sun Microsystems - Beijing China 
27745e46d06Srui zang - Sun Microsystems - Beijing China 		data16 = pci_config_get16(pci_conf, PCI_CONF_COMM);
27845e46d06Srui zang - Sun Microsystems - Beijing China 		pci_config_teardown(&pci_conf);
27945e46d06Srui zang - Sun Microsystems - Beijing China 
28045e46d06Srui zang - Sun Microsystems - Beijing China 		if (!(data16 & PCI_COMM_IO))
281*c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
28245e46d06Srui zang - Sun Microsystems - Beijing China 
28345e46d06Srui zang - Sun Microsystems - Beijing China 		*(dev_info_t **)found_dip = dip;
28445e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_TERMINATE);
28545e46d06Srui zang - Sun Microsystems - Beijing China 	}
28645e46d06Srui zang - Sun Microsystems - Beijing China 
28745e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_prop_free(parent_type);
288*c401c7a8Srui zang - Sun Microsystems - Beijing China 	return (DDI_WALK_PRUNECHILD);
28945e46d06Srui zang - Sun Microsystems - Beijing China }
29045e46d06Srui zang - Sun Microsystems - Beijing China 
291ae115bc7Smrj /*
29245e46d06Srui zang - Sun Microsystems - Beijing China  * Conduct a width-first traverse searching for a display device which
29345e46d06Srui zang - Sun Microsystems - Beijing China  * has either:
29445e46d06Srui zang - Sun Microsystems - Beijing China  * 1) a VGA device.
29545e46d06Srui zang - Sun Microsystems - Beijing China  * 2) a PCI VGA compatible device whose IO space is enabled
29645e46d06Srui zang - Sun Microsystems - Beijing China  *    and the VGA Enable bit of any PCI-PCI bridge above it is set.
29745e46d06Srui zang - Sun Microsystems - Beijing China  *
29845e46d06Srui zang - Sun Microsystems - Beijing China  * Return the device path as the console fb path.
299ae115bc7Smrj  */
300ae115bc7Smrj char *
301ae115bc7Smrj plat_fbpath(void)
302ae115bc7Smrj {
30345e46d06Srui zang - Sun Microsystems - Beijing China 	dev_info_t *fb_dip = NULL;
304ae115bc7Smrj 	static char *fbpath = NULL;
305ae115bc7Smrj 	static char fbpath_buf[MAXPATHLEN];
306ae115bc7Smrj 
30745e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_walk_devs(ddi_root_node(), find_fb_dev, &fb_dip);
308843e1988Sjohnlev 
30945e46d06Srui zang - Sun Microsystems - Beijing China 	if (fb_dip == NULL)
31045e46d06Srui zang - Sun Microsystems - Beijing China 		return (NULL);
311843e1988Sjohnlev 
31245e46d06Srui zang - Sun Microsystems - Beijing China 	(void) ddi_pathname(fb_dip, fbpath_buf);
313ae115bc7Smrj 	fbpath = fbpath_buf;
314ae115bc7Smrj 
315843e1988Sjohnlev 	return (fbpath);
316ae115bc7Smrj }
317ae115bc7Smrj 
318ae115bc7Smrj char *
319ae115bc7Smrj plat_mousepath(void)
320ae115bc7Smrj {
32178323854SJudy Chen 	static char mpath[MAXPATHLEN];
32278323854SJudy Chen 
323ae115bc7Smrj 	/*
324ae115bc7Smrj 	 * Hardcode to isa mouse path
325ae115bc7Smrj 	 * XXX make it settable via bootprop?
326ae115bc7Smrj 	 */
32778323854SJudy Chen 	if (pseudo_isa)
328ae115bc7Smrj 		return ("/isa/i8042@1,60/mouse@1");
32978323854SJudy Chen 
33078323854SJudy Chen 	if (plat_devpath("mouse8042", mpath) == NULL)
33178323854SJudy Chen 		return (NULL);
33278323854SJudy Chen 
33378323854SJudy Chen 	return (mpath);
334ae115bc7Smrj }
335ae115bc7Smrj 
336ae115bc7Smrj /* return path of first usb serial device */
337ae115bc7Smrj static char *
338ae115bc7Smrj plat_usbser_path(void)
339ae115bc7Smrj {
340ae115bc7Smrj 	extern dev_info_t *usbser_first_device(void);
341ae115bc7Smrj 
342ae115bc7Smrj 	dev_info_t *us_dip;
343ae115bc7Smrj 	static char *us_path = NULL;
344ae115bc7Smrj 
345ae115bc7Smrj 	if (us_path)
346ae115bc7Smrj 		return (us_path);
347ae115bc7Smrj 
348ae115bc7Smrj 	us_dip = usbser_first_device();
349ae115bc7Smrj 	if (us_dip == NULL)
350ae115bc7Smrj 		return (NULL);
351ae115bc7Smrj 
352ae115bc7Smrj 	us_path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
353ae115bc7Smrj 	(void) ddi_pathname(us_dip, us_path);
354ae115bc7Smrj 	ndi_rele_devi(us_dip);	/* held from usbser_first_device */
355ae115bc7Smrj 	return (us_path);
356ae115bc7Smrj }
357ae115bc7Smrj 
35878323854SJudy Chen static char *
35978323854SJudy Chen plat_ttypath(int inum)
36078323854SJudy Chen {
36178323854SJudy Chen 	static char *defaultpath[] = {
36278323854SJudy Chen 	    "/isa/asy@1,3f8:a",
36378323854SJudy Chen 	    "/isa/asy@1,2f8:b"
36478323854SJudy Chen 	};
36578323854SJudy Chen 	static char path[MAXPATHLEN];
36678323854SJudy Chen 	char *bp;
36778323854SJudy Chen 	major_t major;
36878323854SJudy Chen 	dev_info_t *dip;
36978323854SJudy Chen 
37078323854SJudy Chen 	if (pseudo_isa)
37178323854SJudy Chen 		return (defaultpath[inum]);
37278323854SJudy Chen 
37378323854SJudy Chen 	if ((major = ddi_name_to_major("asy")) == (major_t)-1)
37478323854SJudy Chen 		return (NULL);
37578323854SJudy Chen 
37678323854SJudy Chen 	if ((dip = devnamesp[major].dn_head) == NULL)
37778323854SJudy Chen 		return (NULL);
37878323854SJudy Chen 
37901457ffdSJudy Chen 	for (; dip != NULL; dip = ddi_get_next(dip)) {
38078323854SJudy Chen 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
38178323854SJudy Chen 			return (NULL);
38278323854SJudy Chen 
38301457ffdSJudy Chen 		if (DEVI(dip)->devi_minor->ddm_name[0] == ('a' + (char)inum))
38401457ffdSJudy Chen 			break;
38501457ffdSJudy Chen 	}
38601457ffdSJudy Chen 	if (dip == NULL)
38701457ffdSJudy Chen 		return (NULL);
38801457ffdSJudy Chen 
38978323854SJudy Chen 	(void) ddi_pathname(dip, path);
39078323854SJudy Chen 	bp = path + strlen(path);
39178323854SJudy Chen 	(void) snprintf(bp, 3, ":%s", DEVI(dip)->devi_minor->ddm_name);
39278323854SJudy Chen 
39378323854SJudy Chen 	return (path);
39478323854SJudy Chen }
39578323854SJudy Chen 
396ae115bc7Smrj /*
397ae115bc7Smrj  * Lacking support for com2 and com3, if that matters.
398ae115bc7Smrj  * Another possible enhancement could be to use properties
399ae115bc7Smrj  * for the port mapping rather than simply hard-code them.
400ae115bc7Smrj  */
401ae115bc7Smrj char *
402ae115bc7Smrj plat_stdinpath(void)
403ae115bc7Smrj {
404ae115bc7Smrj 	switch (console_type()) {
405843e1988Sjohnlev #if defined(__xpv)
406843e1988Sjohnlev 	case CONS_HYPERVISOR:
407843e1988Sjohnlev 		return ("/xpvd/xencons@0");
408843e1988Sjohnlev #endif /* __xpv */
409ae115bc7Smrj 	case CONS_TTYA:
41078323854SJudy Chen 		return (plat_ttypath(0));
411ae115bc7Smrj 	case CONS_TTYB:
41278323854SJudy Chen 		return (plat_ttypath(1));
413ae115bc7Smrj 	case CONS_USBSER:
414ae115bc7Smrj 		return (plat_usbser_path());
415ae115bc7Smrj 	case CONS_SCREEN:
416ae115bc7Smrj 	default:
417ae115bc7Smrj 		break;
418ae115bc7Smrj 	};
419ae115bc7Smrj 	return (plat_kbdpath());
420ae115bc7Smrj }
421ae115bc7Smrj 
422ae115bc7Smrj char *
423ae115bc7Smrj plat_stdoutpath(void)
424ae115bc7Smrj {
425ae115bc7Smrj 	switch (console_type()) {
426843e1988Sjohnlev #if defined(__xpv)
427843e1988Sjohnlev 	case CONS_HYPERVISOR:
428843e1988Sjohnlev 		return ("/xpvd/xencons@0");
429843e1988Sjohnlev #endif /* __xpv */
430ae115bc7Smrj 	case CONS_TTYA:
43178323854SJudy Chen 		return (plat_ttypath(0));
432ae115bc7Smrj 	case CONS_TTYB:
43378323854SJudy Chen 		return (plat_ttypath(1));
434ae115bc7Smrj 	case CONS_USBSER:
435ae115bc7Smrj 		return (plat_usbser_path());
436ae115bc7Smrj 	case CONS_SCREEN:
437ae115bc7Smrj 	default:
438ae115bc7Smrj 		break;
439ae115bc7Smrj 	};
440ae115bc7Smrj 	return (plat_fbpath());
441ae115bc7Smrj }
442ae115bc7Smrj 
443ae115bc7Smrj /*
444ae115bc7Smrj  * If VIS_PIXEL mode will be implemented on x86, these following
445ae115bc7Smrj  * functions should be re-considered. Now these functions are
446ae115bc7Smrj  * unused on x86.
447ae115bc7Smrj  */
448ae115bc7Smrj void
449c9503a49Slq150181 plat_tem_get_inverses(int *inverse, int *inverse_screen)
450c9503a49Slq150181 {
451c9503a49Slq150181 	*inverse = 0;
452c9503a49Slq150181 	*inverse_screen = 0;
453c9503a49Slq150181 }
454c9503a49Slq150181 
455c9503a49Slq150181 void
456ae115bc7Smrj plat_tem_get_prom_font_size(int *charheight, int *windowtop)
457ae115bc7Smrj {
458ae115bc7Smrj 	*charheight = 0;
459ae115bc7Smrj 	*windowtop = 0;
460ae115bc7Smrj }
461ae115bc7Smrj 
462843e1988Sjohnlev /*ARGSUSED*/
463ae115bc7Smrj void
464ae115bc7Smrj plat_tem_get_prom_size(size_t *height, size_t *width)
465ae115bc7Smrj {
466843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
467ae115bc7Smrj }
468ae115bc7Smrj 
469ae115bc7Smrj void
470ae115bc7Smrj plat_tem_hide_prom_cursor(void)
471ae115bc7Smrj {
472843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
473ae115bc7Smrj }
474ae115bc7Smrj 
475843e1988Sjohnlev /*ARGSUSED*/
476ae115bc7Smrj void
477ae115bc7Smrj plat_tem_get_prom_pos(uint32_t *row, uint32_t *col)
478ae115bc7Smrj {
479843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
480ae115bc7Smrj }
481